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

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

Issue 1763433002: [wasm] Rework encoding of local declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/cctest/wasm/wasm-run-utils.h ('k') | test/mjsunit/wasm/verify-function-simple.js » ('j') | 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 var debug = false; 10 var debug = false;
(...skipping 29 matching lines...) Expand all
40 .addLocals({i32_count: 1}) 40 .addLocals({i32_count: 1})
41 .addBody([kExprSetLocal, 1, kExprGetLocal, 0]) 41 .addBody([kExprSetLocal, 1, kExprGetLocal, 0])
42 .exportAs("main"); 42 .exportAs("main");
43 43
44 var buffer = module.toBuffer(debug); 44 var buffer = module.toBuffer(debug);
45 var instance = _WASMEXP_.instantiateModule(buffer); 45 var instance = _WASMEXP_.instantiateModule(buffer);
46 assertEquals(19, instance.exports.main(19)); 46 assertEquals(19, instance.exports.main(19));
47 assertEquals(27777, instance.exports.main(27777)); 47 assertEquals(27777, instance.exports.main(27777));
48 })(); 48 })();
49 49
50 (function LocalsTest2() {
51 // TODO(titzer): i64 only works on 64-bit platforms.
52 var types = [
53 {locals: {i32_count: 1}, type: kAstI32},
54 // {locals: {i64_count: 1}, type: kAstI64},
55 {locals: {f32_count: 1}, type: kAstF32},
56 {locals: {f64_count: 1}, type: kAstF64},
57 ];
58
59 for (p of types) {
60 var module = new WasmModuleBuilder();
61 module.addFunction(undefined, [p.type, p.type])
62 .addLocals(p.locals)
63 .addBody([kExprSetLocal, 1, kExprGetLocal, 0])
64 .exportAs("main");
65
66 var buffer = module.toBuffer(debug);
67 var instance = _WASMEXP_.instantiateModule(buffer);
68 assertEquals(19, instance.exports.main(19));
69 assertEquals(27777, instance.exports.main(27777));
70 }
71 })();
72
50 (function CallTest() { 73 (function CallTest() {
51 var module = new WasmModuleBuilder(); 74 var module = new WasmModuleBuilder();
52 module.addFunction("add", [kAstI32, kAstI32, kAstI32]) 75 module.addFunction("add", [kAstI32, kAstI32, kAstI32])
53 .addBody([kExprI32Add, kExprGetLocal, 0, kExprGetLocal, 1]); 76 .addBody([kExprI32Add, kExprGetLocal, 0, kExprGetLocal, 1]);
54 module.addFunction("main", [kAstI32, kAstI32, kAstI32]) 77 module.addFunction("main", [kAstI32, kAstI32, kAstI32])
55 .addBody([kExprCallFunction, 0, kExprGetLocal, 0, kExprGetLocal, 1]) 78 .addBody([kExprCallFunction, 0, kExprGetLocal, 0, kExprGetLocal, 1])
56 .exportAs("main"); 79 .exportAs("main");
57 80
58 var instance = module.instantiate(); 81 var instance = module.instantiate();
59 assertEquals(44, instance.exports.main(11, 33)); 82 assertEquals(44, instance.exports.main(11, 33));
(...skipping 21 matching lines...) Expand all
81 module.addMemory(1, 1, false); 104 module.addMemory(1, 1, false);
82 module.addFunction("load", [kAstI32, kAstI32]) 105 module.addFunction("load", [kAstI32, kAstI32])
83 .addBody([kExprI32LoadMem, 0, kExprGetLocal, 0]) 106 .addBody([kExprI32LoadMem, 0, kExprGetLocal, 0])
84 .exportAs("load"); 107 .exportAs("load");
85 module.addDataSegment(0, [9, 9, 9, 9], true); 108 module.addDataSegment(0, [9, 9, 9, 9], true);
86 109
87 var buffer = module.toBuffer(debug); 110 var buffer = module.toBuffer(debug);
88 var instance = _WASMEXP_.instantiateModule(buffer); 111 var instance = _WASMEXP_.instantiateModule(buffer);
89 assertEquals(151587081, instance.exports.load(0)); 112 assertEquals(151587081, instance.exports.load(0));
90 })(); 113 })();
OLDNEW
« no previous file with comments | « test/cctest/wasm/wasm-run-utils.h ('k') | test/mjsunit/wasm/verify-function-simple.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698