Skip to content

Commit

Permalink
8263002: Remove CDS MiscCode region
Browse files Browse the repository at this point in the history
Reviewed-by: coleenp, dholmes
  • Loading branch information
iklam committed Mar 10, 2021
1 parent 67ea3bd commit d8a9c3c
Show file tree
Hide file tree
Showing 39 changed files with 116 additions and 641 deletions.
9 changes: 0 additions & 9 deletions src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,6 @@ bool SharedRuntime::is_wide_vector(int size) {
return size > 8;
}

size_t SharedRuntime::trampoline_size() {
return 16;
}

void SharedRuntime::generate_trampoline(MacroAssembler *masm, address destination) {
__ mov(rscratch1, destination);
__ br(rscratch1);
}

// The java_calling_convention describes stack locations as ideal slots on
// a frame with no abi restrictions. Since we must observe abi restrictions
// (like the placement of the register window) the slots must be biased by
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/cpu/arm/sharedRuntime_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,6 @@ bool SharedRuntime::is_wide_vector(int size) {
return false;
}

size_t SharedRuntime::trampoline_size() {
return 16;
}

void SharedRuntime::generate_trampoline(MacroAssembler *masm, address destination) {
InlinedAddress dest(destination);
__ indirect_jump(dest, Rtemp);
__ bind_literal(dest);
}

int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
VMRegPair *regs,
VMRegPair *regs2,
Expand Down
11 changes: 0 additions & 11 deletions src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,17 +564,6 @@ bool SharedRuntime::is_wide_vector(int size) {
return size > 8;
}

size_t SharedRuntime::trampoline_size() {
return Assembler::load_const_size + 8;
}

void SharedRuntime::generate_trampoline(MacroAssembler *masm, address destination) {
Register Rtemp = R12;
__ load_const(Rtemp, destination);
__ mtctr(Rtemp);
__ bctr();
}

static int reg2slot(VMReg r) {
return r->reg2stack() + SharedRuntime::out_preserve_stack_slots();
}
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/cpu/s390/sharedRuntime_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,6 @@ void RegisterSaver::restore_result_registers(MacroAssembler* masm) {
}
}

size_t SharedRuntime::trampoline_size() {
return MacroAssembler::load_const_size() + 2;
}

void SharedRuntime::generate_trampoline(MacroAssembler *masm, address destination) {
// Think about using pc-relative branch.
__ load_const(Z_R1_scratch, destination);
__ z_br(Z_R1_scratch);
}

// ---------------------------------------------------------------------------
void SharedRuntime::save_native_result(MacroAssembler * masm,
BasicType ret_type,
Expand Down
8 changes: 0 additions & 8 deletions src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,6 @@ bool SharedRuntime::is_wide_vector(int size) {
return size > 16;
}

size_t SharedRuntime::trampoline_size() {
return 16;
}

void SharedRuntime::generate_trampoline(MacroAssembler *masm, address destination) {
__ jump(RuntimeAddress(destination));
}

// The java_calling_convention describes stack locations as ideal slots on
// a frame with no abi restrictions. Since we must observe abi restrictions
// (like the placement of the register window) the slots must be biased by
Expand Down
8 changes: 0 additions & 8 deletions src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,6 @@ bool SharedRuntime::is_wide_vector(int size) {
return size > 16;
}

size_t SharedRuntime::trampoline_size() {
return 16;
}

void SharedRuntime::generate_trampoline(MacroAssembler *masm, address destination) {
__ jump(RuntimeAddress(destination));
}

// The java_calling_convention describes stack locations as ideal slots on
// a frame with no abi restrictions. Since we must observe abi restrictions
// (like the placement of the register window) the slots must be biased by
Expand Down
12 changes: 1 addition & 11 deletions src/hotspot/cpu/zero/sharedRuntime_zero.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -119,16 +119,6 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
return generate_empty_runtime_stub("resolve_blob");
}

size_t SharedRuntime::trampoline_size() {
ShouldNotCallThis();
return 0;
}

void SharedRuntime::generate_trampoline(MacroAssembler *masm, address destination) {
ShouldNotCallThis();
return;
}

int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
VMRegPair *regs,
VMRegPair *regs2,
Expand Down
8 changes: 1 addition & 7 deletions src/hotspot/os_cpu/bsd_x86/thread_bsd_x86.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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
Expand Down Expand Up @@ -67,12 +67,6 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
return false;
}

if (MetaspaceShared::is_in_trampoline_frame(addr)) {
// In the middle of a trampoline call. Bail out for safety.
// This happens rarely so shouldn't affect profiling.
return false;
}

