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