Skip to content

Commit 8d0c25d

Browse files
martinuygnu-andrew
authored andcommittedJan 13, 2023
8286496: Improve Thread labels
Reviewed-by: andrew Backport-of: e733e55de88e63e129f15edefc602c050339b38a
1 parent 259a33e commit 8d0c25d

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed
 

‎hotspot/src/share/vm/jfr/recorder/checkpoint/jfrCheckpointManager.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ bool JfrCheckpointManager::is_locked() const {
156156
}
157157

158158
static void assert_free_lease(const BufferPtr buffer) {
159-
assert(buffer != NULL, "invariant");
159+
if (buffer == NULL) {
160+
return;
161+
}
160162
assert(buffer->acquired_by_self(), "invariant");
161163
assert(buffer->lease(), "invariant");
162164
}

‎hotspot/src/share/vm/jfr/recorder/storage/jfrBuffer.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ JfrBuffer::JfrBuffer() : _next(NULL),
3838
_top(NULL),
3939
_flags(0),
4040
_header_size(0),
41-
_size(0) {}
41+
_size(0)
42+
LP64_ONLY(COMMA _pad(0)) {}
4243

4344
bool JfrBuffer::initialize(size_t header_size, size_t size, const void* id /* NULL */) {
44-
_header_size = (u2)header_size;
45-
_size = (u4)(size / BytesPerWord);
45+
assert(header_size <= max_jushort, "invariant");
46+
_header_size = static_cast<u2>(header_size);
47+
_size = size;
4648
assert(_identity == NULL, "invariant");
4749
_identity = id;
4850
set_pos(start());

‎hotspot/src/share/vm/jfr/recorder/storage/jfrBuffer.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ class JfrBuffer {
5252
const void* volatile _identity;
5353
u1* _pos;
5454
mutable const u1* volatile _top;
55-
u2 _flags;
55+
size_t _size;
5656
u2 _header_size;
57-
u4 _size;
57+
u2 _flags;
58+
LP64_ONLY(const u4 _pad;)
5859

5960
const u1* stable_top() const;
6061

@@ -124,7 +125,7 @@ class JfrBuffer {
124125
}
125126

126127
size_t size() const {
127-
return _size * BytesPerWord;
128+
return _size;
128129
}
129130

130131
size_t total_size() const {

‎hotspot/src/share/vm/jfr/recorder/storage/jfrMemorySpace.hpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,27 @@ class JfrMemorySpace : public JfrCHeapObj {
108108
};
109109

110110
// allocations are even multiples of the mspace min size
111-
inline u8 align_allocation_size(u8 requested_size, size_t min_elem_size) {
111+
inline size_t align_allocation_size(size_t requested_size, size_t min_elem_size) {
112112
assert((int)min_elem_size % os::vm_page_size() == 0, "invariant");
113+
if (requested_size > static_cast<size_t>(min_intx)) {
114+
assert(false, err_msg("requested size: " SIZE_FORMAT " is too large", requested_size));
115+
return 0;
116+
}
113117
u8 alloc_size_bytes = min_elem_size;
114118
while (requested_size > alloc_size_bytes) {
115119
alloc_size_bytes <<= 1;
116120
}
117121
assert((int)alloc_size_bytes % os::vm_page_size() == 0, "invariant");
118-
return alloc_size_bytes;
122+
assert(alloc_size_bytes <= static_cast<size_t>(min_intx), "invariant");
123+
return static_cast<size_t>(alloc_size_bytes);
119124
}
120125

121126
template <typename T, template <typename> class RetrievalType, typename Callback>
122127
T* JfrMemorySpace<T, RetrievalType, Callback>::allocate(size_t size) {
123-
const u8 aligned_size_bytes = align_allocation_size(size, _min_elem_size);
128+
const size_t aligned_size_bytes = align_allocation_size(size, _min_elem_size);
129+
if (size != 0 && aligned_size_bytes == 0) {
130+
return NULL;
131+
}
124132
void* const allocation = JfrCHeapObj::new_array<u1>(aligned_size_bytes + sizeof(T));
125133
if (allocation == NULL) {
126134
return NULL;

‎hotspot/src/share/vm/jfr/writers/jfrWriterHost.inline.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ template <typename T>
7070
inline void WriterHost<BE, IE, WriterPolicyImpl>::write(const T* value, size_t len) {
7171
assert(value != NULL, "invariant");
7272
assert(len > 0, "invariant");
73+
assert(len <= max_jint, "invariant");
7374
// Might need T + 1 size
7475
u1* const pos = ensure_size(sizeof(T) * len + len);
7576
if (pos) {
@@ -125,8 +126,9 @@ template <typename T>
125126
inline void WriterHost<BE, IE, WriterPolicyImpl>::be_write(const T* value, size_t len) {
126127
assert(value != NULL, "invariant");
127128
assert(len > 0, "invariant");
128-
// Might need T + 1 size
129-
u1* const pos = ensure_size(sizeof(T) * len + len);
129+
assert(len <= max_jint, "invariant");
130+
// Big endian writes map one-to-one for length, so no extra space is needed.
131+
u1* const pos = ensure_size(sizeof(T) * len);
130132
if (pos) {
131133
this->set_current_pos(BE::be_write(value, len, pos));
132134
}

‎hotspot/src/share/vm/prims/jni.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ static jint CurrentVersion = JNI_VERSION_1_8;
191191
#define FP_SELECT(TypeName, intcode, fpcode) \
192192
FP_SELECT_##TypeName(intcode, fpcode)
193193

194-
#define COMMA ,
195-
196194
// Choose DT_RETURN_MARK macros based on the type: float/double -> void
197195
// (dtrace doesn't do FP yet)
198196
#ifndef USDT2

‎hotspot/src/share/vm/utilities/macros.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
// Makes a string of the macro expansion of a
3535
#define XSTR(a) STR(a)
3636

37+
// Allow commas in macro arguments.
38+
#define COMMA ,
39+
3740
// -DINCLUDE_<something>=0 | 1 can be specified on the command line to include
3841
// or exclude functionality.
3942

0 commit comments

Comments
 (0)
Please sign in to comment.