IonMonkey: Decouple the stack state from graph traversal order of LIR blocks.

RESOLVED WONTFIX

Status

()

RESOLVED WONTFIX
5 years ago
3 years ago

People

(Reporter: wuwei, Assigned: wuwei)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

5 years ago
LIRGraph uses a vector (pushedArugmentSlots_) to save the current state of stack on graph level, which impedes LIR reordering optimization (bug 901221). One possible way to solve this problem is to allocate a vector for each LIR blocks which represents the stack stat at the entry of the block.
(Assignee)

Updated

5 years ago
Blocks: 901221, 877872
Depends on: 877878
(Assignee)

Comment 1

5 years ago
Created attachment 792235 [details] [diff] [review]
WIP

For early feedback.

This patch iterates LBlocks in RPO order. It pushes the pointer of LStackArgT and LStackArgV instructions into a vector in each LBlock, and pops them after LCallNative, LCallDOMNative, LCallGeneric, LCallKnown are iterated.
Attachment #792235 - Flags: feedback?(nicolas.b.pierron)
Comment on attachment 792235 [details] [diff] [review]
WIP

Review of attachment 792235 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jit/CodeGenerator.cpp
@@ +2644,5 @@
> +        pushedArgumentSlotsMirror.appendAll(pushedArgumentSlots_);
> +#endif
> +        pushedArgumentSlots_.clear();
> +        for (size_t i = 0; i < current->pushedArguments.length(); i++) {
> +            if (current->pushedArguments[i]->accept(this))

No, this is not the way to go.

Here you will push everything back, but the stack is already in a good shape when you jump to it, there is no need to adjust anything.  Only to refresh the memory of the code generator such as it can correctly handle the stack layout.

@@ +2648,5 @@
> +            if (current->pushedArguments[i]->accept(this))
> +                return false;
> +        }
> +#ifdef DEBUG
> +        JS_ASSERT(pushedArgumentSlotsMirror.length() == pushedArgumentSlots_.length());

This assertion does not hold, for the same reason it was failing on the Calls.

::: js/src/jit/IonAnalysis.cpp
@@ +1620,5 @@
> +        block->pushedArguments.appendAll(pushedArguments);
> +        size_t numPoped = 0;
> +        for (LInstructionIterator iter = block->begin(); iter != block->end(); iter++) {
> +            if (iter->isStackArgT() || iter->isStackArgV()) {
> +                pushedArguments.append(*iter);

The vector should be a vector of uint32_t as it is on the CodeGen, filled with:

  StackOffsetToSlot(StackOffsetOfPassedArg(lir->argslot()));

@@ +1621,5 @@
> +        size_t numPoped = 0;
> +        for (LInstructionIterator iter = block->begin(); iter != block->end(); iter++) {
> +            if (iter->isStackArgT() || iter->isStackArgV()) {
> +                pushedArguments.append(*iter);
> +            }

if there is only one line, we do not add brackets.

@@ +1623,5 @@
> +            if (iter->isStackArgT() || iter->isStackArgV()) {
> +                pushedArguments.append(*iter);
> +            }
> +            if (iter->isCallNative()) {
> +                numPoped = iter->toCallNative()->numStackArgs() + 1;

it sounds like you want to add a new virtual function names isJSCall, and use it that way:

  if (iter->isJSCall())
      numPoped = iter->mir()->toCall->numStackArgs();
Attachment #792235 - Flags: feedback?(nicolas.b.pierron)
(Assignee)

Comment 3

5 years ago
Created attachment 793223 [details] [diff] [review]
WIP

Fixed nits.
Attachment #792235 - Attachment is obsolete: true
Assignee: general → nobody
(Assignee)

Updated

3 years ago
Assignee: nobody → lazyparser
(Assignee)

Comment 4

3 years ago
This bug was a supplement feature for bug 877878, which is not necessary now. so wontfix.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.