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

Side by Side Diff: test/mjsunit/wasm/start-function.js

Issue 1775123003: [wasm] Encode immediates to Load and Store as varint. (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/mjsunit/wasm/module-memory.js ('k') | test/mjsunit/wasm/test-wasm-module-builder.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 function instantiate(sig, body) { 10 function instantiate(sig, body) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 })(); 72 })();
73 73
74 74
75 (function testRun() { 75 (function testRun() {
76 print("testRun"); 76 print("testRun");
77 var builder = new WasmModuleBuilder(); 77 var builder = new WasmModuleBuilder();
78 78
79 builder.addMemory(12, 12, true); 79 builder.addMemory(12, 12, true);
80 80
81 var func = builder.addFunction("", [kAstStmt]) 81 var func = builder.addFunction("", [kAstStmt])
82 .addBody([kExprI32StoreMem, 0, kExprI8Const, 0, kExprI8Const, 77]); 82 .addBody([kExprI32StoreMem, 0, 0, kExprI8Const, 0, kExprI8Const, 77]);
83 83
84 builder.addStart(func.index); 84 builder.addStart(func.index);
85 85
86 var module = builder.instantiate(); 86 var module = builder.instantiate();
87 var memory = module.exports.memory; 87 var memory = module.exports.memory;
88 var view = new Int8Array(memory); 88 var view = new Int8Array(memory);
89 assertEquals(77, view[0]); 89 assertEquals(77, view[0]);
90 })(); 90 })();
91 91
92 (function testStartFFI() { 92 (function testStartFFI() {
93 print("testStartFFI"); 93 print("testStartFFI");
94 var ranned = false; 94 var ranned = false;
95 var ffi = { foo : function() { 95 var ffi = { foo : function() {
96 print("we ranned at stert!"); 96 print("we ranned at stert!");
97 ranned = true; 97 ranned = true;
98 }}; 98 }};
99 99
100 var builder = new WasmModuleBuilder(); 100 var builder = new WasmModuleBuilder();
101 var sig_index = builder.addSignature([kAstStmt]); 101 var sig_index = builder.addSignature([kAstStmt]);
102 102
103 builder.addImport("foo", sig_index); 103 builder.addImport("foo", sig_index);
104 var func = builder.addFunction("", sig_index) 104 var func = builder.addFunction("", sig_index)
105 .addBody([kExprCallImport, 0]); 105 .addBody([kExprCallImport, 0]);
106 106
107 builder.addStart(func.index); 107 builder.addStart(func.index);
108 108
109 var module = builder.instantiate(ffi); 109 var module = builder.instantiate(ffi);
110 assertTrue(ranned); 110 assertTrue(ranned);
111 })(); 111 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/module-memory.js ('k') | test/mjsunit/wasm/test-wasm-module-builder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698