Changeset 60392 in webkit for trunk/JavaScriptCore/interpreter/Interpreter.cpp
- Timestamp:
- May 28, 2010, 11:33:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r60117 r60392 376 376 JSValue result = jsUndefined(); 377 377 if (eval) 378 result = callFrame->globalData().interpreter->execute(eval.get(), callFrame, callFrame-> thisValue().toThisObject(callFrame), callFrame->registers() - registerFile->start() + registerOffset, scopeChain, &exceptionValue);378 result = callFrame->globalData().interpreter->execute(eval.get(), callFrame, callFrame->r(codeBlock->thisRegister()).jsValue().toThisObject(callFrame), callFrame->registers() - registerFile->start() + registerOffset, scopeChain, &exceptionValue); 379 379 380 380 return result; … … 629 629 } 630 630 631 // Now unwind the scope chain within the exception handler's call frame. 632 631 // Shrink the JS stack, in case stack overflow made it huge. 632 m_registerFile.shrink(callFrame->registers() + callFrame->codeBlock()->m_numCalleeRegisters); 633 634 // Unwind the scope chain within the exception handler's call frame. 633 635 ScopeChainNode* scopeChain = callFrame->scopeChain(); 634 636 ScopeChain sc(scopeChain); … … 662 664 } 663 665 664 DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);665 666 666 JSGlobalObject* lastGlobalObject = m_registerFile.globalObject(); 667 667 JSGlobalObject* globalObject = callFrame->dynamicGlobalObject(); … … 669 669 670 670 CallFrame* newCallFrame = CallFrame::create(oldEnd + codeBlock->m_numParameters + RegisterFile::CallFrameHeaderSize); 671 newCallFrame->r(codeBlock->thisRegister()) = JSValue(thisObj); 672 newCallFrame->init(codeBlock, 0, scopeChain, CallFrame::noCaller(), 0, 0, 0); 671 ASSERT(codeBlock->m_numParameters == 1); // 1 parameter for 'this'. 672 newCallFrame->init(codeBlock, 0, scopeChain, CallFrame::noCaller(), codeBlock->m_numParameters, 0); 673 newCallFrame->r(newCallFrame->hostThisRegister()) = JSValue(thisObj); 673 674 674 675 if (codeBlock->needsFullScopeChain()) 675 676 scopeChain->ref(); 677 678 DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject); 676 679 677 680 Profiler** profiler = Profiler::enabledProfilerReference(); … … 703 706 } 704 707 705 JSValue Interpreter::executeCall( FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)708 JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args, JSValue* exception) 706 709 { 707 ASSERT(! scopeChain->globalData->exception);710 ASSERT(!callFrame->hadException()); 708 711 709 712 if (m_reentryDepth >= MaxSmallThreadReentryDepth) { … … 715 718 716 719 Register* oldEnd = m_registerFile.end(); 720 int argCount = 1 + args.size(); // implicit "this" parameter 721 size_t registerOffset = argCount + RegisterFile::CallFrameHeaderSize; 722 723 if (!m_registerFile.grow(oldEnd + registerOffset)) { 724 *exception = createStackOverflowError(callFrame); 725 return jsNull(); 726 } 727 728 CallFrame* newCallFrame = CallFrame::create(oldEnd); 729 size_t dst = 0; 730 newCallFrame->r(0) = thisValue; 731 ArgList::const_iterator end = args.end(); 732 for (ArgList::const_iterator it = args.begin(); it != end; ++it) 733 newCallFrame->r(++dst) = *it; 734 735 if (callType == CallTypeJS) { 736 ScopeChainNode* callDataScopeChain = callData.js.scopeChain; 737 CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain); 738 739 newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount); 740 if (UNLIKELY(!newCallFrame)) { 741 *exception = createStackOverflowError(callFrame); 742 m_registerFile.shrink(oldEnd); 743 return jsNull(); 744 } 745 746 newCallFrame->init(newCodeBlock, 0, callDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, function); 747 748 DynamicGlobalObjectScope globalObjectScope(newCallFrame, callDataScopeChain->globalObject); 749 750 Profiler** profiler = Profiler::enabledProfilerReference(); 751 if (*profiler) 752 (*profiler)->willExecute(newCallFrame, function); 753 754 JSValue result; 755 { 756 SamplingTool::CallRecord callRecord(m_sampler.get()); 757 758 m_reentryDepth++; 759 #if ENABLE(JIT) 760 result = callData.js.functionExecutable->jitCodeForCall(newCallFrame, callDataScopeChain).execute(&m_registerFile, newCallFrame, callDataScopeChain->globalData, exception); 761 #else 762 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception); 763 #endif 764 m_reentryDepth--; 765 } 766 767 if (*profiler) 768 (*profiler)->didExecute(newCallFrame, function); 769 770 m_registerFile.shrink(oldEnd); 771 return result; 772 } 773 774 ASSERT(callType == CallTypeHost); 775 ScopeChainNode* scopeChain = callFrame->scopeChain(); 776 newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset); 777 newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, function); 778 779 DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject); 780 781 Profiler** profiler = Profiler::enabledProfilerReference(); 782 if (*profiler) 783 (*profiler)->willExecute(newCallFrame, function); 784 785 JSValue result; 786 { 787 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 788 result = callData.native.function(newCallFrame); 789 } 790 791 if (*profiler) 792 (*profiler)->didExecute(newCallFrame, function); 793 794 m_registerFile.shrink(oldEnd); 795 return result; 796 } 797 798 JSValue Interpreter::executeConstruct(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception) 799 { 800 ASSERT(!scopeChain->globalData->exception); 801 802 if (m_reentryDepth >= MaxSmallThreadReentryDepth) { 803 if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) { 804 *exception = createStackOverflowError(callFrame); 805 return jsNull(); 806 } 807 } 808 809 Register* oldEnd = m_registerFile.end(); 717 810 int argc = 1 + args.size(); // implicit "this" parameter 718 811 … … 721 814 return jsNull(); 722 815 } 723 724 DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);725 816 726 817 CallFrame* newCallFrame = CallFrame::create(oldEnd); … … 731 822 newCallFrame->r(++dst) = *it; 732 823 733 CodeBlock* codeBlock = &functionExecutable->bytecodeForCall(callFrame, scopeChain);734 newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);735 if (UNLIKELY(!newCallFrame)) {736 *exception = createStackOverflowError(callFrame);737 m_registerFile.shrink(oldEnd);738 return jsNull();739 }740 // a 0 codeBlock indicates a built-in caller741 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, argc, function);742 743 Profiler** profiler = Profiler::enabledProfilerReference();744 if (*profiler)745 (*profiler)->willExecute(callFrame, function);746 747 JSValue result;748 {749 SamplingTool::CallRecord callRecord(m_sampler.get());750 751 m_reentryDepth++;752 #if ENABLE(JIT)753 result = functionExecutable->jitCodeForCall(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);754 #else755 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);756 #endif757 m_reentryDepth--;758 }759 760 if (*profiler)761 (*profiler)->didExecute(callFrame, function);762 763 m_registerFile.shrink(oldEnd);764 return result;765 }766 767 JSValue Interpreter::executeConstruct(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)768 {769 ASSERT(!scopeChain->globalData->exception);770 771 if (m_reentryDepth >= MaxSmallThreadReentryDepth) {772 if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) {773 *exception = createStackOverflowError(callFrame);774 return jsNull();775 }776 }777 778 Register* oldEnd = m_registerFile.end();779 int argc = 1 + args.size(); // implicit "this" parameter780 781 if (!m_registerFile.grow(oldEnd + argc)) {782 *exception = createStackOverflowError(callFrame);783 return jsNull();784 }785 786 DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);787 788 CallFrame* newCallFrame = CallFrame::create(oldEnd);789 size_t dst = 0;790 newCallFrame->r(0) = JSValue(thisObj);791 ArgList::const_iterator end = args.end();792 for (ArgList::const_iterator it = args.begin(); it != end; ++it)793 newCallFrame->r(++dst) = *it;794 795 824 CodeBlock* codeBlock = &functionExecutable->bytecodeForConstruct(callFrame, scopeChain); 796 825 newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc); … … 801 830 } 802 831 // a 0 codeBlock indicates a built-in caller 803 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, argc, function); 832 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), argc, function); 833 834 DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject); 804 835 805 836 Profiler** profiler = Profiler::enabledProfilerReference(); … … 859 890 } 860 891 // a 0 codeBlock indicates a built-in caller 861 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0,argc, function);892 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), argc, function); 862 893 #if ENABLE(JIT) 863 894 FunctionExecutable->jitCodeForCall(newCallFrame, scopeChain); … … 958 989 959 990 // a 0 codeBlock indicates a built-in caller 960 newCallFrame->r(codeBlock->thisRegister()) = JSValue(thisObj); 961 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, 0, 0); 991 ASSERT(codeBlock->m_numParameters == 1); // 1 parameter for 'this'. 992 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), codeBlock->m_numParameters, 0); 993 newCallFrame->r(newCallFrame->hostThisRegister()) = JSValue(thisObj); 962 994 963 995 if (codeBlock->needsFullScopeChain()) … … 2939 2971 int offset = 0; 2940 2972 if (subscript == expectedSubscript && baseValue.isCell() && (baseValue.asCell()->structure() == it->cachedStructure()) && it->getOffset(index, offset)) { 2941 callFrame->r(dst) = asObject(baseValue)->getDirectOffset(offset);2973 callFrame->r(dst) = JSValue(asObject(baseValue)->getDirectOffset(offset)); 2942 2974 vPC += OPCODE_LENGTH(op_get_by_pname); 2943 2975 NEXT_INSTRUCTION(); … … 3578 3610 } 3579 3611 3580 callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_call), callDataScopeChain, previousCallFrame, 0,argCount, asFunction(v));3612 callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_call), callDataScopeChain, previousCallFrame, argCount, asFunction(v)); 3581 3613 codeBlock = newCodeBlock; 3582 3614 ASSERT(codeBlock == callFrame->codeBlock()); … … 3593 3625 ScopeChainNode* scopeChain = callFrame->scopeChain(); 3594 3626 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset); 3595 newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call), scopeChain, callFrame, 0, argCount, 0);3627 newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call), scopeChain, callFrame, argCount, asObject(v)); 3596 3628 3597 3629 Register* thisRegister = newCallFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount; 3598 3630 ArgList args(thisRegister + 1, argCount - 1); 3599 3600 // FIXME: All host methods should be calling toThisObject, but this is not presently the case.3601 JSValue thisValue = thisRegister->jsValue();3602 if (thisValue == jsNull())3603 thisValue = callFrame->globalThisValue();3604 3631 3605 3632 JSValue returnValue; 3606 3633 { 3607 3634 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 3608 returnValue = callData.native.function(newCallFrame , asObject(v), thisValue, args);3635 returnValue = callData.native.function(newCallFrame); 3609 3636 } 3610 3637 CHECK_FOR_EXCEPTION(); … … 3628 3655 int32_t argCount = 0; 3629 3656 if (!arguments) { 3630 argCount = (uint32_t)(callFrame->argumentCount()) - 1;3657 argCount = (uint32_t)(callFrame->argumentCount()); 3631 3658 int32_t sizeDelta = argsOffset + argCount + RegisterFile::CallFrameHeaderSize; 3632 3659 Register* newEnd = callFrame->registers() + sizeDelta; … … 3635 3662 goto vm_throw; 3636 3663 } 3637 ASSERT(! callFrame->callee()->isHostFunction());3638 int32_t expectedParams = callFrame->callee()->jsExecutable()->parameterCount();3664 ASSERT(!asFunction(callFrame->callee())->isHostFunction()); 3665 int32_t expectedParams = asFunction(callFrame->callee())->jsExecutable()->parameterCount(); 3639 3666 int32_t inplaceArgs = min(argCount, expectedParams); 3640 3667 int32_t i = 0; … … 3733 3760 } 3734 3761 3735 callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_call_varargs), callDataScopeChain, previousCallFrame, 0,argCount, asFunction(v));3762 callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_call_varargs), callDataScopeChain, previousCallFrame, argCount, asFunction(v)); 3736 3763 codeBlock = newCodeBlock; 3737 3764 ASSERT(codeBlock == callFrame->codeBlock()); … … 3748 3775 ScopeChainNode* scopeChain = callFrame->scopeChain(); 3749 3776 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset); 3750 newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call_varargs), scopeChain, callFrame, 0, argCount, 0);3777 newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call_varargs), scopeChain, callFrame, argCount, asObject(v)); 3751 3778 3752 3779 Register* thisRegister = newCallFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount; 3753 3780 ArgList args(thisRegister + 1, argCount - 1); 3754 3781 3755 // FIXME: All host methods should be calling toThisObject, but this is not presently the case.3756 JSValue thisValue = thisRegister->jsValue();3757 if (thisValue == jsNull())3758 thisValue = callFrame->globalThisValue();3759 3760 3782 JSValue returnValue; 3761 3783 { 3762 3784 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 3763 returnValue = callData.native.function(newCallFrame , asObject(v), thisValue, args);3785 returnValue = callData.native.function(newCallFrame); 3764 3786 } 3765 3787 CHECK_FOR_EXCEPTION(); … … 3966 3988 else 3967 3989 structure = constructor->scope().node()->globalObject->emptyObjectStructure(); 3968 callFrame->r(thisRegister) = new (&callFrame->globalData()) JSObject(structure);3990 callFrame->r(thisRegister) = JSValue(new (&callFrame->globalData()) JSObject(structure)); 3969 3991 3970 3992 vPC += OPCODE_LENGTH(op_create_this); … … 4060 4082 } 4061 4083 4062 callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_construct), callDataScopeChain, previousCallFrame, 0,argCount, asFunction(v));4084 callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_construct), callDataScopeChain, previousCallFrame, argCount, asFunction(v)); 4063 4085 codeBlock = newCodeBlock; 4064 4086 vPC = newCodeBlock->instructions().begin(); … … 4074 4096 ScopeChainNode* scopeChain = callFrame->scopeChain(); 4075 4097 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset); 4076 newCallFrame->init(0, vPC + OPCODE_LENGTH(op_construct), scopeChain, callFrame, 0,argCount, 0);4098 newCallFrame->init(0, vPC + OPCODE_LENGTH(op_construct), scopeChain, callFrame, argCount, 0); 4077 4099 4078 4100 Register* thisRegister = newCallFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount;
Note:
See TracChangeset
for help on using the changeset viewer.