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 "precompiled.hpp"
26 #include "classfile/vmSymbols.hpp"
27 #include "c1/c1_InstructionPrinter.hpp"
28 #include "c1/c1_ValueStack.hpp"
29 #include "ci/ciArray.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 output()->print(" (%c)", type2char(x->elt_type()));
385 if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
386 output()->print(" [rc]");
387 }
388 }
389
390
391 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
392 print_indexed(x);
393 output()->print(" := ");
394 print_value(x->value());
395 output()->print(" (%c)", type2char(x->elt_type()));
396 if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
397 output()->print(" [rc]");
398 }
399 }
400
401 void InstructionPrinter::do_NegateOp(NegateOp* x) {
402 output()->put('-');
403 print_value(x->x());
404 }
478 fill_to(instr_pos);
479 output()->print("%s.%s%s",
480 x->target()->holder()->name()->as_utf8(),
481 x->target()->name()->as_utf8(),
482 x->target()->signature()->as_symbol()->as_utf8());
483 }
484
485
486 void InstructionPrinter::do_NewInstance(NewInstance* x) {
487 output()->print("new instance ");
488 print_klass(x->klass());
489 }
490
491
492 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
493 output()->print("new %s array [", basic_type_name(x->elt_type()));
494 print_value(x->length());
495 output()->put(']');
496 }
497
498
499 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
500 output()->print("new object array [");
501 print_value(x->length());
502 output()->print("] ");
503 print_klass(x->klass());
504 }
505
506
507 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
508 output()->print("new multi array [");
509 Values* dims = x->dims();
510 for (int i = 0; i < dims->length(); i++) {
511 if (i > 0) output()->print(", ");
512 print_value(dims->at(i));
513 }
514 output()->print("] ");
515 print_klass(x->klass());
516 }
517
518
519 void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) {
520 output()->print("enter ");
521 print_monitor(x);
522 }
523
524
525 void InstructionPrinter::do_MonitorExit(MonitorExit* x) {
526 output()->print("exit ");
527 print_monitor(x);
528 }
529
530
531 void InstructionPrinter::do_Intrinsic(Intrinsic* x) {
532 const char* name = vmIntrinsics::name_at(x->id());
533 if (name[0] == '_') name++; // strip leading bug from _hashCode, etc.
534 const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id()));
535 if (strchr(name, '_') == nullptr) {
536 kname = nullptr;
537 } else {
538 const char* kptr = strrchr(kname, '/');
835 output()->print(", ");
836 print_klass(x->known_holder());
837 output()->print(" ");
838 }
839 for (int i = 0; i < x->nb_profiled_args(); i++) {
840 if (i > 0) output()->print(", ");
841 print_value(x->profiled_arg_at(i));
842 if (x->arg_needs_null_check(i)) {
843 output()->print(" [NC]");
844 }
845 }
846 output()->put(')');
847 }
848
849 void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) {
850 output()->print("profile ret type ");
851 print_value(x->ret());
852 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
853 output()->put(')');
854 }
855 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
856 output()->print("profile_invoke ");
857 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
858 output()->put(')');
859
860 }
861
862 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
863 output()->print("call_rt %s(", x->entry_name());
864 for (int i = 0; i < x->number_of_arguments(); i++) {
865 if (i > 0) output()->print(", ");
866 print_value(x->argument_at(i));
867 }
868 output()->put(')');
869 }
870
871 void InstructionPrinter::do_MemBar(MemBar* x) {
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;
|
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 "precompiled.hpp"
26 #include "classfile/vmSymbols.hpp"
27 #include "c1/c1_InstructionPrinter.hpp"
28 #include "c1/c1_ValueStack.hpp"
29 #include "ci/ciArray.hpp"
30 #include "ci/ciInlineKlass.hpp"
31 #include "ci/ciInstance.hpp"
32 #include "ci/ciObject.hpp"
33
34
35 #ifndef PRODUCT
36
37 const char* InstructionPrinter::basic_type_name(BasicType type) {
38 const char* n = type2name(type);
39 if (n == nullptr || type > T_VOID) {
40 return "???";
41 }
42 return n;
43 }
44
45
46 const char* InstructionPrinter::cond_name(If::Condition cond) {
47 switch (cond) {
48 case If::eql: return "==";
49 case If::neq: return "!=";
50 case If::lss: return "<";
365 }
366
367
368 void InstructionPrinter::do_StoreField(StoreField* x) {
369 print_field(x);
370 output()->print(" := ");
371 print_value(x->value());
372 output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
373 output()->print(" %s", x->field()->name()->as_utf8());
374 }
375
376
377 void InstructionPrinter::do_ArrayLength(ArrayLength* x) {
378 print_value(x->array());
379 output()->print(".length");
380 }
381
382
383 void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
384 print_indexed(x);
385 if (x->delayed() != nullptr) {
386 output()->print(" +%d", x->delayed()->offset());
387 output()->print(" (%c)", type2char(x->delayed()->field()->type()->basic_type()));
388 } else {
389 output()->print(" (%c)", type2char(x->elt_type()));
390 }
391 if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
392 output()->print(" [rc]");
393 }
394 }
395
396
397 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
398 print_indexed(x);
399 output()->print(" := ");
400 print_value(x->value());
401 output()->print(" (%c)", type2char(x->elt_type()));
402 if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
403 output()->print(" [rc]");
404 }
405 }
406
407 void InstructionPrinter::do_NegateOp(NegateOp* x) {
408 output()->put('-');
409 print_value(x->x());
410 }
484 fill_to(instr_pos);
485 output()->print("%s.%s%s",
486 x->target()->holder()->name()->as_utf8(),
487 x->target()->name()->as_utf8(),
488 x->target()->signature()->as_symbol()->as_utf8());
489 }
490
491
492 void InstructionPrinter::do_NewInstance(NewInstance* x) {
493 output()->print("new instance ");
494 print_klass(x->klass());
495 }
496
497
498 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
499 output()->print("new %s array [", basic_type_name(x->elt_type()));
500 print_value(x->length());
501 output()->put(']');
502 }
503
504 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
505 output()->print("new object array [");
506 print_value(x->length());
507 output()->print("] ");
508 print_klass(x->klass());
509 }
510
511
512 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
513 output()->print("new multi array [");
514 Values* dims = x->dims();
515 for (int i = 0; i < dims->length(); i++) {
516 if (i > 0) output()->print(", ");
517 print_value(dims->at(i));
518 }
519 output()->print("] ");
520 print_klass(x->klass());
521 }
522
523 void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) {
524 output()->print("enter ");
525 print_monitor(x);
526 }
527
528
529 void InstructionPrinter::do_MonitorExit(MonitorExit* x) {
530 output()->print("exit ");
531 print_monitor(x);
532 }
533
534
535 void InstructionPrinter::do_Intrinsic(Intrinsic* x) {
536 const char* name = vmIntrinsics::name_at(x->id());
537 if (name[0] == '_') name++; // strip leading bug from _hashCode, etc.
538 const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id()));
539 if (strchr(name, '_') == nullptr) {
540 kname = nullptr;
541 } else {
542 const char* kptr = strrchr(kname, '/');
839 output()->print(", ");
840 print_klass(x->known_holder());
841 output()->print(" ");
842 }
843 for (int i = 0; i < x->nb_profiled_args(); i++) {
844 if (i > 0) output()->print(", ");
845 print_value(x->profiled_arg_at(i));
846 if (x->arg_needs_null_check(i)) {
847 output()->print(" [NC]");
848 }
849 }
850 output()->put(')');
851 }
852
853 void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) {
854 output()->print("profile ret type ");
855 print_value(x->ret());
856 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
857 output()->put(')');
858 }
859
860 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
861 output()->print("profile_invoke ");
862 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
863 output()->put(')');
864
865 }
866
867 void InstructionPrinter::do_ProfileACmpTypes(ProfileACmpTypes* x) {
868 output()->print("profile acmp types ");
869 print_value(x->left());
870 output()->print(", ");
871 print_value(x->right());
872 }
873
874 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
875 output()->print("call_rt %s(", x->entry_name());
876 for (int i = 0; i < x->number_of_arguments(); i++) {
877 if (i > 0) output()->print(", ");
878 print_value(x->argument_at(i));
879 }
880 output()->put(')');
881 }
882
883 void InstructionPrinter::do_MemBar(MemBar* x) {
884 LIR_Code code = x->code();
885 switch (code) {
886 case lir_membar_acquire : output()->print("membar_acquire"); break;
887 case lir_membar_release : output()->print("membar_release"); break;
888 case lir_membar : output()->print("membar"); break;
889 case lir_membar_loadload : output()->print("membar_loadload"); break;
890 case lir_membar_storestore: output()->print("membar_storestore"); break;
891 case lir_membar_loadstore : output()->print("membar_loadstore"); break;
892 case lir_membar_storeload : output()->print("membar_storeload"); break;
893 default : ShouldNotReachHere(); break;
|