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

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

Issue 2251863004: [interpreter] Fixes the collection of type feedback in the bitwise binary operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « src/interpreter/interpreter-assembler.cc ('k') | no next file » | 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 "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/bytecode-array-iterator.h" 10 #include "src/interpreter/bytecode-array-iterator.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 Handle<Smi> arg6 = Handle<Smi>(Smi::FromInt(6), handles.main_isolate()); 513 Handle<Smi> arg6 = Handle<Smi>(Smi::FromInt(6), handles.main_isolate());
514 Handle<Smi> arg7 = Handle<Smi>(Smi::FromInt(7), handles.main_isolate()); 514 Handle<Smi> arg7 = Handle<Smi>(Smi::FromInt(7), handles.main_isolate());
515 Handle<Smi> arg8 = Handle<Smi>(Smi::FromInt(8), handles.main_isolate()); 515 Handle<Smi> arg8 = Handle<Smi>(Smi::FromInt(8), handles.main_isolate());
516 // Check for Smis. 516 // Check for Smis.
517 Handle<Object> return_val = 517 Handle<Object> return_val =
518 callable(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) 518 callable(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
519 .ToHandleChecked(); 519 .ToHandleChecked();
520 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(36)); 520 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(36));
521 } 521 }
522 522
523 TEST(InterpreterBitwiseTypeFeedback) {
524 HandleAndZoneScope handles;
525 i::Isolate* isolate = handles.main_isolate();
526 i::Zone zone(isolate->allocator());
527 const Token::Value kBitwiseBinaryOperators[] = {
528 Token::Value::BIT_OR, Token::Value::BIT_XOR, Token::Value::BIT_AND,
529 Token::Value::SHL, Token::Value::SHR, Token::Value::SAR};
530
531 for (Token::Value op : kBitwiseBinaryOperators) {
532 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 4, 0, 0);
533
534 i::FeedbackVectorSpec feedback_spec(&zone);
535 i::FeedbackVectorSlot slot0 = feedback_spec.AddGeneralSlot();
536 i::FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot();
537 i::FeedbackVectorSlot slot2 = feedback_spec.AddGeneralSlot();
538
539 Handle<i::TypeFeedbackVector> vector =
540 i::NewTypeFeedbackVector(isolate, &feedback_spec);
541
542 builder.LoadAccumulatorWithRegister(builder.Parameter(0))
543 .BinaryOperation(op, builder.Parameter(1), vector->GetIndex(slot0))
544 .BinaryOperation(op, builder.Parameter(2), vector->GetIndex(slot1))
545 .BinaryOperation(op, builder.Parameter(3), vector->GetIndex(slot2))
546 .Return();
547
548 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
549
550 InterpreterTester tester(isolate, bytecode_array, vector);
551 typedef Handle<Object> H;
552 auto callable = tester.GetCallable<H, H, H, H>();
553
554 Handle<Smi> arg1 = Handle<Smi>(Smi::FromInt(2), isolate);
555 Handle<Smi> arg2 = Handle<Smi>(Smi::FromInt(2), isolate);
556 Handle<HeapNumber> arg3 = isolate->factory()->NewHeapNumber(2.2);
557 Handle<String> arg4 = isolate->factory()->NewStringFromAsciiChecked("2");
558
559 Handle<Object> return_val =
560 callable(arg1, arg2, arg3, arg4).ToHandleChecked();
561 USE(return_val);
562 Object* feedback0 = vector->Get(slot0);
563 CHECK(feedback0->IsSmi());
564 CHECK_EQ(BinaryOperationFeedback::kSignedSmall,
565 static_cast<Smi*>(feedback0)->value());
566
567 Object* feedback1 = vector->Get(slot1);
568 CHECK(feedback1->IsSmi());
569 CHECK_EQ(BinaryOperationFeedback::kNumber,
570 static_cast<Smi*>(feedback1)->value());
571
572 Object* feedback2 = vector->Get(slot2);
573 CHECK(feedback2->IsSmi());
574 CHECK_EQ(BinaryOperationFeedback::kAny,
575 static_cast<Smi*>(feedback2)->value());
576 }
577 }
523 578
524 TEST(InterpreterParameter1Assign) { 579 TEST(InterpreterParameter1Assign) {
525 HandleAndZoneScope handles; 580 HandleAndZoneScope handles;
526 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 581 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
527 0, 0); 582 0, 0);
528 583
529 builder.LoadLiteral(Smi::FromInt(5)) 584 builder.LoadLiteral(Smi::FromInt(5))
530 .StoreAccumulatorInRegister(builder.Parameter(0)) 585 .StoreAccumulatorInRegister(builder.Parameter(0))
531 .LoadAccumulatorWithRegister(builder.Parameter(0)) 586 .LoadAccumulatorWithRegister(builder.Parameter(0))
532 .Return(); 587 .Return();
(...skipping 3778 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 auto callable = tester.GetCallable<>(); 4366 auto callable = tester.GetCallable<>();
4312 4367
4313 Handle<i::Object> return_value = callable().ToHandleChecked(); 4368 Handle<i::Object> return_value = callable().ToHandleChecked();
4314 CHECK(return_value->SameValue(*tests[i].second)); 4369 CHECK(return_value->SameValue(*tests[i].second));
4315 } 4370 }
4316 } 4371 }
4317 4372
4318 } // namespace interpreter 4373 } // namespace interpreter
4319 } // namespace internal 4374 } // namespace internal
4320 } // namespace v8 4375 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698