Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Oct 3, 2023
2 parents a8ebe1c + 287b243 commit 6248ca2
Show file tree
Hide file tree
Showing 39 changed files with 711 additions and 123 deletions.
20 changes: 3 additions & 17 deletions make/autoconf/flags-cflags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -799,15 +799,6 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
$1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
$1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
elif test "x$TOOLCHAIN_TYPE" = xclang; then
NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG],
PREFIX: $3,
IF_FALSE: [
NO_DELETE_NULL_POINTER_CHECKS_CFLAG=
]
)
$1_TOOLCHAIN_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG}"
fi
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
Expand Down Expand Up @@ -929,17 +920,12 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
# $2 - Prefix for compiler variables (either BUILD_ or nothing).
AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
[
# These flags are required for GCC 6 builds as undefined behavior in OpenJDK code
# runs afoul of the more aggressive versions of these optimizations.
# Notably, value range propagation now assumes that the this pointer of C++
# member functions is non-null.
NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG],
PREFIX: $2, IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
# This flag is required for GCC 6 builds as undefined behavior in OpenJDK code
# runs afoul of the more aggressive versions of this optimization.
NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG],
PREFIX: $2, IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
$1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
$1_GCC6_CFLAGS="${NO_LIFETIME_DSE_CFLAG}"
])

AC_DEFUN_ONCE([FLAGS_SETUP_BRANCH_PROTECTION],
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/adlc/output_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ void ArchDesc::build_pipe_classes(FILE *fp_cpp) {
fprintf(fp_cpp, " }\n");
fprintf(fp_cpp, "#endif\n\n");
#endif
fprintf(fp_cpp, " assert(this, \"null pipeline info\");\n");
fprintf(fp_cpp, " assert(pred, \"null predecessor pipline info\");\n\n");
fprintf(fp_cpp, " if (pred->hasFixedLatency())\n return (pred->fixedLatency());\n\n");
fprintf(fp_cpp, " // If this is not an operand, then assume a dependence with 0 latency\n");
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/asm/codeBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,11 +1061,6 @@ void CodeSection::print(const char* name) {
}

void CodeBuffer::print() {
if (this == nullptr) {
tty->print_cr("null CodeBuffer pointer");
return;
}

tty->print_cr("CodeBuffer:");
for (int n = 0; n < (int)SECT_LIMIT; n++) {
// print each section
Expand Down
13 changes: 9 additions & 4 deletions src/hotspot/share/code/codeBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,21 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
int frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments)
bool caller_must_gc_arguments,
bool alloc_fail_is_fatal)
{
RuntimeStub* stub = nullptr;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(RuntimeStub));
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
if (stub == nullptr) {
if (!alloc_fail_is_fatal) {
return nullptr;
}
fatal("Initial size of CodeCache is too small");
}
}

trace_new_stub(stub, "RuntimeStub - ", stub_name);
Expand All @@ -431,9 +438,7 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,


void* RuntimeStub::operator new(size_t s, unsigned size) throw() {
void* p = CodeCache::allocate(size, CodeBlobType::NonNMethod);
if (!p) fatal("Initial size of CodeCache is too small");
return p;
return CodeCache::allocate(size, CodeBlobType::NonNMethod);
}

// operator new shared by all singletons:
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/code/codeBlob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ class RuntimeStub: public RuntimeBlob {
int frame_complete,
int frame_size,
OopMapSet* oop_maps,
bool caller_must_gc_arguments
bool caller_must_gc_arguments,
bool alloc_fail_is_fatal=true
);

static void free(RuntimeStub* stub) { RuntimeBlob::free(stub); }
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
#include "gc/shenandoah/shenandoahUtils.hpp"
#include "gc/shenandoah/shenandoahVMOperations.hpp"
#include "interpreter/oopMapCache.hpp"
#include "memory/universe.hpp"

bool VM_ShenandoahReferenceOperation::doit_prologue() {
Expand All @@ -40,6 +41,7 @@ bool VM_ShenandoahReferenceOperation::doit_prologue() {
}

void VM_ShenandoahReferenceOperation::doit_epilogue() {
OopMapCache::cleanup_old_entries();
if (Universe::has_reference_pending_list()) {
Heap_lock->notify_all();
}
Expand Down
60 changes: 49 additions & 11 deletions src/hotspot/share/jvmci/jvmciCodeInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "oops/klass.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/arguments.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/jniHandles.inline.hpp"
#include "runtime/os.hpp"
Expand Down Expand Up @@ -650,6 +651,53 @@ void CodeInstaller::initialize_dependencies(HotSpotCompiledCodeStream* stream, u
}
}

JVMCI::CodeInstallResult CodeInstaller::install_runtime_stub(CodeBlob*& cb,
const char* name,
CodeBuffer* buffer,
int stack_slots,
JVMCI_TRAPS) {
if (name == nullptr) {
JVMCI_ERROR_OK("stub should have a name");
}

name = os::strdup(name);
GrowableArray<RuntimeStub*> *stubs_to_free = nullptr;
#ifdef ASSERT
const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.forceRuntimeStubAllocFail");
if (val != nullptr && strstr(name , val) != 0) {
stubs_to_free = new GrowableArray<RuntimeStub*>();
JVMCI_event_1("forcing allocation of %s in code cache to fail", name);
}
#endif

do {
RuntimeStub* stub = RuntimeStub::new_runtime_stub(name,
buffer,
_offsets.value(CodeOffsets::Frame_Complete),
stack_slots,
_debug_recorder->_oopmaps,
/* caller_must_gc_arguments */ false,
/* alloc_fail_is_fatal */ false);
cb = stub;
if (stub == nullptr) {
// Allocation failed
#ifdef ASSERT
if (stubs_to_free != nullptr) {
JVMCI_event_1("allocation of %s in code cache failed, freeing %d stubs", name, stubs_to_free->length());
for (GrowableArrayIterator<RuntimeStub*> iter = stubs_to_free->begin(); iter != stubs_to_free->end(); ++iter) {
RuntimeStub::free(*iter);
}
}
#endif
return JVMCI::cache_full;
}
if (stubs_to_free == nullptr) {
return JVMCI::ok;
}
stubs_to_free->append(stub);
} while (true);
}

JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler,
jlong compiled_code_buffer,
bool with_type_info,
Expand Down Expand Up @@ -707,17 +755,7 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler,
int stack_slots = _total_frame_size / HeapWordSize; // conversion to words

if (!is_nmethod) {
if (name == nullptr) {
JVMCI_ERROR_OK("stub should have a name");
}
name = os::strdup(name); // Note: this leaks. See JDK-8289632
cb = RuntimeStub::new_runtime_stub(name,
&buffer,
_offsets.value(CodeOffsets::Frame_Complete),
stack_slots,
_debug_recorder->_oopmaps,
false);
result = JVMCI::ok;
return install_runtime_stub(cb, name, &buffer, stack_slots, JVMCI_CHECK_OK);
} else {
if (compile_state != nullptr) {
jvmci_env()->set_compile_state(compile_state);
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/jvmci/jvmciCodeInstaller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ class CodeInstaller : public StackObj {
void read_virtual_objects(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);

int estimateStubSpace(int static_call_stubs);

JVMCI::CodeInstallResult install_runtime_stub(CodeBlob*& cb,
const char* name,
CodeBuffer* buffer,
int stack_slots,
JVMCI_TRAPS);
};

#endif // SHARE_JVMCI_JVMCICODEINSTALLER_HPP
3 changes: 0 additions & 3 deletions src/hotspot/share/oops/objArrayKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ class ObjArrayKlass : public ArrayKlass {
template <typename T, class OopClosureType>
inline void oop_oop_iterate_elements_bounded(objArrayOop a, OopClosureType* closure, void* low, void* high);

template <typename T, class OopClosureType>
inline void oop_oop_iterate_elements_bounded(objArrayOop a, OopClosureType* closure, MemRegion mr);

public:
jint compute_modifier_flags() const;

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/prims/unsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ UNSAFE_ENTRY(jobject, Unsafe_AllocateInstance(JNIEnv *env, jobject unsafe, jclas
return JNIHandles::make_local(THREAD, i);
} UNSAFE_END

UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong size)) {
UNSAFE_LEAF(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong size)) {
size_t sz = (size_t)size;

assert(is_aligned(sz, HeapWordSize), "sz not aligned");
Expand All @@ -345,7 +345,7 @@ UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong si
return addr_to_java(x);
} UNSAFE_END

UNSAFE_ENTRY(jlong, Unsafe_ReallocateMemory0(JNIEnv *env, jobject unsafe, jlong addr, jlong size)) {
UNSAFE_LEAF(jlong, Unsafe_ReallocateMemory0(JNIEnv *env, jobject unsafe, jlong addr, jlong size)) {
void* p = addr_from_java(addr);
size_t sz = (size_t)size;

Expand All @@ -356,7 +356,7 @@ UNSAFE_ENTRY(jlong, Unsafe_ReallocateMemory0(JNIEnv *env, jobject unsafe, jlong
return addr_to_java(x);
} UNSAFE_END

UNSAFE_ENTRY(void, Unsafe_FreeMemory0(JNIEnv *env, jobject unsafe, jlong addr)) {
UNSAFE_LEAF(void, Unsafe_FreeMemory0(JNIEnv *env, jobject unsafe, jlong addr)) {
void* p = addr_from_java(addr);

os::free(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void accept(double t) {
public final DoubleStream limit(long maxSize) {
if (maxSize < 0)
throw new IllegalArgumentException(Long.toString(maxSize));
return SliceOps.makeDouble(this, (long) 0, maxSize);
return SliceOps.makeDouble(this, 0L, maxSize);
}

@Override
Expand Down Expand Up @@ -422,7 +422,7 @@ public final DoubleStream sorted() {
public final DoubleStream distinct() {
// While functional and quick to implement, this approach is not very efficient.
// An efficient version requires a double-specific map/set implementation.
return boxed().distinct().mapToDouble(i -> (double) i);
return boxed().distinct().mapToDouble(i -> i);
}

// Terminal ops from DoubleStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public final LongStream sorted() {
public final LongStream distinct() {
// While functional and quick to implement, this approach is not very efficient.
// An efficient version requires a long-specific map/set implementation.
return boxed().distinct().mapToLong(i -> (long) i);
return boxed().distinct().mapToLong(i -> i);
}

// Terminal ops from LongStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -307,7 +307,7 @@ public void forEachRemaining(Consumer<? super P_OUT> consumer) {
Objects.requireNonNull(consumer);
init();

ph.wrapAndCopyInto((Sink<P_OUT>) consumer::accept, spliterator);
ph.wrapAndCopyInto(consumer::accept, spliterator);
finished = true;
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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 @@ -705,6 +705,7 @@ private void setKeyEntry(String alias, Key key,
// set the alias
entry.alias = alias.toLowerCase(Locale.ENGLISH);
// add the entry
populateAttributes(entry);
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);

} catch (KeyStoreException kse) {
Expand Down Expand Up @@ -785,6 +786,7 @@ public synchronized void engineSetKeyEntry(String alias, byte[] key,

// add the entry
privateKeyCount++;
populateAttributes(entry);
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
}

Expand Down Expand Up @@ -988,6 +990,7 @@ private void setCertEntry(String alias, Certificate cert,
new CertEntry((X509Certificate) cert, null, alias, AnyUsage,
attributes);
certificateCount++;
populateAttributes(certEntry);
entries.put(alias.toLowerCase(Locale.ENGLISH), certEntry);

if (debug != null) {
Expand Down Expand Up @@ -1264,7 +1267,7 @@ public Set<KeyStore.Entry.Attribute> engineGetAttributes(String alias) {
return super.engineGetAttributes(alias);
}
Entry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
return Collections.unmodifiableSet(new HashSet<>(getAttributes(entry)));
return Collections.unmodifiableSet(new HashSet<>(entry.attributes));
}

/**
Expand Down Expand Up @@ -1313,7 +1316,7 @@ public KeyStore.Entry engineGetEntry(String alias,
}

return new KeyStore.TrustedCertificateEntry(
((CertEntry)entry).cert, getAttributes(entry));
((CertEntry)entry).cert, entry.attributes);
}
} else {
throw new UnrecoverableKeyException
Expand All @@ -1335,12 +1338,12 @@ public KeyStore.Entry engineGetEntry(String alias,
Certificate[] chain = engineGetCertificateChain(alias);

return new KeyStore.PrivateKeyEntry((PrivateKey)key, chain,
getAttributes(entry));
entry.attributes);

} else if (key instanceof SecretKey) {

return new KeyStore.SecretKeyEntry((SecretKey)key,
getAttributes(entry));
entry.attributes);
}
} else if (!engineIsKeyEntry(alias)) {
throw new UnsupportedOperationException
Expand Down Expand Up @@ -1429,9 +1432,9 @@ public synchronized void engineSetEntry(String alias, KeyStore.Entry entry,
}

/*
* Assemble the entry attributes
* Populate the entry with additional attributes used by the implementation.
*/
private Set<KeyStore.Entry.Attribute> getAttributes(Entry entry) {
private void populateAttributes(Entry entry) {

if (entry.attributes == null) {
entry.attributes = new HashSet<>();
Expand Down Expand Up @@ -1464,8 +1467,6 @@ private Set<KeyStore.Entry.Attribute> getAttributes(Entry entry) {
}
}
}

return entry.attributes;
}

/*
Expand Down Expand Up @@ -2522,6 +2523,7 @@ private void loadSafeContents(DerInputStream stream)
alias = getUnfriendlyName();
}
entry.alias = alias;
populateAttributes(entry);
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);

} else if (bagItem instanceof X509Certificate cert) {
Expand All @@ -2543,6 +2545,7 @@ private void loadSafeContents(DerInputStream stream)
CertEntry certEntry =
new CertEntry(cert, keyId, alias, trustedKeyUsage,
attributes);
populateAttributes(certEntry);
entries.put(alias.toLowerCase(Locale.ENGLISH), certEntry);
} else {
certEntries.add(new CertEntry(cert, keyId, alias));
Expand Down
Loading

0 comments on commit 6248ca2

Please sign in to comment.