#include <wtf/FixedArray.h>
#include <wtf/OwnPtr.h>
+#define JSC_COMMON_STRINGS_EACH_NAME(macro) \
+ macro(boolean) \
+ macro(false) \
+ macro(function) \
+ macro(number) \
+ macro(null) \
+ macro(object) \
+ macro(undefined) \
+ macro(string) \
+ macro(true)
+
namespace JSC {
class HeapRootVisitor;
class JSGlobalData;
class JSString;
- class MarkStack;
class SmallStringsStorage;
- typedef MarkStack SlotVisitor;
+ class SlotVisitor;
static const unsigned maxSingleCharacterString = 0xFF;
return m_singleCharacterStrings[character];
}
- StringImpl* singleCharacterStringRep(unsigned char character);
-
- void visitChildren(HeapRootVisitor&);
- void clear();
+ JS_EXPORT_PRIVATE StringImpl* singleCharacterStringRep(unsigned char character);
- unsigned count() const;
+ void finalizeSmallStrings();
JSString** singleCharacterStrings() { return &m_singleCharacterStrings[0]; }
+#define JSC_COMMON_STRINGS_ACCESSOR_DEFINITION(name) \
+ JSString* name##String(JSGlobalData* globalData) const \
+ { \
+ if (!m_##name) \
+ initialize(globalData, m_##name, #name); \
+ return m_##name; \
+ }
+ JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ACCESSOR_DEFINITION)
+#undef JSC_COMMON_STRINGS_ACCESSOR_DEFINITION
+
private:
static const unsigned singleCharacterStringCount = maxSingleCharacterString + 1;
- void createEmptyString(JSGlobalData*);
- void createSingleCharacterString(JSGlobalData*, unsigned char);
+ JS_EXPORT_PRIVATE void createEmptyString(JSGlobalData*);
+ JS_EXPORT_PRIVATE void createSingleCharacterString(JSGlobalData*, unsigned char);
+
+ void initialize(JSGlobalData* globalData, JSString*& string, const char* value) const;
JSString* m_emptyString;
+#define JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION(name) mutable JSString* m_##name;
+ JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION)
+#undef JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION
JSString* m_singleCharacterStrings[singleCharacterStringCount];
OwnPtr<SmallStringsStorage> m_storage;
};