| 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 3520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3531 // Check if this is an element. | 3531 // Check if this is an element. |
| 3532 uint32_t index; | 3532 uint32_t index; |
| 3533 bool is_element = name->AsArrayIndex(&index); | 3533 bool is_element = name->AsArrayIndex(&index); |
| 3534 | 3534 |
| 3535 // Special case for elements if any of the flags are true. | 3535 // Special case for elements if any of the flags are true. |
| 3536 // If elements are in fast case we always implicitly assume that: | 3536 // If elements are in fast case we always implicitly assume that: |
| 3537 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. | 3537 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
| 3538 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && | 3538 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && |
| 3539 is_element) { | 3539 is_element) { |
| 3540 // Normalize the elements to enable attributes on the property. | 3540 // Normalize the elements to enable attributes on the property. |
| 3541 js_object->NormalizeElements(); | 3541 NormalizeElements(js_object); |
| 3542 NumberDictionary* dictionary = js_object->element_dictionary(); | 3542 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); |
| 3543 // Make sure that we never go back to fast case. | 3543 // Make sure that we never go back to fast case. |
| 3544 dictionary->set_requires_slow_elements(); | 3544 dictionary->set_requires_slow_elements(); |
| 3545 PropertyDetails details = PropertyDetails(attr, NORMAL); | 3545 PropertyDetails details = PropertyDetails(attr, NORMAL); |
| 3546 dictionary->Set(index, *obj_value, details); | 3546 NumberDictionarySet(dictionary, index, obj_value, details); |
| 3547 } | 3547 } |
| 3548 | 3548 |
| 3549 LookupResult result; | 3549 LookupResult result; |
| 3550 js_object->LocalLookupRealNamedProperty(*name, &result); | 3550 js_object->LocalLookupRealNamedProperty(*name, &result); |
| 3551 | 3551 |
| 3552 // Take special care when attributes are different and there is already | 3552 // Take special care when attributes are different and there is already |
| 3553 // a property. For simplicity we normalize the property which enables us | 3553 // a property. For simplicity we normalize the property which enables us |
| 3554 // to not worry about changing the instance_descriptor and creating a new | 3554 // to not worry about changing the instance_descriptor and creating a new |
| 3555 // map. The current version of SetObjectProperty does not handle attributes | 3555 // map. The current version of SetObjectProperty does not handle attributes |
| 3556 // correctly in the case where a property is a field and is reset with | 3556 // correctly in the case where a property is a field and is reset with |
| 3557 // new attributes. | 3557 // new attributes. |
| 3558 if (result.IsProperty() && attr != result.GetAttributes()) { | 3558 if (result.IsProperty() && attr != result.GetAttributes()) { |
| 3559 // New attributes - normalize to avoid writing to instance descriptor | 3559 // New attributes - normalize to avoid writing to instance descriptor |
| 3560 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 3560 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 3561 // Use IgnoreAttributes version since a readonly property may be | 3561 // Use IgnoreAttributes version since a readonly property may be |
| 3562 // overridden and SetProperty does not allow this. | 3562 // overridden and SetProperty does not allow this. |
| 3563 return js_object->IgnoreAttributesAndSetLocalProperty(*name, | 3563 return js_object->IgnoreAttributesAndSetLocalProperty(*name, |
| 3564 *obj_value, | 3564 *obj_value, |
| 3565 attr); | 3565 attr); |
| 3566 } | 3566 } |
| 3567 | 3567 |
| 3568 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); | 3568 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); |
| 3569 } | 3569 } |
| 3570 | 3570 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4147 } | 4147 } |
| 4148 | 4148 |
| 4149 | 4149 |
| 4150 static Object* Runtime_ToSlowProperties(Arguments args) { | 4150 static Object* Runtime_ToSlowProperties(Arguments args) { |
| 4151 HandleScope scope; | 4151 HandleScope scope; |
| 4152 | 4152 |
| 4153 ASSERT(args.length() == 1); | 4153 ASSERT(args.length() == 1); |
| 4154 Handle<Object> object = args.at<Object>(0); | 4154 Handle<Object> object = args.at<Object>(0); |
| 4155 if (object->IsJSObject()) { | 4155 if (object->IsJSObject()) { |
| 4156 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 4156 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
| 4157 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 4157 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 4158 } | 4158 } |
| 4159 return *object; | 4159 return *object; |
| 4160 } | 4160 } |
| 4161 | 4161 |
| 4162 | 4162 |
| 4163 static Object* Runtime_ToBool(Arguments args) { | 4163 static Object* Runtime_ToBool(Arguments args) { |
| 4164 NoHandleAllocation ha; | 4164 NoHandleAllocation ha; |
| 4165 ASSERT(args.length() == 1); | 4165 ASSERT(args.length() == 1); |
| 4166 | 4166 |
| 4167 return args[0]->ToBoolean(); | 4167 return args[0]->ToBoolean(); |
| (...skipping 5989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10157 } else { | 10157 } else { |
| 10158 // Handle last resort GC and make sure to allow future allocations | 10158 // Handle last resort GC and make sure to allow future allocations |
| 10159 // to grow the heap without causing GCs (if possible). | 10159 // to grow the heap without causing GCs (if possible). |
| 10160 Counters::gc_last_resort_from_js.Increment(); | 10160 Counters::gc_last_resort_from_js.Increment(); |
| 10161 Heap::CollectAllGarbage(false); | 10161 Heap::CollectAllGarbage(false); |
| 10162 } | 10162 } |
| 10163 } | 10163 } |
| 10164 | 10164 |
| 10165 | 10165 |
| 10166 } } // namespace v8::internal | 10166 } } // namespace v8::internal |
| OLD | NEW |