Commit 182b43d4 authored by Joshua Litt's avatar Joshua Litt Committed by Commit Bot

[promises] Port promiseAll to torque.

Bug: v8:9838
Change-Id: I04383cba6dcb5fc61c82cb8018160aff6fed3b15
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1988794
Commit-Queue: Joshua Litt <joshualitt@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65899}
parent 365d7c80
This diff is collapsed.
......@@ -285,6 +285,7 @@ extern enum MessageTemplate {
kPromiseNonCallable,
kNotAPromise,
kResolverNotAFunction,
kTooManyElementsInPromiseAll,
kToRadixFormatRange,
kCalledOnNonObject,
kRegExpGlobalInvokedOnNonGlobal,
......
......@@ -710,10 +710,6 @@ namespace internal {
\
/* Promise */ \
CPP(IsPromise) \
/* ES #sec-promise.all */ \
TFJ(PromiseAll, 1, kReceiver, kIterable) \
/* ES #sec-promise.allsettled */ \
TFJ(PromiseAllSettled, 1, kReceiver, kIterable) \
\
/* Reflect */ \
ASM(ReflectApply, JSTrampoline) \
......
This diff is collapsed.
......@@ -47,24 +47,6 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
TNode<JSReceiver> thenable, TNode<Context> context);
Node* PromiseHasHandler(Node* promise);
// Creates the context used by all Promise.all resolve element closures,
// together with the values array. Since all closures for a single Promise.all
// call use the same context, we need to store the indices for the individual
// closures somewhere else (we put them into the identity hash field of the
// closures), and we also need to have a separate marker for when the closure
// was called already (we slap the native context onto the closure in that
// case to mark it's done).
Node* CreatePromiseAllResolveElementContext(Node* promise_capability,
Node* native_context);
TNode<JSFunction> CreatePromiseAllResolveElementFunction(Node* context,
TNode<Smi> index,
Node* native_context,
int slot_index);
TNode<Context> CreatePromiseResolvingFunctionsContext(
TNode<JSPromise> promise, TNode<Object> debug_event,
TNode<NativeContext> native_context);
void BranchIfAccessCheckFailed(SloppyTNode<Context> context,
SloppyTNode<Context> native_context,
TNode<Object> promise_constructor,
......@@ -140,33 +122,7 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
Node* receiver_map, Label* if_fast,
Label* if_slow);
// If resolve is Undefined, we use the builtin %PromiseResolve%
// intrinsic, otherwise we use the given resolve function.
Node* CallResolve(Node* native_context, Node* constructor, Node* resolve,
Node* value, Label* if_exception, Variable* var_exception);
using PromiseAllResolvingElementFunction =
std::function<TNode<Object>(TNode<Context> context, TNode<Smi> index,
TNode<NativeContext> native_context,
TNode<PromiseCapability> capability)>;
TNode<Object> PerformPromiseAll(
Node* context, Node* constructor, Node* capability,
const TorqueStructIteratorRecord& record,
const PromiseAllResolvingElementFunction& create_resolve_element_function,
const PromiseAllResolvingElementFunction& create_reject_element_function,
Label* if_exception, TVariable<Object>* var_exception);
void SetForwardingHandlerIfTrue(Node* context, Node* condition, Node* object);
void SetPromiseHandledByIfTrue(Node* context, Node* condition, Node* promise,
const NodeGenerator<Object>& handled_by);
TNode<JSPromise> AllocateJSPromise(TNode<Context> context);
void Generate_PromiseAll(
TNode<Context> context, TNode<Object> receiver, TNode<Object> iterable,
const PromiseAllResolvingElementFunction& create_resolve_element_function,
const PromiseAllResolvingElementFunction& create_reject_element_function);
};
} // namespace internal
......
......@@ -248,9 +248,6 @@ namespace promise {
extern macro
PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Context): JSPromise;
extern macro
PromiseBuiltinsAssembler::CreatePromiseResolvingFunctionsContext(
JSPromise, Object, NativeContext): Context;
@export
macro CreatePromiseCapabilitiesExecutorContext(
......
This diff is collapsed.
......@@ -47,7 +47,9 @@ extern enum NativeContextSlot extends intptr constexpr 'Context::Field' {
PROMISE_FUNCTION_INDEX,
PROMISE_THEN_INDEX,
STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
PROMISE_ALL_RESOLVE_ELEMENT_SHARED_FUN,
PROMISE_ALL_SETTLED_REJECT_ELEMENT_SHARED_FUN,
PROMISE_ALL_SETTLED_RESOLVE_ELEMENT_SHARED_FUN,
PROMISE_CAPABILITY_DEFAULT_RESOLVE_SHARED_FUN_INDEX,
PROMISE_CAPABILITY_DEFAULT_REJECT_SHARED_FUN_INDEX,
PROMISE_CATCH_FINALLY_SHARED_FUN,
......@@ -56,6 +58,7 @@ extern enum NativeContextSlot extends intptr constexpr 'Context::Field' {
PROMISE_THROWER_FINALLY_SHARED_FUN,
PROMISE_THEN_FINALLY_SHARED_FUN,
PROMISE_VALUE_THUNK_FINALLY_SHARED_FUN,
STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
...
}
......
......@@ -2554,13 +2554,13 @@ TEST(CreatePromiseResolvingFunctionsContext) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
PromiseBuiltinsAssembler m(asm_tester.state());
Node* const context = m.Parameter(kNumParams + 2);
const TNode<Context> context = m.CAST(m.Parameter(kNumParams + 2));
const TNode<NativeContext> native_context = m.LoadNativeContext(context);
const TNode<JSPromise> promise =
m.AllocateAndInitJSPromise(m.CAST(context), m.UndefinedConstant());
m.AllocateAndInitJSPromise(context, m.UndefinedConstant());
const TNode<Context> promise_context =
m.CreatePromiseResolvingFunctionsContext(
promise, m.BooleanConstant(false), native_context);
context, promise, m.BooleanConstant(false), native_context);
m.Return(promise_context);
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......@@ -2672,12 +2672,12 @@ TEST(AllocateFunctionWithMapAndContext) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
PromiseBuiltinsAssembler m(asm_tester.state());
Node* const context = m.Parameter(kNumParams + 2);
const TNode<Context> context = m.CAST(m.Parameter(kNumParams + 2));
const TNode<NativeContext> native_context = m.LoadNativeContext(context);
const TNode<JSPromise> promise =
m.AllocateAndInitJSPromise(m.CAST(context), m.UndefinedConstant());
m.AllocateAndInitJSPromise(context, m.UndefinedConstant());
TNode<Context> promise_context = m.CreatePromiseResolvingFunctionsContext(
promise, m.BooleanConstant(false), native_context);
context, promise, m.BooleanConstant(false), native_context);
TNode<Object> resolve_info = m.LoadContextElement(
native_context,
Context::PROMISE_CAPABILITY_DEFAULT_RESOLVE_SHARED_FUN_INDEX);
......
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