Changeset 34906 in webkit
- Timestamp:
- Jun 30, 2008 10:45:21 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r34904 r34906 1 2008-06-30 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Removed the "registerBase" abstraction. Since the register file never 6 reallocates, we can keep direct pointers into it, instead of 7 <registerBase, offset> tuples. 8 9 SunSpider says 0.8% faster. 10 1 11 2008-06-30 Oliver Hunt <oliver@apple.com> 2 12 -
trunk/JavaScriptCore/VM/Machine.cpp
r34885 r34906 354 354 } 355 355 356 ALWAYS_INLINE void initializeCallFrame(Register* callFrame, CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain, int registerOffset, int returnValueRegister, int argv, int argc, int calledAsConstructor, JSValue* function)356 ALWAYS_INLINE void initializeCallFrame(Register* callFrame, CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain, Register* r, int returnValueRegister, int argv, int argc, int calledAsConstructor, JSValue* function) 357 357 { 358 358 callFrame[RegisterFile::CallerCodeBlock].u.codeBlock = codeBlock; 359 359 callFrame[RegisterFile::ReturnVPC].u.vPC = vPC + 1; 360 360 callFrame[RegisterFile::CallerScopeChain].u.scopeChain = scopeChain; 361 callFrame[RegisterFile::CallerRegister Offset].u.i = registerOffset;361 callFrame[RegisterFile::CallerRegisters].u.r = r; 362 362 callFrame[RegisterFile::ReturnValueRegister].u.i = returnValueRegister; 363 363 callFrame[RegisterFile::ArgumentStartRegister].u.i = argv; // original argument vector (for the sake of the "arguments" object) … … 368 368 } 369 369 370 ALWAYS_INLINE Register* slideRegisterWindowForCall(ExecState* exec, CodeBlock* newCodeBlock, RegisterFile* registerFile, Register** registerBase, int registerOffset, int argv, int argc, JSValue*& exceptionValue) 371 { 372 Register* r = 0; 373 int oldOffset = registerOffset; 374 registerOffset += argv + newCodeBlock->numLocals; 375 size_t size = registerOffset + newCodeBlock->numTemporaries; 370 ALWAYS_INLINE Register* slideRegisterWindowForCall(ExecState* exec, CodeBlock* newCodeBlock, RegisterFile* registerFile, Register* registerBase, Register* r, int argv, int argc, JSValue*& exceptionValue) 371 { 372 size_t registerOffset = argv + newCodeBlock->numLocals; 373 size_t size = r - registerBase + registerOffset + newCodeBlock->numTemporaries; 376 374 377 375 if (argc == newCodeBlock->numParameters) { // correct number of arguments 378 376 if (!registerFile->grow(size)) { 379 377 exceptionValue = createStackOverflowError(exec); 380 return *registerBase + oldOffset;381 } 382 r = (*registerBase) +registerOffset;378 return r; 379 } 380 r += registerOffset; 383 381 } else if (argc < newCodeBlock->numParameters) { // too few arguments -- fill in the blanks 384 382 if (!registerFile->grow(size)) { 385 383 exceptionValue = createStackOverflowError(exec); 386 return *registerBase + oldOffset;387 } 388 r = (*registerBase) +registerOffset;384 return r; 385 } 386 r += registerOffset; 389 387 390 388 int omittedArgCount = newCodeBlock->numParameters - argc; … … 399 397 if (!registerFile->grow(size)) { 400 398 exceptionValue = createStackOverflowError(exec); 401 return *registerBase + oldOffset;402 } 403 r = (*registerBase) +registerOffset;399 return r; 400 } 401 r += registerOffset; 404 402 405 403 Register* it = r - newCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize - shift; … … 416 414 } 417 415 418 ALWAYS_INLINE ScopeChainNode* scopeChainForCall(ExecState* exec, FunctionBodyNode* functionBodyNode, CodeBlock* newCodeBlock, ScopeChainNode* callDataScopeChain, Register* * registerBase, Register*r)416 ALWAYS_INLINE ScopeChainNode* scopeChainForCall(ExecState* exec, FunctionBodyNode* functionBodyNode, CodeBlock* newCodeBlock, ScopeChainNode* callDataScopeChain, Register* r) 419 417 { 420 418 if (newCodeBlock->needsFullScopeChain) { 421 JSActivation* activation = new (exec) JSActivation(functionBodyNode, r egisterBase, r - (*registerBase));419 JSActivation* activation = new (exec) JSActivation(functionBodyNode, r); 422 420 r[RegisterFile::OptionalCalleeActivation - RegisterFile::CallFrameHeaderSize - newCodeBlock->numLocals].u.jsValue = activation; 423 421 … … 462 460 } 463 461 464 JSValue* result = exec->globalData().machine->execute(evalNode.get(), exec, thisObj, r - (*registerFile->basePointer()) + argv + argc, scopeChain, &exceptionValue);462 JSValue* result = exec->globalData().machine->execute(evalNode.get(), exec, thisObj, r - registerFile->base() + argv + argc, scopeChain, &exceptionValue); 465 463 466 464 if (*profiler) … … 563 561 } 564 562 565 NEVER_INLINE bool Machine::unwindCallFrame(ExecState* exec, JSValue* exceptionValue, Register** registerBase,const Instruction*& vPC, CodeBlock*& codeBlock, JSValue**& k, ScopeChainNode*& scopeChain, Register*& r)563 NEVER_INLINE bool Machine::unwindCallFrame(ExecState* exec, JSValue* exceptionValue, const Instruction*& vPC, CodeBlock*& codeBlock, JSValue**& k, ScopeChainNode*& scopeChain, Register*& r) 566 564 { 567 565 CodeBlock* oldCodeBlock = codeBlock; … … 569 567 570 568 if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) { 571 DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, exceptionValue, registerBase, r - *registerBase);569 DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue); 572 570 if (callFrame[RegisterFile::Callee].u.jsObject) 573 571 debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->ownerNode->lastLine()); … … 598 596 k = codeBlock->jsValues.data(); 599 597 scopeChain = callFrame[RegisterFile::CallerScopeChain].u.scopeChain; 600 int callerRegisterOffset = callFrame[RegisterFile::CallerRegisterOffset].u.i; 601 r = (*registerBase) + callerRegisterOffset; 602 exec->m_callFrameOffset = callerRegisterOffset - codeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 598 r = callFrame[RegisterFile::CallerRegisters].u.r; 599 exec->m_callFrame = r - oldCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 603 600 vPC = callFrame[RegisterFile::ReturnVPC].u.vPC; 604 601 … … 606 603 } 607 604 608 NEVER_INLINE Instruction* Machine::throwException(ExecState* exec, JSValue* exceptionValue, Register** registerBase,const Instruction* vPC, CodeBlock*& codeBlock, JSValue**& k, ScopeChainNode*& scopeChain, Register*& r)605 NEVER_INLINE Instruction* Machine::throwException(ExecState* exec, JSValue* exceptionValue, const Instruction* vPC, CodeBlock*& codeBlock, JSValue**& k, ScopeChainNode*& scopeChain, Register*& r) 609 606 { 610 607 // Set up the exception object … … 618 615 619 616 if (exception->isWatchdogException()) { 620 while (unwindCallFrame(exec, exceptionValue, registerBase,vPC, codeBlock, k, scopeChain, r)) {617 while (unwindCallFrame(exec, exceptionValue, vPC, codeBlock, k, scopeChain, r)) { 621 618 // Don't need handler checks or anything, we just want to unroll all the JS callframes possible. 622 619 } … … 626 623 627 624 if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) { 628 DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, exceptionValue, registerBase, r - *registerBase);625 DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue); 629 626 debugger->exception(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->lineNumberForVPC(vPC)); 630 627 } … … 636 633 637 634 while (!codeBlock->getHandlerForVPC(vPC, handlerVPC, scopeDepth)) { 638 if (!unwindCallFrame(exec, exceptionValue, registerBase,vPC, codeBlock, k, scopeChain, r))635 if (!unwindCallFrame(exec, exceptionValue, vPC, codeBlock, k, scopeChain, r)) 639 636 return 0; 640 637 } … … 672 669 globalObject->copyGlobalsTo(m_registerFile); 673 670 674 Register* callFrame = *m_registerFile.basePointer() + oldSize;671 Register* callFrame = m_registerFile.base() + oldSize; 675 672 676 673 // a 0 codeBlock indicates a built-in caller … … 683 680 scopeChain = scopeChain->copy(); 684 681 685 ExecState newExec(exec, &m_registerFile, scopeChain, -1);682 ExecState newExec(exec, &m_registerFile, scopeChain, 0); 686 683 687 684 Profiler** profiler = Profiler::enabledProfilerReference(); … … 722 719 } 723 720 724 Register** registerBase = m_registerFile.basePointer(); 725 int registerOffset = oldSize; 726 int callFrameOffset = registerOffset; 727 Register* callFrame = (*registerBase) + callFrameOffset; 721 Register* callFrame = m_registerFile.base() + oldSize; 728 722 729 723 // put args in place, including "this" … … 736 730 737 731 // a 0 codeBlock indicates a built-in caller 738 initializeCallFrame(callFrame, 0, 0, 0, registerOffset, 0, argv, argc, 0, function);732 initializeCallFrame(callFrame, 0, 0, 0, callFrame, 0, argv, argc, 0, function); 739 733 740 734 CodeBlock* newCodeBlock = &functionBodyNode->code(scopeChain); 741 Register* r = slideRegisterWindowForCall(exec, newCodeBlock, &m_registerFile, registerBase, registerOffset, argv, argc, *exception);735 Register* r = slideRegisterWindowForCall(exec, newCodeBlock, &m_registerFile, m_registerFile.base(), callFrame, argv, argc, *exception); 742 736 if (*exception) { 743 737 m_registerFile.shrink(oldSize); … … 745 739 } 746 740 747 scopeChain = scopeChainForCall(exec, functionBodyNode, newCodeBlock, scopeChain, r egisterBase, r);748 749 ExecState newExec(exec, &m_registerFile, scopeChain, callFrame Offset);741 scopeChain = scopeChainForCall(exec, functionBodyNode, newCodeBlock, scopeChain, r); 742 743 ExecState newExec(exec, &m_registerFile, scopeChain, callFrame); 750 744 751 745 Profiler** profiler = Profiler::enabledProfilerReference(); … … 802 796 } 803 797 804 Register* callFrame = *m_registerFile.basePointer() + registerOffset;798 Register* callFrame = m_registerFile.base() + registerOffset; 805 799 806 800 // a 0 codeBlock indicates a built-in caller 807 initializeCallFrame(callFrame, 0, 0, 0, registerOffset, 0, 0, 0, 0, 0);801 initializeCallFrame(callFrame, 0, 0, 0, 0, 0, 0, 0, 0, 0); 808 802 809 803 Register* r = callFrame + RegisterFile::CallFrameHeaderSize + codeBlock->numVars; … … 813 807 scopeChain = scopeChain->copy(); 814 808 815 ExecState newExec(exec, &m_registerFile, scopeChain, -1);809 ExecState newExec(exec, &m_registerFile, scopeChain, 0); 816 810 817 811 Profiler** profiler = Profiler::enabledProfilerReference(); … … 839 833 } 840 834 841 NEVER_INLINE void Machine::debug(ExecState* exec, const Instruction* vPC, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* * registerBase, Register*r)835 NEVER_INLINE void Machine::debug(ExecState* exec, const Instruction* vPC, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r) 842 836 { 843 837 int debugHookID = (++vPC)->u.operand; … … 849 843 return; 850 844 851 DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, 0, registerBase, r - *registerBase);845 DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, 0); 852 846 853 847 switch((DebugHookID)debugHookID) { … … 968 962 Instruction* handlerVPC = 0; 969 963 970 Register* registerBase = *registerFile->basePointer();964 Register* registerBase = registerFile->base(); 971 965 Instruction* vPC = codeBlock->instructions.begin(); 972 966 JSValue** k = codeBlock->jsValues.data(); … … 1047 1041 int firstArg = (++vPC)->u.operand; 1048 1042 int argCount = (++vPC)->u.operand; 1049 ArgList args(reinterpret_cast<JSValue** *>(®isterBase), r - registerBase+ firstArg, argCount);1043 ArgList args(reinterpret_cast<JSValue**>(r) + firstArg, argCount); 1050 1044 r[dst].u.jsValue = constructArray(exec, args); 1051 1045 … … 2239 2233 if (*enabledProfilerReference) 2240 2234 (*enabledProfilerReference)->willExecute(exec, static_cast<JSObject*>(v)); 2241 int registerOffset = r - registerBase;2242 Register* callFrame = r + firstArg - RegisterFile::CallFrameHeaderSize;2243 int callFrameOffset = registerOffset + firstArg - RegisterFile::CallFrameHeaderSize;2244 2245 r[firstArg].u.jsValue = thisVal == missingThisObjectMarker() ? exec->globalThisValue() : r[thisVal].u.jsValue;2246 initializeCallFrame(callFrame, codeBlock, vPC, scopeChain, registerOffset, dst, firstArg, argCount, 0, v);2247 2235 2248 2236 ScopeChainNode* callDataScopeChain = callData.js.scopeChain; 2249 2237 FunctionBodyNode* functionBodyNode = callData.js.functionBody; 2250 2251 2238 CodeBlock* newCodeBlock = &functionBodyNode->code(callDataScopeChain); 2252 r = slideRegisterWindowForCall(exec, newCodeBlock, registerFile, ®isterBase, registerOffset, firstArg, argCount, exceptionValue); 2239 2240 r[firstArg].u.jsValue = thisVal == missingThisObjectMarker() ? exec->globalThisValue() : r[thisVal].u.jsValue; 2241 2242 Register* callFrame = r + firstArg - RegisterFile::CallFrameHeaderSize; 2243 initializeCallFrame(callFrame, codeBlock, vPC, scopeChain, r, dst, firstArg, argCount, 0, v); 2244 exec->m_callFrame = callFrame; 2245 2246 r = slideRegisterWindowForCall(exec, newCodeBlock, registerFile, registerBase, r, firstArg, argCount, exceptionValue); 2253 2247 if (UNLIKELY(exceptionValue != 0)) 2254 2248 goto vm_throw; 2255 2249 2256 2250 codeBlock = newCodeBlock; 2257 exec->m_callFrameOffset = callFrameOffset; 2258 setScopeChain(exec, scopeChain, scopeChainForCall(exec, functionBodyNode, codeBlock, callDataScopeChain, ®isterBase, r)); 2251 setScopeChain(exec, scopeChain, scopeChainForCall(exec, functionBodyNode, codeBlock, callDataScopeChain, r)); 2259 2252 k = codeBlock->jsValues.data(); 2260 2253 vPC = codeBlock->instructions.begin(); … … 2270 2263 if (*enabledProfilerReference) 2271 2264 (*enabledProfilerReference)->willExecute(exec, static_cast<JSObject*>(v)); 2272 int registerOffset = r - registerBase;2273 2265 2274 2266 JSValue* thisValue = thisVal == missingThisObjectMarker() ? exec->globalThisValue() : r[thisVal].u.jsValue; 2275 2276 ArgList args(reinterpret_cast<JSValue***>(®isterBase), registerOffset + firstArg + 1, argCount - 1); 2267 ArgList args(reinterpret_cast<JSValue**>(r) + firstArg + 1, argCount - 1); 2277 2268 2278 2269 JSValue* returnValue = callData.native.function(exec, static_cast<JSObject*>(v), thisValue, args); … … 2305 2296 int result = (++vPC)->u.operand; 2306 2297 2307 CodeBlock* oldCodeBlock = codeBlock; 2308 2309 Register* callFrame = r - oldCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 2310 JSValue* returnValue = r[result].u.jsValue; 2311 2298 Register* callFrame = r - codeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 2312 2299 if (JSActivation* activation = static_cast<JSActivation*>(callFrame[RegisterFile::OptionalCalleeActivation].u.jsValue)) { 2313 2300 ASSERT(!codeBlock->needsFullScopeChain || scopeChain->object == activation); … … 2322 2309 scopeChain->deref(); 2323 2310 2311 JSValue* returnValue = r[result].u.jsValue; 2324 2312 if (callFrame[RegisterFile::CalledAsConstructor].u.i && !returnValue->isObject()) { 2325 2313 JSValue* thisObject = callFrame[RegisterFile::CallFrameHeaderSize].u.jsValue; … … 2334 2322 vPC = callFrame[RegisterFile::ReturnVPC].u.vPC; 2335 2323 setScopeChain(exec, scopeChain, callFrame[RegisterFile::CallerScopeChain].u.scopeChain); 2336 int callerRegisterOffset = callFrame[RegisterFile::CallerRegisterOffset].u.i; 2337 r = registerBase + callerRegisterOffset; 2338 exec->m_callFrameOffset = callerRegisterOffset - codeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 2324 r = callFrame[RegisterFile::CallerRegisters].u.r; 2325 exec->m_callFrame = r - codeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 2339 2326 int dst = callFrame[RegisterFile::ReturnValueRegister].u.i; 2340 2327 r[dst].u.jsValue = returnValue; … … 2369 2356 if (*enabledProfilerReference) 2370 2357 (*enabledProfilerReference)->willExecute(exec, constructor); 2371 2372 int registerOffset = r - registerBase;2373 Register* callFrame = r + firstArg - RegisterFile::CallFrameHeaderSize;2374 int callFrameOffset = registerOffset + firstArg - RegisterFile::CallFrameHeaderSize;2375 2358 2376 2359 JSObject* prototype; … … 2381 2364 prototype = scopeChain->globalObject()->objectPrototype(); 2382 2365 JSObject* newObject = new (exec) JSObject(prototype); 2383 r[firstArg].u.jsValue = newObject; // "this" value2384 2385 initializeCallFrame(callFrame, codeBlock, vPC, scopeChain, registerOffset, dst, firstArg, argCount, 1, constructor);2386 2366 2387 2367 ScopeChainNode* callDataScopeChain = constructData.js.scopeChain; 2388 2368 FunctionBodyNode* functionBodyNode = constructData.js.functionBody; 2389 2390 2369 CodeBlock* newCodeBlock = &functionBodyNode->code(callDataScopeChain); 2391 r = slideRegisterWindowForCall(exec, newCodeBlock, registerFile, ®isterBase, registerOffset, firstArg, argCount, exceptionValue); 2370 2371 r[firstArg].u.jsValue = newObject; // "this" value 2372 2373 Register* callFrame = r + firstArg - RegisterFile::CallFrameHeaderSize; 2374 initializeCallFrame(callFrame, codeBlock, vPC, scopeChain, r, dst, firstArg, argCount, 1, constructor); 2375 exec->m_callFrame = callFrame; 2376 2377 r = slideRegisterWindowForCall(exec, newCodeBlock, registerFile, registerBase, r, firstArg, argCount, exceptionValue); 2392 2378 if (exceptionValue) 2393 2379 goto vm_throw; 2394 2380 2395 2381 codeBlock = newCodeBlock; 2396 exec->m_callFrameOffset = callFrameOffset; 2397 setScopeChain(exec, scopeChain, scopeChainForCall(exec, functionBodyNode, codeBlock, callDataScopeChain, ®isterBase, r)); 2382 setScopeChain(exec, scopeChain, scopeChainForCall(exec, functionBodyNode, codeBlock, callDataScopeChain, r)); 2398 2383 k = codeBlock->jsValues.data(); 2399 2384 vPC = codeBlock->instructions.begin(); … … 2406 2391 (*enabledProfilerReference)->willExecute(exec, constructor); 2407 2392 2408 int registerOffset = r - registerBase; 2409 ArgList args(reinterpret_cast<JSValue***>(®isterBase), registerOffset + firstArg + 1, argCount - 1); 2393 ArgList args(reinterpret_cast<JSValue**>(r) + firstArg + 1, argCount - 1); 2410 2394 JSValue* returnValue = constructData.native.function(exec, constructor, args); 2411 2395 … … 2538 2522 int ex = (++vPC)->u.operand; 2539 2523 exceptionValue = r[ex].u.jsValue; 2540 handlerVPC = throwException(exec, exceptionValue, ®isterBase,vPC, codeBlock, k, scopeChain, r);2524 handlerVPC = throwException(exec, exceptionValue, vPC, codeBlock, k, scopeChain, r); 2541 2525 if (!handlerVPC) { 2542 2526 *exception = exceptionValue; … … 2666 2650 */ 2667 2651 2668 debug(exec, vPC, codeBlock, scopeChain, ®isterBase,r);2652 debug(exec, vPC, codeBlock, scopeChain, r); 2669 2653 2670 2654 vPC += 4; … … 2678 2662 exceptionValue = createInterruptedExecutionException(exec); 2679 2663 } 2680 handlerVPC = throwException(exec, exceptionValue, ®isterBase,vPC, codeBlock, k, scopeChain, r);2664 handlerVPC = throwException(exec, exceptionValue, vPC, codeBlock, k, scopeChain, r); 2681 2665 if (!handlerVPC) { 2682 2666 *exception = exceptionValue; … … 2694 2678 JSValue* Machine::retrieveArguments(ExecState* exec, JSFunction* function) const 2695 2679 { 2696 Register** registerBase; 2697 int callFrameOffset; 2698 2699 if (!getCallFrame(exec, function, registerBase, callFrameOffset)) 2680 Register* callFrame = this->callFrame(exec, function); 2681 if (!callFrame) 2700 2682 return jsNull(); 2701 2683 2702 Register* callFrame = (*registerBase) + callFrameOffset;2703 2684 JSActivation* activation = static_cast<JSActivation*>(callFrame[RegisterFile::OptionalCalleeActivation].u.jsValue); 2704 2685 if (!activation) { 2705 2686 CodeBlock* codeBlock = &function->body->generatedCode(); 2706 activation = new (exec) JSActivation(function->body, registerBase, callFrameOffset+ RegisterFile::CallFrameHeaderSize + codeBlock->numLocals);2687 activation = new (exec) JSActivation(function->body, callFrame + RegisterFile::CallFrameHeaderSize + codeBlock->numLocals); 2707 2688 callFrame[RegisterFile::OptionalCalleeActivation].u.jsValue = activation; 2708 2689 } … … 2713 2694 JSValue* Machine::retrieveCaller(ExecState* exec, JSFunction* function) const 2714 2695 { 2715 Register** registerBase; 2716 int callFrameOffset; 2717 if (!getCallFrame(exec, function, registerBase, callFrameOffset)) 2696 Register* callFrame = this->callFrame(exec, function); 2697 if (!callFrame) 2718 2698 return jsNull(); 2719 2699 2720 Register* callFrame = (*registerBase) + callFrameOffset;2721 2700 CodeBlock* callerCodeBlock = callFrame[RegisterFile::CallerCodeBlock].u.codeBlock; 2722 2701 if (!callerCodeBlock) 2723 2702 return jsNull(); 2724 2703 2725 int callerCallFrameOffset = callFrame[RegisterFile::CallerRegisterOffset].u.i - callerCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 2726 Register* callerCallFrame = (*registerBase) + callerCallFrameOffset; 2727 2704 Register* callerCallFrame = callFrame[RegisterFile::CallerRegisters].u.r - callerCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 2728 2705 if (JSValue* caller = callerCallFrame[RegisterFile::Callee].u.jsValue) 2729 2706 return caller; … … 2732 2709 } 2733 2710 2734 bool Machine::getCallFrame(ExecState* exec, JSFunction* function, Register**& registerBase, int& callFrameOffset) const2735 { 2736 callFrameOffset = exec->m_callFrameOffset;2711 Register* Machine::callFrame(ExecState* exec, JSFunction* function) const 2712 { 2713 Register* callFrame = exec->m_callFrame; 2737 2714 2738 2715 while (1) { 2739 while ( callFrameOffset == -1) {2716 while (!callFrame) { 2740 2717 exec = exec->m_prev; 2741 2718 if (!exec) 2742 return false; 2743 callFrameOffset = exec->m_callFrameOffset; 2744 } 2745 2746 registerBase = exec->m_registerFile->basePointer(); 2747 Register* callFrame = (*registerBase) + callFrameOffset; 2719 return 0; 2720 callFrame = exec->m_callFrame; 2721 } 2722 2748 2723 if (callFrame[RegisterFile::Callee].u.jsValue == function) 2749 return true;2724 return callFrame; 2750 2725 2751 2726 CodeBlock* callerCodeBlock = callFrame[RegisterFile::CallerCodeBlock].u.codeBlock; 2752 2727 if (!callerCodeBlock) { 2753 callFrame Offset = -1;2728 callFrame = 0; 2754 2729 continue; 2755 2730 } 2756 2731 2757 callFrame Offset = callFrame[RegisterFile::CallerRegisterOffset].u.i- callerCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize;2758 } 2759 } 2760 2761 void Machine::get FunctionAndArguments(Register** registerBase,Register* callFrame, JSFunction*& function, Register*& argv, int& argc)2732 callFrame = callFrame[RegisterFile::CallerRegisters].u.r - callerCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 2733 } 2734 } 2735 2736 void Machine::getArgumentsData(Register* callFrame, JSFunction*& function, Register*& argv, int& argc) 2762 2737 { 2763 2738 function = static_cast<JSFunction*>(callFrame[RegisterFile::Callee].u.jsValue); 2764 2739 ASSERT(function->inherits(&JSFunction::info)); 2765 2740 2766 argv = (*registerBase) + callFrame[RegisterFile::CallerRegisterOffset].u.i + callFrame[RegisterFile::ArgumentStartRegister].u.i + 1; //skip "this"2767 argc = callFrame[RegisterFile::ArgumentCount].u.i - 1; // skip "this"2741 argv = callFrame[RegisterFile::CallerRegisters].u.r + callFrame[RegisterFile::ArgumentStartRegister].u.i + 1; // + 1 to skip "this" 2742 argc = callFrame[RegisterFile::ArgumentCount].u.i - 1; // - 1 to skip "this" 2768 2743 } 2769 2744 -
trunk/JavaScriptCore/VM/Machine.h
r34886 r34906 96 96 JSValue* retrieveCaller(ExecState*, JSFunction*) const; 97 97 98 void get FunctionAndArguments(Register** registerBase,Register* callFrame, JSFunction*&, Register*& argv, int& argc);98 void getArgumentsData(Register* callFrame, JSFunction*&, Register*& argv, int& argc); 99 99 void setTimeoutTime(unsigned timeoutTime) { m_timeoutTime = timeoutTime; } 100 100 … … 127 127 128 128 ALWAYS_INLINE void setScopeChain(ExecState* exec, ScopeChainNode*&, ScopeChainNode*); 129 NEVER_INLINE void debug(ExecState*, const Instruction*, const CodeBlock*, ScopeChainNode*, Register* *, Register*);129 NEVER_INLINE void debug(ExecState*, const Instruction*, const CodeBlock*, ScopeChainNode*, Register*); 130 130 131 NEVER_INLINE bool unwindCallFrame(ExecState*, JSValue*, Register**,const Instruction*&, CodeBlock*&, JSValue**&, ScopeChainNode*&, Register*&);132 NEVER_INLINE Instruction* throwException(ExecState*, JSValue*, Register**,const Instruction*, CodeBlock*&, JSValue**&, ScopeChainNode*&, Register*&);131 NEVER_INLINE bool unwindCallFrame(ExecState*, JSValue*, const Instruction*&, CodeBlock*&, JSValue**&, ScopeChainNode*&, Register*&); 132 NEVER_INLINE Instruction* throwException(ExecState*, JSValue*, const Instruction*, CodeBlock*&, JSValue**&, ScopeChainNode*&, Register*&); 133 133 134 bool getCallFrame(ExecState*, JSFunction*, Register**& registerBase, int& callFrameOffset) const;134 Register* callFrame(ExecState*, JSFunction*) const; 135 135 136 136 JSValue* privateExecute(ExecutionFlag, ExecState* = 0, RegisterFile* = 0, Register* = 0, ScopeChainNode* = 0, CodeBlock* = 0, JSValue** exception = 0); -
trunk/JavaScriptCore/VM/RegisterFile.h
r34886 r34906 94 94 ReturnVPC, 95 95 CallerScopeChain, 96 CallerRegister Offset,96 CallerRegisters, 97 97 ReturnValueRegister, 98 98 ArgumentStartRegister, … … 134 134 ~RegisterFile(); 135 135 136 // Pointer to a value that holds the base of this register file. 137 Register** basePointer() { return &m_base; } 136 Register* base() const { return m_base; } 138 137 139 138 void setGlobalObject(JSGlobalObject* globalObject) { m_globalObject = globalObject; } -
trunk/JavaScriptCore/kjs/DebuggerCallFrame.cpp
r34838 r34906 37 37 namespace KJS { 38 38 39 Register* DebuggerCallFrame::r() const40 {41 return *m_registerBase + m_registerOffset;42 }43 44 39 Register* DebuggerCallFrame::callFrame() const 45 40 { 46 return r()- m_codeBlock->numLocals - RegisterFile::CallFrameHeaderSize;41 return m_registers - m_codeBlock->numLocals - RegisterFile::CallFrameHeaderSize; 47 42 } 48 43 … … 71 66 return 0; 72 67 73 return static_cast<JSObject*>( r()[m_codeBlock->thisRegister].u.jsValue);68 return static_cast<JSObject*>(m_registers[m_codeBlock->thisRegister].u.jsValue); 74 69 } 75 70 -
trunk/JavaScriptCore/kjs/DebuggerCallFrame.h
r34838 r34906 48 48 } Type; 49 49 50 DebuggerCallFrame(JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, JSValue* exception, Register** registerBase, int registerOffset)50 DebuggerCallFrame(JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r, JSValue* exception) 51 51 : m_dynamicGlobalObject(dynamicGlobalObject) 52 52 , m_codeBlock(codeBlock) 53 53 , m_scopeChain(scopeChain) 54 , m_registers(r) 54 55 , m_exception(exception) 55 , m_registerBase(registerBase)56 , m_registerOffset(registerOffset)57 56 { 58 57 } … … 67 66 68 67 private: 69 Register* r() const;70 68 Register* callFrame() const; 71 69 … … 73 71 const CodeBlock* m_codeBlock; 74 72 ScopeChainNode* m_scopeChain; 73 Register* m_registers; 75 74 JSValue* m_exception; 76 Register** m_registerBase;77 int m_registerOffset;78 75 }; 79 76 -
trunk/JavaScriptCore/kjs/ExecState.cpp
r34684 r34906 40 40 , m_registerFile(0) 41 41 , m_scopeChain(globalScopeChain) 42 , m_callFrame Offset(-1)42 , m_callFrame(0) 43 43 { 44 44 } 45 45 46 ExecState::ExecState(ExecState* exec, RegisterFile* registerFile, ScopeChainNode* scopeChain, int callFrameOffset)46 ExecState::ExecState(ExecState* exec, RegisterFile* registerFile, ScopeChainNode* scopeChain, Register* callFrame) 47 47 : m_globalObject(exec->m_globalObject) 48 48 , m_globalThisValue(exec->m_globalThisValue) … … 52 52 , m_registerFile(registerFile) 53 53 , m_scopeChain(scopeChain) 54 , m_callFrame Offset(callFrameOffset)54 , m_callFrame(callFrame) 55 55 { 56 56 ASSERT(!exec->m_exception); -
trunk/JavaScriptCore/kjs/ExecState.h
r34684 r34906 39 39 class Machine; 40 40 class ProgramNode; 41 class Register; 41 42 class RegisterFile; 42 43 class ScopeNode; … … 94 95 ExecState() { } 95 96 96 ExecState(ExecState*, RegisterFile*, ScopeChainNode*, int callFrameOffset);97 ExecState(ExecState*, RegisterFile*, ScopeChainNode*, Register* callFrame); 97 98 98 99 bool isGlobalObject(JSObject*) const; … … 109 110 RegisterFile* m_registerFile; 110 111 ScopeChainNode* m_scopeChain; 111 int m_callFrameOffset; // A negative offset indicates a non-function scope.112 Register* m_callFrame; // The most recent call frame. 112 113 }; 113 114 -
trunk/JavaScriptCore/kjs/JSActivation.cpp
r34838 r34906 39 39 const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 }; 40 40 41 JSActivation::JSActivation(PassRefPtr<FunctionBodyNode> functionBody, Register* * registerBase, int registerOffset)42 : Base(new JSActivationData(functionBody, register Base, registerOffset))41 JSActivation::JSActivation(PassRefPtr<FunctionBodyNode> functionBody, Register* registers) 42 : Base(new JSActivationData(functionBody, registers)) 43 43 { 44 44 } … … 55 55 return; 56 56 57 copyRegisterArray( registers()- numLocals, numLocals);57 copyRegisterArray(d()->registers - numLocals, numLocals); 58 58 } 59 59 … … 156 156 JSObject* JSActivation::createArgumentsObject(ExecState* exec) 157 157 { 158 Register* callFrame = registers()- d()->functionBody->generatedCode().numLocals - RegisterFile::CallFrameHeaderSize;158 Register* callFrame = d()->registers - d()->functionBody->generatedCode().numLocals - RegisterFile::CallFrameHeaderSize; 159 159 160 160 JSFunction* function; 161 161 Register* argv; 162 162 int argc; 163 exec->machine()->getFunctionAndArguments(registerBase(), callFrame, function, argv, argc); 164 ArgList args(reinterpret_cast<JSValue***>(registerBase()), argv - *registerBase(), argc); 163 exec->machine()->getArgumentsData(callFrame, function, argv, argc); 164 165 ArgList args(reinterpret_cast<JSValue**>(argv), argc); 165 166 return new (exec) Arguments(exec, function, args, this); 166 167 } -
trunk/JavaScriptCore/kjs/JSActivation.h
r34838 r34906 41 41 typedef JSVariableObject Base; 42 42 public: 43 JSActivation(PassRefPtr<FunctionBodyNode>, Register* *, int registerOffset);43 JSActivation(PassRefPtr<FunctionBodyNode>, Register*); 44 44 virtual ~JSActivation(); 45 45 … … 64 64 private: 65 65 struct JSActivationData : public JSVariableObjectData { 66 JSActivationData(PassRefPtr<FunctionBodyNode> functionBody_, Register* * registerBase, int registerOffset)67 : JSVariableObjectData(&functionBody_->symbolTable(), register Base, registerOffset)66 JSActivationData(PassRefPtr<FunctionBodyNode> functionBody_, Register* registers) 67 : JSVariableObjectData(&functionBody_->symbolTable(), registers) 68 68 , functionBody(functionBody_) 69 69 , argumentsObject(0) -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r34876 r34906 395 395 { 396 396 ASSERT(!d()->registerArray); 397 ASSERT(!d()->registerArraySize); 397 398 398 399 int numGlobals = registerFile.numGlobals(); 399 400 if (!numGlobals) { 400 ASSERT(!d()->registerOffset); 401 d()->registerBase = 0; 401 d()->registers = 0; 402 402 return; 403 403 } … … 415 415 416 416 if (d()->registerArray) { 417 memcpy( *registerFile.basePointer() - d()->registerOffset, d()->registerArray, d()->registerOffset* sizeof(Register));417 memcpy(registerFile.base() - d()->registerArraySize, d()->registerArray.get(), d()->registerArraySize * sizeof(Register)); 418 418 setRegisterArray(0, 0); 419 419 } 420 420 421 d()->registerBase = registerFile.basePointer(); 422 d()->registerOffset = 0; 421 d()->registers = registerFile.base(); 423 422 } 424 423 -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r34886 r34906 75 75 struct JSGlobalObjectData : public JSVariableObjectData { 76 76 JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue) 77 : JSVariableObjectData(&symbolTable, 0 , 0)77 : JSVariableObjectData(&symbolTable, 0) 78 78 , globalScopeChain(globalObject, thisValue) 79 79 { … … 259 259 inline void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count) 260 260 { 261 int numGlobals = d()->registerOffset;262 Register* registerArray = static_cast<Register*>(fastMalloc(( numGlobals+ count) * sizeof(Register)));261 size_t registerArraySize = d()->registerArraySize; 262 Register* registerArray = static_cast<Register*>(fastMalloc((registerArraySize + count) * sizeof(Register))); 263 263 if (d()->registerArray) 264 memcpy(registerArray + count, d()->registerArray , numGlobals* sizeof(Register));265 setRegisterArray(registerArray, numGlobals+ count);266 267 for (int i = 0, index = - numGlobals- 1; i < count; ++i, --index) {264 memcpy(registerArray + count, d()->registerArray.get(), registerArraySize * sizeof(Register)); 265 setRegisterArray(registerArray, registerArraySize + count); 266 267 for (int i = 0, index = -registerArraySize - 1; i < count; ++i, --index) { 268 268 GlobalPropertyInfo& global = globals[i]; 269 269 ASSERT(global.attributes & DontDelete); -
trunk/JavaScriptCore/kjs/JSVariableObject.cpp
r34838 r34906 71 71 return; 72 72 73 Register* end = d->registerArray + d->registerOffset;74 for (Register* it = d->registerArray ; it != end; ++it) {73 Register* end = d->registerArray.get() + d->registerArraySize; 74 for (Register* it = d->registerArray.get(); it != end; ++it) { 75 75 JSValue* v = (*it).u.jsValue; 76 76 if (!v->marked()) … … 96 96 void JSVariableObject::setRegisterArray(Register* registerArray, size_t count) 97 97 { 98 delete d->registerArray; 99 d->registerArray = registerArray; 100 d->registerBase = &d->registerArray; 101 d->registerOffset = count; 98 d->registerArray.set(registerArray); 99 d->registerArraySize = count; 100 d->registers = registerArray + count; 102 101 } 103 102 -
trunk/JavaScriptCore/kjs/JSVariableObject.h
r34838 r34906 30 30 #define JSVariableObject_h 31 31 32 #include "JSObject.h" 32 33 #include "Register.h" 33 34 #include "SymbolTable.h" 34 35 #include "UnusedParam.h" 35 #include "JSObject.h"36 #include <wtf/OwnPtr.h> 36 37 #include <wtf/UnusedParam.h> 37 38 … … 55 56 virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const; 56 57 57 JSValue*& valueAt(int index) const { return registers()[index].u.jsValue; }58 JSValue*& valueAt(int index) const { return d->registers[index].u.jsValue; } 58 59 59 60 protected: … … 62 63 // size of a JSCell). 63 64 struct JSVariableObjectData { 64 JSVariableObjectData(SymbolTable* symbolTable_, Register* * registerBase_, int registerOffset_)65 JSVariableObjectData(SymbolTable* symbolTable_, Register* registers_) 65 66 : symbolTable(symbolTable_) 66 , registerBase(registerBase_) 67 , registerOffset(registerOffset_) 68 , registerArray(0) 67 , registers(registers_) 68 , registerArraySize(0) 69 69 { 70 70 ASSERT(symbolTable_); 71 71 } 72 72 73 ~JSVariableObjectData()74 {75 delete registerArray;76 }77 78 73 SymbolTable* symbolTable; // Maps name -> offset from "r" in register file. 79 80 Register** registerBase; // Location where a pointer to the base of the register file is stored. 81 int registerOffset; // Offset of "r", the register past the end of local storage. 82 83 Register* registerArray; // Independent copy of registers that were once stored in the register file. 74 Register* registers; // Pointers to the register past the end of local storage. (Local storage indexes are negative.) 75 OwnPtr<Register> registerArray; // Independent copy of registers, used when a variable object copies its registers out of the register file. 76 size_t registerArraySize; 84 77 }; 85 78 … … 95 88 } 96 89 97 Register** registerBase() const { return d->registerBase; }98 Register* registers() const { return *registerBase() + d->registerOffset; }99 100 90 void copyRegisterArray(Register* src, size_t count); 101 91 void setRegisterArray(Register* registerArray, size_t count); -
trunk/JavaScriptCore/kjs/list.cpp
r34659 r34906 35 35 result.m_vector.appendRange(start, end()); 36 36 result.m_size = result.m_vector.size(); 37 result.m_buffer Slot = result.m_vector.dataSlot();37 result.m_buffer = result.m_vector.data(); 38 38 } 39 39 … … 80 80 81 81 m_vector.uncheckedAppend(v); 82 m_buffer Slot = m_vector.dataSlot();82 m_buffer = m_vector.data(); 83 83 } 84 84 -
trunk/JavaScriptCore/kjs/list.h
r34659 r34906 51 51 #endif 52 52 { 53 m_bufferSlot = m_vector.dataSlot(); 54 m_offset = 0; 53 m_buffer = m_vector.data(); 55 54 m_size = 0; 56 55 } 57 56 58 57 // Constructor for a read-only list whose data has already been allocated elsewhere. 59 ArgList(JSValue*** bufferSlot, size_t offset, size_t size) 60 : m_bufferSlot(bufferSlot) 61 , m_offset(offset) 58 ArgList(JSValue** buffer, size_t size) 59 : m_buffer(buffer) 62 60 , m_size(size) 63 61 , m_markSet(0) … … 80 78 { 81 79 if (i < m_size) 82 return buffer()[i];80 return m_buffer[i]; 83 81 return jsUndefined(); 84 82 } … … 89 87 { 90 88 m_vector.clear(); 89 m_buffer = 0; 91 90 m_size = 0; 92 91 } … … 109 108 void getSlice(int startIndex, ArgList& result) const; 110 109 111 iterator begin() { return buffer(); }112 iterator end() { return buffer()+ m_size; }110 iterator begin() { return m_buffer; } 111 iterator end() { return m_buffer + m_size; } 113 112 114 const_iterator begin() const { return buffer(); }115 const_iterator end() const { return buffer()+ m_size; }113 const_iterator begin() const { return m_buffer; } 114 const_iterator end() const { return m_buffer + m_size; } 116 115 117 116 static void markLists(ListSet&); … … 120 119 void slowAppend(JSValue*); 121 120 122 JSValue** buffer() const { return *m_bufferSlot + m_offset; } 123 124 JSValue*** m_bufferSlot; 125 size_t m_offset; 121 JSValue** m_buffer; 126 122 size_t m_size; 127 123
Note: See TracChangeset
for help on using the changeset viewer.