Title: [96831] trunk/Source/_javascript_Core
Revision
96831
Author
mhahnenb...@apple.com
Date
2011-10-06 10:42:50 -0700 (Thu, 06 Oct 2011)

Log Message

JSC objects need to know their own cell size at runtime.
https://bugs.webkit.org/show_bug.cgi?id=69390

Reviewed by Geoffrey Garen.

Added the cellSize field to ClassInfo and the static calculation of
size of each class to the CREATE_METHOD_TABLE macro, which will be
renamed in a followup patch to make its name match its broader use.

Also added a few ClassInfo structs so that each object that is allocated has its
correct size.

* _javascript_Core.exp:
* runtime/ClassInfo.h:

Changed JSByteArray s_defaultInfo to s_info so that the template will get the
correct ClassInfo struct from it when it's allocated.
* runtime/JSByteArray.cpp:
* runtime/JSByteArray.h:
* runtime/JSCell.h:
(JSC::allocateCell):
* runtime/JSNotAnObject.cpp:
* runtime/JSNotAnObject.h:
* runtime/JSObject.cpp:
* runtime/JSObject.h:
(JSC::JSCell::cellSize):
* runtime/JSStaticScopeObject.cpp:
* runtime/JSStaticScopeObject.h:
* runtime/StrictEvalActivation.cpp:
* runtime/StrictEvalActivation.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (96830 => 96831)


--- trunk/Source/_javascript_Core/ChangeLog	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-10-06 17:42:50 UTC (rev 96831)
@@ -1,3 +1,36 @@
+2011-10-06  Mark Hahnenberg  <mhahnenb...@apple.com>
+
+        JSC objects need to know their own cell size at runtime.
+        https://bugs.webkit.org/show_bug.cgi?id=69390
+
+        Reviewed by Geoffrey Garen.
+
+        Added the cellSize field to ClassInfo and the static calculation of 
+        size of each class to the CREATE_METHOD_TABLE macro, which will be 
+        renamed in a followup patch to make its name match its broader use.
+
+        Also added a few ClassInfo structs so that each object that is allocated has its 
+        correct size.  
+
+        * _javascript_Core.exp:
+        * runtime/ClassInfo.h:
+
+        Changed JSByteArray s_defaultInfo to s_info so that the template will get the 
+        correct ClassInfo struct from it when it's allocated.
+        * runtime/JSByteArray.cpp:
+        * runtime/JSByteArray.h:
+        * runtime/JSCell.h:
+        (JSC::allocateCell):
+        * runtime/JSNotAnObject.cpp:
+        * runtime/JSNotAnObject.h:
+        * runtime/JSObject.cpp:
+        * runtime/JSObject.h:
+        (JSC::JSCell::cellSize):
+        * runtime/JSStaticScopeObject.cpp:
+        * runtime/JSStaticScopeObject.h:
+        * runtime/StrictEvalActivation.cpp:
+        * runtime/StrictEvalActivation.h:
+
 2011-10-06  Gavin Peters  <gav...@chromium.org>
 
         export new stack dumping method

Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (96830 => 96831)


--- trunk/Source/_javascript_Core/_javascript_Core.exp	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp	2011-10-06 17:42:50 UTC (rev 96831)
@@ -115,8 +115,8 @@
 __ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEPNS_9StructureE
 __ZN3JSC10throwErrorEPNS_9ExecStateENS_7JSValueE
 __ZN3JSC10throwErrorEPNS_9ExecStateEPNS_8JSObjectE
-__ZN3JSC11JSByteArray13s_defaultInfoE
 __ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataEPNS_14JSGlobalObjectENS_7JSValueEPKNS_9ClassInfoE
+__ZN3JSC11JSByteArray6s_infoE
 __ZN3JSC11JSByteArrayC1EPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE
 __ZN3JSC11ParserArena5resetEv
 __ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeEPNS_7JSValueE
@@ -155,6 +155,7 @@
 __ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
 __ZN3JSC12StringObject6s_infoE
 __ZN3JSC12StringObjectC2ERNS_12JSGlobalDataEPNS_9StructureE
+__ZN3JSC13JSFinalObject6s_infoE
 __ZN3JSC13SamplingFlags4stopEv
 __ZN3JSC13SamplingFlags5startEv
 __ZN3JSC13SamplingFlags7s_flagsE
@@ -330,6 +331,7 @@
 __ZN3JSC8JSObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
 __ZN3JSC8JSObject3putEPNS_9ExecStateEjNS_7JSValueE
 __ZN3JSC8JSObject6s_infoE
+__ZN3JSC8JSString6s_infoE
 __ZN3JSC8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE
 __ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE
 __ZN3JSC8Profiler8profilerEv

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (96830 => 96831)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-10-06 17:42:50 UTC (rev 96831)
@@ -303,6 +303,9 @@
     ?restoreAll@Profile@JSC@@QAEXXZ
     ?retrieveCaller@Interpreter@JSC@@QBE?AVJSValue@2@PAVExecState@2@PAVJSFunction@2@@Z
     ?retrieveLastCaller@Interpreter@JSC@@QBEXPAVExecState@2@AAH1AAVUString@2@AAVJSValue@2@@Z
+    ?s_info@JSAPIValueWrapper@JSC@@2UClassInfo@2@B
+    ?s_info@JSByteArray@JSC@@2UClassInfo@2@B
+    ?s_info@JSFinalObject@JSC@@2UClassInfo@2@B
     ?setAccessorDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@0I@Z
     ?setConfigurable@PropertyDescriptor@JSC@@QAEX_N@Z
     ?setDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@I@Z

Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/ClassInfo.h	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h	2011-10-06 17:42:50 UTC (rev 96831)
@@ -41,7 +41,8 @@
 #define CREATE_METHOD_TABLE(ClassName) { \
         &ClassName::visitChildren, \
         &ClassName::getCallData \
-    }
+    }, \
+    sizeof(ClassName)
 
     struct ClassInfo {
         /**
@@ -79,6 +80,8 @@
         const ClassPropHashTableGetterFunction classPropHashTableGetterFunction;
 
         MethodTable methodTable;
+
+        size_t cellSize;
     };
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSByteArray.cpp (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSByteArray.cpp	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSByteArray.cpp	2011-10-06 17:42:50 UTC (rev 96831)
@@ -33,7 +33,7 @@
 
 namespace JSC {
 
-const ClassInfo JSByteArray::s_defaultInfo = { "ByteArray", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSByteArray) };
+const ClassInfo JSByteArray::s_info = { "ByteArray", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSByteArray) };
 
 JSByteArray::JSByteArray(ExecState* exec, Structure* structure, ByteArray* storage)
     : JSNonFinalObject(exec->globalData(), structure)

Modified: trunk/Source/_javascript_Core/runtime/JSByteArray.h (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSByteArray.h	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSByteArray.h	2011-10-06 17:42:50 UTC (rev 96831)
@@ -86,7 +86,7 @@
             return array;
         }
 
-        static Structure* createStructure(JSGlobalData&, JSGlobalObject*, JSValue prototype, const JSC::ClassInfo* = &s_defaultInfo);
+        static Structure* createStructure(JSGlobalData&, JSGlobalObject*, JSValue prototype, const JSC::ClassInfo* = &s_info);
 
         virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
         virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&);
@@ -96,7 +96,7 @@
 
         virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
 
-        static const ClassInfo s_defaultInfo;
+        static const ClassInfo s_info;
         
         size_t length() const { return m_storage->length(); }
 

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-10-06 17:42:50 UTC (rev 96831)
@@ -319,6 +319,7 @@
     template <typename T> void* allocateCell(Heap& heap)
     {
 #if ENABLE(GC_VALIDATION)
+        ASSERT(sizeof(T) == T::s_info.cellSize);
         ASSERT(!heap.globalData()->isInitializingObject());
         heap.globalData()->setInitializingObject(true);
 #endif

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-10-06 17:42:50 UTC (rev 96831)
@@ -36,6 +36,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(JSNotAnObject);
 
+const ClassInfo JSNotAnObject::s_info = { "Object", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSNotAnObject) };
+
 // JSValue methods
 JSValue JSNotAnObject::defaultValue(ExecState* exec, PreferredPrimitiveType) const
 {

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.h (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-10-06 17:42:50 UTC (rev 96831)
@@ -58,6 +58,8 @@
             return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
         }
 
+        static const ClassInfo s_info;
+
      private:
         
         static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-10-06 17:42:50 UTC (rev 96831)
@@ -49,6 +49,8 @@
 
 const ClassInfo JSObject::s_info = { "Object", 0, 0, 0, CREATE_METHOD_TABLE(JSObject) };
 
+const ClassInfo JSFinalObject::s_info = { "Object", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSFinalObject) };
+
 static inline void getClassPropertyNames(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames, EnumerationMode mode)
 {
     // Add properties from the static hashtables of properties

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2011-10-06 17:42:50 UTC (rev 96831)
@@ -365,6 +365,8 @@
             return Structure::create(globalData, globalObject, prototype, TypeInfo(FinalObjectType, StructureFlags), &s_info);
         }
 
+        static const ClassInfo s_info;
+
     protected:
         void finishCreation(JSGlobalData& globalData)
         {

Modified: trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.cpp (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.cpp	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.cpp	2011-10-06 17:42:50 UTC (rev 96831)
@@ -32,6 +32,8 @@
 namespace JSC {
 ASSERT_CLASS_FITS_IN_CELL(JSStaticScopeObject);
 
+const ClassInfo JSStaticScopeObject::s_info = { "Object", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSStaticScopeObject) };
+
 void JSStaticScopeObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
     JSStaticScopeObject* thisObject = static_cast<JSStaticScopeObject*>(cell);

Modified: trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.h (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.h	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.h	2011-10-06 17:42:50 UTC (rev 96831)
@@ -50,6 +50,8 @@
 
         static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), &s_info); }
 
+        static const ClassInfo s_info;
+
     protected:
         void finishCreation(ExecState* exec, const Identifier& identifier, JSValue value, unsigned attributes)
         {

Modified: trunk/Source/_javascript_Core/runtime/StrictEvalActivation.cpp (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/StrictEvalActivation.cpp	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/StrictEvalActivation.cpp	2011-10-06 17:42:50 UTC (rev 96831)
@@ -28,6 +28,8 @@
 
 namespace JSC {
 
+const ClassInfo StrictEvalActivation::s_info = { "Object", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(StrictEvalActivation) };
+
 StrictEvalActivation::StrictEvalActivation(ExecState* exec)
     : JSNonFinalObject(exec->globalData(), exec->globalData().strictEvalActivationStructure.get())
 {

Modified: trunk/Source/_javascript_Core/runtime/StrictEvalActivation.h (96830 => 96831)


--- trunk/Source/_javascript_Core/runtime/StrictEvalActivation.h	2011-10-06 17:41:04 UTC (rev 96830)
+++ trunk/Source/_javascript_Core/runtime/StrictEvalActivation.h	2011-10-06 17:42:50 UTC (rev 96831)
@@ -49,6 +49,8 @@
         return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
     }
     
+    static const ClassInfo s_info;
+
 protected:
     static const unsigned StructureFlags = IsEnvironmentRecord | JSNonFinalObject::StructureFlags;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to