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 */
24
25 #include "c1/c1_InstructionPrinter.hpp"
26 #include "c1/c1_ValueStack.hpp"
27 #include "ci/ciArray.hpp"
28 #include "ci/ciInstance.hpp"
29 #include "ci/ciObject.hpp"
30 #include "classfile/vmSymbols.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 "!=";
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, '/');
828 output()->print(", ");
829 print_klass(x->known_holder());
830 output()->print(" ");
831 }
832 for (int i = 0; i < x->nb_profiled_args(); i++) {
833 if (i > 0) output()->print(", ");
834 print_value(x->profiled_arg_at(i));
835 if (x->arg_needs_null_check(i)) {
836 output()->print(" [NC]");
837 }
838 }
839 output()->put(')');
840 }
841
842 void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) {
843 output()->print("profile ret type ");
844 print_value(x->ret());
845 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
846 output()->put(')');
847 }
848 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
849 output()->print("profile_invoke ");
850 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
851 output()->put(')');
852
853 }
854
855 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
856 output()->print("call_rt %s(", x->entry_name());
857 for (int i = 0; i < x->number_of_arguments(); i++) {
858 if (i > 0) output()->print(", ");
859 print_value(x->argument_at(i));
860 }
861 output()->put(')');
862 }
863
864 void InstructionPrinter::do_MemBar(MemBar* x) {
865 LIR_Code code = x->code();
866 switch (code) {
867 case lir_membar_acquire : output()->print("membar_acquire"); break;
868 case lir_membar_release : output()->print("membar_release"); break;
869 case lir_membar : output()->print("membar"); break;
870 case lir_membar_loadload : output()->print("membar_loadload"); break;
871 case lir_membar_storestore: output()->print("membar_storestore"); break;
872 case lir_membar_loadstore : output()->print("membar_loadstore"); break;
873 case lir_membar_storeload : output()->print("membar_storeload"); break;
874 default : ShouldNotReachHere(); break;
|
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 */
24
25 #include "c1/c1_InstructionPrinter.hpp"
26 #include "c1/c1_ValueStack.hpp"
27 #include "ci/ciArray.hpp"
28 #include "ci/ciInlineKlass.hpp"
29 #include "ci/ciInstance.hpp"
30 #include "ci/ciObject.hpp"
31 #include "classfile/vmSymbols.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 "!=";
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, '/');
832 output()->print(", ");
833 print_klass(x->known_holder());
834 output()->print(" ");
835 }
836 for (int i = 0; i < x->nb_profiled_args(); i++) {
837 if (i > 0) output()->print(", ");
838 print_value(x->profiled_arg_at(i));
839 if (x->arg_needs_null_check(i)) {
840 output()->print(" [NC]");
841 }
842 }
843 output()->put(')');
844 }
845
846 void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) {
847 output()->print("profile ret type ");
848 print_value(x->ret());
849 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
850 output()->put(')');
851 }
852
853 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
854 output()->print("profile_invoke ");
855 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
856 output()->put(')');
857
858 }
859
860 void InstructionPrinter::do_ProfileACmpTypes(ProfileACmpTypes* x) {
861 output()->print("profile acmp types ");
862 print_value(x->left());
863 output()->print(", ");
864 print_value(x->right());
865 }
866
867 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
868 output()->print("call_rt %s(", x->entry_name());
869 for (int i = 0; i < x->number_of_arguments(); i++) {
870 if (i > 0) output()->print(", ");
871 print_value(x->argument_at(i));
872 }
873 output()->put(')');
874 }
875
876 void InstructionPrinter::do_MemBar(MemBar* x) {
877 LIR_Code code = x->code();
878 switch (code) {
879 case lir_membar_acquire : output()->print("membar_acquire"); break;
880 case lir_membar_release : output()->print("membar_release"); break;
881 case lir_membar : output()->print("membar"); break;
882 case lir_membar_loadload : output()->print("membar_loadload"); break;
883 case lir_membar_storestore: output()->print("membar_storestore"); break;
884 case lir_membar_loadstore : output()->print("membar_loadstore"); break;
885 case lir_membar_storeload : output()->print("membar_storeload"); break;
886 default : ShouldNotReachHere(); break;
|