Page MenuHomePhabricator

Bug 1655042: Support Cranelift-based Wasm validation. r=jseward
ClosedPublic

Authored by cfallin on Oct 5 2020, 9:36 PM.
Referenced Files
Unknown Object (File)
Wed, Apr 15, 3:05 PM
Unknown Object (File)
Tue, Apr 14, 4:32 PM
Unknown Object (File)
Tue, Apr 14, 4:03 PM
Unknown Object (File)
Tue, Apr 14, 2:46 AM
Unknown Object (File)
Tue, Apr 14, 2:30 AM
Unknown Object (File)
Mon, Apr 13, 11:25 AM
Unknown Object (File)
Mon, Apr 13, 8:58 AM
Unknown Object (File)
Sun, Apr 12, 5:14 PM
Subscribers

Details

Summary

This patch is an update of Benjamin Bouvier's WIP patch that supports
Cranelift's new Wasm validator functionality, as introduced in
bytecodealliance/wasmtime#2059.

Previously, Baldrdash allowed SpiderMonkey to validate Wasm function
bodies before invoking Cranelift. The Cranelift PR now causes validation
to happen in the function-body compiler. Because the Cranelift backend
now takes on this responsibility, we no longer need to invoke the
SpiderMonkey function-body validator. This requires some significant new
glue in the Baldrdash bindings to allow Cranelift's Wasm frontend to
access module type information.

Co-authored-by: Benjamin Bouvier <benj@benj.me>

Diff Detail

Event Timeline

phab-bot published this revision for review.Oct 5 2020, 9:36 PM
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.

Code analysis found 16 defects in the diff 348763:

  • 11 defects found by clang-tidy
  • 2 defects found by rustfmt (Mozlint)
  • 3 defects found by clang-format

You can run this analysis locally with:

  • ./mach clang-format -s -p js/src/wasm/cranelift/baldrapi.h js/src/wasm/cranelift/clifapi.h js/src/wasm/WasmCraneliftCompile.cpp (C/C++)
  • ./mach lint --warnings --outgoing
  • ./mach static-analysis check --outgoing (C/C++)

For your convenience, here is a patch that fixes all the clang-format defects (use it in your repository with hg import or git apply -p0).

You have touched the documentation, you can find it rendered here for a week.

If you see a problem in this automated review, please report it here.

You can view these defects on the code-review frontend and on Treeherder.

It looks plausible, is the best I can say given my limited understanding of the SM/CL interface.
A couple of points:

  • it would be good if you could fix as many of the linting/style auto-complaints as is easy to do, before landing.
  • given the complexities of storage management at the C++/Rust interface, and that this patch changes this area, has there been any dynamic analysis (ASan/LSan/Valgrind) to try and ensure that there are no UAFs and no leaks as a result of the changes? Having at least some minimal one-off sanity check be done there, would be nice.
js/src/wasm/WasmCraneliftCompile.cpp
293

How is this related to the validation issue? Is it some kind of ridealong fix?

This revision is now accepted and ready to land.Oct 6 2020, 9:11 AM

This revision requires a Testing Policy Project Tag to be set before landing. Please apply one of testing-approved, testing-exception-unchanged, testing-exception-ui, testing-exception-elsewhere, testing-exception-other.

cfallin edited the summary of this revision. (Show Details)

Thanks, updated!

I'll do an ASan run to be sure this is is good (I don't think I can do a try-push since the config for the asan builds does not have the flag for the Cranelift backend, so I'll do it locally).

js/src/wasm/WasmCraneliftCompile.cpp
293

This flag feeds into the WasmFeatures provided to the validator on the Cranelift side and tells it to accept the atomic-operation instructions as valid (so named because they're part of the "threads proposal" IIRC).

You have touched the documentation, you can find it rendered here for a week.

If you see a problem in this automated review, please report it here.

Local ASan run (../configure --enable-address-sanitizer --disable-jemalloc --enable-optimize) passes jit-tests with --args="--wasm-compiler=cranelift --no-wasm-simd on x86-64; so I'll go ahead and land!

You have touched the documentation, you can find it rendered here for a week.

If you see a problem in this automated review, please report it here.

This revision is now accepted and ready to land.Oct 7 2020, 6:25 AM

You have touched the documentation, you can find it rendered here for a week.

If you see a problem in this automated review, please report it here.