Skip to content

Commit d3aaa90

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents f5feca5 + 266e3d0 commit d3aaa90

File tree

61 files changed

+1233
-459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1233
-459
lines changed

make/Main.gmk

+4-1
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,10 @@ endif
13101310
################################################################################
13111311

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

13151318
# all-bundles packages all our deliverables as tar.gz bundles.
13161319
all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles

src/hotspot/cpu/zero/frame_zero.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ bool frame::safe_for_sender(JavaThread *thread) {
125125
bool frame::is_interpreted_frame_valid(JavaThread *thread) const {
126126
assert(is_interpreted_frame(), "Not an interpreted frame");
127127
// These are reasonable sanity checks
128-
if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) {
128+
if (fp() == nullptr || (intptr_t(fp()) & (wordSize-1)) != 0) {
129129
return false;
130130
}
131-
if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
131+
if (sp() == nullptr || (intptr_t(sp()) & (wordSize-1)) != 0) {
132132
return false;
133133
}
134134
// These are hacks to keep us out of trouble.

src/hotspot/share/cds/filemap.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,7 @@ address FileMapInfo::heap_region_dumptime_address() {
22192219
assert(CDSConfig::is_using_archive(), "runtime only");
22202220
assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be");
22212221
if (UseCompressedOops) {
2222-
return /*dumptime*/ narrow_oop_base() + r->mapping_offset();
2222+
return /*dumptime*/ (address)((uintptr_t)narrow_oop_base() + r->mapping_offset());
22232223
} else {
22242224
return heap_region_requested_address();
22252225
}
@@ -2245,7 +2245,7 @@ address FileMapInfo::heap_region_requested_address() {
22452245
// Runtime base = 0x4000 and shift is also 0. If we map this region at 0x5000, then
22462246
// the value P can remain 0x1200. The decoded address = (0x4000 + (0x1200 << 0)) = 0x5200,
22472247
// which is the runtime location of the referenced object.
2248-
return /*runtime*/ CompressedOops::base() + r->mapping_offset();
2248+
return /*runtime*/ (address)((uintptr_t)CompressedOops::base() + r->mapping_offset());
22492249
} else {
22502250
// This was the hard-coded requested base address used at dump time. With uncompressed oops,
22512251
// the heap range is assigned by the OS so we will most likely have to relocate anyway, no matter

src/hotspot/share/gc/shared/genArguments.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ size_t MinNewSize = 0;
3737
size_t MinOldSize = 0;
3838
size_t MaxOldSize = 0;
3939

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

4246
size_t GenAlignment = 0;
4347

src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool&
792792
// Free set maintains mutator and collector partitions. Normally, each allocates only from its partition,
793793
// except in special cases when the collector steals regions from the mutator partition.
794794

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

797797
switch (req.type()) {
798798
case ShenandoahAllocRequest::_alloc_tlab:

src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void ShenandoahGenerationalEvacuationTask::promote_in_place(ShenandoahHeapRegion
202202
while (obj_addr < tams) {
203203
oop obj = cast_to_oop(obj_addr);
204204
if (marking_context->is_marked(obj)) {
205-
assert(obj->klass() != nullptr, "klass should not be NULL");
205+
assert(obj->klass() != nullptr, "klass should not be null");
206206
// This thread is responsible for registering all objects in this region. No need for lock.
207207
scanner->register_object_without_lock(obj_addr);
208208
obj_addr += obj->size();

src/hotspot/share/gc/z/zUtils.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
2525
#include "gc/z/zUtils.hpp"
2626
#include "runtime/nonJavaThread.hpp"
2727

28-
#include <algorithm>
29-
3028
const char* ZUtils::thread_name() {
3129
const Thread* const thread = Thread::current();
3230
if (thread->is_Named_thread()) {
@@ -38,5 +36,7 @@ const char* ZUtils::thread_name() {
3836
}
3937

4038
void ZUtils::fill(uintptr_t* addr, size_t count, uintptr_t value) {
41-
std::fill_n(addr, count, value);
39+
for (size_t i = 0; i < count; ++i) {
40+
addr[i] = value;
41+
}
4242
}

src/hotspot/share/memory/virtualspace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ void ReservedHeapSpace::try_reserve_range(char *highest_start,
443443
while (attach_point >= lowest_start &&
444444
attach_point <= highest_start && // Avoid wrap around.
445445
((_base == nullptr) ||
446-
(_base < aligned_heap_base_min_address || _base + size > upper_bound))) {
446+
(_base < aligned_heap_base_min_address || size > (uintptr_t)(upper_bound - _base)))) {
447447
try_reserve_heap(size, alignment, page_size, attach_point);
448448
attach_point -= stepsize;
449449
}

src/hotspot/share/oops/instanceKlass.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@
9797
#include "utilities/dtrace.hpp"
9898
#include "utilities/events.hpp"
9999
#include "utilities/macros.hpp"
100-
#include "utilities/stringUtils.hpp"
100+
#include "utilities/nativeStackPrinter.hpp"
101101
#include "utilities/pair.hpp"
102+
#include "utilities/stringUtils.hpp"
102103
#ifdef COMPILER1
103104
#include "c1/c1_Compiler.hpp"
104105
#endif
@@ -4009,14 +4010,9 @@ void InstanceKlass::print_class_load_cause_logging() const {
40094010
stringStream stack_stream;
40104011
char buf[O_BUFLEN];
40114012
address lastpc = nullptr;
4012-
if (os::platform_print_native_stack(&stack_stream, nullptr, buf, O_BUFLEN, lastpc)) {
4013-
// We have printed the native stack in platform-specific code,
4014-
// so nothing else to do in this case.
4015-
} else {
4016-
frame f = os::current_frame();
4017-
VMError::print_native_stack(&stack_stream, f, current, true /*print_source_info */,
4018-
-1 /* max stack_stream */, buf, O_BUFLEN);
4019-
}
4013+
NativeStackPrinter nsp(current);
4014+
nsp.print_stack(&stack_stream, buf, sizeof(buf), lastpc,
4015+
true /* print_source_info */, -1 /* max stack */);
40204016

40214017
LogMessage(class, load, cause, native) msg;
40224018
NonInterleavingLogStream info_stream{LogLevelType::Info, msg};

src/hotspot/share/runtime/frame.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,39 @@ void frame::describe(FrameValues& values, int frame_no, const RegisterMap* reg_m
15581558

15591559
#endif
15601560

1561+
/**
1562+
* Gets the caller frame of `fr` for thread `t`.
1563+
*
1564+
* @returns an invalid frame (i.e. fr.pc() === 0) if the caller cannot be obtained
1565+
*/
1566+
frame frame::next_frame(frame fr, Thread* t) {
1567+
// Compiled code may use EBP register on x86 so it looks like
1568+
// non-walkable C frame. Use frame.sender() for java frames.
1569+
frame invalid;
1570+
if (t != nullptr && t->is_Java_thread()) {
1571+
// Catch very first native frame by using stack address.
1572+
// For JavaThread stack_base and stack_size should be set.
1573+
if (!t->is_in_full_stack((address)(fr.real_fp() + 1))) {
1574+
return invalid;
1575+
}
1576+
if (fr.is_interpreted_frame() || (fr.cb() != nullptr && fr.cb()->frame_size() > 0)) {
1577+
RegisterMap map(JavaThread::cast(t),
1578+
RegisterMap::UpdateMap::skip,
1579+
RegisterMap::ProcessFrames::include,
1580+
RegisterMap::WalkContinuation::skip); // No update
1581+
return fr.sender(&map);
1582+
} else {
1583+
// is_first_C_frame() does only simple checks for frame pointer,
1584+
// it will pass if java compiled code has a pointer in EBP.
1585+
if (os::is_first_C_frame(&fr)) return invalid;
1586+
return os::get_sender_for_C_frame(&fr);
1587+
}
1588+
} else {
1589+
if (os::is_first_C_frame(&fr)) return invalid;
1590+
return os::get_sender_for_C_frame(&fr);
1591+
}
1592+
}
1593+
15611594
#ifndef PRODUCT
15621595

15631596
void FrameValues::describe(int owner, intptr_t* location, const char* description, int priority) {

src/hotspot/share/runtime/frame.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ class frame {
440440
void interpreter_frame_print_on(outputStream* st) const;
441441
void print_on_error(outputStream* st, char* buf, int buflen, bool verbose = false) const;
442442
static void print_C_frame(outputStream* st, char* buf, int buflen, address pc);
443+
static frame next_frame(frame fr, Thread* t); // For native stack walking
443444

444445
#ifndef PRODUCT
445446
// Add annotated descriptions of memory locations belonging to this frame to values

src/hotspot/share/runtime/javaThread.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
#include "utilities/dtrace.hpp"
101101
#include "utilities/events.hpp"
102102
#include "utilities/macros.hpp"
103+
#include "utilities/nativeStackPrinter.hpp"
103104
#include "utilities/preserveException.hpp"
104105
#include "utilities/spinYield.hpp"
105106
#include "utilities/vmError.hpp"
@@ -1772,15 +1773,10 @@ void JavaThread::print_jni_stack() {
17721773
tty->print_cr("Unable to print native stack - out of memory");
17731774
return;
17741775
}
1776+
NativeStackPrinter nsp(this);
17751777
address lastpc = nullptr;
1776-
if (os::platform_print_native_stack(tty, nullptr, buf, O_BUFLEN, lastpc)) {
1777-
// We have printed the native stack in platform-specific code,
1778-
// so nothing else to do in this case.
1779-
} else {
1780-
frame f = os::current_frame();
1781-
VMError::print_native_stack(tty, f, this, true /*print_source_info */,
1782-
-1 /* max stack */, buf, O_BUFLEN);
1783-
}
1778+
nsp.print_stack(tty, buf, O_BUFLEN, lastpc,
1779+
true /*print_source_info */, -1 /* max stack */ );
17841780
} else {
17851781
print_active_stack_on(tty);
17861782
}

src/hotspot/share/utilities/debug.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include "utilities/formatBuffer.hpp"
6262
#include "utilities/globalDefinitions.hpp"
6363
#include "utilities/macros.hpp"
64+
#include "utilities/nativeStackPrinter.hpp"
6465
#include "utilities/unsigned5.hpp"
6566
#include "utilities/vmError.hpp"
6667

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

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
#include "precompiled.hpp"
26+
#include "runtime/frame.inline.hpp"
27+
#include "runtime/os.inline.hpp"
28+
#include "utilities/decoder.hpp"
29+
#include "utilities/globalDefinitions.hpp"
30+
#include "utilities/nativeStackPrinter.hpp"
31+
#include "utilities/ostream.hpp"
32+
33+
bool NativeStackPrinter::print_stack(outputStream* st, char* buf, int buf_size,
34+
address& lastpc, bool print_source_info,
35+
int max_frames) {
36+
if (os::platform_print_native_stack(st, _context, buf, buf_size, lastpc)) {
37+
return true;
38+
} else {
39+
print_stack_from_frame(st, buf, buf_size, print_source_info, max_frames);
40+
return false;
41+
}
42+
}
43+
44+
void NativeStackPrinter::print_stack_from_frame(outputStream* st, frame fr,
45+
char* buf, int buf_size,
46+
bool print_source_info, int max_frames) {
47+
// see if it's a valid frame
48+
if (fr.pc()) {
49+
st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");
50+
const int limit = max_frames == -1 ? StackPrintLimit
51+
: MIN2(max_frames, StackPrintLimit);
52+
int count = 0;
53+
while (count++ < limit) {
54+
fr.print_on_error(st, buf, buf_size);
55+
if (fr.pc()) { // print source file and line, if available
56+
char filename[128];
57+
int line_no;
58+
if (count == 1 && _lineno != 0) {
59+
// We have source information for the first frame for internal errors,
60+
// there is no need to parse it from the symbols.
61+
st->print(" (%s:%d)", _filename, _lineno);
62+
} else if (print_source_info &&
63+
Decoder::get_source_info(fr.pc(), filename, sizeof(filename), &line_no, count != 1)) {
64+
st->print(" (%s:%d)", filename, line_no);
65+
}
66+
}
67+
st->cr();
68+
fr = frame::next_frame(fr, _current);
69+
if (fr.pc() == nullptr) {
70+
break;
71+
}
72+
}
73+
74+
if (count > limit) {
75+
st->print_cr("...<more frames>...");
76+
}
77+
78+
} else {
79+
st->print_cr("Native frames: <unavailable>");
80+
}
81+
}

0 commit comments

Comments
 (0)