Commit Graph

372 Commits

Author SHA1 Message Date
Emanuel Ziegler
de17316ad2 [wasm][reference-types] Implement declarative segments
Implement the latest spec changes:
  - Allow declarative segments to behave like passive & dropped segments.
  - Enforce that only declared functions may be returned or used in globals
    as funcref.
  - Ensure that table fill does not modify any entries if OOB.

Spec tests for select and br_table are still failing due to proposal issue

Bug: v8:10156

R=ahaas@chromium.org

Change-Id: I5b95be36a67bc7482a84b848908cc4cbdf94af03
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2027458
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66297}
2020-02-17 17:38:27 +00:00
Ng Zhi An
554a347892 [wasm-simd] Remove f64x2.convert_i64x2_s and _u
These conversion instructions were removed from the proposal in
https://github.com/WebAssembly/simd/pull/178.

Change-Id: I212ca2f923362bf08e178f6d28cc2338cf6f5927
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2016006
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66015}
2020-01-28 18:36:43 +00:00
Emanuel Ziegler
ea69636247 [wasm][reference-types] Enable ref.null in Wasm code
Add decoding of ref.null as a valid argument for references in
TurboFan, LiftOff and the interpreter.

R=ahaas@chromium.org
R=jkummerow@chromium.org

Bug: chromium:10063
Change-Id: I1e2d9c76f616dacb3aa06f8b535543bdcdcf0783
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1991485
Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65788}
2020-01-15 12:45:59 +00:00
Andreas Haas
b2f094bf93 [wasm] Add AtomicLoad and AtomicStore to the fuzzer
I also fixed one issue in the wasm interpreter.

R=clemensb@chromium.org

Bug: v8:10180
Change-Id: Ie30e908ad051a27fa611e8d36134b67aaf4c830c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2000741
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65764}
2020-01-14 19:29:57 +00:00
Ng Zhi An
650ca8b509 [wasm-simd] Implement v128.andnot for x64 and interpreter
Note the tricky part in instruction-selector-x64, where we flip the
inputs given to the code generator. This is because the semantics we
want is: v128.andnot a b = a & !b, but the x64 instruction performs
andnps a b = !a & b. Therefore we flip the inputs, and combined with
g.DefineSameAsFirst, the output register will be the same as b, and we
can use andnps without any modifications in both SSE and AVX cases.

Bug: v8:10082
Change-Id: Iff98dc1dd944fbc642875f6306c6633d5d646615
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1980894
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65738}
2020-01-13 18:01:06 +00:00
Ng Zhi An
90b42052c6 [wasm-simd] Implement rounding average on x64 and interpreter
This change includes templatization of the test helper to allow the
same function to be reused for both signed and unsigned data types.

We implement a new function RoundingAverageUnsigned in overflowing-math,
rather than in base/utils, since the addition could overflow.

SIMD scalar lowering and implementation for other backends will follow
in future patches.

Bug: v8:10039
Change-Id: I70735f7b6536f197869ef1afbccaf5649e7e8448
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1958007
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65531}
2019-12-19 22:40:59 +00:00
Michael Starzinger
b577c1fe95 Remove and update some outdated TODO(mstarzinger).
R=clemensb@chromium.org

Change-Id: Ibd6790a222590fd4dce9f918219a19f01c2e1e0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1960293
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65439}
2019-12-13 10:18:04 +00:00
Deepti Gandluri
4cfa97f66b [wasm] Add atomics wait/notify to the interpreter, enable tests.
Bug: chromium:1027441
Change-Id: Ieac67e06aebf57a11327cbd34dd31f62cbe540b1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1957847
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65415}
2019-12-11 15:17:35 +00:00
Emanuel Ziegler
7a51fe240b [wasm][bulk-memory] Adjust bulk memory behavior to proposal phase 4
The following changes were introduced with the recent proposal update:
- OOB access with 0 length traps
- Double drop of segments is allowed
- Dropped segments are treated like having size 0 (OOB error)
- Active segments are dropped right after initialization

R=ahaas@chromium.org

Change-Id: I4e9fc4d9212841c7d858585c672143f99287520d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1946355
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65305}
2019-12-03 12:21:48 +00:00
Clemens Backes
b83c5a06c5 [wasm] Refactor WasmFeatures
Make WasmFeatures a proper class which uses an EnumSet under the hood.
This way, it inherits all behaviour of EnumSet like comparison, merge,
etc.
Accesses change from being simple field access into the struct to
actually bit tests in the EnumSet.

R=mstarzinger@chromium.org

Bug: v8:10019
Change-Id: I768f92b90ac0294156f4482defba5ce00bc70165
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1934334
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65184}
2019-11-26 17:36:11 +00:00
Emanuel Ziegler
4b6a699208 [wasm][bulk-memory] Adjust throw behavior to match new proposal
InstanceBuilder::LoadTableSegments - Throw RuntimeError instead of
  LinkError
WasmGraphBuilder::TableInit & WasmGraphBuilder::MemoryInit - Do not
  check for active/dropped status if size == 0
WasmGraphBuilder::MemoryFill - Throw out-of-bounds error BEFORE
  attempting any memory operations if necessary

R=ahaas@chromium.org

Bug: v8:9865
Change-Id: I6a67779dc99fdc1c6bda6a2526d0e9ee5385f3ed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1924442
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65098}
2019-11-21 14:37:43 +00:00
Andreas Haas
9e8cd78d69 [wasm][bulk-memory] Change bounds checks behavior
This is necessary because the spec changed.

R=mstarzinger@chromium.org

Bug: v8:9865
Change-Id: Id8b4d85eafcf368d591666907036e6aa54664e63
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1921794
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65072}
2019-11-20 15:07:17 +00:00
Ng Zhi An
c954e694b9 [wasm-simd] Implement load_extend in interpreter
Bug: v8:9886
Change-Id: I5ed8ad13a4c92b61cddb8d86ec97e242252a556e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1922231
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65056}
2019-11-19 22:21:08 +00:00
Ng Zhi An
e927764216 [wasm-simd] Fix unsigned narrow instructions
These instructions should always treat inputs as signed, and saturate to
unsigned min/max values.

E.g. given -1, it should saturate to 0.

The spec text,
https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing,
has been updated to describe this.

The changes here include codegen changes to ia32, x64, arm, and arm64,
changes to arm simulator, assembler, and disassembler to handle the case
of treating input as signed and narrowing to unsigned. The vqmovn
instruction can handle this case, our assembler wasn't allowing callers
to specify this.

The interpreter and scalar lowering are also fixed with this change.

Bug: v8:9729
Change-Id: I6f72baa825f59037f7754485df6a2964af59fe31
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1879423
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65051}
2019-11-19 18:51:09 +00:00
Ng Zhi An
d30ec8566b [wasm-simd] Implement load_splat in interpreter
Bug: v8:9886
Change-Id: I860bea0c317e9666662329e9b36598952c8ecfad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1919697
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65050}
2019-11-19 18:46:18 +00:00
Z Nguyen-Huu
a3b5229bdd [wasm] Support stepping into Wasm from Javascript
We detect a stepping in Wasm from Javascript into Wasm then prepare
the target function for debugging.

The trick is redirect the target to interpreter and set a 'fake'
breakpoint in the first instruction. Currently we don't need to clear
this 'fake' breakpoint since it won't notify unless user intend to
step in.

Change-Id: Ibe1f9ba31dc6c7919895d3fe31967e9c4699ef63
Bug: chromium:1019606
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1902259
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65020}
2019-11-18 19:59:32 +00:00
Dan Elphick
84f3877c15 [cleanup] Split out bit-field.h and bounds.h from utils/utils.h
utils.h itself is fairly large and contains lots of unrelated functions
as well as having a fair number of dependencies itself, so this splits
bounds checking and bit field operations into their own headers in base
and replaces uses of utils.h with the more appropriate header where
possible. (Also fixes some cases where other headers were previously
brought in transitively).

Bug: v8:9810, v8:8912
Change-Id: I76c53f953848a57e2c5bfad6ce45abcd6d2a4f1b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1916604
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64983}
2019-11-15 13:00:08 +00:00
Thibaud Michaud
53cddab847 [wasm] Allow polymorphic stack in the interpreter's side table
Quoting from the spec, the expected behavior for validating unreachable
code is that:

A polymorphic stack cannot underflow, but instead generates
Unknown types as needed.

