Changeset 151500 in webkit
- Timestamp:
- Jun 12, 2013 8:03:37 AM (11 years ago)
- Location:
- branches/dfgFourthTier/Source
- Files:
-
- 4 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dfgFourthTier/Source/JavaScriptCore/API/JSContextRef.cpp
r151420 r151500 31 31 #include "InitializeThreading.h" 32 32 #include <interpreter/CallFrame.h> 33 #include <interpreter/Interpreter.h> 33 34 #include "JSCallbackObject.h" 34 35 #include "JSClassRef.h" … … 37 38 #include "Operations.h" 38 39 #include "SourceProvider.h" 39 #include "StackIterator.h"40 40 #include <wtf/text/StringBuilder.h> 41 41 #include <wtf/text/StringHash.h> … … 206 206 JSLockHolder lock(exec); 207 207 StringBuilder builder; 208 size_t i = 0; 209 ASSERT(maxStackSize); 210 for (StackIterator iter = exec->begin(); iter != exec->end() && maxStackSize--; ++iter, ++i) { 211 JSObject* callee = iter->callee(); 212 // If callee is unknown, but we've not added any frame yet, we should 213 // still add the frame, because something called us, and gave us arguments. 214 if (!callee && i) 215 break; 216 208 Vector<StackFrame> stackTrace; 209 exec->interpreter()->getStackTrace(stackTrace, maxStackSize); 210 211 for (size_t i = 0; i < stackTrace.size(); i++) { 212 String urlString; 213 String functionName; 214 StackFrame& frame = stackTrace[i]; 215 JSValue function = frame.callee.get(); 216 if (frame.callee) 217 functionName = frame.friendlyFunctionName(exec); 218 else { 219 // Caller is unknown, but if frame is empty we should still add the frame, because 220 // something called us, and gave us arguments. 221 if (i) 222 break; 223 } 224 unsigned lineNumber = frame.line(); 217 225 if (!builder.isEmpty()) 218 226 builder.append('\n'); … … 220 228 builder.appendNumber(i); 221 229 builder.append(' '); 222 builder.append( iter->functionName());230 builder.append(stackTrace[i].friendlyFunctionName(exec)); 223 231 builder.appendLiteral("() at "); 224 builder.append( iter->sourceURL());225 if ( iter->isJSFrame()) {232 builder.append(stackTrace[i].friendlySourceURL()); 233 if (frame.codeType != StackFrameNativeCode) { 226 234 builder.append(':'); 227 builder.appendNumber( iter->line());235 builder.appendNumber(lineNumber); 228 236 } 229 230 if (!callee) 237 if (!function) 231 238 break; 232 239 } -
branches/dfgFourthTier/Source/JavaScriptCore/CMakeLists.txt
r151420 r151500 164 164 interpreter/Interpreter.cpp 165 165 interpreter/JSStack.cpp 166 interpreter/StackIterator.cpp167 166 interpreter/VMInspector.cpp 168 167 -
branches/dfgFourthTier/Source/JavaScriptCore/ChangeLog
r151481 r151500 1 2013-06-12 Mark Lam <mark.lam@apple.com> 2 3 Unreviewed, rolled out r151456, r151420: 4 <http://trac.webkit.org/changeset/151420> 5 6 It causes layout test failures. 7 1 8 2013-06-11 Geoffrey Garen <ggaren@apple.com> 2 9 -
branches/dfgFourthTier/Source/JavaScriptCore/GNUmakefile.list.am
r151481 r151500 434 434 Source/JavaScriptCore/interpreter/JSStackInlines.h \ 435 435 Source/JavaScriptCore/interpreter/Register.h \ 436 Source/JavaScriptCore/interpreter/StackIterator.cpp \437 Source/JavaScriptCore/interpreter/StackIterator.h \438 Source/JavaScriptCore/interpreter/StackIteratorPrivate.h \439 436 Source/JavaScriptCore/interpreter/VMInspector.cpp \ 440 437 Source/JavaScriptCore/interpreter/VMInspector.h \ -
branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r151481 r151500 2423 2423 </File> 2424 2424 <File 2425 RelativePath="..\..\interpreter\StackIterator.cpp"2426 >2427 </File>2428 <File2429 RelativePath="..\..\interpreter\StackIterator.h"2430 >2431 </File>2432 <File2433 RelativePath="..\..\interpreter\StackIteratorPrivate.h"2434 >2435 </File>2436 <File2437 2425 RelativePath="..\..\interpreter\VMInspector.cpp" 2438 2426 > -
branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r151481 r151500 223 223 <ClCompile Include="..\interpreter\Interpreter.cpp" /> 224 224 <ClCompile Include="..\interpreter\JSStack.cpp" /> 225 <ClCompile Include="..\interpreter\StackIterator.cpp" />226 225 <ClCompile Include="..\interpreter\VMInspector.cpp" /> 227 226 <ClCompile Include="..\jit\ClosureCallStubRoutine.cpp" /> … … 556 555 <ClInclude Include="..\interpreter\JSStackInlines.h" /> 557 556 <ClInclude Include="..\interpreter\Register.h" /> 558 <ClInclude Include="..\interpreter\StackIterator.h" />559 <ClInclude Include="..\interpreter\StackIteratorPrivate.h" />560 557 <ClInclude Include="..\interpreter\VMInspector.h" /> 561 558 <ClInclude Include="..\jit\ClosureCallStubRoutine.h" /> -
branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r151481 r151500 286 286 <Filter>interpreter</Filter> 287 287 </ClCompile> 288 <ClCompile Include="..\interpreter\StackIterator.cpp">289 <Filter>interpreter</Filter>290 </ClCompile>291 288 <ClCompile Include="..\interpreter\VMInspector.cpp"> 292 289 <Filter>interpreter</Filter> … … 1213 1210 </ClInclude> 1214 1211 <ClInclude Include="..\interpreter\Register.h"> 1215 <Filter>interpreter</Filter>1216 </ClInclude>1217 <ClInclude Include="..\interpreter\StackIterator.h">1218 <Filter>interpreter</Filter>1219 </ClInclude>1220 <ClInclude Include="..\interpreter\StackIteratorPrivate.h">1221 1212 <Filter>interpreter</Filter> 1222 1213 </ClInclude> -
branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r151481 r151500 953 953 FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */; }; 954 954 FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4A331E15BD2E07006F54F3 /* VMInspector.h */; settings = {ATTRIBUTES = (Private, ); }; }; 955 FE526BD517663A8400B120DC /* StackIteratorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = FE526BD417663A8400B120DC /* StackIteratorPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };956 FE67DB9317519B4A006A814F /* JSStackInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FE67DB9017519B4A006A814F /* JSStackInlines.h */; };957 FE67DB9417519B4A006A814F /* StackIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE67DB9117519B4A006A814F /* StackIterator.cpp */; };958 FE67DB9517519B4A006A814F /* StackIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE67DB9217519B4A006A814F /* StackIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };959 955 FE940322174442590047CF6E /* JITStubsX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = FE940321174442590047CF6E /* JITStubsX86Common.h */; settings = {ATTRIBUTES = (Private, ); }; }; 960 956 FECE74571745456500FF9300 /* MacroAssemblerX86Common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FECE74561745456500FF9300 /* MacroAssemblerX86Common.cpp */; }; … … 1991 1987 FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMInspector.cpp; sourceTree = "<group>"; }; 1992 1988 FE4A331E15BD2E07006F54F3 /* VMInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInspector.h; sourceTree = "<group>"; }; 1993 FE526BD417663A8400B120DC /* StackIteratorPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackIteratorPrivate.h; sourceTree = "<group>"; };1994 FE67DB9017519B4A006A814F /* JSStackInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStackInlines.h; sourceTree = "<group>"; };1995 FE67DB9117519B4A006A814F /* StackIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackIterator.cpp; sourceTree = "<group>"; };1996 FE67DB9217519B4A006A814F /* StackIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackIterator.h; sourceTree = "<group>"; };1997 1989 FE940321174442590047CF6E /* JITStubsX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubsX86Common.h; sourceTree = "<group>"; }; 1998 1990 FECE74561745456500FF9300 /* MacroAssemblerX86Common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerX86Common.cpp; sourceTree = "<group>"; }; … … 2285 2277 1429D85B0ED218E900B89619 /* JSStack.cpp */, 2286 2278 14D792640DAA03FB001A9F05 /* JSStack.h */, 2287 FE67DB9017519B4A006A814F /* JSStackInlines.h */,2288 2279 149B24FF0D8AF6D1009CB8C7 /* Register.h */, 2289 FE67DB9117519B4A006A814F /* StackIterator.cpp */,2290 FE67DB9217519B4A006A814F /* StackIterator.h */,2291 FE526BD417663A8400B120DC /* StackIteratorPrivate.h */,2292 2280 FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */, 2293 2281 FE4A331E15BD2E07006F54F3 /* VMInspector.h */, … … 3268 3256 0F63945515D07057006A597C /* ArrayProfile.h in Headers */, 3269 3257 BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */, 3270 FE67DB9517519B4A006A814F /* StackIterator.h in Headers */,3271 FE526BD517663A8400B120DC /* StackIteratorPrivate.h in Headers */,3272 3258 FEF6835F174343CC00A32E25 /* JITStubsARMv7.h in Headers */, 3273 3259 FE24596217601D580074FCE0 /* CallFrameInlines.h in Headers */, … … 3703 3689 14DF04DA16B3996D0016A513 /* StaticPropertyAnalysis.h in Headers */, 3704 3690 14CA958B16AB50DE00938A06 /* StaticPropertyAnalyzer.h in Headers */, 3705 FE67DB9317519B4A006A814F /* JSStackInlines.h in Headers */,3706 3691 A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */, 3707 3692 BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */, … … 4236 4221 86DB64640F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp in Sources */, 4237 4222 0F56A1D515001CF4002992B1 /* ExecutionCounter.cpp in Sources */, 4238 FE67DB9417519B4A006A814F /* StackIterator.cpp in Sources */,4239 4223 0FB105851675480F00F8AB6E /* ExitKind.cpp in Sources */, 4240 4224 0FDB2CCF1742D7D8007B3C1B /* FTLJITFinalizer.cpp in Sources */, -
branches/dfgFourthTier/Source/JavaScriptCore/Target.pri
r151481 r151500 171 171 interpreter/Interpreter.cpp \ 172 172 interpreter/JSStack.cpp \ 173 interpreter/StackIterator.cpp \174 173 jit/ClosureCallStubRoutine.cpp \ 175 174 jit/ExecutableAllocatorFixedVMPool.cpp \ -
branches/dfgFourthTier/Source/JavaScriptCore/interpreter/CallFrame.cpp
r151420 r151500 68 68 69 69 #if ENABLE(DFG_JIT) 70 CallFrame* CallFrame::trueCallFrame() 71 { 72 // Am I an inline call frame? If so, we're done. 73 if (isInlinedFrame()) 74 return this; 75 76 // If I don't have a code block, then I'm not DFG code, so I'm the true call frame. 77 CodeBlock* machineCodeBlock = codeBlock(); 78 if (!machineCodeBlock) 79 return this; 80 81 // If the code block does not have any code origins, then there was no inlining, so 82 // I'm done. 83 if (!machineCodeBlock->hasCodeOrigins()) 84 return this; 85 86 // Try to determine the CodeOrigin. If we don't have a pc set then the only way 87 // that this makes sense is if the CodeOrigin index was set in the call frame. 88 CodeOrigin codeOrigin; 89 unsigned index = locationAsCodeOriginIndex(); 90 ASSERT(machineCodeBlock->canGetCodeOrigin(index)); 91 if (!machineCodeBlock->canGetCodeOrigin(index)) { 92 // See above. In release builds, we try to protect ourselves from crashing even 93 // though stack walking will be goofed up. 94 return 0; 95 } 96 codeOrigin = machineCodeBlock->codeOrigin(index); 97 98 if (!codeOrigin.inlineCallFrame) 99 return this; // Not currently in inlined code. 100 101 CodeOrigin innerMostCodeOrigin = codeOrigin; 102 103 for (InlineCallFrame* inlineCallFrame = codeOrigin.inlineCallFrame; inlineCallFrame;) { 104 InlineCallFrame* nextInlineCallFrame = inlineCallFrame->caller.inlineCallFrame; 105 106 CallFrame* inlinedCaller = this + inlineCallFrame->stackOffset; 107 108 JSFunction* calleeAsFunction = inlineCallFrame->callee.get(); 109 110 // Fill in the inlinedCaller 111 inlinedCaller->setCodeBlock(inlineCallFrame->baselineCodeBlock()); 112 if (calleeAsFunction) 113 inlinedCaller->setScope(calleeAsFunction->scope()); 114 if (nextInlineCallFrame) 115 inlinedCaller->setCallerFrame(this + nextInlineCallFrame->stackOffset); 116 else 117 inlinedCaller->setCallerFrame(this); 118 119 inlinedCaller->setInlineCallFrame(inlineCallFrame); 120 inlinedCaller->setArgumentCountIncludingThis(inlineCallFrame->arguments.size()); 121 inlinedCaller->setLocationAsBytecodeOffset(codeOrigin.bytecodeIndex); 122 inlinedCaller->setIsInlinedFrame(); 123 if (calleeAsFunction) 124 inlinedCaller->setCallee(calleeAsFunction); 125 126 codeOrigin = inlineCallFrame->caller; 127 inlineCallFrame = nextInlineCallFrame; 128 } 129 130 return this + innerMostCodeOrigin.inlineCallFrame->stackOffset; 131 } 132 133 CallFrame* CallFrame::trueCallerFrame() 134 { 135 CallFrame* callerFrame = this->callerFrame()->removeHostCallFrameFlag(); 136 if (!codeBlock()) 137 return callerFrame; 138 139 // this -> The callee; this is either an inlined callee in which case it already has 140 // a pointer to the true caller. Otherwise it contains current PC in the machine 141 // caller. 142 // 143 // machineCaller -> The caller according to the machine, which may be zero or 144 // more frames above the true caller due to inlining. 145 146 // Am I an inline call frame? If so, we're done. 147 if (isInlinedFrame()) 148 return callerFrame; 149 150 // I am a machine call frame, so the question is: is my caller a machine call frame 151 // that has inlines or a machine call frame that doesn't? 152 if (!callerFrame) 153 return 0; 154 155 if (!callerFrame->codeBlock()) 156 return callerFrame; 157 ASSERT(!callerFrame->isInlinedFrame()); 158 159 return callerFrame->trueCallFrame()->removeHostCallFrameFlag(); 160 } 161 70 162 unsigned CallFrame::bytecodeOffsetFromCodeOriginIndex() 71 163 { … … 98 190 } 99 191 100 StackIterator CallFrame::begin(StackIterator::FrameFilter filter)101 {102 if (!this)103 return StackIterator::empty();104 105 StackIterator iter(&vm());106 iter.beginAt(this, filter);107 return iter;108 192 } 109 110 StackIterator CallFrame::beginAt(JSFunction* calleeFunctionObj, StackIterator::FrameFilter filter)111 {112 if (!this)113 return StackIterator::empty();114 115 StackIterator iter(&vm());116 iter.beginAt(calleeFunctionObj, filter);117 return iter;118 }119 120 } -
branches/dfgFourthTier/Source/JavaScriptCore/interpreter/CallFrame.h
r151420 r151500 29 29 #include "MacroAssemblerCodeRef.h" 30 30 #include "Register.h" 31 #include "StackIteratorPrivate.h"32 31 33 32 namespace JSC { … … 276 275 #if ENABLE(DFG_JIT) 277 276 void setInlineCallFrame(InlineCallFrame* inlineCallFrame) { static_cast<Register*>(this)[JSStack::ReturnPC] = inlineCallFrame; } 277 278 // Call this to get the semantically correct JS CallFrame* for the 279 // currently executing function. 280 CallFrame* trueCallFrame(); 281 282 // Call this to get the semantically correct JS CallFrame* corresponding 283 // to the caller. This resolves issues surrounding inlining and the 284 // HostCallFrameFlag stuff. 285 CallFrame* trueCallerFrame(); 286 #else 287 CallFrame* trueCallFrame() { return this; } 288 CallFrame* trueCallerFrame() { return callerFrame()->removeHostCallFrameFlag(); } 278 289 #endif 279 290 CallFrame* callerFrameNoFlags() { return callerFrame()->removeHostCallFrameFlag(); } 280 281 JS_EXPORT_PRIVATE StackIterator begin(StackIterator::FrameFilter = nullptr);282 JS_EXPORT_PRIVATE StackIterator beginAt(JSFunction* calleeFunctionObj, StackIterator::FrameFilter = nullptr);283 JS_EXPORT_PRIVATE StackIterator::Frame* end() { return StackIterator::end(); }284 291 285 292 private: -
branches/dfgFourthTier/Source/JavaScriptCore/interpreter/Interpreter.cpp
r151481 r151500 64 64 #include "Register.h" 65 65 #include "SamplingTool.h" 66 #include "StackIterator.h"67 66 #include "StrictEvalActivation.h" 68 67 #include "StrongInlines.h" … … 202 201 203 202 203 static CallFrame* getCallerInfo(VM*, CallFrame*, unsigned& bytecodeOffset, CodeBlock*& callerOut); 204 204 205 JSValue eval(CallFrame* callFrame) 205 206 { … … 410 411 dataLogF("[ReturnJITPC] | %10p | %p \n", it, pc.jitReturnAddress().value()); 411 412 #endif 412 StackIterator iter = callFrame->begin(); 413 dataLogF("[ReturnVPC] | %10p | %d (line %d)\n", it, iter->bytecodeOffset(), iter->line()); 413 unsigned bytecodeOffset = 0; 414 int line = 0; 415 CodeBlock* callerCodeBlock = 0; 416 getCallerInfo(&callFrame->vm(), callFrame, bytecodeOffset, callerCodeBlock); 417 line = callerCodeBlock->lineNumberForBytecodeOffset(bytecodeOffset); 418 dataLogF("[ReturnVPC] | %10p | %d (line %d)\n", it, bytecodeOffset, line); 414 419 ++it; 415 420 dataLogF("[CodeBlock] | %10p | %p \n", it, callFrame->codeBlock()); … … 461 466 } 462 467 463 NEVER_INLINE bool Interpreter::unwindCallFrame(StackIterator& iter, JSValue exceptionValue) 464 { 465 CallFrame* callFrame = iter->callFrame(); 466 CodeBlock* codeBlock = iter->codeBlock(); 468 NEVER_INLINE bool Interpreter::unwindCallFrame(CallFrame*& callFrame, JSValue exceptionValue, unsigned& bytecodeOffset, CodeBlock*& codeBlock) 469 { 467 470 CodeBlock* oldCodeBlock = codeBlock; 468 471 JSScope* scope = callFrame->scope(); … … 494 497 CallFrame* callerFrame = callFrame->callerFrame(); 495 498 callFrame->vm().topCallFrame = callerFrame; 496 return !callerFrame->hasHostCallFrameFlag(); 499 if (callerFrame->hasHostCallFrameFlag()) 500 return false; 501 callFrame = getCallerInfo(&callFrame->vm(), callFrame, bytecodeOffset, codeBlock); 502 return true; 497 503 } 498 504 … … 549 555 } 550 556 557 static unsigned getBytecodeOffsetForCallFrame(CallFrame* callFrame) 558 { 559 callFrame = callFrame->removeHostCallFrameFlag(); 560 CodeBlock* codeBlock = callFrame->codeBlock(); 561 if (!codeBlock) 562 return 0; 563 #if ENABLE(JIT) 564 #if ENABLE(DFG_JIT) 565 if (JITCode::isOptimizingJIT(codeBlock->jitType())) 566 return codeBlock->codeOrigin(callFrame->locationAsCodeOriginIndex()).bytecodeIndex; 567 #endif 568 return callFrame->locationAsBytecodeOffset(); 569 #endif 570 } 571 572 static CallFrame* getCallerInfo(VM* vm, CallFrame* callFrame, unsigned& bytecodeOffset, CodeBlock*& caller) 573 { 574 UNUSED_PARAM(vm); 575 bytecodeOffset = 0; 576 ASSERT(!callFrame->hasHostCallFrameFlag()); 577 CallFrame* trueCallerFrame = callFrame->trueCallerFrame(); 578 ASSERT(!trueCallerFrame->hasHostCallFrameFlag()); 579 580 if (trueCallerFrame == CallFrame::noCaller() || !trueCallerFrame || !trueCallerFrame->codeBlock()) { 581 caller = 0; 582 return trueCallerFrame; 583 } 584 585 CodeBlock* callerCodeBlock = trueCallerFrame->codeBlock(); 586 #if ENABLE(DFG_JIT) 587 if (trueCallerFrame->hasLocationAsCodeOriginIndex()) 588 bytecodeOffset = trueCallerFrame->bytecodeOffsetFromCodeOriginIndex(); 589 else 590 #endif // ENABLE(DFG_JIT) 591 bytecodeOffset = trueCallerFrame->locationAsBytecodeOffset(); 592 593 caller = callerCodeBlock; 594 return trueCallerFrame; 595 } 596 597 static ALWAYS_INLINE const String getSourceURLFromCallFrame(CallFrame* callFrame) 598 { 599 ASSERT(!callFrame->hasHostCallFrameFlag()); 600 return callFrame->codeBlock()->ownerExecutable()->sourceURL(); 601 } 602 603 static StackFrameCodeType getStackFrameCodeType(CallFrame* callFrame) 604 { 605 ASSERT(!callFrame->hasHostCallFrameFlag()); 606 607 switch (callFrame->codeBlock()->codeType()) { 608 case EvalCode: 609 return StackFrameEvalCode; 610 case FunctionCode: 611 return StackFrameFunctionCode; 612 case GlobalCode: 613 return StackFrameGlobalCode; 614 } 615 RELEASE_ASSERT_NOT_REACHED(); 616 return StackFrameGlobalCode; 617 } 618 551 619 unsigned StackFrame::line() 552 620 { … … 594 662 { 595 663 VM& vm = m_vm; 596 CallFrame* callFrame = vm.topCallFrame; 597 StackIterator iter = callFrame->begin(); 598 for (; iter != callFrame->end() && maxStackSize--; ++iter) { 599 CodeBlock* codeBlock = iter->codeBlock(); 600 if (codeBlock) { 601 StackFrame s(Strong<JSObject>(vm, iter->callee()), 602 StackFrameCodeType(iter->codeType()), 603 Strong<ExecutableBase>(vm, codeBlock->ownerExecutable()), 604 Strong<UnlinkedCodeBlock>(vm, codeBlock->unlinkedCodeBlock()), 605 codeBlock->source(), 606 codeBlock->ownerExecutable()->lineNo(), 607 codeBlock->sourceOffset(), 608 iter->bytecodeOffset(), 609 iter->sourceURL()); 664 CallFrame* callFrame = vm.topCallFrame->removeHostCallFrameFlag(); 665 if (!callFrame || callFrame == CallFrame::noCaller()) 666 return; 667 unsigned bytecodeOffset = getBytecodeOffsetForCallFrame(callFrame); 668 callFrame = callFrame->trueCallFrame(); 669 if (!callFrame) 670 return; 671 CodeBlock* callerCodeBlock = callFrame->codeBlock(); 672 673 while (callFrame && callFrame != CallFrame::noCaller() && maxStackSize--) { 674 String sourceURL; 675 if (callerCodeBlock) { 676 sourceURL = getSourceURLFromCallFrame(callFrame); 677 StackFrame s(Strong<JSObject>(vm, callFrame->callee()), 678 getStackFrameCodeType(callFrame), 679 Strong<ExecutableBase>(vm, callerCodeBlock->ownerExecutable()), 680 Strong<UnlinkedCodeBlock>(vm, callerCodeBlock->unlinkedCodeBlock()), 681 callerCodeBlock->source(), 682 callerCodeBlock->ownerExecutable()->lineNo(), 683 callerCodeBlock->sourceOffset(), 684 bytecodeOffset, 685 sourceURL); 610 686 results.append(s); 611 687 } else { 612 StackFrame s(Strong<JSObject>(vm, iter->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, String());688 StackFrame s(Strong<JSObject>(vm, callFrame->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, String()); 613 689 results.append(s); 614 690 } 691 callFrame = getCallerInfo(&vm, callFrame, bytecodeOffset, callerCodeBlock); 615 692 } 616 693 } … … 688 765 // Calculate an exception handler vPC, unwinding call frames as necessary. 689 766 HandlerInfo* handler = 0; 690 VM& vm = callFrame->vm(); 691 for (StackIterator iter = callFrame->begin(); iter != callFrame->end(); ++iter) { 692 callFrame = iter->callFrame(); 693 codeBlock = iter->codeBlock(); 694 bytecodeOffset = iter->bytecodeOffset(); 695 696 if (isTermination || !(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) { 697 if (!unwindCallFrame(iter, exceptionValue)) { 698 if (LegacyProfiler* profiler = vm.enabledProfiler()) 699 profiler->exceptionUnwind(callFrame); 700 return 0; 701 } 702 } else 703 break; 767 while (isTermination || !(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) { 768 if (!unwindCallFrame(callFrame, exceptionValue, bytecodeOffset, codeBlock)) { 769 if (LegacyProfiler* profiler = callFrame->vm().enabledProfiler()) 770 profiler->exceptionUnwind(callFrame); 771 return 0; 772 } 704 773 } 705 774 … … 1300 1369 return; 1301 1370 } 1302 } 1371 } 1372 1373 JSValue Interpreter::retrieveArgumentsFromVMCode(CallFrame* callFrame, JSFunction* function) const 1374 { 1375 CallFrame* functionCallFrame = findFunctionCallFrameFromVMCode(callFrame, function); 1376 if (!functionCallFrame) 1377 return jsNull(); 1378 1379 Arguments* arguments = Arguments::create(functionCallFrame->vm(), functionCallFrame); 1380 arguments->tearOff(functionCallFrame); 1381 return JSValue(arguments); 1382 } 1383 1384 JSValue Interpreter::retrieveCallerFromVMCode(CallFrame* callFrame, JSFunction* function) const 1385 { 1386 CallFrame* functionCallFrame = findFunctionCallFrameFromVMCode(callFrame, function); 1387 1388 if (!functionCallFrame) 1389 return jsNull(); 1390 1391 unsigned bytecodeOffset; 1392 CodeBlock* unusedCallerCodeBlock = 0; 1393 CallFrame* callerFrame = getCallerInfo(&callFrame->vm(), functionCallFrame, bytecodeOffset, unusedCallerCodeBlock); 1394 if (!callerFrame) 1395 return jsNull(); 1396 JSValue caller = callerFrame->callee(); 1397 if (!caller) 1398 return jsNull(); 1399 1400 // Skip over function bindings. 1401 ASSERT(caller.isObject()); 1402 while (asObject(caller)->inherits(&JSBoundFunction::s_info)) { 1403 callerFrame = getCallerInfo(&callFrame->vm(), callerFrame, bytecodeOffset, unusedCallerCodeBlock); 1404 if (!callerFrame) 1405 return jsNull(); 1406 caller = callerFrame->callee(); 1407 if (!caller) 1408 return jsNull(); 1409 } 1410 1411 return caller; 1412 } 1413 1414 CallFrame* Interpreter::findFunctionCallFrameFromVMCode(CallFrame* callFrame, JSFunction* function) 1415 { 1416 for (CallFrame* candidate = callFrame->trueCallFrame(); candidate; candidate = candidate->trueCallerFrame()) { 1417 if (candidate->callee() == function) 1418 return candidate; 1419 } 1420 return 0; 1421 } 1303 1422 1304 1423 void Interpreter::enableSampler() -
branches/dfgFourthTier/Source/JavaScriptCore/interpreter/Interpreter.h
r151420 r151500 57 57 class JSScope; 58 58 class SamplingTool; 59 class StackIterator;60 59 struct CallFrameClosure; 61 60 struct HandlerInfo; … … 237 236 JSValue execute(EvalExecutable*, CallFrame*, JSValue thisValue, JSScope*); 238 237 238 JSValue retrieveArgumentsFromVMCode(CallFrame*, JSFunction*) const; 239 JSValue retrieveCallerFromVMCode(CallFrame*, JSFunction*) const; 240 239 241 void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc); 240 242 … … 243 245 NEVER_INLINE HandlerInfo* throwException(CallFrame*&, JSValue&, unsigned bytecodeOffset); 244 246 NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine, int column); 247 static const String getTraceLine(CallFrame*, StackFrameCodeType, const String&, int); 248 JS_EXPORT_PRIVATE void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max()); 245 249 static void addStackTraceIfNecessary(CallFrame*, JSValue error); 246 250 … … 268 272 JSValue execute(CallFrameClosure&); 269 273 270 void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max()); 271 NEVER_INLINE bool unwindCallFrame(StackIterator&, JSValue); 274 NEVER_INLINE bool unwindCallFrame(CallFrame*&, JSValue, unsigned& bytecodeOffset, CodeBlock*&); 275 276 static CallFrame* findFunctionCallFrameFromVMCode(CallFrame*, JSFunction*); 272 277 273 278 void dumpRegisters(CallFrame*); -
branches/dfgFourthTier/Source/JavaScriptCore/jsc.cpp
r151420 r151500 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 , 2013Apple Inc. All rights reserved.3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2006 Bjoern Graf (bjoern.graf@gmail.com) 5 5 * … … 39 39 #include "Operations.h" 40 40 #include "SamplingTool.h" 41 #include "StackIterator.h"42 41 #include "StructureRareDataInlines.h" 43 42 #include <math.h> … … 328 327 trace.appendLiteral("--> Stack trace:\n"); 329 328 329 Vector<StackFrame> stackTrace; 330 exec->interpreter()->getStackTrace(stackTrace); 330 331 int i = 0; 331 for (StackIterator iter = exec->begin(); iter != exec->end(); ++iter, ++i) 332 trace.append(String::format(" %i %s\n", i, iter->toString().utf8().data())); 332 333 for (Vector<StackFrame>::iterator iter = stackTrace.begin(); iter < stackTrace.end(); iter++) { 334 StackFrame level = *iter; 335 trace.append(String::format(" %i %s\n", i, level.toString(exec).utf8().data())); 336 i++; 337 } 333 338 fprintf(stderr, "%s", trace.toString().utf8().data()); 334 339 return JSValue::encode(jsUndefined()); -
branches/dfgFourthTier/Source/JavaScriptCore/profiler/ProfileGenerator.cpp
r151420 r151500 32 32 #include "JSStringRef.h" 33 33 #include "JSFunction.h" 34 #include "Interpreter.h" 34 35 #include "LegacyProfiler.h" 35 36 #include "Operations.h" 36 37 #include "Profile.h" 37 #include "StackIterator.h"38 38 #include "Tracing.h" 39 39 … … 59 59 void ProfileGenerator::addParentForConsoleStart(ExecState* exec) 60 60 { 61 StackIterator iter = exec->begin(); 62 ++iter; 63 CallIdentifier identifier = LegacyProfiler::createCallIdentifier(exec, iter->callee(), iter->sourceURL(), iter->line()); 64 m_currentNode = ProfileNode::create(exec, identifier, m_head.get(), m_head.get()); 65 61 Vector<StackFrame> stackTrace; 62 exec->interpreter()->getStackTrace(stackTrace, 2); 63 64 m_currentNode = ProfileNode::create(exec, LegacyProfiler::createCallIdentifier(exec, stackTrace[1].callee.get(), stackTrace[1].sourceURL, stackTrace[1].line()), m_head.get(), m_head.get()); 66 65 m_head->insertNode(m_currentNode.get()); 67 66 } -
branches/dfgFourthTier/Source/JavaScriptCore/profiler/ProfileNode.h
r151420 r151500 41 41 class ProfileNode; 42 42 43 typedef Vector<RefPtr<ProfileNode> >::const_iterator StackIterator; 43 44 typedef HashCountedSet<StringImpl*> FunctionCallHashCount; 44 45 … … 131 132 132 133 private: 133 typedef Vector<RefPtr<ProfileNode> >::const_iterator StackIterator;134 135 134 ProfileNode(ExecState* callerCallFrame, const CallIdentifier&, ProfileNode* headNode, ProfileNode* parentNode); 136 135 ProfileNode(ExecState* callerCallFrame, ProfileNode* headNode, ProfileNode* nodeToCopy); -
branches/dfgFourthTier/Source/JavaScriptCore/runtime/JSFunction.cpp
r151420 r151500 26 26 #include "JSFunction.h" 27 27 28 #include "Arguments.h"29 28 #include "CodeBlock.h" 30 29 #include "CommonIdentifiers.h" … … 34 33 #include "GetterSetter.h" 35 34 #include "JSArray.h" 36 #include "JSBoundFunction.h"37 35 #include "JSGlobalObject.h" 38 36 #include "JSNotAnObject.h" … … 43 41 #include "Parser.h" 44 42 #include "PropertyNameArray.h" 45 #include "StackIterator.h"46 43 47 44 using namespace WTF; … … 182 179 } 183 180 184 static JSValue retrieveArguments(ExecState* exec, JSFunction* functionObj)185 {186 StackIterator iter = exec->beginAt(functionObj);187 return iter != exec->end() ? JSValue(iter->arguments()) : jsNull();188 }189 190 181 JSValue JSFunction::argumentsGetter(ExecState* exec, JSValue slotBase, PropertyName) 191 182 { 192 183 JSFunction* thisObj = jsCast<JSFunction*>(slotBase); 193 184 ASSERT(!thisObj->isHostFunction()); 194 195 return retrieveArguments(exec, thisObj); 196 } 197 198 static bool skipOverBoundFunctions(StackIterator::Frame* frame) 199 { 200 JSObject* callee = frame->callee(); 201 bool shouldSkip = callee ? callee->inherits(&JSBoundFunction::s_info) : false; 202 return shouldSkip; 203 } 204 205 static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj) 206 { 207 StackIterator iter = exec->beginAt(functionObj, skipOverBoundFunctions); 208 ++iter; 209 return iter != exec->end() && iter->callee() ? iter->callee() : jsNull(); 185 return exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObj); 210 186 } 211 187 … … 214 190 JSFunction* thisObj = jsCast<JSFunction*>(slotBase); 215 191 ASSERT(!thisObj->isHostFunction()); 216 JSValue caller = retrieveCallerFunction(exec, thisObj);192 JSValue caller = exec->interpreter()->retrieveCallerFromVMCode(exec, thisObj); 217 193 218 194 // See ES5.1 15.3.5.4 - Function.caller may not be used to retrieve a strict caller. … … 322 298 return result; 323 299 } 324 descriptor.setDescriptor( retrieveArguments(exec, thisObject), ReadOnly | DontEnum | DontDelete);300 descriptor.setDescriptor(exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete); 325 301 return true; 326 302 } … … 346 322 return result; 347 323 } 348 descriptor.setDescriptor( retrieveCallerFunction(exec, thisObject), ReadOnly | DontEnum | DontDelete);324 descriptor.setDescriptor(exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete); 349 325 return true; 350 326 } … … 440 416 return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException); 441 417 } 442 valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveArguments(exec, thisObject));418 valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject)); 443 419 } else if (propertyName == exec->propertyNames().caller) { 444 420 if (thisObject->jsExecutable()->isStrictMode()) { … … 447 423 return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException); 448 424 } 449 valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveCallerFunction(exec, thisObject));425 valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject)); 450 426 } else if (propertyName == exec->propertyNames().length) 451 427 valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), jsNumber(thisObject->jsExecutable()->parameterCount())); -
branches/dfgFourthTier/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r151481 r151500 37 37 #include "Operations.h" 38 38 #include "Parser.h" 39 #include "StackIterator.h"40 39 #include <wtf/dtoa.h> 41 40 #include <stdio.h> … … 713 712 return JSValue::encode(exec->thisValue().synthesizePrototype(exec)); 714 713 715 StackIterator iter = exec->begin(); 716 ++iter; 717 if (!thisObject->allowsAccessFrom(iter->callFrame())) 714 if (!thisObject->allowsAccessFrom(exec->trueCallerFrame())) 718 715 return JSValue::encode(jsUndefined()); 719 716 … … 731 728 return JSValue::encode(jsUndefined()); 732 729 733 StackIterator iter = exec->begin(); 734 ++iter; 735 if (!thisObject->allowsAccessFrom(iter->callFrame())) 730 if (!thisObject->allowsAccessFrom(exec->trueCallerFrame())) 736 731 return JSValue::encode(jsUndefined()); 737 732 -
branches/dfgFourthTier/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
r151420 r151500 34 34 #include "PropertyDescriptor.h" 35 35 #include "PropertyNameArray.h" 36 #include "StackIterator.h"37 36 38 37 namespace JSC { … … 141 140 return throwVMError(exec, createTypeError(exec, ASCIILiteral("Requested prototype of a value that is not an object."))); 142 141 JSObject* object = asObject(exec->argument(0)); 143 StackIterator iter = exec->begin(); 144 ++iter; 145 if (!object->allowsAccessFrom(iter->callFrame())) 142 if (!object->allowsAccessFrom(exec->trueCallerFrame())) 146 143 return JSValue::encode(jsUndefined()); 147 144 return JSValue::encode(object->prototype()); -
branches/dfgFourthTier/Source/JavaScriptCore/runtime/Operations.h
r151420 r151500 23 23 #define Operations_h 24 24 25 #include "CallFrameInlines.h"26 25 #include "ExceptionHelpers.h" 27 26 #include "Interpreter.h" -
branches/dfgFourthTier/Source/WebCore/ChangeLog
r151420 r151500 1 2013-06-12 Mark Lam <mark.lam@apple.com> 2 3 Unreviewed, rolled out r151456, r151420: 4 <http://trac.webkit.org/changeset/151420> 5 6 It causes layout test failures. 7 1 8 2013-06-10 Mark Lam <mark.lam@apple.com> 2 9 -
branches/dfgFourthTier/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
r151420 r151500 48 48 #include "JSEventListener.h" 49 49 #include "XMLHttpRequest.h" 50 #include <interpreter/StackIterator.h>51 50 #include <runtime/Error.h> 51 #include <interpreter/Interpreter.h> 52 52 #include <wtf/ArrayBuffer.h> 53 53 … … 134 134 } 135 135 136 StackIterator iter = exec->begin(); 137 ++iter; 138 ASSERT(iter != exec->end()); 139 impl()->setLastSendLineNumber(iter->line()); 140 impl()->setLastSendURL(iter->sourceURL()); 136 Vector<StackFrame> stackTrace(2); 137 exec->interpreter()->getStackTrace(stackTrace, 2); 138 impl()->setLastSendLineNumber(stackTrace[1].line()); 139 impl()->setLastSendURL(stackTrace[1].sourceURL); 141 140 142 141 setDOMException(exec, ec); -
branches/dfgFourthTier/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp
r151420 r151500 41 41 #include "ScriptValue.h" 42 42 #include <interpreter/CallFrame.h> 43 #include <interpreter/ StackIterator.h>43 #include <interpreter/Interpreter.h> 44 44 #include <runtime/ArgList.h> 45 45 #include <runtime/JSCJSValue.h> … … 58 58 Vector<ScriptCallFrame> frames; 59 59 if (JSC::ExecState* exec = JSMainThreadExecState::currentState()) { 60 for (StackIterator iter = exec->begin(); iter != exec->end() && maxStackSize--; ++iter) 61 frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), iter->line(), iter->column())); 60 Vector<StackFrame> stackTrace; 61 exec->interpreter()->getStackTrace(stackTrace, maxStackSize); 62 for (size_t i = 0; i < stackTrace.size(); i++) 63 frames.append(ScriptCallFrame(stackTrace[i].friendlyFunctionName(exec), stackTrace[i].friendlySourceURL(), stackTrace[i].line(), stackTrace[i].column())); 62 64 } 63 65 if (frames.isEmpty() && !emptyIsAllowed) { … … 73 75 { 74 76 Vector<ScriptCallFrame> frames; 75 StackIterator iter = exec->begin(); 76 for (++iter; iter != exec->end() && maxStackSize--; ++iter) { 77 Vector<StackFrame> stackTrace; 78 exec->interpreter()->getStackTrace(stackTrace, maxStackSize + 1); 79 for (size_t i = stackTrace.size() == 1 ? 0 : 1; i < stackTrace.size(); i++) { 77 80 // This early exit is necessary to maintain our old behaviour 78 81 // but the stack trace we produce now is complete and handles all 79 82 // ways in which code may be running 80 if (! iter->callee()&& frames.size())83 if (!stackTrace[i].callee && frames.size()) 81 84 break; 82 frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), iter->line(), iter->column())); 85 86 String functionName = stackTrace[i].friendlyFunctionName(exec); 87 frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, stackTrace[i].line(), stackTrace[i].column())); 83 88 } 89 84 90 return ScriptCallStack::create(frames); 85 91 }
Note: See TracChangeset
for help on using the changeset viewer.