Wed, 13 Apr 2011 14:33:03 -0700
6988308: assert((cnt > 0.0f) && (prob > 0.0f)) failed: Bad frequency assignment in if
Summary: Make sure cnt doesn't become negative and integer overflow doesn't happen.
Reviewed-by: kvn, twisti
duke@435 | 1 | /* |
trims@2708 | 2 | * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_OPTO_LOCKNODE_HPP |
stefank@2314 | 26 | #define SHARE_VM_OPTO_LOCKNODE_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "opto/node.hpp" |
stefank@2314 | 29 | #include "opto/opcodes.hpp" |
stefank@2314 | 30 | #include "opto/subnode.hpp" |
stefank@2314 | 31 | #ifdef TARGET_ARCH_MODEL_x86_32 |
stefank@2314 | 32 | # include "adfiles/ad_x86_32.hpp" |
stefank@2314 | 33 | #endif |
stefank@2314 | 34 | #ifdef TARGET_ARCH_MODEL_x86_64 |
stefank@2314 | 35 | # include "adfiles/ad_x86_64.hpp" |
stefank@2314 | 36 | #endif |
stefank@2314 | 37 | #ifdef TARGET_ARCH_MODEL_sparc |
stefank@2314 | 38 | # include "adfiles/ad_sparc.hpp" |
stefank@2314 | 39 | #endif |
stefank@2314 | 40 | #ifdef TARGET_ARCH_MODEL_zero |
stefank@2314 | 41 | # include "adfiles/ad_zero.hpp" |
stefank@2314 | 42 | #endif |
bobv@2508 | 43 | #ifdef TARGET_ARCH_MODEL_arm |
bobv@2508 | 44 | # include "adfiles/ad_arm.hpp" |
bobv@2508 | 45 | #endif |
bobv@2508 | 46 | #ifdef TARGET_ARCH_MODEL_ppc |
bobv@2508 | 47 | # include "adfiles/ad_ppc.hpp" |
bobv@2508 | 48 | #endif |
stefank@2314 | 49 | |
duke@435 | 50 | //------------------------------BoxLockNode------------------------------------ |
duke@435 | 51 | class BoxLockNode : public Node { |
duke@435 | 52 | public: |
duke@435 | 53 | const int _slot; |
duke@435 | 54 | RegMask _inmask; |
kvn@501 | 55 | bool _is_eliminated; // indicates this lock was safely eliminated |
duke@435 | 56 | |
duke@435 | 57 | BoxLockNode( int lock ); |
duke@435 | 58 | virtual int Opcode() const; |
duke@435 | 59 | virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
duke@435 | 60 | virtual uint size(PhaseRegAlloc *ra_) const; |
duke@435 | 61 | virtual const RegMask &in_RegMask(uint) const; |
duke@435 | 62 | virtual const RegMask &out_RegMask() const; |
duke@435 | 63 | virtual uint size_of() const; |
kvn@895 | 64 | virtual uint hash() const; |
duke@435 | 65 | virtual uint cmp( const Node &n ) const; |
duke@435 | 66 | virtual const class Type *bottom_type() const { return TypeRawPtr::BOTTOM; } |
duke@435 | 67 | virtual uint ideal_reg() const { return Op_RegP; } |
duke@435 | 68 | |
duke@435 | 69 | static OptoReg::Name stack_slot(Node* box_node); |
duke@435 | 70 | |
kvn@501 | 71 | bool is_eliminated() { return _is_eliminated; } |
kvn@501 | 72 | // mark lock as eliminated. |
kvn@501 | 73 | void set_eliminated() { _is_eliminated = true; } |
kvn@501 | 74 | |
duke@435 | 75 | #ifndef PRODUCT |
duke@435 | 76 | virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
duke@435 | 77 | virtual void dump_spec(outputStream *st) const { st->print(" Lock %d",_slot); } |
duke@435 | 78 | #endif |
duke@435 | 79 | }; |
duke@435 | 80 | |
duke@435 | 81 | //------------------------------FastLockNode----------------------------------- |
duke@435 | 82 | class FastLockNode: public CmpNode { |
duke@435 | 83 | private: |
duke@435 | 84 | BiasedLockingCounters* _counters; |
duke@435 | 85 | |
duke@435 | 86 | public: |
duke@435 | 87 | FastLockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { |
duke@435 | 88 | init_req(0,ctrl); |
duke@435 | 89 | init_class_id(Class_FastLock); |
duke@435 | 90 | _counters = NULL; |
duke@435 | 91 | } |
duke@435 | 92 | Node* obj_node() const { return in(1); } |
duke@435 | 93 | Node* box_node() const { return in(2); } |
duke@435 | 94 | |
duke@435 | 95 | // FastLock and FastUnlockNode do not hash, we need one for each correspoding |
duke@435 | 96 | // LockNode/UnLockNode to avoid creating Phi's. |
duke@435 | 97 | virtual uint hash() const ; // { return NO_HASH; } |
duke@435 | 98 | virtual uint cmp( const Node &n ) const ; // Always fail, except on self |
duke@435 | 99 | virtual int Opcode() const; |
duke@435 | 100 | virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } |
duke@435 | 101 | const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} |
duke@435 | 102 | |
duke@435 | 103 | void create_lock_counter(JVMState* s); |
duke@435 | 104 | BiasedLockingCounters* counters() const { return _counters; } |
duke@435 | 105 | }; |
duke@435 | 106 | |
duke@435 | 107 | |
duke@435 | 108 | //------------------------------FastUnlockNode--------------------------------- |
duke@435 | 109 | class FastUnlockNode: public CmpNode { |
duke@435 | 110 | public: |
duke@435 | 111 | FastUnlockNode(Node *ctrl, Node *oop, Node *box) : CmpNode(oop,box) { |
duke@435 | 112 | init_req(0,ctrl); |
duke@435 | 113 | init_class_id(Class_FastUnlock); |
duke@435 | 114 | } |
duke@435 | 115 | Node* obj_node() const { return in(1); } |
duke@435 | 116 | Node* box_node() const { return in(2); } |
duke@435 | 117 | |
duke@435 | 118 | |
duke@435 | 119 | // FastLock and FastUnlockNode do not hash, we need one for each correspoding |
duke@435 | 120 | // LockNode/UnLockNode to avoid creating Phi's. |
duke@435 | 121 | virtual uint hash() const ; // { return NO_HASH; } |
duke@435 | 122 | virtual uint cmp( const Node &n ) const ; // Always fail, except on self |
duke@435 | 123 | virtual int Opcode() const; |
duke@435 | 124 | virtual const Type *Value( PhaseTransform *phase ) const { return TypeInt::CC; } |
duke@435 | 125 | const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} |
duke@435 | 126 | |
duke@435 | 127 | }; |
stefank@2314 | 128 | |
stefank@2314 | 129 | #endif // SHARE_VM_OPTO_LOCKNODE_HPP |