Tue, 09 Mar 2010 20:16:19 +0100
6919934: JSR 292 needs to support x86 C1
Summary: This implements JSR 292 support for C1 x86.
Reviewed-by: never, jrose, kvn
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1999-2006 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | #include "incls/_precompiled.incl" |
duke@435 | 26 | #include "incls/_c1_InstructionPrinter.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | |
duke@435 | 29 | #ifndef PRODUCT |
duke@435 | 30 | |
duke@435 | 31 | const char* InstructionPrinter::basic_type_name(BasicType type) { |
duke@435 | 32 | switch (type) { |
duke@435 | 33 | case T_BOOLEAN: return "boolean"; |
duke@435 | 34 | case T_BYTE : return "byte"; |
duke@435 | 35 | case T_CHAR : return "char"; |
duke@435 | 36 | case T_SHORT : return "short"; |
duke@435 | 37 | case T_INT : return "int"; |
duke@435 | 38 | case T_LONG : return "long"; |
duke@435 | 39 | case T_FLOAT : return "float"; |
duke@435 | 40 | case T_DOUBLE : return "double"; |
duke@435 | 41 | case T_ARRAY : return "array"; |
duke@435 | 42 | case T_OBJECT : return "object"; |
duke@435 | 43 | default : return "???"; |
duke@435 | 44 | } |
duke@435 | 45 | } |
duke@435 | 46 | |
duke@435 | 47 | |
duke@435 | 48 | const char* InstructionPrinter::cond_name(If::Condition cond) { |
duke@435 | 49 | switch (cond) { |
duke@435 | 50 | case If::eql: return "=="; |
duke@435 | 51 | case If::neq: return "!="; |
duke@435 | 52 | case If::lss: return "<"; |
duke@435 | 53 | case If::leq: return "<="; |
duke@435 | 54 | case If::gtr: return ">"; |
duke@435 | 55 | case If::geq: return ">="; |
duke@435 | 56 | } |
duke@435 | 57 | ShouldNotReachHere(); |
duke@435 | 58 | return NULL; |
duke@435 | 59 | } |
duke@435 | 60 | |
duke@435 | 61 | |
duke@435 | 62 | const char* InstructionPrinter::op_name(Bytecodes::Code op) { |
duke@435 | 63 | switch (op) { |
duke@435 | 64 | // arithmetic ops |
duke@435 | 65 | case Bytecodes::_iadd : // fall through |
duke@435 | 66 | case Bytecodes::_ladd : // fall through |
duke@435 | 67 | case Bytecodes::_fadd : // fall through |
duke@435 | 68 | case Bytecodes::_dadd : return "+"; |
duke@435 | 69 | case Bytecodes::_isub : // fall through |
duke@435 | 70 | case Bytecodes::_lsub : // fall through |
duke@435 | 71 | case Bytecodes::_fsub : // fall through |
duke@435 | 72 | case Bytecodes::_dsub : return "-"; |
duke@435 | 73 | case Bytecodes::_imul : // fall through |
duke@435 | 74 | case Bytecodes::_lmul : // fall through |
duke@435 | 75 | case Bytecodes::_fmul : // fall through |
duke@435 | 76 | case Bytecodes::_dmul : return "*"; |
duke@435 | 77 | case Bytecodes::_idiv : // fall through |
duke@435 | 78 | case Bytecodes::_ldiv : // fall through |
duke@435 | 79 | case Bytecodes::_fdiv : // fall through |
duke@435 | 80 | case Bytecodes::_ddiv : return "/"; |
duke@435 | 81 | case Bytecodes::_irem : // fall through |
duke@435 | 82 | case Bytecodes::_lrem : // fall through |
duke@435 | 83 | case Bytecodes::_frem : // fall through |
duke@435 | 84 | case Bytecodes::_drem : return "%"; |
duke@435 | 85 | // shift ops |
duke@435 | 86 | case Bytecodes::_ishl : // fall through |
duke@435 | 87 | case Bytecodes::_lshl : return "<<"; |
duke@435 | 88 | case Bytecodes::_ishr : // fall through |
duke@435 | 89 | case Bytecodes::_lshr : return ">>"; |
duke@435 | 90 | case Bytecodes::_iushr: // fall through |
duke@435 | 91 | case Bytecodes::_lushr: return ">>>"; |
duke@435 | 92 | // logic ops |
duke@435 | 93 | case Bytecodes::_iand : // fall through |
duke@435 | 94 | case Bytecodes::_land : return "&"; |
duke@435 | 95 | case Bytecodes::_ior : // fall through |
duke@435 | 96 | case Bytecodes::_lor : return "|"; |
duke@435 | 97 | case Bytecodes::_ixor : // fall through |
duke@435 | 98 | case Bytecodes::_lxor : return "^"; |
duke@435 | 99 | } |
duke@435 | 100 | return Bytecodes::name(op); |
duke@435 | 101 | } |
duke@435 | 102 | |
duke@435 | 103 | |
duke@435 | 104 | bool InstructionPrinter::is_illegal_phi(Value v) { |
duke@435 | 105 | Phi* phi = v ? v->as_Phi() : NULL; |
duke@435 | 106 | if (phi && phi->is_illegal()) { |
duke@435 | 107 | return true; |
duke@435 | 108 | } |
duke@435 | 109 | return false; |
duke@435 | 110 | } |
duke@435 | 111 | |
duke@435 | 112 | |
duke@435 | 113 | bool InstructionPrinter::is_phi_of_block(Value v, BlockBegin* b) { |
duke@435 | 114 | Phi* phi = v ? v->as_Phi() : NULL; |
duke@435 | 115 | return phi && phi->block() == b; |
duke@435 | 116 | } |
duke@435 | 117 | |
duke@435 | 118 | |
duke@435 | 119 | void InstructionPrinter::print_klass(ciKlass* klass) { |
duke@435 | 120 | klass->name()->print_symbol_on(output()); |
duke@435 | 121 | } |
duke@435 | 122 | |
duke@435 | 123 | |
duke@435 | 124 | void InstructionPrinter::print_object(Value obj) { |
duke@435 | 125 | ValueType* type = obj->type(); |
duke@435 | 126 | if (type->as_ObjectConstant() != NULL) { |
duke@435 | 127 | ciObject* value = type->as_ObjectConstant()->value(); |
duke@435 | 128 | if (value->is_null_object()) { |
duke@435 | 129 | output()->print("null"); |
duke@435 | 130 | } else if (!value->is_loaded()) { |
duke@435 | 131 | output()->print("<unloaded object 0x%x>", value); |
duke@435 | 132 | } else if (value->is_method()) { |
duke@435 | 133 | ciMethod* m = (ciMethod*)value; |
duke@435 | 134 | output()->print("<method %s.%s>", m->holder()->name()->as_utf8(), m->name()->as_utf8()); |
duke@435 | 135 | } else { |
jrose@1424 | 136 | output()->print("<object 0x%x>", value->constant_encoding()); |
duke@435 | 137 | } |
duke@435 | 138 | } else if (type->as_InstanceConstant() != NULL) { |
jrose@1424 | 139 | output()->print("<instance 0x%x>", type->as_InstanceConstant()->value()->constant_encoding()); |
duke@435 | 140 | } else if (type->as_ArrayConstant() != NULL) { |
jrose@1424 | 141 | output()->print("<array 0x%x>", type->as_ArrayConstant()->value()->constant_encoding()); |
duke@435 | 142 | } else if (type->as_ClassConstant() != NULL) { |
duke@435 | 143 | ciInstanceKlass* klass = type->as_ClassConstant()->value(); |
duke@435 | 144 | if (!klass->is_loaded()) { |
duke@435 | 145 | output()->print("<unloaded> "); |
duke@435 | 146 | } |
duke@435 | 147 | output()->print("class "); |
duke@435 | 148 | print_klass(klass); |
duke@435 | 149 | } else { |
duke@435 | 150 | output()->print("???"); |
duke@435 | 151 | } |
duke@435 | 152 | } |
duke@435 | 153 | |
duke@435 | 154 | |
duke@435 | 155 | void InstructionPrinter::print_temp(Value value) { |
duke@435 | 156 | output()->print("%c%d", value->type()->tchar(), value->id()); |
duke@435 | 157 | } |
duke@435 | 158 | |
duke@435 | 159 | |
duke@435 | 160 | void InstructionPrinter::print_field(AccessField* field) { |
duke@435 | 161 | print_value(field->obj()); |
duke@435 | 162 | output()->print("._%d", field->offset()); |
duke@435 | 163 | } |
duke@435 | 164 | |
duke@435 | 165 | |
duke@435 | 166 | void InstructionPrinter::print_indexed(AccessIndexed* indexed) { |
duke@435 | 167 | print_value(indexed->array()); |
duke@435 | 168 | output()->put('['); |
duke@435 | 169 | print_value(indexed->index()); |
duke@435 | 170 | output()->put(']'); |
duke@435 | 171 | } |
duke@435 | 172 | |
duke@435 | 173 | |
duke@435 | 174 | void InstructionPrinter::print_monitor(AccessMonitor* monitor) { |
duke@435 | 175 | output()->print("monitor[%d](", monitor->monitor_no()); |
duke@435 | 176 | print_value(monitor->obj()); |
duke@435 | 177 | output()->put(')'); |
duke@435 | 178 | } |
duke@435 | 179 | |
duke@435 | 180 | |
duke@435 | 181 | void InstructionPrinter::print_op2(Op2* instr) { |
duke@435 | 182 | print_value(instr->x()); |
duke@435 | 183 | output()->print(" %s ", op_name(instr->op())); |
duke@435 | 184 | print_value(instr->y()); |
duke@435 | 185 | } |
duke@435 | 186 | |
duke@435 | 187 | |
duke@435 | 188 | void InstructionPrinter::print_value(Value value) { |
duke@435 | 189 | if (value == NULL) { |
duke@435 | 190 | output()->print("NULL"); |
duke@435 | 191 | } else { |
duke@435 | 192 | print_temp(value); |
duke@435 | 193 | } |
duke@435 | 194 | } |
duke@435 | 195 | |
duke@435 | 196 | |
duke@435 | 197 | void InstructionPrinter::print_instr(Instruction* instr) { |
duke@435 | 198 | instr->visit(this); |
duke@435 | 199 | } |
duke@435 | 200 | |
duke@435 | 201 | |
duke@435 | 202 | void InstructionPrinter::print_stack(ValueStack* stack) { |
duke@435 | 203 | int start_position = output()->position(); |
duke@435 | 204 | if (stack->stack_is_empty()) { |
duke@435 | 205 | output()->print("empty stack"); |
duke@435 | 206 | } else { |
duke@435 | 207 | output()->print("stack ["); |
duke@435 | 208 | for (int i = 0; i < stack->stack_size();) { |
duke@435 | 209 | if (i > 0) output()->print(", "); |
duke@435 | 210 | output()->print("%d:", i); |
duke@435 | 211 | Value value = stack->stack_at_inc(i); |
duke@435 | 212 | print_value(value); |
duke@435 | 213 | Phi* phi = value->as_Phi(); |
duke@435 | 214 | if (phi != NULL) { |
duke@435 | 215 | if (phi->operand()->is_valid()) { |
duke@435 | 216 | output()->print(" "); |
duke@435 | 217 | phi->operand()->print(output()); |
duke@435 | 218 | } |
duke@435 | 219 | } |
duke@435 | 220 | } |
duke@435 | 221 | output()->put(']'); |
duke@435 | 222 | } |
duke@435 | 223 | if (!stack->no_active_locks()) { |
duke@435 | 224 | // print out the lines on the line below this |
duke@435 | 225 | // one at the same indentation level. |
duke@435 | 226 | output()->cr(); |
duke@435 | 227 | fill_to(start_position, ' '); |
duke@435 | 228 | output()->print("locks ["); |
duke@435 | 229 | for (int i = i = 0; i < stack->locks_size(); i++) { |
duke@435 | 230 | Value t = stack->lock_at(i); |
duke@435 | 231 | if (i > 0) output()->print(", "); |
duke@435 | 232 | output()->print("%d:", i); |
duke@435 | 233 | if (t == NULL) { |
duke@435 | 234 | // synchronized methods push null on the lock stack |
duke@435 | 235 | output()->print("this"); |
duke@435 | 236 | } else { |
duke@435 | 237 | print_value(t); |
duke@435 | 238 | } |
duke@435 | 239 | } |
duke@435 | 240 | output()->print("]"); |
duke@435 | 241 | } |
duke@435 | 242 | } |
duke@435 | 243 | |
duke@435 | 244 | |
duke@435 | 245 | void InstructionPrinter::print_inline_level(BlockBegin* block) { |
duke@435 | 246 | output()->print_cr("inlining depth %d", block->scope()->level()); |
duke@435 | 247 | } |
duke@435 | 248 | |
duke@435 | 249 | |
duke@435 | 250 | void InstructionPrinter::print_unsafe_op(UnsafeOp* op, const char* name) { |
duke@435 | 251 | output()->print(name); |
duke@435 | 252 | output()->print(".("); |
duke@435 | 253 | } |
duke@435 | 254 | |
duke@435 | 255 | void InstructionPrinter::print_unsafe_raw_op(UnsafeRawOp* op, const char* name) { |
duke@435 | 256 | print_unsafe_op(op, name); |
duke@435 | 257 | output()->print("base "); |
duke@435 | 258 | print_value(op->base()); |
duke@435 | 259 | if (op->has_index()) { |
duke@435 | 260 | output()->print(", index "); print_value(op->index()); |
duke@435 | 261 | output()->print(", log2_scale %d", op->log2_scale()); |
duke@435 | 262 | } |
duke@435 | 263 | } |
duke@435 | 264 | |
duke@435 | 265 | |
duke@435 | 266 | void InstructionPrinter::print_unsafe_object_op(UnsafeObjectOp* op, const char* name) { |
duke@435 | 267 | print_unsafe_op(op, name); |
duke@435 | 268 | print_value(op->object()); |
duke@435 | 269 | output()->print(", "); |
duke@435 | 270 | print_value(op->offset()); |
duke@435 | 271 | } |
duke@435 | 272 | |
duke@435 | 273 | |
duke@435 | 274 | void InstructionPrinter::print_phi(int i, Value v, BlockBegin* b) { |
duke@435 | 275 | Phi* phi = v->as_Phi(); |
duke@435 | 276 | output()->print("%2d ", i); |
duke@435 | 277 | print_value(v); |
duke@435 | 278 | // print phi operands |
duke@435 | 279 | if (phi && phi->block() == b) { |
duke@435 | 280 | output()->print(" ["); |
duke@435 | 281 | for (int j = 0; j < phi->operand_count(); j ++) { |
duke@435 | 282 | output()->print(" "); |
duke@435 | 283 | Value opd = phi->operand_at(j); |
duke@435 | 284 | if (opd) print_value(opd); |
duke@435 | 285 | else output()->print("NULL"); |
duke@435 | 286 | } |
duke@435 | 287 | output()->print("] "); |
duke@435 | 288 | } |
duke@435 | 289 | print_alias(v); |
duke@435 | 290 | } |
duke@435 | 291 | |
duke@435 | 292 | |
duke@435 | 293 | void InstructionPrinter::print_alias(Value v) { |
duke@435 | 294 | if (v != v->subst()) { |
duke@435 | 295 | output()->print("alias "); print_value(v->subst()); |
duke@435 | 296 | } |
duke@435 | 297 | } |
duke@435 | 298 | |
duke@435 | 299 | |
duke@435 | 300 | void InstructionPrinter::fill_to(int pos, char filler) { |
duke@435 | 301 | while (output()->position() < pos) output()->put(filler); |
duke@435 | 302 | } |
duke@435 | 303 | |
duke@435 | 304 | |
duke@435 | 305 | void InstructionPrinter::print_head() { |
duke@435 | 306 | const char filler = '_'; |
duke@435 | 307 | fill_to(bci_pos , filler); output()->print("bci" ); |
duke@435 | 308 | fill_to(use_pos , filler); output()->print("use" ); |
duke@435 | 309 | fill_to(temp_pos , filler); output()->print("tid" ); |
duke@435 | 310 | fill_to(instr_pos, filler); output()->print("instr"); |
duke@435 | 311 | fill_to(end_pos , filler); |
duke@435 | 312 | output()->cr(); |
duke@435 | 313 | } |
duke@435 | 314 | |
duke@435 | 315 | |
duke@435 | 316 | void InstructionPrinter::print_line(Instruction* instr) { |
duke@435 | 317 | // print instruction data on one line |
duke@435 | 318 | if (instr->is_pinned()) output()->put('.'); |
duke@435 | 319 | fill_to(bci_pos ); output()->print("%d", instr->bci()); |
duke@435 | 320 | fill_to(use_pos ); output()->print("%d", instr->use_count()); |
duke@435 | 321 | fill_to(temp_pos ); print_temp(instr); |
duke@435 | 322 | fill_to(instr_pos); print_instr(instr); |
duke@435 | 323 | output()->cr(); |
duke@435 | 324 | // add a line for StateSplit instructions w/ non-empty stacks |
duke@435 | 325 | // (make it robust so we can print incomplete instructions) |
duke@435 | 326 | StateSplit* split = instr->as_StateSplit(); |
duke@435 | 327 | if (split != NULL && split->state() != NULL && !split->state()->stack_is_empty()) { |
duke@435 | 328 | fill_to(instr_pos); print_stack(split->state()); |
duke@435 | 329 | output()->cr(); |
duke@435 | 330 | } |
duke@435 | 331 | } |
duke@435 | 332 | |
duke@435 | 333 | |
duke@435 | 334 | void InstructionPrinter::do_Phi(Phi* x) { |
duke@435 | 335 | output()->print("phi function"); // make that more detailed later |
duke@435 | 336 | if (x->is_illegal()) |
duke@435 | 337 | output()->print(" (illegal)"); |
duke@435 | 338 | } |
duke@435 | 339 | |
duke@435 | 340 | |
duke@435 | 341 | void InstructionPrinter::do_Local(Local* x) { |
duke@435 | 342 | output()->print("local[index %d]", x->java_index()); |
duke@435 | 343 | } |
duke@435 | 344 | |
duke@435 | 345 | |
duke@435 | 346 | void InstructionPrinter::do_Constant(Constant* x) { |
duke@435 | 347 | ValueType* t = x->type(); |
duke@435 | 348 | switch (t->tag()) { |
duke@435 | 349 | case intTag : output()->print("%d" , t->as_IntConstant ()->value()); break; |
duke@435 | 350 | case longTag : output()->print(os::jlong_format_specifier(), t->as_LongConstant()->value()); output()->print("L"); break; |
duke@435 | 351 | case floatTag : output()->print("%g" , t->as_FloatConstant ()->value()); break; |
duke@435 | 352 | case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value()); break; |
duke@435 | 353 | case objectTag : print_object(x); break; |
duke@435 | 354 | case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break; |
duke@435 | 355 | default : output()->print("???"); break; |
duke@435 | 356 | } |
duke@435 | 357 | } |
duke@435 | 358 | |
duke@435 | 359 | |
duke@435 | 360 | void InstructionPrinter::do_LoadField(LoadField* x) { |
duke@435 | 361 | print_field(x); |
duke@435 | 362 | output()->print(" (%c)", type2char(x->field()->type()->basic_type())); |
duke@435 | 363 | } |
duke@435 | 364 | |
duke@435 | 365 | |
duke@435 | 366 | void InstructionPrinter::do_StoreField(StoreField* x) { |
duke@435 | 367 | print_field(x); |
duke@435 | 368 | output()->print(" := "); |
duke@435 | 369 | print_value(x->value()); |
duke@435 | 370 | output()->print(" (%c)", type2char(x->field()->type()->basic_type())); |
duke@435 | 371 | } |
duke@435 | 372 | |
duke@435 | 373 | |
duke@435 | 374 | void InstructionPrinter::do_ArrayLength(ArrayLength* x) { |
duke@435 | 375 | print_value(x->array()); |
duke@435 | 376 | output()->print(".length"); |
duke@435 | 377 | } |
duke@435 | 378 | |
duke@435 | 379 | |
duke@435 | 380 | void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) { |
duke@435 | 381 | print_indexed(x); |
duke@435 | 382 | output()->print(" (%c)", type2char(x->elt_type())); |
duke@435 | 383 | } |
duke@435 | 384 | |
duke@435 | 385 | |
duke@435 | 386 | void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) { |
duke@435 | 387 | print_indexed(x); |
duke@435 | 388 | output()->print(" := "); |
duke@435 | 389 | print_value(x->value()); |
duke@435 | 390 | output()->print(" (%c)", type2char(x->elt_type())); |
duke@435 | 391 | } |
duke@435 | 392 | |
duke@435 | 393 | void InstructionPrinter::do_NegateOp(NegateOp* x) { |
duke@435 | 394 | output()->put('-'); |
duke@435 | 395 | print_value(x->x()); |
duke@435 | 396 | } |
duke@435 | 397 | |
duke@435 | 398 | |
duke@435 | 399 | void InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) { |
duke@435 | 400 | print_op2(x); |
duke@435 | 401 | } |
duke@435 | 402 | |
duke@435 | 403 | |
duke@435 | 404 | void InstructionPrinter::do_ShiftOp(ShiftOp* x) { |
duke@435 | 405 | print_op2(x); |
duke@435 | 406 | } |
duke@435 | 407 | |
duke@435 | 408 | |
duke@435 | 409 | void InstructionPrinter::do_LogicOp(LogicOp* x) { |
duke@435 | 410 | print_op2(x); |
duke@435 | 411 | } |
duke@435 | 412 | |
duke@435 | 413 | |
duke@435 | 414 | void InstructionPrinter::do_CompareOp(CompareOp* x) { |
duke@435 | 415 | print_op2(x); |
duke@435 | 416 | } |
duke@435 | 417 | |
duke@435 | 418 | |
duke@435 | 419 | void InstructionPrinter::do_IfOp(IfOp* x) { |
duke@435 | 420 | print_value(x->x()); |
duke@435 | 421 | output()->print(" %s ", cond_name(x->cond())); |
duke@435 | 422 | print_value(x->y()); |
duke@435 | 423 | output()->print(" ? "); |
duke@435 | 424 | print_value(x->tval()); |
duke@435 | 425 | output()->print(" : "); |
duke@435 | 426 | print_value(x->fval()); |
duke@435 | 427 | } |
duke@435 | 428 | |
duke@435 | 429 | |
duke@435 | 430 | void InstructionPrinter::do_Convert(Convert* x) { |
duke@435 | 431 | output()->print("%s(", Bytecodes::name(x->op())); |
duke@435 | 432 | print_value(x->value()); |
duke@435 | 433 | output()->put(')'); |
duke@435 | 434 | } |
duke@435 | 435 | |
duke@435 | 436 | |
duke@435 | 437 | void InstructionPrinter::do_NullCheck(NullCheck* x) { |
duke@435 | 438 | output()->print("null_check("); |
duke@435 | 439 | print_value(x->obj()); |
duke@435 | 440 | output()->put(')'); |
duke@435 | 441 | if (!x->can_trap()) { |
duke@435 | 442 | output()->print(" (eliminated)"); |
duke@435 | 443 | } |
duke@435 | 444 | } |
duke@435 | 445 | |
duke@435 | 446 | |
duke@435 | 447 | void InstructionPrinter::do_Invoke(Invoke* x) { |
duke@435 | 448 | if (x->receiver() != NULL) { |
duke@435 | 449 | print_value(x->receiver()); |
duke@435 | 450 | output()->print("."); |
duke@435 | 451 | } |
duke@435 | 452 | |
duke@435 | 453 | output()->print("%s(", Bytecodes::name(x->code())); |
duke@435 | 454 | for (int i = 0; i < x->number_of_arguments(); i++) { |
duke@435 | 455 | if (i > 0) output()->print(", "); |
duke@435 | 456 | print_value(x->argument_at(i)); |
duke@435 | 457 | } |
duke@435 | 458 | output()->print_cr(")"); |
duke@435 | 459 | fill_to(instr_pos); |
duke@435 | 460 | output()->print("%s.%s%s", |
duke@435 | 461 | x->target()->holder()->name()->as_utf8(), |
duke@435 | 462 | x->target()->name()->as_utf8(), |
duke@435 | 463 | x->target()->signature()->as_symbol()->as_utf8()); |
duke@435 | 464 | } |
duke@435 | 465 | |
duke@435 | 466 | |
duke@435 | 467 | void InstructionPrinter::do_NewInstance(NewInstance* x) { |
duke@435 | 468 | output()->print("new instance "); |
duke@435 | 469 | print_klass(x->klass()); |
duke@435 | 470 | } |
duke@435 | 471 | |
duke@435 | 472 | |
duke@435 | 473 | void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) { |
duke@435 | 474 | output()->print("new %s array [", basic_type_name(x->elt_type())); |
duke@435 | 475 | print_value(x->length()); |
duke@435 | 476 | output()->put(']'); |
duke@435 | 477 | } |
duke@435 | 478 | |
duke@435 | 479 | |
duke@435 | 480 | void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) { |
duke@435 | 481 | output()->print("new object array ["); |
duke@435 | 482 | print_value(x->length()); |
duke@435 | 483 | output()->print("] "); |
duke@435 | 484 | print_klass(x->klass()); |
duke@435 | 485 | } |
duke@435 | 486 | |
duke@435 | 487 | |
duke@435 | 488 | void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) { |
duke@435 | 489 | output()->print("new multi array ["); |
duke@435 | 490 | Values* dims = x->dims(); |
duke@435 | 491 | for (int i = 0; i < dims->length(); i++) { |
duke@435 | 492 | if (i > 0) output()->print(", "); |
duke@435 | 493 | print_value(dims->at(i)); |
duke@435 | 494 | } |
duke@435 | 495 | output()->print("] "); |
duke@435 | 496 | print_klass(x->klass()); |
duke@435 | 497 | } |
duke@435 | 498 | |
duke@435 | 499 | |
duke@435 | 500 | void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) { |
duke@435 | 501 | output()->print("enter "); |
duke@435 | 502 | print_monitor(x); |
duke@435 | 503 | } |
duke@435 | 504 | |
duke@435 | 505 | |
duke@435 | 506 | void InstructionPrinter::do_MonitorExit(MonitorExit* x) { |
duke@435 | 507 | output()->print("exit "); |
duke@435 | 508 | print_monitor(x); |
duke@435 | 509 | } |
duke@435 | 510 | |
duke@435 | 511 | |
duke@435 | 512 | void InstructionPrinter::do_Intrinsic(Intrinsic* x) { |
duke@435 | 513 | const char* name = vmIntrinsics::name_at(x->id()); |
duke@435 | 514 | if (name[0] == '_') name++; // strip leading bug from _hashCode, etc. |
duke@435 | 515 | const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id())); |
duke@435 | 516 | if (strchr(name, '_') == NULL) { |
duke@435 | 517 | kname = NULL; |
duke@435 | 518 | } else { |
duke@435 | 519 | const char* kptr = strrchr(kname, '/'); |
duke@435 | 520 | if (kptr != NULL) kname = kptr + 1; |
duke@435 | 521 | } |
duke@435 | 522 | if (kname == NULL) |
duke@435 | 523 | output()->print("%s(", name); |
duke@435 | 524 | else |
duke@435 | 525 | output()->print("%s.%s(", kname, name); |
duke@435 | 526 | for (int i = 0; i < x->number_of_arguments(); i++) { |
duke@435 | 527 | if (i > 0) output()->print(", "); |
duke@435 | 528 | print_value(x->argument_at(i)); |
duke@435 | 529 | } |
duke@435 | 530 | output()->put(')'); |
duke@435 | 531 | } |
duke@435 | 532 | |
duke@435 | 533 | |
duke@435 | 534 | void InstructionPrinter::do_BlockBegin(BlockBegin* x) { |
duke@435 | 535 | // print block id |
duke@435 | 536 | BlockEnd* end = x->end(); |
duke@435 | 537 | output()->print("B%d ", x->block_id()); |
duke@435 | 538 | |
duke@435 | 539 | // print flags |
duke@435 | 540 | bool printed_flag = false; |
duke@435 | 541 | if (x->is_set(BlockBegin::std_entry_flag)) { |
duke@435 | 542 | if (!printed_flag) output()->print("("); |
duke@435 | 543 | output()->print("S"); printed_flag = true; |
duke@435 | 544 | } |
duke@435 | 545 | if (x->is_set(BlockBegin::osr_entry_flag)) { |
duke@435 | 546 | if (!printed_flag) output()->print("("); |
duke@435 | 547 | output()->print("O"); printed_flag = true; |
duke@435 | 548 | } |
duke@435 | 549 | if (x->is_set(BlockBegin::exception_entry_flag)) { |
duke@435 | 550 | if (!printed_flag) output()->print("("); |
duke@435 | 551 | output()->print("E"); printed_flag = true; |
duke@435 | 552 | } |
duke@435 | 553 | if (x->is_set(BlockBegin::subroutine_entry_flag)) { |
duke@435 | 554 | if (!printed_flag) output()->print("("); |
duke@435 | 555 | output()->print("s"); printed_flag = true; |
duke@435 | 556 | } |
duke@435 | 557 | if (x->is_set(BlockBegin::parser_loop_header_flag)) { |
duke@435 | 558 | if (!printed_flag) output()->print("("); |
duke@435 | 559 | output()->print("LH"); printed_flag = true; |
duke@435 | 560 | } |
duke@435 | 561 | if (x->is_set(BlockBegin::backward_branch_target_flag)) { |
duke@435 | 562 | if (!printed_flag) output()->print("("); |
duke@435 | 563 | output()->print("b"); printed_flag = true; |
duke@435 | 564 | } |
duke@435 | 565 | if (x->is_set(BlockBegin::was_visited_flag)) { |
duke@435 | 566 | if (!printed_flag) output()->print("("); |
duke@435 | 567 | output()->print("V"); printed_flag = true; |
duke@435 | 568 | } |
duke@435 | 569 | if (printed_flag) output()->print(") "); |
duke@435 | 570 | |
duke@435 | 571 | // print block bci range |
duke@435 | 572 | output()->print("[%d, %d]", x->bci(), (end == NULL ? -1 : end->bci())); |
duke@435 | 573 | |
duke@435 | 574 | // print block successors |
duke@435 | 575 | if (end != NULL && end->number_of_sux() > 0) { |
duke@435 | 576 | output()->print(" ->"); |
duke@435 | 577 | for (int i = 0; i < end->number_of_sux(); i++) { |
duke@435 | 578 | output()->print(" B%d", end->sux_at(i)->block_id()); |
duke@435 | 579 | } |
duke@435 | 580 | } |
duke@435 | 581 | // print exception handlers |
duke@435 | 582 | if (x->number_of_exception_handlers() > 0) { |
duke@435 | 583 | output()->print(" (xhandlers "); |
duke@435 | 584 | for (int i = 0; i < x->number_of_exception_handlers(); i++) { |
duke@435 | 585 | if (i > 0) output()->print(" "); |
duke@435 | 586 | output()->print("B%d", x->exception_handler_at(i)->block_id()); |
duke@435 | 587 | } |
duke@435 | 588 | output()->put(')'); |
duke@435 | 589 | } |
duke@435 | 590 | |
duke@435 | 591 | // print dominator block |
duke@435 | 592 | if (x->dominator() != NULL) { |
duke@435 | 593 | output()->print(" dom B%d", x->dominator()->block_id()); |
duke@435 | 594 | } |
duke@435 | 595 | |
duke@435 | 596 | // print predecessors and successors |
duke@435 | 597 | if (x->successors()->length() > 0) { |
duke@435 | 598 | output()->print(" sux:"); |
duke@435 | 599 | for (int i = 0; i < x->successors()->length(); i ++) { |
duke@435 | 600 | output()->print(" B%d", x->successors()->at(i)->block_id()); |
duke@435 | 601 | } |
duke@435 | 602 | } |
duke@435 | 603 | |
duke@435 | 604 | if (x->number_of_preds() > 0) { |
duke@435 | 605 | output()->print(" pred:"); |
duke@435 | 606 | for (int i = 0; i < x->number_of_preds(); i ++) { |
duke@435 | 607 | output()->print(" B%d", x->pred_at(i)->block_id()); |
duke@435 | 608 | } |
duke@435 | 609 | } |
duke@435 | 610 | |
duke@435 | 611 | if (!_print_phis) { |
duke@435 | 612 | return; |
duke@435 | 613 | } |
duke@435 | 614 | |
duke@435 | 615 | // print phi functions |
duke@435 | 616 | bool has_phis_in_locals = false; |
duke@435 | 617 | bool has_phis_on_stack = false; |
duke@435 | 618 | |
duke@435 | 619 | if (x->end() && x->end()->state()) { |
duke@435 | 620 | ValueStack* state = x->state(); |
duke@435 | 621 | |
duke@435 | 622 | int i = 0; |
duke@435 | 623 | while (!has_phis_on_stack && i < state->stack_size()) { |
duke@435 | 624 | Value v = state->stack_at_inc(i); |
duke@435 | 625 | has_phis_on_stack = is_phi_of_block(v, x); |
duke@435 | 626 | } |
duke@435 | 627 | |
duke@435 | 628 | do { |
duke@435 | 629 | for (i = 0; !has_phis_in_locals && i < state->locals_size();) { |
duke@435 | 630 | Value v = state->local_at(i); |
duke@435 | 631 | has_phis_in_locals = is_phi_of_block(v, x); |
duke@435 | 632 | // also ignore illegal HiWords |
duke@435 | 633 | if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++; |
duke@435 | 634 | } |
duke@435 | 635 | state = state->caller_state(); |
duke@435 | 636 | } while (state != NULL); |
duke@435 | 637 | |
duke@435 | 638 | } |
duke@435 | 639 | |
duke@435 | 640 | // print values in locals |
duke@435 | 641 | if (has_phis_in_locals) { |
duke@435 | 642 | output()->cr(); output()->print_cr("Locals:"); |
duke@435 | 643 | |
duke@435 | 644 | ValueStack* state = x->state(); |
duke@435 | 645 | do { |
duke@435 | 646 | for (int i = 0; i < state->locals_size();) { |
duke@435 | 647 | Value v = state->local_at(i); |
duke@435 | 648 | if (v) { |
duke@435 | 649 | print_phi(i, v, x); output()->cr(); |
duke@435 | 650 | // also ignore illegal HiWords |
duke@435 | 651 | i += (v->type()->is_illegal() ? 1 : v->type()->size()); |
duke@435 | 652 | } else { |
duke@435 | 653 | i ++; |
duke@435 | 654 | } |
duke@435 | 655 | } |
duke@435 | 656 | output()->cr(); |
duke@435 | 657 | state = state->caller_state(); |
duke@435 | 658 | } while (state != NULL); |
duke@435 | 659 | } |
duke@435 | 660 | |
duke@435 | 661 | // print values on stack |
duke@435 | 662 | if (has_phis_on_stack) { |
duke@435 | 663 | output()->print_cr("Stack:"); |
duke@435 | 664 | int i = 0; |
duke@435 | 665 | while (i < x->state()->stack_size()) { |
duke@435 | 666 | int o = i; |
duke@435 | 667 | Value v = x->state()->stack_at_inc(i); |
duke@435 | 668 | if (v) { |
duke@435 | 669 | print_phi(o, v, x); output()->cr(); |
duke@435 | 670 | } |
duke@435 | 671 | } |
duke@435 | 672 | } |
duke@435 | 673 | } |
duke@435 | 674 | |
duke@435 | 675 | |
duke@435 | 676 | void InstructionPrinter::do_CheckCast(CheckCast* x) { |
duke@435 | 677 | output()->print("checkcast("); |
duke@435 | 678 | print_value(x->obj()); |
duke@435 | 679 | output()->print(") "); |
duke@435 | 680 | print_klass(x->klass()); |
duke@435 | 681 | } |
duke@435 | 682 | |
duke@435 | 683 | |
duke@435 | 684 | void InstructionPrinter::do_InstanceOf(InstanceOf* x) { |
duke@435 | 685 | output()->print("instanceof("); |
duke@435 | 686 | print_value(x->obj()); |
duke@435 | 687 | output()->print(") "); |
duke@435 | 688 | print_klass(x->klass()); |
duke@435 | 689 | } |
duke@435 | 690 | |
duke@435 | 691 | |
duke@435 | 692 | void InstructionPrinter::do_Goto(Goto* x) { |
duke@435 | 693 | output()->print("goto B%d", x->default_sux()->block_id()); |
duke@435 | 694 | if (x->is_safepoint()) output()->print(" (safepoint)"); |
duke@435 | 695 | } |
duke@435 | 696 | |
duke@435 | 697 | |
duke@435 | 698 | void InstructionPrinter::do_If(If* x) { |
duke@435 | 699 | output()->print("if "); |
duke@435 | 700 | print_value(x->x()); |
duke@435 | 701 | output()->print(" %s ", cond_name(x->cond())); |
duke@435 | 702 | print_value(x->y()); |
duke@435 | 703 | output()->print(" then B%d else B%d", x->sux_at(0)->block_id(), x->sux_at(1)->block_id()); |
duke@435 | 704 | if (x->is_safepoint()) output()->print(" (safepoint)"); |
duke@435 | 705 | } |
duke@435 | 706 | |
duke@435 | 707 | |
duke@435 | 708 | void InstructionPrinter::do_IfInstanceOf(IfInstanceOf* x) { |
duke@435 | 709 | output()->print("<IfInstanceOf>"); |
duke@435 | 710 | } |
duke@435 | 711 | |
duke@435 | 712 | |
duke@435 | 713 | void InstructionPrinter::do_TableSwitch(TableSwitch* x) { |
duke@435 | 714 | output()->print("tableswitch "); |
duke@435 | 715 | if (x->is_safepoint()) output()->print("(safepoint) "); |
duke@435 | 716 | print_value(x->tag()); |
duke@435 | 717 | output()->cr(); |
duke@435 | 718 | int l = x->length(); |
duke@435 | 719 | for (int i = 0; i < l; i++) { |
duke@435 | 720 | fill_to(instr_pos); |
duke@435 | 721 | output()->print_cr("case %5d: B%d", x->lo_key() + i, x->sux_at(i)->block_id()); |
duke@435 | 722 | } |
duke@435 | 723 | fill_to(instr_pos); |
duke@435 | 724 | output()->print("default : B%d", x->default_sux()->block_id()); |
duke@435 | 725 | } |
duke@435 | 726 | |
duke@435 | 727 | |
duke@435 | 728 | void InstructionPrinter::do_LookupSwitch(LookupSwitch* x) { |
duke@435 | 729 | output()->print("lookupswitch "); |
duke@435 | 730 | if (x->is_safepoint()) output()->print("(safepoint) "); |
duke@435 | 731 | print_value(x->tag()); |
duke@435 | 732 | output()->cr(); |
duke@435 | 733 | int l = x->length(); |
duke@435 | 734 | for (int i = 0; i < l; i++) { |
duke@435 | 735 | fill_to(instr_pos); |
duke@435 | 736 | output()->print_cr("case %5d: B%d", x->key_at(i), x->sux_at(i)->block_id()); |
duke@435 | 737 | } |
duke@435 | 738 | fill_to(instr_pos); |
duke@435 | 739 | output()->print("default : B%d", x->default_sux()->block_id()); |
duke@435 | 740 | } |
duke@435 | 741 | |
duke@435 | 742 | |
duke@435 | 743 | void InstructionPrinter::do_Return(Return* x) { |
duke@435 | 744 | if (x->result() == NULL) { |
duke@435 | 745 | output()->print("return"); |
duke@435 | 746 | } else { |
duke@435 | 747 | output()->print("%creturn ", x->type()->tchar()); |
duke@435 | 748 | print_value(x->result()); |
duke@435 | 749 | } |
duke@435 | 750 | } |
duke@435 | 751 | |
duke@435 | 752 | |
duke@435 | 753 | void InstructionPrinter::do_Throw(Throw* x) { |
duke@435 | 754 | output()->print("throw "); |
duke@435 | 755 | print_value(x->exception()); |
duke@435 | 756 | } |
duke@435 | 757 | |
duke@435 | 758 | |
duke@435 | 759 | void InstructionPrinter::do_Base(Base* x) { |
duke@435 | 760 | output()->print("std entry B%d", x->std_entry()->block_id()); |
duke@435 | 761 | if (x->number_of_sux() > 1) { |
duke@435 | 762 | output()->print(" osr entry B%d", x->osr_entry()->block_id()); |
duke@435 | 763 | } |
duke@435 | 764 | } |
duke@435 | 765 | |
duke@435 | 766 | |
duke@435 | 767 | void InstructionPrinter::do_OsrEntry(OsrEntry* x) { |
duke@435 | 768 | output()->print("osr entry"); |
duke@435 | 769 | } |
duke@435 | 770 | |
duke@435 | 771 | |
duke@435 | 772 | void InstructionPrinter::do_ExceptionObject(ExceptionObject* x) { |
duke@435 | 773 | output()->print("incoming exception"); |
duke@435 | 774 | } |
duke@435 | 775 | |
duke@435 | 776 | |
duke@435 | 777 | void InstructionPrinter::do_RoundFP(RoundFP* x) { |
duke@435 | 778 | output()->print("round_fp "); |
duke@435 | 779 | print_value(x->input()); |
duke@435 | 780 | } |
duke@435 | 781 | |
duke@435 | 782 | |
duke@435 | 783 | void InstructionPrinter::do_UnsafeGetRaw(UnsafeGetRaw* x) { |
duke@435 | 784 | print_unsafe_raw_op(x, "UnsafeGetRaw"); |
duke@435 | 785 | output()->put(')'); |
duke@435 | 786 | } |
duke@435 | 787 | |
duke@435 | 788 | |
duke@435 | 789 | void InstructionPrinter::do_UnsafePutRaw(UnsafePutRaw* x) { |
duke@435 | 790 | print_unsafe_raw_op(x, "UnsafePutRaw"); |
duke@435 | 791 | output()->print(", value "); |
duke@435 | 792 | print_value(x->value()); |
duke@435 | 793 | output()->put(')'); |
duke@435 | 794 | } |
duke@435 | 795 | |
duke@435 | 796 | |
duke@435 | 797 | void InstructionPrinter::do_UnsafeGetObject(UnsafeGetObject* x) { |
duke@435 | 798 | print_unsafe_object_op(x, "UnsafeGetObject"); |
duke@435 | 799 | output()->put(')'); |
duke@435 | 800 | } |
duke@435 | 801 | |
duke@435 | 802 | |
duke@435 | 803 | void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) { |
duke@435 | 804 | print_unsafe_object_op(x, "UnsafePutObject"); |
duke@435 | 805 | output()->print(", value "); |
duke@435 | 806 | print_value(x->value()); |
duke@435 | 807 | output()->put(')'); |
duke@435 | 808 | } |
duke@435 | 809 | |
duke@435 | 810 | |
duke@435 | 811 | void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) { |
duke@435 | 812 | print_unsafe_object_op(x, "UnsafePrefetchRead"); |
duke@435 | 813 | output()->put(')'); |
duke@435 | 814 | } |
duke@435 | 815 | |
duke@435 | 816 | |
duke@435 | 817 | void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { |
duke@435 | 818 | print_unsafe_object_op(x, "UnsafePrefetchWrite"); |
duke@435 | 819 | output()->put(')'); |
duke@435 | 820 | } |
duke@435 | 821 | |
duke@435 | 822 | |
duke@435 | 823 | void InstructionPrinter::do_ProfileCall(ProfileCall* x) { |
duke@435 | 824 | output()->print("profile "); |
duke@435 | 825 | print_value(x->recv()); |
duke@435 | 826 | output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8()); |
duke@435 | 827 | if (x->known_holder() != NULL) { |
duke@435 | 828 | output()->print(", "); |
duke@435 | 829 | print_klass(x->known_holder()); |
duke@435 | 830 | } |
duke@435 | 831 | output()->put(')'); |
duke@435 | 832 | } |
duke@435 | 833 | |
duke@435 | 834 | |
duke@435 | 835 | void InstructionPrinter::do_ProfileCounter(ProfileCounter* x) { |
duke@435 | 836 | |
duke@435 | 837 | ObjectConstant* oc = x->mdo()->type()->as_ObjectConstant(); |
duke@435 | 838 | if (oc != NULL && oc->value()->is_method() && |
duke@435 | 839 | x->offset() == methodOopDesc::interpreter_invocation_counter_offset_in_bytes()) { |
duke@435 | 840 | print_value(x->mdo()); |
duke@435 | 841 | output()->print(".interpreter_invocation_count += %d", x->increment()); |
duke@435 | 842 | } else { |
duke@435 | 843 | output()->print("counter ["); |
duke@435 | 844 | print_value(x->mdo()); |
duke@435 | 845 | output()->print(" + %d] += %d", x->offset(), x->increment()); |
duke@435 | 846 | } |
duke@435 | 847 | } |
duke@435 | 848 | |
duke@435 | 849 | |
duke@435 | 850 | #endif // PRODUCT |