8343140: JfrJavaSupport uses the wrong accessors for sub-int fields

Reviewed-by: shade, egahlin
This commit is contained in:
Daniel Jeliński 2024-11-13 13:18:28 +00:00
parent 133f8f3186
commit b72fe75533

View File

@ -299,6 +299,24 @@ void JfrJavaSupport::set_array_element(jobjectArray arr, jobject element, int in
/* /*
* Field access * Field access
*/ */
static void write_bool_field(const Handle& h_oop, fieldDescriptor* fd, jboolean value) {
assert(h_oop.not_null(), "invariant");
assert(fd != nullptr, "invariant");
h_oop->bool_field_put(fd->offset(), value);
}
static void write_char_field(const Handle& h_oop, fieldDescriptor* fd, jchar value) {
assert(h_oop.not_null(), "invariant");
assert(fd != nullptr, "invariant");
h_oop->char_field_put(fd->offset(), value);
}
static void write_short_field(const Handle& h_oop, fieldDescriptor* fd, jshort value) {
assert(h_oop.not_null(), "invariant");
assert(fd != nullptr, "invariant");
h_oop->short_field_put(fd->offset(), value);
}
static void write_int_field(const Handle& h_oop, fieldDescriptor* fd, jint value) { static void write_int_field(const Handle& h_oop, fieldDescriptor* fd, jint value) {
assert(h_oop.not_null(), "invariant"); assert(h_oop.not_null(), "invariant");
assert(fd != nullptr, "invariant"); assert(fd != nullptr, "invariant");
@ -341,8 +359,14 @@ static void write_specialized_field(JfrJavaArguments* args, const Handle& h_oop,
switch(fd->field_type()) { switch(fd->field_type()) {
case T_BOOLEAN: case T_BOOLEAN:
write_bool_field(h_oop, fd, args->param(1).get_jboolean());
break;
case T_CHAR: case T_CHAR:
write_char_field(h_oop, fd, args->param(1).get_jchar());
break;
case T_SHORT: case T_SHORT:
write_short_field(h_oop, fd, args->param(1).get_jshort());
break;
case T_INT: case T_INT:
write_int_field(h_oop, fd, args->param(1).get_jint()); write_int_field(h_oop, fd, args->param(1).get_jint());
break; break;
@ -374,8 +398,14 @@ static void read_specialized_field(JavaValue* result, const Handle& h_oop, field
switch(fd->field_type()) { switch(fd->field_type()) {
case T_BOOLEAN: case T_BOOLEAN:
result->set_jint(h_oop->bool_field(fd->offset()));
break;
case T_CHAR: case T_CHAR:
result->set_jint(h_oop->char_field(fd->offset()));
break;
case T_SHORT: case T_SHORT:
result->set_jint(h_oop->short_field(fd->offset()));
break;
case T_INT: case T_INT:
result->set_jint(h_oop->int_field(fd->offset())); result->set_jint(h_oop->int_field(fd->offset()));
break; break;