Changeset 35853 in webkit for trunk/JavaScriptCore/API
- Timestamp:
- Aug 20, 2008, 12:23:06 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/API
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r35775 r35853 35 35 #include <kjs/interpreter.h> 36 36 #include <kjs/JSGlobalObject.h> 37 #include <kjs/JSLock.h> 37 38 #include <kjs/JSObject.h> 38 39 … … 43 44 ExecState* exec = toJS(ctx); 44 45 exec->globalData().heap->registerThread(); 46 JSLock lock(exec); 45 47 46 48 JSObject* jsThisObject = toJS(thisObject); … … 67 69 ExecState* exec = toJS(ctx); 68 70 exec->globalData().heap->registerThread(); 71 JSLock lock(exec); 69 72 70 73 Completion completion = Interpreter::checkSyntax(exec->dynamicGlobalObject()->globalExec(), sourceURL->ustring(), startingLineNumber, script->ustring()); … … 92 95 Heap* heap = globalData.heap; 93 96 97 JSLock lock(globalData.isSharedInstance); 98 94 99 if (!heap->isBusy()) 95 100 heap->collect(); -
trunk/JavaScriptCore/API/JSCallbackConstructor.cpp
r35478 r35853 30 30 #include "APICast.h" 31 31 #include <kjs/JSGlobalObject.h> 32 #include <kjs/JSLock.h> 32 33 #include <kjs/ObjectPrototype.h> 33 34 #include <wtf/Vector.h> … … 69 70 arguments[i] = toRef(args.at(exec, i)); 70 71 72 JSLock::DropAllLocks dropAllLocks(exec); 71 73 return toJS(callback(ctx, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); 72 74 } -
trunk/JavaScriptCore/API/JSCallbackFunction.cpp
r35807 r35853 33 33 #include "FunctionPrototype.h" 34 34 #include <kjs/JSGlobalObject.h> 35 #include <kjs/JSLock.h> 35 36 #include <wtf/Vector.h> 36 37 … … 65 66 arguments[i] = toRef(args.at(exec, i)); 66 67 68 JSLock::DropAllLocks dropAllLocks(exec); 67 69 return toJS(static_cast<JSCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); 68 70 } -
trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h
r35807 r35853 31 31 #include "JSClassRef.h" 32 32 #include "JSGlobalObject.h" 33 #include "JSLock.h" 33 34 #include "JSObjectRef.h" 34 35 #include "JSString.h" … … 72 73 // initialize from base to derived 73 74 for (int i = static_cast<int>(initRoutines.size()) - 1; i >= 0; i--) { 75 JSLock::DropAllLocks dropAllLocks(exec); 74 76 JSObjectInitializeCallback initialize = initRoutines[i]; 75 77 initialize(toRef(exec), toRef(this)); … … 109 111 if (!propertyNameRef) 110 112 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 113 JSLock::DropAllLocks dropAllLocks(exec); 111 114 if (hasProperty(ctx, thisRef, propertyNameRef.get())) { 112 115 slot.setCustom(this, callbackGetter); … … 116 119 if (!propertyNameRef) 117 120 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 121 JSLock::DropAllLocks dropAllLocks(exec); 118 122 if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) { 119 123 // cache the value so we don't have to compute it again … … 161 165 if (!propertyNameRef) 162 166 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 167 JSLock::DropAllLocks dropAllLocks(exec); 163 168 if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) 164 169 return; … … 172 177 if (!propertyNameRef) 173 178 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 179 JSLock::DropAllLocks dropAllLocks(exec); 174 180 if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) 175 181 return; … … 209 215 if (!propertyNameRef) 210 216 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 217 JSLock::DropAllLocks dropAllLocks(exec); 211 218 if (deleteProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) 212 219 return true; … … 263 270 for (int i = 0; i < argumentCount; i++) 264 271 arguments[i] = toRef(args.at(exec, i)); 272 JSLock::DropAllLocks dropAllLocks(exec); 265 273 return toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); 266 274 } … … 288 296 289 297 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 290 if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) 298 if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) { 299 JSLock::DropAllLocks dropAllLocks(exec); 291 300 return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot())); 301 } 292 302 } 293 303 ASSERT_NOT_REACHED(); // implementsHasInstance should prevent us from reaching here … … 320 330 for (int i = 0; i < argumentCount; i++) 321 331 arguments[i] = toRef(args.at(exec, i)); 332 JSLock::DropAllLocks dropAllLocks(exec); 322 333 return toJS(callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); 323 334 } … … 335 346 336 347 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 337 if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) 348 if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) { 349 JSLock::DropAllLocks dropAllLocks(exec); 338 350 getPropertyNames(execRef, thisRef, toRef(&propertyNames)); 351 } 339 352 340 353 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { … … 377 390 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 378 391 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { 392 JSLock::DropAllLocks dropAllLocks(exec); 379 393 if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) 380 394 return toJS(value)->getNumber(); … … 392 406 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 393 407 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { 394 JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot())); 408 JSValueRef value; 409 { 410 JSLock::DropAllLocks dropAllLocks(exec); 411 value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot())); 412 } 395 413 if (value) 396 414 return toJS(value)->getString(); … … 445 463 if (!propertyNameRef) 446 464 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 465 JSLock::DropAllLocks dropAllLocks(exec); 447 466 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) 448 467 return toJS(value); … … 491 510 if (!propertyNameRef) 492 511 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 512 JSLock::DropAllLocks dropAllLocks(exec); 493 513 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) 494 514 return toJS(value); -
trunk/JavaScriptCore/API/JSContextRef.cpp
r35815 r35853 56 56 JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) 57 57 { 58 return JSGlobalContextCreateInGroup(toRef(JSGlobalData::create().get()), globalObjectClass); 58 JSLock lock(true); 59 return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass); 59 60 } 60 61 … … 63 64 initializeThreading(); 64 65 65 JSGlobalData* globalData = toJS(group); 66 JSLock lock(true); 67 68 RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::create(); 66 69 67 70 if (!globalObjectClass) { 68 JSGlobalObject* globalObject = new (globalData ) JSGlobalObject;71 JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject; 69 72 return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); 70 73 } 71 74 72 JSGlobalObject* globalObject = new (globalData ) JSCallbackObject<JSGlobalObject>(globalObjectClass);75 JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass); 73 76 ExecState* exec = globalObject->globalExec(); 74 77 JSValue* prototype = globalObjectClass->prototype(exec); … … 82 85 { 83 86 ExecState* exec = toJS(ctx); 87 JSLock lock(exec); 88 84 89 JSGlobalData& globalData = exec->globalData(); 85 90 … … 94 99 { 95 100 ExecState* exec = toJS(ctx); 101 JSLock lock(exec); 96 102 97 103 gcUnprotect(exec->dynamicGlobalObject()); … … 116 122 ExecState* exec = toJS(ctx); 117 123 exec->globalData().heap->registerThread(); 124 JSLock lock(exec); 118 125 119 126 // It is necessary to call toThisObject to get the wrapper object when used with WebCore. -
trunk/JavaScriptCore/API/JSContextRef.h
r35442 r35853 71 71 @discussion JSGlobalContextCreate allocates a global object and populates it with all the 72 72 built-in JavaScript objects, such as Object, Function, String, and Array. 73 The global context is created in a unique context group. 73 74 The created context can only be used on the main thread. JavaScript values cannot be 75 shared or exchanged between contexts. 74 76 @param globalObjectClass The class to use when creating the global object. Pass 75 77 NULL to use the default object class. 76 78 @result A JSGlobalContext with a global object of class globalObjectClass. 77 79 */ 78 JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) ;80 JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1; 79 81 80 82 /*! … … 86 88 NULL to use the default object class. 87 89 @param group The context group to use. The created global context retains the group. 90 Pass NULL to create a unique group for the context. 88 91 @result A JSGlobalContext with a global object of class globalObjectClass and a context 89 92 group equal to group. -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r35775 r35853 71 71 ExecState* exec = toJS(ctx); 72 72 exec->globalData().heap->registerThread(); 73 JSLock lock(exec); 73 74 74 75 if (!jsClass) … … 86 87 ExecState* exec = toJS(ctx); 87 88 exec->globalData().heap->registerThread(); 89 JSLock lock(exec); 88 90 89 91 Identifier nameID = name ? name->identifier(exec) : Identifier(exec, "anonymous"); … … 96 98 ExecState* exec = toJS(ctx); 97 99 exec->globalData().heap->registerThread(); 100 JSLock lock(exec); 98 101 99 102 JSValue* jsPrototype = jsClass … … 110 113 ExecState* exec = toJS(ctx); 111 114 exec->globalData().heap->registerThread(); 115 JSLock lock(exec); 112 116 113 117 Identifier nameID = name ? name->identifier(exec) : Identifier(exec, "anonymous"); … … 146 150 ExecState* exec = toJS(ctx); 147 151 exec->globalData().heap->registerThread(); 152 JSLock lock(exec); 148 153 149 154 JSObject* jsObject = toJS(object); … … 156 161 ExecState* exec = toJS(ctx); 157 162 exec->globalData().heap->registerThread(); 163 JSLock lock(exec); 158 164 159 165 JSObject* jsObject = toJS(object); … … 172 178 ExecState* exec = toJS(ctx); 173 179 exec->globalData().heap->registerThread(); 180 JSLock lock(exec); 174 181 175 182 JSObject* jsObject = toJS(object); … … 193 200 ExecState* exec = toJS(ctx); 194 201 exec->globalData().heap->registerThread(); 202 JSLock lock(exec); 195 203 196 204 JSObject* jsObject = toJS(object); … … 210 218 ExecState* exec = toJS(ctx); 211 219 exec->globalData().heap->registerThread(); 220 JSLock lock(exec); 212 221 213 222 JSObject* jsObject = toJS(object); … … 226 235 ExecState* exec = toJS(ctx); 227 236 exec->globalData().heap->registerThread(); 237 JSLock lock(exec); 228 238 229 239 JSObject* jsObject = toJS(object); … … 275 285 ExecState* exec = toJS(ctx); 276 286 exec->globalData().heap->registerThread(); 287 JSLock lock(exec); 277 288 278 289 JSObject* jsObject = toJS(object); … … 312 323 ExecState* exec = toJS(ctx); 313 324 exec->globalData().heap->registerThread(); 325 JSLock lock(exec); 314 326 315 327 JSObject* jsObject = toJS(object); … … 350 362 ExecState* exec = toJS(ctx); 351 363 exec->globalData().heap->registerThread(); 364 JSLock lock(exec); 352 365 353 366 JSGlobalData* globalData = &exec->globalData(); … … 373 386 void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array) 374 387 { 375 if (--array->refCount == 0) 388 if (--array->refCount == 0) { 389 JSLock lock(array->globalData->isSharedInstance); 376 390 delete array; 391 } 377 392 } 378 393 … … 392 407 393 408 propertyNames->globalData()->heap->registerThread(); 409 JSLock lock(propertyNames->globalData()->isSharedInstance); 394 410 395 411 propertyNames->add(propertyName->identifier(propertyNames->globalData())); -
trunk/JavaScriptCore/API/JSValueRef.cpp
r35830 r35853 115 115 ExecState* exec = toJS(ctx); 116 116 exec->globalData().heap->registerThread(); 117 JSLock lock(exec); 117 118 118 119 JSValue* jsA = toJS(a); … … 141 142 ExecState* exec = toJS(ctx); 142 143 exec->globalData().heap->registerThread(); 144 JSLock lock(exec); 143 145 144 146 JSValue* jsValue = toJS(value); … … 174 176 ExecState* exec = toJS(ctx); 175 177 exec->globalData().heap->registerThread(); 178 JSLock lock(exec); 176 179 177 180 return toRef(jsNumber(exec, value)); … … 182 185 ExecState* exec = toJS(ctx); 183 186 exec->globalData().heap->registerThread(); 187 JSLock lock(exec); 184 188 185 189 return toRef(jsString(exec, string->ustring())); … … 197 201 ExecState* exec = toJS(ctx); 198 202 exec->globalData().heap->registerThread(); 203 JSLock lock(exec); 199 204 200 205 JSValue* jsValue = toJS(value); … … 214 219 ExecState* exec = toJS(ctx); 215 220 exec->globalData().heap->registerThread(); 221 JSLock lock(exec); 216 222 217 223 JSValue* jsValue = toJS(value); … … 231 237 ExecState* exec = toJS(ctx); 232 238 exec->globalData().heap->registerThread(); 239 JSLock lock(exec); 233 240 234 241 JSValue* jsValue = toJS(value); … … 248 255 ExecState* exec = toJS(ctx); 249 256 exec->globalData().heap->registerThread(); 257 JSLock lock(exec); 250 258 251 259 JSValue* jsValue = toJS(value); … … 257 265 ExecState* exec = toJS(ctx); 258 266 exec->globalData().heap->registerThread(); 267 JSLock lock(exec); 259 268 260 269 JSValue* jsValue = toJS(value); -
trunk/JavaScriptCore/API/tests/minidom.c
r35342 r35853 45 45 } 46 46 47 JSGlobalContextRef context = JSGlobalContextCreate (NULL);47 JSGlobalContextRef context = JSGlobalContextCreateInGroup(NULL, NULL); 48 48 JSObjectRef globalObject = JSContextGetGlobalObject(context); 49 49 … … 77 77 globalObject = 0; 78 78 JSGlobalContextRelease(context); 79 JSGarbageCollect(context);80 79 printf("PASS: Program exited normally.\n"); 81 80 return 0; -
trunk/JavaScriptCore/API/tests/testapi.c
r35815 r35853 567 567 568 568 // Test garbage collection with a fresh context 569 context = JSGlobalContextCreate (NULL);569 context = JSGlobalContextCreateInGroup(NULL, NULL); 570 570 TestInitializeFinalize = true; 571 571 testInitializeFinalize(); … … 581 581 globalObjectClassDefinition.attributes = kJSClassAttributeNoAutomaticPrototype; 582 582 JSClassRef globalObjectClass = JSClassCreate(&globalObjectClassDefinition); 583 context = JSGlobalContextCreate (globalObjectClass);583 context = JSGlobalContextCreateInGroup(NULL, globalObjectClass); 584 584 585 585 JSGlobalContextRetain(context);
Note:
See TracChangeset
for help on using the changeset viewer.