Commit 9526c293 authored by Camillo's avatar Camillo Committed by V8 LUCI CQ

Dehandlify more code


Bug: v8:11263
Change-Id: Ia53518d52f906c96afafc084af99679bd64b46fa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3866177
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82888}
parent b7c71a6d
...@@ -135,15 +135,18 @@ Handle<ModuleRequest> SourceTextModuleDescriptor::AstModuleRequest::Serialize( ...@@ -135,15 +135,18 @@ Handle<ModuleRequest> SourceTextModuleDescriptor::AstModuleRequest::Serialize(
static_cast<int>(import_assertions()->size() * static_cast<int>(import_assertions()->size() *
ModuleRequest::kAssertionEntrySize), ModuleRequest::kAssertionEntrySize),
AllocationType::kOld); AllocationType::kOld);
{
int i = 0; DisallowGarbageCollection no_gc;
for (auto iter = import_assertions()->cbegin(); auto raw_import_assertions = *import_assertions_array;
iter != import_assertions()->cend(); int i = 0;
++iter, i += ModuleRequest::kAssertionEntrySize) { for (auto iter = import_assertions()->cbegin();
import_assertions_array->set(i, *iter->first->string()); iter != import_assertions()->cend();
import_assertions_array->set(i + 1, *iter->second.first->string()); ++iter, i += ModuleRequest::kAssertionEntrySize) {
import_assertions_array->set(i + 2, raw_import_assertions.set(i, *iter->first->string());
Smi::FromInt(iter->second.second.beg_pos)); raw_import_assertions.set(i + 1, *iter->second.first->string());
raw_import_assertions.set(i + 2,
Smi::FromInt(iter->second.second.beg_pos));
}
} }
return v8::internal::ModuleRequest::New(isolate, specifier()->string(), return v8::internal::ModuleRequest::New(isolate, specifier()->string(),
import_assertions_array, position()); import_assertions_array, position());
......
...@@ -755,9 +755,13 @@ class ArrayConcatVisitor { ...@@ -755,9 +755,13 @@ class ArrayConcatVisitor {
isolate_->factory()->NewNumber(static_cast<double>(index_offset_)); isolate_->factory()->NewNumber(static_cast<double>(index_offset_));
Handle<Map> map = JSObject::GetElementsTransitionMap( Handle<Map> map = JSObject::GetElementsTransitionMap(
array, fast_elements() ? HOLEY_ELEMENTS : DICTIONARY_ELEMENTS); array, fast_elements() ? HOLEY_ELEMENTS : DICTIONARY_ELEMENTS);
array->set_length(*length); {
array->set_elements(*storage_fixed_array()); DisallowGarbageCollection no_gc;
array->set_map(*map, kReleaseStore); auto raw = *array;
raw.set_length(*length);
raw.set_elements(*storage_fixed_array());
raw.set_map(*map, kReleaseStore);
}
return array; return array;
} }
......
...@@ -850,70 +850,81 @@ class MaglevCodeGeneratorImpl final { ...@@ -850,70 +850,81 @@ class MaglevCodeGeneratorImpl final {
code_gen_state_.compilation_info() code_gen_state_.compilation_info()
->translation_array_builder() ->translation_array_builder()
.ToTranslationArray(isolate()->factory()); .ToTranslationArray(isolate()->factory());
{
DisallowGarbageCollection no_gc;
auto raw_data = *data;
data->SetTranslationByteArray(*translation_array); raw_data.SetTranslationByteArray(*translation_array);
// TODO(leszeks): Fix with the real inlined function count. // TODO(leszeks): Fix with the real inlined function count.
data->SetInlinedFunctionCount(Smi::zero()); raw_data.SetInlinedFunctionCount(Smi::zero());
// TODO(leszeks): Support optimization IDs // TODO(leszeks): Support optimization IDs
data->SetOptimizationId(Smi::zero()); raw_data.SetOptimizationId(Smi::zero());
DCHECK_NE(deopt_exit_start_offset_, -1); DCHECK_NE(deopt_exit_start_offset_, -1);
data->SetDeoptExitStart(Smi::FromInt(deopt_exit_start_offset_)); raw_data.SetDeoptExitStart(Smi::FromInt(deopt_exit_start_offset_));
data->SetEagerDeoptCount(Smi::FromInt(eager_deopt_count)); raw_data.SetEagerDeoptCount(Smi::FromInt(eager_deopt_count));
data->SetLazyDeoptCount(Smi::FromInt(lazy_deopt_count)); raw_data.SetLazyDeoptCount(Smi::FromInt(lazy_deopt_count));
data->SetSharedFunctionInfo(*code_gen_state_.compilation_info() raw_data.SetSharedFunctionInfo(*code_gen_state_.compilation_info()
->toplevel_compilation_unit() ->toplevel_compilation_unit()
->shared_function_info() ->shared_function_info()
.object()); .object());
}
IdentityMap<int, base::DefaultAllocationPolicy>& deopt_literals = IdentityMap<int, base::DefaultAllocationPolicy>& deopt_literals =
code_gen_state_.compilation_info()->deopt_literals(); code_gen_state_.compilation_info()->deopt_literals();
Handle<DeoptimizationLiteralArray> literals = Handle<DeoptimizationLiteralArray> literals =
isolate()->factory()->NewDeoptimizationLiteralArray( isolate()->factory()->NewDeoptimizationLiteralArray(
deopt_literals.size() + 1); deopt_literals.size() + 1);
// TODO(leszeks): Fix with the real inlining positions.
Handle<PodArray<InliningPosition>> inlining_positions =
PodArray<InliningPosition>::New(isolate(), 0);
DisallowGarbageCollection no_gc;
auto raw_literals = *literals;
auto raw_data = *data;
IdentityMap<int, base::DefaultAllocationPolicy>::IteratableScope iterate( IdentityMap<int, base::DefaultAllocationPolicy>::IteratableScope iterate(
&deopt_literals); &deopt_literals);
for (auto it = iterate.begin(); it != iterate.end(); ++it) { for (auto it = iterate.begin(); it != iterate.end(); ++it) {
literals->set(*it.entry(), it.key()); raw_literals.set(*it.entry(), it.key());
} }
// Add the bytecode to the deopt literals to make sure it's held strongly. // Add the bytecode to the deopt literals to make sure it's held strongly.
// TODO(leszeks): Do this for inlined functions too. // TODO(leszeks): Do this for inlined functions too.
literals->set(deopt_literals.size(), *code_gen_state_.compilation_info() raw_literals.set(deopt_literals.size(), *code_gen_state_.compilation_info()
->toplevel_compilation_unit() ->toplevel_compilation_unit()
->bytecode() ->bytecode()
.object()); .object());
data->SetLiteralArray(*literals); raw_data.SetLiteralArray(raw_literals);
// TODO(leszeks): Fix with the real inlining positions. // TODO(leszeks): Fix with the real inlining positions.
Handle<PodArray<InliningPosition>> inlining_positions = raw_data.SetInliningPositions(*inlining_positions);
PodArray<InliningPosition>::New(isolate(), 0);
data->SetInliningPositions(*inlining_positions);
// TODO(leszeks): Fix once we have OSR. // TODO(leszeks): Fix once we have OSR.
BytecodeOffset osr_offset = BytecodeOffset::None(); BytecodeOffset osr_offset = BytecodeOffset::None();
data->SetOsrBytecodeOffset(Smi::FromInt(osr_offset.ToInt())); raw_data.SetOsrBytecodeOffset(Smi::FromInt(osr_offset.ToInt()));
data->SetOsrPcOffset(Smi::FromInt(-1)); raw_data.SetOsrPcOffset(Smi::FromInt(-1));
// Populate deoptimization entries. // Populate deoptimization entries.
int i = 0; int i = 0;
for (EagerDeoptInfo* deopt_info : code_gen_state_.eager_deopts()) { for (EagerDeoptInfo* deopt_info : code_gen_state_.eager_deopts()) {
DCHECK_NE(deopt_info->translation_index, -1); DCHECK_NE(deopt_info->translation_index, -1);
data->SetBytecodeOffset(i, deopt_info->state.bytecode_position); raw_data.SetBytecodeOffset(i, deopt_info->state.bytecode_position);
data->SetTranslationIndex(i, Smi::FromInt(deopt_info->translation_index)); raw_data.SetTranslationIndex(i,
data->SetPc(i, Smi::FromInt(deopt_info->deopt_entry_label.pos())); Smi::FromInt(deopt_info->translation_index));
raw_data.SetPc(i, Smi::FromInt(deopt_info->deopt_entry_label.pos()));
#ifdef DEBUG #ifdef DEBUG
data->SetNodeId(i, Smi::FromInt(i)); raw_data.SetNodeId(i, Smi::FromInt(i));
#endif // DEBUG #endif // DEBUG
i++; i++;
} }
for (LazyDeoptInfo* deopt_info : code_gen_state_.lazy_deopts()) { for (LazyDeoptInfo* deopt_info : code_gen_state_.lazy_deopts()) {
DCHECK_NE(deopt_info->translation_index, -1); DCHECK_NE(deopt_info->translation_index, -1);
data->SetBytecodeOffset(i, deopt_info->state.bytecode_position); raw_data.SetBytecodeOffset(i, deopt_info->state.bytecode_position);
data->SetTranslationIndex(i, Smi::FromInt(deopt_info->translation_index)); raw_data.SetTranslationIndex(i,
data->SetPc(i, Smi::FromInt(deopt_info->deopt_entry_label.pos())); Smi::FromInt(deopt_info->translation_index));
raw_data.SetPc(i, Smi::FromInt(deopt_info->deopt_entry_label.pos()));
#ifdef DEBUG #ifdef DEBUG
data->SetNodeId(i, Smi::FromInt(i)); raw_data.SetNodeId(i, Smi::FromInt(i));
#endif // DEBUG #endif // DEBUG
i++; i++;
} }
......
...@@ -923,11 +923,13 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map, ...@@ -923,11 +923,13 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map,
// Transition to POLYMORPHIC. // Transition to POLYMORPHIC.
Handle<WeakFixedArray> array = Handle<WeakFixedArray> array =
CreateArrayOfSize(2 * kCloneObjectPolymorphicEntrySize); CreateArrayOfSize(2 * kCloneObjectPolymorphicEntrySize);
array->Set(0, HeapObjectReference::Weak(*feedback)); DisallowGarbageCollection no_gc;
array->Set(1, GetFeedbackExtra()); auto raw_array = *array;
array->Set(2, HeapObjectReference::Weak(*source_map)); raw_array.Set(0, HeapObjectReference::Weak(*feedback));
array->Set(3, MaybeObject::FromObject(*result_map)); raw_array.Set(1, GetFeedbackExtra());
SetFeedback(*array, UPDATE_WRITE_BARRIER, raw_array.Set(2, HeapObjectReference::Weak(*source_map));
raw_array.Set(3, MaybeObject::FromObject(*result_map));
SetFeedback(raw_array, UPDATE_WRITE_BARRIER,
HeapObjectReference::ClearedValue(isolate)); HeapObjectReference::ClearedValue(isolate));
} }
break; break;
......
...@@ -327,12 +327,13 @@ Handle<NameToIndexHashTable> NameToIndexHashTable::Add( ...@@ -327,12 +327,13 @@ Handle<NameToIndexHashTable> NameToIndexHashTable::Add(
SLOW_DCHECK(table->FindEntry(isolate, key).is_not_found()); SLOW_DCHECK(table->FindEntry(isolate, key).is_not_found());
// Check whether the dictionary should be extended. // Check whether the dictionary should be extended.
table = EnsureCapacity(isolate, table); table = EnsureCapacity(isolate, table);
DisallowGarbageCollection no_gc;
auto raw_table = *table;
// Compute the key object. // Compute the key object.
InternalIndex entry = table->FindInsertionEntry(isolate, key->hash()); InternalIndex entry = raw_table.FindInsertionEntry(isolate, key->hash());
table->set(EntryToIndex(entry), *key); raw_table.set(EntryToIndex(entry), *key);
table->set(EntryToValueIndex(entry), Smi::FromInt(index)); raw_table.set(EntryToValueIndex(entry), Smi::FromInt(index));
table->ElementAdded(); raw_table.ElementAdded();
return table; return table;
} }
......
...@@ -3981,18 +3981,25 @@ bool DescriptorArray::IsEqualUpTo(DescriptorArray desc, int nof_descriptors) { ...@@ -3981,18 +3981,25 @@ bool DescriptorArray::IsEqualUpTo(DescriptorArray desc, int nof_descriptors) {
Handle<FixedArray> FixedArray::SetAndGrow(Isolate* isolate, Handle<FixedArray> FixedArray::SetAndGrow(Isolate* isolate,
Handle<FixedArray> array, int index, Handle<FixedArray> array, int index,
Handle<Object> value) { Handle<Object> value) {
if (index < array->length()) { int src_length = array->length();
if (index < src_length) {
array->set(index, *value); array->set(index, *value);
return array; return array;
} }
int capacity = array->length(); int capacity = src_length;
do { do {
capacity = JSObject::NewElementsCapacity(capacity); capacity = JSObject::NewElementsCapacity(capacity);
} while (capacity <= index); } while (capacity <= index);
Handle<FixedArray> new_array = isolate->factory()->NewFixedArray(capacity); Handle<FixedArray> new_array = isolate->factory()->NewFixedArray(capacity);
array->CopyTo(0, *new_array, 0, array->length());
new_array->FillWithHoles(array->length(), new_array->length()); DisallowGarbageCollection no_gc;
new_array->set(index, *value); auto raw_src = *array;
auto raw_dst = *new_array;
raw_src.CopyTo(0, raw_dst, 0, src_length);
DCHECK_EQ(raw_dst.length(), capacity);
raw_dst.FillWithHoles(src_length, capacity);
raw_dst.set(index, *value);
return new_array; return new_array;
} }
...@@ -4559,8 +4566,11 @@ int16_t DescriptorArray::UpdateNumberOfMarkedDescriptors( ...@@ -4559,8 +4566,11 @@ int16_t DescriptorArray::UpdateNumberOfMarkedDescriptors(
Handle<AccessorPair> AccessorPair::Copy(Isolate* isolate, Handle<AccessorPair> AccessorPair::Copy(Isolate* isolate,
Handle<AccessorPair> pair) { Handle<AccessorPair> pair) {
Handle<AccessorPair> copy = isolate->factory()->NewAccessorPair(); Handle<AccessorPair> copy = isolate->factory()->NewAccessorPair();
copy->set_getter(pair->getter()); DisallowGarbageCollection no_gc;
copy->set_setter(pair->setter()); auto raw_src = *pair;
auto raw_copy = *copy;
raw_copy.set_getter(raw_src.getter());
raw_copy.set_setter(raw_src.setter());
return copy; return copy;
} }
...@@ -5788,10 +5798,11 @@ Handle<Derived> HashTable<Derived, Shape>::NewInternal( ...@@ -5788,10 +5798,11 @@ Handle<Derived> HashTable<Derived, Shape>::NewInternal(
Handle<FixedArray> array = factory->NewFixedArrayWithMap( Handle<FixedArray> array = factory->NewFixedArrayWithMap(
Derived::GetMap(ReadOnlyRoots(isolate)), length, allocation); Derived::GetMap(ReadOnlyRoots(isolate)), length, allocation);
Handle<Derived> table = Handle<Derived>::cast(array); Handle<Derived> table = Handle<Derived>::cast(array);
DisallowGarbageCollection no_gc;
table->SetNumberOfElements(0); auto raw_table = *table;
table->SetNumberOfDeletedElements(0); raw_table.SetNumberOfElements(0);
table->SetCapacity(capacity); raw_table.SetNumberOfDeletedElements(0);
raw_table.SetCapacity(capacity);
return table; return table;
} }
......
...@@ -35,12 +35,14 @@ MaybeHandle<Derived> OrderedHashTable<Derived, entrysize>::Allocate( ...@@ -35,12 +35,14 @@ MaybeHandle<Derived> OrderedHashTable<Derived, entrysize>::Allocate(
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);
DisallowGarbageCollection no_gc;
auto raw_table = *table;
for (int i = 0; i < num_buckets; ++i) { for (int i = 0; i < num_buckets; ++i) {
table->set(HashTableStartIndex() + i, Smi::FromInt(kNotFound)); raw_table.set(HashTableStartIndex() + i, Smi::FromInt(kNotFound));
} }
table->SetNumberOfBuckets(num_buckets); raw_table.SetNumberOfBuckets(num_buckets);
table->SetNumberOfElements(0); raw_table.SetNumberOfElements(0);
table->SetNumberOfDeletedElements(0); raw_table.SetNumberOfDeletedElements(0);
return table; return table;
} }
...@@ -56,9 +58,11 @@ MaybeHandle<Derived> OrderedHashTable<Derived, entrysize>::AllocateEmpty( ...@@ -56,9 +58,11 @@ MaybeHandle<Derived> OrderedHashTable<Derived, entrysize>::AllocateEmpty(
Derived::GetMap(ReadOnlyRoots(isolate)), HashTableStartIndex(), Derived::GetMap(ReadOnlyRoots(isolate)), HashTableStartIndex(),
allocation); allocation);
Handle<Derived> table = Handle<Derived>::cast(backing_store); Handle<Derived> table = Handle<Derived>::cast(backing_store);
table->SetNumberOfBuckets(0); DisallowHandleAllocation no_gc;
table->SetNumberOfElements(0); auto raw_table = *table;
table->SetNumberOfDeletedElements(0); raw_table.SetNumberOfBuckets(0);
raw_table.SetNumberOfElements(0);
raw_table.SetNumberOfDeletedElements(0);
return table; return table;
} }
...@@ -167,15 +171,21 @@ InternalIndex OrderedHashTable<Derived, entrysize>::FindEntry(Isolate* isolate, ...@@ -167,15 +171,21 @@ InternalIndex OrderedHashTable<Derived, entrysize>::FindEntry(Isolate* isolate,
MaybeHandle<OrderedHashSet> OrderedHashSet::Add(Isolate* isolate, MaybeHandle<OrderedHashSet> OrderedHashSet::Add(Isolate* isolate,
Handle<OrderedHashSet> table, Handle<OrderedHashSet> table,
Handle<Object> key) { Handle<Object> key) {
int hash = key->GetOrCreateHash(isolate).value(); int hash;
if (table->NumberOfElements() > 0) { {
int raw_entry = table->HashToEntryRaw(hash); DisallowGarbageCollection no_gc;
// Walk the chain of the bucket and try finding the key. auto raw_key = *key;
while (raw_entry != kNotFound) { auto raw_table = *table;
Object candidate_key = table->KeyAt(InternalIndex(raw_entry)); hash = raw_key.GetOrCreateHash(isolate).value();
// Do not add if we have the key already if (raw_table.NumberOfElements() > 0) {
if (candidate_key.SameValueZero(*key)) return table; int raw_entry = raw_table.HashToEntryRaw(hash);
raw_entry = table->NextChainEntryRaw(raw_entry); // Walk the chain of the bucket and try finding the key.
while (raw_entry != kNotFound) {
Object candidate_key = raw_table.KeyAt(InternalIndex(raw_entry));
// Do not add if we have the key already
if (candidate_key.SameValueZero(raw_key)) return table;
raw_entry = raw_table.NextChainEntryRaw(raw_entry);
}
} }
} }
...@@ -184,18 +194,20 @@ MaybeHandle<OrderedHashSet> OrderedHashSet::Add(Isolate* isolate, ...@@ -184,18 +194,20 @@ MaybeHandle<OrderedHashSet> OrderedHashSet::Add(Isolate* isolate,
if (!table_candidate.ToHandle(&table)) { if (!table_candidate.ToHandle(&table)) {
return table_candidate; return table_candidate;
} }
DisallowGarbageCollection no_gc;
auto raw_table = *table;
// Read the existing bucket values. // Read the existing bucket values.
int bucket = table->HashToBucket(hash); int bucket = raw_table.HashToBucket(hash);
int previous_entry = table->HashToEntryRaw(hash); int previous_entry = raw_table.HashToEntryRaw(hash);
int nof = table->NumberOfElements(); int nof = raw_table.NumberOfElements();
// Insert a new entry at the end, // Insert a new entry at the end,
int new_entry = nof + table->NumberOfDeletedElements(); int new_entry = nof + raw_table.NumberOfDeletedElements();
int new_index = table->EntryToIndexRaw(new_entry); int new_index = raw_table.EntryToIndexRaw(new_entry);
table->set(new_index, *key); raw_table.set(new_index, *key);
table->set(new_index + kChainOffset, Smi::FromInt(previous_entry)); raw_table.set(new_index + kChainOffset, Smi::FromInt(previous_entry));
// and point the bucket to the new entry. // and point the bucket to the new entry.
table->set(HashTableStartIndex() + bucket, Smi::FromInt(new_entry)); raw_table.set(HashTableStartIndex() + bucket, Smi::FromInt(new_entry));
table->SetNumberOfElements(nof + 1); raw_table.SetNumberOfElements(nof + 1);
return table; return table;
} }
...@@ -390,19 +402,21 @@ MaybeHandle<OrderedHashMap> OrderedHashMap::Add(Isolate* isolate, ...@@ -390,19 +402,21 @@ MaybeHandle<OrderedHashMap> OrderedHashMap::Add(Isolate* isolate,
if (!table_candidate.ToHandle(&table)) { if (!table_candidate.ToHandle(&table)) {
return table_candidate; return table_candidate;
} }
DisallowGarbageCollection no_gc;
auto raw_table = *table;
// Read the existing bucket values. // Read the existing bucket values.
int bucket = table->HashToBucket(hash); int bucket = raw_table.HashToBucket(hash);
int previous_entry = table->HashToEntryRaw(hash); int previous_entry = raw_table.HashToEntryRaw(hash);
int nof = table->NumberOfElements(); int nof = raw_table.NumberOfElements();
// Insert a new entry at the end, // Insert a new entry at the end,
int new_entry = nof + table->NumberOfDeletedElements(); int new_entry = nof + raw_table.NumberOfDeletedElements();
int new_index = table->EntryToIndexRaw(new_entry); int new_index = raw_table.EntryToIndexRaw(new_entry);
table->set(new_index, *key); raw_table.set(new_index, *key);
table->set(new_index + kValueOffset, *value); raw_table.set(new_index + kValueOffset, *value);
table->set(new_index + kChainOffset, Smi::FromInt(previous_entry)); raw_table.set(new_index + kChainOffset, Smi::FromInt(previous_entry));
// and point the bucket to the new entry. // and point the bucket to the new entry.
table->set(HashTableStartIndex() + bucket, Smi::FromInt(new_entry)); raw_table.set(HashTableStartIndex() + bucket, Smi::FromInt(new_entry));
table->SetNumberOfElements(nof + 1); raw_table.SetNumberOfElements(nof + 1);
return table; return table;
} }
...@@ -455,26 +469,28 @@ MaybeHandle<OrderedNameDictionary> OrderedNameDictionary::Add( ...@@ -455,26 +469,28 @@ MaybeHandle<OrderedNameDictionary> OrderedNameDictionary::Add(
if (!table_candidate.ToHandle(&table)) { if (!table_candidate.ToHandle(&table)) {
return table_candidate; return table_candidate;
} }
DisallowGarbageCollection no_gc;
auto raw_table = *table;
// Read the existing bucket values. // Read the existing bucket values.
int hash = key->hash(); int hash = key->hash();
int bucket = table->HashToBucket(hash); int bucket = raw_table.HashToBucket(hash);
int previous_entry = table->HashToEntryRaw(hash); int previous_entry = raw_table.HashToEntryRaw(hash);
int nof = table->NumberOfElements(); int nof = raw_table.NumberOfElements();
// Insert a new entry at the end, // Insert a new entry at the end,
int new_entry = nof + table->NumberOfDeletedElements(); int new_entry = nof + raw_table.NumberOfDeletedElements();
int new_index = table->EntryToIndexRaw(new_entry); int new_index = raw_table.EntryToIndexRaw(new_entry);
table->set(new_index, *key); raw_table.set(new_index, *key);
table->set(new_index + kValueOffset, *value); raw_table.set(new_index + kValueOffset, *value);
// TODO(gsathya): Optimize how PropertyDetails are stored in this // TODO(gsathya): Optimize how PropertyDetails are stored in this
// dictionary to save memory (by reusing padding?) and performance // dictionary to save memory (by reusing padding?) and performance
// (by not doing the Smi conversion). // (by not doing the Smi conversion).
table->set(new_index + kPropertyDetailsOffset, details.AsSmi()); raw_table.set(new_index + kPropertyDetailsOffset, details.AsSmi());
table->set(new_index + kChainOffset, Smi::FromInt(previous_entry)); raw_table.set(new_index + kChainOffset, Smi::FromInt(previous_entry));
// and point the bucket to the new entry. // and point the bucket to the new entry.
table->set(HashTableStartIndex() + bucket, Smi::FromInt(new_entry)); raw_table.set(HashTableStartIndex() + bucket, Smi::FromInt(new_entry));
table->SetNumberOfElements(nof + 1); raw_table.SetNumberOfElements(nof + 1);
return table; return table;
} }
...@@ -718,22 +734,24 @@ MaybeHandle<SmallOrderedHashSet> SmallOrderedHashSet::Add( ...@@ -718,22 +734,24 @@ MaybeHandle<SmallOrderedHashSet> SmallOrderedHashSet::Add(
} }
} }
DisallowGarbageCollection no_gc;
auto raw_table = *table;
int hash = key->GetOrCreateHash(isolate).value(); int hash = key->GetOrCreateHash(isolate).value();
int nof = table->NumberOfElements(); int nof = raw_table.NumberOfElements();
// Read the existing bucket values. // Read the existing bucket values.
int bucket = table->HashToBucket(hash); int bucket = raw_table.HashToBucket(hash);
int previous_entry = table->HashToFirstEntry(hash); int previous_entry = raw_table.HashToFirstEntry(hash);
// Insert a new entry at the end, // Insert a new entry at the end,
int new_entry = nof + table->NumberOfDeletedElements(); int new_entry = nof + raw_table.NumberOfDeletedElements();
table->SetDataEntry(new_entry, SmallOrderedHashSet::kKeyIndex, *key); raw_table.SetDataEntry(new_entry, SmallOrderedHashSet::kKeyIndex, *key);
table->SetFirstEntry(bucket, new_entry); raw_table.SetFirstEntry(bucket, new_entry);
table->SetNextEntry(new_entry, previous_entry); raw_table.SetNextEntry(new_entry, previous_entry);
// and update book keeping. // and update book keeping.
table->SetNumberOfElements(nof + 1); raw_table.SetNumberOfElements(nof + 1);
return table; return table;
} }
...@@ -760,24 +778,25 @@ MaybeHandle<SmallOrderedHashMap> SmallOrderedHashMap::Add( ...@@ -760,24 +778,25 @@ MaybeHandle<SmallOrderedHashMap> SmallOrderedHashMap::Add(
return MaybeHandle<SmallOrderedHashMap>(); return MaybeHandle<SmallOrderedHashMap>();
} }
} }
DisallowGarbageCollection no_gc;
auto raw_table = *table;
int hash = key->GetOrCreateHash(isolate).value(); int hash = key->GetOrCreateHash(isolate).value();
int nof = table->NumberOfElements(); int nof = raw_table.NumberOfElements();
// Read the existing bucket values. // Read the existing bucket values.
int bucket = table->HashToBucket(hash); int bucket = raw_table.HashToBucket(hash);
int previous_entry = table->HashToFirstEntry(hash); int previous_entry = raw_table.HashToFirstEntry(hash);
// Insert a new entry at the end, // Insert a new entry at the end,
int new_entry = nof + table->NumberOfDeletedElements(); int new_entry = nof + raw_table.NumberOfDeletedElements();
table->SetDataEntry(new_entry, SmallOrderedHashMap::kValueIndex, *value); raw_table.SetDataEntry(new_entry, SmallOrderedHashMap::kValueIndex, *value);
table->SetDataEntry(new_entry, SmallOrderedHashMap::kKeyIndex, *key); raw_table.SetDataEntry(new_entry, SmallOrderedHashMap::kKeyIndex, *key);
table->SetFirstEntry(bucket, new_entry); raw_table.SetFirstEntry(bucket, new_entry);
table->SetNextEntry(new_entry, previous_entry); raw_table.SetNextEntry(new_entry, previous_entry);
// and update book keeping. // and update book keeping.
table->SetNumberOfElements(nof + 1); raw_table.SetNumberOfElements(nof + 1);
return table; return table;
} }
......
...@@ -501,7 +501,7 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate, ...@@ -501,7 +501,7 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate,
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Handle<ScopeInfo> scope_info = Handle<ScopeInfo> scope_info =
factory->NewScopeInfo(length, AllocationType::kReadOnly); factory->NewScopeInfo(length, AllocationType::kReadOnly);
DisallowGarbageCollection _nogc;
// Encode the flags. // Encode the flags.
int flags = int flags =
ScopeTypeBits::encode(is_empty_function ? FUNCTION_SCOPE : SCRIPT_SCOPE) | ScopeTypeBits::encode(is_empty_function ? FUNCTION_SCOPE : SCRIPT_SCOPE) |
...@@ -524,18 +524,20 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate, ...@@ -524,18 +524,20 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate,
PrivateNameLookupSkipsOuterClassBit::encode(false) | PrivateNameLookupSkipsOuterClassBit::encode(false) |
HasContextExtensionSlotBit::encode(is_native_context) | HasContextExtensionSlotBit::encode(is_native_context) |
IsReplModeScopeBit::encode(false) | HasLocalsBlockListBit::encode(false); IsReplModeScopeBit::encode(false) | HasLocalsBlockListBit::encode(false);
scope_info->set_flags(flags); auto raw_scope_info = *scope_info;
scope_info->set_parameter_count(parameter_count); raw_scope_info.set_flags(flags);
scope_info->set_context_local_count(context_local_count); raw_scope_info.set_parameter_count(parameter_count);
raw_scope_info.set_context_local_count(context_local_count);
int index = kVariablePartIndex; int index = kVariablePartIndex;
// Here we add info for context-allocated "this". // Here we add info for context-allocated "this".
DCHECK_EQ(index, scope_info->ContextLocalNamesIndex()); DCHECK_EQ(index, raw_scope_info.ContextLocalNamesIndex());
ReadOnlyRoots roots(isolate);
if (context_local_count) { if (context_local_count) {
scope_info->set(index++, ReadOnlyRoots(isolate).this_string()); raw_scope_info.set(index++, roots.this_string());
} }
DCHECK_EQ(index, scope_info->ContextLocalInfosIndex()); DCHECK_EQ(index, raw_scope_info.ContextLocalInfosIndex());
if (context_local_count > 0) { if (context_local_count > 0) {
const uint32_t value = const uint32_t value =
VariableModeBits::encode(VariableMode::kConst) | VariableModeBits::encode(VariableMode::kConst) |
...@@ -543,30 +545,30 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate, ...@@ -543,30 +545,30 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate,
MaybeAssignedFlagBit::encode(kNotAssigned) | MaybeAssignedFlagBit::encode(kNotAssigned) |
ParameterNumberBits::encode(ParameterNumberBits::kMax) | ParameterNumberBits::encode(ParameterNumberBits::kMax) |
IsStaticFlagBit::encode(IsStaticFlag::kNotStatic); IsStaticFlagBit::encode(IsStaticFlag::kNotStatic);
scope_info->set(index++, Smi::FromInt(value)); raw_scope_info.set(index++, Smi::FromInt(value));
} }
DCHECK_EQ(index, scope_info->FunctionVariableInfoIndex()); DCHECK_EQ(index, raw_scope_info.FunctionVariableInfoIndex());
if (is_empty_function) { if (is_empty_function) {
scope_info->set(index++, *isolate->factory()->empty_string()); raw_scope_info.set(index++, roots.empty_string());
scope_info->set(index++, Smi::zero()); raw_scope_info.set(index++, Smi::zero());
} }
DCHECK_EQ(index, scope_info->InferredFunctionNameIndex()); DCHECK_EQ(index, raw_scope_info.InferredFunctionNameIndex());
if (has_inferred_function_name) { if (has_inferred_function_name) {
scope_info->set(index++, *isolate->factory()->empty_string()); raw_scope_info.set(index++, roots.empty_string());
} }
DCHECK_EQ(index, scope_info->PositionInfoIndex()); DCHECK_EQ(index, raw_scope_info.PositionInfoIndex());
// Store dummy position to be in sync with the {scope_type}. // Store dummy position to be in sync with the {scope_type}.
scope_info->set(index++, Smi::zero()); raw_scope_info.set(index++, Smi::zero());
scope_info->set(index++, Smi::zero()); raw_scope_info.set(index++, Smi::zero());
DCHECK_EQ(index, scope_info->OuterScopeInfoIndex()); DCHECK_EQ(index, raw_scope_info.OuterScopeInfoIndex());
DCHECK_EQ(index, scope_info->length()); DCHECK_EQ(index, raw_scope_info.length());
DCHECK_EQ(scope_info->ParameterCount(), parameter_count); DCHECK_EQ(raw_scope_info.ParameterCount(), parameter_count);
if (is_empty_function || is_native_context) { if (is_empty_function || is_native_context) {
DCHECK_EQ(scope_info->ContextLength(), 0); DCHECK_EQ(raw_scope_info.ContextLength(), 0);
} else { } else {
DCHECK_EQ(scope_info->ContextLength(), DCHECK_EQ(raw_scope_info.ContextLength(),
scope_info->ContextHeaderLength() + 1); raw_scope_info.ContextHeaderLength() + 1);
} }
return scope_info; return scope_info;
...@@ -1119,9 +1121,11 @@ Handle<ModuleRequest> ModuleRequest::New(IsolateT* isolate, ...@@ -1119,9 +1121,11 @@ Handle<ModuleRequest> ModuleRequest::New(IsolateT* isolate,
int position) { int position) {
Handle<ModuleRequest> result = Handle<ModuleRequest>::cast( Handle<ModuleRequest> result = Handle<ModuleRequest>::cast(
isolate->factory()->NewStruct(MODULE_REQUEST_TYPE, AllocationType::kOld)); isolate->factory()->NewStruct(MODULE_REQUEST_TYPE, AllocationType::kOld));
result->set_specifier(*specifier); DisallowGarbageCollection no_gc;
result->set_import_assertions(*import_assertions); auto raw = *result;
result->set_position(position); raw.set_specifier(*specifier);
raw.set_import_assertions(*import_assertions);
raw.set_position(position);
return result; return result;
} }
...@@ -1141,13 +1145,15 @@ Handle<SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New( ...@@ -1141,13 +1145,15 @@ Handle<SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New(
Handle<SourceTextModuleInfoEntry> result = Handle<SourceTextModuleInfoEntry> result =
Handle<SourceTextModuleInfoEntry>::cast(isolate->factory()->NewStruct( Handle<SourceTextModuleInfoEntry>::cast(isolate->factory()->NewStruct(
SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, AllocationType::kOld)); SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, AllocationType::kOld));
result->set_export_name(*export_name); DisallowGarbageCollection no_gc;
result->set_local_name(*local_name); auto raw = *result;
result->set_import_name(*import_name); raw.set_export_name(*export_name);
result->set_module_request(module_request); raw.set_local_name(*local_name);
result->set_cell_index(cell_index); raw.set_import_name(*import_name);
result->set_beg_pos(beg_pos); raw.set_module_request(module_request);
result->set_end_pos(end_pos); raw.set_cell_index(cell_index);
raw.set_beg_pos(beg_pos);
raw.set_end_pos(end_pos);
return result; return result;
} }
......
...@@ -503,61 +503,65 @@ void SharedFunctionInfo::InitFromFunctionLiteral( ...@@ -503,61 +503,65 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
IsolateT* isolate, Handle<SharedFunctionInfo> shared_info, IsolateT* isolate, Handle<SharedFunctionInfo> shared_info,
FunctionLiteral* lit, bool is_toplevel) { FunctionLiteral* lit, bool is_toplevel) {
DCHECK(!shared_info->name_or_scope_info(kAcquireLoad).IsScopeInfo()); DCHECK(!shared_info->name_or_scope_info(kAcquireLoad).IsScopeInfo());
{
// When adding fields here, make sure DeclarationScope::AnalyzePartially is DisallowGarbageCollection no_gc;
// updated accordingly. auto raw_sfi = *shared_info;
shared_info->set_internal_formal_parameter_count( // When adding fields here, make sure DeclarationScope::AnalyzePartially is
JSParameterCount(lit->parameter_count())); // updated accordingly.
shared_info->SetFunctionTokenPosition(lit->function_token_position(), raw_sfi.set_internal_formal_parameter_count(
lit->start_position()); JSParameterCount(lit->parameter_count()));
shared_info->set_syntax_kind(lit->syntax_kind()); raw_sfi.SetFunctionTokenPosition(lit->function_token_position(),
shared_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); lit->start_position());
shared_info->set_language_mode(lit->language_mode()); raw_sfi.set_syntax_kind(lit->syntax_kind());
shared_info->set_function_literal_id(lit->function_literal_id()); raw_sfi.set_allows_lazy_compilation(lit->AllowsLazyCompilation());
// FunctionKind must have already been set. raw_sfi.set_language_mode(lit->language_mode());
DCHECK(lit->kind() == shared_info->kind()); raw_sfi.set_function_literal_id(lit->function_literal_id());
DCHECK_IMPLIES(lit->requires_instance_members_initializer(), // FunctionKind must have already been set.
IsClassConstructor(lit->kind())); DCHECK(lit->kind() == raw_sfi.kind());
shared_info->set_requires_instance_members_initializer( DCHECK_IMPLIES(lit->requires_instance_members_initializer(),
lit->requires_instance_members_initializer()); IsClassConstructor(lit->kind()));
DCHECK_IMPLIES(lit->class_scope_has_private_brand(), raw_sfi.set_requires_instance_members_initializer(
IsClassConstructor(lit->kind())); lit->requires_instance_members_initializer());
shared_info->set_class_scope_has_private_brand( DCHECK_IMPLIES(lit->class_scope_has_private_brand(),
lit->class_scope_has_private_brand()); IsClassConstructor(lit->kind()));
DCHECK_IMPLIES(lit->has_static_private_methods_or_accessors(), raw_sfi.set_class_scope_has_private_brand(
IsClassConstructor(lit->kind())); lit->class_scope_has_private_brand());
shared_info->set_has_static_private_methods_or_accessors( DCHECK_IMPLIES(lit->has_static_private_methods_or_accessors(),
lit->has_static_private_methods_or_accessors()); IsClassConstructor(lit->kind()));
raw_sfi.set_has_static_private_methods_or_accessors(
shared_info->set_is_toplevel(is_toplevel); lit->has_static_private_methods_or_accessors());
DCHECK(shared_info->outer_scope_info().IsTheHole());
if (!is_toplevel) { raw_sfi.set_is_toplevel(is_toplevel);
Scope* outer_scope = lit->scope()->GetOuterScopeWithContext(); DCHECK(raw_sfi.outer_scope_info().IsTheHole());
if (outer_scope) { if (!is_toplevel) {
shared_info->set_outer_scope_info(*outer_scope->scope_info()); Scope* outer_scope = lit->scope()->GetOuterScopeWithContext();
shared_info->set_private_name_lookup_skips_outer_class( if (outer_scope) {
lit->scope()->private_name_lookup_skips_outer_class()); raw_sfi.set_outer_scope_info(*outer_scope->scope_info());
raw_sfi.set_private_name_lookup_skips_outer_class(
lit->scope()->private_name_lookup_skips_outer_class());
}
} }
}
shared_info->set_length(lit->function_length()); raw_sfi.set_length(lit->function_length());
// For lazy parsed functions, the following flags will be inaccurate since we // For lazy parsed functions, the following flags will be inaccurate since
// don't have the information yet. They're set later in // we don't have the information yet. They're set later in
// UpdateSharedFunctionFlagsAfterCompilation (compiler.cc), when the function // UpdateSharedFunctionFlagsAfterCompilation (compiler.cc), when the
// is really parsed and compiled. // function is really parsed and compiled.
if (lit->ShouldEagerCompile()) { if (lit->ShouldEagerCompile()) {
shared_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); raw_sfi.set_has_duplicate_parameters(lit->has_duplicate_parameters());
shared_info->UpdateAndFinalizeExpectedNofPropertiesFromEstimate(lit); raw_sfi.UpdateAndFinalizeExpectedNofPropertiesFromEstimate(lit);
DCHECK_NULL(lit->produced_preparse_data()); DCHECK_NULL(lit->produced_preparse_data());
// If we're about to eager compile, we'll have the function literal
// available, so there's no need to wastefully allocate an uncompiled
// data.
return;
}
// If we're about to eager compile, we'll have the function literal raw_sfi.UpdateExpectedNofPropertiesFromEstimate(lit);
// available, so there's no need to wastefully allocate an uncompiled data.
return;
} }
shared_info->UpdateExpectedNofPropertiesFromEstimate(lit);
Handle<UncompiledData> data; Handle<UncompiledData> data;
ProducedPreparseData* scope_data = lit->produced_preparse_data(); ProducedPreparseData* scope_data = lit->produced_preparse_data();
......
...@@ -1210,14 +1210,16 @@ void SourceTextModule::Reset(Isolate* isolate, ...@@ -1210,14 +1210,16 @@ void SourceTextModule::Reset(Isolate* isolate,
Handle<FixedArray> requested_modules = Handle<FixedArray> requested_modules =
factory->NewFixedArray(module->requested_modules().length()); factory->NewFixedArray(module->requested_modules().length());
if (module->status() == kLinking) { DisallowGarbageCollection no_gc;
module->set_code(JSFunction::cast(module->code()).shared()); auto raw_module = *module;
if (raw_module.status() == kLinking) {
raw_module.set_code(JSFunction::cast(raw_module.code()).shared());
} }
module->set_regular_exports(*regular_exports); raw_module.set_regular_exports(*regular_exports);
module->set_regular_imports(*regular_imports); raw_module.set_regular_imports(*regular_imports);
module->set_requested_modules(*requested_modules); raw_module.set_requested_modules(*requested_modules);
module->set_dfs_index(-1); raw_module.set_dfs_index(-1);
module->set_dfs_ancestor_index(-1); raw_module.set_dfs_ancestor_index(-1);
} }
std::vector<std::tuple<Handle<SourceTextModule>, Handle<JSMessageObject>>> std::vector<std::tuple<Handle<SourceTextModule>, Handle<JSMessageObject>>>
......
...@@ -89,8 +89,12 @@ Handle<String> String::SlowFlatten(Isolate* isolate, Handle<ConsString> cons, ...@@ -89,8 +89,12 @@ Handle<String> String::SlowFlatten(Isolate* isolate, Handle<ConsString> cons,
WriteToFlat(*cons, flat->GetChars(no_gc), 0, length); WriteToFlat(*cons, flat->GetChars(no_gc), 0, length);
result = flat; result = flat;
} }
cons->set_first(*result); {
cons->set_second(ReadOnlyRoots(isolate).empty_string()); DisallowGarbageCollection no_gc;
auto raw_cons = *cons;
raw_cons.set_first(*result);
raw_cons.set_second(ReadOnlyRoots(isolate).empty_string());
}
DCHECK(result->IsFlat()); DCHECK(result->IsFlat());
return result; return result;
} }
......
...@@ -512,15 +512,16 @@ Handle<SwissNameDictionary> SwissNameDictionary::Add( ...@@ -512,15 +512,16 @@ Handle<SwissNameDictionary> SwissNameDictionary::Add(
DCHECK(original_table->FindEntry(isolate, *key).is_not_found()); DCHECK(original_table->FindEntry(isolate, *key).is_not_found());
Handle<SwissNameDictionary> table = EnsureGrowable(isolate, original_table); Handle<SwissNameDictionary> table = EnsureGrowable(isolate, original_table);
DisallowGarbageCollection no_gc;
int nof = table->NumberOfElements(); auto raw_table = *table;
int nod = table->NumberOfDeletedElements(); int nof = raw_table.NumberOfElements();
int nod = raw_table.NumberOfDeletedElements();
int new_enum_index = nof + nod; int new_enum_index = nof + nod;
int new_entry = table->AddInternal(*key, *value, details); int new_entry = raw_table.AddInternal(*key, *value, details);
table->SetNumberOfElements(nof + 1); raw_table.SetNumberOfElements(nof + 1);
table->SetEntryForEnumerationIndex(new_enum_index, new_entry); raw_table.SetEntryForEnumerationIndex(new_enum_index, new_entry);
if (entry_out) { if (entry_out) {
*entry_out = InternalIndex(new_entry); *entry_out = InternalIndex(new_entry);
......
...@@ -44,16 +44,19 @@ Handle<SharedFunctionInfo> FunctionTemplateInfo::GetOrCreateSharedFunctionInfo( ...@@ -44,16 +44,19 @@ Handle<SharedFunctionInfo> FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(
} else { } else {
function_kind = FunctionKind::kNormalFunction; function_kind = FunctionKind::kNormalFunction;
} }
Handle<SharedFunctionInfo> result = Handle<SharedFunctionInfo> sfi =
isolate->factory()->NewSharedFunctionInfoForApiFunction(name_string, info, isolate->factory()->NewSharedFunctionInfoForApiFunction(name_string, info,
function_kind); function_kind);
{
result->set_length(info->length()); DisallowGarbageCollection no_gc;
result->DontAdaptArguments(); auto raw_sfi = *sfi;
DCHECK(result->IsApiFunction()); auto raw_template = *info;
raw_sfi.set_length(raw_template.length());
info->set_shared_function_info(*result); raw_sfi.DontAdaptArguments();
return result; DCHECK(raw_sfi.IsApiFunction());
raw_template.set_shared_function_info(raw_sfi);
}
return sfi;
} }
bool FunctionTemplateInfo::IsTemplateFor(Map map) const { bool FunctionTemplateInfo::IsTemplateFor(Map map) const {
......
...@@ -256,28 +256,31 @@ Handle<Script> ParseInfo::CreateScript( ...@@ -256,28 +256,31 @@ Handle<Script> ParseInfo::CreateScript(
flags().script_id() == Script::kTemporaryScriptId); flags().script_id() == Script::kTemporaryScriptId);
Handle<Script> script = Handle<Script> script =
isolate->factory()->NewScriptWithId(source, flags().script_id()); isolate->factory()->NewScriptWithId(source, flags().script_id());
DisallowGarbageCollection no_gc;
auto raw_script = *script;
switch (natives) { switch (natives) {
case EXTENSION_CODE: case EXTENSION_CODE:
script->set_type(Script::TYPE_EXTENSION); raw_script.set_type(Script::TYPE_EXTENSION);
break; break;
case INSPECTOR_CODE: case INSPECTOR_CODE:
script->set_type(Script::TYPE_INSPECTOR); raw_script.set_type(Script::TYPE_INSPECTOR);
break; break;
case NOT_NATIVES_CODE: case NOT_NATIVES_CODE:
break; break;
} }
script->set_origin_options(origin_options); raw_script.set_origin_options(origin_options);
script->set_is_repl_mode(flags().is_repl_mode()); raw_script.set_is_repl_mode(flags().is_repl_mode());
DCHECK_EQ(is_wrapped_as_function(), !maybe_wrapped_arguments.is_null()); DCHECK_EQ(is_wrapped_as_function(), !maybe_wrapped_arguments.is_null());
if (is_wrapped_as_function()) { if (is_wrapped_as_function()) {
script->set_wrapped_arguments(*maybe_wrapped_arguments.ToHandleChecked()); raw_script.set_wrapped_arguments(
*maybe_wrapped_arguments.ToHandleChecked());
} else if (flags().is_eval()) { } else if (flags().is_eval()) {
script->set_compilation_type(Script::COMPILATION_TYPE_EVAL); raw_script.set_compilation_type(Script::COMPILATION_TYPE_EVAL);
} }
CheckFlagsForToplevelCompileFromScript(raw_script,
CheckFlagsForToplevelCompileFromScript(*script,
isolate->is_collecting_type_profile()); isolate->is_collecting_type_profile());
return script; return script;
} }
......
...@@ -58,16 +58,18 @@ RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { ...@@ -58,16 +58,18 @@ RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
Handle<JSGeneratorObject> generator = Handle<JSGeneratorObject> generator =
isolate->factory()->NewJSGeneratorObject(function); isolate->factory()->NewJSGeneratorObject(function);
generator->set_function(*function); DisallowGarbageCollection no_gc;
generator->set_context(isolate->context()); auto raw_generator = *generator;
generator->set_receiver(*receiver); raw_generator.set_function(*function);
generator->set_parameters_and_registers(*parameters_and_registers); raw_generator.set_context(isolate->context());
generator->set_resume_mode(JSGeneratorObject::ResumeMode::kNext); raw_generator.set_receiver(*receiver);
generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); raw_generator.set_parameters_and_registers(*parameters_and_registers);
if (generator->IsJSAsyncGeneratorObject()) { raw_generator.set_resume_mode(JSGeneratorObject::ResumeMode::kNext);
Handle<JSAsyncGeneratorObject>::cast(generator)->set_is_awaiting(0); raw_generator.set_continuation(JSGeneratorObject::kGeneratorExecuting);
if (raw_generator.IsJSAsyncGeneratorObject()) {
JSAsyncGeneratorObject::cast(raw_generator).set_is_awaiting(0);
} }
return *generator; return raw_generator;
} }
RUNTIME_FUNCTION(Runtime_GeneratorClose) { RUNTIME_FUNCTION(Runtime_GeneratorClose) {
......
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