(https://webassembly.github.io/spec/core/appendix/algorithm.html)

This CL changes the representation of the stack height in the
interpreter's side table builder from unsigned to signed to prevent
underflow, and makes some DCHECKs depend on code reachability.

R=clemensb@chromium.org

Bug: chromium:1017061
Change-Id: I4c999859019d6cefb76c1366ba0e98f199f7a0be
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1876813
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64546}
2019-10-24 13:16:03 +00:00
Clemens Backes
334dd91987 [wasm] Move {GetGlobalValue} out of the interpreter
This will allow us to reuse this method in other contexts.
This CL also contains smaller refactorings that helped to move the
code. E.g. the WASMVALUE_CTYPES macro (defined in value-type.h)
replaces the WASM_CTYPES macro (from wasm-interpreter.cc).

R=mstarzinger@chromium.org

Bug: v8:9676
Change-Id: Id788f843af9a09eb940593afa1639f12b652c514
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1876054
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64534}
2019-10-24 09:10:55 +00:00
Clemens Backes
f30a92e6f2 [wasm] Move global storage accessors out of interpreter
These accessors do not make any use of the interpreter, hence we can
define them on the WasmInstanceObject alone. This will allow to reuse
them for other (non-interpreted) frames.

R=mstarzinger@chromium.org

Bug: v8:9676
Change-Id: Iff8b665a4c25581b934c25b66a13cebe044cb02c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1875097
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64511}
2019-10-23 12:39:34 +00:00
Thibaud Michaud
16b83b1b4a [wasm] Fix interpreter multi-value stack height issue
Block inputs are removed from the stack. Set expected stack height
accordingly.

R=ahaas@chromium.org

Bug: v8:9867
Change-Id: I7e3fd2985c0e77e83d5551cac613788f3cf0a370
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1872404
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64465}
2019-10-22 12:59:32 +00:00
Ng Zhi An
b477d91c57 Reland "[wasm-simd] Implement F64x2ConvertI64x2 for x64"
This is a reland of 306bb635b7

Original change's description:
> [wasm-simd] Implement F64x2ConvertI64x2 for x64
> 
> Bug: v8:8460
> Change-Id: Icefb90c67af77ac93bd75b4e452ba426232de83a
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1710332
> Commit-Queue: Zhi An Ng <zhin@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Reviewed-by: Bill Budge <bbudge@chromium.org>
> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#63627}

Bug: v8:8460
Change-Id: I08d2c88e81ce51d3d1cfdf3d7d6ba34792e34e9e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1793902
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64365}
2019-10-17 23:22:47 +00:00
Ng Zhi An
3fdc88defb [wasm-simd] Implement v8x16.swizzle for x64
Bug: v8:8460
Change-Id: I79ae753f15aaa91a2154bd7078a1cdb9f3e049f1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1822497
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64201}
2019-10-09 19:37:52 +00:00
Deepti Gandluri
df546bd15f [wasm-simd] Add ExtractLaneU operations
This CL implements i8x16.extract_lane_u, i16x8.extract_lane_u operations by
changing the default narrow extract operations to be unsigned. The
sign-extended extracts are implemented on top of the unsigned extracts
with an additional extend compiler node.
For IA32/X64, the codegen effectively remains the same -

0x389332bc32a3    63  660f3a14c900   pextrb rcx,xmm1,0
0x389332bc32a9    69  0fbec9         movsxbl rcx,rcx

0x389332bc32a3    63  660f3a14c900   pextrb rcx,xmm1,0
0x389332bc32a9    69  0fbec9         movsxbl rcx,rcx

On ARM, this adds an additional sxt instruction for the signed extracts.

Bug: v8:8460
Change-Id: I67f14b2b860ff8cc86ffbb2f65c7ef7de32da83f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1846711
Reviewed-by: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64172}
2019-10-09 00:58:04 +00:00
Clemens Backes
1876767992 [wasm] Rename {Get,Set}Global to Global{Get,Set}
This brings our constants back in line with the changed spec text. We
already use kExprTableGet and kExprTableSet, but for locals and globals
we still use the old wording.

This renaming is mostly mechanical.

PS1 was created using:
ag -l 'kExpr(Get|Set)Global' src test | \
  xargs -L1 sed -E 's/kExpr(Get|Set)Global\b/kExprGlobal\1/g' -i

PS2 contains manual fixes.

R=mstarzinger@chromium.org

Bug: v8:9810
Change-Id: I064a6448cd95bc24d31a5931b5b4ef2464ea88b1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1847355
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64163}
2019-10-08 14:27:50 +00:00
Clemens Backes
421fd3929d [wasm] Rename {Get,Set,Tee}Local to Local{Get,Set,Tee}
This brings our constants back in line with the changed spec text. We
already use kExprTableGet and kExprTableSet, but for locals and globals
we still use the old wording.

