Changeset 96146 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Sep 27, 2011, 1:16:37 PM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r96143 r96146 1 2011-09-27 Sheriff Bot <[email protected]> 2 3 Unreviewed, rolling out r96131. 4 http://trac.webkit.org/changeset/96131 5 https://bugs.webkit.org/show_bug.cgi?id=68927 6 7 It made 18+ tests crash on all platform (Requested by 8 Ossy_night on #webkit). 9 10 * JavaScriptCore.exp: 11 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 12 * interpreter/Interpreter.cpp: 13 (JSC::Interpreter::throwException): 14 * interpreter/Interpreter.h: 15 * jsc.cpp: 16 (GlobalObject::finishCreation): 17 * parser/Parser.h: 18 (JSC::Parser::parse): 19 * runtime/CommonIdentifiers.h: 20 * runtime/Error.cpp: 21 (JSC::addErrorInfo): 22 * runtime/Error.h: 23 1 24 2011-09-27 Mark Hahnenberg <[email protected]> 2 25 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r96143 r96146 115 115 __ZN3JSC10throwErrorEPNS_9ExecStateENS_7JSValueE 116 116 __ZN3JSC10throwErrorEPNS_9ExecStateEPNS_8JSObjectE 117 __ZN3JSC11Interpreter13getStackTraceEPNS_12JSGlobalDataEiRN3WTF6VectorINS_10StackFrameELm0EEE118 117 __ZN3JSC11JSByteArray13s_defaultInfoE 119 118 __ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataEPNS_14JSGlobalObjectENS_7JSValueEPKNS_9ClassInfoE -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r96143 r96146 209 209 ?getPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z 210 210 ?getSlice@ArgList@JSC@@QBEXHAAV12@@Z 211 ?getStackTrace@Interpreter@JSC@@SAXPAVJSGlobalData@2@HAAV?$Vector@UStackFrame@JSC@@$0A@@WTF@@@Z212 211 ?getString@JSCell@JSC@@QBE?AVUString@2@PAVExecState@2@@Z 213 212 ?getString@JSCell@JSC@@QBE_NPAVExecState@2@AAVUString@2@@Z -
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 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.h
r96131 r96146 32 32 #include "ArgList.h" 33 33 #include "JSCell.h" 34 #include "JSFunction.h"35 34 #include "JSValue.h" 36 35 #include "JSObject.h" … … 44 43 class CodeBlock; 45 44 class EvalExecutable; 46 class ExecutableBase;47 45 class FunctionExecutable; 46 class JSFunction; 48 47 class JSGlobalObject; 49 48 class ProgramExecutable; … … 62 61 WillLeaveCallFrame, 63 62 WillExecuteStatement 64 };65 66 enum StackFrameCodeType {67 StackFrameGlobalCode,68 StackFrameEvalCode,69 StackFrameFunctionCode,70 StackFrameNativeCode71 };72 73 struct StackFrame {74 Strong<JSObject> callee;75 Strong<CallFrame> callFrame;76 StackFrameCodeType codeType;77 Strong<ExecutableBase> executable;78 int line;79 UString sourceURL;80 UString toString() const81 {82 bool hasSourceURLInfo = !sourceURL.isNull() && !sourceURL.isEmpty();83 bool hasLineInfo = line > -1;84 String traceLine;85 JSObject* stackFrameCallee = callee.get();86 87 switch (codeType) {88 case StackFrameEvalCode:89 if (hasSourceURLInfo)90 traceLine = hasLineInfo ? String::format("eval at %s:%d", sourceURL.ascii().data(), line)91 : String::format("eval at %s", sourceURL.ascii().data());92 else93 traceLine = String::format("eval");94 break;95 case StackFrameNativeCode:96 traceLine = "Native code";97 break;98 case StackFrameFunctionCode:99 if (stackFrameCallee && stackFrameCallee->inherits(&JSFunction::s_info)) {100 UString functionName = asFunction(stackFrameCallee)->name(callFrame.get());101 if (hasSourceURLInfo)102 traceLine = hasLineInfo ? String::format("%s at %s:%d", functionName.ascii().data(), sourceURL.ascii().data(), line)103 : String::format("%s at %s", functionName.ascii().data(), sourceURL.ascii().data());104 else105 traceLine = String::format("%s\n", functionName.ascii().data());106 break;107 }108 case StackFrameGlobalCode:109 traceLine = hasLineInfo ? String::format("at %s:%d", sourceURL.ascii().data(), line)110 : String::format("at %s", sourceURL.ascii().data());111 }112 return traceLine.impl();113 }114 63 }; 115 64 … … 180 129 NEVER_INLINE HandlerInfo* throwException(CallFrame*&, JSValue&, unsigned bytecodeOffset); 181 130 NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine); 182 static const UString getTraceLine(CallFrame*, StackFrameCodeType, const UString&, int);183 static void getStackTrace(JSGlobalData*, int line, Vector<StackFrame>& results);184 131 185 132 void dumpSampleData(ExecState* exec); -
trunk/Source/JavaScriptCore/jsc.cpp
r96131 r96146 28 28 #include "ExceptionHelpers.h" 29 29 #include "InitializeThreading.h" 30 #include "Interpreter.h"31 30 #include "JSArray.h" 32 31 #include "JSFunction.h" … … 75 74 static EncodedJSValue JSC_HOST_CALL functionPrint(ExecState*); 76 75 static EncodedJSValue JSC_HOST_CALL functionDebug(ExecState*); 77 static EncodedJSValue JSC_HOST_CALL functionJSCStack(ExecState*);78 76 static EncodedJSValue JSC_HOST_CALL functionGC(ExecState*); 79 77 #ifndef NDEBUG … … 177 175 addFunction(globalData, "load", functionLoad, 1); 178 176 addFunction(globalData, "checkSyntax", functionCheckSyntax, 1); 179 addFunction(globalData, "jscStack", functionJSCStack, 1);180 177 addFunction(globalData, "readline", functionReadline, 0); 181 178 addFunction(globalData, "preciseTime", functionPreciseTime, 0); … … 222 219 { 223 220 fprintf(stderr, "--> %s\n", exec->argument(0).toString(exec).utf8().data()); 224 return JSValue::encode(jsUndefined());225 }226 227 EncodedJSValue JSC_HOST_CALL functionJSCStack(ExecState* exec)228 {229 String trace = "--> Stack trace:\n";230 Vector<StackFrame> stackTrace;231 Interpreter::getStackTrace(&exec->globalData(), -1, stackTrace);232 int i = 0;233 234 for (Vector<StackFrame>::iterator iter = stackTrace.begin(); iter < stackTrace.end(); iter++) {235 StackFrame level = *iter;236 trace += String::format(" %i %s\n", i, level.toString().utf8().data());237 i++;238 }239 fprintf(stderr, "%s", trace.utf8().data());240 221 return JSValue::encode(jsUndefined()); 241 222 } -
trunk/Source/JavaScriptCore/parser/Parser.h
r96131 r96146 115 115 *exception = createSyntaxError(lexicalGlobalObject, errMsg); 116 116 else 117 *exception = addErrorInfo(&lexicalGlobalObject->globalData(), createSyntaxError(lexicalGlobalObject, errMsg), errLine, source , Vector<StackFrame>());117 *exception = addErrorInfo(&lexicalGlobalObject->globalData(), createSyntaxError(lexicalGlobalObject, errMsg), errLine, source); 118 118 } 119 119 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r96131 r96146 53 53 macro(isArray) \ 54 54 macro(isPrototypeOf) \ 55 macro(jscStack) \56 55 macro(length) \ 57 56 macro(message) \ -
trunk/Source/JavaScriptCore/runtime/Error.cpp
r96131 r96146 27 27 #include "ConstructData.h" 28 28 #include "ErrorConstructor.h" 29 #include "JSArray.h"30 29 #include "JSFunction.h" 31 30 #include "JSGlobalObject.h" … … 118 117 } 119 118 120 JSObject* addErrorInfo(JSGlobalData* globalData, JSObject* error, int line, const SourceCode& source , const Vector<StackFrame>& stackTrace)119 JSObject* addErrorInfo(JSGlobalData* globalData, JSObject* error, int line, const SourceCode& source) 121 120 { 122 121 intptr_t sourceID = source.provider()->asID(); … … 129 128 if (!sourceURL.isNull()) 130 129 error->putWithAttributes(globalData, Identifier(globalData, sourceURLPropertyName), jsString(globalData, sourceURL), ReadOnly | DontDelete); 131 if (!stackTrace.isEmpty()) {132 JSArray* stackTraceArray = JSArray::create(*globalData, globalData->dynamicGlobalObject->arrayStructure());133 for (unsigned i = 0; i < stackTrace.size(); i++) {134 UString stackLevel = stackTrace[i].toString();135 stackTraceArray->push(globalData->topCallFrame, jsString(globalData, stackLevel));136 }137 error->putWithAttributes(globalData, globalData->propertyNames->jscStack, stackTraceArray, ReadOnly | DontDelete);138 }139 130 140 131 return error; 141 132 } 142 133 143 JSObject* addErrorInfo(ExecState* exec, JSObject* error, int line, const SourceCode& source , const Vector<StackFrame>& stackTrace)144 { 145 return addErrorInfo(&exec->globalData(), error, line, source , stackTrace);134 JSObject* addErrorInfo(ExecState* exec, JSObject* error, int line, const SourceCode& source) 135 { 136 return addErrorInfo(&exec->globalData(), error, line, source); 146 137 } 147 138 -
trunk/Source/JavaScriptCore/runtime/Error.h
r96131 r96146 24 24 #define Error_h 25 25 26 #include "Interpreter.h"27 26 #include "JSObject.h" 28 27 #include <stdint.h> … … 57 56 // Methods to add 58 57 bool hasErrorInfo(ExecState*, JSObject* error); 59 JSObject* addErrorInfo(JSGlobalData*, JSObject* error, int line, const SourceCode& , const Vector<StackFrame>&);58 JSObject* addErrorInfo(JSGlobalData*, JSObject* error, int line, const SourceCode&); 60 59 // ExecState wrappers. 61 JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode& , const Vector<StackFrame>&);60 JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&); 62 61 63 62 // Methods to throw Errors.
Note:
See TracChangeset
for help on using the changeset viewer.