Thu, 24 May 2018 19:26:50 +0800
#7046 C2 supports long branch
Contributed-by: fujie
aoqi@0 | 1 | /* |
dlong@7598 | 2 | * Copyright (c) 1999, 2015, 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" |
dlong@7598 | 37 | #if defined AD_MD_HPP |
dlong@7598 | 38 | # include AD_MD_HPP |
dlong@7598 | 39 | #elif defined TARGET_ARCH_MODEL_x86_32 |
aoqi@0 | 40 | # include "adfiles/ad_x86_32.hpp" |
dlong@7598 | 41 | #elif defined TARGET_ARCH_MODEL_x86_64 |
aoqi@0 | 42 | # include "adfiles/ad_x86_64.hpp" |
dlong@7598 | 43 | #elif defined TARGET_ARCH_MODEL_sparc |
kvn@6518 | 44 | # include "adfiles/ad_sparc.hpp" |
dlong@7598 | 45 | #elif defined TARGET_ARCH_MODEL_zero |
kvn@6518 | 46 | # include "adfiles/ad_zero.hpp" |
dlong@7598 | 47 | #elif defined TARGET_ARCH_MODEL_ppc_64 |
kvn@6518 | 48 | # include "adfiles/ad_ppc_64.hpp" |
aoqi@7994 | 49 | #elif defined TARGET_ARCH_MODEL_mips_64 |
aoqi@1 | 50 | # include "adfiles/ad_mips_64.hpp" |
aoqi@1 | 51 | #endif |
aoqi@0 | 52 | |
aoqi@0 | 53 | //------------------------------BoxLockNode------------------------------------ |
aoqi@0 | 54 | class BoxLockNode : public Node { |
aoqi@0 | 55 | const int _slot; // stack slot |
aoqi@0 | 56 | RegMask _inmask; // OptoReg corresponding to stack slot |
aoqi@0 | 57 | bool _is_eliminated; // Associated locks were safely eliminated |
aoqi@0 | 58 | |
aoqi@0 | 59 | public: |
aoqi@0 | 60 | BoxLockNode( int lock ); |
aoqi@0 | 61 | virtual int Opcode() const; |
aoqi@0 | 62 | virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
aoqi@0 | 63 | virtual uint size(PhaseRegAlloc *ra_) const; |
aoqi@0 | 64 | virtual const RegMask &in_RegMask(uint) const; |
aoqi@0 | 65 | virtual const RegMask &out_RegMask() const; |
aoqi@0 | 66 | virtual uint size_of() const; |
aoqi@0 | 67 | virtual uint hash() const; |
aoqi@0 | 68 | virtual uint cmp( const Node &n ) const; |
aoqi@0 | 69 | virtual const class Type *bottom_type() const { return TypeRawPtr::BOTTOM; } |
aoqi@0 | 70 | virtual uint ideal_reg() const { return Op_RegP; } |
aoqi@0 | 71 | |
aoqi@0 | 72 | static OptoReg::Name reg(Node* box_node); |
aoqi@0 | 73 | static BoxLockNode* box_node(Node* box_node); |
aoqi@0 | 74 | static bool same_slot(Node* box1, Node* box2) { |
aoqi@0 | 75 | return box1->as_BoxLock()->_slot == box2->as_BoxLock()->_slot; |
aoqi@0 | 76 | } |
aoqi@0 | 77 | int stack_slot() const { return _slot; } |
aoqi@0 | 78 | |
aoqi@0 | 79 | bool is_eliminated() const { return _is_eliminated; } |
aoqi@0 | 80 | // mark lock as eliminated. |
aoqi@0 | 81 | void set_eliminated() { _is_eliminated = true; } |
aoqi@0 | 82 | |
aoqi@0 | 83 | // Is BoxLock node used for one simple lock region? |
aoqi@0 | 84 | bool is_simple_lock_region(LockNode** unique_lock, Node* obj); |
aoqi@0 | 85 | |
aoqi@0 | 86 | #ifndef PRODUCT |
aoqi@0 | 87 | virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
aoqi@0 | 88 | virtual void dump_spec(outputStream *st) const { st->print(" Lock %d",_slot); } |
aoqi@0 | 89 | #endif |
aoqi@0 | 90 | }; |
aoqi@0 | 91 | |
aoqi@0 | 92 | //------------------------------FastLockNode----------------------------------- |
aoqi@0 | 93 | class FastLockNode: public CmpNode { |
aoqi@0 | 94 | private: |
aoqi@0 | 95 | BiasedLockingCounters* _counters; |
aoqi@0 | 96 | RTMLockingCounters* _rtm_counters; // RTM lock counters for inflated locks |
aoqi@0 | 97 | RTMLockingCounters* _stack_rtm_counters; // RTM lock counters for stack locks |
aoqi@0 | 98 | |
aoqi@0 | 99 | public: |
aoqi@0 | 100 | FastLockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { |
aoqi@0 | 101 | init_req(0,ctrl); |
aoqi@0 | 102 | init_class_id(Class_FastLock); |
aoqi@0 | 103 | _counters = NULL; |
aoqi@0 | 104 | _rtm_counters = NULL; |
aoqi@0 | 105 | _stack_rtm_counters = NULL; |
aoqi@0 | 106 | } |
aoqi@0 | 107 | Node* obj_node() const { return in(1); } |
aoqi@0 | 108 | Node* box_node() const { return in(2); } |
aoqi@0 | 109 | void set_box_node(Node* box) { set_req(2, box); } |
aoqi@0 | 110 | |
aoqi@0 | 111 | // FastLock and FastUnlockNode do not hash, we need one for each correspoding |
aoqi@0 | 112 | // LockNode/UnLockNode to avoid creating Phi's. |
aoqi@0 | 113 | virtual uint hash() const ; // { return NO_HASH; } |
aoqi@0 | 114 | virtual uint size_of() const; |
aoqi@0 | 115 | virtual uint cmp( const Node &n ) const ; // Always fail, except on self |
aoqi@0 | 116 | virtual int Opcode() const; |
aoqi@0 | 117 | virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } |
aoqi@0 | 118 | const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} |
aoqi@0 | 119 | |
aoqi@0 | 120 | void create_lock_counter(JVMState* s); |
aoqi@0 | 121 | void create_rtm_lock_counter(JVMState* state); |
aoqi@0 | 122 | BiasedLockingCounters* counters() const { return _counters; } |
aoqi@0 | 123 | RTMLockingCounters* rtm_counters() const { return _rtm_counters; } |
aoqi@0 | 124 | RTMLockingCounters* stack_rtm_counters() const { return _stack_rtm_counters; } |
aoqi@0 | 125 | }; |
aoqi@0 | 126 | |
aoqi@0 | 127 | |
aoqi@0 | 128 | //------------------------------FastUnlockNode--------------------------------- |
aoqi@0 | 129 | class FastUnlockNode: public CmpNode { |
aoqi@0 | 130 | public: |
aoqi@0 | 131 | FastUnlockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { |
aoqi@0 | 132 | init_req(0,ctrl); |
aoqi@0 | 133 | init_class_id(Class_FastUnlock); |
aoqi@0 | 134 | } |
aoqi@0 | 135 | Node* obj_node() const { return in(1); } |
aoqi@0 | 136 | Node* box_node() const { return in(2); } |
aoqi@0 | 137 | |
aoqi@0 | 138 | |
aoqi@0 | 139 | // FastLock and FastUnlockNode do not hash, we need one for each correspoding |
aoqi@0 | 140 | // LockNode/UnLockNode to avoid creating Phi's. |
aoqi@0 | 141 | virtual uint hash() const ; // { return NO_HASH; } |
aoqi@0 | 142 | virtual uint cmp( const Node &n ) const ; // Always fail, except on self |
aoqi@0 | 143 | virtual int Opcode() const; |
aoqi@0 | 144 | virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } |
aoqi@0 | 145 | const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} |
aoqi@0 | 146 | |
aoqi@0 | 147 | }; |
aoqi@0 | 148 | |
aoqi@0 | 149 | #endif // SHARE_VM_OPTO_LOCKNODE_HPP |