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

Side by Side Diff: src/code-stubs.h

Issue 8932004: Implement target cache for constructor calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 #include "allocation.h" 31 #include "allocation.h"
32 #include "globals.h" 32 #include "globals.h"
33 #include "codegen.h" 33 #include "codegen.h"
34 34
35 namespace v8 { 35 namespace v8 {
36 namespace internal { 36 namespace internal {
37 37
38 // List of code stubs used on all platforms. 38 // List of code stubs used on all platforms.
39 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ 39 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \
40 V(CallFunction) \ 40 V(CallFunction) \
41 V(CallConstruct) \
41 V(UnaryOp) \ 42 V(UnaryOp) \
42 V(BinaryOp) \ 43 V(BinaryOp) \
43 V(StringAdd) \ 44 V(StringAdd) \
44 V(SubString) \ 45 V(SubString) \
45 V(StringCompare) \ 46 V(StringCompare) \
46 V(Compare) \ 47 V(Compare) \
47 V(CompareIC) \ 48 V(CompareIC) \
48 V(MathPow) \ 49 V(MathPow) \
49 V(RecordWrite) \ 50 V(RecordWrite) \
50 V(StoreBufferOverflow) \ 51 V(StoreBufferOverflow) \
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 RegExpConstructResultStub() { } 725 RegExpConstructResultStub() { }
725 726
726 private: 727 private:
727 Major MajorKey() { return RegExpConstructResult; } 728 Major MajorKey() { return RegExpConstructResult; }
728 int MinorKey() { return 0; } 729 int MinorKey() { return 0; }
729 730
730 void Generate(MacroAssembler* masm); 731 void Generate(MacroAssembler* masm);
731 }; 732 };
732 733
733 734
734 class CallFunctionStub: public CodeStub { 735 // Base class for call stubs caching call targets in the instruction stream.
736 class CallStub: public CodeStub {
735 public: 737 public:
736 CallFunctionStub(int argc, CallFunctionFlags flags)
737 : argc_(argc), flags_(flags) { }
738
739 void Generate(MacroAssembler* masm);
740
741 virtual void FinishCode(Handle<Code> code);
742
743 static void Clear(Heap* heap, Address address); 738 static void Clear(Heap* heap, Address address);
744 739
745 static Object* GetCachedValue(Address address); 740 static Object* GetCachedValue(Address address);
746 741
747 static int ExtractArgcFromMinorKey(int minor_key) { 742 // Checks whether a call to the given target has a cache attached.
748 return ArgcBits::decode(minor_key); 743 static bool HasCache(Code* target) {
744 return target->kind() == Code::STUB &&
745 (target->major_key() == CallFunction ||
746 target->major_key() == CallConstruct) &&
747 target->has_function_cache();
749 } 748 }
750 749
751 // The object that indicates an uninitialized cache. 750 // The object that indicates an uninitialized cache.
752 static Handle<Object> UninitializedSentinel(Isolate* isolate) { 751 static Handle<Object> UninitializedSentinel(Isolate* isolate) {
753 return isolate->factory()->the_hole_value(); 752 return isolate->factory()->the_hole_value();
754 } 753 }
755 754
756 // A raw version of the uninitialized sentinel that's safe to read during 755 // A raw version of the uninitialized sentinel that's safe to read during
757 // garbage collection (e.g., for patching the cache). 756 // garbage collection (e.g., for patching the cache).
758 static Object* RawUninitializedSentinel(Heap* heap) { 757 static Object* RawUninitializedSentinel(Heap* heap) {
759 return heap->raw_unchecked_the_hole_value(); 758 return heap->raw_unchecked_the_hole_value();
760 } 759 }
761 760
762 // The object that indicates a megamorphic state. 761 // The object that indicates a megamorphic state.
763 static Handle<Object> MegamorphicSentinel(Isolate* isolate) { 762 static Handle<Object> MegamorphicSentinel(Isolate* isolate) {
764 return isolate->factory()->undefined_value(); 763 return isolate->factory()->undefined_value();
765 } 764 }
766 765
766 protected:
767 void GenerateRecordCallTarget(MacroAssembler* masm);
768 };
769
770
771 class CallFunctionStub: public CallStub {
772 public:
773 CallFunctionStub(int argc, CallFunctionFlags flags)
774 : argc_(argc), flags_(flags) { }
775
776 void Generate(MacroAssembler* masm);
777
778 virtual void FinishCode(Handle<Code> code);
779
780 static int ExtractArgcFromMinorKey(int minor_key) {
781 return ArgcBits::decode(minor_key);
782 }
783
767 private: 784 private:
768 int argc_; 785 int argc_;
769 CallFunctionFlags flags_; 786 CallFunctionFlags flags_;
770 787
771 virtual void PrintName(StringStream* stream); 788 virtual void PrintName(StringStream* stream);
772 789
773 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. 790 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>.
774 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; 791 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {};
775 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; 792 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {};
776 793
777 Major MajorKey() { return CallFunction; } 794 Major MajorKey() { return CallFunction; }
778 int MinorKey() { 795 int MinorKey() {
779 // Encode the parameters in a unique 32 bit value. 796 // Encode the parameters in a unique 32 bit value.
780 return FlagBits::encode(flags_) | ArgcBits::encode(argc_); 797 return FlagBits::encode(flags_) | ArgcBits::encode(argc_);
781 } 798 }
782 799
783 bool ReceiverMightBeImplicit() { 800 bool ReceiverMightBeImplicit() {
784 return (flags_ & RECEIVER_MIGHT_BE_IMPLICIT) != 0; 801 return (flags_ & RECEIVER_MIGHT_BE_IMPLICIT) != 0;
785 } 802 }
786 803
787 bool RecordCallTarget() { 804 bool RecordCallTarget() {
788 return (flags_ & RECORD_CALL_TARGET) != 0; 805 return (flags_ & RECORD_CALL_TARGET) != 0;
789 } 806 }
790 }; 807 };
791 808
792 809
810 class CallConstructStub: public CallStub {
811 public:
812 explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {}
813
814 void Generate(MacroAssembler* masm);
815
816 virtual void FinishCode(Handle<Code> code);
817
818 private:
819 CallFunctionFlags flags_;
820
821 Major MajorKey() { return CallConstruct; }
822 int MinorKey() { return flags_; }
823
824 bool RecordCallTarget() {
825 return (flags_ & RECORD_CALL_TARGET) != 0;
826 }
827 };
828
829
793 enum StringIndexFlags { 830 enum StringIndexFlags {
794 // Accepts smis or heap numbers. 831 // Accepts smis or heap numbers.
795 STRING_INDEX_IS_NUMBER, 832 STRING_INDEX_IS_NUMBER,
796 833
797 // Accepts smis or heap numbers that are valid array indices 834 // Accepts smis or heap numbers that are valid array indices
798 // (ECMA-262 15.4). Invalid indices are reported as being out of 835 // (ECMA-262 15.4). Invalid indices are reported as being out of
799 // range. 836 // range.
800 STRING_INDEX_IS_ARRAY_INDEX 837 STRING_INDEX_IS_ARRAY_INDEX
801 }; 838 };
802 839
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 int MinorKey() { return 0; } 1146 int MinorKey() { return 0; }
1110 1147
1111 void Generate(MacroAssembler* masm); 1148 void Generate(MacroAssembler* masm);
1112 1149
1113 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); 1150 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub);
1114 }; 1151 };
1115 1152
1116 } } // namespace v8::internal 1153 } } // namespace v8::internal
1117 1154
1118 #endif // V8_CODE_STUBS_H_ 1155 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/ia32/builtins-ia32.cc » ('j') | src/ia32/builtins-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698