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

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1595103006: [Interpreter] Preparation for wide registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 11 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 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/execution.h" 7 #include "src/execution.h"
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/interpreter/bytecode-array-builder.h" 9 #include "src/interpreter/bytecode-array-builder.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 355 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
356 356
357 InterpreterTester tester(handles.main_isolate(), bytecode_array); 357 InterpreterTester tester(handles.main_isolate(), bytecode_array);
358 auto callable = tester.GetCallable<>(); 358 auto callable = tester.GetCallable<>();
359 Handle<Object> return_val = callable().ToHandleChecked(); 359 Handle<Object> return_val = callable().ToHandleChecked();
360 CHECK(return_val.is_identical_to(true_value)); 360 CHECK(return_val.is_identical_to(true_value));
361 } 361 }
362 } 362 }
363 363
364 364
365 TEST(InterpreterExchangeRegisters) {
366 for (int locals_count = 2; locals_count < 300; locals_count += 126) {
367 HandleAndZoneScope handles;
368 for (int exchanges = 1; exchanges < 4; exchanges++) {
369 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone());
370 builder.set_locals_count(locals_count);
371 builder.set_context_count(0);
372 builder.set_parameter_count(0);
373
374 Register r0(0);
375 Register r1(locals_count - 1);
376 builder.LoadTrue();
377 builder.StoreAccumulatorInRegister(r0);
378 builder.ExchangeRegisters(r0, r1);
379 builder.LoadFalse();
380 builder.StoreAccumulatorInRegister(r0);
381
382 bool expected = false;
383 for (int i = 0; i < exchanges; i++) {
384 builder.ExchangeRegisters(r0, r1);
385 expected = !expected;
386 }
387 builder.LoadAccumulatorWithRegister(r0);
388 builder.Return();
389 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
390 InterpreterTester tester(handles.main_isolate(), bytecode_array);
391 auto callable = tester.GetCallable<>();
392 Handle<Object> return_val = callable().ToHandleChecked();
393 Handle<Object> expected_val =
394 handles.main_isolate()->factory()->ToBoolean(expected);
395 CHECK(return_val.is_identical_to(expected_val));
396 }
397 }
398 }
399
400
401 TEST(InterpreterExchangeRegistersWithParameter) {
402 for (int locals_count = 2; locals_count < 300; locals_count += 126) {
403 HandleAndZoneScope handles;
404 for (int exchanges = 1; exchanges < 4; exchanges++) {
405 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone());
406 builder.set_locals_count(locals_count);
407 builder.set_context_count(0);
408 builder.set_parameter_count(3);
409
410 Register r0 = Register::FromParameterIndex(2, 3);
411 Register r1(locals_count - 1);
412 builder.LoadTrue();
413 builder.StoreAccumulatorInRegister(r0);
414 builder.ExchangeRegisters(r0, r1);
415 builder.LoadFalse();
416 builder.StoreAccumulatorInRegister(r0);
417
418 bool expected = false;
419 for (int i = 0; i < exchanges; i++) {
420 builder.ExchangeRegisters(r0, r1);
421 expected = !expected;
422 }
423 builder.LoadAccumulatorWithRegister(r0);
424 builder.Return();
425 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
426 InterpreterTester tester(handles.main_isolate(), bytecode_array);
427 auto callable = tester.GetCallable<>();
428 Handle<Object> return_val = callable().ToHandleChecked();
429 Handle<Object> expected_val =
430 handles.main_isolate()->factory()->ToBoolean(expected);
431 CHECK(return_val.is_identical_to(expected_val));
432 }
433 }
434 }
435
436
437 TEST(InterpreterExchangeWideRegisters) {
438 for (int locals_count = 3; locals_count < 300; locals_count += 126) {
439 HandleAndZoneScope handles;
440 for (int exchanges = 0; exchanges < 7; exchanges++) {
441 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone());
442 builder.set_locals_count(locals_count);
443 builder.set_context_count(0);
444 builder.set_parameter_count(0);
445
446 Register r0(0);
447 Register r1(locals_count - 1);
448 Register r2(locals_count - 2);
449 builder.LoadLiteral(Smi::FromInt(200));
450 builder.StoreAccumulatorInRegister(r0);
451 builder.ExchangeRegisters(r0, r1);
452 builder.LoadLiteral(Smi::FromInt(100));
453 builder.StoreAccumulatorInRegister(r0);
454 builder.ExchangeRegisters(r0, r2);
455 builder.LoadLiteral(Smi::FromInt(0));
456 builder.StoreAccumulatorInRegister(r0);
457 for (int i = 0; i < exchanges; i++) {
458 builder.ExchangeRegisters(r1, r2);
459 builder.ExchangeRegisters(r0, r1);
460 }
461 builder.LoadAccumulatorWithRegister(r0);
462 builder.Return();
463 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
464 InterpreterTester tester(handles.main_isolate(), bytecode_array);
465 auto callable = tester.GetCallable<>();
466 Handle<Object> return_val = callable().ToHandleChecked();
467 Handle<Object> expected_val =
468 handles.main_isolate()->factory()->NewNumberFromInt(100 *
469 (exchanges % 3));
470 CHECK(return_val.is_identical_to(expected_val));
471 }
472 }
473 }
474
475
476 static const Token::Value kShiftOperators[] = { 365 static const Token::Value kShiftOperators[] = {
477 Token::Value::SHL, Token::Value::SAR, Token::Value::SHR}; 366 Token::Value::SHL, Token::Value::SAR, Token::Value::SHR};
478 367
479 368
480 static const Token::Value kArithmeticOperators[] = { 369 static const Token::Value kArithmeticOperators[] = {
481 Token::Value::BIT_OR, Token::Value::BIT_XOR, Token::Value::BIT_AND, 370 Token::Value::BIT_OR, Token::Value::BIT_XOR, Token::Value::BIT_AND,
482 Token::Value::SHL, Token::Value::SAR, Token::Value::SHR, 371 Token::Value::SHL, Token::Value::SAR, Token::Value::SHR,
483 Token::Value::ADD, Token::Value::SUB, Token::Value::MUL, 372 Token::Value::ADD, Token::Value::SUB, Token::Value::MUL,
484 Token::Value::DIV, Token::Value::MOD}; 373 Token::Value::DIV, Token::Value::MOD};
485 374
(...skipping 3147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3633 auto callable = tester.GetCallable<>(); 3522 auto callable = tester.GetCallable<>();
3634 3523
3635 Handle<i::Object> return_value = callable().ToHandleChecked(); 3524 Handle<i::Object> return_value = callable().ToHandleChecked();
3636 CHECK(return_value->SameValue(*eval_func_decl[i].second)); 3525 CHECK(return_value->SameValue(*eval_func_decl[i].second));
3637 } 3526 }
3638 } 3527 }
3639 3528
3640 } // namespace interpreter 3529 } // namespace interpreter
3641 } // namespace internal 3530 } // namespace internal
3642 } // namespace v8 3531 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/compiler/interpreter-assembler-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698