Changeset 43160 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
May 3, 2009, 2:02:04 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-05-02 Sam Weinig <[email protected]>

Roll JSC API number marshaling back in one last time (I hope).

WebCore:

2009-05-03 Sam Weinig <[email protected]>

Roll JSC API number marshaling back in one last time (I hope).

Location:
trunk/JavaScriptCore/API
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/APICast.h

    r43158 r43160  
    2727#define APICast_h
    2828
     29#include "JSNumberCell.h"
    2930#include "JSValue.h"
     31#include <wtf/Platform.h>
    3032
    3133namespace JSC {
     
    5658}
    5759
    58 inline JSC::JSValue toJS(JSValueRef v)
     60inline JSC::JSValue toJS(JSC::ExecState* exec, JSValueRef v)
    5961{
    60     return JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
     62    JSC::JSValue jsValue = JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
     63#if !USE(ALTERNATE_JSIMMEDIATE)
     64    if (jsValue && jsValue.isNumber()) {
     65        ASSERT(jsValue.isAPIMangledNumber());
     66        return JSC::jsNumber(exec, jsValue.uncheckedGetNumber());
     67    }
     68#endif
     69    return jsValue;
    6170}
    6271
     
    7685}
    7786
    78 inline JSValueRef toRef(JSC::JSValue v)
     87inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v)
    7988{
     89#if !USE(ALTERNATE_JSIMMEDIATE)
     90    if (v && v.isNumber()) {
     91        ASSERT(!v.isAPIMangledNumber());
     92        return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(JSC::jsAPIMangledNumber(exec, v.uncheckedGetNumber())));
     93    }
     94#endif
    8095    return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(v));
    81 }
    82 
    83 inline JSValueRef* toRef(JSC::JSValue* v)
    84 {
    85     return reinterpret_cast<JSValueRef*>(v);
    8696}
    8797
  • trunk/JavaScriptCore/API/JSBase.cpp

    r43158 r43160  
    5656    if (completion.complType() == Throw) {
    5757        if (exception)
    58             *exception = toRef(completion.value());
     58            *exception = toRef(exec, completion.value());
    5959        return 0;
    6060    }
    6161
    6262    if (completion.value())
    63         return toRef(completion.value());
     63        return toRef(exec, completion.value());
    6464   
    6565    // happens, for example, when the only statement is an empty (';') statement
    66     return toRef(jsUndefined());
     66    return toRef(exec, jsUndefined());
    6767}
    6868
     
    7777    if (completion.complType() == Throw) {
    7878        if (exception)
    79             *exception = toRef(completion.value());
     79            *exception = toRef(exec, completion.value());
    8080        return false;
    8181    }
  • trunk/JavaScriptCore/API/JSCallbackConstructor.cpp

    r43158 r43160  
    6262        Vector<JSValueRef, 16> arguments(argumentCount);
    6363        for (int i = 0; i < argumentCount; i++)
    64             arguments[i] = toRef(args.at(i));
    65            
    66         JSLock::DropAllLocks dropAllLocks(exec);
    67         return toJS(callback(ctx, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
     64            arguments[i] = toRef(exec, args.at(i));
     65
     66        JSValueRef exception = 0;
     67        JSObjectRef result;
     68        {
     69            JSLock::DropAllLocks dropAllLocks(exec);
     70            result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception);
     71        }
     72        if (exception)
     73            exec->setException(toJS(exec, exception));
     74        return toJS(result);
    6875    }
    6976   
  • trunk/JavaScriptCore/API/JSCallbackFunction.cpp

    r43158 r43160  
    5656    Vector<JSValueRef, 16> arguments(argumentCount);
    5757    for (int i = 0; i < argumentCount; i++)
    58         arguments[i] = toRef(args.at(i));
     58        arguments[i] = toRef(exec, args.at(i));
    5959
    60     JSLock::DropAllLocks dropAllLocks(exec);
    61     return toJS(static_cast<JSCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
     60    JSValueRef exception = 0;
     61    JSValueRef result;
     62    {
     63        JSLock::DropAllLocks dropAllLocks(exec);
     64        result = static_cast<JSCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
     65    }
     66    if (exception)
     67        exec->setException(toJS(exec, exception));
     68
     69    return toJS(exec, result);
    6270}
    6371
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r43158 r43160  
    126126            if (!propertyNameRef)
    127127                propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    128             JSLock::DropAllLocks dropAllLocks(exec);
    129             JSValueRef exception = 0;
    130             JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    131             exec->setException(toJS(exception));
     128            JSValueRef exception = 0;
     129            JSValueRef value;
     130            {
     131                JSLock::DropAllLocks dropAllLocks(exec);
     132                value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
     133            }
     134            exec->setException(toJS(exec, exception));
    132135            if (value) {
    133                 slot.setValue(toJS(value));
     136                slot.setValue(toJS(exec, value));
    134137                return true;
    135138            }
     
    170173    JSObjectRef thisRef = toRef(this);
    171174    RefPtr<OpaqueJSString> propertyNameRef;
    172     JSValueRef valueRef = toRef(value);
     175    JSValueRef valueRef = toRef(exec, value);
    173176   
    174177    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
     
    176179            if (!propertyNameRef)
    177180                propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    178             JSLock::DropAllLocks dropAllLocks(exec);
    179             JSValueRef exception = 0;
    180             bool result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
    181             exec->setException(toJS(exception));
     181            JSValueRef exception = 0;
     182            bool result;
     183            {
     184                JSLock::DropAllLocks dropAllLocks(exec);
     185                result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
     186            }
     187            exec->setException(toJS(exec, exception));
    182188            if (result || exception)
    183189                return;
     
    191197                    if (!propertyNameRef)
    192198                        propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    193                     JSLock::DropAllLocks dropAllLocks(exec);
    194199                    JSValueRef exception = 0;
    195                     bool result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
    196                     exec->setException(toJS(exception));
     200                    bool result;
     201                    {
     202                        JSLock::DropAllLocks dropAllLocks(exec);
     203                        result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
     204                    }
     205                    exec->setException(toJS(exec, exception));
    197206                    if (result || exception)
    198207                        return;
     
    226235            if (!propertyNameRef)
    227236                propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    228             JSLock::DropAllLocks dropAllLocks(exec);
    229             JSValueRef exception = 0;
    230             bool result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    231             exec->setException(toJS(exception));
     237            JSValueRef exception = 0;
     238            bool result;
     239            {
     240                JSLock::DropAllLocks dropAllLocks(exec);
     241                result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
     242            }
     243            exec->setException(toJS(exec, exception));
    232244            if (result || exception)
    233245                return true;
     
    283295            Vector<JSValueRef, 16> arguments(argumentCount);
    284296            for (int i = 0; i < argumentCount; i++)
    285                 arguments[i] = toRef(args.at(i));
    286             JSLock::DropAllLocks dropAllLocks(exec);
    287             JSValueRef exception = 0;
    288             JSObject* result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
    289             exec->setException(toJS(exception));
     297                arguments[i] = toRef(exec, args.at(i));
     298            JSValueRef exception = 0;
     299            JSObject* result;
     300            {
     301                JSLock::DropAllLocks dropAllLocks(exec);
     302                result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
     303            }
     304            exec->setException(toJS(exec, exception));
    290305            return result;
    291306        }
     
    304319    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    305320        if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) {
    306             JSLock::DropAllLocks dropAllLocks(exec);
    307             JSValueRef exception = 0;
    308             bool result = hasInstance(execRef, thisRef, toRef(value), &exception);
    309             exec->setException(toJS(exception));
     321            JSValueRef exception = 0;
     322            bool result;
     323            {
     324                JSLock::DropAllLocks dropAllLocks(exec);
     325                result = hasInstance(execRef, thisRef, toRef(exec, value), &exception);
     326            }
     327            exec->setException(toJS(exec, exception));
    310328            return result;
    311329        }
     
    338356            Vector<JSValueRef, 16> arguments(argumentCount);
    339357            for (int i = 0; i < argumentCount; i++)
    340                 arguments[i] = toRef(args.at(i));
    341             JSLock::DropAllLocks dropAllLocks(exec);
    342             JSValueRef exception = 0;
    343             JSValue result = toJS(callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
    344             exec->setException(toJS(exception));
     358                arguments[i] = toRef(exec, args.at(i));
     359            JSValueRef exception = 0;
     360            JSValue result;
     361            {
     362                JSLock::DropAllLocks dropAllLocks(exec);
     363                result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
     364            }
     365            exec->setException(toJS(exec, exception));
    345366            return result;
    346367        }
     
    402423    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    403424        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    404             JSLock::DropAllLocks dropAllLocks(exec);
    405            
    406             JSValueRef exception = 0;
    407             JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, &exception);
    408             exec->setException(toJS(exception));
     425            JSValueRef exception = 0;
     426            JSValueRef value;
     427            {
     428                JSLock::DropAllLocks dropAllLocks(exec);
     429                value = convertToType(ctx, thisRef, kJSTypeNumber, &exception);
     430            }
     431            exec->setException(toJS(exec, exception));
    409432            if (value) {
    410433                double dValue;
    411                 return toJS(value).getNumber(dValue) ? dValue : NaN;
     434                return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
    412435            }
    413436        }
     
    424447    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    425448        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
     449            JSValueRef exception = 0;
    426450            JSValueRef value;
    427             JSValueRef exception = 0;
    428451            {
    429452                JSLock::DropAllLocks dropAllLocks(exec);
    430453                value = convertToType(ctx, thisRef, kJSTypeString, &exception);
    431                 exec->setException(toJS(exception));
    432             }
     454            }
     455            exec->setException(toJS(exec, exception));
    433456            if (value)
    434                 return toJS(value).getString();
     457                return toJS(exec, value).getString();
    435458            if (exception)
    436459                return "";
     
    476499                    if (!propertyNameRef)
    477500                        propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    478                     JSLock::DropAllLocks dropAllLocks(exec);
    479501                    JSValueRef exception = 0;
    480                     JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
    481                     exec->setException(toJS(exception));
     502                    JSValueRef value;
     503                    {
     504                        JSLock::DropAllLocks dropAllLocks(exec);
     505                        value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
     506                    }
     507                    exec->setException(toJS(exec, exception));
    482508                    if (value)
    483                         return toJS(value);
     509                        return toJS(exec, value);
    484510                    if (exception)
    485511                        return jsUndefined();
     
    526552            if (!propertyNameRef)
    527553                propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    528             JSLock::DropAllLocks dropAllLocks(exec);
    529 
    530             JSValueRef exception = 0;
    531             JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
    532             exec->setException(toJS(exception));
     554            JSValueRef exception = 0;
     555            JSValueRef value;
     556            {
     557                JSLock::DropAllLocks dropAllLocks(exec);
     558                value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
     559            }
     560            exec->setException(toJS(exec, exception));
    533561            if (value)
    534                 return toJS(value);
     562                return toJS(exec, value);
    535563            if (exception)
    536564                return jsUndefined();
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r43158 r43160  
    131131    if (exec->hadException()) {
    132132        if (exception)
    133             *exception = toRef(exec->exception());
     133            *exception = toRef(exec, exec->exception());
    134134        exec->clearException();
    135135        result = 0;
     
    148148        MarkedArgumentBuffer argList;
    149149        for (size_t i = 0; i < argumentCount; ++i)
    150             argList.append(toJS(arguments[i]));
     150            argList.append(toJS(exec, arguments[i]));
    151151
    152152        result = constructArray(exec, argList);
     
    156156    if (exec->hadException()) {
    157157        if (exception)
    158             *exception = toRef(exec->exception());
     158            *exception = toRef(exec, exec->exception());
    159159        exec->clearException();
    160160        result = 0;
     
    172172    MarkedArgumentBuffer argList;
    173173    for (size_t i = 0; i < argumentCount; ++i)
    174         argList.append(toJS(arguments[i]));
     174        argList.append(toJS(exec, arguments[i]));
    175175
    176176    JSObject* result = constructDate(exec, argList);
    177177    if (exec->hadException()) {
    178178        if (exception)
    179             *exception = toRef(exec->exception());
     179            *exception = toRef(exec, exec->exception());
    180180        exec->clearException();
    181181        result = 0;
     
    193193    MarkedArgumentBuffer argList;
    194194    for (size_t i = 0; i < argumentCount; ++i)
    195         argList.append(toJS(arguments[i]));
     195        argList.append(toJS(exec, arguments[i]));
    196196
    197197    JSObject* result = constructError(exec, argList);
    198198    if (exec->hadException()) {
    199199        if (exception)
    200             *exception = toRef(exec->exception());
     200            *exception = toRef(exec, exec->exception());
    201201        exec->clearException();
    202202        result = 0;
     
    214214    MarkedArgumentBuffer argList;
    215215    for (size_t i = 0; i < argumentCount; ++i)
    216         argList.append(toJS(arguments[i]));
     216        argList.append(toJS(exec, arguments[i]));
    217217
    218218    JSObject* result = constructRegExp(exec, argList);
    219219    if (exec->hadException()) {
    220220        if (exception)
    221             *exception = toRef(exec->exception());
     221            *exception = toRef(exec, exec->exception());
    222222        exec->clearException();
    223223        result = 0;
     
    227227}
    228228
    229 JSValueRef JSObjectGetPrototype(JSContextRef, JSObjectRef object)
    230 {
    231     JSObject* jsObject = toJS(object);
    232     return toRef(jsObject->prototype());
    233 }
    234 
    235 void JSObjectSetPrototype(JSContextRef, JSObjectRef object, JSValueRef value)
    236 {
    237     JSObject* jsObject = toJS(object);
    238     JSValue jsValue = toJS(value);
     229JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object)
     230{
     231    ExecState* exec = toJS(ctx);
     232    exec->globalData().heap.registerThread();
     233    JSLock lock(exec);
     234
     235    JSObject* jsObject = toJS(object);
     236    return toRef(exec, jsObject->prototype());
     237}
     238
     239void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value)
     240{
     241    ExecState* exec = toJS(ctx);
     242    exec->globalData().heap.registerThread();
     243    JSLock lock(exec);
     244
     245    JSObject* jsObject = toJS(object);
     246    JSValue jsValue = toJS(exec, value);
    239247
    240248    jsObject->setPrototype(jsValue.isObject() ? jsValue : jsNull());
     
    263271    if (exec->hadException()) {
    264272        if (exception)
    265             *exception = toRef(exec->exception());
    266         exec->clearException();
    267     }
    268     return toRef(jsValue);
     273            *exception = toRef(exec, exec->exception());
     274        exec->clearException();
     275    }
     276    return toRef(exec, jsValue);
    269277}
    270278
     
    277285    JSObject* jsObject = toJS(object);
    278286    Identifier name(propertyName->identifier(&exec->globalData()));
    279     JSValue jsValue = toJS(value);
     287    JSValue jsValue = toJS(exec, value);
    280288
    281289    if (attributes && !jsObject->hasProperty(exec, name))
     
    288296    if (exec->hadException()) {
    289297        if (exception)
    290             *exception = toRef(exec->exception());
     298            *exception = toRef(exec, exec->exception());
    291299        exec->clearException();
    292300    }
     
    304312    if (exec->hadException()) {
    305313        if (exception)
    306             *exception = toRef(exec->exception());
    307         exec->clearException();
    308     }
    309     return toRef(jsValue);
     314            *exception = toRef(exec, exec->exception());
     315        exec->clearException();
     316    }
     317    return toRef(exec, jsValue);
    310318}
    311319
     
    318326
    319327    JSObject* jsObject = toJS(object);
    320     JSValue jsValue = toJS(value);
     328    JSValue jsValue = toJS(exec, value);
    321329   
    322330    jsObject->put(exec, propertyIndex, jsValue);
    323331    if (exec->hadException()) {
    324332        if (exception)
    325             *exception = toRef(exec->exception());
     333            *exception = toRef(exec, exec->exception());
    326334        exec->clearException();
    327335    }
     
    339347    if (exec->hadException()) {
    340348        if (exception)
    341             *exception = toRef(exec->exception());
     349            *exception = toRef(exec, exec->exception());
    342350        exec->clearException();
    343351    }
     
    392400    MarkedArgumentBuffer argList;
    393401    for (size_t i = 0; i < argumentCount; i++)
    394         argList.append(toJS(arguments[i]));
     402        argList.append(toJS(exec, arguments[i]));
    395403
    396404    CallData callData;
     
    399407        return 0;
    400408
    401     JSValueRef result = toRef(call(exec, jsObject, callType, callData, jsThisObject, argList));
    402     if (exec->hadException()) {
    403         if (exception)
    404             *exception = toRef(exec->exception());
     409    JSValueRef result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList));
     410    if (exec->hadException()) {
     411        if (exception)
     412            *exception = toRef(exec, exec->exception());
    405413        exec->clearException();
    406414        result = 0;
     
    431439    MarkedArgumentBuffer argList;
    432440    for (size_t i = 0; i < argumentCount; i++)
    433         argList.append(toJS(arguments[i]));
     441        argList.append(toJS(exec, arguments[i]));
    434442    JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList));
    435443    if (exec->hadException()) {
    436444        if (exception)
    437             *exception = toRef(exec->exception());
     445            *exception = toRef(exec, exec->exception());
    438446        exec->clearException();
    439447        result = 0;
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r43158 r43160  
    4242#include <algorithm> // for std::min
    4343
    44 JSType JSValueGetType(JSContextRef, JSValueRef value)
    45 {
    46     JSC::JSValue jsValue = toJS(value);
     44JSType JSValueGetType(JSContextRef ctx, JSValueRef value)
     45{
     46    JSC::ExecState* exec = toJS(ctx);
     47    exec->globalData().heap.registerThread();
     48    JSC::JSLock lock(exec);
     49
     50    JSC::JSValue jsValue = toJS(exec, value);
     51
    4752    if (jsValue.isUndefined())
    4853        return kJSTypeUndefined;
     
    6166using namespace JSC; // placed here to avoid conflict between JSC::JSType and JSType, above.
    6267
    63 bool JSValueIsUndefined(JSContextRef, JSValueRef value)
    64 {
    65     JSValue jsValue = toJS(value);
     68bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value)
     69{
     70    ExecState* exec = toJS(ctx);
     71    exec->globalData().heap.registerThread();
     72    JSLock lock(exec);
     73
     74    JSValue jsValue = toJS(exec, value);
    6675    return jsValue.isUndefined();
    6776}
    6877
    69 bool JSValueIsNull(JSContextRef, JSValueRef value)
    70 {
    71     JSValue jsValue = toJS(value);
     78bool JSValueIsNull(JSContextRef ctx, JSValueRef value)
     79{
     80    ExecState* exec = toJS(ctx);
     81    exec->globalData().heap.registerThread();
     82    JSLock lock(exec);
     83
     84    JSValue jsValue = toJS(exec, value);
    7285    return jsValue.isNull();
    7386}
    7487
    75 bool JSValueIsBoolean(JSContextRef, JSValueRef value)
    76 {
    77     JSValue jsValue = toJS(value);
     88bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value)
     89{
     90    ExecState* exec = toJS(ctx);
     91    exec->globalData().heap.registerThread();
     92    JSLock lock(exec);
     93
     94    JSValue jsValue = toJS(exec, value);
    7895    return jsValue.isBoolean();
    7996}
    8097
    81 bool JSValueIsNumber(JSContextRef, JSValueRef value)
    82 {
    83     JSValue jsValue = toJS(value);
     98bool JSValueIsNumber(JSContextRef ctx, JSValueRef value)
     99{
     100    ExecState* exec = toJS(ctx);
     101    exec->globalData().heap.registerThread();
     102    JSLock lock(exec);
     103
     104    JSValue jsValue = toJS(exec, value);
    84105    return jsValue.isNumber();
    85106}
    86107
    87 bool JSValueIsString(JSContextRef, JSValueRef value)
    88 {
    89     JSValue jsValue = toJS(value);
     108bool JSValueIsString(JSContextRef ctx, JSValueRef value)
     109{
     110    ExecState* exec = toJS(ctx);
     111    exec->globalData().heap.registerThread();
     112    JSLock lock(exec);
     113
     114    JSValue jsValue = toJS(exec, value);
    90115    return jsValue.isString();
    91116}
    92117
    93 bool JSValueIsObject(JSContextRef, JSValueRef value)
    94 {
    95     JSValue jsValue = toJS(value);
     118bool JSValueIsObject(JSContextRef ctx, JSValueRef value)
     119{
     120    ExecState* exec = toJS(ctx);
     121    exec->globalData().heap.registerThread();
     122    JSLock lock(exec);
     123
     124    JSValue jsValue = toJS(exec, value);
    96125    return jsValue.isObject();
    97126}
    98127
    99 bool JSValueIsObjectOfClass(JSContextRef, JSValueRef value, JSClassRef jsClass)
    100 {
    101     JSValue jsValue = toJS(value);
     128bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass)
     129{
     130    ExecState* exec = toJS(ctx);
     131    exec->globalData().heap.registerThread();
     132    JSLock lock(exec);
     133
     134    JSValue jsValue = toJS(exec, value);
    102135   
    103136    if (JSObject* o = jsValue.getObject()) {
     
    116149    JSLock lock(exec);
    117150
    118     JSValue jsA = toJS(a);
    119     JSValue jsB = toJS(b);
     151    JSValue jsA = toJS(exec, a);
     152    JSValue jsB = toJS(exec, b);
    120153
    121154    bool result = JSValue::equal(exec, jsA, jsB); // false if an exception is thrown
    122155    if (exec->hadException()) {
    123156        if (exception)
    124             *exception = toRef(exec->exception());
     157            *exception = toRef(exec, exec->exception());
    125158        exec->clearException();
    126159    }
     
    128161}
    129162
    130 bool JSValueIsStrictEqual(JSContextRef, JSValueRef a, JSValueRef b)
    131 {
    132     JSValue jsA = toJS(a);
    133     JSValue jsB = toJS(b);
    134    
    135     bool result = JSValue::strictEqual(jsA, jsB);
    136     return result;
     163bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b)
     164{
     165    ExecState* exec = toJS(ctx);
     166    exec->globalData().heap.registerThread();
     167    JSLock lock(exec);
     168
     169    JSValue jsA = toJS(exec, a);
     170    JSValue jsB = toJS(exec, b);
     171
     172    return JSValue::strictEqual(jsA, jsB);
    137173}
    138174
     
    143179    JSLock lock(exec);
    144180
    145     JSValue jsValue = toJS(value);
     181    JSValue jsValue = toJS(exec, value);
     182
    146183    JSObject* jsConstructor = toJS(constructor);
    147184    if (!jsConstructor->structure()->typeInfo().implementsHasInstance())
     
    150187    if (exec->hadException()) {
    151188        if (exception)
    152             *exception = toRef(exec->exception());
     189            *exception = toRef(exec, exec->exception());
    153190        exec->clearException();
    154191    }
     
    156193}
    157194
    158 JSValueRef JSValueMakeUndefined(JSContextRef)
    159 {
    160     return toRef(jsUndefined());
    161 }
    162 
    163 JSValueRef JSValueMakeNull(JSContextRef)
    164 {
    165     return toRef(jsNull());
    166 }
    167 
    168 JSValueRef JSValueMakeBoolean(JSContextRef, bool value)
    169 {
    170     return toRef(jsBoolean(value));
     195JSValueRef JSValueMakeUndefined(JSContextRef ctx)
     196{
     197    ExecState* exec = toJS(ctx);
     198    exec->globalData().heap.registerThread();
     199    JSLock lock(exec);
     200
     201    return toRef(exec, jsUndefined());
     202}
     203
     204JSValueRef JSValueMakeNull(JSContextRef ctx)
     205{
     206    ExecState* exec = toJS(ctx);
     207    exec->globalData().heap.registerThread();
     208    JSLock lock(exec);
     209
     210    return toRef(exec, jsNull());
     211}
     212
     213JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool value)
     214{
     215    ExecState* exec = toJS(ctx);
     216    exec->globalData().heap.registerThread();
     217    JSLock lock(exec);
     218
     219    return toRef(exec, jsBoolean(value));
    171220}
    172221
     
    177226    JSLock lock(exec);
    178227
    179     return toRef(jsNumber(exec, value));
     228    return toRef(exec, jsNumber(exec, value));
    180229}
    181230
     
    186235    JSLock lock(exec);
    187236
    188     return toRef(jsString(exec, string->ustring()));
     237    return toRef(exec, jsString(exec, string->ustring()));
    189238}
    190239
     
    192241{
    193242    ExecState* exec = toJS(ctx);
    194     JSValue jsValue = toJS(value);
     243    exec->globalData().heap.registerThread();
     244    JSLock lock(exec);
     245
     246    JSValue jsValue = toJS(exec, value);
    195247    return jsValue.toBoolean(exec);
    196248}
     
    202254    JSLock lock(exec);
    203255
    204     JSValue jsValue = toJS(value);
     256    JSValue jsValue = toJS(exec, value);
    205257
    206258    double number = jsValue.toNumber(exec);
    207259    if (exec->hadException()) {
    208260        if (exception)
    209             *exception = toRef(exec->exception());
     261            *exception = toRef(exec, exec->exception());
    210262        exec->clearException();
    211263        number = NaN;
     
    220272    JSLock lock(exec);
    221273
    222     JSValue jsValue = toJS(value);
     274    JSValue jsValue = toJS(exec, value);
    223275   
    224276    RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)));
    225277    if (exec->hadException()) {
    226278        if (exception)
    227             *exception = toRef(exec->exception());
     279            *exception = toRef(exec, exec->exception());
    228280        exec->clearException();
    229281        stringRef.clear();
     
    238290    JSLock lock(exec);
    239291
    240     JSValue jsValue = toJS(value);
     292    JSValue jsValue = toJS(exec, value);
    241293   
    242294    JSObjectRef objectRef = toRef(jsValue.toObject(exec));
    243295    if (exec->hadException()) {
    244296        if (exception)
    245             *exception = toRef(exec->exception());
     297            *exception = toRef(exec, exec->exception());
    246298        exec->clearException();
    247299        objectRef = 0;
     
    256308    JSLock lock(exec);
    257309
    258     JSValue jsValue = toJS(value);
     310    JSValue jsValue = toJS(exec, value);
    259311    gcProtect(jsValue);
    260312}
     
    266318    JSLock lock(exec);
    267319
    268     JSValue jsValue = toJS(value);
     320    JSValue jsValue = toJS(exec, value);
    269321    gcUnprotect(jsValue);
    270322}
Note: See TracChangeset for help on using the changeset viewer.