]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/SmallStrings.h
JavaScriptCore-1097.13.tar.gz
[apple/javascriptcore.git] / runtime / SmallStrings.h
index e762e1f365c88c38d02cce2d775bd192e6c996c1..e609c509221c6ab00d6d578a9f334d1674ed1b1e 100644 (file)
 #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;
 
@@ -61,22 +71,34 @@ namespace JSC {
             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;
     };