Changeset 153457 in webkit
- Timestamp:
- Jul 29, 2013 9:33:35 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r153437 r153457 1 2013-07-29 Chris Curtis <chris_curtis@apple.com> 2 3 Eager stack trace for error objects. 4 https://bugs.webkit.org/show_bug.cgi?id=118918 5 6 Reviewed by Geoffrey Garen. 7 8 Added tests to ensure that the stack property was present at creation for all 9 error Objects. This test will fail without this patch. 10 11 * fast/js/script-tests/stack-at-creation-for-error-objects.js: Added. 12 (checkStack): 13 * fast/js/stack-at-creation-for-error-objects-expected.txt: Added. 14 * fast/js/stack-at-creation-for-error-objects.html: Added. 15 16 * inspector/console/console-format-expected.txt: 17 * inspector/console/console-format.html: 18 This test was modified by removing the error object from being evaluated. Prior to this patch 19 error objects did not have the stack property, so the stack information was not being 20 displayed. The stack trace includes a file path specific to the machine that is running 21 the test. The results would have differed from one computer to the next. There 22 is not an easy way to capture the error object to treat it differently. By removing 23 the error object there is no need to add extra code to treat it differently. 24 Also there are other tests inside inspector/console that test the stack trace, 25 so the testing suite does not lose error testing by removing it. 26 27 The .stack property was added to the error objects at creation time. 28 * fast/js/exception-properties-expected.txt: 29 * fast/js/script-tests/exception-properties.js: 30 31 The column numbers are modified in the following test. When error objects are explicitly 32 invoked, the column number points to the beginning "(" instead of end ")". 33 Functionality between browsers do not match either. Firefox does not output column 34 numbers. Chrome points columns numbers to the beginning of the "new" call. 35 36 * fast/js/line-column-numbers-expected.txt: 37 * fast/js/stack-trace-expected.txt: 38 1 39 2013-07-29 Bem Jones-Bey <bjonesbe@adobe.com> 2 40 -
trunk/LayoutTests/fast/js/exception-properties-expected.txt
r114702 r153457 4 4 5 5 6 PASS enumerableProperties(error) is [ ]6 PASS enumerableProperties(error) is ["stack"] 7 7 PASS enumerableProperties(nativeError) is ["stack", "line", "sourceURL"] 8 8 PASS Object.getPrototypeOf(nativeError).name is "RangeError" -
trunk/LayoutTests/fast/js/line-column-numbers-expected.txt
r153073 r153457 142 142 143 143 --> Case 2 Stack Trace: 144 0 global code at line-column-numbers.js:7:3 2145 146 --> Case 3 Stack Trace: 147 0 global code at line-column-numbers.js:11:2 4148 149 --> Case 3 Stack Trace: 150 0 global code at line-column-numbers.js:11:8 8144 0 global code at line-column-numbers.js:7:30 145 146 --> Case 3 Stack Trace: 147 0 global code at line-column-numbers.js:11:22 148 149 --> Case 3 Stack Trace: 150 0 global code at line-column-numbers.js:11:86 151 151 152 152 --> Case 4 Stack Trace: 153 0 doThrow4b at line-column-numbers.js:16:4 5153 0 doThrow4b at line-column-numbers.js:16:43 154 154 1 global code at line-column-numbers.js:17:14 155 155 156 156 --> Case 5 Stack Trace: 157 0 innerFunc at line-column-numbers.js:24: 70157 0 innerFunc at line-column-numbers.js:24:68 158 158 1 doThrow5b at line-column-numbers.js:24:83 159 159 2 global code at line-column-numbers.js:24:135 160 160 161 161 --> Case 6 Stack Trace: 162 0 innerFunc at line-column-numbers.js:28: 70162 0 innerFunc at line-column-numbers.js:28:68 163 163 1 doThrow6b at line-column-numbers.js:28:83 164 164 2 global code at line-column-numbers.js:28:135 165 165 166 166 --> Case 7 Stack Trace: 167 0 at line-column-numbers.js:32:4 3167 0 at line-column-numbers.js:32:41 168 168 1 global code at line-column-numbers.js:32:47 169 169 170 170 --> Case 8 Stack Trace: 171 0 at line-column-numbers.js:36:4 7171 0 at line-column-numbers.js:36:45 172 172 1 global code at line-column-numbers.js:36:51 173 173 174 174 --> Case 9 Stack Trace: 175 0 at line-column-numbers.js:40:3 9175 0 at line-column-numbers.js:40:37 176 176 1 global code at line-column-numbers.js:40:43 177 177 178 178 --> Case 9 Stack Trace: 179 0 at line-column-numbers.js:40:12 4179 0 at line-column-numbers.js:40:122 180 180 1 global code at line-column-numbers.js:40:128 181 181 182 182 --> Case 10 Stack Trace: 183 0 at line-column-numbers.js:46:2 6183 0 at line-column-numbers.js:46:24 184 184 1 global code at line-column-numbers.js:47:8 185 185 186 186 --> Case 11 Stack Trace: 187 0 at line-column-numbers.js:56: 41187 0 at line-column-numbers.js:56:39 188 188 1 doThrow11b at line-column-numbers.js:56:45 189 189 2 global code at line-column-numbers.js:58:15 190 190 191 191 --> Case 12 Stack Trace: 192 0 at line-column-numbers.js:65:5 3192 0 at line-column-numbers.js:65:51 193 193 1 at line-column-numbers.js:65:57 194 194 2 global code at line-column-numbers.js:65:62 195 195 196 196 --> Case 13 Stack Trace: 197 0 at line-column-numbers.js:69:5 3197 0 at line-column-numbers.js:69:51 198 198 1 at line-column-numbers.js:69:57 199 199 2 global code at line-column-numbers.js:69:62 200 200 201 201 --> Case 14 Stack Trace: 202 0 at line-column-numbers.js:73:7 7202 0 at line-column-numbers.js:73:75 203 203 1 at line-column-numbers.js:73:81 204 204 2 doThrow14b at line-column-numbers.js:73:86 -
trunk/LayoutTests/fast/js/script-tests/exception-properties.js
r114702 r153457 16 16 var error = new Error("message"); 17 17 18 shouldBe('enumerableProperties(error)', '[ ]');18 shouldBe('enumerableProperties(error)', '["stack"]'); 19 19 shouldBe('enumerableProperties(nativeError)', '["stack", "line", "sourceURL"]'); 20 20 -
trunk/LayoutTests/fast/js/stack-trace-expected.txt
r152494 r153457 25 25 26 26 --> Stack Trace: 27 0 inner at stack-trace.js:28: 6927 0 inner at stack-trace.js:28:44 28 28 1 global code at stack-trace.js:43:23 29 29 30 30 --> Stack Trace: 31 0 inner at stack-trace.js:28: 6931 0 inner at stack-trace.js:28:44 32 32 1 outer at stack-trace.js:27:34 33 33 2 global code at stack-trace.js:44:23 … … 39 39 40 40 --> Stack Trace: 41 0 htmlInner at stack-trace.html:10: 5641 0 htmlInner at stack-trace.html:10:39 42 42 1 scripterInner at stack-trace.js:32:37 43 43 2 global code at stack-trace.js:49:20 44 44 45 45 --> Stack Trace: 46 0 htmlInner at stack-trace.html:10: 5646 0 htmlInner at stack-trace.html:10:39 47 47 1 htmlOuter at stack-trace.html:11:33 48 48 2 scripterOuter at stack-trace.js:33:37 -
trunk/LayoutTests/inspector/console/console-format-expected.txt
r143179 r153457 3 3 CONSOLE MESSAGE: line 22: %O 4 4 CONSOLE MESSAGE: line 23: Test for zero "%f" in formatter 5 CONSOLE MESSAGE: line 53: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i 5 6 CONSOLE MESSAGE: line 54: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i 6 CONSOLE MESSAGE: line 5 5: /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i7 CONSOLE MESSAGE: line 53: /foo\\bar\sbaz/i 7 8 CONSOLE MESSAGE: line 54: /foo\\bar\sbaz/i 8 CONSOLE MESSAGE: line 5 5: /foo\\bar\sbaz/i9 CONSOLE MESSAGE: line 53: test 9 10 CONSOLE MESSAGE: line 54: test 10 CONSOLE MESSAGE: line 5 5: test11 CONSOLE MESSAGE: line 53: test named "test" 11 12 CONSOLE MESSAGE: line 54: test named "test" 12 CONSOLE MESSAGE: line 55: test named "test" 13 CONSOLE MESSAGE: line 54: Error 14 CONSOLE MESSAGE: line 55: Error 13 CONSOLE MESSAGE: line 53: [object HTMLParagraphElement] 15 14 CONSOLE MESSAGE: line 54: [object HTMLParagraphElement] 16 CONSOLE MESSAGE: line 5 5: [object HTMLParagraphElement]15 CONSOLE MESSAGE: line 53: function () { return 1; } 17 16 CONSOLE MESSAGE: line 54: function () { return 1; } 18 CONSOLE MESSAGE: line 55: function () { return 1; } 17 CONSOLE MESSAGE: line 53: function () { 18 return 2; 19 } 19 20 CONSOLE MESSAGE: line 54: function () { 20 21 return 2; 21 22 } 22 CONSOLE MESSAGE: line 55: function () { 23 return 2; 24 } 23 CONSOLE MESSAGE: line 53: 0.12 25 24 CONSOLE MESSAGE: line 54: 0.12 26 CONSOLE MESSAGE: line 5 5: 0.1225 CONSOLE MESSAGE: line 53: http://webkit.org/ 27 26 CONSOLE MESSAGE: line 54: http://webkit.org/ 28 CONSOLE MESSAGE: line 5 5: http://webkit.org/29 CONSOLE MESSAGE: line 54: null30 CONSOLE MESSAGE: line 5 5:31 CONSOLE MESSAGE: line 54: undefined32 CONSOLE MESSAGE: line 5 5:27 CONSOLE MESSAGE: line 53: null 28 CONSOLE MESSAGE: line 54: 29 CONSOLE MESSAGE: line 53: undefined 30 CONSOLE MESSAGE: line 54: 31 CONSOLE MESSAGE: line 53: [object Attr] 33 32 CONSOLE MESSAGE: line 54: [object Attr] 34 CONSOLE MESSAGE: line 5 5: [object Attr]33 CONSOLE MESSAGE: line 53: [object Attr] 35 34 CONSOLE MESSAGE: line 54: [object Attr] 36 CONSOLE MESSAGE: line 5 5: [object Attr]35 CONSOLE MESSAGE: line 53: [object Attr] 37 36 CONSOLE MESSAGE: line 54: [object Attr] 38 CONSOLE MESSAGE: line 5 5: [object Attr]37 CONSOLE MESSAGE: line 53: [object Object] 39 38 CONSOLE MESSAGE: line 54: [object Object] 40 CONSOLE MESSAGE: line 5 5: [object Object]39 CONSOLE MESSAGE: line 53: NaN 41 40 CONSOLE MESSAGE: line 54: NaN 42 CONSOLE MESSAGE: line 5 5: NaN41 CONSOLE MESSAGE: line 53: Infinity 43 42 CONSOLE MESSAGE: line 54: Infinity 44 CONSOLE MESSAGE: line 5 5:Infinity43 CONSOLE MESSAGE: line 53: -Infinity 45 44 CONSOLE MESSAGE: line 54: -Infinity 46 CONSOLE MESSAGE: line 5 5: -Infinity45 CONSOLE MESSAGE: line 53: test,test2,,,test4,,,,, 47 46 CONSOLE MESSAGE: line 54: test,test2,,,test4,,,,, 48 CONSOLE MESSAGE: line 5 5: test,test2,,,test4,,,,,47 CONSOLE MESSAGE: line 53: [object Object] 49 48 CONSOLE MESSAGE: line 54: [object Object] 50 CONSOLE MESSAGE: line 5 5: [object Object]49 CONSOLE MESSAGE: line 53: function () {} 51 50 CONSOLE MESSAGE: line 54: function () {} 52 CONSOLE MESSAGE: line 5 5: function () {}51 CONSOLE MESSAGE: line 53: [object Object] 53 52 CONSOLE MESSAGE: line 54: [object Object] 54 CONSOLE MESSAGE: line 55: [object Object]55 53 Tests that console logging dumps proper messages. 56 54 … … 59 57 Array[10] console-format.html:22 60 58 Test for zero "0" in formatter console-format.html:23 61 /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i console-format.html:5 462 [/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\…?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i] console-format.html:5 559 /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i console-format.html:53 60 [/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\…?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i] console-format.html:54 63 61 globals[0] 64 62 /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i 65 /foo\\bar\sbaz/i console-format.html:5 466 [/foo\\bar\sbaz/i] console-format.html:5 563 /foo\\bar\sbaz/i console-format.html:53 64 [/foo\\bar\sbaz/i] console-format.html:54 67 65 globals[1] 68 66 /foo\\bar\sbaz/i 69 test console-format.html:5 470 ["test"] console-format.html:5 567 test console-format.html:53 68 ["test"] console-format.html:54 71 69 globals[2] 72 70 "test" 73 test named "test" console-format.html:5 474 ["test named "test""] console-format.html:5 571 test named "test" console-format.html:53 72 ["test named "test""] console-format.html:54 75 73 globals[3] 76 74 "test named "test"" 77 Error {} console-format.html:54 78 [ Error] console-format.html:5575 <p id="p">Tests that console logging dumps proper messages.</p> console-format.html:53 76 [p#p] console-format.html:54 79 77 globals[4] 80 Error {} 81 <p id="p">Tests that console logging dumps proper messages.</p> console-format.html:54 82 [ p#p] console-format.html:5578 <p id="p">Tests that console logging dumps proper messages.</p> 79 function () { return 1; } console-format.html:53 80 [function] console-format.html:54 83 81 globals[5] 84 <p id="p">Tests that console logging dumps proper messages.</p>85 function () { return 1; } console-format.html:5486 [function] console-format.html:5587 globals[6]88 82 function () { return 1; } 89 83 function () { 90 84 return 2; 91 } console-format.html:5 492 [function] console-format.html:5 593 globals[ 7]85 } console-format.html:53 86 [function] console-format.html:54 87 globals[6] 94 88 function () { 95 89 return 2; 96 90 } 97 0.12 console-format.html:54 98 [0.12] console-format.html:55 91 0.12 console-format.html:53 92 [0.12] console-format.html:54 93 globals[7] 94 0.12 95 http://webkit.org/ console-format.html:53 96 ["http://webkit.org/"] console-format.html:54 99 97 globals[8] 100 0.12 101 http://webkit.org/ console-format.html:54 102 [ "http://webkit.org/"] console-format.html:5598 "http://webkit.org/" 99 null console-format.html:53 100 [null] console-format.html:54 103 101 globals[9] 104 "http://webkit.org/" 105 null console-format.html:54 106 [ null] console-format.html:55102 null 103 undefined console-format.html:53 104 [undefined] console-format.html:54 107 105 globals[10] 108 null 109 undefined console-format.html:54 110 [ undefined] console-format.html:55106 undefined 107 attr="" console-format.html:53 108 [attr] console-format.html:54 111 109 globals[11] 112 undefined 113 attr=" " console-format.html:54114 [attr] console-format.html:5 5110 attr="" 111 attr="value""value" console-format.html:53 112 [attr] console-format.html:54 115 113 globals[12] 116 attr=" "117 attr="value""value" console-format.html:54 118 [ attr] console-format.html:55114 attr="value""value" 115 id="x""x" console-format.html:53 116 [id] console-format.html:54 119 117 globals[13] 120 attr="value""value"121 id="x""x" console-format.html:54 122 [ id] console-format.html:55118 id="x""x" 119 Object {} console-format.html:53 120 [Object] console-format.html:54 123 121 globals[14] 124 id="x""x" 125 Object {} console-format.html:54 126 [ Object] console-format.html:55122 Object {} 123 NaN console-format.html:53 124 [NaN] console-format.html:54 127 125 globals[15] 126 NaN 127 Infinity console-format.html:53 128 [Infinity] console-format.html:54 129 globals[16] 130 Infinity 131 -Infinity console-format.html:53 132 [-Infinity] console-format.html:54 133 globals[17] 134 -Infinity 135 ["test", "test2", 4: "test4", foo: Object] console-format.html:53 136 [Array[10]] console-format.html:54 137 globals[18] 138 ["test", "test2", undefined × 2, "test4", undefined × 5] 139 Object {} console-format.html:53 140 [Object] console-format.html:54 141 globals[19] 128 142 Object {} 129 NaN console-format.html:54 130 [NaN] console-format.html:55 131 globals[16] 132 NaN 133 Infinity console-format.html:54 134 [Infinity] console-format.html:55 135 globals[17] 136 Infinity 137 -Infinity console-format.html:54 138 [-Infinity] console-format.html:55 139 globals[18] 140 -Infinity 141 ["test", "test2", 4: "test4", foo: Object] console-format.html:54 142 [Array[10]] console-format.html:55 143 globals[19] 144 ["test", "test2", undefined × 2, "test4", undefined × 5] 145 Object {} console-format.html:54 146 [Object] console-format.html:55 143 [function] console-format.html:53 144 [Array[1]] console-format.html:54 147 145 globals[20] 148 Object {} 149 [function] console-format.html:54 150 [ Array[1]] console-format.html:55146 [function () {}] 147 Object {bar: "bar", foo: "foo"} console-format.html:53 148 [Object] console-format.html:54 151 149 globals[21] 152 [function () {}]153 Object {bar: "bar", foo: "foo"} console-format.html:54154 [Object] console-format.html:55155 globals[22]156 150 Object {bar: "bar", foo: "foo"} 157 151 -
trunk/LayoutTests/inspector/console/console-format.html
r143179 r153457 27 27 var str = "test"; 28 28 var str2 = "test named \"test\""; 29 var error = new Error;30 29 var node = document.getElementById("p"); 31 30 var func = function() { return 1; }; … … 42 41 43 42 globals = [ 44 regex1, regex2, str, str2, error,node, func, multilinefunc, num, linkify,43 regex1, regex2, str, str2, node, func, multilinefunc, num, linkify, 45 44 null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter, 46 45 NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar -
trunk/Source/JavaScriptCore/ChangeLog
r153454 r153457 1 2013-07-29 Chris Curtis <chris_curtis@apple.com> 2 3 Eager stack trace for error objects. 4 https://bugs.webkit.org/show_bug.cgi?id=118918 5 6 Reviewed by Geoffrey Garen. 7 8 Chrome and Firefox give error objects the stack property and we wanted to match 9 that functionality. This allows developers to see the stack without throwing an object. 10 11 * runtime/ErrorInstance.cpp: 12 (JSC::ErrorInstance::finishCreation): 13 For error objects that are not thrown as an exception, we pass the stackTrace in 14 as a parameter. This allows the error object to have the stack property. 15 16 * interpreter/Interpreter.cpp: 17 (JSC::stackTraceAsString): 18 Helper function used to eliminate duplicate code. 19 20 (JSC::Interpreter::addStackTraceIfNecessary): 21 When an error object is created by the user the vm->exceptionStack is not set. 22 If the user throws this error object later the stack that is in the error object 23 may not be the correct stack for the throw, so when we set the vm->exception stack, 24 the stack property on the error object is set as well. 25 26 * runtime/ErrorConstructor.cpp: 27 (JSC::constructWithErrorConstructor): 28 (JSC::callErrorConstructor): 29 * runtime/NativeErrorConstructor.cpp: 30 (JSC::constructWithNativeErrorConstructor): 31 (JSC::callNativeErrorConstructor): 32 These functions indicate that the user created an error object. For all error objects 33 that the user explicitly creates, the topCallFrame is at a new frame created to 34 handle the user's call. In this case though, the error object needs the caller's 35 frame to create the stack trace correctly. 36 37 * interpreter/Interpreter.h: 38 * runtime/ErrorInstance.h: 39 (JSC::ErrorInstance::create): 40 1 41 2013-07-29 Gavin Barraclough <barraclough@apple.com> 2 42 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r153221 r153457 558 558 } 559 559 } 560 560 JSString* Interpreter:: stackTraceAsString(ExecState* exec, Vector<StackFrame> stackTrace) 561 { 562 // FIXME: JSStringJoiner could be more efficient than StringBuilder here. 563 StringBuilder builder; 564 for (unsigned i = 0; i < stackTrace.size(); i++) { 565 builder.append(String(stackTrace[i].toString(exec))); 566 if (i != stackTrace.size() - 1) 567 builder.append('\n'); 568 } 569 return jsString(&exec->vm(), builder.toString()); 570 } 571 561 572 void Interpreter::addStackTraceIfNecessary(CallFrame* callFrame, JSValue error) 562 573 { … … 564 575 ASSERT(callFrame == vm->topCallFrame || callFrame == callFrame->lexicalGlobalObject()->globalExec() || callFrame == callFrame->dynamicGlobalObject()->globalExec()); 565 576 566 if ( error.isObject()) {567 if ( asObject(error)->hasProperty(callFrame, vm->propertyNames->stack))577 if (vm->exceptionStack().size()) { 578 if (!error.isObject() || asObject(error)->hasProperty(callFrame, vm->propertyNames->stack)) 568 579 return; 569 580 } … … 575 586 return; 576 587 577 JSObject* errorObject = asObject(error); 578 JSGlobalObject* globalObject = 0; 579 if (isTerminatedExecutionException(error)) 580 globalObject = vm->dynamicGlobalObject; 581 else 582 globalObject = errorObject->globalObject(); 583 584 // FIXME: JSStringJoiner could be more efficient than StringBuilder here. 585 StringBuilder builder; 586 for (unsigned i = 0; i < stackTrace.size(); i++) { 587 builder.append(String(stackTrace[i].toString(globalObject->globalExec()).impl())); 588 if (i != stackTrace.size() - 1) 589 builder.append('\n'); 590 } 591 592 errorObject->putDirect(*vm, vm->propertyNames->stack, jsString(vm, builder.toString()), ReadOnly | DontDelete); 588 // Note: 'error' might already have a stack property if it was created by the user (e.g. "new Error"). The stack 589 // now, as the error is thrown, might be different from the stack when it was created, so we overwrite it with 590 // the current stack unconditionally. 591 asObject(error)->putDirect(*vm, vm->propertyNames->stack, vm->interpreter->stackTraceAsString(vm->topCallFrame, stackTrace), ReadOnly | DontDelete); 592 593 593 } 594 594 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.h
r153383 r153457 221 221 NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine, int column); 222 222 static void addStackTraceIfNecessary(CallFrame*, JSValue error); 223 JSString* stackTraceAsString(ExecState*, Vector<StackFrame>); 223 224 224 225 void dumpSampleData(ExecState* exec); -
trunk/Source/JavaScriptCore/runtime/ErrorConstructor.cpp
r148696 r153457 23 23 24 24 #include "ErrorPrototype.h" 25 #include "Interpreter.h" 25 26 #include "JSGlobalObject.h" 26 27 #include "JSString.h" … … 52 53 JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined(); 53 54 Structure* errorStructure = asInternalFunction(exec->callee())->globalObject()->errorStructure(); 54 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message)); 55 Vector<StackFrame> stackTrace; 56 exec->vm().interpreter->getStackTrace(stackTrace, std::numeric_limits<size_t>::max()); 57 stackTrace.remove(0); 58 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, stackTrace)); 55 59 } 56 60 … … 65 69 JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined(); 66 70 Structure* errorStructure = asInternalFunction(exec->callee())->globalObject()->errorStructure(); 67 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message)); 71 Vector<StackFrame> stackTrace; 72 exec->vm().interpreter->getStackTrace(stackTrace, std::numeric_limits<size_t>::max()); 73 stackTrace.remove(0); 74 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, stackTrace)); 68 75 } 69 76 -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp
r148696 r153457 37 37 } 38 38 39 void ErrorInstance::finishCreation(VM& vm, const String& message, Vector<StackFrame> stackTrace) 40 { 41 Base::finishCreation(vm); 42 ASSERT(inherits(&s_info)); 43 if (!message.isNull()) 44 putDirect(vm, vm.propertyNames->message, jsString(&vm, message), DontEnum); 45 46 if (!stackTrace.isEmpty()) 47 putDirect(vm, vm.propertyNames->stack, vm.interpreter->stackTraceAsString(vm.topCallFrame, stackTrace), ReadOnly | DontDelete); 48 } 49 39 50 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.h
r148696 r153457 22 22 #define ErrorInstance_h 23 23 24 #include "Interpreter.h" 24 25 #include "JSObject.h" 26 #include "SourceProvider.h" 25 27 26 28 namespace JSC { … … 37 39 } 38 40 39 static ErrorInstance* create(VM& vm, Structure* structure, const String& message )41 static ErrorInstance* create(VM& vm, Structure* structure, const String& message, Vector<StackFrame> stackTrace = Vector<StackFrame>()) 40 42 { 41 43 ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure); 42 instance->finishCreation(vm, message );44 instance->finishCreation(vm, message, stackTrace); 43 45 return instance; 44 46 } 45 47 46 static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message )48 static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message, Vector<StackFrame> stackTrace = Vector<StackFrame>()) 47 49 { 48 return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec) );50 return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), stackTrace); 49 51 } 50 52 … … 56 58 explicit ErrorInstance(VM&, Structure*); 57 59 58 void finishCreation(VM& vm, const String& message) 59 { 60 Base::finishCreation(vm); 61 ASSERT(inherits(&s_info)); 62 if (!message.isNull()) 63 putDirect(vm, vm.propertyNames->message, jsString(&vm, message), DontEnum); 64 } 60 void finishCreation(VM&, const String&, Vector<StackFrame> = Vector<StackFrame>()); 65 61 66 62 bool m_appendSourceToMessage; -
trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
r139541 r153457 55 55 Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->callee())->errorStructure(); 56 56 ASSERT(errorStructure); 57 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message)); 57 Vector<StackFrame> stackTrace; 58 exec->vm().interpreter->getStackTrace(stackTrace, std::numeric_limits<size_t>::max()); 59 stackTrace.remove(0); 60 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, stackTrace)); 58 61 } 59 62 … … 68 71 JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined(); 69 72 Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->callee())->errorStructure(); 70 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message)); 73 Vector<StackFrame> stackTrace; 74 exec->vm().interpreter->getStackTrace(stackTrace, std::numeric_limits<size_t>::max()); 75 stackTrace.remove(0); 76 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, stackTrace)); 71 77 } 72 78
Note: See TracChangeset
for help on using the changeset viewer.