Changeset 43130 in webkit for trunk/JavaScriptCore/API/APICast.h


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:
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.