Commit Graph

331 Commits

Author SHA1 Message Date
Ben Smith
baf84940f4 [wasm] Display wasm globals in the inspector
They are added under the global scope object, as follows:

  {
    "memory": ...,
    "globals": {
      "global#0": ...,
      "global#1": ...,
      "global#2": ...,
    }
  }

We currently don't have any way to name globals in the wasm binary
format, but it is possible to extend the name section with these names
in the future.

Bug: v8:6846
Change-Id: I79fa4ed3d83964bc8e26d66516605d41e92b3d03
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1601829
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61425}
2019-05-10 18:35:44 +00:00
Frederik Gossen
ffc75252a5 [wasm-hints] Fix lazy compilation and validation in interpreter
The interpreter accesses code directly from the code manager. With lazy
validation, however, this code is not guaranteed to exist. The
interpreter now checks for this and compiles it lazily if needed. It
also handles exceptions that may arise from lazy validation.

Bug: v8:9003
Change-Id: I37c365f0a4d755ed55630d01c8526f2a3efa9a9e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1594567
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Frederik Gossen <frgossen@google.com>
Cr-Commit-Position: refs/heads/master@{#61240}
2019-05-06 13:56:38 +00:00
Michael Starzinger
784055ade0 [wasm] Extend encoding of references as exception values.
This extends the existing test coverage of interactions between the
exception handling and the reference type proposal. Now "any-func" and
"except-ref" can both be encoded as an exception value. Missing switch
cases have been added.

R=clemensh@chromium.org
TEST=mjsunit/wasm/exceptions-anyref[-interpreter]
BUG=v8:8091,v8:7581

Change-Id: Ie2e9819fe66b4daab623390f27bb19007131f619
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1581600
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60977}
2019-04-24 11:38:57 +00:00
Clemens Hammacher
de6a07dcda [wasm] Fix data race on code table
The {code_table_} in {NativeModule} is protected by the
{allocation_mutex_}. The {code} and {code_table} accessors did not
acquire this lock though.
This CL removes the unsafe {code_table} accessor, renames {code} to
{GetCode} and protects it by a lock.

R=mstarzinger@chromium.org

Bug: v8:9112
Change-Id: Id2df68460b4c10291a49b4016b9574e02744e8b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1561315
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60779}
2019-04-11 13:52:33 +00:00
Michael Starzinger
b077d88e12 [wasm] Support anyref for external calls in interpreter.
This adds support for passing/returning reference type parameter/return
values when the interpreter is calling extern functions. It expands the
existing test coverage to the interpreter.

R=clemensh@chromium.org
TEST=mjsunit/wasm/anyref-interpreter,mjsunit/wasm/anyfunc-interpreter
BUG=v8:8091,v8:7581

Change-Id: I377e9d28aa36866c0441683ffd6a48160b721ec1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1559853
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60715}
2019-04-09 13:42:57 +00:00
Michael Starzinger
8acae9be7c [wasm] Support mutable imported anyref globals in interpreter.
This adds support for loading and storing mutable imported globals
having a reference type in the interpreter. It expands existing test
coverage to the interpreter.

R=clemensh@chromium.org
TEST=mjsunit/wasm/anyref-globals-interpreter
BUG=v8:8091,v8:7581

Change-Id: I78e0c5c73664a183e1d92ec91eadf8b9a93e4787
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1559743
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60701}
2019-04-09 11:52:41 +00:00
Michael Starzinger
802a2d0385 [wasm] Support reference type globals in interpreter.
This adds support for handling reference types when loading/storing
globals. Support for imported mutable globals is still missing and will
be done in a follow-up change.

R=clemensh@chromium.org
TEST=mjsunit/wasm/exceptions-global-interpreter
BUG=v8:8091,v8:7581

Change-Id: I0d14919b1ce7f49c4a0541e3d6a99ee203cfb311
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1558086
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60695}
2019-04-09 09:50:48 +00:00
Ben Smith
9010424ff5 Reland "[wasm] Implement table.init for interpreter"
This is a reland of 63608968b6

The previous CL failed on Windows, but it was a general bug. The
dropped_elem_segments was not being set on the instance properly in
cctests, so`table.init` instructions would fail by reading uninitialized
data.

I took this opportunity to also add an implementation of
`elem.drop` in the interpreter, and ported the JS tests for those too.

Original change's description:
> [wasm] Implement table.init for interpreter
>
> This also fixes CheckCallViaJS when a trap occurs. In that case, the
> trap callback is called instead of an exception being thrown, so if it
> isn't handled, a bogus result will be returned instead.
>
> Bug: v8:8965
> Change-Id: I560e89f353756df23c062fb8c9484d9971c19253
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1539078
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Commit-Queue: Ben Smith <binji@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#60473}

Bug: v8:8965
Change-Id: Ia547d9530b7ca67fde5bd94539f49153b796e82d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1547142
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60664}
2019-04-05 20:09:33 +00:00
Michael Starzinger
77d05811ad [wasm] Fix interpreter stack height for throwing opcode.
This makes sure that the implicit operand stack slot used for passing an
exception from the throw-site to the catch-site is counted against the
maximum stack height.

R=clemensh@chromium.org
TEST=mjsunit/wasm/exceptions-rethrow-interpreter
BUG=v8:8091

Change-Id: I7e8f47ba4662eb273792e7508207f67588264a2f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1554683
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60658}
2019-04-05 14:04:56 +00:00
Michael Starzinger
165eb80115 [wasm] Extend interpreter exception support to Simd128.
R=clemensh@chromium.org
TEST=mjsunit/wasm/exceptions-simd-interpreter
BUG=v8:8091

Change-Id: Id0b5da98bbfb91c7a5a878681d7fffe81233284f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1552794
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60655}
2019-04-05 13:51:06 +00:00
Michael Starzinger
2b7fdbfc75 [wasm] Fix lifetime of reference values on interpreter stack.
This ensures the lifetime of reference values on the simulated operand
stack of the interpreter is coupled to a lifetime of the {ThreadImpl}.
We no longer directly store reference values on the stack, but maintain
a separate "reference stack" on the GC'ed heap. This will ensure the GC
traces such references properly.

The new {StackValue} safety wrapper makes sure all use-sites that access
the operand stack properly convert to/from handles when dealing with
reference values.

R=clemensh@chromium.org
TEST=mjsunit/wasm/exceptions-interpreter
BUG=v8:8091,v8:7581

Change-Id: I8c05f2d945a6def943b89be0cfca538a73df8855
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1552791
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60650}
2019-04-05 12:47:56 +00:00
Michael Starzinger
5128ca0fd7 [wasm] Simplify access to Isolate in the interpreter.
R=clemensh@chromium.org

Change-Id: I643d9a142e55405ec010cfe56915527e3cff2d6d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1552783
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60632}
2019-04-04 12:00:02 +00:00
Michael Starzinger
7fccbfe9c3 [wasm] Be more rigorous about {HandleScope} in interpreter.
This seals any surrounding {HandleScope} when the interpreter enters the
main interpreter loop. It ensures that there are no accidental leaks of
handles into the surrounding scope and enforces that operations dealing
with handles open their own scope.

R=clemensh@chromium.org

