| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // Determines which map must be used for keeping the code stub. | 143 // Determines which map must be used for keeping the code stub. |
| 144 // These methods should not be called with undefined or null. | 144 // These methods should not be called with undefined or null. |
| 145 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); | 145 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); |
| 146 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* | 146 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* |
| 147 // since loading the IC for loading the length from strings are stored on | 147 // since loading the IC for loading the length from strings are stored on |
| 148 // the string map directly, rather than on the JSObject-typed prototype. | 148 // the string map directly, rather than on the JSObject-typed prototype. |
| 149 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, | 149 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, |
| 150 Object* object, | 150 Object* object, |
| 151 InlineCacheHolderFlag holder); | 151 InlineCacheHolderFlag holder); |
| 152 | 152 |
| 153 static inline InlineCacheHolderFlag GetCodeCacheFlag(Type* type); | 153 static inline InlineCacheHolderFlag GetCodeCacheFlag(HeapType* type); |
| 154 static inline Handle<Map> GetCodeCacheHolder(InlineCacheHolderFlag flag, | 154 static inline Handle<Map> GetCodeCacheHolder(InlineCacheHolderFlag flag, |
| 155 Type* type, | 155 HeapType* type, |
| 156 Isolate* isolate); | 156 Isolate* isolate); |
| 157 | 157 |
| 158 static bool IsCleared(Code* code) { | 158 static bool IsCleared(Code* code) { |
| 159 InlineCacheState state = code->ic_state(); | 159 InlineCacheState state = code->ic_state(); |
| 160 return state == UNINITIALIZED || state == PREMONOMORPHIC; | 160 return state == UNINITIALIZED || state == PREMONOMORPHIC; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // Utility functions to convert maps to types and back. There are two special | 163 // Utility functions to convert maps to types and back. There are two special |
| 164 // cases: | 164 // cases: |
| 165 // - The heap_number_map is used as a marker which includes heap numbers as | 165 // - The heap_number_map is used as a marker which includes heap numbers as |
| 166 // well as smis. | 166 // well as smis. |
| 167 // - The oddball map is only used for booleans. | 167 // - The oddball map is only used for booleans. |
| 168 static Handle<Map> TypeToMap(Type* type, Isolate* isolate); | 168 static Handle<Map> TypeToMap(HeapType* type, Isolate* isolate); |
| 169 static Handle<Type> MapToType(Handle<Map> type); | 169 static Handle<HeapType> MapToType(Handle<Map> map); |
| 170 static Handle<Type> CurrentTypeOf(Handle<Object> object, Isolate* isolate); | 170 static Handle<HeapType> CurrentTypeOf( |
| 171 Handle<Object> object, Isolate* isolate); |
| 171 | 172 |
| 172 protected: | 173 protected: |
| 173 // Get the call-site target; used for determining the state. | 174 // Get the call-site target; used for determining the state. |
| 174 Handle<Code> target() const { return target_; } | 175 Handle<Code> target() const { return target_; } |
| 175 | 176 |
| 176 Address fp() const { return fp_; } | 177 Address fp() const { return fp_; } |
| 177 Address pc() const { return *pc_address_; } | 178 Address pc() const { return *pc_address_; } |
| 178 Isolate* isolate() const { return isolate_; } | 179 Isolate* isolate() const { return isolate_; } |
| 179 | 180 |
| 180 #ifdef ENABLE_DEBUGGER_SUPPORT | 181 #ifdef ENABLE_DEBUGGER_SUPPORT |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 Handle<Object> value = Handle<Code>::null()); | 215 Handle<Object> value = Handle<Code>::null()); |
| 215 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 216 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
| 216 Handle<Object> object, | 217 Handle<Object> object, |
| 217 Handle<String> name, | 218 Handle<String> name, |
| 218 Handle<Object> value, | 219 Handle<Object> value, |
| 219 InlineCacheHolderFlag cache_holder) { | 220 InlineCacheHolderFlag cache_holder) { |
| 220 UNREACHABLE(); | 221 UNREACHABLE(); |
| 221 return Handle<Code>::null(); | 222 return Handle<Code>::null(); |
| 222 } | 223 } |
| 223 | 224 |
| 224 void UpdateMonomorphicIC(Handle<Type> type, | 225 void UpdateMonomorphicIC(Handle<HeapType> type, |
| 225 Handle<Code> handler, | 226 Handle<Code> handler, |
| 226 Handle<String> name); | 227 Handle<String> name); |
| 227 | 228 |
| 228 bool UpdatePolymorphicIC(Handle<Type> type, | 229 bool UpdatePolymorphicIC(Handle<HeapType> type, |
| 229 Handle<String> name, | 230 Handle<String> name, |
| 230 Handle<Code> code); | 231 Handle<Code> code); |
| 231 | 232 |
| 232 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code); | 233 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); |
| 233 | 234 |
| 234 void CopyICToMegamorphicCache(Handle<String> name); | 235 void CopyICToMegamorphicCache(Handle<String> name); |
| 235 bool IsTransitionOfMonomorphicTarget(Handle<Type> type); | 236 bool IsTransitionOfMonomorphicTarget(Handle<HeapType> type); |
| 236 void PatchCache(Handle<Type> type, | 237 void PatchCache(Handle<HeapType> type, |
| 237 Handle<String> name, | 238 Handle<String> name, |
| 238 Handle<Code> code); | 239 Handle<Code> code); |
| 239 virtual Code::Kind kind() const { | 240 virtual Code::Kind kind() const { |
| 240 UNREACHABLE(); | 241 UNREACHABLE(); |
| 241 return Code::STUB; | 242 return Code::STUB; |
| 242 } | 243 } |
| 243 virtual Handle<Code> slow_stub() const { | 244 virtual Handle<Code> slow_stub() const { |
| 244 UNREACHABLE(); | 245 UNREACHABLE(); |
| 245 return Handle<Code>::null(); | 246 return Handle<Code>::null(); |
| 246 } | 247 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 virtual Handle<Code> megamorphic_stub() { | 535 virtual Handle<Code> megamorphic_stub() { |
| 535 return isolate()->builtins()->KeyedLoadIC_Generic(); | 536 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 536 } | 537 } |
| 537 virtual Handle<Code> generic_stub() const { | 538 virtual Handle<Code> generic_stub() const { |
| 538 return isolate()->builtins()->KeyedLoadIC_Generic(); | 539 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 539 } | 540 } |
| 540 virtual Handle<Code> slow_stub() const { | 541 virtual Handle<Code> slow_stub() const { |
| 541 return isolate()->builtins()->KeyedLoadIC_Slow(); | 542 return isolate()->builtins()->KeyedLoadIC_Slow(); |
| 542 } | 543 } |
| 543 | 544 |
| 544 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } | 545 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {} |
| 545 | 546 |
| 546 private: | 547 private: |
| 547 // Stub accessors. | 548 // Stub accessors. |
| 548 static Handle<Code> initialize_stub(Isolate* isolate) { | 549 static Handle<Code> initialize_stub(Isolate* isolate) { |
| 549 return isolate->builtins()->KeyedLoadIC_Initialize(); | 550 return isolate->builtins()->KeyedLoadIC_Initialize(); |
| 550 } | 551 } |
| 551 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | 552 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { |
| 552 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); | 553 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); |
| 553 } | 554 } |
| 554 virtual Handle<Code> pre_monomorphic_stub() { | 555 virtual Handle<Code> pre_monomorphic_stub() { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 static void GenerateMiss(MacroAssembler* masm); | 739 static void GenerateMiss(MacroAssembler* masm); |
| 739 static void GenerateSlow(MacroAssembler* masm); | 740 static void GenerateSlow(MacroAssembler* masm); |
| 740 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 741 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 741 StrictModeFlag strict_mode); | 742 StrictModeFlag strict_mode); |
| 742 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 743 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
| 743 static void GenerateNonStrictArguments(MacroAssembler* masm); | 744 static void GenerateNonStrictArguments(MacroAssembler* masm); |
| 744 | 745 |
| 745 protected: | 746 protected: |
| 746 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 747 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
| 747 | 748 |
| 748 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } | 749 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {} |
| 749 | 750 |
| 750 virtual ExtraICState extra_ic_state() { | 751 virtual ExtraICState extra_ic_state() { |
| 751 return ComputeExtraICState(strict_mode(), STANDARD_STORE); | 752 return ComputeExtraICState(strict_mode(), STANDARD_STORE); |
| 752 } | 753 } |
| 753 | 754 |
| 754 virtual Handle<Code> pre_monomorphic_stub() { | 755 virtual Handle<Code> pre_monomorphic_stub() { |
| 755 return pre_monomorphic_stub(isolate(), strict_mode()); | 756 return pre_monomorphic_stub(isolate(), strict_mode()); |
| 756 } | 757 } |
| 757 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 758 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 758 StrictModeFlag strict_mode) { | 759 StrictModeFlag strict_mode) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 return KindMaybeSmi(left_kind_) || KindMaybeSmi(right_kind_); | 870 return KindMaybeSmi(left_kind_) || KindMaybeSmi(right_kind_); |
| 870 } | 871 } |
| 871 | 872 |
| 872 static const int FIRST_TOKEN = Token::BIT_OR; | 873 static const int FIRST_TOKEN = Token::BIT_OR; |
| 873 static const int LAST_TOKEN = Token::MOD; | 874 static const int LAST_TOKEN = Token::MOD; |
| 874 | 875 |
| 875 Token::Value op() const { return op_; } | 876 Token::Value op() const { return op_; } |
| 876 OverwriteMode mode() const { return mode_; } | 877 OverwriteMode mode() const { return mode_; } |
| 877 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | 878 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } |
| 878 | 879 |
| 879 Handle<Type> GetLeftType(Isolate* isolate) const { | 880 Type* GetLeftType(Zone* zone) const { |
| 880 return KindToType(left_kind_, isolate); | 881 return KindToType(left_kind_, zone); |
| 881 } | 882 } |
| 882 Handle<Type> GetRightType(Isolate* isolate) const { | 883 Type* GetRightType(Zone* zone) const { |
| 883 return KindToType(right_kind_, isolate); | 884 return KindToType(right_kind_, zone); |
| 884 } | 885 } |
| 885 Handle<Type> GetResultType(Isolate* isolate) const; | 886 Type* GetResultType(Zone* zone) const; |
| 886 | 887 |
| 887 void Print(StringStream* stream) const; | 888 void Print(StringStream* stream) const; |
| 888 | 889 |
| 889 void Update(Handle<Object> left, | 890 void Update(Handle<Object> left, |
| 890 Handle<Object> right, | 891 Handle<Object> right, |
| 891 Handle<Object> result); | 892 Handle<Object> result); |
| 892 | 893 |
| 893 private: | 894 private: |
| 894 enum Kind { NONE, SMI, INT32, NUMBER, STRING, GENERIC }; | 895 enum Kind { NONE, SMI, INT32, NUMBER, STRING, GENERIC }; |
| 895 | 896 |
| 896 Kind UpdateKind(Handle<Object> object, Kind kind) const; | 897 Kind UpdateKind(Handle<Object> object, Kind kind) const; |
| 897 | 898 |
| 898 static const char* KindToString(Kind kind); | 899 static const char* KindToString(Kind kind); |
| 899 static Handle<Type> KindToType(Kind kind, Isolate* isolate); | 900 static Type* KindToType(Kind kind, Zone* zone); |
| 900 static bool KindMaybeSmi(Kind kind) { | 901 static bool KindMaybeSmi(Kind kind) { |
| 901 return (kind >= SMI && kind <= NUMBER) || kind == GENERIC; | 902 return (kind >= SMI && kind <= NUMBER) || kind == GENERIC; |
| 902 } | 903 } |
| 903 | 904 |
| 904 // We truncate the last bit of the token. | 905 // We truncate the last bit of the token. |
| 905 STATIC_ASSERT(LAST_TOKEN - FIRST_TOKEN < (1 << 4)); | 906 STATIC_ASSERT(LAST_TOKEN - FIRST_TOKEN < (1 << 4)); |
| 906 class OpField: public BitField<int, 0, 4> {}; | 907 class OpField: public BitField<int, 0, 4> {}; |
| 907 class OverwriteModeField: public BitField<OverwriteMode, 4, 2> {}; | 908 class OverwriteModeField: public BitField<OverwriteMode, 4, 2> {}; |
| 908 class SSE2Field: public BitField<bool, 6, 1> {}; | 909 class SSE2Field: public BitField<bool, 6, 1> {}; |
| 909 class ResultKindField: public BitField<Kind, 7, 3> {}; | 910 class ResultKindField: public BitField<Kind, 7, 3> {}; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 STRING, | 947 STRING, |
| 947 INTERNALIZED_STRING, | 948 INTERNALIZED_STRING, |
| 948 UNIQUE_NAME, // Symbol or InternalizedString | 949 UNIQUE_NAME, // Symbol or InternalizedString |
| 949 OBJECT, // JSObject | 950 OBJECT, // JSObject |
| 950 KNOWN_OBJECT, // JSObject with specific map (faster check) | 951 KNOWN_OBJECT, // JSObject with specific map (faster check) |
| 951 GENERIC | 952 GENERIC |
| 952 }; | 953 }; |
| 953 | 954 |
| 954 static State NewInputState(State old_state, Handle<Object> value); | 955 static State NewInputState(State old_state, Handle<Object> value); |
| 955 | 956 |
| 956 static Handle<Type> StateToType(Isolate* isolate, | 957 static Type* StateToType(Zone* zone, |
| 957 State state, | 958 State state, |
| 958 Handle<Map> map = Handle<Map>()); | 959 Handle<Map> map = Handle<Map>()); |
| 959 | 960 |
| 960 static void StubInfoToType(int stub_minor_key, | 961 static void StubInfoToType(int stub_minor_key, |
| 961 Handle<Type>* left_type, | 962 Type** left_type, |
| 962 Handle<Type>* right_type, | 963 Type** right_type, |
| 963 Handle<Type>* overall_type, | 964 Type** overall_type, |
| 964 Handle<Map> map, | 965 Handle<Map> map, |
| 965 Isolate* isolate); | 966 Zone* zone); |
| 966 | 967 |
| 967 CompareIC(Isolate* isolate, Token::Value op) | 968 CompareIC(Isolate* isolate, Token::Value op) |
| 968 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } | 969 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } |
| 969 | 970 |
| 970 // Update the inline cache for the given operands. | 971 // Update the inline cache for the given operands. |
| 971 Code* UpdateCaches(Handle<Object> x, Handle<Object> y); | 972 Code* UpdateCaches(Handle<Object> x, Handle<Object> y); |
| 972 | 973 |
| 973 | 974 |
| 974 // Factory method for getting an uninitialized compare stub. | 975 // Factory method for getting an uninitialized compare stub. |
| 975 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op); | 976 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); | 1037 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); |
| 1037 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 1038 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
| 1038 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 1039 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
| 1039 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 1040 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
| 1040 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 1041 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
| 1041 | 1042 |
| 1042 | 1043 |
| 1043 } } // namespace v8::internal | 1044 } } // namespace v8::internal |
| 1044 | 1045 |
| 1045 #endif // V8_IC_H_ | 1046 #endif // V8_IC_H_ |
| OLD | NEW |