Changeset 34947 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Jul 2, 2008, 12:00:53 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Disable JSLock for per-thread contexts.

No change on SunSpider.

  • kjs/JSGlobalData.h:
  • kjs/JSGlobalData.cpp: (KJS::JSGlobalData::JSGlobalData): (KJS::JSGlobalData::sharedInstance): Added isSharedInstance as a better way to tell whether the instance is shared (legacy).
  • kjs/JSLock.cpp: (KJS::createJSLockCount): (KJS::JSLock::lockCount): (KJS::setLockCount): (KJS::JSLock::JSLock): (KJS::JSLock::lock): (KJS::JSLock::unlock): (KJS::JSLock::currentThreadIsHoldingLock): (KJS::JSLock::DropAllLocks::DropAllLocks): (KJS::JSLock::DropAllLocks::~DropAllLocks):
  • kjs/JSLock.h: (KJS::JSLock::JSLock): (KJS::JSLock::~JSLock): Made JSLock and JSLock::DropAllLocks constructors take a parameter to decide whether to actually lock a mutex, or only to increment recursion count. We cannot turn it into no-op if we want to keep existing assertions working. Made recursion count per-thread, now that locks may not lock.
  • API/JSBase.cpp: (JSEvaluateScript): Take JSLock after casting JSContextRef to ExecState* (which doesn't need locking in any case), so that a decision whether to actually lock can be made. (JSCheckScriptSyntax): Ditto. (JSGarbageCollect): Only lock while collecting the shared heap, not the per-thread one.
  • API/JSObjectRef.cpp: (JSClassCreate): Don't lock, as there is no reason to. (JSClassRetain): Ditto. (JSClassRelease): Ditto. (JSPropertyNameArrayRetain): Ditto. (JSPropertyNameArrayRelease): Only lock while deleting the array, as that may touch identifier table. (JSPropertyNameAccumulatorAddName): Adding a string also involves an identifier table lookup, and possibly modification.
  • API/JSStringRef.cpp: (JSStringCreateWithCharacters): (JSStringCreateWithUTF8CString): (JSStringRetain): (JSStringRelease): (JSStringGetUTF8CString): (JSStringIsEqual):
  • API/JSStringRefCF.cpp: (JSStringCreateWithCFString): JSStringRef operations other than releasing do not need locking.
  • VM/Machine.cpp: Don't include unused JSLock.h.
  • kjs/CollectorHeapIntrospector.cpp: (KJS::CollectorHeapIntrospector::statistics): Don't take the lock for real, as heap introspection pauses the process anyway. It seems that the existing code could cause deadlocks.
  • kjs/Shell.cpp: (functionGC): (main): (jscmain): The test tool uses a per-thread context, so no real locking is required.
  • kjs/collector.h: (KJS::Heap::setGCProtectNeedsLocking): Optionally protect m_protectedValues access with a per-heap mutex. This is only needed for WebCore Database code, which violates the "no data migration between threads" by using ProtectedPtr on a background thread. (KJS::Heap::isShared): Keep a shared flag here, as well.
  • kjs/protect.h: (KJS::::ProtectedPtr): (KJS::::~ProtectedPtr): (KJS::::operator): (KJS::operator==): (KJS::operator!=): ProtectedPtr is ony used from WebCore, so it doesn't need to take JSLock. An assertion in Heap::protect/unprotect guards agains possible future unlocked uses of ProtectedPtr in JSC.
  • kjs/collector.cpp: (KJS::Heap::Heap): Initialize m_isShared. (KJS::Heap::~Heap): No need to lock for real during destruction, but must keep assertions in sweep() working. (KJS::destroyRegisteredThread): Registered thread list is only accessed for shared heap, so locking is always needed here. (KJS::Heap::registerThread): Ditto. (KJS::Heap::markStackObjectsConservatively): Use m_isShared instead of comparing to a shared instance for a small speedup. (KJS::Heap::setGCProtectNeedsLocking): Create m_protectedValuesMutex. There is currently no way to undo this - and ideally, Database code will be fixed to lo longer require this quirk. (KJS::Heap::protect): Take m_protectedValuesMutex (if it exists) while accessing m_protectedValues. (KJS::Heap::unprotect): Ditto. (KJS::Heap::markProtectedObjects): Ditto. (KJS::Heap::protectedGlobalObjectCount): Ditto. (KJS::Heap::protectedObjectCount): Ditto. (KJS::Heap::protectedObjectTypeCounts): Ditto.
  • kjs/ustring.cpp:
  • kjs/ustring.h: Don't include JSLock.h, which is no longer used here. As a result, an explicit include had to be added to many files in JavaScriptGlue, WebCore and WebKit.
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::init):
  • API/JSCallbackConstructor.cpp: (KJS::constructJSCallback):
  • API/JSCallbackFunction.cpp: (KJS::JSCallbackFunction::call):
  • API/JSCallbackObjectFunctions.h: (KJS::::init): (KJS::::getOwnPropertySlot): (KJS::::put): (KJS::::deleteProperty): (KJS::::construct): (KJS::::hasInstance): (KJS::::call): (KJS::::getPropertyNames): (KJS::::toNumber): (KJS::::toString): (KJS::::staticValueGetter): (KJS::::callbackGetter):
  • API/JSContextRef.cpp: (JSGlobalContextCreate): (JSGlobalContextRetain): (JSGlobalContextRelease):
  • API/JSValueRef.cpp: (JSValueIsEqual): (JSValueIsStrictEqual): (JSValueIsInstanceOfConstructor): (JSValueMakeNumber): (JSValueMakeString): (JSValueToNumber): (JSValueToStringCopy): (JSValueToObject): (JSValueProtect): (JSValueUnprotect):
  • JavaScriptCore.exp:
  • kjs/PropertyNameArray.h: (KJS::PropertyNameArray::globalData):
  • kjs/interpreter.cpp: (KJS::Interpreter::checkSyntax): (KJS::Interpreter::evaluate): Pass a parameter to JSLock/JSLock::DropAllLocks to decide whether the lock needs to be taken.
