[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/903928 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#51125}
This commit is contained in:
parent
d468ff4e1f
commit
7632da067b
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user