diff options
Diffstat (limited to 'JavaScriptCore/runtime/Arguments.h')
| -rw-r--r-- | JavaScriptCore/runtime/Arguments.h | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/JavaScriptCore/runtime/Arguments.h b/JavaScriptCore/runtime/Arguments.h index 9797e08..715a2ac 100644 --- a/JavaScriptCore/runtime/Arguments.h +++ b/JavaScriptCore/runtime/Arguments.h @@ -50,11 +50,17 @@ namespace JSC { JSFunction* callee; bool overrodeLength : 1; bool overrodeCallee : 1; + bool overrodeCaller : 1; + bool isStrictMode : 1; }; class Arguments : public JSObject { public: + // Use an enum because otherwise gcc insists on doing a memory + // read. + enum { MaxArguments = 0x10000 }; + enum NoParametersType { NoParameters }; Arguments(CallFrame*); @@ -101,6 +107,8 @@ namespace JSC { virtual void put(ExecState*, unsigned propertyName, JSValue, PutPropertySlot&); virtual bool deleteProperty(ExecState*, const Identifier& propertyName); virtual bool deleteProperty(ExecState*, unsigned propertyName); + void createStrictModeCallerIfNecessary(ExecState*); + void createStrictModeCalleeIfNecessary(ExecState*); virtual const ClassInfo* classInfo() const { return &info; } @@ -119,10 +127,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; @@ -135,7 +143,7 @@ namespace JSC { inline Arguments::Arguments(CallFrame* callFrame) : JSObject(callFrame->lexicalGlobalObject()->argumentsStructure()) - , d(new ArgumentsData) + , d(adoptPtr(new ArgumentsData)) { JSFunction* callee; ptrdiff_t firstParameterIndex; @@ -168,15 +176,19 @@ namespace JSC { d->callee = callee; d->overrodeLength = false; d->overrodeCallee = false; + d->overrodeCaller = false; + d->isStrictMode = callFrame->codeBlock()->isStrictMode(); + if (d->isStrictMode) + copyRegisters(); } inline Arguments::Arguments(CallFrame* callFrame, NoParametersType) : JSObject(callFrame->lexicalGlobalObject()->argumentsStructure()) - , d(new ArgumentsData) + , d(adoptPtr(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,9 +206,13 @@ namespace JSC { d->extraArguments = extraArguments; - d->callee = callFrame->callee(); + d->callee = asFunction(callFrame->callee()); d->overrodeLength = false; d->overrodeCallee = false; + d->overrodeCaller = false; + d->isStrictMode = callFrame->codeBlock()->isStrictMode(); + if (d->isStrictMode) + copyRegisters(); } inline void Arguments::copyRegisters() @@ -216,12 +232,12 @@ namespace JSC { } // This JSActivation function is defined here so it can get at Arguments::setRegisters. - inline void JSActivation::copyRegisters(Arguments* arguments) + inline void JSActivation::copyRegisters() { ASSERT(!d()->registerArray); - size_t numParametersMinusThis = d()->functionExecutable->generatedBytecode().m_numParameters - 1; - size_t numVars = d()->functionExecutable->generatedBytecode().m_numVars; + size_t numParametersMinusThis = d()->functionExecutable->parameterCount(); + size_t numVars = d()->functionExecutable->capturedVariableCount(); size_t numLocals = numVars + numParametersMinusThis; if (!numLocals) @@ -232,17 +248,7 @@ namespace JSC { Register* registerArray = copyRegisterArray(d()->registers - registerOffset, registerArraySize); setRegisters(registerArray + registerOffset, registerArray); - if (arguments && !arguments->isTornOff()) - static_cast<Arguments*>(arguments)->setActivation(this); - } - - ALWAYS_INLINE Arguments* Register::arguments() const - { - if (jsValue() == JSValue()) - return 0; - return asArguments(jsValue()); } - } // namespace JSC |
