Changeset 114317 in webkit for trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
- Timestamp:
- Apr 16, 2012, 4:37:40 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r114309 r114317 66 66 #include <stdio.h> 67 67 #include <wtf/Threading.h> 68 #include <wtf/text/StringBuilder.h>69 68 70 69 #if ENABLE(JIT) … … 954 953 } 955 954 956 void Interpreter::getStackTrace(JSGlobalData* globalData, Vector<StackFrame>& results)955 void Interpreter::getStackTrace(JSGlobalData* globalData, int line, Vector<StackFrame>& results) 957 956 { 958 CallFrame* callFrame = globalData->topCallFrame->removeHostCallFrameFlag() ;957 CallFrame* callFrame = globalData->topCallFrame->removeHostCallFrameFlag()->trueCallFrameFromVMCode(); 959 958 if (!callFrame || callFrame == CallFrame::noCaller()) 960 959 return; 961 int line = getLineNumberForCallFrame(globalData, callFrame); 962 963 callFrame = callFrame->trueCallFrameFromVMCode();960 961 if (line == -1) 962 line = getLineNumberForCallFrame(globalData, callFrame); 964 963 965 964 while (callFrame && callFrame != CallFrame::noCaller()) { … … 977 976 } 978 977 979 void Interpreter::addStackTraceIfNecessary(CallFrame* callFrame, JSObject* error)980 {981 JSGlobalData* globalData = &callFrame->globalData();982 if (error->hasProperty(callFrame, globalData->propertyNames->stack))983 return;984 985 Vector<StackFrame> stackTrace;986 getStackTrace(&callFrame->globalData(), stackTrace);987 988 if (stackTrace.isEmpty())989 return;990 991 JSGlobalObject* globalObject = 0;992 if (isTerminatedExecutionException(error) || isInterruptedExecutionException(error))993 globalObject = globalData->dynamicGlobalObject;994 else995 globalObject = error->globalObject();996 StringBuilder builder;997 for (unsigned i = 0; i < stackTrace.size(); i++) {998 builder.append(String(stackTrace[i].toString(globalObject->globalExec()).impl()));999 if (i != stackTrace.size() - 1)1000 builder.append('\n');1001 }1002 1003 error->putDirect(*globalData, globalData->propertyNames->stack, jsString(globalData, UString(builder.toString().impl())), ReadOnly | DontDelete);1004 }1005 1006 978 NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSValue& exceptionValue, unsigned bytecodeOffset) 1007 979 { … … 1019 991 if (codeBlock->hasExpressionInfo() && !hasErrorInfo(callFrame, exception)) { 1020 992 ASSERT(codeBlock->hasLineInfo()); 993 1021 994 // FIXME: should only really be adding these properties to VM generated exceptions, 1022 995 // but the inspector currently requires these for all thrown objects. 1023 addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source()); 996 Vector<StackFrame> stackTrace; 997 getStackTrace(&callFrame->globalData(), codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), stackTrace); 998 addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source(), stackTrace); 1024 999 } 1025 1000
Note:
See TracChangeset
for help on using the changeset viewer.