src/share/vm/c1/c1_InstructionPrinter.cpp

Tue, 24 Jul 2012 10:51:00 -0700

author
twisti
date
Tue, 24 Jul 2012 10:51:00 -0700
changeset 3969
1d7922586cf6
parent 3592
701a83c86f28
child 4037
da91efe96a93
permissions
-rw-r--r--

7023639: JSR 292 method handle invocation needs a fast path for compiled code
6984705: JSR 292 method handle creation should not go through JNI
Summary: remove assembly code for JDK 7 chained method handles
Reviewed-by: jrose, twisti, kvn, mhaupt
Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>

     1 /*
     2  * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "c1/c1_InstructionPrinter.hpp"
    27 #include "c1/c1_ValueStack.hpp"
    28 #include "ci/ciArray.hpp"
    29 #include "ci/ciInstance.hpp"
    30 #include "ci/ciObject.hpp"
    33 #ifndef PRODUCT
    35 const char* InstructionPrinter::basic_type_name(BasicType type) {
    36   switch (type) {
    37     case T_BOOLEAN: return "boolean";
    38     case T_BYTE   : return "byte";
    39     case T_CHAR   : return "char";
    40     case T_SHORT  : return "short";
    41     case T_INT    : return "int";
    42     case T_LONG   : return "long";
    43     case T_FLOAT  : return "float";
    44     case T_DOUBLE : return "double";
    45     case T_ARRAY  : return "array";
    46     case T_OBJECT : return "object";
    47     default       : return "???";
    48   }
    49 }
    52 const char* InstructionPrinter::cond_name(If::Condition cond) {
    53   switch (cond) {
    54     case If::eql: return "==";
    55     case If::neq: return "!=";
    56     case If::lss: return "<";
    57     case If::leq: return "<=";
    58     case If::gtr: return ">";
    59     case If::geq: return ">=";
    60   }
    61   ShouldNotReachHere();
    62   return NULL;
    63 }
    66 const char* InstructionPrinter::op_name(Bytecodes::Code op) {
    67   switch (op) {
    68     // arithmetic ops
    69     case Bytecodes::_iadd : // fall through
    70     case Bytecodes::_ladd : // fall through
    71     case Bytecodes::_fadd : // fall through
    72     case Bytecodes::_dadd : return "+";
    73     case Bytecodes::_isub : // fall through
    74     case Bytecodes::_lsub : // fall through
    75     case Bytecodes::_fsub : // fall through
    76     case Bytecodes::_dsub : return "-";
    77     case Bytecodes::_imul : // fall through
    78     case Bytecodes::_lmul : // fall through
    79     case Bytecodes::_fmul : // fall through
    80     case Bytecodes::_dmul : return "*";
    81     case Bytecodes::_idiv : // fall through
    82     case Bytecodes::_ldiv : // fall through
    83     case Bytecodes::_fdiv : // fall through
    84     case Bytecodes::_ddiv : return "/";
    85     case Bytecodes::_irem : // fall through
    86     case Bytecodes::_lrem : // fall through
    87     case Bytecodes::_frem : // fall through
    88     case Bytecodes::_drem : return "%";
    89     // shift ops
    90     case Bytecodes::_ishl : // fall through
    91     case Bytecodes::_lshl : return "<<";
    92     case Bytecodes::_ishr : // fall through
    93     case Bytecodes::_lshr : return ">>";
    94     case Bytecodes::_iushr: // fall through
    95     case Bytecodes::_lushr: return ">>>";
    96     // logic ops
    97     case Bytecodes::_iand : // fall through
    98     case Bytecodes::_land : return "&";
    99     case Bytecodes::_ior  : // fall through
   100     case Bytecodes::_lor  : return "|";
   101     case Bytecodes::_ixor : // fall through
   102     case Bytecodes::_lxor : return "^";
   103   }
   104   return Bytecodes::name(op);
   105 }
   108 bool InstructionPrinter::is_illegal_phi(Value v) {
   109   Phi* phi = v ? v->as_Phi() : NULL;
   110   if (phi && phi->is_illegal()) {
   111     return true;
   112   }
   113   return false;
   114 }
   117 bool InstructionPrinter::is_phi_of_block(Value v, BlockBegin* b) {
   118   Phi* phi = v ? v->as_Phi() : NULL;
   119   return phi && phi->block() == b;
   120 }
   123 void InstructionPrinter::print_klass(ciKlass* klass) {
   124   klass->name()->print_symbol_on(output());
   125 }
   128 void InstructionPrinter::print_object(Value obj) {
   129   ValueType* type = obj->type();
   130   if (type->as_ObjectConstant() != NULL) {
   131     ciObject* value = type->as_ObjectConstant()->value();
   132     if (value->is_null_object()) {
   133       output()->print("null");
   134     } else if (!value->is_loaded()) {
   135       output()->print("<unloaded object " PTR_FORMAT ">", value);
   136     } else if (value->is_method()) {
   137       ciMethod* m = (ciMethod*)value;
   138       output()->print("<method %s.%s>", m->holder()->name()->as_utf8(), m->name()->as_utf8());
   139     } else {
   140       output()->print("<object " PTR_FORMAT " klass=", value->constant_encoding());
   141       print_klass(value->klass());
   142       output()->print(">");
   143     }
   144   } else if (type->as_InstanceConstant() != NULL) {
   145     ciInstance* value = type->as_InstanceConstant()->value();
   146     if (value->is_loaded()) {
   147       output()->print("<instance " PTR_FORMAT " klass=", value->constant_encoding());
   148       print_klass(value->klass());
   149       output()->print(">");
   150     } else {
   151       output()->print("<unloaded instance " PTR_FORMAT ">", value);
   152     }
   153   } else if (type->as_ArrayConstant() != NULL) {
   154     output()->print("<array " PTR_FORMAT ">", type->as_ArrayConstant()->value()->constant_encoding());
   155   } else if (type->as_ClassConstant() != NULL) {
   156     ciInstanceKlass* klass = type->as_ClassConstant()->value();
   157     if (!klass->is_loaded()) {
   158       output()->print("<unloaded> ");
   159     }
   160     output()->print("class ");
   161     print_klass(klass);
   162   } else {
   163     output()->print("???");
   164   }
   165 }
   168 void InstructionPrinter::print_temp(Value value) {
   169   output()->print("%c%d", value->type()->tchar(), value->id());
   170 }
   173 void InstructionPrinter::print_field(AccessField* field) {
   174   print_value(field->obj());
   175   output()->print("._%d", field->offset());
   176 }
   179 void InstructionPrinter::print_indexed(AccessIndexed* indexed) {
   180   print_value(indexed->array());
   181   output()->put('[');
   182   print_value(indexed->index());
   183   output()->put(']');
   184 }
   187 void InstructionPrinter::print_monitor(AccessMonitor* monitor) {
   188   output()->print("monitor[%d](", monitor->monitor_no());
   189   print_value(monitor->obj());
   190   output()->put(')');
   191 }
   194 void InstructionPrinter::print_op2(Op2* instr) {
   195   print_value(instr->x());
   196   output()->print(" %s ", op_name(instr->op()));
   197   print_value(instr->y());
   198 }
   201 void InstructionPrinter::print_value(Value value) {
   202   if (value == NULL) {
   203     output()->print("NULL");
   204   } else {
   205     print_temp(value);
   206   }
   207 }
   210 void InstructionPrinter::print_instr(Instruction* instr) {
   211   instr->visit(this);
   212 }
   215 void InstructionPrinter::print_stack(ValueStack* stack) {
   216   int start_position = output()->position();
   217   if (stack->stack_is_empty()) {
   218     output()->print("empty stack");
   219   } else {
   220     output()->print("stack [");
   221     for (int i = 0; i < stack->stack_size();) {
   222       if (i > 0) output()->print(", ");
   223       output()->print("%d:", i);
   224       Value value = stack->stack_at_inc(i);
   225       print_value(value);
   226       Phi* phi = value->as_Phi();
   227       if (phi != NULL) {
   228         if (phi->operand()->is_valid()) {
   229           output()->print(" ");
   230           phi->operand()->print(output());
   231         }
   232       }
   233     }
   234     output()->put(']');
   235   }
   236   if (!stack->no_active_locks()) {
   237     // print out the lines on the line below this
   238     // one at the same indentation level.
   239     output()->cr();
   240     fill_to(start_position, ' ');
   241     output()->print("locks [");
   242     for (int i = i = 0; i < stack->locks_size(); i++) {
   243       Value t = stack->lock_at(i);
   244       if (i > 0) output()->print(", ");
   245       output()->print("%d:", i);
   246       if (t == NULL) {
   247         // synchronized methods push null on the lock stack
   248         output()->print("this");
   249       } else {
   250         print_value(t);
   251       }
   252     }
   253     output()->print("]");
   254   }
   255 }
   258 void InstructionPrinter::print_inline_level(BlockBegin* block) {
   259   output()->print_cr("inlining depth %d", block->scope()->level());
   260 }
   263 void InstructionPrinter::print_unsafe_op(UnsafeOp* op, const char* name) {
   264   output()->print(name);
   265   output()->print(".(");
   266 }
   268 void InstructionPrinter::print_unsafe_raw_op(UnsafeRawOp* op, const char* name) {
   269   print_unsafe_op(op, name);
   270   output()->print("base ");
   271   print_value(op->base());
   272   if (op->has_index()) {
   273     output()->print(", index "); print_value(op->index());
   274     output()->print(", log2_scale %d", op->log2_scale());
   275   }
   276 }
   279 void InstructionPrinter::print_unsafe_object_op(UnsafeObjectOp* op, const char* name) {
   280   print_unsafe_op(op, name);
   281   print_value(op->object());
   282   output()->print(", ");
   283   print_value(op->offset());
   284 }
   287 void InstructionPrinter::print_phi(int i, Value v, BlockBegin* b) {
   288   Phi* phi = v->as_Phi();
   289   output()->print("%2d  ", i);
   290   print_value(v);
   291   // print phi operands
   292   if (phi && phi->block() == b) {
   293     output()->print(" [");
   294     for (int j = 0; j < phi->operand_count(); j ++) {
   295       output()->print(" ");
   296       Value opd = phi->operand_at(j);
   297       if (opd) print_value(opd);
   298       else output()->print("NULL");
   299     }
   300     output()->print("] ");
   301   }
   302   print_alias(v);
   303 }
   306 void InstructionPrinter::print_alias(Value v) {
   307   if (v != v->subst()) {
   308     output()->print("alias "); print_value(v->subst());
   309   }
   310 }
   313 void InstructionPrinter::fill_to(int pos, char filler) {
   314   while (output()->position() < pos) output()->put(filler);
   315 }
   318 void InstructionPrinter::print_head() {
   319   const char filler = '_';
   320   fill_to(bci_pos  , filler); output()->print("bci"  );
   321   fill_to(use_pos  , filler); output()->print("use"  );
   322   fill_to(temp_pos , filler); output()->print("tid"  );
   323   fill_to(instr_pos, filler); output()->print("instr");
   324   fill_to(end_pos  , filler);
   325   output()->cr();
   326 }
   329 void InstructionPrinter::print_line(Instruction* instr) {
   330   // print instruction data on one line
   331   if (instr->is_pinned()) output()->put('.');
   332   fill_to(bci_pos  ); output()->print("%d", instr->printable_bci());
   333   fill_to(use_pos  ); output()->print("%d", instr->use_count());
   334   fill_to(temp_pos ); print_temp(instr);
   335   fill_to(instr_pos); print_instr(instr);
   336   output()->cr();
   337   // add a line for StateSplit instructions w/ non-empty stacks
   338   // (make it robust so we can print incomplete instructions)
   339   StateSplit* split = instr->as_StateSplit();
   340   if (split != NULL && split->state() != NULL && !split->state()->stack_is_empty()) {
   341     fill_to(instr_pos); print_stack(split->state());
   342     output()->cr();
   343   }
   344 }
   347 void InstructionPrinter::do_Phi(Phi* x) {
   348   output()->print("phi function");  // make that more detailed later
   349   if (x->is_illegal())
   350     output()->print(" (illegal)");
   351 }
   354 void InstructionPrinter::do_Local(Local* x) {
   355   output()->print("local[index %d]", x->java_index());
   356 }
   359 void InstructionPrinter::do_Constant(Constant* x) {
   360   ValueType* t = x->type();
   361   switch (t->tag()) {
   362     case intTag    : output()->print("%d"  , t->as_IntConstant   ()->value());    break;
   363     case longTag   : output()->print(os::jlong_format_specifier(), t->as_LongConstant()->value()); output()->print("L"); break;
   364     case floatTag  : output()->print("%g"  , t->as_FloatConstant ()->value());    break;
   365     case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value());    break;
   366     case objectTag : print_object(x);                                        break;
   367     case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break;
   368     default        : output()->print("???");                                      break;
   369   }
   370 }
   373 void InstructionPrinter::do_LoadField(LoadField* x) {
   374   print_field(x);
   375   output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
   376 }
   379 void InstructionPrinter::do_StoreField(StoreField* x) {
   380   print_field(x);
   381   output()->print(" := ");
   382   print_value(x->value());
   383   output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
   384 }
   387 void InstructionPrinter::do_ArrayLength(ArrayLength* x) {
   388   print_value(x->array());
   389   output()->print(".length");
   390 }
   393 void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
   394   print_indexed(x);
   395   output()->print(" (%c)", type2char(x->elt_type()));
   396 }
   399 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
   400   print_indexed(x);
   401   output()->print(" := ");
   402   print_value(x->value());
   403   output()->print(" (%c)", type2char(x->elt_type()));
   404 }
   406 void InstructionPrinter::do_NegateOp(NegateOp* x) {
   407   output()->put('-');
   408   print_value(x->x());
   409 }
   412 void InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) {
   413   print_op2(x);
   414 }
   417 void InstructionPrinter::do_ShiftOp(ShiftOp* x) {
   418   print_op2(x);
   419 }
   422 void InstructionPrinter::do_LogicOp(LogicOp* x) {
   423   print_op2(x);
   424 }
   427 void InstructionPrinter::do_CompareOp(CompareOp* x) {
   428   print_op2(x);
   429 }
   432 void InstructionPrinter::do_IfOp(IfOp* x) {
   433   print_value(x->x());
   434   output()->print(" %s ", cond_name(x->cond()));
   435   print_value(x->y());
   436   output()->print(" ? ");
   437   print_value(x->tval());
   438   output()->print(" : ");
   439   print_value(x->fval());
   440 }
   443 void InstructionPrinter::do_Convert(Convert* x) {
   444   output()->print("%s(", Bytecodes::name(x->op()));
   445   print_value(x->value());
   446   output()->put(')');
   447 }
   450 void InstructionPrinter::do_NullCheck(NullCheck* x) {
   451   output()->print("null_check(");
   452   print_value(x->obj());
   453   output()->put(')');
   454   if (!x->can_trap()) {
   455     output()->print(" (eliminated)");
   456   }
   457 }
   460 void InstructionPrinter::do_TypeCast(TypeCast* x) {
   461   output()->print("type_cast(");
   462   print_value(x->obj());
   463   output()->print(") ");
   464   print_klass(x->declared_type()->klass());
   465 }
   468 void InstructionPrinter::do_Invoke(Invoke* x) {
   469   if (x->receiver() != NULL) {
   470     print_value(x->receiver());
   471     output()->print(".");
   472   }
   474   output()->print("%s(", Bytecodes::name(x->code()));
   475   for (int i = 0; i < x->number_of_arguments(); i++) {
   476     if (i > 0) output()->print(", ");
   477     print_value(x->argument_at(i));
   478   }
   479   output()->print_cr(")");
   480   fill_to(instr_pos);
   481   output()->print("%s.%s%s",
   482              x->target()->holder()->name()->as_utf8(),
   483              x->target()->name()->as_utf8(),
   484              x->target()->signature()->as_symbol()->as_utf8());
   485 }
   488 void InstructionPrinter::do_NewInstance(NewInstance* x) {
   489   output()->print("new instance ");
   490   print_klass(x->klass());
   491 }
   494 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
   495   output()->print("new %s array [", basic_type_name(x->elt_type()));
   496   print_value(x->length());
   497   output()->put(']');
   498 }
   501 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
   502   output()->print("new object array [");
   503   print_value(x->length());
   504   output()->print("] ");
   505   print_klass(x->klass());
   506 }
   509 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
   510   output()->print("new multi array [");
   511   Values* dims = x->dims();
   512   for (int i = 0; i < dims->length(); i++) {
   513     if (i > 0) output()->print(", ");
   514     print_value(dims->at(i));
   515   }
   516   output()->print("] ");
   517   print_klass(x->klass());
   518 }
   521 void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) {
   522   output()->print("enter ");
   523   print_monitor(x);
   524 }
   527 void InstructionPrinter::do_MonitorExit(MonitorExit* x) {
   528   output()->print("exit ");
   529   print_monitor(x);
   530 }
   533 void InstructionPrinter::do_Intrinsic(Intrinsic* x) {
   534   const char* name = vmIntrinsics::name_at(x->id());
   535   if (name[0] == '_')  name++;  // strip leading bug from _hashCode, etc.
   536   const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id()));
   537   if (strchr(name, '_') == NULL) {
   538     kname = NULL;
   539   } else {
   540     const char* kptr = strrchr(kname, '/');
   541     if (kptr != NULL)  kname = kptr + 1;
   542   }
   543   if (kname == NULL)
   544     output()->print("%s(", name);
   545   else
   546     output()->print("%s.%s(", kname, name);
   547   for (int i = 0; i < x->number_of_arguments(); i++) {
   548     if (i > 0) output()->print(", ");
   549     print_value(x->argument_at(i));
   550   }
   551   output()->put(')');
   552 }
   555 void InstructionPrinter::do_BlockBegin(BlockBegin* x) {
   556   // print block id
   557   BlockEnd* end = x->end();
   558   output()->print("B%d ", x->block_id());
   560   // print flags
   561   bool printed_flag = false;
   562   if (x->is_set(BlockBegin::std_entry_flag)) {
   563     if (!printed_flag) output()->print("(");
   564     output()->print("S"); printed_flag = true;
   565   }
   566   if (x->is_set(BlockBegin::osr_entry_flag)) {
   567     if (!printed_flag) output()->print("(");
   568     output()->print("O"); printed_flag = true;
   569   }
   570   if (x->is_set(BlockBegin::exception_entry_flag)) {
   571     if (!printed_flag) output()->print("(");
   572     output()->print("E"); printed_flag = true;
   573   }
   574   if (x->is_set(BlockBegin::subroutine_entry_flag)) {
   575     if (!printed_flag) output()->print("(");
   576     output()->print("s"); printed_flag = true;
   577   }
   578   if (x->is_set(BlockBegin::parser_loop_header_flag)) {
   579     if (!printed_flag) output()->print("(");
   580     output()->print("LH"); printed_flag = true;
   581   }
   582   if (x->is_set(BlockBegin::backward_branch_target_flag)) {
   583     if (!printed_flag) output()->print("(");
   584     output()->print("b"); printed_flag = true;
   585   }
   586   if (x->is_set(BlockBegin::was_visited_flag)) {
   587     if (!printed_flag) output()->print("(");
   588     output()->print("V"); printed_flag = true;
   589   }
   590   if (printed_flag) output()->print(") ");
   592   // print block bci range
   593   output()->print("[%d, %d]", x->bci(), (end == NULL ? -1 : end->printable_bci()));
   595   // print block successors
   596   if (end != NULL && end->number_of_sux() > 0) {
   597     output()->print(" ->");
   598     for (int i = 0; i < end->number_of_sux(); i++) {
   599       output()->print(" B%d", end->sux_at(i)->block_id());
   600     }
   601   }
   602   // print exception handlers
   603   if (x->number_of_exception_handlers() > 0) {
   604     output()->print(" (xhandlers ");
   605     for (int i = 0; i < x->number_of_exception_handlers();  i++) {
   606       if (i > 0) output()->print(" ");
   607       output()->print("B%d", x->exception_handler_at(i)->block_id());
   608     }
   609     output()->put(')');
   610   }
   612   // print dominator block
   613   if (x->dominator() != NULL) {
   614     output()->print(" dom B%d", x->dominator()->block_id());
   615   }
   617   // print predecessors and successors
   618   if (x->successors()->length() > 0) {
   619     output()->print(" sux:");
   620     for (int i = 0; i < x->successors()->length(); i ++) {
   621       output()->print(" B%d", x->successors()->at(i)->block_id());
   622     }
   623   }
   625   if (x->number_of_preds() > 0) {
   626     output()->print(" pred:");
   627     for (int i = 0; i < x->number_of_preds(); i ++) {
   628       output()->print(" B%d", x->pred_at(i)->block_id());
   629     }
   630   }
   632   if (!_print_phis) {
   633     return;
   634   }
   636   // print phi functions
   637   bool has_phis_in_locals = false;
   638   bool has_phis_on_stack = false;
   640   if (x->end() && x->end()->state()) {
   641     ValueStack* state = x->state();
   643     int i = 0;
   644     while (!has_phis_on_stack && i < state->stack_size()) {
   645       Value v = state->stack_at_inc(i);
   646       has_phis_on_stack = is_phi_of_block(v, x);
   647     }
   649     do {
   650       for (i = 0; !has_phis_in_locals && i < state->locals_size();) {
   651         Value v = state->local_at(i);
   652         has_phis_in_locals = is_phi_of_block(v, x);
   653         // also ignore illegal HiWords
   654         if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++;
   655       }
   656       state = state->caller_state();
   657     } while (state != NULL);
   659   }
   661   // print values in locals
   662   if (has_phis_in_locals) {
   663     output()->cr(); output()->print_cr("Locals:");
   665     ValueStack* state = x->state();
   666     do {
   667       for (int i = 0; i < state->locals_size();) {
   668         Value v = state->local_at(i);
   669         if (v) {
   670           print_phi(i, v, x); output()->cr();
   671           // also ignore illegal HiWords
   672           i += (v->type()->is_illegal() ? 1 : v->type()->size());
   673         } else {
   674           i ++;
   675         }
   676       }
   677       output()->cr();
   678       state = state->caller_state();
   679     } while (state != NULL);
   680   }
   682   // print values on stack
   683   if (has_phis_on_stack) {
   684     output()->print_cr("Stack:");
   685     int i = 0;
   686     while (i < x->state()->stack_size()) {
   687       int o = i;
   688       Value v = x->state()->stack_at_inc(i);
   689       if (v) {
   690         print_phi(o, v, x); output()->cr();
   691       }
   692     }
   693   }
   694 }
   697 void InstructionPrinter::do_CheckCast(CheckCast* x) {
   698   output()->print("checkcast(");
   699   print_value(x->obj());
   700   output()->print(") ");
   701   print_klass(x->klass());
   702 }
   705 void InstructionPrinter::do_InstanceOf(InstanceOf* x) {
   706   output()->print("instanceof(");
   707   print_value(x->obj());
   708   output()->print(") ");
   709   print_klass(x->klass());
   710 }
   713 void InstructionPrinter::do_Goto(Goto* x) {
   714   output()->print("goto B%d", x->default_sux()->block_id());
   715   if (x->is_safepoint()) output()->print(" (safepoint)");
   716 }
   719 void InstructionPrinter::do_If(If* x) {
   720   output()->print("if ");
   721   print_value(x->x());
   722   output()->print(" %s ", cond_name(x->cond()));
   723   print_value(x->y());
   724   output()->print(" then B%d else B%d", x->sux_at(0)->block_id(), x->sux_at(1)->block_id());
   725   if (x->is_safepoint()) output()->print(" (safepoint)");
   726 }
   729 void InstructionPrinter::do_IfInstanceOf(IfInstanceOf* x) {
   730   output()->print("<IfInstanceOf>");
   731 }
   734 void InstructionPrinter::do_TableSwitch(TableSwitch* x) {
   735   output()->print("tableswitch ");
   736   if (x->is_safepoint()) output()->print("(safepoint) ");
   737   print_value(x->tag());
   738   output()->cr();
   739   int l = x->length();
   740   for (int i = 0; i < l; i++) {
   741     fill_to(instr_pos);
   742     output()->print_cr("case %5d: B%d", x->lo_key() + i, x->sux_at(i)->block_id());
   743   }
   744   fill_to(instr_pos);
   745   output()->print("default   : B%d", x->default_sux()->block_id());
   746 }
   749 void InstructionPrinter::do_LookupSwitch(LookupSwitch* x) {
   750   output()->print("lookupswitch ");
   751   if (x->is_safepoint()) output()->print("(safepoint) ");
   752   print_value(x->tag());
   753   output()->cr();
   754   int l = x->length();
   755   for (int i = 0; i < l; i++) {
   756     fill_to(instr_pos);
   757     output()->print_cr("case %5d: B%d", x->key_at(i), x->sux_at(i)->block_id());
   758   }
   759   fill_to(instr_pos);
   760   output()->print("default   : B%d", x->default_sux()->block_id());
   761 }
   764 void InstructionPrinter::do_Return(Return* x) {
   765   if (x->result() == NULL) {
   766     output()->print("return");
   767   } else {
   768     output()->print("%creturn ", x->type()->tchar());
   769     print_value(x->result());
   770   }
   771 }
   774 void InstructionPrinter::do_Throw(Throw* x) {
   775   output()->print("throw ");
   776   print_value(x->exception());
   777 }
   780 void InstructionPrinter::do_Base(Base* x) {
   781   output()->print("std entry B%d", x->std_entry()->block_id());
   782   if (x->number_of_sux() > 1) {
   783     output()->print(" osr entry B%d", x->osr_entry()->block_id());
   784   }
   785 }
   788 void InstructionPrinter::do_OsrEntry(OsrEntry* x) {
   789   output()->print("osr entry");
   790 }
   793 void InstructionPrinter::do_ExceptionObject(ExceptionObject* x) {
   794   output()->print("incoming exception");
   795 }
   798 void InstructionPrinter::do_RoundFP(RoundFP* x) {
   799   output()->print("round_fp ");
   800   print_value(x->input());
   801 }
   804 void InstructionPrinter::do_UnsafeGetRaw(UnsafeGetRaw* x) {
   805   print_unsafe_raw_op(x, "UnsafeGetRaw");
   806   output()->put(')');
   807 }
   810 void InstructionPrinter::do_UnsafePutRaw(UnsafePutRaw* x) {
   811   print_unsafe_raw_op(x, "UnsafePutRaw");
   812   output()->print(", value ");
   813   print_value(x->value());
   814   output()->put(')');
   815 }
   818 void InstructionPrinter::do_UnsafeGetObject(UnsafeGetObject* x) {
   819   print_unsafe_object_op(x, "UnsafeGetObject");
   820   output()->put(')');
   821 }
   824 void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) {
   825   print_unsafe_object_op(x, "UnsafePutObject");
   826   output()->print(", value ");
   827   print_value(x->value());
   828   output()->put(')');
   829 }
   832 void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) {
   833   print_unsafe_object_op(x, "UnsafePrefetchRead");
   834   output()->put(')');
   835 }
   838 void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {
   839   print_unsafe_object_op(x, "UnsafePrefetchWrite");
   840   output()->put(')');
   841 }
   843 void InstructionPrinter::do_ProfileCall(ProfileCall* x) {
   844   output()->print("profile ");
   845   print_value(x->recv());
   846   output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
   847   if (x->known_holder() != NULL) {
   848     output()->print(", ");
   849     print_klass(x->known_holder());
   850   }
   851   output()->put(')');
   852 }
   854 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
   855   output()->print("profile_invoke ");
   856   output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
   857   output()->put(')');
   859 }
   861 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
   862   output()->print("call_rt %s(", x->entry_name());
   863   for (int i = 0; i < x->number_of_arguments(); i++) {
   864     if (i > 0) output()->print(", ");
   865     print_value(x->argument_at(i));
   866   }
   867   output()->put(')');
   868 }
   870 void InstructionPrinter::do_MemBar(MemBar* x) {
   871   if (os::is_MP()) {
   872     LIR_Code code = x->code();
   873     switch (code) {
   874       case lir_membar_acquire   : output()->print("membar_acquire"); break;
   875       case lir_membar_release   : output()->print("membar_release"); break;
   876       case lir_membar           : output()->print("membar"); break;
   877       case lir_membar_loadload  : output()->print("membar_loadload"); break;
   878       case lir_membar_storestore: output()->print("membar_storestore"); break;
   879       case lir_membar_loadstore : output()->print("membar_loadstore"); break;
   880       case lir_membar_storeload : output()->print("membar_storeload"); break;
   881       default                   : ShouldNotReachHere(); break;
   882     }
   883   }
   884 }
   886 #endif // PRODUCT

mercurial