// Index caller states in s, where 0 is the oldest, 1 its callee, etc. // Return NULL if n is too large. // Returns the caller_bci for the next-younger state, also. static ValueStack* nth_oldest(ValueStack* s, int n, int& bci_result) { ValueStack* t = s; for (int i = 0; i < n; i++) { if (t == NULL) break; t = t->caller_state(); } if (t == NULL) return NULL; for (;;) { ValueStack* tc = t->caller_state(); if (tc == NULL) return s; t = tc; bci_result = tc->bci(); s = s->caller_state(); } }
void ValueStack::clear_stores() { ValueStack* stack = this; while (stack != NULL) { for (int i = 0; i < stack->_stores.length(); i++) stack->_stores.at_put(i, NULL); stack = stack->caller_state(); } }
void ValueStack::eliminate_all_scope_stores(int bci) { ValueStack* stack = this; while (stack != NULL) { stack->eliminate_stores(bci); stack = stack->caller_state(); } }
void InstructionPrinter::do_BlockBegin(BlockBegin* x) { // print block id BlockEnd* end = x->end(); output()->print("B%d ", x->block_id()); // print flags bool printed_flag = false; if (x->is_set(BlockBegin::std_entry_flag)) { if (!printed_flag) output()->print("("); output()->print("S"); printed_flag = true; } if (x->is_set(BlockBegin::osr_entry_flag)) { if (!printed_flag) output()->print("("); output()->print("O"); printed_flag = true; } if (x->is_set(BlockBegin::exception_entry_flag)) { if (!printed_flag) output()->print("("); output()->print("E"); printed_flag = true; } if (x->is_set(BlockBegin::subroutine_entry_flag)) { if (!printed_flag) output()->print("("); output()->print("s"); printed_flag = true; } if (x->is_set(BlockBegin::parser_loop_header_flag)) { if (!printed_flag) output()->print("("); output()->print("LH"); printed_flag = true; } if (x->is_set(BlockBegin::backward_branch_target_flag)) { if (!printed_flag) output()->print("("); output()->print("b"); printed_flag = true; } if (x->is_set(BlockBegin::was_visited_flag)) { if (!printed_flag) output()->print("("); output()->print("V"); printed_flag = true; } if (printed_flag) output()->print(") "); // print block bci range output()->print("[%d, %d]",x->bci(),(end==NULL?InvocationEntryBci:end->bci())); // print block successors if (end != NULL && end->number_of_sux() > 0) { output()->print(" ->"); for (int i = 0; i < end->number_of_sux(); i++) { output()->print(" B%d", end->sux_at(i)->block_id()); } } // print exception handlers if (x->number_of_exception_handlers() > 0) { output()->print(" (xhandlers "); for (int i = 0; i < x->number_of_exception_handlers(); i++) { if (i > 0) output()->print(" "); output()->print("B%d", x->exception_handler_at(i)->block_id()); } output()->put(')'); } // print dominator block if (x->dominator() != NULL) { output()->print(" dom B%d", x->dominator()->block_id()); } // print predecessors and successors if (x->successors()->length() > 0) { output()->print(" sux:"); for (int i = 0; i < x->successors()->length(); i ++) { output()->print(" B%d", x->successors()->at(i)->block_id()); } } if (x->number_of_preds() > 0) { output()->print(" pred:"); for (int i = 0; i < x->number_of_preds(); i ++) { output()->print(" B%d", x->pred_at(i)->block_id()); } } if (!_print_phis) { return; } // print phi functions bool has_phis_in_locals = false; bool has_phis_on_stack = false; 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(); } } } }