Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2925 | 2925 |
| 2926 // Try to flatten before operating on the string. | 2926 // Try to flatten before operating on the string. |
| 2927 name->TryFlatten(); | 2927 name->TryFlatten(); |
| 2928 | 2928 |
| 2929 if (!CanSetCallback(name)) { | 2929 if (!CanSetCallback(name)) { |
| 2930 return Heap::undefined_value(); | 2930 return Heap::undefined_value(); |
| 2931 } | 2931 } |
| 2932 | 2932 |
| 2933 uint32_t index = 0; | 2933 uint32_t index = 0; |
| 2934 bool is_element = name->AsArrayIndex(&index); | 2934 bool is_element = name->AsArrayIndex(&index); |
| 2935 if (is_element && IsJSArray()) return Heap::undefined_value(); | |
| 2936 | 2935 |
| 2937 if (is_element) { | 2936 if (is_element) { |
| 2938 switch (GetElementsKind()) { | 2937 switch (GetElementsKind()) { |
| 2939 case FAST_ELEMENTS: | 2938 case FAST_ELEMENTS: |
| 2940 break; | 2939 break; |
| 2941 case PIXEL_ELEMENTS: | 2940 case PIXEL_ELEMENTS: |
| 2942 case EXTERNAL_BYTE_ELEMENTS: | 2941 case EXTERNAL_BYTE_ELEMENTS: |
| 2943 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2942 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 2944 case EXTERNAL_SHORT_ELEMENTS: | 2943 case EXTERNAL_SHORT_ELEMENTS: |
| 2945 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2944 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| (...skipping 3992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6938 bool check_prototype) { | 6937 bool check_prototype) { |
| 6939 ASSERT(HasFastElements()); | 6938 ASSERT(HasFastElements()); |
| 6940 | 6939 |
| 6941 Object* elms_obj; | 6940 Object* elms_obj; |
| 6942 { MaybeObject* maybe_elms_obj = EnsureWritableFastElements(); | 6941 { MaybeObject* maybe_elms_obj = EnsureWritableFastElements(); |
| 6943 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; | 6942 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; |
| 6944 } | 6943 } |
| 6945 FixedArray* elms = FixedArray::cast(elms_obj); | 6944 FixedArray* elms = FixedArray::cast(elms_obj); |
| 6946 uint32_t elms_length = static_cast<uint32_t>(elms->length()); | 6945 uint32_t elms_length = static_cast<uint32_t>(elms->length()); |
| 6947 | 6946 |
| 6948 if (check_prototype && !IsJSArray() && | 6947 if (check_prototype && |
| 6949 (index >= elms_length || elms->get(index)->IsTheHole())) { | 6948 (index >= elms_length || elms->get(index)->IsTheHole())) { |
| 6950 if (SetElementWithCallbackSetterInPrototypes(index, value)) { | 6949 if (SetElementWithCallbackSetterInPrototypes(index, value)) { |
|
Lasse Reichstein
2011/01/04 13:34:34
For the heck of it, combine the two ifs into one.
Rico
2011/01/04 13:57:50
Done.
| |
| 6951 return value; | 6950 return value; |
| 6952 } | 6951 } |
| 6953 } | 6952 } |
| 6954 | 6953 |
| 6955 // Check whether there is extra space in fixed array.. | 6954 // Check whether there is extra space in fixed array.. |
| 6956 if (index < elms_length) { | 6955 if (index < elms_length) { |
| 6957 elms->set(index, value); | 6956 elms->set(index, value); |
| 6958 if (IsJSArray()) { | 6957 if (IsJSArray()) { |
| 6959 // Update the length of the array if needed. | 6958 // Update the length of the array if needed. |
| 6960 uint32_t array_length = 0; | 6959 uint32_t array_length = 0; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7073 Object* element = dictionary->ValueAt(entry); | 7072 Object* element = dictionary->ValueAt(entry); |
| 7074 PropertyDetails details = dictionary->DetailsAt(entry); | 7073 PropertyDetails details = dictionary->DetailsAt(entry); |
| 7075 if (details.type() == CALLBACKS) { | 7074 if (details.type() == CALLBACKS) { |
| 7076 return SetElementWithCallback(element, index, value, this); | 7075 return SetElementWithCallback(element, index, value, this); |
| 7077 } else { | 7076 } else { |
| 7078 dictionary->UpdateMaxNumberKey(index); | 7077 dictionary->UpdateMaxNumberKey(index); |
| 7079 dictionary->ValueAtPut(entry, value); | 7078 dictionary->ValueAtPut(entry, value); |
| 7080 } | 7079 } |
| 7081 } else { | 7080 } else { |
| 7082 // Index not already used. Look for an accessor in the prototype chain. | 7081 // Index not already used. Look for an accessor in the prototype chain. |
| 7083 if (check_prototype && !IsJSArray() && | 7082 if (check_prototype && |
| 7084 SetElementWithCallbackSetterInPrototypes(index, value)) { | 7083 SetElementWithCallbackSetterInPrototypes(index, value)) { |
| 7085 return value; | 7084 return value; |
| 7086 } | 7085 } |
| 7087 // When we set the is_extensible flag to false we always force | 7086 // When we set the is_extensible flag to false we always force |
| 7088 // the element into dictionary mode (and force them to stay there). | 7087 // the element into dictionary mode (and force them to stay there). |
| 7089 if (!map()->is_extensible()) { | 7088 if (!map()->is_extensible()) { |
| 7090 Handle<Object> number(Factory::NewNumberFromUint(index)); | 7089 Handle<Object> number(Factory::NewNumberFromUint(index)); |
| 7091 Handle<String> index_string(Factory::NumberToString(number)); | 7090 Handle<String> index_string(Factory::NumberToString(number)); |
| 7092 Handle<Object> args[1] = { index_string }; | 7091 Handle<Object> args[1] = { index_string }; |
| 7093 return Top::Throw(*Factory::NewTypeError("object_not_extensible", | 7092 return Top::Throw(*Factory::NewTypeError("object_not_extensible", |
| (...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9867 if (break_point_objects()->IsUndefined()) return 0; | 9866 if (break_point_objects()->IsUndefined()) return 0; |
| 9868 // Single beak point. | 9867 // Single beak point. |
| 9869 if (!break_point_objects()->IsFixedArray()) return 1; | 9868 if (!break_point_objects()->IsFixedArray()) return 1; |
| 9870 // Multiple break points. | 9869 // Multiple break points. |
| 9871 return FixedArray::cast(break_point_objects())->length(); | 9870 return FixedArray::cast(break_point_objects())->length(); |
| 9872 } | 9871 } |
| 9873 #endif | 9872 #endif |
| 9874 | 9873 |
| 9875 | 9874 |
| 9876 } } // namespace v8::internal | 9875 } } // namespace v8::internal |
| OLD | NEW |