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 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 map()->has_fast_double_elements()); | 1446 map()->has_fast_double_elements()); |
1447 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 1447 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
1448 WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array()); | 1448 WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array()); |
1449 } | 1449 } |
1450 | 1450 |
1451 | 1451 |
1452 MaybeObject* JSObject::ResetElements() { | 1452 MaybeObject* JSObject::ResetElements() { |
1453 if (map()->is_observed()) { | 1453 if (map()->is_observed()) { |
1454 // Maintain invariant that observed elements are always in dictionary mode. | 1454 // Maintain invariant that observed elements are always in dictionary mode. |
1455 SeededNumberDictionary* dictionary; | 1455 SeededNumberDictionary* dictionary; |
1456 MaybeObject* maybe = SeededNumberDictionary::Allocate(0); | 1456 MaybeObject* maybe = SeededNumberDictionary::Allocate(GetHeap(), 0); |
1457 if (!maybe->To(&dictionary)) return maybe; | 1457 if (!maybe->To(&dictionary)) return maybe; |
1458 if (map() == GetHeap()->non_strict_arguments_elements_map()) { | 1458 if (map() == GetHeap()->non_strict_arguments_elements_map()) { |
1459 FixedArray::cast(elements())->set(1, dictionary); | 1459 FixedArray::cast(elements())->set(1, dictionary); |
1460 } else { | 1460 } else { |
1461 set_elements(dictionary); | 1461 set_elements(dictionary); |
1462 } | 1462 } |
1463 return this; | 1463 return this; |
1464 } | 1464 } |
1465 | 1465 |
1466 ElementsKind elements_kind = GetInitialFastElementsKind(); | 1466 ElementsKind elements_kind = GetInitialFastElementsKind(); |
(...skipping 4156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5623 return ComputeIntegerHash(key, seed); | 5623 return ComputeIntegerHash(key, seed); |
5624 } | 5624 } |
5625 | 5625 |
5626 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, | 5626 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, |
5627 uint32_t seed, | 5627 uint32_t seed, |
5628 Object* other) { | 5628 Object* other) { |
5629 ASSERT(other->IsNumber()); | 5629 ASSERT(other->IsNumber()); |
5630 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); | 5630 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); |
5631 } | 5631 } |
5632 | 5632 |
5633 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { | 5633 MaybeObject* NumberDictionaryShape::AsObject(Isolate* isolate, uint32_t key) { |
5634 return Isolate::Current()->heap()->NumberFromUint32(key); | 5634 return isolate->heap()->NumberFromUint32(key); |
5635 } | 5635 } |
5636 | 5636 |
5637 | 5637 |
5638 bool NameDictionaryShape::IsMatch(Name* key, Object* other) { | 5638 bool NameDictionaryShape::IsMatch(Name* key, Object* other) { |
5639 // We know that all entries in a hash table had their hash keys created. | 5639 // We know that all entries in a hash table had their hash keys created. |
5640 // Use that knowledge to have fast failure. | 5640 // Use that knowledge to have fast failure. |
5641 if (key->Hash() != Name::cast(other)->Hash()) return false; | 5641 if (key->Hash() != Name::cast(other)->Hash()) return false; |
5642 return key->Equals(Name::cast(other)); | 5642 return key->Equals(Name::cast(other)); |
5643 } | 5643 } |
5644 | 5644 |
5645 | 5645 |
5646 uint32_t NameDictionaryShape::Hash(Name* key) { | 5646 uint32_t NameDictionaryShape::Hash(Name* key) { |
5647 return key->Hash(); | 5647 return key->Hash(); |
5648 } | 5648 } |
5649 | 5649 |
5650 | 5650 |
5651 uint32_t NameDictionaryShape::HashForObject(Name* key, Object* other) { | 5651 uint32_t NameDictionaryShape::HashForObject(Name* key, Object* other) { |
5652 return Name::cast(other)->Hash(); | 5652 return Name::cast(other)->Hash(); |
5653 } | 5653 } |
5654 | 5654 |
5655 | 5655 |
5656 MaybeObject* NameDictionaryShape::AsObject(Name* key) { | 5656 MaybeObject* NameDictionaryShape::AsObject(Isolate* isolate, Name* key) { |
5657 return key; | 5657 return key; |
5658 } | 5658 } |
5659 | 5659 |
5660 | 5660 |
5661 template <int entrysize> | 5661 template <int entrysize> |
5662 bool ObjectHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { | 5662 bool ObjectHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { |
5663 return key->SameValue(other); | 5663 return key->SameValue(other); |
5664 } | 5664 } |
5665 | 5665 |
5666 | 5666 |
5667 template <int entrysize> | 5667 template <int entrysize> |
5668 uint32_t ObjectHashTableShape<entrysize>::Hash(Object* key) { | 5668 uint32_t ObjectHashTableShape<entrysize>::Hash(Object* key) { |
5669 MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION); | 5669 MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION); |
5670 return Smi::cast(maybe_hash->ToObjectChecked())->value(); | 5670 return Smi::cast(maybe_hash->ToObjectChecked())->value(); |
5671 } | 5671 } |
5672 | 5672 |
5673 | 5673 |
5674 template <int entrysize> | 5674 template <int entrysize> |
5675 uint32_t ObjectHashTableShape<entrysize>::HashForObject(Object* key, | 5675 uint32_t ObjectHashTableShape<entrysize>::HashForObject(Object* key, |
5676 Object* other) { | 5676 Object* other) { |
5677 MaybeObject* maybe_hash = other->GetHash(OMIT_CREATION); | 5677 MaybeObject* maybe_hash = other->GetHash(OMIT_CREATION); |
5678 return Smi::cast(maybe_hash->ToObjectChecked())->value(); | 5678 return Smi::cast(maybe_hash->ToObjectChecked())->value(); |
5679 } | 5679 } |
5680 | 5680 |
5681 | 5681 |
5682 template <int entrysize> | 5682 template <int entrysize> |
5683 MaybeObject* ObjectHashTableShape<entrysize>::AsObject(Object* key) { | 5683 MaybeObject* ObjectHashTableShape<entrysize>::AsObject(Isolate* isolate, |
| 5684 Object* key) { |
5684 return key; | 5685 return key; |
5685 } | 5686 } |
5686 | 5687 |
5687 | 5688 |
5688 void Map::ClearCodeCache(Heap* heap) { | 5689 void Map::ClearCodeCache(Heap* heap) { |
5689 // No write barrier is needed since empty_fixed_array is not in new space. | 5690 // No write barrier is needed since empty_fixed_array is not in new space. |
5690 // Please note this function is used during marking: | 5691 // Please note this function is used during marking: |
5691 // - MarkCompactCollector::MarkUnmarkedObject | 5692 // - MarkCompactCollector::MarkUnmarkedObject |
5692 // - IncrementalMarking::Step | 5693 // - IncrementalMarking::Step |
5693 ASSERT(!heap->InNewSpace(heap->empty_fixed_array())); | 5694 ASSERT(!heap->InNewSpace(heap->empty_fixed_array())); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5984 #undef WRITE_UINT32_FIELD | 5985 #undef WRITE_UINT32_FIELD |
5985 #undef READ_SHORT_FIELD | 5986 #undef READ_SHORT_FIELD |
5986 #undef WRITE_SHORT_FIELD | 5987 #undef WRITE_SHORT_FIELD |
5987 #undef READ_BYTE_FIELD | 5988 #undef READ_BYTE_FIELD |
5988 #undef WRITE_BYTE_FIELD | 5989 #undef WRITE_BYTE_FIELD |
5989 | 5990 |
5990 | 5991 |
5991 } } // namespace v8::internal | 5992 } } // namespace v8::internal |
5992 | 5993 |
5993 #endif // V8_OBJECTS_INL_H_ | 5994 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |