Reviewers: Toon Verwaest,

Description:
When freezing global object, go through the property cell

[email protected]
BUG=

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

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

Affected files (+8, -3 lines):
  M src/objects.cc
  A + test/mjsunit/regress/regress-global-freeze-const.js


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 9cda2baf0d44476c6aeef51b8deb600a5fe35395..a544c8686563fd84109f18eec414bc215f78d138 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5507,8 +5507,11 @@ static void FreezeDictionary(Dictionary* dictionary) {
       PropertyDetails details = dictionary->DetailsAt(i);
       int attrs = DONT_DELETE;
       // READ_ONLY is an invalid attribute for JS setters/getters.
-      if (details.type() != CALLBACKS ||
-          !dictionary->ValueAt(i)->IsAccessorPair()) {
+      if (details.type() == CALLBACKS) {
+        Object* v = dictionary->ValueAt(i);
+        if (v->IsPropertyCell()) v = PropertyCell::cast(v)->value();
+        if (!v->IsAccessorPair()) attrs |= READ_ONLY;
+      } else {
         attrs |= READ_ONLY;
       }
       details = details.CopyAddAttributes(
Index: test/mjsunit/regress/regress-global-freeze-const.js
diff --git a/test/mjsunit/regress/regress-355485.js b/test/mjsunit/regress/regress-global-freeze-const.js
similarity index 67%
copy from test/mjsunit/regress/regress-355485.js
copy to test/mjsunit/regress/regress-global-freeze-const.js
index 3c66884c000dd5860b2bd9c82705f7a58afb28ae..0b9e1f3ebd4bb79c00db30a7b33e450e5bfe68a0 100644
--- a/test/mjsunit/regress/regress-355485.js
+++ b/test/mjsunit/regress/regress-global-freeze-const.js
@@ -2,4 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-assertEquals("\u039c", "\u00b5".toUpperCase());
+__defineSetter__('x', function() { });
+Object.freeze(this);
+eval('const x = 1');


--
--
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/d/optout.

Reply via email to