| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 ASSERT(target()->is_store_stub() || target()->is_keyed_store_stub()); | 504 ASSERT(target()->is_store_stub() || target()->is_keyed_store_stub()); |
| 505 } | 505 } |
| 506 | 506 |
| 507 // Code generators for stub routines. Only called once at startup. | 507 // Code generators for stub routines. Only called once at startup. |
| 508 static void GenerateSlow(MacroAssembler* masm); | 508 static void GenerateSlow(MacroAssembler* masm); |
| 509 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 509 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 510 static void GenerateMiss(MacroAssembler* masm); | 510 static void GenerateMiss(MacroAssembler* masm); |
| 511 static void GenerateMegamorphic(MacroAssembler* masm, | 511 static void GenerateMegamorphic(MacroAssembler* masm, |
| 512 StrictModeFlag strict_mode); | 512 StrictModeFlag strict_mode); |
| 513 static void GenerateNormal(MacroAssembler* masm); | 513 static void GenerateNormal(MacroAssembler* masm); |
| 514 static void GenerateGlobalProxy(MacroAssembler* masm, | 514 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 515 StrictModeFlag strict_mode); | 515 StrictModeFlag strict_mode); |
| 516 | 516 |
| 517 MUST_USE_RESULT MaybeObject* Store( | 517 MUST_USE_RESULT MaybeObject* Store( |
| 518 State state, | 518 State state, |
| 519 StrictModeFlag strict_mode, | 519 StrictModeFlag strict_mode, |
| 520 Handle<Object> object, | 520 Handle<Object> object, |
| 521 Handle<String> name, | 521 Handle<String> name, |
| 522 Handle<Object> value, | 522 Handle<Object> value, |
| 523 JSReceiver::StoreFromKeyed store_mode = | 523 JSReceiver::StoreFromKeyed store_mode = |
| 524 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); | 524 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); |
| 525 | 525 |
| 526 protected: | 526 protected: |
| 527 virtual Code::Kind kind() const { return Code::STORE_IC; } | 527 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 528 virtual Handle<Code> megamorphic_stub() { | 528 virtual Handle<Code> megamorphic_stub() { |
| 529 return isolate()->builtins()->StoreIC_Megamorphic(); | 529 return isolate()->builtins()->StoreIC_Megamorphic(); |
| 530 } | 530 } |
| 531 // Stub accessors. | 531 // Stub accessors. |
| 532 virtual Handle<Code> megamorphic_stub_strict() { | 532 virtual Handle<Code> megamorphic_stub_strict() { |
| 533 return isolate()->builtins()->StoreIC_Megamorphic_Strict(); | 533 return isolate()->builtins()->StoreIC_Megamorphic_Strict(); |
| 534 } | 534 } |
| 535 virtual Handle<Code> generic_stub() const { |
| 536 return isolate()->builtins()->StoreIC_Generic(); |
| 537 } |
| 538 virtual Handle<Code> generic_stub_strict() const { |
| 539 return isolate()->builtins()->StoreIC_Generic_Strict(); |
| 540 } |
| 535 virtual Handle<Code> global_proxy_stub() { | 541 virtual Handle<Code> global_proxy_stub() { |
| 536 return isolate()->builtins()->StoreIC_GlobalProxy(); | 542 return isolate()->builtins()->StoreIC_GlobalProxy(); |
| 537 } | 543 } |
| 538 virtual Handle<Code> global_proxy_stub_strict() { | 544 virtual Handle<Code> global_proxy_stub_strict() { |
| 539 return isolate()->builtins()->StoreIC_GlobalProxy_Strict(); | 545 return isolate()->builtins()->StoreIC_GlobalProxy_Strict(); |
| 540 } | 546 } |
| 541 | 547 |
| 542 | 548 |
| 543 // Update the inline cache and the global stub cache based on the | 549 // Update the inline cache and the global stub cache based on the |
| 544 // lookup result. | 550 // lookup result. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 public: | 683 public: |
| 678 // sorted: increasingly more unspecific (ignoring UNINITIALIZED) | 684 // sorted: increasingly more unspecific (ignoring UNINITIALIZED) |
| 679 // TODO(svenpanne) Using enums+switch is an antipattern, use a class instead. | 685 // TODO(svenpanne) Using enums+switch is an antipattern, use a class instead. |
| 680 enum TypeInfo { | 686 enum TypeInfo { |
| 681 UNINITIALIZED, | 687 UNINITIALIZED, |
| 682 SMI, | 688 SMI, |
| 683 NUMBER, | 689 NUMBER, |
| 684 GENERIC | 690 GENERIC |
| 685 }; | 691 }; |
| 686 | 692 |
| 693 static Handle<Type> TypeInfoToType(TypeInfo info, Isolate* isolate); |
| 694 |
| 687 explicit UnaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 695 explicit UnaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } |
| 688 | 696 |
| 689 void patch(Code* code); | 697 void patch(Code* code); |
| 690 | 698 |
| 691 static const char* GetName(TypeInfo type_info); | 699 static const char* GetName(TypeInfo type_info); |
| 692 | 700 |
| 693 static State ToState(TypeInfo type_info); | 701 static State ToState(TypeInfo type_info); |
| 694 | 702 |
| 695 static TypeInfo GetTypeInfo(Handle<Object> operand); | 703 static TypeInfo GetTypeInfo(Handle<Object> operand); |
| 696 | 704 |
| 697 static TypeInfo ComputeNewType(TypeInfo type, TypeInfo previous); | 705 static TypeInfo ComputeNewType(TypeInfo type, TypeInfo previous); |
| 698 }; | 706 }; |
| 699 | 707 |
| 700 | 708 |
| 701 // Type Recording BinaryOpIC, that records the types of the inputs and outputs. | 709 // Type Recording BinaryOpIC, that records the types of the inputs and outputs. |
| 702 class BinaryOpIC: public IC { | 710 class BinaryOpIC: public IC { |
| 703 public: | 711 public: |
| 704 enum TypeInfo { | 712 enum TypeInfo { |
| 705 UNINITIALIZED, | 713 UNINITIALIZED, |
| 706 SMI, | 714 SMI, |
| 707 INT32, | 715 INT32, |
| 708 NUMBER, | 716 NUMBER, |
| 709 ODDBALL, | 717 ODDBALL, |
| 710 STRING, // Only used for addition operation. | 718 STRING, // Only used for addition operation. |
| 711 GENERIC | 719 GENERIC |
| 712 }; | 720 }; |
| 713 | 721 |
| 722 static void StubInfoToType(int minor_key, |
| 723 Handle<Type>* left, |
| 724 Handle<Type>* right, |
| 725 Handle<Type>* result, |
| 726 Isolate* isolate); |
| 727 |
| 714 explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 728 explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } |
| 715 | 729 |
| 716 void patch(Code* code); | 730 void patch(Code* code); |
| 717 | 731 |
| 718 static const char* GetName(TypeInfo type_info); | 732 static const char* GetName(TypeInfo type_info); |
| 719 | 733 |
| 720 static State ToState(TypeInfo type_info); | 734 static State ToState(TypeInfo type_info); |
| 735 |
| 736 private: |
| 737 static Handle<Type> TypeInfoToType(TypeInfo binary_type, Isolate* isolate); |
| 721 }; | 738 }; |
| 722 | 739 |
| 723 | 740 |
| 724 class CompareIC: public IC { | 741 class CompareIC: public IC { |
| 725 public: | 742 public: |
| 726 // The type/state lattice is defined by the following inequations: | 743 // The type/state lattice is defined by the following inequations: |
| 727 // UNINITIALIZED < ... | 744 // UNINITIALIZED < ... |
| 728 // ... < GENERIC | 745 // ... < GENERIC |
| 729 // SMI < NUMBER | 746 // SMI < NUMBER |
| 730 // INTERNALIZED_STRING < STRING | 747 // INTERNALIZED_STRING < STRING |
| 731 // KNOWN_OBJECT < OBJECT | 748 // KNOWN_OBJECT < OBJECT |
| 732 enum State { | 749 enum State { |
| 733 UNINITIALIZED, | 750 UNINITIALIZED, |
| 734 SMI, | 751 SMI, |
| 735 NUMBER, | 752 NUMBER, |
| 736 STRING, | 753 STRING, |
| 737 INTERNALIZED_STRING, | 754 INTERNALIZED_STRING, |
| 738 UNIQUE_NAME, // Symbol or InternalizedString | 755 UNIQUE_NAME, // Symbol or InternalizedString |
| 739 OBJECT, // JSObject | 756 OBJECT, // JSObject |
| 740 KNOWN_OBJECT, // JSObject with specific map (faster check) | 757 KNOWN_OBJECT, // JSObject with specific map (faster check) |
| 741 GENERIC | 758 GENERIC |
| 742 }; | 759 }; |
| 743 | 760 |
| 761 static State NewInputState(State old_state, Handle<Object> value); |
| 762 |
| 763 static Handle<Type> StateToType(Isolate* isolate, |
| 764 State state, |
| 765 Handle<Map> map = Handle<Map>()); |
| 766 |
| 767 static void StubInfoToType(int stub_minor_key, |
| 768 Handle<Type>* left_type, |
| 769 Handle<Type>* right_type, |
| 770 Handle<Type>* overall_type, |
| 771 Handle<Map> map, |
| 772 Isolate* isolate); |
| 773 |
| 744 CompareIC(Isolate* isolate, Token::Value op) | 774 CompareIC(Isolate* isolate, Token::Value op) |
| 745 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } | 775 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } |
| 746 | 776 |
| 747 // Update the inline cache for the given operands. | 777 // Update the inline cache for the given operands. |
| 748 void UpdateCaches(Handle<Object> x, Handle<Object> y); | 778 void UpdateCaches(Handle<Object> x, Handle<Object> y); |
| 749 | 779 |
| 750 | 780 |
| 751 // Factory method for getting an uninitialized compare stub. | 781 // Factory method for getting an uninitialized compare stub. |
| 752 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op); | 782 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op); |
| 753 | 783 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 | 838 |
| 809 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); | 839 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); |
| 810 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure); | 840 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure); |
| 811 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 841 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
| 812 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 842 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
| 813 | 843 |
| 814 | 844 |
| 815 } } // namespace v8::internal | 845 } } // namespace v8::internal |
| 816 | 846 |
| 817 #endif // V8_IC_H_ | 847 #endif // V8_IC_H_ |
| OLD | NEW |