| 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/objects.h" | 5 #include "src/objects.h" | 
| 6 | 6 | 
| 7 #include <cmath> | 7 #include <cmath> | 
| 8 #include <iomanip> | 8 #include <iomanip> | 
| 9 #include <sstream> | 9 #include <sstream> | 
| 10 | 10 | 
| (...skipping 6153 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6164 | 6164 | 
| 6165   return OrdinaryDefineOwnProperty(&it, desc, should_throw); | 6165   return OrdinaryDefineOwnProperty(&it, desc, should_throw); | 
| 6166 } | 6166 } | 
| 6167 | 6167 | 
| 6168 | 6168 | 
| 6169 // ES6 9.1.6.1 | 6169 // ES6 9.1.6.1 | 
| 6170 // static | 6170 // static | 
| 6171 bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it, | 6171 bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it, | 
| 6172                                            PropertyDescriptor* desc, | 6172                                            PropertyDescriptor* desc, | 
| 6173                                            ShouldThrow should_throw) { | 6173                                            ShouldThrow should_throw) { | 
|  | 6174   Isolate* isolate = it->isolate(); | 
| 6174   // 1. Let current be O.[[GetOwnProperty]](P). | 6175   // 1. Let current be O.[[GetOwnProperty]](P). | 
| 6175   // 2. ReturnIfAbrupt(current). | 6176   // 2. ReturnIfAbrupt(current). | 
| 6176   PropertyDescriptor current; | 6177   PropertyDescriptor current; | 
| 6177   if (!GetOwnPropertyDescriptor(it, ¤t) && | 6178   if (!GetOwnPropertyDescriptor(it, ¤t) && | 
| 6178       it->isolate()->has_pending_exception()) { | 6179       isolate->has_pending_exception()) { | 
| 6179     return false; | 6180     return false; | 
| 6180   } | 6181   } | 
| 6181   // TODO(jkummerow/verwaest): It would be nice if we didn't have to reset | 6182   // TODO(jkummerow/verwaest): It would be nice if we didn't have to reset | 
| 6182   // the iterator every time. Currently, the reasons why we need it are: | 6183   // the iterator every time. Currently, the reasons why we need it are: | 
| 6183   // - handle interceptors correctly | 6184   // - handle interceptors correctly | 
| 6184   // - handle accessors correctly (which might change the holder's map) | 6185   // - handle accessors correctly (which might change the holder's map) | 
| 6185   it->Restart(); | 6186   it->Restart(); | 
| 6186   // 3. Let extensible be the value of the [[Extensible]] internal slot of O. | 6187   // 3. Let extensible be the value of the [[Extensible]] internal slot of O. | 
| 6187   Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); | 6188   Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); | 
| 6188   bool extensible = JSObject::IsExtensible(object); | 6189   bool extensible = JSObject::IsExtensible(object); | 
| 6189 | 6190 | 
| 6190   return ValidateAndApplyPropertyDescriptor(it, extensible, desc, ¤t, | 6191   return ValidateAndApplyPropertyDescriptor(isolate, it, extensible, desc, | 
| 6191                                             should_throw); | 6192                                             ¤t, should_throw); | 
| 6192 } | 6193 } | 
| 6193 | 6194 | 
| 6194 | 6195 | 
| 6195 // ES6 9.1.6.2 | 6196 // ES6 9.1.6.2 | 
| 6196 // static | 6197 // static | 
| 6197 bool JSReceiver::IsCompatiblePropertyDescriptor(bool extensible, | 6198 bool JSReceiver::IsCompatiblePropertyDescriptor(Isolate* isolate, | 
|  | 6199                                                 bool extensible, | 
| 6198                                                 PropertyDescriptor* desc, | 6200                                                 PropertyDescriptor* desc, | 
| 6199                                                 PropertyDescriptor* current, | 6201                                                 PropertyDescriptor* current, | 
| 6200                                                 Handle<Name> property_name) { | 6202                                                 Handle<Name> property_name) { | 
| 6201   // 1. Return ValidateAndApplyPropertyDescriptor(undefined, undefined, | 6203   // 1. Return ValidateAndApplyPropertyDescriptor(undefined, undefined, | 
| 6202   //    Extensible, Desc, Current). | 6204   //    Extensible, Desc, Current). | 
| 6203   return ValidateAndApplyPropertyDescriptor(NULL, extensible, desc, current, | 6205   return ValidateAndApplyPropertyDescriptor( | 
| 6204                                             THROW_ON_ERROR, property_name); | 6206       isolate, NULL, extensible, desc, current, THROW_ON_ERROR, property_name); | 
| 6205 } | 6207 } | 
| 6206 | 6208 | 
| 6207 | 6209 | 
| 6208 // ES6 9.1.6.3 | 6210 // ES6 9.1.6.3 | 
| 6209 // static | 6211 // static | 
| 6210 bool JSReceiver::ValidateAndApplyPropertyDescriptor( | 6212 bool JSReceiver::ValidateAndApplyPropertyDescriptor( | 
| 6211     LookupIterator* it, bool extensible, PropertyDescriptor* desc, | 6213     Isolate* isolate, LookupIterator* it, bool extensible, | 
| 6212     PropertyDescriptor* current, ShouldThrow should_throw, | 6214     PropertyDescriptor* desc, PropertyDescriptor* current, | 
| 6213     Handle<Name> property_name) { | 6215     ShouldThrow should_throw, Handle<Name> property_name) { | 
| 6214   // We either need a LookupIterator, or a property name. | 6216   // We either need a LookupIterator, or a property name. | 
| 6215   DCHECK((it == NULL) != property_name.is_null()); | 6217   DCHECK((it == NULL) != property_name.is_null()); | 
| 6216   Handle<JSObject> object; | 6218   Handle<JSObject> object; | 
| 6217   if (it != NULL) object = Handle<JSObject>::cast(it->GetReceiver()); | 6219   if (it != NULL) object = Handle<JSObject>::cast(it->GetReceiver()); | 
| 6218   Isolate* isolate = it->isolate(); |  | 
| 6219   bool desc_is_data_descriptor = PropertyDescriptor::IsDataDescriptor(desc); | 6220   bool desc_is_data_descriptor = PropertyDescriptor::IsDataDescriptor(desc); | 
| 6220   bool desc_is_accessor_descriptor = | 6221   bool desc_is_accessor_descriptor = | 
| 6221       PropertyDescriptor::IsAccessorDescriptor(desc); | 6222       PropertyDescriptor::IsAccessorDescriptor(desc); | 
| 6222   bool desc_is_generic_descriptor = | 6223   bool desc_is_generic_descriptor = | 
| 6223       PropertyDescriptor::IsGenericDescriptor(desc); | 6224       PropertyDescriptor::IsGenericDescriptor(desc); | 
| 6224   // 1. (Assert) | 6225   // 1. (Assert) | 
| 6225   // 2. If current is undefined, then | 6226   // 2. If current is undefined, then | 
| 6226   if (current->is_empty()) { | 6227   if (current->is_empty()) { | 
| 6227     // 2a. If extensible is false, return false. | 6228     // 2a. If extensible is false, return false. | 
| 6228     if (!extensible) { | 6229     if (!extensible) { | 
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6861   // 13. Let resultDesc be ? ToPropertyDescriptor(trapResultObj). | 6862   // 13. Let resultDesc be ? ToPropertyDescriptor(trapResultObj). | 
| 6862   if (!PropertyDescriptor::ToPropertyDescriptor(isolate, trap_result_obj, | 6863   if (!PropertyDescriptor::ToPropertyDescriptor(isolate, trap_result_obj, | 
| 6863                                                 desc)) { | 6864                                                 desc)) { | 
| 6864     DCHECK(isolate->has_pending_exception()); | 6865     DCHECK(isolate->has_pending_exception()); | 
| 6865     return false; | 6866     return false; | 
| 6866   } | 6867   } | 
| 6867   // 14. Call CompletePropertyDescriptor(resultDesc). | 6868   // 14. Call CompletePropertyDescriptor(resultDesc). | 
| 6868   PropertyDescriptor::CompletePropertyDescriptor(isolate, desc); | 6869   PropertyDescriptor::CompletePropertyDescriptor(isolate, desc); | 
| 6869   // 15. Let valid be IsCompatiblePropertyDescriptor (extensibleTarget, | 6870   // 15. Let valid be IsCompatiblePropertyDescriptor (extensibleTarget, | 
| 6870   //     resultDesc, targetDesc). | 6871   //     resultDesc, targetDesc). | 
| 6871   bool valid = IsCompatiblePropertyDescriptor(extensible_target, desc, | 6872   bool valid = IsCompatiblePropertyDescriptor(isolate, extensible_target, desc, | 
| 6872                                               &target_desc, property_name); | 6873                                               &target_desc, property_name); | 
| 6873   // 16. If valid is false, throw a TypeError exception. | 6874   // 16. If valid is false, throw a TypeError exception. | 
| 6874   if (!valid) { | 6875   if (!valid) { | 
| 6875     DCHECK(isolate->has_pending_exception()); | 6876     DCHECK(isolate->has_pending_exception()); | 
| 6876     return false; | 6877     return false; | 
| 6877   } | 6878   } | 
| 6878   // 17. If resultDesc.[[Configurable]] is false, then | 6879   // 17. If resultDesc.[[Configurable]] is false, then | 
| 6879   if (!desc->configurable()) { | 6880   if (!desc->configurable()) { | 
| 6880     // 17a. If targetDesc is undefined or targetDesc.[[Configurable]] is true: | 6881     // 17a. If targetDesc is undefined or targetDesc.[[Configurable]] is true: | 
| 6881     if (target_desc.is_empty() || target_desc.configurable()) { | 6882     if (target_desc.is_empty() || target_desc.configurable()) { | 
| (...skipping 11227 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 18109   if (cell->value() != *new_value) { | 18110   if (cell->value() != *new_value) { | 
| 18110     cell->set_value(*new_value); | 18111     cell->set_value(*new_value); | 
| 18111     Isolate* isolate = cell->GetIsolate(); | 18112     Isolate* isolate = cell->GetIsolate(); | 
| 18112     cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18113     cell->dependent_code()->DeoptimizeDependentCodeGroup( | 
| 18113         isolate, DependentCode::kPropertyCellChangedGroup); | 18114         isolate, DependentCode::kPropertyCellChangedGroup); | 
| 18114   } | 18115   } | 
| 18115 } | 18116 } | 
| 18116 | 18117 | 
| 18117 }  // namespace internal | 18118 }  // namespace internal | 
| 18118 }  // namespace v8 | 18119 }  // namespace v8 | 
| OLD | NEW | 
|---|