duke@435: /* xdono@631: * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: //------------------------------BoxLockNode------------------------------------ duke@435: class BoxLockNode : public Node { duke@435: public: duke@435: const int _slot; duke@435: RegMask _inmask; kvn@501: bool _is_eliminated; // indicates this lock was safely eliminated duke@435: duke@435: BoxLockNode( int lock ); duke@435: virtual int Opcode() const; duke@435: virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; duke@435: virtual uint size(PhaseRegAlloc *ra_) const; duke@435: virtual const RegMask &in_RegMask(uint) const; duke@435: virtual const RegMask &out_RegMask() const; duke@435: virtual uint size_of() const; kvn@895: virtual uint hash() const; duke@435: virtual uint cmp( const Node &n ) const; duke@435: virtual const class Type *bottom_type() const { return TypeRawPtr::BOTTOM; } duke@435: virtual uint ideal_reg() const { return Op_RegP; } duke@435: duke@435: static OptoReg::Name stack_slot(Node* box_node); duke@435: kvn@501: bool is_eliminated() { return _is_eliminated; } kvn@501: // mark lock as eliminated. kvn@501: void set_eliminated() { _is_eliminated = true; } kvn@501: duke@435: #ifndef PRODUCT duke@435: virtual void format( PhaseRegAlloc *, outputStream *st ) const; duke@435: virtual void dump_spec(outputStream *st) const { st->print(" Lock %d",_slot); } duke@435: #endif duke@435: }; duke@435: duke@435: //------------------------------FastLockNode----------------------------------- duke@435: class FastLockNode: public CmpNode { duke@435: private: duke@435: BiasedLockingCounters* _counters; duke@435: duke@435: public: duke@435: FastLockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { duke@435: init_req(0,ctrl); duke@435: init_class_id(Class_FastLock); duke@435: _counters = NULL; duke@435: } duke@435: Node* obj_node() const { return in(1); } duke@435: Node* box_node() const { return in(2); } duke@435: duke@435: // FastLock and FastUnlockNode do not hash, we need one for each correspoding duke@435: // LockNode/UnLockNode to avoid creating Phi's. duke@435: virtual uint hash() const ; // { return NO_HASH; } duke@435: virtual uint cmp( const Node &n ) const ; // Always fail, except on self duke@435: virtual int Opcode() const; duke@435: virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } duke@435: const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} duke@435: duke@435: void create_lock_counter(JVMState* s); duke@435: BiasedLockingCounters* counters() const { return _counters; } duke@435: }; duke@435: duke@435: duke@435: //------------------------------FastUnlockNode--------------------------------- duke@435: class FastUnlockNode: public CmpNode { duke@435: public: duke@435: FastUnlockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { duke@435: init_req(0,ctrl); duke@435: init_class_id(Class_FastUnlock); duke@435: } duke@435: Node* obj_node() const { return in(1); } duke@435: Node* box_node() const { return in(2); } duke@435: duke@435: duke@435: // FastLock and FastUnlockNode do not hash, we need one for each correspoding duke@435: // LockNode/UnLockNode to avoid creating Phi's. duke@435: virtual uint hash() const ; // { return NO_HASH; } duke@435: virtual uint cmp( const Node &n ) const ; // Always fail, except on self duke@435: virtual int Opcode() const; duke@435: virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } duke@435: const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} duke@435: duke@435: };