This renaming is mostly mechanical.

PS1 was created using:
ag -l 'kExpr(Get|Set|Tee)Local' src test | \
  xargs -L1 sed -E 's/kExpr(Get|Set|Tee)Local\b/kExprLocal\1/g' -i

PS2 contains manual fixes.

R=mstarzinger@chromium.org

Bug: v8:9810
Change-Id: I1617f1b2a100685a3bf56218e76845a9481959c5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1847354
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64161}
2019-10-08 14:14:40 +00:00
Michael Starzinger
cae9aaeb32 [wasm] Improve {WasmExceptionPackage} type safety.
This uses Handle<WasmExceptionPackage> where applicable to increase type
safety. Note that {WasmExceptionPackage} is not a full-fledged instance
type though. The {HeapObject::IsWasmExceptionPackage} predicate is an
approximation because a precise version could only be implemented using
handlified code performing a property lookup.

R=clemensb@chromium.org

Change-Id: I061e3eea201a0e9909ba67ae33db81d14aaefe4b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1477673
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Backes [né Hammacher] <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63987}
2019-09-26 11:44:46 +00:00
Andreas Haas
9cf9e82a2a [wasm][interpreter] Fix memory leak with the reference stack
This CL fixes a memory leak in the interpreter. The leak was caused by
a cycle the object graph that was rooted with a global object. The
cycle was the following:

A global handle, owned by the interpreter -> reference stack of the
Interpreter -> ref.func element (WasmExportedFunction) ->
WasmInstanceObject -> WasmDebugInfo -> InterpreterHandle -> Interpreter

With this CL we get rid of the global handle. Instead we store the stack
in the WasmDebugInfo. We then have to load the reference stack every time
we enter the Interpreter and want access the reference stack.

R=mstarzinger@chromium.org

Bug: chromium:1000610
Change-Id: If8995725f7ec35862b2f99a07582c861027daaf1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1800582
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63953}
2019-09-24 17:20:40 +00:00
Ng Zhi An
bcb31fe4df [wasm-simd] Fix simd 128 load and store memarg reading in interpreter
Add a new test SimdLoadStoreLoadMemargOffset to test this, without this fix
this test would have failed.

Bug: v8:9753
Change-Id: I119adda8e3c6c7adb0ad4023298bbce9c0c64a01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1811457
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63914}
2019-09-20 18:04:29 +00:00
Ng Zhi An
2cf821cc01 [wasm-simd] Implement QFMA and QFMS on x64
Quasi Fused Multiply-Add and Quasi Fused Multiply-Subtract performs, on floats, a + b * c and a - b * c respectively.
When there is only a single rounding, it is a fused operation. Quasi in this case means that the result can either be fused or not fused (two roundings), depending on hardware support.

It is tricky to write the test because we need to calculate the expected value, and there is no easy way to express fused or unfused operation in C++, i.e.
we cannot confirm that float expected = a + b * c will perform a fused or unfused operation (unless we use intrinsics).
Thus in the test we have a list of simple checks, plus interesting values that we know will produce different results depending on whether it was fused or not.

The difference between 32x4 and 64x2 qfma/qfms is the type, and also the values of b and c that will cause an overflow, and thus the intermediate rounding will affect the final result.
The same array can be copy pasted for both types, but with a bit of templating we can avoid that duplication.

Change-Id: I0973a3d28468d25f310b593c72f21bff54d809a7
Bug: v8:9415
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1779325
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63878}
2019-09-18 20:25:07 +00:00
Andreas Haas
e92e8871dd [wasm] Make WasmInterpreterInternals a normal object
For unknown reasons, WasmInterpreterInternals was a zone object. However
WasmInterpreterInternals indirectly owns a global handle and a
unique_ptr, both for the interpreter stack. As a zone object,
WasmInterpreterInternals is never destructed, and therefore never frees
the unique_ptr. With this CL I make WasmInterpreterInternals a normal
object and allocate it into a unique_ptr, so that it gets destructed
properly.

R=mstarzinger@chromium.org

