Skip to content

Commit b05b0e0

Browse files
Update documentation.
1 parent b33ebe6 commit b05b0e0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,11 +2355,14 @@ static jobject read_field_value(Handle obj, long displacement, jchar type_char,
23552355
}
23562356

23572357
// Perform basic sanity checks on the read. Primitive reads are permitted to read outside the
2358-
// bounds of their fields but object reads must map exactly onto the underlying oop slot.
2358+
// bounds of their fields but object reads must map exactly onto the underlying oop slot. This
2359+
// also ensures that the load is naturally aligned, which is required because the code below
2360+
// uses volatile reads (see JDK-8275874).
23592361
bool aligned = (displacement % basic_type_elemsize) == 0;
23602362
if (!aligned) {
23612363
JVMCI_THROW_MSG_NULL(IllegalArgumentException, "read is unaligned");
23622364
}
2365+
23632366
if (obj->is_array()) {
23642367
// Disallow reading after the last element of an array
23652368
size_t array_length = arrayOop(obj())->length();
@@ -2370,6 +2373,7 @@ static jobject read_field_value(Handle obj, long displacement, jchar type_char,
23702373
JVMCI_THROW_MSG_NULL(IllegalArgumentException, "reading after last array element");
23712374
}
23722375
}
2376+
23732377
if (basic_type == T_OBJECT) {
23742378
if (obj->is_objArray()) {
23752379
if (displacement < arrayOopDesc::base_offset_in_bytes(T_OBJECT)) {

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MemoryAccessProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ public interface MemoryAccessProvider {
3535
* @param displacement the displacement within the object in bytes
3636
* @param bits the number of bits to read from memory
3737
* @return the read value encapsulated in a {@link JavaConstant} object of {@link JavaKind} kind
38+
* or {@code null} in case that the value could not be read
3839
* @throws IllegalArgumentException if the read is out of bounds of the object or {@code kind}
3940
* is {@link JavaKind#Void} or not {@linkplain JavaKind#isPrimitive() primitive}
40-
* kind or {@code bits} is not 8, 16, 32 or 64, or the read is unaligned
41+
* kind or {@code bits} is not 8, 16, 32 or 64, or the value cannot be read safely
42+
* (e.g. unaligned volatile reads on AArch64)
4143
*/
4244
JavaConstant readPrimitiveConstant(JavaKind kind, Constant base, long displacement, int bits) throws IllegalArgumentException;
4345

0 commit comments

Comments
 (0)