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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 var kDeclFunctionImport = 0x02; | 75 var kDeclFunctionImport = 0x02; |
76 var kDeclFunctionLocals = 0x04; | 76 var kDeclFunctionLocals = 0x04; |
77 var kDeclFunctionExport = 0x08; | 77 var kDeclFunctionExport = 0x08; |
78 | 78 |
79 // Local types | 79 // Local types |
80 var kAstStmt = 0; | 80 var kAstStmt = 0; |
81 var kAstI32 = 1; | 81 var kAstI32 = 1; |
82 var kAstI64 = 2; | 82 var kAstI64 = 2; |
83 var kAstF32 = 3; | 83 var kAstF32 = 3; |
84 var kAstF64 = 4; | 84 var kAstF64 = 4; |
| 85 var kAstS128 = 5; |
85 | 86 |
86 var kExternalFunction = 0; | 87 var kExternalFunction = 0; |
87 var kExternalTable = 1; | 88 var kExternalTable = 1; |
88 var kExternalMemory = 2; | 89 var kExternalMemory = 2; |
89 var kExternalGlobal = 3; | 90 var kExternalGlobal = 3; |
90 | 91 |
91 // Useful signatures | 92 // Useful signatures |
92 var kSig_i_i = makeSig([kAstI32], [kAstI32]); | 93 var kSig_i_i = makeSig([kAstI32], [kAstI32]); |
93 var kSig_i_l = makeSig([kAstI64], [kAstI32]); | 94 var kSig_i_l = makeSig([kAstI64], [kAstI32]); |
94 var kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]); | 95 var kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]); |
95 var kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]); | 96 var kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]); |
96 var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); | 97 var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); |
97 var kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); | 98 var kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); |
98 var kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); | 99 var kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); |
99 var kSig_v_v = makeSig([], []); | 100 var kSig_v_v = makeSig([], []); |
100 var kSig_i_v = makeSig([], [kAstI32]); | 101 var kSig_i_v = makeSig([], [kAstI32]); |
101 var kSig_f_v = makeSig([], [kAstF64]); | 102 var kSig_f_v = makeSig([], [kAstF64]); |
102 var kSig_d_v = makeSig([], [kAstF64]); | 103 var kSig_d_v = makeSig([], [kAstF64]); |
103 var kSig_v_i = makeSig([kAstI32], []); | 104 var kSig_v_i = makeSig([kAstI32], []); |
104 var kSig_v_ii = makeSig([kAstI32, kAstI32], []); | 105 var kSig_v_ii = makeSig([kAstI32, kAstI32], []); |
105 var kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []); | 106 var kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []); |
106 var kSig_v_d = makeSig([kAstF64], []); | 107 var kSig_v_d = makeSig([kAstF64], []); |
107 var kSig_v_dd = makeSig([kAstF64, kAstF64], []); | 108 var kSig_v_dd = makeSig([kAstF64, kAstF64], []); |
108 var kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []); | 109 var kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []); |
| 110 var kSig_s_v = makeSig([], [kAstS128]); |
109 | 111 |
110 function makeSig(params, results) { | 112 function makeSig(params, results) { |
111 return {params: params, results: results}; | 113 return {params: params, results: results}; |
112 } | 114 } |
113 | 115 |
114 function makeSig_v_x(x) { | 116 function makeSig_v_x(x) { |
115 return makeSig([x], []); | 117 return makeSig([x], []); |
116 } | 118 } |
117 | 119 |
118 function makeSig_v_xx(x) { | 120 function makeSig_v_xx(x) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 eval(code); | 364 eval(code); |
363 } | 365 } |
364 } catch (e) { | 366 } catch (e) { |
365 assertEquals("number", typeof e); | 367 assertEquals("number", typeof e); |
366 assertEquals(value, e); | 368 assertEquals(value, e); |
367 // Success. | 369 // Success. |
368 return; | 370 return; |
369 } | 371 } |
370 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); | 372 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); |
371 } | 373 } |
OLD | NEW |