Changeset 60631 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Jun 3, 2010, 1:00:18 PM (15 years ago)
Author:
[email protected]
Message:

Bug 40094 - The return type of NativeFunction should be EncodedJSValue
On Windows & Linux, using JSVALUE32_64, EncodedJSValue is returned in registers, but JSValue is not.

Reviewed by Oliver Hunt.

JavaScriptCore:

  • API/JSCallbackFunction.cpp:

(JSC::JSCallbackFunction::call):

  • API/JSCallbackFunction.h:
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:

(JSC::::call):

(JSC::Interpreter::executeCall):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • jit/JITStubs.h:
  • jsc.cpp:

(functionPrint):
(functionDebug):
(functionGC):
(functionVersion):
(functionRun):
(functionLoad):
(functionCheckSyntax):
(functionSetSamplingFlags):
(functionClearSamplingFlags):
(functionReadline):
(functionQuit):

  • runtime/ArrayConstructor.cpp:

(JSC::callArrayConstructor):
(JSC::arrayConstructorIsArray):

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
(JSC::arrayProtoFuncJoin):
(JSC::arrayProtoFuncConcat):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncReverse):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSort):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):
(JSC::arrayProtoFuncFilter):
(JSC::arrayProtoFuncMap):
(JSC::arrayProtoFuncEvery):
(JSC::arrayProtoFuncForEach):
(JSC::arrayProtoFuncSome):
(JSC::arrayProtoFuncReduce):
(JSC::arrayProtoFuncReduceRight):
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):

  • runtime/BooleanConstructor.cpp:

(JSC::callBooleanConstructor):

  • runtime/BooleanPrototype.cpp:

(JSC::booleanProtoFuncToString):
(JSC::booleanProtoFuncValueOf):

  • runtime/CallData.h:
  • runtime/DateConstructor.cpp:

(JSC::callDate):
(JSC::dateParse):
(JSC::dateNow):
(JSC::dateUTC):

  • runtime/DatePrototype.cpp:

(JSC::dateProtoFuncToString):
(JSC::dateProtoFuncToUTCString):
(JSC::dateProtoFuncToISOString):
(JSC::dateProtoFuncToDateString):
(JSC::dateProtoFuncToTimeString):
(JSC::dateProtoFuncToLocaleString):
(JSC::dateProtoFuncToLocaleDateString):
(JSC::dateProtoFuncToLocaleTimeString):
(JSC::dateProtoFuncGetTime):
(JSC::dateProtoFuncGetFullYear):
(JSC::dateProtoFuncGetUTCFullYear):
(JSC::dateProtoFuncToGMTString):
(JSC::dateProtoFuncGetMonth):
(JSC::dateProtoFuncGetUTCMonth):
(JSC::dateProtoFuncGetDate):
(JSC::dateProtoFuncGetUTCDate):
(JSC::dateProtoFuncGetDay):
(JSC::dateProtoFuncGetUTCDay):
(JSC::dateProtoFuncGetHours):
(JSC::dateProtoFuncGetUTCHours):
(JSC::dateProtoFuncGetMinutes):
(JSC::dateProtoFuncGetUTCMinutes):
(JSC::dateProtoFuncGetSeconds):
(JSC::dateProtoFuncGetUTCSeconds):
(JSC::dateProtoFuncGetMilliSeconds):
(JSC::dateProtoFuncGetUTCMilliseconds):
(JSC::dateProtoFuncGetTimezoneOffset):
(JSC::dateProtoFuncSetTime):
(JSC::dateProtoFuncSetMilliSeconds):
(JSC::dateProtoFuncSetUTCMilliseconds):
(JSC::dateProtoFuncSetSeconds):
(JSC::dateProtoFuncSetUTCSeconds):
(JSC::dateProtoFuncSetMinutes):
(JSC::dateProtoFuncSetUTCMinutes):
(JSC::dateProtoFuncSetHours):
(JSC::dateProtoFuncSetUTCHours):
(JSC::dateProtoFuncSetDate):
(JSC::dateProtoFuncSetUTCDate):
(JSC::dateProtoFuncSetMonth):
(JSC::dateProtoFuncSetUTCMonth):
(JSC::dateProtoFuncSetFullYear):
(JSC::dateProtoFuncSetUTCFullYear):
(JSC::dateProtoFuncSetYear):
(JSC::dateProtoFuncGetYear):
(JSC::dateProtoFuncToJSON):

  • runtime/ErrorConstructor.cpp:

(JSC::callErrorConstructor):

  • runtime/ErrorPrototype.cpp:

(JSC::errorProtoFuncToString):

  • runtime/FunctionConstructor.cpp:

(JSC::callFunctionConstructor):

  • runtime/FunctionPrototype.cpp:

(JSC::callFunctionPrototype):
(JSC::functionProtoFuncToString):
(JSC::functionProtoFuncApply):
(JSC::functionProtoFuncCall):

  • runtime/JSCell.h:

(JSC::getCallData):
(JSC::getConstructData):

  • runtime/JSFunction.cpp:

(JSC::callHostFunctionAsConstructor):

  • runtime/JSFunction.h:
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):
(JSC::globalFuncParseInt):
(JSC::globalFuncParseFloat):
(JSC::globalFuncIsNaN):
(JSC::globalFuncIsFinite):
(JSC::globalFuncDecodeURI):
(JSC::globalFuncDecodeURIComponent):
(JSC::globalFuncEncodeURI):
(JSC::globalFuncEncodeURIComponent):
(JSC::globalFuncEscape):
(JSC::globalFuncUnescape):
(JSC::globalFuncJSCPrint):

  • runtime/JSGlobalObjectFunctions.h:
  • runtime/JSONObject.cpp:

(JSC::JSONProtoFuncParse):
(JSC::JSONProtoFuncStringify):

  • runtime/JSObject.cpp:

(JSC::callDefaultValueFunction):

  • runtime/JSValue.h:
  • runtime/MathObject.cpp:

(JSC::mathProtoFuncAbs):
(JSC::mathProtoFuncACos):
(JSC::mathProtoFuncASin):
(JSC::mathProtoFuncATan):
(JSC::mathProtoFuncATan2):
(JSC::mathProtoFuncCeil):
(JSC::mathProtoFuncCos):
(JSC::mathProtoFuncExp):
(JSC::mathProtoFuncFloor):
(JSC::mathProtoFuncLog):
(JSC::mathProtoFuncMax):
(JSC::mathProtoFuncMin):
(JSC::mathProtoFuncPow):
(JSC::mathProtoFuncRandom):
(JSC::mathProtoFuncRound):
(JSC::mathProtoFuncSin):
(JSC::mathProtoFuncSqrt):
(JSC::mathProtoFuncTan):

  • runtime/NativeErrorConstructor.cpp:

(JSC::callNativeErrorConstructor):

  • runtime/NumberConstructor.cpp:

(JSC::callNumberConstructor):

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncToString):
(JSC::numberProtoFuncToLocaleString):
(JSC::numberProtoFuncValueOf):
(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToExponential):
(JSC::numberProtoFuncToPrecision):

  • runtime/ObjectConstructor.cpp:

(JSC::callObjectConstructor):
(JSC::objectConstructorGetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorKeys):
(JSC::toPropertyDescriptor):
(JSC::objectConstructorDefineProperty):
(JSC::objectConstructorDefineProperties):
(JSC::objectConstructorCreate):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncValueOf):
(JSC::objectProtoFuncHasOwnProperty):
(JSC::objectProtoFuncIsPrototypeOf):
(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncPropertyIsEnumerable):
(JSC::objectProtoFuncToLocaleString):
(JSC::objectProtoFuncToString):

  • runtime/ObjectPrototype.h:
  • runtime/RegExpConstructor.cpp:

(JSC::callRegExpConstructor):

  • runtime/RegExpObject.cpp:

(JSC::callRegExpObject):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncTest):
(JSC::regExpProtoFuncExec):
(JSC::regExpProtoFuncCompile):
(JSC::regExpProtoFuncToString):

  • runtime/StringConstructor.cpp:

(JSC::stringFromCharCode):
(JSC::callStringConstructor):

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncToString):
(JSC::stringProtoFuncCharAt):
(JSC::stringProtoFuncCharCodeAt):
(JSC::stringProtoFuncConcat):
(JSC::stringProtoFuncIndexOf):
(JSC::stringProtoFuncLastIndexOf):
(JSC::stringProtoFuncMatch):
(JSC::stringProtoFuncSearch):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplit):
(JSC::stringProtoFuncSubstr):
(JSC::stringProtoFuncSubstring):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(JSC::stringProtoFuncLocaleCompare):
(JSC::stringProtoFuncBig):
(JSC::stringProtoFuncSmall):
(JSC::stringProtoFuncBlink):
(JSC::stringProtoFuncBold):
(JSC::stringProtoFuncFixed):
(JSC::stringProtoFuncItalics):
(JSC::stringProtoFuncStrike):
(JSC::stringProtoFuncSub):
(JSC::stringProtoFuncSup):
(JSC::stringProtoFuncFontcolor):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncAnchor):
(JSC::stringProtoFuncLink):
(JSC::stringProtoFuncTrim):
(JSC::stringProtoFuncTrimLeft):
(JSC::stringProtoFuncTrimRight):

JavaScriptGlue:

  • JSObject.cpp:

(nativeCallFunction):

WebCore:

  • bindings/js/JSCallbackData.cpp:

(WebCore::JSCallbackData::invokeCallback):

  • bindings/js/JSCustomXPathNSResolver.cpp:

(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):

  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):

  • bindings/js/JSHTMLAllCollectionCustom.cpp:

(WebCore::callHTMLAllCollection):

  • bindings/js/JSHTMLCollectionCustom.cpp:

(WebCore::callHTMLCollection):

  • bindings/js/JSHTMLDocumentCustom.cpp:

(WebCore::JSHTMLDocument::open):

  • bindings/js/JSInjectedScriptHostCustom.cpp:

(WebCore::InjectedScriptHost::createInjectedScript):

  • bindings/js/JSNodeFilterCondition.cpp:

(WebCore::JSNodeFilterCondition::acceptNode):

  • bindings/js/JSNodeListCustom.cpp:

(WebCore::callNodeList):

  • bindings/js/JSPluginElementFunctions.cpp:

(WebCore::callPlugin):

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::create):
(WebCore::ScheduledAction::executeFunctionInContext):

  • bindings/js/ScriptFunctionCall.cpp:

(WebCore::ScriptFunctionCall::call):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::SerializingTreeWalker::convertIfTerminal):

  • bindings/objc/WebScriptObject.mm:

(-[WebScriptObject callWebScriptMethod:withArguments:]):

  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/NP_jsobject.cpp:

(_NPN_InvokeDefault):
(_NPN_Invoke):
(_NPN_Construct):

  • bridge/jni/jni_jsobject.mm:

(JavaJSObject::call):

  • bridge/objc/objc_runtime.mm:

(JSC::Bindings::callObjCFallbackObject):

  • bridge/runtime_method.cpp:

(JSC::callRuntimeMethod):

  • bridge/runtime_object.cpp:

(JSC::Bindings::callRuntimeObject):

WebKit/mac:

  • Plugins/Hosted/NetscapePluginInstanceProxy.h:
  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::invoke):

