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

Side by Side Diff: test/mjsunit/wasm/globals.js

Issue 2395133002: Revert of [wasm] Refactor import handling for 0xC. (Closed)
Patch Set: 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/function-prototype.js ('k') | test/mjsunit/wasm/import-table.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 2016 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 // Flags: --expose-wasm
6
7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js");
9
10 function TestImported(type, val, expected) {
11 print("TestImported " + type + "(" + val +")" + " = " + expected);
12 var builder = new WasmModuleBuilder();
13 var sig = makeSig([], [type]);
14 var g = builder.addImportedGlobal("foo", undefined, type);
15 builder.addFunction("main", sig)
16 .addBody([kExprGetGlobal, g.index])
17 .exportAs("main");
18 builder.addGlobal(kAstI32); // pad
19
20 var instance = builder.instantiate({foo: val});
21 assertEquals(expected, instance.exports.main());
22 }
23
24 TestImported(kAstI32, 300.1, 300);
25 TestImported(kAstF32, 87234.87238, Math.fround(87234.87238));
26 TestImported(kAstF64, 77777.88888, 77777.88888);
27 TestImported(kAstF64, "89", 89);
28
29
30 function TestExported(type, val, expected) {
31 print("TestExported " + type + "(" + val +")" + " = " + expected);
32 var builder = new WasmModuleBuilder();
33 var sig = makeSig([type], []);
34 builder.addGlobal(kAstI32); // pad
35 var g = builder.addGlobal(type, false)
36 .exportAs("foo");
37 g.init = val;
38 builder.addGlobal(kAstI32); // pad
39
40 var instance = builder.instantiate();
41 assertEquals(expected, instance.exports.foo);
42 }
43
44 TestExported(kAstI32, 455.5, 455);
45 TestExported(kAstF32, -999.34343, Math.fround(-999.34343));
46 TestExported(kAstF64, 87347.66666, 87347.66666);
47
48
49 function TestImportedExported(type, val, expected) {
50 print("TestImportedExported " + type + "(" + val +")" + " = " + expected);
51 var builder = new WasmModuleBuilder();
52 var sig = makeSig([type], []);
53 var i = builder.addImportedGlobal("foo", undefined, type);
54 builder.addGlobal(kAstI32); // pad
55 var o = builder.addGlobal(type, false)
56 .exportAs("bar");
57 o.init_index = i;
58 builder.addGlobal(kAstI32); // pad
59
60 var instance = builder.instantiate({foo: val});
61 assertEquals(expected, instance.exports.bar);
62 }
63
64 TestImportedExported(kAstI32, 415.5, 415);
65 TestImportedExported(kAstF32, -979.34343, Math.fround(-979.34343));
66 TestImportedExported(kAstF64, 81347.66666, 81347.66666);
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/function-prototype.js ('k') | test/mjsunit/wasm/import-table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698