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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 let kResizableMaximumFlag = 1; | 71 let kResizableMaximumFlag = 1; |
72 | 72 |
73 // Function declaration flags | 73 // Function declaration flags |
74 let kDeclFunctionName = 0x01; | 74 let kDeclFunctionName = 0x01; |
75 let kDeclFunctionImport = 0x02; | 75 let kDeclFunctionImport = 0x02; |
76 let kDeclFunctionLocals = 0x04; | 76 let kDeclFunctionLocals = 0x04; |
77 let kDeclFunctionExport = 0x08; | 77 let kDeclFunctionExport = 0x08; |
78 | 78 |
79 // Local types | 79 // Local types |
80 let kAstStmt = 0x40; | 80 let kWasmStmt = 0x40; |
81 let kAstI32 = 0x7f; | 81 let kWasmI32 = 0x7f; |
82 let kAstI64 = 0x7e; | 82 let kWasmI64 = 0x7e; |
83 let kAstF32 = 0x7d; | 83 let kWasmF32 = 0x7d; |
84 let kAstF64 = 0x7c; | 84 let kWasmF64 = 0x7c; |
85 let kAstS128 = 0x7b; | 85 let kWasmS128 = 0x7b; |
86 | 86 |
87 let kExternalFunction = 0; | 87 let kExternalFunction = 0; |
88 let kExternalTable = 1; | 88 let kExternalTable = 1; |
89 let kExternalMemory = 2; | 89 let kExternalMemory = 2; |
90 let kExternalGlobal = 3; | 90 let kExternalGlobal = 3; |
91 | 91 |
92 let kTableZero = 0; | 92 let kTableZero = 0; |
93 let kMemoryZero = 0; | 93 let kMemoryZero = 0; |
94 | 94 |
95 // Useful signatures | 95 // Useful signatures |
96 let kSig_i_i = makeSig([kAstI32], [kAstI32]); | 96 let kSig_i_i = makeSig([kWasmI32], [kWasmI32]); |
97 let kSig_l_l = makeSig([kAstI64], [kAstI64]); | 97 let kSig_l_l = makeSig([kWasmI64], [kWasmI64]); |
98 let kSig_i_l = makeSig([kAstI64], [kAstI32]); | 98 let kSig_i_l = makeSig([kWasmI64], [kWasmI32]); |
99 let kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]); | 99 let kSig_i_ii = makeSig([kWasmI32, kWasmI32], [kWasmI32]); |
100 let kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]); | 100 let kSig_i_iii = makeSig([kWasmI32, kWasmI32, kWasmI32], [kWasmI32]); |
101 let kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); | 101 let kSig_d_dd = makeSig([kWasmF64, kWasmF64], [kWasmF64]); |
102 let kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); | 102 let kSig_l_ll = makeSig([kWasmI64, kWasmI64], [kWasmI64]); |
103 let kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); | 103 let kSig_i_dd = makeSig([kWasmF64, kWasmF64], [kWasmI32]); |
104 let kSig_v_v = makeSig([], []); | 104 let kSig_v_v = makeSig([], []); |
105 let kSig_i_v = makeSig([], [kAstI32]); | 105 let kSig_i_v = makeSig([], [kWasmI32]); |
106 let kSig_l_v = makeSig([], [kAstI64]); | 106 let kSig_l_v = makeSig([], [kWasmI64]); |
107 let kSig_f_v = makeSig([], [kAstF64]); | 107 let kSig_f_v = makeSig([], [kWasmF64]); |
108 let kSig_d_v = makeSig([], [kAstF64]); | 108 let kSig_d_v = makeSig([], [kWasmF64]); |
109 let kSig_v_i = makeSig([kAstI32], []); | 109 let kSig_v_i = makeSig([kWasmI32], []); |
110 let kSig_v_ii = makeSig([kAstI32, kAstI32], []); | 110 let kSig_v_ii = makeSig([kWasmI32, kWasmI32], []); |
111 let kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []); | 111 let kSig_v_iii = makeSig([kWasmI32, kWasmI32, kWasmI32], []); |
112 let kSig_v_l = makeSig([kAstI64], []); | 112 let kSig_v_l = makeSig([kWasmI64], []); |
113 let kSig_v_d = makeSig([kAstF64], []); | 113 let kSig_v_d = makeSig([kWasmF64], []); |
114 let kSig_v_dd = makeSig([kAstF64, kAstF64], []); | 114 let kSig_v_dd = makeSig([kWasmF64, kWasmF64], []); |
115 let kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []); | 115 let kSig_v_ddi = makeSig([kWasmF64, kWasmF64, kWasmI32], []); |
116 let kSig_s_v = makeSig([], [kAstS128]); | 116 let kSig_s_v = makeSig([], [kWasmS128]); |
117 | 117 |
118 function makeSig(params, results) { | 118 function makeSig(params, results) { |
119 return {params: params, results: results}; | 119 return {params: params, results: results}; |
120 } | 120 } |
121 | 121 |
122 function makeSig_v_x(x) { | 122 function makeSig_v_x(x) { |
123 return makeSig([x], []); | 123 return makeSig([x], []); |
124 } | 124 } |
125 | 125 |
126 function makeSig_v_xx(x) { | 126 function makeSig_v_xx(x) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 eval(code); | 366 eval(code); |
367 } | 367 } |
368 } catch (e) { | 368 } catch (e) { |
369 assertEquals("number", typeof e); | 369 assertEquals("number", typeof e); |
370 assertEquals(value, e); | 370 assertEquals(value, e); |
371 // Success. | 371 // Success. |
372 return; | 372 return; |
373 } | 373 } |
374 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); | 374 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); |
375 } | 375 } |
OLD | NEW |