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

Unified Diff: src/objects.cc

Issue 355123006: Make freeze & friends ignore private properties (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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/cctest/test-types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 785bd4ce4f579d7b04d43fda5e97360d4233dcdc..7db464e8c901207c569be2ef6daf8929f924371b 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5679,7 +5679,8 @@ static void FreezeDictionary(Dictionary* dictionary) {
int capacity = dictionary->Capacity();
for (int i = 0; i < capacity; i++) {
Object* k = dictionary->KeyAt(i);
- if (dictionary->IsKey(k)) {
+ if (dictionary->IsKey(k) &&
+ !(k->IsSymbol() && Symbol::cast(k)->is_private())) {
PropertyDetails details = dictionary->DetailsAt(i);
int attrs = DONT_DELETE;
// READ_ONLY is an invalid attribute for JS setters/getters.
@@ -7453,17 +7454,20 @@ Handle<DescriptorArray> DescriptorArray::CopyUpToAddAttributes(
if (attributes != NONE) {
for (int i = 0; i < size; ++i) {
Object* value = desc->GetValue(i);
+ Name* key = desc->GetKey(i);
PropertyDetails details = desc->GetDetails(i);
- int mask = DONT_DELETE | DONT_ENUM;
- // READ_ONLY is an invalid attribute for JS setters/getters.
- if (details.type() != CALLBACKS || !value->IsAccessorPair()) {
- mask |= READ_ONLY;
+ // Bulk attribute changes never affect private properties.
+ if (!key->IsSymbol() || !Symbol::cast(key)->is_private()) {
+ int mask = DONT_DELETE | DONT_ENUM;
+ // READ_ONLY is an invalid attribute for JS setters/getters.
+ if (details.type() != CALLBACKS || !value->IsAccessorPair()) {
+ mask |= READ_ONLY;
+ }
+ details = details.CopyAddAttributes(
+ static_cast<PropertyAttributes>(attributes & mask));
}
- details = details.CopyAddAttributes(
- static_cast<PropertyAttributes>(attributes & mask));
- Descriptor inner_desc(handle(desc->GetKey(i)),
- handle(value, desc->GetIsolate()),
- details);
+ Descriptor inner_desc(
+ handle(key), handle(value, desc->GetIsolate()), details);
descriptors->Set(i, &inner_desc, witness);
}
} else {
« no previous file with comments | « no previous file | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698