Changeset 33370
- Timestamp:
- 05/12/08 23:06:43 (6 months ago)
- Location:
- branches/squirrelfish
- Files:
-
- 2 added
- 5 modified
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/VM/Machine.cpp (modified) (3 diffs)
-
JavaScriptCore/VM/Machine.h (modified) (1 diff)
-
JavaScriptCore/kjs/function.cpp (modified) (1 diff)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/js/function-dot-arguments-and-caller-expected.txt (added)
-
LayoutTests/fast/js/function-dot-arguments-and-caller.html (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/squirrelfish/JavaScriptCore/ChangeLog
r33369 r33370 1 2008-05-12 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Introduced support for function.caller. 6 7 Improved support for walking interesting scopes for function introspection. 8 9 This fixes all remaining layout tests not blocked by rebasing to trunk. 10 11 SunSpider reports no change. 12 13 * VM/Machine.cpp: 14 (KJS::Machine::dumpRegisters): Fixed a spacing issue. 15 1 16 2008-05-11 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 17 -
branches/squirrelfish/JavaScriptCore/VM/Machine.cpp
r33367 r33370 61 61 #endif 62 62 63 // Retrieves the offset of a calling function within the current register file. 64 bool getCallerFunctionOffset(Register** registerBase, int callOffset, int& callerOffset) 65 { 66 Register* callFrame = (*registerBase) + callOffset; 67 68 CodeBlock* callerCodeBlock = callFrame[Machine::CallerCodeBlock].u.codeBlock; 69 if (!callerCodeBlock) // test for top frame of re-entrant function call 70 return false; 71 72 callerOffset = callFrame[Machine::CallerRegisterOffset].u.i - callerCodeBlock->numLocals - Machine::CallFrameHeaderSize; 73 if (callerOffset < 0) // test for global frame 74 return false; 75 76 Register* callerCallFrame = (*registerBase) + callerOffset; 77 if (!callerCallFrame[Machine::CallerCodeBlock].u.codeBlock) // test for eval frame 78 return false; 79 80 return true; 81 } 82 63 83 // Returns the depth of the scope chain within a given call frame. 64 84 static int depth(ScopeChain& sc) … … 442 462 if (it != end) { 443 463 do { 444 printf("[call frame] | %10p | %10p \n", it, (*it).u.jsValue);464 printf("[call frame] | %10p | %10p \n", it, (*it).u.jsValue); 445 465 ++it; 446 466 } while (it != end); … … 2042 2062 } 2043 2063 2064 JSValue* Machine::retrieveCaller(ExecState* exec, FunctionImp* function) const 2065 { 2066 Register** registerBase; 2067 int callFrameOffset; 2068 2069 if (!getCallFrame(exec, function, registerBase, callFrameOffset)) 2070 return jsNull(); 2071 2072 int callerFrameOffset; 2073 if (!getCallerFunctionOffset(registerBase, callFrameOffset, callerFrameOffset)) 2074 return jsNull(); 2075 2076 Register* callerFrame = (*registerBase) + callerFrameOffset; 2077 ASSERT(callerFrame[Callee].u.jsValue); 2078 return callerFrame[Callee].u.jsValue; 2079 } 2080 2044 2081 bool Machine::getCallFrame(ExecState* exec, FunctionImp* function, Register**& registerBase, int& callFrameOffset) const 2045 2082 { 2046 2083 callFrameOffset = exec->m_callFrameOffset; 2047 if (callFrameOffset < 0) 2048 return false; 2049 2050 registerBase = exec->m_registerFile->basePointer(); 2051 Register* callFrame = (*registerBase) + callFrameOffset; 2052 return callFrame[Callee].u.jsValue == function; 2084 2085 while (1) { 2086 while (callFrameOffset < 0) { 2087 exec = exec->m_prev; 2088 if (!exec) 2089 return false; 2090 callFrameOffset = exec->m_callFrameOffset; 2091 } 2092 2093 registerBase = exec->m_registerFile->basePointer(); 2094 Register* callFrame = (*registerBase) + callFrameOffset; 2095 if (callFrame[Callee].u.jsValue == function) 2096 return true; 2097 2098 if (!getCallerFunctionOffset(registerBase, callFrameOffset, callFrameOffset)) 2099 callFrameOffset = -1; 2100 } 2053 2101 } 2054 2102 -
branches/squirrelfish/JavaScriptCore/VM/Machine.h
r33346 r33370 90 90 91 91 JSValue* retrieveArguments(ExecState*, FunctionImp*) const; 92 JSValue* retrieveCaller(ExecState*, FunctionImp*) const; 92 93 93 94 private: -
branches/squirrelfish/JavaScriptCore/kjs/function.cpp
r33367 r33370 111 111 FunctionImp* thisObj = static_cast<FunctionImp*>(slot.slotBase()); 112 112 ASSERT(exec->machine()); 113 UNUSED_PARAM(exec); 114 UNUSED_PARAM(slot); 115 UNUSED_PARAM(thisObj); 116 // FIXME: Implement this. 117 return jsNull(); 113 return exec->machine()->retrieveCaller(exec, thisObj); 118 114 } 119 115 -
branches/squirrelfish/LayoutTests/ChangeLog
r33369 r33370 1 2008-05-12 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Layout test for function.arguments and function.caller in interesting 6 scopes. 7 8 * fast/js/function-dot-arguments-and-caller-expected.txt: Added. 9 * fast/js/function-dot-arguments-and-caller.html: Added. 10 1 11 2008-05-11 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 12