1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/c1/c1_InstructionPrinter.cpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,850 @@ 1.4 +/* 1.5 + * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "incls/_precompiled.incl" 1.29 +#include "incls/_c1_InstructionPrinter.cpp.incl" 1.30 + 1.31 + 1.32 +#ifndef PRODUCT 1.33 + 1.34 +const char* InstructionPrinter::basic_type_name(BasicType type) { 1.35 + switch (type) { 1.36 + case T_BOOLEAN: return "boolean"; 1.37 + case T_BYTE : return "byte"; 1.38 + case T_CHAR : return "char"; 1.39 + case T_SHORT : return "short"; 1.40 + case T_INT : return "int"; 1.41 + case T_LONG : return "long"; 1.42 + case T_FLOAT : return "float"; 1.43 + case T_DOUBLE : return "double"; 1.44 + case T_ARRAY : return "array"; 1.45 + case T_OBJECT : return "object"; 1.46 + default : return "???"; 1.47 + } 1.48 +} 1.49 + 1.50 + 1.51 +const char* InstructionPrinter::cond_name(If::Condition cond) { 1.52 + switch (cond) { 1.53 + case If::eql: return "=="; 1.54 + case If::neq: return "!="; 1.55 + case If::lss: return "<"; 1.56 + case If::leq: return "<="; 1.57 + case If::gtr: return ">"; 1.58 + case If::geq: return ">="; 1.59 + } 1.60 + ShouldNotReachHere(); 1.61 + return NULL; 1.62 +} 1.63 + 1.64 + 1.65 +const char* InstructionPrinter::op_name(Bytecodes::Code op) { 1.66 + switch (op) { 1.67 + // arithmetic ops 1.68 + case Bytecodes::_iadd : // fall through 1.69 + case Bytecodes::_ladd : // fall through 1.70 + case Bytecodes::_fadd : // fall through 1.71 + case Bytecodes::_dadd : return "+"; 1.72 + case Bytecodes::_isub : // fall through 1.73 + case Bytecodes::_lsub : // fall through 1.74 + case Bytecodes::_fsub : // fall through 1.75 + case Bytecodes::_dsub : return "-"; 1.76 + case Bytecodes::_imul : // fall through 1.77 + case Bytecodes::_lmul : // fall through 1.78 + case Bytecodes::_fmul : // fall through 1.79 + case Bytecodes::_dmul : return "*"; 1.80 + case Bytecodes::_idiv : // fall through 1.81 + case Bytecodes::_ldiv : // fall through 1.82 + case Bytecodes::_fdiv : // fall through 1.83 + case Bytecodes::_ddiv : return "/"; 1.84 + case Bytecodes::_irem : // fall through 1.85 + case Bytecodes::_lrem : // fall through 1.86 + case Bytecodes::_frem : // fall through 1.87 + case Bytecodes::_drem : return "%"; 1.88 + // shift ops 1.89 + case Bytecodes::_ishl : // fall through 1.90 + case Bytecodes::_lshl : return "<<"; 1.91 + case Bytecodes::_ishr : // fall through 1.92 + case Bytecodes::_lshr : return ">>"; 1.93 + case Bytecodes::_iushr: // fall through 1.94 + case Bytecodes::_lushr: return ">>>"; 1.95 + // logic ops 1.96 + case Bytecodes::_iand : // fall through 1.97 + case Bytecodes::_land : return "&"; 1.98 + case Bytecodes::_ior : // fall through 1.99 + case Bytecodes::_lor : return "|"; 1.100 + case Bytecodes::_ixor : // fall through 1.101 + case Bytecodes::_lxor : return "^"; 1.102 + } 1.103 + return Bytecodes::name(op); 1.104 +} 1.105 + 1.106 + 1.107 +bool InstructionPrinter::is_illegal_phi(Value v) { 1.108 + Phi* phi = v ? v->as_Phi() : NULL; 1.109 + if (phi && phi->is_illegal()) { 1.110 + return true; 1.111 + } 1.112 + return false; 1.113 +} 1.114 + 1.115 + 1.116 +bool InstructionPrinter::is_phi_of_block(Value v, BlockBegin* b) { 1.117 + Phi* phi = v ? v->as_Phi() : NULL; 1.118 + return phi && phi->block() == b; 1.119 +} 1.120 + 1.121 + 1.122 +void InstructionPrinter::print_klass(ciKlass* klass) { 1.123 + klass->name()->print_symbol_on(output()); 1.124 +} 1.125 + 1.126 + 1.127 +void InstructionPrinter::print_object(Value obj) { 1.128 + ValueType* type = obj->type(); 1.129 + if (type->as_ObjectConstant() != NULL) { 1.130 + ciObject* value = type->as_ObjectConstant()->value(); 1.131 + if (value->is_null_object()) { 1.132 + output()->print("null"); 1.133 + } else if (!value->is_loaded()) { 1.134 + output()->print("<unloaded object 0x%x>", value); 1.135 + } else if (value->is_method()) { 1.136 + ciMethod* m = (ciMethod*)value; 1.137 + output()->print("<method %s.%s>", m->holder()->name()->as_utf8(), m->name()->as_utf8()); 1.138 + } else { 1.139 + output()->print("<object 0x%x>", value->encoding()); 1.140 + } 1.141 + } else if (type->as_InstanceConstant() != NULL) { 1.142 + output()->print("<instance 0x%x>", type->as_InstanceConstant()->value()->encoding()); 1.143 + } else if (type->as_ArrayConstant() != NULL) { 1.144 + output()->print("<array 0x%x>", type->as_ArrayConstant()->value()->encoding()); 1.145 + } else if (type->as_ClassConstant() != NULL) { 1.146 + ciInstanceKlass* klass = type->as_ClassConstant()->value(); 1.147 + if (!klass->is_loaded()) { 1.148 + output()->print("<unloaded> "); 1.149 + } 1.150 + output()->print("class "); 1.151 + print_klass(klass); 1.152 + } else { 1.153 + output()->print("???"); 1.154 + } 1.155 +} 1.156 + 1.157 + 1.158 +void InstructionPrinter::print_temp(Value value) { 1.159 + output()->print("%c%d", value->type()->tchar(), value->id()); 1.160 +} 1.161 + 1.162 + 1.163 +void InstructionPrinter::print_field(AccessField* field) { 1.164 + print_value(field->obj()); 1.165 + output()->print("._%d", field->offset()); 1.166 +} 1.167 + 1.168 + 1.169 +void InstructionPrinter::print_indexed(AccessIndexed* indexed) { 1.170 + print_value(indexed->array()); 1.171 + output()->put('['); 1.172 + print_value(indexed->index()); 1.173 + output()->put(']'); 1.174 +} 1.175 + 1.176 + 1.177 +void InstructionPrinter::print_monitor(AccessMonitor* monitor) { 1.178 + output()->print("monitor[%d](", monitor->monitor_no()); 1.179 + print_value(monitor->obj()); 1.180 + output()->put(')'); 1.181 +} 1.182 + 1.183 + 1.184 +void InstructionPrinter::print_op2(Op2* instr) { 1.185 + print_value(instr->x()); 1.186 + output()->print(" %s ", op_name(instr->op())); 1.187 + print_value(instr->y()); 1.188 +} 1.189 + 1.190 + 1.191 +void InstructionPrinter::print_value(Value value) { 1.192 + if (value == NULL) { 1.193 + output()->print("NULL"); 1.194 + } else { 1.195 + print_temp(value); 1.196 + } 1.197 +} 1.198 + 1.199 + 1.200 +void InstructionPrinter::print_instr(Instruction* instr) { 1.201 + instr->visit(this); 1.202 +} 1.203 + 1.204 + 1.205 +void InstructionPrinter::print_stack(ValueStack* stack) { 1.206 + int start_position = output()->position(); 1.207 + if (stack->stack_is_empty()) { 1.208 + output()->print("empty stack"); 1.209 + } else { 1.210 + output()->print("stack ["); 1.211 + for (int i = 0; i < stack->stack_size();) { 1.212 + if (i > 0) output()->print(", "); 1.213 + output()->print("%d:", i); 1.214 + Value value = stack->stack_at_inc(i); 1.215 + print_value(value); 1.216 + Phi* phi = value->as_Phi(); 1.217 + if (phi != NULL) { 1.218 + if (phi->operand()->is_valid()) { 1.219 + output()->print(" "); 1.220 + phi->operand()->print(output()); 1.221 + } 1.222 + } 1.223 + } 1.224 + output()->put(']'); 1.225 + } 1.226 + if (!stack->no_active_locks()) { 1.227 + // print out the lines on the line below this 1.228 + // one at the same indentation level. 1.229 + output()->cr(); 1.230 + fill_to(start_position, ' '); 1.231 + output()->print("locks ["); 1.232 + for (int i = i = 0; i < stack->locks_size(); i++) { 1.233 + Value t = stack->lock_at(i); 1.234 + if (i > 0) output()->print(", "); 1.235 + output()->print("%d:", i); 1.236 + if (t == NULL) { 1.237 + // synchronized methods push null on the lock stack 1.238 + output()->print("this"); 1.239 + } else { 1.240 + print_value(t); 1.241 + } 1.242 + } 1.243 + output()->print("]"); 1.244 + } 1.245 +} 1.246 + 1.247 + 1.248 +void InstructionPrinter::print_inline_level(BlockBegin* block) { 1.249 + output()->print_cr("inlining depth %d", block->scope()->level()); 1.250 +} 1.251 + 1.252 + 1.253 +void InstructionPrinter::print_unsafe_op(UnsafeOp* op, const char* name) { 1.254 + output()->print(name); 1.255 + output()->print(".("); 1.256 +} 1.257 + 1.258 +void InstructionPrinter::print_unsafe_raw_op(UnsafeRawOp* op, const char* name) { 1.259 + print_unsafe_op(op, name); 1.260 + output()->print("base "); 1.261 + print_value(op->base()); 1.262 + if (op->has_index()) { 1.263 + output()->print(", index "); print_value(op->index()); 1.264 + output()->print(", log2_scale %d", op->log2_scale()); 1.265 + } 1.266 +} 1.267 + 1.268 + 1.269 +void InstructionPrinter::print_unsafe_object_op(UnsafeObjectOp* op, const char* name) { 1.270 + print_unsafe_op(op, name); 1.271 + print_value(op->object()); 1.272 + output()->print(", "); 1.273 + print_value(op->offset()); 1.274 +} 1.275 + 1.276 + 1.277 +void InstructionPrinter::print_phi(int i, Value v, BlockBegin* b) { 1.278 + Phi* phi = v->as_Phi(); 1.279 + output()->print("%2d ", i); 1.280 + print_value(v); 1.281 + // print phi operands 1.282 + if (phi && phi->block() == b) { 1.283 + output()->print(" ["); 1.284 + for (int j = 0; j < phi->operand_count(); j ++) { 1.285 + output()->print(" "); 1.286 + Value opd = phi->operand_at(j); 1.287 + if (opd) print_value(opd); 1.288 + else output()->print("NULL"); 1.289 + } 1.290 + output()->print("] "); 1.291 + } 1.292 + print_alias(v); 1.293 +} 1.294 + 1.295 + 1.296 +void InstructionPrinter::print_alias(Value v) { 1.297 + if (v != v->subst()) { 1.298 + output()->print("alias "); print_value(v->subst()); 1.299 + } 1.300 +} 1.301 + 1.302 + 1.303 +void InstructionPrinter::fill_to(int pos, char filler) { 1.304 + while (output()->position() < pos) output()->put(filler); 1.305 +} 1.306 + 1.307 + 1.308 +void InstructionPrinter::print_head() { 1.309 + const char filler = '_'; 1.310 + fill_to(bci_pos , filler); output()->print("bci" ); 1.311 + fill_to(use_pos , filler); output()->print("use" ); 1.312 + fill_to(temp_pos , filler); output()->print("tid" ); 1.313 + fill_to(instr_pos, filler); output()->print("instr"); 1.314 + fill_to(end_pos , filler); 1.315 + output()->cr(); 1.316 +} 1.317 + 1.318 + 1.319 +void InstructionPrinter::print_line(Instruction* instr) { 1.320 + // print instruction data on one line 1.321 + if (instr->is_pinned()) output()->put('.'); 1.322 + fill_to(bci_pos ); output()->print("%d", instr->bci()); 1.323 + fill_to(use_pos ); output()->print("%d", instr->use_count()); 1.324 + fill_to(temp_pos ); print_temp(instr); 1.325 + fill_to(instr_pos); print_instr(instr); 1.326 + output()->cr(); 1.327 + // add a line for StateSplit instructions w/ non-empty stacks 1.328 + // (make it robust so we can print incomplete instructions) 1.329 + StateSplit* split = instr->as_StateSplit(); 1.330 + if (split != NULL && split->state() != NULL && !split->state()->stack_is_empty()) { 1.331 + fill_to(instr_pos); print_stack(split->state()); 1.332 + output()->cr(); 1.333 + } 1.334 +} 1.335 + 1.336 + 1.337 +void InstructionPrinter::do_Phi(Phi* x) { 1.338 + output()->print("phi function"); // make that more detailed later 1.339 + if (x->is_illegal()) 1.340 + output()->print(" (illegal)"); 1.341 +} 1.342 + 1.343 + 1.344 +void InstructionPrinter::do_Local(Local* x) { 1.345 + output()->print("local[index %d]", x->java_index()); 1.346 +} 1.347 + 1.348 + 1.349 +void InstructionPrinter::do_Constant(Constant* x) { 1.350 + ValueType* t = x->type(); 1.351 + switch (t->tag()) { 1.352 + case intTag : output()->print("%d" , t->as_IntConstant ()->value()); break; 1.353 + case longTag : output()->print(os::jlong_format_specifier(), t->as_LongConstant()->value()); output()->print("L"); break; 1.354 + case floatTag : output()->print("%g" , t->as_FloatConstant ()->value()); break; 1.355 + case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value()); break; 1.356 + case objectTag : print_object(x); break; 1.357 + case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break; 1.358 + default : output()->print("???"); break; 1.359 + } 1.360 +} 1.361 + 1.362 + 1.363 +void InstructionPrinter::do_LoadField(LoadField* x) { 1.364 + print_field(x); 1.365 + output()->print(" (%c)", type2char(x->field()->type()->basic_type())); 1.366 +} 1.367 + 1.368 + 1.369 +void InstructionPrinter::do_StoreField(StoreField* x) { 1.370 + print_field(x); 1.371 + output()->print(" := "); 1.372 + print_value(x->value()); 1.373 + output()->print(" (%c)", type2char(x->field()->type()->basic_type())); 1.374 +} 1.375 + 1.376 + 1.377 +void InstructionPrinter::do_ArrayLength(ArrayLength* x) { 1.378 + print_value(x->array()); 1.379 + output()->print(".length"); 1.380 +} 1.381 + 1.382 + 1.383 +void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) { 1.384 + print_indexed(x); 1.385 + output()->print(" (%c)", type2char(x->elt_type())); 1.386 +} 1.387 + 1.388 + 1.389 +void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) { 1.390 + print_indexed(x); 1.391 + output()->print(" := "); 1.392 + print_value(x->value()); 1.393 + output()->print(" (%c)", type2char(x->elt_type())); 1.394 +} 1.395 + 1.396 +void InstructionPrinter::do_NegateOp(NegateOp* x) { 1.397 + output()->put('-'); 1.398 + print_value(x->x()); 1.399 +} 1.400 + 1.401 + 1.402 +void InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) { 1.403 + print_op2(x); 1.404 +} 1.405 + 1.406 + 1.407 +void InstructionPrinter::do_ShiftOp(ShiftOp* x) { 1.408 + print_op2(x); 1.409 +} 1.410 + 1.411 + 1.412 +void InstructionPrinter::do_LogicOp(LogicOp* x) { 1.413 + print_op2(x); 1.414 +} 1.415 + 1.416 + 1.417 +void InstructionPrinter::do_CompareOp(CompareOp* x) { 1.418 + print_op2(x); 1.419 +} 1.420 + 1.421 + 1.422 +void InstructionPrinter::do_IfOp(IfOp* x) { 1.423 + print_value(x->x()); 1.424 + output()->print(" %s ", cond_name(x->cond())); 1.425 + print_value(x->y()); 1.426 + output()->print(" ? "); 1.427 + print_value(x->tval()); 1.428 + output()->print(" : "); 1.429 + print_value(x->fval()); 1.430 +} 1.431 + 1.432 + 1.433 +void InstructionPrinter::do_Convert(Convert* x) { 1.434 + output()->print("%s(", Bytecodes::name(x->op())); 1.435 + print_value(x->value()); 1.436 + output()->put(')'); 1.437 +} 1.438 + 1.439 + 1.440 +void InstructionPrinter::do_NullCheck(NullCheck* x) { 1.441 + output()->print("null_check("); 1.442 + print_value(x->obj()); 1.443 + output()->put(')'); 1.444 + if (!x->can_trap()) { 1.445 + output()->print(" (eliminated)"); 1.446 + } 1.447 +} 1.448 + 1.449 + 1.450 +void InstructionPrinter::do_Invoke(Invoke* x) { 1.451 + if (x->receiver() != NULL) { 1.452 + print_value(x->receiver()); 1.453 + output()->print("."); 1.454 + } 1.455 + 1.456 + output()->print("%s(", Bytecodes::name(x->code())); 1.457 + for (int i = 0; i < x->number_of_arguments(); i++) { 1.458 + if (i > 0) output()->print(", "); 1.459 + print_value(x->argument_at(i)); 1.460 + } 1.461 + output()->print_cr(")"); 1.462 + fill_to(instr_pos); 1.463 + output()->print("%s.%s%s", 1.464 + x->target()->holder()->name()->as_utf8(), 1.465 + x->target()->name()->as_utf8(), 1.466 + x->target()->signature()->as_symbol()->as_utf8()); 1.467 +} 1.468 + 1.469 + 1.470 +void InstructionPrinter::do_NewInstance(NewInstance* x) { 1.471 + output()->print("new instance "); 1.472 + print_klass(x->klass()); 1.473 +} 1.474 + 1.475 + 1.476 +void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) { 1.477 + output()->print("new %s array [", basic_type_name(x->elt_type())); 1.478 + print_value(x->length()); 1.479 + output()->put(']'); 1.480 +} 1.481 + 1.482 + 1.483 +void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) { 1.484 + output()->print("new object array ["); 1.485 + print_value(x->length()); 1.486 + output()->print("] "); 1.487 + print_klass(x->klass()); 1.488 +} 1.489 + 1.490 + 1.491 +void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) { 1.492 + output()->print("new multi array ["); 1.493 + Values* dims = x->dims(); 1.494 + for (int i = 0; i < dims->length(); i++) { 1.495 + if (i > 0) output()->print(", "); 1.496 + print_value(dims->at(i)); 1.497 + } 1.498 + output()->print("] "); 1.499 + print_klass(x->klass()); 1.500 +} 1.501 + 1.502 + 1.503 +void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) { 1.504 + output()->print("enter "); 1.505 + print_monitor(x); 1.506 +} 1.507 + 1.508 + 1.509 +void InstructionPrinter::do_MonitorExit(MonitorExit* x) { 1.510 + output()->print("exit "); 1.511 + print_monitor(x); 1.512 +} 1.513 + 1.514 + 1.515 +void InstructionPrinter::do_Intrinsic(Intrinsic* x) { 1.516 + const char* name = vmIntrinsics::name_at(x->id()); 1.517 + if (name[0] == '_') name++; // strip leading bug from _hashCode, etc. 1.518 + const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id())); 1.519 + if (strchr(name, '_') == NULL) { 1.520 + kname = NULL; 1.521 + } else { 1.522 + const char* kptr = strrchr(kname, '/'); 1.523 + if (kptr != NULL) kname = kptr + 1; 1.524 + } 1.525 + if (kname == NULL) 1.526 + output()->print("%s(", name); 1.527 + else 1.528 + output()->print("%s.%s(", kname, name); 1.529 + for (int i = 0; i < x->number_of_arguments(); i++) { 1.530 + if (i > 0) output()->print(", "); 1.531 + print_value(x->argument_at(i)); 1.532 + } 1.533 + output()->put(')'); 1.534 +} 1.535 + 1.536 + 1.537 +void InstructionPrinter::do_BlockBegin(BlockBegin* x) { 1.538 + // print block id 1.539 + BlockEnd* end = x->end(); 1.540 + output()->print("B%d ", x->block_id()); 1.541 + 1.542 + // print flags 1.543 + bool printed_flag = false; 1.544 + if (x->is_set(BlockBegin::std_entry_flag)) { 1.545 + if (!printed_flag) output()->print("("); 1.546 + output()->print("S"); printed_flag = true; 1.547 + } 1.548 + if (x->is_set(BlockBegin::osr_entry_flag)) { 1.549 + if (!printed_flag) output()->print("("); 1.550 + output()->print("O"); printed_flag = true; 1.551 + } 1.552 + if (x->is_set(BlockBegin::exception_entry_flag)) { 1.553 + if (!printed_flag) output()->print("("); 1.554 + output()->print("E"); printed_flag = true; 1.555 + } 1.556 + if (x->is_set(BlockBegin::subroutine_entry_flag)) { 1.557 + if (!printed_flag) output()->print("("); 1.558 + output()->print("s"); printed_flag = true; 1.559 + } 1.560 + if (x->is_set(BlockBegin::parser_loop_header_flag)) { 1.561 + if (!printed_flag) output()->print("("); 1.562 + output()->print("LH"); printed_flag = true; 1.563 + } 1.564 + if (x->is_set(BlockBegin::backward_branch_target_flag)) { 1.565 + if (!printed_flag) output()->print("("); 1.566 + output()->print("b"); printed_flag = true; 1.567 + } 1.568 + if (x->is_set(BlockBegin::was_visited_flag)) { 1.569 + if (!printed_flag) output()->print("("); 1.570 + output()->print("V"); printed_flag = true; 1.571 + } 1.572 + if (printed_flag) output()->print(") "); 1.573 + 1.574 + // print block bci range 1.575 + output()->print("[%d, %d]", x->bci(), (end == NULL ? -1 : end->bci())); 1.576 + 1.577 + // print block successors 1.578 + if (end != NULL && end->number_of_sux() > 0) { 1.579 + output()->print(" ->"); 1.580 + for (int i = 0; i < end->number_of_sux(); i++) { 1.581 + output()->print(" B%d", end->sux_at(i)->block_id()); 1.582 + } 1.583 + } 1.584 + // print exception handlers 1.585 + if (x->number_of_exception_handlers() > 0) { 1.586 + output()->print(" (xhandlers "); 1.587 + for (int i = 0; i < x->number_of_exception_handlers(); i++) { 1.588 + if (i > 0) output()->print(" "); 1.589 + output()->print("B%d", x->exception_handler_at(i)->block_id()); 1.590 + } 1.591 + output()->put(')'); 1.592 + } 1.593 + 1.594 + // print dominator block 1.595 + if (x->dominator() != NULL) { 1.596 + output()->print(" dom B%d", x->dominator()->block_id()); 1.597 + } 1.598 + 1.599 + // print predecessors and successors 1.600 + if (x->successors()->length() > 0) { 1.601 + output()->print(" sux:"); 1.602 + for (int i = 0; i < x->successors()->length(); i ++) { 1.603 + output()->print(" B%d", x->successors()->at(i)->block_id()); 1.604 + } 1.605 + } 1.606 + 1.607 + if (x->number_of_preds() > 0) { 1.608 + output()->print(" pred:"); 1.609 + for (int i = 0; i < x->number_of_preds(); i ++) { 1.610 + output()->print(" B%d", x->pred_at(i)->block_id()); 1.611 + } 1.612 + } 1.613 + 1.614 + if (!_print_phis) { 1.615 + return; 1.616 + } 1.617 + 1.618 + // print phi functions 1.619 + bool has_phis_in_locals = false; 1.620 + bool has_phis_on_stack = false; 1.621 + 1.622 + if (x->end() && x->end()->state()) { 1.623 + ValueStack* state = x->state(); 1.624 + 1.625 + int i = 0; 1.626 + while (!has_phis_on_stack && i < state->stack_size()) { 1.627 + Value v = state->stack_at_inc(i); 1.628 + has_phis_on_stack = is_phi_of_block(v, x); 1.629 + } 1.630 + 1.631 + do { 1.632 + for (i = 0; !has_phis_in_locals && i < state->locals_size();) { 1.633 + Value v = state->local_at(i); 1.634 + has_phis_in_locals = is_phi_of_block(v, x); 1.635 + // also ignore illegal HiWords 1.636 + if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++; 1.637 + } 1.638 + state = state->caller_state(); 1.639 + } while (state != NULL); 1.640 + 1.641 + } 1.642 + 1.643 + // print values in locals 1.644 + if (has_phis_in_locals) { 1.645 + output()->cr(); output()->print_cr("Locals:"); 1.646 + 1.647 + ValueStack* state = x->state(); 1.648 + do { 1.649 + for (int i = 0; i < state->locals_size();) { 1.650 + Value v = state->local_at(i); 1.651 + if (v) { 1.652 + print_phi(i, v, x); output()->cr(); 1.653 + // also ignore illegal HiWords 1.654 + i += (v->type()->is_illegal() ? 1 : v->type()->size()); 1.655 + } else { 1.656 + i ++; 1.657 + } 1.658 + } 1.659 + output()->cr(); 1.660 + state = state->caller_state(); 1.661 + } while (state != NULL); 1.662 + } 1.663 + 1.664 + // print values on stack 1.665 + if (has_phis_on_stack) { 1.666 + output()->print_cr("Stack:"); 1.667 + int i = 0; 1.668 + while (i < x->state()->stack_size()) { 1.669 + int o = i; 1.670 + Value v = x->state()->stack_at_inc(i); 1.671 + if (v) { 1.672 + print_phi(o, v, x); output()->cr(); 1.673 + } 1.674 + } 1.675 + } 1.676 +} 1.677 + 1.678 + 1.679 +void InstructionPrinter::do_CheckCast(CheckCast* x) { 1.680 + output()->print("checkcast("); 1.681 + print_value(x->obj()); 1.682 + output()->print(") "); 1.683 + print_klass(x->klass()); 1.684 +} 1.685 + 1.686 + 1.687 +void InstructionPrinter::do_InstanceOf(InstanceOf* x) { 1.688 + output()->print("instanceof("); 1.689 + print_value(x->obj()); 1.690 + output()->print(") "); 1.691 + print_klass(x->klass()); 1.692 +} 1.693 + 1.694 + 1.695 +void InstructionPrinter::do_Goto(Goto* x) { 1.696 + output()->print("goto B%d", x->default_sux()->block_id()); 1.697 + if (x->is_safepoint()) output()->print(" (safepoint)"); 1.698 +} 1.699 + 1.700 + 1.701 +void InstructionPrinter::do_If(If* x) { 1.702 + output()->print("if "); 1.703 + print_value(x->x()); 1.704 + output()->print(" %s ", cond_name(x->cond())); 1.705 + print_value(x->y()); 1.706 + output()->print(" then B%d else B%d", x->sux_at(0)->block_id(), x->sux_at(1)->block_id()); 1.707 + if (x->is_safepoint()) output()->print(" (safepoint)"); 1.708 +} 1.709 + 1.710 + 1.711 +void InstructionPrinter::do_IfInstanceOf(IfInstanceOf* x) { 1.712 + output()->print("<IfInstanceOf>"); 1.713 +} 1.714 + 1.715 + 1.716 +void InstructionPrinter::do_TableSwitch(TableSwitch* x) { 1.717 + output()->print("tableswitch "); 1.718 + if (x->is_safepoint()) output()->print("(safepoint) "); 1.719 + print_value(x->tag()); 1.720 + output()->cr(); 1.721 + int l = x->length(); 1.722 + for (int i = 0; i < l; i++) { 1.723 + fill_to(instr_pos); 1.724 + output()->print_cr("case %5d: B%d", x->lo_key() + i, x->sux_at(i)->block_id()); 1.725 + } 1.726 + fill_to(instr_pos); 1.727 + output()->print("default : B%d", x->default_sux()->block_id()); 1.728 +} 1.729 + 1.730 + 1.731 +void InstructionPrinter::do_LookupSwitch(LookupSwitch* x) { 1.732 + output()->print("lookupswitch "); 1.733 + if (x->is_safepoint()) output()->print("(safepoint) "); 1.734 + print_value(x->tag()); 1.735 + output()->cr(); 1.736 + int l = x->length(); 1.737 + for (int i = 0; i < l; i++) { 1.738 + fill_to(instr_pos); 1.739 + output()->print_cr("case %5d: B%d", x->key_at(i), x->sux_at(i)->block_id()); 1.740 + } 1.741 + fill_to(instr_pos); 1.742 + output()->print("default : B%d", x->default_sux()->block_id()); 1.743 +} 1.744 + 1.745 + 1.746 +void InstructionPrinter::do_Return(Return* x) { 1.747 + if (x->result() == NULL) { 1.748 + output()->print("return"); 1.749 + } else { 1.750 + output()->print("%creturn ", x->type()->tchar()); 1.751 + print_value(x->result()); 1.752 + } 1.753 +} 1.754 + 1.755 + 1.756 +void InstructionPrinter::do_Throw(Throw* x) { 1.757 + output()->print("throw "); 1.758 + print_value(x->exception()); 1.759 +} 1.760 + 1.761 + 1.762 +void InstructionPrinter::do_Base(Base* x) { 1.763 + output()->print("std entry B%d", x->std_entry()->block_id()); 1.764 + if (x->number_of_sux() > 1) { 1.765 + output()->print(" osr entry B%d", x->osr_entry()->block_id()); 1.766 + } 1.767 +} 1.768 + 1.769 + 1.770 +void InstructionPrinter::do_OsrEntry(OsrEntry* x) { 1.771 + output()->print("osr entry"); 1.772 +} 1.773 + 1.774 + 1.775 +void InstructionPrinter::do_ExceptionObject(ExceptionObject* x) { 1.776 + output()->print("incoming exception"); 1.777 +} 1.778 + 1.779 + 1.780 +void InstructionPrinter::do_RoundFP(RoundFP* x) { 1.781 + output()->print("round_fp "); 1.782 + print_value(x->input()); 1.783 +} 1.784 + 1.785 + 1.786 +void InstructionPrinter::do_UnsafeGetRaw(UnsafeGetRaw* x) { 1.787 + print_unsafe_raw_op(x, "UnsafeGetRaw"); 1.788 + output()->put(')'); 1.789 +} 1.790 + 1.791 + 1.792 +void InstructionPrinter::do_UnsafePutRaw(UnsafePutRaw* x) { 1.793 + print_unsafe_raw_op(x, "UnsafePutRaw"); 1.794 + output()->print(", value "); 1.795 + print_value(x->value()); 1.796 + output()->put(')'); 1.797 +} 1.798 + 1.799 + 1.800 +void InstructionPrinter::do_UnsafeGetObject(UnsafeGetObject* x) { 1.801 + print_unsafe_object_op(x, "UnsafeGetObject"); 1.802 + output()->put(')'); 1.803 +} 1.804 + 1.805 + 1.806 +void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) { 1.807 + print_unsafe_object_op(x, "UnsafePutObject"); 1.808 + output()->print(", value "); 1.809 + print_value(x->value()); 1.810 + output()->put(')'); 1.811 +} 1.812 + 1.813 + 1.814 +void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) { 1.815 + print_unsafe_object_op(x, "UnsafePrefetchRead"); 1.816 + output()->put(')'); 1.817 +} 1.818 + 1.819 + 1.820 +void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { 1.821 + print_unsafe_object_op(x, "UnsafePrefetchWrite"); 1.822 + output()->put(')'); 1.823 +} 1.824 + 1.825 + 1.826 +void InstructionPrinter::do_ProfileCall(ProfileCall* x) { 1.827 + output()->print("profile "); 1.828 + print_value(x->recv()); 1.829 + output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8()); 1.830 + if (x->known_holder() != NULL) { 1.831 + output()->print(", "); 1.832 + print_klass(x->known_holder()); 1.833 + } 1.834 + output()->put(')'); 1.835 +} 1.836 + 1.837 + 1.838 +void InstructionPrinter::do_ProfileCounter(ProfileCounter* x) { 1.839 + 1.840 + ObjectConstant* oc = x->mdo()->type()->as_ObjectConstant(); 1.841 + if (oc != NULL && oc->value()->is_method() && 1.842 + x->offset() == methodOopDesc::interpreter_invocation_counter_offset_in_bytes()) { 1.843 + print_value(x->mdo()); 1.844 + output()->print(".interpreter_invocation_count += %d", x->increment()); 1.845 + } else { 1.846 + output()->print("counter ["); 1.847 + print_value(x->mdo()); 1.848 + output()->print(" + %d] += %d", x->offset(), x->increment()); 1.849 + } 1.850 +} 1.851 + 1.852 + 1.853 +#endif // PRODUCT