Bug: chromium:1000610
Change-Id: Ie08c5627393a434521f5c32702bf9945db2c7811
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1807361
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63835}
2019-09-17 13:16:52 +00:00
Clemens Hammacher
4d97099c65 [wasm] Prepare for multiple jump tables
This adds logic to choose the closest jump table for each call in wasm
code. The "main jump table" (held in {NativeModule::main_jump_table_})
is still kept though and used for any external or indirect call.
Any direct call from within wasm now chooses the jump table that
corresponds to the code space that the code lives in.

R=mstarzinger@chromium.org

Bug: v8:9477
Change-Id: Ie52b5bb3a4a160cb754b8702c530f6feb182b3a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1800576
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63760}
2019-09-13 15:27:43 +00:00
Ng Zhi An
167ca2e252 [wasm-simd] Fix shifts value to be modulo lane width
Drive by fix of type of expected value in a test

Bug: v8:9626
Change-Id: I1bb44082b873383ea75e7089828bc68c9d4e0df0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1757503
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63727}
2019-09-12 17:37:10 +00:00
Ng Zhi An
134e110211 [wasm-simd] Implement f32x4.sqrt f64x2.sqrt for x64
Implementations for other architectures will follow in subsequent
changes.

Bug: v8:8460
Change-Id: I279388ab76b1d88d65cbe179088be5573c17fc58
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1796317
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63693}
2019-09-11 17:26:32 +00:00
Zhi An Ng
08b9d21461 Revert "[wasm-simd] Implement F64x2ConvertI64x2 for x64"
This reverts commit 306bb635b7.

Reason for revert: Fails on Win64 msvc https://ci.chromium.org/p/v8/builders/ci/V8%20Win64%20-%20msvc/10601

Original change's description:
> [wasm-simd] Implement F64x2ConvertI64x2 for x64
> 
> Bug: v8:8460
> Change-Id: Icefb90c67af77ac93bd75b4e452ba426232de83a
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1710332
> Commit-Queue: Zhi An Ng <zhin@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Reviewed-by: Bill Budge <bbudge@chromium.org>
> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#63627}

TBR=bbudge@chromium.org,mstarzinger@chromium.org,gdeepti@chromium.org,zhin@chromium.org

Change-Id: I3ad568ec01f93e89ccc758170681035413b8414e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8460
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1792232
Reviewed-by: Zhi An Ng <zhin@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63628}
2019-09-09 18:04:14 +00:00
Ng Zhi An
306bb635b7 [wasm-simd] Implement F64x2ConvertI64x2 for x64
Bug: v8:8460
Change-Id: Icefb90c67af77ac93bd75b4e452ba426232de83a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1710332
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63627}
2019-09-09 17:27:13 +00:00
Ng Zhi An
85e2dbb32a [wasm-simd] F32x4Div for ia32 x64 arm arm64
Bug: v8:8460
Change-Id: I529310a35b74964cb034b4c757981c7ec70f1d19
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1765442
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63532}
2019-09-03 17:07:57 +00:00
Ng Zhi An
14f1796f04 Fix opcode lengths for execute and loads for wasm-interpreter
This off-by-1 error surfaces when the load/store opcodes take up 2
bytes, which is the case for v128.load and v128.store SIMD operations.

Bug: v8:9015
Change-Id: Ife17375ed3450a95399b326bc6415dbc3ed3773b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1769480
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63405}
2019-08-26 17:39:52 +00:00
Michael Starzinger
e16775163a [wasm] Preserve identity on {WasmJSFunction} re-export.
This preserves the object identity of a {WebAssembly.Function} instance
that is being re-exported by a module. Such functions are considered to
have an internal [[FunctionAddress]] slot and hence require their object
identity to be preserved (similar to {WasmExportedFunction} already).

R=jkummerow@chromium.org
TEST=mjsunit/wasm/type-reflection
BUG=v8:7742

Change-Id: I88ba75fcd91ce04440008467f3b218a1ac3047db
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1763545
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63346}
2019-08-22 15:00:22 +00:00
Ng Zhi An
238489c623 Implement F64x2Div for x64
This is a reland of
https://chromium-review.googlesource.com/c/v8/v8/+/1749712 with a fix in
test-run-wasm-simd.cc to use base::Divide to work around C++ undefined
behavior when the denominator is 0.

Bug: v8:8460
Change-Id: Ia0a4ff621cccc6d9b7528717bf3fa7c79e42ba1a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1745819
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63198}
2019-08-13 16:50:24 +00:00
Michael Starzinger
bf83f84aaf [wasm] Make {IsJSCompatibleSignature} flag independent.
This makes sure that the above predicate is independent of any global
process-wide state. The state of enabled features is now passed in
explicitly.