Change-Id: I43d479129bef60beb7565022b24577f8bf1dc522
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1550401
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60601}
2019-04-03 13:46:20 +00:00
Michael Starzinger
46a99b07fc [wasm] Add support for "br_on_exn" in the interpreter.
This adds preliminary support for handling the "br_on_exn" opcode in the
interpreter. It also makes "catch" and "rethrow" use a proper exception
reference instead of a dummy value.

To that end this also adds {Handle<>} as a new kind of {WasmValue} which
is intended to pass reference values (e.g. "anyref" or "except_ref") to
the runtime system. Therefore lifetime of such a {WasmValue} is directly
coupled to any surrounding {HandleScope}.

For now we just store {Handle<>} directly on the simulated operand stack
of the interpreter. This is of course bogus, since the surrounding scope
does not outlive the interpreter activation. Decoupling the lifetime of
the operand stack from a {HandleScope} will be done in a follow-up CL.

As a drive-by this change also implements support for the "ref_null" and
the "ref_is_null" opcodes as a proof-of-concept that the new {WasmValue}
is also applicable to the "anyref" reference type.

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-interpreter/ReferenceTypeLocals
BUG=v8:8091,v8:7581

Change-Id: I2307e0689a19c4aab1d67f1ba6742cb3cc31aa3c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1550299
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60598}
2019-04-03 12:16:36 +00:00
Deepti Gandluri
dfc0100aff [wasm-simd] Add tracing for S128 Locals in the interpreter
Change-Id: Ibe60c5025a25b353e6661576872a8fda1aeef5de
Bug: v8:9014
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1536986
Reviewed-by: Aseem Garg <aseemgarg@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60478}
2019-03-26 23:30:06 +00:00
Michael Achenbach
470aaf6699 Revert "[wasm] Implement table.init for interpreter"
This reverts commit 63608968b6.

Reason for revert:
https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20debug/19535

Original change's description:
> [wasm] Implement table.init for interpreter
> 
> This also fixes CheckCallViaJS when a trap occurs. In that case, the
> trap callback is called instead of an exception being thrown, so if it
> isn't handled, a bogus result will be returned instead.
> 
> Bug: v8:8965
> Change-Id: I560e89f353756df23c062fb8c9484d9971c19253
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1539078
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Commit-Queue: Ben Smith <binji@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#60473}

TBR=binji@chromium.org,mstarzinger@chromium.org

Change-Id: Iee528ac2f16988b25579af3555e6f17974cb0b05
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8965
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1539498
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60474}
2019-03-26 19:27:00 +00:00
Ben Smith
63608968b6 [wasm] Implement table.init for interpreter
This also fixes CheckCallViaJS when a trap occurs. In that case, the
trap callback is called instead of an exception being thrown, so if it
isn't handled, a bogus result will be returned instead.

Bug: v8:8965
Change-Id: I560e89f353756df23c062fb8c9484d9971c19253
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1539078
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Ben Smith <binji@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60473}
2019-03-26 18:49:16 +00:00
Deepti Gandluri
fff8b5ca1d [wasm-simd] Fix Interpreter BitSelect and Boolean reductions
- Swap BitSelect operand order
 - Simplify, fix bugs for reductions

Bug: v8:8636, v8:8665
Change-Id: I9f43ac8007f9ecb317b1ffa4f99e9c249c58a2dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1534972
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60472}
2019-03-26 18:12:02 +00:00
Ben Smith
8a7f562e14 [wasm] Implement bulk memory table.copy in interpreter
Most of the mjsunit/wasm/table-copy.js tests have been ported to
cctests, so they can be tested with all execution tiers.

Bug: v8:8965
Change-Id: I448719be30a4b2bddb9e2cffb4c74d3134db2f50
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1529548
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60396}
2019-03-21 16:26:20 +00:00
Andreas Haas
2d9ec0a420 Reland: [wasm][anyref] Add support of call-indirect for multiple tables
The reason for the revert was that Liftoff did not bail out on indirect
calls to tables other than table 0. Whenever the Liftoff code got
executed, the test would fail.

Original message:
With this CL it is possible to use any anyfunc table in call-indirect,
not just the first table.

The current implementation is based on runtime calls. This is just an
initial implementation which should be replaced by a
dispatch-table-based eventually. However, this implementation allows
us to move forward with the anyref proposal implementation.

R=mstarzinger@chromium.org

Bug: v8:7581
Change-Id: Iedd56ee7acb281441bca32ffd3dc7157203ee1ac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1532072
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Auto-Submit: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60382}
2019-03-21 08:42:48 +00:00
Ben Smith
1a88414c41 [wasm] Call through dispatch table in interpreter
When running wasm tests, the interpreter previously used a static
collection of function indexes stored in WasmTable to perform
call_indirect calls internal to that module. This has the wrong behavior
if the table is changed (via WasmTableObject::Set, `table.copy`, or
`table.init`).

This CL changes the cctests to always generate an intepreter entry for
all functions, and stores those entries in the dispatch table. This
allows us to use the same execution path as for non-testing code.

The interpreter entry compiler needed to be changed to support
multi-value returns too, since a 64-bit integer return value may be
lowered to two 32-bit integer returns.

Bug: v8:9016
Change-Id: I277df21ffde5c2eee0b691fcc9bab2b1a43eeffc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1531137
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60380}
2019-03-21 07:35:27 +00:00
Andreas Haas
c808b934d3 Revert "[wasm][anyref] Add support of call-indirect for multiple tables"
This reverts commit 9d167f57e0.

Reason for revert: There is a crash on https://ci.chromium.org/p/v8/builders/ci/V8%20Win32/20026

Original change's description:
> [wasm][anyref] Add support of call-indirect for multiple tables
> 
> With this CL it is possible to use any anyfunc table in call-indirect,
> not just the first table.
> 
> The current implementation is based on runtime calls. This is just an
> initial implementation which should be replaced by a
> dispatch-table-based eventually. However, this implementation allows
> us to move forward with the anyref proposal implementation.
> 
> R=​mstarzinger@chromium.org
> 
> Bug: v8:7581
> Change-Id: I57d09b18add7f525555bf7c949aef17a64b0e7c5
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1530801
> Commit-Queue: Andreas Haas <ahaas@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#60360}

TBR=mstarzinger@chromium.org,ahaas@chromium.org

Change-Id: Iba4b84078aa070498be7e79212970b94595f5757
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7581
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1532069
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60362}
2019-03-20 11:52:37 +00:00
Andreas Haas
9d167f57e0 [wasm][anyref] Add support of call-indirect for multiple tables
With this CL it is possible to use any anyfunc table in call-indirect,
not just the first table.

The current implementation is based on runtime calls. This is just an
initial implementation which should be replaced by a
dispatch-table-based eventually. However, this implementation allows
us to move forward with the anyref proposal implementation.

R=mstarzinger@chromium.org

Bug: v8:7581
Change-Id: I57d09b18add7f525555bf7c949aef17a64b0e7c5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1530801
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60360}
2019-03-20 11:33:16 +00:00
Clemens Hammacher
c853d114a9 [wasm] Fix stack size estimate
We were just counting the number of stack elements instead of their
actual memory usage. This limits recursion a lot more and helps
avoiding OOM situations.

R=titzer@chromium.org

Bug: chromium:938739
Change-Id: I0e0ec2949f9fbad9c9e2c8677ec0223d5cd6a24b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1526006
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60264}
2019-03-15 14:09:25 +00:00
Ben Smith
94f22de62e [wasm] Implement bulk memory in interpreter
This CL only provides the implementation of memory.{init,copy,fill} and
data.drop.

Bug: v8:8965
Change-Id: I439f2520bfee8f147e4b0d1d31f954aaad2e14ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1510575
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60253}
2019-03-15 05:29:59 +00:00
Andreas Haas
dd23f2f316 [wasm][interpreter] Support calls to imported JS functions in cctests
The interpreter is set up specially in cctests to allow more direct
testing. This requires sometimes to write special testing code in the
interpreter which is different than production code. This CL fixes one
instance of testing code which deals with indirect calls.

In production code, indirect calls go through the indirect function
table which can change over time. In cctests, however, the indirect
function table is not set up completely. In cctests the interpreter
uses information from the module instead to acquire the target of an
indirect call. In that testing code, calls to imported JS functions
were not handled. This handling gets added with this CL.


CC=fgm@chromium.org
R=titzer@chromium.org

Bug: v8:7431
Change-Id: I3b90d4ea8fec2633c010dd8359814440c7988509
Reviewed-on: https://chromium-review.googlesource.com/c/1495560
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59965}
2019-03-01 11:30:10 +00:00
Francis McCabe
4c9c6c5804 [wasm] ReturnCall Implementation (interpreter)
Implement the ReturnCall functionality for the interpreter.

Note that some tests have had to be deferred to the implementation
of ReturnCall for TurboFan.

This a reland of https://chromium-review.googlesource.com/c/v8/v8/+/1467343

Bug: v8:7431
Change-Id: Iac9392a6a81995e30009dac74035e4d728ac3dbb
Cq-Include-Trybots: luci.v8.try:v8_linux64_ubsan_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/c/1484905
Commit-Queue: Francis McCabe <fgm@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59925}
2019-02-27 19:34:50 +00:00
Deepti Gandluri
5d0f5bd739 Revert "[wasm] ReturnCall Implementation (interpreter)"
This reverts commit 6a88f0b1e4.

Reason for revert: Fails UBSAN bots - https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux64%20UBSan/4866

Original change's description:
> [wasm] ReturnCall Implementation (interpreter)
> 
> Implement the ReturnCall functionality for the interpreter.
> 
> Note that some tests have had to be deferred to the implementation
> of ReturnCall for TurboFan.
> 
> Bug: v8:7431
> Change-Id: I091528e72f9113ddf1929bd1a5650b490bc8cc0c
> Reviewed-on: https://chromium-review.googlesource.com/c/1467343
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Commit-Queue: Francis McCabe <fgm@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#59803}

TBR=adamk@chromium.org,ahaas@chromium.org,clemensh@chromium.org,fgm@chromium.org

Change-Id: Ib2a85e586549e9c36f94d70f04f6e103a8272367
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7431
Reviewed-on: https://chromium-review.googlesource.com/c/1484574
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59804}
2019-02-22 23:31:54 +00:00
Francis McCabe
6a88f0b1e4 [wasm] ReturnCall Implementation (interpreter)
Implement the ReturnCall functionality for the interpreter.

Note that some tests have had to be deferred to the implementation
of ReturnCall for TurboFan.

Bug: v8:7431
Change-Id: I091528e72f9113ddf1929bd1a5650b490bc8cc0c
Reviewed-on: https://chromium-review.googlesource.com/c/1467343
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Francis McCabe <fgm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59803}
2019-02-22 19:27:10 +00:00
Michael Starzinger
34b67481db [wasm] Remove dead {ThreadImpl::Block} structure.
R=clemensh@chromium.org

Change-Id: I73393686c1529a470b4c10297e88626555b9253e
Reviewed-on: https://chromium-review.googlesource.com/c/1470128
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59564}
2019-02-13 14:48:18 +00:00
Michael Starzinger
eb69c7da2c [wasm] Simplify exceptional continuation in interpreter.
This unifies how continuations after a control transfer are handled
within the interpreter loop. To avoid bumping the {pc} we can either
reset the opcode length to zero or just "continue" the loop. This just
unifies the approach for the entire {Execute} method.

R=clemensh@chromium.org

Change-Id: Ifc33c3a87cff69d417f61fa0bc234260c7fa502a
Reviewed-on: https://chromium-review.googlesource.com/c/1458216
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59434}
2019-02-07 12:18:02 +00:00
Michael Starzinger
0999709cf2 [wasm] Add test for handling "unreachable" trap.
This adds a test case to check consistency of how an "unreachable" trap
is handled by a surrounding "try" block in case those two operations are
in different functions (i.e. not local to one function body). It also
fixes a DCHECK for an as-of-yet untested interpreter state transition.

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-exceptions
BUG=v8:8729

Change-Id: I432c48d0bc664f7ab092aaafef6dfa29c5f262fd
Reviewed-on: https://chromium-review.googlesource.com/c/1454605
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59429}
2019-02-07 10:41:00 +00:00
Michael Starzinger
a392e4a301 [wasm] Fix interpreter stack height on type error trap.
This fixes stack height management when a call to an external function
raises a type error trap. It also adds a test case that such exceptions
can be caught locally.

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-exceptions
BUG=v8:8729

Change-Id: I54b19ba86eb937695584229753d7f6cfa7e1a15d
Reviewed-on: https://chromium-review.googlesource.com/c/1447773
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59273}
2019-02-01 09:37:18 +00:00
Michael Starzinger
5b8c7f84bf [wasm] Support exceptions between interpreter frames.
This adds support for handling exceptions between different frames of
one single interpreter activation. Frames are dropped until a local
handler is found. If none is found in the current activation then we
delegate to the existing stack unwinding mechanism to deal with multiple
activations interspersed with non-interpreter stack frames on the actual
machine stack.

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-exceptions
BUG=v8:8091

Change-Id: Ia4abb27ff037bf0d3e3b05721bd3c971ef820e3c
Reviewed-on: https://chromium-review.googlesource.com/c/1445989
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59228}
2019-01-31 09:32:21 +00:00
Michael Starzinger
866d43e6c6 [wasm] Fix interpreter exception stack height change.
This fixes how the interpreter modifies the operand stack in the case
calls with non-zero parameter or return count throw an exception. The
interpreter raises the exception before arguments are popped and before
results are pushed onto the stack. This makes the control transfer
analysis fit this model. It also makes the tests trigger this aspect.

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-exceptions
BUG=v8:8091

Change-Id: I001fc4bc0030393d3c97be3fa9425bc540575071
Reviewed-on: https://chromium-review.googlesource.com/c/1445972
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59212}
2019-01-30 15:08:53 +00:00
Michael Starzinger
9d61228b6c [wasm] Handle external exception in the interpreter.
This implements preliminary handling of exceptions thrown by external
functions that have been imported into the module. Note that handling
internal function is still missing, but tests have been added.

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-exceptions
BUG=v8:8091

Change-Id: I9d07739d8b4715a5643114fd7a868cdd8d72efd0
Reviewed-on: https://chromium-review.googlesource.com/c/1445751
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59199}
2019-01-30 12:18:43 +00:00
Junliang Yan
0ae14a49e2 [wasm] Add BE support for atomic operations for wasm interpreter
This fixes RunWasmInterpreter_* tests on big endian mips/ppc/s390.

Change-Id: I4b9b767d0de45004ee1195ac225c6d1027c17a05
Reviewed-on: https://chromium-review.googlesource.com/c/1439517
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59174}
2019-01-29 15:23:48 +00:00
Jakob Kummerow
c640296e5a [ubsan] Avoid signed left shifts
The workaround is simple: cast to unsigned before shifting.

Bug: v8:3770
Change-Id: I5f0f7af697ec5db0ab1df3d061008940c83c5c56
Reviewed-on: https://chromium-review.googlesource.com/c/1436215
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59140}
2019-01-28 20:43:47 +00:00
Michael Starzinger
2dd3264422 [wasm] Preliminary interpreter support for exceptions.
This adds preliminary support for exception handling to the interpreter.
Note that due to missing reference type support, the exception object is
not yet correctly put onto the operand stack. Also exceptions raised by
call operations are not handled properly yet.

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-exceptions
BUG=v8:8091

Change-Id: Ie68ca9448c7beafe8967dff5bb5de6642edcc9e4
Reviewed-on: https://chromium-review.googlesource.com/c/1436017
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59131}
2019-01-28 16:03:56 +00:00
Jakob Kummerow
1df72c6fa1 [ubsan] Don't call memcpy with nullptr arguments
Not even when copying 0 bytes. Same for memmove and memcmp.

Bug: v8:3770
Change-Id: I3ed45a4572467ec7a9fc697ac28c004aa9b8b274
Reviewed-on: https://chromium-review.googlesource.com/c/1436217
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59101}
2019-01-25 20:53:45 +00:00
Michael Starzinger
87773260d3 [wasm] Implement interpreter support for "throw".
This implements support for the "throw" operation in the interpreter.
Note that support for catching/handling exceptions is still missing
from the interpreter in will be done separately.

This also introduces a {WasmExceptionPackage} class to the object model
that acts as an interface for allocating and accessing exceptions that
originate from WebAssembly. It does not represent a new instance type
however as exceptions are instances of {WebAssembly.RuntimeError} for
now.

R=clemensh@chromium.org
TEST=mjsunit/wasm/exceptions
BUG=v8:8091

Change-Id: I1f0cb548efb798e3c1488d42e4a31421c3c1aada
Reviewed-on: https://chromium-review.googlesource.com/c/1430099
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59033}
2019-01-23 14:35:53 +00:00
Ben L. Titzer
e254ec915b [utils] Add IsInBounds(index, size, max) helper
This CL adds a helper function that simplifies a bounds check pattern
that appears repeatedly in the code.

R=clemensh@chromium.org

Change-Id: I8c617515b34eb2d262d58a239a29c1515de2d92d
Reviewed-on: https://chromium-review.googlesource.com/c/1417611
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58892}
2019-01-17 15:25:42 +00:00
Jakob Kummerow
40ac5a39fc [ubsan] Fix numerical overflows in wasm
Mostly signed integer overflows, and a few cases of double
division by zero (which is defined by IEEE-754 to return
Infinity (or NaN for 0/0) but is UB in C++).

Bug: v8:3770
Change-Id: Id92725b0ac57cb357978124a3dc6f477430bc97d
Reviewed-on: https://chromium-review.googlesource.com/c/1403133
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58696}
2019-01-10 12:24:51 +00:00
Jakob Kummerow
056f927861 [ubsan] Port Object to the new design
Tbr: ahaas@chromium.org,leszeks@chromium.org,verwaest@chromium.org
Bug: v8:3770
Change-Id: Ia6530fbb70dac05e9972283781c3550d8b50e1eb
Reviewed-on: https://chromium-review.googlesource.com/c/1390116
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58470}
2018-12-26 20:54:07 +00:00
Clemens Hammacher
95db83b680 [wasm] Consistently use "branch" instead of "break"
In most places we already call them "branches", and the spec also only
uses this name. Hence remove the remaining mentions of "break".

R=titzer@chromium.org

Bug: v8:8562
Change-Id: I64ac39324681b8214cd2e68315eb86a69d85cba8
Reviewed-on: https://chromium-review.googlesource.com/c/1371567
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58153}
2018-12-11 12:35:00 +00:00
Sven Sauleau
2b92afd054 [wasm] Add WebAssembly's i64<>JavaScript's BigInt conversions - 64 bits
Uses the JavaScript BigInt Object to represent Wasm's 64bits integers.
Attention, 32 bits architectures are not supported yet.

Bug: v8:7741
Change-Id: I28b718fa567bca5103b2f38a879049cd20a46f12
Reviewed-on: https://chromium-review.googlesource.com/c/1355144
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58152}
2018-12-11 12:30:50 +00:00
Jakob Gruber
f7f18b0f1e [nojit] Explicitly pass the root register value to JSEntry
In preparation for converting JSEntry into a builtin. The root register
used to be initialized by an embedded external reference, which is not
isolate-independent. Pass in its value explicitly instead.

Tbr: clemensh@chromium.org
Bug: v8:7777
Change-Id: If9d20cb193af175bd1cf58e5826bdf6f397869ad
Reviewed-on: https://chromium-review.googlesource.com/c/1363139
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58065}
2018-12-06 09:44:32 +00:00
Ben Smith
3896c04767 [wasm] Use uint32_t instead of unsigned
The style guide says that only `int` should be used of the builtin
integer types. Instead, we should use the stdint types.

See https://google.github.io/styleguide/cppguide.html#Integer_Types

Change-Id: I1af53a3bceefbfed85589b74a602c8ebe1c7ee25
Reviewed-on: https://chromium-review.googlesource.com/c/1342663
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Ben Smith <binji@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57851}
2018-11-26 19:58:20 +00:00
Jakob Kummerow
18ac14688d Reland "[ubsan] Replace Object** in GlobalHandles"
and reland "[ubsan] More Object** replacements"

This reverts commit 162d4e6de8.

Reason for revert: Not the culprit, test failed before.

Original change's description:
> Revert "[ubsan] Replace Object** in GlobalHandles"
> 
> This reverts commit 9392727982.
> 
> Reason for revert: Speculative revert, seems the most probable cause of
> https://bugs.chromium.org/p/v8/issues/detail?id=8396
> 
> Revert "[ubsan] More Object** replacements"
> 
> This reverts commit 5cce694d60.
> 
> Speculative revert.
> 
> NOTRY=true
> 
> Bug: v8:8396
> Change-Id: I9c2866a9db707cd03e4cf90822acde20813cebf0
> Reviewed-on: https://chromium-review.googlesource.com/c/1309761
> Commit-Queue: Maya Lekova <mslekova@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#57174}

TBR=yangguo@chromium.org,mstarzinger@chromium.org,mslekova@chromium.org

Bug: v8:8396
Change-Id: I64fc80804b4ec324cef80ac528d08b724963f7f7
Reviewed-on: https://chromium-review.googlesource.com/c/1311813
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57194}
2018-10-31 23:56:23 +00:00
Maya Lekova
162d4e6de8 Revert "[ubsan] Replace Object** in GlobalHandles"
This reverts commit 9392727982.

Reason for revert: Speculative revert, seems the most probable cause of
https://bugs.chromium.org/p/v8/issues/detail?id=8396

Revert "[ubsan] More Object** replacements"

This reverts commit 5cce694d60.

Speculative revert.

NOTRY=true

Bug: v8:8396
Change-Id: I9c2866a9db707cd03e4cf90822acde20813cebf0
Reviewed-on: https://chromium-review.googlesource.com/c/1309761
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57174}
2018-10-31 14:48:57 +00:00
Jakob Kummerow
9392727982 [ubsan] Replace Object** in GlobalHandles
as part of the continuing quest to get rid of Object*/Object** entirely.
Since it fits nicely, this CL as a bonus includes the planned change to
make Handle::location() return an Address*, in the process dropping the
temporarily needed duplicate Handle::location_as_address_ptr().

Bug: v8:3770
Change-Id: I87480289ce2a62ea1ae503e73d179256b7108c5c
Reviewed-on: https://chromium-review.googlesource.com/c/1298389
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57153}
2018-10-31 00:28:40 +00:00
Clemens Hammacher
cc70a6b050 [wasm] Rename GrowMemory to MemoryGrow
The "grow_memory" opcode was renamed to "memory.grow", and the spec
repo was updated to use kExprMemoryGrow internally instead of
kExprGrowMemory (https://github.com/WebAssembly/spec/pull/720).
This CL does the same change for v8.

Drive-by: Rename "current_size" to "memory.size", and a minor cleanup
in wasm-graph-builder.js to bring it in line with the version in the
js-api tests in the spec repo.

R=titzer@chromium.org

Change-Id: If525dba898b2c248890a616d3392c22b45f698ef
Reviewed-on: https://chromium-review.googlesource.com/c/1302057
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57089}
2018-10-29 14:06:24 +00:00
Ben L. Titzer
a2b3480611 [wasm] Use a tuple as the instance for JS imports
This CL refactors the implementation of WASM->JS import wrappers in order
to make the wrapper code shareable. Instead of specializing to the import
index, we use a tuple as the object ref in the both the import and indirect
tables. The tuple allows the wrapper code to load both the calling
instance and the target callable, rather than relying on code specialization.

This requires some tricky codegen machinery, because WASM call descriptors
expect an instance argument in a given register, yet the wrappers receive
a tuple, the code generator must generate a prologue that loads the
instance (and the callable), since it is not possible to express this at
the graph level.

R=mstarzinger@chromium.org
CC=clemensh@chromium.org

Change-Id: Id67e307f7f5089e776f5439a53b5aee4b76934b6
Reviewed-on: https://chromium-review.googlesource.com/c/1268237
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56520}
2018-10-10 11:07:35 +00:00
Jakob Kummerow
9ed4b96578 Fix building with GCC 7.x and 8.x
GCC 7.x doesn't like it (-Werror=subobject-linkage) when a class
either derives from a class or has a member field of a type that
was declared in an anonymous namespace.
It is also opposed (-Werror=attributes) to visibility attributes
being defined at explicit template instantiations.
GCC 8.x further has reservations (-Werror=class-memaccess) about
letting memset/memcpy modify areas within non-POD objects.

Change-Id: Ic5107bb5ee3af6233e3741e3ef78d03a0a84005a
Reviewed-on: https://chromium-review.googlesource.com/1208306
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56106}
2018-09-21 01:12:25 +00:00
Clemens Hammacher
0a059c3c72 [wasm][interpreter] Store code entry as raw pointer
We are currently wrapping the pointer to the instruction start in a
Foreign. The argument buffer, which is also a raw pointer, is passed
directly though.
This CL changes this to also pass the code entry as a raw pointer.

R=mstarzinger@chromium.org

Change-Id: Id7344efa589a5297339ec01c3cfa7688bcc706b3
Reviewed-on: https://chromium-review.googlesource.com/1226970
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55895}
2018-09-14 10:52:33 +00:00
Clemens Hammacher
2d7e221d40 [wasm] Switch to phantom handles in interpreter
The interpreter stores a weak reference to the WasmInstance it belongs
to. Make this a phantom reference, so the GC can get rid of the
interpreter and its associated memory already on the first GC.

Drive-by: Some renamings/refactorings.

R=ahaas@chromium.org

Bug: chromium:875647
Change-Id: Ib49f6d8aa820b904f07fabe7df78ddf6df944264
Reviewed-on: https://chromium-review.googlesource.com/1221806
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55831}
2018-09-12 15:10:36 +00:00
Ben L. Titzer
398242f582 [flags] s/wasm_trace/trace_wasm/g in flags
This CL makes the names of tracing flags related to WASM consistent
with the rest of V8 tracing flags.

R=ahaas@chromium.org

Change-Id: I871fb7b5e27ff7b8f587e08507d15c0719881990
Reviewed-on: https://chromium-review.googlesource.com/1193182
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55479}
2018-08-29 08:49:09 +00:00
Ben L. Titzer
3d35921eb3 [wasm] Unify all enums representing execution tiers
R=mstarzinger@chromium.org

Change-Id: Iacdff28dd1383d77d7708de4ee22d9f2a77d872a
Reviewed-on: https://chromium-review.googlesource.com/1183440
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55284}
2018-08-21 15:45:18 +00:00
Michael Starzinger
2b89727539 [wasm] Preserve interpreter entry even on tier-up.
This makes sure that a tier-up from Ignition to TurboFan (or any other
code publishing) preserves redirections to the Interpreter. Currently an
interpreted function never switches back to compiled.

R=titzer@chromium.org
TEST=mjsunit/wasm/interpreter-mixed
BUG=v8:7921,v8:8018

Change-Id: Ifca479953509708c998c11cc00b481c232678e00
Reviewed-on: https://chromium-review.googlesource.com/1179661
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55195}
2018-08-17 13:21:59 +00:00
Ivica Bogosavljevic
91bd6a5dda [wasm] Implement SIMD big-endian support
This CL implements several things needed for full SIMD BE support in WASM:
* Global variables are now kept in little-endian order as per specification
* Added support for SIMD on BE in wasm interpreter
* Fixed several tests that didn't work on BE because input or output
  data were not using LE in-memory layout

Change-Id: I4542d13d09fd276e15b0fc39f02e4a58831f65e4
Reviewed-on: https://chromium-review.googlesource.com/1160484
Commit-Queue: Ivica Bogosavljevic <ibogosavljevic@wavecomp.com>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55075}
2018-08-13 08:58:39 +00:00
Ben L. Titzer
6aa2a25313 [wasm] Add WasmFeatures to enable/detect features
This CL introduces a set of configuration options implemented as
a struct of booleans that together comprise the set of enabled
or detected features. The configuration options replace command-line
flags that were checked deep in the implementation. As such, it is
necessary to plumb them through multiple levels of abstraction.

R=ahaas@chromium.org
CC=mstarzinger@chromium.org
BUG=chromium:868844

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I1b82f5826e4fd263f68e8cafcd923bac5818a637
Reviewed-on: https://chromium-review.googlesource.com/1163670
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55018}
2018-08-09 10:58:22 +00:00
Ben L. Titzer
99de47f155 [cleanup] Remove redundant wasm:: namespace prefixes
The wasm/ directory is inconsistent in many places, often within the
same file. For all code that exists in a v8::internal::wasm namespace,
this CL removes any wasm:: qualifiers, which is especially helpful
since most types are already Wasm-named, such as WasmCode, WasmModule,
etc. Namespace qualifiers are redundant inside the wasm:: namespace and
thus go against the main point of using namespaces. Removing the
qualifiers for non Wasm-named classes also makes the code somewhat more
future-proof, should we move some things that are not really WASM-specific
(such as ErrorThrower and Decoder) into a higher namespace.

R=clemensh@chromium.org,mstarzinger@chromium.org

Change-Id: Ibff3e1e93c64c12dcb53c46c03d1bfb2fb0b7586
Reviewed-on: https://chromium-review.googlesource.com/1160232
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54862}
2018-08-02 10:36:00 +00:00
Leszek Swirski
6de8560209 [cleanup] Remove unused Isolate parameters
ReadOnlyRoots means that some added Isolate parameters are no longer
needed. So, we can remove them.

This patch was generated mostly automatically with a bespoke tool.

Bug: v8:7786
Bug: v8:7754
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ia44fd2a66652253f780e3674bf7fb431caef0493
Reviewed-on: https://chromium-review.googlesource.com/1136305
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Dan Elphick <delphick@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54526}
2018-07-18 16:47:22 +00:00
Andreas Haas
cf9563ea71 [wasm] Trace traps in the interpreter
R=clemensh@chromium.org

Change-Id: I4f1bda6f0ad420776eb181563d5efbc0d06a911e
Reviewed-on: https://chromium-review.googlesource.com/1141582
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54518}
2018-07-18 11:50:42 +00:00
Clemens Hammacher
a119f9cac3 [wasm] Refactor SignatureMap to use unordered_map
An unordered_map typically provides better performance. Instead of a
compare function, we now need a hash function and equality defined on
{Signature<T>}.

R=mstarzinger@chromium.org

Bug: chromium:862123
Change-Id: Iba71030f91949d7453740c884de1d8a4f921c618
Reviewed-on: https://chromium-review.googlesource.com/1131182
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54404}
2018-07-12 12:34:28 +00:00
Aseem Garg
2114c6eea6 Reland "[wasm] add 64 bit atomic ops to interpreter"
This is a reland of 5301cdc39f

Original change's description:
> [wasm] add 64 bit atomic ops to interpreter
>
> R=gdeepti@chromium.org
> BUG=v8:6532
>
> Change-Id: I532bf67f1631c692e12f9b054b29601a57b76f05
> Reviewed-on: https://chromium-review.googlesource.com/1130635
> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
> Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#54365}

Bug: v8:6532
Change-Id: I22af58646b898ee2f54ccb64467d9fb978a645c5
Reviewed-on: https://chromium-review.googlesource.com/1132155
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54369}
2018-07-10 22:35:37 +00:00
Aseem Garg
cab5304b61 Revert "[wasm] add 64 bit atomic ops to interpreter"
This reverts commit 5301cdc39f.

Reason for revert: Failing on mips

Original change's description:
> [wasm] add 64 bit atomic ops to interpreter
> 
> R=​gdeepti@chromium.org
> BUG=v8:6532
> 
> Change-Id: I532bf67f1631c692e12f9b054b29601a57b76f05
> Reviewed-on: https://chromium-review.googlesource.com/1130635
> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
> Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#54365}

TBR=gdeepti@chromium.org,aseemgarg@chromium.org

Change-Id: Id56d3bb1228b38b6e2ad29876ea78542658e8310
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6532
Reviewed-on: https://chromium-review.googlesource.com/1132154
Reviewed-by: Aseem Garg <aseemgarg@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54366}
2018-07-10 20:01:18 +00:00
Aseem Garg
5301cdc39f [wasm] add 64 bit atomic ops to interpreter
R=gdeepti@chromium.org
BUG=v8:6532

Change-Id: I532bf67f1631c692e12f9b054b29601a57b76f05
Reviewed-on: https://chromium-review.googlesource.com/1130635
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54365}
2018-07-10 19:04:07 +00:00
Andreas Haas
d87287bc48 [wasm][anyref] Allow tables of different reference types
Allow the decoding of multiple tables, and allow these tables to have
any reference type. In addition, rename function-tables (in different
occurrences) to tables.

R=titzer@chromium.org

Bug: v8:7581
Change-Id: I191ea8e303b76563f9d91ae7447b373c4760d8b8
Reviewed-on: https://chromium-review.googlesource.com/1019581
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54355}
2018-07-10 13:50:36 +00:00
Clemens Hammacher
4174a68e84 [wasm] Fix importing exported function in interpreter
When calling an import which is an exported wasm function, the
interpreter needs to look through the jump table to find the
actual code object.
We already had that logic for indirect calls, but it was missing for
imported calls.

R=ahaas@chromium.org

Bug: chromium:860392
Change-Id: I6b5a0192f79c23cb1de55407fe93f6df9a17235a
Reviewed-on: https://chromium-review.googlesource.com/1127671
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54291}
2018-07-06 11:22:01 +00:00
Andreas Haas
c0a0c9eb46 [wasm] Store the wasm interpreter stack on the C++ heap
The stack of the wasm interpreter was stored in a zone. However, when
the stack grows, the previous memory of the stack cannot be reused.
With this CL we allocate the stack on the C++ heap to remove this memory
leak.

R=clemensh@chromium.org

Bug: chromium:856594
Change-Id: Idce22c5c1732f7097fc4281c73174892c95f49e2
Reviewed-on: https://chromium-review.googlesource.com/1126301
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54238}
2018-07-05 09:54:28 +00:00
Aseem Garg
d3fe5ac7c3 [wasm] add simd horiz and reduce to interpreter
This CL adds simd select, addHoriz, shuffle, anyTrue and all true to the
interpreter. It also gets rid of SIMD_COMPILED_AND_LOWERED_TEST and
SIMD_COMPILED_TEST macros.

R=gdeepti@chromium.org
BUG=v8:6020

Change-Id: I44abbcaddc3223a95c79ccc65ae9c6bf1a911c5d
Reviewed-on: https://chromium-review.googlesource.com/1119258
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54116}
2018-06-29 20:13:50 +00:00
Leszek Swirski
83ac43275e [GetIsolate] More low-hanging fruit
Access Isolate* and Heap* wherever already available.

Roughly:
GetIsolate(): -20
GetHeap(): -22
Handle<>(HeapObject): -315
handle(HeapObject): -21

Bug: v8:7786
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng;luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I2da36ed1909d849812a1cb6bf94cb735eedca45b
Reviewed-on: https://chromium-review.googlesource.com/1111707
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53987}
2018-06-23 09:53:20 +00:00
Aseem Garg
618bc445fe [wasm] add simd convert and pack to interpreter
R=gdeepti@chromium.org
BUG=v8:6020

Change-Id: Ibdeb926ef3e2884b9a3f0831e9482ebe2da227ac
Reviewed-on: https://chromium-review.googlesource.com/1105464
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53898}
2018-06-20 21:26:16 +00:00
Clemens Hammacher
5f56641b41 Reland "[wasm] Introduce jump table"
This is a reland of 733b7c8258.
The arm64 bug was fixed in https://crrev.com/c/1105051.

Original change's description:
> [wasm] Introduce jump table
>
> This introduces the concept of a jump table for WebAssembly, which is
> used for every direct and indirect call to any WebAssembly function.
> For lazy compilation, it will initially contain code to call the
> WasmCompileLazy builtin, where it passes the function index to be
> called.
> For non-lazy-compilation, it will contain a jump to the actual code.
> The jump table allows to easily redirect functions for lazy
> compilation, tier-up, debugging and (in the future) code aging. After
> this CL, we will not need to patch existing code any more for any of
> these operations.
>
> R=mstarzinger@chromium.org, titzer@chromium.org
>
> Bug: v8:7758
> Change-Id: I45f9983c2b06ae81bf5ce9847f4542fb48844a4f
> Reviewed-on: https://chromium-review.googlesource.com/1097075
> Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Ben Titzer <titzer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53805}

TBR=titzer@chromium.org,mstarzinger@chromium.org

Bug: v8:7758
Change-Id: I68555230c6db97e70f0b8fef784188f55ee04794
Reviewed-on: https://chromium-review.googlesource.com/1105158
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53829}
2018-06-19 10:29:48 +00:00
Clemens Hammacher
33f6c3e10e Revert "[wasm] Introduce jump table"
This reverts commit 733b7c8258.

Reason for revert: breaks arm64 gc-stress: https://ci.chromium.org/buildbot/client.v8.ports/V8%20Linux%20-%20arm64%20-%20sim%20-%20gc%20stress/11659

Original change's description:
> [wasm] Introduce jump table
> 
> This introduces the concept of a jump table for WebAssembly, which is
> used for every direct and indirect call to any WebAssembly function.
> For lazy compilation, it will initially contain code to call the
> WasmCompileLazy builtin, where it passes the function index to be
> called.
> For non-lazy-compilation, it will contain a jump to the actual code.
> The jump table allows to easily redirect functions for lazy
> compilation, tier-up, debugging and (in the future) code aging. After
> this CL, we will not need to patch existing code any more for any of
> these operations.
> 
> R=​mstarzinger@chromium.org, titzer@chromium.org
> 
> Bug: v8:7758
> Change-Id: I45f9983c2b06ae81bf5ce9847f4542fb48844a4f
> Reviewed-on: https://chromium-review.googlesource.com/1097075
> Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Ben Titzer <titzer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53805}

TBR=mstarzinger@chromium.org,titzer@chromium.org,clemensh@chromium.org,sreten.kovacevic@mips.com

Change-Id: Iea358db2cf13656a65cf69a6d82cbbc10d3e7e1c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7758
Reviewed-on: https://chromium-review.googlesource.com/1105157
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53807}
2018-06-18 20:38:50 +00:00
Clemens Hammacher
733b7c8258 [wasm] Introduce jump table
This introduces the concept of a jump table for WebAssembly, which is
used for every direct and indirect call to any WebAssembly function.
For lazy compilation, it will initially contain code to call the
WasmCompileLazy builtin, where it passes the function index to be
called.
For non-lazy-compilation, it will contain a jump to the actual code.
The jump table allows to easily redirect functions for lazy
compilation, tier-up, debugging and (in the future) code aging. After
this CL, we will not need to patch existing code any more for any of
these operations.

R=mstarzinger@chromium.org, titzer@chromium.org

Bug: v8:7758
Change-Id: I45f9983c2b06ae81bf5ce9847f4542fb48844a4f
Reviewed-on: https://chromium-review.googlesource.com/1097075
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53805}
2018-06-18 16:38:09 +00:00
Aseem Garg
0091973e82 Reland "[wasm] Add simd mem and shift ops to interpreter"
This is a reland of 2338a2fd63

Original change's description:
> [wasm] Add simd mem and shift ops to interpreter
>
> R=clemensh@chromium.org
> BUG=v8:6020
>
> Change-Id: I5d95e4c23240ae4e174d896d31e1b9b1d89d9418
> Reviewed-on: https://chromium-review.googlesource.com/1096493
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53717}

Bug: v8:6020
Change-Id: I38a73f5e389617a05a12e0a9477544c4e3aa2883
Reviewed-on: https://chromium-review.googlesource.com/1099895
Reviewed-by: Ben Smith <binji@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53722}
2018-06-13 22:03:46 +00:00
Sathya Gunasekaran
76cc2ad07e Revert "[wasm] Add simd mem and shift ops to interpreter"
This reverts commit 2338a2fd63.

Reason for revert: broke mips

see https://ci.chromium.org/buildbot/client.v8.ports/V8%20Mips%20-%20builder/17573

Original change's description:
> [wasm] Add simd mem and shift ops to interpreter
> 
> R=​clemensh@chromium.org
> BUG=v8:6020
> 
> Change-Id: I5d95e4c23240ae4e174d896d31e1b9b1d89d9418
> Reviewed-on: https://chromium-review.googlesource.com/1096493
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53717}

TBR=aseemgarg@chromium.org,clemensh@chromium.org

Change-Id: I8e5b2e9a9c1c09d035335ba6681bbe3e1ce5abfb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6020
Reviewed-on: https://chromium-review.googlesource.com/1099776
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53718}
2018-06-13 21:10:18 +00:00
Aseem Garg
2338a2fd63 [wasm] Add simd mem and shift ops to interpreter
R=clemensh@chromium.org
BUG=v8:6020

Change-Id: I5d95e4c23240ae4e174d896d31e1b9b1d89d9418
Reviewed-on: https://chromium-review.googlesource.com/1096493
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53717}
2018-06-13 19:42:03 +00:00
Aseem Garg
62620a4257 [wasm] use static_cast for simd in interpreter
R=clemensh@chromium.org
BUG=v8:6020

Change-Id: I03ad47ea119be699bd9defde6d962d32295be40c
Reviewed-on: https://chromium-review.googlesource.com/1083694
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53537}
2018-06-05 21:14:36 +00:00
Deepti Gandluri
785bd43b7e [wasm] Enable sign extension operations in the interpreter
Change-Id: I204a021ffc8b120ffe232e3f5db924e54c6d980e
Reviewed-on: https://chromium-review.googlesource.com/1083337
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53478}
2018-06-01 22:12:45 +00:00
Aseem Garg
dc6819ec56 [wasm] Add simd replaceLane ops to wasm interpreter
Also enables tests for globals and mixed type use

R=gdeepti@chromium.org,bbudge@chromium.org,clemensh@chromium.org,titzer@chromium.org
BUG=v8:6020

Change-Id: I828f1628a1c27d9f07ba3a830600f81c5a404b2d
Reviewed-on: https://chromium-review.googlesource.com/1080340
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53477}
2018-06-01 21:50:35 +00:00
Aseem Garg
f22991ab40 [wasm] Add simd compare ops to wasm interpreter
R=gdeepti@chromium.org,bbudge@chromium.org,clemensh@chromium.org,titzer@chromium.org
BUG=v8:6020

Change-Id: I9d307a70d44504dc0e84e3e09d48bcc9b9542462
Reviewed-on: https://chromium-review.googlesource.com/1071095
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53375}
2018-05-25 22:29:34 +00:00
Aseem Garg
f8445719c3 [wasm] Delete Simd unsigned int types for interpreter
R=gdeepti@chromium.org,bbudge@chromium.org,clemensh@chromium.org,titzer@chromium.org
BUG=v8:6020

Change-Id: I05bb2124751f64565ad4e22f267fe42a3e0f1845
Reviewed-on: https://chromium-review.googlesource.com/1070935
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53374}
2018-05-25 22:19:24 +00:00
Aseem Garg
bedcef5cd0 [wasm] Add simd unops to wasm interpreter
R=gdeepti@chromium.org,bbudge@chromium.org,clemensh@chromium.org,titzer@chromium.org
BUG=v8:6020

