| 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 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2954 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); | 2954 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); |
| 2955 } | 2955 } |
| 2956 | 2956 |
| 2957 | 2957 |
| 2958 Object* Map::prototype() { | 2958 Object* Map::prototype() { |
| 2959 return READ_FIELD(this, kPrototypeOffset); | 2959 return READ_FIELD(this, kPrototypeOffset); |
| 2960 } | 2960 } |
| 2961 | 2961 |
| 2962 | 2962 |
| 2963 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 2963 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
| 2964 ASSERT(value->IsNull() || value->IsJSObject()); | 2964 ASSERT(value->IsNull() || value->IsJSReceiver()); |
| 2965 WRITE_FIELD(this, kPrototypeOffset, value); | 2965 WRITE_FIELD(this, kPrototypeOffset, value); |
| 2966 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, mode); | 2966 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, mode); |
| 2967 } | 2967 } |
| 2968 | 2968 |
| 2969 | 2969 |
| 2970 MaybeObject* Map::GetFastElementsMap() { | 2970 MaybeObject* Map::GetFastElementsMap() { |
| 2971 if (has_fast_elements()) return this; | 2971 if (has_fast_elements()) return this; |
| 2972 Object* obj; | 2972 Object* obj; |
| 2973 { MaybeObject* maybe_obj = CopyDropTransitions(); | 2973 { MaybeObject* maybe_obj = CopyDropTransitions(); |
| 2974 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2974 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2975 } | 2975 } |
| 2976 Map* new_map = Map::cast(obj); | 2976 Map* new_map = Map::cast(obj); |
| 2977 new_map->set_has_fast_elements(true); | 2977 new_map->set_elements_kind(JSObject::FAST_ELEMENTS); |
| 2978 isolate()->counters()->map_slow_to_fast_elements()->Increment(); | 2978 isolate()->counters()->map_slow_to_fast_elements()->Increment(); |
| 2979 return new_map; | 2979 return new_map; |
| 2980 } | 2980 } |
| 2981 | 2981 |
| 2982 | 2982 |
| 2983 MaybeObject* Map::GetSlowElementsMap() { | 2983 MaybeObject* Map::GetSlowElementsMap() { |
| 2984 if (!has_fast_elements()) return this; | 2984 if (!has_fast_elements()) return this; |
| 2985 Object* obj; | 2985 Object* obj; |
| 2986 { MaybeObject* maybe_obj = CopyDropTransitions(); | 2986 { MaybeObject* maybe_obj = CopyDropTransitions(); |
| 2987 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2987 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2988 } | 2988 } |
| 2989 Map* new_map = Map::cast(obj); | 2989 Map* new_map = Map::cast(obj); |
| 2990 new_map->set_has_fast_elements(false); | 2990 new_map->set_elements_kind(JSObject::DICTIONARY_ELEMENTS); |
| 2991 isolate()->counters()->map_fast_to_slow_elements()->Increment(); | 2991 isolate()->counters()->map_fast_to_slow_elements()->Increment(); |
| 2992 return new_map; | 2992 return new_map; |
| 2993 } | 2993 } |
| 2994 | 2994 |
| 2995 | 2995 |
| 2996 DescriptorArray* Map::instance_descriptors() { | 2996 DescriptorArray* Map::instance_descriptors() { |
| 2997 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); | 2997 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); |
| 2998 if (object->IsSmi()) { | 2998 if (object->IsSmi()) { |
| 2999 return HEAP->empty_descriptor_array(); | 2999 return HEAP->empty_descriptor_array(); |
| 3000 } else { | 3000 } else { |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3769 | 3769 |
| 3770 | 3770 |
| 3771 void JSRegExp::SetDataAt(int index, Object* value) { | 3771 void JSRegExp::SetDataAt(int index, Object* value) { |
| 3772 ASSERT(TypeTag() != NOT_COMPILED); | 3772 ASSERT(TypeTag() != NOT_COMPILED); |
| 3773 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. | 3773 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. |
| 3774 FixedArray::cast(data())->set(index, value); | 3774 FixedArray::cast(data())->set(index, value); |
| 3775 } | 3775 } |
| 3776 | 3776 |
| 3777 | 3777 |
| 3778 JSObject::ElementsKind JSObject::GetElementsKind() { | 3778 JSObject::ElementsKind JSObject::GetElementsKind() { |
| 3779 if (map()->has_fast_elements()) { | 3779 ElementsKind kind = map()->elements_kind(); |
| 3780 ASSERT(elements()->map() == GetHeap()->fixed_array_map() || | 3780 ASSERT((kind == FAST_ELEMENTS && |
| 3781 elements()->map() == GetHeap()->fixed_cow_array_map()); | 3781 (elements()->map() == GetHeap()->fixed_array_map() || |
| 3782 return FAST_ELEMENTS; | 3782 elements()->map() == GetHeap()->fixed_cow_array_map())) || |
| 3783 } | 3783 (kind == DICTIONARY_ELEMENTS && |
| 3784 HeapObject* array = elements(); | 3784 elements()->IsFixedArray() && |
| 3785 if (array->IsFixedArray()) { | 3785 elements()->IsDictionary()) || |
| 3786 // FAST_ELEMENTS or DICTIONARY_ELEMENTS are both stored in a | 3786 (kind > DICTIONARY_ELEMENTS)); |
| 3787 // FixedArray, but FAST_ELEMENTS is already handled above. | 3787 return kind; |
| 3788 ASSERT(array->IsDictionary()); | |
| 3789 return DICTIONARY_ELEMENTS; | |
| 3790 } | |
| 3791 ASSERT(!map()->has_fast_elements()); | |
| 3792 if (array->IsExternalArray()) { | |
| 3793 switch (array->map()->instance_type()) { | |
| 3794 case EXTERNAL_BYTE_ARRAY_TYPE: | |
| 3795 return EXTERNAL_BYTE_ELEMENTS; | |
| 3796 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: | |
| 3797 return EXTERNAL_UNSIGNED_BYTE_ELEMENTS; | |
| 3798 case EXTERNAL_SHORT_ARRAY_TYPE: | |
| 3799 return EXTERNAL_SHORT_ELEMENTS; | |
| 3800 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: | |
| 3801 return EXTERNAL_UNSIGNED_SHORT_ELEMENTS; | |
| 3802 case EXTERNAL_INT_ARRAY_TYPE: | |
| 3803 return EXTERNAL_INT_ELEMENTS; | |
| 3804 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: | |
| 3805 return EXTERNAL_UNSIGNED_INT_ELEMENTS; | |
| 3806 case EXTERNAL_FLOAT_ARRAY_TYPE: | |
| 3807 return EXTERNAL_FLOAT_ELEMENTS; | |
| 3808 case EXTERNAL_DOUBLE_ARRAY_TYPE: | |
| 3809 return EXTERNAL_DOUBLE_ELEMENTS; | |
| 3810 case EXTERNAL_PIXEL_ARRAY_TYPE: | |
| 3811 return EXTERNAL_PIXEL_ELEMENTS; | |
| 3812 default: | |
| 3813 break; | |
| 3814 } | |
| 3815 } | |
| 3816 UNREACHABLE(); | |
| 3817 return DICTIONARY_ELEMENTS; | |
| 3818 } | 3788 } |
| 3819 | 3789 |
| 3820 | 3790 |
| 3821 bool JSObject::HasFastElements() { | 3791 bool JSObject::HasFastElements() { |
| 3822 return GetElementsKind() == FAST_ELEMENTS; | 3792 return GetElementsKind() == FAST_ELEMENTS; |
| 3823 } | 3793 } |
| 3824 | 3794 |
| 3825 | 3795 |
| 3826 bool JSObject::HasDictionaryElements() { | 3796 bool JSObject::HasDictionaryElements() { |
| 3827 return GetElementsKind() == DICTIONARY_ELEMENTS; | 3797 return GetElementsKind() == DICTIONARY_ELEMENTS; |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4328 #undef WRITE_INT_FIELD | 4298 #undef WRITE_INT_FIELD |
| 4329 #undef READ_SHORT_FIELD | 4299 #undef READ_SHORT_FIELD |
| 4330 #undef WRITE_SHORT_FIELD | 4300 #undef WRITE_SHORT_FIELD |
| 4331 #undef READ_BYTE_FIELD | 4301 #undef READ_BYTE_FIELD |
| 4332 #undef WRITE_BYTE_FIELD | 4302 #undef WRITE_BYTE_FIELD |
| 4333 | 4303 |
| 4334 | 4304 |
| 4335 } } // namespace v8::internal | 4305 } } // namespace v8::internal |
| 4336 | 4306 |
| 4337 #endif // V8_OBJECTS_INL_H_ | 4307 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |