Changeset 115579 in webkit for trunk/Source/JavaScriptCore/API/JSContextRef.cpp
- Timestamp:
- Apr 28, 2012, 1:51:27 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSContextRef.cpp
r115156 r115579 39 39 #include <wtf/text/StringHash.h> 40 40 41 42 #if OS(DARWIN)43 #include <mach-o/dyld.h>44 45 static const int32_t webkitFirstVersionWithConcurrentGlobalContexts = 0x2100500; // 528.5.046 #endif47 48 41 using namespace JSC; 42 43 // From the API's perspective, a context group remains alive iff 44 // (a) it has been JSContextGroupRetained 45 // OR 46 // (b) one of its contexts has been JSContextRetained 49 47 50 48 JSContextGroupRef JSContextGroupCreate() … … 65 63 } 66 64 65 // From the API's perspective, a global context remains alive iff it has been JSGlobalContextRetained. 66 67 67 JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) 68 68 { 69 69 initializeThreading(); 70 #if OS(DARWIN)71 // When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed72 // to use a unique JSGlobalData, we use a shared one for compatibility.73 #ifndef BUILDING_ON_LEOPARD74 if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) {75 #else76 {77 #endif78 JSLock lock(LockForReal);79 return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass);80 }81 #endif // OS(DARWIN)82 83 70 return JSGlobalContextCreateInGroup(0, globalObjectClass); 84 71 } … … 126 113 127 114 JSGlobalData& globalData = exec->globalData(); 128 JSGlobalObject* dgo = exec->dynamicGlobalObject();129 115 IdentifierTable* savedIdentifierTable = wtfThreadData().setCurrentIdentifierTable(globalData.identifierTable); 130 116 131 // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain(). 132 bool releasingContextGroup = globalData.refCount() == 2; 133 bool releasingGlobalObject = Heap::heap(dgo)->unprotect(dgo); 134 // If this is the last reference to a global data, it should also 135 // be the only remaining reference to the global object too! 136 ASSERT(!releasingContextGroup || releasingGlobalObject); 137 138 // An API 'JSGlobalContextRef' retains two things - a global object and a 139 // global data (or context group, in API terminology). 140 // * If this is the last reference to any contexts in the given context group, 141 // call destroy on the heap (the global data is being freed). 142 // * If this was the last reference to the global object, then unprotecting 143 // it may release a lot of GC memory - tickle the activity callback to 144 // garbage collect soon. 145 // * If there are more references remaining the the global object, then do nothing 146 // (specifically that is more protects, which we assume come from other JSGlobalContextRefs). 147 if (releasingContextGroup) { 148 globalData.clearBuiltinStructures(); 149 globalData.heap.destroy(); 150 } else if (releasingGlobalObject) { 117 bool protectCountIsZero = Heap::heap(exec->dynamicGlobalObject())->unprotect(exec->dynamicGlobalObject()); 118 if (protectCountIsZero) { 151 119 globalData.heap.activityCallback()->synchronize(); 152 120 globalData.heap.reportAbandonedObjectGraph(); 153 121 } 154 155 122 globalData.deref(); 156 123
Note:
See TracChangeset
for help on using the changeset viewer.