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