ClonedArguments* ClonedArguments::createEmpty(ExecState* exec, JSFunction* callee, unsigned length) { VM& vm = exec->vm(); // NB. Some clients might expect that the global object of of this object is the global object // of the callee. We don't do this for now, but maybe we should. ClonedArguments* result = createEmpty(vm, exec->lexicalGlobalObject()->clonedArgumentsStructure(), callee, length); ASSERT(!result->structure(vm)->needsSlowPutIndexing() || shouldUseSlowPut(result->structure(vm)->indexingType())); return result; }
ClonedArguments* ClonedArguments::createByCopyingFrom( ExecState* exec, Structure* structure, Register* argumentStart, unsigned length, JSFunction* callee) { VM& vm = exec->vm(); ClonedArguments* result = createEmpty(vm, structure, callee, length); for (unsigned i = length; i--;) result->initializeIndex(vm, i, argumentStart[i].jsValue()); ASSERT(!result->structure(vm)->needsSlowPutIndexing() || shouldUseSlowPut(result->structure(vm)->indexingType())); return result; }
ClonedArguments* ClonedArguments::createWithInlineFrame(ExecState* myFrame, ExecState* targetFrame, InlineCallFrame* inlineCallFrame, ArgumentsMode mode) { VM& vm = myFrame->vm(); JSFunction* callee; if (inlineCallFrame) callee = jsCast<JSFunction*>(inlineCallFrame->calleeRecovery.recover(targetFrame)); else callee = jsCast<JSFunction*>(targetFrame->jsCallee()); ClonedArguments* result = nullptr; unsigned length = 0; // Initialize because VC needs it. switch (mode) { case ArgumentsMode::Cloned: { if (inlineCallFrame) { if (inlineCallFrame->argumentCountRegister.isValid()) length = targetFrame->r(inlineCallFrame->argumentCountRegister).unboxedInt32(); else length = inlineCallFrame->arguments.size(); length--; result = createEmpty(myFrame, callee, length); for (unsigned i = length; i--;) result->initializeIndex(vm, i, inlineCallFrame->arguments[i + 1].recover(targetFrame)); } else { length = targetFrame->argumentCount(); result = createEmpty(myFrame, callee, length); for (unsigned i = length; i--;) result->initializeIndex(vm, i, targetFrame->uncheckedArgument(i)); } break; } case ArgumentsMode::FakeValues: { result = createEmpty(myFrame, callee, 0); break; } } ASSERT(myFrame->lexicalGlobalObject()->clonedArgumentsStructure() == result->structure()); ASSERT(!result->structure(vm)->needsSlowPutIndexing() || shouldUseSlowPut(result->structure(vm)->indexingType())); return result; }
ClonedArguments* ClonedArguments::createWithMachineFrame(ExecState* myFrame, ExecState* targetFrame, ArgumentsMode mode) { ClonedArguments* result = createWithInlineFrame(myFrame, targetFrame, nullptr, mode); ASSERT(!result->structure()->needsSlowPutIndexing() || shouldUseSlowPut(result->structure()->indexingType())); return result; }