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

Unified Diff: src/messages.js

Issue 258933007: Error stack getter should not overwrite itself with a data property. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | « no previous file | test/mjsunit/regress/regress-3294.js » ('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 d402731f7fa569302475bd7db3fdedc442bdca38..3f7a25f7651ebd6cee48e64d9c8b5d833f195a1c 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -1157,19 +1157,6 @@ function captureStackTrace(obj, cons_opt) {
stackTraceLimit);
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
- // format a stack trace string and turn this accessor pair into a data
- // 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));
- // Turn this accessor into a data property.
- %DefineOrRedefineDataProperty(obj, 'stack', result, NONE);
- // Release context values.
- stack = error_string = UNDEFINED;
- return result;
- };
// Set the 'stack' property on the receiver. If the receiver is the same as
// holder of this setter, the accessor pair is turned into a data property.
@@ -1182,6 +1169,21 @@ function captureStackTrace(obj, cons_opt) {
}
};
+ // 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
+ // format a stack trace string and turn this accessor pair into a data
+ // property (on the holder).
ulan 2014/04/28 12:01:26 The comment is outdated now.
+ var getter = function() {
+ // Stack is still a raw array awaiting to be formatted.
+ var result = FormatStackTrace(obj, error_string, GetStackFrames(stack));
+ // Replace this accessor to return result directly.
+ %DefineOrRedefineAccessorProperty(
+ obj, 'stack', function() { return result }, setter, DONT_ENUM);
+ // Release context values.
+ stack = error_string = UNDEFINED;
+ return result;
+ };
+
%DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM);
}
@@ -1320,6 +1322,15 @@ function SetUpStackOverflowBoilerplate() {
var error_string = boilerplate.name + ": " + boilerplate.message;
+ // Set the 'stack' property on the receiver. If the receiver is the same as
+ // holder of this setter, the accessor pair is turned into a data property.
+ var setter = function(v) {
+ %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
+ // Tentatively clear the hidden property. If the receiver is the same as
+ // holder, we release the raw stack trace this way.
+ %GetAndClearOverflowedStackTrace(this);
+ };
+
// The raw stack trace is stored as a hidden property on the holder of this
// getter, which may not be the same as the receiver. Find the holder to
// retrieve the raw stack trace and then turn this accessor pair into a
@@ -1335,20 +1346,12 @@ function SetUpStackOverflowBoilerplate() {
if (IS_UNDEFINED(stack)) return stack;
var result = FormatStackTrace(holder, error_string, GetStackFrames(stack));
- // Replace this accessor with a data property.
- %DefineOrRedefineDataProperty(holder, 'stack', result, NONE);
+ // Replace this accessor to return result directly.
+ %DefineOrRedefineAccessorProperty(
+ holder, 'stack', function() { return result }, setter, DONT_ENUM);
return result;
};
- // Set the 'stack' property on the receiver. If the receiver is the same as
- // holder of this setter, the accessor pair is turned into a data property.
- var setter = function(v) {
- %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
- // Tentatively clear the hidden property. If the receiver is the same as
- // holder, we release the raw stack trace this way.
- %GetAndClearOverflowedStackTrace(this);
- };
-
%DefineOrRedefineAccessorProperty(
boilerplate, 'stack', getter, setter, DONT_ENUM);
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-3294.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698