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 {
namespace internal {
class Isolate;
class OffThreadIsolate;
class OffThreadLogger;
// HiddenOffThreadFactory parallels Isolate's HiddenFactory
......
......@@ -196,6 +196,13 @@ inline SealHandleScope::~SealHandleScope() {
#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 v8
......
......@@ -368,6 +368,9 @@ class OffThreadHandleScope {
// Off-thread Handles are allocated in the parse/compile zone, and not
// cleared out, so the scope doesn't have to do anything
explicit OffThreadHandleScope(OffThreadIsolate* isolate) {}
template <typename T>
inline Handle<T> CloseAndEscape(Handle<T> handle_value);
};
} // namespace internal
......
......@@ -55,6 +55,15 @@ Handle<Struct> FactoryBase<Impl>::NewStruct(InstanceType type,
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>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArray(int length,
AllocationType allocation) {
......@@ -637,6 +646,32 @@ Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo() {
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>
Handle<SeqOneByteString>
FactoryBase<Impl>::AllocateRawOneByteInternalizedString(int length,
......
......@@ -29,6 +29,7 @@ class UncompiledDataWithoutPreparseData;
class UncompiledDataWithPreparseData;
class BytecodeArray;
class CoverageInfo;
class ClassPositions;
struct SourceRange;
template <typename T>
class ZoneVector;
......@@ -64,6 +65,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
Handle<Struct> NewStruct(InstanceType type,
AllocationType allocation = AllocationType::kYoung);
// Create a pre-tenured empty AccessorPair.
Handle<AccessorPair> NewAccessorPair();
// Allocates a fixed array initialized with undefined values.
Handle<FixedArray> NewFixedArray(
int length, AllocationType allocation = AllocationType::kYoung);
......@@ -175,6 +179,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) FactoryBase {
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:
// Allocate memory for an uninitialized array (e.g., a FixedArray or similar).
HeapObject AllocateRawArray(int size, AllocationType allocation);
......
......@@ -501,14 +501,6 @@ Handle<OrderedNameDictionary> Factory::NewOrderedNameDictionary() {
.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> object =
Handle<PropertyDescriptorObject>::cast(
......@@ -1361,21 +1353,6 @@ Handle<PropertyCell> Factory::NewPropertyCell(Handle<Name> name,
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,
int slack) {
int capacity = TransitionArray::LengthFor(number_of_transitions + slack);
......@@ -3019,14 +2996,6 @@ Handle<String> Factory::SizeToString(size_t value, bool check_cache) {
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) {
DCHECK(!shared->HasDebugInfo());
Heap* heap = isolate()->heap();
......
......@@ -167,9 +167,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<Tuple2> NewTuple2(Handle<Object> value1, Handle<Object> value2,
AllocationType allocation);
// Create a pre-tenured empty AccessorPair.
Handle<AccessorPair> NewAccessorPair();
// Create a new PropertyDescriptorObject struct.
Handle<PropertyDescriptorObject> NewPropertyDescriptorObject();
......@@ -381,8 +378,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<FeedbackCell> NewOneClosureCell(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,
int slack = 0);
......@@ -730,7 +725,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
int end_position, Handle<SharedFunctionInfo> shared_info,
int bytecode_offset, Handle<Script> script, Handle<Object> stack_frames);
Handle<ClassPositions> NewClassPositions(int start, int end);
Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
// Return a map for given number of properties using the map cache in the
......
......@@ -5,6 +5,7 @@
#ifndef V8_OBJECTS_DESCRIPTOR_ARRAY_H_
#define V8_OBJECTS_DESCRIPTOR_ARRAY_H_
#include "src/common/globals.h"
#include "src/objects/fixed-array.h"
// TODO(jkummerow): Consider forward-declaring instead.
#include "src/base/bit-field.h"
......@@ -126,9 +127,10 @@ class DescriptorArray : public HeapObject {
// Allocates a DescriptorArray, but returns the singleton
// empty descriptor array object if number_of_descriptors is 0.
V8_EXPORT_PRIVATE static Handle<DescriptorArray> Allocate(Isolate* isolate,
int nof_descriptors,
int slack);
template <typename LocalIsolate>
V8_EXPORT_PRIVATE static Handle<DescriptorArray> Allocate(
LocalIsolate* isolate, int nof_descriptors, int slack,
AllocationType allocation = AllocationType::kYoung);
void Initialize(EnumCache enum_cache, HeapObject undefined_value,
int nof_descriptors, int slack);
......
......@@ -264,6 +264,11 @@ Handle<Object> NumberDictionaryBaseShape::AsHandle(Isolate* isolate,
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) {
return roots.number_dictionary_map_handle();
}
......@@ -302,6 +307,12 @@ Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate,
return key;
}
Handle<Object> NameDictionaryShape::AsHandle(OffThreadIsolate* isolate,
Handle<Name> key) {
DCHECK(key->IsUniqueName());
return key;
}
template <typename Dictionary>
PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary dict,
InternalIndex entry) {
......
......@@ -72,8 +72,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
// Garbage collection support.
inline ObjectSlot RawFieldOfValueAt(InternalIndex entry);
template <typename LocalIsolate>
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,
InternalIndex* entry_out = nullptr);
......@@ -111,6 +112,8 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
static inline uint32_t Hash(ReadOnlyRoots roots, Handle<Name> key);
static inline uint32_t HashForObject(ReadOnlyRoots roots, Object object);
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 const int kPrefixSize = 2;
static const int kEntrySize = 3;
......@@ -133,8 +136,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
inline int Hash() const;
// Creates a new dictionary.
template <typename LocalIsolate>
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,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY);
......@@ -161,8 +165,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
Handle<FixedArray> storage, KeyCollectionMode mode,
KeyAccumulator* accumulator);
template <typename LocalIsolate>
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,
InternalIndex* entry_out = nullptr);
......@@ -246,6 +251,8 @@ class NumberDictionaryBaseShape : public BaseDictionaryShape<uint32_t> {
public:
static inline bool IsMatch(uint32_t key, Object other);
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 HashForObject(ReadOnlyRoots roots, Object object);
......
......@@ -2723,14 +2723,12 @@ class FastSealedObjectElementsAccessor
class FastPackedSealedObjectElementsAccessor
: public FastSealedObjectElementsAccessor<
FastPackedSealedObjectElementsAccessor,
ElementsKindTraits<PACKED_SEALED_ELEMENTS>> {
};
ElementsKindTraits<PACKED_SEALED_ELEMENTS>> {};
class FastHoleySealedObjectElementsAccessor
: public FastSealedObjectElementsAccessor<
FastHoleySealedObjectElementsAccessor,
ElementsKindTraits<HOLEY_SEALED_ELEMENTS>> {
};
ElementsKindTraits<HOLEY_SEALED_ELEMENTS>> {};
template <typename Subclass, typename KindTraits>
class FastFrozenObjectElementsAccessor
......@@ -2802,14 +2800,12 @@ class FastFrozenObjectElementsAccessor
class FastPackedFrozenObjectElementsAccessor
: public FastFrozenObjectElementsAccessor<
FastPackedFrozenObjectElementsAccessor,
ElementsKindTraits<PACKED_FROZEN_ELEMENTS>> {
};
ElementsKindTraits<PACKED_FROZEN_ELEMENTS>> {};
class FastHoleyFrozenObjectElementsAccessor
: public FastFrozenObjectElementsAccessor<
FastHoleyFrozenObjectElementsAccessor,
ElementsKindTraits<HOLEY_FROZEN_ELEMENTS>> {
};
ElementsKindTraits<HOLEY_FROZEN_ELEMENTS>> {};
class FastHoleyObjectElementsAccessor
: public FastSmiOrObjectElementsAccessor<
......
......@@ -129,8 +129,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
using Key = typename Shape::Key;
// Returns a new HashTable object.
template <typename LocalIsolate>
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,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY);
......@@ -192,8 +193,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
}
// Ensure enough space for n additional elements.
template <typename LocalIsolate>
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);
// Returns true if this table has sufficient capacity for adding n elements.
......@@ -202,8 +204,9 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
protected:
friend class ObjectHashTable;
template <typename LocalIsolate>
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
// has the given hash value.
......@@ -244,9 +247,23 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
OBJECT_CONSTRUCTORS(HashTable, HashTableBase);
};
#define EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
HashTable<class DERIVED, SHAPE>;
#define EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
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.
class HashTableKey {
......
......@@ -7,8 +7,11 @@
#include "src/ast/ast.h"
#include "src/base/logging.h"
#include "src/builtins/accessors.h"
#include "src/common/globals.h"
#include "src/execution/isolate.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/literal-objects-inl.h"
#include "src/objects/objects-inl.h"
......@@ -28,8 +31,9 @@ inline int EncodeComputedEntry(ClassBoilerplate::ValueKind value_kind,
return flags;
}
template <typename LocalIsolate>
void AddToDescriptorArrayTemplate(
Isolate* isolate, Handle<DescriptorArray> descriptor_array_template,
LocalIsolate* isolate, Handle<DescriptorArray> descriptor_array_template,
Handle<Name> name, ClassBoilerplate::ValueKind value_kind,
Handle<Object> value) {
InternalIndex entry = descriptor_array_template->Search(
......@@ -80,17 +84,19 @@ void AddToDescriptorArrayTemplate(
}
}
template <typename LocalIsolate>
Handle<NameDictionary> DictionaryAddNoUpdateNextEnumerationIndex(
Isolate* isolate, Handle<NameDictionary> dictionary, Handle<Name> name,
LocalIsolate* isolate, Handle<NameDictionary> dictionary, Handle<Name> name,
Handle<Object> value, PropertyDetails details,
InternalIndex* entry_out = nullptr) {
return NameDictionary::AddNoUpdateNextEnumerationIndex(
isolate, dictionary, name, value, details, entry_out);
}
template <typename LocalIsolate>
Handle<NumberDictionary> DictionaryAddNoUpdateNextEnumerationIndex(
Isolate* isolate, Handle<NumberDictionary> dictionary, uint32_t element,
Handle<Object> value, PropertyDetails details,
LocalIsolate* isolate, Handle<NumberDictionary> dictionary,
uint32_t element, Handle<Object> value, PropertyDetails details,
InternalIndex* entry_out = nullptr) {
// NumberDictionary does not maintain the enumeration order, so it's
// a normal Add().
......@@ -121,9 +127,10 @@ inline int GetExistingValueIndex(Object value) {
return value.IsSmi() ? Smi::ToInt(value) : -1;
}
template <typename Dictionary, typename Key>
void AddToDictionaryTemplate(Isolate* isolate, Handle<Dictionary> dictionary,
Key key, int key_index,
template <typename LocalIsolate, typename Dictionary, typename Key>
void AddToDictionaryTemplate(LocalIsolate* isolate,
Handle<Dictionary> dictionary, Key key,
int key_index,
ClassBoilerplate::ValueKind value_kind,
Smi value) {
InternalIndex entry = dictionary->FindEntry(ReadOnlyRoots(isolate), key);
......@@ -253,6 +260,7 @@ void AddToDictionaryTemplate(Isolate* isolate, Handle<Dictionary> dictionary,
// Helper class that eases building of a properties, elements and computed
// properties templates.
template <typename LocalIsolate>
class ObjectDescriptor {
public:
void IncComputedCount() { ++computed_count_; }
......@@ -281,14 +289,16 @@ class ObjectDescriptor {
return computed_properties_;
}
void CreateTemplates(Isolate* isolate) {
Factory* factory = isolate->factory();
void CreateTemplates(LocalIsolate* isolate) {
auto* factory = isolate->factory();
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 (HasDictionaryProperties()) {
properties_dictionary_template_ = NameDictionary::New(
isolate, property_count_ + computed_count_ + property_slack_);
isolate, property_count_ + computed_count_ + property_slack_,
AllocationType::kOld);
} else {
descriptor_array_template_ = DescriptorArray::Allocate(
isolate, 0, property_count_ + property_slack_);
......@@ -306,8 +316,8 @@ class ObjectDescriptor {
temp_handle_ = handle(Smi::zero(), isolate);
}
void AddConstant(Isolate* isolate, Handle<Name> name, Handle<Object> value,
PropertyAttributes attribs) {
void AddConstant(LocalIsolate* isolate, Handle<Name> name,
Handle<Object> value, PropertyAttributes attribs) {
bool is_accessor = value->IsAccessorInfo();
DCHECK(!value->IsAccessorPair());
if (HasDictionaryProperties()) {
......@@ -325,7 +335,7 @@ class ObjectDescriptor {
}
}
void AddNamedProperty(Isolate* isolate, Handle<Name> name,
void AddNamedProperty(LocalIsolate* isolate, Handle<Name> name,
ClassBoilerplate::ValueKind value_kind,
int value_index) {
Smi value = Smi::FromInt(value_index);
......@@ -340,7 +350,7 @@ class ObjectDescriptor {
}
}
void AddIndexedProperty(Isolate* isolate, uint32_t element,
void AddIndexedProperty(LocalIsolate* isolate, uint32_t element,
ClassBoilerplate::ValueKind value_kind,
int value_index) {
Smi value = Smi::FromInt(value_index);
......@@ -362,7 +372,7 @@ class ObjectDescriptor {
next_enumeration_index_ = next_index;
}
void Finalize(Isolate* isolate) {
void Finalize(LocalIsolate* isolate) {
if (HasDictionaryProperties()) {
DCHECK_EQ(current_computed_index_, computed_properties_->length());
properties_dictionary_template_->set_next_enumeration_index(
......@@ -388,33 +398,51 @@ class ObjectDescriptor {
Handle<Object> temp_handle_;
};
template <typename LocalIsolate>
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) {
AddToDictionaryTemplate(isolate, dictionary, name, key_index, value_kind,
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(
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) {
AddToDictionaryTemplate(isolate, dictionary, key, key_index, value_kind,
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(
Isolate* isolate, ClassLiteral* expr) {
LocalIsolate* isolate, ClassLiteral* expr) {
// Create a non-caching handle scope to ensure that the temporary handle used
// by ObjectDescriptor for passing Smis around does not corrupt handle cache
// in CanonicalHandleScope.
HandleScope scope(isolate);
Factory* factory = isolate->factory();
ObjectDescriptor static_desc(kMinimumClassPropertiesCount);
ObjectDescriptor instance_desc(kMinimumPrototypePropertiesCount);
typename LocalIsolate::HandleScopeType scope(isolate);
auto* factory = isolate->factory();
ObjectDescriptor<LocalIsolate> static_desc(kMinimumClassPropertiesCount);
ObjectDescriptor<LocalIsolate> instance_desc(
kMinimumPrototypePropertiesCount);
for (int i = 0; i < expr->public_members()->length(); i++) {
ClassLiteral::Property* property = expr->public_members()->at(i);
ObjectDescriptor& desc =
ObjectDescriptor<LocalIsolate>& desc =
property->is_static() ? static_desc : instance_desc;
if (property->is_computed_name()) {
if (property->kind() != ClassLiteral::Property::FIELD) {
......@@ -500,7 +528,7 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
continue;
}
ObjectDescriptor& desc =
ObjectDescriptor<LocalIsolate>& desc =
property->is_static() ? static_desc : instance_desc;
if (property->is_computed_name()) {
int computed_name_index = dynamic_argument_index;
......@@ -567,11 +595,10 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
return scope.CloseAndEscape(class_boilerplate);
}
Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
OffThreadIsolate* isolate, ClassLiteral* expr) {
// TODO(leszeks): Add class boilerplate support to off-thread finalization.
UNREACHABLE();
}
template Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
Isolate* isolate, ClassLiteral* expr);
template Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
OffThreadIsolate* isolate, ClassLiteral* expr);
} // namespace internal
} // namespace v8
......@@ -117,22 +117,22 @@ class ClassBoilerplate : public FixedArray {
DECL_ACCESSORS(instance_elements_template, Object)
DECL_ACCESSORS(instance_computed_properties, FixedArray)
static void AddToPropertiesTemplate(Isolate* isolate,
template <typename LocalIsolate>
static void AddToPropertiesTemplate(LocalIsolate* isolate,
Handle<NameDictionary> dictionary,
Handle<Name> name, int key_index,
ValueKind value_kind, Smi value);
static void AddToElementsTemplate(Isolate* isolate,
template <typename LocalIsolate>
static void AddToElementsTemplate(LocalIsolate* isolate,
Handle<NumberDictionary> dictionary,
uint32_t key, int key_index,
ValueKind value_kind, Smi value);
static Handle<ClassBoilerplate> BuildClassBoilerplate(Isolate* isolate,
template <typename LocalIsolate>
static Handle<ClassBoilerplate> BuildClassBoilerplate(LocalIsolate* isolate,
ClassLiteral* expr);
static Handle<ClassBoilerplate> BuildClassBoilerplate(
OffThreadIsolate* isolate, ClassLiteral* expr);
enum {
kFlagsIndex,
kClassPropertiesTemplateIndex,
......
This diff is collapsed.
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