1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/locknode.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,149 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_OPTO_LOCKNODE_HPP 1.29 +#define SHARE_VM_OPTO_LOCKNODE_HPP 1.30 + 1.31 +#include "opto/node.hpp" 1.32 +#include "opto/opcodes.hpp" 1.33 +#include "opto/subnode.hpp" 1.34 +#ifdef TARGET_ARCH_MODEL_x86_32 1.35 +# include "adfiles/ad_x86_32.hpp" 1.36 +#endif 1.37 +#ifdef TARGET_ARCH_MODEL_x86_64 1.38 +# include "adfiles/ad_x86_64.hpp" 1.39 +#endif 1.40 +#ifdef TARGET_ARCH_MODEL_sparc 1.41 +# include "adfiles/ad_sparc.hpp" 1.42 +#endif 1.43 +#ifdef TARGET_ARCH_MODEL_zero 1.44 +# include "adfiles/ad_zero.hpp" 1.45 +#endif 1.46 +#ifdef TARGET_ARCH_MODEL_arm 1.47 +# include "adfiles/ad_arm.hpp" 1.48 +#endif 1.49 +#ifdef TARGET_ARCH_MODEL_ppc_32 1.50 +# include "adfiles/ad_ppc_32.hpp" 1.51 +#endif 1.52 +#ifdef TARGET_ARCH_MODEL_ppc_64 1.53 +# include "adfiles/ad_ppc_64.hpp" 1.54 +#endif 1.55 + 1.56 +//------------------------------BoxLockNode------------------------------------ 1.57 +class BoxLockNode : public Node { 1.58 + const int _slot; // stack slot 1.59 + RegMask _inmask; // OptoReg corresponding to stack slot 1.60 + bool _is_eliminated; // Associated locks were safely eliminated 1.61 + 1.62 +public: 1.63 + BoxLockNode( int lock ); 1.64 + virtual int Opcode() const; 1.65 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.66 + virtual uint size(PhaseRegAlloc *ra_) const; 1.67 + virtual const RegMask &in_RegMask(uint) const; 1.68 + virtual const RegMask &out_RegMask() const; 1.69 + virtual uint size_of() const; 1.70 + virtual uint hash() const; 1.71 + virtual uint cmp( const Node &n ) const; 1.72 + virtual const class Type *bottom_type() const { return TypeRawPtr::BOTTOM; } 1.73 + virtual uint ideal_reg() const { return Op_RegP; } 1.74 + 1.75 + static OptoReg::Name reg(Node* box_node); 1.76 + static BoxLockNode* box_node(Node* box_node); 1.77 + static bool same_slot(Node* box1, Node* box2) { 1.78 + return box1->as_BoxLock()->_slot == box2->as_BoxLock()->_slot; 1.79 + } 1.80 + int stack_slot() const { return _slot; } 1.81 + 1.82 + bool is_eliminated() const { return _is_eliminated; } 1.83 + // mark lock as eliminated. 1.84 + void set_eliminated() { _is_eliminated = true; } 1.85 + 1.86 + // Is BoxLock node used for one simple lock region? 1.87 + bool is_simple_lock_region(LockNode** unique_lock, Node* obj); 1.88 + 1.89 +#ifndef PRODUCT 1.90 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.91 + virtual void dump_spec(outputStream *st) const { st->print(" Lock %d",_slot); } 1.92 +#endif 1.93 +}; 1.94 + 1.95 +//------------------------------FastLockNode----------------------------------- 1.96 +class FastLockNode: public CmpNode { 1.97 +private: 1.98 + BiasedLockingCounters* _counters; 1.99 + RTMLockingCounters* _rtm_counters; // RTM lock counters for inflated locks 1.100 + RTMLockingCounters* _stack_rtm_counters; // RTM lock counters for stack locks 1.101 + 1.102 +public: 1.103 + FastLockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { 1.104 + init_req(0,ctrl); 1.105 + init_class_id(Class_FastLock); 1.106 + _counters = NULL; 1.107 + _rtm_counters = NULL; 1.108 + _stack_rtm_counters = NULL; 1.109 + } 1.110 + Node* obj_node() const { return in(1); } 1.111 + Node* box_node() const { return in(2); } 1.112 + void set_box_node(Node* box) { set_req(2, box); } 1.113 + 1.114 + // FastLock and FastUnlockNode do not hash, we need one for each correspoding 1.115 + // LockNode/UnLockNode to avoid creating Phi's. 1.116 + virtual uint hash() const ; // { return NO_HASH; } 1.117 + virtual uint size_of() const; 1.118 + virtual uint cmp( const Node &n ) const ; // Always fail, except on self 1.119 + virtual int Opcode() const; 1.120 + virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } 1.121 + const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} 1.122 + 1.123 + void create_lock_counter(JVMState* s); 1.124 + void create_rtm_lock_counter(JVMState* state); 1.125 + BiasedLockingCounters* counters() const { return _counters; } 1.126 + RTMLockingCounters* rtm_counters() const { return _rtm_counters; } 1.127 + RTMLockingCounters* stack_rtm_counters() const { return _stack_rtm_counters; } 1.128 +}; 1.129 + 1.130 + 1.131 +//------------------------------FastUnlockNode--------------------------------- 1.132 +class FastUnlockNode: public CmpNode { 1.133 +public: 1.134 + FastUnlockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { 1.135 + init_req(0,ctrl); 1.136 + init_class_id(Class_FastUnlock); 1.137 + } 1.138 + Node* obj_node() const { return in(1); } 1.139 + Node* box_node() const { return in(2); } 1.140 + 1.141 + 1.142 + // FastLock and FastUnlockNode do not hash, we need one for each correspoding 1.143 + // LockNode/UnLockNode to avoid creating Phi's. 1.144 + virtual uint hash() const ; // { return NO_HASH; } 1.145 + virtual uint cmp( const Node &n ) const ; // Always fail, except on self 1.146 + virtual int Opcode() const; 1.147 + virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } 1.148 + const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} 1.149 + 1.150 +}; 1.151 + 1.152 +#endif // SHARE_VM_OPTO_LOCKNODE_HPP