< prev index next > src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp
Print this page
#include "gc/shared/tlab_globals.hpp"
#include "interpreter/interpreter.hpp"
#include "oops/arrayOop.hpp"
#include "oops/markWord.hpp"
#include "runtime/basicLock.hpp"
+ #include "runtime/frame.inline.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
#include "utilities/checkedCast.hpp"
Label done;
// Load object header
movptr(hdr, Address(obj, hdr_offset));
// and mark it as unlocked
orptr(hdr, markWord::unlocked_value);
+ if (EnableValhalla) {
+ // Mask inline_type bit such that we go to the slow path if object is an inline type
+ andptr(hdr, ~((int) markWord::inline_type_bit_in_place));
+ }
// save unlocked object header into the displaced header location on the stack
movptr(Address(disp_hdr, 0), hdr);
// test if object header is still the same (i.e. unlocked), and if so, store the
// displaced header address in the object header - if it is not the same, get the
// object header instead
}
void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
assert_different_registers(obj, klass, len);
! movptr(Address(obj, oopDesc::mark_offset_in_bytes()), checked_cast<int32_t>(markWord::prototype().value()));
#ifdef _LP64
if (UseCompressedClassPointers) { // Take care not to kill klass
movptr(t1, klass);
encode_klass_not_null(t1, rscratch1);
movl(Address(obj, oopDesc::klass_offset_in_bytes()), t1);
}
void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
assert_different_registers(obj, klass, len);
! if (EnableValhalla) {
+ // Need to copy markWord::prototype header for klass
+ assert_different_registers(obj, klass, len, t1, t2);
+ movptr(t1, Address(klass, Klass::prototype_header_offset()));
+ movptr(Address(obj, oopDesc::mark_offset_in_bytes()), t1);
+ } else {
+ // This assumes that all prototype bits fit in an int32_t
+ movptr(Address(obj, oopDesc::mark_offset_in_bytes()), checked_cast<int32_t>(markWord::prototype().value()));
+ }
#ifdef _LP64
if (UseCompressedClassPointers) { // Take care not to kill klass
movptr(t1, klass);
encode_klass_not_null(t1, rscratch1);
movl(Address(obj, oopDesc::klass_offset_in_bytes()), t1);
}
verify_oop(obj);
}
! void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
- assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
- // Make sure there is enough stack space for this method's activation.
- // Note that we do this before doing an enter(). This matches the
- // ordering of C2's stack overflow check / rsp decrement and allows
- // the SharedRuntime stack overflow handling to be consistent
- // between the two compilers.
- generate_stack_overflow_check(bang_size_in_bytes);
-
push(rbp);
if (PreserveFramePointer) {
mov(rbp, rsp);
}
#if !defined(_LP64) && defined(COMPILER2)
if (UseSSE < 2 && !CompilerConfig::is_c1_only_no_jvmci()) {
! // c2 leaves fpu stack dirty. Clean it on entry
! empty_FPU_stack();
! }
#endif // !_LP64 && COMPILER2
! decrement(rsp, frame_size_in_bytes); // does not emit code for frame_size == 0
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
// C1 code is not hot enough to micro optimize the nmethod entry barrier with an out-of-line stub
bs->nmethod_entry_barrier(this, nullptr /* slow_path */, nullptr /* continuation */);
- }
!
! void C1_MacroAssembler::remove_frame(int frame_size_in_bytes) {
! increment(rsp, frame_size_in_bytes); // Does not emit code for frame_size == 0
! pop(rbp);
}
-
void C1_MacroAssembler::verified_entry(bool breakAtEntry) {
if (breakAtEntry || VerifyFPU) {
// Verified Entry first instruction should be 5 bytes long for correct
// patching by patch_verified_entry().
//
}
verify_oop(obj);
}
! void C1_MacroAssembler::build_frame_helper(int frame_size_in_bytes, int sp_offset_for_orig_pc, int sp_inc, bool reset_orig_pc, bool needs_stack_repair) {
push(rbp);
if (PreserveFramePointer) {
mov(rbp, rsp);
}
#if !defined(_LP64) && defined(COMPILER2)
if (UseSSE < 2 && !CompilerConfig::is_c1_only_no_jvmci()) {
! // c2 leaves fpu stack dirty. Clean it on entry
! empty_FPU_stack();
! }
#endif // !_LP64 && COMPILER2
! decrement(rsp, frame_size_in_bytes);
+
+ if (needs_stack_repair) {
+ // Save stack increment (also account for fixed framesize and rbp)
+ assert((sp_inc & (StackAlignmentInBytes-1)) == 0, "stack increment not aligned");
+ int real_frame_size = sp_inc + frame_size_in_bytes + wordSize;
+ movptr(Address(rsp, frame_size_in_bytes - wordSize), real_frame_size);
+ }
+ if (reset_orig_pc) {
+ // Zero orig_pc to detect deoptimization during buffering in the entry points
+ movptr(Address(rsp, sp_offset_for_orig_pc), 0);
+ }
+ }
+
+ void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes, int sp_offset_for_orig_pc, bool needs_stack_repair, bool has_scalarized_args, Label* verified_inline_entry_label) {
+ // Make sure there is enough stack space for this method's activation.
+ // Note that we do this before doing an enter(). This matches the
+ // ordering of C2's stack overflow check / rsp decrement and allows
+ // the SharedRuntime stack overflow handling to be consistent
+ // between the two compilers.
+ assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
+ generate_stack_overflow_check(bang_size_in_bytes);
+
+ build_frame_helper(frame_size_in_bytes, sp_offset_for_orig_pc, 0, has_scalarized_args, needs_stack_repair);
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
// C1 code is not hot enough to micro optimize the nmethod entry barrier with an out-of-line stub
bs->nmethod_entry_barrier(this, nullptr /* slow_path */, nullptr /* continuation */);
! if (verified_inline_entry_label != nullptr) {
! // Jump here from the scalarized entry points that already created the frame.
! bind(*verified_inline_entry_label);
! }
}
void C1_MacroAssembler::verified_entry(bool breakAtEntry) {
if (breakAtEntry || VerifyFPU) {
// Verified Entry first instruction should be 5 bytes long for correct
// patching by patch_verified_entry().
//
if (breakAtEntry) int3();
// build frame
IA32_ONLY( verify_FPU(0, "method_entry"); )
}
+ int C1_MacroAssembler::scalarized_entry(const CompiledEntrySignature* ces, int frame_size_in_bytes, int bang_size_in_bytes, int sp_offset_for_orig_pc, Label& verified_inline_entry_label, bool is_inline_ro_entry) {
+ assert(InlineTypePassFieldsAsArgs, "sanity");
+ // Make sure there is enough stack space for this method's activation.
+ assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
+ generate_stack_overflow_check(bang_size_in_bytes);
+
+ GrowableArray<SigEntry>* sig = ces->sig();
+ GrowableArray<SigEntry>* sig_cc = is_inline_ro_entry ? ces->sig_cc_ro() : ces->sig_cc();
+ VMRegPair* regs = ces->regs();
+ VMRegPair* regs_cc = is_inline_ro_entry ? ces->regs_cc_ro() : ces->regs_cc();
+ int args_on_stack = ces->args_on_stack();
+ int args_on_stack_cc = is_inline_ro_entry ? ces->args_on_stack_cc_ro() : ces->args_on_stack_cc();
+
+ assert(sig->length() <= sig_cc->length(), "Zero-sized inline class not allowed!");
+ BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sig_cc->length());
+ int args_passed = sig->length();
+ int args_passed_cc = SigEntry::fill_sig_bt(sig_cc, sig_bt);
+
+ // Create a temp frame so we can call into the runtime. It must be properly set up to accommodate GC.
+ build_frame_helper(frame_size_in_bytes, sp_offset_for_orig_pc, 0, true, ces->c1_needs_stack_repair());
+
+ // The runtime call might safepoint, make sure nmethod entry barrier is executed
+ BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+ // C1 code is not hot enough to micro optimize the nmethod entry barrier with an out-of-line stub
+ bs->nmethod_entry_barrier(this, nullptr /* slow_path */, nullptr /* continuation */);
+
+ // FIXME -- call runtime only if we cannot in-line allocate all the incoming inline type args.
+ movptr(rbx, (intptr_t)(ces->method()));
+ if (is_inline_ro_entry) {
+ call(RuntimeAddress(Runtime1::entry_for(Runtime1::buffer_inline_args_no_receiver_id)));
+ } else {
+ call(RuntimeAddress(Runtime1::entry_for(Runtime1::buffer_inline_args_id)));
+ }
+ int rt_call_offset = offset();
+
+ // Remove the temp frame
+ addptr(rsp, frame_size_in_bytes);
+ pop(rbp);
+
+ // Check if we need to extend the stack for packing
+ int sp_inc = 0;
+ if (args_on_stack > args_on_stack_cc) {
+ sp_inc = extend_stack_for_inline_args(args_on_stack);
+ }
+
+ shuffle_inline_args(true, is_inline_ro_entry, sig_cc,
+ args_passed_cc, args_on_stack_cc, regs_cc, // from
+ args_passed, args_on_stack, regs, // to
+ sp_inc, rax);
+
+ // Create the real frame. Below jump will then skip over the stack banging and frame
+ // setup code in the verified_inline_entry (which has a different real_frame_size).
+ build_frame_helper(frame_size_in_bytes, sp_offset_for_orig_pc, sp_inc, false, ces->c1_needs_stack_repair());
+
+ jmp(verified_inline_entry_label);
+ return rt_call_offset;
+ }
+
void C1_MacroAssembler::load_parameter(int offset_in_words, Register reg) {
// rbp, + 0: link
// + 1: return address
// + 2: argument with offset 0
// + 3: argument with offset 1
< prev index next >