Closed Bug 1271375 Opened 8 years ago Closed 8 years ago

[wasm] Parse binary format into AST tree

Categories

(Core :: JavaScript Engine: JIT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: yury, Assigned: yury)

References

Details

Attachments

(1 file)

This will also restore wasmBinaryToText functionality  (bug 1259295 disabled it) to complete the use case and provide testing.

The WasmTextToBinary.cpp contains AST data structures that can be refactored into separate file/header and used for both processes: text-to-binary and binary-to-text. The latter will evolve in the future and will require to have in-memory representation (in comparison with the current implementation, Bug 1254984)
Comment on attachment 8750405 [details]
MozReview Request: Bug 1271375 - Extracts WASM AST and fixes wasmBinaryToText. r?luke

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/51397/diff/1-2/
Attachment #8750405 - Attachment description: MozReview Request: Bug 1271375 - Extracts WASM AST and fixes wasmBinaryToText. → MozReview Request: Bug 1271375 - Extracts WASM AST and fixes wasmBinaryToText. r?luke
Attachment #8750405 - Flags: review?(luke)
Comment on attachment 8750405 [details]
MozReview Request: Bug 1271375 - Extracts WASM AST and fixes wasmBinaryToText. r?luke

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/51397/diff/2-3/
Comment on attachment 8750405 [details]
MozReview Request: Bug 1271375 - Extracts WASM AST and fixes wasmBinaryToText. r?luke

https://reviewboard.mozilla.org/r/51397/#review49159

Fantastic!  Thanks for doing this.

::: js/src/asmjs/WasmAST.h:45
(Diff revision 3)
> +using WasmAstVector = mozilla::Vector<T, 0, LifoAllocPolicy<Fallible>>;
> +
> +template <class K, class V, class HP>
> +using WasmAstHashMap = HashMap<K, V, HP, LifoAllocPolicy<Fallible>>;
> +
> +class WasmName

The motivation for prefixing everything with Wasm- was to avoid name clashes in unified builds.  However, instead, we could use Ast- as the prefix which you've already started doing in WasmBinaryToAST.  One character shorter, and it avoids the logical redundancy of wasm::Wasm-.  Since you're touching all this code anyways, could you just fold in this rename from Wasm- to Ast-?  (Also, some types like WasmAstVector would simply become AstVector.)

::: js/src/asmjs/WasmBinaryToAST.cpp:60
(Diff revision 3)
> +    typedef AstDecodeStackItem Value;
> +};
> +
> +typedef ExprIter<AstDecodePolicy> AstDecodeExprIter;
> +
> +class AstDecodeContext {

{ on new line

::: js/src/asmjs/WasmBinaryToText.cpp:176
(Diff revision 3)
>  {
>      return RenderExprType(c, ToExprType(type));
>  }
>  
>  static bool
> -RenderExpr(WasmRenderContext& c);
> +RenderName(WasmRenderContext& c, const WasmName& name) {

{ on new line (here and below)

::: js/src/asmjs/WasmBinaryToText.cpp:1343
(Diff revision 3)
> +    if (!BinaryToAst(cx, bytes, length, lifo, &module))
>          return false;
>  
> +    WasmRenderContext c(cx, module, buffer);
> +
>      // FIXME: Implement binary-to-text and re-enable this.

You can remove this comment now.
Attachment #8750405 - Flags: review?(luke) → review+
Comment on attachment 8750405 [details]
MozReview Request: Bug 1271375 - Extracts WASM AST and fixes wasmBinaryToText. r?luke

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/51397/diff/3-4/
https://reviewboard.mozilla.org/r/51397/#review49159

> The motivation for prefixing everything with Wasm- was to avoid name clashes in unified builds.  However, instead, we could use Ast- as the prefix which you've already started doing in WasmBinaryToAST.  One character shorter, and it avoids the logical redundancy of wasm::Wasm-.  Since you're touching all this code anyways, could you just fold in this rename from Wasm- to Ast-?  (Also, some types like WasmAstVector would simply become AstVector.)

Made such replacements in the following files: WasmAST.h, WasmBinaryToAST.*, WasmBinaryTextToBinary.cpp and WasmBinaryToText.cpp
Whiteboard: checking-needed
Keywords: checkin-needed
Whiteboard: checking-needed
I can rebase and land
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/1ad3cdb2bd05
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
this reduced the number of constructors from build metrics :)

https://treeherder.mozilla.org/perf.html#/alerts?id=1219
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: