/* * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
constchar* InstructionPrinter::op_name(Bytecodes::Code op) { switch (op) { // arithmetic ops case Bytecodes::_iadd : // fall through case Bytecodes::_ladd : // fall through case Bytecodes::_fadd : // fall through case Bytecodes::_dadd : return"+"; case Bytecodes::_isub : // fall through case Bytecodes::_lsub : // fall through case Bytecodes::_fsub : // fall through case Bytecodes::_dsub : return"-"; case Bytecodes::_imul : // fall through case Bytecodes::_lmul : // fall through case Bytecodes::_fmul : // fall through case Bytecodes::_dmul : return"*"; case Bytecodes::_idiv : // fall through case Bytecodes::_ldiv : // fall through case Bytecodes::_fdiv : // fall through case Bytecodes::_ddiv : return"/"; case Bytecodes::_irem : // fall through case Bytecodes::_lrem : // fall through case Bytecodes::_frem : // fall through case Bytecodes::_drem : return"%"; // shift ops case Bytecodes::_ishl : // fall through case Bytecodes::_lshl : return"<<"; case Bytecodes::_ishr : // fall through case Bytecodes::_lshr : return">>"; case Bytecodes::_iushr: // fall through case Bytecodes::_lushr: return">>>"; // logic ops case Bytecodes::_iand : // fall through case Bytecodes::_land : return"&"; case Bytecodes::_ior : // fall through case Bytecodes::_lor : return"|"; case Bytecodes::_ixor : // fall through case Bytecodes::_lxor : return"^"; default : return Bytecodes::name(op);
}
}
void InstructionPrinter::print_stack(ValueStack* stack) { int start_position = output()->position(); if (stack->stack_is_empty()) {
output()->print("empty stack");
} else {
output()->print("stack ["); for (int i = 0; i < stack->stack_size();) { if (i > 0) output()->print(", ");
output()->print("%d:", i);
Value value = stack->stack_at_inc(i);
print_value(value);
Phi* phi = value->as_Phi(); if (phi != NULL) { if (phi->operand()->is_valid()) {
output()->print(" ");
phi->operand()->print(output());
}
}
}
output()->put(']');
} if (!stack->no_active_locks()) { // print out the lines on the line below this // one at the same indentation level.
output()->cr();
fill_to(start_position, ' ');
output()->print("locks ["); for (int i = 0; i < stack->locks_size(); i++) {
Value t = stack->lock_at(i); if (i > 0) output()->print(", ");
output()->print("%d:", i); if (t == NULL) { // synchronized methods push null on the lock stack
output()->print("this");
} else {
print_value(t);
}
}
output()->print("]");
}
}
void InstructionPrinter::print_line(Instruction* instr) { // print instruction data on one line if (instr->is_pinned()) output()->put('.'); if (instr->has_printable_bci()) {
fill_to(bci_pos ); output()->print("%d", instr->printable_bci());
}
fill_to(use_pos ); output()->print("%d", instr->use_count());
fill_to(temp_pos ); print_temp(instr);
fill_to(instr_pos); print_instr(instr);
output()->cr(); // add a line for StateSplit instructions w/ non-empty stacks // (make it robust so we can print incomplete instructions)
StateSplit* split = instr->as_StateSplit(); if (split != NULL && split->state() != NULL && !split->state()->stack_is_empty()) {
fill_to(instr_pos); print_stack(split->state());
output()->cr();
}
}
void InstructionPrinter::do_Phi(Phi* x) {
output()->print("phi function"); // make that more detailed later if (x->is_illegal())
output()->print(" (illegal)");
}
if (x->end() && x->end()->state()) {
ValueStack* state = x->state();
int i = 0; while (!has_phis_on_stack && i < state->stack_size()) {
Value v = state->stack_at_inc(i);
has_phis_on_stack = is_phi_of_block(v, x);
}
do { for (i = 0; !has_phis_in_locals && i < state->locals_size();) {
Value v = state->local_at(i);
has_phis_in_locals = is_phi_of_block(v, x); // also ignore illegal HiWords if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++;
}
state = state->caller_state();
} while (state != NULL);
}
// print values in locals if (has_phis_in_locals) {
output()->cr(); output()->print_cr("Locals:");
ValueStack* state = x->state(); do { for (int i = 0; i < state->locals_size();) {
Value v = state->local_at(i); if (v) {
print_phi(i, v, x); output()->cr(); // also ignore illegal HiWords
i += (v->type()->is_illegal() ? 1 : v->type()->size());
} else {
i ++;
}
}
output()->cr();
state = state->caller_state();
} while (state != NULL);
}
// print values on stack if (has_phis_on_stack) {
output()->print_cr("Stack:"); int i = 0; while (i < x->state()->stack_size()) { int o = i;
Value v = x->state()->stack_at_inc(i); if (v) {
print_phi(o, v, x); output()->cr();
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.