void writeReference(RelocatableBuffer buffer, int index, Object target, Object reason) { assert !(target instanceof WordBase) : "word values are not references"; mustBeReferenceAligned(index); if (target != null) { ObjectInfo targetInfo = objects.get(target); verifyTargetDidNotChange(target, reason, targetInfo); if (useHeapBase()) { CompressEncoding compressEncoding = ImageSingletons.lookup(CompressEncoding.class); int shift = compressEncoding.getShift(); writeReferenceValue(buffer, index, targetInfo.getOffsetInSection() >>> shift); } else { addDirectRelocationWithoutAddend(buffer, index, referenceSize(), target); } } }
private static void markDataRelocationSite(final ProgbitsSectionImpl sectionImpl, final int offset, final RelocatableBuffer.Info info, final NativeImageHeap.ObjectInfo targetObjectInfo) { // References to objects are via relocations to offsets from the symbol // for the section the symbol is in. // Use the target object to find the partition and offset, and from the // partition the section and the partition offset. assert ((info.getRelocationSize() == 4) || (info.getRelocationSize() == 8)) : "Data relocation size should be 4 or 8 bytes."; assert targetObjectInfo != null; // Gather information about the target object. HeapPartition partition = targetObjectInfo.getPartition(); assert partition != null; final String targetSectionName = partition.getSectionName(); final long targetOffsetInSection = targetObjectInfo.getOffsetInSection(); final long relocationInfoAddend = info.hasExplicitAddend() ? info.getExplicitAddend().longValue() : 0L; final long relocationAddend = targetOffsetInSection + relocationInfoAddend; sectionImpl.markRelocationSite(offset, info.getRelocationSize(), info.getRelocationKind(), targetSectionName, false, relocationAddend); }
long targetOffset = objectMap.get(object).getOffsetInSection(); int encShift = ImageSingletons.lookup(CompressEncoding.class).getShift(); long targetValue = targetOffset >>> encShift;
private void writeDynamicHub(RelocatableBuffer buffer, int index, DynamicHub target) { assert target != null : "Null DynamicHub found during native image generation."; mustBeReferenceAligned(index); ObjectInfo targetInfo = objects.get(target); assert targetInfo != null : "Unknown object " + target.toString() + " found. Static field or an object referenced from a static field changed during native image generation?"; if (useHeapBase()) { // NOTE: we do not apply a shift to the hub reference in the object header because the // least significant bits are used for state information long targetOffset = targetInfo.getOffsetInSection(); long bits = Heap.getHeap().getObjectHeader().setBootImageOnLong(targetOffset); writeReferenceValue(buffer, index, bits); } else { // The address of the DynamicHub target will have to be added by the link editor. long objectHeaderBits = Heap.getHeap().getObjectHeader().setBootImageOnLong(0L); addDirectRelocationWithAddend(buffer, index, target, objectHeaderBits); } }
/** An index into a object in the native image heap. E.g., a field within an object. */ public long getIndexInSection(long index) { assert index >= 0 && index < getSize() : "Index: " + index + " out of bounds: [0 .. " + getSize() + ")."; return getOffsetInSection() + index; }