Changeset 96146 in webkit for trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
- Timestamp:
- Sep 27, 2011, 1:16:37 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r96131 r96146 46 46 #include "JSArray.h" 47 47 #include "JSByteArray.h" 48 #include "JSFunction.h" 48 49 #include "JSNotAnObject.h" 49 50 #include "JSPropertyNameIterator.h" … … 687 688 } 688 689 689 static void getCallerLine(JSGlobalData* globalData, CallFrame* callFrame, int& lineNumber)690 {691 (void)globalData;692 unsigned bytecodeOffset;693 lineNumber = -1;694 callFrame = callFrame->removeHostCallFrameFlag();695 696 if (callFrame->callerFrame() == CallFrame::noCaller() || callFrame->callerFrame()->hasHostCallFrameFlag())697 return;698 699 CodeBlock* callerCodeBlock = callFrame->callerFrame()->removeHostCallFrameFlag()->codeBlock();700 701 #if ENABLE(INTERPRETER)702 if (!globalData->canUseJIT())703 bytecodeOffset = callerCodeBlock->bytecodeOffset(callFrame->returnVPC());704 #if ENABLE(JIT)705 else706 bytecodeOffset = callerCodeBlock->bytecodeOffset(callFrame->returnPC());707 #endif708 #else709 bytecodeOffset = callerCodeBlock->bytecodeOffset(callFrame->returnPC());710 #endif711 712 lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(bytecodeOffset - 1);713 }714 715 static ALWAYS_INLINE const UString getSourceURLFromCallFrame(CallFrame* callFrame)716 {717 if (callFrame->hasHostCallFrameFlag())718 return UString();719 #if ENABLE(INTERPRETER)720 if (!callFrame->globalData().canUseJIT())721 return callFrame->codeBlock()->source()->url();722 #if ENABLE(JIT)723 return callFrame->codeBlock()->ownerExecutable()->sourceURL();724 #endif725 #else726 return callFrame->codeBlock()->ownerExecutable()->sourceURL();727 #endif728 }729 730 static StackFrameCodeType getStackFrameCodeType(CallFrame* callFrame)731 {732 if (callFrame->hasHostCallFrameFlag())733 return StackFrameNativeCode;734 735 switch (callFrame->codeBlock()->codeType()) {736 case EvalCode:737 return StackFrameEvalCode;738 case FunctionCode:739 return StackFrameFunctionCode;740 case GlobalCode:741 return StackFrameGlobalCode;742 }743 ASSERT_NOT_REACHED();744 return StackFrameGlobalCode;745 }746 747 void Interpreter::getStackTrace(JSGlobalData* globalData, int line, Vector<StackFrame>& results)748 {749 int stackLimit = 15;750 CallFrame* callFrame = globalData->topCallFrame->removeHostCallFrameFlag();751 if (!callFrame || callFrame == CallFrame::noCaller() || !callFrame->codeBlock())752 return;753 UString sourceURL;754 UString traceLevel;755 756 for (int i = 0; i < stackLimit; ++i) {757 if (!callFrame || callFrame == CallFrame::noCaller())758 break;759 if (callFrame->codeBlock()) {760 sourceURL = getSourceURLFromCallFrame(callFrame);761 762 StackFrame s = { Strong<JSObject>(*globalData, callFrame->callee()), Strong<CallFrame>(*globalData, callFrame), getStackFrameCodeType(callFrame), Strong<ExecutableBase>(*globalData, callFrame->codeBlock()->ownerExecutable()), line, sourceURL};763 764 results.append(s);765 }766 getCallerLine(globalData, callFrame, line);767 callFrame = callFrame->callerFrame()->removeHostCallFrameFlag();768 }769 }770 771 690 NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSValue& exceptionValue, unsigned bytecodeOffset) 772 691 { … … 787 706 // FIXME: should only really be adding these properties to VM generated exceptions, 788 707 // but the inspector currently requires these for all thrown objects. 789 Vector<StackFrame> stackTrace; 790 getStackTrace(&callFrame->globalData(), codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), stackTrace); 791 addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source(), stackTrace); 708 addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source()); 792 709 } 793 710
Note:
See TracChangeset
for help on using the changeset viewer.