Changeset 35159 in webkit for trunk/JavaScriptCore/API/JSBase.cpp
- Timestamp:
- Jul 14, 2008, 4:28:57 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r34977 r35159 42 42 { 43 43 ExecState* exec = toJS(ctx); 44 exec->globalData().heap->registerThread(); 44 45 JSLock lock(exec); 46 45 47 JSObject* jsThisObject = toJS(thisObject); 46 48 UString::Rep* scriptRep = toJS(script); … … 67 69 { 68 70 ExecState* exec = toJS(ctx); 71 exec->globalData().heap->registerThread(); 69 72 JSLock lock(exec); 73 70 74 UString::Rep* scriptRep = toJS(script); 71 75 UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; … … 86 90 initializeThreading(); 87 91 88 // It might seem that we have a context passed to this function, and can use toJS(ctx)->heap(), but the parameter is likely to be NULL, 89 // and it may actually be garbage for some clients (most likely, because of JSGarbageCollect being called after releasing the context). 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; 90 99 91 if (JSGlobalData::threadInstanceExists()) {92 Heap* heap = JSGlobalData::threadInstance().heap; 100 JSLock lock(globalData.isSharedInstance); 101 93 102 if (!heap->isBusy()) 94 103 heap->collect(); 95 } 104 } else { 105 JSLock lock(true); 96 106 97 JSLock lock(true); 98 99 if (JSGlobalData::sharedInstanceExists()) { 100 Heap* heap = JSGlobalData::sharedInstance().heap; 101 if (!heap->isBusy()) 102 heap->collect(); 107 if (JSGlobalData::sharedInstanceExists()) { 108 Heap* heap = JSGlobalData::sharedInstance().heap; 109 if (!heap->isBusy()) 110 heap->collect(); 111 } 103 112 } 104 113
Note:
See TracChangeset
for help on using the changeset viewer.