OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_IC_H_ | 5 #ifndef V8_IC_H_ |
6 #define V8_IC_H_ | 6 #define V8_IC_H_ |
7 | 7 |
8 #include "src/macro-assembler.h" | 8 #include "src/macro-assembler.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 bool is_target_set() { return target_set_; } | 162 bool is_target_set() { return target_set_; } |
163 | 163 |
164 char TransitionMarkFromState(IC::State state); | 164 char TransitionMarkFromState(IC::State state); |
165 void TraceIC(const char* type, Handle<Object> name); | 165 void TraceIC(const char* type, Handle<Object> name); |
166 void TraceIC(const char* type, Handle<Object> name, State old_state, | 166 void TraceIC(const char* type, Handle<Object> name, State old_state, |
167 State new_state); | 167 State new_state); |
168 | 168 |
169 MaybeHandle<Object> TypeError(const char* type, | 169 MaybeHandle<Object> TypeError(const char* type, |
170 Handle<Object> object, | 170 Handle<Object> object, |
171 Handle<Object> key); | 171 Handle<Object> key); |
172 MaybeHandle<Object> ReferenceError(const char* type, Handle<String> name); | 172 MaybeHandle<Object> ReferenceError(const char* type, Handle<Name> name); |
173 | 173 |
174 // Access the target code for the given IC address. | 174 // Access the target code for the given IC address. |
175 static inline Code* GetTargetAtAddress(Address address, | 175 static inline Code* GetTargetAtAddress(Address address, |
176 ConstantPoolArray* constant_pool); | 176 ConstantPoolArray* constant_pool); |
177 static inline void SetTargetAtAddress(Address address, | 177 static inline void SetTargetAtAddress(Address address, |
178 Code* target, | 178 Code* target, |
179 ConstantPoolArray* constant_pool); | 179 ConstantPoolArray* constant_pool); |
180 static void OnTypeFeedbackChanged(Isolate* isolate, Address address, | 180 static void OnTypeFeedbackChanged(Isolate* isolate, Address address, |
181 State old_state, State new_state, | 181 State old_state, State new_state, |
182 bool target_remains_ic_stub); | 182 bool target_remains_ic_stub); |
183 static void PostPatching(Address address, Code* target, Code* old_target); | 183 static void PostPatching(Address address, Code* target, Code* old_target); |
184 | 184 |
185 // Compute the handler either by compiling or by retrieving a cached version. | 185 // Compute the handler either by compiling or by retrieving a cached version. |
186 Handle<Code> ComputeHandler(LookupIterator* lookup, Handle<Object> object, | 186 Handle<Code> ComputeHandler(LookupIterator* lookup, Handle<Object> object, |
187 Handle<String> name, | 187 Handle<Name> name, |
188 Handle<Object> value = Handle<Code>::null()); | 188 Handle<Object> value = Handle<Code>::null()); |
189 virtual Handle<Code> CompileHandler(LookupIterator* lookup, | 189 virtual Handle<Code> CompileHandler(LookupIterator* lookup, |
190 Handle<Object> object, | 190 Handle<Object> object, |
191 Handle<String> name, Handle<Object> value, | 191 Handle<Name> name, Handle<Object> value, |
192 CacheHolderFlag cache_holder) { | 192 CacheHolderFlag cache_holder) { |
193 UNREACHABLE(); | 193 UNREACHABLE(); |
194 return Handle<Code>::null(); | 194 return Handle<Code>::null(); |
195 } | 195 } |
196 // Temporary copy of the above, but using a LookupResult. | 196 // Temporary copy of the above, but using a LookupResult. |
197 // TODO(jkummerow): Migrate callers to LookupIterator and delete these. | 197 // TODO(jkummerow): Migrate callers to LookupIterator and delete these. |
198 Handle<Code> ComputeStoreHandler(LookupResult* lookup, Handle<Object> object, | 198 Handle<Code> ComputeStoreHandler(LookupResult* lookup, Handle<Object> object, |
199 Handle<String> name, | 199 Handle<Name> name, |
200 Handle<Object> value = Handle<Code>::null()); | 200 Handle<Object> value = Handle<Code>::null()); |
201 virtual Handle<Code> CompileStoreHandler(LookupResult* lookup, | 201 virtual Handle<Code> CompileStoreHandler(LookupResult* lookup, |
202 Handle<Object> object, | 202 Handle<Object> object, |
203 Handle<String> name, | 203 Handle<Name> name, |
204 Handle<Object> value, | 204 Handle<Object> value, |
205 CacheHolderFlag cache_holder) { | 205 CacheHolderFlag cache_holder) { |
206 UNREACHABLE(); | 206 UNREACHABLE(); |
207 return Handle<Code>::null(); | 207 return Handle<Code>::null(); |
208 } | 208 } |
209 | 209 |
210 void UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name); | 210 void UpdateMonomorphicIC(Handle<Code> handler, Handle<Name> name); |
211 bool UpdatePolymorphicIC(Handle<String> name, Handle<Code> code); | 211 bool UpdatePolymorphicIC(Handle<Name> name, Handle<Code> code); |
212 void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); | 212 void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); |
213 | 213 |
214 void CopyICToMegamorphicCache(Handle<String> name); | 214 void CopyICToMegamorphicCache(Handle<Name> name); |
215 bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map); | 215 bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map); |
216 void PatchCache(Handle<String> name, Handle<Code> code); | 216 void PatchCache(Handle<Name> name, Handle<Code> code); |
217 Code::Kind kind() const { return kind_; } | 217 Code::Kind kind() const { return kind_; } |
218 Code::Kind handler_kind() const { | 218 Code::Kind handler_kind() const { |
219 if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC; | 219 if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC; |
220 DCHECK(kind_ == Code::LOAD_IC || kind_ == Code::STORE_IC || | 220 DCHECK(kind_ == Code::LOAD_IC || kind_ == Code::STORE_IC || |
221 kind_ == Code::KEYED_STORE_IC); | 221 kind_ == Code::KEYED_STORE_IC); |
222 return kind_; | 222 return kind_; |
223 } | 223 } |
224 virtual Handle<Code> megamorphic_stub() { | 224 virtual Handle<Code> megamorphic_stub() { |
225 UNREACHABLE(); | 225 UNREACHABLE(); |
226 return Handle<Code>::null(); | 226 return Handle<Code>::null(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } | 462 } |
463 static void GenerateMiss(MacroAssembler* masm); | 463 static void GenerateMiss(MacroAssembler* masm); |
464 static void GenerateMegamorphic(MacroAssembler* masm); | 464 static void GenerateMegamorphic(MacroAssembler* masm); |
465 static void GenerateNormal(MacroAssembler* masm); | 465 static void GenerateNormal(MacroAssembler* masm); |
466 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 466 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
467 | 467 |
468 static Handle<Code> initialize_stub(Isolate* isolate, | 468 static Handle<Code> initialize_stub(Isolate* isolate, |
469 ExtraICState extra_state); | 469 ExtraICState extra_state); |
470 | 470 |
471 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 471 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
472 Handle<String> name); | 472 Handle<Name> name); |
473 | 473 |
474 protected: | 474 protected: |
475 void set_target(Code* code) { | 475 void set_target(Code* code) { |
476 // The contextual mode must be preserved across IC patching. | 476 // The contextual mode must be preserved across IC patching. |
477 DCHECK(GetContextualMode(code->extra_ic_state()) == | 477 DCHECK(GetContextualMode(code->extra_ic_state()) == |
478 GetContextualMode(target()->extra_ic_state())); | 478 GetContextualMode(target()->extra_ic_state())); |
479 | 479 |
480 IC::set_target(code); | 480 IC::set_target(code); |
481 } | 481 } |
482 | 482 |
483 Handle<Code> slow_stub() const { | 483 Handle<Code> slow_stub() const { |
484 if (kind() == Code::LOAD_IC) { | 484 if (kind() == Code::LOAD_IC) { |
485 return isolate()->builtins()->LoadIC_Slow(); | 485 return isolate()->builtins()->LoadIC_Slow(); |
486 } else { | 486 } else { |
487 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); | 487 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); |
488 return isolate()->builtins()->KeyedLoadIC_Slow(); | 488 return isolate()->builtins()->KeyedLoadIC_Slow(); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 virtual Handle<Code> megamorphic_stub(); | 492 virtual Handle<Code> megamorphic_stub(); |
493 | 493 |
494 // Update the inline cache and the global stub cache based on the | 494 // Update the inline cache and the global stub cache based on the |
495 // lookup result. | 495 // lookup result. |
496 void UpdateCaches(LookupIterator* lookup, Handle<Object> object, | 496 void UpdateCaches(LookupIterator* lookup, Handle<Object> object, |
497 Handle<String> name); | 497 Handle<Name> name); |
498 | 498 |
499 virtual Handle<Code> CompileHandler(LookupIterator* lookup, | 499 virtual Handle<Code> CompileHandler(LookupIterator* lookup, |
500 Handle<Object> object, | 500 Handle<Object> object, |
501 Handle<String> name, | 501 Handle<Name> name, |
502 Handle<Object> unused, | 502 Handle<Object> unused, |
503 CacheHolderFlag cache_holder); | 503 CacheHolderFlag cache_holder); |
504 | 504 |
505 private: | 505 private: |
506 virtual Handle<Code> pre_monomorphic_stub() const; | 506 virtual Handle<Code> pre_monomorphic_stub() const; |
507 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 507 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
508 ExtraICState extra_state); | 508 ExtraICState extra_state); |
509 | 509 |
510 Handle<Code> SimpleFieldLoad(FieldIndex index); | 510 Handle<Code> SimpleFieldLoad(FieldIndex index); |
511 | 511 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 static void GenerateMegamorphic(MacroAssembler* masm); | 621 static void GenerateMegamorphic(MacroAssembler* masm); |
622 static void GenerateNormal(MacroAssembler* masm); | 622 static void GenerateNormal(MacroAssembler* masm); |
623 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 623 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
624 StrictMode strict_mode); | 624 StrictMode strict_mode); |
625 | 625 |
626 static Handle<Code> initialize_stub(Isolate* isolate, | 626 static Handle<Code> initialize_stub(Isolate* isolate, |
627 StrictMode strict_mode); | 627 StrictMode strict_mode); |
628 | 628 |
629 MUST_USE_RESULT MaybeHandle<Object> Store( | 629 MUST_USE_RESULT MaybeHandle<Object> Store( |
630 Handle<Object> object, | 630 Handle<Object> object, |
631 Handle<String> name, | 631 Handle<Name> name, |
632 Handle<Object> value, | 632 Handle<Object> value, |
633 JSReceiver::StoreFromKeyed store_mode = | 633 JSReceiver::StoreFromKeyed store_mode = |
634 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); | 634 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); |
635 | 635 |
636 protected: | 636 protected: |
637 virtual Handle<Code> megamorphic_stub(); | 637 virtual Handle<Code> megamorphic_stub(); |
638 | 638 |
639 // Stub accessors. | 639 // Stub accessors. |
640 virtual Handle<Code> generic_stub() const; | 640 virtual Handle<Code> generic_stub() const; |
641 | 641 |
642 virtual Handle<Code> slow_stub() const { | 642 virtual Handle<Code> slow_stub() const { |
643 return isolate()->builtins()->StoreIC_Slow(); | 643 return isolate()->builtins()->StoreIC_Slow(); |
644 } | 644 } |
645 | 645 |
646 virtual Handle<Code> pre_monomorphic_stub() const { | 646 virtual Handle<Code> pre_monomorphic_stub() const { |
647 return pre_monomorphic_stub(isolate(), strict_mode()); | 647 return pre_monomorphic_stub(isolate(), strict_mode()); |
648 } | 648 } |
649 | 649 |
650 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 650 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
651 StrictMode strict_mode); | 651 StrictMode strict_mode); |
652 | 652 |
653 // Update the inline cache and the global stub cache based on the | 653 // Update the inline cache and the global stub cache based on the |
654 // lookup result. | 654 // lookup result. |
655 void UpdateCaches(LookupResult* lookup, | 655 void UpdateCaches(LookupResult* lookup, |
656 Handle<JSObject> receiver, | 656 Handle<JSObject> receiver, |
657 Handle<String> name, | 657 Handle<Name> name, |
658 Handle<Object> value); | 658 Handle<Object> value); |
659 virtual Handle<Code> CompileStoreHandler(LookupResult* lookup, | 659 virtual Handle<Code> CompileStoreHandler(LookupResult* lookup, |
660 Handle<Object> object, | 660 Handle<Object> object, |
661 Handle<String> name, | 661 Handle<Name> name, |
662 Handle<Object> value, | 662 Handle<Object> value, |
663 CacheHolderFlag cache_holder); | 663 CacheHolderFlag cache_holder); |
664 | 664 |
665 private: | 665 private: |
666 void set_target(Code* code) { | 666 void set_target(Code* code) { |
667 // Strict mode must be preserved across IC patching. | 667 // Strict mode must be preserved across IC patching. |
668 DCHECK(GetStrictMode(code->extra_ic_state()) == | 668 DCHECK(GetStrictMode(code->extra_ic_state()) == |
669 GetStrictMode(target()->extra_ic_state())); | 669 GetStrictMode(target()->extra_ic_state())); |
670 IC::set_target(code); | 670 IC::set_target(code); |
671 } | 671 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); | 1040 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); |
1041 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); | 1041 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); |
1042 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); | 1042 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); |
1043 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); | 1043 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); |
1044 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); | 1044 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); |
1045 | 1045 |
1046 | 1046 |
1047 } } // namespace v8::internal | 1047 } } // namespace v8::internal |
1048 | 1048 |
1049 #endif // V8_IC_H_ | 1049 #endif // V8_IC_H_ |
OLD | NEW |