Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(686)

Unified Diff: src/messages.js

Issue 21173004: Version 3.20.11.1 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mark-compact.cc ('k') | src/mips/assembler-mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index 92ac1bc46aac4a8e525b34accca62980848b6e92..8b647dd20584fcd761f65b04f636738a53e557ba 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -1078,26 +1078,7 @@ function GetStackFrames(raw_stack) {
}
-// Flag to prevent recursive call of Error.prepareStackTrace.
-var formatting_custom_stack_trace = false;
-
-
-function FormatStackTrace(obj, error_string, frames) {
- if (IS_FUNCTION($Error.prepareStackTrace) && !formatting_custom_stack_trace) {
- var array = [];
- %MoveArrayContents(frames, array);
- formatting_custom_stack_trace = true;
- var stack_trace = void 0;
- try {
- stack_trace = $Error.prepareStackTrace(obj, array);
- } catch (e) {
- throw e; // The custom formatting function threw. Rethrow.
- } finally {
- formatting_custom_stack_trace = false;
- }
- return stack_trace;
- }
-
+function FormatStackTrace(error_string, frames) {
var lines = new InternalArray();
lines.push(error_string);
for (var i = 0; i < frames.length; i++) {
@@ -1134,6 +1115,10 @@ function GetTypeName(receiver, requireConstructor) {
}
+// Flag to prevent recursive call of Error.prepareStackTrace.
+var formatting_custom_stack_trace = false;
+
+
function captureStackTrace(obj, cons_opt) {
var stackTraceLimit = $Error.stackTraceLimit;
if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return;
@@ -1144,6 +1129,21 @@ function captureStackTrace(obj, cons_opt) {
cons_opt ? cons_opt : captureStackTrace,
stackTraceLimit);
+ // Don't be lazy if the error stack formatting is custom (observable).
+ if (IS_FUNCTION($Error.prepareStackTrace) && !formatting_custom_stack_trace) {
+ var array = [];
+ %MoveArrayContents(GetStackFrames(stack), array);
+ formatting_custom_stack_trace = true;
+ try {
+ obj.stack = $Error.prepareStackTrace(obj, array);
+ } catch (e) {
+ throw e; // The custom formatting function threw. Rethrow.
+ } finally {
+ formatting_custom_stack_trace = false;
+ }
+ return;
+ }
+
var error_string = FormatErrorString(obj);
// The holder of this getter ('obj') may not be the receiver ('this').
// When this getter is called the first time, we use the context values to
@@ -1151,7 +1151,7 @@ function captureStackTrace(obj, cons_opt) {
// property (on the holder).
var getter = function() {
// Stack is still a raw array awaiting to be formatted.
- var result = FormatStackTrace(obj, error_string, GetStackFrames(stack));
+ var result = FormatStackTrace(error_string, GetStackFrames(stack));
// Turn this accessor into a data property.
%DefineOrRedefineDataProperty(obj, 'stack', result, NONE);
// Release context values.
@@ -1321,7 +1321,7 @@ function SetUpStackOverflowBoilerplate() {
// We may not have captured any stack trace.
if (IS_UNDEFINED(stack)) return stack;
- var result = FormatStackTrace(holder, error_string, GetStackFrames(stack));
+ var result = FormatStackTrace(error_string, GetStackFrames(stack));
// Replace this accessor with a data property.
%DefineOrRedefineDataProperty(holder, 'stack', result, NONE);
return result;
« no previous file with comments | « src/mark-compact.cc ('k') | src/mips/assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698