< prev index next >

src/hotspot/share/c1/c1_InstructionPrinter.cpp

Print this page

  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  */
 24 
 25 #include "classfile/vmSymbols.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"
 31 
 32 
 33 #ifndef PRODUCT
 34 
 35 const char* InstructionPrinter::basic_type_name(BasicType type) {
 36   const char* n = type2name(type);
 37   if (n == nullptr || type > T_VOID) {
 38     return "???";
 39   }
 40   return n;
 41 }
 42 
 43 
 44 const char* InstructionPrinter::cond_name(If::Condition cond) {
 45   switch (cond) {
 46     case If::eql: return "==";
 47     case If::neq: return "!=";
 48     case If::lss: return "<";

363 }
364 
365 
366 void InstructionPrinter::do_StoreField(StoreField* x) {
367   print_field(x);
368   output()->print(" := ");
369   print_value(x->value());
370   output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
371   output()->print(" %s", x->field()->name()->as_utf8());
372 }
373 
374 
375 void InstructionPrinter::do_ArrayLength(ArrayLength* x) {
376   print_value(x->array());
377   output()->print(".length");
378 }
379 
380 
381 void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
382   print_indexed(x);
383   output()->print(" (%c)", type2char(x->elt_type()));





384   if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
385     output()->print(" [rc]");
386   }
387 }
388 
389 
390 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
391   print_indexed(x);
392   output()->print(" := ");
393   print_value(x->value());
394   output()->print(" (%c)", type2char(x->elt_type()));
395   if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
396     output()->print(" [rc]");
397   }
398 }
399 
400 void InstructionPrinter::do_NegateOp(NegateOp* x) {
401   output()->put('-');
402   print_value(x->x());
403 }

477   fill_to(instr_pos);
478   output()->print("%s.%s%s",
479              x->target()->holder()->name()->as_utf8(),
480              x->target()->name()->as_utf8(),
481              x->target()->signature()->as_symbol()->as_utf8());
482 }
483 
484 
485 void InstructionPrinter::do_NewInstance(NewInstance* x) {
486   output()->print("new instance ");
487   print_klass(x->klass());
488 }
489 
490 
491 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
492   output()->print("new %s array [", basic_type_name(x->elt_type()));
493   print_value(x->length());
494   output()->put(']');
495 }
496 
497 
498 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
499   output()->print("new object array [");
500   print_value(x->length());
501   output()->print("] ");
502   print_klass(x->klass());
503 }
504 
505 
506 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
507   output()->print("new multi array [");
508   Values* dims = x->dims();
509   for (int i = 0; i < dims->length(); i++) {
510     if (i > 0) output()->print(", ");
511     print_value(dims->at(i));
512   }
513   output()->print("] ");
514   print_klass(x->klass());
515 }
516 
517 
518 void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) {
519   output()->print("enter ");
520   print_monitor(x);
521 }
522 
523 
524 void InstructionPrinter::do_MonitorExit(MonitorExit* x) {
525   output()->print("exit ");
526   print_monitor(x);
527 }
528 
529 
530 void InstructionPrinter::do_Intrinsic(Intrinsic* x) {
531   const char* name = vmIntrinsics::name_at(x->id());
532   if (name[0] == '_')  name++;  // strip leading bug from _hashCode, etc.
533   const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id()));
534   if (strchr(name, '_') == nullptr) {
535     kname = nullptr;
536   } else {
537     const char* kptr = strrchr(kname, '/');

834     output()->print(", ");
835     print_klass(x->known_holder());
836     output()->print(" ");
837   }
838   for (int i = 0; i < x->nb_profiled_args(); i++) {
839     if (i > 0) output()->print(", ");
840     print_value(x->profiled_arg_at(i));
841     if (x->arg_needs_null_check(i)) {
842       output()->print(" [NC]");
843     }
844   }
845   output()->put(')');
846 }
847 
848 void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) {
849   output()->print("profile ret type ");
850   print_value(x->ret());
851   output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
852   output()->put(')');
853 }

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(')');
858 
859 }
860 







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 }
869 
870 void InstructionPrinter::do_MemBar(MemBar* x) {
871   LIR_Code code = x->code();
872   switch (code) {
873   case lir_membar_acquire   : output()->print("membar_acquire"); break;
874   case lir_membar_release   : output()->print("membar_release"); break;
875   case lir_membar           : output()->print("membar"); break;
876   case lir_membar_loadload  : output()->print("membar_loadload"); break;
877   case lir_membar_storestore: output()->print("membar_storestore"); break;
878   case lir_membar_loadstore : output()->print("membar_loadstore"); break;
879   case lir_membar_storeload : output()->print("membar_storeload"); break;
880   default                   : ShouldNotReachHere(); break;

  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  */
 24 
 25 #include "classfile/vmSymbols.hpp"
 26 #include "c1/c1_InstructionPrinter.hpp"
 27 #include "c1/c1_ValueStack.hpp"
 28 #include "ci/ciArray.hpp"
 29 #include "ci/ciInlineKlass.hpp"
 30 #include "ci/ciInstance.hpp"
 31 #include "ci/ciObject.hpp"
 32 
 33 
 34 #ifndef PRODUCT
 35 
 36 const char* InstructionPrinter::basic_type_name(BasicType type) {
 37   const char* n = type2name(type);
 38   if (n == nullptr || type > T_VOID) {
 39     return "???";
 40   }
 41   return n;
 42 }
 43 
 44 
 45 const char* InstructionPrinter::cond_name(If::Condition cond) {
 46   switch (cond) {
 47     case If::eql: return "==";
 48     case If::neq: return "!=";
 49     case If::lss: return "<";

364 }
365 
366 
367 void InstructionPrinter::do_StoreField(StoreField* x) {
368   print_field(x);
369   output()->print(" := ");
370   print_value(x->value());
371   output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
372   output()->print(" %s", x->field()->name()->as_utf8());
373 }
374 
375 
376 void InstructionPrinter::do_ArrayLength(ArrayLength* x) {
377   print_value(x->array());
378   output()->print(".length");
379 }
380 
381 
382 void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
383   print_indexed(x);
384   if (x->delayed() != nullptr) {
385     output()->print(" +%d", x->delayed()->offset());
386     output()->print(" (%c)", type2char(x->delayed()->field()->type()->basic_type()));
387   } else {
388     output()->print(" (%c)", type2char(x->elt_type()));
389   }
390   if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
391     output()->print(" [rc]");
392   }
393 }
394 
395 
396 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
397   print_indexed(x);
398   output()->print(" := ");
399   print_value(x->value());
400   output()->print(" (%c)", type2char(x->elt_type()));
401   if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
402     output()->print(" [rc]");
403   }
404 }
405 
406 void InstructionPrinter::do_NegateOp(NegateOp* x) {
407   output()->put('-');
408   print_value(x->x());
409 }

483   fill_to(instr_pos);
484   output()->print("%s.%s%s",
485              x->target()->holder()->name()->as_utf8(),
486              x->target()->name()->as_utf8(),
487              x->target()->signature()->as_symbol()->as_utf8());
488 }
489 
490 
491 void InstructionPrinter::do_NewInstance(NewInstance* x) {
492   output()->print("new instance ");
493   print_klass(x->klass());
494 }
495 
496 
497 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
498   output()->print("new %s array [", basic_type_name(x->elt_type()));
499   print_value(x->length());
500   output()->put(']');
501 }
502 

503 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
504   output()->print("new object array [");
505   print_value(x->length());
506   output()->print("] ");
507   print_klass(x->klass());
508 }
509 
510 
511 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
512   output()->print("new multi array [");
513   Values* dims = x->dims();
514   for (int i = 0; i < dims->length(); i++) {
515     if (i > 0) output()->print(", ");
516     print_value(dims->at(i));
517   }
518   output()->print("] ");
519   print_klass(x->klass());
520 }
521 

522 void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) {
523   output()->print("enter ");
524   print_monitor(x);
525 }
526 
527 
528 void InstructionPrinter::do_MonitorExit(MonitorExit* x) {
529   output()->print("exit ");
530   print_monitor(x);
531 }
532 
533 
534 void InstructionPrinter::do_Intrinsic(Intrinsic* x) {
535   const char* name = vmIntrinsics::name_at(x->id());
536   if (name[0] == '_')  name++;  // strip leading bug from _hashCode, etc.
537   const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id()));
538   if (strchr(name, '_') == nullptr) {
539     kname = nullptr;
540   } else {
541     const char* kptr = strrchr(kname, '/');

838     output()->print(", ");
839     print_klass(x->known_holder());
840     output()->print(" ");
841   }
842   for (int i = 0; i < x->nb_profiled_args(); i++) {
843     if (i > 0) output()->print(", ");
844     print_value(x->profiled_arg_at(i));
845     if (x->arg_needs_null_check(i)) {
846       output()->print(" [NC]");
847     }
848   }
849   output()->put(')');
850 }
851 
852 void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) {
853   output()->print("profile ret type ");
854   print_value(x->ret());
855   output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
856   output()->put(')');
857 }
858 
859 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
860   output()->print("profile_invoke ");
861   output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
862   output()->put(')');
863 
864 }
865 
866 void InstructionPrinter::do_ProfileACmpTypes(ProfileACmpTypes* x) {
867   output()->print("profile acmp types ");
868   print_value(x->left());
869   output()->print(", ");
870   print_value(x->right());
871 }
872 
873 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
874   output()->print("call_rt %s(", x->entry_name());
875   for (int i = 0; i < x->number_of_arguments(); i++) {
876     if (i > 0) output()->print(", ");
877     print_value(x->argument_at(i));
878   }
879   output()->put(')');
880 }
881 
882 void InstructionPrinter::do_MemBar(MemBar* x) {
883   LIR_Code code = x->code();
884   switch (code) {
885   case lir_membar_acquire   : output()->print("membar_acquire"); break;
886   case lir_membar_release   : output()->print("membar_release"); break;
887   case lir_membar           : output()->print("membar"); break;
888   case lir_membar_loadload  : output()->print("membar_loadload"); break;
889   case lir_membar_storestore: output()->print("membar_storestore"); break;
890   case lir_membar_loadstore : output()->print("membar_loadstore"); break;
891   case lir_membar_storeload : output()->print("membar_storeload"); break;
892   default                   : ShouldNotReachHere(); break;
< prev index next >