Closed Bug 1249531 Opened 8 years ago Closed 8 years ago

Baldr: add text format and encoding support for control operators

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: luke, Assigned: luke)

References

Details

Attachments

(2 files, 1 obsolete file)

Bug 1246116 will make the actual encoding/semantic changes for Br/BrIf/Loop/Tableswitch; this bug just adds br/br_if/loop/tableswitch to the s-expr text language.  With this patch, we can parse full Binaryen output (at least bananabread).
Attachment #8721157 - Flags: review?(mbebenita)
Comment on attachment 8721157 [details] [diff] [review]
other-control-flow

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

Looks great! Minor nits and table switch bug need to be addressed. Excited to see that we can parse large Binaryen files now.

::: js/src/asmjs/WasmText.cpp
@@ +2602,5 @@
>  
> +static WasmAstTableSwitch*
> +ParseTableSwitch(WasmParseContext& c)
> +{
> +    WasmAstExpr* index = ParseExpr(c);

TableSwitches also have breakNames.

@@ +2614,5 @@
> +
> +    WasmRefVector table(c.lifo);
> +
> +    while (c.ts.getIf(WasmToken::OpenParen)) {
> +        if (!c.ts.match(WasmToken::Br, c.error))

What about WasmToken::Case, follow-up bug?

@@ +3184,5 @@
> +
> +static bool
> +ResolveBranch(Resolver& r, WasmAstBranch& br)
> +{
> +    if (!br.target().name().empty() && !r.resolveTarget(br.target()))

Since the |if(!x.name().empty() && !r.resolveXXXX()) pattern is so common, it would be nice to move the name().empty() check into the resolveXXX() function. Here, and everywhere else.

@@ +3321,5 @@
>  }
>  
>  static bool
> +ResolveTableSwitch(Resolver& r, WasmAstTableSwitch& ts)
> +{

Need to push the TableSwitch breakName here.
Attachment #8721157 - Flags: review?(mbebenita) → review+
(In reply to Michael Bebenita [:mbx] from comment #1)
> TableSwitches also have breakNames.

Those are only really useful when you have cases; along with the proposal to remove cases we're proposing to remove the break label too.

> What about WasmToken::Case, follow-up bug?

We'll be proposing to remove them next week :)
Attached patch measure (obsolete) — Splinter Review
Not for landing, but here's a patch I wrote that adds some basic instrumentation to WasmText.cpp to print AST node percentage as well as the number of bytes spent on various nodes' immediates.
Neat. Also take a look at: https://github.com/WebAssembly/binaryen/pull/204

You can do something like |./binaryen-shell/ x.wast --metrics| to dump stats, for example:

https://pastebin.mozilla.org/8860409
https://hg.mozilla.org/mozilla-central/rev/0e20bdd12dd1
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Attached patch measureSplinter Review
Attachment #8721580 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: