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 3241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3252 } | 3252 } |
3253 | 3253 |
3254 | 3254 |
3255 MaybeObject* Map::GetFastElementsMap() { | 3255 MaybeObject* Map::GetFastElementsMap() { |
3256 if (has_fast_elements()) return this; | 3256 if (has_fast_elements()) return this; |
3257 Object* obj; | 3257 Object* obj; |
3258 { MaybeObject* maybe_obj = CopyDropTransitions(); | 3258 { MaybeObject* maybe_obj = CopyDropTransitions(); |
3259 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3259 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
3260 } | 3260 } |
3261 Map* new_map = Map::cast(obj); | 3261 Map* new_map = Map::cast(obj); |
3262 new_map->set_elements_kind(JSObject::FAST_ELEMENTS); | 3262 new_map->set_elements_kind(FAST_ELEMENTS); |
3263 isolate()->counters()->map_to_fast_elements()->Increment(); | 3263 isolate()->counters()->map_to_fast_elements()->Increment(); |
3264 return new_map; | 3264 return new_map; |
3265 } | 3265 } |
3266 | 3266 |
3267 | 3267 |
3268 MaybeObject* Map::GetFastDoubleElementsMap() { | 3268 MaybeObject* Map::GetFastDoubleElementsMap() { |
3269 if (has_fast_double_elements()) return this; | 3269 if (has_fast_double_elements()) return this; |
3270 Object* obj; | 3270 Object* obj; |
3271 { MaybeObject* maybe_obj = CopyDropTransitions(); | 3271 { MaybeObject* maybe_obj = CopyDropTransitions(); |
3272 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3272 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
3273 } | 3273 } |
3274 Map* new_map = Map::cast(obj); | 3274 Map* new_map = Map::cast(obj); |
3275 new_map->set_elements_kind(JSObject::FAST_DOUBLE_ELEMENTS); | 3275 new_map->set_elements_kind(FAST_DOUBLE_ELEMENTS); |
3276 isolate()->counters()->map_to_fast_double_elements()->Increment(); | 3276 isolate()->counters()->map_to_fast_double_elements()->Increment(); |
3277 return new_map; | 3277 return new_map; |
3278 } | 3278 } |
3279 | 3279 |
3280 | 3280 |
3281 MaybeObject* Map::GetSlowElementsMap() { | 3281 MaybeObject* Map::GetSlowElementsMap() { |
3282 if (!has_fast_elements() && !has_fast_double_elements()) return this; | 3282 if (!has_fast_elements() && !has_fast_double_elements()) return this; |
3283 Object* obj; | 3283 Object* obj; |
3284 { MaybeObject* maybe_obj = CopyDropTransitions(); | 3284 { MaybeObject* maybe_obj = CopyDropTransitions(); |
3285 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3285 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
3286 } | 3286 } |
3287 Map* new_map = Map::cast(obj); | 3287 Map* new_map = Map::cast(obj); |
3288 new_map->set_elements_kind(JSObject::DICTIONARY_ELEMENTS); | 3288 new_map->set_elements_kind(DICTIONARY_ELEMENTS); |
3289 isolate()->counters()->map_to_slow_elements()->Increment(); | 3289 isolate()->counters()->map_to_slow_elements()->Increment(); |
3290 return new_map; | 3290 return new_map; |
3291 } | 3291 } |
3292 | 3292 |
3293 | 3293 |
3294 DescriptorArray* Map::instance_descriptors() { | 3294 DescriptorArray* Map::instance_descriptors() { |
3295 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); | 3295 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); |
3296 if (object->IsSmi()) { | 3296 if (object->IsSmi()) { |
3297 return HEAP->empty_descriptor_array(); | 3297 return HEAP->empty_descriptor_array(); |
3298 } else { | 3298 } else { |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4091 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. | 4091 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. |
4092 FixedArray* fa = reinterpret_cast<FixedArray*>(data()); | 4092 FixedArray* fa = reinterpret_cast<FixedArray*>(data()); |
4093 if (value->IsSmi()) { | 4093 if (value->IsSmi()) { |
4094 fa->set_unchecked(index, Smi::cast(value)); | 4094 fa->set_unchecked(index, Smi::cast(value)); |
4095 } else { | 4095 } else { |
4096 fa->set_unchecked(heap, index, value, SKIP_WRITE_BARRIER); | 4096 fa->set_unchecked(heap, index, value, SKIP_WRITE_BARRIER); |
4097 } | 4097 } |
4098 } | 4098 } |
4099 | 4099 |
4100 | 4100 |
4101 JSObject::ElementsKind JSObject::GetElementsKind() { | 4101 ElementsKind JSObject::GetElementsKind() { |
4102 ElementsKind kind = map()->elements_kind(); | 4102 ElementsKind kind = map()->elements_kind(); |
4103 ASSERT((kind == FAST_ELEMENTS && | 4103 ASSERT((kind == FAST_ELEMENTS && |
4104 (elements()->map() == GetHeap()->fixed_array_map() || | 4104 (elements()->map() == GetHeap()->fixed_array_map() || |
4105 elements()->map() == GetHeap()->fixed_cow_array_map())) || | 4105 elements()->map() == GetHeap()->fixed_cow_array_map())) || |
4106 (kind == FAST_DOUBLE_ELEMENTS && | 4106 (kind == FAST_DOUBLE_ELEMENTS && |
4107 elements()->IsFixedDoubleArray()) || | 4107 elements()->IsFixedDoubleArray()) || |
4108 (kind == DICTIONARY_ELEMENTS && | 4108 (kind == DICTIONARY_ELEMENTS && |
4109 elements()->IsFixedArray() && | 4109 elements()->IsFixedArray() && |
4110 elements()->IsDictionary()) || | 4110 elements()->IsDictionary()) || |
4111 (kind > DICTIONARY_ELEMENTS)); | 4111 (kind > DICTIONARY_ELEMENTS)); |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4685 #undef WRITE_INT_FIELD | 4685 #undef WRITE_INT_FIELD |
4686 #undef READ_SHORT_FIELD | 4686 #undef READ_SHORT_FIELD |
4687 #undef WRITE_SHORT_FIELD | 4687 #undef WRITE_SHORT_FIELD |
4688 #undef READ_BYTE_FIELD | 4688 #undef READ_BYTE_FIELD |
4689 #undef WRITE_BYTE_FIELD | 4689 #undef WRITE_BYTE_FIELD |
4690 | 4690 |
4691 | 4691 |
4692 } } // namespace v8::internal | 4692 } } // namespace v8::internal |
4693 | 4693 |
4694 #endif // V8_OBJECTS_INL_H_ | 4694 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |