Thu, 07 Oct 2010 21:40:55 -0700
6980792: Crash "exception happened outside interpreter, nmethods and vtable stubs (1)"
Reviewed-by: kvn
duke@435 | 1 | /* |
trims@1907 | 2 | * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | #include "incls/_precompiled.incl" |
duke@435 | 26 | #include "incls/_machnode.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | //============================================================================= |
duke@435 | 29 | // Return the value requested |
duke@435 | 30 | // result register lookup, corresponding to int_format |
duke@435 | 31 | int MachOper::reg(PhaseRegAlloc *ra_, const Node *node) const { |
duke@435 | 32 | return (int)ra_->get_encode(node); |
duke@435 | 33 | } |
duke@435 | 34 | // input register lookup, corresponding to ext_format |
duke@435 | 35 | int MachOper::reg(PhaseRegAlloc *ra_, const Node *node, int idx) const { |
duke@435 | 36 | return (int)(ra_->get_encode(node->in(idx))); |
duke@435 | 37 | } |
duke@435 | 38 | intptr_t MachOper::constant() const { return 0x00; } |
duke@435 | 39 | bool MachOper::constant_is_oop() const { return false; } |
duke@435 | 40 | jdouble MachOper::constantD() const { ShouldNotReachHere(); return 0.0; } |
duke@435 | 41 | jfloat MachOper::constantF() const { ShouldNotReachHere(); return 0.0; } |
duke@435 | 42 | jlong MachOper::constantL() const { ShouldNotReachHere(); return CONST64(0) ; } |
duke@435 | 43 | TypeOopPtr *MachOper::oop() const { return NULL; } |
duke@435 | 44 | int MachOper::ccode() const { return 0x00; } |
duke@435 | 45 | // A zero, default, indicates this value is not needed. |
duke@435 | 46 | // May need to lookup the base register, as done in int_ and ext_format |
duke@435 | 47 | int MachOper::base (PhaseRegAlloc *ra_, const Node *node, int idx) const { return 0x00; } |
duke@435 | 48 | int MachOper::index(PhaseRegAlloc *ra_, const Node *node, int idx) const { return 0x00; } |
duke@435 | 49 | int MachOper::scale() const { return 0x00; } |
duke@435 | 50 | int MachOper::disp (PhaseRegAlloc *ra_, const Node *node, int idx) const { return 0x00; } |
duke@435 | 51 | int MachOper::constant_disp() const { return 0; } |
duke@435 | 52 | int MachOper::base_position() const { return -1; } // no base input |
duke@435 | 53 | int MachOper::index_position() const { return -1; } // no index input |
duke@435 | 54 | // Check for PC-Relative displacement |
duke@435 | 55 | bool MachOper::disp_is_oop() const { return false; } |
duke@435 | 56 | // Return the label |
duke@435 | 57 | Label* MachOper::label() const { ShouldNotReachHere(); return 0; } |
duke@435 | 58 | intptr_t MachOper::method() const { ShouldNotReachHere(); return 0; } |
duke@435 | 59 | |
duke@435 | 60 | |
duke@435 | 61 | //------------------------------negate----------------------------------------- |
duke@435 | 62 | // Negate conditional branches. Error for non-branch operands |
duke@435 | 63 | void MachOper::negate() { |
duke@435 | 64 | ShouldNotCallThis(); |
duke@435 | 65 | } |
duke@435 | 66 | |
duke@435 | 67 | //-----------------------------type-------------------------------------------- |
duke@435 | 68 | const Type *MachOper::type() const { |
duke@435 | 69 | return Type::BOTTOM; |
duke@435 | 70 | } |
duke@435 | 71 | |
duke@435 | 72 | //------------------------------in_RegMask------------------------------------- |
duke@435 | 73 | const RegMask *MachOper::in_RegMask(int index) const { |
duke@435 | 74 | ShouldNotReachHere(); |
duke@435 | 75 | return NULL; |
duke@435 | 76 | } |
duke@435 | 77 | |
duke@435 | 78 | //------------------------------dump_spec-------------------------------------- |
duke@435 | 79 | // Print any per-operand special info |
duke@435 | 80 | #ifndef PRODUCT |
duke@435 | 81 | void MachOper::dump_spec(outputStream *st) const { } |
duke@435 | 82 | #endif |
duke@435 | 83 | |
duke@435 | 84 | //------------------------------hash------------------------------------------- |
duke@435 | 85 | // Print any per-operand special info |
duke@435 | 86 | uint MachOper::hash() const { |
duke@435 | 87 | ShouldNotCallThis(); |
duke@435 | 88 | return 5; |
duke@435 | 89 | } |
duke@435 | 90 | |
duke@435 | 91 | //------------------------------cmp-------------------------------------------- |
duke@435 | 92 | // Print any per-operand special info |
duke@435 | 93 | uint MachOper::cmp( const MachOper &oper ) const { |
duke@435 | 94 | ShouldNotCallThis(); |
duke@435 | 95 | return opcode() == oper.opcode(); |
duke@435 | 96 | } |
duke@435 | 97 | |
duke@435 | 98 | //------------------------------hash------------------------------------------- |
duke@435 | 99 | // Print any per-operand special info |
duke@435 | 100 | uint labelOper::hash() const { |
duke@435 | 101 | return _block_num; |
duke@435 | 102 | } |
duke@435 | 103 | |
duke@435 | 104 | //------------------------------cmp-------------------------------------------- |
duke@435 | 105 | // Print any per-operand special info |
duke@435 | 106 | uint labelOper::cmp( const MachOper &oper ) const { |
duke@435 | 107 | return (opcode() == oper.opcode()) && (_label == oper.label()); |
duke@435 | 108 | } |
duke@435 | 109 | |
duke@435 | 110 | //------------------------------hash------------------------------------------- |
duke@435 | 111 | // Print any per-operand special info |
duke@435 | 112 | uint methodOper::hash() const { |
duke@435 | 113 | return (uint)_method; |
duke@435 | 114 | } |
duke@435 | 115 | |
duke@435 | 116 | //------------------------------cmp-------------------------------------------- |
duke@435 | 117 | // Print any per-operand special info |
duke@435 | 118 | uint methodOper::cmp( const MachOper &oper ) const { |
duke@435 | 119 | return (opcode() == oper.opcode()) && (_method == oper.method()); |
duke@435 | 120 | } |
duke@435 | 121 | |
duke@435 | 122 | |
duke@435 | 123 | //============================================================================= |
duke@435 | 124 | //------------------------------MachNode--------------------------------------- |
duke@435 | 125 | |
duke@435 | 126 | //------------------------------emit------------------------------------------- |
duke@435 | 127 | void MachNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { |
duke@435 | 128 | #ifdef ASSERT |
duke@435 | 129 | tty->print("missing MachNode emit function: "); |
duke@435 | 130 | dump(); |
duke@435 | 131 | #endif |
duke@435 | 132 | ShouldNotCallThis(); |
duke@435 | 133 | } |
duke@435 | 134 | |
duke@435 | 135 | //------------------------------size------------------------------------------- |
duke@435 | 136 | // Size of instruction in bytes |
duke@435 | 137 | uint MachNode::size(PhaseRegAlloc *ra_) const { |
duke@435 | 138 | // If a virtual was not defined for this specific instruction, |
twisti@1040 | 139 | // Call the helper which finds the size by emitting the bits. |
duke@435 | 140 | return MachNode::emit_size(ra_); |
duke@435 | 141 | } |
duke@435 | 142 | |
duke@435 | 143 | //------------------------------size------------------------------------------- |
duke@435 | 144 | // Helper function that computes size by emitting code |
duke@435 | 145 | uint MachNode::emit_size(PhaseRegAlloc *ra_) const { |
duke@435 | 146 | // Emit into a trash buffer and count bytes emitted. |
duke@435 | 147 | assert(ra_ == ra_->C->regalloc(), "sanity"); |
duke@435 | 148 | return ra_->C->scratch_emit_size(this); |
duke@435 | 149 | } |
duke@435 | 150 | |
duke@435 | 151 | |
duke@435 | 152 | |
duke@435 | 153 | //------------------------------hash------------------------------------------- |
duke@435 | 154 | uint MachNode::hash() const { |
duke@435 | 155 | uint no = num_opnds(); |
duke@435 | 156 | uint sum = rule(); |
duke@435 | 157 | for( uint i=0; i<no; i++ ) |
duke@435 | 158 | sum += _opnds[i]->hash(); |
duke@435 | 159 | return sum+Node::hash(); |
duke@435 | 160 | } |
duke@435 | 161 | |
duke@435 | 162 | //-----------------------------cmp--------------------------------------------- |
duke@435 | 163 | uint MachNode::cmp( const Node &node ) const { |
duke@435 | 164 | MachNode& n = *((Node&)node).as_Mach(); |
duke@435 | 165 | uint no = num_opnds(); |
duke@435 | 166 | if( no != n.num_opnds() ) return 0; |
duke@435 | 167 | if( rule() != n.rule() ) return 0; |
duke@435 | 168 | for( uint i=0; i<no; i++ ) // All operands must match |
duke@435 | 169 | if( !_opnds[i]->cmp( *n._opnds[i] ) ) |
duke@435 | 170 | return 0; // mis-matched operands |
duke@435 | 171 | return 1; // match |
duke@435 | 172 | } |
duke@435 | 173 | |
duke@435 | 174 | // Return an equivalent instruction using memory for cisc_operand position |
duke@435 | 175 | MachNode *MachNode::cisc_version(int offset, Compile* C) { |
duke@435 | 176 | ShouldNotCallThis(); |
duke@435 | 177 | return NULL; |
duke@435 | 178 | } |
duke@435 | 179 | |
duke@435 | 180 | void MachNode::use_cisc_RegMask() { |
duke@435 | 181 | ShouldNotReachHere(); |
duke@435 | 182 | } |
duke@435 | 183 | |
duke@435 | 184 | |
duke@435 | 185 | //-----------------------------in_RegMask-------------------------------------- |
duke@435 | 186 | const RegMask &MachNode::in_RegMask( uint idx ) const { |
duke@435 | 187 | uint numopnds = num_opnds(); // Virtual call for number of operands |
duke@435 | 188 | uint skipped = oper_input_base(); // Sum of leaves skipped so far |
duke@435 | 189 | if( idx < skipped ) { |
duke@435 | 190 | assert( ideal_Opcode() == Op_AddP, "expected base ptr here" ); |
duke@435 | 191 | assert( idx == 1, "expected base ptr here" ); |
duke@435 | 192 | // debug info can be anywhere |
duke@435 | 193 | return *Compile::current()->matcher()->idealreg2spillmask[Op_RegP]; |
duke@435 | 194 | } |
duke@435 | 195 | uint opcnt = 1; // First operand |
duke@435 | 196 | uint num_edges = _opnds[1]->num_edges(); // leaves for first operand |
duke@435 | 197 | while( idx >= skipped+num_edges ) { |
duke@435 | 198 | skipped += num_edges; |
duke@435 | 199 | opcnt++; // Bump operand count |
duke@435 | 200 | assert( opcnt < numopnds, "Accessing non-existent operand" ); |
duke@435 | 201 | num_edges = _opnds[opcnt]->num_edges(); // leaves for next operand |
duke@435 | 202 | } |
duke@435 | 203 | |
duke@435 | 204 | const RegMask *rm = cisc_RegMask(); |
duke@435 | 205 | if( rm == NULL || (int)opcnt != cisc_operand() ) { |
duke@435 | 206 | rm = _opnds[opcnt]->in_RegMask(idx-skipped); |
duke@435 | 207 | } |
duke@435 | 208 | return *rm; |
duke@435 | 209 | } |
duke@435 | 210 | |
duke@435 | 211 | //-----------------------------memory_inputs-------------------------------- |
duke@435 | 212 | const MachOper* MachNode::memory_inputs(Node* &base, Node* &index) const { |
duke@435 | 213 | const MachOper* oper = memory_operand(); |
duke@435 | 214 | |
duke@435 | 215 | if (oper == (MachOper*)-1) { |
duke@435 | 216 | base = NodeSentinel; |
duke@435 | 217 | index = NodeSentinel; |
duke@435 | 218 | } else { |
duke@435 | 219 | base = NULL; |
duke@435 | 220 | index = NULL; |
duke@435 | 221 | if (oper != NULL) { |
duke@435 | 222 | // It has a unique memory operand. Find its index. |
duke@435 | 223 | int oper_idx = num_opnds(); |
duke@435 | 224 | while (--oper_idx >= 0) { |
duke@435 | 225 | if (_opnds[oper_idx] == oper) break; |
duke@435 | 226 | } |
duke@435 | 227 | int oper_pos = operand_index(oper_idx); |
duke@435 | 228 | int base_pos = oper->base_position(); |
duke@435 | 229 | if (base_pos >= 0) { |
duke@435 | 230 | base = _in[oper_pos+base_pos]; |
duke@435 | 231 | } |
duke@435 | 232 | int index_pos = oper->index_position(); |
duke@435 | 233 | if (index_pos >= 0) { |
duke@435 | 234 | index = _in[oper_pos+index_pos]; |
duke@435 | 235 | } |
duke@435 | 236 | } |
duke@435 | 237 | } |
duke@435 | 238 | |
duke@435 | 239 | return oper; |
duke@435 | 240 | } |
duke@435 | 241 | |
duke@435 | 242 | //-----------------------------get_base_and_disp---------------------------- |
duke@435 | 243 | const Node* MachNode::get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const { |
duke@435 | 244 | |
duke@435 | 245 | // Find the memory inputs using our helper function |
duke@435 | 246 | Node* base; |
duke@435 | 247 | Node* index; |
duke@435 | 248 | const MachOper* oper = memory_inputs(base, index); |
duke@435 | 249 | |
duke@435 | 250 | if (oper == NULL) { |
duke@435 | 251 | // Base has been set to NULL |
duke@435 | 252 | offset = 0; |
duke@435 | 253 | } else if (oper == (MachOper*)-1) { |
duke@435 | 254 | // Base has been set to NodeSentinel |
duke@435 | 255 | // There is not a unique memory use here. We will fall to AliasIdxBot. |
duke@435 | 256 | offset = Type::OffsetBot; |
duke@435 | 257 | } else { |
duke@435 | 258 | // Base may be NULL, even if offset turns out to be != 0 |
duke@435 | 259 | |
duke@435 | 260 | intptr_t disp = oper->constant_disp(); |
duke@435 | 261 | int scale = oper->scale(); |
duke@435 | 262 | // Now we have collected every part of the ADLC MEMORY_INTER. |
duke@435 | 263 | // See if it adds up to a base + offset. |
duke@435 | 264 | if (index != NULL) { |
kvn@656 | 265 | const Type* t_index = index->bottom_type(); |
kvn@656 | 266 | if (t_index->isa_narrowoop()) { // EncodeN, LoadN, LoadConN, LoadNKlass. |
kvn@651 | 267 | // Memory references through narrow oops have a |
kvn@651 | 268 | // funny base so grab the type from the index: |
kvn@651 | 269 | // [R12 + narrow_oop_reg<<3 + offset] |
kvn@651 | 270 | assert(base == NULL, "Memory references through narrow oops have no base"); |
kvn@651 | 271 | offset = disp; |
kvn@656 | 272 | adr_type = t_index->make_ptr()->add_offset(offset); |
kvn@651 | 273 | return NULL; |
kvn@651 | 274 | } else if (!index->is_Con()) { |
duke@435 | 275 | disp = Type::OffsetBot; |
duke@435 | 276 | } else if (disp != Type::OffsetBot) { |
kvn@656 | 277 | const TypeX* ti = t_index->isa_intptr_t(); |
duke@435 | 278 | if (ti == NULL) { |
duke@435 | 279 | disp = Type::OffsetBot; // a random constant?? |
duke@435 | 280 | } else { |
duke@435 | 281 | disp += ti->get_con() << scale; |
duke@435 | 282 | } |
duke@435 | 283 | } |
duke@435 | 284 | } |
duke@435 | 285 | offset = disp; |
duke@435 | 286 | |
duke@435 | 287 | // In i486.ad, indOffset32X uses base==RegI and disp==RegP, |
duke@435 | 288 | // this will prevent alias analysis without the following support: |
duke@435 | 289 | // Lookup the TypePtr used by indOffset32X, a compile-time constant oop, |
duke@435 | 290 | // Add the offset determined by the "base", or use Type::OffsetBot. |
duke@435 | 291 | if( adr_type == TYPE_PTR_SENTINAL ) { |
duke@435 | 292 | const TypePtr *t_disp = oper->disp_as_type(); // only !NULL for indOffset32X |
duke@435 | 293 | if (t_disp != NULL) { |
duke@435 | 294 | offset = Type::OffsetBot; |
duke@435 | 295 | const Type* t_base = base->bottom_type(); |
duke@435 | 296 | if (t_base->isa_intptr_t()) { |
duke@435 | 297 | const TypeX *t_offset = t_base->is_intptr_t(); |
duke@435 | 298 | if( t_offset->is_con() ) { |
duke@435 | 299 | offset = t_offset->get_con(); |
duke@435 | 300 | } |
duke@435 | 301 | } |
duke@435 | 302 | adr_type = t_disp->add_offset(offset); |
kvn@1286 | 303 | } else if( base == NULL && offset != 0 && offset != Type::OffsetBot ) { |
kvn@1286 | 304 | // Use ideal type if it is oop ptr. |
kvn@1286 | 305 | const TypePtr *tp = oper->type()->isa_ptr(); |
kvn@1286 | 306 | if( tp != NULL) { |
kvn@1286 | 307 | adr_type = tp; |
kvn@1286 | 308 | } |
duke@435 | 309 | } |
duke@435 | 310 | } |
duke@435 | 311 | |
duke@435 | 312 | } |
duke@435 | 313 | return base; |
duke@435 | 314 | } |
duke@435 | 315 | |
duke@435 | 316 | |
duke@435 | 317 | //---------------------------------adr_type--------------------------------- |
duke@435 | 318 | const class TypePtr *MachNode::adr_type() const { |
duke@435 | 319 | intptr_t offset = 0; |
duke@435 | 320 | const TypePtr *adr_type = TYPE_PTR_SENTINAL; // attempt computing adr_type |
duke@435 | 321 | const Node *base = get_base_and_disp(offset, adr_type); |
duke@435 | 322 | if( adr_type != TYPE_PTR_SENTINAL ) { |
duke@435 | 323 | return adr_type; // get_base_and_disp has the answer |
duke@435 | 324 | } |
duke@435 | 325 | |
duke@435 | 326 | // Direct addressing modes have no base node, simply an indirect |
duke@435 | 327 | // offset, which is always to raw memory. |
duke@435 | 328 | // %%%%% Someday we'd like to allow constant oop offsets which |
duke@435 | 329 | // would let Intel load from static globals in 1 instruction. |
duke@435 | 330 | // Currently Intel requires 2 instructions and a register temp. |
duke@435 | 331 | if (base == NULL) { |
duke@435 | 332 | // NULL base, zero offset means no memory at all (a null pointer!) |
duke@435 | 333 | if (offset == 0) { |
duke@435 | 334 | return NULL; |
duke@435 | 335 | } |
duke@435 | 336 | // NULL base, any offset means any pointer whatever |
duke@435 | 337 | if (offset == Type::OffsetBot) { |
duke@435 | 338 | return TypePtr::BOTTOM; |
duke@435 | 339 | } |
duke@435 | 340 | // %%% make offset be intptr_t |
duke@435 | 341 | assert(!Universe::heap()->is_in_reserved((oop)offset), "must be a raw ptr"); |
duke@435 | 342 | return TypeRawPtr::BOTTOM; |
duke@435 | 343 | } |
duke@435 | 344 | |
duke@435 | 345 | // base of -1 with no particular offset means all of memory |
duke@435 | 346 | if (base == NodeSentinel) return TypePtr::BOTTOM; |
duke@435 | 347 | |
duke@435 | 348 | const Type* t = base->bottom_type(); |
kvn@1108 | 349 | if (UseCompressedOops && Universe::narrow_oop_shift() == 0) { |
kvn@1108 | 350 | // 32-bit unscaled narrow oop can be the base of any address expression |
kvn@1108 | 351 | t = t->make_ptr(); |
kvn@1108 | 352 | } |
duke@435 | 353 | if (t->isa_intptr_t() && offset != 0 && offset != Type::OffsetBot) { |
duke@435 | 354 | // We cannot assert that the offset does not look oop-ish here. |
duke@435 | 355 | // Depending on the heap layout the cardmark base could land |
duke@435 | 356 | // inside some oopish region. It definitely does for Win2K. |
duke@435 | 357 | // The sum of cardmark-base plus shift-by-9-oop lands outside |
duke@435 | 358 | // the oop-ish area but we can't assert for that statically. |
duke@435 | 359 | return TypeRawPtr::BOTTOM; |
duke@435 | 360 | } |
duke@435 | 361 | |
duke@435 | 362 | const TypePtr *tp = t->isa_ptr(); |
duke@435 | 363 | |
duke@435 | 364 | // be conservative if we do not recognize the type |
duke@435 | 365 | if (tp == NULL) { |
kvn@1108 | 366 | assert(false, "this path may produce not optimal code"); |
duke@435 | 367 | return TypePtr::BOTTOM; |
duke@435 | 368 | } |
duke@435 | 369 | assert(tp->base() != Type::AnyPtr, "not a bare pointer"); |
duke@435 | 370 | |
duke@435 | 371 | return tp->add_offset(offset); |
duke@435 | 372 | } |
duke@435 | 373 | |
duke@435 | 374 | |
duke@435 | 375 | //-----------------------------operand_index--------------------------------- |
duke@435 | 376 | int MachNode::operand_index( uint operand ) const { |
duke@435 | 377 | if( operand < 1 ) return -1; |
duke@435 | 378 | assert(operand < num_opnds(), "oob"); |
duke@435 | 379 | if( _opnds[operand]->num_edges() == 0 ) return -1; |
duke@435 | 380 | |
duke@435 | 381 | uint skipped = oper_input_base(); // Sum of leaves skipped so far |
duke@435 | 382 | for (uint opcnt = 1; opcnt < operand; opcnt++) { |
duke@435 | 383 | uint num_edges = _opnds[opcnt]->num_edges(); // leaves for operand |
duke@435 | 384 | skipped += num_edges; |
duke@435 | 385 | } |
duke@435 | 386 | return skipped; |
duke@435 | 387 | } |
duke@435 | 388 | |
duke@435 | 389 | |
duke@435 | 390 | //------------------------------negate----------------------------------------- |
duke@435 | 391 | // Negate conditional branches. Error for non-branch Nodes |
duke@435 | 392 | void MachNode::negate() { |
duke@435 | 393 | ShouldNotCallThis(); |
duke@435 | 394 | } |
duke@435 | 395 | |
duke@435 | 396 | //------------------------------peephole--------------------------------------- |
duke@435 | 397 | // Apply peephole rule(s) to this instruction |
duke@435 | 398 | MachNode *MachNode::peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ) { |
duke@435 | 399 | return NULL; |
duke@435 | 400 | } |
duke@435 | 401 | |
duke@435 | 402 | //------------------------------add_case_label--------------------------------- |
duke@435 | 403 | // Adds the label for the case |
duke@435 | 404 | void MachNode::add_case_label( int index_num, Label* blockLabel) { |
duke@435 | 405 | ShouldNotCallThis(); |
duke@435 | 406 | } |
duke@435 | 407 | |
duke@435 | 408 | //------------------------------label_set-------------------------------------- |
duke@435 | 409 | // Set the Label for a LabelOper, if an operand for this instruction |
duke@435 | 410 | void MachNode::label_set( Label& label, uint block_num ) { |
duke@435 | 411 | ShouldNotCallThis(); |
duke@435 | 412 | } |
duke@435 | 413 | |
duke@435 | 414 | //------------------------------method_set------------------------------------- |
duke@435 | 415 | // Set the absolute address of a method |
duke@435 | 416 | void MachNode::method_set( intptr_t addr ) { |
duke@435 | 417 | ShouldNotCallThis(); |
duke@435 | 418 | } |
duke@435 | 419 | |
duke@435 | 420 | //------------------------------rematerialize---------------------------------- |
duke@435 | 421 | bool MachNode::rematerialize() const { |
duke@435 | 422 | // Temps are always rematerializable |
duke@435 | 423 | if (is_MachTemp()) return true; |
duke@435 | 424 | |
duke@435 | 425 | uint r = rule(); // Match rule |
duke@435 | 426 | if( r < Matcher::_begin_rematerialize || |
duke@435 | 427 | r >= Matcher::_end_rematerialize ) |
duke@435 | 428 | return false; |
duke@435 | 429 | |
duke@435 | 430 | // For 2-address instructions, the input live range is also the output |
duke@435 | 431 | // live range. Remateralizing does not make progress on the that live range. |
duke@435 | 432 | if( two_adr() ) return false; |
duke@435 | 433 | |
duke@435 | 434 | // Check for rematerializing float constants, or not |
duke@435 | 435 | if( !Matcher::rematerialize_float_constants ) { |
duke@435 | 436 | int op = ideal_Opcode(); |
duke@435 | 437 | if( op == Op_ConF || op == Op_ConD ) |
duke@435 | 438 | return false; |
duke@435 | 439 | } |
duke@435 | 440 | |
duke@435 | 441 | // Defining flags - can't spill these! Must remateralize. |
duke@435 | 442 | if( ideal_reg() == Op_RegFlags ) |
duke@435 | 443 | return true; |
duke@435 | 444 | |
duke@435 | 445 | // Stretching lots of inputs - don't do it. |
duke@435 | 446 | if( req() > 2 ) |
duke@435 | 447 | return false; |
duke@435 | 448 | |
duke@435 | 449 | // Don't remateralize somebody with bound inputs - it stretches a |
duke@435 | 450 | // fixed register lifetime. |
duke@435 | 451 | uint idx = oper_input_base(); |
duke@435 | 452 | if( req() > idx ) { |
duke@435 | 453 | const RegMask &rm = in_RegMask(idx); |
duke@435 | 454 | if( rm.is_bound1() || rm.is_bound2() ) |
duke@435 | 455 | return false; |
duke@435 | 456 | } |
duke@435 | 457 | |
duke@435 | 458 | return true; |
duke@435 | 459 | } |
duke@435 | 460 | |
duke@435 | 461 | #ifndef PRODUCT |
duke@435 | 462 | //------------------------------dump_spec-------------------------------------- |
duke@435 | 463 | // Print any per-operand special info |
duke@435 | 464 | void MachNode::dump_spec(outputStream *st) const { |
duke@435 | 465 | uint cnt = num_opnds(); |
duke@435 | 466 | for( uint i=0; i<cnt; i++ ) |
duke@435 | 467 | _opnds[i]->dump_spec(st); |
duke@435 | 468 | const TypePtr *t = adr_type(); |
duke@435 | 469 | if( t ) { |
duke@435 | 470 | Compile* C = Compile::current(); |
duke@435 | 471 | if( C->alias_type(t)->is_volatile() ) |
duke@435 | 472 | st->print(" Volatile!"); |
duke@435 | 473 | } |
duke@435 | 474 | } |
duke@435 | 475 | |
duke@435 | 476 | //------------------------------dump_format------------------------------------ |
duke@435 | 477 | // access to virtual |
duke@435 | 478 | void MachNode::dump_format(PhaseRegAlloc *ra, outputStream *st) const { |
duke@435 | 479 | format(ra, st); // access to virtual |
duke@435 | 480 | } |
duke@435 | 481 | #endif |
duke@435 | 482 | |
duke@435 | 483 | //============================================================================= |
duke@435 | 484 | #ifndef PRODUCT |
duke@435 | 485 | void MachTypeNode::dump_spec(outputStream *st) const { |
duke@435 | 486 | _bottom_type->dump_on(st); |
duke@435 | 487 | } |
duke@435 | 488 | #endif |
duke@435 | 489 | |
duke@435 | 490 | //============================================================================= |
duke@435 | 491 | #ifndef PRODUCT |
duke@435 | 492 | void MachNullCheckNode::format( PhaseRegAlloc *ra_, outputStream *st ) const { |
duke@435 | 493 | int reg = ra_->get_reg_first(in(1)->in(_vidx)); |
duke@435 | 494 | tty->print("%s %s", Name(), Matcher::regName[reg]); |
duke@435 | 495 | } |
duke@435 | 496 | #endif |
duke@435 | 497 | |
duke@435 | 498 | void MachNullCheckNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { |
duke@435 | 499 | // only emits entries in the null-pointer exception handler table |
duke@435 | 500 | } |
duke@435 | 501 | |
duke@435 | 502 | const RegMask &MachNullCheckNode::in_RegMask( uint idx ) const { |
duke@435 | 503 | if( idx == 0 ) return RegMask::Empty; |
duke@435 | 504 | else return in(1)->as_Mach()->out_RegMask(); |
duke@435 | 505 | } |
duke@435 | 506 | |
duke@435 | 507 | //============================================================================= |
duke@435 | 508 | const Type *MachProjNode::bottom_type() const { |
duke@435 | 509 | if( _ideal_reg == fat_proj ) return Type::BOTTOM; |
duke@435 | 510 | // Try the normal mechanism first |
duke@435 | 511 | const Type *t = in(0)->bottom_type(); |
duke@435 | 512 | if( t->base() == Type::Tuple ) { |
duke@435 | 513 | const TypeTuple *tt = t->is_tuple(); |
duke@435 | 514 | if (_con < tt->cnt()) |
duke@435 | 515 | return tt->field_at(_con); |
duke@435 | 516 | } |
duke@435 | 517 | // Else use generic type from ideal register set |
duke@435 | 518 | assert((uint)_ideal_reg < (uint)_last_machine_leaf && Type::mreg2type[_ideal_reg], "in bounds"); |
duke@435 | 519 | return Type::mreg2type[_ideal_reg]; |
duke@435 | 520 | } |
duke@435 | 521 | |
duke@435 | 522 | const TypePtr *MachProjNode::adr_type() const { |
duke@435 | 523 | if (bottom_type() == Type::MEMORY) { |
duke@435 | 524 | // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM |
duke@435 | 525 | const TypePtr* adr_type = in(0)->adr_type(); |
duke@435 | 526 | #ifdef ASSERT |
duke@435 | 527 | if (!is_error_reported() && !Node::in_dump()) |
duke@435 | 528 | assert(adr_type != NULL, "source must have adr_type"); |
duke@435 | 529 | #endif |
duke@435 | 530 | return adr_type; |
duke@435 | 531 | } |
duke@435 | 532 | assert(bottom_type()->base() != Type::Memory, "no other memories?"); |
duke@435 | 533 | return NULL; |
duke@435 | 534 | } |
duke@435 | 535 | |
duke@435 | 536 | #ifndef PRODUCT |
duke@435 | 537 | void MachProjNode::dump_spec(outputStream *st) const { |
duke@435 | 538 | ProjNode::dump_spec(st); |
duke@435 | 539 | switch (_ideal_reg) { |
duke@435 | 540 | case unmatched_proj: st->print("/unmatched"); break; |
duke@435 | 541 | case fat_proj: st->print("/fat"); if (WizardMode) _rout.dump(); break; |
duke@435 | 542 | } |
duke@435 | 543 | } |
duke@435 | 544 | #endif |
duke@435 | 545 | |
duke@435 | 546 | //============================================================================= |
duke@435 | 547 | #ifndef PRODUCT |
duke@435 | 548 | void MachIfNode::dump_spec(outputStream *st) const { |
duke@435 | 549 | st->print("P=%f, C=%f",_prob, _fcnt); |
duke@435 | 550 | } |
duke@435 | 551 | #endif |
duke@435 | 552 | |
duke@435 | 553 | //============================================================================= |
duke@435 | 554 | uint MachReturnNode::size_of() const { return sizeof(*this); } |
duke@435 | 555 | |
duke@435 | 556 | //------------------------------Registers-------------------------------------- |
duke@435 | 557 | const RegMask &MachReturnNode::in_RegMask( uint idx ) const { |
duke@435 | 558 | return _in_rms[idx]; |
duke@435 | 559 | } |
duke@435 | 560 | |
duke@435 | 561 | const TypePtr *MachReturnNode::adr_type() const { |
duke@435 | 562 | // most returns and calls are assumed to consume & modify all of memory |
duke@435 | 563 | // the matcher will copy non-wide adr_types from ideal originals |
duke@435 | 564 | return _adr_type; |
duke@435 | 565 | } |
duke@435 | 566 | |
duke@435 | 567 | //============================================================================= |
duke@435 | 568 | const Type *MachSafePointNode::bottom_type() const { return TypeTuple::MEMBAR; } |
duke@435 | 569 | |
duke@435 | 570 | //------------------------------Registers-------------------------------------- |
duke@435 | 571 | const RegMask &MachSafePointNode::in_RegMask( uint idx ) const { |
duke@435 | 572 | // Values in the domain use the users calling convention, embodied in the |
duke@435 | 573 | // _in_rms array of RegMasks. |
duke@435 | 574 | if( idx < TypeFunc::Parms ) return _in_rms[idx]; |
duke@435 | 575 | |
duke@435 | 576 | if (SafePointNode::needs_polling_address_input() && |
duke@435 | 577 | idx == TypeFunc::Parms && |
duke@435 | 578 | ideal_Opcode() == Op_SafePoint) { |
duke@435 | 579 | return MachNode::in_RegMask(idx); |
duke@435 | 580 | } |
duke@435 | 581 | |
duke@435 | 582 | // Values outside the domain represent debug info |
duke@435 | 583 | return *Compile::current()->matcher()->idealreg2spillmask[in(idx)->ideal_reg()]; |
duke@435 | 584 | } |
duke@435 | 585 | |
duke@435 | 586 | |
duke@435 | 587 | //============================================================================= |
duke@435 | 588 | |
duke@435 | 589 | uint MachCallNode::cmp( const Node &n ) const |
duke@435 | 590 | { return _tf == ((MachCallNode&)n)._tf; } |
duke@435 | 591 | const Type *MachCallNode::bottom_type() const { return tf()->range(); } |
duke@435 | 592 | const Type *MachCallNode::Value(PhaseTransform *phase) const { return tf()->range(); } |
duke@435 | 593 | |
duke@435 | 594 | #ifndef PRODUCT |
duke@435 | 595 | void MachCallNode::dump_spec(outputStream *st) const { |
duke@435 | 596 | st->print("# "); |
duke@435 | 597 | tf()->dump_on(st); |
duke@435 | 598 | if (_cnt != COUNT_UNKNOWN) st->print(" C=%f",_cnt); |
duke@435 | 599 | if (jvms() != NULL) jvms()->dump_spec(st); |
duke@435 | 600 | } |
duke@435 | 601 | #endif |
duke@435 | 602 | |
duke@435 | 603 | |
duke@435 | 604 | bool MachCallNode::return_value_is_used() const { |
duke@435 | 605 | if (tf()->range()->cnt() == TypeFunc::Parms) { |
duke@435 | 606 | // void return |
duke@435 | 607 | return false; |
duke@435 | 608 | } |
duke@435 | 609 | |
duke@435 | 610 | // find the projection corresponding to the return value |
duke@435 | 611 | for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) { |
duke@435 | 612 | Node *use = fast_out(i); |
duke@435 | 613 | if (!use->is_Proj()) continue; |
duke@435 | 614 | if (use->as_Proj()->_con == TypeFunc::Parms) { |
duke@435 | 615 | return true; |
duke@435 | 616 | } |
duke@435 | 617 | } |
duke@435 | 618 | return false; |
duke@435 | 619 | } |
duke@435 | 620 | |
duke@435 | 621 | |
duke@435 | 622 | //------------------------------Registers-------------------------------------- |
duke@435 | 623 | const RegMask &MachCallNode::in_RegMask( uint idx ) const { |
duke@435 | 624 | // Values in the domain use the users calling convention, embodied in the |
duke@435 | 625 | // _in_rms array of RegMasks. |
duke@435 | 626 | if (idx < tf()->domain()->cnt()) return _in_rms[idx]; |
duke@435 | 627 | // Values outside the domain represent debug info |
duke@435 | 628 | return *Compile::current()->matcher()->idealreg2debugmask[in(idx)->ideal_reg()]; |
duke@435 | 629 | } |
duke@435 | 630 | |
duke@435 | 631 | //============================================================================= |
duke@435 | 632 | uint MachCallJavaNode::size_of() const { return sizeof(*this); } |
duke@435 | 633 | uint MachCallJavaNode::cmp( const Node &n ) const { |
duke@435 | 634 | MachCallJavaNode &call = (MachCallJavaNode&)n; |
duke@435 | 635 | return MachCallNode::cmp(call) && _method->equals(call._method); |
duke@435 | 636 | } |
duke@435 | 637 | #ifndef PRODUCT |
duke@435 | 638 | void MachCallJavaNode::dump_spec(outputStream *st) const { |
twisti@1572 | 639 | if (_method_handle_invoke) |
twisti@1572 | 640 | st->print("MethodHandle "); |
twisti@1572 | 641 | if (_method) { |
duke@435 | 642 | _method->print_short_name(st); |
duke@435 | 643 | st->print(" "); |
duke@435 | 644 | } |
duke@435 | 645 | MachCallNode::dump_spec(st); |
duke@435 | 646 | } |
duke@435 | 647 | #endif |
duke@435 | 648 | |
twisti@1572 | 649 | //------------------------------Registers-------------------------------------- |
twisti@1572 | 650 | const RegMask &MachCallJavaNode::in_RegMask(uint idx) const { |
twisti@1572 | 651 | // Values in the domain use the users calling convention, embodied in the |
twisti@1572 | 652 | // _in_rms array of RegMasks. |
twisti@1572 | 653 | if (idx < tf()->domain()->cnt()) return _in_rms[idx]; |
twisti@1572 | 654 | // Values outside the domain represent debug info |
twisti@1572 | 655 | Matcher* m = Compile::current()->matcher(); |
twisti@1572 | 656 | // If this call is a MethodHandle invoke we have to use a different |
twisti@1572 | 657 | // debugmask which does not include the register we use to save the |
twisti@1572 | 658 | // SP over MH invokes. |
twisti@1572 | 659 | RegMask** debugmask = _method_handle_invoke ? m->idealreg2mhdebugmask : m->idealreg2debugmask; |
twisti@1572 | 660 | return *debugmask[in(idx)->ideal_reg()]; |
twisti@1572 | 661 | } |
twisti@1572 | 662 | |
duke@435 | 663 | //============================================================================= |
duke@435 | 664 | uint MachCallStaticJavaNode::size_of() const { return sizeof(*this); } |
duke@435 | 665 | uint MachCallStaticJavaNode::cmp( const Node &n ) const { |
duke@435 | 666 | MachCallStaticJavaNode &call = (MachCallStaticJavaNode&)n; |
duke@435 | 667 | return MachCallJavaNode::cmp(call) && _name == call._name; |
duke@435 | 668 | } |
duke@435 | 669 | |
duke@435 | 670 | //----------------------------uncommon_trap_request---------------------------- |
duke@435 | 671 | // If this is an uncommon trap, return the request code, else zero. |
duke@435 | 672 | int MachCallStaticJavaNode::uncommon_trap_request() const { |
duke@435 | 673 | if (_name != NULL && !strcmp(_name, "uncommon_trap")) { |
duke@435 | 674 | return CallStaticJavaNode::extract_uncommon_trap_request(this); |
duke@435 | 675 | } |
duke@435 | 676 | return 0; |
duke@435 | 677 | } |
duke@435 | 678 | |
duke@435 | 679 | #ifndef PRODUCT |
duke@435 | 680 | // Helper for summarizing uncommon_trap arguments. |
duke@435 | 681 | void MachCallStaticJavaNode::dump_trap_args(outputStream *st) const { |
duke@435 | 682 | int trap_req = uncommon_trap_request(); |
duke@435 | 683 | if (trap_req != 0) { |
duke@435 | 684 | char buf[100]; |
duke@435 | 685 | st->print("(%s)", |
duke@435 | 686 | Deoptimization::format_trap_request(buf, sizeof(buf), |
duke@435 | 687 | trap_req)); |
duke@435 | 688 | } |
duke@435 | 689 | } |
duke@435 | 690 | |
duke@435 | 691 | void MachCallStaticJavaNode::dump_spec(outputStream *st) const { |
duke@435 | 692 | st->print("Static "); |
duke@435 | 693 | if (_name != NULL) { |
duke@435 | 694 | st->print("wrapper for: %s", _name ); |
duke@435 | 695 | dump_trap_args(st); |
duke@435 | 696 | st->print(" "); |
duke@435 | 697 | } |
duke@435 | 698 | MachCallJavaNode::dump_spec(st); |
duke@435 | 699 | } |
duke@435 | 700 | #endif |
duke@435 | 701 | |
duke@435 | 702 | //============================================================================= |
duke@435 | 703 | #ifndef PRODUCT |
duke@435 | 704 | void MachCallDynamicJavaNode::dump_spec(outputStream *st) const { |
duke@435 | 705 | st->print("Dynamic "); |
duke@435 | 706 | MachCallJavaNode::dump_spec(st); |
duke@435 | 707 | } |
duke@435 | 708 | #endif |
duke@435 | 709 | //============================================================================= |
duke@435 | 710 | uint MachCallRuntimeNode::size_of() const { return sizeof(*this); } |
duke@435 | 711 | uint MachCallRuntimeNode::cmp( const Node &n ) const { |
duke@435 | 712 | MachCallRuntimeNode &call = (MachCallRuntimeNode&)n; |
duke@435 | 713 | return MachCallNode::cmp(call) && !strcmp(_name,call._name); |
duke@435 | 714 | } |
duke@435 | 715 | #ifndef PRODUCT |
duke@435 | 716 | void MachCallRuntimeNode::dump_spec(outputStream *st) const { |
duke@435 | 717 | st->print("%s ",_name); |
duke@435 | 718 | MachCallNode::dump_spec(st); |
duke@435 | 719 | } |
duke@435 | 720 | #endif |
duke@435 | 721 | //============================================================================= |
duke@435 | 722 | // A shared JVMState for all HaltNodes. Indicates the start of debug info |
duke@435 | 723 | // is at TypeFunc::Parms. Only required for SOE register spill handling - |
duke@435 | 724 | // to indicate where the stack-slot-only debug info inputs begin. |
duke@435 | 725 | // There is no other JVM state needed here. |
duke@435 | 726 | JVMState jvms_for_throw(0); |
duke@435 | 727 | JVMState *MachHaltNode::jvms() const { |
duke@435 | 728 | return &jvms_for_throw; |
duke@435 | 729 | } |
duke@435 | 730 | |
duke@435 | 731 | //============================================================================= |
duke@435 | 732 | #ifndef PRODUCT |
duke@435 | 733 | void labelOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const { |
duke@435 | 734 | st->print("B%d", _block_num); |
duke@435 | 735 | } |
duke@435 | 736 | #endif // PRODUCT |
duke@435 | 737 | |
duke@435 | 738 | //============================================================================= |
duke@435 | 739 | #ifndef PRODUCT |
duke@435 | 740 | void methodOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const { |
duke@435 | 741 | st->print(INTPTR_FORMAT, _method); |
duke@435 | 742 | } |
duke@435 | 743 | #endif // PRODUCT |