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

Side by Side Diff: test/cctest/wasm/test-run-wasm-module.cc

Issue 2170773003: [wasm] Remove the explicit count from WASM_BLOCK and WASM_LOOP macros. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/test-run-wasm-64.cc ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('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 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 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "src/wasm/encoder.h" 8 #include "src/wasm/encoder.h"
9 #include "src/wasm/wasm-js.h" 9 #include "src/wasm/wasm-js.h"
10 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 TestSignatures sigs; 109 TestSignatures sigs;
110 110
111 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 111 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
112 uint16_t f_index = builder->AddFunction(); 112 uint16_t f_index = builder->AddFunction();
113 WasmFunctionBuilder* f = builder->FunctionAt(f_index); 113 WasmFunctionBuilder* f = builder->FunctionAt(f_index);
114 f->SetSignature(sigs.i_v()); 114 f->SetSignature(sigs.i_v());
115 115
116 uint16_t localIndex = f->AddLocal(kAstI32); 116 uint16_t localIndex = f->AddLocal(kAstI32);
117 ExportAsMain(f); 117 ExportAsMain(f);
118 byte code[] = {WASM_BLOCK( 118 byte code[] = {WASM_BLOCK(
119 2,
120 WASM_WHILE( 119 WASM_WHILE(
121 WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I32V_3(kCheckSize)), 120 WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I32V_3(kCheckSize)),
122 WASM_IF_ELSE( 121 WASM_IF_ELSE(
123 WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(localIndex)), 122 WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(localIndex)),
124 WASM_BRV(2, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))), 123 WASM_BRV(2, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))),
125 WASM_I8(11))}; 124 WASM_I8(11))};
126 f->EmitCode(code, sizeof(code)); 125 f->EmitCode(code, sizeof(code));
127 TestModule(&zone, builder, 11); 126 TestModule(&zone, builder, 11);
128 } 127 }
129 128
130 TEST(Run_WasmModule_CallMain_recursive) { 129 TEST(Run_WasmModule_CallMain_recursive) {
131 v8::base::AccountingAllocator allocator; 130 v8::base::AccountingAllocator allocator;
132 Zone zone(&allocator); 131 Zone zone(&allocator);
133 TestSignatures sigs; 132 TestSignatures sigs;
134 133
135 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 134 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
136 uint16_t f_index = builder->AddFunction(); 135 uint16_t f_index = builder->AddFunction();
137 WasmFunctionBuilder* f = builder->FunctionAt(f_index); 136 WasmFunctionBuilder* f = builder->FunctionAt(f_index);
138 f->SetSignature(sigs.i_v()); 137 f->SetSignature(sigs.i_v());
139 138
140 uint16_t localIndex = f->AddLocal(kAstI32); 139 uint16_t localIndex = f->AddLocal(kAstI32);
141 ExportAsMain(f); 140 ExportAsMain(f);
142 byte code[] = {WASM_BLOCK( 141 byte code[] = {WASM_BLOCK(
143 2, WASM_SET_LOCAL(localIndex, 142 WASM_SET_LOCAL(localIndex,
144 WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)), 143 WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
145 WASM_IF_ELSE(WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I8(5)), 144 WASM_IF_ELSE(WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I8(5)),
146 WASM_BLOCK(2, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, 145 WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
147 WASM_INC_LOCAL(localIndex)), 146 WASM_INC_LOCAL(localIndex)),
148 WASM_BRV(1, WASM_CALL_FUNCTION0(0))), 147 WASM_BRV(1, WASM_CALL_FUNCTION0(0))),
149 WASM_BRV(0, WASM_I8(55))))}; 148 WASM_BRV(0, WASM_I8(55))))};
150 f->EmitCode(code, sizeof(code)); 149 f->EmitCode(code, sizeof(code));
151 TestModule(&zone, builder, 55); 150 TestModule(&zone, builder, 55);
152 } 151 }
153 152
154 TEST(Run_WasmModule_Global) { 153 TEST(Run_WasmModule_Global) {
155 v8::base::AccountingAllocator allocator; 154 v8::base::AccountingAllocator allocator;
156 Zone zone(&allocator); 155 Zone zone(&allocator);
157 TestSignatures sigs; 156 TestSignatures sigs;
(...skipping 10 matching lines...) Expand all
168 uint16_t f2_index = builder->AddFunction(); 167 uint16_t f2_index = builder->AddFunction();
169 f = builder->FunctionAt(f2_index); 168 f = builder->FunctionAt(f2_index);
170 f->SetSignature(sigs.i_v()); 169 f->SetSignature(sigs.i_v());
171 ExportAsMain(f); 170 ExportAsMain(f);
172 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)), 171 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)),
173 WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)), 172 WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)),
174 WASM_RETURN1(WASM_CALL_FUNCTION0(f1_index))}; 173 WASM_RETURN1(WASM_CALL_FUNCTION0(f1_index))};
175 f->EmitCode(code2, sizeof(code2)); 174 f->EmitCode(code2, sizeof(code2));
176 TestModule(&zone, builder, 97); 175 TestModule(&zone, builder, 97);
177 } 176 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-64.cc ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698