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

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

Issue 17468003: Use AST's type field and merge types for unary, binary & compare ICs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 6 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 | « src/ast.cc ('k') | src/globals.h » ('j') | no next file with comments »
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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 897
898 class BinaryOpStub: public PlatformCodeStub { 898 class BinaryOpStub: public PlatformCodeStub {
899 public: 899 public:
900 BinaryOpStub(Token::Value op, OverwriteMode mode) 900 BinaryOpStub(Token::Value op, OverwriteMode mode)
901 : op_(op), 901 : op_(op),
902 mode_(mode), 902 mode_(mode),
903 platform_specific_bit_(false), 903 platform_specific_bit_(false),
904 left_type_(BinaryOpIC::UNINITIALIZED), 904 left_type_(BinaryOpIC::UNINITIALIZED),
905 right_type_(BinaryOpIC::UNINITIALIZED), 905 right_type_(BinaryOpIC::UNINITIALIZED),
906 result_type_(BinaryOpIC::UNINITIALIZED), 906 result_type_(BinaryOpIC::UNINITIALIZED),
907 has_fixed_right_arg_(false), 907 encoded_right_arg_(false, encode_arg_value(1)) {
908 encoded_right_arg_(encode_arg_value(1)) {
909 Initialize(); 908 Initialize();
910 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); 909 ASSERT(OpBits::is_valid(Token::NUM_TOKENS));
911 } 910 }
912 911
913 BinaryOpStub( 912 BinaryOpStub(
914 int key, 913 int key,
915 BinaryOpIC::TypeInfo left_type, 914 BinaryOpIC::TypeInfo left_type,
916 BinaryOpIC::TypeInfo right_type, 915 BinaryOpIC::TypeInfo right_type,
917 BinaryOpIC::TypeInfo result_type, 916 BinaryOpIC::TypeInfo result_type,
918 bool has_fixed_right_arg, 917 Maybe<int32_t> fixed_right_arg)
919 int32_t fixed_right_arg_value)
920 : op_(OpBits::decode(key)), 918 : op_(OpBits::decode(key)),
921 mode_(ModeBits::decode(key)), 919 mode_(ModeBits::decode(key)),
922 platform_specific_bit_(PlatformSpecificBits::decode(key)), 920 platform_specific_bit_(PlatformSpecificBits::decode(key)),
923 left_type_(left_type), 921 left_type_(left_type),
924 right_type_(right_type), 922 right_type_(right_type),
925 result_type_(result_type), 923 result_type_(result_type),
926 has_fixed_right_arg_(has_fixed_right_arg), 924 encoded_right_arg_(fixed_right_arg.has_value,
927 encoded_right_arg_(encode_arg_value(fixed_right_arg_value)) { } 925 encode_arg_value(fixed_right_arg.value)) { }
928 926
929 static void decode_types_from_minor_key(int minor_key, 927 static void decode_types_from_minor_key(int minor_key,
930 BinaryOpIC::TypeInfo* left_type, 928 BinaryOpIC::TypeInfo* left_type,
931 BinaryOpIC::TypeInfo* right_type, 929 BinaryOpIC::TypeInfo* right_type,
932 BinaryOpIC::TypeInfo* result_type) { 930 BinaryOpIC::TypeInfo* result_type) {
933 *left_type = 931 *left_type =
934 static_cast<BinaryOpIC::TypeInfo>(LeftTypeBits::decode(minor_key)); 932 static_cast<BinaryOpIC::TypeInfo>(LeftTypeBits::decode(minor_key));
935 *right_type = 933 *right_type =
936 static_cast<BinaryOpIC::TypeInfo>(RightTypeBits::decode(minor_key)); 934 static_cast<BinaryOpIC::TypeInfo>(RightTypeBits::decode(minor_key));
937 *result_type = 935 *result_type =
938 static_cast<BinaryOpIC::TypeInfo>(ResultTypeBits::decode(minor_key)); 936 static_cast<BinaryOpIC::TypeInfo>(ResultTypeBits::decode(minor_key));
939 } 937 }
940 938
941 static Token::Value decode_op_from_minor_key(int minor_key) { 939 static Token::Value decode_op_from_minor_key(int minor_key) {
942 return static_cast<Token::Value>(OpBits::decode(minor_key)); 940 return static_cast<Token::Value>(OpBits::decode(minor_key));
943 } 941 }
944 942
945 static bool decode_has_fixed_right_arg_from_minor_key(int minor_key) { 943 static Maybe<int> decode_fixed_right_arg_from_minor_key(int minor_key) {
946 return HasFixedRightArgBits::decode(minor_key); 944 return Maybe<int>(
947 } 945 HasFixedRightArgBits::decode(minor_key),
948 946 decode_arg_value(FixedRightArgValueBits::decode(minor_key)));
949 static int decode_fixed_right_arg_value_from_minor_key(int minor_key) {
950 return decode_arg_value(FixedRightArgValueBits::decode(minor_key));
951 } 947 }
952 948
953 int fixed_right_arg_value() const { 949 int fixed_right_arg_value() const {
954 return decode_arg_value(encoded_right_arg_); 950 return decode_arg_value(encoded_right_arg_.value);
955 } 951 }
956 952
957 static bool can_encode_arg_value(int32_t value) { 953 static bool can_encode_arg_value(int32_t value) {
958 return value > 0 && 954 return value > 0 &&
959 IsPowerOf2(value) && 955 IsPowerOf2(value) &&
960 FixedRightArgValueBits::is_valid(WhichPowerOf2(value)); 956 FixedRightArgValueBits::is_valid(WhichPowerOf2(value));
961 } 957 }
962 958
963 enum SmiCodeGenerateHeapNumberResults { 959 enum SmiCodeGenerateHeapNumberResults {
964 ALLOW_HEAPNUMBER_RESULTS, 960 ALLOW_HEAPNUMBER_RESULTS,
965 NO_HEAPNUMBER_RESULTS 961 NO_HEAPNUMBER_RESULTS
966 }; 962 };
967 963
968 private: 964 private:
969 Token::Value op_; 965 Token::Value op_;
970 OverwriteMode mode_; 966 OverwriteMode mode_;
971 bool platform_specific_bit_; // Indicates SSE3 on IA32. 967 bool platform_specific_bit_; // Indicates SSE3 on IA32.
972 968
973 // Operand type information determined at runtime. 969 // Operand type information determined at runtime.
974 BinaryOpIC::TypeInfo left_type_; 970 BinaryOpIC::TypeInfo left_type_;
975 BinaryOpIC::TypeInfo right_type_; 971 BinaryOpIC::TypeInfo right_type_;
976 BinaryOpIC::TypeInfo result_type_; 972 BinaryOpIC::TypeInfo result_type_;
977 973
978 bool has_fixed_right_arg_; 974 Maybe<int> encoded_right_arg_;
979 int encoded_right_arg_;
980 975
981 static int encode_arg_value(int32_t value) { 976 static int encode_arg_value(int32_t value) {
982 ASSERT(can_encode_arg_value(value)); 977 ASSERT(can_encode_arg_value(value));
983 return WhichPowerOf2(value); 978 return WhichPowerOf2(value);
984 } 979 }
985 980
986 static int32_t decode_arg_value(int value) { 981 static int32_t decode_arg_value(int value) {
987 return 1 << value; 982 return 1 << value;
988 } 983 }
989 984
(...skipping 12 matching lines...) Expand all
1002 class FixedRightArgValueBits: public BitField<int, 20, 5> {}; 997 class FixedRightArgValueBits: public BitField<int, 20, 5> {};
1003 998
1004 Major MajorKey() { return BinaryOp; } 999 Major MajorKey() { return BinaryOp; }
1005 int MinorKey() { 1000 int MinorKey() {
1006 return OpBits::encode(op_) 1001 return OpBits::encode(op_)
1007 | ModeBits::encode(mode_) 1002 | ModeBits::encode(mode_)
1008 | PlatformSpecificBits::encode(platform_specific_bit_) 1003 | PlatformSpecificBits::encode(platform_specific_bit_)
1009 | LeftTypeBits::encode(left_type_) 1004 | LeftTypeBits::encode(left_type_)
1010 | RightTypeBits::encode(right_type_) 1005 | RightTypeBits::encode(right_type_)
1011 | ResultTypeBits::encode(result_type_) 1006 | ResultTypeBits::encode(result_type_)
1012 | HasFixedRightArgBits::encode(has_fixed_right_arg_) 1007 | HasFixedRightArgBits::encode(encoded_right_arg_.has_value)
1013 | FixedRightArgValueBits::encode(encoded_right_arg_); 1008 | FixedRightArgValueBits::encode(encoded_right_arg_.value);
1014 } 1009 }
1015 1010
1016 1011
1017 // Platform-independent implementation. 1012 // Platform-independent implementation.
1018 void Generate(MacroAssembler* masm); 1013 void Generate(MacroAssembler* masm);
1019 void GenerateCallRuntime(MacroAssembler* masm); 1014 void GenerateCallRuntime(MacroAssembler* masm);
1020 1015
1021 // Platform-independent signature, platform-specific implementation. 1016 // Platform-independent signature, platform-specific implementation.
1022 void Initialize(); 1017 void Initialize();
1023 void GenerateAddStrings(MacroAssembler* masm); 1018 void GenerateAddStrings(MacroAssembler* masm);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 1195
1201 Handle<Code> GenerateCode(); 1196 Handle<Code> GenerateCode();
1202 1197
1203 // extra ic state = nil_value | type_n-1 | ... | type_0 1198 // extra ic state = nil_value | type_n-1 | ... | type_0
1204 virtual Code::ExtraICState GetExtraICState() { 1199 virtual Code::ExtraICState GetExtraICState() {
1205 return NilValueField::encode(nil_value_) | state_.ToIntegral(); 1200 return NilValueField::encode(nil_value_) | state_.ToIntegral();
1206 } 1201 }
1207 static byte ExtractTypesFromExtraICState(Code::ExtraICState state) { 1202 static byte ExtractTypesFromExtraICState(Code::ExtraICState state) {
1208 return state & ((1 << NUMBER_OF_TYPES) - 1); 1203 return state & ((1 << NUMBER_OF_TYPES) - 1);
1209 } 1204 }
1205 static NilValue ExtractNilValueFromExtraICState(Code::ExtraICState state) {
1206 return NilValueField::decode(state);
1207 }
1210 1208
1211 void Record(Handle<Object> object); 1209 void Record(Handle<Object> object);
1212 1210
1213 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); } 1211 bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); }
1214 NilValue GetNilValue() const { return nil_value_; } 1212 NilValue GetNilValue() const { return nil_value_; }
1215 State GetState() const { return state_; } 1213 State GetState() const { return state_; }
1216 void ClearState() { state_.RemoveAll(); } 1214 void ClearState() { state_.RemoveAll(); }
1217 1215
1218 virtual void PrintName(StringStream* stream); 1216 virtual void PrintName(StringStream* stream);
1219 1217
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 2153
2156 // The current function entry hook. 2154 // The current function entry hook.
2157 static FunctionEntryHook entry_hook_; 2155 static FunctionEntryHook entry_hook_;
2158 2156
2159 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 2157 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
2160 }; 2158 };
2161 2159
2162 } } // namespace v8::internal 2160 } } // namespace v8::internal
2163 2161
2164 #endif // V8_CODE_STUBS_H_ 2162 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698