Location:
trunk/JavaScriptCore/runtime
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/ArrayConstructor.cpp

    r60392 r60631  
    3636ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
    3737   
    38 static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*);
     38static EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*);
    3939
    4040ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
     
    7777}
    7878
    79 static JSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec)
     79static EncodedJSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec)
    8080{
    8181    ArgList args(exec);
    82     return constructArrayWithSizeQuirk(exec, args);
     82    return JSValue::encode(constructArrayWithSizeQuirk(exec, args));
    8383}
    8484
     
    9191}
    9292
    93 JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState* exec)
     93EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState* exec)
    9494{
    95     return jsBoolean(exec->argument(0).inherits(&JSArray::info));
     95    return JSValue::encode(jsBoolean(exec->argument(0).inherits(&JSArray::info)));
    9696}
    9797
  • trunk/JavaScriptCore/runtime/ArrayPrototype.cpp

    r60392 r60631  
    4141ASSERT_CLASS_FITS_IN_CELL(ArrayPrototype);
    4242
    43 static JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*);
    44 static JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState*);
    45 static JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState*);
    46 static JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState*);
    47 static JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState*);
    48 static JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState*);
    49 static JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState*);
    50 static JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState*);
    51 static JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState*);
    52 static JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState*);
    53 static JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState*);
    54 static JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*);
    55 static JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState*);
    56 static JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState*);
    57 static JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState*);
    58 static JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*);
    59 static JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState*);
    60 static JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState*);
    61 static JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState*);
    62 static JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState*);
    63 static JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*);
     43static EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*);
     44static EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState*);
     45static EncodedJSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState*);
     46static EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState*);
     47static EncodedJSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState*);
     48static EncodedJSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState*);
     49static EncodedJSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState*);
     50static EncodedJSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState*);
     51static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState*);
     52static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState*);
     53static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState*);
     54static EncodedJSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*);
     55static EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState*);
     56static EncodedJSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState*);
     57static EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState*);
     58static EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*);
     59static EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState*);
     60static EncodedJSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState*);
     61static EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState*);
     62static EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState*);
     63static EncodedJSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*);
    6464
    6565}
     
    150150}
    151151
    152 JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec)
     152EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec)
    153153{
    154154    JSValue thisValue = exec->hostThisValue();
    155155    bool isRealArray = isJSArray(&exec->globalData(), thisValue);
    156156    if (!isRealArray && !thisValue.inherits(&JSArray::info))
    157         return throwError(exec, TypeError);
     157        return JSValue::encode(throwError(exec, TypeError));
    158158    JSArray* thisObj = asArray(thisValue);
    159159   
     
    161161    if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) {
    162162        if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth)
    163             return throwError(exec, RangeError, "Maximum call stack size exceeded.");   
     163            return JSValue::encode(throwError(exec, RangeError, "Maximum call stack size exceeded."));   
    164164    }
    165165
    166166    bool alreadyVisited = !arrayVisitedElements.add(thisObj).second;
    167167    if (alreadyVisited)
    168         return jsEmptyString(exec); // return an empty string, avoiding infinite recursion.
     168        return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoiding infinite recursion.
    169169
    170170    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
     
    194194    arrayVisitedElements.remove(thisObj);
    195195    if (!totalSize)
    196         return jsEmptyString(exec);
     196        return JSValue::encode(jsEmptyString(exec));
    197197    Vector<UChar> buffer;
    198198    buffer.reserveCapacity(totalSize);
    199199    if (!buffer.data())
    200         return throwOutOfMemoryError(exec);
     200        return JSValue::encode(throwOutOfMemoryError(exec));
    201201       
    202202    for (unsigned i = 0; i < length; i++) {
     
    207207    }
    208208    ASSERT(buffer.size() == totalSize);
    209     return jsString(exec, UString::adopt(buffer));
    210 }
    211 
    212 JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec)
     209    return JSValue::encode(jsString(exec, UString::adopt(buffer)));
     210}
     211
     212EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec)
    213213{
    214214    JSValue thisValue = exec->hostThisValue();
    215215    if (!thisValue.inherits(&JSArray::info))
    216         return throwError(exec, TypeError);
     216        return JSValue::encode(throwError(exec, TypeError));
    217217    JSObject* thisObj = asArray(thisValue);
    218218
     
    220220    if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) {
    221221        if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth)
    222             return throwError(exec, RangeError, "Maximum call stack size exceeded.");   
     222            return JSValue::encode(throwError(exec, RangeError, "Maximum call stack size exceeded."));
    223223    }
    224224
    225225    bool alreadyVisited = !arrayVisitedElements.add(thisObj).second;
    226226    if (alreadyVisited)
    227         return jsEmptyString(exec); // return an empty string, avoding infinite recursion.
     227        return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion.
    228228
    229229    JSStringBuilder strBuffer;
     
    239239            UString str;
    240240            CallData callData;
    241             CallType callType = conversionFunction.getCallData(callData);
     241            CallType callType = getCallData(conversionFunction, callData);
    242242            if (callType != CallTypeNone)
    243243                str = call(exec, conversionFunction, callType, callData, element, exec->emptyList()).toString(exec);
     
    248248    }
    249249    arrayVisitedElements.remove(thisObj);
    250     return strBuffer.build(exec);
    251 }
    252 
    253 JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
     250    return JSValue::encode(strBuffer.build(exec));
     251}
     252
     253EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
    254254{
    255255    JSValue thisValue = exec->hostThisValue();
     
    259259    if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) {
    260260        if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth)
    261             return throwError(exec, RangeError, "Maximum call stack size exceeded.");   
     261            return JSValue::encode(throwError(exec, RangeError, "Maximum call stack size exceeded."));
    262262    }
    263263
    264264    bool alreadyVisited = !arrayVisitedElements.add(thisObj).second;
    265265    if (alreadyVisited)
    266         return jsEmptyString(exec); // return an empty string, avoding infinite recursion.
     266        return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion.
    267267
    268268    JSStringBuilder strBuffer;
     
    320320    }
    321321    arrayVisitedElements.remove(thisObj);
    322     return strBuffer.build(exec);
    323 }
    324 
    325 JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState* exec)
     322    return JSValue::encode(strBuffer.build(exec));
     323}
     324
     325EncodedJSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState* exec)
    326326{
    327327    JSValue thisValue = exec->hostThisValue();
     
    350350    }
    351351    arr->setLength(n);
    352     return arr;
    353 }
    354 
    355 JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec)
     352    return JSValue::encode(arr);
     353}
     354
     355EncodedJSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec)
    356356{
    357357    JSValue thisValue = exec->hostThisValue();
    358358    if (isJSArray(&exec->globalData(), thisValue))
    359         return asArray(thisValue)->pop();
     359        return JSValue::encode(asArray(thisValue)->pop());
    360360
    361361    JSObject* thisObj = thisValue.toThisObject(exec);
     
    370370        putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length - 1));
    371371    }
    372     return result;
    373 }
    374 
    375 JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec)
     372    return JSValue::encode(result);
     373}
     374
     375EncodedJSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec)
    376376{
    377377    JSValue thisValue = exec->hostThisValue();
     
    379379        JSArray* array = asArray(thisValue);
    380380        array->push(exec, exec->argument(0));
    381         return jsNumber(exec, array->length());
     381        return JSValue::encode(jsNumber(exec, array->length()));
    382382    }
    383383
     
    388388    length += exec->argumentCount();
    389389    putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length));
    390     return jsNumber(exec, length);
    391 }
    392 
    393 JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec)
     390    return JSValue::encode(jsNumber(exec, length));
     391}
     392
     393EncodedJSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec)
    394394{
    395395    JSValue thisValue = exec->hostThisValue();
     
    413413            thisObj->deleteProperty(exec, lk1);
    414414    }
    415     return thisObj;
    416 }
    417 
    418 JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec)
     415    return JSValue::encode(thisObj);
     416}
     417
     418EncodedJSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec)
    419419{
    420420    JSValue thisValue = exec->hostThisValue();
     
    437437        putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length - 1));
    438438    }
    439     return result;
    440 }
    441 
    442 JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec)
     439    return JSValue::encode(result);
     440}
     441
     442EncodedJSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec)
    443443{
    444444    JSValue thisValue = exec->hostThisValue();
     
    483483    }
    484484    resObj->setLength(n);
    485     return result;
    486 }
    487 
    488 JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec)
     485    return JSValue::encode(result);
     486}
     487
     488EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec)
    489489{
    490490    JSValue thisValue = exec->hostThisValue();
     
    493493    JSValue function = exec->argument(0);
    494494    CallData callData;
    495     CallType callType = function.getCallData(callData);
     495    CallType callType = getCallData(function, callData);
    496496
    497497    if (thisObj->classInfo() == &JSArray::info) {
     
    502502        else
    503503            asArray(thisObj)->sort(exec);
    504         return thisObj;
     504        return JSValue::encode(thisObj);
    505505    }
    506506
     
    508508
    509509    if (!length)
    510         return thisObj;
     510        return JSValue::encode(thisObj);
    511511
    512512    // "Min" sort. Not the fastest, but definitely less code than heapsort
     
    542542        }
    543543    }
    544     return thisObj;
    545 }
    546 
    547 JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec)
     544    return JSValue::encode(thisObj);
     545}
     546
     547EncodedJSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec)
    548548{
    549549    JSValue thisValue = exec->hostThisValue();
     
    556556    // FIXME: Firefox returns an empty array.
    557557    if (!exec->argumentCount())
    558         return jsUndefined();
     558        return JSValue::encode(jsUndefined());
    559559
    560560    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
     
    603603
    604604    putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length - deleteCount + additionalArgs));
    605     return result;
    606 }
    607 
    608 JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec)
     605    return JSValue::encode(result);
     606}
     607
     608EncodedJSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec)
    609609{
    610610    JSValue thisValue = exec->hostThisValue();
     
    626626    JSValue result = jsNumber(exec, length + nrArgs);
    627627    putProperty(exec, thisObj, exec->propertyNames().length, result);
    628     return result;
    629 }
    630 
    631 JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec)
     628    return JSValue::encode(result);
     629}
     630
     631EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec)
    632632{
    633633    JSValue thisValue = exec->hostThisValue();
     
    636636    JSValue function = exec->argument(0);
    637637    CallData callData;
    638     CallType callType = function.getCallData(callData);
     638    CallType callType = getCallData(function, callData);
    639639    if (callType == CallTypeNone)
    640         return throwError(exec, TypeError);
     640        return JSValue::encode(throwError(exec, TypeError));
    641641
    642642    JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec);
     
    664664        }
    665665        if (k == length)
    666             return resultArray;
     666            return JSValue::encode(resultArray);
    667667    }
    668668    for (; k < length && !exec->hadException(); ++k) {
     
    685685            resultArray->put(exec, filterIndex++, v);
    686686    }
    687     return resultArray;
    688 }
    689 
    690 JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec)
     687    return JSValue::encode(resultArray);
     688}
     689
     690EncodedJSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec)
    691691{
    692692    JSValue thisValue = exec->hostThisValue();
     
    695695    JSValue function = exec->argument(0);
    696696    CallData callData;
    697     CallType callType = function.getCallData(callData);
     697    CallType callType = getCallData(function, callData);
    698698    if (callType == CallTypeNone)
    699         return throwError(exec, TypeError);
     699        return JSValue::encode(throwError(exec, TypeError));
    700700
    701701    JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec);
     
    738738    }
    739739
    740     return resultArray;
     740    return JSValue::encode(resultArray);
    741741}
    742742
     
    746746// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
    747747
    748 JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec)
     748EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec)
    749749{
    750750    JSValue thisValue = exec->hostThisValue();
     
    753753    JSValue function = exec->argument(0);
    754754    CallData callData;
    755     CallType callType = function.getCallData(callData);
     755    CallType callType = getCallData(function, callData);
    756756    if (callType == CallTypeNone)
    757         return throwError(exec, TypeError);
     757        return JSValue::encode(throwError(exec, TypeError));
    758758
    759759    JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec);
     
    777777            JSValue result = cachedCall.call();
    778778            if (!result.toBoolean(cachedCall.newCallFrame(exec)))
    779                 return jsBoolean(false);
     779                return JSValue::encode(jsBoolean(false));
    780780        }
    781781    }
     
    800800    }
    801801
    802     return result;
    803 }
    804 
    805 JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec)
     802    return JSValue::encode(result);
     803}
     804
     805EncodedJSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec)
    806806{
    807807    JSValue thisValue = exec->hostThisValue();
     
    810810    JSValue function = exec->argument(0);
    811811    CallData callData;
    812     CallType callType = function.getCallData(callData);
     812    CallType callType = getCallData(function, callData);
    813813    if (callType == CallTypeNone)
    814         return throwError(exec, TypeError);
     814        return JSValue::encode(throwError(exec, TypeError));
    815815
    816816    JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec);
     
    846846        call(exec, function, callType, callData, applyThis, eachArguments);
    847847    }
    848     return jsUndefined();
    849 }
    850 
    851 JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec)
     848    return JSValue::encode(jsUndefined());
     849}
     850
     851EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec)
    852852{
    853853    JSValue thisValue = exec->hostThisValue();
     
    856856    JSValue function = exec->argument(0);
    857857    CallData callData;
    858     CallType callType = function.getCallData(callData);
     858    CallType callType = getCallData(function, callData);
    859859    if (callType == CallTypeNone)
    860         return throwError(exec, TypeError);
     860        return JSValue::encode(throwError(exec, TypeError));
    861861
    862862    JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec);
     
    880880            JSValue result = cachedCall.call();
    881881            if (result.toBoolean(cachedCall.newCallFrame(exec)))
    882                 return jsBoolean(true);
     882                return JSValue::encode(jsBoolean(true));
    883883        }
    884884    }
     
    900900        }
    901901    }
    902     return result;
    903 }
    904 
    905 JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec)
     902    return JSValue::encode(result);
     903}
     904
     905EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec)
    906906{
    907907    JSValue thisValue = exec->hostThisValue();
     
    910910    JSValue function = exec->argument(0);
    911911    CallData callData;
    912     CallType callType = function.getCallData(callData);
     912    CallType callType = getCallData(function, callData);
    913913    if (callType == CallTypeNone)
    914         return throwError(exec, TypeError);
     914        return JSValue::encode(throwError(exec, TypeError));
    915915
    916916    unsigned i = 0;
     
    918918    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    919919    if (!length && exec->argumentCount() == 1)
    920         return throwError(exec, TypeError);
     920        return JSValue::encode(throwError(exec, TypeError));
    921921    JSArray* array = 0;
    922922    if (isJSArray(&exec->globalData(), thisObj))
     
    935935        }
    936936        if (!rv)
    937             return throwError(exec, TypeError);
     937            return JSValue::encode(throwError(exec, TypeError));
    938938        i++;
    939939    }
     
    955955        }
    956956        if (i == length) // only return if we reached the end of the array
    957             return rv;
     957            return JSValue::encode(rv);
    958958    }
    959959
     
    971971        rv = call(exec, function, callType, callData, jsNull(), eachArguments);
    972972    }
    973     return rv;
    974 }
    975 
    976 JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec)
     973    return JSValue::encode(rv);
     974}
     975
     976EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec)
    977977{
    978978    JSValue thisValue = exec->hostThisValue();
     
    981981    JSValue function = exec->argument(0);
    982982    CallData callData;
    983     CallType callType = function.getCallData(callData);
     983    CallType callType = getCallData(function, callData);
    984984    if (callType == CallTypeNone)
    985         return throwError(exec, TypeError);
     985        return JSValue::encode(throwError(exec, TypeError));
    986986   
    987987    unsigned i = 0;
     
    989989    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    990990    if (!length && exec->argumentCount() == 1)
    991         return throwError(exec, TypeError);
     991        return JSValue::encode(throwError(exec, TypeError));
    992992    JSArray* array = 0;
    993993    if (isJSArray(&exec->globalData(), thisObj))
     
    10061006        }
    10071007        if (!rv)
    1008             return throwError(exec, TypeError);
     1008            return JSValue::encode(throwError(exec, TypeError));
    10091009        i++;
    10101010    }
     
    10241024        }
    10251025        if (i == length) // only return if we reached the end of the array
    1026             return rv;
     1026            return JSValue::encode(rv);
    10271027    }
    10281028   
     
    10411041        rv = call(exec, function, callType, callData, jsNull(), eachArguments);
    10421042    }
    1043     return rv;       
    1044 }
    1045 
    1046 JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec)
     1043    return JSValue::encode(rv);       
     1044}
     1045
     1046EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec)
    10471047{
    10481048    JSValue thisValue = exec->hostThisValue();
     
    10701070            continue;
    10711071        if (JSValue::strictEqual(exec, searchElement, e))
    1072             return jsNumber(exec, index);
    1073     }
    1074 
    1075     return jsNumber(exec, -1);
    1076 }
    1077 
    1078 JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec)
     1072            return JSValue::encode(jsNumber(exec, index));
     1073    }
     1074
     1075    return JSValue::encode(jsNumber(exec, -1));
     1076}
     1077
     1078EncodedJSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec)
    10791079{
    10801080    JSValue thisValue = exec->hostThisValue();
     
    10911091        d += length;
    10921092        if (d < 0)
    1093             return jsNumber(exec, -1);
     1093            return JSValue::encode(jsNumber(exec, -1));
    10941094    }
    10951095    if (d < length)
     
    11021102            continue;
    11031103        if (JSValue::strictEqual(exec, searchElement, e))
    1104             return jsNumber(exec, index);
    1105     }
    1106 
    1107     return jsNumber(exec, -1);
     1104            return JSValue::encode(jsNumber(exec, index));
     1105    }
     1106
     1107    return JSValue::encode(jsNumber(exec, -1));
    11081108}
    11091109
  • trunk/JavaScriptCore/runtime/BooleanConstructor.cpp

    r60392 r60631  
    5858
    5959// ECMA 15.6.1
    60 static JSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec)
     60static EncodedJSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec)
    6161{
    62     return jsBoolean(exec->argument(0).toBoolean(exec));
     62    return JSValue::encode(jsBoolean(exec->argument(0).toBoolean(exec)));
    6363}
    6464
  • trunk/JavaScriptCore/runtime/BooleanPrototype.cpp

    r60392 r60631  
    3333
    3434// Functions
    35 static JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState*);
    36 static JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*);
     35static EncodedJSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState*);
     36static EncodedJSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*);
    3737
    3838// ECMA 15.6.4
     
    5252// ECMA 15.6.4.2 + 15.6.4.3
    5353
    54 JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec)
     54EncodedJSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec)
    5555{
    5656    JSValue thisValue = exec->hostThisValue();
    5757    if (thisValue == jsBoolean(false))
    58         return jsNontrivialString(exec, "false");
     58        return JSValue::encode(jsNontrivialString(exec, "false"));
    5959
    6060    if (thisValue == jsBoolean(true))
    61         return jsNontrivialString(exec, "true");
     61        return JSValue::encode(jsNontrivialString(exec, "true"));
    6262
    6363    if (!thisValue.inherits(&BooleanObject::info))
    64         return throwError(exec, TypeError);
     64        return JSValue::encode(throwError(exec, TypeError));
    6565
    6666    if (asBooleanObject(thisValue)->internalValue() == jsBoolean(false))
    67         return jsNontrivialString(exec, "false");
     67        return JSValue::encode(jsNontrivialString(exec, "false"));
    6868
    6969    ASSERT(asBooleanObject(thisValue)->internalValue() == jsBoolean(true));
    70     return jsNontrivialString(exec, "true");
     70    return JSValue::encode(jsNontrivialString(exec, "true"));
    7171}
    7272
    73 JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState* exec)
     73EncodedJSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState* exec)
    7474{
    7575    JSValue thisValue = exec->hostThisValue();
    7676    if (thisValue.isBoolean())
    77         return thisValue;
     77        return JSValue::encode(thisValue);
    7878
    7979    if (!thisValue.inherits(&BooleanObject::info))
    80         return throwError(exec, TypeError);
     80        return JSValue::encode(throwError(exec, TypeError));
    8181
    82     return asBooleanObject(thisValue)->internalValue();
     82    return JSValue::encode(asBooleanObject(thisValue)->internalValue());
    8383}
    8484
  • trunk/JavaScriptCore/runtime/CallData.h

    r60392 r60631  
    3030#define CallData_h
    3131
     32#include "JSValue.h"
    3233#include "NativeFunctionWrapper.h"
    3334
     
    3839    class FunctionExecutable;
    3940    class JSObject;
    40     class JSValue;
    4141    class ScopeChainNode;
    4242
     
    4747    };
    4848
    49     typedef JSValue (JSC_HOST_CALL *NativeFunction)(ExecState*);
     49    typedef EncodedJSValue (JSC_HOST_CALL *NativeFunction)(ExecState*);
    5050
    5151    union CallData {
  • trunk/JavaScriptCore/runtime/DateConstructor.cpp

    r60392 r60631  
    5555ASSERT_CLASS_FITS_IN_CELL(DateConstructor);
    5656
    57 static JSValue JSC_HOST_CALL dateParse(ExecState*);
    58 static JSValue JSC_HOST_CALL dateNow(ExecState*);
    59 static JSValue JSC_HOST_CALL dateUTC(ExecState*);
     57static EncodedJSValue JSC_HOST_CALL dateParse(ExecState*);
     58static EncodedJSValue JSC_HOST_CALL dateNow(ExecState*);
     59static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState*);
    6060
    6161DateConstructor::DateConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype)
     
    129129
    130130// ECMA 15.9.2
    131 static JSValue JSC_HOST_CALL callDate(ExecState* exec)
     131static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec)
    132132{
    133133    time_t localTime = time(0);
     
    139139    formatDate(ts, date);
    140140    formatTime(ts, time);
    141     return jsMakeNontrivialString(exec, date, " ", time);
     141    return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
    142142}
    143143
     
    148148}
    149149
    150 static JSValue JSC_HOST_CALL dateParse(ExecState* exec)
     150static EncodedJSValue JSC_HOST_CALL dateParse(ExecState* exec)
    151151{
    152     return jsNumber(exec, parseDate(exec, exec->argument(0).toString(exec)));
     152    return JSValue::encode(jsNumber(exec, parseDate(exec, exec->argument(0).toString(exec))));
    153153}
    154154
    155 static JSValue JSC_HOST_CALL dateNow(ExecState* exec)
     155static EncodedJSValue JSC_HOST_CALL dateNow(ExecState* exec)
    156156{
    157     return jsNumber(exec, jsCurrentTime());
     157    return JSValue::encode(jsNumber(exec, jsCurrentTime()));
    158158}
    159159
    160 static JSValue JSC_HOST_CALL dateUTC(ExecState* exec)
     160static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec)
    161161{
    162162    int n = exec->argumentCount();
     
    168168            || (n >= 6 && isnan(exec->argument(5).toNumber(exec)))
    169169            || (n >= 7 && isnan(exec->argument(6).toNumber(exec))))
    170         return jsNaN(exec);
     170        return JSValue::encode(jsNaN(exec));
    171171
    172172    GregorianDateTime t;
     
    179179    t.second = exec->argument(5).toInt32(exec);
    180180    double ms = (n >= 7) ? exec->argument(6).toNumber(exec) : 0;
    181     return jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true)));
     181    return JSValue::encode(jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true))));
    182182}
    183183
  • trunk/JavaScriptCore/runtime/DatePrototype.cpp

    r60392 r60631  
    7474ASSERT_CLASS_FITS_IN_CELL(DatePrototype);
    7575
    76 static JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState*);
    77 static JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState*);
    78 static JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState*);
    79 static JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState*);
    80 static JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState*);
    81 static JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState*);
    82 static JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState*);
    83 static JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState*);
    84 static JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState*);
    85 static JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState*);
    86 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState*);
    87 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState*);
    88 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState*);
    89 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState*);
    90 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState*);
    91 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState*);
    92 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState*);
    93 static JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState*);
    94 static JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState*);
    95 static JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState*);
    96 static JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState*);
    97 static JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState*);
    98 static JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState*);
    99 static JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState*);
    100 static JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState*);
    101 static JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState*);
    102 static JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState*);
    103 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState*);
    104 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState*);
    105 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState*);
    106 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState*);
    107 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState*);
    108 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState*);
    109 static JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState*);
    110 static JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState*);
    111 static JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState*);
    112 static JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState*);
    113 static JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState*);
    114 static JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState*);
    115 static JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState*);
    116 static JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState*);
    117 static JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState*);
    118 static JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState*);
    119 static JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState*);
    120 static JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState*);
     76static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState*);
     77static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState*);
     78static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState*);
     79static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState*);
     80static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState*);
     81static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState*);
     82static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState*);
     83static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState*);
     84static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState*);
     85static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState*);
     86static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState*);
     87static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState*);
     88static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState*);
     89static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState*);
     90static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState*);
     91static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState*);
     92static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState*);
     93static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState*);
     94static EncodedJSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState*);
     95static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState*);
     96static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState*);
     97static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState*);
     98static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState*);
     99static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState*);
     100static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState*);
     101static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState*);
     102static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState*);
     103static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState*);
     104static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState*);
     105static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState*);
     106static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState*);
     107static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState*);
     108static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState*);
     109static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState*);
     110static EncodedJSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState*);
     111static EncodedJSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState*);
     112static EncodedJSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState*);
     113static EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState*);
     114static EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState*);
     115static EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState*);
     116static EncodedJSValue JSC_HOST_CALL dateProtoFuncToString(ExecState*);
     117static EncodedJSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState*);
     118static EncodedJSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState*);
     119static EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState*);
     120static EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState*);
    121121
    122122}
     
    438438// Functions
    439439
    440 JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec)
    441 {
    442     JSValue thisValue = exec->hostThisValue();
    443     if (!thisValue.inherits(&DateInstance::info))
    444         return throwError(exec, TypeError);
    445 
    446     DateInstance* thisDateObj = asDateInstance(thisValue);
    447 
    448     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    449     if (!gregorianDateTime)
    450         return jsNontrivialString(exec, "Invalid Date");
     440EncodedJSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec)
     441{
     442    JSValue thisValue = exec->hostThisValue();
     443    if (!thisValue.inherits(&DateInstance::info))
     444        return JSValue::encode(throwError(exec, TypeError));
     445
     446    DateInstance* thisDateObj = asDateInstance(thisValue);
     447
     448    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     449    if (!gregorianDateTime)
     450        return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
    451451    DateConversionBuffer date;
    452452    DateConversionBuffer time;
    453453    formatDate(*gregorianDateTime, date);
    454454    formatTime(*gregorianDateTime, time);
    455     return jsMakeNontrivialString(exec, date, " ", time);
    456 }
    457 
    458 JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec)
    459 {
    460     JSValue thisValue = exec->hostThisValue();
    461     if (!thisValue.inherits(&DateInstance::info))
    462         return throwError(exec, TypeError);
     455    return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
     456}
     457
     458EncodedJSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec)
     459{
     460    JSValue thisValue = exec->hostThisValue();
     461    if (!thisValue.inherits(&DateInstance::info))
     462        return JSValue::encode(throwError(exec, TypeError));
    463463
    464464    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    466466    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    467467    if (!gregorianDateTime)
    468         return jsNontrivialString(exec, "Invalid Date");
     468        return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
    469469    DateConversionBuffer date;
    470470    DateConversionBuffer time;
    471471    formatDateUTCVariant(*gregorianDateTime, date);
    472472    formatTimeUTC(*gregorianDateTime, time);
    473     return jsMakeNontrivialString(exec, date, " ", time);
    474 }
    475 
    476 JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec)
    477 {
    478     JSValue thisValue = exec->hostThisValue();
    479     if (!thisValue.inherits(&DateInstance::info))
    480         return throwError(exec, TypeError);
     473    return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
     474}
     475
     476EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec)
     477{
     478    JSValue thisValue = exec->hostThisValue();
     479    if (!thisValue.inherits(&DateInstance::info))
     480        return JSValue::encode(throwError(exec, TypeError));
    481481   
    482482    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    484484    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    485485    if (!gregorianDateTime)
    486         return jsNontrivialString(exec, "Invalid Date");
     486        return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
    487487    // Maximum amount of space we need in buffer: 6 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) + 4 (. + 3 digits for milliseconds)
    488488    // 6 for formatting and one for null termination = 27.  We add one extra character to allow us to force null termination.
     
    490490    snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year, gregorianDateTime->month + 1, gregorianDateTime->monthDay, gregorianDateTime->hour, gregorianDateTime->minute, gregorianDateTime->second, static_cast<int>(fmod(thisDateObj->internalNumber(), 1000)));
    491491    buffer[sizeof(buffer) - 1] = 0;
    492     return jsNontrivialString(exec, buffer);
    493 }
    494 
    495 JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec)
    496 {
    497     JSValue thisValue = exec->hostThisValue();
    498     if (!thisValue.inherits(&DateInstance::info))
    499         return throwError(exec, TypeError);
    500 
    501     DateInstance* thisDateObj = asDateInstance(thisValue);
    502 
    503     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    504     if (!gregorianDateTime)
    505         return jsNontrivialString(exec, "Invalid Date");
     492    return JSValue::encode(jsNontrivialString(exec, buffer));
     493}
     494
     495EncodedJSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec)
     496{
     497    JSValue thisValue = exec->hostThisValue();
     498    if (!thisValue.inherits(&DateInstance::info))
     499        return JSValue::encode(throwError(exec, TypeError));
     500
     501    DateInstance* thisDateObj = asDateInstance(thisValue);
     502
     503    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     504    if (!gregorianDateTime)
     505        return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
    506506    DateConversionBuffer date;
    507507    formatDate(*gregorianDateTime, date);
    508     return jsNontrivialString(exec, date);
    509 }
    510 
    511 JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec)
    512 {
    513     JSValue thisValue = exec->hostThisValue();
    514     if (!thisValue.inherits(&DateInstance::info))
    515         return throwError(exec, TypeError);
    516 
    517     DateInstance* thisDateObj = asDateInstance(thisValue);
    518 
    519     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    520     if (!gregorianDateTime)
    521         return jsNontrivialString(exec, "Invalid Date");
     508    return JSValue::encode(jsNontrivialString(exec, date));
     509}
     510
     511EncodedJSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec)
     512{
     513    JSValue thisValue = exec->hostThisValue();
     514    if (!thisValue.inherits(&DateInstance::info))
     515        return JSValue::encode(throwError(exec, TypeError));
     516
     517    DateInstance* thisDateObj = asDateInstance(thisValue);
     518
     519    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     520    if (!gregorianDateTime)
     521        return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
    522522    DateConversionBuffer time;
    523523    formatTime(*gregorianDateTime, time);
    524     return jsNontrivialString(exec, time);
    525 }
    526 
    527 JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec)
    528 {
    529     JSValue thisValue = exec->hostThisValue();
    530     if (!thisValue.inherits(&DateInstance::info))
    531         return throwError(exec, TypeError);
    532 
    533     DateInstance* thisDateObj = asDateInstance(thisValue);
    534     return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime);
    535 }
    536 
    537 JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec)
    538 {
    539     JSValue thisValue = exec->hostThisValue();
    540     if (!thisValue.inherits(&DateInstance::info))
    541         return throwError(exec, TypeError);
    542 
    543     DateInstance* thisDateObj = asDateInstance(thisValue);
    544     return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate);
    545 }
    546 
    547 JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec)
    548 {
    549     JSValue thisValue = exec->hostThisValue();
    550     if (!thisValue.inherits(&DateInstance::info))
    551         return throwError(exec, TypeError);
    552 
    553     DateInstance* thisDateObj = asDateInstance(thisValue);
    554     return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime);
    555 }
    556 
    557 JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec)
    558 {
    559     JSValue thisValue = exec->hostThisValue();
    560     if (!thisValue.inherits(&DateInstance::info))
    561         return throwError(exec, TypeError);
    562 
    563     return asDateInstance(thisValue)->internalValue();
    564 }
    565 
    566 JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec)
    567 {
    568     JSValue thisValue = exec->hostThisValue();
    569     if (!thisValue.inherits(&DateInstance::info))
    570         return throwError(exec, TypeError);
    571 
    572     DateInstance* thisDateObj = asDateInstance(thisValue);
    573 
    574     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    575     if (!gregorianDateTime)
    576         return jsNaN(exec);
    577     return jsNumber(exec, 1900 + gregorianDateTime->year);
    578 }
    579 
    580 JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec)
    581 {
    582     JSValue thisValue = exec->hostThisValue();
    583     if (!thisValue.inherits(&DateInstance::info))
    584         return throwError(exec, TypeError);
     524    return JSValue::encode(jsNontrivialString(exec, time));
     525}
     526
     527EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec)
     528{
     529    JSValue thisValue = exec->hostThisValue();
     530    if (!thisValue.inherits(&DateInstance::info))
     531        return JSValue::encode(throwError(exec, TypeError));
     532
     533    DateInstance* thisDateObj = asDateInstance(thisValue);
     534    return JSValue::encode(formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime));
     535}
     536
     537EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec)
     538{
     539    JSValue thisValue = exec->hostThisValue();
     540    if (!thisValue.inherits(&DateInstance::info))
     541        return JSValue::encode(throwError(exec, TypeError));
     542
     543    DateInstance* thisDateObj = asDateInstance(thisValue);
     544    return JSValue::encode(formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate));
     545}
     546
     547EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec)
     548{
     549    JSValue thisValue = exec->hostThisValue();
     550    if (!thisValue.inherits(&DateInstance::info))
     551        return JSValue::encode(throwError(exec, TypeError));
     552
     553    DateInstance* thisDateObj = asDateInstance(thisValue);
     554    return JSValue::encode(formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime));
     555}
     556
     557EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec)
     558{
     559    JSValue thisValue = exec->hostThisValue();
     560    if (!thisValue.inherits(&DateInstance::info))
     561        return JSValue::encode(throwError(exec, TypeError));
     562
     563    return JSValue::encode(asDateInstance(thisValue)->internalValue());
     564}
     565
     566EncodedJSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec)
     567{
     568    JSValue thisValue = exec->hostThisValue();
     569    if (!thisValue.inherits(&DateInstance::info))
     570        return JSValue::encode(throwError(exec, TypeError));
     571
     572    DateInstance* thisDateObj = asDateInstance(thisValue);
     573
     574    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     575    if (!gregorianDateTime)
     576        return JSValue::encode(jsNaN(exec));
     577    return JSValue::encode(jsNumber(exec, 1900 + gregorianDateTime->year));
     578}
     579
     580EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec)
     581{
     582    JSValue thisValue = exec->hostThisValue();
     583    if (!thisValue.inherits(&DateInstance::info))
     584        return JSValue::encode(throwError(exec, TypeError));
    585585
    586586    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    588588    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    589589    if (!gregorianDateTime)
    590         return jsNaN(exec);
    591     return jsNumber(exec, 1900 + gregorianDateTime->year);
    592 }
    593 
    594 JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec)
    595 {
    596     JSValue thisValue = exec->hostThisValue();
    597     if (!thisValue.inherits(&DateInstance::info))
    598         return throwError(exec, TypeError);
     590        return JSValue::encode(jsNaN(exec));
     591    return JSValue::encode(jsNumber(exec, 1900 + gregorianDateTime->year));
     592}
     593
     594EncodedJSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec)
     595{
     596    JSValue thisValue = exec->hostThisValue();
     597    if (!thisValue.inherits(&DateInstance::info))
     598        return JSValue::encode(throwError(exec, TypeError));
    599599
    600600    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    602602    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    603603    if (!gregorianDateTime)
    604         return jsNontrivialString(exec, "Invalid Date");
     604        return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
    605605    DateConversionBuffer date;
    606606    DateConversionBuffer time;
    607607    formatDateUTCVariant(*gregorianDateTime, date);
    608608    formatTimeUTC(*gregorianDateTime, time);
    609     return jsMakeNontrivialString(exec, date, " ", time);
    610 }
    611 
    612 JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec)
    613 {
    614     JSValue thisValue = exec->hostThisValue();
    615     if (!thisValue.inherits(&DateInstance::info))
    616         return throwError(exec, TypeError);
    617 
    618     DateInstance* thisDateObj = asDateInstance(thisValue);
    619 
    620     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    621     if (!gregorianDateTime)
    622         return jsNaN(exec);
    623     return jsNumber(exec, gregorianDateTime->month);
    624 }
    625 
    626 JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec)
    627 {
    628     JSValue thisValue = exec->hostThisValue();
    629     if (!thisValue.inherits(&DateInstance::info))
    630         return throwError(exec, TypeError);
     609    return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
     610}
     611
     612EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec)
     613{
     614    JSValue thisValue = exec->hostThisValue();
     615    if (!thisValue.inherits(&DateInstance::info))
     616        return JSValue::encode(throwError(exec, TypeError));
     617
     618    DateInstance* thisDateObj = asDateInstance(thisValue);
     619
     620    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     621    if (!gregorianDateTime)
     622        return JSValue::encode(jsNaN(exec));
     623    return JSValue::encode(jsNumber(exec, gregorianDateTime->month));
     624}
     625
     626EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec)
     627{
     628    JSValue thisValue = exec->hostThisValue();
     629    if (!thisValue.inherits(&DateInstance::info))
     630        return JSValue::encode(throwError(exec, TypeError));
    631631
    632632    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    634634    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    635635    if (!gregorianDateTime)
    636         return jsNaN(exec);
    637     return jsNumber(exec, gregorianDateTime->month);
    638 }
    639 
    640 JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec)
    641 {
    642     JSValue thisValue = exec->hostThisValue();
    643     if (!thisValue.inherits(&DateInstance::info))
    644         return throwError(exec, TypeError);
    645 
    646     DateInstance* thisDateObj = asDateInstance(thisValue);
    647 
    648     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    649     if (!gregorianDateTime)
    650         return jsNaN(exec);
    651     return jsNumber(exec, gregorianDateTime->monthDay);
    652 }
    653 
    654 JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec)
    655 {
    656     JSValue thisValue = exec->hostThisValue();
    657     if (!thisValue.inherits(&DateInstance::info))
    658         return throwError(exec, TypeError);
     636        return JSValue::encode(jsNaN(exec));
     637    return JSValue::encode(jsNumber(exec, gregorianDateTime->month));
     638}
     639
     640EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec)
     641{
     642    JSValue thisValue = exec->hostThisValue();
     643    if (!thisValue.inherits(&DateInstance::info))
     644        return JSValue::encode(throwError(exec, TypeError));
     645
     646    DateInstance* thisDateObj = asDateInstance(thisValue);
     647
     648    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     649    if (!gregorianDateTime)
     650        return JSValue::encode(jsNaN(exec));
     651    return JSValue::encode(jsNumber(exec, gregorianDateTime->monthDay));
     652}
     653
     654EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec)
     655{
     656    JSValue thisValue = exec->hostThisValue();
     657    if (!thisValue.inherits(&DateInstance::info))
     658        return JSValue::encode(throwError(exec, TypeError));
    659659
    660660    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    662662    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    663663    if (!gregorianDateTime)
    664         return jsNaN(exec);
    665     return jsNumber(exec, gregorianDateTime->monthDay);
    666 }
    667 
    668 JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec)
    669 {
    670     JSValue thisValue = exec->hostThisValue();
    671     if (!thisValue.inherits(&DateInstance::info))
    672         return throwError(exec, TypeError);
    673 
    674     DateInstance* thisDateObj = asDateInstance(thisValue);
    675 
    676     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    677     if (!gregorianDateTime)
    678         return jsNaN(exec);
    679     return jsNumber(exec, gregorianDateTime->weekDay);
    680 }
    681 
    682 JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec)
    683 {
    684     JSValue thisValue = exec->hostThisValue();
    685     if (!thisValue.inherits(&DateInstance::info))
    686         return throwError(exec, TypeError);
     664        return JSValue::encode(jsNaN(exec));
     665    return JSValue::encode(jsNumber(exec, gregorianDateTime->monthDay));
     666}
     667
     668EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec)
     669{
     670    JSValue thisValue = exec->hostThisValue();
     671    if (!thisValue.inherits(&DateInstance::info))
     672        return JSValue::encode(throwError(exec, TypeError));
     673
     674    DateInstance* thisDateObj = asDateInstance(thisValue);
     675
     676    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     677    if (!gregorianDateTime)
     678        return JSValue::encode(jsNaN(exec));
     679    return JSValue::encode(jsNumber(exec, gregorianDateTime->weekDay));
     680}
     681
     682EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec)
     683{
     684    JSValue thisValue = exec->hostThisValue();
     685    if (!thisValue.inherits(&DateInstance::info))
     686        return JSValue::encode(throwError(exec, TypeError));
    687687
    688688    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    690690    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    691691    if (!gregorianDateTime)
    692         return jsNaN(exec);
    693     return jsNumber(exec, gregorianDateTime->weekDay);
    694 }
    695 
    696 JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec)
    697 {
    698     JSValue thisValue = exec->hostThisValue();
    699     if (!thisValue.inherits(&DateInstance::info))
    700         return throwError(exec, TypeError);
    701 
    702     DateInstance* thisDateObj = asDateInstance(thisValue);
    703 
    704     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    705     if (!gregorianDateTime)
    706         return jsNaN(exec);
    707     return jsNumber(exec, gregorianDateTime->hour);
    708 }
    709 
    710 JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec)
    711 {
    712     JSValue thisValue = exec->hostThisValue();
    713     if (!thisValue.inherits(&DateInstance::info))
    714         return throwError(exec, TypeError);
     692        return JSValue::encode(jsNaN(exec));
     693    return JSValue::encode(jsNumber(exec, gregorianDateTime->weekDay));
     694}
     695
     696EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec)
     697{
     698    JSValue thisValue = exec->hostThisValue();
     699    if (!thisValue.inherits(&DateInstance::info))
     700        return JSValue::encode(throwError(exec, TypeError));
     701
     702    DateInstance* thisDateObj = asDateInstance(thisValue);
     703
     704    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     705    if (!gregorianDateTime)
     706        return JSValue::encode(jsNaN(exec));
     707    return JSValue::encode(jsNumber(exec, gregorianDateTime->hour));
     708}
     709
     710EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec)
     711{
     712    JSValue thisValue = exec->hostThisValue();
     713    if (!thisValue.inherits(&DateInstance::info))
     714        return JSValue::encode(throwError(exec, TypeError));
    715715
    716716    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    718718    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    719719    if (!gregorianDateTime)
    720         return jsNaN(exec);
    721     return jsNumber(exec, gregorianDateTime->hour);
    722 }
    723 
    724 JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec)
    725 {
    726     JSValue thisValue = exec->hostThisValue();
    727     if (!thisValue.inherits(&DateInstance::info))
    728         return throwError(exec, TypeError);
    729 
    730     DateInstance* thisDateObj = asDateInstance(thisValue);
    731 
    732     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    733     if (!gregorianDateTime)
    734         return jsNaN(exec);
    735     return jsNumber(exec, gregorianDateTime->minute);
    736 }
    737 
    738 JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec)
    739 {
    740     JSValue thisValue = exec->hostThisValue();
    741     if (!thisValue.inherits(&DateInstance::info))
    742         return throwError(exec, TypeError);
     720        return JSValue::encode(jsNaN(exec));
     721    return JSValue::encode(jsNumber(exec, gregorianDateTime->hour));
     722}
     723
     724EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec)
     725{
     726    JSValue thisValue = exec->hostThisValue();
     727    if (!thisValue.inherits(&DateInstance::info))
     728        return JSValue::encode(throwError(exec, TypeError));
     729
     730    DateInstance* thisDateObj = asDateInstance(thisValue);
     731
     732    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     733    if (!gregorianDateTime)
     734        return JSValue::encode(jsNaN(exec));
     735    return JSValue::encode(jsNumber(exec, gregorianDateTime->minute));
     736}
     737
     738EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec)
     739{
     740    JSValue thisValue = exec->hostThisValue();
     741    if (!thisValue.inherits(&DateInstance::info))
     742        return JSValue::encode(throwError(exec, TypeError));
    743743
    744744    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    746746    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    747747    if (!gregorianDateTime)
    748         return jsNaN(exec);
    749     return jsNumber(exec, gregorianDateTime->minute);
    750 }
    751 
    752 JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec)
    753 {
    754     JSValue thisValue = exec->hostThisValue();
    755     if (!thisValue.inherits(&DateInstance::info))
    756         return throwError(exec, TypeError);
    757 
    758     DateInstance* thisDateObj = asDateInstance(thisValue);
    759 
    760     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    761     if (!gregorianDateTime)
    762         return jsNaN(exec);
    763     return jsNumber(exec, gregorianDateTime->second);
    764 }
    765 
    766 JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec)
    767 {
    768     JSValue thisValue = exec->hostThisValue();
    769     if (!thisValue.inherits(&DateInstance::info))
    770         return throwError(exec, TypeError);
     748        return JSValue::encode(jsNaN(exec));
     749    return JSValue::encode(jsNumber(exec, gregorianDateTime->minute));
     750}
     751
     752EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec)
     753{
     754    JSValue thisValue = exec->hostThisValue();
     755    if (!thisValue.inherits(&DateInstance::info))
     756        return JSValue::encode(throwError(exec, TypeError));
     757
     758    DateInstance* thisDateObj = asDateInstance(thisValue);
     759
     760    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     761    if (!gregorianDateTime)
     762        return JSValue::encode(jsNaN(exec));
     763    return JSValue::encode(jsNumber(exec, gregorianDateTime->second));
     764}
     765
     766EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec)
     767{
     768    JSValue thisValue = exec->hostThisValue();
     769    if (!thisValue.inherits(&DateInstance::info))
     770        return JSValue::encode(throwError(exec, TypeError));
    771771
    772772    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    774774    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    775775    if (!gregorianDateTime)
    776         return jsNaN(exec);
    777     return jsNumber(exec, gregorianDateTime->second);
    778 }
    779 
    780 JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec)
    781 {
    782     JSValue thisValue = exec->hostThisValue();
    783     if (!thisValue.inherits(&DateInstance::info))
    784         return throwError(exec, TypeError);
     776        return JSValue::encode(jsNaN(exec));
     777    return JSValue::encode(jsNumber(exec, gregorianDateTime->second));
     778}
     779
     780EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec)
     781{
     782    JSValue thisValue = exec->hostThisValue();
     783    if (!thisValue.inherits(&DateInstance::info))
     784        return JSValue::encode(throwError(exec, TypeError));
    785785
    786786    DateInstance* thisDateObj = asDateInstance(thisValue);
    787787    double milli = thisDateObj->internalNumber();
    788788    if (isnan(milli))
    789         return jsNaN(exec);
     789        return JSValue::encode(jsNaN(exec));
    790790
    791791    double secs = floor(milli / msPerSecond);
    792792    double ms = milli - secs * msPerSecond;
    793     return jsNumber(exec, ms);
    794 }
    795 
    796 JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec)
    797 {
    798     JSValue thisValue = exec->hostThisValue();
    799     if (!thisValue.inherits(&DateInstance::info))
    800         return throwError(exec, TypeError);
     793    return JSValue::encode(jsNumber(exec, ms));
     794}
     795
     796EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec)
     797{
     798    JSValue thisValue = exec->hostThisValue();
     799    if (!thisValue.inherits(&DateInstance::info))
     800        return JSValue::encode(throwError(exec, TypeError));
    801801
    802802    DateInstance* thisDateObj = asDateInstance(thisValue);
    803803    double milli = thisDateObj->internalNumber();
    804804    if (isnan(milli))
    805         return jsNaN(exec);
     805        return JSValue::encode(jsNaN(exec));
    806806
    807807    double secs = floor(milli / msPerSecond);
    808808    double ms = milli - secs * msPerSecond;
    809     return jsNumber(exec, ms);
    810 }
    811 
    812 JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec)
    813 {
    814     JSValue thisValue = exec->hostThisValue();
    815     if (!thisValue.inherits(&DateInstance::info))
    816         return throwError(exec, TypeError);
    817 
    818     DateInstance* thisDateObj = asDateInstance(thisValue);
    819 
    820     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    821     if (!gregorianDateTime)
    822         return jsNaN(exec);
    823     return jsNumber(exec, -gregorianDateTime->utcOffset / minutesPerHour);
    824 }
    825 
    826 JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec)
    827 {
    828     JSValue thisValue = exec->hostThisValue();
    829     if (!thisValue.inherits(&DateInstance::info))
    830         return throwError(exec, TypeError);
     809    return JSValue::encode(jsNumber(exec, ms));
     810}
     811
     812EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec)
     813{
     814    JSValue thisValue = exec->hostThisValue();
     815    if (!thisValue.inherits(&DateInstance::info))
     816        return JSValue::encode(throwError(exec, TypeError));
     817
     818    DateInstance* thisDateObj = asDateInstance(thisValue);
     819
     820    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     821    if (!gregorianDateTime)
     822        return JSValue::encode(jsNaN(exec));
     823    return JSValue::encode(jsNumber(exec, -gregorianDateTime->utcOffset / minutesPerHour));
     824}
     825
     826EncodedJSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec)
     827{
     828    JSValue thisValue = exec->hostThisValue();
     829    if (!thisValue.inherits(&DateInstance::info))
     830        return JSValue::encode(throwError(exec, TypeError));
    831831
    832832    DateInstance* thisDateObj = asDateInstance(thisValue);
     
    835835    JSValue result = jsNumber(exec, milli);
    836836    thisDateObj->setInternalValue(result);
    837     return result;
     837    return JSValue::encode(result);
    838838}
    839839
     
    915915}
    916916
    917 JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState* exec)
     917EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState* exec)
    918918{
    919919    const bool inputIsUTC = false;
    920     return setNewValueFromTimeArgs(exec, 1, inputIsUTC);
    921 }
    922 
    923 JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState* exec)
     920    return JSValue::encode(setNewValueFromTimeArgs(exec, 1, inputIsUTC));
     921}
     922
     923EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState* exec)
    924924{
    925925    const bool inputIsUTC = true;
    926     return setNewValueFromTimeArgs(exec, 1, inputIsUTC);
    927 }
    928 
    929 JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState* exec)
     926    return JSValue::encode(setNewValueFromTimeArgs(exec, 1, inputIsUTC));
     927}
     928
     929EncodedJSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState* exec)
    930930{
    931931    const bool inputIsUTC = false;
    932     return setNewValueFromTimeArgs(exec, 2, inputIsUTC);
    933 }
    934 
    935 JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState* exec)
     932    return JSValue::encode(setNewValueFromTimeArgs(exec, 2, inputIsUTC));
     933}
     934
     935EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState* exec)
    936936{
    937937    const bool inputIsUTC = true;
    938     return setNewValueFromTimeArgs(exec, 2, inputIsUTC);
    939 }
    940 
    941 JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState* exec)
     938    return JSValue::encode(setNewValueFromTimeArgs(exec, 2, inputIsUTC));
     939}
     940
     941EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState* exec)
    942942{
    943943    const bool inputIsUTC = false;
    944     return setNewValueFromTimeArgs(exec, 3, inputIsUTC);
    945 }
    946 
    947 JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState* exec)
     944    return JSValue::encode(setNewValueFromTimeArgs(exec, 3, inputIsUTC));
     945}
     946
     947EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState* exec)
    948948{
    949949    const bool inputIsUTC = true;
    950     return setNewValueFromTimeArgs(exec, 3, inputIsUTC);
    951 }
    952 
    953 JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState* exec)
     950    return JSValue::encode(setNewValueFromTimeArgs(exec, 3, inputIsUTC));
     951}
     952
     953EncodedJSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState* exec)
    954954{
    955955    const bool inputIsUTC = false;
    956     return setNewValueFromTimeArgs(exec, 4, inputIsUTC);
    957 }
    958 
    959 JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState* exec)
     956    return JSValue::encode(setNewValueFromTimeArgs(exec, 4, inputIsUTC));
     957}
     958
     959EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState* exec)
    960960{
    961961    const bool inputIsUTC = true;
    962     return setNewValueFromTimeArgs(exec, 4, inputIsUTC);
    963 }
    964 
    965 JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState* exec)
     962    return JSValue::encode(setNewValueFromTimeArgs(exec, 4, inputIsUTC));
     963}
     964
     965EncodedJSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState* exec)
    966966{
    967967    const bool inputIsUTC = false;
    968     return setNewValueFromDateArgs(exec, 1, inputIsUTC);
    969 }
    970 
    971 JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState* exec)
     968    return JSValue::encode(setNewValueFromDateArgs(exec, 1, inputIsUTC));
     969}
     970
     971EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState* exec)
    972972{
    973973    const bool inputIsUTC = true;
    974     return setNewValueFromDateArgs(exec, 1, inputIsUTC);
    975 }
    976 
    977 JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState* exec)
     974    return JSValue::encode(setNewValueFromDateArgs(exec, 1, inputIsUTC));
     975}
     976
     977EncodedJSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState* exec)
    978978{
    979979    const bool inputIsUTC = false;
    980     return setNewValueFromDateArgs(exec, 2, inputIsUTC);
    981 }
    982 
    983 JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState* exec)
     980    return JSValue::encode(setNewValueFromDateArgs(exec, 2, inputIsUTC));
     981}
     982
     983EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState* exec)
    984984{
    985985    const bool inputIsUTC = true;
    986     return setNewValueFromDateArgs(exec, 2, inputIsUTC);
    987 }
    988 
    989 JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState* exec)
     986    return JSValue::encode(setNewValueFromDateArgs(exec, 2, inputIsUTC));
     987}
     988
     989EncodedJSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState* exec)
    990990{
    991991    const bool inputIsUTC = false;
    992     return setNewValueFromDateArgs(exec, 3, inputIsUTC);
    993 }
    994 
    995 JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState* exec)
     992    return JSValue::encode(setNewValueFromDateArgs(exec, 3, inputIsUTC));
     993}
     994
     995EncodedJSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState* exec)
    996996{
    997997    const bool inputIsUTC = true;
    998     return setNewValueFromDateArgs(exec, 3, inputIsUTC);
    999 }
    1000 
    1001 JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec)
    1002 {
    1003     JSValue thisValue = exec->hostThisValue();
    1004     if (!thisValue.inherits(&DateInstance::info))
    1005         return throwError(exec, TypeError);
     998    return JSValue::encode(setNewValueFromDateArgs(exec, 3, inputIsUTC));
     999}
     1000
     1001EncodedJSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec)
     1002{
     1003    JSValue thisValue = exec->hostThisValue();
     1004    if (!thisValue.inherits(&DateInstance::info))
     1005        return JSValue::encode(throwError(exec, TypeError));
    10061006
    10071007    DateInstance* thisDateObj = asDateInstance(thisValue);     
     
    10091009        JSValue result = jsNaN(exec);
    10101010        thisDateObj->setInternalValue(result);
    1011         return result;
     1011        return JSValue::encode(result);
    10121012    }
    10131013   
     
    10321032        JSValue result = jsNaN(exec);
    10331033        thisDateObj->setInternalValue(result);
    1034         return result;
     1034        return JSValue::encode(result);
    10351035    }
    10361036           
     
    10381038    JSValue result = jsNumber(exec, gregorianDateTimeToMS(exec, gregorianDateTime, ms, false));
    10391039    thisDateObj->setInternalValue(result);
    1040     return result;
    1041 }
    1042 
    1043 JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec)
    1044 {
    1045     JSValue thisValue = exec->hostThisValue();
    1046     if (!thisValue.inherits(&DateInstance::info))
    1047         return throwError(exec, TypeError);
    1048 
    1049     DateInstance* thisDateObj = asDateInstance(thisValue);
    1050 
    1051     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
    1052     if (!gregorianDateTime)
    1053         return jsNaN(exec);
     1040    return JSValue::encode(result);
     1041}
     1042
     1043EncodedJSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec)
     1044{
     1045    JSValue thisValue = exec->hostThisValue();
     1046    if (!thisValue.inherits(&DateInstance::info))
     1047        return JSValue::encode(throwError(exec, TypeError));
     1048
     1049    DateInstance* thisDateObj = asDateInstance(thisValue);
     1050
     1051    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     1052    if (!gregorianDateTime)
     1053        return JSValue::encode(jsNaN(exec));
    10541054
    10551055    // NOTE: IE returns the full year even in getYear.
    1056     return jsNumber(exec, gregorianDateTime->year);
    1057 }
    1058 
    1059 JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec)
     1056    return JSValue::encode(jsNumber(exec, gregorianDateTime->year));
     1057}
     1058
     1059EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec)
    10601060{
    10611061    JSValue thisValue = exec->hostThisValue();
    10621062    JSObject* object = thisValue.toThisObject(exec);
    10631063    if (exec->hadException())
    1064         return jsNull();
     1064        return JSValue::encode(jsNull());
    10651065   
    10661066    JSValue toISOValue = object->get(exec, exec->globalData().propertyNames->toISOString);
    10671067    if (exec->hadException())
    1068         return jsNull();
     1068        return JSValue::encode(jsNull());
    10691069
    10701070    CallData callData;
    1071     CallType callType = toISOValue.getCallData(callData);
     1071    CallType callType = getCallData(toISOValue, callData);
    10721072    if (callType == CallTypeNone)
    1073         return throwError(exec, TypeError, "toISOString is not a function");
     1073        return JSValue::encode(throwError(exec, TypeError, "toISOString is not a function"));
    10741074
    10751075    JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
    10761076    if (exec->hadException())
    1077         return jsNull();
     1077        return JSValue::encode(jsNull());
    10781078    if (result.isObject())
    1079         return throwError(exec, TypeError, "toISOString did not return a primitive value");
    1080     return result;
     1079        return JSValue::encode(throwError(exec, TypeError, "toISOString did not return a primitive value"));
     1080    return JSValue::encode(result);
    10811081}
    10821082
  • trunk/JavaScriptCore/runtime/ErrorConstructor.cpp

    r60392 r60631  
    5858}
    5959
    60 static JSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec)
     60static EncodedJSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec)
    6161{
    6262    ArgList args(exec);
    63     return constructError(exec, args);
     63    return JSValue::encode(constructError(exec, args));
    6464}
    6565
  • trunk/JavaScriptCore/runtime/ErrorPrototype.cpp

    r60392 r60631  
    3333ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype);
    3434
    35 static JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*);
     35static EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*);
    3636
    3737// ECMA 15.9.4
     
    4747}
    4848
    49 JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
     49EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
    5050{
    5151    JSObject* thisObj = exec->hostThisValue().toThisObject(exec);
     
    5757    if (!name.isUndefined()) {
    5858        if (!message.isUndefined())
    59             return jsMakeNontrivialString(exec, name.toString(exec), ": ", message.toString(exec));
    60         return jsNontrivialString(exec, name.toString(exec));
     59            return JSValue::encode(jsMakeNontrivialString(exec, name.toString(exec), ": ", message.toString(exec)));
     60        return JSValue::encode(jsNontrivialString(exec, name.toString(exec)));
    6161    }
    6262    if (!message.isUndefined())
    63         return jsMakeNontrivialString(exec, "Error: ", message.toString(exec));
    64     return jsNontrivialString(exec, "Error");
     63        return JSValue::encode(jsMakeNontrivialString(exec, "Error: ", message.toString(exec)));
     64    return JSValue::encode(jsNontrivialString(exec, "Error"));
    6565}
    6666
  • trunk/JavaScriptCore/runtime/FunctionConstructor.cpp

    r60392 r60631  
    5656}
    5757
    58 static JSValue JSC_HOST_CALL callFunctionConstructor(ExecState* exec)
     58static EncodedJSValue JSC_HOST_CALL callFunctionConstructor(ExecState* exec)
    5959{
    6060    ArgList args(exec);
    61     return constructFunction(exec, args);
     61    return JSValue::encode(constructFunction(exec, args));
    6262}
    6363
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r60392 r60631  
    3535ASSERT_CLASS_FITS_IN_CELL(FunctionPrototype);
    3636
    37 static JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*);
    38 static JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*);
    39 static JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*);
     37static EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*);
     38static EncodedJSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*);
     39static EncodedJSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*);
    4040
    4141FunctionPrototype::FunctionPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
     
    5454}
    5555
    56 static JSValue JSC_HOST_CALL callFunctionPrototype(ExecState*)
     56static EncodedJSValue JSC_HOST_CALL callFunctionPrototype(ExecState*)
    5757{
    58     return jsUndefined();
     58    return JSValue::encode(jsUndefined());
    5959}
    6060
     
    8484}
    8585
    86 JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec)
     86EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec)
    8787{
    8888    JSValue thisValue = exec->hostThisValue();
     
    9090        JSFunction* function = asFunction(thisValue);
    9191        if (function->isHostFunction())
    92             return jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n    [native code]\n}");
     92            return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n    [native code]\n}"));
    9393        FunctionExecutable* executable = function->jsExecutable();
    9494        UString sourceString = executable->source().toString();
    9595        insertSemicolonIfNeeded(sourceString);
    96         return jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString);
     96        return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString));
    9797    }
    9898
    9999    if (thisValue.inherits(&InternalFunction::info)) {
    100100        InternalFunction* function = asInternalFunction(thisValue);
    101         return jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n    [native code]\n}");
     101        return JSValue::encode(jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n    [native code]\n}"));
    102102    }
    103103
    104     return throwError(exec, TypeError);
     104    return JSValue::encode(throwError(exec, TypeError));
    105105}
    106106
    107 JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState* exec)
     107EncodedJSValue JSC_HOST_CALL functionProtoFuncApply(ExecState* exec)
    108108{
    109109    JSValue thisValue = exec->hostThisValue();
    110110    CallData callData;
    111     CallType callType = thisValue.getCallData(callData);
     111    CallType callType = getCallData(thisValue, callData);
    112112    if (callType == CallTypeNone)
    113         return throwError(exec, TypeError);
     113        return JSValue::encode(throwError(exec, TypeError));
    114114
    115115    JSValue array = exec->argument(1);
     
    118118    if (!array.isUndefinedOrNull()) {
    119119        if (!array.isObject())
    120             return throwError(exec, TypeError);
     120            return JSValue::encode(throwError(exec, TypeError));
    121121        if (asObject(array)->classInfo() == &Arguments::info)
    122122            asArguments(array)->fillArgList(exec, applyArgs);
     
    128128                applyArgs.append(asArray(array)->get(exec, i));
    129129        } else
    130             return throwError(exec, TypeError);
     130            return JSValue::encode(throwError(exec, TypeError));
    131131    }
    132132
    133     return call(exec, thisValue, callType, callData, exec->argument(0), applyArgs);
     133    return JSValue::encode(call(exec, thisValue, callType, callData, exec->argument(0), applyArgs));
    134134}
    135135
    136 JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState* exec)
     136EncodedJSValue JSC_HOST_CALL functionProtoFuncCall(ExecState* exec)
    137137{
    138138    JSValue thisValue = exec->hostThisValue();
    139139    CallData callData;
    140     CallType callType = thisValue.getCallData(callData);
     140    CallType callType = getCallData(thisValue, callData);
    141141    if (callType == CallTypeNone)
    142         return throwError(exec, TypeError);
     142        return JSValue::encode(throwError(exec, TypeError));
    143143
    144144    ArgList args(exec);
    145145    ArgList callArgs;
    146146    args.getSlice(1, callArgs);
    147     return call(exec, thisValue, callType, callData, exec->argument(0), callArgs);
     147    return JSValue::encode(call(exec, thisValue, callType, callData, exec->argument(0), callArgs));
    148148}
    149149
  • trunk/JavaScriptCore/runtime/JSCell.h

    r59941 r60631  
    2424#define JSCell_h
    2525
     26#include "CallData.h"
     27#include "ConstructData.h"
    2628#include "Collector.h"
    2729#include "JSImmediate.h"
     
    206208    }
    207209
    208     inline CallType JSValue::getCallData(CallData& callData)
    209     {
    210         CallType result = isCell() ? asCell()->getCallData(callData) : CallTypeNone;
    211         ASSERT(result == CallTypeNone || isValidCallee());
     210    inline CallType getCallData(JSValue value, CallData& callData)
     211    {
     212        CallType result = value.isCell() ? asCell(value)->getCallData(callData) : CallTypeNone;
     213        ASSERT(result == CallTypeNone || value.isValidCallee());
    212214        return result;
    213215    }
    214216
    215     inline ConstructType JSValue::getConstructData(ConstructData& constructData)
    216     {
    217         ConstructType result = isCell() ? asCell()->getConstructData(constructData) : ConstructTypeNone;
    218         ASSERT(result == ConstructTypeNone || isValidCallee());
     217    inline ConstructType getConstructData(JSValue value, ConstructData& constructData)
     218    {
     219        ConstructType result = value.isCell() ? asCell(value)->getConstructData(constructData) : ConstructTypeNone;
     220        ASSERT(result == ConstructTypeNone || value.isValidCallee());
    219221        return result;
    220222    }
  • trunk/JavaScriptCore/runtime/JSFunction.cpp

    r60392 r60631  
    4444namespace JSC {
    4545
    46 JSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState* exec)
     46EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState* exec)
    4747{
    4848    CodeBlock* codeBlock = exec->callerFrame()->codeBlock();
    4949    unsigned vPCIndex = codeBlock->bytecodeOffset(exec, exec->returnPC());
    5050    exec->setException(createNotAConstructorError(exec, exec->callee(), vPCIndex, codeBlock));
    51     return JSValue();
     51    return JSValue::encode(JSValue());
    5252}
    5353
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r60392 r60631  
    3636    class NativeExecutable;
    3737
    38     JSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState*);
     38    EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState*);
    3939
    4040    class JSFunction : public JSObjectWithGlobalObject {
  • trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r60392 r60631  
    273273}
    274274
    275 JSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
     275EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
    276276{
    277277    JSObject* thisObject = exec->hostThisValue().toThisObject(exec);
    278278    JSObject* unwrappedObject = thisObject->unwrappedObject();
    279279    if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee())
    280         return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated");
     280        return JSValue::encode(throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated"));
    281281
    282282    JSValue x = exec->argument(0);
    283283    if (!x.isString())
    284         return x;
     284        return JSValue::encode(x);
    285285
    286286    UString s = x.toString(exec);
     
    288288    LiteralParser preparser(exec, s, LiteralParser::NonStrictJSON);
    289289    if (JSValue parsedObject = preparser.tryLiteralParse())
    290         return parsedObject;
     290        return JSValue::encode(parsedObject);
    291291
    292292    RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s));
    293293    JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node());
    294294    if (error)
    295         return throwError(exec, error);
    296 
    297     return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot());
    298 }
    299 
    300 JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)
     295        return JSValue::encode(throwError(exec, error));
     296
     297    return JSValue::encode(exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot()));
     298}
     299
     300EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)
    301301{
    302302    JSValue value = exec->argument(0);
     
    304304
    305305    if (radix != 0 && radix != 10)
    306         return jsNumber(exec, parseInt(value.toString(exec), radix));
     306        return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix)));
    307307
    308308    if (value.isInt32())
    309         return value;
     309        return JSValue::encode(value);
    310310
    311311    if (value.isDouble()) {
    312312        double d = value.asDouble();
    313313        if (isfinite(d))
    314             return jsNumber(exec, (d > 0) ? floor(d) : ceil(d));
     314            return JSValue::encode(jsNumber(exec, (d > 0) ? floor(d) : ceil(d)));
    315315        if (isnan(d) || isinf(d))
    316             return jsNaN(exec);
    317         return jsNumber(exec, 0);
    318     }
    319 
    320     return jsNumber(exec, parseInt(value.toString(exec), radix));
    321 }
    322 
    323 JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec)
    324 {
    325     return jsNumber(exec, parseFloat(exec->argument(0).toString(exec)));
    326 }
    327 
    328 JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec)
    329 {
    330     return jsBoolean(isnan(exec->argument(0).toNumber(exec)));
    331 }
    332 
    333 JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec)
     316            return JSValue::encode(jsNaN(exec));
     317        return JSValue::encode(jsNumber(exec, 0));
     318    }
     319
     320    return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix)));
     321}
     322
     323EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec)
     324{
     325    return JSValue::encode(jsNumber(exec, parseFloat(exec->argument(0).toString(exec))));
     326}
     327
     328EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec)
     329{
     330    return JSValue::encode(jsBoolean(isnan(exec->argument(0).toNumber(exec))));
     331}
     332
     333EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec)
    334334{
    335335    double n = exec->argument(0).toNumber(exec);
    336     return jsBoolean(!isnan(n) && !isinf(n));
    337 }
    338 
    339 JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec)
     336    return JSValue::encode(jsBoolean(!isnan(n) && !isinf(n)));
     337}
     338
     339EncodedJSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec)
    340340{
    341341    static const char do_not_unescape_when_decoding_URI[] =
    342342        "#$&+,/:;=?@";
    343343
    344     return decode(exec, do_not_unescape_when_decoding_URI, true);
    345 }
    346 
    347 JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec)
    348 {
    349     return decode(exec, "", true);
    350 }
    351 
    352 JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec)
     344    return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true));
     345}
     346
     347EncodedJSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec)
     348{
     349    return JSValue::encode(decode(exec, "", true));
     350}
     351
     352EncodedJSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec)
    353353{
    354354    static const char do_not_escape_when_encoding_URI[] =
     
    358358        "!#$&'()*+,-./:;=?@_~";
    359359
    360     return encode(exec, do_not_escape_when_encoding_URI);
    361 }
    362 
    363 JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec)
     360    return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI));
     361}
     362
     363EncodedJSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec)
    364364{
    365365    static const char do_not_escape_when_encoding_URI_component[] =
     
    369369        "!'()*-._~";
    370370
    371     return encode(exec, do_not_escape_when_encoding_URI_component);
    372 }
    373 
    374 JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)
     371    return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI_component));
     372}
     373
     374EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)
    375375{
    376376    static const char do_not_escape[] =
     
    398398    }
    399399
    400     return builder.build(exec);
    401 }
    402 
    403 JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)
     400    return JSValue::encode(builder.build(exec));
     401}
     402
     403EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)
    404404{
    405405    StringBuilder builder;
     
    425425    }
    426426
    427     return jsString(exec, builder.build());
     427    return JSValue::encode(jsString(exec, builder.build()));
    428428}
    429429
    430430#ifndef NDEBUG
    431 JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec)
     431EncodedJSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec)
    432432{
    433433    CString string = exec->argument(0).toString(exec).UTF8String();
    434434    puts(string.data());
    435     return jsUndefined();
     435    return JSValue::encode(jsUndefined());
    436436}
    437437#endif
  • trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.h

    r60392 r60631  
    2525#define JSGlobalObjectFunctions_h
    2626
     27#include "JSValue.h"
    2728#include <wtf/unicode/Unicode.h>
    2829
     
    3233    class ExecState;
    3334    class JSObject;
    34     class JSValue;
    3535
    3636    // FIXME: These functions should really be in JSGlobalObject.cpp, but putting them there
    3737    // is a 0.5% reduction.
    3838
    39     JSValue JSC_HOST_CALL globalFuncEval(ExecState*);
    40     JSValue JSC_HOST_CALL globalFuncParseInt(ExecState*);
    41     JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState*);
    42     JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState*);
    43     JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState*);
    44     JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState*);
    45     JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState*);
    46     JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState*);
    47     JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState*);
    48     JSValue JSC_HOST_CALL globalFuncEscape(ExecState*);
    49     JSValue JSC_HOST_CALL globalFuncUnescape(ExecState*);
     39    EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState*);
     40    EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState*);
     41    EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState*);
     42    EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState*);
     43    EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState*);
     44    EncodedJSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState*);
     45    EncodedJSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState*);
     46    EncodedJSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState*);
     47    EncodedJSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState*);
     48    EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState*);
     49    EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState*);
    5050#ifndef NDEBUG
    51     JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState*);
     51    EncodedJSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState*);
    5252#endif
    5353
  • trunk/JavaScriptCore/runtime/JSONObject.cpp

    r60392 r60631  
    4242ASSERT_CLASS_FITS_IN_CELL(JSONObject);
    4343
    44 static JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*);
    45 static JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*);
     44static EncodedJSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*);
     45static EncodedJSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*);
    4646
    4747}
     
    840840
    841841// ECMA-262 v5 15.12.2
    842 JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec)
     842EncodedJSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec)
    843843{
    844844    if (!exec->argumentCount())
    845         return throwError(exec, GeneralError, "JSON.parse requires at least one parameter");
     845        return JSValue::encode(throwError(exec, GeneralError, "JSON.parse requires at least one parameter"));
    846846    JSValue value = exec->argument(0);
    847847    UString source = value.toString(exec);
    848848    if (exec->hadException())
    849         return jsNull();
     849        return JSValue::encode(jsNull());
    850850   
    851851    LiteralParser jsonParser(exec, source, LiteralParser::StrictJSON);
    852852    JSValue unfiltered = jsonParser.tryLiteralParse();
    853853    if (!unfiltered)
    854         return throwError(exec, SyntaxError, "Unable to parse JSON string");
     854        return JSValue::encode(throwError(exec, SyntaxError, "Unable to parse JSON string"));
    855855   
    856856    if (exec->argumentCount() < 2)
    857         return unfiltered;
     857        return JSValue::encode(unfiltered);
    858858   
    859859    JSValue function = exec->argument(1);
    860860    CallData callData;
    861     CallType callType = function.getCallData(callData);
     861    CallType callType = getCallData(function, callData);
    862862    if (callType == CallTypeNone)
    863         return unfiltered;
    864     return Walker(exec, asObject(function), callType, callData).walk(unfiltered);
     863        return JSValue::encode(unfiltered);
     864    return JSValue::encode(Walker(exec, asObject(function), callType, callData).walk(unfiltered));
    865865}
    866866
    867867// ECMA-262 v5 15.12.3
    868 JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec)
     868EncodedJSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec)
    869869{
    870870    if (!exec->argumentCount())
    871         return throwError(exec, GeneralError, "No input to stringify");
     871        return JSValue::encode(throwError(exec, GeneralError, "No input to stringify"));
    872872    JSValue value = exec->argument(0);
    873873    JSValue replacer = exec->argument(1);
    874874    JSValue space = exec->argument(2);
    875     return Stringifier(exec, replacer, space).stringify(value);
     875    return JSValue::encode(Stringifier(exec, replacer, space).stringify(value));
    876876}
    877877
  • trunk/JavaScriptCore/runtime/JSObject.cpp

    r60390 r60631  
    225225    JSValue function = object->get(exec, propertyName);
    226226    CallData callData;
    227     CallType callType = function.getCallData(callData);
     227    CallType callType = getCallData(function, callData);
    228228    if (callType == CallTypeNone)
    229229        return exec->exception();
  • trunk/JavaScriptCore/runtime/JSValue.h

    r59941 r60631  
    2424#define JSValue_h
    2525
    26 #include "CallData.h"
    27 #include "ConstructData.h"
    2826#include <math.h>
    2927#include <stddef.h> // for size_t
     
    3634namespace JSC {
    3735
     36    class ExecState;
    3837    class Identifier;
    3938    class JSCell;
     
    144143        JSObject* getObject() const; // 0 if not an object
    145144
    146         CallType getCallData(CallData&);
    147         ConstructType getConstructData(ConstructData&);
    148 
    149145        // Extracting integer values.
    150146        bool getUInt32(uint32_t&) const;
  • trunk/JavaScriptCore/runtime/MathObject.cpp

    r60392 r60631  
    3535ASSERT_CLASS_FITS_IN_CELL(MathObject);
    3636
    37 static JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*);
    38 static JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*);
    39 static JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*);
    40 static JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*);
    41 static JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*);
    42 static JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*);
    43 static JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*);
    44 static JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*);
    45 static JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*);
    46 static JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*);
    47 static JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*);
    48 static JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*);
    49 static JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*);
    50 static JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*);
    51 static JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*);
    52 static JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*);
    53 static JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*);
    54 static JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*);
     37static EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*);
     38static EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*);
     39static EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*);
     40static EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*);
     41static EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*);
     42static EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*);
     43static EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*);
     44static EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*);
     45static EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*);
     46static EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*);
     47static EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*);
     48static EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*);
     49static EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*);
     50static EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*);
     51static EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*);
     52static EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*);
     53static EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*);
     54static EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*);
    5555
    5656}
     
    114114// ------------------------------ Functions --------------------------------
    115115
    116 JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec)
    117 {
    118     return jsNumber(exec, fabs(exec->argument(0).toNumber(exec)));
    119 }
    120 
    121 JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec)
    122 {
    123     return jsDoubleNumber(exec, acos(exec->argument(0).toNumber(exec)));
    124 }
    125 
    126 JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec)
    127 {
    128     return jsDoubleNumber(exec, asin(exec->argument(0).toNumber(exec)));
    129 }
    130 
    131 JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec)
    132 {
    133     return jsDoubleNumber(exec, atan(exec->argument(0).toNumber(exec)));
    134 }
    135 
    136 JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec)
    137 {
    138     return jsDoubleNumber(exec, atan2(exec->argument(0).toNumber(exec), exec->argument(1).toNumber(exec)));
    139 }
    140 
    141 JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec)
    142 {
    143     return jsNumber(exec, ceil(exec->argument(0).toNumber(exec)));
    144 }
    145 
    146 JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec)
    147 {
    148     return jsDoubleNumber(exec, cos(exec->argument(0).toNumber(exec)));
    149 }
    150 
    151 JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec)
    152 {
    153     return jsDoubleNumber(exec, exp(exec->argument(0).toNumber(exec)));
    154 }
    155 
    156 JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec)
    157 {
    158     return jsNumber(exec, floor(exec->argument(0).toNumber(exec)));
    159 }
    160 
    161 JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec)
    162 {
    163     return jsDoubleNumber(exec, log(exec->argument(0).toNumber(exec)));
    164 }
    165 
    166 JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec)
     116EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec)
     117{
     118    return JSValue::encode(jsNumber(exec, fabs(exec->argument(0).toNumber(exec))));
     119}
     120
     121EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec)
     122{
     123    return JSValue::encode(jsDoubleNumber(exec, acos(exec->argument(0).toNumber(exec))));
     124}
     125
     126EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec)
     127{
     128    return JSValue::encode(jsDoubleNumber(exec, asin(exec->argument(0).toNumber(exec))));
     129}
     130
     131EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec)
     132{
     133    return JSValue::encode(jsDoubleNumber(exec, atan(exec->argument(0).toNumber(exec))));
     134}
     135
     136EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec)
     137{
     138    return JSValue::encode(jsDoubleNumber(exec, atan2(exec->argument(0).toNumber(exec), exec->argument(1).toNumber(exec))));
     139}
     140
     141EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec)
     142{
     143    return JSValue::encode(jsNumber(exec, ceil(exec->argument(0).toNumber(exec))));
     144}
     145
     146EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec)
     147{
     148    return JSValue::encode(jsDoubleNumber(exec, cos(exec->argument(0).toNumber(exec))));
     149}
     150
     151EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec)
     152{
     153    return JSValue::encode(jsDoubleNumber(exec, exp(exec->argument(0).toNumber(exec))));
     154}
     155
     156EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec)
     157{
     158    return JSValue::encode(jsNumber(exec, floor(exec->argument(0).toNumber(exec))));
     159}
     160
     161EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec)
     162{
     163    return JSValue::encode(jsDoubleNumber(exec, log(exec->argument(0).toNumber(exec))));
     164}
     165
     166EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec)
    167167{
    168168    unsigned argsCount = exec->argumentCount();
     
    177177            result = val;
    178178    }
    179     return jsNumber(exec, result);
    180 }
    181 
    182 JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec)
     179    return JSValue::encode(jsNumber(exec, result));
     180}
     181
     182EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec)
    183183{
    184184    unsigned argsCount = exec->argumentCount();
     
    193193            result = val;
    194194    }
    195     return jsNumber(exec, result);
    196 }
    197 
    198 JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec)
     195    return JSValue::encode(jsNumber(exec, result));
     196}
     197
     198EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec)
    199199{
    200200    // ECMA 15.8.2.1.13
     
    204204
    205205    if (isnan(arg2))
    206         return jsNaN(exec);
     206        return JSValue::encode(jsNaN(exec));
    207207    if (isinf(arg2) && fabs(arg) == 1)
    208         return jsNaN(exec);
    209     return jsNumber(exec, pow(arg, arg2));
    210 }
    211 
    212 JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec)
    213 {
    214     return jsDoubleNumber(exec, exec->globalData().weakRandom.get());
    215 }
    216 
    217 JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec)
     208        return JSValue::encode(jsNaN(exec));
     209    return JSValue::encode(jsNumber(exec, pow(arg, arg2)));
     210}
     211
     212EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec)
     213{
     214    return JSValue::encode(jsDoubleNumber(exec, exec->globalData().weakRandom.get()));
     215}
     216
     217EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec)
    218218{
    219219    double arg = exec->argument(0).toNumber(exec);
    220220    double integer = ceil(arg);
    221     return jsNumber(exec, integer - (integer - arg > 0.5));
    222 }
    223 
    224 JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec)
    225 {
    226     return exec->globalData().cachedSin(exec, exec->argument(0).toNumber(exec));
    227 }
    228 
    229 JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec)
    230 {
    231     return jsDoubleNumber(exec, sqrt(exec->argument(0).toNumber(exec)));
    232 }
    233 
    234 JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec)
    235 {
    236     return jsDoubleNumber(exec, tan(exec->argument(0).toNumber(exec)));
     221    return JSValue::encode(jsNumber(exec, integer - (integer - arg > 0.5)));
     222}
     223
     224EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec)
     225{
     226    return JSValue::encode(exec->globalData().cachedSin(exec, exec->argument(0).toNumber(exec)));
     227}
     228
     229EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec)
     230{
     231    return JSValue::encode(jsDoubleNumber(exec, sqrt(exec->argument(0).toNumber(exec))));
     232}
     233
     234EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec)
     235{
     236    return JSValue::encode(jsDoubleNumber(exec, tan(exec->argument(0).toNumber(exec))));
    237237}
    238238
  • trunk/JavaScriptCore/runtime/NativeErrorConstructor.cpp

    r60392 r60631  
    6363}
    6464   
    65 static JSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState* exec)
     65static EncodedJSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState* exec)
    6666{
    6767    ArgList args(exec);
    68     return static_cast<NativeErrorConstructor*>(exec->callee())->construct(exec, args);
     68    return JSValue::encode(static_cast<NativeErrorConstructor*>(exec->callee())->construct(exec, args));
    6969}
    7070
  • trunk/JavaScriptCore/runtime/NumberConstructor.cpp

    r60392 r60631  
    116116
    117117// ECMA 15.7.2
    118 static JSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec)
     118static EncodedJSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec)
    119119{
    120     return jsNumber(exec, !exec->argumentCount() ? 0 : exec->argument(0).toNumber(exec));
     120    return JSValue::encode(jsNumber(exec, !exec->argumentCount() ? 0 : exec->argument(0).toNumber(exec)));
    121121}
    122122
  • trunk/JavaScriptCore/runtime/NumberPrototype.cpp

    r60392 r60631  
    3939ASSERT_CLASS_FITS_IN_CELL(NumberPrototype);
    4040
    41 static JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState*);
    42 static JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState*);
    43 static JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState*);
    44 static JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState*);
    45 static JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState*);
    46 static JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState*);
     41static EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(ExecState*);
     42static EncodedJSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState*);
     43static EncodedJSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState*);
     44static EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState*);
     45static EncodedJSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState*);
     46static EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState*);
    4747
    4848// ECMA 15.7.4
     
    138138}
    139139
    140 JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec)
    141 {
    142     JSValue thisValue = exec->hostThisValue();
    143     JSValue v = thisValue.getJSNumber();
    144     if (!v)
    145         return throwError(exec, TypeError);
     140EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec)
     141{
     142    JSValue thisValue = exec->hostThisValue();
     143    JSValue v = thisValue.getJSNumber();
     144    if (!v)
     145        return JSValue::encode(throwError(exec, TypeError));
    146146
    147147    JSValue radixValue = exec->argument(0);
     
    155155
    156156    if (radix == 10)
    157         return jsString(exec, v.toString(exec));
     157        return JSValue::encode(jsString(exec, v.toString(exec)));
    158158
    159159    static const char* const digits = "0123456789abcdefghijklmnopqrstuvwxyz";
     
    165165            if (static_cast<unsigned>(x) < 36) { // Exclude negatives
    166166                JSGlobalData* globalData = &exec->globalData();
    167                 return globalData->smallStrings.singleCharacterString(globalData, digits[x]);
     167                return JSValue::encode(globalData->smallStrings.singleCharacterString(globalData, digits[x]));
    168168            }
    169169        }
     
    171171
    172172    if (radix < 2 || radix > 36)
    173         return throwError(exec, RangeError, "toString() radix argument must be between 2 and 36");
     173        return JSValue::encode(throwError(exec, RangeError, "toString() radix argument must be between 2 and 36"));
    174174
    175175    // INT_MAX results in 1024 characters left of the dot with radix 2
     
    180180    double x = v.uncheckedGetNumber();
    181181    if (isnan(x) || isinf(x))
    182         return jsString(exec, UString::from(x));
     182        return JSValue::encode(jsString(exec, UString::from(x)));
    183183
    184184    bool isNegative = x < 0.0;
     
    219219    ASSERT(p < s + sizeof(s));
    220220
    221     return jsString(exec, startOfResultString);
    222 }
    223 
    224 JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec)
     221    return JSValue::encode(jsString(exec, startOfResultString));
     222}
     223
     224EncodedJSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec)
    225225{
    226226    JSValue thisValue = exec->hostThisValue();
     
    229229    JSValue v = thisValue.getJSNumber();
    230230    if (!v)
    231         return throwError(exec, TypeError);
    232 
    233     return jsString(exec, v.toString(exec));
    234 }
    235 
    236 JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec)
    237 {
    238     JSValue thisValue = exec->hostThisValue();
    239     JSValue v = thisValue.getJSNumber();
    240     if (!v)
    241         return throwError(exec, TypeError);
    242 
    243     return v;
    244 }
    245 
    246 JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec)
    247 {
    248     JSValue thisValue = exec->hostThisValue();
    249     JSValue v = thisValue.getJSNumber();
    250     if (!v)
    251         return throwError(exec, TypeError);
     231        return JSValue::encode(throwError(exec, TypeError));
     232
     233    return JSValue::encode(jsString(exec, v.toString(exec)));
     234}
     235
     236EncodedJSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec)
     237{
     238    JSValue thisValue = exec->hostThisValue();
     239    JSValue v = thisValue.getJSNumber();
     240    if (!v)
     241        return JSValue::encode(throwError(exec, TypeError));
     242
     243    return JSValue::encode(v);
     244}
     245
     246EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec)
     247{
     248    JSValue thisValue = exec->hostThisValue();
     249    JSValue v = thisValue.getJSNumber();
     250    if (!v)
     251        return JSValue::encode(throwError(exec, TypeError));
    252252
    253253    JSValue fractionDigits = exec->argument(0);
    254254    double df = fractionDigits.toInteger(exec);
    255255    if (!(df >= 0 && df <= 20))
    256         return throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20");
     256        return JSValue::encode(throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20"));
    257257    int f = static_cast<int>(df);
    258258
    259259    double x = v.uncheckedGetNumber();
    260260    if (isnan(x))
    261         return jsNontrivialString(exec, "NaN");
     261        return JSValue::encode(jsNontrivialString(exec, "NaN"));
    262262
    263263    UString s;
     
    272272
    273273    if (x >= pow(10.0, 21.0))
    274         return jsString(exec, makeString(s, UString::from(x)));
     274        return JSValue::encode(jsString(exec, makeString(s, UString::from(x))));
    275275
    276276    const double tenToTheF = pow(10.0, f);
     
    294294
    295295    if (kMinusf < static_cast<int>(m.size()))
    296         return jsString(exec, makeString(s, m.substr(0, kMinusf), ".", m.substr(kMinusf)));
    297     return jsString(exec, makeString(s, m.substr(0, kMinusf)));
     296        return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf), ".", m.substr(kMinusf))));
     297    return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf))));
    298298}
    299299
     
    336336}
    337337
    338 JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec)
    339 {
    340     JSValue thisValue = exec->hostThisValue();
    341     JSValue v = thisValue.getJSNumber();
    342     if (!v)
    343         return throwError(exec, TypeError);
     338EncodedJSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec)
     339{
     340    JSValue thisValue = exec->hostThisValue();
     341    JSValue v = thisValue.getJSNumber();
     342    if (!v)
     343        return JSValue::encode(throwError(exec, TypeError));
    344344
    345345    double x = v.uncheckedGetNumber();
    346346
    347347    if (isnan(x) || isinf(x))
    348         return jsString(exec, UString::from(x));
     348        return JSValue::encode(jsString(exec, UString::from(x)));
    349349
    350350    JSValue fractionalDigitsValue = exec->argument(0);
    351351    double df = fractionalDigitsValue.toInteger(exec);
    352352    if (!(df >= 0 && df <= 20))
    353         return throwError(exec, RangeError, "toExponential() argument must between 0 and 20");
     353        return JSValue::encode(throwError(exec, RangeError, "toExponential() argument must between 0 and 20"));
    354354    int fractionalDigits = static_cast<int>(df);
    355355    bool includeAllDigits = fractionalDigitsValue.isUndefined();
     
    372372
    373373    if (isnan(x))
    374         return jsNontrivialString(exec, "NaN");
     374        return JSValue::encode(jsNontrivialString(exec, "NaN"));
    375375
    376376    if (x == -0.0) // (-0.0).toExponential() should print as 0 instead of -0
     
    406406    ASSERT(i <= 80);
    407407
    408     return jsString(exec, buf);
    409 }
    410 
    411 JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec)
    412 {
    413     JSValue thisValue = exec->hostThisValue();
    414     JSValue v = thisValue.getJSNumber();
    415     if (!v)
    416         return throwError(exec, TypeError);
     408    return JSValue::encode(jsString(exec, buf));
     409}
     410
     411EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec)
     412{
     413    JSValue thisValue = exec->hostThisValue();
     414    JSValue v = thisValue.getJSNumber();
     415    if (!v)
     416        return JSValue::encode(throwError(exec, TypeError));
    417417
    418418    double doublePrecision = exec->argument(0).toIntegerPreserveNaN(exec);
    419419    double x = v.uncheckedGetNumber();
    420420    if (exec->argument(0).isUndefined() || isnan(x) || isinf(x))
    421         return jsString(exec, v.toString(exec));
     421        return JSValue::encode(jsString(exec, v.toString(exec)));
    422422
    423423    UString s;
     
    429429
    430430    if (!(doublePrecision >= 1 && doublePrecision <= 21)) // true for NaN
    431         return throwError(exec, RangeError, "toPrecision() argument must be between 1 and 21");
     431        return JSValue::encode(throwError(exec, RangeError, "toPrecision() argument must be between 1 and 21"));
    432432    int precision = static_cast<int>(doublePrecision);
    433433
     
    459459                m = makeString(m.substr(0, 1), ".", m.substr(1));
    460460            if (e >= 0)
    461                 return jsMakeNontrivialString(exec, s, m, "e+", UString::from(e));
    462             return jsMakeNontrivialString(exec, s, m, "e-", UString::from(-e));
     461                return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e+", UString::from(e)));
     462            return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e-", UString::from(-e)));
    463463        }
    464464    } else {
     
    468468
    469469    if (e == precision - 1)
    470         return jsString(exec, makeString(s, m));
     470        return JSValue::encode(jsString(exec, makeString(s, m)));
    471471    if (e >= 0) {
    472472        if (e + 1 < static_cast<int>(m.size()))
    473             return jsString(exec, makeString(s, m.substr(0, e + 1), ".", m.substr(e + 1)));
    474         return jsString(exec, makeString(s, m));
    475     }
    476     return jsMakeNontrivialString(exec, s, "0.", charSequence('0', -(e + 1)), m);
     473            return JSValue::encode(jsString(exec, makeString(s, m.substr(0, e + 1), ".", m.substr(e + 1))));
     474        return JSValue::encode(jsString(exec, makeString(s, m)));
     475    }
     476    return JSValue::encode(jsMakeNontrivialString(exec, s, "0.", charSequence('0', -(e + 1)), m));
    477477}
    478478
  • trunk/JavaScriptCore/runtime/ObjectConstructor.cpp

    r60392 r60631  
    3535ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor);
    3636
    37 static JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*);
    38 static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*);
    39 static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*);
    40 static JSValue JSC_HOST_CALL objectConstructorKeys(ExecState*);
    41 static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*);
    42 static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*);
    43 static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*);
     37static EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*);
     38static EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*);
     39static EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*);
     40static EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState*);
     41static EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*);
     42static EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*);
     43static EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState*);
    4444
    4545ObjectConstructor::ObjectConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure)
     
    8181}
    8282
    83 static JSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec)
     83static EncodedJSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec)
    8484{
    8585    ArgList args(exec);
    86     return constructObject(exec, args);
     86    return JSValue::encode(constructObject(exec, args));
    8787}
    8888
     
    9393}
    9494
    95 JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec)
    96 {
    97     if (!exec->argument(0).isObject())
    98         return throwError(exec, TypeError, "Requested prototype of a value that is not an object.");
    99     return asObject(exec->argument(0))->prototype();
    100 }
    101 
    102 JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec)
    103 {
    104     if (!exec->argument(0).isObject())
    105         return throwError(exec, TypeError, "Requested property descriptor of a value that is not an object.");
     95EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec)
     96{
     97    if (!exec->argument(0).isObject())
     98        return JSValue::encode(throwError(exec, TypeError, "Requested prototype of a value that is not an object."));
     99    return JSValue::encode(asObject(exec->argument(0))->prototype());
     100}
     101
     102EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec)
     103{
     104    if (!exec->argument(0).isObject())
     105        return JSValue::encode(throwError(exec, TypeError, "Requested property descriptor of a value that is not an object."));
    106106    UString propertyName = exec->argument(1).toString(exec);
    107107    if (exec->hadException())
    108         return jsNull();
     108        return JSValue::encode(jsNull());
    109109    JSObject* object = asObject(exec->argument(0));
    110110    PropertyDescriptor descriptor;
    111111    if (!object->getOwnPropertyDescriptor(exec, Identifier(exec, propertyName), descriptor))
    112         return jsUndefined();
     112        return JSValue::encode(jsUndefined());
    113113    if (exec->hadException())
    114         return jsUndefined();
     114        return JSValue::encode(jsUndefined());
    115115
    116116    JSObject* description = constructEmptyObject(exec);
     
    126126    description->putDirect(exec->propertyNames().configurable, jsBoolean(descriptor.configurable()), 0);
    127127
    128     return description;
     128    return JSValue::encode(description);
    129129}
    130130
    131131// FIXME: Use the enumeration cache.
    132 JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec)
    133 {
    134     if (!exec->argument(0).isObject())
    135         return throwError(exec, TypeError, "Requested property names of a value that is not an object.");
     132EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec)
     133{
     134    if (!exec->argument(0).isObject())
     135        return JSValue::encode(throwError(exec, TypeError, "Requested property names of a value that is not an object."));
    136136    PropertyNameArray properties(exec);
    137137    asObject(exec->argument(0))->getOwnPropertyNames(exec, properties, IncludeDontEnumProperties);
     
    140140    for (size_t i = 0; i < numProperties; i++)
    141141        names->push(exec, jsOwnedString(exec, properties[i].ustring()));
    142     return names;
     142    return JSValue::encode(names);
    143143}
    144144
    145145// FIXME: Use the enumeration cache.
    146 JSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec)
    147 {
    148     if (!exec->argument(0).isObject())
    149         return throwError(exec, TypeError, "Requested keys of a value that is not an object.");
     146EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec)
     147{
     148    if (!exec->argument(0).isObject())
     149        return JSValue::encode(throwError(exec, TypeError, "Requested keys of a value that is not an object."));
    150150    PropertyNameArray properties(exec);
    151151    asObject(exec->argument(0))->getOwnPropertyNames(exec, properties);
     
    154154    for (size_t i = 0; i < numProperties; i++)
    155155        keys->push(exec, jsOwnedString(exec, properties[i].ustring()));
    156     return keys;
     156    return JSValue::encode(keys);
    157157}
    158158
     
    202202        if (!get.isUndefined()) {
    203203            CallData callData;
    204             if (get.getCallData(callData) == CallTypeNone) {
     204            if (getCallData(get, callData) == CallTypeNone) {
    205205                throwError(exec, TypeError, "Getter must be a function.");
    206206                return false;
     
    218218        if (!set.isUndefined()) {
    219219            CallData callData;
    220             if (set.getCallData(callData) == CallTypeNone) {
     220            if (getCallData(set, callData) == CallTypeNone) {
    221221                throwError(exec, TypeError, "Setter must be a function.");
    222222                return false;
     
    243243}
    244244
    245 JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec)
    246 {
    247     if (!exec->argument(0).isObject())
    248         return throwError(exec, TypeError, "Properties can only be defined on Objects.");
     245EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec)
     246{
     247    if (!exec->argument(0).isObject())
     248        return JSValue::encode(throwError(exec, TypeError, "Properties can only be defined on Objects."));
    249249    JSObject* O = asObject(exec->argument(0));
    250250    UString propertyName = exec->argument(1).toString(exec);
    251251    if (exec->hadException())
    252         return jsNull();
     252        return JSValue::encode(jsNull());
    253253    PropertyDescriptor descriptor;
    254254    if (!toPropertyDescriptor(exec, exec->argument(2), descriptor))
    255         return jsNull();
     255        return JSValue::encode(jsNull());
    256256    ASSERT((descriptor.attributes() & (Getter | Setter)) || (!descriptor.isAccessorDescriptor()));
    257257    ASSERT(!exec->hadException());
    258258    O->defineOwnProperty(exec, Identifier(exec, propertyName), descriptor, true);
    259     return O;
     259    return JSValue::encode(O);
    260260}
    261261
     
    294294}
    295295
    296 JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec)
    297 {
    298     if (!exec->argument(0).isObject())
    299         return throwError(exec, TypeError, "Properties can only be defined on Objects.");
     296EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec)
     297{
     298    if (!exec->argument(0).isObject())
     299        return JSValue::encode(throwError(exec, TypeError, "Properties can only be defined on Objects."));
    300300    if (!exec->argument(1).isObject())
    301         return throwError(exec, TypeError, "Property descriptor list must be an Object.");
    302     return defineProperties(exec, asObject(exec->argument(0)), asObject(exec->argument(1)));
    303 }
    304 
    305 JSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec)
     301        return JSValue::encode(throwError(exec, TypeError, "Property descriptor list must be an Object."));
     302    return JSValue::encode(defineProperties(exec, asObject(exec->argument(0)), asObject(exec->argument(1))));
     303}
     304
     305EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec)
    306306{
    307307    if (!exec->argument(0).isObject() && !exec->argument(0).isNull())
    308         return throwError(exec, TypeError, "Object prototype may only be an Object or null.");
     308        return JSValue::encode(throwError(exec, TypeError, "Object prototype may only be an Object or null."));
    309309    JSObject* newObject = constructEmptyObject(exec);
    310310    newObject->setPrototype(exec->argument(0));
    311311    if (exec->argument(1).isUndefined())
    312         return newObject;
     312        return JSValue::encode(newObject);
    313313    if (!exec->argument(1).isObject())
    314         return throwError(exec, TypeError, "Property descriptor list must be an Object.");
    315     return defineProperties(exec, newObject, asObject(exec->argument(1)));
     314        return JSValue::encode(throwError(exec, TypeError, "Property descriptor list must be an Object."));
     315    return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1))));
    316316}
    317317
  • trunk/JavaScriptCore/runtime/ObjectPrototype.cpp

    r60392 r60631  
    3232ASSERT_CLASS_FITS_IN_CELL(ObjectPrototype);
    3333
    34 static JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState*);
    35 static JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState*);
    36 static JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState*);
    37 static JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState*);
    38 static JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState*);
    39 static JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState*);
    40 static JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*);
    41 static JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*);
    42 static JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*);
     34static EncodedJSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState*);
     35static EncodedJSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState*);
     36static EncodedJSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState*);
     37static EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState*);
     38static EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState*);
     39static EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState*);
     40static EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*);
     41static EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*);
     42static EncodedJSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*);
    4343
    4444ObjectPrototype::ObjectPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure)
     
    8282// ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7
    8383
    84 JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec)
     84EncodedJSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec)
    8585{
    8686    JSValue thisValue = exec->hostThisValue();
    87     return thisValue.toThisObject(exec);
     87    return JSValue::encode(thisValue.toThisObject(exec));
    8888}
    8989
    90 JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec)
     90EncodedJSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec)
    9191{
    9292    JSValue thisValue = exec->hostThisValue();
    93     return jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec))));
     93    return JSValue::encode(jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec)))));
    9494}
    9595
    96 JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec)
     96EncodedJSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec)
    9797{
    9898    JSValue thisValue = exec->hostThisValue();
     
    100100
    101101    if (!exec->argument(0).isObject())
    102         return jsBoolean(false);
     102        return JSValue::encode(jsBoolean(false));
    103103
    104104    JSValue v = asObject(exec->argument(0))->prototype();
     
    106106    while (true) {
    107107        if (!v.isObject())
    108             return jsBoolean(false);
     108            return JSValue::encode(jsBoolean(false));
    109109        if (v == thisObj)
    110             return jsBoolean(true);
     110            return JSValue::encode(jsBoolean(true));
    111111        v = asObject(v)->prototype();
    112112    }
    113113}
    114114
    115 JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState* exec)
     115EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState* exec)
    116116{
    117117    JSValue thisValue = exec->hostThisValue();
    118118    CallData callData;
    119     if (exec->argument(1).getCallData(callData) == CallTypeNone)
    120         return throwError(exec, SyntaxError, "invalid getter usage");
     119    if (getCallData(exec->argument(1), callData) == CallTypeNone)
     120        return JSValue::encode(throwError(exec, SyntaxError, "invalid getter usage"));
    121121    thisValue.toThisObject(exec)->defineGetter(exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1)));
    122     return jsUndefined();
     122    return JSValue::encode(jsUndefined());
    123123}
    124124
    125 JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec)
     125EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec)
    126126{
    127127    JSValue thisValue = exec->hostThisValue();
    128128    CallData callData;
    129     if (exec->argument(1).getCallData(callData) == CallTypeNone)
    130         return throwError(exec, SyntaxError, "invalid setter usage");
     129    if (getCallData(exec->argument(1), callData) == CallTypeNone)
     130        return JSValue::encode(throwError(exec, SyntaxError, "invalid setter usage"));
    131131    thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1)));
    132     return jsUndefined();
     132    return JSValue::encode(jsUndefined());
    133133}
    134134
    135 JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec)
     135EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec)
    136136{
    137137    JSValue thisValue = exec->hostThisValue();
    138     return thisValue.toThisObject(exec)->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec)));
     138    return JSValue::encode(thisValue.toThisObject(exec)->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec))));
    139139}
    140140
    141 JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec)
     141EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec)
    142142{
    143143    JSValue thisValue = exec->hostThisValue();
    144     return thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec)));
     144    return JSValue::encode(thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec))));
    145145}
    146146
    147 JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec)
     147EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec)
    148148{
    149149    JSValue thisValue = exec->hostThisValue();
    150     return jsBoolean(thisValue.toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec))));
     150    return JSValue::encode(jsBoolean(thisValue.toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec)))));
    151151}
    152152
    153 JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec)
     153EncodedJSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec)
    154154{
    155155    JSValue thisValue = exec->hostThisValue();
    156     return thisValue.toThisJSString(exec);
     156    return JSValue::encode(thisValue.toThisJSString(exec));
    157157}
    158158
    159 JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec)
     159EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec)
    160160{
    161161    JSValue thisValue = exec->hostThisValue();
    162     return jsMakeNontrivialString(exec, "[object ", thisValue.toThisObject(exec)->className(), "]");
     162    return JSValue::encode(jsMakeNontrivialString(exec, "[object ", thisValue.toThisObject(exec)->className(), "]"));
    163163}
    164164
  • trunk/JavaScriptCore/runtime/ObjectPrototype.h

    r60392 r60631  
    3737    };
    3838
    39     JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState*);
     39    EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState*);
    4040
    4141} // namespace JSC
  • trunk/JavaScriptCore/runtime/RegExpConstructor.cpp

    r60392 r60631  
    320320
    321321// ECMA 15.10.3
    322 static JSValue JSC_HOST_CALL callRegExpConstructor(ExecState* exec)
     322static EncodedJSValue JSC_HOST_CALL callRegExpConstructor(ExecState* exec)
    323323{
    324324    ArgList args(exec);
    325     return constructRegExp(exec, args);
     325    return JSValue::encode(constructRegExp(exec, args));
    326326}
    327327
  • trunk/JavaScriptCore/runtime/RegExpObject.cpp

    r60392 r60631  
    126126}
    127127
    128 static JSValue JSC_HOST_CALL callRegExpObject(ExecState* exec)
     128static EncodedJSValue JSC_HOST_CALL callRegExpObject(ExecState* exec)
    129129{
    130     return asRegExpObject(exec->callee())->exec(exec);
     130    return JSValue::encode(asRegExpObject(exec->callee())->exec(exec));
    131131}
    132132
  • trunk/JavaScriptCore/runtime/RegExpPrototype.cpp

    r60392 r60631  
    3939ASSERT_CLASS_FITS_IN_CELL(RegExpPrototype);
    4040
    41 static JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*);
    42 static JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*);
    43 static JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*);
    44 static JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*);
     41static EncodedJSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*);
     42static EncodedJSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*);
     43static EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*);
     44static EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*);
    4545
    4646// ECMA 15.10.5
     
    5858
    5959// ------------------------------ Functions ---------------------------
    60    
    61 JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState* exec)
     60
     61EncodedJSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState* exec)
    6262{
    6363    JSValue thisValue = exec->hostThisValue();
    6464    if (!thisValue.inherits(&RegExpObject::info))
    65         return throwError(exec, TypeError);
    66     return asRegExpObject(thisValue)->test(exec);
     65        return JSValue::encode(throwError(exec, TypeError));
     66    return JSValue::encode(asRegExpObject(thisValue)->test(exec));
    6767}
    6868
    69 JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState* exec)
     69EncodedJSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState* exec)
    7070{
    7171    JSValue thisValue = exec->hostThisValue();
    7272    if (!thisValue.inherits(&RegExpObject::info))
    73         return throwError(exec, TypeError);
    74     return asRegExpObject(thisValue)->exec(exec);
     73        return JSValue::encode(throwError(exec, TypeError));
     74    return JSValue::encode(asRegExpObject(thisValue)->exec(exec));
    7575}
    7676
    77 JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)
     77EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)
    7878{
    7979    JSValue thisValue = exec->hostThisValue();
    8080    if (!thisValue.inherits(&RegExpObject::info))
    81         return throwError(exec, TypeError);
     81        return JSValue::encode(throwError(exec, TypeError));
    8282
    8383    RefPtr<RegExp> regExp;
     
    8787    if (arg0.inherits(&RegExpObject::info)) {
    8888        if (!arg1.isUndefined())
    89             return throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another.");
     89            return JSValue::encode(throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another."));
    9090        regExp = asRegExpObject(arg0)->regExp();
    9191    } else {
     
    9696
    9797    if (!regExp->isValid())
    98         return throwError(exec, SyntaxError, makeString("Invalid regular expression: ", regExp->errorMessage()));
     98        return JSValue::encode(throwError(exec, SyntaxError, makeString("Invalid regular expression: ", regExp->errorMessage())));
    9999
    100100    asRegExpObject(thisValue)->setRegExp(regExp.release());
    101101    asRegExpObject(thisValue)->setLastIndex(0);
    102     return jsUndefined();
     102    return JSValue::encode(jsUndefined());
    103103}
    104104
    105 JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)
     105EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)
    106106{
    107107    JSValue thisValue = exec->hostThisValue();
    108108    if (!thisValue.inherits(&RegExpObject::info)) {
    109109        if (thisValue.inherits(&RegExpPrototype::info))
    110             return jsNontrivialString(exec, "//");
    111         return throwError(exec, TypeError);
     110            return JSValue::encode(jsNontrivialString(exec, "//"));
     111        return JSValue::encode(throwError(exec, TypeError));
    112112    }
    113113
     
    122122    UString source = asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec);
    123123    // If source is empty, use "/(?:)/" to avoid colliding with comment syntax
    124     return jsMakeNontrivialString(exec, "/", source.size() ? source : UString("(?:)"), postfix);
     124    return JSValue::encode(jsMakeNontrivialString(exec, "/", source.size() ? source : UString("(?:)"), postfix));
    125125}
    126126
  • trunk/JavaScriptCore/runtime/StringConstructor.cpp

    r60394 r60631  
    4141}
    4242
    43 static JSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec)
     43static EncodedJSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec)
    4444{
    4545    if (LIKELY(exec->argumentCount() == 1))
    46         return jsSingleCharacterString(exec, exec->argument(0).toUInt32(exec));
    47     return stringFromCharCodeSlowCase(exec);
     46        return JSValue::encode(jsSingleCharacterString(exec, exec->argument(0).toUInt32(exec)));
     47    return JSValue::encode(stringFromCharCodeSlowCase(exec));
    4848}
    4949
     
    8181
    8282// ECMA 15.5.1
    83 static JSValue JSC_HOST_CALL callStringConstructor(ExecState* exec)
     83static EncodedJSValue JSC_HOST_CALL callStringConstructor(ExecState* exec)
    8484{
    8585    if (!exec->argumentCount())
    86         return jsEmptyString(exec);
    87     return jsString(exec, exec->argument(0).toString(exec));
     86        return JSValue::encode(jsEmptyString(exec));
     87    return JSValue::encode(jsString(exec, exec->argument(0).toString(exec)));
    8888}
    8989
  • trunk/JavaScriptCore/runtime/StringPrototype.cpp

    r60392 r60631  
    4646ASSERT_CLASS_FITS_IN_CELL(StringPrototype);
    4747
    48 static JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState*);
    49 static JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState*);
    50 static JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState*);
    51 static JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState*);
    52 static JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState*);
    53 static JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState*);
    54 static JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState*);
    55 static JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*);
    56 static JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState*);
    57 static JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*);
    58 static JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState*);
    59 static JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState*);
    60 static JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState*);
    61 static JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState*);
    62 static JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState*);
    63 static JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState*);
    64 static JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState*);
    65 static JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState*);
    66 static JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState*);
    67 static JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState*);
    68 static JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState*);
    69 static JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState*);
    70 static JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState*);
    71 static JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState*);
    72 static JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState*);
    73 static JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState*);
    74 static JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState*);
    75 static JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*);
    76 static JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState*);
    77 static JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState*);
    78 static JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState*);
    79 static JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState*);
     48static EncodedJSValue JSC_HOST_CALL stringProtoFuncToString(ExecState*);
     49static EncodedJSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState*);
     50static EncodedJSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState*);
     51static EncodedJSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState*);
     52static EncodedJSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState*);
     53static EncodedJSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState*);
     54static EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState*);
     55static EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*);
     56static EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState*);
     57static EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*);
     58static EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState*);
     59static EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState*);
     60static EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState*);
     61static EncodedJSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState*);
     62static EncodedJSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState*);
     63static EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState*);
     64static EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState*);
     65static EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState*);
     66static EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState*);
     67static EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState*);
     68static EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState*);
     69static EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState*);
     70static EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState*);
     71static EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState*);
     72static EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState*);
     73static EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState*);
     74static EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState*);
     75static EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*);
     76static EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState*);
     77static EncodedJSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState*);
     78static EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState*);
     79static EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState*);
    8080
    8181}
     
    287287}
    288288
    289 JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
     289EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
    290290{
    291291    JSValue thisValue = exec->hostThisValue();
     
    296296    UString replacementString;
    297297    CallData callData;
    298     CallType callType = replacement.getCallData(callData);
     298    CallType callType = getCallData(replacement, callData);
    299299    if (callType == CallTypeNone)
    300300        replacementString = replacement.toString(exec);
     
    303303        const UString& source = sourceVal->value(exec);
    304304        if (exec->hadException())
    305             return JSValue();
     305            return JSValue::encode(JSValue());
    306306        RegExp* reg = asRegExpObject(pattern)->regExp();
    307307        bool global = reg->global();
     
    322322            CachedCall cachedCall(exec, func, argCount, exec->exceptionSlot());
    323323            if (exec->hadException())
    324                 return jsNull();
     324                return JSValue::encode(jsNull());
    325325            while (true) {
    326326                int matchIndex;
     
    414414
    415415        if (!lastIndex && replacements.isEmpty())
    416             return sourceVal;
     416            return JSValue::encode(sourceVal);
    417417
    418418        if (static_cast<unsigned>(lastIndex) < source.size())
    419419            sourceRanges.append(StringRange(lastIndex, source.size() - lastIndex));
    420420
    421         return jsSpliceSubstringsWithSeparators(exec, sourceVal, source, sourceRanges.data(), sourceRanges.size(), replacements.data(), replacements.size());
     421        return JSValue::encode(jsSpliceSubstringsWithSeparators(exec, sourceVal, source, sourceRanges.data(), sourceRanges.size(), replacements.data(), replacements.size()));
    422422    }
    423423
     
    426426    UString patternString = pattern.toString(exec);
    427427    if (patternString.size() == 1 && callType == CallTypeNone)
    428         return sourceVal->replaceCharacter(exec, patternString[0], replacementString);
     428        return JSValue::encode(sourceVal->replaceCharacter(exec, patternString[0], replacementString));
    429429   
    430430    const UString& source = sourceVal->value(exec);
     
    432432
    433433    if (matchPos == UString::NotFound)
    434         return sourceVal;
     434        return JSValue::encode(sourceVal);
    435435
    436436    int matchLen = patternString.size();
     
    446446    size_t matchEnd = matchPos + matchLen;
    447447    int ovector[2] = { matchPos, matchEnd };
    448     return jsString(exec, source.substr(0, matchPos), substituteBackreferences(replacementString, source, ovector, 0), source.substr(matchEnd));
    449 }
    450 
    451 JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec)
     448    return JSValue::encode(jsString(exec, source.substr(0, matchPos), substituteBackreferences(replacementString, source, ovector, 0), source.substr(matchEnd)));
     449}
     450
     451EncodedJSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec)
    452452{
    453453    JSValue thisValue = exec->hostThisValue();
     
    455455
    456456    if (thisValue.isString())
    457         return thisValue;
     457        return JSValue::encode(thisValue);
    458458
    459459    if (thisValue.inherits(&StringObject::info))
    460         return asStringObject(thisValue)->internalValue();
    461 
    462     return throwError(exec, TypeError);
    463 }
    464 
    465 JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec)
     460        return JSValue::encode(asStringObject(thisValue)->internalValue());
     461
     462    return JSValue::encode(throwError(exec, TypeError));
     463}
     464
     465EncodedJSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec)
    466466{
    467467    JSValue thisValue = exec->hostThisValue();
     
    472472        uint32_t i = a0.asUInt32();
    473473        if (i < len)
    474             return jsSingleCharacterSubstring(exec, s, i);
    475         return jsEmptyString(exec);
     474            return JSValue::encode(jsSingleCharacterSubstring(exec, s, i));
     475        return JSValue::encode(jsEmptyString(exec));
    476476    }
    477477    double dpos = a0.toInteger(exec);
    478478    if (dpos >= 0 && dpos < len)
    479         return jsSingleCharacterSubstring(exec, s, static_cast<unsigned>(dpos));
    480     return jsEmptyString(exec);
    481 }
    482 
    483 JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec)
     479        return JSValue::encode(jsSingleCharacterSubstring(exec, s, static_cast<unsigned>(dpos)));
     480    return JSValue::encode(jsEmptyString(exec));
     481}
     482
     483EncodedJSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec)
    484484{
    485485    JSValue thisValue = exec->hostThisValue();
     
    490490        uint32_t i = a0.asUInt32();
    491491        if (i < len)
    492             return jsNumber(exec, s.data()[i]);
    493         return jsNaN(exec);
     492            return JSValue::encode(jsNumber(exec, s.data()[i]));
     493        return JSValue::encode(jsNaN(exec));
    494494    }
    495495    double dpos = a0.toInteger(exec);
    496496    if (dpos >= 0 && dpos < len)
    497         return jsNumber(exec, s[static_cast<int>(dpos)]);
    498     return jsNaN(exec);
    499 }
    500 
    501 JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState* exec)
     497        return JSValue::encode(jsNumber(exec, s[static_cast<int>(dpos)]));
     498    return JSValue::encode(jsNaN(exec));
     499}
     500
     501EncodedJSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState* exec)
    502502{
    503503    JSValue thisValue = exec->hostThisValue();
    504504    if (thisValue.isString() && (exec->argumentCount() == 1)) {
    505505        JSValue v = exec->argument(0);
    506         return v.isString()
     506        return JSValue::encode(v.isString()
    507507            ? jsString(exec, asString(thisValue), asString(v))
    508             : jsString(exec, asString(thisValue), v.toString(exec));
    509     }
    510 
    511     return jsString(exec, thisValue);
    512 }
    513 
    514 JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec)
     508            : jsString(exec, asString(thisValue), v.toString(exec)));
     509    }
     510
     511    return JSValue::encode(jsString(exec, thisValue));
     512}
     513
     514EncodedJSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec)
    515515{
    516516    JSValue thisValue = exec->hostThisValue();
     
    537537    unsigned result = s.find(u2, pos);
    538538    if (result == UString::NotFound)
    539         return jsNumber(exec, -1);
    540     return jsNumber(exec, result);
    541 }
    542 
    543 JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec)
     539        return JSValue::encode(jsNumber(exec, -1));
     540    return JSValue::encode(jsNumber(exec, result));
     541}
     542
     543EncodedJSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec)
    544544{
    545545    JSValue thisValue = exec->hostThisValue();
     
    564564    unsigned result = s.rfind(u2, static_cast<unsigned>(dpos));
    565565    if (result == UString::NotFound)
    566         return jsNumber(exec, -1);
    567     return jsNumber(exec, result);
    568 }
    569 
    570 JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec)
     566        return JSValue::encode(jsNumber(exec, -1));
     567    return JSValue::encode(jsNumber(exec, result));
     568}
     569
     570EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec)
    571571{
    572572    JSValue thisValue = exec->hostThisValue();
     
    595595        // case without 'g' flag is handled like RegExp.prototype.exec
    596596        if (pos < 0)
    597             return jsNull();
    598         return regExpConstructor->arrayOfMatches(exec);
     597            return JSValue::encode(jsNull());
     598        return JSValue::encode(regExpConstructor->arrayOfMatches(exec));
    599599    }
    600600
     
    614614        // Null instead of an empty array, because this matches
    615615        // other browsers and because Null is a false value.
    616         return jsNull();
    617     }
    618 
    619     return constructArray(exec, list);
    620 }
    621 
    622 JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec)
     616        return JSValue::encode(jsNull());
     617    }
     618
     619    return JSValue::encode(constructArray(exec, list));
     620}
     621
     622EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec)
    623623{
    624624    JSValue thisValue = exec->hostThisValue();
     
    643643    int matchLength = 0;
    644644    regExpConstructor->performMatch(reg.get(), u, 0, pos, matchLength);
    645     return jsNumber(exec, pos);
    646 }
    647 
    648 JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec)
     645    return JSValue::encode(jsNumber(exec, pos));
     646}
     647
     648EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec)
    649649{
    650650    JSValue thisValue = exec->hostThisValue();
     
    665665        if (to > len)
    666666            to = len;
    667         return jsSubstring(exec, s, static_cast<unsigned>(from), static_cast<unsigned>(to) - static_cast<unsigned>(from));
    668     }
    669 
    670     return jsEmptyString(exec);
    671 }
    672 
    673 JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec)
     667        return JSValue::encode(jsSubstring(exec, s, static_cast<unsigned>(from), static_cast<unsigned>(to) - static_cast<unsigned>(from)));
     668    }
     669
     670    return JSValue::encode(jsEmptyString(exec));
     671}
     672
     673EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec)
    674674{
    675675    JSValue thisValue = exec->hostThisValue();
     
    687687        if (s.isEmpty() && reg->match(s, 0) >= 0) {
    688688            // empty string matched by regexp -> empty array
    689             return result;
     689            return JSValue::encode(result);
    690690        }
    691691        unsigned pos = 0;
     
    714714            if (s.isEmpty()) {
    715715                // empty separator matches empty string -> empty array
    716                 return result;
     716                return JSValue::encode(result);
    717717            }
    718718            while (i != limit && p0 < s.size() - 1)
     
    732732        result->put(exec, i++, jsSubstring(exec, s, p0, s.size() - p0));
    733733
    734     return result;
    735 }
    736 
    737 JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)
     734    return JSValue::encode(result);
     735}
     736
     737EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)
    738738{
    739739    JSValue thisValue = exec->hostThisValue();
     
    747747    double length = a1.isUndefined() ? len : a1.toInteger(exec);
    748748    if (start >= len || length <= 0)
    749         return jsEmptyString(exec);
     749        return JSValue::encode(jsEmptyString(exec));
    750750    if (start < 0) {
    751751        start += len;
     
    755755    if (start + length > len)
    756756        length = len - start;
    757     return jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(length));
    758 }
    759 
    760 JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec)
     757    return JSValue::encode(jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(length)));
     758}
     759
     760EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec)
    761761{
    762762    JSValue thisValue = exec->hostThisValue();
     
    787787        start = temp;
    788788    }
    789     return jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(end) - static_cast<unsigned>(start));
    790 }
    791 
    792 JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec)
     789    return JSValue::encode(jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(end) - static_cast<unsigned>(start)));
     790}
     791
     792EncodedJSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec)
    793793{
    794794    JSValue thisValue = exec->hostThisValue();
     
    798798    int sSize = s.size();
    799799    if (!sSize)
    800         return sVal;
     800        return JSValue::encode(sVal);
    801801
    802802    const UChar* sData = s.data();
     
    810810    }
    811811    if (!(ored & ~0x7f))
    812         return jsString(exec, UString::adopt(buffer));
     812        return JSValue::encode(jsString(exec, UString::adopt(buffer)));
    813813
    814814    bool error;
     
    818818        length = Unicode::toLower(buffer.data(), length, sData, sSize, &error);
    819819        if (error)
    820             return sVal;
     820            return JSValue::encode(sVal);
    821821    }
    822822    if (length == sSize) {
    823823        if (memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0)
    824             return sVal;
     824            return JSValue::encode(sVal);
    825825    } else
    826826        buffer.resize(length);
    827     return jsString(exec, UString::adopt(buffer));
    828 }
    829 
    830 JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec)
     827    return JSValue::encode(jsString(exec, UString::adopt(buffer)));
     828}
     829
     830EncodedJSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec)
    831831{
    832832    JSValue thisValue = exec->hostThisValue();
     
    836836    int sSize = s.size();
    837837    if (!sSize)
    838         return sVal;
     838        return JSValue::encode(sVal);
    839839
    840840    const UChar* sData = s.data();
     
    848848    }
    849849    if (!(ored & ~0x7f))
    850         return jsString(exec, UString::adopt(buffer));
     850        return JSValue::encode(jsString(exec, UString::adopt(buffer)));
    851851
    852852    bool error;
     
    856856        length = Unicode::toUpper(buffer.data(), length, sData, sSize, &error);
    857857        if (error)
    858             return sVal;
     858            return JSValue::encode(sVal);
    859859    }
    860860    if (length == sSize) {
    861861        if (memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0)
    862             return sVal;
     862            return JSValue::encode(sVal);
    863863    } else
    864864        buffer.resize(length);
    865     return jsString(exec, UString::adopt(buffer));
    866 }
    867 
    868 JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec)
     865    return JSValue::encode(jsString(exec, UString::adopt(buffer)));
     866}
     867
     868EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec)
    869869{
    870870    JSValue thisValue = exec->hostThisValue();
    871871    if (exec->argumentCount() < 1)
    872       return jsNumber(exec, 0);
    873 
    874     UString s = thisValue.toThisString(exec);
    875     JSValue a0 = exec->argument(0);
    876     return jsNumber(exec, localeCompare(s, a0.toString(exec)));
    877 }
    878 
    879 JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec)
    880 {
    881     JSValue thisValue = exec->hostThisValue();
    882     UString s = thisValue.toThisString(exec);
    883     return jsMakeNontrivialString(exec, "<big>", s, "</big>");
    884 }
    885 
    886 JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec)
    887 {
    888     JSValue thisValue = exec->hostThisValue();
    889     UString s = thisValue.toThisString(exec);
    890     return jsMakeNontrivialString(exec, "<small>", s, "</small>");
    891 }
    892 
    893 JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec)
    894 {
    895     JSValue thisValue = exec->hostThisValue();
    896     UString s = thisValue.toThisString(exec);
    897     return jsMakeNontrivialString(exec, "<blink>", s, "</blink>");
    898 }
    899 
    900 JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec)
    901 {
    902     JSValue thisValue = exec->hostThisValue();
    903     UString s = thisValue.toThisString(exec);
    904     return jsMakeNontrivialString(exec, "<b>", s, "</b>");
    905 }
    906 
    907 JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec)
    908 {
    909     JSValue thisValue = exec->hostThisValue();
    910     UString s = thisValue.toThisString(exec);
    911     return jsMakeNontrivialString(exec, "<tt>", s, "</tt>");
    912 }
    913 
    914 JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec)
    915 {
    916     JSValue thisValue = exec->hostThisValue();
    917     UString s = thisValue.toThisString(exec);
    918     return jsMakeNontrivialString(exec, "<i>", s, "</i>");
    919 }
    920 
    921 JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec)
    922 {
    923     JSValue thisValue = exec->hostThisValue();
    924     UString s = thisValue.toThisString(exec);
    925     return jsMakeNontrivialString(exec, "<strike>", s, "</strike>");
    926 }
    927 
    928 JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec)
    929 {
    930     JSValue thisValue = exec->hostThisValue();
    931     UString s = thisValue.toThisString(exec);
    932     return jsMakeNontrivialString(exec, "<sub>", s, "</sub>");
    933 }
    934 
    935 JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec)
    936 {
    937     JSValue thisValue = exec->hostThisValue();
    938     UString s = thisValue.toThisString(exec);
    939     return jsMakeNontrivialString(exec, "<sup>", s, "</sup>");
    940 }
    941 
    942 JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec)
    943 {
    944     JSValue thisValue = exec->hostThisValue();
    945     UString s = thisValue.toThisString(exec);
    946     JSValue a0 = exec->argument(0);
    947     return jsMakeNontrivialString(exec, "<font color=\"", a0.toString(exec), "\">", s, "</font>");
    948 }
    949 
    950 JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
     872      return JSValue::encode(jsNumber(exec, 0));
     873
     874    UString s = thisValue.toThisString(exec);
     875    JSValue a0 = exec->argument(0);
     876    return JSValue::encode(jsNumber(exec, localeCompare(s, a0.toString(exec))));
     877}
     878
     879EncodedJSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec)
     880{
     881    JSValue thisValue = exec->hostThisValue();
     882    UString s = thisValue.toThisString(exec);
     883    return JSValue::encode(jsMakeNontrivialString(exec, "<big>", s, "</big>"));
     884}
     885
     886EncodedJSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec)
     887{
     888    JSValue thisValue = exec->hostThisValue();
     889    UString s = thisValue.toThisString(exec);
     890    return JSValue::encode(jsMakeNontrivialString(exec, "<small>", s, "</small>"));
     891}
     892
     893EncodedJSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec)
     894{
     895    JSValue thisValue = exec->hostThisValue();
     896    UString s = thisValue.toThisString(exec);
     897    return JSValue::encode(jsMakeNontrivialString(exec, "<blink>", s, "</blink>"));
     898}
     899
     900EncodedJSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec)
     901{
     902    JSValue thisValue = exec->hostThisValue();
     903    UString s = thisValue.toThisString(exec);
     904    return JSValue::encode(jsMakeNontrivialString(exec, "<b>", s, "</b>"));
     905}
     906
     907EncodedJSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec)
     908{
     909    JSValue thisValue = exec->hostThisValue();
     910    UString s = thisValue.toThisString(exec);
     911    return JSValue::encode(jsMakeNontrivialString(exec, "<tt>", s, "</tt>"));
     912}
     913
     914EncodedJSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec)
     915{
     916    JSValue thisValue = exec->hostThisValue();
     917    UString s = thisValue.toThisString(exec);
     918    return JSValue::encode(jsMakeNontrivialString(exec, "<i>", s, "</i>"));
     919}
     920
     921EncodedJSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec)
     922{
     923    JSValue thisValue = exec->hostThisValue();
     924    UString s = thisValue.toThisString(exec);
     925    return JSValue::encode(jsMakeNontrivialString(exec, "<strike>", s, "</strike>"));
     926}
     927
     928EncodedJSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec)
     929{
     930    JSValue thisValue = exec->hostThisValue();
     931    UString s = thisValue.toThisString(exec);
     932    return JSValue::encode(jsMakeNontrivialString(exec, "<sub>", s, "</sub>"));
     933}
     934
     935EncodedJSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec)
     936{
     937    JSValue thisValue = exec->hostThisValue();
     938    UString s = thisValue.toThisString(exec);
     939    return JSValue::encode(jsMakeNontrivialString(exec, "<sup>", s, "</sup>"));
     940}
     941
     942EncodedJSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec)
     943{
     944    JSValue thisValue = exec->hostThisValue();
     945    UString s = thisValue.toThisString(exec);
     946    JSValue a0 = exec->argument(0);
     947    return JSValue::encode(jsMakeNontrivialString(exec, "<font color=\"", a0.toString(exec), "\">", s, "</font>"));
     948}
     949
     950EncodedJSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec)
    951951{
    952952    JSValue thisValue = exec->hostThisValue();
     
    961961        PassRefPtr<UStringImpl> impl = UStringImpl::tryCreateUninitialized(bufferSize, buffer);
    962962        if (!impl)
    963             return jsUndefined();
     963            return JSValue::encode(jsUndefined());
    964964        buffer[0] = '<';
    965965        buffer[1] = 'f';
     
    985985        buffer[20 + stringSize] = 't';
    986986        buffer[21 + stringSize] = '>';
    987         return jsNontrivialString(exec, impl);
    988     }
    989 
    990     return jsMakeNontrivialString(exec, "<font size=\"", a0.toString(exec), "\">", s, "</font>");
    991 }
    992 
    993 JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec)
    994 {
    995     JSValue thisValue = exec->hostThisValue();
    996     UString s = thisValue.toThisString(exec);
    997     JSValue a0 = exec->argument(0);
    998     return jsMakeNontrivialString(exec, "<a name=\"", a0.toString(exec), "\">", s, "</a>");
    999 }
    1000 
    1001 JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
     987        return JSValue::encode(jsNontrivialString(exec, impl));
     988    }
     989
     990    return JSValue::encode(jsMakeNontrivialString(exec, "<font size=\"", a0.toString(exec), "\">", s, "</font>"));
     991}
     992
     993EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec)
     994{
     995    JSValue thisValue = exec->hostThisValue();
     996    UString s = thisValue.toThisString(exec);
     997    JSValue a0 = exec->argument(0);
     998    return JSValue::encode(jsMakeNontrivialString(exec, "<a name=\"", a0.toString(exec), "\">", s, "</a>"));
     999}
     1000
     1001EncodedJSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec)
    10021002{
    10031003    JSValue thisValue = exec->hostThisValue();
     
    10121012    PassRefPtr<UStringImpl> impl = UStringImpl::tryCreateUninitialized(bufferSize, buffer);
    10131013    if (!impl)
    1014         return jsUndefined();
     1014        return JSValue::encode(jsUndefined());
    10151015    buffer[0] = '<';
    10161016    buffer[1] = 'a';
     
    10301030    buffer[13 + linkTextSize + stringSize] = 'a';
    10311031    buffer[14 + linkTextSize + stringSize] = '>';
    1032     return jsNontrivialString(exec, impl);
     1032    return JSValue::encode(jsNontrivialString(exec, impl));
    10331033}
    10341034
     
    10641064}
    10651065
    1066 JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState* exec)
    1067 {
    1068     JSValue thisValue = exec->hostThisValue();
    1069     return trimString(exec, thisValue, TrimLeft | TrimRight);
    1070 }
    1071 
    1072 JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState* exec)
    1073 {
    1074     JSValue thisValue = exec->hostThisValue();
    1075     return trimString(exec, thisValue, TrimLeft);
    1076 }
    1077 
    1078 JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState* exec)
    1079 {
    1080     JSValue thisValue = exec->hostThisValue();
    1081     return trimString(exec, thisValue, TrimRight);
     1066EncodedJSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState* exec)
     1067{
     1068    JSValue thisValue = exec->hostThisValue();
     1069    return JSValue::encode(trimString(exec, thisValue, TrimLeft | TrimRight));
     1070}
     1071
     1072EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState* exec)
     1073{
     1074    JSValue thisValue = exec->hostThisValue();
     1075    return JSValue::encode(trimString(exec, thisValue, TrimLeft));
     1076}
     1077
     1078EncodedJSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState* exec)
     1079{
     1080    JSValue thisValue = exec->hostThisValue();
     1081    return JSValue::encode(trimString(exec, thisValue, TrimRight));
    10821082}
    10831083   
Note: See TracChangeset for help on using the changeset viewer.