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

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

Issue 2440953002: [wasm] Binary 0xD: update encoding of opcodes, types, and add immediates. (Closed)
Patch Set: Created 4 years, 1 month 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 var kSig_v_i = makeSig([kAstI32], []); 117 var kSig_v_i = makeSig([kAstI32], []);
118 var signature = builder.addType(kSig_v_i); 118 var signature = builder.addType(kSig_v_i);
119 builder.addImport("some_value", kSig_i_v); 119 builder.addImport("some_value", kSig_i_v);
120 builder.addImport("writer", signature); 120 builder.addImport("writer", signature);
121 121
122 builder.addFunction("main", kSig_i_i) 122 builder.addFunction("main", kSig_i_i)
123 .addBody([ 123 .addBody([
124 kExprGetLocal, 0, 124 kExprGetLocal, 0,
125 kExprI32LoadMem, 0, 0, 125 kExprI32LoadMem, 0, 0,
126 kExprI32Const, 1, 126 kExprI32Const, 1,
127 kExprCallIndirect, signature, 127 kExprCallIndirect, kTableZero, signature,
128 kExprGetLocal,0, 128 kExprGetLocal,0,
129 kExprI32LoadMem,0, 0, 129 kExprI32LoadMem,0, 0,
130 kExprCallFunction, 0, 130 kExprCallFunction, 0,
131 kExprI32Add 131 kExprI32Add
132 ]).exportFunc(); 132 ]).exportFunc();
133 133
134 // writer(mem[i]); 134 // writer(mem[i]);
135 // return mem[i] + some_value(); 135 // return mem[i] + some_value();
136 builder.addFunction("_wrap_writer", signature) 136 builder.addFunction("_wrap_writer", signature)
137 .addBody([ 137 .addBody([
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 view_1[0] = 1; 206 view_1[0] = 1;
207 view_2[0] = 1000; 207 view_2[0] = 1000;
208 208
209 var module = new WebAssembly.Module(builder.toBuffer()); 209 var module = new WebAssembly.Module(builder.toBuffer());
210 var i1 = new WebAssembly.Instance(module, null, mem_1); 210 var i1 = new WebAssembly.Instance(module, null, mem_1);
211 var i2 = new WebAssembly.Instance(module, null, mem_2); 211 var i2 = new WebAssembly.Instance(module, null, mem_2);
212 212
213 assertEquals(1, i1.exports.f()); 213 assertEquals(1, i1.exports.f());
214 assertEquals(1000, i2.exports.f()); 214 assertEquals(1000, i2.exports.f());
215 })(); 215 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698