| OLD | NEW |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 for (int num_params = which + 1; num_params < kMaxParams; num_params++) { | 203 for (int num_params = which + 1; num_params < kMaxParams; num_params++) { |
| 204 HandleScope scope(CcTest::InitIsolateOnce()); | 204 HandleScope scope(CcTest::InitIsolateOnce()); |
| 205 FunctionSig sig(1, num_params, types); | 205 FunctionSig sig(1, num_params, types); |
| 206 | 206 |
| 207 TestingModule module; | 207 TestingModule module; |
| 208 uint32_t js_index = AddJSSelector(&module, &sig, which); | 208 uint32_t js_index = AddJSSelector(&module, &sig, which); |
| 209 WasmFunctionCompiler t(&sig, &module); | 209 WasmFunctionCompiler t(&sig, &module); |
| 210 | 210 |
| 211 { | 211 { |
| 212 std::vector<byte> code; | 212 std::vector<byte> code; |
| 213 ADD_CODE(code, kExprCallFunction, static_cast<byte>(js_index)); | |
| 214 | 213 |
| 215 for (int i = 0; i < num_params; i++) { | 214 for (int i = 0; i < num_params; i++) { |
| 216 ADD_CODE(code, WASM_F64(inputs.arg_d(i))); | 215 ADD_CODE(code, WASM_F64(inputs.arg_d(i))); |
| 217 } | 216 } |
| 218 | 217 |
| 218 ADD_CODE(code, kExprCallFunction, static_cast<byte>(js_index)); |
| 219 |
| 219 size_t end = code.size(); | 220 size_t end = code.size(); |
| 220 code.push_back(0); | 221 code.push_back(0); |
| 221 t.Build(&code[0], &code[end]); | 222 t.Build(&code[0], &code[end]); |
| 222 } | 223 } |
| 223 | 224 |
| 224 Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd()); | 225 Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd()); |
| 225 double expected = inputs.arg_d(which); | 226 double expected = inputs.arg_d(which); |
| 226 EXPECT_CALL(expected, jsfunc, 0.0, 0.0); | 227 EXPECT_CALL(expected, jsfunc, 0.0, 0.0); |
| 227 } | 228 } |
| 228 #endif | 229 #endif |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 Factory* factory = isolate->factory(); | 361 Factory* factory = isolate->factory(); |
| 361 const int kMaxParams = 4; | 362 const int kMaxParams = 4; |
| 362 CHECK_LE(num_args, kMaxParams); | 363 CHECK_LE(num_args, kMaxParams); |
| 363 CHECK_LE(num_params, kMaxParams); | 364 CHECK_LE(num_params, kMaxParams); |
| 364 LocalType type = kAstF64; | 365 LocalType type = kAstF64; |
| 365 LocalType types[kMaxParams + 1] = {type, type, type, type, type}; | 366 LocalType types[kMaxParams + 1] = {type, type, type, type, type}; |
| 366 FunctionSig sig(1, num_params, types); | 367 FunctionSig sig(1, num_params, types); |
| 367 | 368 |
| 368 // Build the calling code. | 369 // Build the calling code. |
| 369 std::vector<byte> code; | 370 std::vector<byte> code; |
| 370 ADD_CODE(code, kExprCallFunction, 0); | |
| 371 | 371 |
| 372 for (int i = 0; i < num_params; i++) { | 372 for (int i = 0; i < num_params; i++) { |
| 373 ADD_CODE(code, WASM_GET_LOCAL(i)); | 373 ADD_CODE(code, WASM_GET_LOCAL(i)); |
| 374 } | 374 } |
| 375 | 375 |
| 376 ADD_CODE(code, kExprCallFunction, 0); |
| 377 |
| 376 size_t end = code.size(); | 378 size_t end = code.size(); |
| 377 code.push_back(0); | 379 code.push_back(0); |
| 378 | 380 |
| 379 // Call different select JS functions. | 381 // Call different select JS functions. |
| 380 for (int which = 0; which < num_params; which++) { | 382 for (int which = 0; which < num_params; which++) { |
| 381 HandleScope scope(isolate); | 383 HandleScope scope(isolate); |
| 382 TestingModule module; | 384 TestingModule module; |
| 383 uint32_t js_index = AddJSSelector(&module, &sig, which); | 385 uint32_t js_index = AddJSSelector(&module, &sig, which); |
| 384 CHECK_EQ(0, js_index); | 386 CHECK_EQ(0, js_index); |
| 385 WasmFunctionCompiler t(&sig, &module); | 387 WasmFunctionCompiler t(&sig, &module); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 RunJSSelectAlignTest(1, 2); | 427 RunJSSelectAlignTest(1, 2); |
| 426 RunJSSelectAlignTest(1, 3); | 428 RunJSSelectAlignTest(1, 3); |
| 427 } | 429 } |
| 428 | 430 |
| 429 | 431 |
| 430 TEST(Run_JSSelectAlign_3) { | 432 TEST(Run_JSSelectAlign_3) { |
| 431 RunJSSelectAlignTest(3, 3); | 433 RunJSSelectAlignTest(3, 3); |
| 432 RunJSSelectAlignTest(3, 4); | 434 RunJSSelectAlignTest(3, 4); |
| 433 } | 435 } |
| 434 #endif | 436 #endif |
| OLD | NEW |