Commit Graph

136 Commits

Author SHA1 Message Date
titzer
82db9dece3 [wasm] Remove legacy encoding of local variables from asm->wasm.
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

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

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

Review-Url: https://codereview.chromium.org/1974933002
Cr-Commit-Position: refs/heads/master@{#36228}
2016-05-13 08:46:40 +00:00
ahaas
481502dad9 [turbofan] Introduce new operators Float32SubPreserveNan and Float64SubPreserveNan for wasm.
The operators are needed because the wasm spec requires that nan bits are preserved.

R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/1973493003
Cr-Commit-Position: refs/heads/master@{#36212}
2016-05-12 14:25:45 +00:00
clemensh
bafa239da0 [wasm] Patch trapping position into stack trace
And add more tests for traps at different locations.

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

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

Review-Url: https://codereview.chromium.org/1970543003
Cr-Commit-Position: refs/heads/master@{#36174}
2016-05-11 12:36:04 +00:00
titzer
f00efdaed5 [wasm] Introduce custom asm.js bytecodes for loads and stores.
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1968943002
Cr-Commit-Position: refs/heads/master@{#36169}
2016-05-11 11:50:55 +00:00
titzer
2973730190 [wasm] Introduce custom asm.js bytecodes for double->int conversions.
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1971693002
Cr-Commit-Position: refs/heads/master@{#36164}
2016-05-11 09:31:50 +00:00
titzer
067a0d6c61 [wasm] Introduce special bytecodes for asm.js division/remainder instead of relying on module state.
R=ahaas@chromium.org, bradnelson@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1968493002
Cr-Commit-Position: refs/heads/master@{#36148}
2016-05-10 17:58:35 +00:00
titzer
86d4a45586 [wasm] Add some tests for control flow corner cases.
R=ahaas@chromium.org,rossberg@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1960143002
Cr-Commit-Position: refs/heads/master@{#36112}
2016-05-09 14:46:40 +00:00
clemensh
a4cd1eef0a [wasm] Make wasm info available on the stack trace
This changes different locations to extract the reference to the wasm
object and the function index from the stack trace, and make it
available through all the APIs which process stack traces.
The javascript CallSite object now has the new methods isWasm(),
getWasmObject() and getWasmFunctionIndex(); the byte offset is
available via getPosition().

Function names of wasm frames should be fully functional with this
commit, position information works reliably for calls, but not for
traps like unreachable or out-of-bounds accesses.

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

Review-Url: https://codereview.chromium.org/1909353002
Cr-Commit-Position: refs/heads/master@{#36067}
2016-05-06 09:07:45 +00:00
ahaas
b6db2255e6 [wasm] Mark all 64-bit instructions as supported on 32-bit platforms.
Additionally I removed some stale comments.

R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/1941323002
Cr-Commit-Position: refs/heads/master@{#35976}
2016-05-03 11:47:59 +00:00
clemensh
0d6d0b700f [wasm] Add tests for function name encoding
In order to have a wasm object (as JSObject), this adds a method to
instantiate the TestingModule. In order for this to work, the bytecode
and the function names of the TestingModule are stored for usage during
instantiation.

R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/1916403002
Cr-Commit-Position: refs/heads/master@{#35906}
2016-04-29 12:43:51 +00:00
clemensh
9fd2650ae0 [wasm] Store function names in the wasm object
We now store the wasm object and the function index in the
deoptimization data of the wasm Code object, and store an array with
function names in the wasm object.

This will make both the wasm module as well as the respective function
name available from the code object.

Tests will follow in https://codereview.chromium.org/1916403002.

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

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

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

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

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

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

Review-Url: https://codereview.chromium.org/1830663002
Cr-Commit-Position: refs/heads/master@{#35896}
2016-04-29 09:16:21 +00:00
mstarzinger
5a54000eda [compiler] Rename OptimizingCompileJob to CompilationJob.
R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/1925743002
Cr-Commit-Position: refs/heads/master@{#35832}
2016-04-27 17:56:16 +00:00
bmeurer
ff19726d80 [turbofan] Enable concurrent (re)compilation.
Refactor the TurboFan pipeline to allow for concurrent recompilation in
the same way that Crankshaft does it. For now we limit the concurrent
phases to scheduling, instruction selection, register allocation and
jump threading.

R=mstarzinger@chromium.org, ahaas@chromium.org, jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35818}
2016-04-27 12:40:00 +00:00
clemensh
af9e4c33ab [wasm] Replace WasmName by Vector<const char>
R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35796}
2016-04-26 14:47:29 +00:00
clemensh
c32b202014 Pass debug name as Vector instead of const char*
This allows to also pass non-null-terminated values, and values containing null
characters. Both might happen in wasm.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35795}
2016-04-26 14:37:05 +00:00
clemensh
91386f0bc0 [wasm] Generate source position information
Annotate call nodes in the TF graph with source code information in the form
of byte offset relative to the wasm function start. The backend finally outputs those positions as RelocInfo.

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

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

Cr-Commit-Position: refs/heads/master@{#35793}
2016-04-26 12:47:09 +00:00
ahaas
b4889f7d93 [wasm] New implementation of popcnt and ctz.
This patch provides a new implementation of popcnt and ctz in the case
where the platform does not provide these instructions. Instead of
building a TF graph which implements it we now call a C function.

Additionally I turned on additional tests in test-run-wasm-64.cc

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35685}
2016-04-21 07:47:05 +00:00
clemensh
ec8e14e697 [wasm] Add a cctest for the stack on a wasm trap
In contrast to the existing cctest, this time the error is not thrown
from javascript, but by a trap in wasm. And in contrast to the mjsunit
tests, this checks the detailed stack trace, not the simple one.

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

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

Cr-Commit-Position: refs/heads/master@{#35665}
2016-04-20 15:10:05 +00:00
clemensh
5c1d28770b [wasm] Add test for detailed stack trace
This cctest triggers a detailed stack trace containing WASM frames.

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

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

Cr-Commit-Position: refs/heads/master@{#35624}
2016-04-19 14:20:43 +00:00
clemensh
3e5f45b64b [wasm] Flag WASM code sections as such in the tests
This makes them show up in the stack trace. Otherwise the stack frames
are identified as type STUB, and skipped by the iterator.

R=ahaas@chromium.org, jfb@chromium.org, titzer@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#35621}
2016-04-19 12:55:02 +00:00
clemensh
09b50113d4 Move two test-internal functions up to header file
... such that they can be reused from other tests.

R=ahaas@chromium.org, jfb@chromium.org, titzer@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#35617}
2016-04-19 12:24:39 +00:00
ahaas
5df9406a07 [arm] Turn off the default NaN mode on arm.
The default NaN mode was originally used to identify holes in double
arrays. With (https://codereview.chromium.org/863633002/) signalling
NaNs are used for that, and the default NaN mode is not needed anymore.
Without the default NaN mode it is easier to satisfy the WebAssembly
spec which requires that quiet NaNs are preserved.

R=titzer@chromium.org, rodolph.perfetta@arm.com, bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35526}
2016-04-15 12:45:27 +00:00
ahaas
2f9eb09f20 [arm64] Turn off the default NaN mode on arm64.
The default NaN mode was originally used to identify holes in double
arrays. With (https://codereview.chromium.org/863633002/) signalling
NaNs are used for that, and the default NaN mode is not needed anymore.
Without the default NaN mode it is easier to satisfy the WebAssembly
spec which requires that quiet NaNs are preserved.

R=titzer@chromium.org, rodolph.perfetta@arm.com, bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35518}
2016-04-15 11:52:04 +00:00
marija.antic
4b86e6e321 MIPS: [wasm] Lowering of Int64Shl, Int64Shr, Int64Sar, Int64Add and Int64Sub.
Implementation of turbofan operators Word32PairShl, Word32PairShr,
Word32PairSar, Int32AddPair and Int32SubPair for MIPS.

Port of:
https://codereview.chromium.org/1765973002/
https://codereview.chromium.org/1778893004/
https://codereview.chromium.org/1778493004/
https://codereview.chromium.org/1778893005/
https://codereview.chromium.org/1842013002/

Added tests for Word32PairShr and Word32PairSar in test-run-machops.cc.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#35307}
2016-04-06 14:45:30 +00:00
titzer
45d75bca5c [turbofan] Handle dead diamonds in scheduling and add a test.
The background here is that graphs generated from WASM are not trimmed.
That means there can be some floating control diamonds that are not
reachable from end. An assertion in the scheduler for phis from floating
diamonds checks that the use edge in this situation is the control edge,
but in general, any edge could cause this.

Scheduling still works without this assertion. The longer term fix
is to either trim the graphs (more compile time overhead for WASM)
or improve the scheduler's handling of dead code in the graph. Currently
it does not schedule dead code but the potential use positions of
dead code are used in the computation of the common dominator of uses. We could
recognize dead nodes in PrepareUses() and check in GetBlockForUse()
as per TODO.

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

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

Cr-Commit-Position: refs/heads/master@{#35245}
2016-04-04 17:45:59 +00:00
ivica.bogosavljevic
114c109a32 MIPS: Fix Run_Wasm_F32CopySign.
Run_Wasm_F32CopySign was failing because function copysign
that is used to verify the results does implicit conversion
from float to double. In this conversion we lose information
about NaN sign and the test fails.

Fix by using copysignf to avoid unnecessary float to double
conversion.

TEST=cctest/test-run-wasm/Run_Wasm_F32CopySign
BUG=

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

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

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

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

Cr-Commit-Position: refs/heads/master@{#35196}
2016-04-01 10:01:56 +00:00
ahaas
3ffee875ef Fixed rotate left on windows.
R=titzer@chromium.org, bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35195}
2016-04-01 09:52:13 +00:00
ahaas
ac7f0e2b61 [wasm] Fixed float-to-int conversion tests.
*) For all tests the input validation was incorrect, i.e. some values
were considered invalid although they were valid. The problem was that
values which are outside int range can get in range through truncation.

*) Removed an assertion in the x64 code generation of
TruncateFloat64ToUint32 which trapped on negative inputs.

*) Introduced a new TF operator TruncateFloat32ToUint32 which does
the same as ChangeFloat32ToUint32 but does not trap on negative inputs.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35176}
2016-03-31 18:38:36 +00:00
ahaas
bd4fb28ecd [wasm] Int64Lowering of Word64Ror and Word64Rol.
R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35173}
2016-03-31 17:05:43 +00:00
titzer
08e0ea38cd [wasm] Fix and enable more tests.
R=ahaas@chromium.org, bradnelson@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#35156}
2016-03-31 09:20:21 +00:00
titzer
d167c3743d [wasm] Mask shift counts on architectures that don't implicitly mask.
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#35136}
2016-03-30 12:40:22 +00:00
titzer
257bdfe543 [wasm] Fix asm.js semantics for divide by zero in WASM translation.
R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#35134}
2016-03-30 11:37:44 +00:00
ahaas
40bdbef975 [wasm] Int64Lowering of Int64Mul on ia32 and arm.
Int64Mul is lowered to a new turbofan operator, Int32MulPair. The new
operator takes 4 inputs an generates 2 outputs. The inputs are the low
word of the left input, high word of the left input, the low word of the
right input, and high word of the right input. The ouputs are the low
and high word of the result of the multiplication.

R=titzer@chromium.org, v8-arm-ports@googlegroups.com

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

Cr-Commit-Position: refs/heads/master@{#35131}
2016-03-30 10:40:06 +00:00
ahaas
682df6dd33 [wasm] New attempt to implement the Int64Lowering of phis.
The new implementation deals with cycles in the TF graph in two steps:
1) The lowering of phis is delayed to avoid cyclic dependencies.
2) The replacement nodes of phis are created already when the phi is
   pushed onto the stack so that other nodes can use these replacements
   for their lowering.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35126}
2016-03-30 08:14:35 +00:00
titzer
c9f59780f7 [wasm] Fix arm64 frame alignment.
In JavaScript code and stubs, JSSP mirrors the CSP but may be unaligned.
    But in WASM code only CSP is used, like native code, and it must be
    aligned.
    Calls into WASM from JS need to carefully align the C stack
    pointer (csp) and restore the previous JSSP, while calls from WASM
    to JS need to compute a new JSSP and restore their CSP after the
    call.

R=ahaas@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#35096}
2016-03-29 11:42:48 +00:00
ahaas
122862f6e9 [wasm] Turn on tests for float-to-int conversion in test-run-wasm-64.
R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34854}
2016-03-17 12:39:25 +00:00
zhengxing.li
43f65e89f2 X87: Change the test case for X87 Run_WasmF32SConvertI64/Run_WasmF64SConvertI64.
The CL #34701 (https://codereview.chromium.org/1779123002/) added the Run_WasmF32SConvertI64/Run_WasmF64SConvertI64 test cases and X87 failed at them.

  The reason is same as the CL #33630 (Issue 1649323002: X87: Change the test case for X87 RunRoundInt32ToFloat32), please refer: https://codereview.chromium.org/1649323002.

  Here is the key comments from CL #33630:
  Some new test cases use CheckFloatEq(...) and CheckDoubleEq(...) function for result check. When GCC compiling the CheckFloatEq() and CheckDoubleEq() function,
  those inlined functions has different behavior comparing with GCC ia32 build and x87 build.
  The major difference is sse float register still has single precision rounding semantic. While X87 register has no such rounding precsion semantic when directly use register value.
  The V8 turbofan JITTed has exactly same result in both X87 and IA32 port.

  For CHECK_EQ(a, b) function, if a and b are double or float, it will has similar behaviors like CheckFloatEq(...) and CheckDoubleEq(...) function when compiled by GCC and causes the test case fail.

  So we add the following sentence to do type case to keep the same precision for Run_WasmF32SConvertI64/Run_WasmF64SConvertI64. Such as: volatile double expect = static_cast<float>(*i).

  ahaas put those codes in CHECK_FLOAT_EQ and CHECK_DOUBLE_EQ macros in CL #34534 (https://codereview.chromium.org/1773513002 ).

  So this CL replaced the CHECK_EQ in Run_WasmF32SConvertI64/Run_WasmF64SConvertI64 to CHECK_FLOAT_EQ/CHECK_DOUBLE_EQ for x87 can pass Run_WasmF32SConvertI64/Run_WasmF64SConvertI64 tests.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#34813}
2016-03-16 13:14:21 +00:00
ahaas
7f19628a5b [wasm] Int64Lowering of Word64Ctz.
R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34811}
2016-03-16 12:16:00 +00:00
ahaas
5c16cac96d [wasm] Int64Lowering of Word64Clz.
R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34809}
2016-03-16 11:03:07 +00:00
ahaas
33c08596e1 [wasm] Int64Lowering of Int64Sub on ia32 and arm.
Int64Sub is lowered to a new turbofan operator, Int32SubPair. The new
operator takes 4 inputs an generates 2 outputs. The inputs are the low
word of the left input, high word of the left input, the low word of the
right input, and high word of the right input. The ouputs are the low
and high word of the result of the subtraction.

The implementation is very similar to the implementation of Int64Add.

@v8-arm-ports: please take a careful look at the implementation of sbc
in the simulator.

R=titzer@chromium.org, v8-arm-ports@googlegroups.com

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

Cr-Commit-Position: refs/heads/master@{#34808}
2016-03-16 10:58:05 +00:00
ahaas
ccbf004293 [wasm] Int64Lowering of F64ReinterpretI64.
The implementation is done by storing to and then loading from memory.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34785}
2016-03-15 12:46:51 +00:00
ahaas
b484cc12f3 [wasm] Int64Lowering of I64ReinterpretF64.
The implementation is done by storing to and loading from memory.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34784}
2016-03-15 12:18:12 +00:00
ahaas
3a2cc90cb4 [wasm] Turn off tests for mips and x87.
The tests require the implementation of Int32PairAdd and Word32PairShl.

R=titzer@chromium.org, v8-mips-ports@googlegroups.com

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

Cr-Commit-Position: refs/heads/master@{#34782}
2016-03-15 11:04:47 +00:00
ahaas
2e6f3e8607 [wasm] Int64Lowering of Word64Popcnt.
Word64Popcnt is lowered to Word32Popcnt(low-word) + Word32Popcnt(high_word).
Since the optional Word64Popcnt operator does not exist on 32 bit platforms,
I introduced a new operator "Word64PopcntPlaceholder" which is generated
in the WasmCompiler and then lowered in the Int64Lowering.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34777}
2016-03-15 10:42:08 +00:00
ahaas
049341f054 [wasm] Implementation of Word32PairShr and Word32PairSar on arm.
Implementation of https://codereview.chromium.org/1768233002 on arm.

R=titzer@chromium.org, v8-arm-ports@googlegroups.com

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

Cr-Commit-Position: refs/heads/master@{#34769}
2016-03-15 07:17:38 +00:00