| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 Handle<Object> value = Handle<Code>::null()); | 185 Handle<Object> value = Handle<Code>::null()); |
| 186 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 186 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
| 187 Handle<Object> object, | 187 Handle<Object> object, |
| 188 Handle<String> name, Handle<Object> value, | 188 Handle<String> name, Handle<Object> value, |
| 189 CacheHolderFlag cache_holder) { | 189 CacheHolderFlag cache_holder) { |
| 190 UNREACHABLE(); | 190 UNREACHABLE(); |
| 191 return Handle<Code>::null(); | 191 return Handle<Code>::null(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name); | 194 void UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name); |
| 195 | |
| 196 bool UpdatePolymorphicIC(Handle<String> name, Handle<Code> code); | 195 bool UpdatePolymorphicIC(Handle<String> name, Handle<Code> code); |
| 197 | 196 void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); |
| 198 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); | |
| 199 | 197 |
| 200 void CopyICToMegamorphicCache(Handle<String> name); | 198 void CopyICToMegamorphicCache(Handle<String> name); |
| 201 bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map); | 199 bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map); |
| 202 void PatchCache(Handle<String> name, Handle<Code> code); | 200 void PatchCache(Handle<String> name, Handle<Code> code); |
| 203 virtual Code::Kind kind() const { | 201 Code::Kind kind() const { return kind_; } |
| 204 UNREACHABLE(); | 202 Code::Kind handler_kind() const { |
| 205 return Code::STUB; | 203 if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC; |
| 206 } | 204 ASSERT(kind_ == Code::LOAD_IC || kind_ == Code::STORE_IC || |
| 207 virtual Handle<Code> slow_stub() const { | 205 kind_ == Code::KEYED_STORE_IC); |
| 208 UNREACHABLE(); | 206 return kind_; |
| 209 return Handle<Code>::null(); | |
| 210 } | 207 } |
| 211 virtual Handle<Code> megamorphic_stub() { | 208 virtual Handle<Code> megamorphic_stub() { |
| 212 UNREACHABLE(); | 209 UNREACHABLE(); |
| 213 return Handle<Code>::null(); | 210 return Handle<Code>::null(); |
| 214 } | 211 } |
| 215 virtual Handle<Code> generic_stub() const { | |
| 216 UNREACHABLE(); | |
| 217 return Handle<Code>::null(); | |
| 218 } | |
| 219 | 212 |
| 220 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, | 213 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
| 221 Handle<String> name); | 214 Handle<String> name); |
| 222 | 215 |
| 223 ExtraICState extra_ic_state() const { return extra_ic_state_; } | 216 ExtraICState extra_ic_state() const { return extra_ic_state_; } |
| 224 void set_extra_ic_state(ExtraICState state) { | 217 void set_extra_ic_state(ExtraICState state) { |
| 225 extra_ic_state_ = state; | 218 extra_ic_state_ = state; |
| 226 } | 219 } |
| 227 | 220 |
| 228 Handle<HeapType> receiver_type() { return receiver_type_; } | 221 Handle<HeapType> receiver_type() { return receiver_type_; } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 Isolate* isolate_; | 274 Isolate* isolate_; |
| 282 | 275 |
| 283 // The constant pool of the code which originally called the IC (which might | 276 // The constant pool of the code which originally called the IC (which might |
| 284 // be for the breakpointed copy of the original code). | 277 // be for the breakpointed copy of the original code). |
| 285 Handle<ConstantPoolArray> raw_constant_pool_; | 278 Handle<ConstantPoolArray> raw_constant_pool_; |
| 286 | 279 |
| 287 // The original code target that missed. | 280 // The original code target that missed. |
| 288 Handle<Code> target_; | 281 Handle<Code> target_; |
| 289 bool target_set_; | 282 bool target_set_; |
| 290 State state_; | 283 State state_; |
| 284 Code::Kind kind_; |
| 291 Handle<HeapType> receiver_type_; | 285 Handle<HeapType> receiver_type_; |
| 292 MaybeHandle<Code> maybe_handler_; | 286 MaybeHandle<Code> maybe_handler_; |
| 293 | 287 |
| 294 ExtraICState extra_ic_state_; | 288 ExtraICState extra_ic_state_; |
| 295 MapHandleList target_maps_; | 289 MapHandleList target_maps_; |
| 296 bool target_maps_set_; | 290 bool target_maps_set_; |
| 297 | 291 |
| 298 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); | 292 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); |
| 299 }; | 293 }; |
| 300 | 294 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 static void GenerateNormal(MacroAssembler* masm); | 429 static void GenerateNormal(MacroAssembler* masm); |
| 436 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 430 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 437 | 431 |
| 438 static Handle<Code> initialize_stub(Isolate* isolate, | 432 static Handle<Code> initialize_stub(Isolate* isolate, |
| 439 ExtraICState extra_state); | 433 ExtraICState extra_state); |
| 440 | 434 |
| 441 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 435 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
| 442 Handle<String> name); | 436 Handle<String> name); |
| 443 | 437 |
| 444 protected: | 438 protected: |
| 445 virtual Code::Kind kind() const { return Code::LOAD_IC; } | |
| 446 | |
| 447 void set_target(Code* code) { | 439 void set_target(Code* code) { |
| 448 // The contextual mode must be preserved across IC patching. | 440 // The contextual mode must be preserved across IC patching. |
| 449 ASSERT(GetContextualMode(code->extra_ic_state()) == | 441 ASSERT(GetContextualMode(code->extra_ic_state()) == |
| 450 GetContextualMode(target()->extra_ic_state())); | 442 GetContextualMode(target()->extra_ic_state())); |
| 451 | 443 |
| 452 IC::set_target(code); | 444 IC::set_target(code); |
| 453 } | 445 } |
| 454 | 446 |
| 455 virtual Handle<Code> slow_stub() const { | 447 Handle<Code> slow_stub() const { |
| 456 return isolate()->builtins()->LoadIC_Slow(); | 448 if (kind() == Code::LOAD_IC) { |
| 449 return isolate()->builtins()->LoadIC_Slow(); |
| 450 } else { |
| 451 ASSERT_EQ(Code::KEYED_LOAD_IC, kind()); |
| 452 return isolate()->builtins()->KeyedLoadIC_Slow(); |
| 453 } |
| 457 } | 454 } |
| 458 | 455 |
| 459 virtual Handle<Code> megamorphic_stub(); | 456 virtual Handle<Code> megamorphic_stub(); |
| 460 virtual Handle<Code> generic_stub() const; | |
| 461 | 457 |
| 462 // Update the inline cache and the global stub cache based on the | 458 // Update the inline cache and the global stub cache based on the |
| 463 // lookup result. | 459 // lookup result. |
| 464 void UpdateCaches(LookupResult* lookup, | 460 void UpdateCaches(LookupResult* lookup, |
| 465 Handle<Object> object, | 461 Handle<Object> object, |
| 466 Handle<String> name); | 462 Handle<String> name); |
| 467 | 463 |
| 468 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 464 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
| 469 Handle<Object> object, | 465 Handle<Object> object, |
| 470 Handle<String> name, | 466 Handle<String> name, |
| 471 Handle<Object> unused, | 467 Handle<Object> unused, |
| 472 CacheHolderFlag cache_holder); | 468 CacheHolderFlag cache_holder); |
| 473 | 469 |
| 474 private: | 470 private: |
| 475 // Stub accessors. | 471 virtual Handle<Code> pre_monomorphic_stub() const; |
| 476 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 472 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 477 ExtraICState exstra_state); | 473 ExtraICState extra_state); |
| 478 | |
| 479 virtual Handle<Code> pre_monomorphic_stub() { | |
| 480 return pre_monomorphic_stub(isolate(), extra_ic_state()); | |
| 481 } | |
| 482 | 474 |
| 483 Handle<Code> SimpleFieldLoad(FieldIndex index); | 475 Handle<Code> SimpleFieldLoad(FieldIndex index); |
| 484 | 476 |
| 485 static void Clear(Isolate* isolate, | 477 static void Clear(Isolate* isolate, |
| 486 Address address, | 478 Address address, |
| 487 Code* target, | 479 Code* target, |
| 488 ConstantPoolArray* constant_pool); | 480 ConstantPoolArray* constant_pool); |
| 489 | 481 |
| 490 friend class IC; | 482 friend class IC; |
| 491 }; | 483 }; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 513 static void GenerateIndexedInterceptor(MacroAssembler* masm); | 505 static void GenerateIndexedInterceptor(MacroAssembler* masm); |
| 514 static void GenerateSloppyArguments(MacroAssembler* masm); | 506 static void GenerateSloppyArguments(MacroAssembler* masm); |
| 515 | 507 |
| 516 // Bit mask to be tested against bit field for the cases when | 508 // Bit mask to be tested against bit field for the cases when |
| 517 // generic stub should go into slow case. | 509 // generic stub should go into slow case. |
| 518 // Access check is necessary explicitly since generic stub does not perform | 510 // Access check is necessary explicitly since generic stub does not perform |
| 519 // map checks. | 511 // map checks. |
| 520 static const int kSlowCaseBitFieldMask = | 512 static const int kSlowCaseBitFieldMask = |
| 521 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); | 513 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); |
| 522 | 514 |
| 515 static Handle<Code> generic_stub(Isolate* isolate); |
| 516 static Handle<Code> pre_monomorphic_stub(Isolate* isolate); |
| 517 |
| 523 protected: | 518 protected: |
| 524 virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } | |
| 525 | |
| 526 Handle<Code> LoadElementStub(Handle<JSObject> receiver); | 519 Handle<Code> LoadElementStub(Handle<JSObject> receiver); |
| 527 | 520 virtual Handle<Code> pre_monomorphic_stub() const { |
| 528 virtual Handle<Code> megamorphic_stub(); | 521 return pre_monomorphic_stub(isolate()); |
| 529 virtual Handle<Code> generic_stub() const; | |
| 530 | |
| 531 virtual Handle<Code> slow_stub() const { | |
| 532 return isolate()->builtins()->KeyedLoadIC_Slow(); | |
| 533 } | 522 } |
| 534 | 523 |
| 535 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {} | |
| 536 | |
| 537 private: | 524 private: |
| 538 // Stub accessors. | 525 Handle<Code> generic_stub() const { return generic_stub(isolate()); } |
| 539 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | |
| 540 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); | |
| 541 } | |
| 542 virtual Handle<Code> pre_monomorphic_stub() { | |
| 543 return pre_monomorphic_stub(isolate()); | |
| 544 } | |
| 545 Handle<Code> indexed_interceptor_stub() { | 526 Handle<Code> indexed_interceptor_stub() { |
| 546 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); | 527 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); |
| 547 } | 528 } |
| 548 Handle<Code> sloppy_arguments_stub() { | 529 Handle<Code> sloppy_arguments_stub() { |
| 549 return isolate()->builtins()->KeyedLoadIC_SloppyArguments(); | 530 return isolate()->builtins()->KeyedLoadIC_SloppyArguments(); |
| 550 } | 531 } |
| 551 Handle<Code> string_stub() { | 532 Handle<Code> string_stub() { |
| 552 return isolate()->builtins()->KeyedLoadIC_String(); | 533 return isolate()->builtins()->KeyedLoadIC_String(); |
| 553 } | 534 } |
| 554 | 535 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 StrictMode strict_mode); | 592 StrictMode strict_mode); |
| 612 | 593 |
| 613 MUST_USE_RESULT MaybeHandle<Object> Store( | 594 MUST_USE_RESULT MaybeHandle<Object> Store( |
| 614 Handle<Object> object, | 595 Handle<Object> object, |
| 615 Handle<String> name, | 596 Handle<String> name, |
| 616 Handle<Object> value, | 597 Handle<Object> value, |
| 617 JSReceiver::StoreFromKeyed store_mode = | 598 JSReceiver::StoreFromKeyed store_mode = |
| 618 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); | 599 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); |
| 619 | 600 |
| 620 protected: | 601 protected: |
| 621 virtual Code::Kind kind() const { return Code::STORE_IC; } | |
| 622 virtual Handle<Code> megamorphic_stub(); | 602 virtual Handle<Code> megamorphic_stub(); |
| 623 | 603 |
| 624 // Stub accessors. | 604 // Stub accessors. |
| 625 virtual Handle<Code> generic_stub() const; | 605 virtual Handle<Code> generic_stub() const; |
| 626 | 606 |
| 627 virtual Handle<Code> slow_stub() const { | 607 virtual Handle<Code> slow_stub() const { |
| 628 return isolate()->builtins()->StoreIC_Slow(); | 608 return isolate()->builtins()->StoreIC_Slow(); |
| 629 } | 609 } |
| 630 | 610 |
| 631 virtual Handle<Code> pre_monomorphic_stub() { | 611 virtual Handle<Code> pre_monomorphic_stub() const { |
| 632 return pre_monomorphic_stub(isolate(), strict_mode()); | 612 return pre_monomorphic_stub(isolate(), strict_mode()); |
| 633 } | 613 } |
| 634 | 614 |
| 635 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 615 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 636 StrictMode strict_mode); | 616 StrictMode strict_mode); |
| 637 | 617 |
| 638 // Update the inline cache and the global stub cache based on the | 618 // Update the inline cache and the global stub cache based on the |
| 639 // lookup result. | 619 // lookup result. |
| 640 void UpdateCaches(LookupResult* lookup, | 620 void UpdateCaches(LookupResult* lookup, |
| 641 Handle<JSObject> receiver, | 621 Handle<JSObject> receiver, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 GenerateMiss(masm); | 697 GenerateMiss(masm); |
| 718 } | 698 } |
| 719 static void GenerateMiss(MacroAssembler* masm); | 699 static void GenerateMiss(MacroAssembler* masm); |
| 720 static void GenerateSlow(MacroAssembler* masm); | 700 static void GenerateSlow(MacroAssembler* masm); |
| 721 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 701 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 722 StrictMode strict_mode); | 702 StrictMode strict_mode); |
| 723 static void GenerateGeneric(MacroAssembler* masm, StrictMode strict_mode); | 703 static void GenerateGeneric(MacroAssembler* masm, StrictMode strict_mode); |
| 724 static void GenerateSloppyArguments(MacroAssembler* masm); | 704 static void GenerateSloppyArguments(MacroAssembler* masm); |
| 725 | 705 |
| 726 protected: | 706 protected: |
| 727 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 707 virtual Handle<Code> pre_monomorphic_stub() const { |
| 728 | |
| 729 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {} | |
| 730 | |
| 731 virtual Handle<Code> pre_monomorphic_stub() { | |
| 732 return pre_monomorphic_stub(isolate(), strict_mode()); | 708 return pre_monomorphic_stub(isolate(), strict_mode()); |
| 733 } | 709 } |
| 734 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 710 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 735 StrictMode strict_mode) { | 711 StrictMode strict_mode) { |
| 736 if (strict_mode == STRICT) { | 712 if (strict_mode == STRICT) { |
| 737 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); | 713 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); |
| 738 } else { | 714 } else { |
| 739 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); | 715 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); |
| 740 } | 716 } |
| 741 } | 717 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); | 1008 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); |
| 1033 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); | 1009 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); |
| 1034 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); | 1010 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); |
| 1035 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); | 1011 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); |
| 1036 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); | 1012 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); |
| 1037 | 1013 |
| 1038 | 1014 |
| 1039 } } // namespace v8::internal | 1015 } } // namespace v8::internal |
| 1040 | 1016 |
| 1041 #endif // V8_IC_H_ | 1017 #endif // V8_IC_H_ |
| OLD | NEW |