diff options
Diffstat (limited to 'JavaScriptCore/runtime')
49 files changed, 854 insertions, 724 deletions
diff --git a/JavaScriptCore/runtime/ArgList.h b/JavaScriptCore/runtime/ArgList.h index 8e1fdbe..cd563a2 100644 --- a/JavaScriptCore/runtime/ArgList.h +++ b/JavaScriptCore/runtime/ArgList.h @@ -22,6 +22,7 @@ #ifndef ArgList_h #define ArgList_h +#include "CallFrame.h" #include "Register.h" #include <wtf/HashSet.h> #include <wtf/Noncopyable.h> @@ -187,6 +188,12 @@ namespace JSC { { } + ArgList(ExecState* exec) + : m_args(reinterpret_cast<JSValue*>(&exec[exec->hostThisRegister() + 1])) + , m_argCount(exec->argumentCount()) + { + } + ArgList(JSValue* args, unsigned argCount) : m_args(args) , m_argCount(argCount) diff --git a/JavaScriptCore/runtime/Arguments.h b/JavaScriptCore/runtime/Arguments.h index 5b8e51c..169c6f6 100644 --- a/JavaScriptCore/runtime/Arguments.h +++ b/JavaScriptCore/runtime/Arguments.h @@ -119,10 +119,10 @@ namespace JSC { ALWAYS_INLINE void Arguments::getArgumentsData(CallFrame* callFrame, JSFunction*& function, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc) { - function = callFrame->callee(); + function = asFunction(callFrame->callee()); int numParameters = function->jsExecutable()->parameterCount(); - argc = callFrame->argumentCount(); + argc = callFrame->argumentCountIncludingThis(); if (argc <= numParameters) argv = callFrame->registers() - RegisterFile::CallFrameHeaderSize - numParameters; @@ -174,9 +174,9 @@ namespace JSC { : JSObject(callFrame->lexicalGlobalObject()->argumentsStructure()) , d(new ArgumentsData) { - ASSERT(!callFrame->callee()->jsExecutable()->parameterCount()); + ASSERT(!asFunction(callFrame->callee())->jsExecutable()->parameterCount()); - unsigned numArguments = callFrame->argumentCount() - 1; + unsigned numArguments = callFrame->argumentCount(); d->numParameters = 0; d->numArguments = numArguments; @@ -194,7 +194,7 @@ namespace JSC { d->extraArguments = extraArguments; - d->callee = callFrame->callee(); + d->callee = asFunction(callFrame->callee()); d->overrodeLength = false; d->overrodeCallee = false; } diff --git a/JavaScriptCore/runtime/ArrayConstructor.cpp b/JavaScriptCore/runtime/ArrayConstructor.cpp index c159be4..674d00a 100644 --- a/JavaScriptCore/runtime/ArrayConstructor.cpp +++ b/JavaScriptCore/runtime/ArrayConstructor.cpp @@ -35,7 +35,7 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor); -static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*); ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure) : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, arrayPrototype->classInfo()->className)) @@ -76,8 +76,9 @@ ConstructType ArrayConstructor::getConstructData(ConstructData& constructData) return ConstructTypeHost; } -static JSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec) { + ArgList args(exec); return constructArrayWithSizeQuirk(exec, args); } @@ -89,9 +90,9 @@ CallType ArrayConstructor::getCallData(CallData& callData) return CallTypeHost; } -JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState* exec) { - return jsBoolean(args.at(0).inherits(&JSArray::info)); + return jsBoolean(exec->argument(0).inherits(&JSArray::info)); } } // namespace JSC diff --git a/JavaScriptCore/runtime/ArrayPrototype.cpp b/JavaScriptCore/runtime/ArrayPrototype.cpp index 70ce69f..c7dea3b 100644 --- a/JavaScriptCore/runtime/ArrayPrototype.cpp +++ b/JavaScriptCore/runtime/ArrayPrototype.cpp @@ -40,27 +40,27 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(ArrayPrototype); -static JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState*); +static JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*); } @@ -149,8 +149,9 @@ static void putProperty(ExecState* exec, JSObject* obj, const Identifier& proper obj->put(exec, propertyName, value, slot); } -JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); bool isRealArray = isJSArray(&exec->globalData(), thisValue); if (!isRealArray && !thisValue.inherits(&JSArray::info)) return throwError(exec, TypeError); @@ -208,8 +209,9 @@ JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec, JSObject*, JSValue return jsString(exec, UString::adopt(buffer)); } -JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSArray::info)) return throwError(exec, TypeError); JSObject* thisObj = asArray(thisValue); @@ -248,8 +250,9 @@ JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec, JSObject*, J return strBuffer.build(exec); } -JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; @@ -265,8 +268,8 @@ JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec, JSObject*, JSValue thi JSStringBuilder strBuffer; UString separator; - if (!args.at(0).isUndefined()) - separator = args.at(0).toString(exec); + if (!exec->argument(0).isUndefined()) + separator = exec->argument(0).toString(exec); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); unsigned k = 0; @@ -319,13 +322,14 @@ JSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec, JSObject*, JSValue thi return strBuffer.build(exec); } -JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSArray* arr = constructEmptyArray(exec); int n = 0; JSValue curArg = thisValue.toThisObject(exec); - ArgList::const_iterator it = args.begin(); - ArgList::const_iterator end = args.end(); + size_t i = 0; + size_t argCount = exec->argumentCount(); while (1) { if (curArg.inherits(&JSArray::info)) { unsigned length = curArg.get(exec, exec->propertyNames().length).toUInt32(exec); @@ -339,17 +343,18 @@ JSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState* exec, JSObject*, JSValue t arr->put(exec, n, curArg); n++; } - if (it == end) + if (i == argCount) break; - curArg = (*it); - ++it; + curArg = (exec->argument(i)); + ++i; } arr->setLength(n); return arr; } -JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (isJSArray(&exec->globalData(), thisValue)) return asArray(thisValue)->pop(); @@ -367,25 +372,27 @@ JSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec, JSObject*, JSValue this return result; } -JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec) { - if (isJSArray(&exec->globalData(), thisValue) && args.size() == 1) { + JSValue thisValue = exec->hostThisValue(); + if (isJSArray(&exec->globalData(), thisValue) && exec->argumentCount() == 1) { JSArray* array = asArray(thisValue); - array->push(exec, *args.begin()); + array->push(exec, exec->argument(0)); return jsNumber(exec, array->length()); } JSObject* thisObj = thisValue.toThisObject(exec); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); - for (unsigned n = 0; n < args.size(); n++) - thisObj->put(exec, length + n, args.at(n)); - length += args.size(); + for (unsigned n = 0; n < exec->argumentCount(); n++) + thisObj->put(exec, length + n, exec->argument(n)); + length += exec->argumentCount(); putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length)); return jsNumber(exec, length); } -JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); unsigned middle = length / 2; @@ -408,8 +415,9 @@ JSValue JSC_HOST_CALL arrayProtoFuncReverse(ExecState* exec, JSObject*, JSValue return thisObj; } -JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); JSValue result; @@ -431,8 +439,9 @@ JSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec, JSObject*, JSValue th return result; } -JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10 JSObject* thisObj = thisValue.toThisObject(exec); @@ -440,7 +449,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec, JSObject*, JSValue th // We return a new array JSArray* resObj = constructEmptyArray(exec); JSValue result = resObj; - double begin = args.at(0).toInteger(exec); + double begin = exec->argument(0).toInteger(exec); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); if (begin >= 0) { if (begin > length) @@ -451,10 +460,10 @@ JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec, JSObject*, JSValue th begin = 0; } double end; - if (args.at(1).isUndefined()) + if (exec->argument(1).isUndefined()) end = length; else { - end = args.at(1).toInteger(exec); + end = exec->argument(1).toInteger(exec); if (end < 0) { end += length; if (end < 0) @@ -476,11 +485,12 @@ JSValue JSC_HOST_CALL arrayProtoFuncSlice(ExecState* exec, JSObject*, JSValue th return result; } -JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); @@ -534,8 +544,9 @@ JSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec, JSObject*, JSValue thi return thisObj; } -JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); // 15.4.4.12 @@ -543,11 +554,11 @@ JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue t JSValue result = resObj; // FIXME: Firefox returns an empty array. - if (!args.size()) + if (!exec->argumentCount()) return jsUndefined(); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); - double relativeBegin = args.at(0).toInteger(exec); + double relativeBegin = exec->argument(0).toInteger(exec); unsigned begin; if (relativeBegin < 0) { relativeBegin += length; @@ -556,8 +567,8 @@ JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue t begin = std::min<unsigned>(static_cast<unsigned>(relativeBegin), length); unsigned deleteCount; - if (args.size() > 1) - deleteCount = std::min<int>(std::max<int>(args.at(1).toUInt32(exec), 0), length - begin); + if (exec->argumentCount() > 1) + deleteCount = std::min<int>(std::max<int>(exec->argument(1).toUInt32(exec), 0), length - begin); else deleteCount = length - begin; @@ -567,7 +578,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue t } resObj->setLength(deleteCount); - unsigned additionalArgs = std::max<int>(args.size() - 2, 0); + unsigned additionalArgs = std::max<int>(exec->argumentCount() - 2, 0); if (additionalArgs != deleteCount) { if (additionalArgs < deleteCount) { for (unsigned k = begin; k < length - deleteCount; ++k) { @@ -588,19 +599,20 @@ JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue t } } for (unsigned k = 0; k < additionalArgs; ++k) - thisObj->put(exec, k + begin, args.at(k + 2)); + thisObj->put(exec, k + begin, exec->argument(k + 2)); putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length - deleteCount + additionalArgs)); return result; } -JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); // 15.4.4.13 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); - unsigned nrArgs = args.size(); + unsigned nrArgs = exec->argumentCount(); if (nrArgs) { for (unsigned k = length; k > 0; --k) { if (JSValue v = getProperty(exec, thisObj, k - 1)) @@ -610,23 +622,24 @@ JSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec, JSObject*, JSValue } } for (unsigned k = 0; k < nrArgs; ++k) - thisObj->put(exec, k, args.at(k)); + thisObj->put(exec, k, exec->argument(k)); JSValue result = jsNumber(exec, length + nrArgs); putProperty(exec, thisObj, exec->propertyNames().length, result); return result; } -JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); - JSObject* applyThis = args.at(1).isUndefinedOrNull() ? exec->globalThisValue() : args.at(1).toObject(exec); + JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); JSArray* resultArray = constructEmptyArray(exec); unsigned filterIndex = 0; @@ -674,17 +687,18 @@ JSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec, JSObject*, JSValue t return resultArray; } -JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); - JSObject* applyThis = args.at(1).isUndefinedOrNull() ? exec->globalThisValue() : args.at(1).toObject(exec); + JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); @@ -731,17 +745,18 @@ JSValue JSC_HOST_CALL arrayProtoFuncMap(ExecState* exec, JSObject*, JSValue this // http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach // http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some -JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); - JSObject* applyThis = args.at(1).isUndefinedOrNull() ? exec->globalThisValue() : args.at(1).toObject(exec); + JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); JSValue result = jsBoolean(true); @@ -787,17 +802,18 @@ JSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec, JSObject*, JSValue th return result; } -JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); - JSObject* applyThis = args.at(1).isUndefinedOrNull() ? exec->globalThisValue() : args.at(1).toObject(exec); + JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); unsigned k = 0; @@ -832,17 +848,18 @@ JSValue JSC_HOST_CALL arrayProtoFuncForEach(ExecState* exec, JSObject*, JSValue return jsUndefined(); } -JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); - JSObject* applyThis = args.at(1).isUndefinedOrNull() ? exec->globalThisValue() : args.at(1).toObject(exec); + JSObject* applyThis = exec->argument(1).isUndefinedOrNull() ? exec->globalThisValue() : exec->argument(1).toObject(exec); JSValue result = jsBoolean(false); @@ -885,11 +902,12 @@ JSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec, JSObject*, JSValue thi return result; } -JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) @@ -898,14 +916,14 @@ JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec, JSObject*, JSValue t unsigned i = 0; JSValue rv; unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); - if (!length && args.size() == 1) + if (!length && exec->argumentCount() == 1) return throwError(exec, TypeError); JSArray* array = 0; if (isJSArray(&exec->globalData(), thisObj)) array = asArray(thisObj); - if (args.size() >= 2) - rv = args.at(1); + if (exec->argumentCount() >= 2) + rv = exec->argument(1); else if (array && array->canGetIndex(0)){ rv = array->getIndex(0); i = 1; @@ -955,11 +973,12 @@ JSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec, JSObject*, JSValue t return rv; } -JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - JSValue function = args.at(0); + JSValue function = exec->argument(0); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) @@ -968,14 +987,14 @@ JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec, JSObject*, JSVa unsigned i = 0; JSValue rv; unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); - if (!length && args.size() == 1) + if (!length && exec->argumentCount() == 1) return throwError(exec, TypeError); JSArray* array = 0; if (isJSArray(&exec->globalData(), thisObj)) array = asArray(thisObj); - if (args.size() >= 2) - rv = args.at(1); + if (exec->argumentCount() >= 2) + rv = exec->argument(1); else if (array && array->canGetIndex(length - 1)){ rv = array->getIndex(length - 1); i = 1; @@ -1024,15 +1043,16 @@ JSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec, JSObject*, JSVa return rv; } -JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); // JavaScript 1.5 Extension by Mozilla // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf JSObject* thisObj = thisValue.toThisObject(exec); unsigned index = 0; - double d = args.at(1).toInteger(exec); + double d = exec->argument(1).toInteger(exec); unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); if (d < 0) d += length; @@ -1043,7 +1063,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue index = static_cast<unsigned>(d); } - JSValue searchElement = args.at(0); + JSValue searchElement = exec->argument(0); for (; index < length; ++index) { JSValue e = getProperty(exec, thisObj, index); if (!e) @@ -1055,8 +1075,9 @@ JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue return jsNumber(exec, -1); } -JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); // JavaScript 1.6 Extension by Mozilla // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf @@ -1064,7 +1085,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSVa unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); int index = length - 1; - double d = args.at(1).toIntegerPreserveNaN(exec); + double d = exec->argument(1).toIntegerPreserveNaN(exec); if (d < 0) { d += length; @@ -1074,7 +1095,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSVa if (d < length) index = static_cast<int>(d); - JSValue searchElement = args.at(0); + JSValue searchElement = exec->argument(0); for (; index >= 0; --index) { JSValue e = getProperty(exec, thisObj, index); if (!e) diff --git a/JavaScriptCore/runtime/BooleanConstructor.cpp b/JavaScriptCore/runtime/BooleanConstructor.cpp index 07bcc97..bc12858 100644 --- a/JavaScriptCore/runtime/BooleanConstructor.cpp +++ b/JavaScriptCore/runtime/BooleanConstructor.cpp @@ -57,9 +57,9 @@ ConstructType BooleanConstructor::getConstructData(ConstructData& constructData) } // ECMA 15.6.1 -static JSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec) { - return jsBoolean(args.at(0).toBoolean(exec)); + return jsBoolean(exec->argument(0).toBoolean(exec)); } CallType BooleanConstructor::getCallData(CallData& callData) diff --git a/JavaScriptCore/runtime/BooleanPrototype.cpp b/JavaScriptCore/runtime/BooleanPrototype.cpp index 4378164..dbb27b2 100644 --- a/JavaScriptCore/runtime/BooleanPrototype.cpp +++ b/JavaScriptCore/runtime/BooleanPrototype.cpp @@ -32,8 +32,8 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(BooleanPrototype); // Functions -static JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState*); +static JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*); // ECMA 15.6.4 @@ -51,8 +51,9 @@ BooleanPrototype::BooleanPrototype(ExecState* exec, JSGlobalObject* globalObject // ECMA 15.6.4.2 + 15.6.4.3 -JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (thisValue == jsBoolean(false)) return jsNontrivialString(exec, "false"); @@ -69,8 +70,9 @@ JSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec, JSObject*, JSVal return jsNontrivialString(exec, "true"); } -JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (thisValue.isBoolean()) return thisValue; diff --git a/JavaScriptCore/runtime/CallData.cpp b/JavaScriptCore/runtime/CallData.cpp index 62e42fe..2b9302a 100644 --- a/JavaScriptCore/runtime/CallData.cpp +++ b/JavaScriptCore/runtime/CallData.cpp @@ -26,17 +26,16 @@ #include "config.h" #include "CallData.h" +#include "Executable.h" +#include "Interpreter.h" #include "JSFunction.h" namespace JSC { JSValue call(ExecState* exec, JSValue functionObject, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args) { - if (callType == CallTypeHost) - return callData.native.function(exec, asObject(functionObject), thisValue, args); - ASSERT(callType == CallTypeJS); - // FIXME: Can this be done more efficiently using the callData? - return asFunction(functionObject)->call(exec, thisValue, args); + ASSERT(callType == CallTypeJS || callType == CallTypeHost); + return exec->interpreter()->executeCall(exec, asObject(functionObject), callType, callData, thisValue, args, exec->exceptionSlot()); } } // namespace JSC diff --git a/JavaScriptCore/runtime/CallData.h b/JavaScriptCore/runtime/CallData.h index 24c19f9..5294e54 100644 --- a/JavaScriptCore/runtime/CallData.h +++ b/JavaScriptCore/runtime/CallData.h @@ -46,7 +46,7 @@ namespace JSC { CallTypeJS }; - typedef JSValue (JSC_HOST_CALL *NativeFunction)(ExecState*, JSObject*, JSValue thisValue, const ArgList&); + typedef JSValue (JSC_HOST_CALL *NativeFunction)(ExecState*); union CallData { struct { diff --git a/JavaScriptCore/runtime/Collector.cpp b/JavaScriptCore/runtime/Collector.cpp index 014685f..03389c4 100644 --- a/JavaScriptCore/runtime/Collector.cpp +++ b/JavaScriptCore/runtime/Collector.cpp @@ -394,7 +394,8 @@ allocate: ++m_heap.nextCell; return cell; } - } while (++m_heap.nextCell != HeapConstants::cellsPerBlock); + block->marked.advanceToNextPossibleFreeCell(m_heap.nextCell); + } while (m_heap.nextCell != HeapConstants::cellsPerBlock); m_heap.nextCell = 0; } while (++m_heap.nextBlock != m_heap.usedBlocks); diff --git a/JavaScriptCore/runtime/Collector.h b/JavaScriptCore/runtime/Collector.h index 0a40758..34e238c 100644 --- a/JavaScriptCore/runtime/Collector.h +++ b/JavaScriptCore/runtime/Collector.h @@ -220,6 +220,13 @@ namespace JSC { void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } void clearAll() { memset(bits, 0, sizeof(bits)); } + ALWAYS_INLINE void advanceToNextPossibleFreeCell(size_t& startCell) + { + if (!~bits[startCell >> 5]) + startCell = (startCell & (~0x1F)) + 32; + else + ++startCell; + } size_t count(size_t startCell = 0) { size_t result = 0; diff --git a/JavaScriptCore/runtime/ConstructData.cpp b/JavaScriptCore/runtime/ConstructData.cpp index 7ee59d7..a7b97e6 100644 --- a/JavaScriptCore/runtime/ConstructData.cpp +++ b/JavaScriptCore/runtime/ConstructData.cpp @@ -26,7 +26,10 @@ #include "config.h" #include "ConstructData.h" +#include "Executable.h" +#include "Interpreter.h" #include "JSFunction.h" +#include "JSGlobalObject.h" namespace JSC { @@ -34,9 +37,23 @@ JSObject* construct(ExecState* exec, JSValue object, ConstructType constructType { if (constructType == ConstructTypeHost) return constructData.native.function(exec, asObject(object), args); + ASSERT(constructType == ConstructTypeJS); - // FIXME: Can this be done more efficiently using the constructData? - return asFunction(object)->construct(exec, args); + JSFunction* jsFunction = asFunction(object); + + ASSERT(!jsFunction->isHostFunction()); + Structure* structure; + JSValue prototype = jsFunction->get(exec, exec->propertyNames().prototype); + if (prototype.isObject()) + structure = asObject(prototype)->inheritorID(); + else + structure = exec->lexicalGlobalObject()->emptyObjectStructure(); + JSObject* thisObj = new (exec) JSObject(structure); + + JSValue result = exec->interpreter()->executeConstruct(jsFunction->jsExecutable(), exec, jsFunction, thisObj, args, jsFunction->scope().node(), exec->exceptionSlot()); + if (exec->hadException() || !result.isObject()) + return thisObj; + return asObject(result); } } // namespace JSC diff --git a/JavaScriptCore/runtime/DateConstructor.cpp b/JavaScriptCore/runtime/DateConstructor.cpp index d732a4f..015a01a 100644 --- a/JavaScriptCore/runtime/DateConstructor.cpp +++ b/JavaScriptCore/runtime/DateConstructor.cpp @@ -54,9 +54,9 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(DateConstructor); -static JSValue JSC_HOST_CALL dateParse(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateNow(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateUTC(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL dateParse(ExecState*); +static JSValue JSC_HOST_CALL dateNow(ExecState*); +static JSValue JSC_HOST_CALL dateUTC(ExecState*); DateConstructor::DateConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype) : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, datePrototype->classInfo()->className)) @@ -128,7 +128,7 @@ ConstructType DateConstructor::getConstructData(ConstructData& constructData) } // ECMA 15.9.2 -static JSValue JSC_HOST_CALL callDate(ExecState* exec, JSObject*, JSValue, const ArgList&) +static JSValue JSC_HOST_CALL callDate(ExecState* exec) { time_t localTime = time(0); tm localTM; @@ -147,37 +147,37 @@ CallType DateConstructor::getCallData(CallData& callData) return CallTypeHost; } -static JSValue JSC_HOST_CALL dateParse(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL dateParse(ExecState* exec) { - return jsNumber(exec, parseDate(exec, args.at(0).toString(exec))); + return jsNumber(exec, parseDate(exec, exec->argument(0).toString(exec))); } -static JSValue JSC_HOST_CALL dateNow(ExecState* exec, JSObject*, JSValue, const ArgList&) +static JSValue JSC_HOST_CALL dateNow(ExecState* exec) { return jsNumber(exec, jsCurrentTime()); } -static JSValue JSC_HOST_CALL dateUTC(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL dateUTC(ExecState* exec) { - int n = args.size(); - if (isnan(args.at(0).toNumber(exec)) - || isnan(args.at(1).toNumber(exec)) - || (n >= 3 && isnan(args.at(2).toNumber(exec))) - || (n >= 4 && isnan(args.at(3).toNumber(exec))) - || (n >= 5 && isnan(args.at(4).toNumber(exec))) - || (n >= 6 && isnan(args.at(5).toNumber(exec))) - || (n >= 7 && isnan(args.at(6).toNumber(exec)))) + int n = exec->argumentCount(); + if (isnan(exec->argument(0).toNumber(exec)) + || isnan(exec->argument(1).toNumber(exec)) + || (n >= 3 && isnan(exec->argument(2).toNumber(exec))) + || (n >= 4 && isnan(exec->argument(3).toNumber(exec))) + || (n >= 5 && isnan(exec->argument(4).toNumber(exec))) + || (n >= 6 && isnan(exec->argument(5).toNumber(exec))) + || (n >= 7 && isnan(exec->argument(6).toNumber(exec)))) return jsNaN(exec); GregorianDateTime t; - int year = args.at(0).toInt32(exec); + int year = exec->argument(0).toInt32(exec); t.year = (year >= 0 && year <= 99) ? year : year - 1900; - t.month = args.at(1).toInt32(exec); - t.monthDay = (n >= 3) ? args.at(2).toInt32(exec) : 1; - t.hour = args.at(3).toInt32(exec); - t.minute = args.at(4).toInt32(exec); - t.second = args.at(5).toInt32(exec); - double ms = (n >= 7) ? args.at(6).toNumber(exec) : 0; + t.month = exec->argument(1).toInt32(exec); + t.monthDay = (n >= 3) ? exec->argument(2).toInt32(exec) : 1; + t.hour = exec->argument(3).toInt32(exec); + t.minute = exec->argument(4).toInt32(exec); + t.second = exec->argument(5).toInt32(exec); + double ms = (n >= 7) ? exec->argument(6).toNumber(exec) : 0; return jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true))); } diff --git a/JavaScriptCore/runtime/DatePrototype.cpp b/JavaScriptCore/runtime/DatePrototype.cpp index a5dfabd..c31a4d0 100644 --- a/JavaScriptCore/runtime/DatePrototype.cpp +++ b/JavaScriptCore/runtime/DatePrototype.cpp @@ -73,52 +73,51 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(DatePrototype); -static JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState*, JSObject*, JSValue, const ArgList&); - -static JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState*); +static JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState*); } @@ -146,7 +145,7 @@ static CFDateFormatterStyle styleFromArgString(const UString& string, CFDateForm return defaultStyle; } -static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMilliseconds, LocaleDateTimeFormat format, const ArgList& args) +static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMilliseconds, LocaleDateTimeFormat format) { CFDateFormatterStyle dateStyle = (format != LocaleTime ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); CFDateFormatterStyle timeStyle = (format != LocaleDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); @@ -154,16 +153,16 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMil bool useCustomFormat = false; UString customFormatString; - UString arg0String = args.at(0).toString(exec); - if (arg0String == "custom" && !args.at(1).isUndefined()) { + UString arg0String = exec->argument(0).toString(exec); + if (arg0String == "custom" && !exec->argument(1).isUndefined()) { useCustomFormat = true; - customFormatString = args.at(1).toString(exec); - } else if (format == LocaleDateAndTime && !args.at(1).isUndefined()) { + customFormatString = exec->argument(1).toString(exec); + } else if (format == LocaleDateAndTime && !exec->argument(1).isUndefined()) { dateStyle = styleFromArgString(arg0String, dateStyle); - timeStyle = styleFromArgString(args.at(1).toString(exec), timeStyle); - } else if (format != LocaleTime && !args.at(0).isUndefined()) + timeStyle = styleFromArgString(exec->argument(1).toString(exec), timeStyle); + } else if (format != LocaleTime && !exec->argument(0).isUndefined()) dateStyle = styleFromArgString(arg0String, dateStyle); - else if (format != LocaleDate && !args.at(0).isUndefined()) + else if (format != LocaleDate && !exec->argument(0).isUndefined()) timeStyle = styleFromArgString(arg0String, timeStyle); CFLocaleRef locale = CFLocaleCopyCurrent(); @@ -274,7 +273,7 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L return jsNontrivialString(exec, timebuffer); } -static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double, LocaleDateTimeFormat format, const ArgList&) +static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double, LocaleDateTimeFormat format) { const GregorianDateTime* gregorianDateTime = dateObject->gregorianDateTime(exec); if (!gregorianDateTime) @@ -288,12 +287,12 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, doubl // ms (representing milliseconds) and t (representing the rest of the date structure) appropriately. // // Format of member function: f([hour,] [min,] [sec,] [ms]) -static bool fillStructuresUsingTimeArgs(ExecState* exec, const ArgList& args, int maxArgs, double* ms, GregorianDateTime* t) +static bool fillStructuresUsingTimeArgs(ExecState* exec, int maxArgs, double* ms, GregorianDateTime* t) { double milliseconds = 0; bool ok = true; int idx = 0; - int numArgs = args.size(); + int numArgs = exec->argumentCount(); // JS allows extra trailing arguments -- ignore them if (numArgs > maxArgs) @@ -302,19 +301,19 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, const ArgList& args, in // hours if (maxArgs >= 4 && idx < numArgs) { t->hour = 0; - milliseconds += args.at(idx++).toInt32(exec, ok) * msPerHour; + milliseconds += exec->argument(idx++).toInt32(exec, ok) * msPerHour; } // minutes if (maxArgs >= 3 && idx < numArgs && ok) { t->minute = 0; - milliseconds += args.at(idx++).toInt32(exec, ok) * msPerMinute; + milliseconds += exec->argument(idx++).toInt32(exec, ok) * msPerMinute; } // seconds if (maxArgs >= 2 && idx < numArgs && ok) { t->second = 0; - milliseconds += args.at(idx++).toInt32(exec, ok) * msPerSecond; + milliseconds += exec->argument(idx++).toInt32(exec, ok) * msPerSecond; } if (!ok) @@ -322,7 +321,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, const ArgList& args, in // milliseconds if (idx < numArgs) { - double millis = args.at(idx).toNumber(exec); + double millis = exec->argument(idx).toNumber(exec); ok = isfinite(millis); milliseconds += millis; } else @@ -336,11 +335,11 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, const ArgList& args, in // ms (representing milliseconds) and t (representing the rest of the date structure) appropriately. // // Format of member function: f([years,] [months,] [days]) -static bool fillStructuresUsingDateArgs(ExecState *exec, const ArgList& args, int maxArgs, double *ms, GregorianDateTime *t) +static bool fillStructuresUsingDateArgs(ExecState *exec, int maxArgs, double *ms, GregorianDateTime *t) { int idx = 0; bool ok = true; - int numArgs = args.size(); + int numArgs = exec->argumentCount(); // JS allows extra trailing arguments -- ignore them if (numArgs > maxArgs) @@ -348,16 +347,16 @@ static bool fillStructuresUsingDateArgs(ExecState *exec, const ArgList& args, in // years if (maxArgs >= 3 && idx < numArgs) - t->year = args.at(idx++).toInt32(exec, ok) - 1900; + t->year = exec->argument(idx++).toInt32(exec, ok) - 1900; // months if (maxArgs >= 2 && idx < numArgs && ok) - t->month = args.at(idx++).toInt32(exec, ok); + t->month = exec->argument(idx++).toInt32(exec, ok); // days if (idx < numArgs && ok) { t->monthDay = 0; - *ms += args.at(idx).toInt32(exec, ok) * msPerDay; + *ms += exec->argument(idx).toInt32(exec, ok) * msPerDay; } return ok; @@ -438,8 +437,9 @@ bool DatePrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& // Functions -JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -455,8 +455,9 @@ JSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec, JSObject*, JSValue return jsMakeNontrivialString(exec, date, " ", time); } -JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -472,8 +473,9 @@ JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec, JSObject*, JSVal return jsMakeNontrivialString(exec, date, " ", time); } -JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -490,8 +492,9 @@ JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec, JSObject*, JSVal return jsNontrivialString(exec, buffer); } -JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -505,8 +508,9 @@ JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec, JSObject*, JSVa return jsNontrivialString(exec, date); } -JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -520,43 +524,48 @@ JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec, JSObject*, JSVa return jsNontrivialString(exec, time); } -JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime, args); + return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime); } -JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate, args); + return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate); } -JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime, args); + return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime); } -JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); return asDateInstance(thisValue)->internalValue(); } -JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -568,8 +577,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSVal return jsNumber(exec, 1900 + gregorianDateTime->year); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -581,8 +591,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JS return jsNumber(exec, 1900 + gregorianDateTime->year); } -JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -598,8 +609,9 @@ JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSVal return jsMakeNontrivialString(exec, date, " ", time); } -JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -611,8 +623,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec, JSObject*, JSValue return jsNumber(exec, gregorianDateTime->month); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -624,8 +637,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec, JSObject*, JSVal return jsNumber(exec, gregorianDateTime->month); } -JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -637,8 +651,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec, JSObject*, JSValue t return jsNumber(exec, gregorianDateTime->monthDay); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -650,8 +665,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec, JSObject*, JSValu return jsNumber(exec, gregorianDateTime->monthDay); } -JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -663,8 +679,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec, JSObject*, JSValue th return jsNumber(exec, gregorianDateTime->weekDay); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -676,8 +693,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec, JSObject*, JSValue return jsNumber(exec, gregorianDateTime->weekDay); } -JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -689,8 +707,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec, JSObject*, JSValue return jsNumber(exec, gregorianDateTime->hour); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -702,8 +721,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec, JSObject*, JSVal return jsNumber(exec, gregorianDateTime->hour); } -JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -715,8 +735,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec, JSObject*, JSValu return jsNumber(exec, gregorianDateTime->minute); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -728,8 +749,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject*, JSV return jsNumber(exec, gregorianDateTime->minute); } -JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -741,8 +763,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec, JSObject*, JSValu return jsNumber(exec, gregorianDateTime->second); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -754,8 +777,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject*, JSV return jsNumber(exec, gregorianDateTime->second); } -JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -769,8 +793,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject*, J return jsNumber(exec, ms); } -JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -784,8 +809,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject* return jsNumber(exec, ms); } -JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -797,28 +823,30 @@ JSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject*, return jsNumber(exec, -gregorianDateTime->utcOffset / minutesPerHour); } -JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - double milli = timeClip(args.at(0).toNumber(exec)); + double milli = timeClip(exec->argument(0).toNumber(exec)); JSValue result = jsNumber(exec, milli); thisDateObj->setInternalValue(result); return result; } -static JSValue setNewValueFromTimeArgs(ExecState* exec, JSValue thisValue, const ArgList& args, int numArgsToUse, bool inputIsUTC) +static JSValue setNewValueFromTimeArgs(ExecState* exec, int numArgsToUse, bool inputIsUTC) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); double milli = thisDateObj->internalNumber(); - if (args.isEmpty() || isnan(milli)) { + if (!exec->argumentCount() || isnan(milli)) { JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); return result; @@ -835,7 +863,7 @@ static JSValue setNewValueFromTimeArgs(ExecState* exec, JSValue thisValue, const GregorianDateTime gregorianDateTime; gregorianDateTime.copyFrom(*other); - if (!fillStructuresUsingTimeArgs(exec, args, numArgsToUse, &ms, &gregorianDateTime)) { + if (!fillStructuresUsingTimeArgs(exec, numArgsToUse, &ms, &gregorianDateTime)) { JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); return result; @@ -846,13 +874,14 @@ static JSValue setNewValueFromTimeArgs(ExecState* exec, JSValue thisValue, const return result; } -static JSValue setNewValueFromDateArgs(ExecState* exec, JSValue thisValue, const ArgList& args, int numArgsToUse, bool inputIsUTC) +static JSValue setNewValueFromDateArgs(ExecState* exec, int numArgsToUse, bool inputIsUTC) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - if (args.isEmpty()) { + if (!exec->argumentCount()) { JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); return result; @@ -874,7 +903,7 @@ static JSValue setNewValueFromDateArgs(ExecState* exec, JSValue thisValue, const gregorianDateTime.copyFrom(*other); } - if (!fillStructuresUsingDateArgs(exec, args, numArgsToUse, &ms, &gregorianDateTime)) { + if (!fillStructuresUsingDateArgs(exec, numArgsToUse, &ms, &gregorianDateTime)) { JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); return result; @@ -885,97 +914,98 @@ static JSValue setNewValueFromDateArgs(ExecState* exec, JSValue thisValue, const return result; } -JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetMilliSeconds(ExecState* exec) { const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisValue, args, 1, inputIsUTC); + return setNewValueFromTimeArgs(exec, 1, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetUTCMilliseconds(ExecState* exec) { const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisValue, args, 1, inputIsUTC); + return setNewValueFromTimeArgs(exec, 1, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetSeconds(ExecState* exec) { const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisValue, args, 2, inputIsUTC); + return setNewValueFromTimeArgs(exec, 2, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetUTCSeconds(ExecState* exec) { const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisValue, args, 2, inputIsUTC); + return setNewValueFromTimeArgs(exec, 2, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetMinutes(ExecState* exec) { const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisValue, args, 3, inputIsUTC); + return setNewValueFromTimeArgs(exec, 3, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetUTCMinutes(ExecState* exec) { const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisValue, args, 3, inputIsUTC); + return setNewValueFromTimeArgs(exec, 3, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetHours(ExecState* exec) { const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisValue, args, 4, inputIsUTC); + return setNewValueFromTimeArgs(exec, 4, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetUTCHours(ExecState* exec) { const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisValue, args, 4, inputIsUTC); + return setNewValueFromTimeArgs(exec, 4, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetDate(ExecState* exec) { const bool inputIsUTC = false; - return setNewValueFromDateArgs(exec, thisValue, args, 1, inputIsUTC); + return setNewValueFromDateArgs(exec, 1, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetUTCDate(ExecState* exec) { const bool inputIsUTC = true; - return setNewValueFromDateArgs(exec, thisValue, args, 1, inputIsUTC); + return setNewValueFromDateArgs(exec, 1, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetMonth(ExecState* exec) { const bool inputIsUTC = false; - return setNewValueFromDateArgs(exec, thisValue, args, 2, inputIsUTC); + return setNewValueFromDateArgs(exec, 2, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetUTCMonth(ExecState* exec) { const bool inputIsUTC = true; - return setNewValueFromDateArgs(exec, thisValue, args, 2, inputIsUTC); + return setNewValueFromDateArgs(exec, 2, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetFullYear(ExecState* exec) { const bool inputIsUTC = false; - return setNewValueFromDateArgs(exec, thisValue, args, 3, inputIsUTC); + return setNewValueFromDateArgs(exec, 3, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetUTCFullYear(ExecState* exec) { const bool inputIsUTC = true; - return setNewValueFromDateArgs(exec, thisValue, args, 3, inputIsUTC); + return setNewValueFromDateArgs(exec, 3, inputIsUTC); } -JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); DateInstance* thisDateObj = asDateInstance(thisValue); - if (args.isEmpty()) { + if (!exec->argumentCount()) { JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); return result; @@ -997,7 +1027,7 @@ JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue t } bool ok = true; - int32_t year = args.at(0).toInt32(exec, ok); + int32_t year = exec->argument(0).toInt32(exec, ok); if (!ok) { JSValue result = jsNaN(exec); thisDateObj->setInternalValue(result); @@ -1010,8 +1040,9 @@ JSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue t return result; } -JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&DateInstance::info)) return throwError(exec, TypeError); @@ -1025,8 +1056,9 @@ JSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec, JSObject*, JSValue t return jsNumber(exec, gregorianDateTime->year); } -JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* object = thisValue.toThisObject(exec); if (exec->hadException()) return jsNull(); diff --git a/JavaScriptCore/runtime/ErrorConstructor.cpp b/JavaScriptCore/runtime/ErrorConstructor.cpp index 4a4559e..b4b0ba2 100644 --- a/JavaScriptCore/runtime/ErrorConstructor.cpp +++ b/JavaScriptCore/runtime/ErrorConstructor.cpp @@ -57,10 +57,9 @@ ConstructType ErrorConstructor::getConstructData(ConstructData& constructData) return ConstructTypeHost; } -// ECMA 15.9.2 -static JSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec) { - // "Error()" gives the sames result as "new Error()" + ArgList args(exec); return constructError(exec, args); } diff --git a/JavaScriptCore/runtime/ErrorPrototype.cpp b/JavaScriptCore/runtime/ErrorPrototype.cpp index 72fa4c4..4c895fa 100644 --- a/JavaScriptCore/runtime/ErrorPrototype.cpp +++ b/JavaScriptCore/runtime/ErrorPrototype.cpp @@ -32,7 +32,7 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype); -static JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*); // ECMA 15.9.4 ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure) @@ -46,9 +46,9 @@ ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, No putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum); } -JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec) { - JSObject* thisObj = thisValue.toThisObject(exec); + JSObject* thisObj = exec->hostThisValue().toThisObject(exec); JSValue name = thisObj->get(exec, exec->propertyNames().name); JSValue message = thisObj->get(exec, exec->propertyNames().message); diff --git a/JavaScriptCore/runtime/ExceptionHelpers.cpp b/JavaScriptCore/runtime/ExceptionHelpers.cpp index aee6f31..b76c226 100644 --- a/JavaScriptCore/runtime/ExceptionHelpers.cpp +++ b/JavaScriptCore/runtime/ExceptionHelpers.cpp @@ -182,13 +182,13 @@ JSNotAnObjectErrorStub* createNotAnObjectErrorStub(ExecState* exec, bool isNull) JSObject* createNotAnObjectError(ExecState* exec, JSNotAnObjectErrorStub* error, unsigned bytecodeOffset, CodeBlock* codeBlock) { - // Both op_construct and op_instanceof require a use of op_get_by_id to get + // Both op_create_this and op_instanceof require a use of op_get_by_id to get // the prototype property from an object. The exception messages for exceptions // thrown by these instances op_get_by_id need to reflect this. OpcodeID followingOpcodeID; if (codeBlock->getByIdExceptionInfoForBytecodeOffset(exec, bytecodeOffset, followingOpcodeID)) { - ASSERT(followingOpcodeID == op_construct || followingOpcodeID == op_instanceof); - if (followingOpcodeID == op_construct) + ASSERT(followingOpcodeID == op_create_this || followingOpcodeID == op_instanceof); + if (followingOpcodeID == op_create_this) return createNotAConstructorError(exec, error->isNull() ? jsNull() : jsUndefined(), bytecodeOffset, codeBlock); return createInvalidParamError(exec, "instanceof", error->isNull() ? jsNull() : jsUndefined(), bytecodeOffset, codeBlock); } diff --git a/JavaScriptCore/runtime/Executable.cpp b/JavaScriptCore/runtime/Executable.cpp index 8cb3c56..2176e36 100644 --- a/JavaScriptCore/runtime/Executable.cpp +++ b/JavaScriptCore/runtime/Executable.cpp @@ -188,7 +188,7 @@ void ProgramExecutable::generateJITCode(ExecState* exec, ScopeChainNode* scopeCh void FunctionExecutable::generateJITCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode) { CodeBlock* codeBlock = &bytecodeForCall(exec, scopeChainNode); - m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock); + m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock, &m_jitCodeForCallWithArityCheck); #if !ENABLE(OPCODE_SAMPLING) if (!BytecodeGenerator::dumpsGeneratedCode()) @@ -199,7 +199,7 @@ void FunctionExecutable::generateJITCodeForCall(ExecState* exec, ScopeChainNode* void FunctionExecutable::generateJITCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode) { CodeBlock* codeBlock = &bytecodeForConstruct(exec, scopeChainNode); - m_jitCodeForConstruct = JIT::compile(scopeChainNode->globalData, codeBlock); + m_jitCodeForConstruct = JIT::compile(scopeChainNode->globalData, codeBlock, &m_jitCodeForConstructWithArityCheck); #if !ENABLE(OPCODE_SAMPLING) if (!BytecodeGenerator::dumpsGeneratedCode()) diff --git a/JavaScriptCore/runtime/Executable.h b/JavaScriptCore/runtime/Executable.h index ac63c49..39ddf49 100644 --- a/JavaScriptCore/runtime/Executable.h +++ b/JavaScriptCore/runtime/Executable.h @@ -86,6 +86,8 @@ namespace JSC { protected: JITCode m_jitCodeForCall; JITCode m_jitCodeForConstruct; + MacroAssemblerCodePtr m_jitCodeForCallWithArityCheck; + MacroAssemblerCodePtr m_jitCodeForConstructWithArityCheck; #endif }; @@ -93,9 +95,9 @@ namespace JSC { class NativeExecutable : public ExecutableBase { friend class JIT; public: - static PassRefPtr<NativeExecutable> create(MacroAssemblerCodePtr thunk, NativeFunction function) + static PassRefPtr<NativeExecutable> create(MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor) { - return adoptRef(new NativeExecutable(JITCode::HostFunction(thunk), function)); + return adoptRef(new NativeExecutable(JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor)); } ~NativeExecutable(); @@ -103,15 +105,21 @@ namespace JSC { NativeFunction function() { return m_function; } private: - NativeExecutable(JITCode thunk, NativeFunction function) + NativeExecutable(JITCode callThunk, NativeFunction function, JITCode constructThunk, NativeFunction constructor) : ExecutableBase(NUM_PARAMETERS_IS_HOST) , m_function(function) + , m_constructor(constructor) { - m_jitCodeForCall = thunk; - m_jitCodeForConstruct = thunk; + m_jitCodeForCall = callThunk; + m_jitCodeForConstruct = constructThunk; + m_jitCodeForCallWithArityCheck = callThunk.addressForCall(); + m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall(); } NativeFunction m_function; + // Probably should be a NativeConstructor, but this will currently require rewriting the JIT + // trampoline. It may be easier to make NativeFunction be passed 'this' as a part of the ArgList. + NativeFunction m_constructor; }; #endif @@ -403,6 +411,20 @@ namespace JSC { return m_jitCodeForConstruct; } + MacroAssemblerCodePtr generatedJITCodeForCallWithArityCheck() + { + ASSERT(m_jitCodeForCall); + ASSERT(m_jitCodeForCallWithArityCheck); + return m_jitCodeForCallWithArityCheck; + } + + MacroAssemblerCodePtr generatedJITCodeForConstructWithArityCheck() + { + ASSERT(m_jitCodeForConstruct); + ASSERT(m_jitCodeForConstructWithArityCheck); + return m_jitCodeForConstructWithArityCheck; + } + private: void generateJITCodeForCall(ExecState*, ScopeChainNode*); void generateJITCodeForConstruct(ExecState*, ScopeChainNode*); diff --git a/JavaScriptCore/runtime/FunctionConstructor.cpp b/JavaScriptCore/runtime/FunctionConstructor.cpp index c8299a9..de9fff1 100644 --- a/JavaScriptCore/runtime/FunctionConstructor.cpp +++ b/JavaScriptCore/runtime/FunctionConstructor.cpp @@ -55,8 +55,9 @@ ConstructType FunctionConstructor::getConstructData(ConstructData& constructData return ConstructTypeHost; } -static JSValue JSC_HOST_CALL callFunctionConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callFunctionConstructor(ExecState* exec) { + ArgList args(exec); return constructFunction(exec, args); } diff --git a/JavaScriptCore/runtime/FunctionPrototype.cpp b/JavaScriptCore/runtime/FunctionPrototype.cpp index 1762816..15392cf 100644 --- a/JavaScriptCore/runtime/FunctionPrototype.cpp +++ b/JavaScriptCore/runtime/FunctionPrototype.cpp @@ -34,9 +34,9 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(FunctionPrototype); -static JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*); +static JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*); +static JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*); FunctionPrototype::FunctionPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure) : InternalFunction(&exec->globalData(), globalObject, structure, exec->propertyNames().nullIdentifier) @@ -53,7 +53,7 @@ void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* g putDirectFunctionWithoutTransition(exec, *callFunction, DontEnum); } -static JSValue JSC_HOST_CALL callFunctionPrototype(ExecState*, JSObject*, JSValue, const ArgList&) +static JSValue JSC_HOST_CALL callFunctionPrototype(ExecState*) { return jsUndefined(); } @@ -83,8 +83,9 @@ static inline void insertSemicolonIfNeeded(UString& functionBody) } } -JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (thisValue.inherits(&JSFunction::info)) { JSFunction* function = asFunction(thisValue); if (function->isHostFunction()) @@ -103,14 +104,15 @@ JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec, JSObject*, JSVa return throwError(exec, TypeError); } -JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); CallData callData; CallType callType = thisValue.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); - JSValue array = args.at(1); + JSValue array = exec->argument(1); MarkedArgumentBuffer applyArgs; if (!array.isUndefinedOrNull()) { @@ -128,19 +130,21 @@ JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState* exec, JSObject*, JSValue return throwError(exec, TypeError); } - return call(exec, thisValue, callType, callData, args.at(0), applyArgs); + return call(exec, thisValue, callType, callData, exec->argument(0), applyArgs); } -JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); CallData callData; CallType callType = thisValue.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); + ArgList args(exec); ArgList callArgs; args.getSlice(1, callArgs); - return call(exec, thisValue, callType, callData, args.at(0), callArgs); + return call(exec, thisValue, callType, callData, exec->argument(0), callArgs); } } // namespace JSC diff --git a/JavaScriptCore/runtime/JSArray.cpp b/JavaScriptCore/runtime/JSArray.cpp index d3ef44c..cf32e07 100644 --- a/JavaScriptCore/runtime/JSArray.cpp +++ b/JavaScriptCore/runtime/JSArray.cpp @@ -649,7 +649,7 @@ static int compareByStringPairForQSort(const void* a, const void* b) { const ValueStringPair* va = static_cast<const ValueStringPair*>(a); const ValueStringPair* vb = static_cast<const ValueStringPair*>(b); - return compare(va->second, vb->second); + return codePointCompare(va->second, vb->second); } void JSArray::sortNumeric(ExecState* exec, JSValue compareFunction, CallType callType, const CallData& callData) diff --git a/JavaScriptCore/runtime/JSFunction.cpp b/JavaScriptCore/runtime/JSFunction.cpp index 9d36e91..f44ca2f 100644 --- a/JavaScriptCore/runtime/JSFunction.cpp +++ b/JavaScriptCore/runtime/JSFunction.cpp @@ -28,8 +28,10 @@ #include "CodeBlock.h" #include "CommonIdentifiers.h" #include "CallFrame.h" +#include "ExceptionHelpers.h" #include "FunctionPrototype.h" #include "JSGlobalObject.h" +#include "JSNotAnObject.h" #include "Interpreter.h" #include "ObjectPrototype.h" #include "Parser.h" @@ -41,6 +43,14 @@ using namespace Unicode; namespace JSC { +JSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState* exec) +{ + CodeBlock* codeBlock = exec->callerFrame()->codeBlock(); + unsigned vPCIndex = codeBlock->bytecodeOffset(exec, exec->returnPC()); + exec->setException(createNotAConstructorError(exec, exec->callee(), vPCIndex, codeBlock)); + return JSValue(); +} + ASSERT_CLASS_FITS_IN_CELL(JSFunction); const ClassInfo JSFunction::info = { "Function", 0, 0, 0 }; @@ -57,22 +67,16 @@ JSFunction::JSFunction(NonNullPassRefPtr<Structure> structure) { } +#if ENABLE(JIT) JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, PassRefPtr<NativeExecutable> thunk) : Base(globalObject, structure) -#if ENABLE(JIT) , m_executable(thunk) -#endif , m_scopeChain(globalObject->globalScopeChain()) { putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); -#if ENABLE(JIT) putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum); -#else - UNUSED_PARAM(thunk); - UNUSED_PARAM(length); - ASSERT_NOT_REACHED(); -#endif } +#endif JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, NativeFunction func) : Base(globalObject, structure) @@ -165,12 +169,6 @@ CallType JSFunction::getCallData(CallData& callData) return CallTypeJS; } -JSValue JSFunction::call(ExecState* exec, JSValue thisValue, const ArgList& args) -{ - ASSERT(!isHostFunction()); - return exec->interpreter()->executeCall(jsExecutable(), exec, this, thisValue.toThisObject(exec), args, scope().node(), exec->exceptionSlot()); -} - JSValue JSFunction::argumentsGetter(ExecState* exec, JSValue slotBase, const Identifier&) { JSFunction* thisObj = asFunction(slotBase); @@ -298,21 +296,4 @@ ConstructType JSFunction::getConstructData(ConstructData& constructData) return ConstructTypeJS; } -JSObject* JSFunction::construct(ExecState* exec, const ArgList& args) -{ - ASSERT(!isHostFunction()); - Structure* structure; - JSValue prototype = get(exec, exec->propertyNames().prototype); - if (prototype.isObject()) - structure = asObject(prototype)->inheritorID(); - else - structure = exec->lexicalGlobalObject()->emptyObjectStructure(); - JSObject* thisObj = new (exec) JSObject(structure); - - JSValue result = exec->interpreter()->executeConstruct(jsExecutable(), exec, this, thisObj, args, scope().node(), exec->exceptionSlot()); - if (exec->hadException() || !result.isObject()) - return thisObj; - return asObject(result); -} - } // namespace JSC diff --git a/JavaScriptCore/runtime/JSFunction.h b/JavaScriptCore/runtime/JSFunction.h index acdfe0d..a906b2e 100644 --- a/JavaScriptCore/runtime/JSFunction.h +++ b/JavaScriptCore/runtime/JSFunction.h @@ -35,6 +35,8 @@ namespace JSC { class JSGlobalObject; class NativeExecutable; + JSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState*); + class JSFunction : public JSObjectWithGlobalObject { friend class JIT; friend class JSGlobalData; @@ -43,13 +45,12 @@ namespace JSC { public: JSFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction); +#if ENABLE(JIT) JSFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, PassRefPtr<NativeExecutable>); +#endif JSFunction(ExecState*, NonNullPassRefPtr<FunctionExecutable>, ScopeChainNode*); virtual ~JSFunction(); - JSObject* construct(ExecState*, const ArgList&); - JSValue call(ExecState*, JSValue thisValue, const ArgList&); - const UString& name(ExecState*); const UString displayName(ExecState*); const UString calculatedDisplayName(ExecState*); diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp index fb9b3eb..69e09c1 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -131,7 +131,7 @@ void JSGlobalObject::init(JSObject* thisValue) d()->globalData = Heap::heap(this)->globalData(); d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), this, thisValue); - JSGlobalObject::globalExec()->init(0, 0, d()->globalScopeChain.node(), CallFrame::noCaller(), 0, 0, 0); + JSGlobalObject::globalExec()->init(0, 0, d()->globalScopeChain.node(), CallFrame::noCaller(), 0, 0); if (JSGlobalObject*& headObject = head()) { d()->prev = headObject; diff --git a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp index 5da5194..21d06b7 100644 --- a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp +++ b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp @@ -51,9 +51,9 @@ using namespace Unicode; namespace JSC { -static JSValue encode(ExecState* exec, const ArgList& args, const char* doNotEscape) +static JSValue encode(ExecState* exec, const char* doNotEscape) { - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); CString cstr = str.UTF8String(true); if (!cstr.data()) return throwError(exec, URIError, "String contained an illegal UTF-16 sequence."); @@ -73,10 +73,10 @@ static JSValue encode(ExecState* exec, const ArgList& args, const char* doNotEsc return builder.build(exec); } -static JSValue decode(ExecState* exec, const ArgList& args, const char* doNotUnescape, bool strict) +static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict) { JSStringBuilder builder; - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); int k = 0; int len = str.size(); const UChar* d = str.data(); @@ -241,11 +241,10 @@ static double parseInt(const UString& s, int radix) } if (number >= mantissaOverflowLowerBound) { - // FIXME: It is incorrect to use UString::ascii() here because it's not thread-safe. if (radix == 10) - number = WTF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), 0); + number = WTF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).UTF8String().data(), 0); else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) - number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), p - firstDigitPosition, radix); + number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).UTF8String().data(), p - firstDigitPosition, radix); } if (!sawDigit) @@ -270,19 +269,17 @@ static double parseFloat(const UString& s) if (length - p >= 2 && data[p] == '0' && (data[p + 1] == 'x' || data[p + 1] == 'X')) return 0; - // FIXME: UString::toDouble will ignore leading ASCII spaces, but we need to ignore - // other StrWhiteSpaceChar values as well. return s.toDouble(true /*tolerant*/, false /* NaN for empty string */); } -JSValue JSC_HOST_CALL globalFuncEval(ExecState* exec, JSObject* function, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncEval(ExecState* exec) { - JSObject* thisObject = thisValue.toThisObject(exec); + JSObject* thisObject = exec->hostThisValue().toThisObject(exec); JSObject* unwrappedObject = thisObject->unwrappedObject(); - if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != function) + if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee()) return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated"); - JSValue x = args.at(0); + JSValue x = exec->argument(0); if (!x.isString()) return x; @@ -300,10 +297,10 @@ JSValue JSC_HOST_CALL globalFuncEval(ExecState* exec, JSObject* function, JSValu return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot()); } -JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec) { - JSValue value = args.at(0); - int32_t radix = args.at(1).toInt32(exec); + JSValue value = exec->argument(0); + int32_t radix = exec->argument(1).toInt32(exec); if (radix != 0 && radix != 10) return jsNumber(exec, parseInt(value.toString(exec), radix)); @@ -323,36 +320,36 @@ JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec, JSObject*, JSValue, co return jsNumber(exec, parseInt(value.toString(exec), radix)); } -JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec) { - return jsNumber(exec, parseFloat(args.at(0).toString(exec))); + return jsNumber(exec, parseFloat(exec->argument(0).toString(exec))); } -JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec) { - return jsBoolean(isnan(args.at(0).toNumber(exec))); + return jsBoolean(isnan(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec) { - double n = args.at(0).toNumber(exec); + double n = exec->argument(0).toNumber(exec); return jsBoolean(!isnan(n) && !isinf(n)); } -JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec) { static const char do_not_unescape_when_decoding_URI[] = "#$&+,/:;=?@"; - return decode(exec, args, do_not_unescape_when_decoding_URI, true); + return decode(exec, do_not_unescape_when_decoding_URI, true); } -JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec) { - return decode(exec, args, "", true); + return decode(exec, "", true); } -JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec) { static const char do_not_escape_when_encoding_URI[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -360,10 +357,10 @@ JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec, JSObject*, JSValue, c "0123456789" "!#$&'()*+,-./:;=?@_~"; - return encode(exec, args, do_not_escape_when_encoding_URI); + return encode(exec, do_not_escape_when_encoding_URI); } -JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec) { static const char do_not_escape_when_encoding_URI_component[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -371,10 +368,10 @@ JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec, JSObject*, J "0123456789" "!'()*-._~"; - return encode(exec, args, do_not_escape_when_encoding_URI_component); + return encode(exec, do_not_escape_when_encoding_URI_component); } -JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) { static const char do_not_escape[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -383,7 +380,7 @@ JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec, JSObject*, JSValue, cons "*+-./@_"; JSStringBuilder builder; - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); const UChar* c = str.data(); for (unsigned k = 0; k < str.size(); k++, c++) { int u = c[0]; @@ -403,10 +400,10 @@ JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec, JSObject*, JSValue, cons return builder.build(exec); } -JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec) { StringBuilder builder; - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); int k = 0; int len = str.size(); while (k < len) { @@ -431,9 +428,9 @@ JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec, JSObject*, JSValue, co } #ifndef NDEBUG -JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec) { - CString string = args.at(0).toString(exec).UTF8String(); + CString string = exec->argument(0).toString(exec).UTF8String(); puts(string.data()); return jsUndefined(); } diff --git a/JavaScriptCore/runtime/JSGlobalObjectFunctions.h b/JavaScriptCore/runtime/JSGlobalObjectFunctions.h index b1046f2..b1dada4 100644 --- a/JavaScriptCore/runtime/JSGlobalObjectFunctions.h +++ b/JavaScriptCore/runtime/JSGlobalObjectFunctions.h @@ -36,19 +36,19 @@ namespace JSC { // FIXME: These functions should really be in JSGlobalObject.cpp, but putting them there // is a 0.5% reduction. - JSValue JSC_HOST_CALL globalFuncEval(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncParseInt(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncEscape(ExecState*, JSObject*, JSValue, const ArgList&); - JSValue JSC_HOST_CALL globalFuncUnescape(ExecState*, JSObject*, JSValue, const ArgList&); + JSValue JSC_HOST_CALL globalFuncEval(ExecState*); + JSValue JSC_HOST_CALL globalFuncParseInt(ExecState*); + JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState*); + JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState*); + JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState*); + JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState*); + JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState*); + JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState*); + JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState*); + JSValue JSC_HOST_CALL globalFuncEscape(ExecState*); + JSValue JSC_HOST_CALL globalFuncUnescape(ExecState*); #ifndef NDEBUG - JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState*, JSObject*, JSValue, const ArgList&); + JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState*); #endif static const double mantissaOverflowLowerBound = 9007199254740992.0; diff --git a/JavaScriptCore/runtime/JSONObject.cpp b/JavaScriptCore/runtime/JSONObject.cpp index bd0e25f..86604d8 100644 --- a/JavaScriptCore/runtime/JSONObject.cpp +++ b/JavaScriptCore/runtime/JSONObject.cpp @@ -41,8 +41,8 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(JSONObject); -static JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*); +static JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*); } @@ -839,11 +839,11 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) } // ECMA-262 v5 15.12.2 -JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec) { - if (args.isEmpty()) + if (!exec->argumentCount()) return throwError(exec, GeneralError, "JSON.parse requires at least one parameter"); - JSValue value = args.at(0); + JSValue value = exec->argument(0); UString source = value.toString(exec); if (exec->hadException()) return jsNull(); @@ -853,10 +853,10 @@ JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec, JSObject*, JSValue, co if (!unfiltered) return throwError(exec, SyntaxError, "Unable to parse JSON string"); - if (args.size() < 2) + if (exec->argumentCount() < 2) return unfiltered; - JSValue function = args.at(1); + JSValue function = exec->argument(1); CallData callData; CallType callType = function.getCallData(callData); if (callType == CallTypeNone) @@ -865,13 +865,13 @@ JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec, JSObject*, JSValue, co } // ECMA-262 v5 15.12.3 -JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec) { - if (args.isEmpty()) + if (!exec->argumentCount()) return throwError(exec, GeneralError, "No input to stringify"); - JSValue value = args.at(0); - JSValue replacer = args.at(1); - JSValue space = args.at(2); + JSValue value = exec->argument(0); + JSValue replacer = exec->argument(1); + JSValue space = exec->argument(2); return Stringifier(exec, replacer, space).stringify(value); } diff --git a/JavaScriptCore/runtime/JSObject.cpp b/JavaScriptCore/runtime/JSObject.cpp index 3ac8a34..5cff4fa 100644 --- a/JavaScriptCore/runtime/JSObject.cpp +++ b/JavaScriptCore/runtime/JSObject.cpp @@ -104,18 +104,8 @@ void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue valu // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla. if (!value.isObject() && !value.isNull()) return; - - JSValue nextPrototypeValue = value; - while (nextPrototypeValue && nextPrototypeValue.isObject()) { - JSObject* nextPrototype = asObject(nextPrototypeValue)->unwrappedObject(); - if (nextPrototype == this) { - throwError(exec, GeneralError, "cyclic __proto__ value"); - return; - } - nextPrototypeValue = nextPrototype->prototype(); - } - - setPrototype(value); + if (!setPrototypeWithCycleCheck(value)) + throwError(exec, GeneralError, "cyclic __proto__ value"); return; } diff --git a/JavaScriptCore/runtime/JSObject.h b/JavaScriptCore/runtime/JSObject.h index e942ad0..0738d60 100644 --- a/JavaScriptCore/runtime/JSObject.h +++ b/JavaScriptCore/runtime/JSObject.h @@ -88,6 +88,7 @@ namespace JSC { JSValue prototype() const; void setPrototype(JSValue prototype); + bool setPrototypeWithCycleCheck(JSValue prototype); void setStructure(NonNullPassRefPtr<Structure>); Structure* inheritorID(); @@ -312,6 +313,19 @@ inline JSValue JSObject::prototype() const return m_structure->storedPrototype(); } +inline bool JSObject::setPrototypeWithCycleCheck(JSValue prototype) +{ + JSValue nextPrototypeValue = prototype; + while (nextPrototypeValue && nextPrototypeValue.isObject()) { + JSObject* nextPrototype = asObject(nextPrototypeValue)->unwrappedObject(); + if (nextPrototype == this) + return false; + nextPrototypeValue = nextPrototype->prototype(); + } + setPrototype(prototype); + return true; +} + inline void JSObject::setPrototype(JSValue prototype) { ASSERT(prototype); diff --git a/JavaScriptCore/runtime/JSString.h b/JavaScriptCore/runtime/JSString.h index dec925d..975ef45 100644 --- a/JavaScriptCore/runtime/JSString.h +++ b/JavaScriptCore/runtime/JSString.h @@ -433,7 +433,7 @@ namespace JSC { friend JSValue jsString(ExecState* exec, const UString& u1, JSString* s2); friend JSValue jsString(ExecState* exec, JSString* s1, const UString& u2); friend JSValue jsString(ExecState* exec, Register* strings, unsigned count); - friend JSValue jsString(ExecState* exec, JSValue thisValue, const ArgList& args); + friend JSValue jsString(ExecState* exec, JSValue thisValue); friend JSString* jsStringWithFinalizer(ExecState*, const UString&, JSStringFinalizerCallback callback, void* context); }; diff --git a/JavaScriptCore/runtime/Lookup.cpp b/JavaScriptCore/runtime/Lookup.cpp index 57d4f0c..50d096c 100644 --- a/JavaScriptCore/runtime/Lookup.cpp +++ b/JavaScriptCore/runtime/Lookup.cpp @@ -79,7 +79,7 @@ void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* if (!location) { NativeFunctionWrapper* function; JSGlobalObject* globalObject = asGlobalObject(thisObj->getAnonymousValue(0).asCell()); -#if ENABLE(JIT) +#if ENABLE(JIT) && ENABLE(JIT_OPTIMIZE_NATIVE_CALL) if (entry->generator()) function = new (exec) NativeFunctionWrapper(exec, globalObject, globalObject->prototypeFunctionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator())); else diff --git a/JavaScriptCore/runtime/Lookup.h b/JavaScriptCore/runtime/Lookup.h index dd36400..5a96fd3 100644 --- a/JavaScriptCore/runtime/Lookup.h +++ b/JavaScriptCore/runtime/Lookup.h @@ -76,7 +76,7 @@ namespace JSC { unsigned char attributes() const { return m_attributes; } -#if ENABLE(JIT) +#if ENABLE(JIT) && ENABLE(JIT_OPTIMIZE_NATIVE_CALL) ThunkGenerator generator() const { ASSERT(m_attributes & Function); return m_u.function.generator; } #endif NativeFunction function() const { ASSERT(m_attributes & Function); return m_u.function.functionValue; } diff --git a/JavaScriptCore/runtime/MathObject.cpp b/JavaScriptCore/runtime/MathObject.cpp index be249e5..28997db 100644 --- a/JavaScriptCore/runtime/MathObject.cpp +++ b/JavaScriptCore/runtime/MathObject.cpp @@ -34,24 +34,24 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(MathObject); -static JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*); +static JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*); } @@ -113,62 +113,62 @@ bool MathObject::getOwnPropertyDescriptor(ExecState* exec, const Identifier& pro // ------------------------------ Functions -------------------------------- -JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec) { - return jsNumber(exec, fabs(args.at(0).toNumber(exec))); + return jsNumber(exec, fabs(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec) { - return jsDoubleNumber(exec, acos(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, acos(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec) { - return jsDoubleNumber(exec, asin(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, asin(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec) { - return jsDoubleNumber(exec, atan(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, atan(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec) { - return jsDoubleNumber(exec, atan2(args.at(0).toNumber(exec), args.at(1).toNumber(exec))); + return jsDoubleNumber(exec, atan2(exec->argument(0).toNumber(exec), exec->argument(1).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec) { - return jsNumber(exec, ceil(args.at(0).toNumber(exec))); + return jsNumber(exec, ceil(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec) { - return jsDoubleNumber(exec, cos(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, cos(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec) { - return jsDoubleNumber(exec, exp(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, exp(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec) { - return jsNumber(exec, floor(args.at(0).toNumber(exec))); + return jsNumber(exec, floor(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec) { - return jsDoubleNumber(exec, log(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, log(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec) { - unsigned argsCount = args.size(); + unsigned argsCount = exec->argumentCount(); double result = -Inf; for (unsigned k = 0; k < argsCount; ++k) { - double val = args.at(k).toNumber(exec); + double val = exec->argument(k).toNumber(exec); if (isnan(val)) { result = NaN; break; @@ -179,12 +179,12 @@ JSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec, JSObject*, JSValue, cons return jsNumber(exec, result); } -JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec) { - unsigned argsCount = args.size(); + unsigned argsCount = exec->argumentCount(); double result = +Inf; for (unsigned k = 0; k < argsCount; ++k) { - double val = args.at(k).toNumber(exec); + double val = exec->argument(k).toNumber(exec); if (isnan(val)) { result = NaN; break; @@ -195,12 +195,12 @@ JSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec, JSObject*, JSValue, cons return jsNumber(exec, result); } -JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec) { // ECMA 15.8.2.1.13 - double arg = args.at(0).toNumber(exec); - double arg2 = args.at(1).toNumber(exec); + double arg = exec->argument(0).toNumber(exec); + double arg2 = exec->argument(1).toNumber(exec); if (isnan(arg2)) return jsNaN(exec); @@ -209,31 +209,31 @@ JSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec, JSObject*, JSValue, cons return jsNumber(exec, pow(arg, arg2)); } -JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec, JSObject*, JSValue, const ArgList&) +JSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec) { return jsDoubleNumber(exec, exec->globalData().weakRandom.get()); } -JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec) { - double arg = args.at(0).toNumber(exec); + double arg = exec->argument(0).toNumber(exec); double integer = ceil(arg); return jsNumber(exec, integer - (integer - arg > 0.5)); } -JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec) { - return exec->globalData().cachedSin(exec, args.at(0).toNumber(exec)); + return exec->globalData().cachedSin(exec, exec->argument(0).toNumber(exec)); } -JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec) { - return jsDoubleNumber(exec, sqrt(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, sqrt(exec->argument(0).toNumber(exec))); } -JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec) { - return jsDoubleNumber(exec, tan(args.at(0).toNumber(exec))); + return jsDoubleNumber(exec, tan(exec->argument(0).toNumber(exec))); } } // namespace JSC diff --git a/JavaScriptCore/runtime/NativeErrorConstructor.cpp b/JavaScriptCore/runtime/NativeErrorConstructor.cpp index 0fa2218..32ae6b8 100644 --- a/JavaScriptCore/runtime/NativeErrorConstructor.cpp +++ b/JavaScriptCore/runtime/NativeErrorConstructor.cpp @@ -62,9 +62,10 @@ ConstructType NativeErrorConstructor::getConstructData(ConstructData& constructD return ConstructTypeHost; } -static JSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState* exec, JSObject* constructor, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState* exec) { - return static_cast<NativeErrorConstructor*>(constructor)->construct(exec, args); + ArgList args(exec); + return static_cast<NativeErrorConstructor*>(exec->callee())->construct(exec, args); } CallType NativeErrorConstructor::getCallData(CallData& callData) diff --git a/JavaScriptCore/runtime/NumberConstructor.cpp b/JavaScriptCore/runtime/NumberConstructor.cpp index 482e87b..fe91f2e 100644 --- a/JavaScriptCore/runtime/NumberConstructor.cpp +++ b/JavaScriptCore/runtime/NumberConstructor.cpp @@ -115,9 +115,9 @@ ConstructType NumberConstructor::getConstructData(ConstructData& constructData) } // ECMA 15.7.2 -static JSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callNumberConstructor(ExecState* exec) { - return jsNumber(exec, args.isEmpty() ? 0 : args.at(0).toNumber(exec)); + return jsNumber(exec, !exec->argumentCount() ? 0 : exec->argument(0).toNumber(exec)); } CallType NumberConstructor::getCallData(CallData& callData) diff --git a/JavaScriptCore/runtime/NumberPrototype.cpp b/JavaScriptCore/runtime/NumberPrototype.cpp index efed90b..0f1590c 100644 --- a/JavaScriptCore/runtime/NumberPrototype.cpp +++ b/JavaScriptCore/runtime/NumberPrototype.cpp @@ -38,12 +38,12 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(NumberPrototype); -static JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState*); +static JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState*); +static JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState*); +static JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState*); +static JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState*); +static JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState*); // ECMA 15.7.4 @@ -137,13 +137,14 @@ static double intPow10(int e) return static_cast<double>(result); } -JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSValue v = thisValue.getJSNumber(); if (!v) return throwError(exec, TypeError); - JSValue radixValue = args.at(0); + JSValue radixValue = exec->argument(0); int radix; if (radixValue.isInt32()) radix = radixValue.asInt32(); @@ -220,8 +221,9 @@ JSValue JSC_HOST_CALL numberProtoFuncToString(ExecState* exec, JSObject*, JSValu return jsString(exec, startOfResultString); } -JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); // FIXME: Not implemented yet. JSValue v = thisValue.getJSNumber(); @@ -231,8 +233,9 @@ JSValue JSC_HOST_CALL numberProtoFuncToLocaleString(ExecState* exec, JSObject*, return jsString(exec, v.toString(exec)); } -JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSValue v = thisValue.getJSNumber(); if (!v) return throwError(exec, TypeError); @@ -240,13 +243,14 @@ JSValue JSC_HOST_CALL numberProtoFuncValueOf(ExecState* exec, JSObject*, JSValue return v; } -JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSValue v = thisValue.getJSNumber(); if (!v) return throwError(exec, TypeError); - JSValue fractionDigits = args.at(0); + JSValue fractionDigits = exec->argument(0); double df = fractionDigits.toInteger(exec); if (!(df >= 0 && df <= 20)) return throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20"); @@ -331,8 +335,9 @@ static void exponentialPartToString(char* buf, int& i, int decimalPoint) buf[i++] = static_cast<char>('0' + exponential % 10); } -JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSValue v = thisValue.getJSNumber(); if (!v) return throwError(exec, TypeError); @@ -342,7 +347,7 @@ JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec, JSObject*, J if (isnan(x) || isinf(x)) return jsString(exec, UString::from(x)); - JSValue fractionalDigitsValue = args.at(0); + JSValue fractionalDigitsValue = exec->argument(0); double df = fractionalDigitsValue.toInteger(exec); if (!(df >= 0 && df <= 20)) return throwError(exec, RangeError, "toExponential() argument must between 0 and 20"); @@ -403,15 +408,16 @@ JSValue JSC_HOST_CALL numberProtoFuncToExponential(ExecState* exec, JSObject*, J return jsString(exec, buf); } -JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSValue v = thisValue.getJSNumber(); if (!v) return throwError(exec, TypeError); - double doublePrecision = args.at(0).toIntegerPreserveNaN(exec); + double doublePrecision = exec->argument(0).toIntegerPreserveNaN(exec); double x = v.uncheckedGetNumber(); - if (args.at(0).isUndefined() || isnan(x) || isinf(x)) + if (exec->argument(0).isUndefined() || isnan(x) || isinf(x)) return jsString(exec, v.toString(exec)); UString s; diff --git a/JavaScriptCore/runtime/ObjectConstructor.cpp b/JavaScriptCore/runtime/ObjectConstructor.cpp index fe98df3..c373f87 100644 --- a/JavaScriptCore/runtime/ObjectConstructor.cpp +++ b/JavaScriptCore/runtime/ObjectConstructor.cpp @@ -34,13 +34,13 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor); -static JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectConstructorKeys(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*); +static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*); +static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*); +static JSValue JSC_HOST_CALL objectConstructorKeys(ExecState*); +static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*); +static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*); +static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*); ObjectConstructor::ObjectConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure) : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, "Object")) @@ -80,8 +80,9 @@ ConstructType ObjectConstructor::getConstructData(ConstructData& constructData) return ConstructTypeHost; } -static JSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec) { + ArgList args(exec); return constructObject(exec, args); } @@ -91,21 +92,21 @@ CallType ObjectConstructor::getCallData(CallData& callData) return CallTypeHost; } -JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec) { - if (!args.at(0).isObject()) + if (!exec->argument(0).isObject()) return throwError(exec, TypeError, "Requested prototype of a value that is not an object."); - return asObject(args.at(0))->prototype(); + return asObject(exec->argument(0))->prototype(); } -JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec) { - if (!args.at(0).isObject()) + if (!exec->argument(0).isObject()) return throwError(exec, TypeError, "Requested property descriptor of a value that is not an object."); - UString propertyName = args.at(1).toString(exec); + UString propertyName = exec->argument(1).toString(exec); if (exec->hadException()) return jsNull(); - JSObject* object = asObject(args.at(0)); + JSObject* object = asObject(exec->argument(0)); PropertyDescriptor descriptor; if (!object->getOwnPropertyDescriptor(exec, Identifier(exec, propertyName), descriptor)) return jsUndefined(); @@ -128,12 +129,12 @@ JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec, } // FIXME: Use the enumeration cache. -JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec) { - if (!args.at(0).isObject()) + if (!exec->argument(0).isObject()) return throwError(exec, TypeError, "Requested property names of a value that is not an object."); PropertyNameArray properties(exec); - asObject(args.at(0))->getOwnPropertyNames(exec, properties, IncludeDontEnumProperties); + asObject(exec->argument(0))->getOwnPropertyNames(exec, properties, IncludeDontEnumProperties); JSArray* names = constructEmptyArray(exec); size_t numProperties = properties.size(); for (size_t i = 0; i < numProperties; i++) @@ -142,12 +143,12 @@ JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec, JSOb } // FIXME: Use the enumeration cache. -JSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec) { - if (!args.at(0).isObject()) + if (!exec->argument(0).isObject()) return throwError(exec, TypeError, "Requested keys of a value that is not an object."); PropertyNameArray properties(exec); - asObject(args.at(0))->getOwnPropertyNames(exec, properties); + asObject(exec->argument(0))->getOwnPropertyNames(exec, properties); JSArray* keys = constructEmptyArray(exec); size_t numProperties = properties.size(); for (size_t i = 0; i < numProperties; i++) @@ -241,16 +242,16 @@ static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor return true; } -JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec) { - if (!args.at(0).isObject()) + if (!exec->argument(0).isObject()) return throwError(exec, TypeError, "Properties can only be defined on Objects."); - JSObject* O = asObject(args.at(0)); - UString propertyName = args.at(1).toString(exec); + JSObject* O = asObject(exec->argument(0)); + UString propertyName = exec->argument(1).toString(exec); if (exec->hadException()) return jsNull(); PropertyDescriptor descriptor; - if (!toPropertyDescriptor(exec, args.at(2), descriptor)) + if (!toPropertyDescriptor(exec, exec->argument(2), descriptor)) return jsNull(); ASSERT((descriptor.attributes() & (Getter | Setter)) || (!descriptor.isAccessorDescriptor())); ASSERT(!exec->hadException()); @@ -292,26 +293,26 @@ static JSValue defineProperties(ExecState* exec, JSObject* object, JSObject* pro return object; } -JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec) { - if (!args.at(0).isObject()) + if (!exec->argument(0).isObject()) return throwError(exec, TypeError, "Properties can only be defined on Objects."); - if (!args.at(1).isObject()) + if (!exec->argument(1).isObject()) return throwError(exec, TypeError, "Property descriptor list must be an Object."); - return defineProperties(exec, asObject(args.at(0)), asObject(args.at(1))); + return defineProperties(exec, asObject(exec->argument(0)), asObject(exec->argument(1))); } -JSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec, JSObject*, JSValue, const ArgList& args) +JSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec) { - if (!args.at(0).isObject() && !args.at(0).isNull()) + if (!exec->argument(0).isObject() && !exec->argument(0).isNull()) return throwError(exec, TypeError, "Object prototype may only be an Object or null."); JSObject* newObject = constructEmptyObject(exec); - newObject->setPrototype(args.at(0)); - if (args.at(1).isUndefined()) + newObject->setPrototype(exec->argument(0)); + if (exec->argument(1).isUndefined()) return newObject; - if (!args.at(1).isObject()) + if (!exec->argument(1).isObject()) return throwError(exec, TypeError, "Property descriptor list must be an Object."); - return defineProperties(exec, newObject, asObject(args.at(1))); + return defineProperties(exec, newObject, asObject(exec->argument(1))); } } // namespace JSC diff --git a/JavaScriptCore/runtime/ObjectPrototype.cpp b/JavaScriptCore/runtime/ObjectPrototype.cpp index 97601f3..87212da 100644 --- a/JavaScriptCore/runtime/ObjectPrototype.cpp +++ b/JavaScriptCore/runtime/ObjectPrototype.cpp @@ -31,15 +31,15 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(ObjectPrototype); -static JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*); +static JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*); ObjectPrototype::ObjectPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure) : JSObject(stucture) @@ -81,74 +81,84 @@ bool ObjectPrototype::getOwnPropertySlot(ExecState* exec, unsigned propertyName, // ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7 -JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL objectProtoFuncValueOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); return thisValue.toThisObject(exec); } -JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec) { - return jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, args.at(0).toString(exec)))); + JSValue thisValue = exec->hostThisValue(); + return jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec)))); } -JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSObject* thisObj = thisValue.toThisObject(exec); - if (!args.at(0).isObject()) + if (!exec->argument(0).isObject()) return jsBoolean(false); - JSValue v = asObject(args.at(0))->prototype(); + JSValue v = asObject(exec->argument(0))->prototype(); while (true) { if (!v.isObject()) return jsBoolean(false); - if (v == thisObj) + if (v == thisObj) return jsBoolean(true); v = asObject(v)->prototype(); } } -JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL objectProtoFuncDefineGetter(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); CallData callData; - if (args.at(1).getCallData(callData) == CallTypeNone) + if (exec->argument(1).getCallData(callData) == CallTypeNone) return throwError(exec, SyntaxError, "invalid getter usage"); - thisValue.toThisObject(exec)->defineGetter(exec, Identifier(exec, args.at(0).toString(exec)), asObject(args.at(1))); + thisValue.toThisObject(exec)->defineGetter(exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1))); return jsUndefined(); } -JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); CallData callData; - if (args.at(1).getCallData(callData) == CallTypeNone) + if (exec->argument(1).getCallData(callData) == CallTypeNone) return throwError(exec, SyntaxError, "invalid setter usage"); - thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, args.at(0).toString(exec)), asObject(args.at(1))); + thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1))); return jsUndefined(); } -JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec) { - return thisValue.toThisObject(exec)->lookupGetter(exec, Identifier(exec, args.at(0).toString(exec))); + JSValue thisValue = exec->hostThisValue(); + return thisValue.toThisObject(exec)->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec))); } -JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec) { - return thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, args.at(0).toString(exec))); + JSValue thisValue = exec->hostThisValue(); + return thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec))); } -JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec) { - return jsBoolean(thisValue.toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, args.at(0).toString(exec)))); + JSValue thisValue = exec->hostThisValue(); + return jsBoolean(thisValue.toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec)))); } -JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); return thisValue.toThisJSString(exec); } -JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); return jsMakeNontrivialString(exec, "[object ", thisValue.toThisObject(exec)->className(), "]"); } diff --git a/JavaScriptCore/runtime/ObjectPrototype.h b/JavaScriptCore/runtime/ObjectPrototype.h index 47065d7..8865d6b 100644 --- a/JavaScriptCore/runtime/ObjectPrototype.h +++ b/JavaScriptCore/runtime/ObjectPrototype.h @@ -36,7 +36,7 @@ namespace JSC { bool m_hasNoPropertiesWithUInt32Names; }; - JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); + JSValue JSC_HOST_CALL objectProtoFuncToString(ExecState*); } // namespace JSC diff --git a/JavaScriptCore/runtime/Operations.h b/JavaScriptCore/runtime/Operations.h index 1228902..bd6c205 100644 --- a/JavaScriptCore/runtime/Operations.h +++ b/JavaScriptCore/runtime/Operations.h @@ -189,15 +189,15 @@ namespace JSC { return new (globalData) JSString(globalData, ropeBuilder.release()); } - ALWAYS_INLINE JSValue jsString(ExecState* exec, JSValue thisValue, const ArgList& args) + ALWAYS_INLINE JSValue jsString(ExecState* exec, JSValue thisValue) { unsigned fiberCount = 0; if (LIKELY(thisValue.isString())) fiberCount += asString(thisValue)->size(); else ++fiberCount; - for (unsigned i = 0; i < args.size(); ++i) { - JSValue v = args.at(i); + for (unsigned i = 0; i < exec->argumentCount(); ++i) { + JSValue v = exec->argument(i); if (LIKELY(v.isString())) fiberCount += asString(v)->size(); else @@ -216,8 +216,8 @@ namespace JSC { unsigned length = 0; bool overflow = false; - for (unsigned i = 0; i < args.size(); ++i) { - JSValue v = args.at(i); + for (unsigned i = 0; i < exec->argumentCount(); ++i) { + JSValue v = exec->argument(i); if (LIKELY(v.isString())) ropeBuilder.append(asString(v)); else diff --git a/JavaScriptCore/runtime/PropertySlot.cpp b/JavaScriptCore/runtime/PropertySlot.cpp index 2306a11..fd16c0c 100644 --- a/JavaScriptCore/runtime/PropertySlot.cpp +++ b/JavaScriptCore/runtime/PropertySlot.cpp @@ -34,11 +34,7 @@ JSValue PropertySlot::functionGetter(ExecState* exec) const CallData callData; CallType callType = m_data.getterFunc->getCallData(callData); - if (callType == CallTypeHost) - return callData.native.function(exec, m_data.getterFunc, thisValue(), exec->emptyList()); - ASSERT(callType == CallTypeJS); - // FIXME: Can this be done more efficiently using the callData? - return asFunction(m_data.getterFunc)->call(exec, thisValue(), exec->emptyList()); + return call(exec, m_data.getterFunc, callType, callData, thisValue(), exec->emptyList()); } } // namespace JSC diff --git a/JavaScriptCore/runtime/RegExpConstructor.cpp b/JavaScriptCore/runtime/RegExpConstructor.cpp index e7e6109..c79d5f8 100644 --- a/JavaScriptCore/runtime/RegExpConstructor.cpp +++ b/JavaScriptCore/runtime/RegExpConstructor.cpp @@ -319,8 +319,9 @@ ConstructType RegExpConstructor::getConstructData(ConstructData& constructData) } // ECMA 15.10.3 -static JSValue JSC_HOST_CALL callRegExpConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callRegExpConstructor(ExecState* exec) { + ArgList args(exec); return constructRegExp(exec, args); } diff --git a/JavaScriptCore/runtime/RegExpObject.cpp b/JavaScriptCore/runtime/RegExpObject.cpp index b04b55e..acec966 100644 --- a/JavaScriptCore/runtime/RegExpObject.cpp +++ b/JavaScriptCore/runtime/RegExpObject.cpp @@ -113,21 +113,21 @@ void setRegExpObjectLastIndex(ExecState* exec, JSObject* baseObject, JSValue val asRegExpObject(baseObject)->setLastIndex(value.toInteger(exec)); } -JSValue RegExpObject::test(ExecState* exec, const ArgList& args) +JSValue RegExpObject::test(ExecState* exec) { - return jsBoolean(match(exec, args)); + return jsBoolean(match(exec)); } -JSValue RegExpObject::exec(ExecState* exec, const ArgList& args) +JSValue RegExpObject::exec(ExecState* exec) { - if (match(exec, args)) + if (match(exec)) return exec->lexicalGlobalObject()->regExpConstructor()->arrayOfMatches(exec); return jsNull(); } -static JSValue JSC_HOST_CALL callRegExpObject(ExecState* exec, JSObject* function, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callRegExpObject(ExecState* exec) { - return asRegExpObject(function)->exec(exec, args); + return asRegExpObject(exec->callee())->exec(exec); } CallType RegExpObject::getCallData(CallData& callData) @@ -137,11 +137,11 @@ CallType RegExpObject::getCallData(CallData& callData) } // Shared implementation used by test and exec. -bool RegExpObject::match(ExecState* exec, const ArgList& args) +bool RegExpObject::match(ExecState* exec) { RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor(); - UString input = args.isEmpty() ? regExpConstructor->input() : args.at(0).toString(exec); + UString input = !exec->argumentCount() ? regExpConstructor->input() : exec->argument(0).toString(exec); if (input.isNull()) { throwError(exec, GeneralError, makeString("No input to ", toString(exec), ".")); return false; diff --git a/JavaScriptCore/runtime/RegExpObject.h b/JavaScriptCore/runtime/RegExpObject.h index 3324e53..f997374 100644 --- a/JavaScriptCore/runtime/RegExpObject.h +++ b/JavaScriptCore/runtime/RegExpObject.h @@ -37,8 +37,8 @@ namespace JSC { void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; } double lastIndex() const { return d->lastIndex; } - JSValue test(ExecState*, const ArgList&); - JSValue exec(ExecState*, const ArgList&); + JSValue test(ExecState*); + JSValue exec(ExecState*); virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); @@ -56,7 +56,7 @@ namespace JSC { static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObjectWithGlobalObject::StructureFlags; private: - bool match(ExecState*, const ArgList&); + bool match(ExecState*); virtual CallType getCallData(CallData&); diff --git a/JavaScriptCore/runtime/RegExpPrototype.cpp b/JavaScriptCore/runtime/RegExpPrototype.cpp index 9ebf105..0a531ac 100644 --- a/JavaScriptCore/runtime/RegExpPrototype.cpp +++ b/JavaScriptCore/runtime/RegExpPrototype.cpp @@ -38,10 +38,10 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(RegExpPrototype); -static JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*); +static JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*); +static JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*); +static JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*); // ECMA 15.10.5 @@ -58,35 +58,38 @@ RegExpPrototype::RegExpPrototype(ExecState* exec, JSGlobalObject* globalObject, // ------------------------------ Functions --------------------------- -JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&RegExpObject::info)) return throwError(exec, TypeError); - return asRegExpObject(thisValue)->test(exec, args); + return asRegExpObject(thisValue)->test(exec); } -JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&RegExpObject::info)) return throwError(exec, TypeError); - return asRegExpObject(thisValue)->exec(exec, args); + return asRegExpObject(thisValue)->exec(exec); } -JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&RegExpObject::info)) return throwError(exec, TypeError); RefPtr<RegExp> regExp; - JSValue arg0 = args.at(0); - JSValue arg1 = args.at(1); + JSValue arg0 = exec->argument(0); + JSValue arg1 = exec->argument(1); if (arg0.inherits(&RegExpObject::info)) { if (!arg1.isUndefined()) return throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another."); regExp = asRegExpObject(arg0)->regExp(); } else { - UString pattern = args.isEmpty() ? UString("") : arg0.toString(exec); + UString pattern = !exec->argumentCount() ? UString("") : arg0.toString(exec); UString flags = arg1.isUndefined() ? UString("") : arg1.toString(exec); regExp = RegExp::create(&exec->globalData(), pattern, flags); } @@ -99,8 +102,9 @@ JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec, JSObject*, JSValue return jsUndefined(); } -JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&RegExpObject::info)) { if (thisValue.inherits(&RegExpPrototype::info)) return jsNontrivialString(exec, "//"); diff --git a/JavaScriptCore/runtime/StringConstructor.cpp b/JavaScriptCore/runtime/StringConstructor.cpp index b5c46b6..c1484c5 100644 --- a/JavaScriptCore/runtime/StringConstructor.cpp +++ b/JavaScriptCore/runtime/StringConstructor.cpp @@ -30,21 +30,21 @@ namespace JSC { -static NEVER_INLINE JSValue stringFromCharCodeSlowCase(ExecState* exec, const ArgList& args) +static NEVER_INLINE JSValue stringFromCharCodeSlowCase(ExecState* exec) { - unsigned length = args.size(); + unsigned length = exec->argumentCount(); UChar* buf; PassRefPtr<UStringImpl> impl = UStringImpl::createUninitialized(length, buf); for (unsigned i = 0; i < length; ++i) - buf[i] = static_cast<UChar>(args.at(i).toUInt32(exec)); + buf[i] = static_cast<UChar>(exec->argument(i).toUInt32(exec)); return jsString(exec, impl); } -static JSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec) { - if (LIKELY(args.size() == 1)) - return jsSingleCharacterString(exec, args.at(0).toUInt32(exec)); - return stringFromCharCodeSlowCase(exec, args); + if (LIKELY(exec->argumentCount() == 1)) + return jsSingleCharacterString(exec, exec->argument(0).toUInt32(exec)); + return stringFromCharCodeSlowCase(exec); } ASSERT_CLASS_FITS_IN_CELL(StringConstructor); @@ -56,7 +56,7 @@ StringConstructor::StringConstructor(ExecState* exec, JSGlobalObject* globalObje putDirectWithoutTransition(exec->propertyNames().prototype, stringPrototype, ReadOnly | DontEnum | DontDelete); // ECMA 15.5.3.2 fromCharCode() -#if ENABLE(JIT) +#if ENABLE(JIT) && ENABLE(JIT_OPTIMIZE_NATIVE_CALL) putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, exec->globalData().getHostFunction(stringFromCharCode, fromCharCodeThunkGenerator)), DontEnum); #else putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum); @@ -80,11 +80,11 @@ ConstructType StringConstructor::getConstructData(ConstructData& constructData) } // ECMA 15.5.1 -static JSValue JSC_HOST_CALL callStringConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args) +static JSValue JSC_HOST_CALL callStringConstructor(ExecState* exec) { - if (args.isEmpty()) + if (!exec->argumentCount()) return jsEmptyString(exec); - return jsString(exec, args.at(0).toString(exec)); + return jsString(exec, exec->argument(0).toString(exec)); } CallType StringConstructor::getCallData(CallData& callData) diff --git a/JavaScriptCore/runtime/StringPrototype.cpp b/JavaScriptCore/runtime/StringPrototype.cpp index 9df3dbb..f90d908 100644 --- a/JavaScriptCore/runtime/StringPrototype.cpp +++ b/JavaScriptCore/runtime/StringPrototype.cpp @@ -45,40 +45,38 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(StringPrototype); -static JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState*, JSObject*, JSValue, const ArgList&); - -static JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState*, JSObject*, JSValue, const ArgList&); - -static JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState*, JSObject*, JSValue, const ArgList&); +static JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState*); +static JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState*); } @@ -288,11 +286,12 @@ static ALWAYS_INLINE JSValue jsSpliceSubstringsWithSeparators(ExecState* exec, J return jsString(exec, impl); } -JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSString* sourceVal = thisValue.toThisJSString(exec); - JSValue pattern = args.at(0); - JSValue replacement = args.at(1); + JSValue pattern = exec->argument(0); + JSValue replacement = exec->argument(1); UString replacementString; CallData callData; @@ -449,8 +448,9 @@ JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue return jsString(exec, source.substr(0, matchPos), substituteBackreferences(replacementString, source, ovector, 0), source.substr(matchEnd)); } -JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); // Also used for valueOf. if (thisValue.isString()) @@ -462,11 +462,12 @@ JSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec, JSObject*, JSValu return throwError(exec, TypeError); } -JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); unsigned len = s.size(); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); if (a0.isUInt32()) { uint32_t i = a0.asUInt32(); if (i < len) @@ -479,11 +480,12 @@ JSValue JSC_HOST_CALL stringProtoFuncCharAt(ExecState* exec, JSObject*, JSValue return jsEmptyString(exec); } -JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); unsigned len = s.size(); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); if (a0.isUInt32()) { uint32_t i = a0.asUInt32(); if (i < len) @@ -496,25 +498,27 @@ JSValue JSC_HOST_CALL stringProtoFuncCharCodeAt(ExecState* exec, JSObject*, JSVa return jsNaN(exec); } -JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState* exec) { - if (thisValue.isString() && (args.size() == 1)) { - JSValue v = args.at(0); + JSValue thisValue = exec->hostThisValue(); + if (thisValue.isString() && (exec->argumentCount() == 1)) { + JSValue v = exec->argument(0); return v.isString() ? jsString(exec, asString(thisValue), asString(v)) : jsString(exec, asString(thisValue), v.toString(exec)); } - return jsString(exec, thisValue, args); + return jsString(exec, thisValue); } -JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); int len = s.size(); - JSValue a0 = args.at(0); - JSValue a1 = args.at(1); + JSValue a0 = exec->argument(0); + JSValue a1 = exec->argument(1); UString u2 = a0.toString(exec); int pos; if (a1.isUndefined()) @@ -536,13 +540,14 @@ JSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue return jsNumber(exec, result); } -JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); int len = s.size(); - JSValue a0 = args.at(0); - JSValue a1 = args.at(1); + JSValue a0 = exec->argument(0); + JSValue a1 = exec->argument(1); UString u2 = a0.toString(exec); double dpos = a1.toIntegerPreserveNaN(exec); @@ -562,11 +567,12 @@ JSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSV return jsNumber(exec, result); } -JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); UString u = s; RefPtr<RegExp> reg; @@ -613,11 +619,12 @@ JSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec, JSObject*, JSValue t return constructArray(exec, list); } -JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); UString u = s; RefPtr<RegExp> reg; @@ -638,13 +645,14 @@ JSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec, JSObject*, JSValue return jsNumber(exec, pos); } -JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); int len = s.size(); - JSValue a0 = args.at(0); - JSValue a1 = args.at(1); + JSValue a0 = exec->argument(0); + JSValue a1 = exec->argument(1); // The arg processing is very much like ArrayProtoFunc::Slice double start = a0.toInteger(exec); @@ -662,12 +670,13 @@ JSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec, JSObject*, JSValue t return jsEmptyString(exec); } -JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); - JSValue a1 = args.at(1); + JSValue a0 = exec->argument(0); + JSValue a1 = exec->argument(1); JSArray* result = constructEmptyArray(exec); unsigned i = 0; @@ -725,13 +734,14 @@ JSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState* exec, JSObject*, JSValue t return result; } -JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); int len = s.size(); - JSValue a0 = args.at(0); - JSValue a1 = args.at(1); + JSValue a0 = exec->argument(0); + JSValue a1 = exec->argument(1); double start = a0.toInteger(exec); double length = a1.isUndefined() ? len : a1.toInteger(exec); @@ -747,13 +757,14 @@ JSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec, JSObject*, JSValue return jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(length)); } -JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); int len = s.size(); - JSValue a0 = args.at(0); - JSValue a1 = args.at(1); + JSValue a0 = exec->argument(0); + JSValue a1 = exec->argument(1); double start = a0.toNumber(exec); double end; @@ -778,8 +789,9 @@ JSValue JSC_HOST_CALL stringProtoFuncSubstring(ExecState* exec, JSObject*, JSVal return jsSubstring(exec, s, static_cast<unsigned>(start), static_cast<unsigned>(end) - static_cast<unsigned>(start)); } -JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSString* sVal = thisValue.toThisJSString(exec); const UString& s = sVal->value(exec); @@ -815,8 +827,9 @@ JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSV return jsString(exec, UString::adopt(buffer)); } -JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); JSString* sVal = thisValue.toThisJSString(exec); const UString& s = sVal->value(exec); @@ -852,81 +865,93 @@ JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSV return jsString(exec, UString::adopt(buffer)); } -JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec) { - if (args.size() < 1) + JSValue thisValue = exec->hostThisValue(); + if (exec->argumentCount() < 1) return jsNumber(exec, 0); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); return jsNumber(exec, localeCompare(s, a0.toString(exec))); } -JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncBig(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<big>", s, "</big>"); } -JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncSmall(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<small>", s, "</small>"); } -JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncBlink(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<blink>", s, "</blink>"); } -JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncBold(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<b>", s, "</b>"); } -JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncFixed(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<tt>", s, "</tt>"); } -JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncItalics(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<i>", s, "</i>"); } -JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncStrike(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<strike>", s, "</strike>"); } -JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncSub(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<sub>", s, "</sub>"); } -JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncSup(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); return jsMakeNontrivialString(exec, "<sup>", s, "</sup>"); } -JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncFontcolor(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); return jsMakeNontrivialString(exec, "<font color=\"", a0.toString(exec), "\">", s, "</font>"); } -JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); uint32_t smallInteger; if (a0.getUInt32(smallInteger) && smallInteger <= 9) { @@ -965,17 +990,19 @@ JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValu return jsMakeNontrivialString(exec, "<font size=\"", a0.toString(exec), "\">", s, "</font>"); } -JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); return jsMakeNontrivialString(exec, "<a name=\"", a0.toString(exec), "\">", s, "</a>"); } -JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); UString s = thisValue.toThisString(exec); - JSValue a0 = args.at(0); + JSValue a0 = exec->argument(0); UString linkText = a0.toString(exec); unsigned linkTextSize = linkText.size(); @@ -1036,18 +1063,21 @@ static inline JSValue trimString(ExecState* exec, JSValue thisValue, int trimKin return jsString(exec, str.substr(left, right - left)); } -JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); return trimString(exec, thisValue, TrimLeft | TrimRight); } -JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncTrimLeft(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); return trimString(exec, thisValue, TrimLeft); } -JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) +JSValue JSC_HOST_CALL stringProtoFuncTrimRight(ExecState* exec) { + JSValue thisValue = exec->hostThisValue(); return trimString(exec, thisValue, TrimRight); } diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp index bdc896d..1c11936 100644 --- a/JavaScriptCore/runtime/UString.cpp +++ b/JavaScriptCore/runtime/UString.cpp @@ -262,6 +262,11 @@ double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) co // encounters invalid UTF-16. Further, we have no need to convert the // non-ASCII characters to UTF-8, so the UTF8String does quite a bit of // unnecessary work. + + // FIXME: The space skipping code below skips only ASCII spaces, but callers + // need to skip all StrWhiteSpace. The isStrWhiteSpace function does the + // right thing but requires UChar, not char, for its argument. + CString s = UTF8String(); if (s.isNull()) return NaN; @@ -324,13 +329,13 @@ double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) co } } - // allow trailing white space - while (isASCIISpace(*c)) - c++; - // don't allow anything after - unless tolerant=true - // FIXME: If string contains a U+0000 character, then this check is incorrect. - if (!tolerateTrailingJunk && *c != '\0') - d = NaN; + if (!tolerateTrailingJunk) { + // allow trailing white space + while (isASCIISpace(*c)) + c++; + if (c != s.data() + s.length()) + d = NaN; + } return d; } @@ -575,29 +580,6 @@ bool operator>(const UString& s1, const UString& s2) return (l1 > l2); } -int compare(const UString& s1, const UString& s2) -{ - const unsigned l1 = s1.size(); - const unsigned l2 = s2.size(); - const unsigned lmin = l1 < l2 ? l1 : l2; - const UChar* c1 = s1.data(); - const UChar* c2 = s2.data(); - unsigned l = 0; - while (l < lmin && *c1 == *c2) { - c1++; - c2++; - l++; - } - - if (l < lmin) - return (c1[0] > c2[0]) ? 1 : -1; - - if (l1 == l2) - return 0; - - return (l1 > l2) ? 1 : -1; -} - CString UString::UTF8String(bool strict) const { // Allocate a buffer big enough to hold all the characters. diff --git a/JavaScriptCore/runtime/UString.h b/JavaScriptCore/runtime/UString.h index a97e0d7..4364021 100644 --- a/JavaScriptCore/runtime/UString.h +++ b/JavaScriptCore/runtime/UString.h @@ -202,7 +202,10 @@ namespace JSC { return !JSC::operator==(s1, s2); } - int compare(const UString&, const UString&); + inline int codePointCompare(const UString& s1, const UString& s2) + { + return codePointCompare(s1.rep(), s2.rep()); + } // Rule from ECMA 15.2 about what an array index is. // Must exactly match string form of an unsigned integer, and be less than 2^32 - 1. |