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

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

Issue 1740373002: [wasm] Add a magic word and a version number to the binary. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
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
19 var kWasmH0 = 0;
20 var kWasmH1 = 0x61;
21 var kWasmH2 = 0x73;
22 var kWasmH3 = 0x6d;
23
24 var kWasmV0 = 10;
25 var kWasmV1 = 0;
26 var kWasmV2 = 0;
27 var kWasmV3 = 0;
28
29 var kHeaderSize = 8;
30
31 function bytesWithHeader() {
32 var buffer = new ArrayBuffer(kHeaderSize + arguments.length);
33 var view = new Uint8Array(buffer);
34 view[0] = kWasmH0;
35 view[1] = kWasmH1;
36 view[2] = kWasmH2;
37 view[3] = kWasmH3;
38 view[4] = kWasmV0;
39 view[5] = kWasmV1;
40 view[6] = kWasmV2;
41 view[7] = kWasmV3;
42 print(view[1]);
binji 2016/02/27 19:26:56 did you leave this in while testing?
titzer 2016/02/27 23:05:09 Good catch. Removed.
43 for (var i = 0; i < arguments.length; i++) {
44 var val = arguments[i];
45 if ((typeof val) == "string") val = val.charCodeAt(0);
46 view[kHeaderSize + i] = val | 0;
47 }
48 return buffer;
49 }
50
18 // Section declaration constants 51 // Section declaration constants
19 var kDeclMemory = 0x00; 52 var kDeclMemory = 0x00;
20 var kDeclSignatures = 0x01; 53 var kDeclSignatures = 0x01;
21 var kDeclFunctions = 0x02; 54 var kDeclFunctions = 0x02;
22 var kDeclGlobals = 0x03; 55 var kDeclGlobals = 0x03;
23 var kDeclDataSegments = 0x04; 56 var kDeclDataSegments = 0x04;
24 var kDeclFunctionTable = 0x05; 57 var kDeclFunctionTable = 0x05;
25 var kDeclStartFunction = 0x07; 58 var kDeclStartFunction = 0x07;
26 var kDeclImportTable = 0x08; 59 var kDeclImportTable = 0x08;
27 var kDeclExportTable = 0x09; 60 var kDeclExportTable = 0x09;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 276 }
244 threwException = false; 277 threwException = false;
245 } catch (e) { 278 } catch (e) {
246 assertEquals("string", typeof e); 279 assertEquals("string", typeof e);
247 assertEquals(kTrapMsgs[trap], e); 280 assertEquals(kTrapMsgs[trap], e);
248 // Success. 281 // Success.
249 return; 282 return;
250 } 283 }
251 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap] ); 284 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap] );
252 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698