RFR 8068975: Remove deprecated methods on sun.misc.Unsafe and clean up native implementation
Paul Sandoz
paul.sandoz at oracle.com
Thu Feb 5 11:48:53 UTC 2015
Hi,
Here is a minor update to the patch, adjusting the documentation on Unsafe.throwIllegalAccessError and removing the TODO related to strange methods (i would like to re-visit those separately, more on that below):
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8068975-unsafe-cleanup/webrev/
On Jan 19, 2015, at 4:31 PM, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
>>> There is one remaining TODO:
>>>
>>> 136 // Externally callable versions:
>>> 137 // (Use these in compiler intrinsics which emulate unsafe primitives.)
>>> 138 jlong Unsafe_field_offset_to_byte_offset(jlong field_offset) {
>>> 139 return field_offset;
>>> 140 }
>>> 141 // TODO The following three methods are not used, can they be removed?
>>> 142 jlong Unsafe_field_offset_from_byte_offset(jlong byte_offset) {
>>> 143 return byte_offset;
>>> 144 }
>>> 145 jint Unsafe_invocation_key_from_method_slot(jint slot) {
>>> 146 return invocation_key_from_method_slot(slot);
>>> 147 }
>>> 148 jint Unsafe_invocation_key_to_method_slot(jint key) {
>>> 149 return invocation_key_to_method_slot(key);
>>> 150 }
>>>
>>> I don't quite know what the above methods are for, but only the first is used, and it's a no-op. Can anyone provider more context for these?
>>
>> Sorry I can't help there.
>>
>
> Ok, i will remove and see what happens.
>
The method:
jlong Unsafe_field_offset_to_byte_offset(jlong field_offset) {
return field_offset;
}
is used in hotspot/src/share/vm/opto/library_call.cpp for assertions:
// Interpret Unsafe.fieldOffset cookies correctly:
extern jlong Unsafe_field_offset_to_byte_offset(jlong field_offset);
...
// We currently rely on the cookies produced by Unsafe.xxxFieldOffset
// to be plain byte offsets, which are also the same as those accepted
// by oopDesc::field_base.
assert(Unsafe_field_offset_to_byte_offset(11) == 11,
"fieldOffset must be byte-scaled");
and in hotspot/src/share/vm/shark/sharkBuilder.cpp:
Value* SharkBuilder::unsafe_field_offset_to_byte_offset() {
extern jlong Unsafe_field_offset_to_byte_offset(jlong field_offset);
return make_function((address) Unsafe_field_offset_to_byte_offset, "l", "l");
}
Paul.
More information about the hotspot-runtime-dev
mailing list