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