| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4280 WRITE_FIELD(this, kBitField3Offset, Smi::FromInt(value >> 1)); | 4280 WRITE_FIELD(this, kBitField3Offset, Smi::FromInt(value >> 1)); |
| 4281 } | 4281 } |
| 4282 | 4282 |
| 4283 | 4283 |
| 4284 uint32_t Map::bit_field3() { | 4284 uint32_t Map::bit_field3() { |
| 4285 Object* value = READ_FIELD(this, kBitField3Offset); | 4285 Object* value = READ_FIELD(this, kBitField3Offset); |
| 4286 return Smi::cast(value)->value(); | 4286 return Smi::cast(value)->value(); |
| 4287 } | 4287 } |
| 4288 | 4288 |
| 4289 | 4289 |
| 4290 void Map::set_bit_field4(uint32_t bits) { |
| 4291 // Ensure the upper 2 bits have the same value by sign extending it. This is |
| 4292 // necessary to be able to use the 31st bit. |
| 4293 int value = bits << 1; |
| 4294 WRITE_FIELD(this, kBitField4Offset, Smi::FromInt(value >> 1)); |
| 4295 } |
| 4296 |
| 4297 |
| 4298 uint32_t Map::bit_field4() { |
| 4299 Object* value = READ_FIELD(this, kBitField4Offset); |
| 4300 return Smi::cast(value)->value(); |
| 4301 } |
| 4302 |
| 4303 |
| 4304 void Map::set_has_element_callbacks(bool value) { |
| 4305 set_bit_field4(HasElementCallbacks::update(bit_field4(), value)); |
| 4306 } |
| 4307 |
| 4308 |
| 4309 bool Map::has_element_callbacks() { |
| 4310 return HasElementCallbacks::decode(bit_field4()); |
| 4311 } |
| 4312 |
| 4313 |
| 4290 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) { | 4314 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) { |
| 4291 Object* back_pointer = GetBackPointer(); | 4315 Object* back_pointer = GetBackPointer(); |
| 4292 | 4316 |
| 4293 if (Heap::ShouldZapGarbage() && HasTransitionArray()) { | 4317 if (Heap::ShouldZapGarbage() && HasTransitionArray()) { |
| 4294 ZapTransitions(); | 4318 ZapTransitions(); |
| 4295 } | 4319 } |
| 4296 | 4320 |
| 4297 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, back_pointer); | 4321 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, back_pointer); |
| 4298 CONDITIONAL_WRITE_BARRIER( | 4322 CONDITIONAL_WRITE_BARRIER( |
| 4299 heap, this, kTransitionsOrBackPointerOffset, back_pointer, mode); | 4323 heap, this, kTransitionsOrBackPointerOffset, back_pointer, mode); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4319 return object; | 4343 return object; |
| 4320 } | 4344 } |
| 4321 } | 4345 } |
| 4322 | 4346 |
| 4323 | 4347 |
| 4324 bool Map::HasElementsTransition() { | 4348 bool Map::HasElementsTransition() { |
| 4325 return HasTransitionArray() && transitions()->HasElementsTransition(); | 4349 return HasTransitionArray() && transitions()->HasElementsTransition(); |
| 4326 } | 4350 } |
| 4327 | 4351 |
| 4328 | 4352 |
| 4353 bool Map::HasElementCallbacksTransition() { |
| 4354 return HasTransitionArray() && transitions()->HasElementCallbacksTransition(); |
| 4355 } |
| 4356 |
| 4357 |
| 4329 bool Map::HasTransitionArray() { | 4358 bool Map::HasTransitionArray() { |
| 4330 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); | 4359 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); |
| 4331 return object->IsTransitionArray(); | 4360 return object->IsTransitionArray(); |
| 4332 } | 4361 } |
| 4333 | 4362 |
| 4334 | 4363 |
| 4335 Map* Map::elements_transition_map() { | 4364 Map* Map::elements_transition_map() { |
| 4336 int index = transitions()->Search(GetHeap()->elements_transition_symbol()); | 4365 int index = transitions()->Search(GetHeap()->elements_transition_symbol()); |
| 4337 return transitions()->GetTarget(index); | 4366 return transitions()->GetTarget(index); |
| 4338 } | 4367 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4369 MaybeObject* maybe_transitions = AddTransition( | 4398 MaybeObject* maybe_transitions = AddTransition( |
| 4370 GetHeap()->elements_transition_symbol(), | 4399 GetHeap()->elements_transition_symbol(), |
| 4371 transitioned_map, | 4400 transitioned_map, |
| 4372 FULL_TRANSITION); | 4401 FULL_TRANSITION); |
| 4373 if (!maybe_transitions->To(&transitions)) return maybe_transitions; | 4402 if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
| 4374 set_transitions(transitions); | 4403 set_transitions(transitions); |
| 4375 return transitions; | 4404 return transitions; |
| 4376 } | 4405 } |
| 4377 | 4406 |
| 4378 | 4407 |
| 4408 MaybeObject* Map::set_element_callbacks_map(Map* callback_map) { |
| 4409 TransitionArray* transitions; |
| 4410 MaybeObject* maybe_transitions = AddTransition( |
| 4411 GetHeap()->element_callbacks_symbol(), |
| 4412 callback_map, |
| 4413 FULL_TRANSITION); |
| 4414 if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
| 4415 set_transitions(transitions); |
| 4416 return transitions; |
| 4417 } |
| 4418 |
| 4419 |
| 4379 FixedArray* Map::GetPrototypeTransitions() { | 4420 FixedArray* Map::GetPrototypeTransitions() { |
| 4380 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array(); | 4421 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array(); |
| 4381 if (!transitions()->HasPrototypeTransitions()) { | 4422 if (!transitions()->HasPrototypeTransitions()) { |
| 4382 return GetHeap()->empty_fixed_array(); | 4423 return GetHeap()->empty_fixed_array(); |
| 4383 } | 4424 } |
| 4384 return transitions()->GetPrototypeTransitions(); | 4425 return transitions()->GetPrototypeTransitions(); |
| 4385 } | 4426 } |
| 4386 | 4427 |
| 4387 | 4428 |
| 4388 MaybeObject* Map::SetPrototypeTransitions(FixedArray* proto_transitions) { | 4429 MaybeObject* Map::SetPrototypeTransitions(FixedArray* proto_transitions) { |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5577 bool JSObject::HasDictionaryElements() { | 5618 bool JSObject::HasDictionaryElements() { |
| 5578 return GetElementsKind() == DICTIONARY_ELEMENTS; | 5619 return GetElementsKind() == DICTIONARY_ELEMENTS; |
| 5579 } | 5620 } |
| 5580 | 5621 |
| 5581 | 5622 |
| 5582 bool JSObject::HasNonStrictArgumentsElements() { | 5623 bool JSObject::HasNonStrictArgumentsElements() { |
| 5583 return GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS; | 5624 return GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS; |
| 5584 } | 5625 } |
| 5585 | 5626 |
| 5586 | 5627 |
| 5628 bool JSObject::HasNonStrictArgumentsElementsMap() { |
| 5629 return elements()->map() == GetHeap()->non_strict_arguments_elements_map(); |
| 5630 } |
| 5631 |
| 5632 |
| 5633 |
| 5634 FixedArrayBase* JSObject::GetElements() { |
| 5635 // Find the backing store. |
| 5636 FixedArrayBase* array = FixedArrayBase::cast(elements()); |
| 5637 if (HasNonStrictArgumentsElementsMap()) { |
| 5638 array = FixedArrayBase::cast(FixedArray::cast(array)->get(1)); |
| 5639 } |
| 5640 return array; |
| 5641 } |
| 5642 |
| 5643 |
| 5587 bool JSObject::HasExternalArrayElements() { | 5644 bool JSObject::HasExternalArrayElements() { |
| 5588 HeapObject* array = elements(); | 5645 HeapObject* array = elements(); |
| 5589 ASSERT(array != NULL); | 5646 ASSERT(array != NULL); |
| 5590 return array->IsExternalArray(); | 5647 return array->IsExternalArray(); |
| 5591 } | 5648 } |
| 5592 | 5649 |
| 5593 | 5650 |
| 5594 #define EXTERNAL_ELEMENTS_CHECK(name, type) \ | 5651 #define EXTERNAL_ELEMENTS_CHECK(name, type) \ |
| 5595 bool JSObject::HasExternal##name##Elements() { \ | 5652 bool JSObject::HasExternal##name##Elements() { \ |
| 5596 HeapObject* array = elements(); \ | 5653 HeapObject* array = elements(); \ |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6398 #undef WRITE_UINT32_FIELD | 6455 #undef WRITE_UINT32_FIELD |
| 6399 #undef READ_SHORT_FIELD | 6456 #undef READ_SHORT_FIELD |
| 6400 #undef WRITE_SHORT_FIELD | 6457 #undef WRITE_SHORT_FIELD |
| 6401 #undef READ_BYTE_FIELD | 6458 #undef READ_BYTE_FIELD |
| 6402 #undef WRITE_BYTE_FIELD | 6459 #undef WRITE_BYTE_FIELD |
| 6403 | 6460 |
| 6404 | 6461 |
| 6405 } } // namespace v8::internal | 6462 } } // namespace v8::internal |
| 6406 | 6463 |
| 6407 #endif // V8_OBJECTS_INL_H_ | 6464 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |