Skip to content

Commit e5cb84e

Browse files
author
Markus Grönlund
committedDec 8, 2021
8278336: Use int64_t to represent byte quantities consistently in JfrObjectAllocationSample
Reviewed-by: egahlin
1 parent 54993b1 commit e5cb84e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎src/hotspot/share/jfr/support/jfrObjectAllocationSample.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ inline void send_allocation_sample(const Klass* klass, int64_t allocated_bytes)
3535
assert(allocated_bytes > 0, "invariant");
3636
EventObjectAllocationSample event;
3737
if (event.should_commit()) {
38-
const size_t weight = allocated_bytes - _last_allocated_bytes;
38+
const int64_t weight = allocated_bytes - _last_allocated_bytes;
3939
assert(weight > 0, "invariant");
4040
event.set_objectClass(klass);
4141
event.set_weight(weight);
@@ -48,7 +48,7 @@ inline bool send_allocation_sample_with_result(const Klass* klass, int64_t alloc
4848
assert(allocated_bytes > 0, "invariant");
4949
EventObjectAllocationSample event;
5050
if (event.should_commit()) {
51-
const size_t weight = allocated_bytes - _last_allocated_bytes;
51+
const int64_t weight = allocated_bytes - _last_allocated_bytes;
5252
assert(weight > 0, "invariant");
5353
event.set_objectClass(klass);
5454
event.set_weight(weight);
@@ -59,11 +59,11 @@ inline bool send_allocation_sample_with_result(const Klass* klass, int64_t alloc
5959
return false;
6060
}
6161

62-
inline intptr_t estimate_tlab_size_bytes(Thread* thread) {
62+
inline int64_t estimate_tlab_size_bytes(Thread* thread) {
6363
const size_t desired_tlab_size_bytes = thread->tlab().desired_size() * HeapWordSize;
6464
const size_t alignment_reserve_bytes = thread->tlab().alignment_reserve_in_bytes();
6565
assert(desired_tlab_size_bytes > alignment_reserve_bytes, "invariant");
66-
return static_cast<intptr_t>(desired_tlab_size_bytes - alignment_reserve_bytes);
66+
return static_cast<int64_t>(desired_tlab_size_bytes - alignment_reserve_bytes);
6767
}
6868

6969
inline int64_t load_allocated_bytes(Thread* thread) {
@@ -81,14 +81,14 @@ inline int64_t load_allocated_bytes(Thread* thread) {
8181

8282
// To avoid large objects from being undersampled compared to the regular TLAB samples,
8383
// the data amount is normalized as if it was a TLAB, giving a number of TLAB sampling attempts to the large object.
84-
static void normalize_as_tlab_and_send_allocation_samples(const Klass* klass, intptr_t obj_alloc_size_bytes, Thread* thread) {
84+
static void normalize_as_tlab_and_send_allocation_samples(const Klass* klass, int64_t obj_alloc_size_bytes, Thread* thread) {
8585
const int64_t allocated_bytes = load_allocated_bytes(thread);
8686
assert(allocated_bytes > 0, "invariant"); // obj_alloc_size_bytes is already attributed to allocated_bytes at this point.
8787
if (!UseTLAB) {
8888
send_allocation_sample(klass, allocated_bytes);
8989
return;
9090
}
91-
const intptr_t tlab_size_bytes = estimate_tlab_size_bytes(thread);
91+
const int64_t tlab_size_bytes = estimate_tlab_size_bytes(thread);
9292
if (allocated_bytes - _last_allocated_bytes < tlab_size_bytes) {
9393
return;
9494
}
@@ -103,7 +103,7 @@ static void normalize_as_tlab_and_send_allocation_samples(const Klass* klass, in
103103

104104
void JfrObjectAllocationSample::send_event(const Klass* klass, size_t alloc_size, bool outside_tlab, Thread* thread) {
105105
if (outside_tlab) {
106-
normalize_as_tlab_and_send_allocation_samples(klass, static_cast<intptr_t>(alloc_size), thread);
106+
normalize_as_tlab_and_send_allocation_samples(klass, static_cast<int64_t>(alloc_size), thread);
107107
return;
108108
}
109109
const int64_t allocated_bytes = load_allocated_bytes(thread);

0 commit comments

Comments
 (0)
Please sign in to comment.