Reviewers: Michael Starzinger,

Description:
Correctly load message from an Error object.

[email protected]
BUG=306220

Please review this at https://codereview.chromium.org/46593010/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+18, -21 lines):
  M src/messages.js
  A + test/mjsunit/regress/regress-crbug-306220.js


Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index 0a301228d748cfe2260b7b00d97df8bd3df9d74d..bfd42de0ad9101220cc4c2c8fa0ba62d92c771f9 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -1247,23 +1247,24 @@ var visited_errors = new InternalArray();
 var cyclic_error_marker = new $Object();

 function GetPropertyWithoutInvokingMonkeyGetters(error, name) {
+  var current = error;
   // Climb the prototype chain until we find the holder.
-  while (error && !%HasLocalProperty(error, name)) {
-    error = %GetPrototype(error);
+  while (current && !%HasLocalProperty(current, name)) {
+    current = %GetPrototype(current);
   }
-  if (IS_NULL(error)) return UNDEFINED;
-  if (!IS_OBJECT(error)) return error[name];
+  if (IS_NULL(current)) return UNDEFINED;
+  if (!IS_OBJECT(current)) return error[name];
// If the property is an accessor on one of the predefined errors that can be // generated statically by the compiler, don't touch it. This is to address
   // http://code.google.com/p/chromium/issues/detail?id=69187
-  var desc = %GetOwnProperty(error, name);
+  var desc = %GetOwnProperty(current, name);
   if (desc && desc[IS_ACCESSOR_INDEX]) {
     var isName = name === "name";
-    if (error === $ReferenceError.prototype)
+    if (current === $ReferenceError.prototype)
       return isName ? "ReferenceError" : UNDEFINED;
-    if (error === $SyntaxError.prototype)
+    if (current === $SyntaxError.prototype)
       return isName ? "SyntaxError" : UNDEFINED;
-    if (error === $TypeError.prototype)
+    if (current === $TypeError.prototype)
       return isName ? "TypeError" : UNDEFINED;
   }
   // Otherwise, read normally.
Index: test/mjsunit/regress/regress-crbug-306220.js
diff --git a/test/mjsunit/regress/regress-crbug-233737.js b/test/mjsunit/regress/regress-crbug-306220.js
similarity index 83%
copy from test/mjsunit/regress/regress-crbug-233737.js
copy to test/mjsunit/regress/regress-crbug-306220.js
index 835726b22429ec3cca68df956255d47c53fcfd25..a481ee9dba111ad7cbbd95fd4ca94a7d8cd2ea56 100644
--- a/test/mjsunit/regress/regress-crbug-233737.js
+++ b/test/mjsunit/regress/regress-crbug-306220.js
@@ -25,18 +25,14 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-// Flags: --allow-natives-syntax
+var CustomError = function(x) { this.x = x; };
+CustomError.prototype = new Error();
+CustomError.prototype.x = "prototype";

-var a = new Array(2);
-a[0] = 1;
-assertTrue(%HasFastSmiElements(a));
-assertTrue(%HasFastHoleyElements(a));
+Object.defineProperties(CustomError.prototype, {
+   'message': {
+      'get': function() { return this.x; }
+   }
+});

-function hole(i) {
-  return a[i] << 0;
-}
-
-assertEquals(1, hole(0));
-assertEquals(1, hole(0));
-%OptimizeFunctionOnNextCall(hole);
-assertEquals(0, hole(1));
\ No newline at end of file
+assertEquals("Error: instance", String(new CustomError("instance")));


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to