| 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 "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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 Handle<Object> return_val = callable().ToHandleChecked(); | 545 Handle<Object> return_val = callable().ToHandleChecked(); |
| 546 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(15)); | 546 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(15)); |
| 547 } | 547 } |
| 548 | 548 |
| 549 | 549 |
| 550 TEST(InterpreterLoadNamedProperty) { | 550 TEST(InterpreterLoadNamedProperty) { |
| 551 HandleAndZoneScope handles; | 551 HandleAndZoneScope handles; |
| 552 i::Isolate* isolate = handles.main_isolate(); | 552 i::Isolate* isolate = handles.main_isolate(); |
| 553 i::Factory* factory = isolate->factory(); | 553 i::Factory* factory = isolate->factory(); |
| 554 | 554 |
| 555 i::Code::Kind ic_kinds[] = {i::Code::LOAD_IC}; | 555 i::FeedbackVectorSlotKind ic_kinds[] = {i::FeedbackVectorSlotKind::LOAD_IC}; |
| 556 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 556 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); |
| 557 Handle<i::TypeFeedbackVector> vector = | 557 Handle<i::TypeFeedbackVector> vector = |
| 558 factory->NewTypeFeedbackVector(&feedback_spec); | 558 factory->NewTypeFeedbackVector(&feedback_spec); |
| 559 | 559 |
| 560 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 560 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 561 name = factory->string_table()->LookupString(isolate, name); | 561 name = factory->string_table()->LookupString(isolate, name); |
| 562 | 562 |
| 563 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 563 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 564 builder.set_locals_count(0); | 564 builder.set_locals_count(0); |
| 565 builder.set_parameter_count(1); | 565 builder.set_parameter_count(1); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 return_val = callable(object5).ToHandleChecked(); | 599 return_val = callable(object5).ToHandleChecked(); |
| 600 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); | 600 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); |
| 601 } | 601 } |
| 602 | 602 |
| 603 | 603 |
| 604 TEST(InterpreterLoadKeyedProperty) { | 604 TEST(InterpreterLoadKeyedProperty) { |
| 605 HandleAndZoneScope handles; | 605 HandleAndZoneScope handles; |
| 606 i::Isolate* isolate = handles.main_isolate(); | 606 i::Isolate* isolate = handles.main_isolate(); |
| 607 i::Factory* factory = isolate->factory(); | 607 i::Factory* factory = isolate->factory(); |
| 608 | 608 |
| 609 i::Code::Kind ic_kinds[] = { i::Code::KEYED_LOAD_IC }; | 609 i::FeedbackVectorSlotKind ic_kinds[] = { |
| 610 i::FeedbackVectorSlotKind::KEYED_LOAD_IC}; |
| 610 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 611 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); |
| 611 Handle<i::TypeFeedbackVector> vector = | 612 Handle<i::TypeFeedbackVector> vector = |
| 612 factory->NewTypeFeedbackVector(&feedback_spec); | 613 factory->NewTypeFeedbackVector(&feedback_spec); |
| 613 | 614 |
| 614 Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); | 615 Handle<i::String> key = factory->NewStringFromAsciiChecked("key"); |
| 615 key = factory->string_table()->LookupString(isolate, key); | 616 key = factory->string_table()->LookupString(isolate, key); |
| 616 | 617 |
| 617 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 618 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 618 builder.set_locals_count(1); | 619 builder.set_locals_count(1); |
| 619 builder.set_parameter_count(1); | 620 builder.set_parameter_count(1); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 641 return_val = callable(object3).ToHandleChecked(); | 642 return_val = callable(object3).ToHandleChecked(); |
| 642 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); | 643 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(789)); |
| 643 } | 644 } |
| 644 | 645 |
| 645 | 646 |
| 646 TEST(InterpreterStoreNamedProperty) { | 647 TEST(InterpreterStoreNamedProperty) { |
| 647 HandleAndZoneScope handles; | 648 HandleAndZoneScope handles; |
| 648 i::Isolate* isolate = handles.main_isolate(); | 649 i::Isolate* isolate = handles.main_isolate(); |
| 649 i::Factory* factory = isolate->factory(); | 650 i::Factory* factory = isolate->factory(); |
| 650 | 651 |
| 651 i::Code::Kind ic_kinds[] = {i::Code::STORE_IC}; | 652 i::FeedbackVectorSlotKind ic_kinds[] = {i::FeedbackVectorSlotKind::STORE_IC}; |
| 652 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 653 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); |
| 653 Handle<i::TypeFeedbackVector> vector = | 654 Handle<i::TypeFeedbackVector> vector = |
| 654 factory->NewTypeFeedbackVector(&feedback_spec); | 655 factory->NewTypeFeedbackVector(&feedback_spec); |
| 655 | 656 |
| 656 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 657 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 657 name = factory->string_table()->LookupString(isolate, name); | 658 name = factory->string_table()->LookupString(isolate, name); |
| 658 | 659 |
| 659 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 660 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 660 builder.set_locals_count(1); | 661 builder.set_locals_count(1); |
| 661 builder.set_parameter_count(1); | 662 builder.set_parameter_count(1); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 CHECK(Runtime::GetObjectProperty(isolate, object5, name).ToHandle(&result)); | 702 CHECK(Runtime::GetObjectProperty(isolate, object5, name).ToHandle(&result)); |
| 702 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); | 703 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); |
| 703 } | 704 } |
| 704 | 705 |
| 705 | 706 |
| 706 TEST(InterpreterStoreKeyedProperty) { | 707 TEST(InterpreterStoreKeyedProperty) { |
| 707 HandleAndZoneScope handles; | 708 HandleAndZoneScope handles; |
| 708 i::Isolate* isolate = handles.main_isolate(); | 709 i::Isolate* isolate = handles.main_isolate(); |
| 709 i::Factory* factory = isolate->factory(); | 710 i::Factory* factory = isolate->factory(); |
| 710 | 711 |
| 711 i::Code::Kind ic_kinds[] = {i::Code::KEYED_STORE_IC}; | 712 i::FeedbackVectorSlotKind ic_kinds[] = { |
| 713 i::FeedbackVectorSlotKind::KEYED_STORE_IC}; |
| 712 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 714 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); |
| 713 Handle<i::TypeFeedbackVector> vector = | 715 Handle<i::TypeFeedbackVector> vector = |
| 714 factory->NewTypeFeedbackVector(&feedback_spec); | 716 factory->NewTypeFeedbackVector(&feedback_spec); |
| 715 | 717 |
| 716 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); | 718 Handle<i::String> name = factory->NewStringFromAsciiChecked("val"); |
| 717 name = factory->string_table()->LookupString(isolate, name); | 719 name = factory->string_table()->LookupString(isolate, name); |
| 718 | 720 |
| 719 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 721 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 720 builder.set_locals_count(1); | 722 builder.set_locals_count(1); |
| 721 builder.set_parameter_count(1); | 723 builder.set_parameter_count(1); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 748 CHECK(Runtime::GetObjectProperty(isolate, object2, name).ToHandle(&result)); | 750 CHECK(Runtime::GetObjectProperty(isolate, object2, name).ToHandle(&result)); |
| 749 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); | 751 CHECK_EQ(Smi::cast(*result), Smi::FromInt(999)); |
| 750 } | 752 } |
| 751 | 753 |
| 752 | 754 |
| 753 TEST(InterpreterCall) { | 755 TEST(InterpreterCall) { |
| 754 HandleAndZoneScope handles; | 756 HandleAndZoneScope handles; |
| 755 i::Isolate* isolate = handles.main_isolate(); | 757 i::Isolate* isolate = handles.main_isolate(); |
| 756 i::Factory* factory = isolate->factory(); | 758 i::Factory* factory = isolate->factory(); |
| 757 | 759 |
| 758 i::Code::Kind ic_kinds[] = { i::Code::LOAD_IC }; | 760 i::FeedbackVectorSlotKind ic_kinds[] = {i::FeedbackVectorSlotKind::LOAD_IC}; |
| 759 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); | 761 i::FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); |
| 760 Handle<i::TypeFeedbackVector> vector = | 762 Handle<i::TypeFeedbackVector> vector = |
| 761 factory->NewTypeFeedbackVector(&feedback_spec); | 763 factory->NewTypeFeedbackVector(&feedback_spec); |
| 762 | 764 |
| 763 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); | 765 Handle<i::String> name = factory->NewStringFromAsciiChecked("func"); |
| 764 name = factory->string_table()->LookupString(isolate, name); | 766 name = factory->string_table()->LookupString(isolate, name); |
| 765 | 767 |
| 766 // Check with no args. | 768 // Check with no args. |
| 767 { | 769 { |
| 768 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); | 770 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 .Bind(&done) | 969 .Bind(&done) |
| 968 .Bind(&done1) | 970 .Bind(&done1) |
| 969 .Return(); | 971 .Return(); |
| 970 | 972 |
| 971 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 973 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 972 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 974 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 973 auto callable = tester.GetCallable<>(); | 975 auto callable = tester.GetCallable<>(); |
| 974 Handle<Object> return_value = callable().ToHandleChecked(); | 976 Handle<Object> return_value = callable().ToHandleChecked(); |
| 975 CHECK_EQ(Smi::cast(*return_value)->value(), 7); | 977 CHECK_EQ(Smi::cast(*return_value)->value(), 7); |
| 976 } | 978 } |
| OLD | NEW |