On Mar 9, 2015, at 5:04 PM, Andrew Haley <a...@redhat.com> wrote: > On 03/09/2015 03:10 PM, Paul Sandoz wrote: >> Do you want to tackle the single-address access methods as a follow up issue? > > It's not clear to me that we need any single-address access methods > because we can pass in a null object. Personally I would prefer that. > Thoughts? >
I agree that would be desirable. I know that people rely on that behaviour for off-heap CAS etc, but i was wondering about such behaviour given that the base and offset should, as documented, be derived from an object/staticFieldBase and objectFieldOffset/staticFieldOffset respectfully. Are there subtle differences? I looked at the C2 code and it seems the results might be equivalent but i cannot say the same for C1 from quickly eyeballing the code. e.g. LibraryCallKit::inline_unsafe_access: if (!is_native_ptr) { // The base is either a Java object or a value produced by Unsafe.staticFieldBase Node* base = argument(1); // type: oop // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset offset = argument(2); // type: long // 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"); <----- weird assertion // 32-bit machines ignore the high half! offset = ConvL2X(offset); adr = make_unsafe_address(base, offset); heap_base_oop = base; val = is_store ? argument(4) : NULL; } else { Node* ptr = argument(1); // type: long ptr = ConvL2X(ptr); // adjust Java long to machine word adr = make_unsafe_address(NULL, ptr); val = is_store ? argument(3) : NULL; } Paul.