Commit Graph

65 Commits

Author SHA1 Message Date
jpp
73eacf6b90 V8. ASM-2-WASM. New type system.
This CL introduces the new type system for the ASM
type-checker/validator.

BUG=

Review-Url: https://codereview.chromium.org/2045703007
Cr-Commit-Position: refs/heads/master@{#36942}
2016-06-13 20:44:53 +00:00
titzer
ce291bedd0 [wasm] Dont compute global offsets if the module had errors (e.g. invalid memory type for global).
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=chromium:617884

Review-Url: https://codereview.chromium.org/2044833002
Cr-Commit-Position: refs/heads/master@{#36779}
2016-06-07 09:38:48 +00:00
titzer
3412af0b40 [wasm] Refactor encoder.h to use a proper buffer and remove OldFunctions section.
This removes the last use of the old_functions section, which greatly
simplifies encoding.

R=bradnelson@chromium.org,aseemgarg@chromium.org,mtrofin@chromium.org

BUG=

Review-Url: https://codereview.chromium.org/2014533003
Cr-Commit-Position: refs/heads/master@{#36523}
2016-05-25 16:13:50 +00:00
titzer
e4bb7ff96c [wasm] Implement an interpreter for WASM.
This interpreter directly decodes and executes WASM binary code for
the purpose of supporting low-level debugging. It is not currently
integrated into the main WASM implementation.

R=ahaas@chromium.org,clemensh@chromium.org,rossberg@chromium.org,binji@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1972153002
Cr-Commit-Position: refs/heads/master@{#36497}
2016-05-25 08:33:10 +00:00
mtrofin
6b8d17e325 [wasm] globals size is not a per-instance property.
Moved globals offsets calculation to the wasm module decoder, since
this is a property of the module, not of each instance.

Qualified as "const" references to WasmModule outside of the decoder
and some test situations.

BUG=

Review-Url: https://codereview.chromium.org/2005933003
Cr-Commit-Position: refs/heads/master@{#36484}
2016-05-24 16:33:49 +00:00
titzer
f93066b3af [wasm] Remove renumbering of local variables from asm->wasm.
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1980543002
Cr-Commit-Position: refs/heads/master@{#36292}
2016-05-17 17:57:34 +00:00
titzer
82db9dece3 [wasm] Remove legacy encoding of local variables from asm->wasm.
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1980483002
Cr-Commit-Position: refs/heads/master@{#36239}
2016-05-13 12:49:36 +00:00
titzer
7cd1a7f768 [wasm] Remove the use of the "external" bit on OldFunctions section.
This is a first step to removing the support for the OldFunctions
section altogether, which will greatly simplify the encoder and remove
the need to do local variable remapping in asm->wasm.

R=bradnelson@chromium.org,aseemgarg@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1974933002
Cr-Commit-Position: refs/heads/master@{#36228}
2016-05-13 08:46:40 +00:00
titzer
bf90d9a33a [formatting] Remove all double blank lines in WASM code.
R=ahaas@chromium.org,mstarzinger@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1970543003
Cr-Commit-Position: refs/heads/master@{#36174}
2016-05-11 12:36:04 +00:00
titzer
86d4a45586 [wasm] Add some tests for control flow corner cases.
R=ahaas@chromium.org,rossberg@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1960143002
Cr-Commit-Position: refs/heads/master@{#36112}
2016-05-09 14:46:40 +00:00
titzer
73a988a0d5 [wasm] Verify expressions do not cross control boundaries in WASM.
This catches malformed code like the following example:

<expr>
<block begin>
<expr>
<binop>
<end>

Which is illegal because the inputs to the binop cross the block boundary.

R=rossberg@chromium.org,ahaas@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1961853002
Cr-Commit-Position: refs/heads/master@{#36103}
2016-05-09 10:36:19 +00:00
jkummerow
148e7076ca Turn on -Wmissing-field-initializers on Linux.
Because not initializing fields can be, you know, dangerous.

Review-Url: https://codereview.chromium.org/1952703002
Cr-Commit-Position: refs/heads/master@{#36071}
2016-05-06 10:20:30 +00:00
titzer
2949e05d1e [wasm] Remove unnecessary kExprNop from WASM_BR and other macros.
R=ahaas@chromium.org,binji@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1942873002
Cr-Commit-Position: refs/heads/master@{#35964}
2016-05-03 08:20:04 +00:00
titzer
e2f94946a8 [wasm] Remove the module environment and signature as arguments to OpcodeArity.
R=rossberg@chromium.org,ahaas@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1937083002
Cr-Commit-Position: refs/heads/master@{#35941}
2016-05-02 15:24:54 +00:00
titzer
ee03b7217b [wasm] Binary 11: Bump module version to 0xB.
[wasm] Binary 11: Swap the order of section name / section length.
[wasm] Binary 11: Shorter section names.
[wasm] Binary 11: Add a prefix for function type declarations.
[wasm] Binary 11: Function types encoded as pcount, p*, rcount, r*
[wasm] Fix numeric names for functions.

R=rossberg@chromium.org,jfb@chromium.org,ahaas@chromium.org
BUG=chromium:575167
LOG=Y

Review-Url: https://codereview.chromium.org/1896863003
Cr-Commit-Position: refs/heads/master@{#35897}
2016-04-29 09:40:24 +00:00
titzer
2aa4656eeb [wasm] Binary 11: WASM AST is now postorder.
[wasm] Binary 11: br_table takes a value.
[wasm] Binary 11: Add implicit blocks to if arms.
[wasm] Binary 11: Add arities to call, return, and breaks
[wasm] Binary 11: Add experimental version.

This CL changes the encoder, decoder, and tests to use a postorder
encoding of the AST, which is more efficient in decode time and
space.

R=bradnelson@chromium.org,rossberg@chromium.org,binji@chromium.org
BUG=chromium:575167
LOG=Y

Review-Url: https://codereview.chromium.org/1830663002
Cr-Commit-Position: refs/heads/master@{#35896}
2016-04-29 09:16:21 +00:00
titzer
b3cf031eb8 [wasm] Enforce strict ordering of WASM module sections.
R=jfb@chromium.org,rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1900153002

Cr-Commit-Position: refs/heads/master@{#35698}
2016-04-21 11:20:15 +00:00
titzer
727c7df035 [wasm] Extra LEB utilities to leb-helper.h
R=bradnelson@chromium.org,aseemgarg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1909513002

Cr-Commit-Position: refs/heads/master@{#35695}
2016-04-21 10:15:16 +00:00
bradnelson
53bc649e88 [wasm] Adding metrics for Asm/Wasm.
Collecting:
Time histograms for: instantiate, decode module, decode function, compile, compile function.
Memory histograms for: decode peak, instantiate peak, compile function peak, min mem pages, max mem pages, function bytes, module bytes.
Range histograms of: functions per module.

BUG= https://code.google.com/p/v8/issues/detail?id=4203
BUG= https://bugs.chromium.org/p/chromium/issues/detail?id=575167
TEST=None
R=ahaas@chromium.org,bmeurer@chromium.org
LOG=N

Review URL: https://codereview.chromium.org/1866873002

Cr-Commit-Position: refs/heads/master@{#35467}
2016-04-14 07:30:14 +00:00
aseemgarg
1d37d4216b [wasm] optimized switch implementation in asm.js to wasm builder
This change implements switch as a balanced if/else tree or break table or
hybrid. A lot of asm.js modules are expected to extensively use switch
alongside function tables that can benefit from a better implementation.

BUG=v8:4203
TEST=mjsunit/asm-wasm
R=titzer@chromium.org,bradnelson@chromium.org,ahaas@chromium.org
LOG=N

Review URL: https://codereview.chromium.org/1838973002

Cr-Commit-Position: refs/heads/master@{#35455}
2016-04-13 21:56:42 +00:00
titzer
e00a0c621c [wasm] Local decl parsing tweak.
R=ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1860103002

Cr-Commit-Position: refs/heads/master@{#35286}
2016-04-06 08:57:50 +00:00
titzer
6dda75f23b [wasm] Refactor decoding of local declarations and make more robust.
R=ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1856413002

Cr-Commit-Position: refs/heads/master@{#35272}
2016-04-05 17:16:30 +00:00
jochen
cb7aa79b12 Expose a lower bound of malloc'd memory via heap statistics
We expect that the majority of malloc'd memory held by V8 is allocated
in Zone objects. Introduce an Allocator class that is used by Zones to
manage memory, and allows for querying the current usage.

BUG=none
R=titzer@chromium.org,bmeurer@chromium.org,jarin@chromium.org
LOG=n
TBR=rossberg@chromium.org

Review URL: https://codereview.chromium.org/1847543002

Cr-Commit-Position: refs/heads/master@{#35196}
2016-04-01 10:01:56 +00:00
titzer
ad91d1c6ca [wasm] Add I64Eqz operator.
R=ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1798863004

Cr-Commit-Position: refs/heads/master@{#34757}
2016-03-14 17:55:22 +00:00
titzer
90eb63418b [wasm] Fix OpcodeLength() calculation.
R=bradnelson@chromium.org,binji@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1787733002

Cr-Commit-Position: refs/heads/master@{#34730}
2016-03-11 18:02:19 +00:00
jfb
abbdca947f wasm: use strings for section names
This will require an equivalent sexpr-wasm change.

See:
https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#high-level-structure

R=titzer@chromium.org, binji@chronium.org

Review URL: https://codereview.chromium.org/1765843002

Cr-Commit-Position: refs/heads/master@{#34668}
2016-03-10 12:37:19 +00:00
titzer
4cb568ec5f [wasm] Encode function signatures, bodies, and names as separate sections.
R=binji@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1783593002

Cr-Commit-Position: refs/heads/master@{#34641}
2016-03-09 22:51:50 +00:00
binji
29cd25be1d [Wasm] Move data segment data inline to the data segment section
BUG=
R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1776923005

Cr-Commit-Position: refs/heads/master@{#34639}
2016-03-09 19:43:14 +00:00
binji
ca0dbaece0 [wasm] All strings are length-prefixed and inline
R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1781523002

Cr-Commit-Position: refs/heads/master@{#34637}
2016-03-09 18:56:30 +00:00
titzer
f99624a98e [wasm] Encode immediates to Load and Store as varint.
R=binji@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1775123003

Cr-Commit-Position: refs/heads/master@{#34635}
2016-03-09 18:54:43 +00:00
binji
78f6f838f0 [Wasm] Convert many of the fixed-size values to LEB128.
This CL modifies the following to be LEB128:
* Function table indices
* Import table signature indices
* Export table function indices
* Function signature param count
* br/br_if break depth
* br_table target count
* block/loop expression count

Still to do:
* Import/export names (LEB128 count + inline data)
* Data segments (LEB128 offset + size + inline data)
* Function header stuff (should seperate into function sig and body sections)
* Memory access alignment + offset (still discussing)

BUG=
R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1775873002

Cr-Commit-Position: refs/heads/master@{#34603}
2016-03-08 22:56:18 +00:00
titzer
d61a0c5a4a [wasm] Support a two-level namespace for imports.
R=binji@chromium.org,dschuff@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1780483002

Cr-Commit-Position: refs/heads/master@{#34600}
2016-03-08 19:57:10 +00:00
titzer
835c5e6beb [wasm] Rework encoding of local declarations.
Local declarations were previously encoded as an optional set of
4 uint16 values as part of the function declaration. This CL
implements the current design of moving these declarations to
a list of pairs of (type, count) that is part of the body.

R=bradnelson@chromium.org,binji@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1763433002

Cr-Commit-Position: refs/heads/master@{#34564}
2016-03-07 21:05:15 +00:00
titzer
bcfa400306 [wasm] Remove TableSwitch and replace with br_table.
R=rossberg@chromium.org,binji@chromium.org,bradnelson@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1764723002

Cr-Commit-Position: refs/heads/master@{#34511}
2016-03-04 23:49:09 +00:00
binji
af193e7534 [wasm] Update {i32,i64}.const to use signed leb128
Reland of https://codereview.chromium.org/1765673002

R=titzer@chromium.org
R=bradnelson@chromium.org
LOG=n
BUG=

Review URL: https://codereview.chromium.org/1761173003

Cr-Commit-Position: refs/heads/master@{#34506}
2016-03-04 19:06:34 +00:00
machenbach
ec0f451b64 Revert of [wasm] Update {i32,i64}.const to use signed leb128 (patchset #3 id:40001 of https://codereview.chromium.org/1765673002/ )
Reason for revert:
[Sheriff] Breaks chromium win compile:
https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Win/builds/3844/steps/compile/logs/stdio

Original issue's description:
> [wasm] Update {i32,i64}.const to use signed leb128
>
> R=titzer@chromium.org
> R=bradnelson@chromium.org
> LOG=n
>
> Committed: https://crrev.com/4b613a67e0aa4e073946f5f0dd95ee9366c8ca86
> Cr-Commit-Position: refs/heads/master@{#34471}

TBR=bradnelson@chromium.org,titzer@chromium.org,binji@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1760363003

Cr-Commit-Position: refs/heads/master@{#34482}
2016-03-04 09:03:30 +00:00
binji
4b613a67e0 [wasm] Update {i32,i64}.const to use signed leb128
R=titzer@chromium.org
R=bradnelson@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/1765673002

Cr-Commit-Position: refs/heads/master@{#34471}
2016-03-04 00:12:45 +00:00
jfb
df269e6e54 WebAssembly: skip unknown sections, add names
Sets the code up so it'll be easier to have section names as strings instead of
hard-coded numbers. Using strings will require synchronizing with sexpr-wasm.

Mostly NFC (besides now skipping *all* unknown sections).

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1743773002

Cr-Commit-Position: refs/heads/master@{#34464}
2016-03-03 16:53:17 +00:00
weiliang.lin
9d0cf920bd [wasm] add rotate opcodes
BUG=

Review URL: https://codereview.chromium.org/1755013003

Cr-Commit-Position: refs/heads/master@{#34455}
2016-03-03 05:11:10 +00:00
dtc-v8
76f37d3ba6 wasm: change the module memory size to be multiples of the page size, 64k.
BUG=

Review URL: https://codereview.chromium.org/1597163002

Cr-Commit-Position: refs/heads/master@{#34450}
2016-03-03 00:00:00 +00:00
titzer
657538dee3 [wasm] Add support for 64-bit LEB encodings.
This is a reland of: http://crrev.com/1746063003

R=binji@chromium.org,ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1752103002

Cr-Commit-Position: refs/heads/master@{#34414}
2016-03-01 23:39:03 +00:00
machenbach
0fbc4f4459 Revert of [wasm] Add support for 64-bit LEB encodings. (patchset #6 id:100001 of https://codereview.chromium.org/1746063003/ )
Reason for revert:
[Sheriff] Seems to break chromium win compile:
https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Win/builds/3800/steps/compile/logs/stdio

Original issue's description:
> [wasm] Add support for 64-bit LEB encodings.
>
> R=binji@chromium.org,ahaas@chromium.org
> BUG=
>
> Committed: https://crrev.com/616f05496e9867cfa934098a76826cfde7feeaa2
> Cr-Commit-Position: refs/heads/master@{#34406}

TBR=ahaas@chromium.org,binji@chromium.org,titzer@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review URL: https://codereview.chromium.org/1749343002

Cr-Commit-Position: refs/heads/master@{#34407}
2016-03-01 19:56:45 +00:00
titzer
616f05496e [wasm] Add support for 64-bit LEB encodings.
R=binji@chromium.org,ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1746063003

Cr-Commit-Position: refs/heads/master@{#34406}
2016-03-01 19:36:57 +00:00
titzer
c5b2f1536b [wasm] Add support and unittests for decoding signed LEB128.
R=bradnelson@chromium.org,ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1746653002

Cr-Commit-Position: refs/heads/master@{#34368}
2016-02-29 18:42:26 +00:00
titzer
008888c8cb [wasm] Allocate WasmModule and WasmModuleInstance vectors inline.
R=bradnelson@chromium.org,ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1745863002

Cr-Commit-Position: refs/heads/master@{#34351}
2016-02-28 19:05:42 +00:00
titzer
91802542d5 [wasm] Rename ExprBoolNot to ExprI32Eqz.
R=bradnelson@chromium.org, binji@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1741393002

Cr-Commit-Position: refs/heads/master@{#34350}
2016-02-28 19:02:24 +00:00
titzer
06241221a6 [wasm] Add a magic word and a version number to the binary.
R=binji@chromium.org,jfb@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1740373002

Cr-Commit-Position: refs/heads/master@{#34346}
2016-02-28 00:37:29 +00:00
titzer
8344687c76 [wasm] Properly plumb the origin of the WASM module from asm.js translation.
R=bradnelson@chromium.org,aseemgarg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1742073002

Cr-Commit-Position: refs/heads/master@{#34345}
2016-02-27 20:40:06 +00:00
titzer
d035d6172a [wasm] Add an export table.
R=binji@chromium.org,jfb@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1744713003

Cr-Commit-Position: refs/heads/master@{#34342}
2016-02-27 01:54:30 +00:00
titzer
915ae08dd5 [wasm] Add support for import section.
This CL introduces an import section that names functions to be imported
as well as a CallImport bytecode to call imports from this table.

R=binji@chromium.org,bradnelson@chromium.org
LOG=Y
BUG=chromium:575167

Review URL: https://codereview.chromium.org/1709653002

Cr-Commit-Position: refs/heads/master@{#34157}
2016-02-19 14:58:43 +00:00