Commit 0954f205 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[offthread] Add off-thread class boilerplate allocation

Add off-thread support for class boilerplate allocation, removing a
previously "unreachable" overload. Notably, this requires support for
off-thread allocation of Dictionaries and DescriptorArrays. Due to
template fun, the off-thread allocation of Dictionaries in particular
requires some amount of boilerplate (no pun intended).

Bug: chromium:1011762
Change-Id: I37139d924858e31e45d369742329826784a8f614
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2080370
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66580}
parent 90a3a660
...@@ -14,7 +14,6 @@ namespace v8 { ...@@ -14,7 +14,6 @@ namespace v8 {
namespace internal { namespace internal {
class Isolate; class Isolate;
class OffThreadIsolate;
class OffThreadLogger; class OffThreadLogger;
// HiddenOffThreadFactory parallels Isolate's HiddenFactory // HiddenOffThreadFactory parallels Isolate's HiddenFactory
......
...@@ -196,6 +196,13 @@ inline SealHandleScope::~SealHandleScope() { ...@@ -196,6 +196,13 @@ inline SealHandleScope::~SealHandleScope() {
#endif #endif
template <typename T>
Handle<T> OffThreadHandleScope::CloseAndEscape(Handle<T> handle_value) {
// At the moment, off-thread handle scopes do nothing on close, so we can
// safely return the same handle value.
return handle_value;
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -368,6 +368,9 @@ class OffThreadHandleScope { ...@@ -368,6 +368,9 @@ class OffThreadHandleScope {
// Off-thread Handles are allocated in the parse/compile zone, and not // Off-thread Handles are allocated in the parse/compile zone, and not
// cleared out, so the scope doesn't have to do anything // cleared out, so the scope doesn't have to do anything
explicit OffThreadHandleScope(OffThreadIsolate* isolate) {} explicit OffThreadHandleScope(OffThreadIsolate* isolate) {}
template <typename T>
inline Handle<T> CloseAndEscape(Handle<T> handle_value);
}; };
} // namespace internal } // namespace internal
......
...@@ -55,6 +55,15 @@ Handle<Struct> FactoryBase<Impl>::NewStruct(InstanceType type, ...@@ -55,6 +55,15 @@ Handle<Struct> FactoryBase<Impl>::NewStruct(InstanceType type,
return str; return str;
} }
template <typename Impl>
Handle<AccessorPair> FactoryBase<Impl>::NewAccessorPair() {
Handle<AccessorPair> accessors = Handle<AccessorPair>::cast(
NewStruct(ACCESSOR_PAIR_TYPE, AllocationType::kOld));
accessors->set_getter(read_only_roots().null_value(), SKIP_WRITE_BARRIER);
accessors->set_setter(read_only_roots().null_value(), SKIP_WRITE_BARRIER);
return accessors;
}
template <typename Impl> template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArray(int length, Handle<FixedArray> FactoryBase<Impl>::NewFixedArray(int length,
AllocationType allocation) { AllocationType allocation) {
...@@ -637,6 +646,32 @@ Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo() { ...@@ -637,6 +646,32 @@ Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo() {
return shared; return shared;
} }
template <typename Impl>
Handle<DescriptorArray> FactoryBase<Impl>::NewDescriptorArray(
int number_of_descriptors, int slack, AllocationType allocation) {
int number_of_all_descriptors = number_of_descriptors + slack;
// Zero-length case must be handled outside.
DCHECK_LT(0, number_of_all_descriptors);
int size = DescriptorArray::SizeFor(number_of_all_descriptors);
HeapObject obj = AllocateRawWithImmortalMap(
size, AllocationType::kYoung, read_only_roots().descriptor_array_map());
DescriptorArray array = DescriptorArray::cast(obj);
array.Initialize(read_only_roots().empty_enum_cache(),
read_only_roots().undefined_value(), number_of_descriptors,
slack);
return handle(array, isolate());
}
template <typename Impl>
Handle<ClassPositions> FactoryBase<Impl>::NewClassPositions(int start,
int end) {
Handle<ClassPositions> class_positions = Handle<ClassPositions>::cast(
NewStruct(CLASS_POSITIONS_TYPE, AllocationType::kOld));
class_positions->set_start(start);
class_positions->set_end(end);
return class_positions;
}
template <typename Impl> template <typename Impl>
Handle<SeqOneByteString> Handle<SeqOneByteString>
FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length, FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
......
...@@ -29,6 +29,7 @@ class UncompiledDataWithoutPreparseData; ...@@ -29,6 +29,7 @@ class UncompiledDataWithoutPreparseData;
class UncompiledDataWithPreparseData; class UncompiledDataWithPreparseData;
class BytecodeArray; class BytecodeArray;
class CoverageInfo; class CoverageInfo;
class ClassPositions;
struct SourceRange; struct SourceRange;
template <typename T> template <typename T>
class ZoneVector; class ZoneVector;
...@@ -64,6 +65,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase { ...@@ -64,6 +65,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
Handle<Struct> NewStruct(InstanceType type, Handle<Struct> NewStruct(InstanceType type,
AllocationType allocation = AllocationType::kYoung); AllocationType allocation = AllocationType::kYoung);
// Create a pre-tenured empty AccessorPair.
Handle<AccessorPair> NewAccessorPair();
// Allocates a fixed array initialized with undefined values. // Allocates a fixed array initialized with undefined values.
Handle<FixedArray> NewFixedArray( Handle<FixedArray> NewFixedArray(
int length, AllocationType allocation = AllocationType::kYoung); int length, AllocationType allocation = AllocationType::kYoung);
...@@ -175,6 +179,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase { ...@@ -175,6 +179,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
Handle<SourceTextModuleInfo> NewSourceTextModuleInfo(); Handle<SourceTextModuleInfo> NewSourceTextModuleInfo();
Handle<DescriptorArray> NewDescriptorArray(
int number_of_entries, int slack = 0,
AllocationType allocation = AllocationType::kYoung);
Handle<ClassPositions> NewClassPositions(int start, int end);
protected: protected:
// Allocate memory for an uninitialized array (e.g., a FixedArray or similar). // Allocate memory for an uninitialized array (e.g., a FixedArray or similar).
HeapObject AllocateRawArray(int size, AllocationType allocation); HeapObject AllocateRawArray(int size, AllocationType allocation);
......
...@@ -501,14 +501,6 @@ Handle<OrderedNameDictionary> Factory::NewOrderedNameDictionary() { ...@@ -501,14 +501,6 @@ Handle<OrderedNameDictionary> Factory::NewOrderedNameDictionary() {
.ToHandleChecked(); .ToHandleChecked();
} }
Handle<AccessorPair> Factory::NewAccessorPair() {
Handle<AccessorPair> accessors = Handle<AccessorPair>::cast(
NewStruct(ACCESSOR_PAIR_TYPE, AllocationType::kOld));
accessors->set_getter(*null_value(), SKIP_WRITE_BARRIER);
accessors->set_setter(*null_value(), SKIP_WRITE_BARRIER);
return accessors;
}
Handle<PropertyDescriptorObject> Factory::NewPropertyDescriptorObject() { Handle<PropertyDescriptorObject> Factory::NewPropertyDescriptorObject() {
Handle<PropertyDescriptorObject> object = Handle<PropertyDescriptorObject> object =
Handle<PropertyDescriptorObject>::cast( Handle<PropertyDescriptorObject>::cast(
...@@ -1361,21 +1353,6 @@ Handle<PropertyCell> Factory::NewPropertyCell(Handle<Name> name, ...@@ -1361,21 +1353,6 @@ Handle<PropertyCell> Factory::NewPropertyCell(Handle<Name> name,
return cell; return cell;
} }
Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors,
int slack) {
int number_of_all_descriptors = number_of_descriptors + slack;
// Zero-length case must be handled outside.
DCHECK_LT(0, number_of_all_descriptors);
int size = DescriptorArray::SizeFor(number_of_all_descriptors);
HeapObject obj = isolate()->heap()->AllocateRawWith<Heap::kRetryOrFail>(
size, AllocationType::kYoung);
obj.set_map_after_allocation(*descriptor_array_map(), SKIP_WRITE_BARRIER);
DescriptorArray array = DescriptorArray::cast(obj);
array.Initialize(*empty_enum_cache(), *undefined_value(),
number_of_descriptors, slack);
return Handle<DescriptorArray>(array, isolate());
}
Handle<TransitionArray> Factory::NewTransitionArray(int number_of_transitions, Handle<TransitionArray> Factory::NewTransitionArray(int number_of_transitions,
int slack) { int slack) {
int capacity = TransitionArray::LengthFor(number_of_transitions + slack); int capacity = TransitionArray::LengthFor(number_of_transitions + slack);
...@@ -3019,14 +2996,6 @@ Handle<String> Factory::SizeToString(size_t value, bool check_cache) { ...@@ -3019,14 +2996,6 @@ Handle<String> Factory::SizeToString(size_t value, bool check_cache) {
return result; return result;
} }
Handle<ClassPositions> Factory::NewClassPositions(int start, int end) {
Handle<ClassPositions> class_positions = Handle<ClassPositions>::cast(
NewStruct(CLASS_POSITIONS_TYPE, AllocationType::kOld));
class_positions->set_start(start);
class_positions->set_end(end);
return class_positions;
}
Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) { Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) {
DCHECK(!shared->HasDebugInfo()); DCHECK(!shared->HasDebugInfo());
Heap* heap = isolate()->heap(); Heap* heap = isolate()->heap();
......
...@@ -167,9 +167,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> { ...@@ -167,9 +167,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<Tuple2> NewTuple2(Handle<Object> value1, Handle<Object> value2, Handle<Tuple2> NewTuple2(Handle<Object> value1, Handle<Object> value2,
AllocationType allocation); AllocationType allocation);
// Create a pre-tenured empty AccessorPair.
Handle<AccessorPair> NewAccessorPair();
// Create a new PropertyDescriptorObject struct. // Create a new PropertyDescriptorObject struct.
Handle<PropertyDescriptorObject> NewPropertyDescriptorObject(); Handle<PropertyDescriptorObject> NewPropertyDescriptorObject();
...@@ -381,8 +378,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> { ...@@ -381,8 +378,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<FeedbackCell> NewOneClosureCell(Handle<HeapObject> value); Handle<FeedbackCell> NewOneClosureCell(Handle<HeapObject> value);
Handle<FeedbackCell> NewManyClosuresCell(Handle<HeapObject> value); Handle<FeedbackCell> NewManyClosuresCell(Handle<HeapObject> value);
Handle<DescriptorArray> NewDescriptorArray(int number_of_entries,
int slack = 0);
Handle<TransitionArray> NewTransitionArray(int number_of_transitions, Handle<TransitionArray> NewTransitionArray(int number_of_transitions,
int slack = 0); int slack = 0);
...@@ -730,7 +725,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> { ...@@ -730,7 +725,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
int end_position, Handle<SharedFunctionInfo> shared_info, int end_position, Handle<SharedFunctionInfo> shared_info,
int bytecode_offset, Handle<Script> script, Handle<Object> stack_frames); int bytecode_offset, Handle<Script> script, Handle<Object> stack_frames);
Handle<ClassPositions> NewClassPositions(int start, int end);
Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
// Return a map for given number of properties using the map cache in the // Return a map for given number of properties using the map cache in the
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef V8_OBJECTS_DESCRIPTOR_ARRAY_H_ #ifndef V8_OBJECTS_DESCRIPTOR_ARRAY_H_
#define V8_OBJECTS_DESCRIPTOR_ARRAY_H_ #define V8_OBJECTS_DESCRIPTOR_ARRAY_H_
#include "src/common/globals.h"
#include "src/objects/fixed-array.h" #include "src/objects/fixed-array.h"
// TODO(jkummerow): Consider forward-declaring instead. // TODO(jkummerow): Consider forward-declaring instead.
#include "src/base/bit-field.h" #include "src/base/bit-field.h"
...@@ -126,9 +127,10 @@ class DescriptorArray : public HeapObject { ...@@ -126,9 +127,10 @@ class DescriptorArray : public HeapObject {
// Allocates a DescriptorArray, but returns the singleton // Allocates a DescriptorArray, but returns the singleton
// empty descriptor array object if number_of_descriptors is 0. // empty descriptor array object if number_of_descriptors is 0.
V8_EXPORT_PRIVATE static Handle<DescriptorArray> Allocate(Isolate* isolate, template <typename LocalIsolate>
int nof_descriptors, V8_EXPORT_PRIVATE static Handle<DescriptorArray> Allocate(
int slack); LocalIsolate* isolate, int nof_descriptors, int slack,
AllocationType allocation = AllocationType::kYoung);
void Initialize(EnumCache enum_cache, HeapObject undefined_value, void Initialize(EnumCache enum_cache, HeapObject undefined_value,
int nof_descriptors, int slack); int nof_descriptors, int slack);
......
...@@ -264,6 +264,11 @@ Handle<Object> NumberDictionaryBaseShape::AsHandle(Isolate* isolate, ...@@ -264,6 +264,11 @@ Handle<Object> NumberDictionaryBaseShape::AsHandle(Isolate* isolate,
return isolate->factory()->NewNumberFromUint(key); return isolate->factory()->NewNumberFromUint(key);
} }
Handle<Object> NumberDictionaryBaseShape::AsHandle(OffThreadIsolate* isolate,
uint32_t key) {
return isolate->factory()->NewNumberFromUint<AllocationType::kOld>(key);
}
Handle<Map> NumberDictionaryShape::GetMap(ReadOnlyRoots roots) { Handle<Map> NumberDictionaryShape::GetMap(ReadOnlyRoots roots) {
return roots.number_dictionary_map_handle(); return roots.number_dictionary_map_handle();
} }
...@@ -302,6 +307,12 @@ Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate, ...@@ -302,6 +307,12 @@ Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate,
return key; return key;
} }
Handle<Object> NameDictionaryShape::AsHandle(OffThreadIsolate* isolate,
Handle<Name> key) {
DCHECK(key->IsUniqueName());
return key;
}
template <typename Dictionary> template <typename Dictionary>
PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary dict, PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary dict,
InternalIndex entry) { InternalIndex entry) {
......
...@@ -72,8 +72,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary ...@@ -72,8 +72,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
// Garbage collection support. // Garbage collection support.
inline ObjectSlot RawFieldOfValueAt(InternalIndex entry); inline ObjectSlot RawFieldOfValueAt(InternalIndex entry);
template <typename LocalIsolate>
V8_WARN_UNUSED_RESULT static Handle<Derived> Add( V8_WARN_UNUSED_RESULT static Handle<Derived> Add(
Isolate* isolate, Handle<Derived> dictionary, Key key, LocalIsolate* isolate, Handle<Derived> dictionary, Key key,
Handle<Object> value, PropertyDetails details, Handle<Object> value, PropertyDetails details,
InternalIndex* entry_out = nullptr); InternalIndex* entry_out = nullptr);
...@@ -111,6 +112,8 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> { ...@@ -111,6 +112,8 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
static inline uint32_t Hash(ReadOnlyRoots roots, Handle<Name> key); static inline uint32_t Hash(ReadOnlyRoots roots, 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 Handle<Object> AsHandle(OffThreadIsolate* isolate,
Handle<Name> key);
static inline Handle<Map> GetMap(ReadOnlyRoots roots); 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;
...@@ -133,8 +136,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary ...@@ -133,8 +136,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
inline int Hash() const; inline int Hash() const;
// Creates a new dictionary. // Creates a new dictionary.
template <typename LocalIsolate>
V8_WARN_UNUSED_RESULT static Handle<Derived> New( V8_WARN_UNUSED_RESULT static Handle<Derived> New(
Isolate* isolate, int at_least_space_for, LocalIsolate* isolate, int at_least_space_for,
AllocationType allocation = AllocationType::kYoung, AllocationType allocation = AllocationType::kYoung,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY); MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY);
...@@ -161,8 +165,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary ...@@ -161,8 +165,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
Handle<FixedArray> storage, KeyCollectionMode mode, Handle<FixedArray> storage, KeyCollectionMode mode,
KeyAccumulator* accumulator); KeyAccumulator* accumulator);
template <typename LocalIsolate>
V8_WARN_UNUSED_RESULT static Handle<Derived> AddNoUpdateNextEnumerationIndex( V8_WARN_UNUSED_RESULT static Handle<Derived> AddNoUpdateNextEnumerationIndex(
Isolate* isolate, Handle<Derived> dictionary, Key key, LocalIsolate* isolate, Handle<Derived> dictionary, Key key,
Handle<Object> value, PropertyDetails details, Handle<Object> value, PropertyDetails details,
InternalIndex* entry_out = nullptr); InternalIndex* entry_out = nullptr);
...@@ -246,6 +251,8 @@ class NumberDictionaryBaseShape : public BaseDictionaryShape<uint32_t> { ...@@ -246,6 +251,8 @@ class NumberDictionaryBaseShape : public BaseDictionaryShape<uint32_t> {
public: public:
static inline bool IsMatch(uint32_t key, Object other); static inline bool IsMatch(uint32_t key, Object other);
static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key); static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key);
static inline Handle<Object> AsHandle(OffThreadIsolate* isolate,
uint32_t key);
static inline uint32_t Hash(ReadOnlyRoots roots, uint32_t key); static inline uint32_t Hash(ReadOnlyRoots roots, uint32_t key);
static inline uint32_t HashForObject(ReadOnlyRoots roots, Object object); static inline uint32_t HashForObject(ReadOnlyRoots roots, Object object);
......
...@@ -2723,14 +2723,12 @@ class FastSealedObjectElementsAccessor ...@@ -2723,14 +2723,12 @@ class FastSealedObjectElementsAccessor
class FastPackedSealedObjectElementsAccessor class FastPackedSealedObjectElementsAccessor
: public FastSealedObjectElementsAccessor< : public FastSealedObjectElementsAccessor<
FastPackedSealedObjectElementsAccessor, FastPackedSealedObjectElementsAccessor,
ElementsKindTraits<PACKED_SEALED_ELEMENTS>> { ElementsKindTraits<PACKED_SEALED_ELEMENTS>> {};
};
class FastHoleySealedObjectElementsAccessor class FastHoleySealedObjectElementsAccessor
: public FastSealedObjectElementsAccessor< : public FastSealedObjectElementsAccessor<
FastHoleySealedObjectElementsAccessor, FastHoleySealedObjectElementsAccessor,
ElementsKindTraits<HOLEY_SEALED_ELEMENTS>> { ElementsKindTraits<HOLEY_SEALED_ELEMENTS>> {};
};
template <typename Subclass, typename KindTraits> template <typename Subclass, typename KindTraits>
class FastFrozenObjectElementsAccessor class FastFrozenObjectElementsAccessor
...@@ -2802,14 +2800,12 @@ class FastFrozenObjectElementsAccessor ...@@ -2802,14 +2800,12 @@ class FastFrozenObjectElementsAccessor
class FastPackedFrozenObjectElementsAccessor class FastPackedFrozenObjectElementsAccessor
: public FastFrozenObjectElementsAccessor< : public FastFrozenObjectElementsAccessor<
FastPackedFrozenObjectElementsAccessor, FastPackedFrozenObjectElementsAccessor,
ElementsKindTraits<PACKED_FROZEN_ELEMENTS>> { ElementsKindTraits<PACKED_FROZEN_ELEMENTS>> {};
};
class FastHoleyFrozenObjectElementsAccessor class FastHoleyFrozenObjectElementsAccessor
: public FastFrozenObjectElementsAccessor< : public FastFrozenObjectElementsAccessor<
FastHoleyFrozenObjectElementsAccessor, FastHoleyFrozenObjectElementsAccessor,
ElementsKindTraits<HOLEY_FROZEN_ELEMENTS>> { ElementsKindTraits<HOLEY_FROZEN_ELEMENTS>> {};
};
class FastHoleyObjectElementsAccessor class FastHoleyObjectElementsAccessor
: public FastSmiOrObjectElementsAccessor< : public FastSmiOrObjectElementsAccessor<
......
...@@ -129,8 +129,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable ...@@ -129,8 +129,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
using Key = typename Shape::Key; using Key = typename Shape::Key;
// Returns a new HashTable object. // Returns a new HashTable object.
template <typename LocalIsolate>
V8_WARN_UNUSED_RESULT static Handle<Derived> New( V8_WARN_UNUSED_RESULT static Handle<Derived> New(
Isolate* isolate, int at_least_space_for, LocalIsolate* isolate, int at_least_space_for,
AllocationType allocation = AllocationType::kYoung, AllocationType allocation = AllocationType::kYoung,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY); MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY);
...@@ -192,8 +193,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable ...@@ -192,8 +193,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
} }
// Ensure enough space for n additional elements. // Ensure enough space for n additional elements.
template <typename LocalIsolate>
V8_WARN_UNUSED_RESULT static Handle<Derived> EnsureCapacity( V8_WARN_UNUSED_RESULT static Handle<Derived> EnsureCapacity(
Isolate* isolate, Handle<Derived> table, int n = 1, LocalIsolate* isolate, Handle<Derived> table, int n = 1,
AllocationType allocation = AllocationType::kYoung); AllocationType allocation = AllocationType::kYoung);
// Returns true if this table has sufficient capacity for adding n elements. // Returns true if this table has sufficient capacity for adding n elements.
...@@ -202,8 +204,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable ...@@ -202,8 +204,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
protected: protected:
friend class ObjectHashTable; friend class ObjectHashTable;
template <typename LocalIsolate>
V8_WARN_UNUSED_RESULT static Handle<Derived> NewInternal( V8_WARN_UNUSED_RESULT static Handle<Derived> NewInternal(
Isolate* isolate, int capacity, AllocationType allocation); LocalIsolate* isolate, int capacity, AllocationType allocation);
// Find the entry at which to insert element with the given key that // Find the entry at which to insert element with the given key that
// has the given hash value. // has the given hash value.
...@@ -244,9 +247,23 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable ...@@ -244,9 +247,23 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
OBJECT_CONSTRUCTORS(HashTable, HashTableBase); OBJECT_CONSTRUCTORS(HashTable, HashTableBase);
}; };
#define EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \ #define EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \ extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
HashTable<class DERIVED, SHAPE>; HashTable<class DERIVED, SHAPE>; \
\
extern template EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::New(Isolate*, int, AllocationType, \
MinimumCapacity); \
extern template EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::New(OffThreadIsolate*, int, AllocationType, \
MinimumCapacity); \
\
extern template EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::EnsureCapacity(Isolate*, Handle<DERIVED>, int, \
AllocationType); \
extern template EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::EnsureCapacity( \
OffThreadIsolate*, Handle<DERIVED>, int, AllocationType);
// HashTableKey is an abstract superclass for virtual key behavior. // HashTableKey is an abstract superclass for virtual key behavior.
class HashTableKey { class HashTableKey {
......
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
#include "src/ast/ast.h" #include "src/ast/ast.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/builtins/accessors.h" #include "src/builtins/accessors.h"
#include "src/common/globals.h"
#include "src/execution/isolate.h" #include "src/execution/isolate.h"
#include "src/heap/factory.h" #include "src/heap/factory.h"
#include "src/heap/off-thread-factory-inl.h"
#include "src/objects/dictionary.h"
#include "src/objects/hash-table-inl.h" #include "src/objects/hash-table-inl.h"
#include "src/objects/literal-objects-inl.h" #include "src/objects/literal-objects-inl.h"
#include "src/objects/objects-inl.h" #include "src/objects/objects-inl.h"
...@@ -28,8 +31,9 @@ inline int EncodeComputedEntry(ClassBoilerplate::ValueKind value_kind, ...@@ -28,8 +31,9 @@ inline int EncodeComputedEntry(ClassBoilerplate::ValueKind value_kind,
return flags; return flags;
} }
template <typename LocalIsolate>
void AddToDescriptorArrayTemplate( void AddToDescriptorArrayTemplate(
Isolate* isolate, Handle<DescriptorArray> descriptor_array_template, LocalIsolate* isolate, Handle<DescriptorArray> descriptor_array_template,
Handle<Name> name, ClassBoilerplate::ValueKind value_kind, Handle<Name> name, ClassBoilerplate::ValueKind value_kind,
Handle<Object> value) { Handle<Object> value) {
InternalIndex entry = descriptor_array_template->Search( InternalIndex entry = descriptor_array_template->Search(
...@@ -80,17 +84,19 @@ void AddToDescriptorArrayTemplate( ...@@ -80,17 +84,19 @@ void AddToDescriptorArrayTemplate(
} }
} }
template <typename LocalIsolate>
Handle<NameDictionary> DictionaryAddNoUpdateNextEnumerationIndex( Handle<NameDictionary> DictionaryAddNoUpdateNextEnumerationIndex(
Isolate* isolate, Handle<NameDictionary> dictionary, Handle<Name> name, LocalIsolate* isolate, Handle<NameDictionary> dictionary, Handle<Name> name,
Handle<Object> value, PropertyDetails details, Handle<Object> value, PropertyDetails details,
InternalIndex* entry_out = nullptr) { InternalIndex* entry_out = nullptr) {
return NameDictionary::AddNoUpdateNextEnumerationIndex( return NameDictionary::AddNoUpdateNextEnumerationIndex(
isolate, dictionary, name, value, details, entry_out); isolate, dictionary, name, value, details, entry_out);
} }
template <typename LocalIsolate>
Handle<NumberDictionary> DictionaryAddNoUpdateNextEnumerationIndex( Handle<NumberDictionary> DictionaryAddNoUpdateNextEnumerationIndex(
Isolate* isolate, Handle<NumberDictionary> dictionary, uint32_t element, LocalIsolate* isolate, Handle<NumberDictionary> dictionary,
Handle<Object> value, PropertyDetails details, uint32_t element, Handle<Object> value, PropertyDetails details,
InternalIndex* entry_out = nullptr) { InternalIndex* entry_out = nullptr) {
// NumberDictionary does not maintain the enumeration order, so it's // NumberDictionary does not maintain the enumeration order, so it's
// a normal Add(). // a normal Add().
...@@ -121,9 +127,10 @@ inline int GetExistingValueIndex(Object value) { ...@@ -121,9 +127,10 @@ inline int GetExistingValueIndex(Object value) {
return value.IsSmi() ? Smi::ToInt(value) : -1; return value.IsSmi() ? Smi::ToInt(value) : -1;
} }
template <typename Dictionary, typename Key> template <typename LocalIsolate, typename Dictionary, typename Key>
void AddToDictionaryTemplate(Isolate* isolate, Handle<Dictionary> dictionary, void AddToDictionaryTemplate(LocalIsolate* isolate,
Key key, int key_index, Handle<Dictionary> dictionary, Key key,
int key_index,
ClassBoilerplate::ValueKind value_kind, ClassBoilerplate::ValueKind value_kind,
Smi value) { Smi value) {
InternalIndex entry = dictionary->FindEntry(ReadOnlyRoots(isolate), key); InternalIndex entry = dictionary->FindEntry(ReadOnlyRoots(isolate), key);
...@@ -253,6 +260,7 @@ void AddToDictionaryTemplate(Isolate* isolate, Handle<Dictionary> dictionary, ...@@ -253,6 +260,7 @@ void AddToDictionaryTemplate(Isolate* isolate, Handle<Dictionary> dictionary,
// Helper class that eases building of a properties, elements and computed // Helper class that eases building of a properties, elements and computed
// properties templates. // properties templates.
template <typename LocalIsolate>
class ObjectDescriptor { class ObjectDescriptor {
public: public:
void IncComputedCount() { ++computed_count_; } void IncComputedCount() { ++computed_count_; }
...@@ -281,14 +289,16 @@ class ObjectDescriptor { ...@@ -281,14 +289,16 @@ class ObjectDescriptor {
return computed_properties_; return computed_properties_;
} }
void CreateTemplates(Isolate* isolate) { void CreateTemplates(LocalIsolate* isolate) {
Factory* factory = isolate->factory(); auto* factory = isolate->factory();
descriptor_array_template_ = factory->empty_descriptor_array(); descriptor_array_template_ = factory->empty_descriptor_array();
properties_dictionary_template_ = factory->empty_property_dictionary(); properties_dictionary_template_ =
Handle<NameDictionary>::cast(factory->empty_property_dictionary());
if (property_count_ || computed_count_ || property_slack_) { if (property_count_ || computed_count_ || property_slack_) {
if (HasDictionaryProperties()) { if (HasDictionaryProperties()) {
properties_dictionary_template_ = NameDictionary::New( properties_dictionary_template_ = NameDictionary::New(
isolate, property_count_ + computed_count_ + property_slack_); isolate, property_count_ + computed_count_ + property_slack_,
AllocationType::kOld);
} else { } else {
descriptor_array_template_ = DescriptorArray::Allocate( descriptor_array_template_ = DescriptorArray::Allocate(
isolate, 0, property_count_ + property_slack_); isolate, 0, property_count_ + property_slack_);
...@@ -306,8 +316,8 @@ class ObjectDescriptor { ...@@ -306,8 +316,8 @@ class ObjectDescriptor {
temp_handle_ = handle(Smi::zero(), isolate); temp_handle_ = handle(Smi::zero(), isolate);
} }
void AddConstant(Isolate* isolate, Handle<Name> name, Handle<Object> value, void AddConstant(LocalIsolate* isolate, Handle<Name> name,
PropertyAttributes attribs) { Handle<Object> value, PropertyAttributes attribs) {
bool is_accessor = value->IsAccessorInfo(); bool is_accessor = value->IsAccessorInfo();
DCHECK(!value->IsAccessorPair()); DCHECK(!value->IsAccessorPair());
if (HasDictionaryProperties()) { if (HasDictionaryProperties()) {
...@@ -325,7 +335,7 @@ class ObjectDescriptor { ...@@ -325,7 +335,7 @@ class ObjectDescriptor {
} }
} }
void AddNamedProperty(Isolate* isolate, Handle<Name> name, void AddNamedProperty(LocalIsolate* isolate, Handle<Name> name,
ClassBoilerplate::ValueKind value_kind, ClassBoilerplate::ValueKind value_kind,
int value_index) { int value_index) {
Smi value = Smi::FromInt(value_index); Smi value = Smi::FromInt(value_index);
...@@ -340,7 +350,7 @@ class ObjectDescriptor { ...@@ -340,7 +350,7 @@ class ObjectDescriptor {
} }
} }
void AddIndexedProperty(Isolate* isolate, uint32_t element, void AddIndexedProperty(LocalIsolate* isolate, uint32_t element,
ClassBoilerplate::ValueKind value_kind, ClassBoilerplate::ValueKind value_kind,
int value_index) { int value_index) {
Smi value = Smi::FromInt(value_index); Smi value = Smi::FromInt(value_index);
...@@ -362,7 +372,7 @@ class ObjectDescriptor { ...@@ -362,7 +372,7 @@ class ObjectDescriptor {
next_enumeration_index_ = next_index; next_enumeration_index_ = next_index;
} }
void Finalize(Isolate* isolate) { void Finalize(LocalIsolate* isolate) {
if (HasDictionaryProperties()) { if (HasDictionaryProperties()) {
DCHECK_EQ(current_computed_index_, computed_properties_->length()); DCHECK_EQ(current_computed_index_, computed_properties_->length());
properties_dictionary_template_->set_next_enumeration_index( properties_dictionary_template_->set_next_enumeration_index(
...@@ -388,33 +398,51 @@ class ObjectDescriptor { ...@@ -388,33 +398,51 @@ class ObjectDescriptor {
Handle<Object> temp_handle_; Handle<Object> temp_handle_;
}; };
template <typename LocalIsolate>
void ClassBoilerplate::AddToPropertiesTemplate( void ClassBoilerplate::AddToPropertiesTemplate(
Isolate* isolate, Handle<NameDictionary> dictionary, Handle<Name> name, LocalIsolate* isolate, Handle<NameDictionary> dictionary, Handle<Name> name,
int key_index, ClassBoilerplate::ValueKind value_kind, Smi value) { int key_index, ClassBoilerplate::ValueKind value_kind, Smi value) {
AddToDictionaryTemplate(isolate, dictionary, name, key_index, value_kind, AddToDictionaryTemplate(isolate, dictionary, name, key_index, value_kind,
value); value);
} }
template void ClassBoilerplate::AddToPropertiesTemplate(
Isolate* isolate, Handle<NameDictionary> dictionary, Handle<Name> name,
int key_index, ClassBoilerplate::ValueKind value_kind, Smi value);
template void ClassBoilerplate::AddToPropertiesTemplate(
OffThreadIsolate* isolate, Handle<NameDictionary> dictionary,
Handle<Name> name, int key_index, ClassBoilerplate::ValueKind value_kind,
Smi value);
template <typename LocalIsolate>
void ClassBoilerplate::AddToElementsTemplate( void ClassBoilerplate::AddToElementsTemplate(
Isolate* isolate, Handle<NumberDictionary> dictionary, uint32_t key, LocalIsolate* isolate, Handle<NumberDictionary> dictionary, uint32_t key,
int key_index, ClassBoilerplate::ValueKind value_kind, Smi value) { int key_index, ClassBoilerplate::ValueKind value_kind, Smi value) {
AddToDictionaryTemplate(isolate, dictionary, key, key_index, value_kind, AddToDictionaryTemplate(isolate, dictionary, key, key_index, value_kind,
value); value);
} }
template void ClassBoilerplate::AddToElementsTemplate(
Isolate* isolate, Handle<NumberDictionary> dictionary, uint32_t key,
int key_index, ClassBoilerplate::ValueKind value_kind, Smi value);
template void ClassBoilerplate::AddToElementsTemplate(
OffThreadIsolate* isolate, Handle<NumberDictionary> dictionary,
uint32_t key, int key_index, ClassBoilerplate::ValueKind value_kind,
Smi value);
template <typename LocalIsolate>
Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate( Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
Isolate* isolate, ClassLiteral* expr) { LocalIsolate* isolate, ClassLiteral* expr) {
// Create a non-caching handle scope to ensure that the temporary handle used // Create a non-caching handle scope to ensure that the temporary handle used
// by ObjectDescriptor for passing Smis around does not corrupt handle cache // by ObjectDescriptor for passing Smis around does not corrupt handle cache
// in CanonicalHandleScope. // in CanonicalHandleScope.
HandleScope scope(isolate); typename LocalIsolate::HandleScopeType scope(isolate);
Factory* factory = isolate->factory(); auto* factory = isolate->factory();
ObjectDescriptor static_desc(kMinimumClassPropertiesCount); ObjectDescriptor<LocalIsolate> static_desc(kMinimumClassPropertiesCount);
ObjectDescriptor instance_desc(kMinimumPrototypePropertiesCount); ObjectDescriptor<LocalIsolate> instance_desc(
kMinimumPrototypePropertiesCount);
for (int i = 0; i < expr->public_members()->length(); i++) { for (int i = 0; i < expr->public_members()->length(); i++) {
ClassLiteral::Property* property = expr->public_members()->at(i); ClassLiteral::Property* property = expr->public_members()->at(i);
ObjectDescriptor& desc = ObjectDescriptor<LocalIsolate>& desc =
property->is_static() ? static_desc : instance_desc; property->is_static() ? static_desc : instance_desc;
if (property->is_computed_name()) { if (property->is_computed_name()) {
if (property->kind() != ClassLiteral::Property::FIELD) { if (property->kind() != ClassLiteral::Property::FIELD) {
...@@ -500,7 +528,7 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate( ...@@ -500,7 +528,7 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
continue; continue;
} }
ObjectDescriptor& desc = ObjectDescriptor<LocalIsolate>& desc =
property->is_static() ? static_desc : instance_desc; property->is_static() ? static_desc : instance_desc;
if (property->is_computed_name()) { if (property->is_computed_name()) {
int computed_name_index = dynamic_argument_index; int computed_name_index = dynamic_argument_index;
...@@ -567,11 +595,10 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate( ...@@ -567,11 +595,10 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
return scope.CloseAndEscape(class_boilerplate); return scope.CloseAndEscape(class_boilerplate);
} }
Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate( template Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
OffThreadIsolate* isolate, ClassLiteral* expr) { Isolate* isolate, ClassLiteral* expr);
// TODO(leszeks): Add class boilerplate support to off-thread finalization. template Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
UNREACHABLE(); OffThreadIsolate* isolate, ClassLiteral* expr);
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -117,22 +117,22 @@ class ClassBoilerplate : public FixedArray { ...@@ -117,22 +117,22 @@ class ClassBoilerplate : public FixedArray {
DECL_ACCESSORS(instance_elements_template, Object) DECL_ACCESSORS(instance_elements_template, Object)
DECL_ACCESSORS(instance_computed_properties, FixedArray) DECL_ACCESSORS(instance_computed_properties, FixedArray)
static void AddToPropertiesTemplate(Isolate* isolate, template <typename LocalIsolate>
static void AddToPropertiesTemplate(LocalIsolate* isolate,
Handle<NameDictionary> dictionary, Handle<NameDictionary> dictionary,
Handle<Name> name, int key_index, Handle<Name> name, int key_index,
ValueKind value_kind, Smi value); ValueKind value_kind, Smi value);
static void AddToElementsTemplate(Isolate* isolate, template <typename LocalIsolate>
static void AddToElementsTemplate(LocalIsolate* isolate,
Handle<NumberDictionary> dictionary, Handle<NumberDictionary> dictionary,
uint32_t key, int key_index, uint32_t key, int key_index,
ValueKind value_kind, Smi value); ValueKind value_kind, Smi value);
static Handle<ClassBoilerplate> BuildClassBoilerplate(Isolate* isolate, template <typename LocalIsolate>
static Handle<ClassBoilerplate> BuildClassBoilerplate(LocalIsolate* isolate,
ClassLiteral* expr); ClassLiteral* expr);
static Handle<ClassBoilerplate> BuildClassBoilerplate(
OffThreadIsolate* isolate, ClassLiteral* expr);
enum { enum {
kFlagsIndex, kFlagsIndex,
kClassPropertiesTemplateIndex, kClassPropertiesTemplateIndex,
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "src/execution/protectors-inl.h" #include "src/execution/protectors-inl.h"
#include "src/heap/factory-inl.h" #include "src/heap/factory-inl.h"
#include "src/heap/heap-inl.h" #include "src/heap/heap-inl.h"
#include "src/heap/off-thread-factory-inl.h"
#include "src/heap/read-only-heap.h" #include "src/heap/read-only-heap.h"
#include "src/ic/ic.h" #include "src/ic/ic.h"
#include "src/init/bootstrapper.h" #include "src/init/bootstrapper.h"
...@@ -4271,13 +4272,22 @@ Handle<FrameArray> FrameArray::EnsureSpace(Isolate* isolate, ...@@ -4271,13 +4272,22 @@ Handle<FrameArray> FrameArray::EnsureSpace(Isolate* isolate,
EnsureSpaceInFixedArray(isolate, array, length)); EnsureSpaceInFixedArray(isolate, array, length));
} }
Handle<DescriptorArray> DescriptorArray::Allocate(Isolate* isolate, template <typename LocalIsolate>
Handle<DescriptorArray> DescriptorArray::Allocate(LocalIsolate* isolate,
int nof_descriptors, int nof_descriptors,
int slack) { int slack,
AllocationType allocation) {
return nof_descriptors + slack == 0 return nof_descriptors + slack == 0
? isolate->factory()->empty_descriptor_array() ? isolate->factory()->empty_descriptor_array()
: isolate->factory()->NewDescriptorArray(nof_descriptors, slack); : isolate->factory()->NewDescriptorArray(nof_descriptors, slack,
allocation);
} }
template Handle<DescriptorArray> DescriptorArray::Allocate(
Isolate* isolate, int nof_descriptors, int slack,
AllocationType allocation);
template Handle<DescriptorArray> DescriptorArray::Allocate(
OffThreadIsolate* isolate, int nof_descriptors, int slack,
AllocationType allocation);
void DescriptorArray::Initialize(EnumCache enum_cache, void DescriptorArray::Initialize(EnumCache enum_cache,
HeapObject undefined_value, HeapObject undefined_value,
...@@ -6533,8 +6543,9 @@ void HashTable<Derived, Shape>::IterateElements(ObjectVisitor* v) { ...@@ -6533,8 +6543,9 @@ void HashTable<Derived, Shape>::IterateElements(ObjectVisitor* v) {
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
template <typename LocalIsolate>
Handle<Derived> HashTable<Derived, Shape>::New( Handle<Derived> HashTable<Derived, Shape>::New(
Isolate* isolate, int at_least_space_for, AllocationType allocation, LocalIsolate* isolate, int at_least_space_for, AllocationType allocation,
MinimumCapacity capacity_option) { MinimumCapacity capacity_option) {
DCHECK_LE(0, at_least_space_for); DCHECK_LE(0, at_least_space_for);
DCHECK_IMPLIES(capacity_option == USE_CUSTOM_MINIMUM_CAPACITY, DCHECK_IMPLIES(capacity_option == USE_CUSTOM_MINIMUM_CAPACITY,
...@@ -6544,15 +6555,16 @@ Handle<Derived> HashTable<Derived, Shape>::New( ...@@ -6544,15 +6555,16 @@ Handle<Derived> HashTable<Derived, Shape>::New(
? at_least_space_for ? at_least_space_for
: ComputeCapacity(at_least_space_for); : ComputeCapacity(at_least_space_for);
if (capacity > HashTable::kMaxCapacity) { if (capacity > HashTable::kMaxCapacity) {
isolate->heap()->FatalProcessOutOfMemory("invalid table size"); isolate->FatalProcessOutOfHeapMemory("invalid table size");
} }
return NewInternal(isolate, capacity, allocation); return NewInternal(isolate, capacity, allocation);
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
template <typename LocalIsolate>
Handle<Derived> HashTable<Derived, Shape>::NewInternal( Handle<Derived> HashTable<Derived, Shape>::NewInternal(
Isolate* isolate, int capacity, AllocationType allocation) { LocalIsolate* isolate, int capacity, AllocationType allocation) {
Factory* factory = isolate->factory(); auto* factory = isolate->factory();
int length = EntryToIndex(InternalIndex(capacity)); int length = EntryToIndex(InternalIndex(capacity));
Handle<FixedArray> array = factory->NewFixedArrayWithMap( Handle<FixedArray> array = factory->NewFixedArrayWithMap(
Shape::GetMap(ReadOnlyRoots(isolate)), length, allocation); Shape::GetMap(ReadOnlyRoots(isolate)), length, allocation);
...@@ -6677,8 +6689,10 @@ void HashTable<Derived, Shape>::Rehash(ReadOnlyRoots roots) { ...@@ -6677,8 +6689,10 @@ void HashTable<Derived, Shape>::Rehash(ReadOnlyRoots roots) {
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
template <typename LocalIsolate>
Handle<Derived> HashTable<Derived, Shape>::EnsureCapacity( Handle<Derived> HashTable<Derived, Shape>::EnsureCapacity(
Isolate* isolate, Handle<Derived> table, int n, AllocationType allocation) { LocalIsolate* isolate, Handle<Derived> table, int n,
AllocationType allocation) {
if (table->HasSufficientCapacityToAdd(n)) return table; if (table->HasSufficientCapacityToAdd(n)) return table;
int capacity = table->Capacity(); int capacity = table->Capacity();
...@@ -7270,8 +7284,9 @@ void CompilationCacheTable::Remove(Object value) { ...@@ -7270,8 +7284,9 @@ void CompilationCacheTable::Remove(Object value) {
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
template <typename LocalIsolate>
Handle<Derived> BaseNameDictionary<Derived, Shape>::New( Handle<Derived> BaseNameDictionary<Derived, Shape>::New(
Isolate* isolate, int at_least_space_for, AllocationType allocation, LocalIsolate* isolate, int at_least_space_for, AllocationType allocation,
MinimumCapacity capacity_option) { MinimumCapacity capacity_option) {
DCHECK_LE(0, at_least_space_for); DCHECK_LE(0, at_least_space_for);
Handle<Derived> dict = Dictionary<Derived, Shape>::New( Handle<Derived> dict = Dictionary<Derived, Shape>::New(
...@@ -7343,10 +7358,11 @@ Handle<Derived> Dictionary<Derived, Shape>::AtPut(Isolate* isolate, ...@@ -7343,10 +7358,11 @@ Handle<Derived> Dictionary<Derived, Shape>::AtPut(Isolate* isolate,
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
template <typename LocalIsolate>
Handle<Derived> Handle<Derived>
BaseNameDictionary<Derived, Shape>::AddNoUpdateNextEnumerationIndex( BaseNameDictionary<Derived, Shape>::AddNoUpdateNextEnumerationIndex(
Isolate* isolate, Handle<Derived> dictionary, Key key, Handle<Object> value, LocalIsolate* isolate, Handle<Derived> dictionary, Key key,
PropertyDetails details, InternalIndex* entry_out) { Handle<Object> value, PropertyDetails details, InternalIndex* entry_out) {
// Insert element at empty or deleted entry. // Insert element at empty or deleted entry.
return Dictionary<Derived, Shape>::Add(isolate, dictionary, key, value, return Dictionary<Derived, Shape>::Add(isolate, dictionary, key, value,
details, entry_out); details, entry_out);
...@@ -7371,7 +7387,8 @@ Handle<Derived> BaseNameDictionary<Derived, Shape>::Add( ...@@ -7371,7 +7387,8 @@ Handle<Derived> BaseNameDictionary<Derived, Shape>::Add(
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
Handle<Derived> Dictionary<Derived, Shape>::Add(Isolate* isolate, template <typename LocalIsolate>
Handle<Derived> Dictionary<Derived, Shape>::Add(LocalIsolate* isolate,
Handle<Derived> dictionary, Handle<Derived> dictionary,
Key key, Handle<Object> value, Key key, Handle<Object> value,
PropertyDetails details, PropertyDetails details,
...@@ -8178,24 +8195,61 @@ Address Smi::LexicographicCompare(Isolate* isolate, Smi x, Smi y) { ...@@ -8178,24 +8195,61 @@ Address Smi::LexicographicCompare(Isolate* isolate, Smi x, Smi y) {
// Please note this list is compiler dependent. // Please note this list is compiler dependent.
// Keep this at the end of this file // Keep this at the end of this file
#define EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \ #define EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \ template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
HashTable<DERIVED, SHAPE>; HashTable<DERIVED, SHAPE>; \
\
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::New(Isolate*, int, AllocationType, \
MinimumCapacity); \
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::New(OffThreadIsolate*, int, AllocationType, \
MinimumCapacity); \
\
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::EnsureCapacity(Isolate*, Handle<DERIVED>, int, \
AllocationType); \
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) Handle<DERIVED> \
HashTable<DERIVED, SHAPE>::EnsureCapacity( \
OffThreadIsolate*, Handle<DERIVED>, int, AllocationType);
#define EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(DERIVED, SHAPE) \ #define EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(DERIVED, SHAPE) \
EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \ EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \ template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
ObjectHashTableBase<DERIVED, SHAPE>; ObjectHashTableBase<DERIVED, SHAPE>;
#define EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \ #define EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \
EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \ EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \ template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
Dictionary<DERIVED, SHAPE>; Dictionary<DERIVED, SHAPE>; \
\
#define EXTERN_DEFINE_BASE_NAME_DICTIONARY(DERIVED, SHAPE) \ template V8_EXPORT_PRIVATE Handle<DERIVED> Dictionary<DERIVED, SHAPE>::Add( \
EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \ Isolate* isolate, Handle<DERIVED>, Key, Handle<Object>, PropertyDetails, \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \ InternalIndex*); \
BaseNameDictionary<DERIVED, SHAPE>; template V8_EXPORT_PRIVATE Handle<DERIVED> Dictionary<DERIVED, SHAPE>::Add( \
OffThreadIsolate* isolate, Handle<DERIVED>, Key, Handle<Object>, \
PropertyDetails, InternalIndex*);
#define EXTERN_DEFINE_BASE_NAME_DICTIONARY(DERIVED, SHAPE) \
EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
BaseNameDictionary<DERIVED, SHAPE>; \
\
template V8_EXPORT_PRIVATE Handle<DERIVED> \
BaseNameDictionary<DERIVED, SHAPE>::New(Isolate*, int, AllocationType, \
MinimumCapacity); \
template V8_EXPORT_PRIVATE Handle<DERIVED> \
BaseNameDictionary<DERIVED, SHAPE>::New(OffThreadIsolate*, int, \
AllocationType, MinimumCapacity); \
\
template Handle<DERIVED> \
BaseNameDictionary<DERIVED, SHAPE>::AddNoUpdateNextEnumerationIndex( \
Isolate* isolate, Handle<DERIVED>, Key, Handle<Object>, PropertyDetails, \
InternalIndex*); \
template Handle<DERIVED> \
BaseNameDictionary<DERIVED, SHAPE>::AddNoUpdateNextEnumerationIndex( \
OffThreadIsolate* isolate, Handle<DERIVED>, Key, Handle<Object>, \
PropertyDetails, InternalIndex*);
EXTERN_DEFINE_HASH_TABLE(StringTable, StringTableShape) EXTERN_DEFINE_HASH_TABLE(StringTable, StringTableShape)
EXTERN_DEFINE_HASH_TABLE(StringSet, StringSetShape) EXTERN_DEFINE_HASH_TABLE(StringSet, StringSetShape)
......
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