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

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

Issue 2296993002: [wasm] mjsunit support for I32 globals and test (Closed)
Patch Set: Created 4 years, 3 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 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 let kReturnValue = 117; 10 let kReturnValue = 117;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 writer: (x)=>outval_1 = x }, mem_1); 146 writer: (x)=>outval_1 = x }, mem_1);
147 var i2 = new WebAssembly.Instance(module, {some_value: () => 2, 147 var i2 = new WebAssembly.Instance(module, {some_value: () => 2,
148 writer: (x)=>outval_2 = x }, mem_2); 148 writer: (x)=>outval_2 = x }, mem_2);
149 149
150 assertEquals(43, i1.exports.main(0)); 150 assertEquals(43, i1.exports.main(0));
151 assertEquals(1002, i2.exports.main(0)); 151 assertEquals(1002, i2.exports.main(0));
152 152
153 assertEquals(42, outval_1); 153 assertEquals(42, outval_1);
154 assertEquals(1000, outval_2); 154 assertEquals(1000, outval_2);
155 })(); 155 })();
156
157 (function GlobalsArePrivateToTheInstance() {
158 var builder = new WasmModuleBuilder();
159 builder.addGlobal(kAstI32);
160 builder.addFunction("read", kSig_i_v)
161 .addBody([
162 kExprGetGlobal, 0])
163 .exportFunc();
164
165 builder.addFunction("write", kSig_v_i)
166 .addBody([
167 kExprGetLocal, 0,
168 kExprSetGlobal, 0])
169 .exportFunc();
170
171 var module = new WebAssembly.Module(builder.toBuffer());
172 var i1 = new WebAssembly.Instance(module);
173 var i2 = new WebAssembly.Instance(module);
174 i1.exports.write(1);
175 i2.exports.write(2);
176 assertEquals(1, i1.exports.read());
177 assertEquals(2, i2.exports.read());
178 })();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/wasm-module-builder.js » ('j') | test/mjsunit/wasm/wasm-module-builder.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698