OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 | 2919 |
2920 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 2920 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
2921 | 2921 |
2922 // Take special care when attributes are different and there is already | 2922 // Take special care when attributes are different and there is already |
2923 // a property. For simplicity we normalize the property which enables us | 2923 // a property. For simplicity we normalize the property which enables us |
2924 // to not worry about changing the instance_descriptor and creating a new | 2924 // to not worry about changing the instance_descriptor and creating a new |
2925 // map. The current version of SetObjectProperty does not handle attributes | 2925 // map. The current version of SetObjectProperty does not handle attributes |
2926 // correctly in the case where a property is a field and is reset with | 2926 // correctly in the case where a property is a field and is reset with |
2927 // new attributes. | 2927 // new attributes. |
2928 if (result.IsProperty() && attr != result.GetAttributes()) { | 2928 if (result.IsProperty() && attr != result.GetAttributes()) { |
2929 PropertyDetails details = PropertyDetails(attr, NORMAL); | |
2930 // New attributes - normalize to avoid writing to instance descriptor | 2929 // New attributes - normalize to avoid writing to instance descriptor |
2931 js_object->NormalizeProperties(KEEP_INOBJECT_PROPERTIES, 0); | 2930 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
2932 return js_object->SetNormalizedProperty(*name, *obj_value, details); | 2931 // Use IgnoreAttributes version since a readonly property may be |
| 2932 // overridden and SetProperty does not allow this. |
| 2933 return js_object->IgnoreAttributesAndSetLocalProperty(*name, |
| 2934 *obj_value, |
| 2935 attr); |
2933 } | 2936 } |
2934 | |
2935 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); | 2937 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); |
2936 } | 2938 } |
2937 | 2939 |
2938 | 2940 |
2939 Object* Runtime::SetObjectProperty(Handle<Object> object, | 2941 Object* Runtime::SetObjectProperty(Handle<Object> object, |
2940 Handle<Object> key, | 2942 Handle<Object> key, |
2941 Handle<Object> value, | 2943 Handle<Object> value, |
2942 PropertyAttributes attr) { | 2944 PropertyAttributes attr) { |
2943 HandleScope scope; | 2945 HandleScope scope; |
2944 | 2946 |
(...skipping 5235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8180 } else { | 8182 } else { |
8181 // Handle last resort GC and make sure to allow future allocations | 8183 // Handle last resort GC and make sure to allow future allocations |
8182 // to grow the heap without causing GCs (if possible). | 8184 // to grow the heap without causing GCs (if possible). |
8183 Counters::gc_last_resort_from_js.Increment(); | 8185 Counters::gc_last_resort_from_js.Increment(); |
8184 Heap::CollectAllGarbage(false); | 8186 Heap::CollectAllGarbage(false); |
8185 } | 8187 } |
8186 } | 8188 } |
8187 | 8189 |
8188 | 8190 |
8189 } } // namespace v8::internal | 8191 } } // namespace v8::internal |
OLD | NEW |