| 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 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3649 if (!CanSetCallback(name)) { | 3649 if (!CanSetCallback(name)) { |
| 3650 return heap->undefined_value(); | 3650 return heap->undefined_value(); |
| 3651 } | 3651 } |
| 3652 | 3652 |
| 3653 uint32_t index = 0; | 3653 uint32_t index = 0; |
| 3654 bool is_element = name->AsArrayIndex(&index); | 3654 bool is_element = name->AsArrayIndex(&index); |
| 3655 | 3655 |
| 3656 if (is_element) { | 3656 if (is_element) { |
| 3657 switch (GetElementsKind()) { | 3657 switch (GetElementsKind()) { |
| 3658 case FAST_ELEMENTS: | 3658 case FAST_ELEMENTS: |
| 3659 case FAST_DOUBLE_ELEMENTS: |
| 3659 break; | 3660 break; |
| 3660 case EXTERNAL_PIXEL_ELEMENTS: | 3661 case EXTERNAL_PIXEL_ELEMENTS: |
| 3661 case EXTERNAL_BYTE_ELEMENTS: | 3662 case EXTERNAL_BYTE_ELEMENTS: |
| 3662 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3663 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3663 case EXTERNAL_SHORT_ELEMENTS: | 3664 case EXTERNAL_SHORT_ELEMENTS: |
| 3664 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3665 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 3665 case EXTERNAL_INT_ELEMENTS: | 3666 case EXTERNAL_INT_ELEMENTS: |
| 3666 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3667 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 3667 case EXTERNAL_FLOAT_ELEMENTS: | 3668 case EXTERNAL_FLOAT_ELEMENTS: |
| 3668 case EXTERNAL_DOUBLE_ELEMENTS: | 3669 case EXTERNAL_DOUBLE_ELEMENTS: |
| 3669 case FAST_DOUBLE_ELEMENTS: | |
| 3670 // Ignore getters and setters on pixel and external array | 3670 // Ignore getters and setters on pixel and external array |
| 3671 // elements. | 3671 // elements. |
| 3672 return heap->undefined_value(); | 3672 return heap->undefined_value(); |
| 3673 case DICTIONARY_ELEMENTS: { | 3673 case DICTIONARY_ELEMENTS: { |
| 3674 Object* probe = | 3674 Object* probe = |
| 3675 FindGetterSetterInDictionary(element_dictionary(), index, heap); | 3675 FindGetterSetterInDictionary(element_dictionary(), index, heap); |
| 3676 if (!probe->IsTheHole()) return probe; | 3676 if (!probe->IsTheHole()) return probe; |
| 3677 // Otherwise allow to override it. | 3677 // Otherwise allow to override it. |
| 3678 break; | 3678 break; |
| 3679 } | 3679 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3898 | 3898 |
| 3899 uint32_t index = 0; | 3899 uint32_t index = 0; |
| 3900 bool is_element = name->AsArrayIndex(&index); | 3900 bool is_element = name->AsArrayIndex(&index); |
| 3901 | 3901 |
| 3902 if (is_element) { | 3902 if (is_element) { |
| 3903 if (IsJSArray()) return isolate->heap()->undefined_value(); | 3903 if (IsJSArray()) return isolate->heap()->undefined_value(); |
| 3904 | 3904 |
| 3905 // Accessors overwrite previous callbacks (cf. with getters/setters). | 3905 // Accessors overwrite previous callbacks (cf. with getters/setters). |
| 3906 switch (GetElementsKind()) { | 3906 switch (GetElementsKind()) { |
| 3907 case FAST_ELEMENTS: | 3907 case FAST_ELEMENTS: |
| 3908 case FAST_DOUBLE_ELEMENTS: |
| 3908 break; | 3909 break; |
| 3909 case EXTERNAL_PIXEL_ELEMENTS: | 3910 case EXTERNAL_PIXEL_ELEMENTS: |
| 3910 case EXTERNAL_BYTE_ELEMENTS: | 3911 case EXTERNAL_BYTE_ELEMENTS: |
| 3911 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3912 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3912 case EXTERNAL_SHORT_ELEMENTS: | 3913 case EXTERNAL_SHORT_ELEMENTS: |
| 3913 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3914 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 3914 case EXTERNAL_INT_ELEMENTS: | 3915 case EXTERNAL_INT_ELEMENTS: |
| 3915 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3916 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 3916 case EXTERNAL_FLOAT_ELEMENTS: | 3917 case EXTERNAL_FLOAT_ELEMENTS: |
| 3917 case EXTERNAL_DOUBLE_ELEMENTS: | 3918 case EXTERNAL_DOUBLE_ELEMENTS: |
| 3918 case FAST_DOUBLE_ELEMENTS: | |
| 3919 // Ignore getters and setters on pixel and external array | 3919 // Ignore getters and setters on pixel and external array |
| 3920 // elements. | 3920 // elements. |
| 3921 return isolate->heap()->undefined_value(); | 3921 return isolate->heap()->undefined_value(); |
| 3922 case DICTIONARY_ELEMENTS: | 3922 case DICTIONARY_ELEMENTS: |
| 3923 break; | 3923 break; |
| 3924 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3924 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 3925 UNIMPLEMENTED(); | 3925 UNIMPLEMENTED(); |
| 3926 break; | 3926 break; |
| 3927 } | 3927 } |
| 3928 | 3928 |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4681 cache->ElementAdded(); | 4681 cache->ElementAdded(); |
| 4682 return cache; | 4682 return cache; |
| 4683 } | 4683 } |
| 4684 | 4684 |
| 4685 | 4685 |
| 4686 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { | 4686 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { |
| 4687 ASSERT(!array->HasExternalArrayElements()); | 4687 ASSERT(!array->HasExternalArrayElements()); |
| 4688 switch (array->GetElementsKind()) { | 4688 switch (array->GetElementsKind()) { |
| 4689 case JSObject::FAST_ELEMENTS: | 4689 case JSObject::FAST_ELEMENTS: |
| 4690 return UnionOfKeys(FixedArray::cast(array->elements())); | 4690 return UnionOfKeys(FixedArray::cast(array->elements())); |
| 4691 case JSObject::FAST_DOUBLE_ELEMENTS: |
| 4692 UNIMPLEMENTED(); |
| 4693 break; |
| 4691 case JSObject::DICTIONARY_ELEMENTS: { | 4694 case JSObject::DICTIONARY_ELEMENTS: { |
| 4692 NumberDictionary* dict = array->element_dictionary(); | 4695 NumberDictionary* dict = array->element_dictionary(); |
| 4693 int size = dict->NumberOfElements(); | 4696 int size = dict->NumberOfElements(); |
| 4694 | 4697 |
| 4695 // Allocate a temporary fixed array. | 4698 // Allocate a temporary fixed array. |
| 4696 Object* object; | 4699 Object* object; |
| 4697 { MaybeObject* maybe_object = GetHeap()->AllocateFixedArray(size); | 4700 { MaybeObject* maybe_object = GetHeap()->AllocateFixedArray(size); |
| 4698 if (!maybe_object->ToObject(&object)) return maybe_object; | 4701 if (!maybe_object->ToObject(&object)) return maybe_object; |
| 4699 } | 4702 } |
| 4700 FixedArray* key_array = FixedArray::cast(object); | 4703 FixedArray* key_array = FixedArray::cast(object); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4715 break; | 4718 break; |
| 4716 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 4719 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
| 4717 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 4720 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 4718 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 4721 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
| 4719 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 4722 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 4720 case JSObject::EXTERNAL_INT_ELEMENTS: | 4723 case JSObject::EXTERNAL_INT_ELEMENTS: |
| 4721 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 4724 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 4722 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 4725 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
| 4723 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: | 4726 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: |
| 4724 case JSObject::EXTERNAL_PIXEL_ELEMENTS: | 4727 case JSObject::EXTERNAL_PIXEL_ELEMENTS: |
| 4725 case JSObject::FAST_DOUBLE_ELEMENTS: | |
| 4726 break; | 4728 break; |
| 4727 } | 4729 } |
| 4728 UNREACHABLE(); | 4730 UNREACHABLE(); |
| 4729 return GetHeap()->null_value(); // Failure case needs to "return" a value. | 4731 return GetHeap()->null_value(); // Failure case needs to "return" a value. |
| 4730 } | 4732 } |
| 4731 | 4733 |
| 4732 | 4734 |
| 4733 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { | 4735 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { |
| 4734 int len0 = length(); | 4736 int len0 = length(); |
| 4735 #ifdef DEBUG | 4737 #ifdef DEBUG |
| (...skipping 3295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8031 uint32_t length = IsJSArray() ? | 8033 uint32_t length = IsJSArray() ? |
| 8032 static_cast<uint32_t> | 8034 static_cast<uint32_t> |
| 8033 (Smi::cast(JSArray::cast(this)->length())->value()) : | 8035 (Smi::cast(JSArray::cast(this)->length())->value()) : |
| 8034 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | 8036 static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
| 8035 if ((index < length) && | 8037 if ((index < length) && |
| 8036 !FixedArray::cast(elements())->get(index)->IsTheHole()) { | 8038 !FixedArray::cast(elements())->get(index)->IsTheHole()) { |
| 8037 return FAST_ELEMENT; | 8039 return FAST_ELEMENT; |
| 8038 } | 8040 } |
| 8039 break; | 8041 break; |
| 8040 } | 8042 } |
| 8043 case FAST_DOUBLE_ELEMENTS: { |
| 8044 uint32_t length = IsJSArray() ? |
| 8045 static_cast<uint32_t> |
| 8046 (Smi::cast(JSArray::cast(this)->length())->value()) : |
| 8047 static_cast<uint32_t>(FixedDoubleArray::cast(elements())->length()); |
| 8048 if ((index < length) && |
| 8049 !FixedDoubleArray::cast(elements())->is_the_hole(index)) { |
| 8050 return FAST_ELEMENT; |
| 8051 } |
| 8052 break; |
| 8053 } |
| 8041 case EXTERNAL_PIXEL_ELEMENTS: { | 8054 case EXTERNAL_PIXEL_ELEMENTS: { |
| 8042 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); | 8055 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
| 8043 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT; | 8056 if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT; |
| 8044 break; | 8057 break; |
| 8045 } | 8058 } |
| 8046 case EXTERNAL_BYTE_ELEMENTS: | 8059 case EXTERNAL_BYTE_ELEMENTS: |
| 8047 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 8060 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 8048 case EXTERNAL_SHORT_ELEMENTS: | 8061 case EXTERNAL_SHORT_ELEMENTS: |
| 8049 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 8062 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 8050 case EXTERNAL_INT_ELEMENTS: | 8063 case EXTERNAL_INT_ELEMENTS: |
| 8051 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 8064 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 8052 case EXTERNAL_FLOAT_ELEMENTS: | 8065 case EXTERNAL_FLOAT_ELEMENTS: |
| 8053 case EXTERNAL_DOUBLE_ELEMENTS: { | 8066 case EXTERNAL_DOUBLE_ELEMENTS: { |
| 8054 ExternalArray* array = ExternalArray::cast(elements()); | 8067 ExternalArray* array = ExternalArray::cast(elements()); |
| 8055 if (index < static_cast<uint32_t>(array->length())) return FAST_ELEMENT; | 8068 if (index < static_cast<uint32_t>(array->length())) return FAST_ELEMENT; |
| 8056 break; | 8069 break; |
| 8057 } | 8070 } |
| 8058 case FAST_DOUBLE_ELEMENTS: | |
| 8059 UNREACHABLE(); | |
| 8060 break; | |
| 8061 case DICTIONARY_ELEMENTS: { | 8071 case DICTIONARY_ELEMENTS: { |
| 8062 if (element_dictionary()->FindEntry(index) != | 8072 if (element_dictionary()->FindEntry(index) != |
| 8063 NumberDictionary::kNotFound) { | 8073 NumberDictionary::kNotFound) { |
| 8064 return DICTIONARY_ELEMENT; | 8074 return DICTIONARY_ELEMENT; |
| 8065 } | 8075 } |
| 8066 break; | 8076 break; |
| 8067 } | 8077 } |
| 8068 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 8078 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 8069 // Aliased parameters and non-aliased elements in a fast backing store | 8079 // Aliased parameters and non-aliased elements in a fast backing store |
| 8070 // behave as FAST_ELEMENT. Non-aliased elements in a dictionary | 8080 // behave as FAST_ELEMENT. Non-aliased elements in a dictionary |
| (...skipping 3765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11836 if (break_point_objects()->IsUndefined()) return 0; | 11846 if (break_point_objects()->IsUndefined()) return 0; |
| 11837 // Single beak point. | 11847 // Single beak point. |
| 11838 if (!break_point_objects()->IsFixedArray()) return 1; | 11848 if (!break_point_objects()->IsFixedArray()) return 1; |
| 11839 // Multiple break points. | 11849 // Multiple break points. |
| 11840 return FixedArray::cast(break_point_objects())->length(); | 11850 return FixedArray::cast(break_point_objects())->length(); |
| 11841 } | 11851 } |
| 11842 #endif | 11852 #endif |
| 11843 | 11853 |
| 11844 | 11854 |
| 11845 } } // namespace v8::internal | 11855 } } // namespace v8::internal |
| OLD | NEW |