OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/ic/ic.h" | 5 #include "src/ic/ic.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/api-arguments.h" | 9 #include "src/api-arguments.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 vector_set_ = true; | 787 vector_set_ = true; |
788 break; | 788 break; |
789 case DEBUG_STUB: | 789 case DEBUG_STUB: |
790 break; | 790 break; |
791 case GENERIC: | 791 case GENERIC: |
792 UNREACHABLE(); | 792 UNREACHABLE(); |
793 break; | 793 break; |
794 } | 794 } |
795 } | 795 } |
796 | 796 |
797 | |
798 Handle<Code> LoadIC::initialize_stub(Isolate* isolate, | |
799 ExtraICState extra_state) { | |
800 return LoadICTrampolineStub(isolate, LoadICState(extra_state)).GetCode(); | |
801 } | |
802 | |
803 | |
804 Handle<Code> LoadIC::initialize_stub_in_optimized_code( | 797 Handle<Code> LoadIC::initialize_stub_in_optimized_code( |
805 Isolate* isolate, ExtraICState extra_state, State initialization_state) { | 798 Isolate* isolate, ExtraICState extra_state, State initialization_state) { |
806 return LoadICStub(isolate, LoadICState(extra_state)).GetCode(); | 799 return LoadICStub(isolate, LoadICState(extra_state)).GetCode(); |
807 } | 800 } |
808 | 801 |
809 | |
810 Handle<Code> KeyedLoadIC::initialize_stub(Isolate* isolate, | |
811 ExtraICState extra_state) { | |
812 return KeyedLoadICTrampolineStub(isolate, LoadICState(extra_state)).GetCode(); | |
813 } | |
814 | |
815 | |
816 Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code( | 802 Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code( |
817 Isolate* isolate, State initialization_state, ExtraICState extra_state) { | 803 Isolate* isolate, State initialization_state, ExtraICState extra_state) { |
818 if (initialization_state != MEGAMORPHIC) { | 804 if (initialization_state != MEGAMORPHIC) { |
819 return KeyedLoadICStub(isolate, LoadICState(extra_state)).GetCode(); | 805 return KeyedLoadICStub(isolate, LoadICState(extra_state)).GetCode(); |
820 } | 806 } |
821 return isolate->builtins()->KeyedLoadIC_Megamorphic(); | 807 return isolate->builtins()->KeyedLoadIC_Megamorphic(); |
822 } | 808 } |
823 | 809 |
824 | 810 |
825 static Handle<Code> KeyedStoreICInitializeStubHelper( | |
826 Isolate* isolate, LanguageMode language_mode, | |
827 InlineCacheState initialization_state) { | |
828 switch (initialization_state) { | |
829 case MEGAMORPHIC: | |
830 return is_strict(language_mode) | |
831 ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict() | |
832 : isolate->builtins()->KeyedStoreIC_Megamorphic(); | |
833 default: | |
834 UNREACHABLE(); | |
835 } | |
836 return Handle<Code>(); | |
837 } | |
838 | |
839 | |
840 Handle<Code> KeyedStoreIC::initialize_stub(Isolate* isolate, | |
841 LanguageMode language_mode, | |
842 State initialization_state) { | |
843 if (initialization_state != MEGAMORPHIC) { | |
844 VectorKeyedStoreICTrampolineStub stub(isolate, StoreICState(language_mode)); | |
845 return stub.GetCode(); | |
846 } | |
847 | |
848 return KeyedStoreICInitializeStubHelper(isolate, language_mode, | |
849 initialization_state); | |
850 } | |
851 | |
852 | |
853 Handle<Code> KeyedStoreIC::initialize_stub_in_optimized_code( | 811 Handle<Code> KeyedStoreIC::initialize_stub_in_optimized_code( |
854 Isolate* isolate, LanguageMode language_mode, State initialization_state) { | 812 Isolate* isolate, LanguageMode language_mode, State initialization_state) { |
| 813 StoreICState state = StoreICState(language_mode); |
855 if (initialization_state != MEGAMORPHIC) { | 814 if (initialization_state != MEGAMORPHIC) { |
856 VectorKeyedStoreICStub stub(isolate, StoreICState(language_mode)); | 815 return VectorKeyedStoreICStub(isolate, state).GetCode(); |
857 return stub.GetCode(); | |
858 } | 816 } |
859 | 817 return ChooseMegamorphicStub(isolate, state.GetExtraICState()); |
860 return KeyedStoreICInitializeStubHelper(isolate, language_mode, | |
861 initialization_state); | |
862 } | 818 } |
863 | 819 |
864 | 820 |
865 Handle<Code> KeyedStoreIC::ChooseMegamorphicStub(Isolate* isolate, | 821 Handle<Code> KeyedStoreIC::ChooseMegamorphicStub(Isolate* isolate, |
866 ExtraICState extra_state) { | 822 ExtraICState extra_state) { |
867 LanguageMode mode = StoreICState::GetLanguageMode(extra_state); | 823 LanguageMode mode = StoreICState::GetLanguageMode(extra_state); |
868 return KeyedStoreICInitializeStubHelper(isolate, mode, MEGAMORPHIC); | 824 return is_strict(mode) |
| 825 ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict() |
| 826 : isolate->builtins()->KeyedStoreIC_Megamorphic(); |
869 } | 827 } |
870 | 828 |
871 | 829 |
872 Handle<Code> LoadIC::SimpleFieldLoad(FieldIndex index) { | 830 Handle<Code> LoadIC::SimpleFieldLoad(FieldIndex index) { |
873 LoadFieldStub stub(isolate(), index); | 831 LoadFieldStub stub(isolate(), index); |
874 return stub.GetCode(); | 832 return stub.GetCode(); |
875 } | 833 } |
876 | 834 |
877 | 835 |
878 bool IsCompatibleReceiver(LookupIterator* lookup, Handle<Map> receiver_map) { | 836 bool IsCompatibleReceiver(LookupIterator* lookup, Handle<Map> receiver_map) { |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 } | 1414 } |
1457 | 1415 |
1458 LookupIterator it(object, name); | 1416 LookupIterator it(object, name); |
1459 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); | 1417 if (FLAG_use_ic) UpdateCaches(&it, value, store_mode); |
1460 | 1418 |
1461 MAYBE_RETURN_NULL( | 1419 MAYBE_RETURN_NULL( |
1462 Object::SetProperty(&it, value, language_mode(), store_mode)); | 1420 Object::SetProperty(&it, value, language_mode(), store_mode)); |
1463 return value; | 1421 return value; |
1464 } | 1422 } |
1465 | 1423 |
1466 Handle<Code> CallIC::initialize_stub(Isolate* isolate, int argc, | |
1467 ConvertReceiverMode mode, | |
1468 TailCallMode tail_call_mode) { | |
1469 CallICTrampolineStub stub(isolate, CallICState(argc, mode, tail_call_mode)); | |
1470 Handle<Code> code = stub.GetCode(); | |
1471 return code; | |
1472 } | |
1473 | |
1474 Handle<Code> CallIC::initialize_stub_in_optimized_code( | 1424 Handle<Code> CallIC::initialize_stub_in_optimized_code( |
1475 Isolate* isolate, int argc, ConvertReceiverMode mode, | 1425 Isolate* isolate, int argc, ConvertReceiverMode mode, |
1476 TailCallMode tail_call_mode) { | 1426 TailCallMode tail_call_mode) { |
1477 CallICStub stub(isolate, CallICState(argc, mode, tail_call_mode)); | 1427 CallICStub stub(isolate, CallICState(argc, mode, tail_call_mode)); |
1478 Handle<Code> code = stub.GetCode(); | 1428 Handle<Code> code = stub.GetCode(); |
1479 return code; | 1429 return code; |
1480 } | 1430 } |
1481 | 1431 |
1482 | 1432 |
1483 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, | |
1484 LanguageMode language_mode, | |
1485 State initialization_state) { | |
1486 DCHECK(initialization_state == UNINITIALIZED || | |
1487 initialization_state == PREMONOMORPHIC || | |
1488 initialization_state == MEGAMORPHIC); | |
1489 VectorStoreICTrampolineStub stub(isolate, StoreICState(language_mode)); | |
1490 return stub.GetCode(); | |
1491 } | |
1492 | |
1493 | |
1494 Handle<Code> StoreIC::initialize_stub_in_optimized_code( | 1433 Handle<Code> StoreIC::initialize_stub_in_optimized_code( |
1495 Isolate* isolate, LanguageMode language_mode, State initialization_state) { | 1434 Isolate* isolate, LanguageMode language_mode, State initialization_state) { |
1496 DCHECK(initialization_state == UNINITIALIZED || | 1435 DCHECK(initialization_state == UNINITIALIZED || |
1497 initialization_state == PREMONOMORPHIC || | 1436 initialization_state == PREMONOMORPHIC || |
1498 initialization_state == MEGAMORPHIC); | 1437 initialization_state == MEGAMORPHIC); |
1499 if (initialization_state != MEGAMORPHIC) { | 1438 if (initialization_state != MEGAMORPHIC) { |
1500 VectorStoreICStub stub(isolate, StoreICState(language_mode)); | 1439 VectorStoreICStub stub(isolate, StoreICState(language_mode)); |
1501 return stub.GetCode(); | 1440 return stub.GetCode(); |
1502 } | 1441 } |
1503 | 1442 |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2810 KeyedLoadICNexus nexus(vector, vector_slot); | 2749 KeyedLoadICNexus nexus(vector, vector_slot); |
2811 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2750 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2812 ic.UpdateState(receiver, key); | 2751 ic.UpdateState(receiver, key); |
2813 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 2752 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
2814 } | 2753 } |
2815 | 2754 |
2816 return *result; | 2755 return *result; |
2817 } | 2756 } |
2818 } // namespace internal | 2757 } // namespace internal |
2819 } // namespace v8 | 2758 } // namespace v8 |
OLD | NEW |