OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 | 5 // Flags: --expose-wasm |
6 | 6 |
7 function bytes() { | 7 function bytes() { |
8 var buffer = new ArrayBuffer(arguments.length); | 8 var buffer = new ArrayBuffer(arguments.length); |
9 var view = new Uint8Array(buffer); | 9 var view = new Uint8Array(buffer); |
10 for (var i = 0; i < arguments.length; i++) { | 10 for (var i = 0; i < arguments.length; i++) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); | 99 var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); |
100 var kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); | 100 var kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); |
101 var kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); | 101 var kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); |
102 var kSig_v_v = makeSig([], []); | 102 var kSig_v_v = makeSig([], []); |
103 var kSig_i_v = makeSig([], [kAstI32]); | 103 var kSig_i_v = makeSig([], [kAstI32]); |
104 var kSig_v_i = makeSig([kAstI32], []); | 104 var kSig_v_i = makeSig([kAstI32], []); |
105 var kSig_v_ii = makeSig([kAstI32, kAstI32], []); | 105 var kSig_v_ii = makeSig([kAstI32, kAstI32], []); |
106 var kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []); | 106 var kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []); |
107 var kSig_v_d = makeSig([kAstF64], []); | 107 var kSig_v_d = makeSig([kAstF64], []); |
108 var kSig_v_dd = makeSig([kAstF64, kAstF64], []); | 108 var kSig_v_dd = makeSig([kAstF64, kAstF64], []); |
| 109 var kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []); |
109 | 110 |
110 function makeSig(params, results) { | 111 function makeSig(params, results) { |
111 return {params: params, results: results}; | 112 return {params: params, results: results}; |
112 } | 113 } |
113 | 114 |
114 function makeSig_v_x(x) { | 115 function makeSig_v_x(x) { |
115 return makeSig([x], []); | 116 return makeSig([x], []); |
116 } | 117 } |
117 | 118 |
118 function makeSig_v_xx(x) { | 119 function makeSig_v_xx(x) { |
(...skipping 17 matching lines...) Expand all Loading... |
136 var kExprBlock = 0x01; | 137 var kExprBlock = 0x01; |
137 var kExprLoop = 0x02; | 138 var kExprLoop = 0x02; |
138 var kExprIf = 0x03; | 139 var kExprIf = 0x03; |
139 var kExprElse = 0x04; | 140 var kExprElse = 0x04; |
140 var kExprSelect = 0x05; | 141 var kExprSelect = 0x05; |
141 var kExprBr = 0x06; | 142 var kExprBr = 0x06; |
142 var kExprBrIf = 0x07; | 143 var kExprBrIf = 0x07; |
143 var kExprBrTable = 0x08; | 144 var kExprBrTable = 0x08; |
144 var kExprReturn = 0x09; | 145 var kExprReturn = 0x09; |
145 var kExprUnreachable = 0x0a; | 146 var kExprUnreachable = 0x0a; |
| 147 var kExprThrow = 0xfa; |
146 var kExprEnd = 0x0f; | 148 var kExprEnd = 0x0f; |
147 | 149 |
148 var kExprI32Const = 0x10; | 150 var kExprI32Const = 0x10; |
149 var kExprI64Const = 0x11; | 151 var kExprI64Const = 0x11; |
150 var kExprF64Const = 0x12; | 152 var kExprF64Const = 0x12; |
151 var kExprF32Const = 0x13; | 153 var kExprF32Const = 0x13; |
152 var kExprGetLocal = 0x14; | 154 var kExprGetLocal = 0x14; |
153 var kExprSetLocal = 0x15; | 155 var kExprSetLocal = 0x15; |
154 var kExprCallFunction = 0x16; | 156 var kExprCallFunction = 0x16; |
155 var kExprCallIndirect = 0x17; | 157 var kExprCallIndirect = 0x17; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 343 } |
342 threwException = false; | 344 threwException = false; |
343 } catch (e) { | 345 } catch (e) { |
344 assertEquals("object", typeof e); | 346 assertEquals("object", typeof e); |
345 assertEquals(kTrapMsgs[trap], e.message); | 347 assertEquals(kTrapMsgs[trap], e.message); |
346 // Success. | 348 // Success. |
347 return; | 349 return; |
348 } | 350 } |
349 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap]
); | 351 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap]
); |
350 } | 352 } |
| 353 |
| 354 function assertWasmThrows(value, code) { |
| 355 assertEquals("number", typeof(value)); |
| 356 try { |
| 357 if (typeof code === 'function') { |
| 358 code(); |
| 359 } else { |
| 360 eval(code); |
| 361 } |
| 362 } catch (e) { |
| 363 assertEquals("number", typeof e); |
| 364 assertEquals(value, e); |
| 365 // Success. |
| 366 return; |
| 367 } |
| 368 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); |
| 369 } |
OLD | NEW |