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

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

Issue 2342853002: [TypeFeedbackVector] special ic slots for interpreter compare/binary ops. (Closed)
Patch Set: Code comments. 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
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 <tuple> 5 #include <tuple>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/execution.h" 9 #include "src/execution.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { 262 for (size_t l = 0; l < arraysize(lhs_inputs); l++) {
263 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { 263 for (size_t r = 0; r < arraysize(rhs_inputs); r++) {
264 for (size_t o = 0; o < arraysize(kShiftOperators); o++) { 264 for (size_t o = 0; o < arraysize(kShiftOperators); o++) {
265 HandleAndZoneScope handles; 265 HandleAndZoneScope handles;
266 Isolate* isolate = handles.main_isolate(); 266 Isolate* isolate = handles.main_isolate();
267 Factory* factory = isolate->factory(); 267 Factory* factory = isolate->factory();
268 Zone zone(isolate->allocator()); 268 Zone zone(isolate->allocator());
269 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); 269 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
270 270
271 FeedbackVectorSpec feedback_spec(&zone); 271 FeedbackVectorSpec feedback_spec(&zone);
272 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 272 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
273 Handle<i::TypeFeedbackVector> vector = 273 Handle<i::TypeFeedbackVector> vector =
274 NewTypeFeedbackVector(isolate, &feedback_spec); 274 NewTypeFeedbackVector(isolate, &feedback_spec);
275 275
276 Register reg(0); 276 Register reg(0);
277 int lhs = lhs_inputs[l]; 277 int lhs = lhs_inputs[l];
278 int rhs = rhs_inputs[r]; 278 int rhs = rhs_inputs[r];
279 builder.LoadLiteral(Smi::FromInt(lhs)) 279 builder.LoadLiteral(Smi::FromInt(lhs))
280 .StoreAccumulatorInRegister(reg) 280 .StoreAccumulatorInRegister(reg)
281 .LoadLiteral(Smi::FromInt(rhs)) 281 .LoadLiteral(Smi::FromInt(rhs))
282 .BinaryOperation(kShiftOperators[o], reg, vector->GetIndex(slot)) 282 .BinaryOperation(kShiftOperators[o], reg, vector->GetIndex(slot))
(...skipping 18 matching lines...) Expand all
301 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { 301 for (size_t l = 0; l < arraysize(lhs_inputs); l++) {
302 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { 302 for (size_t r = 0; r < arraysize(rhs_inputs); r++) {
303 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { 303 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) {
304 HandleAndZoneScope handles; 304 HandleAndZoneScope handles;
305 Isolate* isolate = handles.main_isolate(); 305 Isolate* isolate = handles.main_isolate();
306 Factory* factory = isolate->factory(); 306 Factory* factory = isolate->factory();
307 Zone zone(isolate->allocator()); 307 Zone zone(isolate->allocator());
308 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); 308 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
309 309
310 FeedbackVectorSpec feedback_spec(&zone); 310 FeedbackVectorSpec feedback_spec(&zone);
311 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 311 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
312 Handle<i::TypeFeedbackVector> vector = 312 Handle<i::TypeFeedbackVector> vector =
313 NewTypeFeedbackVector(isolate, &feedback_spec); 313 NewTypeFeedbackVector(isolate, &feedback_spec);
314 314
315 Register reg(0); 315 Register reg(0);
316 int lhs = lhs_inputs[l]; 316 int lhs = lhs_inputs[l];
317 int rhs = rhs_inputs[r]; 317 int rhs = rhs_inputs[r];
318 builder.LoadLiteral(Smi::FromInt(lhs)) 318 builder.LoadLiteral(Smi::FromInt(lhs))
319 .StoreAccumulatorInRegister(reg) 319 .StoreAccumulatorInRegister(reg)
320 .LoadLiteral(Smi::FromInt(rhs)) 320 .LoadLiteral(Smi::FromInt(rhs))
321 .BinaryOperation(kArithmeticOperators[o], reg, 321 .BinaryOperation(kArithmeticOperators[o], reg,
(...skipping 20 matching lines...) Expand all
342 for (size_t l = 0; l < arraysize(lhs_inputs); l++) { 342 for (size_t l = 0; l < arraysize(lhs_inputs); l++) {
343 for (size_t r = 0; r < arraysize(rhs_inputs); r++) { 343 for (size_t r = 0; r < arraysize(rhs_inputs); r++) {
344 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) { 344 for (size_t o = 0; o < arraysize(kArithmeticOperators); o++) {
345 HandleAndZoneScope handles; 345 HandleAndZoneScope handles;
346 Isolate* isolate = handles.main_isolate(); 346 Isolate* isolate = handles.main_isolate();
347 Factory* factory = isolate->factory(); 347 Factory* factory = isolate->factory();
348 Zone zone(isolate->allocator()); 348 Zone zone(isolate->allocator());
349 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); 349 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
350 350
351 FeedbackVectorSpec feedback_spec(&zone); 351 FeedbackVectorSpec feedback_spec(&zone);
352 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 352 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
353 Handle<i::TypeFeedbackVector> vector = 353 Handle<i::TypeFeedbackVector> vector =
354 NewTypeFeedbackVector(isolate, &feedback_spec); 354 NewTypeFeedbackVector(isolate, &feedback_spec);
355 355
356 Register reg(0); 356 Register reg(0);
357 double lhs = lhs_inputs[l]; 357 double lhs = lhs_inputs[l];
358 double rhs = rhs_inputs[r]; 358 double rhs = rhs_inputs[r];
359 builder.LoadLiteral(factory->NewNumber(lhs)) 359 builder.LoadLiteral(factory->NewNumber(lhs))
360 .StoreAccumulatorInRegister(reg) 360 .StoreAccumulatorInRegister(reg)
361 .LoadLiteral(factory->NewNumber(rhs)) 361 .LoadLiteral(factory->NewNumber(rhs))
362 .BinaryOperation(kArithmeticOperators[o], reg, 362 .BinaryOperation(kArithmeticOperators[o], reg,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 458
459 TEST(InterpreterParameter8) { 459 TEST(InterpreterParameter8) {
460 HandleAndZoneScope handles; 460 HandleAndZoneScope handles;
461 Isolate* isolate = handles.main_isolate(); 461 Isolate* isolate = handles.main_isolate();
462 Zone zone(isolate->allocator()); 462 Zone zone(isolate->allocator());
463 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 8, 0, 0); 463 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 8, 0, 0);
464 464
465 FeedbackVectorSpec feedback_spec(&zone); 465 FeedbackVectorSpec feedback_spec(&zone);
466 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 466 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
467 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); 467 FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
468 FeedbackVectorSlot slot2 = feedback_spec.AddGeneralSlot(); 468 FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
469 FeedbackVectorSlot slot3 = feedback_spec.AddGeneralSlot(); 469 FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot();
470 FeedbackVectorSlot slot4 = feedback_spec.AddGeneralSlot(); 470 FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot();
471 FeedbackVectorSlot slot5 = feedback_spec.AddGeneralSlot(); 471 FeedbackVectorSlot slot5 = feedback_spec.AddInterpreterBinaryOpICSlot();
472 FeedbackVectorSlot slot6 = feedback_spec.AddGeneralSlot(); 472 FeedbackVectorSlot slot6 = feedback_spec.AddInterpreterBinaryOpICSlot();
473 473
474 Handle<i::TypeFeedbackVector> vector = 474 Handle<i::TypeFeedbackVector> vector =
475 NewTypeFeedbackVector(isolate, &feedback_spec); 475 NewTypeFeedbackVector(isolate, &feedback_spec);
476 476
477 builder.LoadAccumulatorWithRegister(builder.Parameter(0)) 477 builder.LoadAccumulatorWithRegister(builder.Parameter(0))
478 .BinaryOperation(Token::Value::ADD, builder.Parameter(1), 478 .BinaryOperation(Token::Value::ADD, builder.Parameter(1),
479 vector->GetIndex(slot)) 479 vector->GetIndex(slot))
480 .BinaryOperation(Token::Value::ADD, builder.Parameter(2), 480 .BinaryOperation(Token::Value::ADD, builder.Parameter(2),
481 vector->GetIndex(slot1)) 481 vector->GetIndex(slot1))
482 .BinaryOperation(Token::Value::ADD, builder.Parameter(3), 482 .BinaryOperation(Token::Value::ADD, builder.Parameter(3),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 isolate->factory()->NewHeapNumber(fmod(-3.1415, -1.4142)), 625 isolate->factory()->NewHeapNumber(fmod(-3.1415, -1.4142)),
626 BinaryOperationFeedback::kNumber}, 626 BinaryOperationFeedback::kNumber},
627 {Token::Value::MOD, Handle<Smi>(Smi::FromInt(3), isolate), 627 {Token::Value::MOD, Handle<Smi>(Smi::FromInt(3), isolate),
628 isolate->factory()->NewStringFromAsciiChecked("-2"), 628 isolate->factory()->NewStringFromAsciiChecked("-2"),
629 Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kAny}}; 629 Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kAny}};
630 630
631 for (const BinaryOpExpectation& test_case : kTestCases) { 631 for (const BinaryOpExpectation& test_case : kTestCases) {
632 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); 632 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
633 633
634 i::FeedbackVectorSpec feedback_spec(&zone); 634 i::FeedbackVectorSpec feedback_spec(&zone);
635 i::FeedbackVectorSlot slot0 = feedback_spec.AddGeneralSlot(); 635 i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot();
636 636
637 Handle<i::TypeFeedbackVector> vector = 637 Handle<i::TypeFeedbackVector> vector =
638 i::NewTypeFeedbackVector(isolate, &feedback_spec); 638 i::NewTypeFeedbackVector(isolate, &feedback_spec);
639 639
640 Register reg(0); 640 Register reg(0);
641 builder.LoadLiteral(test_case.arg1) 641 builder.LoadLiteral(test_case.arg1)
642 .StoreAccumulatorInRegister(reg) 642 .StoreAccumulatorInRegister(reg)
643 .LoadLiteral(test_case.arg2) 643 .LoadLiteral(test_case.arg2)
644 .BinaryOperation(test_case.op, reg, vector->GetIndex(slot0)) 644 .BinaryOperation(test_case.op, reg, vector->GetIndex(slot0))
645 .Return(); 645 .Return();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 BinaryOperationFeedback::kSignedSmall}, 729 BinaryOperationFeedback::kSignedSmall},
730 {Token::Value::SAR, isolate->factory()->NewHeapNumber(3.1415), 2, 730 {Token::Value::SAR, isolate->factory()->NewHeapNumber(3.1415), 2,
731 Handle<Smi>(Smi::FromInt(0), isolate), BinaryOperationFeedback::kNumber}, 731 Handle<Smi>(Smi::FromInt(0), isolate), BinaryOperationFeedback::kNumber},
732 {Token::Value::SAR, isolate->factory()->NewStringFromAsciiChecked("2"), 1, 732 {Token::Value::SAR, isolate->factory()->NewStringFromAsciiChecked("2"), 1,
733 Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kAny}}; 733 Handle<Smi>(Smi::FromInt(1), isolate), BinaryOperationFeedback::kAny}};
734 734
735 for (const BinaryOpExpectation& test_case : kTestCases) { 735 for (const BinaryOpExpectation& test_case : kTestCases) {
736 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); 736 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
737 737
738 i::FeedbackVectorSpec feedback_spec(&zone); 738 i::FeedbackVectorSpec feedback_spec(&zone);
739 i::FeedbackVectorSlot slot0 = feedback_spec.AddGeneralSlot(); 739 i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot();
740 740
741 Handle<i::TypeFeedbackVector> vector = 741 Handle<i::TypeFeedbackVector> vector =
742 i::NewTypeFeedbackVector(isolate, &feedback_spec); 742 i::NewTypeFeedbackVector(isolate, &feedback_spec);
743 743
744 Register reg(0); 744 Register reg(0);
745 builder.LoadLiteral(test_case.arg1) 745 builder.LoadLiteral(test_case.arg1)
746 .StoreAccumulatorInRegister(reg) 746 .StoreAccumulatorInRegister(reg)
747 .LoadLiteral(Smi::FromInt(test_case.arg2)) 747 .LoadLiteral(Smi::FromInt(test_case.arg2))
748 .BinaryOperation(test_case.op, reg, vector->GetIndex(slot0)) 748 .BinaryOperation(test_case.op, reg, vector->GetIndex(slot0))
749 .Return(); 749 .Return();
(...skipping 29 matching lines...) Expand all
779 Handle<HeapNumber> number_feedback_value; 779 Handle<HeapNumber> number_feedback_value;
780 Handle<Object> any_feedback_value; 780 Handle<Object> any_feedback_value;
781 }; 781 };
782 TestCase const kTestCases[] = { 782 TestCase const kTestCases[] = {
783 {Token::Value::ADD, smi_one, smi_max, number, str}, 783 {Token::Value::ADD, smi_one, smi_max, number, str},
784 {Token::Value::SUB, smi_one, smi_min, number, str}}; 784 {Token::Value::SUB, smi_one, smi_min, number, str}};
785 for (TestCase const& test_case : kTestCases) { 785 for (TestCase const& test_case : kTestCases) {
786 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 4, 0, 0); 786 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 4, 0, 0);
787 787
788 i::FeedbackVectorSpec feedback_spec(&zone); 788 i::FeedbackVectorSpec feedback_spec(&zone);
789 i::FeedbackVectorSlot slot0 = feedback_spec.AddGeneralSlot(); 789 i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot();
790 i::FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); 790 i::FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
791 i::FeedbackVectorSlot slot2 = feedback_spec.AddGeneralSlot(); 791 i::FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
792 i::FeedbackVectorSlot slot3 = feedback_spec.AddGeneralSlot(); 792 i::FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot();
793 793
794 Handle<i::TypeFeedbackVector> vector = 794 Handle<i::TypeFeedbackVector> vector =
795 i::NewTypeFeedbackVector(isolate, &feedback_spec); 795 i::NewTypeFeedbackVector(isolate, &feedback_spec);
796 796
797 builder.LoadAccumulatorWithRegister(builder.Parameter(0)) 797 builder.LoadAccumulatorWithRegister(builder.Parameter(0))
798 .CountOperation(test_case.op, vector->GetIndex(slot0)) 798 .CountOperation(test_case.op, vector->GetIndex(slot0))
799 .LoadAccumulatorWithRegister(builder.Parameter(1)) 799 .LoadAccumulatorWithRegister(builder.Parameter(1))
800 .CountOperation(test_case.op, vector->GetIndex(slot1)) 800 .CountOperation(test_case.op, vector->GetIndex(slot1))
801 .LoadAccumulatorWithRegister(builder.Parameter(2)) 801 .LoadAccumulatorWithRegister(builder.Parameter(2))
802 .CountOperation(test_case.op, vector->GetIndex(slot2)) 802 .CountOperation(test_case.op, vector->GetIndex(slot2))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 i::Isolate* isolate = handles.main_isolate(); 843 i::Isolate* isolate = handles.main_isolate();
844 i::Zone zone(isolate->allocator()); 844 i::Zone zone(isolate->allocator());
845 const Token::Value kBitwiseBinaryOperators[] = { 845 const Token::Value kBitwiseBinaryOperators[] = {
846 Token::Value::BIT_OR, Token::Value::BIT_XOR, Token::Value::BIT_AND, 846 Token::Value::BIT_OR, Token::Value::BIT_XOR, Token::Value::BIT_AND,
847 Token::Value::SHL, Token::Value::SHR, Token::Value::SAR}; 847 Token::Value::SHL, Token::Value::SHR, Token::Value::SAR};
848 848
849 for (Token::Value op : kBitwiseBinaryOperators) { 849 for (Token::Value op : kBitwiseBinaryOperators) {
850 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 4, 0, 0); 850 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 4, 0, 0);
851 851
852 i::FeedbackVectorSpec feedback_spec(&zone); 852 i::FeedbackVectorSpec feedback_spec(&zone);
853 i::FeedbackVectorSlot slot0 = feedback_spec.AddGeneralSlot(); 853 i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot();
854 i::FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); 854 i::FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
855 i::FeedbackVectorSlot slot2 = feedback_spec.AddGeneralSlot(); 855 i::FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
856 856
857 Handle<i::TypeFeedbackVector> vector = 857 Handle<i::TypeFeedbackVector> vector =
858 i::NewTypeFeedbackVector(isolate, &feedback_spec); 858 i::NewTypeFeedbackVector(isolate, &feedback_spec);
859 859
860 builder.LoadAccumulatorWithRegister(builder.Parameter(0)) 860 builder.LoadAccumulatorWithRegister(builder.Parameter(0))
861 .BinaryOperation(op, builder.Parameter(1), vector->GetIndex(slot0)) 861 .BinaryOperation(op, builder.Parameter(1), vector->GetIndex(slot0))
862 .BinaryOperation(op, builder.Parameter(2), vector->GetIndex(slot1)) 862 .BinaryOperation(op, builder.Parameter(2), vector->GetIndex(slot1))
863 .BinaryOperation(op, builder.Parameter(3), vector->GetIndex(slot2)) 863 .BinaryOperation(op, builder.Parameter(3), vector->GetIndex(slot2))
864 .Return(); 864 .Return();
865 865
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 } 1385 }
1386 1386
1387 1387
1388 TEST(InterpreterJumps) { 1388 TEST(InterpreterJumps) {
1389 HandleAndZoneScope handles; 1389 HandleAndZoneScope handles;
1390 Isolate* isolate = handles.main_isolate(); 1390 Isolate* isolate = handles.main_isolate();
1391 Zone zone(isolate->allocator()); 1391 Zone zone(isolate->allocator());
1392 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2); 1392 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2);
1393 1393
1394 FeedbackVectorSpec feedback_spec(&zone); 1394 FeedbackVectorSpec feedback_spec(&zone);
1395 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1395 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
1396 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); 1396 FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
1397 FeedbackVectorSlot slot2 = feedback_spec.AddGeneralSlot(); 1397 FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
1398 1398
1399 Handle<i::TypeFeedbackVector> vector = 1399 Handle<i::TypeFeedbackVector> vector =
1400 NewTypeFeedbackVector(isolate, &feedback_spec); 1400 NewTypeFeedbackVector(isolate, &feedback_spec);
1401 1401
1402 Register reg(0), scratch(1); 1402 Register reg(0), scratch(1);
1403 BytecodeLabel label[3]; 1403 BytecodeLabel label[3];
1404 1404
1405 builder.LoadLiteral(Smi::FromInt(0)) 1405 builder.LoadLiteral(Smi::FromInt(0))
1406 .StoreAccumulatorInRegister(reg) 1406 .StoreAccumulatorInRegister(reg)
1407 .Jump(&label[1]); 1407 .Jump(&label[1]);
(...skipping 16 matching lines...) Expand all
1424 } 1424 }
1425 1425
1426 1426
1427 TEST(InterpreterConditionalJumps) { 1427 TEST(InterpreterConditionalJumps) {
1428 HandleAndZoneScope handles; 1428 HandleAndZoneScope handles;
1429 Isolate* isolate = handles.main_isolate(); 1429 Isolate* isolate = handles.main_isolate();
1430 Zone zone(isolate->allocator()); 1430 Zone zone(isolate->allocator());
1431 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2); 1431 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2);
1432 1432
1433 FeedbackVectorSpec feedback_spec(&zone); 1433 FeedbackVectorSpec feedback_spec(&zone);
1434 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1434 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
1435 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); 1435 FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
1436 FeedbackVectorSlot slot2 = feedback_spec.AddGeneralSlot(); 1436 FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
1437 FeedbackVectorSlot slot3 = feedback_spec.AddGeneralSlot(); 1437 FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot();
1438 FeedbackVectorSlot slot4 = feedback_spec.AddGeneralSlot(); 1438 FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot();
1439 1439
1440 Handle<i::TypeFeedbackVector> vector = 1440 Handle<i::TypeFeedbackVector> vector =
1441 NewTypeFeedbackVector(isolate, &feedback_spec); 1441 NewTypeFeedbackVector(isolate, &feedback_spec);
1442 1442
1443 Register reg(0), scratch(1); 1443 Register reg(0), scratch(1);
1444 BytecodeLabel label[2]; 1444 BytecodeLabel label[2];
1445 BytecodeLabel done, done1; 1445 BytecodeLabel done, done1;
1446 1446
1447 builder.LoadLiteral(Smi::FromInt(0)) 1447 builder.LoadLiteral(Smi::FromInt(0))
1448 .StoreAccumulatorInRegister(reg) 1448 .StoreAccumulatorInRegister(reg)
(...skipping 25 matching lines...) Expand all
1474 } 1474 }
1475 1475
1476 TEST(InterpreterConditionalJumps2) { 1476 TEST(InterpreterConditionalJumps2) {
1477 // TODO(oth): Add tests for all conditional jumps near and far. 1477 // TODO(oth): Add tests for all conditional jumps near and far.
1478 HandleAndZoneScope handles; 1478 HandleAndZoneScope handles;
1479 Isolate* isolate = handles.main_isolate(); 1479 Isolate* isolate = handles.main_isolate();
1480 Zone zone(isolate->allocator()); 1480 Zone zone(isolate->allocator());
1481 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2); 1481 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 2);
1482 1482
1483 FeedbackVectorSpec feedback_spec(&zone); 1483 FeedbackVectorSpec feedback_spec(&zone);
1484 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1484 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
1485 FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot(); 1485 FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
1486 FeedbackVectorSlot slot2 = feedback_spec.AddGeneralSlot(); 1486 FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
1487 FeedbackVectorSlot slot3 = feedback_spec.AddGeneralSlot(); 1487 FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot();
1488 FeedbackVectorSlot slot4 = feedback_spec.AddGeneralSlot(); 1488 FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot();
1489 1489
1490 Handle<i::TypeFeedbackVector> vector = 1490 Handle<i::TypeFeedbackVector> vector =
1491 NewTypeFeedbackVector(isolate, &feedback_spec); 1491 NewTypeFeedbackVector(isolate, &feedback_spec);
1492 1492
1493 Register reg(0), scratch(1); 1493 Register reg(0), scratch(1);
1494 BytecodeLabel label[2]; 1494 BytecodeLabel label[2];
1495 BytecodeLabel done, done1; 1495 BytecodeLabel done, done1;
1496 1496
1497 builder.LoadLiteral(Smi::FromInt(0)) 1497 builder.LoadLiteral(Smi::FromInt(0))
1498 .StoreAccumulatorInRegister(reg) 1498 .StoreAccumulatorInRegister(reg)
(...skipping 25 matching lines...) Expand all
1524 } 1524 }
1525 1525
1526 TEST(InterpreterJumpConstantWith16BitOperand) { 1526 TEST(InterpreterJumpConstantWith16BitOperand) {
1527 HandleAndZoneScope handles; 1527 HandleAndZoneScope handles;
1528 Isolate* isolate = handles.main_isolate(); 1528 Isolate* isolate = handles.main_isolate();
1529 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 257); 1529 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 257);
1530 1530
1531 Zone zone(isolate->allocator()); 1531 Zone zone(isolate->allocator());
1532 1532
1533 FeedbackVectorSpec feedback_spec(&zone); 1533 FeedbackVectorSpec feedback_spec(&zone);
1534 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1534 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
1535 Handle<i::TypeFeedbackVector> vector = 1535 Handle<i::TypeFeedbackVector> vector =
1536 NewTypeFeedbackVector(isolate, &feedback_spec); 1536 NewTypeFeedbackVector(isolate, &feedback_spec);
1537 1537
1538 Register reg(0), scratch(256); 1538 Register reg(0), scratch(256);
1539 BytecodeLabel done, fake; 1539 BytecodeLabel done, fake;
1540 1540
1541 builder.LoadLiteral(Smi::FromInt(0)); 1541 builder.LoadLiteral(Smi::FromInt(0));
1542 builder.StoreAccumulatorInRegister(reg); 1542 builder.StoreAccumulatorInRegister(reg);
1543 // Consume all 8-bit operands 1543 // Consume all 8-bit operands
1544 for (int i = 1; i <= 256; i++) { 1544 for (int i = 1; i <= 256; i++) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { 1670 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) {
1671 Token::Value comparison = kComparisonTypes[c]; 1671 Token::Value comparison = kComparisonTypes[c];
1672 for (size_t i = 0; i < arraysize(inputs); i++) { 1672 for (size_t i = 0; i < arraysize(inputs); i++) {
1673 for (size_t j = 0; j < arraysize(inputs); j++) { 1673 for (size_t j = 0; j < arraysize(inputs); j++) {
1674 HandleAndZoneScope handles; 1674 HandleAndZoneScope handles;
1675 Isolate* isolate = handles.main_isolate(); 1675 Isolate* isolate = handles.main_isolate();
1676 Zone zone(isolate->allocator()); 1676 Zone zone(isolate->allocator());
1677 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); 1677 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1);
1678 1678
1679 FeedbackVectorSpec feedback_spec(&zone); 1679 FeedbackVectorSpec feedback_spec(&zone);
1680 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1680 FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
1681 Handle<i::TypeFeedbackVector> vector = 1681 Handle<i::TypeFeedbackVector> vector =
1682 NewTypeFeedbackVector(isolate, &feedback_spec); 1682 NewTypeFeedbackVector(isolate, &feedback_spec);
1683 1683
1684 Register r0(0); 1684 Register r0(0);
1685 builder.LoadLiteral(Smi::FromInt(inputs[i])) 1685 builder.LoadLiteral(Smi::FromInt(inputs[i]))
1686 .StoreAccumulatorInRegister(r0) 1686 .StoreAccumulatorInRegister(r0)
1687 .LoadLiteral(Smi::FromInt(inputs[j])) 1687 .LoadLiteral(Smi::FromInt(inputs[j]))
1688 .CompareOperation(comparison, r0, vector->GetIndex(slot)) 1688 .CompareOperation(comparison, r0, vector->GetIndex(slot))
1689 .Return(); 1689 .Return();
1690 1690
(...skipping 26 matching lines...) Expand all
1717 Token::Value comparison = kComparisonTypes[c]; 1717 Token::Value comparison = kComparisonTypes[c];
1718 for (size_t i = 0; i < arraysize(inputs); i++) { 1718 for (size_t i = 0; i < arraysize(inputs); i++) {
1719 for (size_t j = 0; j < arraysize(inputs); j++) { 1719 for (size_t j = 0; j < arraysize(inputs); j++) {
1720 HandleAndZoneScope handles; 1720 HandleAndZoneScope handles;
1721 Isolate* isolate = handles.main_isolate(); 1721 Isolate* isolate = handles.main_isolate();
1722 Factory* factory = isolate->factory(); 1722 Factory* factory = isolate->factory();
1723 Zone zone(isolate->allocator()); 1723 Zone zone(isolate->allocator());
1724 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); 1724 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1);
1725 1725
1726 FeedbackVectorSpec feedback_spec(&zone); 1726 FeedbackVectorSpec feedback_spec(&zone);
1727 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1727 FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
1728 Handle<i::TypeFeedbackVector> vector = 1728 Handle<i::TypeFeedbackVector> vector =
1729 NewTypeFeedbackVector(isolate, &feedback_spec); 1729 NewTypeFeedbackVector(isolate, &feedback_spec);
1730 1730
1731 Register r0(0); 1731 Register r0(0);
1732 builder.LoadLiteral(factory->NewHeapNumber(inputs[i])) 1732 builder.LoadLiteral(factory->NewHeapNumber(inputs[i]))
1733 .StoreAccumulatorInRegister(r0) 1733 .StoreAccumulatorInRegister(r0)
1734 .LoadLiteral(factory->NewHeapNumber(inputs[j])) 1734 .LoadLiteral(factory->NewHeapNumber(inputs[j]))
1735 .CompareOperation(comparison, r0, vector->GetIndex(slot)) 1735 .CompareOperation(comparison, r0, vector->GetIndex(slot))
1736 .Return(); 1736 .Return();
1737 1737
(...skipping 24 matching lines...) Expand all
1762 1762
1763 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { 1763 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) {
1764 Token::Value comparison = kComparisonTypes[c]; 1764 Token::Value comparison = kComparisonTypes[c];
1765 for (size_t i = 0; i < arraysize(inputs); i++) { 1765 for (size_t i = 0; i < arraysize(inputs); i++) {
1766 for (size_t j = 0; j < arraysize(inputs); j++) { 1766 for (size_t j = 0; j < arraysize(inputs); j++) {
1767 CanonicalHandleScope canonical(isolate); 1767 CanonicalHandleScope canonical(isolate);
1768 const char* lhs = inputs[i].c_str(); 1768 const char* lhs = inputs[i].c_str();
1769 const char* rhs = inputs[j].c_str(); 1769 const char* rhs = inputs[j].c_str();
1770 1770
1771 FeedbackVectorSpec feedback_spec(&zone); 1771 FeedbackVectorSpec feedback_spec(&zone);
1772 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1772 FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
1773 Handle<i::TypeFeedbackVector> vector = 1773 Handle<i::TypeFeedbackVector> vector =
1774 NewTypeFeedbackVector(isolate, &feedback_spec); 1774 NewTypeFeedbackVector(isolate, &feedback_spec);
1775 1775
1776 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); 1776 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1);
1777 Register r0(0); 1777 Register r0(0);
1778 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs)) 1778 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs))
1779 .StoreAccumulatorInRegister(r0) 1779 .StoreAccumulatorInRegister(r0)
1780 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs)) 1780 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs))
1781 .CompareOperation(comparison, r0, vector->GetIndex(slot)) 1781 .CompareOperation(comparison, r0, vector->GetIndex(slot))
1782 .Return(); 1782 .Return();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 ConversionFlags::NO_FLAGS); 1818 ConversionFlags::NO_FLAGS);
1819 double rhs = StringToDouble(&unicode_cache, rhs_cstr, 1819 double rhs = StringToDouble(&unicode_cache, rhs_cstr,
1820 ConversionFlags::NO_FLAGS); 1820 ConversionFlags::NO_FLAGS);
1821 HandleAndZoneScope handles; 1821 HandleAndZoneScope handles;
1822 Isolate* isolate = handles.main_isolate(); 1822 Isolate* isolate = handles.main_isolate();
1823 Factory* factory = isolate->factory(); 1823 Factory* factory = isolate->factory();
1824 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1); 1824 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1);
1825 Zone zone(isolate->allocator()); 1825 Zone zone(isolate->allocator());
1826 1826
1827 FeedbackVectorSpec feedback_spec(&zone); 1827 FeedbackVectorSpec feedback_spec(&zone);
1828 FeedbackVectorSlot slot = feedback_spec.AddGeneralSlot(); 1828 FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
1829 Handle<i::TypeFeedbackVector> vector = 1829 Handle<i::TypeFeedbackVector> vector =
1830 NewTypeFeedbackVector(isolate, &feedback_spec); 1830 NewTypeFeedbackVector(isolate, &feedback_spec);
1831 1831
1832 Register r0(0); 1832 Register r0(0);
1833 if (pass == 0) { 1833 if (pass == 0) {
1834 // Comparison with HeapNumber on the lhs and String on the rhs 1834 // Comparison with HeapNumber on the lhs and String on the rhs
1835 builder.LoadLiteral(factory->NewNumber(lhs)) 1835 builder.LoadLiteral(factory->NewNumber(lhs))
1836 .StoreAccumulatorInRegister(r0) 1836 .StoreAccumulatorInRegister(r0)
1837 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr)) 1837 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr))
1838 .CompareOperation(comparison, r0, vector->GetIndex(slot)) 1838 .CompareOperation(comparison, r0, vector->GetIndex(slot))
(...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after
4805 auto callable = tester.GetCallable<>(); 4805 auto callable = tester.GetCallable<>();
4806 4806
4807 Handle<i::Object> return_value = callable().ToHandleChecked(); 4807 Handle<i::Object> return_value = callable().ToHandleChecked();
4808 CHECK(return_value->SameValue(*tests[i].second)); 4808 CHECK(return_value->SameValue(*tests[i].second));
4809 } 4809 }
4810 } 4810 }
4811 4811
4812 } // namespace interpreter 4812 } // namespace interpreter
4813 } // namespace internal 4813 } // namespace internal
4814 } // namespace v8 4814 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698