Commit Graph

16 Commits

Author SHA1 Message Date
bradnelson
437735ed34 [wasm][asm.js] Make asm.js->wasm return a regular object.
Return a regular JSObject in the asm.js -> wasm case.

BUG=v8:5877
R=mtrofin@chromium.org,aseemgarg@chromium.org,titzer@chromium.org

Review-Url: https://codereview.chromium.org/2664493002
Cr-Commit-Position: refs/heads/master@{#42757}
2017-01-28 23:15:58 +00:00
bradnelson
d0befa956f [wasm][asm.js] Permit ternary operator in asm.js returns in some cases.
In practice, Emscripten seems to emit cond?+a:+b type return
expressions. This is not allowed by the spec or errata, but we need
to support it for compatibility.

Similar patterns with ints / signed, do not seem to be supported.

BUG=v8:5891
R=mtrofin@chromium.org,aseemgarg@chromium.org

Review-Url: https://codereview.chromium.org/2648353010
Cr-Commit-Position: refs/heads/master@{#42677}
2017-01-26 08:12:07 +00:00
bradnelson
be10e68f39 Forbid non-locals/keyed-property calls to allow interleaved compile.
Deferred function call validation is required to support out of order
asm.js function declaration. Unfortunately, since we've started interleaving
validation and asm-wasm building, we don't check names are resolved until
the end.
Fortunately, undefined names can be detected from their CallType.
Check this at asm-typer time.

BUG=676797
R=aseemgarg@chromium.org,titzer@chromium.org

Review-Url: https://codereview.chromium.org/2615443003
Cr-Commit-Position: refs/heads/master@{#42158}
2017-01-10 04:07:16 +00:00
bradnelson
be9ee2237d [wasm][asm.js] Ignore duplicate exports in asm.js.
BUG=672789
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2559113006
Cr-Commit-Position: refs/heads/master@{#41647}
2016-12-12 14:47:38 +00:00
bradnelson
626d620d4d [wasm][asm.js] Require a number for fround literals.
BUG=673240
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2565343002
Cr-Commit-Position: refs/heads/master@{#41643}
2016-12-12 13:51:25 +00:00
bradnelson
7659728be2 [wasm][asm.js] Forbid function declaration replacing variable declaration.
BUG=673240
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2568773002
Cr-Commit-Position: refs/heads/master@{#41638}
2016-12-12 12:27:14 +00:00
bradnelson
25189ffc36 [wasm][asm.js] Check that property keys are literals for imports.
BUG=672785
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2566683002
Cr-Commit-Position: refs/heads/master@{#41624}
2016-12-09 15:58:40 +00:00
bradnelson
89e10055e4 [wasm][asm.js] Allow true/false in int binary ops.
Because the parser optimizes !123 -> false,
we allow booleans in expressions (but not parameter annotations).
Allow this in asm-wasm-builder.
Turn on an early out case in asm-typer that is fine.

BUG=672784
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2561193003
Cr-Commit-Position: refs/heads/master@{#41622}
2016-12-09 15:01:30 +00:00
mstarzinger
75128636f3 [wasm] Remove obsolete %IsNotAsmWasmCode predicate.
By now the predicate in question is an exact negation of %IsAsmWasmCode
as the name intuitively implies. The need for two separate test methods
no longer exists and one of the two can be removed.

R=bradnelson@chromium.org

Review-Url: https://codereview.chromium.org/2562003002
Cr-Commit-Position: refs/heads/master@{#41616}
2016-12-09 11:56:05 +00:00
mstarzinger
9fde10ebed [wasm] Cleanup %IsAsmWasmCode testing predicate.
By now the compiler pipeline will not produce optimized code for asm.js
functions unless validation failed (even when --always-opt is enabled).
The related workaround in the testing predicate can be removed.

R=rmcilroy@chromium.org

Review-Url: https://codereview.chromium.org/2549463002
Cr-Commit-Position: refs/heads/master@{#41614}
2016-12-09 11:30:10 +00:00
bradnelson
4a637abea3 [wasm][asm.js] Confirm literals are Numbers before using AsNumber, refactor.
We have been assuming in several places that ContainsDot or ToInt32 is
sufficient to check a value is a valid double or int.
Refactoring all the checks to one place and making them cope with booleans
or other unexpected types being present.

BUG=672044
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2555323003
Cr-Commit-Position: refs/heads/master@{#41595}
2016-12-08 14:55:03 +00:00
bradnelson
3f2db58c89 [wasm] [asm.js] Don't allow bad return types from a global constant
We recently allowed global constants in asm.js validated code.
When used in a return statement, these need to be of an allowed type.

BUG=660813
R=jpp@chromium.org,aseemgarg@chromium.org

Review-Url: https://codereview.chromium.org/2481103002
Cr-Commit-Position: refs/heads/master@{#40850}
2016-11-08 23:32:04 +00:00
jpp
5331e3b616 [V8][asm.js] Adds support to global const variables.
This CL adds support for:
https://discourse.wicg.io/t/allow-const-global-variables/684

It allows global const variables to be used as if they were numeric
literals. For example:

  const f0 = fround(0);
  ...
  function foo() {
    var v = f0;  // no type annotation.
    ...
    return f0;  // no return type annotation.
  }

BUG= https://bugs.chromium.org/p/v8/issues/detail?id=5540

Review-Url: https://chromiumcodereview.appspot.com/2435823002
Cr-Commit-Position: refs/heads/master@{#40477}
2016-10-20 15:48:41 +00:00
bradnelson
e5f5ac7d2b [wasm] asm.js - Remove Wasm.instantiateModuleFromAsm, use asm.js directly.
Make use of %IsAsmWasmCode in place of Wasm.instantiateModuleFromAsm,
in order to reduce the surface area of the Wasm object,
and to focus on testing asm.js coming in via the parser.

Ignore extra CONST_LEGACY assignment introduced by the parser
when modules have the form:
(function Foo(a, b, c) {..});
This requires both a validator and AsmWasmBuilder change.

Move stdlib use collection to import time,
to reject modules that import a function, even if not used.

BUG= https://bugs.chromium.org/p/v8/issues/detail?id=4203
LOG=N
R=jpp@chromium.org,titzer@chromium.org

Review-Url: https://codereview.chromium.org/2264913002
Cr-Commit-Position: refs/heads/master@{#38806}
2016-08-23 04:07:23 +00:00
mstarzinger
f9763eb275 [wasm] Fix asm.js module instantiation on retry.
This fixes the case where a module is instantiated twice via the same
closure when in the meantime another closure has destroyed and removed
the WASM data attached to the SharedFunctionInfo.

R=bradnelson@chromium.org
TEST=mjsunit/asm/asm-validation
BUG=v8:4203

Review-Url: https://codereview.chromium.org/2253613004
Cr-Commit-Position: refs/heads/master@{#38696}
2016-08-18 07:44:30 +00:00
bradnelson
d0e52555f0 [wasm] Support validation of asm.js modules with != 3 args.
Our previous per-arch instantiation thunks for asm.js
didn't support modules that had or were called with anything other
than 3 arguments. Adding support for this.

Addding a runtime test method to check if asm validation succeeded.

Adding a test of validation with different argument count combinations.

R=mstarzinger@chromium.org
TEST=mjsunit/asm/asm-validator.js
BUG= https://bugs.chromium.org/p/v8/issues/detail?id=4203

Review-Url: https://codereview.chromium.org/2229723002
Cr-Commit-Position: refs/heads/master@{#38688}
2016-08-17 17:22:30 +00:00