| 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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 | 885 |
| 886 bool Object::HasSpecificClassOf(String* name) { | 886 bool Object::HasSpecificClassOf(String* name) { |
| 887 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); | 887 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); |
| 888 } | 888 } |
| 889 | 889 |
| 890 | 890 |
| 891 MaybeObject* Object::GetElement(uint32_t index) { | 891 MaybeObject* Object::GetElement(uint32_t index) { |
| 892 // GetElement can trigger a getter which can cause allocation. | 892 // GetElement can trigger a getter which can cause allocation. |
| 893 // This was not always the case. This ASSERT is here to catch | 893 // This was not always the case. This ASSERT is here to catch |
| 894 // leftover incorrect uses. | 894 // leftover incorrect uses. |
| 895 ASSERT(HEAP->IsAllocationAllowed()); | 895 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 896 return GetElementWithReceiver(this, index); | 896 return GetElementWithReceiver(this, index); |
| 897 } | 897 } |
| 898 | 898 |
| 899 | 899 |
| 900 Object* Object::GetElementNoExceptionThrown(uint32_t index) { | 900 Object* Object::GetElementNoExceptionThrown(uint32_t index) { |
| 901 MaybeObject* maybe = GetElementWithReceiver(this, index); | 901 MaybeObject* maybe = GetElementWithReceiver(this, index); |
| 902 ASSERT(!maybe->IsFailure()); | 902 ASSERT(!maybe->IsFailure()); |
| 903 Object* result = NULL; // Initialization to please compiler. | 903 Object* result = NULL; // Initialization to please compiler. |
| 904 maybe->ToObject(&result); | 904 maybe->ToObject(&result); |
| 905 return result; | 905 return result; |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 | 1543 |
| 1544 | 1544 |
| 1545 MaybeObject* JSObject::TryMigrateInstance() { | 1545 MaybeObject* JSObject::TryMigrateInstance() { |
| 1546 Map* new_map = map()->CurrentMapForDeprecated(); | 1546 Map* new_map = map()->CurrentMapForDeprecated(); |
| 1547 if (new_map == NULL) return Smi::FromInt(0); | 1547 if (new_map == NULL) return Smi::FromInt(0); |
| 1548 return MigrateToMap(new_map); | 1548 return MigrateToMap(new_map); |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 | 1551 |
| 1552 Handle<String> JSObject::ExpectedTransitionKey(Handle<Map> map) { | 1552 Handle<String> JSObject::ExpectedTransitionKey(Handle<Map> map) { |
| 1553 AssertNoAllocation no_gc; | 1553 DisallowHeapAllocation no_gc; |
| 1554 if (!map->HasTransitionArray()) return Handle<String>::null(); | 1554 if (!map->HasTransitionArray()) return Handle<String>::null(); |
| 1555 TransitionArray* transitions = map->transitions(); | 1555 TransitionArray* transitions = map->transitions(); |
| 1556 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); | 1556 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); |
| 1557 int transition = TransitionArray::kSimpleTransitionIndex; | 1557 int transition = TransitionArray::kSimpleTransitionIndex; |
| 1558 PropertyDetails details = transitions->GetTargetDetails(transition); | 1558 PropertyDetails details = transitions->GetTargetDetails(transition); |
| 1559 Name* name = transitions->GetKey(transition); | 1559 Name* name = transitions->GetKey(transition); |
| 1560 if (details.type() != FIELD) return Handle<String>::null(); | 1560 if (details.type() != FIELD) return Handle<String>::null(); |
| 1561 if (details.attributes() != NONE) return Handle<String>::null(); | 1561 if (details.attributes() != NONE) return Handle<String>::null(); |
| 1562 if (!name->IsString()) return Handle<String>::null(); | 1562 if (!name->IsString()) return Handle<String>::null(); |
| 1563 return Handle<String>(String::cast(name)); | 1563 return Handle<String>(String::cast(name)); |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 | 1566 |
| 1567 Handle<Map> JSObject::ExpectedTransitionTarget(Handle<Map> map) { | 1567 Handle<Map> JSObject::ExpectedTransitionTarget(Handle<Map> map) { |
| 1568 ASSERT(!ExpectedTransitionKey(map).is_null()); | 1568 ASSERT(!ExpectedTransitionKey(map).is_null()); |
| 1569 return Handle<Map>(map->transitions()->GetTarget( | 1569 return Handle<Map>(map->transitions()->GetTarget( |
| 1570 TransitionArray::kSimpleTransitionIndex)); | 1570 TransitionArray::kSimpleTransitionIndex)); |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 | 1573 |
| 1574 Handle<Map> JSObject::FindTransitionToField(Handle<Map> map, Handle<Name> key) { | 1574 Handle<Map> JSObject::FindTransitionToField(Handle<Map> map, Handle<Name> key) { |
| 1575 AssertNoAllocation no_allocation; | 1575 DisallowHeapAllocation no_allocation; |
| 1576 if (!map->HasTransitionArray()) return Handle<Map>::null(); | 1576 if (!map->HasTransitionArray()) return Handle<Map>::null(); |
| 1577 TransitionArray* transitions = map->transitions(); | 1577 TransitionArray* transitions = map->transitions(); |
| 1578 int transition = transitions->Search(*key); | 1578 int transition = transitions->Search(*key); |
| 1579 if (transition == TransitionArray::kNotFound) return Handle<Map>::null(); | 1579 if (transition == TransitionArray::kNotFound) return Handle<Map>::null(); |
| 1580 PropertyDetails target_details = transitions->GetTargetDetails(transition); | 1580 PropertyDetails target_details = transitions->GetTargetDetails(transition); |
| 1581 if (target_details.type() != FIELD) return Handle<Map>::null(); | 1581 if (target_details.type() != FIELD) return Handle<Map>::null(); |
| 1582 if (target_details.attributes() != NONE) return Handle<Map>::null(); | 1582 if (target_details.attributes() != NONE) return Handle<Map>::null(); |
| 1583 return Handle<Map>(transitions->GetTarget(transition)); | 1583 return Handle<Map>(transitions->GetTarget(transition)); |
| 1584 } | 1584 } |
| 1585 | 1585 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | 1977 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); |
| 1978 } | 1978 } |
| 1979 | 1979 |
| 1980 | 1980 |
| 1981 bool FixedDoubleArray::is_the_hole(int index) { | 1981 bool FixedDoubleArray::is_the_hole(int index) { |
| 1982 int offset = kHeaderSize + index * kDoubleSize; | 1982 int offset = kHeaderSize + index * kDoubleSize; |
| 1983 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); | 1983 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 | 1986 |
| 1987 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { | 1987 WriteBarrierMode HeapObject::GetWriteBarrierMode( |
| 1988 const DisallowHeapAllocation& promise) { |
| 1988 Heap* heap = GetHeap(); | 1989 Heap* heap = GetHeap(); |
| 1989 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; | 1990 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; |
| 1990 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 1991 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; |
| 1991 return UPDATE_WRITE_BARRIER; | 1992 return UPDATE_WRITE_BARRIER; |
| 1992 } | 1993 } |
| 1993 | 1994 |
| 1994 | 1995 |
| 1995 void FixedArray::set(int index, | 1996 void FixedArray::set(int index, |
| 1996 Object* value, | 1997 Object* value, |
| 1997 WriteBarrierMode mode) { | 1998 WriteBarrierMode mode) { |
| (...skipping 3821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5819 | 5820 |
| 5820 template<typename Shape, typename Key> | 5821 template<typename Shape, typename Key> |
| 5821 void Dictionary<Shape, Key>::SetEntry(int entry, | 5822 void Dictionary<Shape, Key>::SetEntry(int entry, |
| 5822 Object* key, | 5823 Object* key, |
| 5823 Object* value, | 5824 Object* value, |
| 5824 PropertyDetails details) { | 5825 PropertyDetails details) { |
| 5825 ASSERT(!key->IsName() || | 5826 ASSERT(!key->IsName() || |
| 5826 details.IsDeleted() || | 5827 details.IsDeleted() || |
| 5827 details.dictionary_index() > 0); | 5828 details.dictionary_index() > 0); |
| 5828 int index = HashTable<Shape, Key>::EntryToIndex(entry); | 5829 int index = HashTable<Shape, Key>::EntryToIndex(entry); |
| 5829 AssertNoAllocation no_gc; | 5830 DisallowHeapAllocation no_gc; |
| 5830 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | 5831 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
| 5831 FixedArray::set(index, key, mode); | 5832 FixedArray::set(index, key, mode); |
| 5832 FixedArray::set(index+1, value, mode); | 5833 FixedArray::set(index+1, value, mode); |
| 5833 FixedArray::set(index+2, details.AsSmi()); | 5834 FixedArray::set(index+2, details.AsSmi()); |
| 5834 } | 5835 } |
| 5835 | 5836 |
| 5836 | 5837 |
| 5837 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 5838 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
| 5838 ASSERT(other->IsNumber()); | 5839 ASSERT(other->IsNumber()); |
| 5839 return key == static_cast<uint32_t>(other->Number()); | 5840 return key == static_cast<uint32_t>(other->Number()); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6217 #undef WRITE_UINT32_FIELD | 6218 #undef WRITE_UINT32_FIELD |
| 6218 #undef READ_SHORT_FIELD | 6219 #undef READ_SHORT_FIELD |
| 6219 #undef WRITE_SHORT_FIELD | 6220 #undef WRITE_SHORT_FIELD |
| 6220 #undef READ_BYTE_FIELD | 6221 #undef READ_BYTE_FIELD |
| 6221 #undef WRITE_BYTE_FIELD | 6222 #undef WRITE_BYTE_FIELD |
| 6222 | 6223 |
| 6223 | 6224 |
| 6224 } } // namespace v8::internal | 6225 } } // namespace v8::internal |
| 6225 | 6226 |
| 6226 #endif // V8_OBJECTS_INL_H_ | 6227 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |