Tue, 08 Aug 2017 15:57:29 +0800
merge
1 /*
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 /*
26 * This file has been modified by Loongson Technology in 2015. These
27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
28 * available on the same license terms set forth above.
29 */
31 #ifndef SHARE_VM_OPTO_LOCKNODE_HPP
32 #define SHARE_VM_OPTO_LOCKNODE_HPP
34 #include "opto/node.hpp"
35 #include "opto/opcodes.hpp"
36 #include "opto/subnode.hpp"
37 #ifdef TARGET_ARCH_MODEL_x86_32
38 # include "adfiles/ad_x86_32.hpp"
39 #endif
40 #ifdef TARGET_ARCH_MODEL_x86_64
41 # include "adfiles/ad_x86_64.hpp"
42 #endif
43 #ifdef TARGET_ARCH_MODEL_mips_64
44 # include "adfiles/ad_mips_64.hpp"
45 #endif
46 #ifdef TARGET_ARCH_MODEL_sparc
47 # include "adfiles/ad_sparc.hpp"
48 #endif
49 #ifdef TARGET_ARCH_MODEL_zero
50 # include "adfiles/ad_zero.hpp"
51 #endif
52 #ifdef TARGET_ARCH_MODEL_arm
53 # include "adfiles/ad_arm.hpp"
54 #endif
55 #ifdef TARGET_ARCH_MODEL_ppc_32
56 # include "adfiles/ad_ppc_32.hpp"
57 #endif
58 #ifdef TARGET_ARCH_MODEL_ppc_64
59 # include "adfiles/ad_ppc_64.hpp"
60 #endif
62 //------------------------------BoxLockNode------------------------------------
63 class BoxLockNode : public Node {
64 const int _slot; // stack slot
65 RegMask _inmask; // OptoReg corresponding to stack slot
66 bool _is_eliminated; // Associated locks were safely eliminated
68 public:
69 BoxLockNode( int lock );
70 virtual int Opcode() const;
71 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
72 virtual uint size(PhaseRegAlloc *ra_) const;
73 virtual const RegMask &in_RegMask(uint) const;
74 virtual const RegMask &out_RegMask() const;
75 virtual uint size_of() const;
76 virtual uint hash() const;
77 virtual uint cmp( const Node &n ) const;
78 virtual const class Type *bottom_type() const { return TypeRawPtr::BOTTOM; }
79 virtual uint ideal_reg() const { return Op_RegP; }
81 static OptoReg::Name reg(Node* box_node);
82 static BoxLockNode* box_node(Node* box_node);
83 static bool same_slot(Node* box1, Node* box2) {
84 return box1->as_BoxLock()->_slot == box2->as_BoxLock()->_slot;
85 }
86 int stack_slot() const { return _slot; }
88 bool is_eliminated() const { return _is_eliminated; }
89 // mark lock as eliminated.
90 void set_eliminated() { _is_eliminated = true; }
92 // Is BoxLock node used for one simple lock region?
93 bool is_simple_lock_region(LockNode** unique_lock, Node* obj);
95 #ifndef PRODUCT
96 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
97 virtual void dump_spec(outputStream *st) const { st->print(" Lock %d",_slot); }
98 #endif
99 };
101 //------------------------------FastLockNode-----------------------------------
102 class FastLockNode: public CmpNode {
103 private:
104 BiasedLockingCounters* _counters;
105 RTMLockingCounters* _rtm_counters; // RTM lock counters for inflated locks
106 RTMLockingCounters* _stack_rtm_counters; // RTM lock counters for stack locks
108 public:
109 FastLockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) {
110 init_req(0,ctrl);
111 init_class_id(Class_FastLock);
112 _counters = NULL;
113 _rtm_counters = NULL;
114 _stack_rtm_counters = NULL;
115 }
116 Node* obj_node() const { return in(1); }
117 Node* box_node() const { return in(2); }
118 void set_box_node(Node* box) { set_req(2, box); }
120 // FastLock and FastUnlockNode do not hash, we need one for each correspoding
121 // LockNode/UnLockNode to avoid creating Phi's.
122 virtual uint hash() const ; // { return NO_HASH; }
123 virtual uint size_of() const;
124 virtual uint cmp( const Node &n ) const ; // Always fail, except on self
125 virtual int Opcode() const;
126 virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; }
127 const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;}
129 void create_lock_counter(JVMState* s);
130 void create_rtm_lock_counter(JVMState* state);
131 BiasedLockingCounters* counters() const { return _counters; }
132 RTMLockingCounters* rtm_counters() const { return _rtm_counters; }
133 RTMLockingCounters* stack_rtm_counters() const { return _stack_rtm_counters; }
134 };
137 //------------------------------FastUnlockNode---------------------------------
138 class FastUnlockNode: public CmpNode {
139 public:
140 FastUnlockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) {
141 init_req(0,ctrl);
142 init_class_id(Class_FastUnlock);
143 }
144 Node* obj_node() const { return in(1); }
145 Node* box_node() const { return in(2); }
148 // FastLock and FastUnlockNode do not hash, we need one for each correspoding
149 // LockNode/UnLockNode to avoid creating Phi's.
150 virtual uint hash() const ; // { return NO_HASH; }
151 virtual uint cmp( const Node &n ) const ; // Always fail, except on self
152 virtual int Opcode() const;
153 virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; }
154 const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;}
156 };
158 #endif // SHARE_VM_OPTO_LOCKNODE_HPP