Commit cd8100b6 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[CSA][cleanup] TNodify builtins promise gen (pt. 2)

The promise file is too big so I am splitting it in several CLs.

TNodified:
 * AllocatePromiseReaction
 * AllocatePromiseReactionJobTask
 * AllocatePromiseResolveThenableJobTask
 * CreatePromiseResolvingFunctions
 * CreatePromiseResolvingFunctionsContext
 * CreatePromiseContext

This CL introduces some CASTs that will be deleted once the file is
TNodified in full.

Bug: v8:6949
Change-Id: Ia3006faa5e9fd0e6fa3c58511772857910326532
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1809360
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63882}
parent e8d74ad0
......@@ -93,8 +93,7 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld(
InitializeNativeClosure(closure_context, native_context, on_reject,
on_reject_context_index);
VARIABLE(var_throwaway, MachineRepresentation::kTaggedPointer,
UndefinedConstant());
TVARIABLE(HeapObject, var_throwaway, UndefinedConstant());
// Deal with PromiseHooks and debug support in the runtime. This
// also allocates the throwaway promise, which is only needed in
......@@ -103,9 +102,9 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOld(
Branch(IsPromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate(),
&if_debugging, &do_resolve_promise);
BIND(&if_debugging);
var_throwaway.Bind(CallRuntime(Runtime::kAwaitPromisesInitOld, context, value,
wrapped_value, outer_promise, on_reject,
is_predicted_as_caught));
var_throwaway = CAST(CallRuntime(Runtime::kAwaitPromisesInitOld, context,
value, wrapped_value, outer_promise,
on_reject, is_predicted_as_caught));
Goto(&do_resolve_promise);
BIND(&do_resolve_promise);
......@@ -164,8 +163,7 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized(
InitializeNativeClosure(closure_context, native_context, on_reject,
on_reject_context_index);
VARIABLE(var_throwaway, MachineRepresentation::kTaggedPointer,
UndefinedConstant());
TVARIABLE(HeapObject, var_throwaway, UndefinedConstant());
// Deal with PromiseHooks and debug support in the runtime. This
// also allocates the throwaway promise, which is only needed in
......@@ -174,9 +172,9 @@ TNode<Object> AsyncBuiltinsAssembler::AwaitOptimized(
Branch(IsPromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate(),
&if_debugging, &do_perform_promise_then);
BIND(&if_debugging);
var_throwaway.Bind(CallRuntime(Runtime::kAwaitPromisesInit, context, promise,
promise, outer_promise, on_reject,
is_predicted_as_caught));
var_throwaway =
CAST(CallRuntime(Runtime::kAwaitPromisesInit, context, promise, promise,
outer_promise, on_reject, is_predicted_as_caught));
Goto(&do_perform_promise_then);
BIND(&do_perform_promise_then);
......@@ -281,22 +279,22 @@ void AsyncBuiltinsAssembler::InitializeNativeClosure(
TNode<JSFunction> AsyncBuiltinsAssembler::CreateUnwrapClosure(
TNode<NativeContext> native_context, TNode<HeapObject> done) {
TNode<Object> const map = LoadContextElement(
native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
TNode<SharedFunctionInfo> const on_fulfilled_shared = CAST(LoadContextElement(
const TNode<Map> map = CAST(LoadContextElement(
native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX));
const TNode<SharedFunctionInfo> on_fulfilled_shared = CAST(LoadContextElement(
native_context, Context::ASYNC_ITERATOR_VALUE_UNWRAP_SHARED_FUN));
TNode<Context> const closure_context =
const TNode<Context> closure_context =
AllocateAsyncIteratorValueUnwrapContext(native_context, done);
return SloppyTNode<JSFunction>(AllocateFunctionWithMapAndContext(
map, on_fulfilled_shared, closure_context));
return AllocateFunctionWithMapAndContext(map, on_fulfilled_shared,
closure_context);
}
TNode<Context> AsyncBuiltinsAssembler::AllocateAsyncIteratorValueUnwrapContext(
TNode<NativeContext> native_context, TNode<HeapObject> done) {
CSA_ASSERT(this, IsBoolean(done));
TNode<Context> context = SloppyTNode<Context>(
CreatePromiseContext(native_context, ValueUnwrapContext::kLength));
TNode<Context> context =
CreatePromiseContext(native_context, ValueUnwrapContext::kLength);
StoreContextElementNoWriteBarrier(context, ValueUnwrapContext::kDoneSlot,
done);
return context;
......
This diff is collapsed.
......@@ -34,19 +34,22 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
v8::Promise::PromiseState status,
TNode<Object> result);
Node* AllocatePromiseReaction(Node* next, Node* promise_or_capability,
Node* fulfill_handler, Node* reject_handler);
Node* AllocatePromiseReactionJobTask(Node* map, Node* context, Node* argument,
Node* handler,
Node* promise_or_capability);
Node* AllocatePromiseResolveThenableJobTask(Node* promise_to_resolve,
Node* then, Node* thenable,
Node* context);
std::pair<Node*, Node*> CreatePromiseResolvingFunctions(Node* promise,
Node* debug_event,
Node* native_context);
TNode<PromiseReaction> AllocatePromiseReaction(
TNode<Object> next, TNode<HeapObject> promise_or_capability,
TNode<HeapObject> fulfill_handler, TNode<HeapObject> reject_handler);
TNode<PromiseReactionJobTask> AllocatePromiseReactionJobTask(
TNode<Map> map, TNode<Context> context, TNode<Object> argument,
TNode<HeapObject> handler, TNode<HeapObject> promise_or_capability);
TNode<PromiseResolveThenableJobTask> AllocatePromiseResolveThenableJobTask(
TNode<JSPromise> promise_to_resolve, TNode<JSReceiver> then,
TNode<JSReceiver> thenable, TNode<Context> context);
std::pair<TNode<JSFunction>, TNode<JSFunction>>
CreatePromiseResolvingFunctions(TNode<JSPromise> promise,
TNode<Object> debug_event,
TNode<NativeContext> native_context);
Node* PromiseHasHandler(Node* promise);
......@@ -64,8 +67,9 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
Node* native_context,
int slot_index);
Node* CreatePromiseResolvingFunctionsContext(Node* promise, Node* debug_event,
Node* native_context);
TNode<Context> CreatePromiseResolvingFunctionsContext(
TNode<JSPromise> promise, TNode<Object> debug_event,
TNode<NativeContext> native_context);
Node* CreatePromiseGetCapabilitiesExecutorContext(Node* promise_capability,
Node* native_context);
......@@ -81,7 +85,8 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
TNode<HeapObject> on_rejected,
TNode<HeapObject> result_promise_or_capability);
Node* CreatePromiseContext(Node* native_context, int slots);
TNode<Context> CreatePromiseContext(TNode<NativeContext> native_context,
int slots);
Node* TriggerPromiseReactions(Node* context, Node* promise, Node* result,
PromiseReaction::Type type);
......
......@@ -129,15 +129,15 @@ TNode<JSFunction> ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(
TNode<Context> context, TNode<JSProxy> proxy) {
TNode<NativeContext> const native_context = LoadNativeContext(context);
Node* const proxy_context =
CreateProxyRevokeFunctionContext(proxy, native_context);
TNode<Object> const revoke_map = LoadContextElement(
native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
TNode<Object> const revoke_info =
LoadContextElement(native_context, Context::PROXY_REVOKE_SHARED_FUN);
return CAST(AllocateFunctionWithMapAndContext(revoke_map, revoke_info,
proxy_context));
const TNode<Context> proxy_context =
CAST(CreateProxyRevokeFunctionContext(proxy, native_context));
const TNode<Map> revoke_map = CAST(LoadContextElement(
native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX));
const TNode<SharedFunctionInfo> revoke_info = CAST(
LoadContextElement(native_context, Context::PROXY_REVOKE_SHARED_FUN));
return AllocateFunctionWithMapAndContext(revoke_map, revoke_info,
proxy_context);
}
TF_BUILTIN(CallProxy, ProxiesCodeStubAssembler) {
......
......@@ -13945,11 +13945,9 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
return sfi_code.value();
}
Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map,
Node* shared_info,
Node* context) {
CSA_SLOW_ASSERT(this, IsMap(map));
TNode<JSFunction> CodeStubAssembler::AllocateFunctionWithMapAndContext(
TNode<Map> map, TNode<SharedFunctionInfo> shared_info,
TNode<Context> context) {
TNode<Code> const code = GetSharedFunctionInfoCode(shared_info);
// TODO(ishell): All the callers of this function pass map loaded from
......@@ -13970,7 +13968,7 @@ Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map,
shared_info);
StoreObjectFieldNoWriteBarrier(fun, JSFunction::kContextOffset, context);
StoreObjectFieldNoWriteBarrier(fun, JSFunction::kCodeOffset, code);
return fun;
return CAST(fun);
}
void CodeStubAssembler::CheckPrototypeEnumCache(Node* receiver,
......
......@@ -3566,8 +3566,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
SloppyTNode<SharedFunctionInfo> shared_info,
Label* if_compile_lazy = nullptr);
Node* AllocateFunctionWithMapAndContext(Node* map, Node* shared_info,
Node* context);
TNode<JSFunction> AllocateFunctionWithMapAndContext(
TNode<Map> map, TNode<SharedFunctionInfo> shared_info,
TNode<Context> context);
// Promise helpers
Node* IsPromiseHookEnabled();
......
......@@ -2419,7 +2419,7 @@ TEST(CreatePromiseResolvingFunctionsContext) {
Node* const context = m.Parameter(kNumParams + 2);
TNode<NativeContext> const native_context = m.LoadNativeContext(context);
Node* const promise =
const TNode<JSPromise> promise =
m.AllocateAndInitJSPromise(m.CAST(context), m.UndefinedConstant());
Node* const promise_context = m.CreatePromiseResolvingFunctionsContext(
promise, m.BooleanConstant(false), native_context);
......@@ -2447,7 +2447,7 @@ TEST(CreatePromiseResolvingFunctions) {
Node* const context = m.Parameter(kNumParams + 2);
TNode<NativeContext> const native_context = m.LoadNativeContext(context);
Node* const promise =
const TNode<JSPromise> promise =
m.AllocateAndInitJSPromise(m.CAST(context), m.UndefinedConstant());
Node *resolve, *reject;
std::tie(resolve, reject) = m.CreatePromiseResolvingFunctions(
......@@ -2537,7 +2537,7 @@ TEST(AllocateFunctionWithMapAndContext) {
Node* const context = m.Parameter(kNumParams + 2);
TNode<NativeContext> const native_context = m.LoadNativeContext(context);
Node* const promise =
const TNode<JSPromise> promise =
m.AllocateAndInitJSPromise(m.CAST(context), m.UndefinedConstant());
Node* promise_context = m.CreatePromiseResolvingFunctionsContext(
promise, m.BooleanConstant(false), native_context);
......@@ -2546,8 +2546,8 @@ TEST(AllocateFunctionWithMapAndContext) {
Context::PROMISE_CAPABILITY_DEFAULT_RESOLVE_SHARED_FUN_INDEX);
TNode<Object> const map = m.LoadContextElement(
native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
Node* const resolve =
m.AllocateFunctionWithMapAndContext(map, resolve_info, promise_context);
Node* const resolve = m.AllocateFunctionWithMapAndContext(
m.CAST(map), m.CAST(resolve_info), m.CAST(promise_context));
m.Return(resolve);
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......
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