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

Side by Side Diff: test/mjsunit/wasm/instantiate-module-basic.js

Issue 1504713014: Initial import of v8-native WASM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/indirect-calls.js ('k') | test/mjsunit/wasm/module-memory.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 load("test/mjsunit/wasm/wasm-constants.js");
6
7 var kReturnValue = 117;
8
9 var kBodySize = 2;
10 var kNameOffset = 19 + kBodySize + 1;
11
12 var data = bytes(
13 // -- memory
14 kDeclMemory,
15 10, 10, 1,
16 // -- signatures
17 kDeclSignatures, 1,
18 0, kAstI32, // signature: void -> int
19 // -- main function
20 kDeclFunctions, 1,
21 kDeclFunctionName | kDeclFunctionExport,
22 0, 0, // signature index
23 kNameOffset, 0, 0, 0, // name offset
24 kBodySize, 0, // body size
25 // -- body
26 kExprI8Const, // --
27 kReturnValue, // --
28 kDeclEnd,
29 'm', 'a', 'i', 'n', 0 // name
30 );
31
32 var module = WASM.instantiateModule(data);
33
34 // Check the module exists.
35 assertFalse(module === undefined);
36 assertFalse(module === null);
37 assertFalse(module === 0);
38 assertEquals("object", typeof module);
39
40 // Check the memory is an ArrayBuffer.
41 var mem = module.memory;
42 assertFalse(mem === undefined);
43 assertFalse(mem === null);
44 assertFalse(mem === 0);
45 assertEquals("object", typeof mem);
46 assertTrue(mem instanceof ArrayBuffer);
47 for (var i = 0; i < 4; i++) {
48 module.memory = 0; // should be ignored
49 assertEquals(mem, module.memory);
50 }
51
52 assertEquals(1024, module.memory.byteLength);
53
54 // Check the properties of the main function.
55 assertFalse(module.main === undefined);
56 assertFalse(module.main === null);
57 assertFalse(module.main === 0);
58 assertEquals("function", typeof module.main);
59
60 assertEquals(kReturnValue, module.main());
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/indirect-calls.js ('k') | test/mjsunit/wasm/module-memory.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698