Search in sources :

Example 1 with ImageHeapObject

use of com.oracle.svm.core.image.ImageHeapObject in project graal by oracle.

the class AlignedChunkRememberedSet method enableRememberedSet.

@Platforms(Platform.HOSTED_ONLY.class)
public static void enableRememberedSet(HostedByteBufferPointer chunk, int chunkPosition, List<ImageHeapObject> objects) {
    // Completely clean the card table and the first object table.
    CardTable.cleanTable(getCardTableStart(chunk), getCardTableSize());
    FirstObjectTable.initializeTable(getFirstObjectTableStart(chunk), getFirstObjectTableSize());
    Pointer fotStart = getFirstObjectTableStart(chunk);
    UnsignedWord objectsStartOffset = AlignedHeapChunk.getObjectsStartOffset();
    for (ImageHeapObject obj : objects) {
        long offsetWithinChunk = obj.getOffset() - chunkPosition;
        assert offsetWithinChunk > 0 && WordFactory.unsigned(offsetWithinChunk).aboveOrEqual(objectsStartOffset);
        UnsignedWord startOffset = WordFactory.unsigned(offsetWithinChunk).subtract(objectsStartOffset);
        UnsignedWord endOffset = startOffset.add(WordFactory.unsigned(obj.getSize()));
        FirstObjectTable.setTableForObject(fotStart, startOffset, endOffset);
    // The remembered set bit in the header will be set by the code that writes the objects.
    }
}
Also used : ImageHeapObject(com.oracle.svm.core.image.ImageHeapObject) UnsignedWord(org.graalvm.word.UnsignedWord) HostedByteBufferPointer(com.oracle.svm.core.util.HostedByteBufferPointer) Pointer(org.graalvm.word.Pointer) Platforms(org.graalvm.nativeimage.Platforms)

Example 2 with ImageHeapObject

use of com.oracle.svm.core.image.ImageHeapObject in project graal by oracle.

the class ChunkedImageHeapPartition method dequeueBestFit.

private ImageHeapObject dequeueBestFit(NavigableMap<Long, Queue<ImageHeapObject>> objects, long nbytes) {
    if (nbytes < minimumObjectSize) {
        return null;
    }
    Map.Entry<Long, Queue<ImageHeapObject>> entry = objects.floorEntry(nbytes);
    if (entry == null) {
        return null;
    }
    Queue<ImageHeapObject> queue = entry.getValue();
    ImageHeapObject info = queue.remove();
    if (queue.isEmpty()) {
        objects.remove(entry.getKey());
    }
    return info;
}
Also used : ImageHeapObject(com.oracle.svm.core.image.ImageHeapObject) TreeMap(java.util.TreeMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) Queue(java.util.Queue)

Example 3 with ImageHeapObject

use of com.oracle.svm.core.image.ImageHeapObject in project graal by oracle.

the class ChunkedImageHeapPartition method createSortedObjectsMap.

private static NavigableMap<Long, Queue<ImageHeapObject>> createSortedObjectsMap(List<ImageHeapObject> objects) {
    ImageHeapObject[] sorted = objects.toArray(new ImageHeapObject[0]);
    Arrays.sort(sorted, new SizeComparator());
    NavigableMap<Long, Queue<ImageHeapObject>> map = new TreeMap<>();
    Queue<ImageHeapObject> currentQueue = null;
    long currentObjectsSize = -1;
    for (ImageHeapObject obj : sorted) {
        long objSize = obj.getSize();
        if (objSize != currentObjectsSize) {
            assert objSize > currentObjectsSize && objSize >= ConfigurationValues.getObjectLayout().getMinimumObjectSize();
            currentObjectsSize = objSize;
            currentQueue = new ArrayDeque<>();
            map.put(currentObjectsSize, currentQueue);
        }
        currentQueue.add(obj);
    }
    return map;
}
Also used : ImageHeapObject(com.oracle.svm.core.image.ImageHeapObject) TreeMap(java.util.TreeMap) Queue(java.util.Queue)

Example 4 with ImageHeapObject

use of com.oracle.svm.core.image.ImageHeapObject in project graal by oracle.

the class ChunkedImageHeapPartition method layoutInUnalignedChunks.

private void layoutInUnalignedChunks(ChunkedImageHeapAllocator allocator) {
    allocator.finishAlignedChunk();
    allocator.alignBetweenChunks(getStartAlignment());
    startOffset = allocator.getPosition();
    for (ImageHeapObject info : getObjects()) {
        // No need to sort by size
        appendAllocatedObject(info, allocator.allocateUnalignedChunkForObject(info, isWritable()));
    }
    allocator.alignBetweenChunks(getEndAlignment());
    endOffset = allocator.getPosition();
}
Also used : ImageHeapObject(com.oracle.svm.core.image.ImageHeapObject)

Example 5 with ImageHeapObject

use of com.oracle.svm.core.image.ImageHeapObject in project graal by oracle.

the class LinearImageHeapPartition method allocateObjects.

void allocateObjects(LinearImageHeapAllocator allocator) {
    allocator.align(getStartAlignment());
    startOffset = allocator.getPosition();
    for (ImageHeapObject info : getObjects()) {
        allocate(info, allocator);
    }
    allocator.align(getEndAlignment());
    endOffset = allocator.getPosition();
}
Also used : ImageHeapObject(com.oracle.svm.core.image.ImageHeapObject)

Aggregations

ImageHeapObject (com.oracle.svm.core.image.ImageHeapObject)5 Queue (java.util.Queue)2 TreeMap (java.util.TreeMap)2 HostedByteBufferPointer (com.oracle.svm.core.util.HostedByteBufferPointer)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 Platforms (org.graalvm.nativeimage.Platforms)1 Pointer (org.graalvm.word.Pointer)1 UnsignedWord (org.graalvm.word.UnsignedWord)1