Commit 1ed76a3c authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

Move helper SFIs from NativeContext to Isolate, part 1

There's no need for them to be in NativeContext.

This CL moves the minimal subset of SFIs related to async functions
and async generators.

Bug: v8:10482
Change-Id: Ic90e342ae77b406c12dedf6b8f7e3fadb661b205
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2179843
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67590}
parent 61927f30
...@@ -271,10 +271,12 @@ void AsyncFunctionBuiltinsAssembler::AsyncFunctionAwait( ...@@ -271,10 +271,12 @@ void AsyncFunctionBuiltinsAssembler::AsyncFunctionAwait(
Goto(&after_debug_hook); Goto(&after_debug_hook);
BIND(&after_debug_hook); BIND(&after_debug_hook);
Await(context, async_function_object, value, outer_promise, TNode<SharedFunctionInfo> on_resolve_sfi =
Context::ASYNC_FUNCTION_AWAIT_RESOLVE_SHARED_FUN, AsyncFunctionAwaitResolveSharedFunConstant();
Context::ASYNC_FUNCTION_AWAIT_REJECT_SHARED_FUN, TNode<SharedFunctionInfo> on_reject_sfi =
is_predicted_as_caught); AsyncFunctionAwaitRejectSharedFunConstant();
Await(context, async_function_object, value, outer_promise, on_resolve_sfi,
on_reject_sfi, is_predicted_as_caught);
// Return outer promise to avoid adding an load of the outer promise before // Return outer promise to avoid adding an load of the outer promise before
// suspending in BytecodeGenerator. // suspending in BytecodeGenerator.
......
...@@ -27,8 +27,8 @@ class ValueUnwrapContext { ...@@ -27,8 +27,8 @@ class ValueUnwrapContext {
TNode<Object> AsyncBuiltinsAssembler::AwaitOld( TNode<Object> AsyncBuiltinsAssembler::AwaitOld(
TNode<Context> context, TNode<JSGeneratorObject> generator, TNode<Context> context, TNode<JSGeneratorObject> generator,
TNode<Object> value, TNode<JSPromise> outer_promise, TNode<Object> value, TNode<JSPromise> outer_promise,
TNode<IntPtrT> on_resolve_context_index, TNode<SharedFunctionInfo> on_resolve_sfi,
TNode<IntPtrT> on_reject_context_index, TNode<SharedFunctionInfo> on_reject_sfi,
TNode<Oddball> is_predicted_as_caught) { TNode<Oddball> is_predicted_as_caught) {
const TNode<NativeContext> native_context = LoadNativeContext(context); const TNode<NativeContext> native_context = LoadNativeContext(context);
...@@ -90,12 +90,12 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld( ...@@ -90,12 +90,12 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld(
// Initialize resolve handler // Initialize resolve handler
TNode<HeapObject> on_resolve = InnerAllocate(base, kResolveClosureOffset); TNode<HeapObject> on_resolve = InnerAllocate(base, kResolveClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_resolve, InitializeNativeClosure(closure_context, native_context, on_resolve,
on_resolve_context_index); on_resolve_sfi);
// Initialize reject handler // Initialize reject handler
TNode<HeapObject> on_reject = InnerAllocate(base, kRejectClosureOffset); TNode<HeapObject> on_reject = InnerAllocate(base, kRejectClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_reject, InitializeNativeClosure(closure_context, native_context, on_reject,
on_reject_context_index); on_reject_sfi);
TVARIABLE(HeapObject, var_throwaway, UndefinedConstant()); TVARIABLE(HeapObject, var_throwaway, UndefinedConstant());
...@@ -122,8 +122,8 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld( ...@@ -122,8 +122,8 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld(
TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized( TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized(
TNode<Context> context, TNode<JSGeneratorObject> generator, TNode<Context> context, TNode<JSGeneratorObject> generator,
TNode<JSPromise> promise, TNode<JSPromise> outer_promise, TNode<JSPromise> promise, TNode<JSPromise> outer_promise,
TNode<IntPtrT> on_resolve_context_index, TNode<SharedFunctionInfo> on_resolve_sfi,
TNode<IntPtrT> on_reject_context_index, TNode<SharedFunctionInfo> on_reject_sfi,
TNode<Oddball> is_predicted_as_caught) { TNode<Oddball> is_predicted_as_caught) {
const TNode<NativeContext> native_context = LoadNativeContext(context); const TNode<NativeContext> native_context = LoadNativeContext(context);
...@@ -161,12 +161,12 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized( ...@@ -161,12 +161,12 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized(
// Initialize resolve handler // Initialize resolve handler
TNode<HeapObject> on_resolve = InnerAllocate(base, kResolveClosureOffset); TNode<HeapObject> on_resolve = InnerAllocate(base, kResolveClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_resolve, InitializeNativeClosure(closure_context, native_context, on_resolve,
on_resolve_context_index); on_resolve_sfi);
// Initialize reject handler // Initialize reject handler
TNode<HeapObject> on_reject = InnerAllocate(base, kRejectClosureOffset); TNode<HeapObject> on_reject = InnerAllocate(base, kRejectClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_reject, InitializeNativeClosure(closure_context, native_context, on_reject,
on_reject_context_index); on_reject_sfi);
TVARIABLE(HeapObject, var_throwaway, UndefinedConstant()); TVARIABLE(HeapObject, var_throwaway, UndefinedConstant());
...@@ -190,8 +190,8 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized( ...@@ -190,8 +190,8 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized(
TNode<Object> AsyncBuiltinsAssembler::Await( TNode<Object> AsyncBuiltinsAssembler::Await(
TNode<Context> context, TNode<JSGeneratorObject> generator, TNode<Context> context, TNode<JSGeneratorObject> generator,
TNode<Object> value, TNode<JSPromise> outer_promise, TNode<Object> value, TNode<JSPromise> outer_promise,
TNode<IntPtrT> on_resolve_context_index, TNode<SharedFunctionInfo> on_resolve_sfi,
TNode<IntPtrT> on_reject_context_index, TNode<SharedFunctionInfo> on_reject_sfi,
TNode<Oddball> is_predicted_as_caught) { TNode<Oddball> is_predicted_as_caught) {
TVARIABLE(Object, result); TVARIABLE(Object, result);
Label if_old(this), if_new(this), done(this), Label if_old(this), if_new(this), done(this),
...@@ -230,15 +230,14 @@ TNode<Object> AsyncBuiltinsAssembler::Await( ...@@ -230,15 +230,14 @@ TNode<Object> AsyncBuiltinsAssembler::Await(
} }
BIND(&if_old); BIND(&if_old);
result = AwaitOld(context, generator, value, outer_promise, result = AwaitOld(context, generator, value, outer_promise, on_resolve_sfi,
on_resolve_context_index, on_reject_context_index, on_reject_sfi, is_predicted_as_caught);
is_predicted_as_caught);
Goto(&done); Goto(&done);
BIND(&if_new); BIND(&if_new);
result = AwaitOptimized(context, generator, CAST(value), outer_promise, result =
on_resolve_context_index, on_reject_context_index, AwaitOptimized(context, generator, CAST(value), outer_promise,
is_predicted_as_caught); on_resolve_sfi, on_reject_sfi, is_predicted_as_caught);
Goto(&done); Goto(&done);
BIND(&done); BIND(&done);
...@@ -247,7 +246,7 @@ TNode<Object> AsyncBuiltinsAssembler::Await( ...@@ -247,7 +246,7 @@ TNode<Object> AsyncBuiltinsAssembler::Await(
void AsyncBuiltinsAssembler::InitializeNativeClosure( void AsyncBuiltinsAssembler::InitializeNativeClosure(
TNode<Context> context, TNode<NativeContext> native_context, TNode<Context> context, TNode<NativeContext> native_context,
TNode<HeapObject> function, TNode<IntPtrT> context_index) { TNode<HeapObject> function, TNode<SharedFunctionInfo> shared_info) {
TNode<Map> function_map = CAST(LoadContextElement( TNode<Map> function_map = CAST(LoadContextElement(
native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX)); native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX));
// Ensure that we don't have to initialize prototype_or_initial_map field of // Ensure that we don't have to initialize prototype_or_initial_map field of
...@@ -265,8 +264,6 @@ void AsyncBuiltinsAssembler::InitializeNativeClosure( ...@@ -265,8 +264,6 @@ void AsyncBuiltinsAssembler::InitializeNativeClosure(
StoreObjectFieldRoot(function, JSFunction::kFeedbackCellOffset, StoreObjectFieldRoot(function, JSFunction::kFeedbackCellOffset,
RootIndex::kManyClosuresCell); RootIndex::kManyClosuresCell);
TNode<SharedFunctionInfo> shared_info =
CAST(LoadContextElement(native_context, context_index));
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
function, JSFunction::kSharedFunctionInfoOffset, shared_info); function, JSFunction::kSharedFunctionInfoOffset, shared_info);
StoreObjectFieldNoWriteBarrier(function, JSFunction::kContextOffset, context); StoreObjectFieldNoWriteBarrier(function, JSFunction::kContextOffset, context);
......
...@@ -17,34 +17,23 @@ class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler { ...@@ -17,34 +17,23 @@ class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
protected: protected:
// Perform steps to resume generator after `value` is resolved. // Perform steps to resume generator after `value` is resolved.
// `on_reject_context_index` is an index into the Native Context, which should // `on_reject` is the SharedFunctioninfo instance used to create the reject
// point to a SharedFunctioninfo instance used to create the closure. The // closure. `on_resolve` is the SharedFunctioninfo instance used to create the
// value following the reject index should be a similar value for the resolve // resolve closure. Returns the Promise-wrapped `value`.
// closure. Returns the Promise-wrapped `value`.
TNode<Object> Await(TNode<Context> context, TNode<Object> Await(TNode<Context> context,
TNode<JSGeneratorObject> generator, TNode<Object> value, TNode<JSGeneratorObject> generator, TNode<Object> value,
TNode<JSPromise> outer_promise, TNode<JSPromise> outer_promise,
TNode<IntPtrT> on_resolve_context_index, TNode<SharedFunctionInfo> on_resolve_sfi,
TNode<IntPtrT> on_reject_context_index, TNode<SharedFunctionInfo> on_reject_sfi,
TNode<Oddball> is_predicted_as_caught); TNode<Oddball> is_predicted_as_caught);
TNode<Object> Await(TNode<Context> context, TNode<Object> Await(TNode<Context> context,
TNode<JSGeneratorObject> generator, TNode<Object> value, TNode<JSGeneratorObject> generator, TNode<Object> value,
TNode<JSPromise> outer_promise, TNode<JSPromise> outer_promise,
int on_resolve_context_index, int on_reject_context_index, TNode<SharedFunctionInfo> on_resolve_sfi,
TNode<Oddball> is_predicted_as_caught) { TNode<SharedFunctionInfo> on_reject_sfi,
return Await(context, generator, value, outer_promise,
IntPtrConstant(on_resolve_context_index),
IntPtrConstant(on_reject_context_index),
is_predicted_as_caught);
}
TNode<Object> Await(TNode<Context> context,
TNode<JSGeneratorObject> generator, TNode<Object> value,
TNode<JSPromise> outer_promise,
int on_resolve_context_index, int on_reject_context_index,
bool is_predicted_as_caught) { bool is_predicted_as_caught) {
return Await(context, generator, value, outer_promise, return Await(context, generator, value, outer_promise, on_resolve_sfi,
on_resolve_context_index, on_reject_context_index, on_reject_sfi, BooleanConstant(is_predicted_as_caught));
BooleanConstant(is_predicted_as_caught));
} }
// Return a new built-in function object as defined in // Return a new built-in function object as defined in
...@@ -56,22 +45,22 @@ class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler { ...@@ -56,22 +45,22 @@ class AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
void InitializeNativeClosure(TNode<Context> context, void InitializeNativeClosure(TNode<Context> context,
TNode<NativeContext> native_context, TNode<NativeContext> native_context,
TNode<HeapObject> function, TNode<HeapObject> function,
TNode<IntPtrT> context_index); TNode<SharedFunctionInfo> shared_info);
TNode<Context> AllocateAsyncIteratorValueUnwrapContext( TNode<Context> AllocateAsyncIteratorValueUnwrapContext(
TNode<NativeContext> native_context, TNode<Oddball> done); TNode<NativeContext> native_context, TNode<Oddball> done);
TNode<Object> AwaitOld(TNode<Context> context, TNode<Object> AwaitOld(TNode<Context> context,
TNode<JSGeneratorObject> generator, TNode<JSGeneratorObject> generator,
TNode<Object> value, TNode<JSPromise> outer_promise, TNode<Object> value, TNode<JSPromise> outer_promise,
TNode<IntPtrT> on_resolve_context_index, TNode<SharedFunctionInfo> on_resolve_sfi,
TNode<IntPtrT> on_reject_context_index, TNode<SharedFunctionInfo> on_reject_sfi,
TNode<Oddball> is_predicted_as_caught); TNode<Oddball> is_predicted_as_caught);
TNode<Object> AwaitOptimized(TNode<Context> context, TNode<Object> AwaitOptimized(TNode<Context> context,
TNode<JSGeneratorObject> generator, TNode<JSGeneratorObject> generator,
TNode<JSPromise> promise, TNode<JSPromise> promise,
TNode<JSPromise> outer_promise, TNode<JSPromise> outer_promise,
TNode<IntPtrT> on_resolve_context_index, TNode<SharedFunctionInfo> on_resolve_sfi,
TNode<IntPtrT> on_reject_context_index, TNode<SharedFunctionInfo> on_reject_sfi,
TNode<Oddball> is_predicted_as_caught); TNode<Oddball> is_predicted_as_caught);
}; };
......
...@@ -242,12 +242,10 @@ void AsyncGeneratorBuiltinsAssembler::AsyncGeneratorAwait(bool is_catchable) { ...@@ -242,12 +242,10 @@ void AsyncGeneratorBuiltinsAssembler::AsyncGeneratorAwait(bool is_catchable) {
TNode<JSPromise> outer_promise = LoadObjectField<JSPromise>( TNode<JSPromise> outer_promise = LoadObjectField<JSPromise>(
request, AsyncGeneratorRequest::kPromiseOffset); request, AsyncGeneratorRequest::kPromiseOffset);
const int resolve_index = Context::ASYNC_GENERATOR_AWAIT_RESOLVE_SHARED_FUN;
const int reject_index = Context::ASYNC_GENERATOR_AWAIT_REJECT_SHARED_FUN;
SetGeneratorAwaiting(async_generator_object); SetGeneratorAwaiting(async_generator_object);
Await(context, async_generator_object, value, outer_promise, resolve_index, Await(context, async_generator_object, value, outer_promise,
reject_index, is_catchable); AsyncGeneratorAwaitResolveSharedFunConstant(),
AsyncGeneratorAwaitRejectSharedFunConstant(), is_catchable);
Return(UndefinedConstant()); Return(UndefinedConstant());
} }
...@@ -573,12 +571,10 @@ TF_BUILTIN(AsyncGeneratorYield, AsyncGeneratorBuiltinsAssembler) { ...@@ -573,12 +571,10 @@ TF_BUILTIN(AsyncGeneratorYield, AsyncGeneratorBuiltinsAssembler) {
const TNode<JSPromise> outer_promise = const TNode<JSPromise> outer_promise =
LoadPromiseFromAsyncGeneratorRequest(request); LoadPromiseFromAsyncGeneratorRequest(request);
const int on_resolve = Context::ASYNC_GENERATOR_YIELD_RESOLVE_SHARED_FUN;
const int on_reject = Context::ASYNC_GENERATOR_AWAIT_REJECT_SHARED_FUN;
SetGeneratorAwaiting(generator); SetGeneratorAwaiting(generator);
Await(context, generator, value, outer_promise, on_resolve, on_reject, Await(context, generator, value, outer_promise,
is_caught); AsyncGeneratorYieldResolveSharedFunConstant(),
AsyncGeneratorAwaitRejectSharedFunConstant(), is_caught);
Return(UndefinedConstant()); Return(UndefinedConstant());
} }
...@@ -623,19 +619,17 @@ TF_BUILTIN(AsyncGeneratorReturn, AsyncGeneratorBuiltinsAssembler) { ...@@ -623,19 +619,17 @@ TF_BUILTIN(AsyncGeneratorReturn, AsyncGeneratorBuiltinsAssembler) {
CAST(LoadFirstAsyncGeneratorRequestFromQueue(generator)); CAST(LoadFirstAsyncGeneratorRequestFromQueue(generator));
Label perform_await(this); Label perform_await(this);
TVARIABLE(IntPtrT, var_on_resolve, TVARIABLE(SharedFunctionInfo, var_on_resolve,
IntPtrConstant( AsyncGeneratorReturnClosedResolveSharedFunConstant());
Context::ASYNC_GENERATOR_RETURN_CLOSED_RESOLVE_SHARED_FUN));
TVARIABLE( TVARIABLE(SharedFunctionInfo, var_on_reject,
IntPtrT, var_on_reject, AsyncGeneratorReturnClosedRejectSharedFunConstant());
IntPtrConstant(Context::ASYNC_GENERATOR_RETURN_CLOSED_REJECT_SHARED_FUN));
const TNode<Smi> state = LoadGeneratorState(generator); const TNode<Smi> state = LoadGeneratorState(generator);
GotoIf(IsGeneratorStateClosed(state), &perform_await); GotoIf(IsGeneratorStateClosed(state), &perform_await);
var_on_resolve = var_on_resolve = AsyncGeneratorReturnResolveSharedFunConstant();
IntPtrConstant(Context::ASYNC_GENERATOR_RETURN_RESOLVE_SHARED_FUN); var_on_reject = AsyncGeneratorAwaitRejectSharedFunConstant();
var_on_reject =
IntPtrConstant(Context::ASYNC_GENERATOR_AWAIT_REJECT_SHARED_FUN);
Goto(&perform_await); Goto(&perform_await);
BIND(&perform_await); BIND(&perform_await);
......
...@@ -34,24 +34,47 @@ class StubCache; ...@@ -34,24 +34,47 @@ class StubCache;
enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
#define HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(V) \ #define HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(V) \
V(ArrayIteratorProtector, array_iterator_protector, ArrayIteratorProtector) \ V(ArrayIteratorProtector, array_iterator_protector, ArrayIteratorProtector) \
V(ArraySpeciesProtector, array_species_protector, ArraySpeciesProtector) \ V(ArraySpeciesProtector, array_species_protector, ArraySpeciesProtector) \
V(MapIteratorProtector, map_iterator_protector, MapIteratorProtector) \ V(AsyncFunctionAwaitRejectSharedFun, async_function_await_reject_shared_fun, \
V(NoElementsProtector, no_elements_protector, NoElementsProtector) \ AsyncFunctionAwaitRejectSharedFun) \
V(NumberStringCache, number_string_cache, NumberStringCache) \ V(AsyncFunctionAwaitResolveSharedFun, \
V(PromiseResolveProtector, promise_resolve_protector, \ async_function_await_resolve_shared_fun, \
PromiseResolveProtector) \ AsyncFunctionAwaitResolveSharedFun) \
V(PromiseSpeciesProtector, promise_species_protector, \ V(AsyncGeneratorAwaitRejectSharedFun, \
PromiseSpeciesProtector) \ async_generator_await_reject_shared_fun, \
V(PromiseThenProtector, promise_then_protector, PromiseThenProtector) \ AsyncGeneratorAwaitRejectSharedFun) \
V(RegExpSpeciesProtector, regexp_species_protector, RegExpSpeciesProtector) \ V(AsyncGeneratorAwaitResolveSharedFun, \
V(SetIteratorProtector, set_iterator_protector, SetIteratorProtector) \ async_generator_await_resolve_shared_fun, \
V(SingleCharacterStringCache, single_character_string_cache, \ AsyncGeneratorAwaitResolveSharedFun) \
SingleCharacterStringCache) \ V(AsyncGeneratorReturnClosedRejectSharedFun, \
V(StringIteratorProtector, string_iterator_protector, \ async_generator_return_closed_reject_shared_fun, \
StringIteratorProtector) \ AsyncGeneratorReturnClosedRejectSharedFun) \
V(TypedArraySpeciesProtector, typed_array_species_protector, \ V(AsyncGeneratorReturnClosedResolveSharedFun, \
async_generator_return_closed_resolve_shared_fun, \
AsyncGeneratorReturnClosedResolveSharedFun) \
V(AsyncGeneratorReturnResolveSharedFun, \
async_generator_return_resolve_shared_fun, \
AsyncGeneratorReturnResolveSharedFun) \
V(AsyncGeneratorYieldResolveSharedFun, \
async_generator_yield_resolve_shared_fun, \
AsyncGeneratorYieldResolveSharedFun) \
V(MapIteratorProtector, map_iterator_protector, MapIteratorProtector) \
V(NoElementsProtector, no_elements_protector, NoElementsProtector) \
V(NumberStringCache, number_string_cache, NumberStringCache) \
V(PromiseResolveProtector, promise_resolve_protector, \
PromiseResolveProtector) \
V(PromiseSpeciesProtector, promise_species_protector, \
PromiseSpeciesProtector) \
V(PromiseThenProtector, promise_then_protector, PromiseThenProtector) \
V(RegExpSpeciesProtector, regexp_species_protector, RegExpSpeciesProtector) \
V(SetIteratorProtector, set_iterator_protector, SetIteratorProtector) \
V(SingleCharacterStringCache, single_character_string_cache, \
SingleCharacterStringCache) \
V(StringIteratorProtector, string_iterator_protector, \
StringIteratorProtector) \
V(TypedArraySpeciesProtector, typed_array_species_protector, \
TypedArraySpeciesProtector) TypedArraySpeciesProtector)
#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \ #define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "src/init/setup-isolate.h"
#include "src/builtins/accessors.h" #include "src/builtins/accessors.h"
#include "src/codegen/compilation-cache.h" #include "src/codegen/compilation-cache.h"
#include "src/execution/isolate.h" #include "src/execution/isolate.h"
...@@ -12,6 +10,7 @@ ...@@ -12,6 +10,7 @@
#include "src/heap/heap-inl.h" #include "src/heap/heap-inl.h"
#include "src/ic/handler-configuration.h" #include "src/ic/handler-configuration.h"
#include "src/init/heap-symbols.h" #include "src/init/heap-symbols.h"
#include "src/init/setup-isolate.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/objects/arguments.h" #include "src/objects/arguments.h"
#include "src/objects/cell-inl.h" #include "src/objects/cell-inl.h"
...@@ -51,6 +50,21 @@ ...@@ -51,6 +50,21 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace {
Handle<SharedFunctionInfo> CreateSharedFunctionInfo(
Isolate* isolate, Builtins::Name builtin_id, int len,
FunctionKind kind = FunctionKind::kNormalFunction) {
Handle<SharedFunctionInfo> shared =
isolate->factory()->NewSharedFunctionInfoForBuiltin(
isolate->factory()->empty_string(), builtin_id, kind);
shared->set_internal_formal_parameter_count(len);
shared->set_length(len);
return shared;
}
} // namespace
bool SetupIsolateDelegate::SetupHeapInternal(Heap* heap) { bool SetupIsolateDelegate::SetupHeapInternal(Heap* heap) {
return heap->CreateHeapObjects(); return heap->CreateHeapObjects();
} }
...@@ -348,7 +362,7 @@ bool Heap::CreateInitialMaps() { ...@@ -348,7 +362,7 @@ bool Heap::CreateInitialMaps() {
} }
#define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \
ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name)
#define ALLOCATE_PRIMITIVE_MAP(instance_type, size, field_name, \ #define ALLOCATE_PRIMITIVE_MAP(instance_type, size, field_name, \
constructor_function_index) \ constructor_function_index) \
...@@ -434,14 +448,14 @@ bool Heap::CreateInitialMaps() { ...@@ -434,14 +448,14 @@ bool Heap::CreateInitialMaps() {
// The "no closures" and "one closure" FeedbackCell maps need // The "no closures" and "one closure" FeedbackCell maps need
// to be marked unstable because their objects can change maps. // to be marked unstable because their objects can change maps.
ALLOCATE_MAP( ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kAlignedSize,
FEEDBACK_CELL_TYPE, FeedbackCell::kAlignedSize, no_closures_cell) no_closures_cell)
roots.no_closures_cell_map().mark_unstable(); roots.no_closures_cell_map().mark_unstable();
ALLOCATE_MAP( ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kAlignedSize,
FEEDBACK_CELL_TYPE, FeedbackCell::kAlignedSize, one_closure_cell) one_closure_cell)
roots.one_closure_cell_map().mark_unstable(); roots.one_closure_cell_map().mark_unstable();
ALLOCATE_MAP( ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kAlignedSize,
FEEDBACK_CELL_TYPE, FeedbackCell::kAlignedSize, many_closures_cell) many_closures_cell)
ALLOCATE_VARSIZE_MAP(TRANSITION_ARRAY_TYPE, transition_array) ALLOCATE_VARSIZE_MAP(TRANSITION_ARRAY_TYPE, transition_array)
...@@ -988,6 +1002,46 @@ void Heap::CreateInitialObjects() { ...@@ -988,6 +1002,46 @@ void Heap::CreateInitialObjects() {
// Initialize compilation cache. // Initialize compilation cache.
isolate_->compilation_cache()->Clear(); isolate_->compilation_cache()->Clear();
// Create internal SharedFunctionInfos.
// Async functions:
{
Handle<SharedFunctionInfo> info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncFunctionAwaitRejectClosure, 1);
set_async_function_await_reject_shared_fun(*info);
info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncFunctionAwaitResolveClosure, 1);
set_async_function_await_resolve_shared_fun(*info);
}
// Async generators:
{
Handle<SharedFunctionInfo> info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncGeneratorAwaitResolveClosure, 1);
set_async_generator_await_resolve_shared_fun(*info);
info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncGeneratorAwaitRejectClosure, 1);
set_async_generator_await_reject_shared_fun(*info);
info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncGeneratorYieldResolveClosure, 1);
set_async_generator_yield_resolve_shared_fun(*info);
info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncGeneratorReturnResolveClosure, 1);
set_async_generator_return_resolve_shared_fun(*info);
info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncGeneratorReturnClosedResolveClosure, 1);
set_async_generator_return_closed_resolve_shared_fun(*info);
info = CreateSharedFunctionInfo(
isolate(), Builtins::kAsyncGeneratorReturnClosedRejectClosure, 1);
set_async_generator_return_closed_reject_shared_fun(*info);
}
} }
void Heap::CreateInternalAccessorInfoObjects() { void Heap::CreateInternalAccessorInfoObjects() {
......
...@@ -368,6 +368,9 @@ void Bootstrapper::DetachGlobal(Handle<Context> env) { ...@@ -368,6 +368,9 @@ void Bootstrapper::DetachGlobal(Handle<Context> env) {
namespace { namespace {
// FIXME(marja): Remove SimpleCreateSharedFunctionInfo and
// SimpleCreateBuiltinSharedFunctionInfo when migration to
// setup-heap-internal.cc is complete (see v8:10482).
V8_NOINLINE Handle<SharedFunctionInfo> SimpleCreateSharedFunctionInfo( V8_NOINLINE Handle<SharedFunctionInfo> SimpleCreateSharedFunctionInfo(
Isolate* isolate, Builtins::Name builtin_id, Handle<String> name, int len, Isolate* isolate, Builtins::Name builtin_id, Handle<String> name, int len,
FunctionKind kind = FunctionKind::kNormalFunction) { FunctionKind kind = FunctionKind::kNormalFunction) {
...@@ -1620,40 +1623,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1620,40 +1623,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
native_context()->set_async_iterator_value_unwrap_shared_fun(*info); native_context()->set_async_iterator_value_unwrap_shared_fun(*info);
} }
{ // --- A s y n c G e n e r a t o r ---
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
isolate_, Builtins::kAsyncGeneratorAwaitResolveClosure,
factory->empty_string(), 1);
native_context()->set_async_generator_await_resolve_shared_fun(*info);
info = SimpleCreateSharedFunctionInfo(
isolate_, Builtins::kAsyncGeneratorAwaitRejectClosure,
factory->empty_string(), 1);
native_context()->set_async_generator_await_reject_shared_fun(*info);
info = SimpleCreateSharedFunctionInfo(
isolate_, Builtins::kAsyncGeneratorYieldResolveClosure,
factory->empty_string(), 1);
native_context()->set_async_generator_yield_resolve_shared_fun(*info);
info = SimpleCreateSharedFunctionInfo(
isolate_, Builtins::kAsyncGeneratorReturnResolveClosure,
factory->empty_string(), 1);
native_context()->set_async_generator_return_resolve_shared_fun(*info);
info = SimpleCreateSharedFunctionInfo(
isolate_, Builtins::kAsyncGeneratorReturnClosedResolveClosure,
factory->empty_string(), 1);
native_context()->set_async_generator_return_closed_resolve_shared_fun(
*info);
info = SimpleCreateSharedFunctionInfo(
isolate_, Builtins::kAsyncGeneratorReturnClosedRejectClosure,
factory->empty_string(), 1);
native_context()->set_async_generator_return_closed_reject_shared_fun(
*info);
}
Handle<JSFunction> array_prototype_to_string_fun; Handle<JSFunction> array_prototype_to_string_fun;
{ // --- A r r a y --- { // --- A r r a y ---
Handle<JSFunction> array_function = InstallFunction( Handle<JSFunction> array_function = InstallFunction(
...@@ -3734,11 +3703,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -3734,11 +3703,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->NewJSObject(isolate_->object_function(), AllocationType::kOld); factory->NewJSObject(isolate_->object_function(), AllocationType::kOld);
JSObject::AddProperty(isolate_, global, reflect_string, reflect, DONT_ENUM); JSObject::AddProperty(isolate_, global, reflect_string, reflect, DONT_ENUM);
SimpleInstallFunction(isolate_, reflect, "defineProperty", SimpleInstallFunction(isolate_, reflect, "defineProperty",
Builtins::kReflectDefineProperty, 3, true); Builtins::kReflectDefineProperty, 3, true);
SimpleInstallFunction(isolate_, reflect, "deleteProperty", SimpleInstallFunction(isolate_, reflect, "deleteProperty",
Builtins::kReflectDeleteProperty, 2, true); Builtins::kReflectDeleteProperty, 2, true);
Handle<JSFunction> apply = SimpleInstallFunction( Handle<JSFunction> apply = SimpleInstallFunction(
isolate_, reflect, "apply", Builtins::kReflectApply, 3, false); isolate_, reflect, "apply", Builtins::kReflectApply, 3, false);
...@@ -4180,20 +4149,6 @@ void Genesis::InitializeIteratorFunctions() { ...@@ -4180,20 +4149,6 @@ void Genesis::InitializeIteratorFunctions() {
Handle<Map> async_function_object_map = factory->NewMap( Handle<Map> async_function_object_map = factory->NewMap(
JS_ASYNC_FUNCTION_OBJECT_TYPE, JSAsyncFunctionObject::kHeaderSize); JS_ASYNC_FUNCTION_OBJECT_TYPE, JSAsyncFunctionObject::kHeaderSize);
native_context->set_async_function_object_map(*async_function_object_map); native_context->set_async_function_object_map(*async_function_object_map);
{
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
isolate, Builtins::kAsyncFunctionAwaitRejectClosure,
factory->empty_string(), 1);
native_context->set_async_function_await_reject_shared_fun(*info);
}
{
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
isolate, Builtins::kAsyncFunctionAwaitResolveClosure,
factory->empty_string(), 1);
native_context->set_async_function_await_resolve_shared_fun(*info);
}
} }
} }
......
...@@ -70,28 +70,12 @@ enum ContextLookupFlags { ...@@ -70,28 +70,12 @@ enum ContextLookupFlags {
V(ARRAY_FUNCTION_INDEX, JSFunction, array_function) \ V(ARRAY_FUNCTION_INDEX, JSFunction, array_function) \
V(ARRAY_JOIN_STACK_INDEX, HeapObject, array_join_stack) \ V(ARRAY_JOIN_STACK_INDEX, HeapObject, array_join_stack) \
V(ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX, Map, async_from_sync_iterator_map) \ V(ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX, Map, async_from_sync_iterator_map) \
V(ASYNC_FUNCTION_AWAIT_REJECT_SHARED_FUN, SharedFunctionInfo, \
async_function_await_reject_shared_fun) \
V(ASYNC_FUNCTION_AWAIT_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
async_function_await_resolve_shared_fun) \
V(ASYNC_FUNCTION_FUNCTION_INDEX, JSFunction, async_function_constructor) \ V(ASYNC_FUNCTION_FUNCTION_INDEX, JSFunction, async_function_constructor) \
V(ASYNC_FUNCTION_OBJECT_MAP_INDEX, Map, async_function_object_map) \ V(ASYNC_FUNCTION_OBJECT_MAP_INDEX, Map, async_function_object_map) \
V(ASYNC_GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \ V(ASYNC_GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \
async_generator_function_function) \ async_generator_function_function) \
V(ASYNC_ITERATOR_VALUE_UNWRAP_SHARED_FUN, SharedFunctionInfo, \ V(ASYNC_ITERATOR_VALUE_UNWRAP_SHARED_FUN, SharedFunctionInfo, \
async_iterator_value_unwrap_shared_fun) \ async_iterator_value_unwrap_shared_fun) \
V(ASYNC_GENERATOR_AWAIT_REJECT_SHARED_FUN, SharedFunctionInfo, \
async_generator_await_reject_shared_fun) \
V(ASYNC_GENERATOR_AWAIT_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
async_generator_await_resolve_shared_fun) \
V(ASYNC_GENERATOR_YIELD_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
async_generator_yield_resolve_shared_fun) \
V(ASYNC_GENERATOR_RETURN_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
async_generator_return_resolve_shared_fun) \
V(ASYNC_GENERATOR_RETURN_CLOSED_RESOLVE_SHARED_FUN, SharedFunctionInfo, \
async_generator_return_closed_resolve_shared_fun) \
V(ASYNC_GENERATOR_RETURN_CLOSED_REJECT_SHARED_FUN, SharedFunctionInfo, \
async_generator_return_closed_reject_shared_fun) \
V(ATOMICS_OBJECT, JSObject, atomics_object) \ V(ATOMICS_OBJECT, JSObject, atomics_object) \
V(BIGINT_FUNCTION_INDEX, JSFunction, bigint_function) \ V(BIGINT_FUNCTION_INDEX, JSFunction, bigint_function) \
V(BIGINT64_ARRAY_FUN_INDEX, JSFunction, bigint64_array_fun) \ V(BIGINT64_ARRAY_FUN_INDEX, JSFunction, bigint64_array_fun) \
......
...@@ -231,7 +231,24 @@ class Symbol; ...@@ -231,7 +231,24 @@ class Symbol;
V(FixedArray, string_split_cache, StringSplitCache) \ V(FixedArray, string_split_cache, StringSplitCache) \
V(FixedArray, regexp_multiple_cache, RegExpMultipleCache) \ V(FixedArray, regexp_multiple_cache, RegExpMultipleCache) \
/* Indirection lists for isolate-independent builtins */ \ /* Indirection lists for isolate-independent builtins */ \
V(FixedArray, builtins_constants_table, BuiltinsConstantsTable) V(FixedArray, builtins_constants_table, BuiltinsConstantsTable) \
/* Internal SFIs */ \
V(SharedFunctionInfo, async_function_await_reject_shared_fun, \
AsyncFunctionAwaitRejectSharedFun) \
V(SharedFunctionInfo, async_function_await_resolve_shared_fun, \
AsyncFunctionAwaitResolveSharedFun) \
V(SharedFunctionInfo, async_generator_await_reject_shared_fun, \
AsyncGeneratorAwaitRejectSharedFun) \
V(SharedFunctionInfo, async_generator_await_resolve_shared_fun, \
AsyncGeneratorAwaitResolveSharedFun) \
V(SharedFunctionInfo, async_generator_yield_resolve_shared_fun, \
AsyncGeneratorYieldResolveSharedFun) \
V(SharedFunctionInfo, async_generator_return_resolve_shared_fun, \
AsyncGeneratorReturnResolveSharedFun) \
V(SharedFunctionInfo, async_generator_return_closed_reject_shared_fun, \
AsyncGeneratorReturnClosedRejectSharedFun) \
V(SharedFunctionInfo, async_generator_return_closed_resolve_shared_fun, \
AsyncGeneratorReturnClosedResolveSharedFun)
// These root references can be updated by the mutator. // These root references can be updated by the mutator.
#define STRONG_MUTABLE_MOVABLE_ROOT_LIST(V) \ #define STRONG_MUTABLE_MOVABLE_ROOT_LIST(V) \
......
...@@ -435,6 +435,14 @@ KNOWN_OBJECTS = { ...@@ -435,6 +435,14 @@ KNOWN_OBJECTS = {
("old_space", 0x009ed): "StringSplitCache", ("old_space", 0x009ed): "StringSplitCache",
("old_space", 0x00df5): "RegExpMultipleCache", ("old_space", 0x00df5): "RegExpMultipleCache",
("old_space", 0x011fd): "BuiltinsConstantsTable", ("old_space", 0x011fd): "BuiltinsConstantsTable",
("old_space", 0x015a1): "AsyncFunctionAwaitRejectSharedFun",
("old_space", 0x015c9): "AsyncFunctionAwaitResolveSharedFun",
("old_space", 0x015f1): "AsyncGeneratorAwaitRejectSharedFun",
("old_space", 0x01619): "AsyncGeneratorAwaitResolveSharedFun",
("old_space", 0x01641): "AsyncGeneratorYieldResolveSharedFun",
("old_space", 0x01669): "AsyncGeneratorReturnResolveSharedFun",
("old_space", 0x01691): "AsyncGeneratorReturnClosedRejectSharedFun",
("old_space", 0x016b9): "AsyncGeneratorReturnClosedResolveSharedFun",
} }
# Lower 32 bits of first page addresses for various heap spaces. # Lower 32 bits of first page addresses for various heap spaces.
......
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