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

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

Issue 2410953003: [wasm] Fix decoding of shared global index space (Closed)
Patch Set: Increase allocation limit 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 | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 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 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 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 function TestImported(type, val, expected) { 10 function TestImported(type, val, expected) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 o.init_index = i; 57 o.init_index = i;
58 builder.addGlobal(kAstI32); // pad 58 builder.addGlobal(kAstI32); // pad
59 59
60 var instance = builder.instantiate({foo: val}); 60 var instance = builder.instantiate({foo: val});
61 assertEquals(expected, instance.exports.bar); 61 assertEquals(expected, instance.exports.bar);
62 } 62 }
63 63
64 TestImportedExported(kAstI32, 415.5, 415); 64 TestImportedExported(kAstI32, 415.5, 415);
65 TestImportedExported(kAstF32, -979.34343, Math.fround(-979.34343)); 65 TestImportedExported(kAstF32, -979.34343, Math.fround(-979.34343));
66 TestImportedExported(kAstF64, 81347.66666, 81347.66666); 66 TestImportedExported(kAstF64, 81347.66666, 81347.66666);
67
68 function TestGlobalIndexSpace(type, val) {
69 print("TestGlobalIndexSpace(" + val + ") = " + val);
70 var builder = new WasmModuleBuilder();
71 var im = builder.addImportedGlobal("foo", undefined, type);
72 assertEquals(0, im);
73 var def = builder.addGlobal(type, false);
74 assertEquals(1, def.index);
75 def.init_index = im;
76
77 var sig = makeSig([], [type]);
78 builder.addFunction("main", sig)
79 .addBody([kExprGetGlobal, def.index])
80 .exportAs("main");
81
82 var instance = builder.instantiate({foo: val});
83 assertEquals(val, instance.exports.main());
84 }
85
86 TestGlobalIndexSpace(kAstI32, 123);
87 TestGlobalIndexSpace(kAstF32, 54321.125);
88 TestGlobalIndexSpace(kAstF64, 12345.678);
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698