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

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

Issue 2081973003: Refactor module builder (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 })(); 58 })();
59 59
60 60
61 (function testTwoStartFuncs() { 61 (function testTwoStartFuncs() {
62 print("testTwoStartFuncs"); 62 print("testTwoStartFuncs");
63 var builder = new WasmModuleBuilder(); 63 var builder = new WasmModuleBuilder();
64 64
65 var func = builder.addFunction("", kSig_v_v) 65 var func = builder.addFunction("", kSig_v_v)
66 .addBody([kExprNop]); 66 .addBody([kExprNop]);
67 67
68 builder.addExplicitSection([kDeclStartFunction, 0]); 68 builder.addExplicitSection([kDeclStart, 0]);
69 builder.addExplicitSection([kDeclStartFunction, 0]); 69 builder.addExplicitSection([kDeclStart, 0]);
70 70
71 assertThrows(builder.instantiate); 71 assertThrows(builder.instantiate);
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);
(...skipping 11 matching lines...) Expand all
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(kSig_v_v); 101 var sig_index = builder.addType(kSig_v_v);
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, kArity0, 0]); 105 .addBody([kExprCallImport, kArity0, 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

Powered by Google App Engine
This is Rietveld 408576698