OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 4991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5002 | 5002 |
5003 LookupResult lookup(isolate); | 5003 LookupResult lookup(isolate); |
5004 js_object->LookupOwnRealNamedProperty(name, &lookup); | 5004 js_object->LookupOwnRealNamedProperty(name, &lookup); |
5005 | 5005 |
5006 // Take special care when attributes are different and there is already | 5006 // Take special care when attributes are different and there is already |
5007 // a property. For simplicity we normalize the property which enables us | 5007 // a property. For simplicity we normalize the property which enables us |
5008 // to not worry about changing the instance_descriptor and creating a new | 5008 // to not worry about changing the instance_descriptor and creating a new |
5009 // map. | 5009 // map. |
5010 if (lookup.IsFound() && | 5010 if (lookup.IsFound() && |
5011 (attr != lookup.GetAttributes() || lookup.IsPropertyCallbacks())) { | 5011 (attr != lookup.GetAttributes() || lookup.IsPropertyCallbacks())) { |
5012 // New attributes - normalize to avoid writing to instance descriptor | |
5013 if (js_object->IsJSGlobalProxy()) { | |
5014 // Since the result is a property, the prototype will exist so | |
5015 // we don't have to check for null. | |
5016 PrototypeIterator iter(isolate, js_object); | |
5017 js_object = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | |
5018 } | |
5019 | |
5020 if (attr != lookup.GetAttributes() || | |
5021 (lookup.IsPropertyCallbacks() && | |
5022 !lookup.GetCallbackObject()->IsAccessorInfo())) { | |
5023 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | |
5024 } | |
5025 | |
5026 // Use IgnoreAttributes version since a readonly property may be | 5012 // Use IgnoreAttributes version since a readonly property may be |
5027 // overridden and SetProperty does not allow this. | 5013 // overridden and SetProperty does not allow this. |
5028 Handle<Object> result; | 5014 Handle<Object> result; |
5029 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5015 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5030 isolate, result, | 5016 isolate, result, |
5031 JSObject::SetOwnPropertyIgnoreAttributes( | 5017 JSObject::SetOwnPropertyIgnoreAttributes( |
5032 js_object, name, obj_value, attr, | 5018 js_object, name, obj_value, attr, |
5033 JSReceiver::PERFORM_EXTENSIBILITY_CHECK, | 5019 JSReceiver::PERFORM_EXTENSIBILITY_CHECK, |
5034 JSReceiver::MAY_BE_STORE_FROM_KEYED, | 5020 JSReceiver::MAY_BE_STORE_FROM_KEYED, |
5035 JSObject::DONT_FORCE_FIELD)); | 5021 JSObject::DONT_FORCE_FIELD)); |
(...skipping 10548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15584 } | 15570 } |
15585 return NULL; | 15571 return NULL; |
15586 } | 15572 } |
15587 | 15573 |
15588 | 15574 |
15589 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15575 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15590 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15576 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15591 } | 15577 } |
15592 | 15578 |
15593 } } // namespace v8::internal | 15579 } } // namespace v8::internal |
OLD | NEW |