Commit 7632da06 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[builtins] Save one word in contexts for Promise.all.

In the contexts for the resolver closures used in Promise.all we can
save the "already visited" cell, by just setting the index slot to a
negative value, which then indicates that this element was already
done.

Bug: v8:7253
Change-Id: I1296a2216eac3b51368c1e7795dbcd2c80cc430a
Reviewed-on: https://chromium-review.googlesource.com/903928Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51125}
parent d468ff4e
......@@ -1703,9 +1703,6 @@ Node* PromiseBuiltinsAssembler::PerformPromiseAll(
// Promise.all Resolve Element Functions.
Node* const resolve_context =
CreatePromiseContext(native_context, kPromiseAllResolveElementLength);
StoreContextElementNoWriteBarrier(
resolve_context, kPromiseAllResolveElementAlreadyVisitedSlot,
SmiConstant(0));
StoreContextElementNoWriteBarrier(
resolve_context, kPromiseAllResolveElementIndexSlot, var_index.value());
StoreContextElementNoWriteBarrier(
......@@ -1890,19 +1887,16 @@ TF_BUILTIN(PromiseAllResolveElementClosure, PromiseBuiltinsAssembler) {
CSA_ASSERT(this, SmiEqual(LoadFixedArrayBaseLength(context),
SmiConstant(kPromiseAllResolveElementLength)));
Label already_called(this), resolve_promise(this);
GotoIf(SmiEqual(LoadContextElement(
context, kPromiseAllResolveElementAlreadyVisitedSlot),
SmiConstant(1)),
&already_called);
StoreContextElementNoWriteBarrier(
context, kPromiseAllResolveElementAlreadyVisitedSlot, SmiConstant(1));
Node* const index =
LoadContextElement(context, kPromiseAllResolveElementIndexSlot);
Node* const values_array =
LoadContextElement(context, kPromiseAllResolveElementValuesArraySlot);
Label already_called(this, Label::kDeferred), resolve_promise(this);
GotoIf(SmiLessThan(index, SmiConstant(Smi::kZero)), &already_called);
StoreContextElementNoWriteBarrier(context, kPromiseAllResolveElementIndexSlot,
SmiConstant(-1));
// Set element in FixedArray
Label runtime_set_element(this), did_set_element(this);
GotoIfNot(TaggedIsPositiveSmi(index), &runtime_set_element);
......
......@@ -29,11 +29,8 @@ class PromiseBuiltinsAssembler : public CodeStubAssembler {
protected:
enum PromiseAllResolveElementContextSlots {
// Whether the resolve callback was already called.
kPromiseAllResolveElementAlreadyVisitedSlot = Context::MIN_CONTEXT_SLOTS,
// Index into the values array
kPromiseAllResolveElementIndexSlot,
// Index into the values array, or -1 if the callback was already called
kPromiseAllResolveElementIndexSlot = Context::MIN_CONTEXT_SLOTS,
// Remaining elements count (mutable HeapNumber)
kPromiseAllResolveElementRemainingElementsSlot,
......
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