| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 5661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5672 } | 5672 } |
| 5673 return object; | 5673 return object; |
| 5674 } | 5674 } |
| 5675 | 5675 |
| 5676 | 5676 |
| 5677 template<typename Dictionary> | 5677 template<typename Dictionary> |
| 5678 static void FreezeDictionary(Dictionary* dictionary) { | 5678 static void FreezeDictionary(Dictionary* dictionary) { |
| 5679 int capacity = dictionary->Capacity(); | 5679 int capacity = dictionary->Capacity(); |
| 5680 for (int i = 0; i < capacity; i++) { | 5680 for (int i = 0; i < capacity; i++) { |
| 5681 Object* k = dictionary->KeyAt(i); | 5681 Object* k = dictionary->KeyAt(i); |
| 5682 if (dictionary->IsKey(k)) { | 5682 if (dictionary->IsKey(k) && |
| 5683 !(k->IsSymbol() && Symbol::cast(k)->is_private())) { |
| 5683 PropertyDetails details = dictionary->DetailsAt(i); | 5684 PropertyDetails details = dictionary->DetailsAt(i); |
| 5684 int attrs = DONT_DELETE; | 5685 int attrs = DONT_DELETE; |
| 5685 // READ_ONLY is an invalid attribute for JS setters/getters. | 5686 // READ_ONLY is an invalid attribute for JS setters/getters. |
| 5686 if (details.type() == CALLBACKS) { | 5687 if (details.type() == CALLBACKS) { |
| 5687 Object* v = dictionary->ValueAt(i); | 5688 Object* v = dictionary->ValueAt(i); |
| 5688 if (v->IsPropertyCell()) v = PropertyCell::cast(v)->value(); | 5689 if (v->IsPropertyCell()) v = PropertyCell::cast(v)->value(); |
| 5689 if (!v->IsAccessorPair()) attrs |= READ_ONLY; | 5690 if (!v->IsAccessorPair()) attrs |= READ_ONLY; |
| 5690 } else { | 5691 } else { |
| 5691 attrs |= READ_ONLY; | 5692 attrs |= READ_ONLY; |
| 5692 } | 5693 } |
| (...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7446 | 7447 |
| 7447 int size = enumeration_index; | 7448 int size = enumeration_index; |
| 7448 | 7449 |
| 7449 Handle<DescriptorArray> descriptors = | 7450 Handle<DescriptorArray> descriptors = |
| 7450 DescriptorArray::Allocate(desc->GetIsolate(), size, slack); | 7451 DescriptorArray::Allocate(desc->GetIsolate(), size, slack); |
| 7451 DescriptorArray::WhitenessWitness witness(*descriptors); | 7452 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 7452 | 7453 |
| 7453 if (attributes != NONE) { | 7454 if (attributes != NONE) { |
| 7454 for (int i = 0; i < size; ++i) { | 7455 for (int i = 0; i < size; ++i) { |
| 7455 Object* value = desc->GetValue(i); | 7456 Object* value = desc->GetValue(i); |
| 7457 Name* key = desc->GetKey(i); |
| 7456 PropertyDetails details = desc->GetDetails(i); | 7458 PropertyDetails details = desc->GetDetails(i); |
| 7457 int mask = DONT_DELETE | DONT_ENUM; | 7459 // Bulk attribute changes never affect private properties. |
| 7458 // READ_ONLY is an invalid attribute for JS setters/getters. | 7460 if (!key->IsSymbol() || !Symbol::cast(key)->is_private()) { |
| 7459 if (details.type() != CALLBACKS || !value->IsAccessorPair()) { | 7461 int mask = DONT_DELETE | DONT_ENUM; |
| 7460 mask |= READ_ONLY; | 7462 // READ_ONLY is an invalid attribute for JS setters/getters. |
| 7463 if (details.type() != CALLBACKS || !value->IsAccessorPair()) { |
| 7464 mask |= READ_ONLY; |
| 7465 } |
| 7466 details = details.CopyAddAttributes( |
| 7467 static_cast<PropertyAttributes>(attributes & mask)); |
| 7461 } | 7468 } |
| 7462 details = details.CopyAddAttributes( | 7469 Descriptor inner_desc( |
| 7463 static_cast<PropertyAttributes>(attributes & mask)); | 7470 handle(key), handle(value, desc->GetIsolate()), details); |
| 7464 Descriptor inner_desc(handle(desc->GetKey(i)), | |
| 7465 handle(value, desc->GetIsolate()), | |
| 7466 details); | |
| 7467 descriptors->Set(i, &inner_desc, witness); | 7471 descriptors->Set(i, &inner_desc, witness); |
| 7468 } | 7472 } |
| 7469 } else { | 7473 } else { |
| 7470 for (int i = 0; i < size; ++i) { | 7474 for (int i = 0; i < size; ++i) { |
| 7471 descriptors->CopyFrom(i, *desc, witness); | 7475 descriptors->CopyFrom(i, *desc, witness); |
| 7472 } | 7476 } |
| 7473 } | 7477 } |
| 7474 | 7478 |
| 7475 if (desc->number_of_descriptors() != enumeration_index) descriptors->Sort(); | 7479 if (desc->number_of_descriptors() != enumeration_index) descriptors->Sort(); |
| 7476 | 7480 |
| (...skipping 9495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16972 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16976 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16973 static const char* error_messages_[] = { | 16977 static const char* error_messages_[] = { |
| 16974 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16978 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16975 }; | 16979 }; |
| 16976 #undef ERROR_MESSAGES_TEXTS | 16980 #undef ERROR_MESSAGES_TEXTS |
| 16977 return error_messages_[reason]; | 16981 return error_messages_[reason]; |
| 16978 } | 16982 } |
| 16979 | 16983 |
| 16980 | 16984 |
| 16981 } } // namespace v8::internal | 16985 } } // namespace v8::internal |
| OLD | NEW |