frame ret_frame(ret_sp, ret_fp, addr);
if (!ret_frame.safe_for_sender(this)) {
#if COMPILER2_OR_JVMCI
Expand Down
8 changes: 1 addition & 7 deletions src/hotspot/os_cpu/linux_aarch64/thread_linux_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -68,12 +68,6 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
return false;
}

if (MetaspaceShared::is_in_trampoline_frame(addr)) {
// In the middle of a trampoline call. Bail out for safety.
// This happens rarely so shouldn't affect profiling.
return false;
}

frame ret_frame(ret_sp, ret_fp, addr);
if (!ret_frame.safe_for_sender(this)) {
#ifdef COMPILER2
Expand Down
8 changes: 1 addition & 7 deletions src/hotspot/os_cpu/linux_arm/thread_linux_arm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2021, 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
Expand Down Expand Up @@ -101,12 +101,6 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
return false;
}

if (MetaspaceShared::is_in_trampoline_frame(addr)) {
// In the middle of a trampoline call. Bail out for safety.
// This happens rarely so shouldn't affect profiling.
return false;
}

frame ret_frame(ret_sp, ret_fp, addr);
if (!ret_frame.safe_for_sender(this)) {
#ifdef COMPILER2
Expand Down
8 changes: 1 addition & 7 deletions src/hotspot/os_cpu/linux_x86/thread_linux_x86.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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
Expand Down Expand Up @@ -68,12 +68,6 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
return false;
}

if (MetaspaceShared::is_in_trampoline_frame(addr)) {
// In the middle of a trampoline call. Bail out for safety.
// This happens rarely so shouldn't affect profiling.
return false;
}

frame ret_frame(ret_sp, ret_fp, addr);
if (!ret_frame.safe_for_sender(this)) {
#if COMPILER2_OR_JVMCI
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/os_cpu/windows_aarch64/thread_windows_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
return false;
}

if (MetaspaceShared::is_in_trampoline_frame(ret_frame.pc())) {
// In the middle of a trampoline call. Bail out for safety.
// This happens rarely so shouldn't affect profiling.
return false;
}

if (!ret_frame.safe_for_sender(jt)) {
#if COMPILER2_OR_JVMCI
// C2 and JVMCI use ebp as a general register see if NULL fp helps
Expand Down
8 changes: 1 addition & 7 deletions src/hotspot/os_cpu/windows_x86/thread_windows_x86.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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
Expand Down Expand Up @@ -64,12 +64,6 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
return false;
}

if (MetaspaceShared::is_in_trampoline_frame(ret_frame.pc())) {
// In the middle of a trampoline call. Bail out for safety.
// This happens rarely so shouldn't affect profiling.
return false;
}

if (!ret_frame.safe_for_sender(this)) {
#if COMPILER2_OR_JVMCI
// C2 and JVMCI use ebp as a general register see if NULL fp helps
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/include/cds.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, 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
Expand Down Expand Up @@ -33,18 +33,18 @@
//
// Also, this is a C header file. Do not use C++ here.

#define NUM_CDS_REGIONS 8 // this must be the same as MetaspaceShared::n_regions
#define NUM_CDS_REGIONS 7 // this must be the same as MetaspaceShared::n_regions
#define CDS_ARCHIVE_MAGIC 0xf00baba2
#define CDS_DYNAMIC_ARCHIVE_MAGIC 0xf00baba8
#define CURRENT_CDS_ARCHIVE_VERSION 10
#define CURRENT_CDS_ARCHIVE_VERSION 11
#define INVALID_CDS_ARCHIVE_VERSION -1

struct CDSFileMapRegion {
int _crc; // CRC checksum of this region.
int _read_only; // read only region?
int _allow_exec; // executable code in this region?
int _is_heap_region; // Used by SA and debug build.
int _is_bitmap_region; // Relocation bitmap for RO/RW/MC/MD regions (used by SA and debug build).
int _is_bitmap_region; // Relocation bitmap for RO/RW regions (used by SA and debug build).
int _mapped_from_file; // Is this region mapped from a file?
// If false, this region was initialized using os::read().
size_t _file_offset; // Data for this region starts at this offset in the archive file.
Expand Down
42 changes: 1 addition & 41 deletions src/hotspot/share/interpreter/abstractInterpreter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
Expand Down Expand Up @@ -92,7 +92,6 @@ address AbstractInterpreter::_native_entry_begin = NU
address AbstractInterpreter::_native_entry_end = NULL;
address AbstractInterpreter::_slow_signature_handler;
address AbstractInterpreter::_entry_table [AbstractInterpreter::number_of_method_entries];
address AbstractInterpreter::_cds_entry_table [AbstractInterpreter::number_of_method_entries];
address AbstractInterpreter::_native_abi_to_tosca [AbstractInterpreter::number_of_result_handlers];

//------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -200,49 +199,11 @@ AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(const methodHan
return zerolocals;
}

#if INCLUDE_CDS

// For a shared Method m, to improve sharing across processes, we avoid writing to m->_i2i_entry
// at runtime. Instead, m->_i2i_entry points to a fixed location inside the CDS archive.
// This location contains a trampoline (generated by generate_entry_for_cds_method)
// which jumps to _entry_table[kind].
address AbstractInterpreter::entry_for_cds_method(const methodHandle& m) {
MethodKind kind = method_kind(m);
assert(0 <= kind && kind < number_of_method_entries, "illegal kind");
return entry_for_cds_method(kind);
}

address AbstractInterpreter::entry_for_cds_method(AbstractInterpreter::MethodKind kind) {
const size_t trampoline_size = SharedRuntime::trampoline_size();
address addr = MetaspaceShared::i2i_entry_code_buffers();
addr += (size_t)(kind) * trampoline_size;

return addr;
}

void AbstractInterpreter::generate_entry_for_cds_method(AbstractInterpreter::MethodKind kind) {
if (UseSharedSpaces) {
address trampoline = entry_for_cds_method(kind);
CodeBuffer buffer(trampoline, (int)(SharedRuntime::trampoline_size()));
MacroAssembler _masm(&buffer);
SharedRuntime::generate_trampoline(&_masm, _entry_table[kind]);
_masm.flush();

if (PrintInterpreter) {
Disassembler::decode(buffer.insts_begin(), buffer.insts_end());
}
}
}

#endif

void AbstractInterpreter::set_entry_for_kind(AbstractInterpreter::MethodKind kind, address entry) {
assert(kind >= method_handle_invoke_FIRST &&
kind <= method_handle_invoke_LAST, "late initialization only for MH entry points");
assert(_entry_table[kind] == _entry_table[abstract], "previous value must be AME entry");
_entry_table[kind] = entry;

generate_entry_for_cds_method(kind);
}

// Return true if the interpreter can prove that the given bytecode has
Expand Down Expand Up @@ -479,6 +440,5 @@ void AbstractInterpreter::initialize_method_handle_entries() {
for (int i = method_handle_invoke_FIRST; i <= method_handle_invoke_LAST; i++) {
MethodKind kind = (MethodKind) i;
_entry_table[kind] = _entry_table[Interpreter::abstract];
Interpreter::generate_entry_for_cds_method(kind);
}
}
6 changes: 0 additions & 6 deletions src/hotspot/share/interpreter/abstractInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class AbstractInterpreter: AllStatic {

// method entry points
static address _entry_table[number_of_method_entries]; // entry points for a given method
static address _cds_entry_table[number_of_method_entries]; // entry points for methods in the CDS archive
static address _native_abi_to_tosca[number_of_result_handlers]; // for native method result handlers
static address _slow_signature_handler; // the native method generic (slow) signature handler

Expand All @@ -136,11 +135,6 @@ class AbstractInterpreter: AllStatic {
static address entry_for_kind(MethodKind k) { assert(0 <= k && k < number_of_method_entries, "illegal kind"); return _entry_table[k]; }
static address entry_for_method(const methodHandle& m) { return entry_for_kind(method_kind(m)); }

// used by class data sharing
static address entry_for_cds_method(const methodHandle& m) NOT_CDS_RETURN_(NULL);
static address entry_for_cds_method(AbstractInterpreter::MethodKind kind) NOT_CDS_RETURN_(NULL);
static void generate_entry_for_cds_method(MethodKind kind) NOT_CDS_RETURN;

// used for bootstrapping method handles:
static void set_entry_for_kind(MethodKind k, address e);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
Expand Down Expand Up @@ -181,7 +181,6 @@ void TemplateInterpreterGenerator::generate_all() {
#define method_entry(kind) \
{ CodeletMark cm(_masm, "method entry point (kind = " #kind ")"); \
Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind); \
Interpreter::generate_entry_for_cds_method(Interpreter::kind); \
}

// all non-native method kinds
Expand Down
Loading

1 comment on commit d8a9c3c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.