Wasm baseline: Use NonAssertingLabel for Block/Loop, get rid of the label pool

RESOLVED FIXED in Firefox 53

Status

()

defect
P2
normal
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: lth, Assigned: lth)

Tracking

(Blocks 1 bug)

unspecified
mozilla53
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox53 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

Currently there is a label pool in the baseline compiler because the labels for Block and Loop don't obey stack discipline (because of nonrecursive traversal of the bytecode).  This label pool is dynamic, so risks OOM, so there is OOM handling and error propagation, it's all a little ugly.

Luke suggests (bug 1316819 comment 3) that we can use NonAssertingLabel instead here, and get rid of the label pool and the OOM handling.

This work will interact slightly with bug 1316814 (control stack revamp), be sure to take that into account.
Something like this?  Passes testing locally, seems reasonable.  (Sits on top of my current patch for bug 1331900.)

Notes:

(1) Discussion going on in bug 1331900 about whether it's reasonable for the iterator's control stack to reinitialize the control item when it switches to the 'else' branch.  In the patch on that bug I hacked around the problem.  Here I remove that functionality entirely since it requires the ControlItem to be assignable, and mine aren't.  Hence asking for feedback only.  If we keep the current reinit functionality for ControlItems then this patch won't work in its current form.

(2) What became a copy before readEnd() in bug 1331900 becomes a Move here to handle the non-copyable Labels.
Assignee: nobody → lhansen
Status: NEW → ASSIGNED
Attachment #8827851 - Flags: feedback?(luke)
Comment on attachment 8827851 [details] [diff] [review]
bug1329096-remove-label-pool.patch

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

Looks great, pretty mechanical except for interactions with bug 1316814 which I think will be decided in that bug (possibly folding in this patch).
Attachment #8827851 - Flags: feedback?(luke) → feedback+
Similar to the patch you just saw but avoids the very dodgy use of the Move() operation and does not make any changes to the iterator, only to the baseline compiler.
Attachment #8827851 - Attachment is obsolete: true
Attachment #8827982 - Flags: review?(luke)
Comment on attachment 8827982 [details] [diff] [review]
bug1329096-remove-label-pool-v2.patch

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

Great!  It'll be interesting to see if this moves the dial on awfy.

::: js/src/wasm/WasmBaselineCompile.cpp
@@ +380,1 @@
>                stackSize(0),

Could these be initialized to bogus (UINT32_MAX) values that initControl() asserts are bogus?

@@ +5416,4 @@
>      if (!deadCode_)
>          sync();                    // Simplifies branching out from block
>  
> +    initControl(controlItem());

Could this now be moved to right after readBlock() (to minimize the created-but-not-initialized range of the Control item)?  Also in emitLoop()

@@ +7591,5 @@
>          return false;
>  
>      beginFunction();
>  
> +    initControl(controlItem());

Similarly, could this be moved right under readFunctionStart()?
Attachment #8827982 - Flags: review?(luke) → review+
(In reply to Luke Wagner [:luke] from comment #4)
> Comment on attachment 8827982 [details] [diff] [review]
> bug1329096-remove-label-pool-v2.patch
> 
> Review of attachment 8827982 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> @@ +5416,4 @@
> >      if (!deadCode_)
> >          sync();                    // Simplifies branching out from block
> >  
> > +    initControl(controlItem());
> 
> Could this now be moved to right after readBlock() (to minimize the
> created-but-not-initialized range of the Control item)?  Also in emitLoop()

I don't think so.  initControl() captures masm.framePushed() and that may be updated by sync(): for now, we have an adjustable stack pointer.

> @@ +7591,5 @@
> >          return false;
> >  
> >      beginFunction();
> >  
> > +    initControl(controlItem());
> 
> Similarly, could this be moved right under readFunctionStart()?

Ditto, masm.framePushed() will be updated (for sure) by beginFunction.
https://hg.mozilla.org/integration/mozilla-inbound/rev/082be147ff94724672c59bb62ef47d8c086cd191
Bug 1329096 - Wasm baseline, remove the label pool and use NonAssertingLabel instead. r=luke
https://hg.mozilla.org/mozilla-central/rev/082be147ff94
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.