OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 ASSERT_EQ(flags, code->flags()); | 671 ASSERT_EQ(flags, code->flags()); |
672 PROFILE(isolate(), | 672 PROFILE(isolate(), |
673 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); | 673 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); |
674 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); | 674 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); |
675 JSObject::UpdateMapCodeCache(map_holder, name, code); | 675 JSObject::UpdateMapCodeCache(map_holder, name, code); |
676 return code; | 676 return code; |
677 } | 677 } |
678 | 678 |
679 | 679 |
680 static void FillCache(Isolate* isolate, Handle<Code> code) { | 680 static void FillCache(Isolate* isolate, Handle<Code> code) { |
681 Handle<NumberDictionary> dictionary = | 681 Handle<NotSeededNumberDictionary> dictionary = |
682 NumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), | 682 NotSeededNumberDictionary::Set( |
| 683 isolate->factory()->non_monomorphic_cache(), |
683 code->flags(), | 684 code->flags(), |
684 code, | 685 code, |
685 PropertyDetails(NONE, NORMAL)); | 686 PropertyDetails(NONE, NORMAL)); |
686 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); | 687 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); |
687 } | 688 } |
688 | 689 |
689 | 690 |
690 Code* StubCache::FindCallInitialize(int argc, | 691 Code* StubCache::FindCallInitialize(int argc, |
691 RelocInfo::Mode mode, | 692 RelocInfo::Mode mode, |
692 Code::Kind kind) { | 693 Code::Kind kind) { |
693 Code::ExtraICState extra_state = | 694 Code::ExtraICState extra_state = |
694 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 695 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | |
695 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); | 696 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); |
696 Code::Flags flags = | 697 Code::Flags flags = |
697 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, NORMAL, argc); | 698 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, NORMAL, argc); |
698 | 699 |
699 // Use raw_unchecked... so we don't get assert failures during GC. | 700 // Use raw_unchecked... so we don't get assert failures during GC. |
700 NumberDictionary* dictionary = | 701 NotSeededNumberDictionary* dictionary = |
701 isolate()->heap()->raw_unchecked_non_monomorphic_cache(); | 702 isolate()->heap()->raw_unchecked_non_monomorphic_cache(); |
702 int entry = dictionary->FindEntry(isolate(), flags); | 703 int entry = dictionary->FindEntry(isolate(), flags); |
703 ASSERT(entry != -1); | 704 ASSERT(entry != -1); |
704 Object* code = dictionary->ValueAt(entry); | 705 Object* code = dictionary->ValueAt(entry); |
705 // This might be called during the marking phase of the collector | 706 // This might be called during the marking phase of the collector |
706 // hence the unchecked cast. | 707 // hence the unchecked cast. |
707 return reinterpret_cast<Code*>(code); | 708 return reinterpret_cast<Code*>(code); |
708 } | 709 } |
709 | 710 |
710 | 711 |
711 Handle<Code> StubCache::ComputeCallInitialize(int argc, | 712 Handle<Code> StubCache::ComputeCallInitialize(int argc, |
712 RelocInfo::Mode mode, | 713 RelocInfo::Mode mode, |
713 Code::Kind kind) { | 714 Code::Kind kind) { |
714 Code::ExtraICState extra_state = | 715 Code::ExtraICState extra_state = |
715 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 716 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | |
716 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); | 717 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); |
717 Code::Flags flags = | 718 Code::Flags flags = |
718 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, NORMAL, argc); | 719 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, NORMAL, argc); |
719 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 720 Handle<NotSeededNumberDictionary> cache = |
| 721 isolate_->factory()->non_monomorphic_cache(); |
720 int entry = cache->FindEntry(isolate_, flags); | 722 int entry = cache->FindEntry(isolate_, flags); |
721 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 723 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
722 | 724 |
723 StubCompiler compiler(isolate_); | 725 StubCompiler compiler(isolate_); |
724 Handle<Code> code = compiler.CompileCallInitialize(flags); | 726 Handle<Code> code = compiler.CompileCallInitialize(flags); |
725 FillCache(isolate_, code); | 727 FillCache(isolate_, code); |
726 return code; | 728 return code; |
727 } | 729 } |
728 | 730 |
729 | 731 |
730 Handle<Code> StubCache::ComputeCallInitialize(int argc, RelocInfo::Mode mode) { | 732 Handle<Code> StubCache::ComputeCallInitialize(int argc, RelocInfo::Mode mode) { |
731 return ComputeCallInitialize(argc, mode, Code::CALL_IC); | 733 return ComputeCallInitialize(argc, mode, Code::CALL_IC); |
732 } | 734 } |
733 | 735 |
734 | 736 |
735 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { | 737 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { |
736 return ComputeCallInitialize(argc, RelocInfo::CODE_TARGET, | 738 return ComputeCallInitialize(argc, RelocInfo::CODE_TARGET, |
737 Code::KEYED_CALL_IC); | 739 Code::KEYED_CALL_IC); |
738 } | 740 } |
739 | 741 |
740 | 742 |
741 Handle<Code> StubCache::ComputeCallPreMonomorphic( | 743 Handle<Code> StubCache::ComputeCallPreMonomorphic( |
742 int argc, | 744 int argc, |
743 Code::Kind kind, | 745 Code::Kind kind, |
744 Code::ExtraICState extra_state) { | 746 Code::ExtraICState extra_state) { |
745 Code::Flags flags = | 747 Code::Flags flags = |
746 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, NORMAL, argc); | 748 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, NORMAL, argc); |
747 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 749 Handle<NotSeededNumberDictionary> cache = |
| 750 isolate_->factory()->non_monomorphic_cache(); |
748 int entry = cache->FindEntry(isolate_, flags); | 751 int entry = cache->FindEntry(isolate_, flags); |
749 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 752 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
750 | 753 |
751 StubCompiler compiler(isolate_); | 754 StubCompiler compiler(isolate_); |
752 Handle<Code> code = compiler.CompileCallPreMonomorphic(flags); | 755 Handle<Code> code = compiler.CompileCallPreMonomorphic(flags); |
753 FillCache(isolate_, code); | 756 FillCache(isolate_, code); |
754 return code; | 757 return code; |
755 } | 758 } |
756 | 759 |
757 | 760 |
758 Handle<Code> StubCache::ComputeCallNormal(int argc, | 761 Handle<Code> StubCache::ComputeCallNormal(int argc, |
759 Code::Kind kind, | 762 Code::Kind kind, |
760 Code::ExtraICState extra_state) { | 763 Code::ExtraICState extra_state) { |
761 Code::Flags flags = | 764 Code::Flags flags = |
762 Code::ComputeFlags(kind, MONOMORPHIC, extra_state, NORMAL, argc); | 765 Code::ComputeFlags(kind, MONOMORPHIC, extra_state, NORMAL, argc); |
763 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 766 Handle<NotSeededNumberDictionary> cache = |
| 767 isolate_->factory()->non_monomorphic_cache(); |
764 int entry = cache->FindEntry(isolate_, flags); | 768 int entry = cache->FindEntry(isolate_, flags); |
765 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 769 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
766 | 770 |
767 StubCompiler compiler(isolate_); | 771 StubCompiler compiler(isolate_); |
768 Handle<Code> code = compiler.CompileCallNormal(flags); | 772 Handle<Code> code = compiler.CompileCallNormal(flags); |
769 FillCache(isolate_, code); | 773 FillCache(isolate_, code); |
770 return code; | 774 return code; |
771 } | 775 } |
772 | 776 |
773 | 777 |
774 Handle<Code> StubCache::ComputeCallArguments(int argc, Code::Kind kind) { | 778 Handle<Code> StubCache::ComputeCallArguments(int argc, Code::Kind kind) { |
775 ASSERT(kind == Code::KEYED_CALL_IC); | 779 ASSERT(kind == Code::KEYED_CALL_IC); |
776 Code::Flags flags = | 780 Code::Flags flags = |
777 Code::ComputeFlags(kind, MEGAMORPHIC, Code::kNoExtraICState, | 781 Code::ComputeFlags(kind, MEGAMORPHIC, Code::kNoExtraICState, |
778 NORMAL, argc); | 782 NORMAL, argc); |
779 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 783 Handle<NotSeededNumberDictionary> cache = |
| 784 isolate_->factory()->non_monomorphic_cache(); |
780 int entry = cache->FindEntry(isolate_, flags); | 785 int entry = cache->FindEntry(isolate_, flags); |
781 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 786 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
782 | 787 |
783 StubCompiler compiler(isolate_); | 788 StubCompiler compiler(isolate_); |
784 Handle<Code> code = compiler.CompileCallArguments(flags); | 789 Handle<Code> code = compiler.CompileCallArguments(flags); |
785 FillCache(isolate_, code); | 790 FillCache(isolate_, code); |
786 return code; | 791 return code; |
787 } | 792 } |
788 | 793 |
789 | 794 |
790 Handle<Code> StubCache::ComputeCallMegamorphic( | 795 Handle<Code> StubCache::ComputeCallMegamorphic( |
791 int argc, | 796 int argc, |
792 Code::Kind kind, | 797 Code::Kind kind, |
793 Code::ExtraICState extra_state) { | 798 Code::ExtraICState extra_state) { |
794 Code::Flags flags = | 799 Code::Flags flags = |
795 Code::ComputeFlags(kind, MEGAMORPHIC, extra_state, | 800 Code::ComputeFlags(kind, MEGAMORPHIC, extra_state, |
796 NORMAL, argc); | 801 NORMAL, argc); |
797 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 802 Handle<NotSeededNumberDictionary> cache = |
| 803 isolate_->factory()->non_monomorphic_cache(); |
798 int entry = cache->FindEntry(isolate_, flags); | 804 int entry = cache->FindEntry(isolate_, flags); |
799 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 805 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
800 | 806 |
801 StubCompiler compiler(isolate_); | 807 StubCompiler compiler(isolate_); |
802 Handle<Code> code = compiler.CompileCallMegamorphic(flags); | 808 Handle<Code> code = compiler.CompileCallMegamorphic(flags); |
803 FillCache(isolate_, code); | 809 FillCache(isolate_, code); |
804 return code; | 810 return code; |
805 } | 811 } |
806 | 812 |
807 | 813 |
808 Handle<Code> StubCache::ComputeCallMiss(int argc, | 814 Handle<Code> StubCache::ComputeCallMiss(int argc, |
809 Code::Kind kind, | 815 Code::Kind kind, |
810 Code::ExtraICState extra_state) { | 816 Code::ExtraICState extra_state) { |
811 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs | 817 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs |
812 // and monomorphic stubs are not mixed up together in the stub cache. | 818 // and monomorphic stubs are not mixed up together in the stub cache. |
813 Code::Flags flags = | 819 Code::Flags flags = |
814 Code::ComputeFlags(kind, MONOMORPHIC_PROTOTYPE_FAILURE, extra_state, | 820 Code::ComputeFlags(kind, MONOMORPHIC_PROTOTYPE_FAILURE, extra_state, |
815 NORMAL, argc, OWN_MAP); | 821 NORMAL, argc, OWN_MAP); |
816 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 822 Handle<NotSeededNumberDictionary> cache = |
| 823 isolate_->factory()->non_monomorphic_cache(); |
817 int entry = cache->FindEntry(isolate_, flags); | 824 int entry = cache->FindEntry(isolate_, flags); |
818 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 825 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
819 | 826 |
820 StubCompiler compiler(isolate_); | 827 StubCompiler compiler(isolate_); |
821 Handle<Code> code = compiler.CompileCallMiss(flags); | 828 Handle<Code> code = compiler.CompileCallMiss(flags); |
822 FillCache(isolate_, code); | 829 FillCache(isolate_, code); |
823 return code; | 830 return code; |
824 } | 831 } |
825 | 832 |
826 | 833 |
827 #ifdef ENABLE_DEBUGGER_SUPPORT | 834 #ifdef ENABLE_DEBUGGER_SUPPORT |
828 Handle<Code> StubCache::ComputeCallDebugBreak(int argc, | 835 Handle<Code> StubCache::ComputeCallDebugBreak(int argc, |
829 Code::Kind kind) { | 836 Code::Kind kind) { |
830 // Extra IC state is irrelevant for debug break ICs. They jump to | 837 // Extra IC state is irrelevant for debug break ICs. They jump to |
831 // the actual call ic to carry out the work. | 838 // the actual call ic to carry out the work. |
832 Code::Flags flags = | 839 Code::Flags flags = |
833 Code::ComputeFlags(kind, DEBUG_BREAK, Code::kNoExtraICState, | 840 Code::ComputeFlags(kind, DEBUG_BREAK, Code::kNoExtraICState, |
834 NORMAL, argc); | 841 NORMAL, argc); |
835 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 842 Handle<NotSeededNumberDictionary> cache = |
| 843 isolate_->factory()->non_monomorphic_cache(); |
836 int entry = cache->FindEntry(isolate_, flags); | 844 int entry = cache->FindEntry(isolate_, flags); |
837 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 845 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
838 | 846 |
839 StubCompiler compiler(isolate_); | 847 StubCompiler compiler(isolate_); |
840 Handle<Code> code = compiler.CompileCallDebugBreak(flags); | 848 Handle<Code> code = compiler.CompileCallDebugBreak(flags); |
841 FillCache(isolate_, code); | 849 FillCache(isolate_, code); |
842 return code; | 850 return code; |
843 } | 851 } |
844 | 852 |
845 | 853 |
846 Handle<Code> StubCache::ComputeCallDebugPrepareStepIn(int argc, | 854 Handle<Code> StubCache::ComputeCallDebugPrepareStepIn(int argc, |
847 Code::Kind kind) { | 855 Code::Kind kind) { |
848 // Extra IC state is irrelevant for debug break ICs. They jump to | 856 // Extra IC state is irrelevant for debug break ICs. They jump to |
849 // the actual call ic to carry out the work. | 857 // the actual call ic to carry out the work. |
850 Code::Flags flags = | 858 Code::Flags flags = |
851 Code::ComputeFlags(kind, DEBUG_PREPARE_STEP_IN, Code::kNoExtraICState, | 859 Code::ComputeFlags(kind, DEBUG_PREPARE_STEP_IN, Code::kNoExtraICState, |
852 NORMAL, argc); | 860 NORMAL, argc); |
853 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); | 861 Handle<NotSeededNumberDictionary> cache = |
| 862 isolate_->factory()->non_monomorphic_cache(); |
854 int entry = cache->FindEntry(isolate_, flags); | 863 int entry = cache->FindEntry(isolate_, flags); |
855 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 864 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
856 | 865 |
857 StubCompiler compiler(isolate_); | 866 StubCompiler compiler(isolate_); |
858 Handle<Code> code = compiler.CompileCallDebugPrepareStepIn(flags); | 867 Handle<Code> code = compiler.CompileCallDebugPrepareStepIn(flags); |
859 FillCache(isolate_, code); | 868 FillCache(isolate_, code); |
860 return code; | 869 return code; |
861 } | 870 } |
862 #endif | 871 #endif |
863 | 872 |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 Handle<FunctionTemplateInfo>( | 1518 Handle<FunctionTemplateInfo>( |
1510 FunctionTemplateInfo::cast(signature->receiver())); | 1519 FunctionTemplateInfo::cast(signature->receiver())); |
1511 } | 1520 } |
1512 } | 1521 } |
1513 | 1522 |
1514 is_simple_api_call_ = true; | 1523 is_simple_api_call_ = true; |
1515 } | 1524 } |
1516 | 1525 |
1517 | 1526 |
1518 } } // namespace v8::internal | 1527 } } // namespace v8::internal |
OLD | NEW |