Ignore:
Timestamp:
Mar 22, 2013, 4:49:52 PM (12 years ago)
Author:
[email protected]
Message:

opaqueJSClassData should be cached on JSGlobalObject, not the JSGlobalData
https://bugs.webkit.org/show_bug.cgi?id=113086

Reviewed by Geoffrey Garen.

opaqueJSClassData stores cached prototypes for JSClassRefs in the C API. It doesn't make sense to
share these prototypes within a JSGlobalData across JSGlobalObjects, and in fact doing so will cause
a leak of the original JSGlobalObject that these prototypes were created in. Therefore we should move
this cache to JSGlobalObject where it belongs and where it won't cause memory leaks.

  • API/JSBase.cpp: Needed to add an extern "C" so that testapi.c can use the super secret GC function.
  • API/JSClassRef.cpp: We now grab the cached context data from the global object rather than the global data.

(OpaqueJSClass::contextData):

  • API/JSClassRef.h: Remove this header because it's unnecessary and causes circular dependencies.
  • API/tests/testapi.c: Added a new test that makes sure that using the same JSClassRef in two different contexts

doesn't cause leaks of the original global object.
(leakFinalize):
(nestedAllocateObject): This is a hack to bypass the conservative scan of the GC, which was unnecessarily marking
objects and keeping them alive, ruining the test result.
(testLeakingPrototypesAcrossContexts):
(main):

  • API/tests/testapi.mm: extern "C" this so we can continue using it here.
  • runtime/JSGlobalData.cpp: Remove JSClassRef related stuff.

(JSC::JSGlobalData::~JSGlobalData):

  • runtime/JSGlobalData.h:

(JSGlobalData):

  • runtime/JSGlobalObject.h: Add the stuff that JSGlobalData had. We add it to JSGlobalObjectRareData so that

clients who don't use the C API don't have to pay the memory cost of this extra HashMap.
(JSGlobalObject):
(JSGlobalObjectRareData):
(JSC::JSGlobalObject::opaqueJSClassData):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r146383 r146682  
    6363#endif
    6464
    65 struct OpaqueJSClass;
    66 struct OpaqueJSClassContextData;
    67 
    6865namespace JSC {
    6966
     
    370367#endif
    371368
    372         HashMap<OpaqueJSClass*, OwnPtr<OpaqueJSClassContextData> > opaqueJSClassData;
    373 
    374369        JSGlobalObject* dynamicGlobalObject;
    375370
Note: See TracChangeset for help on using the changeset viewer.