Changeset 35442 in webkit for trunk/JavaScriptCore/API/JSBase.cpp
- Timestamp:
- Jul 29, 2008, 11:05:11 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r35159 r35442 86 86 void JSGarbageCollect(JSContextRef ctx) 87 87 { 88 // Unlikely, but it is legal to call JSGarbageCollect(0) before actually doing anything that would implicitly call initializeThreading(). 88 // We used to recommend passing NULL as an argument here, which caused the only heap to be collected. 89 // As there is no longer a shared heap, the previously recommended usage became a no-op (but the GC 90 // will happen when the context group is destroyed). 91 // Because the function argument was originally ignored, some clients may pass their released context here, 92 // in which case there is a risk of crashing if another thread performs GC on the same heap in between. 89 93 if (!ctx) 90 initializeThreading();94 return; 91 95 92 // When using a shared heap, clients need to call JSGarbageCollect(0) after releasing the last reference to the context to avoid 93 // leaking protected objects. Because the function arguments were originally ignored, some clients may pass their released context here, 94 // in which case there is a risk of crashing if another thread performs GC on the same heap in between. 95 if (ctx) { 96 ExecState* exec = toJS(ctx); 97 JSGlobalData& globalData = exec->globalData(); 98 Heap* heap = globalData.heap; 96 ExecState* exec = toJS(ctx); 97 JSGlobalData& globalData = exec->globalData(); 98 Heap* heap = globalData.heap; 99 99 100 100 JSLock lock(globalData.isSharedInstance); 101 101 102 if (!heap->isBusy()) 103 heap->collect(); 104 } else { 105 JSLock lock(true); 106 107 if (JSGlobalData::sharedInstanceExists()) { 108 Heap* heap = JSGlobalData::sharedInstance().heap; 109 if (!heap->isBusy()) 110 heap->collect(); 111 } 112 } 102 if (!heap->isBusy()) 103 heap->collect(); 113 104 114 105 // FIXME: Perhaps we should trigger a second mark and sweep
Note:
See TracChangeset
for help on using the changeset viewer.