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 // 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 = 0xD; | 24 var kWasmV0 = 0x1; |
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); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 eval(code); | 365 eval(code); |
366 } | 366 } |
367 } catch (e) { | 367 } catch (e) { |
368 assertEquals("number", typeof e); | 368 assertEquals("number", typeof e); |
369 assertEquals(value, e); | 369 assertEquals(value, e); |
370 // Success. | 370 // Success. |
371 return; | 371 return; |
372 } | 372 } |
373 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); | 373 throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); |
374 } | 374 } |
OLD | NEW |