- /*
- Our hypothesis is that small strings are very common. So, we cache them
- to avoid GC churn. However, in cases where this hypothesis turns out to
- be false -- including the degenerate case where all JavaScript execution
- has terminated -- we don't want to waste memory.
-
- To test our hypothesis, we check if any small string has been marked. If
- so, it's probably reasonable to mark the rest. If not, we clear the cache.
- */
-
- bool isAnyStringMarked = isMarked(m_emptyString);
- for (unsigned i = 0; i < singleCharacterStringCount && !isAnyStringMarked; ++i)
- isAnyStringMarked = isMarked(m_singleCharacterStrings[i]);
-
- if (!isAnyStringMarked) {
- clear();
- return;
- }
-
- if (m_emptyString)
- heapRootMarker.mark(&m_emptyString);
- for (unsigned i = 0; i < singleCharacterStringCount; ++i) {
- if (m_singleCharacterStrings[i])
- heapRootMarker.mark(&m_singleCharacterStrings[i]);
- }
+ createEmptyString(&vm);
+ for (unsigned i = 0; i <= maxSingleCharacterString; ++i)
+ createSingleCharacterString(&vm, i);
+#define JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE(name) initialize(&vm, m_##name, #name);
+ JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE)
+#undef JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE
+ initialize(&vm, m_nullObjectString, "[object Null]");
+ initialize(&vm, m_undefinedObjectString, "[object Undefined]");