| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3100 case EXTERNAL_FLOAT_ELEMENTS: | 3100 case EXTERNAL_FLOAT_ELEMENTS: |
| 3101 case EXTERNAL_DOUBLE_ELEMENTS: | 3101 case EXTERNAL_DOUBLE_ELEMENTS: |
| 3102 // Pixel and external array elements cannot be deleted. Just | 3102 // Pixel and external array elements cannot be deleted. Just |
| 3103 // silently ignore here. | 3103 // silently ignore here. |
| 3104 break; | 3104 break; |
| 3105 | 3105 |
| 3106 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 3106 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 3107 FixedArray* parameter_map = FixedArray::cast(elements()); | 3107 FixedArray* parameter_map = FixedArray::cast(elements()); |
| 3108 uint32_t length = parameter_map->length(); | 3108 uint32_t length = parameter_map->length(); |
| 3109 Object* probe = | 3109 Object* probe = |
| 3110 (index + 2) < length ? parameter_map->get(index + 2) : NULL; | 3110 index < (length - 2) ? parameter_map->get(index + 2) : NULL; |
| 3111 if (probe != NULL && !probe->IsTheHole()) { | 3111 if (probe != NULL && !probe->IsTheHole()) { |
| 3112 // TODO(kmillikin): We could check if this was the last aliased | 3112 // TODO(kmillikin): We could check if this was the last aliased |
| 3113 // parameter, and revert to normal elements in that case. That | 3113 // parameter, and revert to normal elements in that case. That |
| 3114 // would enable GC of the context. | 3114 // would enable GC of the context. |
| 3115 parameter_map->set_the_hole(index + 2); | 3115 parameter_map->set_the_hole(index + 2); |
| 3116 } else { | 3116 } else { |
| 3117 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 3117 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 3118 if (arguments->IsDictionary()) { | 3118 if (arguments->IsDictionary()) { |
| 3119 return DeleteDictionaryElement(index, mode); | 3119 return DeleteDictionaryElement(index, mode); |
| 3120 } else { | 3120 } else { |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3547 // Otherwise allow to override it. | 3547 // Otherwise allow to override it. |
| 3548 break; | 3548 break; |
| 3549 } | 3549 } |
| 3550 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 3550 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 3551 // Ascertain whether we have read-only properties or an existing | 3551 // Ascertain whether we have read-only properties or an existing |
| 3552 // getter/setter pair in an arguments elements dictionary backing | 3552 // getter/setter pair in an arguments elements dictionary backing |
| 3553 // store. | 3553 // store. |
| 3554 FixedArray* parameter_map = FixedArray::cast(elements()); | 3554 FixedArray* parameter_map = FixedArray::cast(elements()); |
| 3555 uint32_t length = parameter_map->length(); | 3555 uint32_t length = parameter_map->length(); |
| 3556 Object* probe = | 3556 Object* probe = |
| 3557 (index + 2) < length ? parameter_map->get(index + 2) : NULL; | 3557 index < (length - 2) ? parameter_map->get(index + 2) : NULL; |
| 3558 if (probe == NULL || probe->IsTheHole()) { | 3558 if (probe == NULL || probe->IsTheHole()) { |
| 3559 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 3559 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 3560 if (arguments->IsDictionary()) { | 3560 if (arguments->IsDictionary()) { |
| 3561 NumberDictionary* dictionary = NumberDictionary::cast(arguments); | 3561 NumberDictionary* dictionary = NumberDictionary::cast(arguments); |
| 3562 probe = FindGetterSetterInDictionary(dictionary, index, heap); | 3562 probe = FindGetterSetterInDictionary(dictionary, index, heap); |
| 3563 if (!probe->IsTheHole()) return probe; | 3563 if (!probe->IsTheHole()) return probe; |
| 3564 } | 3564 } |
| 3565 } | 3565 } |
| 3566 break; | 3566 break; |
| 3567 } | 3567 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3645 dictionary->set_requires_slow_elements(); | 3645 dictionary->set_requires_slow_elements(); |
| 3646 // Update the dictionary backing store on the object. | 3646 // Update the dictionary backing store on the object. |
| 3647 if (elements()->map() == GetHeap()->non_strict_arguments_elements_map()) { | 3647 if (elements()->map() == GetHeap()->non_strict_arguments_elements_map()) { |
| 3648 // Also delete any parameter alias. | 3648 // Also delete any parameter alias. |
| 3649 // | 3649 // |
| 3650 // TODO(kmillikin): when deleting the last parameter alias we could | 3650 // TODO(kmillikin): when deleting the last parameter alias we could |
| 3651 // switch to a direct backing store without the parameter map. This | 3651 // switch to a direct backing store without the parameter map. This |
| 3652 // would allow GC of the context. | 3652 // would allow GC of the context. |
| 3653 FixedArray* parameter_map = FixedArray::cast(elements()); | 3653 FixedArray* parameter_map = FixedArray::cast(elements()); |
| 3654 uint32_t length = parameter_map->length(); | 3654 uint32_t length = parameter_map->length(); |
| 3655 if (index + 2 < length) { | 3655 if (index < length - 2) { |
| 3656 parameter_map->set(index + 2, GetHeap()->the_hole_value()); | 3656 parameter_map->set(index + 2, GetHeap()->the_hole_value()); |
| 3657 } | 3657 } |
| 3658 parameter_map->set(1, dictionary); | 3658 parameter_map->set(1, dictionary); |
| 3659 } else { | 3659 } else { |
| 3660 set_elements(dictionary); | 3660 set_elements(dictionary); |
| 3661 } | 3661 } |
| 3662 | 3662 |
| 3663 return structure; | 3663 return structure; |
| 3664 } | 3664 } |
| 3665 | 3665 |
| (...skipping 4229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7895 } | 7895 } |
| 7896 break; | 7896 break; |
| 7897 } | 7897 } |
| 7898 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 7898 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 7899 // Aliased parameters and non-aliased elements in a fast backing store | 7899 // Aliased parameters and non-aliased elements in a fast backing store |
| 7900 // behave as FAST_ELEMENT. Non-aliased elements in a dictionary | 7900 // behave as FAST_ELEMENT. Non-aliased elements in a dictionary |
| 7901 // backing store behave as DICTIONARY_ELEMENT. | 7901 // backing store behave as DICTIONARY_ELEMENT. |
| 7902 FixedArray* parameter_map = FixedArray::cast(elements()); | 7902 FixedArray* parameter_map = FixedArray::cast(elements()); |
| 7903 uint32_t length = parameter_map->length(); | 7903 uint32_t length = parameter_map->length(); |
| 7904 Object* probe = | 7904 Object* probe = |
| 7905 (index + 2) < length ? parameter_map->get(index + 2) : NULL; | 7905 index < (length - 2) ? parameter_map->get(index + 2) : NULL; |
| 7906 if (probe != NULL && !probe->IsTheHole()) return FAST_ELEMENT; | 7906 if (probe != NULL && !probe->IsTheHole()) return FAST_ELEMENT; |
| 7907 // If not aliased, check the arguments. | 7907 // If not aliased, check the arguments. |
| 7908 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 7908 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 7909 if (arguments->IsDictionary()) { | 7909 if (arguments->IsDictionary()) { |
| 7910 NumberDictionary* dictionary = NumberDictionary::cast(arguments); | 7910 NumberDictionary* dictionary = NumberDictionary::cast(arguments); |
| 7911 if (dictionary->FindEntry(index) != NumberDictionary::kNotFound) { | 7911 if (dictionary->FindEntry(index) != NumberDictionary::kNotFound) { |
| 7912 return DICTIONARY_ELEMENT; | 7912 return DICTIONARY_ELEMENT; |
| 7913 } | 7913 } |
| 7914 } else { | 7914 } else { |
| 7915 length = arguments->length(); | 7915 length = arguments->length(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8000 if (element_dictionary()->FindEntry(index) | 8000 if (element_dictionary()->FindEntry(index) |
| 8001 != NumberDictionary::kNotFound) { | 8001 != NumberDictionary::kNotFound) { |
| 8002 return true; | 8002 return true; |
| 8003 } | 8003 } |
| 8004 break; | 8004 break; |
| 8005 } | 8005 } |
| 8006 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 8006 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 8007 FixedArray* parameter_map = FixedArray::cast(elements()); | 8007 FixedArray* parameter_map = FixedArray::cast(elements()); |
| 8008 uint32_t length = parameter_map->length(); | 8008 uint32_t length = parameter_map->length(); |
| 8009 Object* probe = | 8009 Object* probe = |
| 8010 (index + 2 < length) ? parameter_map->get(index + 2) : NULL; | 8010 (index < length - 2) ? parameter_map->get(index + 2) : NULL; |
| 8011 if (probe != NULL && !probe->IsTheHole()) return true; | 8011 if (probe != NULL && !probe->IsTheHole()) return true; |
| 8012 | 8012 |
| 8013 // Not a mapped parameter, check the arguments. | 8013 // Not a mapped parameter, check the arguments. |
| 8014 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 8014 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 8015 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : FAST_ELEMENTS; | 8015 kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : FAST_ELEMENTS; |
| 8016 if (HasElementInElements(arguments, kind, index)) return true; | 8016 if (HasElementInElements(arguments, kind, index)) return true; |
| 8017 break; | 8017 break; |
| 8018 } | 8018 } |
| 8019 } | 8019 } |
| 8020 | 8020 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8542 case EXTERNAL_DOUBLE_ELEMENTS: { | 8542 case EXTERNAL_DOUBLE_ELEMENTS: { |
| 8543 ExternalDoubleArray* array = ExternalDoubleArray::cast(elements()); | 8543 ExternalDoubleArray* array = ExternalDoubleArray::cast(elements()); |
| 8544 return array->SetValue(index, value); | 8544 return array->SetValue(index, value); |
| 8545 } | 8545 } |
| 8546 case DICTIONARY_ELEMENTS: | 8546 case DICTIONARY_ELEMENTS: |
| 8547 return SetDictionaryElement(index, value, strict_mode, check_prototype); | 8547 return SetDictionaryElement(index, value, strict_mode, check_prototype); |
| 8548 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 8548 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 8549 FixedArray* parameter_map = FixedArray::cast(elements()); | 8549 FixedArray* parameter_map = FixedArray::cast(elements()); |
| 8550 uint32_t length = parameter_map->length(); | 8550 uint32_t length = parameter_map->length(); |
| 8551 Object* probe = | 8551 Object* probe = |
| 8552 (index + 2 < length) ? parameter_map->get(index + 2) : NULL; | 8552 (index < length - 2) ? parameter_map->get(index + 2) : NULL; |
| 8553 if (probe != NULL && !probe->IsTheHole()) { | 8553 if (probe != NULL && !probe->IsTheHole()) { |
| 8554 Context* context = Context::cast(parameter_map->get(0)); | 8554 Context* context = Context::cast(parameter_map->get(0)); |
| 8555 int context_index = Smi::cast(probe)->value(); | 8555 int context_index = Smi::cast(probe)->value(); |
| 8556 ASSERT(!context->get(context_index)->IsTheHole()); | 8556 ASSERT(!context->get(context_index)->IsTheHole()); |
| 8557 context->set(context_index, value); | 8557 context->set(context_index, value); |
| 8558 return value; | 8558 return value; |
| 8559 } else { | 8559 } else { |
| 8560 // Object is not mapped, defer to the arguments. | 8560 // Object is not mapped, defer to the arguments. |
| 8561 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 8561 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 8562 if (arguments->IsDictionary()) { | 8562 if (arguments->IsDictionary()) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8756 this); | 8756 this); |
| 8757 } | 8757 } |
| 8758 return element; | 8758 return element; |
| 8759 } | 8759 } |
| 8760 break; | 8760 break; |
| 8761 } | 8761 } |
| 8762 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 8762 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 8763 FixedArray* parameter_map = FixedArray::cast(elements()); | 8763 FixedArray* parameter_map = FixedArray::cast(elements()); |
| 8764 uint32_t length = parameter_map->length(); | 8764 uint32_t length = parameter_map->length(); |
| 8765 Object* probe = | 8765 Object* probe = |
| 8766 (index + 2 < length) ? parameter_map->get(index + 2) : NULL; | 8766 (index < length - 2) ? parameter_map->get(index + 2) : NULL; |
| 8767 if (probe != NULL && !probe->IsTheHole()) { | 8767 if (probe != NULL && !probe->IsTheHole()) { |
| 8768 Context* context = Context::cast(parameter_map->get(0)); | 8768 Context* context = Context::cast(parameter_map->get(0)); |
| 8769 int context_index = Smi::cast(probe)->value(); | 8769 int context_index = Smi::cast(probe)->value(); |
| 8770 ASSERT(!context->get(context_index)->IsTheHole()); | 8770 ASSERT(!context->get(context_index)->IsTheHole()); |
| 8771 return context->get(context_index); | 8771 return context->get(context_index); |
| 8772 } else { | 8772 } else { |
| 8773 // Object is not mapped, defer to the arguments. | 8773 // Object is not mapped, defer to the arguments. |
| 8774 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 8774 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 8775 if (arguments->IsDictionary()) { | 8775 if (arguments->IsDictionary()) { |
| 8776 NumberDictionary* dictionary = NumberDictionary::cast(arguments); | 8776 NumberDictionary* dictionary = NumberDictionary::cast(arguments); |
| (...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11561 if (break_point_objects()->IsUndefined()) return 0; | 11561 if (break_point_objects()->IsUndefined()) return 0; |
| 11562 // Single beak point. | 11562 // Single beak point. |
| 11563 if (!break_point_objects()->IsFixedArray()) return 1; | 11563 if (!break_point_objects()->IsFixedArray()) return 1; |
| 11564 // Multiple break points. | 11564 // Multiple break points. |
| 11565 return FixedArray::cast(break_point_objects())->length(); | 11565 return FixedArray::cast(break_point_objects())->length(); |
| 11566 } | 11566 } |
| 11567 #endif | 11567 #endif |
| 11568 | 11568 |
| 11569 | 11569 |
| 11570 } } // namespace v8::internal | 11570 } } // namespace v8::internal |
| OLD | NEW |