1 /*
2 * Copyright (c) 1999, 2017, 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 */
24
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"
31
32
33 #ifndef PRODUCT
34
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 }
50
51
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 case If::aeq: return "|>=|";
61 case If::beq: return "|<=|";
62 default:
63 ShouldNotReachHere();
64 return NULL;
65 }
66 }
499 fill_to(instr_pos);
500 output()->print("%s.%s%s",
501 x->target()->holder()->name()->as_utf8(),
502 x->target()->name()->as_utf8(),
503 x->target()->signature()->as_symbol()->as_utf8());
504 }
505
506
507 void InstructionPrinter::do_NewInstance(NewInstance* x) {
508 output()->print("new instance ");
509 print_klass(x->klass());
510 }
511
512
513 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
514 output()->print("new %s array [", basic_type_name(x->elt_type()));
515 print_value(x->length());
516 output()->put(']');
517 }
518
519
520 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
521 output()->print("new object array [");
522 print_value(x->length());
523 output()->print("] ");
524 print_klass(x->klass());
525 }
526
527
528 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
529 output()->print("new multi array [");
530 Values* dims = x->dims();
531 for (int i = 0; i < dims->length(); i++) {
532 if (i > 0) output()->print(", ");
533 print_value(dims->at(i));
534 }
535 output()->print("] ");
536 print_klass(x->klass());
537 }
538
|
1 /*
2 * Copyright (c) 1999, 2018, 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 */
24
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"
31 #include "ci/ciValueKlass.hpp"
32
33
34 #ifndef PRODUCT
35
36 const char* InstructionPrinter::basic_type_name(BasicType type) {
37 switch (type) {
38 case T_BOOLEAN: return "boolean";
39 case T_BYTE : return "byte";
40 case T_CHAR : return "char";
41 case T_SHORT : return "short";
42 case T_INT : return "int";
43 case T_LONG : return "long";
44 case T_FLOAT : return "float";
45 case T_DOUBLE : return "double";
46 case T_ARRAY : return "array";
47 case T_OBJECT : return "object";
48 case T_VALUETYPE : return "value type";
49 default : return "???";
50 }
51 }
52
53
54 const char* InstructionPrinter::cond_name(If::Condition cond) {
55 switch (cond) {
56 case If::eql: return "==";
57 case If::neq: return "!=";
58 case If::lss: return "<";
59 case If::leq: return "<=";
60 case If::gtr: return ">";
61 case If::geq: return ">=";
62 case If::aeq: return "|>=|";
63 case If::beq: return "|<=|";
64 default:
65 ShouldNotReachHere();
66 return NULL;
67 }
68 }
501 fill_to(instr_pos);
502 output()->print("%s.%s%s",
503 x->target()->holder()->name()->as_utf8(),
504 x->target()->name()->as_utf8(),
505 x->target()->signature()->as_symbol()->as_utf8());
506 }
507
508
509 void InstructionPrinter::do_NewInstance(NewInstance* x) {
510 output()->print("new instance ");
511 print_klass(x->klass());
512 }
513
514
515 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
516 output()->print("new %s array [", basic_type_name(x->elt_type()));
517 print_value(x->length());
518 output()->put(']');
519 }
520
521 void InstructionPrinter::do_NewValueTypeInstance(NewValueTypeInstance* x) {
522 output()->print("new value type instance ");
523 print_klass(x->klass());
524 }
525
526 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
527 output()->print("new object array [");
528 print_value(x->length());
529 output()->print("] ");
530 print_klass(x->klass());
531 }
532
533
534 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
535 output()->print("new multi array [");
536 Values* dims = x->dims();
537 for (int i = 0; i < dims->length(); i++) {
538 if (i > 0) output()->print(", ");
539 print_value(dims->at(i));
540 }
541 output()->print("] ");
542 print_klass(x->klass());
543 }
544
|