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++) { |
11 var val = arguments[i]; | 11 var val = arguments[i]; |
12 if ((typeof val) == "string") val = val.charCodeAt(0); | 12 if ((typeof val) == "string") val = val.charCodeAt(0); |
13 view[i] = val | 0; | 13 view[i] = val | 0; |
14 } | 14 } |
15 return buffer; | 15 return buffer; |
16 } | 16 } |
17 | 17 |
18 // Section declaration constants | 18 // Section declaration constants |
19 var kDeclMemory = 0x00; | 19 var kDeclMemory = 0x00; |
20 var kDeclSignatures = 0x01; | 20 var kDeclSignatures = 0x01; |
21 var kDeclFunctions = 0x02; | 21 var kDeclFunctions = 0x02; |
22 var kDeclGlobals = 0x03; | 22 var kDeclGlobals = 0x03; |
23 var kDeclDataSegments = 0x04; | 23 var kDeclDataSegments = 0x04; |
24 var kDeclFunctionTable = 0x05; | 24 var kDeclFunctionTable = 0x05; |
25 var kDeclStartFunction = 0x07; | 25 var kDeclStartFunction = 0x07; |
| 26 var kDeclImportTable = 0x08; |
26 var kDeclEnd = 0x06; | 27 var kDeclEnd = 0x06; |
27 | 28 |
28 // Function declaration flags | 29 // Function declaration flags |
29 var kDeclFunctionName = 0x01; | 30 var kDeclFunctionName = 0x01; |
30 var kDeclFunctionImport = 0x02; | 31 var kDeclFunctionImport = 0x02; |
31 var kDeclFunctionLocals = 0x04; | 32 var kDeclFunctionLocals = 0x04; |
32 var kDeclFunctionExport = 0x08; | 33 var kDeclFunctionExport = 0x08; |
33 | 34 |
34 // Local types | 35 // Local types |
35 var kAstStmt = 0; | 36 var kAstStmt = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
55 var kExprI32Const = 0x0a; | 56 var kExprI32Const = 0x0a; |
56 var kExprI64Const = 0x0b; | 57 var kExprI64Const = 0x0b; |
57 var kExprF64Const = 0x0c; | 58 var kExprF64Const = 0x0c; |
58 var kExprF32Const = 0x0d; | 59 var kExprF32Const = 0x0d; |
59 var kExprGetLocal = 0x0e; | 60 var kExprGetLocal = 0x0e; |
60 var kExprSetLocal = 0x0f; | 61 var kExprSetLocal = 0x0f; |
61 var kExprLoadGlobal = 0x10; | 62 var kExprLoadGlobal = 0x10; |
62 var kExprStoreGlobal = 0x11; | 63 var kExprStoreGlobal = 0x11; |
63 var kExprCallFunction = 0x12; | 64 var kExprCallFunction = 0x12; |
64 var kExprCallIndirect = 0x13; | 65 var kExprCallIndirect = 0x13; |
| 66 var kExprCallImport = 0x1F; |
65 | 67 |
66 var kExprI32LoadMem8S = 0x20; | 68 var kExprI32LoadMem8S = 0x20; |
67 var kExprI32LoadMem8U = 0x21; | 69 var kExprI32LoadMem8U = 0x21; |
68 var kExprI32LoadMem16S = 0x22; | 70 var kExprI32LoadMem16S = 0x22; |
69 var kExprI32LoadMem16U = 0x23; | 71 var kExprI32LoadMem16U = 0x23; |
70 var kExprI64LoadMem8S = 0x24; | 72 var kExprI64LoadMem8S = 0x24; |
71 var kExprI64LoadMem8U = 0x25; | 73 var kExprI64LoadMem8U = 0x25; |
72 var kExprI64LoadMem16S = 0x26; | 74 var kExprI64LoadMem16S = 0x26; |
73 var kExprI64LoadMem16U = 0x27; | 75 var kExprI64LoadMem16U = 0x27; |
74 var kExprI64LoadMem32S = 0x28; | 76 var kExprI64LoadMem32S = 0x28; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 242 } |
241 threwException = false; | 243 threwException = false; |
242 } catch (e) { | 244 } catch (e) { |
243 assertEquals("string", typeof e); | 245 assertEquals("string", typeof e); |
244 assertEquals(kTrapMsgs[trap], e); | 246 assertEquals(kTrapMsgs[trap], e); |
245 // Success. | 247 // Success. |
246 return; | 248 return; |
247 } | 249 } |
248 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap]
); | 250 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap]
); |
249 } | 251 } |
OLD | NEW |