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

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

Issue 1830663002: [wasm] Binary 11: AST changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/cctest/wasm/test-run-wasm-module.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 <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 EXPECT_CALL(6, jsfunc, 0x3F, 0); 149 EXPECT_CALL(6, jsfunc, 0x3F, 0);
150 } 150 }
151 151
152 152
153 TEST(Run_CallJS_Add_jswrapped) { 153 TEST(Run_CallJS_Add_jswrapped) {
154 TestSignatures sigs; 154 TestSignatures sigs;
155 TestingModule module; 155 TestingModule module;
156 WasmFunctionCompiler t(sigs.i_i(), &module); 156 WasmFunctionCompiler t(sigs.i_i(), &module);
157 uint32_t js_index = 157 uint32_t js_index =
158 module.AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })"); 158 module.AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })");
159 BUILD(t, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0))); 159 BUILD(t, WASM_CALL_FUNCTION1(js_index, WASM_GET_LOCAL(0)));
160 160
161 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); 161 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
162 162
163 EXPECT_CALL(101, jsfunc, 2, -8); 163 EXPECT_CALL(101, jsfunc, 2, -8);
164 EXPECT_CALL(199, jsfunc, 100, -1); 164 EXPECT_CALL(199, jsfunc, 100, -1);
165 EXPECT_CALL(-666666801, jsfunc, -666666900, -1); 165 EXPECT_CALL(-666666801, jsfunc, -666666900, -1);
166 } 166 }
167 167
168 168
169 void RunJSSelectTest(int which) { 169 void RunJSSelectTest(int which) {
170 const int kMaxParams = 8; 170 const int kMaxParams = 8;
171 PredictableInputValues inputs(0x100); 171 PredictableInputValues inputs(0x100);
172 LocalType type = kAstF64; 172 LocalType type = kAstF64;
173 LocalType types[kMaxParams + 1] = {type, type, type, type, type, 173 LocalType types[kMaxParams + 1] = {type, type, type, type, type,
174 type, type, type, type}; 174 type, type, type, type};
175 for (int num_params = which + 1; num_params < kMaxParams; num_params++) { 175 for (int num_params = which + 1; num_params < kMaxParams; num_params++) {
176 HandleScope scope(CcTest::InitIsolateOnce()); 176 HandleScope scope(CcTest::InitIsolateOnce());
177 FunctionSig sig(1, num_params, types); 177 FunctionSig sig(1, num_params, types);
178 178
179 TestingModule module; 179 TestingModule module;
180 uint32_t js_index = AddJSSelector(&module, &sig, which); 180 uint32_t js_index = AddJSSelector(&module, &sig, which);
181 WasmFunctionCompiler t(&sig, &module); 181 WasmFunctionCompiler t(&sig, &module);
182 182
183 { 183 {
184 std::vector<byte> code; 184 std::vector<byte> code;
185 ADD_CODE(code, kExprCallFunction, static_cast<byte>(js_index));
186 185
187 for (int i = 0; i < num_params; i++) { 186 for (int i = 0; i < num_params; i++) {
188 ADD_CODE(code, WASM_F64(inputs.arg_d(i))); 187 ADD_CODE(code, WASM_F64(inputs.arg_d(i)));
189 } 188 }
190 189
190 ADD_CODE(code, kExprCallFunction, static_cast<byte>(num_params),
191 static_cast<byte>(js_index));
192
191 size_t end = code.size(); 193 size_t end = code.size();
192 code.push_back(0); 194 code.push_back(0);
193 t.Build(&code[0], &code[end]); 195 t.Build(&code[0], &code[end]);
194 } 196 }
195 197
196 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); 198 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
197 double expected = inputs.arg_d(which); 199 double expected = inputs.arg_d(which);
198 EXPECT_CALL(expected, jsfunc, 0.0, 0.0); 200 EXPECT_CALL(expected, jsfunc, 0.0, 0.0);
199 } 201 }
200 } 202 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 const int kMaxParams = 10; 365 const int kMaxParams = 10;
364 CHECK_LE(num_args, kMaxParams); 366 CHECK_LE(num_args, kMaxParams);
365 CHECK_LE(num_params, kMaxParams); 367 CHECK_LE(num_params, kMaxParams);
366 LocalType type = kAstF64; 368 LocalType type = kAstF64;
367 LocalType types[kMaxParams + 1] = {type, type, type, type, type, type, 369 LocalType types[kMaxParams + 1] = {type, type, type, type, type, type,
368 type, type, type, type, type}; 370 type, type, type, type, type};
369 FunctionSig sig(1, num_params, types); 371 FunctionSig sig(1, num_params, types);
370 372
371 // Build the calling code. 373 // Build the calling code.
372 std::vector<byte> code; 374 std::vector<byte> code;
373 ADD_CODE(code, kExprCallFunction, 0);
374 375
375 for (int i = 0; i < num_params; i++) { 376 for (int i = 0; i < num_params; i++) {
376 ADD_CODE(code, WASM_GET_LOCAL(i)); 377 ADD_CODE(code, WASM_GET_LOCAL(i));
377 } 378 }
378 379
380 ADD_CODE(code, kExprCallFunction, static_cast<byte>(num_params), 0);
381
379 size_t end = code.size(); 382 size_t end = code.size();
380 code.push_back(0); 383 code.push_back(0);
381 384
382 // Call different select JS functions. 385 // Call different select JS functions.
383 for (int which = 0; which < num_params; which++) { 386 for (int which = 0; which < num_params; which++) {
384 HandleScope scope(isolate); 387 HandleScope scope(isolate);
385 TestingModule module; 388 TestingModule module;
386 uint32_t js_index = AddJSSelector(&module, &sig, which); 389 uint32_t js_index = AddJSSelector(&module, &sig, which);
387 CHECK_EQ(0, js_index); 390 CHECK_EQ(0, js_index);
388 WasmFunctionCompiler t(&sig, &module); 391 WasmFunctionCompiler t(&sig, &module);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 RunJSSelectAlignTest(9, 8); 458 RunJSSelectAlignTest(9, 8);
456 RunJSSelectAlignTest(9, 9); 459 RunJSSelectAlignTest(9, 9);
457 } 460 }
458 461
459 TEST(Run_JSSelectAlign_10) { 462 TEST(Run_JSSelectAlign_10) {
460 RunJSSelectAlignTest(10, 7); 463 RunJSSelectAlignTest(10, 7);
461 RunJSSelectAlignTest(10, 8); 464 RunJSSelectAlignTest(10, 8);
462 RunJSSelectAlignTest(10, 9); 465 RunJSSelectAlignTest(10, 9);
463 RunJSSelectAlignTest(10, 10); 466 RunJSSelectAlignTest(10, 10);
464 } 467 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-64.cc ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698