Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: src/objects-inl.h

Issue 6966041: Add complete ElementKind information directly to Map for objects with elements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: implement all platforms Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2953 } 2953 }
2954 2954
2955 2955
2956 MaybeObject* Map::GetFastElementsMap() { 2956 MaybeObject* Map::GetFastElementsMap() {
2957 if (has_fast_elements()) return this; 2957 if (has_fast_elements()) return this;
2958 Object* obj; 2958 Object* obj;
2959 { MaybeObject* maybe_obj = CopyDropTransitions(); 2959 { MaybeObject* maybe_obj = CopyDropTransitions();
2960 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2960 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2961 } 2961 }
2962 Map* new_map = Map::cast(obj); 2962 Map* new_map = Map::cast(obj);
2963 new_map->set_has_fast_elements(true); 2963 new_map->set_elements_kind(JSObject::FAST_ELEMENTS);
2964 isolate()->counters()->map_slow_to_fast_elements()->Increment(); 2964 isolate()->counters()->map_slow_to_fast_elements()->Increment();
2965 return new_map; 2965 return new_map;
2966 } 2966 }
2967 2967
2968 2968
2969 MaybeObject* Map::GetSlowElementsMap() { 2969 MaybeObject* Map::GetSlowElementsMap() {
2970 if (!has_fast_elements()) return this; 2970 if (!has_fast_elements()) return this;
2971 Object* obj; 2971 Object* obj;
2972 { MaybeObject* maybe_obj = CopyDropTransitions(); 2972 { MaybeObject* maybe_obj = CopyDropTransitions();
2973 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2973 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2974 } 2974 }
2975 Map* new_map = Map::cast(obj); 2975 Map* new_map = Map::cast(obj);
2976 new_map->set_has_fast_elements(false); 2976 new_map->set_elements_kind(JSObject::DICTIONARY_ELEMENTS);
2977 isolate()->counters()->map_fast_to_slow_elements()->Increment(); 2977 isolate()->counters()->map_fast_to_slow_elements()->Increment();
2978 return new_map; 2978 return new_map;
2979 } 2979 }
2980 2980
2981 2981
2982 DescriptorArray* Map::instance_descriptors() { 2982 DescriptorArray* Map::instance_descriptors() {
2983 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); 2983 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset);
2984 if (object->IsSmi()) { 2984 if (object->IsSmi()) {
2985 return HEAP->empty_descriptor_array(); 2985 return HEAP->empty_descriptor_array();
2986 } else { 2986 } else {
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
3755 3755
3756 3756
3757 void JSRegExp::SetDataAt(int index, Object* value) { 3757 void JSRegExp::SetDataAt(int index, Object* value) {
3758 ASSERT(TypeTag() != NOT_COMPILED); 3758 ASSERT(TypeTag() != NOT_COMPILED);
3759 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. 3759 ASSERT(index >= kDataIndex); // Only implementation data can be set this way.
3760 FixedArray::cast(data())->set(index, value); 3760 FixedArray::cast(data())->set(index, value);
3761 } 3761 }
3762 3762
3763 3763
3764 JSObject::ElementsKind JSObject::GetElementsKind() { 3764 JSObject::ElementsKind JSObject::GetElementsKind() {
3765 if (map()->has_fast_elements()) { 3765 ElementsKind kind = map()->elements_kind();
3766 ASSERT(elements()->map() == GetHeap()->fixed_array_map() || 3766 ASSERT((kind == FAST_ELEMENTS &&
3767 elements()->map() == GetHeap()->fixed_cow_array_map()); 3767 (elements()->map() == GetHeap()->fixed_array_map() ||
3768 return FAST_ELEMENTS; 3768 elements()->map() == GetHeap()->fixed_cow_array_map())) ||
3769 } 3769 (kind == DICTIONARY_ELEMENTS &&
3770 HeapObject* array = elements(); 3770 elements()->IsFixedArray() &&
3771 if (array->IsFixedArray()) { 3771 elements()->IsDictionary()) ||
3772 // FAST_ELEMENTS or DICTIONARY_ELEMENTS are both stored in a 3772 (kind > DICTIONARY_ELEMENTS));
3773 // FixedArray, but FAST_ELEMENTS is already handled above. 3773 return kind;
3774 ASSERT(array->IsDictionary());
3775 return DICTIONARY_ELEMENTS;
3776 }
3777 ASSERT(!map()->has_fast_elements());
3778 if (array->IsExternalArray()) {
3779 switch (array->map()->instance_type()) {
3780 case EXTERNAL_BYTE_ARRAY_TYPE:
3781 return EXTERNAL_BYTE_ELEMENTS;
3782 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
3783 return EXTERNAL_UNSIGNED_BYTE_ELEMENTS;
3784 case EXTERNAL_SHORT_ARRAY_TYPE:
3785 return EXTERNAL_SHORT_ELEMENTS;
3786 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
3787 return EXTERNAL_UNSIGNED_SHORT_ELEMENTS;
3788 case EXTERNAL_INT_ARRAY_TYPE:
3789 return EXTERNAL_INT_ELEMENTS;
3790 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
3791 return EXTERNAL_UNSIGNED_INT_ELEMENTS;
3792 case EXTERNAL_FLOAT_ARRAY_TYPE:
3793 return EXTERNAL_FLOAT_ELEMENTS;
3794 case EXTERNAL_DOUBLE_ARRAY_TYPE:
3795 return EXTERNAL_DOUBLE_ELEMENTS;
3796 case EXTERNAL_PIXEL_ARRAY_TYPE:
3797 return EXTERNAL_PIXEL_ELEMENTS;
3798 default:
3799 break;
3800 }
3801 }
3802 UNREACHABLE();
3803 return DICTIONARY_ELEMENTS;
3804 } 3774 }
3805 3775
3806 3776
3807 bool JSObject::HasFastElements() { 3777 bool JSObject::HasFastElements() {
3808 return GetElementsKind() == FAST_ELEMENTS; 3778 return GetElementsKind() == FAST_ELEMENTS;
3809 } 3779 }
3810 3780
3811 3781
3812 bool JSObject::HasDictionaryElements() { 3782 bool JSObject::HasDictionaryElements() {
3813 return GetElementsKind() == DICTIONARY_ELEMENTS; 3783 return GetElementsKind() == DICTIONARY_ELEMENTS;
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
4314 #undef WRITE_INT_FIELD 4284 #undef WRITE_INT_FIELD
4315 #undef READ_SHORT_FIELD 4285 #undef READ_SHORT_FIELD
4316 #undef WRITE_SHORT_FIELD 4286 #undef WRITE_SHORT_FIELD
4317 #undef READ_BYTE_FIELD 4287 #undef READ_BYTE_FIELD
4318 #undef WRITE_BYTE_FIELD 4288 #undef WRITE_BYTE_FIELD
4319 4289
4320 4290
4321 } } // namespace v8::internal 4291 } } // namespace v8::internal
4322 4292
4323 #endif // V8_OBJECTS_INL_H_ 4293 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/objects.h ('K') | « src/objects.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698