838 }; |
838 }; |
839 |
839 |
840 //------------------------------AbstractLockNode----------------------------------- |
840 //------------------------------AbstractLockNode----------------------------------- |
841 class AbstractLockNode: public CallNode { |
841 class AbstractLockNode: public CallNode { |
842 private: |
842 private: |
843 bool _eliminate; // indicates this lock can be safely eliminated |
843 enum { |
844 bool _coarsened; // indicates this lock was coarsened |
844 Regular = 0, // Normal lock |
|
845 NonEscObj, // Lock is used for non escaping object |
|
846 Coarsened, // Lock was coarsened |
|
847 Nested // Nested lock |
|
848 } _kind; |
845 #ifndef PRODUCT |
849 #ifndef PRODUCT |
846 NamedCounter* _counter; |
850 NamedCounter* _counter; |
847 #endif |
851 #endif |
848 |
852 |
849 protected: |
853 protected: |
856 GrowableArray<AbstractLockNode*> &lock_ops); |
860 GrowableArray<AbstractLockNode*> &lock_ops); |
857 bool find_unlocks_for_region(const RegionNode* region, LockNode* lock, |
861 bool find_unlocks_for_region(const RegionNode* region, LockNode* lock, |
858 GrowableArray<AbstractLockNode*> &lock_ops); |
862 GrowableArray<AbstractLockNode*> &lock_ops); |
859 LockNode *find_matching_lock(UnlockNode* unlock); |
863 LockNode *find_matching_lock(UnlockNode* unlock); |
860 |
864 |
|
865 // Update the counter to indicate that this lock was eliminated. |
|
866 void set_eliminated_lock_counter() PRODUCT_RETURN; |
861 |
867 |
862 public: |
868 public: |
863 AbstractLockNode(const TypeFunc *tf) |
869 AbstractLockNode(const TypeFunc *tf) |
864 : CallNode(tf, NULL, TypeRawPtr::BOTTOM), |
870 : CallNode(tf, NULL, TypeRawPtr::BOTTOM), |
865 _coarsened(false), |
871 _kind(Regular) |
866 _eliminate(false) |
|
867 { |
872 { |
868 #ifndef PRODUCT |
873 #ifndef PRODUCT |
869 _counter = NULL; |
874 _counter = NULL; |
870 #endif |
875 #endif |
871 } |
876 } |
872 virtual int Opcode() const = 0; |
877 virtual int Opcode() const = 0; |
873 Node * obj_node() const {return in(TypeFunc::Parms + 0); } |
878 Node * obj_node() const {return in(TypeFunc::Parms + 0); } |
874 Node * box_node() const {return in(TypeFunc::Parms + 1); } |
879 Node * box_node() const {return in(TypeFunc::Parms + 1); } |
875 Node * fastlock_node() const {return in(TypeFunc::Parms + 2); } |
880 Node * fastlock_node() const {return in(TypeFunc::Parms + 2); } |
|
881 void set_box_node(Node* box) { set_req(TypeFunc::Parms + 1, box); } |
|
882 |
876 const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} |
883 const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} |
877 |
884 |
878 virtual uint size_of() const { return sizeof(*this); } |
885 virtual uint size_of() const { return sizeof(*this); } |
879 |
886 |
880 bool is_eliminated() {return _eliminate; } |
887 bool is_eliminated() const { return (_kind != Regular); } |
881 // mark node as eliminated and update the counter if there is one |
888 bool is_non_esc_obj() const { return (_kind == NonEscObj); } |
882 void set_eliminated(); |
889 bool is_coarsened() const { return (_kind == Coarsened); } |
883 |
890 bool is_nested() const { return (_kind == Nested); } |
884 bool is_coarsened() { return _coarsened; } |
891 |
885 void set_coarsened() { _coarsened = true; } |
892 void set_non_esc_obj() { _kind = NonEscObj; set_eliminated_lock_counter(); } |
886 void clear_coarsened() { _coarsened = false; } |
893 void set_coarsened() { _kind = Coarsened; set_eliminated_lock_counter(); } |
|
894 void set_nested() { _kind = Nested; set_eliminated_lock_counter(); } |
887 |
895 |
888 // locking does not modify its arguments |
896 // locking does not modify its arguments |
889 virtual bool may_modify(const TypePtr *addr_t, PhaseTransform *phase){ return false;} |
897 virtual bool may_modify(const TypePtr *addr_t, PhaseTransform *phase){ return false;} |
890 |
898 |
891 #ifndef PRODUCT |
899 #ifndef PRODUCT |
892 void create_lock_counter(JVMState* s); |
900 void create_lock_counter(JVMState* s); |
893 NamedCounter* counter() const { return _counter; } |
901 NamedCounter* counter() const { return _counter; } |
894 #endif |
902 #endif |
934 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
942 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
935 // Expansion modifies the JVMState, so we need to clone it |
943 // Expansion modifies the JVMState, so we need to clone it |
936 virtual void clone_jvms() { |
944 virtual void clone_jvms() { |
937 set_jvms(jvms()->clone_deep(Compile::current())); |
945 set_jvms(jvms()->clone_deep(Compile::current())); |
938 } |
946 } |
|
947 |
|
948 bool is_nested_lock_region(); // Is this Lock nested? |
939 }; |
949 }; |
940 |
950 |
941 //------------------------------Unlock--------------------------------------- |
951 //------------------------------Unlock--------------------------------------- |
942 // High-level unlock operation |
952 // High-level unlock operation |
943 class UnlockNode : public AbstractLockNode { |
953 class UnlockNode : public AbstractLockNode { |