Index: src/runtime.cc |
=================================================================== |
--- src/runtime.cc (revision 8272) |
+++ src/runtime.cc (working copy) |
@@ -3995,6 +3995,24 @@ |
return *value; |
} |
+ // Special case for elements if any of the flags are true. |
+ // If elements are in fast case we always implicitly assume that: |
+ // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
+ if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { |
+ // Normalize the elements to enable attributes on the property. |
+ NormalizeElements(js_object); |
+ Handle<NumberDictionary> dictionary(js_object->element_dictionary()); |
+ // Make sure that we never go back to fast case. |
+ dictionary->set_requires_slow_elements(); |
+ PropertyDetails details = PropertyDetails(attr, NORMAL); |
+ Handle<NumberDictionary> extended_dictionary = |
+ NumberDictionarySet(dictionary, index, value, details); |
+ if (*extended_dictionary != *dictionary) { |
+ js_object->set_elements(*extended_dictionary); |
+ } |
+ return *value; |
+ } |
+ |
Handle<Object> result = SetElement(js_object, index, value, strict_mode); |
if (result.is_null()) return Failure::Exception(); |
return *value; |
@@ -4003,6 +4021,23 @@ |
if (key->IsString()) { |
Handle<Object> result; |
if (Handle<String>::cast(key)->AsArrayIndex(&index)) { |
Erik Corry
2011/06/14 13:21:51
There's a ton of copied code here.
You could creat
Rico
2011/06/14 13:44:23
Done.
|
+ // Special case for elements if any of the flags are true. |
+ // If elements are in fast case we always implicitly assume that: |
+ // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
+ if (((attr & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0)) { |
+ // Normalize the elements to enable attributes on the property. |
+ NormalizeElements(js_object); |
+ Handle<NumberDictionary> dictionary(js_object->element_dictionary()); |
+ // Make sure that we never go back to fast case. |
+ dictionary->set_requires_slow_elements(); |
+ PropertyDetails details = PropertyDetails(attr, NORMAL); |
+ Handle<NumberDictionary> extended_dictionary = |
+ NumberDictionarySet(dictionary, index, value, details); |
+ if (*extended_dictionary != *dictionary) { |
+ js_object->set_elements(*extended_dictionary); |
+ } |
+ return *value; |
+ } |
result = SetElement(js_object, index, value, strict_mode); |
} else { |
Handle<String> key_string = Handle<String>::cast(key); |