Skip to content

Commit

Permalink
Merge branch 'openjdk:master' into float16_support
Browse files Browse the repository at this point in the history
  • Loading branch information
jatin-bhateja authored Oct 14, 2024
2 parents c5536c5 + 1581508 commit cb98166
Show file tree
Hide file tree
Showing 21 changed files with 411 additions and 66 deletions.
4 changes: 3 additions & 1 deletion src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5011,8 +5011,10 @@ void MacroAssembler::decode_heap_oop(Register d, Register s) {
verify_heapbase("MacroAssembler::decode_heap_oop: heap base corrupted?");
#endif
if (CompressedOops::base() == nullptr) {
if (CompressedOops::shift() != 0 || d != s) {
if (CompressedOops::shift() != 0) {
lsl(d, s, CompressedOops::shift());
} else if (d != s) {
mov(d, s);
}
} else {
Label done;
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2483,16 +2483,6 @@ int os::open(const char *path, int oflag, int mode) {
return fd;
}

// return current position of file pointer
jlong os::current_file_offset(int fd) {
return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
}

// move file pointer to the specified offset
jlong os::seek_to_file_offset(int fd, jlong offset) {
return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
}

// current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
// are used by JVM M&M and JVMTI to get user+sys or user CPU time
// of a thread.
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2400,16 +2400,6 @@ int os::open(const char *path, int oflag, int mode) {
return fd;
}

// return current position of file pointer
jlong os::current_file_offset(int fd) {
return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
}

// move file pointer to the specified offset
jlong os::seek_to_file_offset(int fd, jlong offset) {
return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
}

// current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
// are used by JVM M&M and JVMTI to get user+sys or user CPU time
// of a thread.
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5053,16 +5053,6 @@ int os::open(const char *path, int oflag, int mode) {
return fd;
}

// return current position of file pointer
jlong os::current_file_offset(int fd) {
return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
}

// move file pointer to the specified offset
jlong os::seek_to_file_offset(int fd, jlong offset) {
return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
}

static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time);

static jlong fast_cpu_time(Thread *thread) {
Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/os/posix/os_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ int os::create_file_for_heap(const char* dir) {
return fd;
}

// return current position of file pointer
jlong os::current_file_offset(int fd) {
return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
}

// move file pointer to the specified offset
jlong os::seek_to_file_offset(int fd, jlong offset) {
return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
}

// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
DIR *dir = nullptr;
Expand Down
10 changes: 3 additions & 7 deletions src/hotspot/share/classfile/fieldLayoutBuilder.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, 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,17 +101,13 @@ class LayoutRawBlock : public ResourceObj {
// sort fields in decreasing order.
// Note: with line types, the comparison should include alignment constraint if sizes are equals
static int compare_size_inverted(LayoutRawBlock** x, LayoutRawBlock** y) {
#ifdef _WINDOWS
// qsort() on Windows reverse the order of fields with the same size
// the extension of the comparison function below preserves this order
int diff = (*y)->size() - (*x)->size();
// qsort() may reverse the order of fields with the same size.
// The extension is to ensure stable sort.
if (diff == 0) {
diff = (*x)->field_index() - (*y)->field_index();
}
return diff;
#else
return (*y)->size() - (*x)->size();
#endif // _WINDOWS
}

};
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@
nonstatic_field(JavaThread, _jvmci_reserved_oop0, oop) \
nonstatic_field(JavaThread, _should_post_on_exceptions_flag, int) \
nonstatic_field(JavaThread, _jni_environment, JNIEnv) \
nonstatic_field(JavaThread, _poll_data, SafepointMechanism::ThreadData) \
nonstatic_field(JavaThread, _stack_overflow_state._reserved_stack_activation, address) \
nonstatic_field(JavaThread, _held_monitor_count, intx) \
nonstatic_field(JavaThread, _lock_stack, LockStack) \
Expand Down Expand Up @@ -409,6 +408,7 @@
static_field(StubRoutines, _cont_thaw, address) \
static_field(StubRoutines, _lookup_secondary_supers_table_slow_path_stub, address) \
\
nonstatic_field(Thread, _poll_data, SafepointMechanism::ThreadData) \
nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \
nonstatic_field(Thread, _allocated_bytes, jlong) \
JFR_ONLY(nonstatic_field(Thread, _jfr_thread_local, JfrThreadLocal)) \
Expand Down
20 changes: 19 additions & 1 deletion src/hotspot/share/nmt/vmatree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

#include "precompiled.hpp"
#include "logging/log.hpp"
#include "nmt/vmatree.hpp"
#include "utilities/growableArray.hpp"

Expand All @@ -34,7 +35,9 @@ const char* VMATree::statetype_strings[3] = {
};

VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType state,
const RegionData& metadata) {
const RegionData& metadata, bool use_tag_inplace) {
assert(!use_tag_inplace || metadata.mem_tag == mtNone,
"If using use_tag_inplace, then the supplied tag should be mtNone, was instead: %s", NMTUtil::tag_to_name(metadata.mem_tag));
if (A == B) {
// A 0-sized mapping isn't worth recording.
return SummaryDiff();
Expand All @@ -55,13 +58,28 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType
AddressState LEQ_A;
TreapNode* leqA_n = _tree.closest_leq(A);
if (leqA_n == nullptr) {
assert(!use_tag_inplace, "Cannot use the tag inplace if no pre-existing tag exists. From: " PTR_FORMAT " To: " PTR_FORMAT, A, B);
if (use_tag_inplace) {
log_debug(nmt)("Cannot use the tag inplace if no pre-existing tag exists. From: " PTR_FORMAT " To: " PTR_FORMAT, A, B);
}
// No match. We add the A node directly, unless it would have no effect.
if (!stA.is_noop()) {
_tree.upsert(A, stA);
}
} else {
LEQ_A_found = true;
LEQ_A = AddressState{leqA_n->key(), leqA_n->val()};
StateType leqA_state = leqA_n->val().out.type();
StateType new_state = stA.out.type();
// If we specify use_tag_inplace then the new region takes over the current tag instead of the tag in metadata.
// This is important because the VirtualMemoryTracker API doesn't require supplying the tag for some operations.
if (use_tag_inplace) {
assert(leqA_n->val().out.type() != StateType::Released, "Should not use inplace the tag of a released region");
MemTag tag = leqA_n->val().out.mem_tag();
stA.out.set_tag(tag);
stB.in.set_tag(tag);
}

// Unless we know better, let B's outgoing state be the outgoing state of the node at or preceding A.
// Consider the case where the found node is the start of a region enclosing [A,B)
stB.out = leqA_n->val().out;
Expand Down
32 changes: 21 additions & 11 deletions src/hotspot/share/nmt/vmatree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class VMATree {
return statetype_strings[static_cast<uint8_t>(type)];
}

// Each point has some stack and a flag associated with it.
// Each point has some stack and a tag associated with it.
struct RegionData {
const NativeCallStackStorage::StackIndex stack_idx;
const MemTag mem_tag;
Expand All @@ -88,30 +88,34 @@ class VMATree {
struct IntervalState {
private:
// Store the type and mem_tag as two bytes
uint8_t type_flag[2];
uint8_t type_tag[2];
NativeCallStackStorage::StackIndex sidx;

public:
IntervalState() : type_flag{0,0}, sidx() {}
IntervalState() : type_tag{0,0}, sidx() {}
IntervalState(const StateType type, const RegionData data) {
assert(!(type == StateType::Released) || data.mem_tag == mtNone, "Released type must have memory tag mtNone");
type_flag[0] = static_cast<uint8_t>(type);
type_flag[1] = static_cast<uint8_t>(data.mem_tag);
type_tag[0] = static_cast<uint8_t>(type);
type_tag[1] = static_cast<uint8_t>(data.mem_tag);
sidx = data.stack_idx;
}

StateType type() const {
return static_cast<StateType>(type_flag[0]);
return static_cast<StateType>(type_tag[0]);
}

MemTag mem_tag() const {
return static_cast<MemTag>(type_flag[1]);
return static_cast<MemTag>(type_tag[1]);
}

RegionData regiondata() const {
return RegionData{sidx, mem_tag()};
}

void set_tag(MemTag tag) {
type_tag[1] = static_cast<uint8_t>(tag);
}

NativeCallStackStorage::StackIndex stack() const {
return sidx;
}
Expand Down Expand Up @@ -167,14 +171,20 @@ class VMATree {
}
};

SummaryDiff register_mapping(position A, position B, StateType state, const RegionData& metadata);
private:
SummaryDiff register_mapping(position A, position B, StateType state, const RegionData& metadata, bool use_tag_inplace = false);

public:
SummaryDiff reserve_mapping(position from, position sz, const RegionData& metadata) {
return register_mapping(from, from + sz, StateType::Reserved, metadata);
return register_mapping(from, from + sz, StateType::Reserved, metadata, false);
}

SummaryDiff commit_mapping(position from, position sz, const RegionData& metadata, bool use_tag_inplace = false) {
return register_mapping(from, from + sz, StateType::Committed, metadata, use_tag_inplace);
}

SummaryDiff commit_mapping(position from, position sz, const RegionData& metadata) {
return register_mapping(from, from + sz, StateType::Committed, metadata);
SummaryDiff uncommit_mapping(position from, position sz, const RegionData& metadata) {
return register_mapping(from, from + sz, StateType::Reserved, metadata, true);
}

SummaryDiff release_mapping(position from, position sz) {
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/opto/callGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,10 @@ void CallGenerator::do_late_inline_helper() {

// check for unreachable loop
CallProjections callprojs;
call->extract_projections(&callprojs, true);
// Similar to incremental inlining, don't assert that all call
// projections are still there for post-parse call devirtualization.
bool do_asserts = !is_mh_late_inline() && !is_virtual_late_inline();
call->extract_projections(&callprojs, true, do_asserts);
if ((callprojs.fallthrough_catchproj == call->in(0)) ||
(callprojs.catchall_catchproj == call->in(0)) ||
(callprojs.fallthrough_memproj == call->in(TypeFunc::Memory)) ||
Expand All @@ -647,7 +650,7 @@ void CallGenerator::do_late_inline_helper() {

if (is_pure_call() && result_not_used) {
GraphKit kit(call->jvms());
kit.replace_call(call, C->top(), true);
kit.replace_call(call, C->top(), true, do_asserts);
} else {
// Make a clone of the JVMState that appropriate to use for driving a parse
JVMState* old_jvms = call->jvms();
Expand Down Expand Up @@ -729,7 +732,7 @@ void CallGenerator::do_late_inline_helper() {
}
C->set_inlining_progress(true);
C->set_do_cleanup(kit.stopped()); // path is dead; needs cleanup
kit.replace_call(call, result, true);
kit.replace_call(call, result, true, do_asserts);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/graphKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ static void add_mergemem_users_to_worklist(Unique_Node_List& wl, Node* mem) {
}

// Replace the call with the current state of the kit.
void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes) {
void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes, bool do_asserts) {
JVMState* ejvms = nullptr;
if (has_exceptions()) {
ejvms = transfer_exceptions_into_jvms();
Expand All @@ -1944,7 +1944,7 @@ void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes

// Find all the needed outputs of this call
CallProjections callprojs;
call->extract_projections(&callprojs, true);
call->extract_projections(&callprojs, true, do_asserts);

Unique_Node_List wl;
Node* init_mem = call->in(TypeFunc::Memory);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/graphKit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ class GraphKit : public Phase {
// Replace the call with the current state of the kit. Requires
// that the call was generated with separate io_projs so that
// exceptional control flow can be handled properly.
void replace_call(CallNode* call, Node* result, bool do_replaced_nodes = false);
void replace_call(CallNode* call, Node* result, bool do_replaced_nodes = false, bool do_asserts = true);

// helper functions for statistics
void increment_counter(address counter_addr); // increment a debug counter
Expand Down
20 changes: 16 additions & 4 deletions src/hotspot/share/runtime/javaThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ class JavaThread: public Thread {
// Safepoint support
public: // Expose _thread_state for SafeFetchInt()
volatile JavaThreadState _thread_state;
private:
SafepointMechanism::ThreadData _poll_data;
ThreadSafepointState* _safepoint_state; // Holds information about a thread during a safepoint
address _saved_exception_pc; // Saved pc of instruction where last implicit exception happened
NOT_PRODUCT(bool _requires_cross_modify_fence;) // State used by VerifyCrossModifyFence
Expand Down Expand Up @@ -598,6 +596,22 @@ class JavaThread: public Thread {

SafepointMechanism::ThreadData* poll_data() { return &_poll_data; }

static ByteSize polling_word_offset() {
ByteSize offset = byte_offset_of(Thread, _poll_data) +
byte_offset_of(SafepointMechanism::ThreadData, _polling_word);
// At least on x86_64, safepoint polls encode the offset as disp8 imm.
assert(in_bytes(offset) < 128, "Offset >= 128");
return offset;
}

static ByteSize polling_page_offset() {
ByteSize offset = byte_offset_of(Thread, _poll_data) +
byte_offset_of(SafepointMechanism::ThreadData, _polling_page);
// At least on x86_64, safepoint polls encode the offset as disp8 imm.
assert(in_bytes(offset) < 128, "Offset >= 128");
return offset;
}

void set_requires_cross_modify_fence(bool val) PRODUCT_RETURN NOT_PRODUCT({ _requires_cross_modify_fence = val; })

// Continuation support
Expand Down Expand Up @@ -787,8 +801,6 @@ class JavaThread: public Thread {
static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result); }
static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2); }
static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state); }
static ByteSize polling_word_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_word);}
static ByteSize polling_page_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_page);}
static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc); }
static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread); }
#if INCLUDE_JVMCI
Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/runtime/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/threadHeapSampler.hpp"
#include "runtime/threadLocalStorage.hpp"
#include "runtime/threadStatisticalInfo.hpp"
Expand Down Expand Up @@ -109,6 +110,7 @@ class Thread: public ThreadShadow {
friend class VMErrorCallbackMark;
friend class VMStructs;
friend class JVMCIVMStructs;
friend class JavaThread;
private:

#ifndef USE_LIBRARY_BASED_TLS_ONLY
Expand All @@ -135,6 +137,11 @@ class Thread: public ThreadShadow {
}

private:
// Poll data is used in generated code for safepoint polls.
// It is important for performance to put this at lower offset
// in Thread. The accessors are in JavaThread.
SafepointMechanism::ThreadData _poll_data;

// Thread local data area available to the GC. The internal
// structure and contents of this data area is GC-specific.
// Only GC and GC barrier code should access this data area.
Expand Down
Loading

0 comments on commit cb98166

Please sign in to comment.