Changeset 60708 in webkit for trunk/JavaScriptCore/interpreter
- Timestamp:
- Jun 4, 2010, 2:38:38 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/interpreter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r60637 r60708 796 796 } 797 797 798 JS Value Interpreter::executeConstruct(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)798 JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* constructor, ConstructType constructType, const ConstructData& constructData, const ArgList& args, JSValue* exception) 799 799 { 800 ASSERT(! scopeChain->globalData->exception);800 ASSERT(!callFrame->hadException()); 801 801 802 802 if (m_reentryDepth >= MaxSmallThreadReentryDepth) { 803 803 if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) { 804 804 *exception = createStackOverflowError(callFrame); 805 return jsNull();805 return 0; 806 806 } 807 807 } 808 808 809 809 Register* oldEnd = m_registerFile.end(); 810 int argc = 1 + args.size(); // implicit "this" parameter 811 812 if (!m_registerFile.grow(oldEnd + argc)) { 810 int argCount = 1 + args.size(); // implicit "this" parameter 811 size_t registerOffset = argCount + RegisterFile::CallFrameHeaderSize; 812 813 if (!m_registerFile.grow(oldEnd + registerOffset)) { 813 814 *exception = createStackOverflowError(callFrame); 814 return jsNull();815 return 0; 815 816 } 816 817 817 818 CallFrame* newCallFrame = CallFrame::create(oldEnd); 818 819 size_t dst = 0; 819 newCallFrame->r(0) = JSValue(thisObj);820 820 ArgList::const_iterator end = args.end(); 821 821 for (ArgList::const_iterator it = args.begin(); it != end; ++it) 822 822 newCallFrame->r(++dst) = *it; 823 823 824 CodeBlock* codeBlock = &functionExecutable->bytecodeForConstruct(callFrame, scopeChain); 825 newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc); 826 if (UNLIKELY(!newCallFrame)) { 827 *exception = createStackOverflowError(callFrame); 824 if (constructType == ConstructTypeJS) { 825 ScopeChainNode* constructDataScopeChain = constructData.js.scopeChain; 826 CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecodeForConstruct(callFrame, constructDataScopeChain); 827 828 newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount); 829 if (UNLIKELY(!newCallFrame)) { 830 *exception = createStackOverflowError(callFrame); 831 m_registerFile.shrink(oldEnd); 832 return 0; 833 } 834 835 newCallFrame->init(newCodeBlock, 0, constructDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor); 836 837 DynamicGlobalObjectScope globalObjectScope(newCallFrame, constructDataScopeChain->globalObject); 838 839 Profiler** profiler = Profiler::enabledProfilerReference(); 840 if (*profiler) 841 (*profiler)->willExecute(newCallFrame, constructor); 842 843 JSValue result; 844 { 845 SamplingTool::CallRecord callRecord(m_sampler.get()); 846 847 m_reentryDepth++; 848 #if ENABLE(JIT) 849 result = constructData.js.functionExecutable->jitCodeForConstruct(newCallFrame, constructDataScopeChain).execute(&m_registerFile, newCallFrame, constructDataScopeChain->globalData, exception); 850 #else 851 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception); 852 #endif 853 m_reentryDepth--; 854 } 855 856 if (*profiler) 857 (*profiler)->didExecute(newCallFrame, constructor); 858 828 859 m_registerFile.shrink(oldEnd); 829 return jsNull(); 830 } 831 // a 0 codeBlock indicates a built-in caller 832 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), argc, function); 833 834 DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject); 860 if (callFrame->hadException()) 861 return 0; 862 ASSERT(result.isObject()); 863 return asObject(result); 864 } 865 866 ASSERT(constructType == ConstructTypeHost); 867 ScopeChainNode* scopeChain = callFrame->scopeChain(); 868 newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset); 869 newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor); 870 871 DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject); 835 872 836 873 Profiler** profiler = Profiler::enabledProfilerReference(); 837 874 if (*profiler) 838 (*profiler)->willExecute( callFrame, function);875 (*profiler)->willExecute(newCallFrame, constructor); 839 876 840 877 JSValue result; 841 878 { 842 SamplingTool::CallRecord callRecord(m_sampler.get()); 843 844 m_reentryDepth++; 845 #if ENABLE(JIT) 846 result = functionExecutable->jitCodeForConstruct(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception); 847 #else 848 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception); 849 #endif 850 m_reentryDepth--; 879 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 880 result = JSValue::decode(constructData.native.function(newCallFrame)); 851 881 } 852 882 853 883 if (*profiler) 854 (*profiler)->didExecute( callFrame, function);884 (*profiler)->didExecute(newCallFrame, constructor); 855 885 856 886 m_registerFile.shrink(oldEnd); 857 return result; 887 if (callFrame->hadException()) 888 return 0; 889 ASSERT(result.isObject()); 890 return asObject(result); 858 891 } 859 892 -
trunk/JavaScriptCore/interpreter/Interpreter.h
r60392 r60708 97 97 JSValue execute(ProgramExecutable*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue* exception); 98 98 JSValue executeCall(CallFrame*, JSObject* function, CallType, const CallData&, JSValue thisValue, const ArgList&, JSValue* exception); 99 JS Value executeConstruct(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);99 JSObject* executeConstruct(CallFrame*, JSObject* function, ConstructType, const ConstructData&, const ArgList&, JSValue* exception); 100 100 JSValue execute(EvalExecutable* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception); 101 101
Note:
See TracChangeset
for help on using the changeset viewer.