| 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 4004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4015 // Check if this is an element. | 4015 // Check if this is an element. |
| 4016 uint32_t index; | 4016 uint32_t index; |
| 4017 bool is_element = name->AsArrayIndex(&index); | 4017 bool is_element = name->AsArrayIndex(&index); |
| 4018 | 4018 |
| 4019 // Special case for elements if any of the flags are true. | 4019 // Special case for elements if any of the flags are true. |
| 4020 // If elements are in fast case we always implicitly assume that: | 4020 // If elements are in fast case we always implicitly assume that: |
| 4021 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. | 4021 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
| 4022 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && | 4022 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && |
| 4023 is_element) { | 4023 is_element) { |
| 4024 // Normalize the elements to enable attributes on the property. | 4024 // Normalize the elements to enable attributes on the property. |
| 4025 js_object->NormalizeElements(); | 4025 NormalizeElements(js_object); |
| 4026 NumberDictionary* dictionary = js_object->element_dictionary(); | 4026 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); |
| 4027 // Make sure that we never go back to fast case. | 4027 // Make sure that we never go back to fast case. |
| 4028 dictionary->set_requires_slow_elements(); | 4028 dictionary->set_requires_slow_elements(); |
| 4029 PropertyDetails details = PropertyDetails(attr, NORMAL); | 4029 PropertyDetails details = PropertyDetails(attr, NORMAL); |
| 4030 dictionary->Set(index, *obj_value, details); | 4030 NumberDictionarySet(dictionary, index, obj_value, details); |
| 4031 } | 4031 } |
| 4032 | 4032 |
| 4033 LookupResult result; | 4033 LookupResult result; |
| 4034 js_object->LocalLookupRealNamedProperty(*name, &result); | 4034 js_object->LocalLookupRealNamedProperty(*name, &result); |
| 4035 | 4035 |
| 4036 // Take special care when attributes are different and there is already | 4036 // Take special care when attributes are different and there is already |
| 4037 // a property. For simplicity we normalize the property which enables us | 4037 // a property. For simplicity we normalize the property which enables us |
| 4038 // to not worry about changing the instance_descriptor and creating a new | 4038 // to not worry about changing the instance_descriptor and creating a new |
| 4039 // map. The current version of SetObjectProperty does not handle attributes | 4039 // map. The current version of SetObjectProperty does not handle attributes |
| 4040 // correctly in the case where a property is a field and is reset with | 4040 // correctly in the case where a property is a field and is reset with |
| 4041 // new attributes. | 4041 // new attributes. |
| 4042 if (result.IsProperty() && attr != result.GetAttributes()) { | 4042 if (result.IsProperty() && attr != result.GetAttributes()) { |
| 4043 // New attributes - normalize to avoid writing to instance descriptor | 4043 // New attributes - normalize to avoid writing to instance descriptor |
| 4044 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 4044 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 4045 // Use IgnoreAttributes version since a readonly property may be | 4045 // Use IgnoreAttributes version since a readonly property may be |
| 4046 // overridden and SetProperty does not allow this. | 4046 // overridden and SetProperty does not allow this. |
| 4047 return js_object->IgnoreAttributesAndSetLocalProperty(*name, | 4047 return js_object->IgnoreAttributesAndSetLocalProperty(*name, |
| 4048 *obj_value, | 4048 *obj_value, |
| 4049 attr); | 4049 attr); |
| 4050 } | 4050 } |
| 4051 | 4051 |
| 4052 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); | 4052 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); |
| 4053 } | 4053 } |
| 4054 | 4054 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4631 } | 4631 } |
| 4632 | 4632 |
| 4633 | 4633 |
| 4634 static Object* Runtime_ToSlowProperties(Arguments args) { | 4634 static Object* Runtime_ToSlowProperties(Arguments args) { |
| 4635 HandleScope scope; | 4635 HandleScope scope; |
| 4636 | 4636 |
| 4637 ASSERT(args.length() == 1); | 4637 ASSERT(args.length() == 1); |
| 4638 Handle<Object> object = args.at<Object>(0); | 4638 Handle<Object> object = args.at<Object>(0); |
| 4639 if (object->IsJSObject()) { | 4639 if (object->IsJSObject()) { |
| 4640 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 4640 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
| 4641 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 4641 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 4642 } | 4642 } |
| 4643 return *object; | 4643 return *object; |
| 4644 } | 4644 } |
| 4645 | 4645 |
| 4646 | 4646 |
| 4647 static Object* Runtime_ToBool(Arguments args) { | 4647 static Object* Runtime_ToBool(Arguments args) { |
| 4648 NoHandleAllocation ha; | 4648 NoHandleAllocation ha; |
| 4649 ASSERT(args.length() == 1); | 4649 ASSERT(args.length() == 1); |
| 4650 | 4650 |
| 4651 return args[0]->ToBoolean(); | 4651 return args[0]->ToBoolean(); |
| (...skipping 5902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10554 } else { | 10554 } else { |
| 10555 // Handle last resort GC and make sure to allow future allocations | 10555 // Handle last resort GC and make sure to allow future allocations |
| 10556 // to grow the heap without causing GCs (if possible). | 10556 // to grow the heap without causing GCs (if possible). |
| 10557 Counters::gc_last_resort_from_js.Increment(); | 10557 Counters::gc_last_resort_from_js.Increment(); |
| 10558 Heap::CollectAllGarbage(false); | 10558 Heap::CollectAllGarbage(false); |
| 10559 } | 10559 } |
| 10560 } | 10560 } |
| 10561 | 10561 |
| 10562 | 10562 |
| 10563 } } // namespace v8::internal | 10563 } } // namespace v8::internal |
| OLD | NEW |