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 }
61 ShouldNotReachHere();
62 return NULL;
63 }
64
65
66 const char* InstructionPrinter::op_name(Bytecodes::Code op) {
67 switch (op) {
68 // arithmetic ops
69 case Bytecodes::_iadd : // fall through
70 case Bytecodes::_ladd : // fall through
71 case Bytecodes::_fadd : // fall through
72 case Bytecodes::_dadd : return "+";
73 case Bytecodes::_isub : // fall through
74 case Bytecodes::_lsub : // fall through
75 case Bytecodes::_fsub : // fall through
76 case Bytecodes::_dsub : return "-";
77 case Bytecodes::_imul : // fall through
78 case Bytecodes::_lmul : // fall through
79 case Bytecodes::_fmul : // fall through
164 }
165 }
166
167
168 void InstructionPrinter::print_temp(Value value) {
169 output()->print("%c%d", value->type()->tchar(), value->id());
170 }
171
172
173 void InstructionPrinter::print_field(AccessField* field) {
174 print_value(field->obj());
175 output()->print("._%d", field->offset());
176 }
177
178
179 void InstructionPrinter::print_indexed(AccessIndexed* indexed) {
180 print_value(indexed->array());
181 output()->put('[');
182 print_value(indexed->index());
183 output()->put(']');
184 }
185
186
187 void InstructionPrinter::print_monitor(AccessMonitor* monitor) {
188 output()->print("monitor[%d](", monitor->monitor_no());
189 print_value(monitor->obj());
190 output()->put(')');
191 }
192
193
194 void InstructionPrinter::print_op2(Op2* instr) {
195 print_value(instr->x());
196 output()->print(" %s ", op_name(instr->op()));
197 print_value(instr->y());
198 }
199
200
201 void InstructionPrinter::print_value(Value value) {
202 if (value == NULL) {
203 output()->print("NULL");
356 }
357
358
359 void InstructionPrinter::do_Constant(Constant* x) {
360 ValueType* t = x->type();
361 switch (t->tag()) {
362 case intTag : output()->print("%d" , t->as_IntConstant ()->value()); break;
363 case longTag : output()->print(JLONG_FORMAT, t->as_LongConstant()->value()); output()->print("L"); break;
364 case floatTag : output()->print("%g" , t->as_FloatConstant ()->value()); break;
365 case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value()); break;
366 case objectTag : print_object(x); break;
367 case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break;
368 default : output()->print("???"); break;
369 }
370 }
371
372
373 void InstructionPrinter::do_LoadField(LoadField* x) {
374 print_field(x);
375 output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
376 }
377
378
379 void InstructionPrinter::do_StoreField(StoreField* x) {
380 print_field(x);
381 output()->print(" := ");
382 print_value(x->value());
383 output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
384 }
385
386
387 void InstructionPrinter::do_ArrayLength(ArrayLength* x) {
388 print_value(x->array());
389 output()->print(".length");
390 }
391
392
393 void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
394 print_indexed(x);
395 output()->print(" (%c)", type2char(x->elt_type()));
396 }
397
398
399 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
400 print_indexed(x);
401 output()->print(" := ");
402 print_value(x->value());
403 output()->print(" (%c)", type2char(x->elt_type()));
404 }
405
406 void InstructionPrinter::do_NegateOp(NegateOp* x) {
407 output()->put('-');
408 print_value(x->x());
409 }
410
411
412 void InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) {
413 print_op2(x);
414 }
415
416
417 void InstructionPrinter::do_ShiftOp(ShiftOp* x) {
418 print_op2(x);
419 }
420
421
422 void InstructionPrinter::do_LogicOp(LogicOp* x) {
423 print_op2(x);
826
827 void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) {
828 print_unsafe_object_op(x, "UnsafePutObject");
829 output()->print(", value ");
830 print_value(x->value());
831 output()->put(')');
832 }
833
834 void InstructionPrinter::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {
835 print_unsafe_object_op(x, x->is_add()?"UnsafeGetAndSetObject (add)":"UnsafeGetAndSetObject");
836 output()->print(", value ");
837 print_value(x->value());
838 output()->put(')');
839 }
840
841 void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) {
842 print_unsafe_object_op(x, "UnsafePrefetchRead");
843 output()->put(')');
844 }
845
846
847 void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {
848 print_unsafe_object_op(x, "UnsafePrefetchWrite");
849 output()->put(')');
850 }
851
852 void InstructionPrinter::do_ProfileCall(ProfileCall* x) {
853 output()->print("profile ");
854 print_value(x->recv());
855 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
856 if (x->known_holder() != NULL) {
857 output()->print(", ");
858 print_klass(x->known_holder());
859 }
860 output()->put(')');
861 }
862
863 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
864 output()->print("profile_invoke ");
865 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
|
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 "aeq";
61 case If::beq: return "beq";
62 }
63 ShouldNotReachHere();
64 return NULL;
65 }
66
67
68 const char* InstructionPrinter::op_name(Bytecodes::Code op) {
69 switch (op) {
70 // arithmetic ops
71 case Bytecodes::_iadd : // fall through
72 case Bytecodes::_ladd : // fall through
73 case Bytecodes::_fadd : // fall through
74 case Bytecodes::_dadd : return "+";
75 case Bytecodes::_isub : // fall through
76 case Bytecodes::_lsub : // fall through
77 case Bytecodes::_fsub : // fall through
78 case Bytecodes::_dsub : return "-";
79 case Bytecodes::_imul : // fall through
80 case Bytecodes::_lmul : // fall through
81 case Bytecodes::_fmul : // fall through
166 }
167 }
168
169
170 void InstructionPrinter::print_temp(Value value) {
171 output()->print("%c%d", value->type()->tchar(), value->id());
172 }
173
174
175 void InstructionPrinter::print_field(AccessField* field) {
176 print_value(field->obj());
177 output()->print("._%d", field->offset());
178 }
179
180
181 void InstructionPrinter::print_indexed(AccessIndexed* indexed) {
182 print_value(indexed->array());
183 output()->put('[');
184 print_value(indexed->index());
185 output()->put(']');
186 if (indexed->length() != NULL) {
187 output()->put('(');
188 print_value(indexed->length());
189 output()->put(')');
190 }
191 }
192
193
194 void InstructionPrinter::print_monitor(AccessMonitor* monitor) {
195 output()->print("monitor[%d](", monitor->monitor_no());
196 print_value(monitor->obj());
197 output()->put(')');
198 }
199
200
201 void InstructionPrinter::print_op2(Op2* instr) {
202 print_value(instr->x());
203 output()->print(" %s ", op_name(instr->op()));
204 print_value(instr->y());
205 }
206
207
208 void InstructionPrinter::print_value(Value value) {
209 if (value == NULL) {
210 output()->print("NULL");
363 }
364
365
366 void InstructionPrinter::do_Constant(Constant* x) {
367 ValueType* t = x->type();
368 switch (t->tag()) {
369 case intTag : output()->print("%d" , t->as_IntConstant ()->value()); break;
370 case longTag : output()->print(JLONG_FORMAT, t->as_LongConstant()->value()); output()->print("L"); break;
371 case floatTag : output()->print("%g" , t->as_FloatConstant ()->value()); break;
372 case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value()); break;
373 case objectTag : print_object(x); break;
374 case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break;
375 default : output()->print("???"); break;
376 }
377 }
378
379
380 void InstructionPrinter::do_LoadField(LoadField* x) {
381 print_field(x);
382 output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
383 output()->print(" %s", x->field()->name()->as_utf8());
384 }
385
386
387 void InstructionPrinter::do_StoreField(StoreField* x) {
388 print_field(x);
389 output()->print(" := ");
390 print_value(x->value());
391 output()->print(" (%c)", type2char(x->field()->type()->basic_type()));
392 output()->print(" %s", x->field()->name()->as_utf8());
393 }
394
395
396 void InstructionPrinter::do_ArrayLength(ArrayLength* x) {
397 print_value(x->array());
398 output()->print(".length");
399 }
400
401
402 void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) {
403 print_indexed(x);
404 output()->print(" (%c)", type2char(x->elt_type()));
405 if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
406 output()->print(" [rc]");
407 }
408 }
409
410
411 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) {
412 print_indexed(x);
413 output()->print(" := ");
414 print_value(x->value());
415 output()->print(" (%c)", type2char(x->elt_type()));
416 if (x->check_flag(Instruction::NeedsRangeCheckFlag)) {
417 output()->print(" [rc]");
418 }
419 }
420
421 void InstructionPrinter::do_NegateOp(NegateOp* x) {
422 output()->put('-');
423 print_value(x->x());
424 }
425
426
427 void InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) {
428 print_op2(x);
429 }
430
431
432 void InstructionPrinter::do_ShiftOp(ShiftOp* x) {
433 print_op2(x);
434 }
435
436
437 void InstructionPrinter::do_LogicOp(LogicOp* x) {
438 print_op2(x);
841
842 void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) {
843 print_unsafe_object_op(x, "UnsafePutObject");
844 output()->print(", value ");
845 print_value(x->value());
846 output()->put(')');
847 }
848
849 void InstructionPrinter::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {
850 print_unsafe_object_op(x, x->is_add()?"UnsafeGetAndSetObject (add)":"UnsafeGetAndSetObject");
851 output()->print(", value ");
852 print_value(x->value());
853 output()->put(')');
854 }
855
856 void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) {
857 print_unsafe_object_op(x, "UnsafePrefetchRead");
858 output()->put(')');
859 }
860
861 void InstructionPrinter::do_RangeCheckPredicate(RangeCheckPredicate* x) {
862
863 if (x->x() != NULL && x->y() != NULL) {
864 output()->print("if ");
865 print_value(x->x());
866 output()->print(" %s ", cond_name(x->cond()));
867 print_value(x->y());
868 output()->print(" then deoptimize!");
869 } else {
870 output()->print("always deoptimize!");
871 }
872 }
873
874 void InstructionPrinter::do_Assert(Assert* x) {
875 output()->print("assert ");
876 print_value(x->x());
877 output()->print(" %s ", cond_name(x->cond()));
878 print_value(x->y());
879 }
880
881 void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {
882 print_unsafe_object_op(x, "UnsafePrefetchWrite");
883 output()->put(')');
884 }
885
886 void InstructionPrinter::do_ProfileCall(ProfileCall* x) {
887 output()->print("profile ");
888 print_value(x->recv());
889 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8());
890 if (x->known_holder() != NULL) {
891 output()->print(", ");
892 print_klass(x->known_holder());
893 }
894 output()->put(')');
895 }
896
897 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) {
898 output()->print("profile_invoke ");
899 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8());
|