OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm --expose-gc | 5 // Flags: --expose-wasm --expose-gc |
6 | 6 |
7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
9 | 9 |
10 function makeFFI(func, t) { | 10 function makeFFI(func, t) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 function print10(a, b, c, d, e, f, g, h, i) { | 50 function print10(a, b, c, d, e, f, g, h, i) { |
51 print(a + ",", b + ",", c + ",", d + ",", e + ",", f + ",", g + ",", h + ",",
i); | 51 print(a + ",", b + ",", c + ",", d + ",", e + ",", f + ",", g + ",", h + ",",
i); |
52 gc(); | 52 gc(); |
53 print(a + ",", b + ",", c + ",", d + ",", e + ",", f + ",", g + ",", h + ",",
i); | 53 print(a + ",", b + ",", c + ",", d + ",", e + ",", f + ",", g + ",", h + ",",
i); |
54 } | 54 } |
55 | 55 |
56 (function I32Test() { | 56 (function I32Test() { |
57 var main = makeFFI(print10, kAstI32); | 57 var main = makeFFI(print10, kWasmI32); |
58 for (var i = 1; i < 0xFFFFFFF; i <<= 2) { | 58 for (var i = 1; i < 0xFFFFFFF; i <<= 2) { |
59 main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8); | 59 main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8); |
60 } | 60 } |
61 })(); | 61 })(); |
62 | 62 |
63 (function F32Test() { | 63 (function F32Test() { |
64 var main = makeFFI(print10, kAstF32); | 64 var main = makeFFI(print10, kWasmF32); |
65 for (var i = 1; i < 2e+30; i *= -157) { | 65 for (var i = 1; i < 2e+30; i *= -157) { |
66 main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8); | 66 main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8); |
67 } | 67 } |
68 })(); | 68 })(); |
69 | 69 |
70 (function F64Test() { | 70 (function F64Test() { |
71 var main = makeFFI(print10, kAstF64); | 71 var main = makeFFI(print10, kWasmF64); |
72 for (var i = 1; i < 2e+80; i *= -1137) { | 72 for (var i = 1; i < 2e+80; i *= -1137) { |
73 main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8); | 73 main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8); |
74 } | 74 } |
75 })(); | 75 })(); |
76 | 76 |
77 (function GCInJSToWasmTest() { | 77 (function GCInJSToWasmTest() { |
78 var builder = new WasmModuleBuilder(); | 78 var builder = new WasmModuleBuilder(); |
79 | 79 |
80 var sig_index = builder.addType(kSig_i_i); | 80 var sig_index = builder.addType(kSig_i_i); |
81 builder.addFunction("main", sig_index) | 81 builder.addFunction("main", sig_index) |
82 .addBody([ | 82 .addBody([ |
83 kExprGetLocal, 0, // -- | 83 kExprGetLocal, 0, // -- |
84 ]) // -- | 84 ]) // -- |
85 .exportFunc(); | 85 .exportFunc(); |
86 | 86 |
87 var main = builder.instantiate({}).exports.main; | 87 var main = builder.instantiate({}).exports.main; |
88 | 88 |
89 var gc_object = { | 89 var gc_object = { |
90 valueOf: function() { | 90 valueOf: function() { |
91 // Call the GC in valueOf, which is called within the JSToWasm wrapper. | 91 // Call the GC in valueOf, which is called within the JSToWasm wrapper. |
92 gc(); | 92 gc(); |
93 return {}; | 93 return {}; |
94 } | 94 } |
95 }; | 95 }; |
96 | 96 |
97 main(gc_object); | 97 main(gc_object); |
98 })(); | 98 })(); |
OLD | NEW |