Change-Id: Ibc4e45df65ad8fc649e42b2166545cbc5fcb4296
Reviewed-on: https://chromium-review.googlesource.com/1070933
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53346}
2018-05-24 19:01:32 +00:00
Aseem Garg
7b3089c0de [wasm] Add simd binops to wasm interpreter
R=gdeepti@chromium.org,bbudge@chromium.org,clemensh@chromium.org,titzer@chromium.org
BUG=v8:6020

Change-Id: I671d74b49206a3612764c7b9cb63591e7e81e857
Reviewed-on: https://chromium-review.googlesource.com/1069933
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53316}
2018-05-23 22:56:36 +00:00
Aseem Garg
eff265415a [wasm] Add simd splat to wasm interpreter
R=gdeepti@chromium.org,bbudge@chromium.org,clemensh@chromium.org,titzer@chromium.org
BUG=v8:6020

Change-Id: I25676d4f8a7ea7b1e02a54abe009faec0eb2c6db
Reviewed-on: https://chromium-review.googlesource.com/1018840
Commit-Queue: Aseem Garg <aseemgarg@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53266}
2018-05-18 22:30:10 +00:00
Clemens Hammacher
7696972ec3 [wasm][cleanup] Name interpreter entry consistently
The interpreter entry was sometimes referred to as "interpreter stub"
or "interpreter wrapper". Use the term "interpreter entry" consistently.

R=titzer@chromium.org

Bug: v8:7754
Change-Id: Ia06449c91300fca454c6afd5c82a789749d6b7d0
Reviewed-on: https://chromium-review.googlesource.com/1058794
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53184}
2018-05-15 12:53:44 +00:00
Ben L. Titzer
e677d54a79 [wasm] Use inline field inits
R=clemensh@chromium.org

Change-Id: Ib1a0105e3347a5ccafdb72dadd9aa144ab77732c
Reviewed-on: https://chromium-review.googlesource.com/1046970
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53035}
2018-05-07 16:15:08 +00:00
Andreas Haas
6380476c71 [wasm] Make wasm::ValueType independent of the MachineRepresentation
R=clemensh@chromium.org
CC=​titzer@chromium.org

Change-Id: I4951bf7ffc8baf51225e7bef60349186811b9f76
Reviewed-on: https://chromium-review.googlesource.com/1024037
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53020}
2018-05-07 11:54:56 +00:00
Ben L. Titzer
2c0edb48cd [wasm] Rename XXXOperand to XXXImmediate
R=clemensh@chromium.org
CC=ahaas@chromium.org

Change-Id: Ibcbc5e43e7095d9783f49ad2c3f27338100c4fdf
Reviewed-on: https://chromium-review.googlesource.com/1039489
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52953}
2018-05-03 12:41:54 +00:00
Marja Hölttä
c56cabb5ea [wasm] iwyu part 2
BUG=v8:7490

Change-Id: I2a597eda708b2ea34c9e32e39556159b48591b61
Reviewed-on: https://chromium-review.googlesource.com/1039196
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52911}
2018-05-02 11:22:56 +00:00
Eric Holk
9286358071 [wasm][interpreter] Clear thread in wasm flag on exceptional return
A stack overflow can be thrown by JSEntryStub, which means the
thread-in-wasm flag will not have the expected value. To accommodate
this, we now clear the flag during exceptional returns if it is set.

Bug: chromium:834624
Change-Id: I8359af79886ab98dfecc2fb39ca19118b7fa38eb
Reviewed-on: https://chromium-review.googlesource.com/1019570
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Eric Holk <eholk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52891}
2018-04-30 17:13:19 +00:00
Ben L. Titzer
8ba3f1366d [wasm] Handlify table entry helpers
R=clemensh@chromium.org

Change-Id: Iade16b07a24dca8ac542e68becad734d977b673a
Reviewed-on: https://chromium-review.googlesource.com/1032778
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52852}
2018-04-27 14:11:34 +00:00
Clemens Hammacher
8466b71ad8 [wasm] Split off wasm-linkage.h
Linkage-related methods were declared in wasm-compiler.h and
implemented in wasm-linkage.cc. This required all users of e.g. wasm
call descriptors to include the whole wasm compiler header. Also, some
wasm linkage information is independent of turbofan and also used
outside of the compiler directory.

This CL splits off wasm-linkage.h (with minimal includes) and puts it
in src/wasm. This allows to use that information without including
compiler headers (will clean up several uses in follow-up CLs).

R=mstarzinger@chromium.org, titzer@chromium.org

Bug: v8:7570
Change-Id: Ifcae70b4ea7932cda30953b325c2b87c4176c598
Reviewed-on: https://chromium-review.googlesource.com/1013701
Reviewed-by: Ben Titzer <titzer@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52849}
2018-04-27 13:43:49 +00:00
Stephan Herhut
48d508cb45 [wasm] Add I32AtomicCompareExchange to interpreter
This adds support for the I32AtomicCompareExchange operations in the
interpreter. Also, the interpreter will now fail if it encounters
an unknown opcode from the atomic prefix.

Bug: chromium:826069
Change-Id: Iec1742271f4fdd83fcaa09ca72c24d1cf8c58835
Reviewed-on: https://chromium-review.googlesource.com/1029867
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52807}
2018-04-26 12:02:11 +00:00
Ben Smith
9166affb29 [wasm] Implement importing mutable globals
The WasmInstanceObject stores two new arrays:

- imported_mutable_globals_buffers_: a FixedArray of all the imported
  globals' array buffers.
- imported_mutable_globals: a calloc'd array of Addresses pointing to
  the mutable global in its array buffer.

When accessing the global, the generated code looks up the address in
imported_mutable_globals to find where to load/store.

Bug: v8:7625
Change-Id: I60844c21a788fce28f346455f10f2283d1c152e9
Reviewed-on: https://chromium-review.googlesource.com/1020602
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52794}
2018-04-25 18:57:48 +00:00
Clemens Hammacher
8d2d0513c3 [wasm] Simplify C calls
Instead of passing multiple pointers to input and output, or to two
input values, just pass one pointer which holds all inputs and where
the output is written.
This also reduces the size of generated Turbofan graphs, since only one
stack slot is needed and less arguments are passed to the call.
It also fixes undefined behaviour, since we were passing a pointer e.g.
as {uint64_t*}, but accessed it using {ReadUnalignedValue}. Now we pass
an Address, which does not have any alignment constraints.

R=ahaas@chromium.org

Bug: v8:3770, v8:6600
Change-Id: I54ef80b7e27f77587a9062560c0b3e01d6593e6d
Reviewed-on: https://chromium-review.googlesource.com/1019147
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52702}
2018-04-20 08:14:51 +00:00
Vincent Belliard
abfcc1124c [arm64][Liftoff] Start Liftoff implementation.
First version which can compile a very basic code.

Change-Id: I3b98412a5ca39a28f8fe5b60516b82c6981dd187
Reviewed-on: https://chromium-review.googlesource.com/993232
Commit-Queue: Vincent Belliard <vincent.belliard@arm.com>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52622}
2018-04-16 16:16:47 +00:00