Revision: 13228
Author:   [email protected]
Date:     Mon Dec 17 06:00:50 2012
Log:      Make sure error message formatting does not have side effects.

[email protected]
BUG=

Review URL: https://chromiumcodereview.appspot.com/11598011
http://code.google.com/p/v8/source/detail?r=13228

Modified:
 /branches/bleeding_edge/src/messages.js
 /branches/bleeding_edge/test/mjsunit/error-tostring.js

=======================================
--- /branches/bleeding_edge/src/messages.js     Tue Dec 11 06:55:23 2012
+++ /branches/bleeding_edge/src/messages.js     Mon Dec 17 06:00:50 2012
@@ -192,7 +192,7 @@
   if (IS_NULL(obj)) return 'null';
   if (IS_FUNCTION(obj)) return  %_CallFunction(obj, FunctionToString);
if (IS_OBJECT(obj) && %GetDataProperty(obj, "toString") === ObjectToString) {
-    var constructor = obj.constructor;
+    var constructor = %GetDataProperty(obj, "constructor");
     if (typeof constructor == "function") {
       var constructorName = constructor.name;
       if (IS_STRING(constructorName) && constructorName !== "") {
=======================================
--- /branches/bleeding_edge/test/mjsunit/error-tostring.js Wed Oct 26 03:41:52 2011 +++ /branches/bleeding_edge/test/mjsunit/error-tostring.js Mon Dec 17 06:00:50 2012
@@ -83,3 +83,11 @@
 assertEquals(["null: e2",[1,2,3,4]], testErrorToString(null, "e2"));
 assertEquals(["e2",[1,2,3,4]], testErrorToString("", "e2"));
 assertEquals(["e1: e2",[1,2,3,4]], testErrorToString("e1", "e2"));
+
+var obj = {
+  get constructor () {
+    assertUnreachable();
+  }
+};
+
+assertThrows(function() { obj.x(); });

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to