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 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 | 1421 |
1422 void JSObject::initialize_elements() { | 1422 void JSObject::initialize_elements() { |
1423 ASSERT(map()->has_fast_elements()); | 1423 ASSERT(map()->has_fast_elements()); |
1424 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 1424 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
1425 WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array()); | 1425 WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array()); |
1426 } | 1426 } |
1427 | 1427 |
1428 | 1428 |
1429 MaybeObject* JSObject::ResetElements() { | 1429 MaybeObject* JSObject::ResetElements() { |
1430 Object* obj; | 1430 Object* obj; |
1431 { MaybeObject* maybe_obj = map()->GetFastElementsMap(); | 1431 { MaybeObject* maybe_obj = GetElementsTransitionMap(FAST_ELEMENTS); |
1432 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1432 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
1433 } | 1433 } |
1434 set_map(Map::cast(obj)); | 1434 set_map(Map::cast(obj)); |
1435 initialize_elements(); | 1435 initialize_elements(); |
1436 return this; | 1436 return this; |
1437 } | 1437 } |
1438 | 1438 |
1439 | 1439 |
1440 ACCESSORS(Oddball, to_string, String, kToStringOffset) | 1440 ACCESSORS(Oddball, to_string, String, kToStringOffset) |
1441 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) | 1441 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) |
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 } | 3235 } |
3236 | 3236 |
3237 | 3237 |
3238 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 3238 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
3239 ASSERT(value->IsNull() || value->IsJSReceiver()); | 3239 ASSERT(value->IsNull() || value->IsJSReceiver()); |
3240 WRITE_FIELD(this, kPrototypeOffset, value); | 3240 WRITE_FIELD(this, kPrototypeOffset, value); |
3241 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, mode); | 3241 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, mode); |
3242 } | 3242 } |
3243 | 3243 |
3244 | 3244 |
3245 MaybeObject* Map::GetFastElementsMap() { | |
3246 if (has_fast_elements()) return this; | |
3247 Object* obj; | |
3248 { MaybeObject* maybe_obj = CopyDropTransitions(); | |
3249 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
3250 } | |
3251 Map* new_map = Map::cast(obj); | |
3252 new_map->set_elements_kind(FAST_ELEMENTS); | |
3253 isolate()->counters()->map_to_fast_elements()->Increment(); | |
3254 return new_map; | |
3255 } | |
3256 | |
3257 | |
3258 MaybeObject* Map::GetFastDoubleElementsMap() { | |
3259 if (has_fast_double_elements()) return this; | |
3260 Object* obj; | |
3261 { MaybeObject* maybe_obj = CopyDropTransitions(); | |
3262 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
3263 } | |
3264 Map* new_map = Map::cast(obj); | |
3265 new_map->set_elements_kind(FAST_DOUBLE_ELEMENTS); | |
3266 isolate()->counters()->map_to_fast_double_elements()->Increment(); | |
3267 return new_map; | |
3268 } | |
3269 | |
3270 | |
3271 MaybeObject* Map::GetSlowElementsMap() { | |
3272 if (!has_fast_elements() && !has_fast_double_elements()) return this; | |
3273 Object* obj; | |
3274 { MaybeObject* maybe_obj = CopyDropTransitions(); | |
3275 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
3276 } | |
3277 Map* new_map = Map::cast(obj); | |
3278 new_map->set_elements_kind(DICTIONARY_ELEMENTS); | |
3279 isolate()->counters()->map_to_slow_elements()->Increment(); | |
3280 return new_map; | |
3281 } | |
3282 | |
3283 | |
3284 DescriptorArray* Map::instance_descriptors() { | 3245 DescriptorArray* Map::instance_descriptors() { |
3285 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); | 3246 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); |
3286 if (object->IsSmi()) { | 3247 if (object->IsSmi()) { |
3287 return HEAP->empty_descriptor_array(); | 3248 return HEAP->empty_descriptor_array(); |
3288 } else { | 3249 } else { |
3289 return DescriptorArray::cast(object); | 3250 return DescriptorArray::cast(object); |
3290 } | 3251 } |
3291 } | 3252 } |
3292 | 3253 |
3293 | 3254 |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4682 #undef WRITE_INT_FIELD | 4643 #undef WRITE_INT_FIELD |
4683 #undef READ_SHORT_FIELD | 4644 #undef READ_SHORT_FIELD |
4684 #undef WRITE_SHORT_FIELD | 4645 #undef WRITE_SHORT_FIELD |
4685 #undef READ_BYTE_FIELD | 4646 #undef READ_BYTE_FIELD |
4686 #undef WRITE_BYTE_FIELD | 4647 #undef WRITE_BYTE_FIELD |
4687 | 4648 |
4688 | 4649 |
4689 } } // namespace v8::internal | 4650 } } // namespace v8::internal |
4690 | 4651 |
4691 #endif // V8_OBJECTS_INL_H_ | 4652 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |