Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
scientificware committed Aug 11, 2023
2 parents ed69596 + 6ffc032 commit 06409e6
Show file tree
Hide file tree
Showing 26 changed files with 296 additions and 320 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Contributing to the JDK

Please see <https://openjdk.org/contribute> for how to contribute.
Please see the [OpenJDK Developers’ Guide](https://openjdk.org/guide/).
19 changes: 5 additions & 14 deletions doc/building.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ <h3 id="building-on-x86">Building on x86</h3>
<p>Even for 32-bit builds, it is recommended to use a 64-bit build
machine, and instead create a 32-bit target using
<code>--with-target-bits=32</code>.</p>
<p>Note: The Windows 32-bit x86 port is deprecated and may be removed in a future release.</p>
<p>Note: The Windows 32-bit x86 port is deprecated and may be removed in
a future release.</p>
<h3 id="building-on-aarch64">Building on aarch64</h3>
<p>At a minimum, a machine with 8 cores is advisable, as well as 8 GB of
RAM. (The more cores to use, the more memory you need.) At least 6 GB of
Expand Down Expand Up @@ -401,7 +402,8 @@ <h3 id="windows">Windows</h3>
use <code>--with-msvcr-dll=/cygdrive/c/msvcr100.dll</code> rather than
<code>--with-msvcr-dll=c:\msvcr100.dll</code>. For details on this
conversion, see the section on <a href="#fixpath">Fixpath</a>.</p>
<p>Note: The Windows 32-bit x86 port is deprecated and may be removed in a future release.</p>
<p>Note: The Windows 32-bit x86 port is deprecated and may be removed in
a future release.</p>
<h4 id="cygwin">Cygwin</h4>
<p>A functioning <a href="http://www.cygwin.com/">Cygwin</a> environment
is required for building the JDK on Windows. If you have a 64-bit OS, we
Expand Down Expand Up @@ -2255,18 +2257,7 @@ <h2 id="contributing-to-the-jdk">Contributing to the JDK</h2>
must ask you to follow our rules and guidelines to be able to accept
your contribution.</p>
<p>The official place to start is the <a
href="http://openjdk.org/contribute/">'How to contribute' page</a>.
There is also an official (but somewhat outdated and skimpy on details)
<a href="http://openjdk.org/guide/">Developer's Guide</a>.</p>
<p>If this seems overwhelming to you, the Adoption Group is there to
help you! A good place to start is their <a
href="https://wiki.openjdk.org/display/Adoption/New+Contributor">'New
Contributor' page</a>, or start reading the comprehensive <a
href="https://adoptopenjdk.gitbooks.io/adoptopenjdk-getting-started-kit/en/">Getting
Started Kit</a>. The Adoption Group will also happily answer any
questions you have about contributing. Contact them by <a
href="http://mail.openjdk.org/mailman/listinfo/adoption-discuss">mail</a>
or <a href="http://openjdk.org/irc/">IRC</a>.</p>
href="https://openjdk.org/guide/">OpenJDK Developers’ Guide</a>.</p>
<h2 id="editing-this-document">Editing this document</h2>
<p>If you want to contribute changes to this document, edit
<code>doc/building.md</code> and then run
Expand Down
15 changes: 1 addition & 14 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -2032,20 +2032,7 @@ First of all: Thank you! We gladly welcome your contribution.
However, please bear in mind that the JDK is a massive project, and we must ask
you to follow our rules and guidelines to be able to accept your contribution.

The official place to start is the ['How to contribute' page](
http://openjdk.org/contribute/). There is also an official (but somewhat
outdated and skimpy on details) [Developer's Guide](
http://openjdk.org/guide/).

If this seems overwhelming to you, the Adoption Group is there to help you! A
good place to start is their ['New Contributor' page](
https://wiki.openjdk.org/display/Adoption/New+Contributor), or start
reading the comprehensive [Getting Started Kit](
https://adoptopenjdk.gitbooks.io/adoptopenjdk-getting-started-kit/en/). The
Adoption Group will also happily answer any questions you have about
contributing. Contact them by [mail](
http://mail.openjdk.org/mailman/listinfo/adoption-discuss) or [IRC](
http://openjdk.org/irc/).
The official place to start is the [OpenJDK Developers’ Guide](https://openjdk.org/guide/).

## Editing this document

Expand Down
16 changes: 11 additions & 5 deletions src/hotspot/share/classfile/classLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ void ClassLoader::setup_app_search_path(JavaThread* current, const char *class_p

while (cp_stream.has_next()) {
const char* path = cp_stream.get_next();
update_class_path_entry_list(current, path, false, false, false);
update_class_path_entry_list(current, path, /* check_for_duplicates */ true,
/* is_boot_append */ false, /* from_class_path_attr */ false);
}
}

Expand Down Expand Up @@ -668,7 +669,8 @@ void ClassLoader::setup_bootstrap_search_path_impl(JavaThread* current, const ch
} else {
// Every entry on the boot class path after the initial base piece,
// which is set by os::set_boot_path(), is considered an appended entry.
update_class_path_entry_list(current, path, false, true, false);
update_class_path_entry_list(current, path, /* check_for_duplicates */ false,
/* is_boot_append */ true, /* from_class_path_attr */ false);
}
}
}
Expand Down Expand Up @@ -803,7 +805,7 @@ void ClassLoader::add_to_boot_append_entries(ClassPathEntry *new_entry) {
// Note that at dump time, ClassLoader::_app_classpath_entries are NOT used for
// loading app classes. Instead, the app class are loaded by the
// jdk/internal/loader/ClassLoaders$AppClassLoader instance.
void ClassLoader::add_to_app_classpath_entries(JavaThread* current,
bool ClassLoader::add_to_app_classpath_entries(JavaThread* current,
ClassPathEntry* entry,
bool check_for_duplicates) {
#if INCLUDE_CDS
Expand All @@ -813,7 +815,7 @@ void ClassLoader::add_to_app_classpath_entries(JavaThread* current,
while (e != nullptr) {
if (strcmp(e->name(), entry->name()) == 0) {
// entry already exists
return;
return false;
}
e = e->next();
}
Expand All @@ -832,6 +834,7 @@ void ClassLoader::add_to_app_classpath_entries(JavaThread* current,
ClassLoaderExt::process_jar_manifest(current, entry);
}
#endif
return true;
}

// Returns true IFF the file/dir exists and the entry was successfully created.
Expand All @@ -854,7 +857,10 @@ bool ClassLoader::update_class_path_entry_list(JavaThread* current,
if (is_boot_append) {
add_to_boot_append_entries(new_entry);
} else {
add_to_app_classpath_entries(current, new_entry, check_for_duplicates);
if (!add_to_app_classpath_entries(current, new_entry, check_for_duplicates)) {
// new_entry is not saved, free it now
delete new_entry;
}
}
return true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/classLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class ClassLoader: AllStatic {
CDS_ONLY(static ClassPathEntry* _last_module_path_entry;)
CDS_ONLY(static void setup_app_search_path(JavaThread* current, const char* class_path);)
CDS_ONLY(static void setup_module_search_path(JavaThread* current, const char* path);)
static void add_to_app_classpath_entries(JavaThread* current,
static bool add_to_app_classpath_entries(JavaThread* current,
ClassPathEntry* entry,
bool check_for_duplicates);
CDS_ONLY(static void add_to_module_path_entries(const char* path,
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/share/gc/g1/g1CardSetContainers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ class G1CardSetInlinePtr : public StackObj {

static ContainerPtr merge(ContainerPtr orig_value, uint card_in_region, uint idx, uint bits_per_card);

static uint card_at(ContainerPtr value, uint const idx, uint const bits_per_card) {
uint8_t card_pos = card_pos_for(idx, bits_per_card);
uint result = ((uintptr_t)value >> card_pos) & (((uintptr_t)1 << bits_per_card) - 1);
return result;
}

uint find(uint const card_idx, uint const bits_per_card, uint start_at, uint num_cards);

public:
Expand Down
21 changes: 11 additions & 10 deletions src/hotspot/share/gc/shared/memAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class MemAllocator::Allocation: StackObj {
bool check_out_of_memory();
void verify_before();
void verify_after();
void notify_allocation(JavaThread* thread);
void notify_allocation();
void notify_allocation_jvmti_sampler();
void notify_allocation_low_memory_detector();
void notify_allocation_jfr_sampler();
void notify_allocation_dtrace_sampler(JavaThread* thread);
void notify_allocation_dtrace_sampler();
#ifdef ASSERT
void check_for_valid_allocation_state() const;
#endif
Expand All @@ -70,19 +70,20 @@ class MemAllocator::Allocation: StackObj {
public:
Allocation(const MemAllocator& allocator, oop* obj_ptr)
: _allocator(allocator),
_thread(JavaThread::current()),
_thread(JavaThread::cast(allocator._thread)), // Do not use Allocation in non-JavaThreads.
_obj_ptr(obj_ptr),
_overhead_limit_exceeded(false),
_allocated_outside_tlab(false),
_allocated_tlab_size(0),
_tlab_end_reset_for_sample(false)
{
assert(Thread::current() == allocator._thread, "do not pass MemAllocator across threads");
verify_before();
}

~Allocation() {
if (!check_out_of_memory()) {
notify_allocation(_thread);
notify_allocation();
}
}

Expand Down Expand Up @@ -156,7 +157,7 @@ void MemAllocator::Allocation::check_for_valid_allocation_state() const {
assert(!_thread->has_pending_exception(),
"shouldn't be allocating with pending exception");
// Allocation of an oop can always invoke a safepoint.
JavaThread::cast(_thread)->check_for_valid_safepoint_state();
_thread->check_for_valid_safepoint_state();
}
#endif

Expand Down Expand Up @@ -217,21 +218,21 @@ void MemAllocator::Allocation::notify_allocation_jfr_sampler() {
}
}

void MemAllocator::Allocation::notify_allocation_dtrace_sampler(JavaThread* thread) {
void MemAllocator::Allocation::notify_allocation_dtrace_sampler() {
if (DTraceAllocProbes) {
// support for Dtrace object alloc event (no-op most of the time)
Klass* klass = obj()->klass();
size_t word_size = _allocator._word_size;
if (klass != nullptr && klass->name() != nullptr) {
SharedRuntime::dtrace_object_alloc(thread, obj(), word_size);
SharedRuntime::dtrace_object_alloc(_thread, obj(), word_size);
}
}
}

void MemAllocator::Allocation::notify_allocation(JavaThread* thread) {
void MemAllocator::Allocation::notify_allocation() {
notify_allocation_low_memory_detector();
notify_allocation_jfr_sampler();
notify_allocation_dtrace_sampler(thread);
notify_allocation_dtrace_sampler();
notify_allocation_jvmti_sampler();
}

Expand Down Expand Up @@ -335,7 +336,7 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab_slow(Allocation& allocation) co

HeapWord* MemAllocator::mem_allocate_slow(Allocation& allocation) const {
// Allocation of an oop can always invoke a safepoint.
debug_only(JavaThread::cast(_thread)->check_for_valid_safepoint_state());
debug_only(allocation._thread->check_for_valid_safepoint_state());

if (UseTLAB) {
// Try refilling the TLAB and allocating the object in it.
Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/gc/shared/memAllocator.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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 @@ -61,7 +61,9 @@ class MemAllocator: StackObj {
: _thread(thread),
_klass(klass),
_word_size(word_size)
{ }
{
assert(_thread == Thread::current(), "must be");
}

// Initialization provided by subclasses.
virtual oop initialize(HeapWord* mem) const = 0;
Expand Down
13 changes: 13 additions & 0 deletions src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp"
#include "prims/nativeLookup.hpp"
#include "runtime/arguments.hpp"
#include "runtime/atomic.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/fieldDescriptor.inline.hpp"
Expand Down Expand Up @@ -585,6 +586,18 @@ C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, ARGU
JVMCI_THROW_MSG_0(InternalError, err_msg("Primitive type %s should be handled in Java code", str));
}

#ifdef ASSERT
const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.lookupTypeException");
if (val != nullptr) {
if (strstr(val, "<trace>") != nullptr) {
tty->print_cr("CompilerToVM.lookupType: %s", str);
} else if (strstr(val, str) != nullptr) {
THROW_MSG_0(vmSymbols::java_lang_Exception(),
err_msg("lookupTypeException: %s", str));
}
}
#endif

JVMCIKlassHandle resolved_klass(THREAD);
Klass* accessing_klass = UNPACK_PAIR(Klass, accessing_klass);
Handle class_loader;
Expand Down
14 changes: 12 additions & 2 deletions src/hotspot/share/jvmci/jvmciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ class HotSpotToSharedLibraryExceptionTranslation : public ExceptionTranslation {
private:
const Handle& _throwable;

int encode(JavaThread* THREAD, jlong buffer, int buffer_size) {
Klass* vmSupport = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_vm_VMSupport(), true, THREAD);
bool handle_pending_exception(JavaThread* THREAD, jlong buffer, int buffer_size) {
if (HAS_PENDING_EXCEPTION) {
Handle throwable = Handle(THREAD, PENDING_EXCEPTION);
Symbol *ex_name = throwable->klass()->name();
Expand All @@ -451,6 +450,14 @@ class HotSpotToSharedLibraryExceptionTranslation : public ExceptionTranslation {
JVMCI_event_1("error translating exception: %s", char_buffer);
decode(THREAD, _encode_fail, buffer);
}
return true;
}
return false;
}

int encode(JavaThread* THREAD, jlong buffer, int buffer_size) {
Klass* vmSupport = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_vm_VMSupport(), true, THREAD);
if (handle_pending_exception(THREAD, buffer, buffer_size)) {
return 0;
}
JavaCallArguments jargs;
Expand All @@ -462,6 +469,9 @@ class HotSpotToSharedLibraryExceptionTranslation : public ExceptionTranslation {
vmSupport,
vmSymbols::encodeThrowable_name(),
vmSymbols::encodeThrowable_signature(), &jargs, THREAD);
if (handle_pending_exception(THREAD, buffer, buffer_size)) {
return 0;
}
return result.get_jint();
}

Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,11 +1247,13 @@ JNIEnv* JVMCIRuntime::init_shared_library_javavm(int* create_JavaVM_err) {
MutexLocker locker(_lock);
JavaVM* javaVM = _shared_library_javavm;
if (javaVM == nullptr) {
#ifdef ASSERT
const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.forceEnomemOnLibjvmciInit");
if (val != nullptr && strcmp(val, "true") == 0) {
*create_JavaVM_err = JNI_ENOMEM;
return nullptr;
}
#endif

char* sl_path;
void* sl_handle = JVMCI::get_shared_library(sl_path, true);
Expand Down Expand Up @@ -2062,12 +2064,14 @@ void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, c

JVMCIObject result_object = JVMCIENV->call_HotSpotJVMCIRuntime_compileMethod(receiver, jvmci_method, entry_bci,
(jlong) compile_state, compile_state->task()->compile_id());
#ifdef ASSERT
if (JVMCIENV->has_pending_exception()) {
const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.compileMethodExceptionIsFatal");
if (val != nullptr && strcmp(val, "true") == 0) {
fatal_exception(JVMCIENV, "testing JVMCI fatal exception handling");
}
}
#endif

if (after_compiler_upcall(JVMCIENV, compiler, method, "call_HotSpotJVMCIRuntime_compileMethod")) {
return;
Expand Down

0 comments on commit 06409e6

Please sign in to comment.