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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 // Determines which map must be used for keeping the code stub. | 141 // Determines which map must be used for keeping the code stub. |
142 // These methods should not be called with undefined or null. | 142 // These methods should not be called with undefined or null. |
143 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); | 143 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); |
144 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* | 144 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* |
145 // since loading the IC for loading the length from strings are stored on | 145 // since loading the IC for loading the length from strings are stored on |
146 // the string map directly, rather than on the JSObject-typed prototype. | 146 // the string map directly, rather than on the JSObject-typed prototype. |
147 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, | 147 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, |
148 Object* object, | 148 Object* object, |
149 InlineCacheHolderFlag holder); | 149 InlineCacheHolderFlag holder); |
150 | 150 |
151 static inline InlineCacheHolderFlag GetCodeCacheFlag(Type* type); | |
152 static inline Handle<Map> GetCodeCacheHolder(InlineCacheHolderFlag flag, | |
153 Type* type, | |
154 Isolate* isolate); | |
155 | |
151 static bool IsCleared(Code* code) { | 156 static bool IsCleared(Code* code) { |
152 InlineCacheState state = code->ic_state(); | 157 InlineCacheState state = code->ic_state(); |
153 return state == UNINITIALIZED || state == PREMONOMORPHIC; | 158 return state == UNINITIALIZED || state == PREMONOMORPHIC; |
154 } | 159 } |
155 | 160 |
161 // Utility functions to convert maps to types and back. There are two special | |
162 // cases: | |
163 // - The heap_number_map is used as a marker which includes heap numbers as | |
164 // well as smis. | |
165 // - The oddball map is only used for booleans. | |
166 static Handle<Map> GetMap(Type* type, Isolate* isolate); | |
rossberg
2013/11/18 17:02:06
Nit: I'd prefer names that make clearer that it's
| |
167 static Type* GetType(Handle<Map> type); | |
168 | |
156 protected: | 169 protected: |
157 // Get the call-site target; used for determining the state. | 170 // Get the call-site target; used for determining the state. |
158 Handle<Code> target() const { return target_; } | 171 Handle<Code> target() const { return target_; } |
159 | 172 |
160 Address fp() const { return fp_; } | 173 Address fp() const { return fp_; } |
161 Address pc() const { return *pc_address_; } | 174 Address pc() const { return *pc_address_; } |
162 Isolate* isolate() const { return isolate_; } | 175 Isolate* isolate() const { return isolate_; } |
163 | 176 |
164 #ifdef ENABLE_DEBUGGER_SUPPORT | 177 #ifdef ENABLE_DEBUGGER_SUPPORT |
165 // Computes the address in the original code when the code running is | 178 // Computes the address in the original code when the code running is |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 Handle<String> name, | 210 Handle<String> name, |
198 Handle<Object> value = Handle<Code>::null()); | 211 Handle<Object> value = Handle<Code>::null()); |
199 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 212 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
200 Handle<Object> object, | 213 Handle<Object> object, |
201 Handle<String> name, | 214 Handle<String> name, |
202 Handle<Object> value, | 215 Handle<Object> value, |
203 InlineCacheHolderFlag cache_holder) { | 216 InlineCacheHolderFlag cache_holder) { |
204 UNREACHABLE(); | 217 UNREACHABLE(); |
205 return Handle<Code>::null(); | 218 return Handle<Code>::null(); |
206 } | 219 } |
207 void UpdateMonomorphicIC(Handle<Object> receiver, | 220 |
221 void UpdateMonomorphicIC(Handle<Type> type, | |
208 Handle<Code> handler, | 222 Handle<Code> handler, |
209 Handle<String> name); | 223 Handle<String> name); |
210 | 224 |
211 bool UpdatePolymorphicIC(Handle<Object> receiver, | 225 bool UpdatePolymorphicIC(Handle<Type> type, |
212 Handle<String> name, | 226 Handle<String> name, |
213 Handle<Code> code); | 227 Handle<Code> code); |
214 | 228 |
229 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code); | |
230 | |
215 void CopyICToMegamorphicCache(Handle<String> name); | 231 void CopyICToMegamorphicCache(Handle<String> name); |
216 bool IsTransitionedMapOfMonomorphicTarget(Map* receiver_map); | 232 bool IsTransitionOfMonomorphicTarget(Type* type); |
217 void PatchCache(Handle<Object> object, | 233 void PatchCache(Handle<Type> type, |
218 Handle<String> name, | 234 Handle<String> name, |
219 Handle<Code> code); | 235 Handle<Code> code); |
220 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code); | |
221 virtual Code::Kind kind() const { | 236 virtual Code::Kind kind() const { |
222 UNREACHABLE(); | 237 UNREACHABLE(); |
223 return Code::STUB; | 238 return Code::STUB; |
224 } | 239 } |
225 virtual Handle<Code> slow_stub() const { | 240 virtual Handle<Code> slow_stub() const { |
226 UNREACHABLE(); | 241 UNREACHABLE(); |
227 return Handle<Code>::null(); | 242 return Handle<Code>::null(); |
228 } | 243 } |
229 virtual Handle<Code> megamorphic_stub() { | 244 virtual Handle<Code> megamorphic_stub() { |
230 UNREACHABLE(); | 245 UNREACHABLE(); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 virtual Handle<Code> megamorphic_stub() { | 520 virtual Handle<Code> megamorphic_stub() { |
506 return isolate()->builtins()->KeyedLoadIC_Generic(); | 521 return isolate()->builtins()->KeyedLoadIC_Generic(); |
507 } | 522 } |
508 virtual Handle<Code> generic_stub() const { | 523 virtual Handle<Code> generic_stub() const { |
509 return isolate()->builtins()->KeyedLoadIC_Generic(); | 524 return isolate()->builtins()->KeyedLoadIC_Generic(); |
510 } | 525 } |
511 virtual Handle<Code> slow_stub() const { | 526 virtual Handle<Code> slow_stub() const { |
512 return isolate()->builtins()->KeyedLoadIC_Slow(); | 527 return isolate()->builtins()->KeyedLoadIC_Slow(); |
513 } | 528 } |
514 | 529 |
515 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { } | 530 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } |
516 | 531 |
517 private: | 532 private: |
518 // Stub accessors. | 533 // Stub accessors. |
519 static Handle<Code> initialize_stub(Isolate* isolate) { | 534 static Handle<Code> initialize_stub(Isolate* isolate) { |
520 return isolate->builtins()->KeyedLoadIC_Initialize(); | 535 return isolate->builtins()->KeyedLoadIC_Initialize(); |
521 } | 536 } |
522 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | 537 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { |
523 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); | 538 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); |
524 } | 539 } |
525 virtual Handle<Code> pre_monomorphic_stub() { | 540 virtual Handle<Code> pre_monomorphic_stub() { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 static void GenerateMiss(MacroAssembler* masm); | 701 static void GenerateMiss(MacroAssembler* masm); |
687 static void GenerateSlow(MacroAssembler* masm); | 702 static void GenerateSlow(MacroAssembler* masm); |
688 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 703 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
689 StrictModeFlag strict_mode); | 704 StrictModeFlag strict_mode); |
690 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 705 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
691 static void GenerateNonStrictArguments(MacroAssembler* masm); | 706 static void GenerateNonStrictArguments(MacroAssembler* masm); |
692 | 707 |
693 protected: | 708 protected: |
694 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 709 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
695 | 710 |
696 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { } | 711 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } |
697 | 712 |
698 virtual Handle<Code> pre_monomorphic_stub() { | 713 virtual Handle<Code> pre_monomorphic_stub() { |
699 return pre_monomorphic_stub(isolate(), strict_mode()); | 714 return pre_monomorphic_stub(isolate(), strict_mode()); |
700 } | 715 } |
701 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 716 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
702 StrictModeFlag strict_mode) { | 717 StrictModeFlag strict_mode) { |
703 if (strict_mode == kStrictMode) { | 718 if (strict_mode == kStrictMode) { |
704 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); | 719 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); |
705 } else { | 720 } else { |
706 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); | 721 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); | 910 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); |
896 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 911 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
897 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 912 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
898 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 913 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
899 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 914 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
900 | 915 |
901 | 916 |
902 } } // namespace v8::internal | 917 } } // namespace v8::internal |
903 | 918 |
904 #endif // V8_IC_H_ | 919 #endif // V8_IC_H_ |
OLD | NEW |