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

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

Issue 2361053004: Revert of [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 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-interpreter.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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 EXPECT_CALL(6, jsfunc, 0x3F, 0); 145 EXPECT_CALL(6, jsfunc, 0x3F, 0);
146 } 146 }
147 147
148 TEST(Run_CallJS_Add_jswrapped) { 148 TEST(Run_CallJS_Add_jswrapped) {
149 CcTest::InitializeVM(); 149 CcTest::InitializeVM();
150 TestSignatures sigs; 150 TestSignatures sigs;
151 TestingModule module; 151 TestingModule module;
152 WasmFunctionCompiler t(sigs.i_i(), &module); 152 WasmFunctionCompiler t(sigs.i_i(), &module);
153 uint32_t js_index = 153 uint32_t js_index =
154 module.AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })"); 154 module.AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })");
155 BUILD(t, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0))); 155 BUILD(t, WASM_CALL_FUNCTION1(js_index, WASM_GET_LOCAL(0)));
156 156
157 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); 157 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
158 158
159 EXPECT_CALL(101, jsfunc, 2, -8); 159 EXPECT_CALL(101, jsfunc, 2, -8);
160 EXPECT_CALL(199, jsfunc, 100, -1); 160 EXPECT_CALL(199, jsfunc, 100, -1);
161 EXPECT_CALL(-666666801, jsfunc, -666666900, -1); 161 EXPECT_CALL(-666666801, jsfunc, -666666900, -1);
162 } 162 }
163 163
164 void RunJSSelectTest(int which) { 164 void RunJSSelectTest(int which) {
165 const int kMaxParams = 8; 165 const int kMaxParams = 8;
166 PredictableInputValues inputs(0x100); 166 PredictableInputValues inputs(0x100);
167 LocalType type = kAstF64; 167 LocalType type = kAstF64;
168 LocalType types[kMaxParams + 1] = {type, type, type, type, type, 168 LocalType types[kMaxParams + 1] = {type, type, type, type, type,
169 type, type, type, type}; 169 type, type, type, type};
170 for (int num_params = which + 1; num_params < kMaxParams; num_params++) { 170 for (int num_params = which + 1; num_params < kMaxParams; num_params++) {
171 HandleScope scope(CcTest::InitIsolateOnce()); 171 HandleScope scope(CcTest::InitIsolateOnce());
172 FunctionSig sig(1, num_params, types); 172 FunctionSig sig(1, num_params, types);
173 173
174 TestingModule module; 174 TestingModule module;
175 uint32_t js_index = AddJSSelector(&module, &sig, which); 175 uint32_t js_index = AddJSSelector(&module, &sig, which);
176 WasmFunctionCompiler t(&sig, &module); 176 WasmFunctionCompiler t(&sig, &module);
177 177
178 { 178 {
179 std::vector<byte> code; 179 std::vector<byte> code;
180 180
181 for (int i = 0; i < num_params; i++) { 181 for (int i = 0; i < num_params; i++) {
182 ADD_CODE(code, WASM_F64(inputs.arg_d(i))); 182 ADD_CODE(code, WASM_F64(inputs.arg_d(i)));
183 } 183 }
184 184
185 ADD_CODE(code, kExprCallFunction, static_cast<byte>(js_index)); 185 ADD_CODE(code, kExprCallFunction, static_cast<byte>(num_params),
186 static_cast<byte>(js_index));
186 187
187 size_t end = code.size(); 188 size_t end = code.size();
188 code.push_back(0); 189 code.push_back(0);
189 t.Build(&code[0], &code[end]); 190 t.Build(&code[0], &code[end]);
190 } 191 }
191 192
192 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); 193 Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
193 double expected = inputs.arg_d(which); 194 double expected = inputs.arg_d(which);
194 EXPECT_CALL(expected, jsfunc, 0.0, 0.0); 195 EXPECT_CALL(expected, jsfunc, 0.0, 0.0);
195 } 196 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 type, type, type, type, type}; 413 type, type, type, type, type};
413 FunctionSig sig(1, num_params, types); 414 FunctionSig sig(1, num_params, types);
414 415
415 // Build the calling code. 416 // Build the calling code.
416 std::vector<byte> code; 417 std::vector<byte> code;
417 418
418 for (int i = 0; i < num_params; i++) { 419 for (int i = 0; i < num_params; i++) {
419 ADD_CODE(code, WASM_GET_LOCAL(i)); 420 ADD_CODE(code, WASM_GET_LOCAL(i));
420 } 421 }
421 422
422 ADD_CODE(code, kExprCallFunction, 0); 423 ADD_CODE(code, kExprCallFunction, static_cast<byte>(num_params), 0);
423 424
424 size_t end = code.size(); 425 size_t end = code.size();
425 code.push_back(0); 426 code.push_back(0);
426 427
427 // Call different select JS functions. 428 // Call different select JS functions.
428 for (int which = 0; which < num_params; which++) { 429 for (int which = 0; which < num_params; which++) {
429 HandleScope scope(isolate); 430 HandleScope scope(isolate);
430 TestingModule module; 431 TestingModule module;
431 uint32_t js_index = AddJSSelector(&module, &sig, which); 432 uint32_t js_index = AddJSSelector(&module, &sig, which);
432 CHECK_EQ(0, js_index); 433 CHECK_EQ(0, js_index);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 RunJSSelectAlignTest(9, 9); 509 RunJSSelectAlignTest(9, 9);
509 } 510 }
510 511
511 TEST(Run_JSSelectAlign_10) { 512 TEST(Run_JSSelectAlign_10) {
512 CcTest::InitializeVM(); 513 CcTest::InitializeVM();
513 RunJSSelectAlignTest(10, 7); 514 RunJSSelectAlignTest(10, 7);
514 RunJSSelectAlignTest(10, 8); 515 RunJSSelectAlignTest(10, 8);
515 RunJSSelectAlignTest(10, 9); 516 RunJSSelectAlignTest(10, 9);
516 RunJSSelectAlignTest(10, 10); 517 RunJSSelectAlignTest(10, 10);
517 } 518 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-interpreter.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