c1_InstructionPrinter.cpp revision 2459
0N/A/*
6330N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
3012N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6330N/A *
6330N/A * This code is free software; you can redistribute it and/or modify it
6330N/A * under the terms of the GNU General Public License version 2 only, as
6330N/A * published by the Free Software Foundation.
233N/A *
6330N/A * This code is distributed in the hope that it will be useful, but WITHOUT
6330N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6330N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6330N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
6330N/A *
6330N/A * You should have received a copy of the GNU General Public License version
6330N/A * 2 along with this work; if not, write to the Free Software Foundation,
6330N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6330N/A *
6330N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6330N/A * or visit www.oracle.com if you need additional information or have any
6330N/A * questions.
6330N/A *
6330N/A */
6330N/A
6330N/A#include "precompiled.hpp"
6330N/A#include "c1/c1_InstructionPrinter.hpp"
6330N/A#include "c1/c1_ValueStack.hpp"
0N/A#include "ci/ciArray.hpp"
6331N/A#include "ci/ciInstance.hpp"
6330N/A#include "ci/ciObject.hpp"
6330N/A
6330N/A
6330N/A#ifndef PRODUCT
6330N/A
6330N/Aconst char* InstructionPrinter::basic_type_name(BasicType type) {
6330N/A switch (type) {
3381N/A case T_BOOLEAN: return "boolean";
6330N/A case T_BYTE : return "byte";
6330N/A case T_CHAR : return "char";
6330N/A case T_SHORT : return "short";
6330N/A case T_INT : return "int";
6331N/A case T_LONG : return "long";
6331N/A case T_FLOAT : return "float";
6330N/A case T_DOUBLE : return "double";
6330N/A case T_ARRAY : return "array";
3980N/A case T_OBJECT : return "object";
6330N/A default : return "???";
6330N/A }
6301N/A}
6301N/A
6301N/A
3012N/Aconst char* InstructionPrinter::cond_name(If::Condition cond) {
6330N/A switch (cond) {
6330N/A case If::eql: return "==";
6331N/A case If::neq: return "!=";
6330N/A case If::lss: return "<";
6331N/A case If::leq: return "<=";
6331N/A case If::gtr: return ">";
233N/A case If::geq: return ">=";
6330N/A }
6330N/A ShouldNotReachHere();
6330N/A return NULL;
6330N/A}
0N/A
6330N/A
6330N/Aconst char* InstructionPrinter::op_name(Bytecodes::Code op) {
6330N/A switch (op) {
6330N/A // arithmetic ops
6330N/A case Bytecodes::_iadd : // fall through
6330N/A case Bytecodes::_ladd : // fall through
6330N/A case Bytecodes::_fadd : // fall through
6330N/A case Bytecodes::_dadd : return "+";
6330N/A case Bytecodes::_isub : // fall through
6330N/A case Bytecodes::_lsub : // fall through
6330N/A case Bytecodes::_fsub : // fall through
6330N/A case Bytecodes::_dsub : return "-";
6330N/A case Bytecodes::_imul : // fall through
6330N/A case Bytecodes::_lmul : // fall through
6330N/A case Bytecodes::_fmul : // fall through
6330N/A case Bytecodes::_dmul : return "*";
6330N/A case Bytecodes::_idiv : // fall through
6330N/A case Bytecodes::_ldiv : // fall through
6330N/A case Bytecodes::_fdiv : // fall through
6331N/A case Bytecodes::_ddiv : return "/";
567N/A case Bytecodes::_irem : // fall through
6330N/A case Bytecodes::_lrem : // fall through
6330N/A case Bytecodes::_frem : // fall through
6330N/A case Bytecodes::_drem : return "%";
6330N/A // shift ops
6330N/A case Bytecodes::_ishl : // fall through
0N/A case Bytecodes::_lshl : return "<<";
6330N/A case Bytecodes::_ishr : // fall through
6330N/A case Bytecodes::_lshr : return ">>";
6330N/A case Bytecodes::_iushr: // fall through
6330N/A case Bytecodes::_lushr: return ">>>";
0N/A // logic ops
6330N/A case Bytecodes::_iand : // fall through
6330N/A case Bytecodes::_land : return "&";
6330N/A case Bytecodes::_ior : // fall through
6330N/A case Bytecodes::_lor : return "|";
6330N/A case Bytecodes::_ixor : // fall through
6330N/A case Bytecodes::_lxor : return "^";
6330N/A }
6330N/A return Bytecodes::name(op);
6330N/A}
6330N/A
6330N/A
6330N/Abool InstructionPrinter::is_illegal_phi(Value v) {
902N/A Phi* phi = v ? v->as_Phi() : NULL;
6330N/A if (phi && phi->is_illegal()) {
6330N/A return true;
6330N/A }
6330N/A return false;
6330N/A}
6330N/A
233N/A
6330N/Abool InstructionPrinter::is_phi_of_block(Value v, BlockBegin* b) {
6330N/A Phi* phi = v ? v->as_Phi() : NULL;
6330N/A return phi && phi->block() == b;
6330N/A}
6330N/A
6330N/A
699N/Avoid InstructionPrinter::print_klass(ciKlass* klass) {
6330N/A klass->name()->print_symbol_on(output());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::print_object(Value obj) {
6330N/A ValueType* type = obj->type();
6330N/A if (type->as_ObjectConstant() != NULL) {
6330N/A ciObject* value = type->as_ObjectConstant()->value();
6330N/A if (value->is_null_object()) {
3381N/A output()->print("null");
6330N/A } else if (!value->is_loaded()) {
6330N/A output()->print("<unloaded object " PTR_FORMAT ">", value);
0N/A } else if (value->is_method()) {
6330N/A ciMethod* m = (ciMethod*)value;
6330N/A output()->print("<method %s.%s>", m->holder()->name()->as_utf8(), m->name()->as_utf8());
6330N/A } else {
1177N/A output()->print("<object " PTR_FORMAT ">", value->constant_encoding());
6330N/A }
6330N/A } else if (type->as_InstanceConstant() != NULL) {
6330N/A ciInstance* value = type->as_InstanceConstant()->value();
6330N/A if (value->is_loaded()) {
6330N/A output()->print("<instance " PTR_FORMAT ">", value->constant_encoding());
6330N/A } else {
6330N/A output()->print("<unloaded instance " PTR_FORMAT ">", value);
6330N/A }
3980N/A } else if (type->as_ArrayConstant() != NULL) {
6330N/A output()->print("<array " PTR_FORMAT ">", type->as_ArrayConstant()->value()->constant_encoding());
6330N/A } else if (type->as_ClassConstant() != NULL) {
6401N/A ciInstanceKlass* klass = type->as_ClassConstant()->value();
6330N/A if (!klass->is_loaded()) {
6330N/A output()->print("<unloaded> ");
6330N/A }
3381N/A output()->print("class ");
6330N/A print_klass(klass);
6330N/A } else {
6330N/A output()->print("???");
6158N/A }
6330N/A}
6330N/A
6330N/A
6165N/Avoid InstructionPrinter::print_temp(Value value) {
6330N/A output()->print("%c%d", value->type()->tchar(), value->id());
6330N/A}
6330N/A
3381N/A
6330N/Avoid InstructionPrinter::print_field(AccessField* field) {
6330N/A print_value(field->obj());
6330N/A output()->print("._%d", field->offset());
6330N/A}
6330N/A
6158N/A
6330N/Avoid InstructionPrinter::print_indexed(AccessIndexed* indexed) {
6330N/A print_value(indexed->array());
6330N/A output()->put('[');
6330N/A print_value(indexed->index());
6330N/A output()->put(']');
6330N/A}
3381N/A
6330N/A
6330N/Avoid InstructionPrinter::print_monitor(AccessMonitor* monitor) {
6330N/A output()->print("monitor[%d](", monitor->monitor_no());
6330N/A print_value(monitor->obj());
6330N/A output()->put(')');
6330N/A}
6330N/A
3381N/A
6330N/Avoid InstructionPrinter::print_op2(Op2* instr) {
6330N/A print_value(instr->x());
6330N/A output()->print(" %s ", op_name(instr->op()));
6330N/A print_value(instr->y());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::print_value(Value value) {
6330N/A if (value == NULL) {
6330N/A output()->print("NULL");
6330N/A } else {
6330N/A print_temp(value);
6330N/A }
6330N/A}
6330N/A
6330N/A
0N/Avoid InstructionPrinter::print_instr(Instruction* instr) {
6330N/A instr->visit(this);
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::print_stack(ValueStack* stack) {
6330N/A int start_position = output()->position();
6330N/A if (stack->stack_is_empty()) {
6330N/A output()->print("empty stack");
6330N/A } else {
0N/A output()->print("stack [");
6330N/A for (int i = 0; i < stack->stack_size();) {
6330N/A if (i > 0) output()->print(", ");
0N/A output()->print("%d:", i);
6330N/A Value value = stack->stack_at_inc(i);
6330N/A print_value(value);
6330N/A Phi* phi = value->as_Phi();
6330N/A if (phi != NULL) {
6330N/A if (phi->operand()->is_valid()) {
6330N/A output()->print(" ");
6330N/A phi->operand()->print(output());
6330N/A }
6330N/A }
6330N/A }
6330N/A output()->put(']');
6330N/A }
6330N/A if (!stack->no_active_locks()) {
0N/A // print out the lines on the line below this
0N/A // one at the same indentation level.
6330N/A output()->cr();
6330N/A fill_to(start_position, ' ');
6330N/A output()->print("locks [");
6330N/A for (int i = i = 0; i < stack->locks_size(); i++) {
6330N/A Value t = stack->lock_at(i);
6301N/A if (i > 0) output()->print(", ");
6330N/A output()->print("%d:", i);
6330N/A if (t == NULL) {
6330N/A // synchronized methods push null on the lock stack
5947N/A output()->print("this");
6302N/A } else {
6302N/A print_value(t);
6302N/A }
6330N/A }
6302N/A output()->print("]");
6330N/A }
6302N/A}
6302N/A
5947N/A
6302N/Avoid InstructionPrinter::print_inline_level(BlockBegin* block) {
6302N/A output()->print_cr("inlining depth %d", block->scope()->level());
6302N/A}
6302N/A
6302N/A
6302N/Avoid InstructionPrinter::print_unsafe_op(UnsafeOp* op, const char* name) {
6302N/A output()->print(name);
6302N/A output()->print(".(");
6302N/A}
0N/A
6302N/Avoid InstructionPrinter::print_unsafe_raw_op(UnsafeRawOp* op, const char* name) {
6302N/A print_unsafe_op(op, name);
6302N/A output()->print("base ");
6302N/A print_value(op->base());
6302N/A if (op->has_index()) {
6302N/A output()->print(", index "); print_value(op->index());
6302N/A output()->print(", log2_scale %d", op->log2_scale());
6330N/A }
6302N/A}
6302N/A
6302N/A
3381N/Avoid InstructionPrinter::print_unsafe_object_op(UnsafeObjectOp* op, const char* name) {
6330N/A print_unsafe_op(op, name);
6330N/A print_value(op->object());
6330N/A output()->print(", ");
6302N/A print_value(op->offset());
6330N/A}
6302N/A
0N/A
6330N/Avoid InstructionPrinter::print_phi(int i, Value v, BlockBegin* b) {
6330N/A Phi* phi = v->as_Phi();
6330N/A output()->print("%2d ", i);
6302N/A print_value(v);
6330N/A // print phi operands
6302N/A if (phi && phi->block() == b) {
6302N/A output()->print(" [");
1344N/A for (int j = 0; j < phi->operand_count(); j ++) {
6330N/A output()->print(" ");
6302N/A Value opd = phi->operand_at(j);
6302N/A if (opd) print_value(opd);
1344N/A else output()->print("NULL");
6302N/A }
6330N/A output()->print("] ");
6330N/A }
6302N/A print_alias(v);
6302N/A}
0N/A
0N/A
6330N/Avoid InstructionPrinter::print_alias(Value v) {
6330N/A if (v != v->subst()) {
6331N/A output()->print("alias "); print_value(v->subst());
567N/A }
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::fill_to(int pos, char filler) {
6330N/A while (output()->position() < pos) output()->put(filler);
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::print_head() {
6330N/A const char filler = '_';
6330N/A fill_to(bci_pos , filler); output()->print("bci" );
6330N/A fill_to(use_pos , filler); output()->print("use" );
6330N/A fill_to(temp_pos , filler); output()->print("tid" );
6330N/A fill_to(instr_pos, filler); output()->print("instr");
6330N/A fill_to(end_pos , filler);
6330N/A output()->cr();
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::print_line(Instruction* instr) {
6330N/A // print instruction data on one line
6330N/A if (instr->is_pinned()) output()->put('.');
6330N/A fill_to(bci_pos ); output()->print("%d", instr->printable_bci());
6330N/A fill_to(use_pos ); output()->print("%d", instr->use_count());
6330N/A fill_to(temp_pos ); print_temp(instr);
6330N/A fill_to(instr_pos); print_instr(instr);
6330N/A output()->cr();
662N/A // add a line for StateSplit instructions w/ non-empty stacks
6330N/A // (make it robust so we can print incomplete instructions)
6330N/A StateSplit* split = instr->as_StateSplit();
1210N/A if (split != NULL && split->state() != NULL && !split->state()->stack_is_empty()) {
6330N/A fill_to(instr_pos); print_stack(split->state());
6330N/A output()->cr();
6330N/A }
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Phi(Phi* x) {
3387N/A output()->print("phi function"); // make that more detailed later
6330N/A if (x->is_illegal())
6330N/A output()->print(" (illegal)");
6330N/A}
712N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Local(Local* x) {
6330N/A output()->print("local[index %d]", x->java_index());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Constant(Constant* x) {
6330N/A ValueType* t = x->type();
6330N/A switch (t->tag()) {
6330N/A case intTag : output()->print("%d" , t->as_IntConstant ()->value()); break;
6330N/A case longTag : output()->print(os::jlong_format_specifier(), t->as_LongConstant()->value()); output()->print("L"); break;
3381N/A case floatTag : output()->print("%g" , t->as_FloatConstant ()->value()); break;
6330N/A case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value()); break;
6330N/A case objectTag : print_object(x); break;
6330N/A case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break;
6330N/A default : output()->print("???"); break;
6331N/A }
6331N/A}
6331N/A
6331N/A
114N/Avoid InstructionPrinter::do_LoadField(LoadField* x) {
6330N/A print_field(x);
6330N/A output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
6330N/A}
6331N/A
6331N/A
6331N/Avoid InstructionPrinter::do_StoreField(StoreField* x) {
6331N/A print_field(x);
6330N/A output()->print(" := ");
6330N/A print_value(x->value());
0N/A output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_ArrayLength(ArrayLength* x) {
6330N/A print_value(x->array());
6330N/A output()->print(".length");
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
6330N/A print_indexed(x);
6330N/A output()->print(" (%c)", type2char(x->elt_type()));
6330N/A}
6330N/A
4156N/A
6330N/Avoid InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
6330N/A print_indexed(x);
6330N/A output()->print(" := ");
6330N/A print_value(x->value());
6330N/A output()->print(" (%c)", type2char(x->elt_type()));
6330N/A}
6330N/A
6330N/Avoid InstructionPrinter::do_NegateOp(NegateOp* x) {
6330N/A output()->put('-');
6330N/A print_value(x->x());
6330N/A}
1607N/A
6330N/A
6330N/Avoid InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) {
0N/A print_op2(x);
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_ShiftOp(ShiftOp* x) {
6330N/A print_op2(x);
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_LogicOp(LogicOp* x) {
1177N/A print_op2(x);
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_CompareOp(CompareOp* x) {
6330N/A print_op2(x);
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_IfOp(IfOp* x) {
6330N/A print_value(x->x());
2556N/A output()->print(" %s ", cond_name(x->cond()));
6330N/A print_value(x->y());
6330N/A output()->print(" ? ");
6410N/A print_value(x->tval());
6330N/A output()->print(" : ");
6330N/A print_value(x->fval());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Convert(Convert* x) {
6410N/A output()->print("%s(", Bytecodes::name(x->op()));
6330N/A print_value(x->value());
6330N/A output()->put(')');
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_NullCheck(NullCheck* x) {
6330N/A output()->print("null_check(");
6410N/A print_value(x->obj());
6410N/A output()->put(')');
6410N/A if (!x->can_trap()) {
6410N/A output()->print(" (eliminated)");
6410N/A }
6410N/A}
6410N/A
6410N/A
6410N/Avoid InstructionPrinter::do_Invoke(Invoke* x) {
6410N/A if (x->receiver() != NULL) {
6410N/A print_value(x->receiver());
6410N/A output()->print(".");
6410N/A }
6410N/A
6410N/A output()->print("%s(", Bytecodes::name(x->code()));
6410N/A for (int i = 0; i < x->number_of_arguments(); i++) {
6410N/A if (i > 0) output()->print(", ");
6410N/A print_value(x->argument_at(i));
6410N/A }
6410N/A output()->print_cr(")");
6410N/A fill_to(instr_pos);
6410N/A output()->print("%s.%s%s",
6330N/A x->target()->holder()->name()->as_utf8(),
6330N/A x->target()->name()->as_utf8(),
6330N/A x->target()->signature()->as_symbol()->as_utf8());
6410N/A}
6410N/A
6330N/A
6330N/Avoid InstructionPrinter::do_NewInstance(NewInstance* x) {
6330N/A output()->print("new instance ");
5058N/A print_klass(x->klass());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
6330N/A output()->print("new %s array [", basic_type_name(x->elt_type()));
6330N/A print_value(x->length());
6330N/A output()->put(']');
6330N/A}
6330N/A
6410N/A
6330N/Avoid InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
6330N/A output()->print("new object array [");
6330N/A print_value(x->length());
6330N/A output()->print("] ");
6410N/A print_klass(x->klass());
6410N/A}
6410N/A
6410N/A
6330N/Avoid InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
6410N/A output()->print("new multi array [");
6330N/A Values* dims = x->dims();
6330N/A for (int i = 0; i < dims->length(); i++) {
6330N/A if (i > 0) output()->print(", ");
6330N/A print_value(dims->at(i));
6410N/A }
6410N/A output()->print("] ");
6330N/A print_klass(x->klass());
6330N/A}
6330N/A
0N/A
6330N/Avoid InstructionPrinter::do_MonitorEnter(MonitorEnter* x) {
6330N/A output()->print("enter ");
6330N/A print_monitor(x);
6410N/A}
6330N/A
6410N/A
6330N/Avoid InstructionPrinter::do_MonitorExit(MonitorExit* x) {
6330N/A output()->print("exit ");
6330N/A print_monitor(x);
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Intrinsic(Intrinsic* x) {
712N/A const char* name = vmIntrinsics::name_at(x->id());
6330N/A if (name[0] == '_') name++; // strip leading bug from _hashCode, etc.
6330N/A const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id()));
6330N/A if (strchr(name, '_') == NULL) {
6330N/A kname = NULL;
6330N/A } else {
6330N/A const char* kptr = strrchr(kname, '/');
6330N/A if (kptr != NULL) kname = kptr + 1;
6330N/A }
6330N/A if (kname == NULL)
6330N/A output()->print("%s(", name);
1008N/A else
6330N/A output()->print("%s.%s(", kname, name);
6330N/A for (int i = 0; i < x->number_of_arguments(); i++) {
6330N/A if (i > 0) output()->print(", ");
6330N/A print_value(x->argument_at(i));
6330N/A }
6330N/A output()->put(')');
3381N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_BlockBegin(BlockBegin* x) {
6330N/A // print block id
6330N/A BlockEnd* end = x->end();
6330N/A output()->print("B%d ", x->block_id());
6330N/A
6330N/A // print flags
6330N/A bool printed_flag = false;
6330N/A if (x->is_set(BlockBegin::std_entry_flag)) {
6330N/A if (!printed_flag) output()->print("(");
6330N/A output()->print("S"); printed_flag = true;
2086N/A }
3980N/A if (x->is_set(BlockBegin::osr_entry_flag)) {
6330N/A if (!printed_flag) output()->print("(");
6330N/A output()->print("O"); printed_flag = true;
6330N/A }
6330N/A if (x->is_set(BlockBegin::exception_entry_flag)) {
6330N/A if (!printed_flag) output()->print("(");
6330N/A output()->print("E"); printed_flag = true;
6330N/A }
6330N/A if (x->is_set(BlockBegin::subroutine_entry_flag)) {
6330N/A if (!printed_flag) output()->print("(");
6330N/A output()->print("s"); printed_flag = true;
6330N/A }
6330N/A if (x->is_set(BlockBegin::parser_loop_header_flag)) {
6330N/A if (!printed_flag) output()->print("(");
6330N/A output()->print("LH"); printed_flag = true;
6330N/A }
6330N/A if (x->is_set(BlockBegin::backward_branch_target_flag)) {
6330N/A if (!printed_flag) output()->print("(");
6330N/A output()->print("b"); printed_flag = true;
6330N/A }
6330N/A if (x->is_set(BlockBegin::was_visited_flag)) {
6330N/A if (!printed_flag) output()->print("(");
6330N/A output()->print("V"); printed_flag = true;
6330N/A }
6330N/A if (printed_flag) output()->print(") ");
6330N/A
6330N/A // print block bci range
6330N/A output()->print("[%d, %d]", x->bci(), (end == NULL ? -1 : end->printable_bci()));
6330N/A
6330N/A // print block successors
6330N/A if (end != NULL && end->number_of_sux() > 0) {
6330N/A output()->print(" ->");
6330N/A for (int i = 0; i < end->number_of_sux(); i++) {
6330N/A output()->print(" B%d", end->sux_at(i)->block_id());
6330N/A }
6330N/A }
6330N/A // print exception handlers
6330N/A if (x->number_of_exception_handlers() > 0) {
6330N/A output()->print(" (xhandlers ");
6330N/A for (int i = 0; i < x->number_of_exception_handlers(); i++) {
6330N/A if (i > 0) output()->print(" ");
6330N/A output()->print("B%d", x->exception_handler_at(i)->block_id());
6330N/A }
6330N/A output()->put(')');
6330N/A }
6330N/A
6330N/A // print dominator block
6330N/A if (x->dominator() != NULL) {
6330N/A output()->print(" dom B%d", x->dominator()->block_id());
6330N/A }
6330N/A
712N/A // print predecessors and successors
6330N/A if (x->successors()->length() > 0) {
6330N/A output()->print(" sux:");
6330N/A for (int i = 0; i < x->successors()->length(); i ++) {
6330N/A output()->print(" B%d", x->successors()->at(i)->block_id());
6330N/A }
6330N/A }
6330N/A
6330N/A if (x->number_of_preds() > 0) {
6330N/A output()->print(" pred:");
6330N/A for (int i = 0; i < x->number_of_preds(); i ++) {
6330N/A output()->print(" B%d", x->pred_at(i)->block_id());
6330N/A }
6330N/A }
6330N/A
6330N/A if (!_print_phis) {
6330N/A return;
6330N/A }
6330N/A
6330N/A // print phi functions
6330N/A bool has_phis_in_locals = false;
6330N/A bool has_phis_on_stack = false;
6330N/A
6330N/A if (x->end() && x->end()->state()) {
6330N/A ValueStack* state = x->state();
6330N/A
6330N/A int i = 0;
6330N/A while (!has_phis_on_stack && i < state->stack_size()) {
6330N/A Value v = state->stack_at_inc(i);
6330N/A has_phis_on_stack = is_phi_of_block(v, x);
6330N/A }
6330N/A
6330N/A do {
6330N/A for (i = 0; !has_phis_in_locals && i < state->locals_size();) {
6330N/A Value v = state->local_at(i);
6330N/A has_phis_in_locals = is_phi_of_block(v, x);
6330N/A // also ignore illegal HiWords
6330N/A if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++;
6330N/A }
6330N/A state = state->caller_state();
6330N/A } while (state != NULL);
6330N/A
6330N/A }
6330N/A
6330N/A // print values in locals
6330N/A if (has_phis_in_locals) {
6330N/A output()->cr(); output()->print_cr("Locals:");
6330N/A
6330N/A ValueStack* state = x->state();
6330N/A do {
6330N/A for (int i = 0; i < state->locals_size();) {
6330N/A Value v = state->local_at(i);
6330N/A if (v) {
563N/A print_phi(i, v, x); output()->cr();
6330N/A // also ignore illegal HiWords
6330N/A i += (v->type()->is_illegal() ? 1 : v->type()->size());
6330N/A } else {
6330N/A i ++;
6330N/A }
6330N/A }
712N/A output()->cr();
6330N/A state = state->caller_state();
6330N/A } while (state != NULL);
6330N/A }
6330N/A
6330N/A // print values on stack
6330N/A if (has_phis_on_stack) {
6330N/A output()->print_cr("Stack:");
6330N/A int i = 0;
6330N/A while (i < x->state()->stack_size()) {
6330N/A int o = i;
6330N/A Value v = x->state()->stack_at_inc(i);
6330N/A if (v) {
6330N/A print_phi(o, v, x); output()->cr();
6330N/A }
6330N/A }
6330N/A }
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_CheckCast(CheckCast* x) {
6330N/A output()->print("checkcast(");
6330N/A print_value(x->obj());
6330N/A output()->print(") ");
6330N/A print_klass(x->klass());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_InstanceOf(InstanceOf* x) {
6330N/A output()->print("instanceof(");
6330N/A print_value(x->obj());
6330N/A output()->print(") ");
6330N/A print_klass(x->klass());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Goto(Goto* x) {
6330N/A output()->print("goto B%d", x->default_sux()->block_id());
6330N/A if (x->is_safepoint()) output()->print(" (safepoint)");
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_If(If* x) {
6330N/A output()->print("if ");
6330N/A print_value(x->x());
6330N/A output()->print(" %s ", cond_name(x->cond()));
3381N/A print_value(x->y());
6330N/A output()->print(" then B%d else B%d", x->sux_at(0)->block_id(), x->sux_at(1)->block_id());
6330N/A if (x->is_safepoint()) output()->print(" (safepoint)");
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_IfInstanceOf(IfInstanceOf* x) {
6330N/A output()->print("<IfInstanceOf>");
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_TableSwitch(TableSwitch* x) {
6330N/A output()->print("tableswitch ");
6330N/A if (x->is_safepoint()) output()->print("(safepoint) ");
6330N/A print_value(x->tag());
6330N/A output()->cr();
6330N/A int l = x->length();
6330N/A for (int i = 0; i < l; i++) {
6330N/A fill_to(instr_pos);
6330N/A output()->print_cr("case %5d: B%d", x->lo_key() + i, x->sux_at(i)->block_id());
6330N/A }
6330N/A fill_to(instr_pos);
6330N/A output()->print("default : B%d", x->default_sux()->block_id());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_LookupSwitch(LookupSwitch* x) {
6330N/A output()->print("lookupswitch ");
6330N/A if (x->is_safepoint()) output()->print("(safepoint) ");
6330N/A print_value(x->tag());
6330N/A output()->cr();
6330N/A int l = x->length();
6330N/A for (int i = 0; i < l; i++) {
6330N/A fill_to(instr_pos);
6330N/A output()->print_cr("case %5d: B%d", x->key_at(i), x->sux_at(i)->block_id());
3214N/A }
6330N/A fill_to(instr_pos);
6330N/A output()->print("default : B%d", x->default_sux()->block_id());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Return(Return* x) {
6330N/A if (x->result() == NULL) {
6330N/A output()->print("return");
6330N/A } else {
6330N/A output()->print("%creturn ", x->type()->tchar());
6330N/A print_value(x->result());
6330N/A }
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Throw(Throw* x) {
0N/A output()->print("throw ");
6330N/A print_value(x->exception());
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_Base(Base* x) {
6330N/A output()->print("std entry B%d", x->std_entry()->block_id());
6330N/A if (x->number_of_sux() > 1) {
6330N/A output()->print(" osr entry B%d", x->osr_entry()->block_id());
6330N/A }
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_OsrEntry(OsrEntry* x) {
6330N/A output()->print("osr entry");
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_ExceptionObject(ExceptionObject* x) {
6330N/A output()->print("incoming exception");
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_RoundFP(RoundFP* x) {
6330N/A output()->print("round_fp ");
6330N/A print_value(x->input());
3214N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_UnsafeGetRaw(UnsafeGetRaw* x) {
6330N/A print_unsafe_raw_op(x, "UnsafeGetRaw");
6330N/A output()->put(')');
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_UnsafePutRaw(UnsafePutRaw* x) {
6330N/A print_unsafe_raw_op(x, "UnsafePutRaw");
6330N/A output()->print(", value ");
6330N/A print_value(x->value());
6330N/A output()->put(')');
6330N/A}
6330N/A
6330N/A
0N/Avoid InstructionPrinter::do_UnsafeGetObject(UnsafeGetObject* x) {
6330N/A print_unsafe_object_op(x, "UnsafeGetObject");
6330N/A output()->put(')');
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) {
6330N/A print_unsafe_object_op(x, "UnsafePutObject");
6330N/A output()->print(", value ");
6330N/A print_value(x->value());
6330N/A output()->put(')');
6330N/A}
6330N/A
6330N/A
6330N/Avoid InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) {
6330N/A print_unsafe_object_op(x, "UnsafePrefetchRead");
6330N/A output()->put(')');
6330N/A}
0N/A
6330N/A
6330N/Avoid InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {
6330N/A print_unsafe_object_op(x, "UnsafePrefetchWrite");
6330N/A output()->put(')');
6330N/A}
6330N/A
6330N/Avoid InstructionPrinter::do_ProfileCall(ProfileCall* x) {
6330N/A output()->print("profile ");
6330N/A print_value(x->recv());
6330N/A output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
6330N/A if (x->known_holder() != NULL) {
6330N/A output()->print(", ");
6330N/A print_klass(x->known_holder());
6330N/A }
6330N/A output()->put(')');
0N/A}
6330N/A
6330N/Avoid InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
6330N/A output()->print("profile_invoke ");
6330N/A output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
6330N/A output()->put(')');
6330N/A
6330N/A}
6330N/A
6330N/Avoid InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
6330N/A output()->print("call_rt %s(", x->entry_name());
6330N/A for (int i = 0; i < x->number_of_arguments(); i++) {
6330N/A if (i > 0) output()->print(", ");
6330N/A print_value(x->argument_at(i));
6330N/A }
6330N/A output()->put(')');
6330N/A}
6330N/A
6330N/A#endif // PRODUCT
6330N/A