hotspot/src/share/vm/opto/machnode.cpp
author vlivanov
Tue, 14 Jul 2015 06:44:50 -0700
changeset 31857 adbf29d9ca43
parent 30764 fec48bf5a827
child 34194 213af0859e7e
permissions -rw-r--r--
8078629: VM should constant fold Unsafe.get*() loads from final fields Reviewed-by: kvn, jrose, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28202
diff changeset
     2
 * Copyright (c) 1997, 2015, 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: 4566
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4566
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: 4566
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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28202
diff changeset
    26
#include "gc/shared/collectedHeap.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "opto/machnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/regalloc.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Return the value requested
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// result register lookup, corresponding to int_format
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
int MachOper::reg(PhaseRegAlloc *ra_, const Node *node) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  return (int)ra_->get_encode(node);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// input register lookup, corresponding to ext_format
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
int MachOper::reg(PhaseRegAlloc *ra_, const Node *node, int idx) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  return (int)(ra_->get_encode(node->in(idx)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
intptr_t  MachOper::constant() const { return 0x00; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13104
diff changeset
    41
relocInfo::relocType MachOper::constant_reloc() const { return relocInfo::none; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
jdouble MachOper::constantD() const { ShouldNotReachHere(); return 0.0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
jfloat  MachOper::constantF() const { ShouldNotReachHere(); return 0.0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
jlong   MachOper::constantL() const { ShouldNotReachHere(); return CONST64(0) ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
TypeOopPtr *MachOper::oop() const { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
int MachOper::ccode() const { return 0x00; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// A zero, default, indicates this value is not needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// May need to lookup the base register, as done in int_ and ext_format
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
int MachOper::base (PhaseRegAlloc *ra_, const Node *node, int idx)  const { return 0x00; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
int MachOper::index(PhaseRegAlloc *ra_, const Node *node, int idx)  const { return 0x00; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
int MachOper::scale()  const { return 0x00; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
int MachOper::disp (PhaseRegAlloc *ra_, const Node *node, int idx)  const { return 0x00; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
int MachOper::constant_disp()  const { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
int MachOper::base_position()  const { return -1; }  // no base input
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
int MachOper::index_position() const { return -1; }  // no index input
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// Check for PC-Relative displacement
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13104
diff changeset
    57
relocInfo::relocType MachOper::disp_reloc() const { return relocInfo::none; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// Return the label
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
Label*   MachOper::label()  const { ShouldNotReachHere(); return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
intptr_t MachOper::method() const { ShouldNotReachHere(); return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
//------------------------------negate-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// Negate conditional branches.  Error for non-branch operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
void MachOper::negate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  ShouldNotCallThis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//-----------------------------type--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
const Type *MachOper::type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  return Type::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//------------------------------in_RegMask-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
const RegMask *MachOper::in_RegMask(int index) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
//------------------------------dump_spec--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
void MachOper::dump_spec(outputStream *st) const { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
//------------------------------hash-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
uint MachOper::hash() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  ShouldNotCallThis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  return 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
//------------------------------cmp--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
uint MachOper::cmp( const MachOper &oper ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  ShouldNotCallThis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  return opcode() == oper.opcode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
//------------------------------hash-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
uint labelOper::hash() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  return _block_num;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
//------------------------------cmp--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
uint labelOper::cmp( const MachOper &oper ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  return (opcode() == oper.opcode()) && (_label == oper.label());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
//------------------------------hash-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
uint methodOper::hash() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  return (uint)_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
//------------------------------cmp--------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
uint methodOper::cmp( const MachOper &oper ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  return (opcode() == oper.opcode()) && (_method == oper.method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
//------------------------------MachNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
//------------------------------emit-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
void MachNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  tty->print("missing MachNode emit function: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  ShouldNotCallThis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
22844
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 20282
diff changeset
   137
//---------------------------postalloc_expand----------------------------------
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 20282
diff changeset
   138
// Expand node after register allocation.
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 20282
diff changeset
   139
void MachNode::postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_) {}
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 20282
diff changeset
   140
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
//------------------------------size-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
// Size of instruction in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
uint MachNode::size(PhaseRegAlloc *ra_) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // If a virtual was not defined for this specific instruction,
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 781
diff changeset
   145
  // Call the helper which finds the size by emitting the bits.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  return MachNode::emit_size(ra_);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
//------------------------------size-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
// Helper function that computes size by emitting code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
uint MachNode::emit_size(PhaseRegAlloc *ra_) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // Emit into a trash buffer and count bytes emitted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  assert(ra_ == ra_->C->regalloc(), "sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  return ra_->C->scratch_emit_size(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
//------------------------------hash-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
uint MachNode::hash() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  uint no = num_opnds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  uint sum = rule();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  for( uint i=0; i<no; i++ )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    sum += _opnds[i]->hash();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  return sum+Node::hash();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
//-----------------------------cmp---------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
uint MachNode::cmp( const Node &node ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  MachNode& n = *((Node&)node).as_Mach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  uint no = num_opnds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  if( no != n.num_opnds() ) return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  if( rule() != n.rule() ) return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  for( uint i=0; i<no; i++ )    // All operands must match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    if( !_opnds[i]->cmp( *n._opnds[i] ) )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      return 0;                 // mis-matched operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  return 1;                     // match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
// Return an equivalent instruction using memory for cisc_operand position
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 25637
diff changeset
   181
MachNode *MachNode::cisc_version(int offset) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  ShouldNotCallThis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
void MachNode::use_cisc_RegMask() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
//-----------------------------in_RegMask--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
const RegMask &MachNode::in_RegMask( uint idx ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  uint numopnds = num_opnds();        // Virtual call for number of operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  uint skipped   = oper_input_base(); // Sum of leaves skipped so far
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  if( idx < skipped ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    assert( ideal_Opcode() == Op_AddP, "expected base ptr here" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    assert( idx == 1, "expected base ptr here" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    // debug info can be anywhere
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    return *Compile::current()->matcher()->idealreg2spillmask[Op_RegP];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  uint opcnt     = 1;                 // First operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  uint num_edges = _opnds[1]->num_edges(); // leaves for first operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  while( idx >= skipped+num_edges ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    skipped += num_edges;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    opcnt++;                          // Bump operand count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    assert( opcnt < numopnds, "Accessing non-existent operand" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    num_edges = _opnds[opcnt]->num_edges(); // leaves for next operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  const RegMask *rm = cisc_RegMask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  if( rm == NULL || (int)opcnt != cisc_operand() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    rm = _opnds[opcnt]->in_RegMask(idx-skipped);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  return *rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
//-----------------------------memory_inputs--------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
const MachOper*  MachNode::memory_inputs(Node* &base, Node* &index) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  const MachOper* oper = memory_operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  if (oper == (MachOper*)-1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    base = NodeSentinel;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    index = NodeSentinel;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    base = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    index = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    if (oper != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      // It has a unique memory operand.  Find its index.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      int oper_idx = num_opnds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      while (--oper_idx >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        if (_opnds[oper_idx] == oper)  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      int oper_pos = operand_index(oper_idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      int base_pos = oper->base_position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      if (base_pos >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        base = _in[oper_pos+base_pos];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      int index_pos = oper->index_position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      if (index_pos >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        index = _in[oper_pos+index_pos];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  return oper;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
//-----------------------------get_base_and_disp----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
const Node* MachNode::get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // Find the memory inputs using our helper function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  Node* base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  Node* index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  const MachOper* oper = memory_inputs(base, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  if (oper == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    // Base has been set to NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    offset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  } else if (oper == (MachOper*)-1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    // Base has been set to NodeSentinel
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    // There is not a unique memory use here.  We will fall to AliasIdxBot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    offset = Type::OffsetBot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    // Base may be NULL, even if offset turns out to be != 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    intptr_t disp = oper->constant_disp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    int scale = oper->scale();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    // Now we have collected every part of the ADLC MEMORY_INTER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    // See if it adds up to a base + offset.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    if (index != NULL) {
767
64fb1fd7186d 6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents: 762
diff changeset
   271
      const Type* t_index = index->bottom_type();
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   272
      if (t_index->isa_narrowoop() || t_index->isa_narrowklass()) { // EncodeN, LoadN, LoadConN, LoadNKlass,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   273
                                                                    // EncodeNKlass, LoadConNklass.
762
1b26adb5fea1 6715633: when matching a memory node the adr_type should not change
kvn
parents: 360
diff changeset
   274
        // Memory references through narrow oops have a
1b26adb5fea1 6715633: when matching a memory node the adr_type should not change
kvn
parents: 360
diff changeset
   275
        // funny base so grab the type from the index:
1b26adb5fea1 6715633: when matching a memory node the adr_type should not change
kvn
parents: 360
diff changeset
   276
        // [R12 + narrow_oop_reg<<3 + offset]
1b26adb5fea1 6715633: when matching a memory node the adr_type should not change
kvn
parents: 360
diff changeset
   277
        assert(base == NULL, "Memory references through narrow oops have no base");
1b26adb5fea1 6715633: when matching a memory node the adr_type should not change
kvn
parents: 360
diff changeset
   278
        offset = disp;
767
64fb1fd7186d 6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents: 762
diff changeset
   279
        adr_type = t_index->make_ptr()->add_offset(offset);
762
1b26adb5fea1 6715633: when matching a memory node the adr_type should not change
kvn
parents: 360
diff changeset
   280
        return NULL;
1b26adb5fea1 6715633: when matching a memory node the adr_type should not change
kvn
parents: 360
diff changeset
   281
      } else if (!index->is_Con()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        disp = Type::OffsetBot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      } else if (disp != Type::OffsetBot) {
767
64fb1fd7186d 6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents: 762
diff changeset
   284
        const TypeX* ti = t_index->isa_intptr_t();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
        if (ti == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
          disp = Type::OffsetBot;  // a random constant??
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
          disp += ti->get_con() << scale;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    offset = disp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    // In i486.ad, indOffset32X uses base==RegI and disp==RegP,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    // this will prevent alias analysis without the following support:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    // Lookup the TypePtr used by indOffset32X, a compile-time constant oop,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    // Add the offset determined by the "base", or use Type::OffsetBot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    if( adr_type == TYPE_PTR_SENTINAL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
      const TypePtr *t_disp = oper->disp_as_type();  // only !NULL for indOffset32X
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
      if (t_disp != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
        offset = Type::OffsetBot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
        const Type* t_base = base->bottom_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
        if (t_base->isa_intptr_t()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
          const TypeX *t_offset = t_base->is_intptr_t();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
          if( t_offset->is_con() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
            offset = t_offset->get_con();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
        adr_type = t_disp->add_offset(offset);
3268
f034e0c86895 6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents: 2340
diff changeset
   310
      } else if( base == NULL && offset != 0 && offset != Type::OffsetBot ) {
f034e0c86895 6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents: 2340
diff changeset
   311
        // Use ideal type if it is oop ptr.
f034e0c86895 6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents: 2340
diff changeset
   312
        const TypePtr *tp = oper->type()->isa_ptr();
f034e0c86895 6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents: 2340
diff changeset
   313
        if( tp != NULL) {
f034e0c86895 6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents: 2340
diff changeset
   314
          adr_type = tp;
f034e0c86895 6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents: 2340
diff changeset
   315
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  return base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
//---------------------------------adr_type---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
const class TypePtr *MachNode::adr_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  intptr_t offset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  const TypePtr *adr_type = TYPE_PTR_SENTINAL;  // attempt computing adr_type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  const Node *base = get_base_and_disp(offset, adr_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  if( adr_type != TYPE_PTR_SENTINAL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    return adr_type;      // get_base_and_disp has the answer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // Direct addressing modes have no base node, simply an indirect
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // offset, which is always to raw memory.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  // %%%%% Someday we'd like to allow constant oop offsets which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // would let Intel load from static globals in 1 instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // Currently Intel requires 2 instructions and a register temp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  if (base == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    // NULL base, zero offset means no memory at all (a null pointer!)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    if (offset == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
      return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    // NULL base, any offset means any pointer whatever
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    if (offset == Type::OffsetBot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
      return TypePtr::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    // %%% make offset be intptr_t
20282
7f9cbdf89af2 7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents: 17384
diff changeset
   348
    assert(!Universe::heap()->is_in_reserved(cast_to_oop(offset)), "must be a raw ptr");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    return TypeRawPtr::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  // base of -1 with no particular offset means all of memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  if (base == NodeSentinel)  return TypePtr::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  const Type* t = base->bottom_type();
17384
4e6ea5fa04ad 8014189: JVM crash with SEGV in ConnectionGraph::record_for_escape_analysis()
kvn
parents: 15241
diff changeset
   356
  if (t->isa_narrowoop() && Universe::narrow_oop_shift() == 0) {
2340
cb47f8209cd8 6810845: Performance regression in mpegaudio on x64
kvn
parents: 2131
diff changeset
   357
    // 32-bit unscaled narrow oop can be the base of any address expression
cb47f8209cd8 6810845: Performance regression in mpegaudio on x64
kvn
parents: 2131
diff changeset
   358
    t = t->make_ptr();
cb47f8209cd8 6810845: Performance regression in mpegaudio on x64
kvn
parents: 2131
diff changeset
   359
  }
17384
4e6ea5fa04ad 8014189: JVM crash with SEGV in ConnectionGraph::record_for_escape_analysis()
kvn
parents: 15241
diff changeset
   360
  if (t->isa_narrowklass() && Universe::narrow_klass_shift() == 0) {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   361
    // 32-bit unscaled narrow oop can be the base of any address expression
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   362
    t = t->make_ptr();
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   363
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  if (t->isa_intptr_t() && offset != 0 && offset != Type::OffsetBot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    // We cannot assert that the offset does not look oop-ish here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    // Depending on the heap layout the cardmark base could land
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    // inside some oopish region.  It definitely does for Win2K.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    // The sum of cardmark-base plus shift-by-9-oop lands outside
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    // the oop-ish area but we can't assert for that statically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    return TypeRawPtr::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  const TypePtr *tp = t->isa_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // be conservative if we do not recognize the type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  if (tp == NULL) {
2340
cb47f8209cd8 6810845: Performance regression in mpegaudio on x64
kvn
parents: 2131
diff changeset
   377
    assert(false, "this path may produce not optimal code");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    return TypePtr::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  assert(tp->base() != Type::AnyPtr, "not a bare pointer");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  return tp->add_offset(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
//-----------------------------operand_index---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
int MachNode::operand_index( uint operand ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  if( operand < 1 )  return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  assert(operand < num_opnds(), "oob");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  if( _opnds[operand]->num_edges() == 0 )  return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  uint skipped   = oper_input_base(); // Sum of leaves skipped so far
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  for (uint opcnt = 1; opcnt < operand; opcnt++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    uint num_edges = _opnds[opcnt]->num_edges(); // leaves for operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    skipped += num_edges;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  return skipped;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
22853
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   400
int MachNode::operand_index(const MachOper *oper) const {
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   401
  uint skipped = oper_input_base(); // Sum of leaves skipped so far
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   402
  uint opcnt;
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   403
  for (opcnt = 1; opcnt < num_opnds(); opcnt++) {
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   404
    if (_opnds[opcnt] == oper) break;
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   405
    uint num_edges = _opnds[opcnt]->num_edges(); // leaves for operand
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   406
    skipped += num_edges;
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   407
  }
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   408
  if (_opnds[opcnt] != oper) return -1;
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   409
  return skipped;
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
   410
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
//------------------------------peephole---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
// Apply peephole rule(s) to this instruction
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 25637
diff changeset
   414
MachNode *MachNode::peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
//------------------------------add_case_label---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
// Adds the label for the case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
void MachNode::add_case_label( int index_num, Label* blockLabel) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  ShouldNotCallThis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
//------------------------------method_set-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
// Set the absolute address of a method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
void MachNode::method_set( intptr_t addr ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  ShouldNotCallThis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
//------------------------------rematerialize----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
bool MachNode::rematerialize() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  // Temps are always rematerializable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  if (is_MachTemp()) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  uint r = rule();              // Match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  if( r <  Matcher::_begin_rematerialize ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
      r >= Matcher::_end_rematerialize )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  // For 2-address instructions, the input live range is also the output
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  // live range.  Remateralizing does not make progress on the that live range.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  if( two_adr() )  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  // Check for rematerializing float constants, or not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  if( !Matcher::rematerialize_float_constants ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    int op = ideal_Opcode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    if( op == Op_ConF || op == Op_ConD )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  // Defining flags - can't spill these!  Must remateralize.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  if( ideal_reg() == Op_RegFlags )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // Stretching lots of inputs - don't do it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  if( req() > 2 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Don't remateralize somebody with bound inputs - it stretches a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  // fixed register lifetime.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  uint idx = oper_input_base();
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 11190
diff changeset
   462
  if (req() > idx) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    const RegMask &rm = in_RegMask(idx);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 11190
diff changeset
   464
    if (rm.is_bound(ideal_reg()))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
//------------------------------dump_spec--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
// Print any per-operand special info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
void MachNode::dump_spec(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  uint cnt = num_opnds();
28202
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   476
  for( uint i=0; i<cnt; i++ ) {
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   477
    if (_opnds[i] != NULL) {
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   478
      _opnds[i]->dump_spec(st);
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   479
    } else {
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   480
      st->print(" _");
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   481
    }
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   482
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  const TypePtr *t = adr_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  if( t ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    Compile* C = Compile::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    if( C->alias_type(t)->is_volatile() )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
      st->print(" Volatile!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
//------------------------------dump_format------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
// access to virtual
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
void MachNode::dump_format(PhaseRegAlloc *ra, outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  format(ra, st); // access to virtual
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
void MachTypeNode::dump_spec(outputStream *st) const {
28202
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   501
  if (_bottom_type != NULL) {
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   502
    _bottom_type->dump_on(st);
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   503
  } else {
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   504
    st->print(" NULL");
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   505
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   509
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   510
//=============================================================================
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   511
int MachConstantNode::constant_offset() {
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   512
  // Bind the offset lazily.
11190
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   513
  if (_constant.offset() == -1) {
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   514
    Compile::ConstantTable& constant_table = Compile::current()->constant_table();
11190
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   515
    int offset = constant_table.find_offset(_constant);
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   516
    // If called from Compile::scratch_emit_size return the
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   517
    // pre-calculated offset.
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   518
    // NOTE: If the AD file does some table base offset optimizations
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   519
    // later the AD file needs to take care of this fact.
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   520
    if (Compile::current()->in_scratch_emit_size()) {
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   521
      return constant_table.calculate_table_base_offset() + offset;
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   522
    }
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   523
    _constant.set_offset(constant_table.table_base_offset() + offset);
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   524
  }
11190
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10977
diff changeset
   525
  return _constant.offset();
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   526
}
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   527
22847
603ad1f10e16 8028401: PPC (part 117): Improve usability of adlc and format() functionality.
goetz
parents: 22844
diff changeset
   528
int MachConstantNode::constant_offset_unchecked() const {
603ad1f10e16 8028401: PPC (part 117): Improve usability of adlc and format() functionality.
goetz
parents: 22844
diff changeset
   529
  return _constant.offset();
603ad1f10e16 8028401: PPC (part 117): Improve usability of adlc and format() functionality.
goetz
parents: 22844
diff changeset
   530
}
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   531
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
void MachNullCheckNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  int reg = ra_->get_reg_first(in(1)->in(_vidx));
15241
87d217c2d183 8005055: pass outputStream to more opto debug routines
kvn
parents: 13969
diff changeset
   536
  st->print("%s %s", Name(), Matcher::regName[reg]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
void MachNullCheckNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  // only emits entries in the null-pointer exception handler table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
}
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 7433
diff changeset
   543
void MachNullCheckNode::label_set(Label* label, uint block_num) {
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 7433
diff changeset
   544
  // Nothing to emit
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 7433
diff changeset
   545
}
10266
2ea344c79e33 7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents: 10252
diff changeset
   546
void MachNullCheckNode::save_label( Label** label, uint* block_num ) {
2ea344c79e33 7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents: 10252
diff changeset
   547
  // Nothing to emit
2ea344c79e33 7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents: 10252
diff changeset
   548
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
const RegMask &MachNullCheckNode::in_RegMask( uint idx ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  if( idx == 0 ) return RegMask::Empty;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  else return in(1)->as_Mach()->out_RegMask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
const Type *MachProjNode::bottom_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  if( _ideal_reg == fat_proj ) return Type::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  // Try the normal mechanism first
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  const Type *t = in(0)->bottom_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  if( t->base() == Type::Tuple ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    const TypeTuple *tt = t->is_tuple();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    if (_con < tt->cnt())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
      return tt->field_at(_con);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  // Else use generic type from ideal register set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  assert((uint)_ideal_reg < (uint)_last_machine_leaf && Type::mreg2type[_ideal_reg], "in bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  return Type::mreg2type[_ideal_reg];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
const TypePtr *MachProjNode::adr_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  if (bottom_type() == Type::MEMORY) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
27697
ae60f551e5c8 8062258: compiler/debug/TraceIterativeGVN.java segfaults in trace_PhaseIterGVN
vlivanov
parents: 25930
diff changeset
   573
    Node* ctrl = in(0);
ae60f551e5c8 8062258: compiler/debug/TraceIterativeGVN.java segfaults in trace_PhaseIterGVN
vlivanov
parents: 25930
diff changeset
   574
    if (ctrl == NULL)  return NULL; // node is dead
ae60f551e5c8 8062258: compiler/debug/TraceIterativeGVN.java segfaults in trace_PhaseIterGVN
vlivanov
parents: 25930
diff changeset
   575
    const TypePtr* adr_type = ctrl->adr_type();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
    if (!is_error_reported() && !Node::in_dump())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
      assert(adr_type != NULL, "source must have adr_type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    return adr_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  assert(bottom_type()->base() != Type::Memory, "no other memories?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
void MachProjNode::dump_spec(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  ProjNode::dump_spec(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  switch (_ideal_reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  case unmatched_proj:  st->print("/unmatched");                         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  case fat_proj:        st->print("/fat"); if (WizardMode) _rout.dump(); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
void MachIfNode::dump_spec(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  st->print("P=%f, C=%f",_prob, _fcnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
uint MachReturnNode::size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
//------------------------------Registers--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
const RegMask &MachReturnNode::in_RegMask( uint idx ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  return _in_rms[idx];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
const TypePtr *MachReturnNode::adr_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  // most returns and calls are assumed to consume & modify all of memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  // the matcher will copy non-wide adr_types from ideal originals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  return _adr_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
const Type *MachSafePointNode::bottom_type() const {  return TypeTuple::MEMBAR; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
//------------------------------Registers--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
const RegMask &MachSafePointNode::in_RegMask( uint idx ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  // Values in the domain use the users calling convention, embodied in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  // _in_rms array of RegMasks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  if( idx < TypeFunc::Parms ) return _in_rms[idx];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  if (SafePointNode::needs_polling_address_input() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      idx == TypeFunc::Parms &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
      ideal_Opcode() == Op_SafePoint) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    return MachNode::in_RegMask(idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  // Values outside the domain represent debug info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
  return *Compile::current()->matcher()->idealreg2spillmask[in(idx)->ideal_reg()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
uint MachCallNode::cmp( const Node &n ) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
{ return _tf == ((MachCallNode&)n)._tf; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
const Type *MachCallNode::bottom_type() const { return tf()->range(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
const Type *MachCallNode::Value(PhaseTransform *phase) const { return tf()->range(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
void MachCallNode::dump_spec(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  st->print("# ");
28202
3518158ff5d0 8067338: compiler/debug/TraceIterativeGVN.java segfaults
vlivanov
parents: 27697
diff changeset
   647
  if (tf() != NULL)  tf()->dump_on(st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  if (_cnt != COUNT_UNKNOWN)  st->print(" C=%f",_cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  if (jvms() != NULL)  jvms()->dump_spec(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
bool MachCallNode::return_value_is_used() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  if (tf()->range()->cnt() == TypeFunc::Parms) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    // void return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  // find the projection corresponding to the return value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    Node *use = fast_out(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    if (!use->is_Proj()) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    if (use->as_Proj()->_con == TypeFunc::Parms) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
25637
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   670
// Similar to cousin class CallNode::returns_pointer
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   671
// Because this is used in deoptimization, we want the type info, not the data
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   672
// flow info; the interpreter will "use" things that are dead to the optimizer.
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   673
bool MachCallNode::returns_pointer() const {
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   674
  const TypeTuple *r = tf()->range();
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   675
  return (r->cnt() > TypeFunc::Parms &&
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   676
          r->field_at(TypeFunc::Parms)->isa_ptr());
369f62cdfaba 8036588: VerifyFieldClosure fails instanceKlass:3133
drchase
parents: 22853
diff changeset
   677
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
//------------------------------Registers--------------------------------------
22850
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   680
const RegMask &MachCallNode::in_RegMask(uint idx) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
  // Values in the domain use the users calling convention, embodied in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
  // _in_rms array of RegMasks.
22850
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   683
  if (idx < tf()->domain()->cnt()) {
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   684
    return _in_rms[idx];
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   685
  }
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   686
  if (idx == mach_constant_base_node_input()) {
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   687
    return MachConstantBaseNode::static_out_RegMask();
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   688
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  // Values outside the domain represent debug info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  return *Compile::current()->matcher()->idealreg2debugmask[in(idx)->ideal_reg()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
uint MachCallJavaNode::size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
uint MachCallJavaNode::cmp( const Node &n ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  MachCallJavaNode &call = (MachCallJavaNode&)n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  return MachCallNode::cmp(call) && _method->equals(call._method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
void MachCallJavaNode::dump_spec(outputStream *st) const {
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   701
  if (_method_handle_invoke)
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   702
    st->print("MethodHandle ");
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   703
  if (_method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    _method->print_short_name(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    st->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  MachCallNode::dump_spec(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   711
//------------------------------Registers--------------------------------------
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   712
const RegMask &MachCallJavaNode::in_RegMask(uint idx) const {
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   713
  // Values in the domain use the users calling convention, embodied in the
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   714
  // _in_rms array of RegMasks.
22850
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   715
  if (idx < tf()->domain()->cnt()) {
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   716
    return _in_rms[idx];
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   717
  }
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   718
  if (idx == mach_constant_base_node_input()) {
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   719
    return MachConstantBaseNode::static_out_RegMask();
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22847
diff changeset
   720
  }
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   721
  // Values outside the domain represent debug info
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   722
  Matcher* m = Compile::current()->matcher();
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   723
  // If this call is a MethodHandle invoke we have to use a different
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   724
  // debugmask which does not include the register we use to save the
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   725
  // SP over MH invokes.
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   726
  RegMask** debugmask = _method_handle_invoke ? m->idealreg2mhdebugmask : m->idealreg2debugmask;
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   727
  return *debugmask[in(idx)->ideal_reg()];
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   728
}
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3283
diff changeset
   729
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
uint MachCallStaticJavaNode::size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
uint MachCallStaticJavaNode::cmp( const Node &n ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  MachCallStaticJavaNode &call = (MachCallStaticJavaNode&)n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  return MachCallJavaNode::cmp(call) && _name == call._name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
//----------------------------uncommon_trap_request----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
// If this is an uncommon trap, return the request code, else zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
int MachCallStaticJavaNode::uncommon_trap_request() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  if (_name != NULL && !strcmp(_name, "uncommon_trap")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
    return CallStaticJavaNode::extract_uncommon_trap_request(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
// Helper for summarizing uncommon_trap arguments.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
void MachCallStaticJavaNode::dump_trap_args(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  int trap_req = uncommon_trap_request();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  if (trap_req != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    char buf[100];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
    st->print("(%s)",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
               Deoptimization::format_trap_request(buf, sizeof(buf),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
                                                   trap_req));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
void MachCallStaticJavaNode::dump_spec(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  st->print("Static ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  if (_name != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
    st->print("wrapper for: %s", _name );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
    dump_trap_args(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
    st->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  MachCallJavaNode::dump_spec(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
void MachCallDynamicJavaNode::dump_spec(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  st->print("Dynamic ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  MachCallJavaNode::dump_spec(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
uint MachCallRuntimeNode::size_of() const { return sizeof(*this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
uint MachCallRuntimeNode::cmp( const Node &n ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  MachCallRuntimeNode &call = (MachCallRuntimeNode&)n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  return MachCallNode::cmp(call) && !strcmp(_name,call._name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
void MachCallRuntimeNode::dump_spec(outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  st->print("%s ",_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  MachCallNode::dump_spec(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
// A shared JVMState for all HaltNodes.  Indicates the start of debug info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
// is at TypeFunc::Parms.  Only required for SOE register spill handling -
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
// to indicate where the stack-slot-only debug info inputs begin.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
// There is no other JVM state needed here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
JVMState jvms_for_throw(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
JVMState *MachHaltNode::jvms() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
  return &jvms_for_throw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
void labelOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
  st->print("B%d", _block_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
void methodOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  st->print(INTPTR_FORMAT, _method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
#endif // PRODUCT