OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 764 |
765 // Type Recording BinaryOpIC, that records the types of the inputs and outputs. | 765 // Type Recording BinaryOpIC, that records the types of the inputs and outputs. |
766 class BinaryOpIC: public IC { | 766 class BinaryOpIC: public IC { |
767 public: | 767 public: |
768 enum TypeInfo { | 768 enum TypeInfo { |
769 UNINITIALIZED, | 769 UNINITIALIZED, |
770 SMI, | 770 SMI, |
771 INT32, | 771 INT32, |
772 HEAP_NUMBER, | 772 HEAP_NUMBER, |
773 ODDBALL, | 773 ODDBALL, |
774 BOTH_STRING, // Only used for addition operation. | 774 STRING, // Only used for addition operation. |
775 STRING, // Only used for addition operation. At least one string operand. | |
776 GENERIC | 775 GENERIC |
777 }; | 776 }; |
778 | 777 |
779 explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 778 explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } |
780 | 779 |
781 void patch(Code* code); | 780 void patch(Code* code); |
782 | 781 |
783 static const char* GetName(TypeInfo type_info); | 782 static const char* GetName(TypeInfo type_info); |
784 | 783 |
785 static State ToState(TypeInfo type_info); | 784 static State ToState(TypeInfo type_info); |
786 | |
787 static TypeInfo GetTypeInfo(Handle<Object> left, Handle<Object> right); | |
788 | |
789 static TypeInfo JoinTypes(TypeInfo x, TypeInfo y); | |
790 }; | 785 }; |
791 | 786 |
792 | 787 |
793 class CompareIC: public IC { | 788 class CompareIC: public IC { |
794 public: | 789 public: |
795 enum State { | 790 enum State { |
796 UNINITIALIZED, | 791 UNINITIALIZED, |
797 SMIS, | 792 SMI, |
798 HEAP_NUMBERS, | 793 HEAP_NUMBER, |
799 SYMBOLS, | 794 SYMBOL, |
800 STRINGS, | 795 STRING, |
801 OBJECTS, | 796 OBJECT, |
802 KNOWN_OBJECTS, | 797 KNOWN_OBJECTS, |
803 GENERIC | 798 GENERIC |
804 }; | 799 }; |
805 | 800 |
806 CompareIC(Isolate* isolate, Token::Value op) | 801 CompareIC(Isolate* isolate, Token::Value op) |
807 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } | 802 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } |
808 | 803 |
809 // Update the inline cache for the given operands. | 804 // Update the inline cache for the given operands. |
810 void UpdateCaches(Handle<Object> x, Handle<Object> y); | 805 void UpdateCaches(Handle<Object> x, Handle<Object> y); |
811 | 806 |
| 807 |
812 // Factory method for getting an uninitialized compare stub. | 808 // Factory method for getting an uninitialized compare stub. |
813 static Handle<Code> GetUninitialized(Token::Value op); | 809 static Handle<Code> GetUninitialized(Token::Value op); |
814 | 810 |
815 // Helper function for computing the condition for a compare operation. | 811 // Helper function for computing the condition for a compare operation. |
816 static Condition ComputeCondition(Token::Value op); | 812 static Condition ComputeCondition(Token::Value op); |
817 | 813 |
818 // Helper function for determining the state of a compare IC. | |
819 static State ComputeState(Code* target); | |
820 | |
821 // Helper function for determining the operation a compare IC is for. | |
822 static Token::Value ComputeOperation(Code* target); | |
823 | |
824 static const char* GetStateName(State state); | 814 static const char* GetStateName(State state); |
825 | 815 |
826 private: | 816 private: |
827 State TargetState(State state, bool has_inlined_smi_code, | 817 static bool HasInlinedSmiCode(Address address); |
828 Handle<Object> x, Handle<Object> y); | 818 |
| 819 State TargetState(State old_state, |
| 820 State old_left, |
| 821 State old_right, |
| 822 bool has_inlined_smi_code, |
| 823 Handle<Object> x, |
| 824 Handle<Object> y); |
829 | 825 |
830 bool strict() const { return op_ == Token::EQ_STRICT; } | 826 bool strict() const { return op_ == Token::EQ_STRICT; } |
831 Condition GetCondition() const { return ComputeCondition(op_); } | 827 Condition GetCondition() const { return ComputeCondition(op_); } |
832 State GetState() { return ComputeState(target()); } | |
833 | 828 |
834 static Code* GetRawUninitialized(Token::Value op); | 829 static Code* GetRawUninitialized(Token::Value op); |
835 | 830 |
836 static void Clear(Address address, Code* target); | 831 static void Clear(Address address, Code* target); |
837 | 832 |
838 Token::Value op_; | 833 Token::Value op_; |
839 | 834 |
840 friend class IC; | 835 friend class IC; |
841 }; | 836 }; |
842 | 837 |
843 | 838 |
844 class ToBooleanIC: public IC { | 839 class ToBooleanIC: public IC { |
845 public: | 840 public: |
846 explicit ToBooleanIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 841 explicit ToBooleanIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } |
847 | 842 |
848 void patch(Code* code); | 843 void patch(Code* code); |
849 }; | 844 }; |
850 | 845 |
851 | 846 |
852 // Helper for BinaryOpIC and CompareIC. | 847 // Helper for BinaryOpIC and CompareIC. |
853 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 848 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
854 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); | 849 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); |
855 | 850 |
856 } } // namespace v8::internal | 851 } } // namespace v8::internal |
857 | 852 |
858 #endif // V8_IC_H_ | 853 #endif // V8_IC_H_ |
OLD | NEW |