Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8240363: Refactor Compile::Output() to its own Phase
Reviewed-by: kvn, vlivanov
  • Loading branch information
fisk committed Mar 16, 2020
1 parent 6ddb0f2 commit 21cd75cb98f658639df14632680e9c5e58f11faa
@@ -1575,7 +1575,7 @@ uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const {
//=============================================================================
const RegMask& MachConstantBaseNode::_out_RegMask = RegMask::Empty;

int Compile::ConstantTable::calculate_table_base_offset() const {
int ConstantTable::calculate_table_base_offset() const {
return 0; // absolute addressing, no offset
}

@@ -1602,9 +1602,9 @@ void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
Compile* C = ra_->C;

int framesize = C->frame_slots() << LogBytesPerInt;
int framesize = C->output()->frame_slots() << LogBytesPerInt;

if (C->need_stack_bang(framesize))
if (C->output()->need_stack_bang(framesize))
st->print("# stack bang size=%d\n\t", framesize);

if (framesize < ((1 << 9) + 2 * wordSize)) {
@@ -1625,7 +1625,7 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
MacroAssembler _masm(&cbuf);

// n.b. frame size includes space for return pc and rfp
const long framesize = C->frame_size_in_bytes();
const long framesize = C->output()->frame_size_in_bytes();
assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment");

// insert a nop at the start of the prolog so we can patch in a
@@ -1643,8 +1643,8 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
__ bind(L_skip_barrier);
}

int bangsize = C->bang_size_in_bytes();
if (C->need_stack_bang(bangsize) && UseStackBanging)
int bangsize = C->output()->bang_size_in_bytes();
if (C->output()->need_stack_bang(bangsize) && UseStackBanging)
__ generate_stack_overflow_check(bangsize);

__ build_frame(framesize);
@@ -1653,12 +1653,12 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
Unimplemented();
}

C->set_frame_complete(cbuf.insts_size());
C->output()->set_frame_complete(cbuf.insts_size());

if (C->has_mach_constant_base_node()) {
// NOTE: We set the table base offset here because users might be
// emitted before MachConstantBaseNode.
Compile::ConstantTable& constant_table = C->constant_table();
ConstantTable& constant_table = C->output()->constant_table();
constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
}
}
@@ -1679,7 +1679,7 @@ int MachPrologNode::reloc() const
#ifndef PRODUCT
void MachEpilogNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
Compile* C = ra_->C;
int framesize = C->frame_slots() << LogBytesPerInt;
int framesize = C->output()->frame_slots() << LogBytesPerInt;

st->print("# pop frame %d\n\t",framesize);

@@ -1705,7 +1705,7 @@ void MachEpilogNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
Compile* C = ra_->C;
MacroAssembler _masm(&cbuf);
int framesize = C->frame_slots() << LogBytesPerInt;
int framesize = C->output()->frame_slots() << LogBytesPerInt;

__ remove_frame(framesize);

@@ -56,6 +56,7 @@
#include "opto/compile.hpp"
#include "opto/intrinsicnode.hpp"
#include "opto/node.hpp"
#include "opto/output.hpp"
#endif

#ifdef PRODUCT
@@ -745,7 +746,7 @@ address MacroAssembler::trampoline_call(Address entry, CodeBuffer *cbuf) {
CompileTask* task = ciEnv::current()->task();
in_scratch_emit_size =
(task != NULL && is_c2_compile(task->comp_level()) &&
Compile::current()->in_scratch_emit_size());
Compile::current()->output()->in_scratch_emit_size());
#endif
if (!in_scratch_emit_size) {
address stub = emit_trampoline_stub(offset(), entry.target());
@@ -194,7 +194,7 @@ void emit_hi(CodeBuffer &cbuf, int val) { }
//=============================================================================
const RegMask& MachConstantBaseNode::_out_RegMask = PTR_REG_mask();

int Compile::ConstantTable::calculate_table_base_offset() const {
int ConstantTable::calculate_table_base_offset() const {
int offset = -(size() / 2);
// flds, fldd: 8-bit offset multiplied by 4: +/- 1024
// ldr, ldrb : 12-bit offset: +/- 4096
@@ -211,7 +211,7 @@ void MachConstantBaseNode::postalloc_expand(GrowableArray <Node *> *nodes, Phase

void MachConstantBaseNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
Compile* C = ra_->C;
Compile::ConstantTable& constant_table = C->constant_table();
ConstantTable& constant_table = C->output()->constant_table();
MacroAssembler _masm(&cbuf);

Register r = as_Register(ra_->get_encode(this));
@@ -245,9 +245,9 @@ void MachPrologNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
st->print_cr("NOP"); st->print("\t");
}

size_t framesize = C->frame_size_in_bytes();
size_t framesize = C->output()->frame_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
int bangsize = C->bang_size_in_bytes();
int bangsize = C->output()->bang_size_in_bytes();
// Remove two words for return addr and rbp,
framesize -= 2*wordSize;
bangsize -= 2*wordSize;
@@ -257,7 +257,7 @@ void MachPrologNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
// some VM calls (such as call site linkage) can use several kilobytes of
// stack. But the stack safety zone should account for that.
// See bugs 4446381, 4468289, 4497237.
if (C->need_stack_bang(bangsize)) {
if (C->output()->need_stack_bang(bangsize)) {
st->print_cr("! stack bang (%d bytes)", bangsize); st->print("\t");
}
st->print_cr("PUSH R_FP|R_LR_LR"); st->print("\t");
@@ -275,9 +275,9 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
__ nop();
}

size_t framesize = C->frame_size_in_bytes();
size_t framesize = C->output()->frame_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
int bangsize = C->bang_size_in_bytes();
int bangsize = C->output()->bang_size_in_bytes();
// Remove two words for return addr and fp,
framesize -= 2*wordSize;
bangsize -= 2*wordSize;
@@ -287,7 +287,7 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
// some VM calls (such as call site linkage) can use several kilobytes of
// stack. But the stack safety zone should account for that.
// See bugs 4446381, 4468289, 4497237.
if (C->need_stack_bang(bangsize)) {
if (C->output()->need_stack_bang(bangsize)) {
__ arm_stack_overflow_check(bangsize, Rtemp);
}

@@ -298,13 +298,13 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {

// offset from scratch buffer is not valid
if (strcmp(cbuf.name(), "Compile::Fill_buffer") == 0) {
C->set_frame_complete( __ offset() );
C->output()->set_frame_complete( __ offset() );
}

if (C->has_mach_constant_base_node()) {
// NOTE: We set the table base offset here because users might be
// emitted before MachConstantBaseNode.
Compile::ConstantTable& constant_table = C->constant_table();
ConstantTable& constant_table = C->output()->constant_table();
constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
}
}
@@ -322,7 +322,7 @@ int MachPrologNode::reloc() const {
void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
Compile* C = ra_->C;

size_t framesize = C->frame_size_in_bytes();
size_t framesize = C->output()->frame_size_in_bytes();
framesize -= 2*wordSize;

if (framesize != 0) {
@@ -342,7 +342,7 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
MacroAssembler _masm(&cbuf);
Compile* C = ra_->C;

size_t framesize = C->frame_size_in_bytes();
size_t framesize = C->output()->frame_size_in_bytes();
framesize -= 2*wordSize;
if (framesize != 0) {
__ add_slow(SP, SP, framesize);
@@ -827,7 +827,7 @@ void BoxLockNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
uint BoxLockNode::size(PhaseRegAlloc *ra_) const {
// BoxLockNode is not a MachNode, so we can't just call MachNode::size(ra_)
assert(ra_ == ra_->C->regalloc(), "sanity");
return ra_->C->scratch_emit_size(this);
return ra_->C->output()->scratch_emit_size(this);
}

//=============================================================================
@@ -1297,7 +1297,7 @@ static inline jlong replicate_immF(float con) {
//=============================================================================

const RegMask& MachConstantBaseNode::_out_RegMask = BITS64_CONSTANT_TABLE_BASE_mask();
int Compile::ConstantTable::calculate_table_base_offset() const {
int ConstantTable::calculate_table_base_offset() const {
return 0; // absolute addressing, no offset
}

@@ -1338,10 +1338,10 @@ void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
#ifndef PRODUCT
void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
Compile* C = ra_->C;
const long framesize = C->frame_slots() << LogBytesPerInt;
const long framesize = C->output()->frame_slots() << LogBytesPerInt;

st->print("PROLOG\n\t");
if (C->need_stack_bang(framesize)) {
if (C->output()->need_stack_bang(framesize)) {
st->print("stack_overflow_check\n\t");
}

@@ -1381,7 +1381,7 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
Compile* C = ra_->C;
MacroAssembler _masm(&cbuf);

const long framesize = C->frame_size_in_bytes();
const long framesize = C->output()->frame_size_in_bytes();
assert(framesize % (2 * wordSize) == 0, "must preserve 2*wordSize alignment");

const bool method_is_frameless = false /* TODO: PPC port C->is_frameless_method()*/;
@@ -1426,9 +1426,9 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
// use several kilobytes of stack. But the stack safety zone should
// account for that. See bugs 4446381, 4468289, 4497237.

int bangsize = C->bang_size_in_bytes();
int bangsize = C->output()->bang_size_in_bytes();
assert(bangsize >= framesize || bangsize <= 0, "stack bang size incorrect");
if (C->need_stack_bang(bangsize) && UseStackBanging) {
if (C->output()->need_stack_bang(bangsize) && UseStackBanging) {
// Unfortunately we cannot use the function provided in
// assembler.cpp as we have to emulate the pipes. So I had to
// insert the code of generate_stack_overflow_check(), see
@@ -1482,7 +1482,7 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
bang_offset += page_size;
}
// R11 trashed
} // C->need_stack_bang(framesize) && UseStackBanging
} // C->output()->need_stack_bang(framesize) && UseStackBanging

unsigned int bytes = (unsigned int)framesize;
long offset = Assembler::align_addr(bytes, frame::alignment_in_bytes);
@@ -1537,7 +1537,7 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
___(std) std(return_pc, _abi(lr), callers_sp);
}

C->set_frame_complete(cbuf.insts_size());
C->output()->set_frame_complete(cbuf.insts_size());
}
#undef ___
#undef ___stop
@@ -1573,7 +1573,7 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
Compile* C = ra_->C;
MacroAssembler _masm(&cbuf);

const long framesize = ((long)C->frame_slots()) << LogBytesPerInt;
const long framesize = ((long)C->output()->frame_slots()) << LogBytesPerInt;
assert(framesize >= 0, "negative frame-size?");

const bool method_needs_polling = do_polling() && C->is_method_compilation();
@@ -2786,7 +2786,7 @@ encode %{

MacroAssembler _masm(&cbuf);

if (!ra_->C->in_scratch_emit_size()) {
if (!ra_->C->output()->in_scratch_emit_size()) {
address const_toc_addr;
// Create a non-oop constant, no relocation needed.
// If it is an IC, it has a virtual_call_Relocation.
@@ -3053,7 +3053,7 @@ encode %{
// TODO: PPC port $archOpcode(ppc64Opcode_addis);

MacroAssembler _masm(&cbuf);
if (!ra_->C->in_scratch_emit_size()) {
if (!ra_->C->output()->in_scratch_emit_size()) {
intptr_t val = $src$$constant;
relocInfo::relocType constant_reloc = $src->constant_reloc(); // src
address const_toc_addr;
@@ -3791,7 +3791,7 @@ encode %{

MacroAssembler _masm(&cbuf);

if (!ra_->C->in_scratch_emit_size()) {
if (!ra_->C->output()->in_scratch_emit_size()) {
// Create a call trampoline stub for the given method.
const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method;
const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none);
@@ -6285,7 +6285,7 @@ instruct loadConL_lo(iRegLdst dst, immL src, iRegLdst base) %{
size(4);
ins_encode %{
// TODO: PPC port $archOpcode(ppc64Opcode_ld);
int offset = ra_->C->in_scratch_emit_size() ? 0 : _const_toc_offset_hi_node->_const_toc_offset;
int offset = ra_->C->output()->in_scratch_emit_size() ? 0 : _const_toc_offset_hi_node->_const_toc_offset;
__ ld($dst$$Register, MacroAssembler::largeoffset_si16_si16_lo(offset), $base$$Register);
%}
ins_pipe(pipe_class_memory);
@@ -6570,7 +6570,7 @@ instruct loadConP_lo(iRegPdst dst, immP_NM src, iRegLdst base) %{
size(4);
ins_encode %{
// TODO: PPC port $archOpcode(ppc64Opcode_ld);
int offset = ra_->C->in_scratch_emit_size() ? 0 : _const_toc_offset_hi_node->_const_toc_offset;
int offset = ra_->C->output()->in_scratch_emit_size() ? 0 : _const_toc_offset_hi_node->_const_toc_offset;
__ ld($dst$$Register, MacroAssembler::largeoffset_si16_si16_lo(offset), $base$$Register);
%}
ins_pipe(pipe_class_memory);
@@ -54,7 +54,7 @@ address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark/*
// That's why we must use the macroassembler to generate a stub.
MacroAssembler _masm(&cbuf);

address stub = __ start_a_stub(Compile::MAX_stubs_size);
address stub = __ start_a_stub(CompiledStaticCall::to_interp_stub_size());
if (stub == NULL) {
return NULL; // CodeBuffer::expand failed.
}

0 comments on commit 21cd75c

Please sign in to comment.