src/share/vm/opto/locknode.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6518
62c54fcc0a35
parent 1
2d8a650513c2
child 7994
04ff2f6cd0eb
permissions
-rw-r--r--

merge

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

mercurial