R=thibaudm@chromium.org

Change-Id: I5d44e2b0c0843d2e4f26aaf0d58d23afd5943726
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1751348
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63188}
2019-08-13 13:41:07 +00:00
Zhi An Ng
10a1ad25d7 Revert "Implement F64x2Div for x64"
This reverts commit 7cefcded8e.

Reason for revert: ubsan failures, see https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20UBSan/7465

Original change's description:
> Implement F64x2Div for x64
> 
> Bug: v8:8460
> Change-Id: I78cb2badab3f28621f91d6ff5f455967fdcbee44
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1731782
> Reviewed-by: Bill Budge <bbudge@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Commit-Queue: Zhi An Ng <zhin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#63171}

TBR=bbudge@chromium.org,mstarzinger@chromium.org,gdeepti@chromium.org,zhin@chromium.org

Change-Id: I17db933763ba966a2d3f8be58e586b6a61f7995e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8460
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1749712
Reviewed-by: Zhi An Ng <zhin@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63172}
2019-08-12 19:57:59 +00:00
Ng Zhi An
7cefcded8e Implement F64x2Div for x64
Bug: v8:8460
Change-Id: I78cb2badab3f28621f91d6ff5f455967fdcbee44
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1731782
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63171}
2019-08-12 17:12:58 +00:00
Ng Zhi An
e17ac92556 [wasm-simd] Implement F64x2 min max for x64
Also add a IsExtreme(double) overload.
This wasn't causing issues because there was no codepath
which exercised it (only approx operations did).

Change-Id: If7583fb567137c428d16c0d2cdfc37e086f7f3fd
Bug: v8:8460
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1726675
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63053}
2019-08-02 15:44:10 +00:00
Deepti Gandluri
f6a05ec845 [wasm-simd] SIMD shifts should use register instead of immediates
- Add new instruction variants for psllq, psrlq (x64), vshl (ARM)
 - Add instruction selection, code generation for register shifts
 - Remove implicit immediate for shift operators
 - Fix interpreter, tests

Bug:v8:8934, v8:8460

Change-Id: I3481d7ba34a34f7792ff1a61d4a726a1a9abab8d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1722198
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62995}
2019-07-30 19:51:55 +00:00
Ng Zhi An
6aac01f3ff Fix f32x4 min and max in wasm-interpreter
-0.0 and 0.0 compare equals, so a < b ? a : b for min would pick b
incorrectly. We need to use JS semantics here, which returns -0.0.

Bug: v8:8425
Change-Id: I8ab094b566ece9c586de86aad4594dfdf8da930b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1724802
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62969}
2019-07-30 00:32:28 +00:00
Ng Zhi An
8c58e0513e [wasm simd] Implement I64x2 Min and Max on x64
Bug: v8:8460
Change-Id: I913406a4079c766432a56d059a6cb9861fd469bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1703993
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62924}
2019-07-25 18:13:16 +00:00
Ng Zhi An
f9b2f66579 [wasm simd] Implement F64x2 Add Sub Mul on x64
Bug: v8:8460
Change-Id: Ia9b2360c414abedfd9690e97b555c4e9b19fa1b4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1708451
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62922}
2019-07-25 17:05:54 +00:00
Michael Starzinger
4ca8b4dd67 [wasm] Implement "atomic.fence" operator.
This adds decoding and compilation of the "atomic.fence" operator, which
is intended to preserve the synchronization guarantees of higher-level
languages.

Unlike other atomic operators, it does not target a particular linear
memory. It may occur in modules which declare no memory, or a non-shared
memory, without causing a validation error.

See proposal: https://github.com/WebAssembly/threads/pull/141
See discussion: https://github.com/WebAssembly/threads/issues/140

R=clemensh@chromium.org
TEST=cctest/test-run-wasm-atomics/RunWasmXXX_AtomicFence
BUG=v8:9452

Change-Id: Ibf7e46227f7edfe5c81c097cfc15924c59614067
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1701856
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62821}
2019-07-19 09:14:42 +00:00
Ng Zhi An
70f7557ee0 [wasm simd] Implement F64x2Neg on x64
Bug: v8:8460
Change-Id: I3e649e1398be429b8aff5b57316e320f9ca5ae8f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1703763
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62817}
2019-07-19 02:23:00 +00:00