Changeset 43130 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
May 1, 2009, 5:25:41 PM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Geoff "The Minneapolis" Garen.

Add mechanism to vend heap allocated JS numbers to JavaScriptCore API clients with a
representation that is independent of the number representation in the VM.

  • Numbers leaving the interpreter are converted to a tagged JSNumberCell.
  • The numbers coming into the interpreter (asserted to be the tagged JSNumberCell) are converted back to the VM's internal number representation.
  • API/APICast.h: (toJS): (toRef):
  • API/JSBase.cpp: (JSEvaluateScript): (JSCheckScriptSyntax):
  • API/JSCallbackConstructor.cpp: (JSC::constructJSCallback):
  • API/JSCallbackFunction.cpp: (JSC::JSCallbackFunction::call):
  • API/JSCallbackObjectFunctions.h: (JSC::::getOwnPropertySlot): (JSC::::put): (JSC::::deleteProperty): (JSC::::construct): (JSC::::hasInstance): (JSC::::call): (JSC::::toNumber): (JSC::::toString): (JSC::::staticValueGetter): (JSC::::callbackGetter):
  • API/JSObjectRef.cpp: (JSObjectMakeFunction): (JSObjectMakeArray): (JSObjectMakeDate): (JSObjectMakeError): (JSObjectMakeRegExp): (JSObjectGetPrototype): (JSObjectSetPrototype): (JSObjectGetProperty): (JSObjectSetProperty): (JSObjectGetPropertyAtIndex): (JSObjectSetPropertyAtIndex): (JSObjectDeleteProperty): (JSObjectCallAsFunction): (JSObjectCallAsConstructor):
  • API/JSValueRef.cpp: (JSValueGetType): (JSValueIsUndefined): (JSValueIsNull): (JSValueIsBoolean): (JSValueIsNumber): (JSValueIsString): (JSValueIsObject): (JSValueIsObjectOfClass): (JSValueIsEqual): (JSValueIsStrictEqual): (JSValueIsInstanceOfConstructor): (JSValueMakeUndefined): (JSValueMakeNull): (JSValueMakeBoolean): (JSValueMakeNumber): (JSValueMakeString): (JSValueToBoolean): (JSValueToNumber): (JSValueToStringCopy): (JSValueToObject): (JSValueProtect): (JSValueUnprotect):
  • runtime/JSNumberCell.cpp: (JSC::jsAPIMangledNumber):
  • runtime/JSNumberCell.h: (JSC::JSNumberCell::isAPIMangledNumber): (JSC::JSNumberCell::): (JSC::JSNumberCell::JSNumberCell): (JSC::JSValue::isAPIMangledNumber):
  • runtime/JSValue.h:
Location:
trunk/JavaScriptCore/API
Files:
7 edited

Legend:

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

    r43122 r43130  
    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

    r41594 r43130  
    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

    r42989 r43130  
    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

    r43122 r43130  
    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

    r43122 r43130  
    129129            JSValueRef exception = 0;
    130130            JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    131             exec->setException(toJS(exception));
     131            exec->setException(toJS(exec, exception));
    132132            if (value) {
    133                 slot.setValue(toJS(value));
     133                slot.setValue(toJS(exec, value));
    134134                return true;
    135135            }
     
    170170    JSObjectRef thisRef = toRef(this);
    171171    RefPtr<OpaqueJSString> propertyNameRef;
    172     JSValueRef valueRef = toRef(value);
     172    JSValueRef valueRef = toRef(exec, value);
    173173   
    174174    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
     
    179179            JSValueRef exception = 0;
    180180            bool result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
    181             exec->setException(toJS(exception));
     181            exec->setException(toJS(exec, exception));
    182182            if (result || exception)
    183183                return;
     
    194194                    JSValueRef exception = 0;
    195195                    bool result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
    196                     exec->setException(toJS(exception));
     196                    exec->setException(toJS(exec, exception));
    197197                    if (result || exception)
    198198                        return;
     
    229229            JSValueRef exception = 0;
    230230            bool result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    231             exec->setException(toJS(exception));
     231            exec->setException(toJS(exec, exception));
    232232            if (result || exception)
    233233                return true;
     
    283283            Vector<JSValueRef, 16> arguments(argumentCount);
    284284            for (int i = 0; i < argumentCount; i++)
    285                 arguments[i] = toRef(args.at(i));
     285                arguments[i] = toRef(exec, args.at(i));
    286286            JSLock::DropAllLocks dropAllLocks(exec);
    287287            JSValueRef exception = 0;
    288288            JSObject* result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
    289             exec->setException(toJS(exception));
     289            exec->setException(toJS(exec, exception));
    290290            return result;
    291291        }
     
    306306            JSLock::DropAllLocks dropAllLocks(exec);
    307307            JSValueRef exception = 0;
    308             bool result = hasInstance(execRef, thisRef, toRef(value), &exception);
    309             exec->setException(toJS(exception));
     308            bool result = hasInstance(execRef, thisRef, toRef(exec, value), &exception);
     309            exec->setException(toJS(exec, exception));
    310310            return result;
    311311        }
     
    338338            Vector<JSValueRef, 16> arguments(argumentCount);
    339339            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));
     340                arguments[i] = toRef(exec, args.at(i));
     341            JSLock::DropAllLocks dropAllLocks(exec);
     342            JSValueRef exception = 0;
     343            JSValue result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
     344            exec->setException(toJS(exec, exception));
    345345            return result;
    346346        }
     
    406406            JSValueRef exception = 0;
    407407            JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, &exception);
    408             exec->setException(toJS(exception));
     408            exec->setException(toJS(exec, exception));
    409409            if (value) {
    410410                double dValue;
    411                 return toJS(value).getNumber(dValue) ? dValue : NaN;
     411                return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
    412412            }
    413413        }
     
    429429                JSLock::DropAllLocks dropAllLocks(exec);
    430430                value = convertToType(ctx, thisRef, kJSTypeString, &exception);
    431                 exec->setException(toJS(exception));
     431                exec->setException(toJS(exec, exception));
    432432            }
    433433            if (value)
    434                 return toJS(value).getString();
     434                return toJS(exec, value).getString();
    435435            if (exception)
    436436                return "";
     
    476476                    if (!propertyNameRef)
    477477                        propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    478                     JSLock::DropAllLocks dropAllLocks(exec);
    479478                    JSValueRef exception = 0;
    480                     JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
    481                     exec->setException(toJS(exception));
     479                    JSValueRef value;
     480                    {
     481                        JSLock::DropAllLocks dropAllLocks(exec);
     482                        value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
     483                    }
     484                    exec->setException(toJS(exec, exception));
    482485                    if (value)
    483                         return toJS(value);
     486                        return toJS(exec, value);
    484487                    if (exception)
    485488                        return jsUndefined();
     
    530533            JSValueRef exception = 0;
    531534            JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
    532             exec->setException(toJS(exception));
     535            exec->setException(toJS(exec, exception));
    533536            if (value)
    534                 return toJS(value);
     537                return toJS(exec, value);
    535538            if (exception)
    536539                return jsUndefined();
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r43122 r43130  
    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

    r43122 r43130  
    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.