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

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

Issue 15735005: Collect type feedback for power-of-2 right operands in BinaryOps. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Handle INT32. Avoid transition interference. Cleanup. Rebased. Created 7 years, 7 months 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
« no previous file with comments | « no previous file | src/ia32/code-stubs-ia32.cc » ('j') | src/ic.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 863
864 864
865 class BinaryOpStub: public PlatformCodeStub { 865 class BinaryOpStub: public PlatformCodeStub {
866 public: 866 public:
867 BinaryOpStub(Token::Value op, OverwriteMode mode) 867 BinaryOpStub(Token::Value op, OverwriteMode mode)
868 : op_(op), 868 : op_(op),
869 mode_(mode), 869 mode_(mode),
870 platform_specific_bit_(false), 870 platform_specific_bit_(false),
871 left_type_(BinaryOpIC::UNINITIALIZED), 871 left_type_(BinaryOpIC::UNINITIALIZED),
872 right_type_(BinaryOpIC::UNINITIALIZED), 872 right_type_(BinaryOpIC::UNINITIALIZED),
873 result_type_(BinaryOpIC::UNINITIALIZED) { 873 result_type_(BinaryOpIC::UNINITIALIZED),
874 has_fixed_right_arg_(false),
875 encoded_right_arg_(encode_arg_value(1)) {
874 Initialize(); 876 Initialize();
875 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); 877 ASSERT(OpBits::is_valid(Token::NUM_TOKENS));
876 } 878 }
877 879
878 BinaryOpStub( 880 BinaryOpStub(
879 int key, 881 int key,
880 BinaryOpIC::TypeInfo left_type, 882 BinaryOpIC::TypeInfo left_type,
881 BinaryOpIC::TypeInfo right_type, 883 BinaryOpIC::TypeInfo right_type,
882 BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED) 884 BinaryOpIC::TypeInfo result_type,
885 bool has_fixed_right_arg,
886 int32_t fixed_right_arg_value)
883 : op_(OpBits::decode(key)), 887 : op_(OpBits::decode(key)),
884 mode_(ModeBits::decode(key)), 888 mode_(ModeBits::decode(key)),
885 platform_specific_bit_(PlatformSpecificBits::decode(key)), 889 platform_specific_bit_(PlatformSpecificBits::decode(key)),
886 left_type_(left_type), 890 left_type_(left_type),
887 right_type_(right_type), 891 right_type_(right_type),
888 result_type_(result_type) { } 892 result_type_(result_type),
893 has_fixed_right_arg_(has_fixed_right_arg),
894 encoded_right_arg_(encode_arg_value(fixed_right_arg_value)) { }
889 895
890 static void decode_types_from_minor_key(int minor_key, 896 static void decode_types_from_minor_key(int minor_key,
891 BinaryOpIC::TypeInfo* left_type, 897 BinaryOpIC::TypeInfo* left_type,
892 BinaryOpIC::TypeInfo* right_type, 898 BinaryOpIC::TypeInfo* right_type,
893 BinaryOpIC::TypeInfo* result_type) { 899 BinaryOpIC::TypeInfo* result_type) {
894 *left_type = 900 *left_type =
895 static_cast<BinaryOpIC::TypeInfo>(LeftTypeBits::decode(minor_key)); 901 static_cast<BinaryOpIC::TypeInfo>(LeftTypeBits::decode(minor_key));
896 *right_type = 902 *right_type =
897 static_cast<BinaryOpIC::TypeInfo>(RightTypeBits::decode(minor_key)); 903 static_cast<BinaryOpIC::TypeInfo>(RightTypeBits::decode(minor_key));
898 *result_type = 904 *result_type =
899 static_cast<BinaryOpIC::TypeInfo>(ResultTypeBits::decode(minor_key)); 905 static_cast<BinaryOpIC::TypeInfo>(ResultTypeBits::decode(minor_key));
900 } 906 }
901 907
902 static Token::Value decode_op_from_minor_key(int minor_key) { 908 static Token::Value decode_op_from_minor_key(int minor_key) {
903 return static_cast<Token::Value>(OpBits::decode(minor_key)); 909 return static_cast<Token::Value>(OpBits::decode(minor_key));
904 } 910 }
905 911
912 static bool decode_has_fixed_right_arg_from_minor_key(int minor_key) {
913 return HasFixedRightArgBits::decode(minor_key);
914 }
915
916 static int decode_fixed_right_arg_value_from_minor_key(int minor_key) {
917 return decode_arg_value(FixedRightArgValueBits::decode(minor_key));
918 }
919
920 int fixed_right_arg_value() const {
921 return decode_arg_value(encoded_right_arg_);
922 }
923
924 static bool can_encode_arg_value(int32_t value) {
925 return value > 0 &&
926 IsPowerOf2(value) &&
927 FixedRightArgValueBits::is_valid(WhichPowerOf2(value));
928 }
929
906 enum SmiCodeGenerateHeapNumberResults { 930 enum SmiCodeGenerateHeapNumberResults {
907 ALLOW_HEAPNUMBER_RESULTS, 931 ALLOW_HEAPNUMBER_RESULTS,
908 NO_HEAPNUMBER_RESULTS 932 NO_HEAPNUMBER_RESULTS
909 }; 933 };
910 934
911 private: 935 private:
912 Token::Value op_; 936 Token::Value op_;
913 OverwriteMode mode_; 937 OverwriteMode mode_;
914 bool platform_specific_bit_; // Indicates SSE3 on IA32. 938 bool platform_specific_bit_; // Indicates SSE3 on IA32.
915 939
916 // Operand type information determined at runtime. 940 // Operand type information determined at runtime.
917 BinaryOpIC::TypeInfo left_type_; 941 BinaryOpIC::TypeInfo left_type_;
918 BinaryOpIC::TypeInfo right_type_; 942 BinaryOpIC::TypeInfo right_type_;
919 BinaryOpIC::TypeInfo result_type_; 943 BinaryOpIC::TypeInfo result_type_;
920 944
945 bool has_fixed_right_arg_;
946 int encoded_right_arg_;
947
948 static int encode_arg_value(int32_t value) {
949 ASSERT(can_encode_arg_value(value));
950 return WhichPowerOf2(value);
951 }
952
953 static int32_t decode_arg_value(int value) {
954 return 1 << value;
955 }
956
921 virtual void PrintName(StringStream* stream); 957 virtual void PrintName(StringStream* stream);
922 958
923 // Minor key encoding in 19 bits TTTRRRLLLSOOOOOOOMM. 959 // Minor key encoding in 19 bits TTTRRRLLLSOOOOOOOMM.
Jakob Kummerow 2013/05/23 12:05:43 Please update this comment.
Sven Panne 2013/05/23 14:39:20 Done.
924 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; 960 class ModeBits: public BitField<OverwriteMode, 0, 2> {};
925 class OpBits: public BitField<Token::Value, 2, 7> {}; 961 class OpBits: public BitField<Token::Value, 2, 7> {};
926 class PlatformSpecificBits: public BitField<bool, 9, 1> {}; 962 class PlatformSpecificBits: public BitField<bool, 9, 1> {};
927 class LeftTypeBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {}; 963 class LeftTypeBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {};
928 class RightTypeBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {}; 964 class RightTypeBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {};
929 class ResultTypeBits: public BitField<BinaryOpIC::TypeInfo, 16, 3> {}; 965 class ResultTypeBits: public BitField<BinaryOpIC::TypeInfo, 16, 3> {};
966 class HasFixedRightArgBits: public BitField<bool, 19, 1> {};
967 class FixedRightArgValueBits: public BitField<int, 20, 5> {};
930 968
931 Major MajorKey() { return BinaryOp; } 969 Major MajorKey() { return BinaryOp; }
932 int MinorKey() { 970 int MinorKey() {
933 return OpBits::encode(op_) 971 return OpBits::encode(op_)
934 | ModeBits::encode(mode_) 972 | ModeBits::encode(mode_)
935 | PlatformSpecificBits::encode(platform_specific_bit_) 973 | PlatformSpecificBits::encode(platform_specific_bit_)
936 | LeftTypeBits::encode(left_type_) 974 | LeftTypeBits::encode(left_type_)
937 | RightTypeBits::encode(right_type_) 975 | RightTypeBits::encode(right_type_)
938 | ResultTypeBits::encode(result_type_); 976 | ResultTypeBits::encode(result_type_)
977 | HasFixedRightArgBits::encode(has_fixed_right_arg_)
978 | FixedRightArgValueBits::encode(encoded_right_arg_);
939 } 979 }
940 980
941 981
942 // Platform-independent implementation. 982 // Platform-independent implementation.
943 void Generate(MacroAssembler* masm); 983 void Generate(MacroAssembler* masm);
944 void GenerateCallRuntime(MacroAssembler* masm); 984 void GenerateCallRuntime(MacroAssembler* masm);
945 985
946 // Platform-independent signature, platform-specific implementation. 986 // Platform-independent signature, platform-specific implementation.
947 void Initialize(); 987 void Initialize();
948 void GenerateAddStrings(MacroAssembler* masm); 988 void GenerateAddStrings(MacroAssembler* masm);
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 2030
1991 // The current function entry hook. 2031 // The current function entry hook.
1992 static FunctionEntryHook entry_hook_; 2032 static FunctionEntryHook entry_hook_;
1993 2033
1994 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 2034 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
1995 }; 2035 };
1996 2036
1997 } } // namespace v8::internal 2037 } } // namespace v8::internal
1998 2038
1999 #endif // V8_CODE_STUBS_H_ 2039 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « no previous file | src/ia32/code-stubs-ia32.cc » ('j') | src/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698