Changeset 35159 in webkit for trunk/JavaScriptCore/API
- Timestamp:
- Jul 14, 2008, 4:28:57 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/API
- Files:
-
- 6 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 -
trunk/JavaScriptCore/API/JSContextRef.cpp
r34947 r35159 44 44 JSLock lock(true); 45 45 46 JSGlobalData* sharedGlobalData = &JSGlobalData::sharedInstance(); 47 46 48 if (!globalObjectClass) { 47 JSGlobalObject* globalObject = new ( JSGlobalObject::Shared) JSGlobalObject;49 JSGlobalObject* globalObject = new (sharedGlobalData) JSGlobalObject; 48 50 return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); 49 51 } 50 52 51 JSGlobalObject* globalObject = new ( JSGlobalObject::Shared) JSCallbackObject<JSGlobalObject>(globalObjectClass);53 JSGlobalObject* globalObject = new (sharedGlobalData) JSCallbackObject<JSGlobalObject>(globalObjectClass); 52 54 JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec()); 53 55 JSValue* prototype = globalObjectClass->prototype(ctx); … … 61 63 { 62 64 ExecState* exec = toJS(ctx); 65 exec->globalData().heap->registerThread(); 63 66 JSLock lock(exec); 67 64 68 gcProtect(exec->dynamicGlobalObject()); 65 69 return ctx; … … 70 74 ExecState* exec = toJS(ctx); 71 75 JSLock lock(exec); 76 72 77 gcUnprotect(exec->dynamicGlobalObject()); 73 78 } … … 76 81 { 77 82 ExecState* exec = toJS(ctx); 83 exec->globalData().heap->registerThread(); 78 84 79 85 // It is necessary to call toThisObject to get the wrapper object when used with WebCore. -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r34947 r35159 69 69 { 70 70 ExecState* exec = toJS(ctx); 71 exec->globalData().heap->registerThread(); 71 72 JSLock lock(exec); 72 73 … … 84 85 { 85 86 ExecState* exec = toJS(ctx); 86 JSLock lock(exec); 87 exec->globalData().heap->registerThread(); 88 JSLock lock(exec); 89 87 90 Identifier nameID = name ? Identifier(exec, toJS(name)) : Identifier(exec, "anonymous"); 88 91 … … 93 96 { 94 97 ExecState* exec = toJS(ctx); 95 JSLock lock(exec); 96 98 exec->globalData().heap->registerThread(); 99 JSLock lock(exec); 100 97 101 JSValue* jsPrototype = jsClass 98 102 ? jsClass->prototype(ctx) … … 107 111 { 108 112 ExecState* exec = toJS(ctx); 113 exec->globalData().heap->registerThread(); 109 114 JSLock lock(exec); 110 115 … … 146 151 { 147 152 ExecState* exec = toJS(ctx); 148 JSLock lock(exec); 153 exec->globalData().heap->registerThread(); 154 JSLock lock(exec); 155 149 156 JSObject* jsObject = toJS(object); 150 157 UString::Rep* nameRep = toJS(propertyName); … … 156 163 { 157 164 ExecState* exec = toJS(ctx); 158 JSLock lock(exec); 165 exec->globalData().heap->registerThread(); 166 JSLock lock(exec); 167 159 168 JSObject* jsObject = toJS(object); 160 169 UString::Rep* nameRep = toJS(propertyName); … … 172 181 { 173 182 ExecState* exec = toJS(ctx); 174 JSLock lock(exec); 183 exec->globalData().heap->registerThread(); 184 JSLock lock(exec); 185 175 186 JSObject* jsObject = toJS(object); 176 187 Identifier name(exec, toJS(propertyName)); … … 192 203 { 193 204 ExecState* exec = toJS(ctx); 194 JSLock lock(exec); 205 exec->globalData().heap->registerThread(); 206 JSLock lock(exec); 207 195 208 JSObject* jsObject = toJS(object); 196 209 … … 208 221 { 209 222 ExecState* exec = toJS(ctx); 210 JSLock lock(exec); 223 exec->globalData().heap->registerThread(); 224 JSLock lock(exec); 225 211 226 JSObject* jsObject = toJS(object); 212 227 JSValue* jsValue = toJS(value); … … 223 238 { 224 239 ExecState* exec = toJS(ctx); 225 JSLock lock(exec); 240 exec->globalData().heap->registerThread(); 241 JSLock lock(exec); 242 226 243 JSObject* jsObject = toJS(object); 227 244 UString::Rep* nameRep = toJS(propertyName); … … 272 289 { 273 290 ExecState* exec = toJS(ctx); 274 JSLock lock(exec); 291 exec->globalData().heap->registerThread(); 292 JSLock lock(exec); 293 275 294 JSObject* jsObject = toJS(object); 276 295 JSObject* jsThisObject = toJS(thisObject); … … 308 327 { 309 328 ExecState* exec = toJS(ctx); 310 JSLock lock(exec); 329 exec->globalData().heap->registerThread(); 330 JSLock lock(exec); 331 311 332 JSObject* jsObject = toJS(object); 312 333 … … 343 364 JSObject* jsObject = toJS(object); 344 365 ExecState* exec = toJS(ctx); 345 JSLock lock(exec); 346 366 exec->globalData().heap->registerThread(); 367 JSLock lock(exec); 368 347 369 JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(&exec->globalData()); 348 370 jsObject->getPropertyNames(exec, propertyNames->array); … … 380 402 UString::Rep* rep = toJS(propertyName); 381 403 404 propertyNames->globalData()->heap->registerThread(); 382 405 JSLock lock(propertyNames->globalData()->isSharedInstance); 406 383 407 propertyNames->add(rep); 384 408 } -
trunk/JavaScriptCore/API/JSStringRef.cpp
r34947 r35159 67 67 bool needsLocking = rep->identifierTable; 68 68 if (needsLocking) { 69 // It is wasteful to take the lock for per-thread contexts, but we don't have a good way69 // It is wasteful to take the lock for non-shared contexts, but we don't have a good way 70 70 // to determine what the context is. 71 71 JSLock lock(true); -
trunk/JavaScriptCore/API/JSStringRefCF.cpp
r34947 r35159 30 30 #include "APICast.h" 31 31 #include "JSStringRef.h" 32 #include <kjs/JSLock.h>33 32 #include <kjs/ustring.h> 34 33 #include <kjs/JSValue.h> -
trunk/JavaScriptCore/API/JSValueRef.cpp
r34947 r35159 120 120 { 121 121 ExecState* exec = toJS(ctx); 122 exec->globalData().heap->registerThread(); 122 123 JSLock lock(exec); 123 124 … … 146 147 { 147 148 ExecState* exec = toJS(ctx); 149 exec->globalData().heap->registerThread(); 148 150 JSLock lock(exec); 149 151 … … 179 181 { 180 182 ExecState* exec = toJS(ctx); 183 exec->globalData().heap->registerThread(); 181 184 JSLock lock(exec); 182 185 … … 187 190 { 188 191 ExecState* exec = toJS(ctx); 192 exec->globalData().heap->registerThread(); 189 193 JSLock lock(exec); 190 194 … … 203 207 { 204 208 ExecState* exec = toJS(ctx); 209 exec->globalData().heap->registerThread(); 205 210 JSLock lock(exec); 206 211 … … 220 225 { 221 226 ExecState* exec = toJS(ctx); 227 exec->globalData().heap->registerThread(); 222 228 JSLock lock(exec); 223 229 … … 237 243 { 238 244 ExecState* exec = toJS(ctx); 245 exec->globalData().heap->registerThread(); 239 246 JSLock lock(exec); 240 247 … … 254 261 { 255 262 ExecState* exec = toJS(ctx); 263 exec->globalData().heap->registerThread(); 256 264 JSLock lock(exec); 257 265 … … 263 271 { 264 272 ExecState* exec = toJS(ctx); 273 exec->globalData().heap->registerThread(); 265 274 JSLock lock(exec); 266 275
Note:
See TracChangeset
for help on using the changeset viewer.