Commit 5aaccdcf authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[cleanup] Make Hashtable Shapes return Map Handles

Make Hashtable Shapes return Map Handles (from the read-only roots)
instead of the root index of the Map, so that they can be used off
the main thread.

Bug: chromium:1011762
Change-Id: I4c0a8518dc1c6d490b5c04da05b5319081a6fae5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2083298
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66569}
parent 27538aa3
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "src/objects/hash-table-inl.h" #include "src/objects/hash-table-inl.h"
#include "src/objects/js-collection.h" #include "src/objects/js-collection.h"
#include "src/objects/ordered-hash-table.h" #include "src/objects/ordered-hash-table.h"
#include "src/roots/roots.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -2508,8 +2509,9 @@ TNode<HeapObject> WeakCollectionsBuiltinsAssembler::AllocateTable( ...@@ -2508,8 +2509,9 @@ TNode<HeapObject> WeakCollectionsBuiltinsAssembler::AllocateTable(
TNode<FixedArray> table = CAST( TNode<FixedArray> table = CAST(
AllocateFixedArray(HOLEY_ELEMENTS, length, kAllowLargeObjectAllocation)); AllocateFixedArray(HOLEY_ELEMENTS, length, kAllowLargeObjectAllocation));
RootIndex map_root_index = EphemeronHashTableShape::GetMapRootIndex(); TNode<Map> map =
StoreMapNoWriteBarrier(table, map_root_index); HeapConstant(EphemeronHashTableShape::GetMap(ReadOnlyRoots(isolate())));
StoreMapNoWriteBarrier(table, map);
StoreFixedArrayElement(table, EphemeronHashTable::kNumberOfElementsIndex, StoreFixedArrayElement(table, EphemeronHashTable::kNumberOfElementsIndex,
SmiConstant(0), SKIP_WRITE_BARRIER); SmiConstant(0), SKIP_WRITE_BARRIER);
StoreFixedArrayElement(table, StoreFixedArrayElement(table,
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "src/objects/oddball.h" #include "src/objects/oddball.h"
#include "src/objects/ordered-hash-table-inl.h" #include "src/objects/ordered-hash-table-inl.h"
#include "src/objects/property-cell.h" #include "src/objects/property-cell.h"
#include "src/roots/roots.h"
#include "src/wasm/wasm-objects.h" #include "src/wasm/wasm-objects.h"
namespace v8 { namespace v8 {
...@@ -3374,7 +3375,6 @@ TNode<String> CodeStubAssembler::AllocateSlicedTwoByteString( ...@@ -3374,7 +3375,6 @@ TNode<String> CodeStubAssembler::AllocateSlicedTwoByteString(
offset); offset);
} }
TNode<NameDictionary> CodeStubAssembler::AllocateNameDictionary( TNode<NameDictionary> CodeStubAssembler::AllocateNameDictionary(
int at_least_space_for) { int at_least_space_for) {
return AllocateNameDictionary(IntPtrConstant(at_least_space_for)); return AllocateNameDictionary(IntPtrConstant(at_least_space_for));
...@@ -3479,7 +3479,7 @@ TNode<CollectionType> CodeStubAssembler::AllocateOrderedHashTable() { ...@@ -3479,7 +3479,7 @@ TNode<CollectionType> CodeStubAssembler::AllocateOrderedHashTable() {
const ElementsKind elements_kind = HOLEY_ELEMENTS; const ElementsKind elements_kind = HOLEY_ELEMENTS;
TNode<IntPtrT> length_intptr = IntPtrConstant(kFixedArrayLength); TNode<IntPtrT> length_intptr = IntPtrConstant(kFixedArrayLength);
TNode<Map> fixed_array_map = TNode<Map> fixed_array_map =
CAST(LoadRoot(CollectionType::GetMapRootIndex())); HeapConstant(CollectionType::GetMap(ReadOnlyRoots(isolate())));
TNode<CollectionType> table = TNode<CollectionType> table =
CAST(AllocateFixedArray(elements_kind, length_intptr, CAST(AllocateFixedArray(elements_kind, length_intptr,
kAllowLargeObjectAllocation, fixed_array_map)); kAllowLargeObjectAllocation, fixed_array_map));
......
...@@ -60,19 +60,19 @@ Handle<FixedArray> FactoryBase<Impl>::NewFixedArray(int length, ...@@ -60,19 +60,19 @@ Handle<FixedArray> FactoryBase<Impl>::NewFixedArray(int length,
AllocationType allocation) { AllocationType allocation) {
DCHECK_LE(0, length); DCHECK_LE(0, length);
if (length == 0) return impl()->empty_fixed_array(); if (length == 0) return impl()->empty_fixed_array();
return NewFixedArrayWithFiller(read_only_roots().fixed_array_map(), length, return NewFixedArrayWithFiller(
read_only_roots().undefined_value(), read_only_roots().fixed_array_map_handle(), length,
allocation); read_only_roots().undefined_value_handle(), allocation);
} }
template <typename Impl> template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithMap( Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithMap(
Map map, int length, AllocationType allocation) { Handle<Map> map, int length, AllocationType allocation) {
// Zero-length case must be handled outside, where the knowledge about // Zero-length case must be handled outside, where the knowledge about
// the map is. // the map is.
DCHECK_LT(0, length); DCHECK_LT(0, length);
return NewFixedArrayWithFiller( return NewFixedArrayWithFiller(
map, length, read_only_roots().undefined_value(), allocation); map, length, read_only_roots().undefined_value_handle(), allocation);
} }
template <typename Impl> template <typename Impl>
...@@ -80,21 +80,22 @@ Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithHoles( ...@@ -80,21 +80,22 @@ Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithHoles(
int length, AllocationType allocation) { int length, AllocationType allocation) {
DCHECK_LE(0, length); DCHECK_LE(0, length);
if (length == 0) return impl()->empty_fixed_array(); if (length == 0) return impl()->empty_fixed_array();
return NewFixedArrayWithFiller(read_only_roots().fixed_array_map(), length, return NewFixedArrayWithFiller(
read_only_roots().the_hole_value(), read_only_roots().fixed_array_map_handle(), length,
allocation); read_only_roots().the_hole_value_handle(), allocation);
} }
template <typename Impl> template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithFiller( Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithFiller(
Map map, int length, Oddball filler, AllocationType allocation) { Handle<Map> map, int length, Handle<Oddball> filler,
AllocationType allocation) {
HeapObject result = AllocateRawFixedArray(length, allocation); HeapObject result = AllocateRawFixedArray(length, allocation);
DCHECK(ReadOnlyHeap::Contains(map)); DCHECK(ReadOnlyHeap::Contains(*map));
DCHECK(ReadOnlyHeap::Contains(filler)); DCHECK(ReadOnlyHeap::Contains(*filler));
result.set_map_after_allocation(map, SKIP_WRITE_BARRIER); result.set_map_after_allocation(*map, SKIP_WRITE_BARRIER);
Handle<FixedArray> array = handle(FixedArray::cast(result), isolate()); Handle<FixedArray> array = handle(FixedArray::cast(result), isolate());
array->set_length(length); array->set_length(length);
MemsetTagged(array->data_start(), filler, length); MemsetTagged(array->data_start(), *filler, length);
return array; return array;
} }
...@@ -352,7 +353,7 @@ FactoryBase<Impl>::NewObjectBoilerplateDescription(int boilerplate, ...@@ -352,7 +353,7 @@ FactoryBase<Impl>::NewObjectBoilerplateDescription(int boilerplate,
Handle<ObjectBoilerplateDescription> description = Handle<ObjectBoilerplateDescription> description =
Handle<ObjectBoilerplateDescription>::cast(NewFixedArrayWithMap( Handle<ObjectBoilerplateDescription>::cast(NewFixedArrayWithMap(
read_only_roots().object_boilerplate_description_map(), size, read_only_roots().object_boilerplate_description_map_handle(), size,
AllocationType::kOld)); AllocationType::kOld));
if (has_different_size_backing_store) { if (has_different_size_backing_store) {
...@@ -605,14 +606,14 @@ template <typename Impl> ...@@ -605,14 +606,14 @@ template <typename Impl>
Handle<ScopeInfo> FactoryBase<Impl>::NewScopeInfo(int length, Handle<ScopeInfo> FactoryBase<Impl>::NewScopeInfo(int length,
AllocationType type) { AllocationType type) {
DCHECK(type == AllocationType::kOld || type == AllocationType::kReadOnly); DCHECK(type == AllocationType::kOld || type == AllocationType::kReadOnly);
return Handle<ScopeInfo>::cast( return Handle<ScopeInfo>::cast(NewFixedArrayWithMap(
NewFixedArrayWithMap(read_only_roots().scope_info_map(), length, type)); read_only_roots().scope_info_map_handle(), length, type));
} }
template <typename Impl> template <typename Impl>
Handle<SourceTextModuleInfo> FactoryBase<Impl>::NewSourceTextModuleInfo() { Handle<SourceTextModuleInfo> FactoryBase<Impl>::NewSourceTextModuleInfo() {
return Handle<SourceTextModuleInfo>::cast(NewFixedArrayWithMap( return Handle<SourceTextModuleInfo>::cast(NewFixedArrayWithMap(
read_only_roots().module_info_map(), SourceTextModuleInfo::kLength, read_only_roots().module_info_map_handle(), SourceTextModuleInfo::kLength,
AllocationType::kOld)); AllocationType::kOld));
} }
......
...@@ -71,7 +71,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase { ...@@ -71,7 +71,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
// Allocates a fixed array-like object with given map and initialized with // Allocates a fixed array-like object with given map and initialized with
// undefined values. // undefined values.
Handle<FixedArray> NewFixedArrayWithMap( Handle<FixedArray> NewFixedArrayWithMap(
Map map, int length, AllocationType allocation = AllocationType::kYoung); Handle<Map> map, int length,
AllocationType allocation = AllocationType::kYoung);
// Allocate a new fixed array with non-existing entries (the hole). // Allocate a new fixed array with non-existing entries (the hole).
Handle<FixedArray> NewFixedArrayWithHoles( Handle<FixedArray> NewFixedArrayWithHoles(
...@@ -185,8 +186,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase { ...@@ -185,8 +186,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
AllocationAlignment alignment = kWordAligned); AllocationAlignment alignment = kWordAligned);
HeapObject NewWithImmortalMap(Map map, AllocationType allocation); HeapObject NewWithImmortalMap(Map map, AllocationType allocation);
Handle<FixedArray> NewFixedArrayWithFiller(Map map, int length, Handle<FixedArray> NewFixedArrayWithFiller(Handle<Map> map, int length,
Oddball filler, Handle<Oddball> filler,
AllocationType allocation); AllocationType allocation);
Handle<SharedFunctionInfo> NewSharedFunctionInfo(); Handle<SharedFunctionInfo> NewSharedFunctionInfo();
......
...@@ -334,12 +334,6 @@ Handle<PropertyArray> Factory::NewPropertyArray(int length) { ...@@ -334,12 +334,6 @@ Handle<PropertyArray> Factory::NewPropertyArray(int length) {
return array; return array;
} }
Handle<FixedArray> Factory::NewFixedArrayWithMapRootIndex(
RootIndex map_root_index, int length, AllocationType allocation) {
return NewFixedArrayWithMap(Map::cast(isolate()->root(map_root_index)),
length, allocation);
}
MaybeHandle<FixedArray> Factory::TryNewFixedArray( MaybeHandle<FixedArray> Factory::TryNewFixedArray(
int length, AllocationType allocation_type) { int length, AllocationType allocation_type) {
DCHECK_LE(0, length); DCHECK_LE(0, length);
...@@ -371,8 +365,9 @@ Handle<FixedArray> Factory::NewUninitializedFixedArray(int length) { ...@@ -371,8 +365,9 @@ Handle<FixedArray> Factory::NewUninitializedFixedArray(int length) {
// TODO(ulan): As an experiment this temporarily returns an initialized fixed // TODO(ulan): As an experiment this temporarily returns an initialized fixed
// array. After getting canary/performance coverage, either remove the // array. After getting canary/performance coverage, either remove the
// function or revert to returning uninitilized array. // function or revert to returning uninitilized array.
return NewFixedArrayWithFiller(read_only_roots().fixed_array_map(), length, return NewFixedArrayWithFiller(read_only_roots().fixed_array_map_handle(),
*undefined_value(), AllocationType::kYoung); length, undefined_value(),
AllocationType::kYoung);
} }
Handle<ClosureFeedbackCellArray> Factory::NewClosureFeedbackCellArray( Handle<ClosureFeedbackCellArray> Factory::NewClosureFeedbackCellArray(
...@@ -381,7 +376,7 @@ Handle<ClosureFeedbackCellArray> Factory::NewClosureFeedbackCellArray( ...@@ -381,7 +376,7 @@ Handle<ClosureFeedbackCellArray> Factory::NewClosureFeedbackCellArray(
Handle<ClosureFeedbackCellArray> feedback_cell_array = Handle<ClosureFeedbackCellArray> feedback_cell_array =
Handle<ClosureFeedbackCellArray>::cast(NewFixedArrayWithMap( Handle<ClosureFeedbackCellArray>::cast(NewFixedArrayWithMap(
read_only_roots().closure_feedback_cell_array_map(), length, read_only_roots().closure_feedback_cell_array_map_handle(), length,
AllocationType::kOld)); AllocationType::kOld));
return feedback_cell_array; return feedback_cell_array;
...@@ -1083,7 +1078,7 @@ Handle<Context> Factory::NewScriptContext(Handle<NativeContext> outer, ...@@ -1083,7 +1078,7 @@ Handle<Context> Factory::NewScriptContext(Handle<NativeContext> outer,
Handle<ScriptContextTable> Factory::NewScriptContextTable() { Handle<ScriptContextTable> Factory::NewScriptContextTable() {
Handle<ScriptContextTable> context_table = Handle<ScriptContextTable>::cast( Handle<ScriptContextTable> context_table = Handle<ScriptContextTable>::cast(
NewFixedArrayWithMap(read_only_roots().script_context_table_map(), NewFixedArrayWithMap(read_only_roots().script_context_table_map_handle(),
ScriptContextTable::kMinLength)); ScriptContextTable::kMinLength));
context_table->set_used(0); context_table->set_used(0);
return context_table; return context_table;
......
...@@ -110,12 +110,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> { ...@@ -110,12 +110,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
// Marks self references within code generation. // Marks self references within code generation.
Handle<Oddball> NewSelfReferenceMarker(); Handle<Oddball> NewSelfReferenceMarker();
// Allocates a fixed array-like object with given map and initialized with
// undefined values.
Handle<FixedArray> NewFixedArrayWithMapRootIndex(
RootIndex map_root_index, int length,
AllocationType allocation = AllocationType::kYoung);
// Allocates a property array initialized with undefined values. // Allocates a property array initialized with undefined values.
Handle<PropertyArray> NewPropertyArray(int length); Handle<PropertyArray> NewPropertyArray(int length);
// Tries allocating a fixed array initialized with undefined values. // Tries allocating a fixed array initialized with undefined values.
......
...@@ -179,8 +179,8 @@ Object GlobalDictionaryShape::Unwrap(Object object) { ...@@ -179,8 +179,8 @@ Object GlobalDictionaryShape::Unwrap(Object object) {
return PropertyCell::cast(object).name(); return PropertyCell::cast(object).name();
} }
RootIndex GlobalDictionaryShape::GetMapRootIndex() { Handle<Map> GlobalDictionaryShape::GetMap(ReadOnlyRoots roots) {
return RootIndex::kGlobalDictionaryMap; return roots.global_dictionary_map_handle();
} }
Name NameDictionary::NameAt(InternalIndex entry) { Name NameDictionary::NameAt(InternalIndex entry) {
...@@ -192,8 +192,8 @@ Name NameDictionary::NameAt(const Isolate* isolate, InternalIndex entry) { ...@@ -192,8 +192,8 @@ Name NameDictionary::NameAt(const Isolate* isolate, InternalIndex entry) {
return Name::cast(KeyAt(isolate, entry)); return Name::cast(KeyAt(isolate, entry));
} }
RootIndex NameDictionaryShape::GetMapRootIndex() { Handle<Map> NameDictionaryShape::GetMap(ReadOnlyRoots roots) {
return RootIndex::kNameDictionaryMap; return roots.name_dictionary_map_handle();
} }
PropertyCell GlobalDictionary::CellAt(InternalIndex entry) { PropertyCell GlobalDictionary::CellAt(InternalIndex entry) {
...@@ -267,12 +267,12 @@ Handle<Object> NumberDictionaryBaseShape::AsHandle(Isolate* isolate, ...@@ -267,12 +267,12 @@ Handle<Object> NumberDictionaryBaseShape::AsHandle(Isolate* isolate,
return isolate->factory()->NewNumberFromUint(key); return isolate->factory()->NewNumberFromUint(key);
} }
RootIndex NumberDictionaryShape::GetMapRootIndex() { Handle<Map> NumberDictionaryShape::GetMap(ReadOnlyRoots roots) {
return RootIndex::kNumberDictionaryMap; return roots.number_dictionary_map_handle();
} }
RootIndex SimpleNumberDictionaryShape::GetMapRootIndex() { Handle<Map> SimpleNumberDictionaryShape::GetMap(ReadOnlyRoots roots) {
return RootIndex::kSimpleNumberDictionaryMap; return roots.simple_number_dictionary_map_handle();
} }
bool NameDictionaryShape::IsMatch(Handle<Name> key, Object other) { bool NameDictionaryShape::IsMatch(Handle<Name> key, Object other) {
......
...@@ -112,7 +112,7 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> { ...@@ -112,7 +112,7 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
static inline uint32_t Hash(Isolate* isolate, Handle<Name> key); static inline uint32_t Hash(Isolate* isolate, Handle<Name> key);
static inline uint32_t HashForObject(ReadOnlyRoots roots, Object object); static inline uint32_t HashForObject(ReadOnlyRoots roots, Object object);
static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key); static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static const int kPrefixSize = 2; static const int kPrefixSize = 2;
static const int kEntrySize = 3; static const int kEntrySize = 3;
static const int kEntryValueIndex = 1; static const int kEntryValueIndex = 1;
...@@ -218,7 +218,7 @@ class V8_EXPORT_PRIVATE GlobalDictionaryShape : public NameDictionaryShape { ...@@ -218,7 +218,7 @@ class V8_EXPORT_PRIVATE GlobalDictionaryShape : public NameDictionaryShape {
static inline Object Unwrap(Object key); static inline Object Unwrap(Object key);
static inline bool IsKey(ReadOnlyRoots roots, Object k); static inline bool IsKey(ReadOnlyRoots roots, Object k);
static inline bool IsLive(ReadOnlyRoots roots, Object key); static inline bool IsLive(ReadOnlyRoots roots, Object key);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
}; };
EXTERN_DECLARE_BASE_NAME_DICTIONARY(GlobalDictionary, GlobalDictionaryShape) EXTERN_DECLARE_BASE_NAME_DICTIONARY(GlobalDictionary, GlobalDictionaryShape)
...@@ -257,7 +257,7 @@ class NumberDictionaryShape : public NumberDictionaryBaseShape { ...@@ -257,7 +257,7 @@ class NumberDictionaryShape : public NumberDictionaryBaseShape {
static const int kPrefixSize = 1; static const int kPrefixSize = 1;
static const int kEntrySize = 3; static const int kEntrySize = 3;
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
}; };
class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape { class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape {
...@@ -278,7 +278,7 @@ class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape { ...@@ -278,7 +278,7 @@ class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape {
UNREACHABLE(); UNREACHABLE();
} }
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
}; };
EXTERN_DECLARE_DICTIONARY(SimpleNumberDictionary, SimpleNumberDictionaryShape) EXTERN_DECLARE_DICTIONARY(SimpleNumberDictionary, SimpleNumberDictionaryShape)
......
...@@ -123,12 +123,12 @@ void HashTableBase::SetNumberOfDeletedElements(int nod) { ...@@ -123,12 +123,12 @@ void HashTableBase::SetNumberOfDeletedElements(int nod) {
} }
template <typename Key> template <typename Key>
RootIndex BaseShape<Key>::GetMapRootIndex() { Handle<Map> BaseShape<Key>::GetMap(ReadOnlyRoots roots) {
return RootIndex::kHashTableMap; return roots.hash_table_map_handle();
} }
RootIndex EphemeronHashTableShape::GetMapRootIndex() { Handle<Map> EphemeronHashTableShape::GetMap(ReadOnlyRoots roots) {
return RootIndex::kEphemeronHashTableMap; return roots.ephemeron_hash_table_map_handle();
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
......
...@@ -60,7 +60,7 @@ template <typename KeyT> ...@@ -60,7 +60,7 @@ template <typename KeyT>
class V8_EXPORT_PRIVATE BaseShape { class V8_EXPORT_PRIVATE BaseShape {
public: public:
using Key = KeyT; using Key = KeyT;
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static const bool kNeedsHoleCheck = true; static const bool kNeedsHoleCheck = true;
static Object Unwrap(Object key) { return key; } static Object Unwrap(Object key) { return key; }
static inline bool IsKey(ReadOnlyRoots roots, Object key); static inline bool IsKey(ReadOnlyRoots roots, Object key);
...@@ -347,7 +347,7 @@ class V8_EXPORT_PRIVATE ObjectHashTable ...@@ -347,7 +347,7 @@ class V8_EXPORT_PRIVATE ObjectHashTable
class EphemeronHashTableShape : public ObjectHashTableShape { class EphemeronHashTableShape : public ObjectHashTableShape {
public: public:
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
}; };
EXTERN_DECLARE_OBJECT_BASE_HASH_TABLE(EphemeronHashTable, EXTERN_DECLARE_OBJECT_BASE_HASH_TABLE(EphemeronHashTable,
......
...@@ -6545,9 +6545,8 @@ Handle<Derived> HashTable<Derived, Shape>::NewInternal( ...@@ -6545,9 +6545,8 @@ Handle<Derived> HashTable<Derived, Shape>::NewInternal(
Isolate* isolate, int capacity, AllocationType allocation) { Isolate* isolate, int capacity, AllocationType allocation) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
int length = EntryToIndex(InternalIndex(capacity)); int length = EntryToIndex(InternalIndex(capacity));
RootIndex map_root_index = Shape::GetMapRootIndex(); Handle<FixedArray> array = factory->NewFixedArrayWithMap(
Handle<FixedArray> array = factory->NewFixedArrayWithMapRootIndex( Shape::GetMap(ReadOnlyRoots(isolate)), length, allocation);
map_root_index, length, allocation);
Handle<Derived> table = Handle<Derived>::cast(array); Handle<Derived> table = Handle<Derived>::cast(array);
table->SetNumberOfElements(0); table->SetNumberOfElements(0);
......
...@@ -73,28 +73,28 @@ OBJECT_CONSTRUCTORS_IMPL(SmallOrderedHashMap, ...@@ -73,28 +73,28 @@ OBJECT_CONSTRUCTORS_IMPL(SmallOrderedHashMap,
OBJECT_CONSTRUCTORS_IMPL(SmallOrderedNameDictionary, OBJECT_CONSTRUCTORS_IMPL(SmallOrderedNameDictionary,
SmallOrderedHashTable<SmallOrderedNameDictionary>) SmallOrderedHashTable<SmallOrderedNameDictionary>)
RootIndex OrderedHashSet::GetMapRootIndex() { Handle<Map> OrderedHashSet::GetMap(ReadOnlyRoots roots) {
return RootIndex::kOrderedHashSetMap; return roots.ordered_hash_set_map_handle();
} }
RootIndex OrderedHashMap::GetMapRootIndex() { Handle<Map> OrderedHashMap::GetMap(ReadOnlyRoots roots) {
return RootIndex::kOrderedHashMapMap; return roots.ordered_hash_map_map_handle();
} }
RootIndex OrderedNameDictionary::GetMapRootIndex() { Handle<Map> OrderedNameDictionary::GetMap(ReadOnlyRoots roots) {
return RootIndex::kOrderedNameDictionaryMap; return roots.ordered_name_dictionary_map_handle();
} }
RootIndex SmallOrderedNameDictionary::GetMapRootIndex() { Handle<Map> SmallOrderedNameDictionary::GetMap(ReadOnlyRoots roots) {
return RootIndex::kSmallOrderedNameDictionaryMap; return roots.small_ordered_name_dictionary_map_handle();
} }
RootIndex SmallOrderedHashMap::GetMapRootIndex() { Handle<Map> SmallOrderedHashMap::GetMap(ReadOnlyRoots roots) {
return RootIndex::kSmallOrderedHashMapMap; return roots.small_ordered_hash_map_map_handle();
} }
RootIndex SmallOrderedHashSet::GetMapRootIndex() { Handle<Map> SmallOrderedHashSet::GetMap(ReadOnlyRoots roots) {
return RootIndex::kSmallOrderedHashSetMap; return roots.small_ordered_hash_set_map_handle();
} }
inline Object OrderedHashMap::ValueAt(int entry) { inline Object OrderedHashMap::ValueAt(int entry) {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "src/objects/js-collection-inl.h" #include "src/objects/js-collection-inl.h"
#include "src/objects/objects-inl.h" #include "src/objects/objects-inl.h"
#include "src/objects/ordered-hash-table-inl.h" #include "src/objects/ordered-hash-table-inl.h"
#include "src/roots/roots.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -26,11 +27,10 @@ MaybeHandle<Derived> OrderedHashTable<Derived, entrysize>::Allocate( ...@@ -26,11 +27,10 @@ MaybeHandle<Derived> OrderedHashTable<Derived, entrysize>::Allocate(
return MaybeHandle<Derived>(); return MaybeHandle<Derived>();
} }
int num_buckets = capacity / kLoadFactor; int num_buckets = capacity / kLoadFactor;
Handle<FixedArray> backing_store = Handle<FixedArray> backing_store = isolate->factory()->NewFixedArrayWithMap(
isolate->factory()->NewFixedArrayWithMapRootIndex( Derived::GetMap(ReadOnlyRoots(isolate)),
Derived::GetMapRootIndex(), HashTableStartIndex() + num_buckets + (capacity * kEntrySize),
HashTableStartIndex() + num_buckets + (capacity * kEntrySize), allocation);
allocation);
Handle<Derived> table = Handle<Derived>::cast(backing_store); Handle<Derived> table = Handle<Derived>::cast(backing_store);
for (int i = 0; i < num_buckets; ++i) { for (int i = 0; i < num_buckets; ++i) {
table->set(HashTableStartIndex() + i, Smi::FromInt(kNotFound)); table->set(HashTableStartIndex() + i, Smi::FromInt(kNotFound));
......
...@@ -248,7 +248,7 @@ class V8_EXPORT_PRIVATE OrderedHashSet ...@@ -248,7 +248,7 @@ class V8_EXPORT_PRIVATE OrderedHashSet
Isolate* isolate, int capacity, Isolate* isolate, int capacity,
AllocationType allocation = AllocationType::kYoung); AllocationType allocation = AllocationType::kYoung);
static HeapObject GetEmpty(ReadOnlyRoots ro_roots); static HeapObject GetEmpty(ReadOnlyRoots ro_roots);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static inline bool Is(Handle<HeapObject> table); static inline bool Is(Handle<HeapObject> table);
static const int kPrefixSize = 0; static const int kPrefixSize = 0;
...@@ -280,7 +280,7 @@ class V8_EXPORT_PRIVATE OrderedHashMap ...@@ -280,7 +280,7 @@ class V8_EXPORT_PRIVATE OrderedHashMap
static Address GetHash(Isolate* isolate, Address raw_key); static Address GetHash(Isolate* isolate, Address raw_key);
static HeapObject GetEmpty(ReadOnlyRoots ro_roots); static HeapObject GetEmpty(ReadOnlyRoots ro_roots);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static inline bool Is(Handle<HeapObject> table); static inline bool Is(Handle<HeapObject> table);
static const int kValueOffset = 1; static const int kValueOffset = 1;
...@@ -602,7 +602,7 @@ class SmallOrderedHashSet : public SmallOrderedHashTable<SmallOrderedHashSet> { ...@@ -602,7 +602,7 @@ class SmallOrderedHashSet : public SmallOrderedHashTable<SmallOrderedHashSet> {
V8_EXPORT_PRIVATE bool HasKey(Isolate* isolate, Handle<Object> key); V8_EXPORT_PRIVATE bool HasKey(Isolate* isolate, Handle<Object> key);
static inline bool Is(Handle<HeapObject> table); static inline bool Is(Handle<HeapObject> table);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static Handle<SmallOrderedHashSet> Rehash(Isolate* isolate, static Handle<SmallOrderedHashSet> Rehash(Isolate* isolate,
Handle<SmallOrderedHashSet> table, Handle<SmallOrderedHashSet> table,
int new_capacity); int new_capacity);
...@@ -635,7 +635,7 @@ class SmallOrderedHashMap : public SmallOrderedHashTable<SmallOrderedHashMap> { ...@@ -635,7 +635,7 @@ class SmallOrderedHashMap : public SmallOrderedHashTable<SmallOrderedHashMap> {
SmallOrderedHashMap table, Object key); SmallOrderedHashMap table, Object key);
V8_EXPORT_PRIVATE bool HasKey(Isolate* isolate, Handle<Object> key); V8_EXPORT_PRIVATE bool HasKey(Isolate* isolate, Handle<Object> key);
static inline bool Is(Handle<HeapObject> table); static inline bool Is(Handle<HeapObject> table);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static Handle<SmallOrderedHashMap> Rehash(Isolate* isolate, static Handle<SmallOrderedHashMap> Rehash(Isolate* isolate,
Handle<SmallOrderedHashMap> table, Handle<SmallOrderedHashMap> table,
...@@ -730,7 +730,7 @@ class OrderedNameDictionary ...@@ -730,7 +730,7 @@ class OrderedNameDictionary
inline int Hash(); inline int Hash();
static HeapObject GetEmpty(ReadOnlyRoots ro_roots); static HeapObject GetEmpty(ReadOnlyRoots ro_roots);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static inline bool Is(Handle<HeapObject> table); static inline bool Is(Handle<HeapObject> table);
static const int kValueOffset = 1; static const int kValueOffset = 1;
...@@ -832,7 +832,7 @@ class SmallOrderedNameDictionary ...@@ -832,7 +832,7 @@ class SmallOrderedNameDictionary
V8_EXPORT_PRIVATE void SetEntry(Isolate* isolate, int entry, Object key, V8_EXPORT_PRIVATE void SetEntry(Isolate* isolate, int entry, Object key,
Object value, PropertyDetails details); Object value, PropertyDetails details);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static inline bool Is(Handle<HeapObject> table); static inline bool Is(Handle<HeapObject> table);
OBJECT_CONSTRUCTORS(SmallOrderedNameDictionary, OBJECT_CONSTRUCTORS(SmallOrderedNameDictionary,
......
...@@ -72,8 +72,8 @@ uint32_t StringTableShape::HashForObject(ReadOnlyRoots roots, Object object) { ...@@ -72,8 +72,8 @@ uint32_t StringTableShape::HashForObject(ReadOnlyRoots roots, Object object) {
return String::cast(object).Hash(); return String::cast(object).Hash();
} }
RootIndex StringTableShape::GetMapRootIndex() { Handle<Map> StringTableShape::GetMap(ReadOnlyRoots roots) {
return RootIndex::kStringTableMap; return roots.string_table_map_handle();
} }
} // namespace internal } // namespace internal
......
...@@ -47,7 +47,7 @@ class V8_EXPORT_PRIVATE StringTableShape : public BaseShape<StringTableKey*> { ...@@ -47,7 +47,7 @@ class V8_EXPORT_PRIVATE StringTableShape : public BaseShape<StringTableKey*> {
static inline Handle<Object> AsHandle(Isolate* isolate, Key key); static inline Handle<Object> AsHandle(Isolate* isolate, Key key);
static inline RootIndex GetMapRootIndex(); static inline Handle<Map> GetMap(ReadOnlyRoots roots);
static const int kPrefixSize = 0; static const int kPrefixSize = 0;
static const int kEntrySize = 1; static const int kEntrySize = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment