Skip to content

Commit

Permalink
[EagerAppCDS] Add EagerAppCDS Support for JDK8
Browse files Browse the repository at this point in the history
Summary:  Add EagerAppCDS Support for JDK8

Test Plan: ci jtreg CDS

Reviewed-by:  yuleil, zhengxiaolinX, lingjun-cg

Issue: dragonwell-project#552
CR:
  • Loading branch information
jia-wei-tang committed Jun 25, 2023
1 parent c58c56a commit 1640100
Show file tree
Hide file tree
Showing 336 changed files with 24,121 additions and 493 deletions.
51 changes: 47 additions & 4 deletions .github/workflows/submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,28 @@ jobs:
[ -d build ] && rm -rf build
sh configure --with-debug-level=release --with-cacerts-file=${PWD}/common/security/cacerts --with-milestone=fcs --enable-unlimited-crypto
make images CONF=linux-x86_64-normal-server-release
- name: Install dependencies
run: |
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
tar -xvf apache-maven-3.8.8-bin.tar.gz
- name: Download serverless-adapter-jdk8 source code
uses: actions/checkout@v3
with:
repository: dragonwell-project/serverless-adapter-jdk8
ref: main
path: serverless-adapter-jdk8
- name: Build serverless-adapter-jdk8
run: |
export JAVA_HOME=../build/linux-x86_64-normal-server-release/images/j2sdk-image
../apache-maven-3.8.8/bin/mvn package
mkdir -p ../build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/serverless
cp -f target/serverless-adapter-0.1.jar ../build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/serverless/serverless-adapter.jar
cp -f output/libloadclassagent.so ../build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/serverless/
working-directory: serverless-adapter-jdk8
- name: Upload Test image
uses: actions/upload-artifact@v2
with:
name: dragonwell8_release_image_${{ needs.prerequisites.outputs.bundle_id }}
name: dragonwell8_x86_release_image_${{ needs.prerequisites.outputs.bundle_id }}
path: |
build/linux-x86_64-normal-server-release/images/j2sdk-image
Expand Down Expand Up @@ -88,11 +106,14 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Clear Dragonwell8 Dir
run: |
rm -rf /opt/dragonwell8
- name: Download image
id: jtreg_restore
uses: actions/download-artifact@v2
with:
name: dragonwell8_release_image_${{ needs.prerequisites.outputs.bundle_id }}
name: dragonwell8_x86_release_image_${{ needs.prerequisites.outputs.bundle_id }}
path: /opt/dragonwell8
continue-on-error: false
- name: Test image version
Expand Down Expand Up @@ -135,10 +156,29 @@ jobs:
run: |
sh configure --with-debug-level=release --with-cacerts-file=${PWD}/common/security/cacerts --with-milestone=fcs --enable-unlimited-crypto --with-boot-jdk=/home/${USER}/dragonwell8/dragonwell-8.15.16
make images CONF=linux-aarch64-normal-server-release
- name: Install dependencies
run: |
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
tar -xvf apache-maven-3.8.8-bin.tar.gz
- name: Download serverless-adapter-jdk8 source code
uses: actions/checkout@v3
with:
repository: dragonwell-project/serverless-adapter-jdk8
ref: main
path: serverless-adapter-jdk8
- name: Build serverless-adapter-jdk8
run: |
export JAVA_HOME=../build/linux-aarch64-normal-server-release/images/j2sdk-image
../apache-maven-3.8.8/bin/mvn package
mkdir -p ../build/linux-aarch64-normal-server-release/images/j2sdk-image/jre/lib/aarch64/serverless
cp -f target/serverless-adapter-0.1.jar ../build/linux-aarch64-normal-server-release/images/j2sdk-image/jre/lib/aarch64/serverless/serverless-adapter.jar
cp -f output/libloadclassagent.so ../build/linux-aarch64-normal-server-release/images/j2sdk-image/jre/lib/aarch64/serverless/
../build/linux-aarch64-normal-server-release/images/j2sdk-image/bin/java -version
working-directory: serverless-adapter-jdk8
- name: Upload Test image
uses: actions/upload-artifact@v2
with:
name: dragonwell8_release_image_${{ needs.prerequisites.outputs.bundle_id }}
name: dragonwell8_aarch64_release_image_${{ needs.prerequisites.outputs.bundle_id }}
path: |
build/linux-aarch64-normal-server-release/images/j2sdk-image
Expand Down Expand Up @@ -189,11 +229,14 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Clear Dragonwell8 Dir
run: |
rm -rf /opt/dragonwell8
- name: Download image
id: jtreg_restore
uses: actions/download-artifact@v2
with:
name: dragonwell8_release_image_${{ needs.prerequisites.outputs.bundle_id }}
name: dragonwell8_aarch64_release_image_${{ needs.prerequisites.outputs.bundle_id }}
path: /opt/dragonwell8
continue-on-error: false
- name: Test image version
Expand Down
2 changes: 2 additions & 0 deletions hotspot/make/linux/makefiles/mapfile-vers-debug
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ SUNWprivate_1.1 {

# JVM
JVM_Accept;
JVM_DefineClassFromCDS;
JVM_ActiveProcessorCount;
JVM_AllocateNewArray;
JVM_AllocateNewObject;
Expand Down Expand Up @@ -221,6 +222,7 @@ SUNWprivate_1.1 {
JVM_NewInstanceFromConstructor;
JVM_NewMultiArray;
JVM_NotifyApplicationStartUpIsDone;
JVM_NotifyDump;
JVM_NotifyJVMDeoptWarmUpMethods;
JVM_OnExit;
JVM_Open;
Expand Down
2 changes: 2 additions & 0 deletions hotspot/make/linux/makefiles/mapfile-vers-product
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ SUNWprivate_1.1 {

# JVM
JVM_Accept;
JVM_DefineClassFromCDS;
JVM_ActiveProcessorCount;
JVM_AllocateNewArray;
JVM_AllocateNewObject;
Expand Down Expand Up @@ -221,6 +222,7 @@ SUNWprivate_1.1 {
JVM_NewInstanceFromConstructor;
JVM_NewMultiArray;
JVM_NotifyApplicationStartUpIsDone;
JVM_NotifyDump;
JVM_NotifyJVMDeoptWarmUpMethods;
JVM_OnExit;
JVM_Open;
Expand Down
9 changes: 9 additions & 0 deletions hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4518,6 +4518,10 @@ void create_switchTo_contents(MacroAssembler *masm, int start, OopMapSet* oop_ma
__ movl(temp, Address(thread, JavaThread::java_call_counter_offset()));
__ movl(Address(old_coroutine, Coroutine::java_call_counter_offset()), temp);

if (EagerAppCDS && !UseSharedSpaces) {
__ movptr(temp, Address(thread, JavaThread::initiating_loader_offset()));
__ movptr(Address(old_coroutine, Coroutine::initiating_loader_offset()), temp);
}
__ movptr(Address(old_stack, CoroutineStack::last_sp_offset()), rsp);
}
Register target_stack = r12;
Expand Down Expand Up @@ -4565,6 +4569,11 @@ void create_switchTo_contents(MacroAssembler *masm, int start, OopMapSet* oop_ma
__ movl(Address(target_coroutine, Coroutine::java_call_counter_offset()), 0);
#endif

if (EagerAppCDS && !UseSharedSpaces) {
__ movptr(temp, Address(target_coroutine, Coroutine::initiating_loader_offset()));
__ movptr(Address(thread, JavaThread::initiating_loader_offset()), temp);
}

// update the thread's stack base and size
__ movptr(temp, Address(target_stack, CoroutineStack::stack_base_offset()));
__ movptr(Address(thread, JavaThread::stack_base_offset()), temp);
Expand Down
36 changes: 14 additions & 22 deletions hotspot/src/share/vm/classfile/classFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "classfile/verifier.hpp"
#include "classfile/vmSymbols.hpp"
#include "memory/allocation.hpp"
#include "memory/metaspaceShared.hpp"
#include "memory/gcLocker.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/oopFactory.hpp"
Expand Down Expand Up @@ -3918,17 +3919,13 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
u2 minor_version = cfs->get_u2_fast();
u2 major_version = cfs->get_u2_fast();

if (DumpSharedSpaces && major_version < JAVA_1_5_VERSION) {
ResourceMark rm;
#if INCLUDE_CDS
if (DumpSharedSpaces && major_version < JAVA_1_5_VERSION && !EagerAppCDSLegacyVerisonSupport) {
ResourceMark rm(THREAD);
warning("Pre JDK 1.5 class not supported by CDS: %u.%u %s",
major_version, minor_version, name->as_C_string());
Exceptions::fthrow(
THREAD_AND_LOCATION,
vmSymbols::java_lang_UnsupportedClassVersionError(),
"Unsupported major.minor version for dump time %u.%u",
major_version,
minor_version);
}
#endif

// Check version numbers - we check this even with verifier off
if (!is_supported_version(major_version, minor_version)) {
Expand Down Expand Up @@ -4037,18 +4034,6 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
if (cfs->source() != NULL) tty->print(" from %s", cfs->source());
tty->print_cr("]");
}
#if INCLUDE_CDS
if (DumpLoadedClassList != NULL && cfs->source() != NULL && classlist_file->is_open()) {
// Only dump the classes that can be stored into CDS archive
if (SystemDictionaryShared::is_sharing_possible(loader_data)) {
if (name != NULL) {
ResourceMark rm(THREAD);
classlist_file->print_cr("%s", name->as_C_string());
classlist_file->flush();
}
}
}
#endif

u2 super_class_index = cfs->get_u2_fast();
instanceKlassHandle super_klass = parse_super_class(super_class_index,
Expand Down Expand Up @@ -4232,7 +4217,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
this_klass->set_has_default_methods(has_default_methods);
this_klass->set_declares_default_methods(declares_default_methods);

if (CompilationWarmUp || CompilationWarmUpRecording) {
if (EagerAppCDS || CompilationWarmUp || CompilationWarmUpRecording) {
if (_stream->source() == NULL) {
this_klass->set_source_file_path(NULL);
} else {
Expand Down Expand Up @@ -4378,13 +4363,20 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
instanceKlassHandle this_klass (THREAD, preserve_this_klass);
debug_only(this_klass->verify();)

if (CompilationWarmUp || CompilationWarmUpRecording) {
if (CompilationWarmUp || CompilationWarmUpRecording || (EagerAppCDS && DumpLoadedClassList)) {
unsigned int crc32 = ClassLoader::crc32(0, (char*)(_stream->buffer()), _stream->length());
unsigned int class_bytes_size = _stream->length();
this_klass->set_crc32(crc32);
this_klass->set_bytes_size(class_bytes_size);
}

#if INCLUDE_CDS
// CDS set shared_classpath_index
if (DumpSharedSpaces) {
ClassLoader::record_shared_class_loader_type(this_klass(), cfs);
}
#endif

// Clear class if no error has occurred so destructor doesn't deallocate it
_klass = NULL;
return this_klass;
Expand Down
7 changes: 7 additions & 0 deletions hotspot/src/share/vm/classfile/classFileParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ PRAGMA_DIAG_POP
public:
// Constructor
ClassFileParser(ClassFileStream* st) { set_stream(st); }

ClassFileParser(ClassFileStream* st, bool dummy) {
// A safe constructor: the ClassFileParser's constructor is UB.
memset((void*)this, 0, sizeof(ClassFileParser));
set_stream(st);
}

~ClassFileParser();

// Parse .class file and return new Klass*. The Klass* is not hooked up
Expand Down
9 changes: 9 additions & 0 deletions hotspot/src/share/vm/classfile/classFileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,12 @@ ClassFileStream* ClassFileStream::clone() const {
need_verify());
}
#endif // INCLUDE_JFR

uint64_t ClassFileStream::compute_fingerprint() const {
int classfile_size = length();
int classfile_crc = ClassLoader::crc32(0, (const char*)buffer(), length());
uint64_t fingerprint = (uint64_t(classfile_size) << 32) | uint64_t(uint32_t(classfile_crc));
assert(fingerprint != 0, "must not be zero");

return fingerprint;
}
2 changes: 2 additions & 0 deletions hotspot/src/share/vm/classfile/classFileStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class ClassFileStream: public ResourceObj {

bool need_verify() const { return _need_verify; }
#endif

uint64_t compute_fingerprint() const;
};

#endif // SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP
Loading

0 comments on commit 1640100

Please sign in to comment.