JSCell* JIT_OPERATION operationCreateClonedArgumentsDuringExit(ExecState* exec, InlineCallFrame* inlineCallFrame, JSFunction* callee, int32_t argumentCount) { VM& vm = exec->vm(); NativeCallFrameTracer target(&vm, exec); DeferGCForAWhile deferGC(vm.heap); CodeBlock* codeBlock; if (inlineCallFrame) codeBlock = baselineCodeBlockForInlineCallFrame(inlineCallFrame); else codeBlock = exec->codeBlock(); unsigned length = argumentCount - 1; ClonedArguments* result = ClonedArguments::createEmpty( vm, codeBlock->globalObject()->outOfBandArgumentsStructure(), callee); Register* arguments = exec->registers() + (inlineCallFrame ? inlineCallFrame->stackOffset : 0) + CallFrame::argumentOffset(0); for (unsigned i = length; i--;) result->putDirectIndex(exec, i, arguments[i].jsValue()); result->putDirect(vm, vm.propertyNames->length, jsNumber(length)); 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->callee()); ClonedArguments* result = createEmpty(myFrame, callee); 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--; for (unsigned i = length; i--;) result->putDirectIndex(myFrame, i, inlineCallFrame->arguments[i + 1].recover(targetFrame)); } else { length = targetFrame->argumentCount(); for (unsigned i = length; i--;) result->putDirectIndex(myFrame, i, targetFrame->uncheckedArgument(i)); } break; } case ArgumentsMode::FakeValues: { length = 0; break; } } result->putDirect(vm, vm.propertyNames->length, jsNumber(length), DontEnum); 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); for (unsigned i = length; i--;) result->putDirectIndex(exec, i, argumentStart[i].jsValue()); result->putDirect(vm, vm.propertyNames->length, jsNumber(length), DontEnum); return result; }