Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: test/mjsunit/wasm/wasm-constants.js

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/wasm/verify-function-simple.js ('k') | test/mjsunit/wasm/wasm-module-builder.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Header declaration constants 18 // Header declaration constants
19 var kWasmH0 = 0; 19 var kWasmH0 = 0;
20 var kWasmH1 = 0x61; 20 var kWasmH1 = 0x61;
21 var kWasmH2 = 0x73; 21 var kWasmH2 = 0x73;
22 var kWasmH3 = 0x6d; 22 var kWasmH3 = 0x6d;
23 23
24 var kWasmV0 = 11; 24 var kWasmV0 = 0xC;
25 var kWasmV1 = 0; 25 var kWasmV1 = 0;
26 var kWasmV2 = 0; 26 var kWasmV2 = 0;
27 var kWasmV3 = 0; 27 var kWasmV3 = 0;
28 28
29 var kHeaderSize = 8; 29 var kHeaderSize = 8;
30 var kPageSize = 65536; 30 var kPageSize = 65536;
31 31
32 function bytesWithHeader() { 32 function bytesWithHeader() {
33 var buffer = new ArrayBuffer(kHeaderSize + arguments.length); 33 var buffer = new ArrayBuffer(kHeaderSize + arguments.length);
34 var view = new Uint8Array(buffer); 34 var view = new Uint8Array(buffer);
35 view[0] = kWasmH0; 35 view[0] = kWasmH0;
36 view[1] = kWasmH1; 36 view[1] = kWasmH1;
37 view[2] = kWasmH2; 37 view[2] = kWasmH2;
38 view[3] = kWasmH3; 38 view[3] = kWasmH3;
39 view[4] = kWasmV0; 39 view[4] = kWasmV0;
40 view[5] = kWasmV1; 40 view[5] = kWasmV1;
41 view[6] = kWasmV2; 41 view[6] = kWasmV2;
42 view[7] = kWasmV3; 42 view[7] = kWasmV3;
43 for (var i = 0; i < arguments.length; i++) { 43 for (var i = 0; i < arguments.length; i++) {
44 var val = arguments[i]; 44 var val = arguments[i];
45 if ((typeof val) == "string") val = val.charCodeAt(0); 45 if ((typeof val) == "string") val = val.charCodeAt(0);
46 view[kHeaderSize + i] = val | 0; 46 view[kHeaderSize + i] = val | 0;
47 } 47 }
48 return buffer; 48 return buffer;
49 } 49 }
50 50
51 var kDeclNoLocals = 0; 51 var kDeclNoLocals = 0;
52 52
53 // Section declaration constants 53 // Section declaration constants
54 var kDeclMemory = 0x00; 54 var kUnknownSectionCode = 0;
55 var kDeclTypes = 0x01; 55 var kTypeSectionCode = 1; // Function signature declarations
56 var kDeclFunctions = 0x02; 56 var kImportSectionCode = 2; // Import declarations
57 var kDeclGlobals = 0x03; 57 var kFunctionSectionCode = 3; // Function declarations
58 var kDeclData = 0x04; 58 var kTableSectionCode = 4; // Indirect function table and other tables
59 var kDeclTable = 0x05; 59 var kMemorySectionCode = 5; // Memory attributes
60 var kDeclEnd = 0x06; 60 var kGlobalSectionCode = 6; // Global declarations
61 var kDeclStart = 0x07; 61 var kExportSectionCode = 7; // Exports
62 var kDeclImports = 0x08; 62 var kStartSectionCode = 8; // Start function declaration
63 var kDeclExports = 0x09; 63 var kElementSectionCode = 9; // Elements section
64 var kDeclFunctions = 0x0a; 64 var kCodeSectionCode = 10; // Function code
65 var kDeclCode = 0x0b; 65 var kDataSectionCode = 11; // Data segments
66 var kDeclNames = 0x0c; 66 var kNameSectionCode = 12; // Name section (encoded as string)
67 67
68 var kArity0 = 0;
69 var kArity1 = 1;
70 var kArity2 = 2;
71 var kArity3 = 3;
72 var kWasmFunctionTypeForm = 0x40; 68 var kWasmFunctionTypeForm = 0x40;
69 var kWasmAnyFunctionTypeForm = 0x20;
73 70
74 var section_names = [ 71 var kResizableMaximumFlag = 1;
75 "memory", "type", "old_function", "global", "data",
76 "table", "end", "start", "import", "export",
77 "function", "code", "name"];
78 72
79 // Function declaration flags 73 // Function declaration flags
80 var kDeclFunctionName = 0x01; 74 var kDeclFunctionName = 0x01;
81 var kDeclFunctionImport = 0x02; 75 var kDeclFunctionImport = 0x02;
82 var kDeclFunctionLocals = 0x04; 76 var kDeclFunctionLocals = 0x04;
83 var kDeclFunctionExport = 0x08; 77 var kDeclFunctionExport = 0x08;
84 78
85 // Local types 79 // Local types
86 var kAstStmt = 0; 80 var kAstStmt = 0;
87 var kAstI32 = 1; 81 var kAstI32 = 1;
88 var kAstI64 = 2; 82 var kAstI64 = 2;
89 var kAstF32 = 3; 83 var kAstF32 = 3;
90 var kAstF64 = 4; 84 var kAstF64 = 4;
91 85
86 var kExternalFunction = 0;
87 var kExternalTable = 1;
88 var kExternalMemory = 2;
89 var kExternalGlobal = 3;
90
92 // Useful signatures 91 // Useful signatures
93 var kSig_i = makeSig([], [kAstI32]); 92 var kSig_i = makeSig([], [kAstI32]);
94 var kSig_d = makeSig([], [kAstF64]); 93 var kSig_d = makeSig([], [kAstF64]);
95 var kSig_i_i = makeSig([kAstI32], [kAstI32]); 94 var kSig_i_i = makeSig([kAstI32], [kAstI32]);
96 var kSig_i_l = makeSig([kAstI64], [kAstI32]); 95 var kSig_i_l = makeSig([kAstI64], [kAstI32]);
97 var kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]); 96 var kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]);
98 var kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]); 97 var kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]);
99 var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); 98 var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]);
100 var kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); 99 var kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]);
101 var kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); 100 var kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]);
(...skipping 24 matching lines...) Expand all
126 125
127 function makeSig_r_x(r, x) { 126 function makeSig_r_x(r, x) {
128 return makeSig([x], [r]); 127 return makeSig([x], [r]);
129 } 128 }
130 129
131 function makeSig_r_xx(r, x) { 130 function makeSig_r_xx(r, x) {
132 return makeSig([x, x], [r]); 131 return makeSig([x, x], [r]);
133 } 132 }
134 133
135 // Opcodes 134 // Opcodes
136 var kExprNop = 0x00; 135 var kExprUnreachable = 0x00;
136 var kExprNop = 0x0a;
137 var kExprBlock = 0x01; 137 var kExprBlock = 0x01;
138 var kExprLoop = 0x02; 138 var kExprLoop = 0x02;
139 var kExprIf = 0x03; 139 var kExprIf = 0x03;
140 var kExprElse = 0x04; 140 var kExprElse = 0x04;
141 var kExprSelect = 0x05; 141 var kExprSelect = 0x05;
142 var kExprBr = 0x06; 142 var kExprBr = 0x06;
143 var kExprBrIf = 0x07; 143 var kExprBrIf = 0x07;
144 var kExprBrTable = 0x08; 144 var kExprBrTable = 0x08;
145 var kExprReturn = 0x09; 145 var kExprReturn = 0x09;
146 var kExprUnreachable = 0x0a;
147 var kExprThrow = 0xfa; 146 var kExprThrow = 0xfa;
148 var kExprEnd = 0x0f; 147 var kExprEnd = 0x0f;
148 var kExprTeeLocal = 0x19;
149 var kExprDrop = 0x0b;
149 150
150 var kExprI32Const = 0x10; 151 var kExprI32Const = 0x10;
151 var kExprI64Const = 0x11; 152 var kExprI64Const = 0x11;
152 var kExprF64Const = 0x12; 153 var kExprF64Const = 0x12;
153 var kExprF32Const = 0x13; 154 var kExprF32Const = 0x13;
154 var kExprGetLocal = 0x14; 155 var kExprGetLocal = 0x14;
155 var kExprSetLocal = 0x15; 156 var kExprSetLocal = 0x15;
156 var kExprCallFunction = 0x16; 157 var kExprCallFunction = 0x16;
157 var kExprCallIndirect = 0x17; 158 var kExprCallIndirect = 0x17;
158 var kExprCallImport = 0x18;
159 var kExprI8Const = 0xcb; 159 var kExprI8Const = 0xcb;
160 var kExprGetGlobal = 0xbb; 160 var kExprGetGlobal = 0xbb;
161 var kExprSetGlobal = 0xbc; 161 var kExprSetGlobal = 0xbc;
162 162
163 var kExprI32LoadMem8S = 0x20; 163 var kExprI32LoadMem8S = 0x20;
164 var kExprI32LoadMem8U = 0x21; 164 var kExprI32LoadMem8U = 0x21;
165 var kExprI32LoadMem16S = 0x22; 165 var kExprI32LoadMem16S = 0x22;
166 var kExprI32LoadMem16U = 0x23; 166 var kExprI32LoadMem16U = 0x23;
167 var kExprI64LoadMem8S = 0x24; 167 var kExprI64LoadMem8S = 0x24;
168 var kExprI64LoadMem8U = 0x25; 168 var kExprI64LoadMem8U = 0x25;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 eval(code); 360 eval(code);
361 } 361 }
362 } catch (e) { 362 } catch (e) {
363 assertEquals("number", typeof e); 363 assertEquals("number", typeof e);
364 assertEquals(value, e); 364 assertEquals(value, e);
365 // Success. 365 // Success.
366 return; 366 return;
367 } 367 }
368 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); 368 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value);
369 } 369 }
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/verify-function-simple.js ('k') | test/mjsunit/wasm/wasm-module-builder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698