Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed Dec 13, 2024
2 parents f5feca5 + 266e3d0 commit d3aaa90
Show file tree
Hide file tree
Showing 61 changed files with 1,233 additions and 459 deletions.
5 changes: 4 additions & 1 deletion make/Main.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,10 @@ endif
################################################################################

# all-images builds all our deliverables as images.
all-images: product-images static-jdk-image test-image all-docs-images
all-images: product-images test-image all-docs-images
ifeq ($(call isTargetOs, linux macosx windows), true)
all-images: static-jdk-image
endif

# all-bundles packages all our deliverables as tar.gz bundles.
all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/zero/frame_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ bool frame::safe_for_sender(JavaThread *thread) {
bool frame::is_interpreted_frame_valid(JavaThread *thread) const {
assert(is_interpreted_frame(), "Not an interpreted frame");
// These are reasonable sanity checks
if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) {
if (fp() == nullptr || (intptr_t(fp()) & (wordSize-1)) != 0) {
return false;
}
if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
if (sp() == nullptr || (intptr_t(sp()) & (wordSize-1)) != 0) {
return false;
}
// These are hacks to keep us out of trouble.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ address FileMapInfo::heap_region_dumptime_address() {
assert(CDSConfig::is_using_archive(), "runtime only");
assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be");
if (UseCompressedOops) {
return /*dumptime*/ narrow_oop_base() + r->mapping_offset();
return /*dumptime*/ (address)((uintptr_t)narrow_oop_base() + r->mapping_offset());
} else {
return heap_region_requested_address();
}
Expand All @@ -2245,7 +2245,7 @@ address FileMapInfo::heap_region_requested_address() {
// Runtime base = 0x4000 and shift is also 0. If we map this region at 0x5000, then
// the value P can remain 0x1200. The decoded address = (0x4000 + (0x1200 << 0)) = 0x5200,
// which is the runtime location of the referenced object.
return /*runtime*/ CompressedOops::base() + r->mapping_offset();
return /*runtime*/ (address)((uintptr_t)CompressedOops::base() + r->mapping_offset());
} else {
// This was the hard-coded requested base address used at dump time. With uncompressed oops,
// the heap range is assigned by the OS so we will most likely have to relocate anyway, no matter
Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/gc/shared/genArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ size_t MinNewSize = 0;
size_t MinOldSize = 0;
size_t MaxOldSize = 0;

size_t OldSize = 0;
// If InitialHeapSize or MinHeapSize is not set on cmdline, this variable,
// together with NewSize, is used to derive them.
// Using the same value when it was a configurable flag to avoid breakage.
// See more in JDK-8346005
size_t OldSize = ScaleForWordSize(4*M);

size_t GenAlignment = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool&
// Free set maintains mutator and collector partitions. Normally, each allocates only from its partition,
// except in special cases when the collector steals regions from the mutator partition.

// Overwrite with non-zero (non-NULL) values only if necessary for allocation bookkeeping.
// Overwrite with non-zero (non-null) values only if necessary for allocation bookkeeping.

switch (req.type()) {
case ShenandoahAllocRequest::_alloc_tlab:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void ShenandoahGenerationalEvacuationTask::promote_in_place(ShenandoahHeapRegion
while (obj_addr < tams) {
oop obj = cast_to_oop(obj_addr);
if (marking_context->is_marked(obj)) {
assert(obj->klass() != nullptr, "klass should not be NULL");
assert(obj->klass() != nullptr, "klass should not be null");
// This thread is responsible for registering all objects in this region. No need for lock.
scanner->register_object_without_lock(obj_addr);
obj_addr += obj->size();
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/gc/z/zUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 All @@ -25,8 +25,6 @@
#include "gc/z/zUtils.hpp"
#include "runtime/nonJavaThread.hpp"

#include <algorithm>

const char* ZUtils::thread_name() {
const Thread* const thread = Thread::current();
if (thread->is_Named_thread()) {
Expand All @@ -38,5 +36,7 @@ const char* ZUtils::thread_name() {
}

void ZUtils::fill(uintptr_t* addr, size_t count, uintptr_t value) {
std::fill_n(addr, count, value);
for (size_t i = 0; i < count; ++i) {
addr[i] = value;
}
}
2 changes: 1 addition & 1 deletion src/hotspot/share/memory/virtualspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void ReservedHeapSpace::try_reserve_range(char *highest_start,
while (attach_point >= lowest_start &&
attach_point <= highest_start && // Avoid wrap around.
((_base == nullptr) ||
(_base < aligned_heap_base_min_address || _base + size > upper_bound))) {
(_base < aligned_heap_base_min_address || size > (uintptr_t)(upper_bound - _base)))) {
try_reserve_heap(size, alignment, page_size, attach_point);
attach_point -= stepsize;
}
Expand Down
14 changes: 5 additions & 9 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@
#include "utilities/dtrace.hpp"
#include "utilities/events.hpp"
#include "utilities/macros.hpp"
#include "utilities/stringUtils.hpp"
#include "utilities/nativeStackPrinter.hpp"
#include "utilities/pair.hpp"
#include "utilities/stringUtils.hpp"
#ifdef COMPILER1
#include "c1/c1_Compiler.hpp"
#endif
Expand Down Expand Up @@ -4009,14 +4010,9 @@ void InstanceKlass::print_class_load_cause_logging() const {
stringStream stack_stream;
char buf[O_BUFLEN];
address lastpc = nullptr;
if (os::platform_print_native_stack(&stack_stream, nullptr, buf, O_BUFLEN, lastpc)) {
// We have printed the native stack in platform-specific code,
// so nothing else to do in this case.
} else {
frame f = os::current_frame();
VMError::print_native_stack(&stack_stream, f, current, true /*print_source_info */,
-1 /* max stack_stream */, buf, O_BUFLEN);
}
NativeStackPrinter nsp(current);
nsp.print_stack(&stack_stream, buf, sizeof(buf), lastpc,
true /* print_source_info */, -1 /* max stack */);

LogMessage(class, load, cause, native) msg;
NonInterleavingLogStream info_stream{LogLevelType::Info, msg};
Expand Down
33 changes: 33 additions & 0 deletions src/hotspot/share/runtime/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,39 @@ void frame::describe(FrameValues& values, int frame_no, const RegisterMap* reg_m

#endif

/**
* Gets the caller frame of `fr` for thread `t`.
*
* @returns an invalid frame (i.e. fr.pc() === 0) if the caller cannot be obtained
*/
frame frame::next_frame(frame fr, Thread* t) {
// Compiled code may use EBP register on x86 so it looks like
// non-walkable C frame. Use frame.sender() for java frames.
frame invalid;
if (t != nullptr && t->is_Java_thread()) {
// Catch very first native frame by using stack address.
// For JavaThread stack_base and stack_size should be set.
if (!t->is_in_full_stack((address)(fr.real_fp() + 1))) {
return invalid;
}
if (fr.is_interpreted_frame() || (fr.cb() != nullptr && fr.cb()->frame_size() > 0)) {
RegisterMap map(JavaThread::cast(t),
RegisterMap::UpdateMap::skip,
RegisterMap::ProcessFrames::include,
RegisterMap::WalkContinuation::skip); // No update
return fr.sender(&map);
} else {
// is_first_C_frame() does only simple checks for frame pointer,
// it will pass if java compiled code has a pointer in EBP.
if (os::is_first_C_frame(&fr)) return invalid;
return os::get_sender_for_C_frame(&fr);
}
} else {
if (os::is_first_C_frame(&fr)) return invalid;
return os::get_sender_for_C_frame(&fr);
}
}

#ifndef PRODUCT

void FrameValues::describe(int owner, intptr_t* location, const char* description, int priority) {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/runtime/frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ class frame {
void interpreter_frame_print_on(outputStream* st) const;
void print_on_error(outputStream* st, char* buf, int buflen, bool verbose = false) const;
static void print_C_frame(outputStream* st, char* buf, int buflen, address pc);
static frame next_frame(frame fr, Thread* t); // For native stack walking

#ifndef PRODUCT
// Add annotated descriptions of memory locations belonging to this frame to values
Expand Down
12 changes: 4 additions & 8 deletions src/hotspot/share/runtime/javaThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
#include "utilities/dtrace.hpp"
#include "utilities/events.hpp"
#include "utilities/macros.hpp"
#include "utilities/nativeStackPrinter.hpp"
#include "utilities/preserveException.hpp"
#include "utilities/spinYield.hpp"
#include "utilities/vmError.hpp"
Expand Down Expand Up @@ -1772,15 +1773,10 @@ void JavaThread::print_jni_stack() {
tty->print_cr("Unable to print native stack - out of memory");
return;
}
NativeStackPrinter nsp(this);
address lastpc = nullptr;
if (os::platform_print_native_stack(tty, nullptr, buf, O_BUFLEN, lastpc)) {
// We have printed the native stack in platform-specific code,
// so nothing else to do in this case.
} else {
frame f = os::current_frame();
VMError::print_native_stack(tty, f, this, true /*print_source_info */,
-1 /* max stack */, buf, O_BUFLEN);
}
nsp.print_stack(tty, buf, O_BUFLEN, lastpc,
true /*print_source_info */, -1 /* max stack */ );
} else {
print_active_stack_on(tty);
}
Expand Down
17 changes: 7 additions & 10 deletions src/hotspot/share/utilities/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "utilities/formatBuffer.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "utilities/nativeStackPrinter.hpp"
#include "utilities/unsigned5.hpp"
#include "utilities/vmError.hpp"

Expand Down Expand Up @@ -645,10 +646,11 @@ void help() {
extern "C" DEBUGEXPORT void pns(void* sp, void* fp, void* pc) { // print native stack
Command c("pns");
static char buf[O_BUFLEN];
Thread* t = Thread::current_or_null();
// Call generic frame constructor (certain arguments may be ignored)
frame fr(sp, fp, pc);
VMError::print_native_stack(tty, fr, t, false, -1, buf, sizeof(buf));
NativeStackPrinter nsp(Thread::current_or_null());
nsp.print_stack_from_frame(tty, fr, buf, sizeof(buf),
false /* print_source_info */, -1 /* max stack */);
}

//
Expand All @@ -663,14 +665,9 @@ extern "C" DEBUGEXPORT void pns2() { // print native stack
Command c("pns2");
static char buf[O_BUFLEN];
address lastpc = nullptr;
if (os::platform_print_native_stack(tty, nullptr, buf, sizeof(buf), lastpc)) {
// We have printed the native stack in platform-specific code,
// so nothing else to do in this case.
} else {
Thread* t = Thread::current_or_null();
frame fr = os::current_frame();
VMError::print_native_stack(tty, fr, t, false, -1, buf, sizeof(buf));
}
NativeStackPrinter nsp(Thread::current_or_null());
nsp.print_stack(tty, buf, sizeof(buf), lastpc,
false /* print_source_info */, -1 /* max stack */);
}
#endif

Expand Down
81 changes: 81 additions & 0 deletions src/hotspot/share/utilities/nativeStackPrinter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2003, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#include "precompiled.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/os.inline.hpp"
#include "utilities/decoder.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/nativeStackPrinter.hpp"
#include "utilities/ostream.hpp"

bool NativeStackPrinter::print_stack(outputStream* st, char* buf, int buf_size,
address& lastpc, bool print_source_info,
int max_frames) {
if (os::platform_print_native_stack(st, _context, buf, buf_size, lastpc)) {
return true;
} else {
print_stack_from_frame(st, buf, buf_size, print_source_info, max_frames);
return false;
}
}

void NativeStackPrinter::print_stack_from_frame(outputStream* st, frame fr,
char* buf, int buf_size,
bool print_source_info, int max_frames) {
// see if it's a valid frame
if (fr.pc()) {
st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");
const int limit = max_frames == -1 ? StackPrintLimit
: MIN2(max_frames, StackPrintLimit);
int count = 0;
while (count++ < limit) {
fr.print_on_error(st, buf, buf_size);
if (fr.pc()) { // print source file and line, if available
char filename[128];
int line_no;
if (count == 1 && _lineno != 0) {
// We have source information for the first frame for internal errors,
// there is no need to parse it from the symbols.
st->print(" (%s:%d)", _filename, _lineno);
} else if (print_source_info &&
Decoder::get_source_info(fr.pc(), filename, sizeof(filename), &line_no, count != 1)) {
st->print(" (%s:%d)", filename, line_no);
}
}
st->cr();
fr = frame::next_frame(fr, _current);
if (fr.pc() == nullptr) {
break;
}
}

if (count > limit) {
st->print_cr("...<more frames>...");
}

} else {
st->print_cr("Native frames: <unavailable>");
}
}
Loading

0 comments on commit d3aaa90

Please sign in to comment.