hotspot/src/share/vm/opto/locknode.cpp
author iveresov
Thu, 22 Jan 2015 11:25:23 -0800
changeset 28723 0a36120cb225
parent 23491 f690330b10b9
permissions -rw-r--r--
8071302: assert(!_reg_node[reg_lo] || edge_from_to(_reg_node[reg_lo], def)) failed: after block local Summary: Add merge nodes to node to block mapping Reviewed-by: kvn, vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13963
e5b53c306fb5 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 11460
diff changeset
     2
 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "opto/locknode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "opto/parse.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/rootnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/runtime.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
const RegMask &BoxLockNode::in_RegMask(uint i) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  return _inmask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
const RegMask &BoxLockNode::out_RegMask() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  return *Matcher::idealreg2regmask[Op_RegP];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
uint BoxLockNode::size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
239
fb31825d5444 6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents: 1
diff changeset
    42
BoxLockNode::BoxLockNode( int slot ) : Node( Compile::current()->root() ),
fb31825d5444 6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents: 1
diff changeset
    43
                                       _slot(slot), _is_eliminated(false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  init_class_id(Class_BoxLock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  init_flags(Flag_rematerialize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  OptoReg::Name reg = OptoReg::stack2reg(_slot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  _inmask.Insert(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
1613
be097ec639a2 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 670
diff changeset
    50
//-----------------------------hash--------------------------------------------
be097ec639a2 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 670
diff changeset
    51
uint BoxLockNode::hash() const {
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    52
  if (EliminateNestedLocks)
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    53
    return NO_HASH; // Each locked region has own BoxLock node
1613
be097ec639a2 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 670
diff changeset
    54
  return Node::hash() + _slot + (_is_eliminated ? Compile::current()->fixed_slots() : 0);
be097ec639a2 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 670
diff changeset
    55
}
be097ec639a2 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 670
diff changeset
    56
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//------------------------------cmp--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
uint BoxLockNode::cmp( const Node &n ) const {
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    59
  if (EliminateNestedLocks)
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    60
    return (&n == this); // Always fail except on self
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  const BoxLockNode &bn = (const BoxLockNode &)n;
1613
be097ec639a2 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 670
diff changeset
    62
  return bn._slot == _slot && bn._is_eliminated == _is_eliminated;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    65
BoxLockNode* BoxLockNode::box_node(Node* box) {
11458
5ba160829cef 7128355: assert(!nocreate) failed: Cannot build a phi for a block already parsed
kvn
parents: 11446
diff changeset
    66
  // Chase down the BoxNode after RA which may spill box nodes.
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    67
  while (!box->is_BoxLock()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    //    if (box_node->is_SpillCopy()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    //      Node *m = box_node->in(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    //      if (m->is_Mach() && m->as_Mach()->ideal_Opcode() == Op_StoreP) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    //        box_node = m->in(m->as_Mach()->operand_index(2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    //        continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    //      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    //    }
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    75
    assert(box->is_SpillCopy() || box->is_Phi(), "Bad spill of Lock.");
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    76
    // Only BoxLock nodes with the same stack slot are merged.
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    77
    // So it is enough to trace one path to find the slot value.
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    78
    box = box->in(1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  }
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    80
  return box->as_BoxLock();
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    81
}
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    82
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    83
OptoReg::Name BoxLockNode::reg(Node* box) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    84
  return box_node(box)->in_RegMask(0).find_first_elem();
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    85
}
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    86
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    87
// Is BoxLock node used for one simple lock region (same box and obj)?
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    88
bool BoxLockNode::is_simple_lock_region(LockNode** unique_lock, Node* obj) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    89
  LockNode* lock = NULL;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    90
  bool has_one_lock = false;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    91
  for (uint i = 0; i < this->outcnt(); i++) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    92
    Node* n = this->raw_out(i);
11458
5ba160829cef 7128355: assert(!nocreate) failed: Cannot build a phi for a block already parsed
kvn
parents: 11446
diff changeset
    93
    assert(!n->is_Phi(), "should not merge BoxLock nodes");
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    94
    if (n->is_AbstractLock()) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    95
      AbstractLockNode* alock = n->as_AbstractLock();
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    96
      // Check lock's box since box could be referenced by Lock's debug info.
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    97
      if (alock->box_node() == this) {
11446
fd87432a895b 7128352: assert(obj_node == obj) failed
kvn
parents: 11445
diff changeset
    98
        if (alock->obj_node()->eqv_uncast(obj)) {
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
    99
          if ((unique_lock != NULL) && alock->is_Lock()) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   100
            if (lock == NULL) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   101
              lock = alock->as_Lock();
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   102
              has_one_lock = true;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   103
            } else if (lock != alock->as_Lock()) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   104
              has_one_lock = false;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   105
            }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   106
          }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   107
        } else {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   108
          return false; // Different objects
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   109
        }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   110
      }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   111
    }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   112
  }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   113
#ifdef ASSERT
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   114
  // Verify that FastLock and Safepoint reference only this lock region.
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   115
  for (uint i = 0; i < this->outcnt(); i++) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   116
    Node* n = this->raw_out(i);
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   117
    if (n->is_FastLock()) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   118
      FastLockNode* flock = n->as_FastLock();
11446
fd87432a895b 7128352: assert(obj_node == obj) failed
kvn
parents: 11445
diff changeset
   119
      assert((flock->box_node() == this) && flock->obj_node()->eqv_uncast(obj),"");
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   120
    }
11460
06e676d0b512 7129618: assert(obj_node->eqv_uncast(obj),"");
kvn
parents: 11458
diff changeset
   121
    // Don't check monitor info in safepoints since the referenced object could
06e676d0b512 7129618: assert(obj_node->eqv_uncast(obj),"");
kvn
parents: 11458
diff changeset
   122
    // be different from the locked object. It could be Phi node of different
06e676d0b512 7129618: assert(obj_node->eqv_uncast(obj),"");
kvn
parents: 11458
diff changeset
   123
    // cast nodes which point to this locked object.
06e676d0b512 7129618: assert(obj_node->eqv_uncast(obj),"");
kvn
parents: 11458
diff changeset
   124
    // We assume that no other objects could be referenced in monitor info
06e676d0b512 7129618: assert(obj_node->eqv_uncast(obj),"");
kvn
parents: 11458
diff changeset
   125
    // associated with this BoxLock node because all associated locks and
06e676d0b512 7129618: assert(obj_node->eqv_uncast(obj),"");
kvn
parents: 11458
diff changeset
   126
    // unlocks are reference only this one object.
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   127
  }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   128
#endif
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   129
  if (unique_lock != NULL && has_one_lock) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   130
    *unique_lock = lock;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   131
  }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 7397
diff changeset
   132
  return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
//-----------------------------hash--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
uint FastLockNode::hash() const { return NO_HASH; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
23491
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   139
uint FastLockNode::size_of() const { return sizeof(*this); }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   140
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
//------------------------------cmp--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
uint FastLockNode::cmp( const Node &n ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  return (&n == this);                // Always fail except on self
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
//-----------------------------hash--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
uint FastUnlockNode::hash() const { return NO_HASH; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
//------------------------------cmp--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
uint FastUnlockNode::cmp( const Node &n ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  return (&n == this);                // Always fail except on self
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// Create a counter which counts the number of times this lock is acquired
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
void FastLockNode::create_lock_counter(JVMState* state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  BiasedLockingNamedCounter* blnc = (BiasedLockingNamedCounter*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
           OptoRuntime::new_named_counter(state, NamedCounter::BiasedLockingCounter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  _counters = blnc->counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
23491
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   164
void FastLockNode::create_rtm_lock_counter(JVMState* state) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   165
#if INCLUDE_RTM_OPT
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   166
  Compile* C = Compile::current();
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   167
  if (C->profile_rtm() || (PrintPreciseRTMLockingStatistics && C->use_rtm())) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   168
    RTMLockingNamedCounter* rlnc = (RTMLockingNamedCounter*)
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   169
           OptoRuntime::new_named_counter(state, NamedCounter::RTMLockingCounter);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   170
    _rtm_counters = rlnc->counters();
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   171
    if (UseRTMForStackLocks) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   172
      rlnc = (RTMLockingNamedCounter*)
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   173
           OptoRuntime::new_named_counter(state, NamedCounter::RTMLockingCounter);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   174
      _stack_rtm_counters = rlnc->counters();
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   175
    }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   176
  }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   177
#endif
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   178
}
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents: 14621
diff changeset
   179
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
//------------------------------do_monitor_enter-------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
void Parse::do_monitor_enter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  kill_dead_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // Null check; get casted pointer.
14621
fd9265ab0f67 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 13963
diff changeset
   186
  Node* obj = null_check(peek());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // Check for locking null object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  if (stopped()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // the monitor object is not part of debug info expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Insert a FastLockNode which takes as arguments the current thread pointer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // the obj pointer & the address of the stack slot pair used for the lock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  shared_lock(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
//------------------------------do_monitor_exit--------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
void Parse::do_monitor_exit() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  kill_dead_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  pop();                        // Pop oop to unlock
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1613
diff changeset
   203
  // Because monitors are guaranteed paired (else we bail out), we know
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  // the matching Lock for this Unlock.  Hence we know there is no need
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // for a null check on Unlock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  shared_unlock(map()->peek_monitor_box(), map()->peek_monitor_obj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
}