Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/c1/c1_InstructionPrinter.cpp
40930 views
1
/*
2
* Copyright (c) 1999, 2019, 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 "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 == NULL || 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 "<";
50
case If::leq: return "<=";
51
case If::gtr: return ">";
52
case If::geq: return ">=";
53
case If::aeq: return "|>=|";
54
case If::beq: return "|<=|";
55
default:
56
ShouldNotReachHere();
57
return NULL;
58
}
59
}
60
61
62
const char* InstructionPrinter::op_name(Bytecodes::Code op) {
63
switch (op) {
64
// arithmetic ops
65
case Bytecodes::_iadd : // fall through
66
case Bytecodes::_ladd : // fall through
67
case Bytecodes::_fadd : // fall through
68
case Bytecodes::_dadd : return "+";
69
case Bytecodes::_isub : // fall through
70
case Bytecodes::_lsub : // fall through
71
case Bytecodes::_fsub : // fall through
72
case Bytecodes::_dsub : return "-";
73
case Bytecodes::_imul : // fall through
74
case Bytecodes::_lmul : // fall through
75
case Bytecodes::_fmul : // fall through
76
case Bytecodes::_dmul : return "*";
77
case Bytecodes::_idiv : // fall through
78
case Bytecodes::_ldiv : // fall through
79
case Bytecodes::_fdiv : // fall through
80
case Bytecodes::_ddiv : return "/";
81
case Bytecodes::_irem : // fall through
82
case Bytecodes::_lrem : // fall through
83
case Bytecodes::_frem : // fall through
84
case Bytecodes::_drem : return "%";
85
// shift ops
86
case Bytecodes::_ishl : // fall through
87
case Bytecodes::_lshl : return "<<";
88
case Bytecodes::_ishr : // fall through
89
case Bytecodes::_lshr : return ">>";
90
case Bytecodes::_iushr: // fall through
91
case Bytecodes::_lushr: return ">>>";
92
// logic ops
93
case Bytecodes::_iand : // fall through
94
case Bytecodes::_land : return "&";
95
case Bytecodes::_ior : // fall through
96
case Bytecodes::_lor : return "|";
97
case Bytecodes::_ixor : // fall through
98
case Bytecodes::_lxor : return "^";
99
default : return Bytecodes::name(op);
100
}
101
}
102
103
104
bool InstructionPrinter::is_illegal_phi(Value v) {
105
Phi* phi = v ? v->as_Phi() : NULL;
106
if (phi && phi->is_illegal()) {
107
return true;
108
}
109
return false;
110
}
111
112
113
bool InstructionPrinter::is_phi_of_block(Value v, BlockBegin* b) {
114
Phi* phi = v ? v->as_Phi() : NULL;
115
return phi && phi->block() == b;
116
}
117
118
119
void InstructionPrinter::print_klass(ciKlass* klass) {
120
klass->name()->print_symbol_on(output());
121
}
122
123
124
void InstructionPrinter::print_object(Value obj) {
125
ValueType* type = obj->type();
126
if (type->as_ObjectConstant() != NULL) {
127
ciObject* value = type->as_ObjectConstant()->value();
128
if (value->is_null_object()) {
129
output()->print("null");
130
} else if (!value->is_loaded()) {
131
output()->print("<unloaded object " INTPTR_FORMAT ">", p2i(value));
132
} else {
133
output()->print("<object " INTPTR_FORMAT " klass=", p2i(value->constant_encoding()));
134
print_klass(value->klass());
135
output()->print(">");
136
}
137
} else if (type->as_InstanceConstant() != NULL) {
138
ciInstance* value = type->as_InstanceConstant()->value();
139
if (value->is_loaded()) {
140
output()->print("<instance " INTPTR_FORMAT " klass=", p2i(value->constant_encoding()));
141
print_klass(value->klass());
142
output()->print(">");
143
} else {
144
output()->print("<unloaded instance " INTPTR_FORMAT ">", p2i(value));
145
}
146
} else if (type->as_ArrayConstant() != NULL) {
147
output()->print("<array " INTPTR_FORMAT ">", p2i(type->as_ArrayConstant()->value()->constant_encoding()));
148
} else if (type->as_ClassConstant() != NULL) {
149
ciInstanceKlass* klass = type->as_ClassConstant()->value();
150
if (!klass->is_loaded()) {
151
output()->print("<unloaded> ");
152
}
153
output()->print("class ");
154
print_klass(klass);
155
} else if (type->as_MethodConstant() != NULL) {
156
ciMethod* m = type->as_MethodConstant()->value();
157
output()->print("<method %s.%s>", m->holder()->name()->as_utf8(), m->name()->as_utf8());
158
} else {
159
output()->print("???");
160
}
161
}
162
163
164
void InstructionPrinter::print_temp(Value value) {
165
output()->print("%c%d", value->type()->tchar(), value->id());
166
}
167
168
169
void InstructionPrinter::print_field(AccessField* field) {
170
print_value(field->obj());
171
output()->print("._%d", field->offset());
172
}
173
174
175
void InstructionPrinter::print_indexed(AccessIndexed* indexed) {
176
print_value(indexed->array());
177
output()->put('[');
178
print_value(indexed->index());
179
output()->put(']');
180
if (indexed->length() != NULL) {
181
output()->put('(');
182
print_value(indexed->length());
183
output()->put(')');
184
}
185
}
186
187
188
void InstructionPrinter::print_monitor(AccessMonitor* monitor) {
189
output()->print("monitor[%d](", monitor->monitor_no());
190
print_value(monitor->obj());
191
output()->put(')');
192
}
193
194
195
void InstructionPrinter::print_op2(Op2* instr) {
196
print_value(instr->x());
197
output()->print(" %s ", op_name(instr->op()));
198
print_value(instr->y());
199
}
200
201
202
void InstructionPrinter::print_value(Value value) {
203
if (value == NULL) {
204
output()->print("NULL");
205
} else {
206
print_temp(value);
207
}
208
}
209
210
211
void InstructionPrinter::print_instr(Instruction* instr) {
212
instr->visit(this);
213
}
214
215
216
void InstructionPrinter::print_stack(ValueStack* stack) {
217
int start_position = output()->position();
218
if (stack->stack_is_empty()) {
219
output()->print("empty stack");
220
} else {
221
output()->print("stack [");
222
for (int i = 0; i < stack->stack_size();) {
223
if (i > 0) output()->print(", ");
224
output()->print("%d:", i);
225
Value value = stack->stack_at_inc(i);
226
print_value(value);
227
Phi* phi = value->as_Phi();
228
if (phi != NULL) {
229
if (phi->operand()->is_valid()) {
230
output()->print(" ");
231
phi->operand()->print(output());
232
}
233
}
234
}
235
output()->put(']');
236
}
237
if (!stack->no_active_locks()) {
238
// print out the lines on the line below this
239
// one at the same indentation level.
240
output()->cr();
241
fill_to(start_position, ' ');
242
output()->print("locks [");
243
for (int i = 0; i < stack->locks_size(); i++) {
244
Value t = stack->lock_at(i);
245
if (i > 0) output()->print(", ");
246
output()->print("%d:", i);
247
if (t == NULL) {
248
// synchronized methods push null on the lock stack
249
output()->print("this");
250
} else {
251
print_value(t);
252
}
253
}
254
output()->print("]");
255
}
256
}
257
258
259
void InstructionPrinter::print_inline_level(BlockBegin* block) {
260
output()->print_cr("inlining depth %d", block->scope()->level());
261
}
262
263
264
void InstructionPrinter::print_unsafe_op(UnsafeOp* op, const char* name) {
265
output()->print("%s", name);
266
output()->print(".(");
267
}
268
269
void InstructionPrinter::print_unsafe_raw_op(UnsafeRawOp* op, const char* name) {
270
print_unsafe_op(op, name);
271
output()->print("base ");
272
print_value(op->base());
273
if (op->has_index()) {
274
output()->print(", index "); print_value(op->index());
275
output()->print(", log2_scale %d", op->log2_scale());
276
}
277
}
278
279
280
void InstructionPrinter::print_unsafe_object_op(UnsafeObjectOp* op, const char* name) {
281
print_unsafe_op(op, name);
282
print_value(op->object());
283
output()->print(", ");
284
print_value(op->offset());
285
}
286
287
288
void InstructionPrinter::print_phi(int i, Value v, BlockBegin* b) {
289
Phi* phi = v->as_Phi();
290
output()->print("%2d ", i);
291
print_value(v);
292
// print phi operands
293
if (phi && phi->block() == b) {
294
output()->print(" [");
295
for (int j = 0; j < phi->operand_count(); j ++) {
296
output()->print(" ");
297
Value opd = phi->operand_at(j);
298
if (opd) print_value(opd);
299
else output()->print("NULL");
300
}
301
output()->print("] ");
302
}
303
print_alias(v);
304
}
305
306
307
void InstructionPrinter::print_alias(Value v) {
308
if (v != v->subst()) {
309
output()->print("alias "); print_value(v->subst());
310
}
311
}
312
313
314
void InstructionPrinter::fill_to(int pos, char filler) {
315
while (output()->position() < pos) output()->put(filler);
316
}
317
318
319
void InstructionPrinter::print_head() {
320
const char filler = '_';
321
fill_to(bci_pos , filler); output()->print("bci" );
322
fill_to(use_pos , filler); output()->print("use" );
323
fill_to(temp_pos , filler); output()->print("tid" );
324
fill_to(instr_pos, filler); output()->print("instr");
325
fill_to(end_pos , filler);
326
output()->cr();
327
}
328
329
330
void InstructionPrinter::print_line(Instruction* instr) {
331
// print instruction data on one line
332
if (instr->is_pinned()) output()->put('.');
333
if (instr->has_printable_bci()) {
334
fill_to(bci_pos ); output()->print("%d", instr->printable_bci());
335
}
336
fill_to(use_pos ); output()->print("%d", instr->use_count());
337
fill_to(temp_pos ); print_temp(instr);
338
fill_to(instr_pos); print_instr(instr);
339
output()->cr();
340
// add a line for StateSplit instructions w/ non-empty stacks
341
// (make it robust so we can print incomplete instructions)
342
StateSplit* split = instr->as_StateSplit();
343
if (split != NULL && split->state() != NULL && !split->state()->stack_is_empty()) {
344
fill_to(instr_pos); print_stack(split->state());
345
output()->cr();
346
}
347
}
348
349
350
void InstructionPrinter::do_Phi(Phi* x) {
351
output()->print("phi function"); // make that more detailed later
352
if (x->is_illegal())
353
output()->print(" (illegal)");
354
}
355
356
357
void InstructionPrinter::do_Local(Local* x) {
358
output()->print("local[index %d]", x->java_index());
359
}
360
361
362
void InstructionPrinter::do_Constant(Constant* x) {
363
ValueType* t = x->type();
364
switch (t->tag()) {
365
case intTag : output()->print("%d" , t->as_IntConstant ()->value()); break;
366
case longTag : output()->print(JLONG_FORMAT, t->as_LongConstant()->value()); output()->print("L"); break;
367
case floatTag : output()->print("%g" , t->as_FloatConstant ()->value()); break;
368
case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value()); break;
369
case objectTag : print_object(x); break;
370
case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break;
371
default : output()->print("???"); break;
372
}
373
}
374
375
376
void InstructionPrinter::do_LoadField(LoadField* x) {
377
print_field(x);
378
output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
379
output()->print(" %s", x->field()->name()->as_utf8());
380
}
381
382
383
void InstructionPrinter::do_StoreField(StoreField* x) {
384
print_field(x);
385
output()->print(" := ");
386
print_value(x->value());
387
output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
388
output()->print(" %s", x->field()->name()->as_utf8());
389
}
390
391
392
void InstructionPrinter::do_ArrayLength(ArrayLength* x) {
393
print_value(x->array());
394
output()->print(".length");
395
}
396
397
398
void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
399
print_indexed(x);
400
output()->print(" (%c)", type2char(x->elt_type()));
401
if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
402
output()->print(" [rc]");
403
}
404
}
405
406
407
void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
408
print_indexed(x);
409
output()->print(" := ");
410
print_value(x->value());
411
output()->print(" (%c)", type2char(x->elt_type()));
412
if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
413
output()->print(" [rc]");
414
}
415
}
416
417
void InstructionPrinter::do_NegateOp(NegateOp* x) {
418
output()->put('-');
419
print_value(x->x());
420
}
421
422
423
void InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) {
424
print_op2(x);
425
}
426
427
428
void InstructionPrinter::do_ShiftOp(ShiftOp* x) {
429
print_op2(x);
430
}
431
432
433
void InstructionPrinter::do_LogicOp(LogicOp* x) {
434
print_op2(x);
435
}
436
437
438
void InstructionPrinter::do_CompareOp(CompareOp* x) {
439
print_op2(x);
440
}
441
442
443
void InstructionPrinter::do_IfOp(IfOp* x) {
444
print_value(x->x());
445
output()->print(" %s ", cond_name(x->cond()));
446
print_value(x->y());
447
output()->print(" ? ");
448
print_value(x->tval());
449
output()->print(" : ");
450
print_value(x->fval());
451
}
452
453
454
void InstructionPrinter::do_Convert(Convert* x) {
455
output()->print("%s(", Bytecodes::name(x->op()));
456
print_value(x->value());
457
output()->put(')');
458
}
459
460
461
void InstructionPrinter::do_NullCheck(NullCheck* x) {
462
output()->print("null_check(");
463
print_value(x->obj());
464
output()->put(')');
465
if (!x->can_trap()) {
466
output()->print(" (eliminated)");
467
}
468
}
469
470
471
void InstructionPrinter::do_TypeCast(TypeCast* x) {
472
output()->print("type_cast(");
473
print_value(x->obj());
474
output()->print(") ");
475
if (x->declared_type()->is_klass())
476
print_klass(x->declared_type()->as_klass());
477
else
478
output()->print("%s", type2name(x->declared_type()->basic_type()));
479
}
480
481
482
void InstructionPrinter::do_Invoke(Invoke* x) {
483
if (x->receiver() != NULL) {
484
print_value(x->receiver());
485
output()->print(".");
486
}
487
488
output()->print("%s(", Bytecodes::name(x->code()));
489
for (int i = 0; i < x->number_of_arguments(); i++) {
490
if (i > 0) output()->print(", ");
491
print_value(x->argument_at(i));
492
}
493
output()->print_cr(")");
494
fill_to(instr_pos);
495
output()->print("%s.%s%s",
496
x->target()->holder()->name()->as_utf8(),
497
x->target()->name()->as_utf8(),
498
x->target()->signature()->as_symbol()->as_utf8());
499
}
500
501
502
void InstructionPrinter::do_NewInstance(NewInstance* x) {
503
output()->print("new instance ");
504
print_klass(x->klass());
505
}
506
507
508
void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) {
509
output()->print("new %s array [", basic_type_name(x->elt_type()));
510
print_value(x->length());
511
output()->put(']');
512
}
513
514
515
void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) {
516
output()->print("new object array [");
517
print_value(x->length());
518
output()->print("] ");
519
print_klass(x->klass());
520
}
521
522
523
void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) {
524
output()->print("new multi array [");
525
Values* dims = x->dims();
526
for (int i = 0; i < dims->length(); i++) {
527
if (i > 0) output()->print(", ");
528
print_value(dims->at(i));
529
}
530
output()->print("] ");
531
print_klass(x->klass());
532
}
533
534
535
void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) {
536
output()->print("enter ");
537
print_monitor(x);
538
}
539
540
541
void InstructionPrinter::do_MonitorExit(MonitorExit* x) {
542
output()->print("exit ");
543
print_monitor(x);
544
}
545
546
547
void InstructionPrinter::do_Intrinsic(Intrinsic* x) {
548
const char* name = vmIntrinsics::name_at(x->id());
549
if (name[0] == '_') name++; // strip leading bug from _hashCode, etc.
550
const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id()));
551
if (strchr(name, '_') == NULL) {
552
kname = NULL;
553
} else {
554
const char* kptr = strrchr(kname, '/');
555
if (kptr != NULL) kname = kptr + 1;
556
}
557
if (kname == NULL)
558
output()->print("%s(", name);
559
else
560
output()->print("%s.%s(", kname, name);
561
for (int i = 0; i < x->number_of_arguments(); i++) {
562
if (i > 0) output()->print(", ");
563
print_value(x->argument_at(i));
564
}
565
output()->put(')');
566
}
567
568
569
void InstructionPrinter::do_BlockBegin(BlockBegin* x) {
570
// print block id
571
BlockEnd* end = x->end();
572
output()->print("B%d ", x->block_id());
573
574
// print flags
575
bool printed_flag = false;
576
if (x->is_set(BlockBegin::std_entry_flag)) {
577
if (!printed_flag) output()->print("(");
578
output()->print("S"); printed_flag = true;
579
}
580
if (x->is_set(BlockBegin::osr_entry_flag)) {
581
if (!printed_flag) output()->print("(");
582
output()->print("O"); printed_flag = true;
583
}
584
if (x->is_set(BlockBegin::exception_entry_flag)) {
585
if (!printed_flag) output()->print("(");
586
output()->print("E"); printed_flag = true;
587
}
588
if (x->is_set(BlockBegin::subroutine_entry_flag)) {
589
if (!printed_flag) output()->print("(");
590
output()->print("s"); printed_flag = true;
591
}
592
if (x->is_set(BlockBegin::parser_loop_header_flag)) {
593
if (!printed_flag) output()->print("(");
594
output()->print("LH"); printed_flag = true;
595
}
596
if (x->is_set(BlockBegin::backward_branch_target_flag)) {
597
if (!printed_flag) output()->print("(");
598
output()->print("b"); printed_flag = true;
599
}
600
if (x->is_set(BlockBegin::was_visited_flag)) {
601
if (!printed_flag) output()->print("(");
602
output()->print("V"); printed_flag = true;
603
}
604
if (printed_flag) output()->print(") ");
605
606
// print block bci range
607
output()->print("[%d, %d]", x->bci(), (end == NULL ? -1 : end->printable_bci()));
608
609
// print block successors
610
if (end != NULL && end->number_of_sux() > 0) {
611
output()->print(" ->");
612
for (int i = 0; i < end->number_of_sux(); i++) {
613
output()->print(" B%d", end->sux_at(i)->block_id());
614
}
615
}
616
// print exception handlers
617
if (x->number_of_exception_handlers() > 0) {
618
output()->print(" (xhandlers ");
619
for (int i = 0; i < x->number_of_exception_handlers(); i++) {
620
if (i > 0) output()->print(" ");
621
output()->print("B%d", x->exception_handler_at(i)->block_id());
622
}
623
output()->put(')');
624
}
625
626
// print dominator block
627
if (x->dominator() != NULL) {
628
output()->print(" dom B%d", x->dominator()->block_id());
629
}
630
631
// print predecessors and successors
632
if (x->successors()->length() > 0) {
633
output()->print(" sux:");
634
for (int i = 0; i < x->successors()->length(); i ++) {
635
output()->print(" B%d", x->successors()->at(i)->block_id());
636
}
637
}
638
639
if (x->number_of_preds() > 0) {
640
output()->print(" pred:");
641
for (int i = 0; i < x->number_of_preds(); i ++) {
642
output()->print(" B%d", x->pred_at(i)->block_id());
643
}
644
}
645
646
if (!_print_phis) {
647
return;
648
}
649
650
// print phi functions
651
bool has_phis_in_locals = false;
652
bool has_phis_on_stack = false;
653
654
if (x->end() && x->end()->state()) {
655
ValueStack* state = x->state();
656
657
int i = 0;
658
while (!has_phis_on_stack && i < state->stack_size()) {
659
Value v = state->stack_at_inc(i);
660
has_phis_on_stack = is_phi_of_block(v, x);
661
}
662
663
do {
664
for (i = 0; !has_phis_in_locals && i < state->locals_size();) {
665
Value v = state->local_at(i);
666
has_phis_in_locals = is_phi_of_block(v, x);
667
// also ignore illegal HiWords
668
if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++;
669
}
670
state = state->caller_state();
671
} while (state != NULL);
672
673
}
674
675
// print values in locals
676
if (has_phis_in_locals) {
677
output()->cr(); output()->print_cr("Locals:");
678
679
ValueStack* state = x->state();
680
do {
681
for (int i = 0; i < state->locals_size();) {
682
Value v = state->local_at(i);
683
if (v) {
684
print_phi(i, v, x); output()->cr();
685
// also ignore illegal HiWords
686
i += (v->type()->is_illegal() ? 1 : v->type()->size());
687
} else {
688
i ++;
689
}
690
}
691
output()->cr();
692
state = state->caller_state();
693
} while (state != NULL);
694
}
695
696
// print values on stack
697
if (has_phis_on_stack) {
698
output()->print_cr("Stack:");
699
int i = 0;
700
while (i < x->state()->stack_size()) {
701
int o = i;
702
Value v = x->state()->stack_at_inc(i);
703
if (v) {
704
print_phi(o, v, x); output()->cr();
705
}
706
}
707
}
708
}
709
710
711
void InstructionPrinter::do_CheckCast(CheckCast* x) {
712
output()->print("checkcast(");
713
print_value(x->obj());
714
output()->print(") ");
715
print_klass(x->klass());
716
}
717
718
719
void InstructionPrinter::do_InstanceOf(InstanceOf* x) {
720
output()->print("instanceof(");
721
print_value(x->obj());
722
output()->print(") ");
723
print_klass(x->klass());
724
}
725
726
727
void InstructionPrinter::do_Goto(Goto* x) {
728
output()->print("goto B%d", x->default_sux()->block_id());
729
if (x->is_safepoint()) output()->print(" (safepoint)");
730
}
731
732
733
void InstructionPrinter::do_If(If* x) {
734
output()->print("if ");
735
print_value(x->x());
736
output()->print(" %s ", cond_name(x->cond()));
737
print_value(x->y());
738
output()->print(" then B%d else B%d", x->sux_at(0)->block_id(), x->sux_at(1)->block_id());
739
if (x->is_safepoint()) output()->print(" (safepoint)");
740
}
741
742
743
void InstructionPrinter::do_TableSwitch(TableSwitch* x) {
744
output()->print("tableswitch ");
745
if (x->is_safepoint()) output()->print("(safepoint) ");
746
print_value(x->tag());
747
output()->cr();
748
int l = x->length();
749
for (int i = 0; i < l; i++) {
750
fill_to(instr_pos);
751
output()->print_cr("case %5d: B%d", x->lo_key() + i, x->sux_at(i)->block_id());
752
}
753
fill_to(instr_pos);
754
output()->print("default : B%d", x->default_sux()->block_id());
755
}
756
757
758
void InstructionPrinter::do_LookupSwitch(LookupSwitch* x) {
759
output()->print("lookupswitch ");
760
if (x->is_safepoint()) output()->print("(safepoint) ");
761
print_value(x->tag());
762
output()->cr();
763
int l = x->length();
764
for (int i = 0; i < l; i++) {
765
fill_to(instr_pos);
766
output()->print_cr("case %5d: B%d", x->key_at(i), x->sux_at(i)->block_id());
767
}
768
fill_to(instr_pos);
769
output()->print("default : B%d", x->default_sux()->block_id());
770
}
771
772
773
void InstructionPrinter::do_Return(Return* x) {
774
if (x->result() == NULL) {
775
output()->print("return");
776
} else {
777
output()->print("%creturn ", x->type()->tchar());
778
print_value(x->result());
779
}
780
}
781
782
783
void InstructionPrinter::do_Throw(Throw* x) {
784
output()->print("throw ");
785
print_value(x->exception());
786
}
787
788
789
void InstructionPrinter::do_Base(Base* x) {
790
output()->print("std entry B%d", x->std_entry()->block_id());
791
if (x->number_of_sux() > 1) {
792
output()->print(" osr entry B%d", x->osr_entry()->block_id());
793
}
794
}
795
796
797
void InstructionPrinter::do_OsrEntry(OsrEntry* x) {
798
output()->print("osr entry");
799
}
800
801
802
void InstructionPrinter::do_ExceptionObject(ExceptionObject* x) {
803
output()->print("incoming exception");
804
}
805
806
807
void InstructionPrinter::do_RoundFP(RoundFP* x) {
808
output()->print("round_fp ");
809
print_value(x->input());
810
}
811
812
813
void InstructionPrinter::do_UnsafeGetRaw(UnsafeGetRaw* x) {
814
print_unsafe_raw_op(x, "UnsafeGetRaw");
815
output()->put(')');
816
}
817
818
819
void InstructionPrinter::do_UnsafePutRaw(UnsafePutRaw* x) {
820
print_unsafe_raw_op(x, "UnsafePutRaw");
821
output()->print(", value ");
822
print_value(x->value());
823
output()->put(')');
824
}
825
826
827
void InstructionPrinter::do_UnsafeGetObject(UnsafeGetObject* x) {
828
print_unsafe_object_op(x, "UnsafeGetObject");
829
output()->put(')');
830
}
831
832
833
void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) {
834
print_unsafe_object_op(x, "UnsafePutObject");
835
output()->print(", value ");
836
print_value(x->value());
837
output()->put(')');
838
}
839
840
void InstructionPrinter::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {
841
print_unsafe_object_op(x, x->is_add()?"UnsafeGetAndSetObject (add)":"UnsafeGetAndSetObject");
842
output()->print(", value ");
843
print_value(x->value());
844
output()->put(')');
845
}
846
847
void InstructionPrinter::do_RangeCheckPredicate(RangeCheckPredicate* x) {
848
849
if (x->x() != NULL && x->y() != NULL) {
850
output()->print("if ");
851
print_value(x->x());
852
output()->print(" %s ", cond_name(x->cond()));
853
print_value(x->y());
854
output()->print(" then deoptimize!");
855
} else {
856
output()->print("always deoptimize!");
857
}
858
}
859
860
#ifdef ASSERT
861
void InstructionPrinter::do_Assert(Assert* x) {
862
output()->print("assert ");
863
print_value(x->x());
864
output()->print(" %s ", cond_name(x->cond()));
865
print_value(x->y());
866
}
867
#endif
868
869
void InstructionPrinter::do_ProfileCall(ProfileCall* x) {
870
output()->print("profile ");
871
print_value(x->recv());
872
output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
873
if (x->known_holder() != NULL) {
874
output()->print(", ");
875
print_klass(x->known_holder());
876
output()->print(" ");
877
}
878
for (int i = 0; i < x->nb_profiled_args(); i++) {
879
if (i > 0) output()->print(", ");
880
print_value(x->profiled_arg_at(i));
881
if (x->arg_needs_null_check(i)) {
882
output()->print(" [NC]");
883
}
884
}
885
output()->put(')');
886
}
887
888
void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) {
889
output()->print("profile ret type ");
890
print_value(x->ret());
891
output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
892
output()->put(')');
893
}
894
void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
895
output()->print("profile_invoke ");
896
output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
897
output()->put(')');
898
899
}
900
901
void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) {
902
output()->print("call_rt %s(", x->entry_name());
903
for (int i = 0; i < x->number_of_arguments(); i++) {
904
if (i > 0) output()->print(", ");
905
print_value(x->argument_at(i));
906
}
907
output()->put(')');
908
}
909
910
void InstructionPrinter::do_MemBar(MemBar* x) {
911
LIR_Code code = x->code();
912
switch (code) {
913
case lir_membar_acquire : output()->print("membar_acquire"); break;
914
case lir_membar_release : output()->print("membar_release"); break;
915
case lir_membar : output()->print("membar"); break;
916
case lir_membar_loadload : output()->print("membar_loadload"); break;
917
case lir_membar_storestore: output()->print("membar_storestore"); break;
918
case lir_membar_loadstore : output()->print("membar_loadstore"); break;
919
case lir_membar_storeload : output()->print("membar_storeload"); break;
920
default : ShouldNotReachHere(); break;
921
}
922
}
923
924
#endif // PRODUCT
925
926