8290534: Move MacroAssembler::verified_entry to C2_MacroAssembler on x86
Reviewed-by: shade, kvn
This commit is contained in:
parent
5425573bb4
commit
43c47b1ad7
@ -25,6 +25,8 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "asm/assembler.hpp"
|
||||
#include "asm/assembler.inline.hpp"
|
||||
#include "gc/shared/barrierSet.hpp"
|
||||
#include "gc/shared/barrierSetAssembler.hpp"
|
||||
#include "oops/methodData.hpp"
|
||||
#include "opto/c2_MacroAssembler.hpp"
|
||||
#include "opto/intrinsicnode.hpp"
|
||||
@ -33,6 +35,103 @@
|
||||
#include "runtime/objectMonitor.hpp"
|
||||
#include "runtime/stubRoutines.hpp"
|
||||
|
||||
#ifdef PRODUCT
|
||||
#define BLOCK_COMMENT(str) /* nothing */
|
||||
#define STOP(error) stop(error)
|
||||
#else
|
||||
#define BLOCK_COMMENT(str) block_comment(str)
|
||||
#define STOP(error) block_comment(error); stop(error)
|
||||
#endif
|
||||
|
||||
// C2 compiled method's prolog code.
|
||||
void C2_MacroAssembler::verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b, bool is_stub) {
|
||||
|
||||
// WARNING: Initial instruction MUST be 5 bytes or longer so that
|
||||
// NativeJump::patch_verified_entry will be able to patch out the entry
|
||||
// code safely. The push to verify stack depth is ok at 5 bytes,
|
||||
// the frame allocation can be either 3 or 6 bytes. So if we don't do
|
||||
// stack bang then we must use the 6 byte frame allocation even if
|
||||
// we have no frame. :-(
|
||||
assert(stack_bang_size >= framesize || stack_bang_size <= 0, "stack bang size incorrect");
|
||||
|
||||
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
|
||||
// Remove word for return addr
|
||||
framesize -= wordSize;
|
||||
stack_bang_size -= wordSize;
|
||||
|
||||
// Calls to C2R adapters often do not accept exceptional returns.
|
||||
// We require that their callers must bang for them. But be careful, because
|
||||
// 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 (stack_bang_size > 0) {
|
||||
generate_stack_overflow_check(stack_bang_size);
|
||||
|
||||
// We always push rbp, so that on return to interpreter rbp, will be
|
||||
// restored correctly and we can correct the stack.
|
||||
push(rbp);
|
||||
// Save caller's stack pointer into RBP if the frame pointer is preserved.
|
||||
if (PreserveFramePointer) {
|
||||
mov(rbp, rsp);
|
||||
}
|
||||
// Remove word for ebp
|
||||
framesize -= wordSize;
|
||||
|
||||
// Create frame
|
||||
if (framesize) {
|
||||
subptr(rsp, framesize);
|
||||
}
|
||||
} else {
|
||||
// Create frame (force generation of a 4 byte immediate value)
|
||||
subptr_imm32(rsp, framesize);
|
||||
|
||||
// Save RBP register now.
|
||||
framesize -= wordSize;
|
||||
movptr(Address(rsp, framesize), rbp);
|
||||
// Save caller's stack pointer into RBP if the frame pointer is preserved.
|
||||
if (PreserveFramePointer) {
|
||||
movptr(rbp, rsp);
|
||||
if (framesize > 0) {
|
||||
addptr(rbp, framesize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (VerifyStackAtCalls) { // Majik cookie to verify stack depth
|
||||
framesize -= wordSize;
|
||||
movptr(Address(rsp, framesize), (int32_t)0xbadb100d);
|
||||
}
|
||||
|
||||
#ifndef _LP64
|
||||
// If method sets FPU control word do it now
|
||||
if (fp_mode_24b) {
|
||||
fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_24()));
|
||||
}
|
||||
if (UseSSE >= 2 && VerifyFPU) {
|
||||
verify_FPU(0, "FPU stack must be clean on entry");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ASSERT
|
||||
if (VerifyStackAtCalls) {
|
||||
Label L;
|
||||
push(rax);
|
||||
mov(rax, rsp);
|
||||
andptr(rax, StackAlignmentInBytes-1);
|
||||
cmpptr(rax, StackAlignmentInBytes-wordSize);
|
||||
pop(rax);
|
||||
jcc(Assembler::equal, L);
|
||||
STOP("Stack is not properly aligned!");
|
||||
bind(L);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!is_stub) {
|
||||
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
|
||||
bs->nmethod_entry_barrier(this);
|
||||
}
|
||||
}
|
||||
|
||||
inline Assembler::AvxVectorLen C2_MacroAssembler::vector_length_encoding(int vlen_in_bytes) {
|
||||
switch (vlen_in_bytes) {
|
||||
case 4: // fall-through
|
||||
|
@ -28,6 +28,9 @@
|
||||
// C2_MacroAssembler contains high-level macros for C2
|
||||
|
||||
public:
|
||||
// C2 compiled method's prolog code.
|
||||
void verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b, bool is_stub);
|
||||
|
||||
Assembler::AvxVectorLen vector_length_encoding(int vlen_in_bytes);
|
||||
|
||||
// Code used by cmpFastLock and cmpFastUnlock mach instructions in .ad file.
|
||||
|
@ -5270,95 +5270,6 @@ void MacroAssembler::reinit_heapbase() {
|
||||
|
||||
#endif // _LP64
|
||||
|
||||
// C2 compiled method's prolog code.
|
||||
void MacroAssembler::verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b, bool is_stub) {
|
||||
|
||||
// WARNING: Initial instruction MUST be 5 bytes or longer so that
|
||||
// NativeJump::patch_verified_entry will be able to patch out the entry
|
||||
// code safely. The push to verify stack depth is ok at 5 bytes,
|
||||
// the frame allocation can be either 3 or 6 bytes. So if we don't do
|
||||
// stack bang then we must use the 6 byte frame allocation even if
|
||||
// we have no frame. :-(
|
||||
assert(stack_bang_size >= framesize || stack_bang_size <= 0, "stack bang size incorrect");
|
||||
|
||||
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
|
||||
// Remove word for return addr
|
||||
framesize -= wordSize;
|
||||
stack_bang_size -= wordSize;
|
||||
|
||||
// Calls to C2R adapters often do not accept exceptional returns.
|
||||
// We require that their callers must bang for them. But be careful, because
|
||||
// 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 (stack_bang_size > 0) {
|
||||
generate_stack_overflow_check(stack_bang_size);
|
||||
|
||||
// We always push rbp, so that on return to interpreter rbp, will be
|
||||
// restored correctly and we can correct the stack.
|
||||
push(rbp);
|
||||
// Save caller's stack pointer into RBP if the frame pointer is preserved.
|
||||
if (PreserveFramePointer) {
|
||||
mov(rbp, rsp);
|
||||
}
|
||||
// Remove word for ebp
|
||||
framesize -= wordSize;
|
||||
|
||||
// Create frame
|
||||
if (framesize) {
|
||||
subptr(rsp, framesize);
|
||||
}
|
||||
} else {
|
||||
// Create frame (force generation of a 4 byte immediate value)
|
||||
subptr_imm32(rsp, framesize);
|
||||
|
||||
// Save RBP register now.
|
||||
framesize -= wordSize;
|
||||
movptr(Address(rsp, framesize), rbp);
|
||||
// Save caller's stack pointer into RBP if the frame pointer is preserved.
|
||||
if (PreserveFramePointer) {
|
||||
movptr(rbp, rsp);
|
||||
if (framesize > 0) {
|
||||
addptr(rbp, framesize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (VerifyStackAtCalls) { // Majik cookie to verify stack depth
|
||||
framesize -= wordSize;
|
||||
movptr(Address(rsp, framesize), (int32_t)0xbadb100d);
|
||||
}
|
||||
|
||||
#ifndef _LP64
|
||||
// If method sets FPU control word do it now
|
||||
if (fp_mode_24b) {
|
||||
fldcw(ExternalAddress(StubRoutines::x86::addr_fpu_cntrl_wrd_24()));
|
||||
}
|
||||
if (UseSSE >= 2 && VerifyFPU) {
|
||||
verify_FPU(0, "FPU stack must be clean on entry");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ASSERT
|
||||
if (VerifyStackAtCalls) {
|
||||
Label L;
|
||||
push(rax);
|
||||
mov(rax, rsp);
|
||||
andptr(rax, StackAlignmentInBytes-1);
|
||||
cmpptr(rax, StackAlignmentInBytes-wordSize);
|
||||
pop(rax);
|
||||
jcc(Assembler::equal, L);
|
||||
STOP("Stack is not properly aligned!");
|
||||
bind(L);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!is_stub) {
|
||||
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
|
||||
bs->nmethod_entry_barrier(this);
|
||||
}
|
||||
}
|
||||
|
||||
#if COMPILER2_OR_JVMCI
|
||||
|
||||
// clear memory of size 'cnt' qwords, starting at 'base' using XMM/YMM/ZMM registers
|
||||
|
@ -1882,9 +1882,6 @@ public:
|
||||
|
||||
|
||||
public:
|
||||
// C2 compiled method's prolog code.
|
||||
void verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b, bool is_stub);
|
||||
|
||||
// clear memory of size 'cnt' qwords, starting at 'base';
|
||||
// if 'is_large' is set, do not try to produce short loop
|
||||
void clear_mem(Register base, Register cnt, Register rtmp, XMMRegister xtmp, bool is_large, KRegister mask=knoreg);
|
||||
|
@ -608,7 +608,7 @@ void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
|
||||
|
||||
void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
|
||||
Compile* C = ra_->C;
|
||||
MacroAssembler _masm(&cbuf);
|
||||
C2_MacroAssembler _masm(&cbuf);
|
||||
|
||||
int framesize = C->output()->frame_size_in_bytes();
|
||||
int bangsize = C->output()->bang_size_in_bytes();
|
||||
|
@ -894,7 +894,7 @@ void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
|
||||
|
||||
void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
|
||||
Compile* C = ra_->C;
|
||||
MacroAssembler _masm(&cbuf);
|
||||
C2_MacroAssembler _masm(&cbuf);
|
||||
|
||||
int framesize = C->output()->frame_size_in_bytes();
|
||||
int bangsize = C->output()->bang_size_in_bytes();
|
||||
|
Loading…
Reference in New Issue
Block a user