Location:
trunk/JavaScriptCore/API
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSBase.cpp

    r34659 r34947  
    4141JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    4242{
    43     JSLock lock;
    4443    ExecState* exec = toJS(ctx);
     44    JSLock lock(exec);
    4545    JSObject* jsThisObject = toJS(thisObject);
    4646    UString::Rep* scriptRep = toJS(script);
     
    6666bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    6767{
    68     JSLock lock;
    69 
    7068    ExecState* exec = toJS(ctx);
     69    JSLock lock(exec);
    7170    UString::Rep* scriptRep = toJS(script);
    7271    UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null;
     
    9089    // and it may actually be garbage for some clients (most likely, because of JSGarbageCollect being called after releasing the context).
    9190
    92     JSLock lock;
    93 
    9491    // FIXME: It would be good to avoid creating a JSGlobalData instance if it didn't exist for this thread yet.
    9592    Heap* heap = JSGlobalData::threadInstance().heap;
    9693    if (!heap->isBusy())
    9794        heap->collect();
     95
     96    JSLock lock(true);
    9897
    9998    // FIXME: Similarly, we shouldn't create a shared instance here.
  • trunk/JavaScriptCore/API/JSCallbackConstructor.cpp

    r34854 r34947  
    3030#include "APICast.h"
    3131#include <kjs/JSGlobalObject.h>
     32#include <kjs/JSLock.h>
    3233#include <kjs/ObjectPrototype.h>
    3334#include <wtf/Vector.h>
     
    6970            arguments[i] = toRef(args[i]);
    7071           
    71         JSLock::DropAllLocks dropAllLocks;
     72        JSLock::DropAllLocks dropAllLocks(exec);
    7273        return toJS(callback(ctx, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
    7374    }
  • trunk/JavaScriptCore/API/JSCallbackFunction.cpp

    r34754 r34947  
    3333#include "FunctionPrototype.h"
    3434#include <kjs/JSGlobalObject.h>
     35#include <kjs/JSLock.h>
    3536#include <wtf/Vector.h>
    3637
     
    6364        arguments[i] = toRef(args[i]);
    6465
    65     JSLock::DropAllLocks dropAllLocks;
     66    JSLock::DropAllLocks dropAllLocks(exec);
    6667    return toJS(static_cast<JSCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
    6768}
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r34754 r34947  
    3030#include "JSClassRef.h"
    3131#include "JSGlobalObject.h"
     32#include "JSLock.h"
    3233#include "JSObjectRef.h"
    3334#include "JSString.h"
     
    7273    // initialize from base to derived
    7374    for (int i = static_cast<int>(initRoutines.size()) - 1; i >= 0; i--) {
    74         JSLock::DropAllLocks dropAllLocks;
     75        JSLock::DropAllLocks dropAllLocks(exec);
    7576        JSObjectInitializeCallback initialize = initRoutines[i];
    7677        initialize(toRef(exec), toRef(this));
     
    110111        // optional optimization to bypass getProperty in cases when we only need to know if the property exists
    111112        if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
    112             JSLock::DropAllLocks dropAllLocks;
     113            JSLock::DropAllLocks dropAllLocks(exec);
    113114            if (hasProperty(ctx, thisRef, propertyNameRef)) {
    114115                slot.setCustom(this, callbackGetter);
     
    116117            }
    117118        } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    118             JSLock::DropAllLocks dropAllLocks;
     119            JSLock::DropAllLocks dropAllLocks(exec);
    119120            if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) {
    120121                // cache the value so we don't have to compute it again
     
    160161    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    161162        if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
    162             JSLock::DropAllLocks dropAllLocks;
     163            JSLock::DropAllLocks dropAllLocks(exec);
    163164            if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))
    164165                return;
     
    170171                    return;
    171172                if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
    172                     JSLock::DropAllLocks dropAllLocks;
     173                    JSLock::DropAllLocks dropAllLocks(exec);
    173174                    if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))
    174175                        return;
     
    206207    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    207208        if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
    208             JSLock::DropAllLocks dropAllLocks;
     209            JSLock::DropAllLocks dropAllLocks(exec);
    209210            if (deleteProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
    210211                return true;
     
    261262            for (int i = 0; i < argumentCount; i++)
    262263                arguments[i] = toRef(args[i]);
    263             JSLock::DropAllLocks dropAllLocks;
     264            JSLock::DropAllLocks dropAllLocks(exec);
    264265            return toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
    265266        }
     
    288289    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    289290        if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) {
    290             JSLock::DropAllLocks dropAllLocks;
     291            JSLock::DropAllLocks dropAllLocks(exec);
    291292            return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));
    292293        }
     
    321322            for (int i = 0; i < argumentCount; i++)
    322323                arguments[i] = toRef(args[i]);
    323             JSLock::DropAllLocks dropAllLocks;
     324            JSLock::DropAllLocks dropAllLocks(exec);
    324325            return toJS(callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
    325326        }
     
    338339    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    339340        if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) {
    340             JSLock::DropAllLocks dropAllLocks;
     341            JSLock::DropAllLocks dropAllLocks(exec);
    341342            getPropertyNames(execRef, thisRef, toRef(&propertyNames));
    342343        }
     
    381382    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    382383        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    383             JSLock::DropAllLocks dropAllLocks;
     384            JSLock::DropAllLocks dropAllLocks(exec);
    384385            if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))
    385386                return toJS(value)->getNumber();
     
    399400            JSValueRef value;
    400401            {
    401                 JSLock::DropAllLocks dropAllLocks;
     402                JSLock::DropAllLocks dropAllLocks(exec);
    402403                value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot()));
    403404            }
     
    452453            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
    453454                if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
    454                     JSLock::DropAllLocks dropAllLocks;
     455                    JSLock::DropAllLocks dropAllLocks(exec);
    455456                    if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
    456457                        return toJS(value);
     
    497498    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
    498499        if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    499             JSLock::DropAllLocks dropAllLocks;
     500            JSLock::DropAllLocks dropAllLocks(exec);
    500501            if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
    501502                return toJS(value);
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r34659 r34947  
    4242    initializeThreading();
    4343
    44     JSLock lock;
     44    JSLock lock(true);
    4545
    4646    if (!globalObjectClass) {
     
    6060JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
    6161{
    62     JSLock lock;
    6362    ExecState* exec = toJS(ctx);
     63    JSLock lock(exec);
    6464    gcProtect(exec->dynamicGlobalObject());
    6565    return ctx;
     
    6868void JSGlobalContextRelease(JSGlobalContextRef ctx)
    6969{
    70     JSLock lock;
    7170    ExecState* exec = toJS(ctx);
     71    JSLock lock(exec);
    7272    gcUnprotect(exec->dynamicGlobalObject());
    7373}
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r34854 r34947  
    4848JSClassRef JSClassCreate(const JSClassDefinition* definition)
    4949{
    50     JSLock lock;
    5150    RefPtr<OpaqueJSClass> jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype)
    5251        ? OpaqueJSClass::createNoAutomaticPrototype(definition)
     
    5857JSClassRef JSClassRetain(JSClassRef jsClass)
    5958{
    60     JSLock lock;
    6159    jsClass->ref();
    6260    return jsClass;
     
    6563void JSClassRelease(JSClassRef jsClass)
    6664{
    67     JSLock lock;
    6865    jsClass->deref();
    6966}
     
    7168JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
    7269{
    73     JSLock lock;
    74     ExecState* exec = toJS(ctx);
     70    ExecState* exec = toJS(ctx);
     71    JSLock lock(exec);
    7572
    7673    if (!jsClass)
     
    8683JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
    8784{
    88     JSLock lock;
    89     ExecState* exec = toJS(ctx);
     85    ExecState* exec = toJS(ctx);
     86    JSLock lock(exec);
    9087    Identifier nameID = name ? Identifier(exec, toJS(name)) : Identifier(exec, "anonymous");
    9188   
     
    9592JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
    9693{
    97     JSLock lock;
    98     ExecState* exec = toJS(ctx);
     94    ExecState* exec = toJS(ctx);
     95    JSLock lock(exec);
    9996   
    10097    JSValue* jsPrototype = jsClass
     
    109106JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    110107{
    111     JSLock lock;
    112    
    113     ExecState* exec = toJS(ctx);
     108    ExecState* exec = toJS(ctx);
     109    JSLock lock(exec);
     110
    114111    UString::Rep* bodyRep = toJS(body);
    115112    UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null;
     
    148145bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
    149146{
    150     JSLock lock;
    151     ExecState* exec = toJS(ctx);
     147    ExecState* exec = toJS(ctx);
     148    JSLock lock(exec);
    152149    JSObject* jsObject = toJS(object);
    153150    UString::Rep* nameRep = toJS(propertyName);
     
    158155JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
    159156{
    160     JSLock lock;
    161     ExecState* exec = toJS(ctx);
     157    ExecState* exec = toJS(ctx);
     158    JSLock lock(exec);
    162159    JSObject* jsObject = toJS(object);
    163160    UString::Rep* nameRep = toJS(propertyName);
     
    174171void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
    175172{
    176     JSLock lock;
    177     ExecState* exec = toJS(ctx);
     173    ExecState* exec = toJS(ctx);
     174    JSLock lock(exec);
    178175    JSObject* jsObject = toJS(object);
    179176    Identifier name(exec, toJS(propertyName));
     
    194191JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception)
    195192{
    196     JSLock lock;
    197     ExecState* exec = toJS(ctx);
     193    ExecState* exec = toJS(ctx);
     194    JSLock lock(exec);
    198195    JSObject* jsObject = toJS(object);
    199196
     
    210207void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception)
    211208{
    212     JSLock lock;
    213     ExecState* exec = toJS(ctx);
     209    ExecState* exec = toJS(ctx);
     210    JSLock lock(exec);
    214211    JSObject* jsObject = toJS(object);
    215212    JSValue* jsValue = toJS(value);
     
    225222bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
    226223{
    227     JSLock lock;
    228     ExecState* exec = toJS(ctx);
     224    ExecState* exec = toJS(ctx);
     225    JSLock lock(exec);
    229226    JSObject* jsObject = toJS(object);
    230227    UString::Rep* nameRep = toJS(propertyName);
     
    274271JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    275272{
    276     JSLock lock;
    277     ExecState* exec = toJS(ctx);
     273    ExecState* exec = toJS(ctx);
     274    JSLock lock(exec);
    278275    JSObject* jsObject = toJS(object);
    279276    JSObject* jsThisObject = toJS(thisObject);
     
    310307JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    311308{
    312     JSLock lock;
    313     ExecState* exec = toJS(ctx);
     309    ExecState* exec = toJS(ctx);
     310    JSLock lock(exec);
    314311    JSObject* jsObject = toJS(object);
    315312
     
    344341JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object)
    345342{
    346     JSLock lock;
    347     JSObject* jsObject = toJS(object);
    348     ExecState* exec = toJS(ctx);
     343    JSObject* jsObject = toJS(object);
     344    ExecState* exec = toJS(ctx);
     345    JSLock lock(exec);
    349346   
    350347    JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(&exec->globalData());
     
    356353JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array)
    357354{
    358     JSLock lock;
    359355    ++array->refCount;
    360356    return array;
     
    363359void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array)
    364360{
    365     JSLock lock;
    366     if (--array->refCount == 0)
     361    if (--array->refCount == 0) {
     362        JSLock lock(array->array.globalData()->isSharedInstance);
    367363        delete array;
     364    }
    368365}
    369366
     
    380377void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStringRef propertyName)
    381378{
    382     JSLock lock;
    383379    PropertyNameArray* propertyNames = toJS(array);
    384380    UString::Rep* rep = toJS(propertyName);
     381
     382    JSLock lock(propertyNames->globalData()->isSharedInstance);
    385383    propertyNames->add(rep);
    386384}
  • trunk/JavaScriptCore/API/JSStringRef.cpp

    r34581 r34947  
    4444JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
    4545{
    46     JSLock lock;
    4746    return toRef(UString(chars, static_cast<int>(numChars)).rep()->ref());
    4847}
     
    5049JSStringRef JSStringCreateWithUTF8CString(const char* string)
    5150{
    52     JSLock lock;
    53 
    5451    RefPtr<UString::Rep> result = UString::Rep::createFromUTF8(string);
    5552    if (result.get() == &UString::Rep::null)
     
    6158JSStringRef JSStringRetain(JSStringRef string)
    6259{
    63     JSLock lock;
    6460    UString::Rep* rep = toJS(string);
    6561    return toRef(rep->ref());
     
    6864void JSStringRelease(JSStringRef string)
    6965{
    70     JSLock lock;
    7166    UString::Rep* rep = toJS(string);
    72     rep->deref();
     67    bool needsLocking = rep->identifierTable;
     68    if (needsLocking) {
     69        // It is wasteful to take the lock for per-thread contexts, but we don't have a good way
     70        // to determine what the context is.
     71        JSLock lock(true);
     72        rep->deref();
     73    } else
     74        rep->deref();
    7375}
    7476
     
    9597size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize)
    9698{
    97     JSLock lock;
    9899    UString::Rep* rep = toJS(string);
    99100    CString cString = UString(rep).UTF8String();
     
    106107bool JSStringIsEqual(JSStringRef a, JSStringRef b)
    107108{
    108     JSLock lock;
    109 
    110109    UString::Rep* aRep = toJS(a);
    111110    UString::Rep* bRep = toJS(b);
  • trunk/JavaScriptCore/API/JSStringRefCF.cpp

    r34581 r34947  
    3838JSStringRef JSStringCreateWithCFString(CFStringRef string)
    3939{
    40     JSLock lock;
    4140    CFIndex length = CFStringGetLength(string);
    4241    UString::Rep* rep;
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r34659 r34947  
    119119bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception)
    120120{
    121     JSLock lock;
    122     ExecState* exec = toJS(ctx);
     121    ExecState* exec = toJS(ctx);
     122    JSLock lock(exec);
     123
    123124    JSValue* jsA = toJS(a);
    124125    JSValue* jsB = toJS(b);
     
    133134}
    134135
    135 bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b)
    136 {
    137     UNUSED_PARAM(ctx);
    138 
    139     JSLock lock;
     136bool JSValueIsStrictEqual(JSContextRef, JSValueRef a, JSValueRef b)
     137{
    140138    JSValue* jsA = toJS(a);
    141139    JSValue* jsB = toJS(b);
     
    147145bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)
    148146{
    149     JSLock lock;
    150     ExecState* exec = toJS(ctx);
     147    ExecState* exec = toJS(ctx);
     148    JSLock lock(exec);
     149
    151150    JSValue* jsValue = toJS(value);
    152151    JSObject* jsConstructor = toJS(constructor);
     
    179178JSValueRef JSValueMakeNumber(JSContextRef ctx, double value)
    180179{
    181     JSLock lock;
    182     return toRef(jsNumber(toJS(ctx), value));
     180    ExecState* exec = toJS(ctx);
     181    JSLock lock(exec);
     182
     183    return toRef(jsNumber(exec, value));
    183184}
    184185
    185186JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string)
    186187{
    187     JSLock lock;
     188    ExecState* exec = toJS(ctx);
     189    JSLock lock(exec);
     190
    188191    UString::Rep* rep = toJS(string);
    189     return toRef(jsString(toJS(ctx), UString(rep)));
     192    return toRef(jsString(exec, UString(rep)));
    190193}
    191194
     
    199202double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
    200203{
    201     JSLock lock;
    202     JSValue* jsValue = toJS(value);
    203     ExecState* exec = toJS(ctx);
     204    ExecState* exec = toJS(ctx);
     205    JSLock lock(exec);
     206
     207    JSValue* jsValue = toJS(value);
    204208
    205209    double number = jsValue->toNumber(exec);
     
    215219JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
    216220{
    217     JSLock lock;
    218     JSValue* jsValue = toJS(value);
    219     ExecState* exec = toJS(ctx);
     221    ExecState* exec = toJS(ctx);
     222    JSLock lock(exec);
     223
     224    JSValue* jsValue = toJS(value);
    220225   
    221226    JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref());
     
    231236JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
    232237{
    233     JSLock lock;
    234     ExecState* exec = toJS(ctx);
     238    ExecState* exec = toJS(ctx);
     239    JSLock lock(exec);
     240
    235241    JSValue* jsValue = toJS(value);
    236242   
     
    245251}   
    246252
    247 void JSValueProtect(JSContextRef, JSValueRef value)
    248 {
    249     JSLock lock;
     253void JSValueProtect(JSContextRef ctx, JSValueRef value)
     254{
     255    ExecState* exec = toJS(ctx);
     256    JSLock lock(exec);
     257
    250258    JSValue* jsValue = toJS(value);
    251259    gcProtect(jsValue);
    252260}
    253261
    254 void JSValueUnprotect(JSContextRef, JSValueRef value)
    255 {
    256     JSLock lock;
     262void JSValueUnprotect(JSContextRef ctx, JSValueRef value)
     263{
     264    ExecState* exec = toJS(ctx);
     265    JSLock lock(exec);
     266
    257267    JSValue* jsValue = toJS(value);
    258268    gcUnprotect(jsValue);
Note: See TracChangeset for help on using the changeset viewer.