Commit 16ff5f83 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

Move helper SFIs from NativeContext to Isolate, part 3

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

This CL moves the minimal subset of SFIs related to Promises / finally.

Bug: v8:10482
Change-Id: I06a20dc927f13b7bfc8cea853a11913314ee019d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2187271Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67674}
parent f4b98cc6
......@@ -43,8 +43,7 @@ namespace promise {
const map = UnsafeCast<Map>(
nativeContext
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
const throwerInfo = UnsafeCast<SharedFunctionInfo>(
nativeContext[NativeContextSlot::PROMISE_THROWER_FINALLY_SHARED_FUN]);
const throwerInfo = PromiseThrowerFinallySharedFunConstant();
return AllocateFunctionWithMapAndContext(map, throwerInfo, throwerContext);
}
......@@ -85,9 +84,7 @@ namespace promise {
const map = UnsafeCast<Map>(
nativeContext
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
const valueThunkInfo = UnsafeCast<SharedFunctionInfo>(
nativeContext
[NativeContextSlot::PROMISE_VALUE_THUNK_FINALLY_SHARED_FUN]);
const valueThunkInfo = PromiseValueThunkFinallySharedFunConstant();
return AllocateFunctionWithMapAndContext(
map, valueThunkInfo, valueThunkContext);
}
......@@ -136,12 +133,10 @@ namespace promise {
const map = UnsafeCast<Map>(
nativeContext
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
const thenFinallyInfo = UnsafeCast<SharedFunctionInfo>(
nativeContext[NativeContextSlot::PROMISE_THEN_FINALLY_SHARED_FUN]);
const thenFinallyInfo = PromiseThenFinallySharedFunConstant();
const thenFinally =
AllocateFunctionWithMapAndContext(map, thenFinallyInfo, promiseContext);
const catchFinallyInfo = UnsafeCast<SharedFunctionInfo>(
nativeContext[NativeContextSlot::PROMISE_CATCH_FINALLY_SHARED_FUN]);
const catchFinallyInfo = PromiseCatchFinallySharedFunConstant();
const catchFinally = AllocateFunctionWithMapAndContext(
map, catchFinallyInfo, promiseContext);
return PromiseFinallyFunctions{
......@@ -205,4 +200,9 @@ namespace promise {
return UnsafeCast<JSAny>(
InvokeThen(nativeContext, receiver, thenFinally, catchFinally));
}
extern macro PromiseCatchFinallySharedFunConstant(): SharedFunctionInfo;
extern macro PromiseThenFinallySharedFunConstant(): SharedFunctionInfo;
extern macro PromiseThrowerFinallySharedFunConstant(): SharedFunctionInfo;
extern macro PromiseValueThunkFinallySharedFunConstant(): SharedFunctionInfo;
}
......@@ -65,11 +65,19 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
V(MapIteratorProtector, map_iterator_protector, MapIteratorProtector) \
V(NoElementsProtector, no_elements_protector, NoElementsProtector) \
V(NumberStringCache, number_string_cache, NumberStringCache) \
V(PromiseCatchFinallySharedFun, promise_catch_finally_shared_fun, \
PromiseCatchFinallySharedFun) \
V(PromiseResolveProtector, promise_resolve_protector, \
PromiseResolveProtector) \
V(PromiseSpeciesProtector, promise_species_protector, \
PromiseSpeciesProtector) \
V(PromiseThenFinallySharedFun, promise_then_finally_shared_fun, \
PromiseThenFinallySharedFun) \
V(PromiseThenProtector, promise_then_protector, PromiseThenProtector) \
V(PromiseThrowerFinallySharedFun, promise_thrower_finally_shared_fun, \
PromiseThrowerFinallySharedFun) \
V(PromiseValueThunkFinallySharedFun, promise_value_thunk_finally_shared_fun, \
PromiseValueThunkFinallySharedFun) \
V(RegExpSpeciesProtector, regexp_species_protector, RegExpSpeciesProtector) \
V(SetIteratorProtector, set_iterator_protector, SetIteratorProtector) \
V(SingleCharacterStringCache, single_character_string_cache, \
......
......@@ -421,8 +421,6 @@ class ContextRef : public HeapObjectRef {
V(Map, with_context_map) \
V(ScriptContextTable, script_context_table) \
V(SharedFunctionInfo, promise_capability_default_reject_shared_fun) \
V(SharedFunctionInfo, promise_catch_finally_shared_fun) \
V(SharedFunctionInfo, promise_then_finally_shared_fun) \
V(SharedFunctionInfo, promise_capability_default_resolve_shared_fun)
// Those are set by Bootstrapper::ExportFromRuntime, which may not yet have
......
......@@ -6355,14 +6355,16 @@ Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) {
context, constructor, etrue, if_true);
// Allocate the closure for the reject case.
SharedFunctionInfoRef promise_catch_finally(
broker(), factory()->promise_catch_finally_shared_fun());
catch_true = etrue = CreateClosureFromBuiltinSharedFunctionInfo(
native_context().promise_catch_finally_shared_fun(), context, etrue,
if_true);
promise_catch_finally, context, etrue, if_true);
// Allocate the closure for the fulfill case.
SharedFunctionInfoRef promise_then_finally(
broker(), factory()->promise_then_finally_shared_fun());
then_true = etrue = CreateClosureFromBuiltinSharedFunctionInfo(
native_context().promise_then_finally_shared_fun(), context, etrue,
if_true);
promise_then_finally, context, etrue, if_true);
}
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
......
......@@ -2302,6 +2302,12 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
if (arguments.size() >= 1) {
ProcessMapHintsForPromises(arguments[0]);
}
SharedFunctionInfoRef(
broker(),
broker()->isolate()->factory()->promise_catch_finally_shared_fun());
SharedFunctionInfoRef(
broker(),
broker()->isolate()->factory()->promise_then_finally_shared_fun());
}
break;
}
......
......@@ -1049,6 +1049,27 @@ void Heap::CreateInitialObjects() {
isolate_, Builtins::kAsyncIteratorValueUnwrap, 1);
set_async_iterator_value_unwrap_shared_fun(*info);
}
// Promises / finally:
{
Handle<SharedFunctionInfo> info =
CreateSharedFunctionInfo(isolate(), Builtins::kPromiseThenFinally, 1);
info->set_native(true);
set_promise_then_finally_shared_fun(*info);
info =
CreateSharedFunctionInfo(isolate(), Builtins::kPromiseCatchFinally, 1);
info->set_native(true);
set_promise_catch_finally_shared_fun(*info);
info = CreateSharedFunctionInfo(isolate(),
Builtins::kPromiseValueThunkFinally, 0);
set_promise_value_thunk_finally_shared_fun(*info);
info = CreateSharedFunctionInfo(isolate(), Builtins::kPromiseThrowerFinally,
0);
set_promise_thrower_finally_shared_fun(*info);
}
}
void Heap::CreateInternalAccessorInfoObjects() {
......
......@@ -2351,36 +2351,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallFunctionWithBuiltinId(isolate_, prototype, "finally",
Builtins::kPromisePrototypeFinally, 1, true);
{
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
isolate(), Builtins::kPromiseThenFinally,
isolate_->factory()->empty_string(), 1);
info->set_native(true);
native_context()->set_promise_then_finally_shared_fun(*info);
}
{
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
isolate(), Builtins::kPromiseCatchFinally,
isolate_->factory()->empty_string(), 1);
info->set_native(true);
native_context()->set_promise_catch_finally_shared_fun(*info);
}
{
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
isolate(), Builtins::kPromiseValueThunkFinally,
isolate_->factory()->empty_string(), 0);
native_context()->set_promise_value_thunk_finally_shared_fun(*info);
}
{
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
isolate(), Builtins::kPromiseThrowerFinally,
isolate_->factory()->empty_string(), 0);
native_context()->set_promise_thrower_finally_shared_fun(*info);
}
DCHECK(promise_fun->HasFastProperties());
Handle<Map> prototype_map(prototype->map(), isolate());
......
......@@ -207,14 +207,6 @@ enum ContextLookupFlags {
promise_capability_default_reject_shared_fun) \
V(PROMISE_CAPABILITY_DEFAULT_RESOLVE_SHARED_FUN_INDEX, SharedFunctionInfo, \
promise_capability_default_resolve_shared_fun) \
V(PROMISE_THEN_FINALLY_SHARED_FUN, SharedFunctionInfo, \
promise_then_finally_shared_fun) \
V(PROMISE_CATCH_FINALLY_SHARED_FUN, SharedFunctionInfo, \
promise_catch_finally_shared_fun) \
V(PROMISE_VALUE_THUNK_FINALLY_SHARED_FUN, SharedFunctionInfo, \
promise_value_thunk_finally_shared_fun) \
V(PROMISE_THROWER_FINALLY_SHARED_FUN, SharedFunctionInfo, \
promise_thrower_finally_shared_fun) \
V(PROMISE_ALL_RESOLVE_ELEMENT_SHARED_FUN, SharedFunctionInfo, \
promise_all_resolve_element_shared_fun) \
V(PROMISE_ALL_SETTLED_RESOLVE_ELEMENT_SHARED_FUN, SharedFunctionInfo, \
......
......@@ -54,12 +54,8 @@ extern enum NativeContextSlot extends intptr constexpr 'Context::Field' {
PROMISE_ANY_REJECT_ELEMENT_SHARED_FUN,
PROMISE_CAPABILITY_DEFAULT_RESOLVE_SHARED_FUN_INDEX,
PROMISE_CAPABILITY_DEFAULT_REJECT_SHARED_FUN_INDEX,
PROMISE_CATCH_FINALLY_SHARED_FUN,
PROMISE_GET_CAPABILITIES_EXECUTOR_SHARED_FUN,
PROMISE_PROTOTYPE_INDEX,
PROMISE_THROWER_FINALLY_SHARED_FUN,
PROMISE_THEN_FINALLY_SHARED_FUN,
PROMISE_VALUE_THUNK_FINALLY_SHARED_FUN,
STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX,
......
......@@ -251,7 +251,15 @@ class Symbol;
V(SharedFunctionInfo, async_generator_return_closed_resolve_shared_fun, \
AsyncGeneratorReturnClosedResolveSharedFun) \
V(SharedFunctionInfo, async_iterator_value_unwrap_shared_fun, \
AsyncIteratorValueUnwrapSharedFun)
AsyncIteratorValueUnwrapSharedFun) \
V(SharedFunctionInfo, promise_catch_finally_shared_fun, \
PromiseCatchFinallySharedFun) \
V(SharedFunctionInfo, promise_then_finally_shared_fun, \
PromiseThenFinallySharedFun) \
V(SharedFunctionInfo, promise_thrower_finally_shared_fun, \
PromiseThrowerFinallySharedFun) \
V(SharedFunctionInfo, promise_value_thunk_finally_shared_fun, \
PromiseValueThunkFinallySharedFun)
// These root references can be updated by the mutator.
#define STRONG_MUTABLE_MOVABLE_ROOT_LIST(V) \
......
......@@ -445,6 +445,10 @@ KNOWN_OBJECTS = {
("old_space", 0x01691): "AsyncGeneratorReturnClosedRejectSharedFun",
("old_space", 0x016b9): "AsyncGeneratorReturnClosedResolveSharedFun",
("old_space", 0x016e1): "AsyncIteratorValueUnwrapSharedFun",
("old_space", 0x01709): "PromiseCatchFinallySharedFun",
("old_space", 0x01731): "PromiseThenFinallySharedFun",
("old_space", 0x01759): "PromiseThrowerFinallySharedFun",
("old_space", 0x01781): "PromiseValueThunkFinallySharedFun",
}
# 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