Search in sources :

Example 1 with Space

use of org.mmtk.policy.Space in project JikesRVM by JikesRVM.

the class JMXSupport method getUsage.

public static MemoryUsage getUsage(String poolName) {
    Space space = getSpace(poolName);
    long reservedBytes = JMXSupport.getReservedBytes(space);
    long committedBytes = JMXSupport.getComittedBytes(space);
    long poolExtent = JMXSupport.getPoolExtent(space);
    return new MemoryUsage(-1, reservedBytes, committedBytes, poolExtent);
}
Also used : Space(org.mmtk.policy.Space) MemoryUsage(java.lang.management.MemoryUsage)

Example 2 with Space

use of org.mmtk.policy.Space in project JikesRVM by JikesRVM.

the class JMXSupport method getType.

/**
 * Returns non-heap for immortal spaces and heap for non-immortal
 * spaces because objects can be added and remove from non-immortal
 * spaces.
 *
 * @param poolName the pool's name
 * @return the type of the memory pool
 */
public static MemoryType getType(String poolName) {
    Space space = getSpace(poolName);
    boolean immortal = space.isImmortal();
    if (immortal) {
        return MemoryType.NON_HEAP;
    } else {
        return MemoryType.HEAP;
    }
}
Also used : Space(org.mmtk.policy.Space)

Example 3 with Space

use of org.mmtk.policy.Space in project JikesRVM by JikesRVM.

the class JMXSupport method getUsage.

public static MemoryUsage getUsage(boolean immortal) {
    long committed = 0, used = 0, max = 0;
    int spaceCount = Space.getSpaceCount();
    Space[] spaces = Space.getSpaces();
    for (int index = 0; index < spaceCount; index++) {
        Space space = spaces[index];
        if (space.isImmortal() == immortal) {
            used += getReservedBytes(space);
            committed += getComittedBytes(space);
            max += getPoolExtent(space);
        }
    }
    return new MemoryUsage(-1, used, committed, max);
}
Also used : Space(org.mmtk.policy.Space) MemoryUsage(java.lang.management.MemoryUsage)

Example 4 with Space

use of org.mmtk.policy.Space in project JikesRVM by JikesRVM.

the class Harness method checkSpaces.

private static void checkSpaces() {
    Set<String> expectedSpaces = PlanSpecificConfig.get(plan.getValue()).getExpectedSpaces();
    final Set<String> actualSpaces = new HashSet<String>();
    Space.visitSpaces(new SpaceVisitor() {

        @Override
        public void visit(Space s) {
            actualSpaces.add(s.getName());
        }
    });
    if (!expectedSpaces.equals(actualSpaces)) {
        for (String name : expectedSpaces) {
            if (!actualSpaces.contains(name)) {
                System.err.printf("Expected space %s was not found%n", name);
            }
        }
        for (String name : actualSpaces) {
            if (!expectedSpaces.contains(name)) {
                System.err.printf("Space %s was not expected%n", name);
            }
        }
        throw new AssertionError("Space map does not match expectations");
    }
}
Also used : Space(org.mmtk.policy.Space) SpaceVisitor(org.mmtk.policy.Space.SpaceVisitor) HashSet(java.util.HashSet)

Example 5 with Space

use of org.mmtk.policy.Space in project JikesRVM by JikesRVM.

the class ImmixSpace method traceObjectWithOpportunisticCopy.

/**
 * Trace a reference to an object, forwarding the object if appropriate
 * If the object is not already marked, mark the object and enqueue it
 * for subsequent processing.
 *
 * @param trace The trace performing the transitive closure
 * @param object The object to be traced.
 * @param allocator The allocator to which any copying should be directed
 * @param nurseryCollection whether the current collection is a nursery collection
 * @return Either the object or a forwarded object, if it was forwarded.
 */
@Inline
private ObjectReference traceObjectWithOpportunisticCopy(TransitiveClosure trace, ObjectReference object, int allocator, boolean nurseryCollection) {
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert((nurseryCollection && !ObjectHeader.isMatureObject(object)) || (defrag.determined(true) && isDefragSource(object)));
    /* Race to be the (potential) forwarder */
    Word priorStatusWord = ForwardingWord.attemptToForward(object);
    if (ForwardingWord.stateIsForwardedOrBeingForwarded(priorStatusWord)) {
        /* We lost the race; the object is either forwarded or being forwarded by another thread. */
        /* Note that the concurrent attempt to forward the object may fail, so the object may remain in-place */
        ObjectReference rtn = ForwardingWord.spinAndGetForwardedObject(object, priorStatusWord);
        if (VM.VERIFY_ASSERTIONS && rtn == object)
            VM.assertions._assert((nurseryCollection && ObjectHeader.testMarkState(object, markState)) || defrag.spaceExhausted() || ObjectHeader.isPinnedObject(object));
        if (VM.VERIFY_ASSERTIONS && rtn != object)
            VM.assertions._assert(nurseryCollection || !isDefragSource(rtn));
        if (VM.VERIFY_ASSERTIONS && HeaderByte.NEEDS_UNLOGGED_BIT)
            VM.assertions._assert(HeaderByte.isUnlogged(rtn));
        return rtn;
    } else {
        byte priorState = (byte) (priorStatusWord.toInt() & 0xFF);
        /* the object is unforwarded, either because this is the first thread to reach it, or because the object can't be forwarded */
        if (ObjectHeader.testMarkState(priorState, markState)) {
            /* Note that in a sticky mark bits collector, the mark state does not change at each GC, so correct mark state does not imply another thread got there first */
            if (VM.VERIFY_ASSERTIONS)
                VM.assertions._assert(nurseryCollection || defrag.spaceExhausted() || ObjectHeader.isPinnedObject(object));
            // return to uncontested state
            ObjectHeader.returnToPriorStateAndEnsureUnlogged(object, priorState);
            if (VM.VERIFY_ASSERTIONS && Plan.NEEDS_LOG_BIT_IN_HEADER)
                VM.assertions._assert(HeaderByte.isUnlogged(object));
            return object;
        } else {
            /* we are the first to reach the object; either mark in place or forward it */
            ObjectReference newObject;
            if (ObjectHeader.isPinnedObject(object) || (!nurseryCollection && defrag.spaceExhausted())) {
                /* mark in place */
                ObjectHeader.setMarkStateUnlogAndUnlock(object, priorState, markState);
                newObject = object;
                if (VM.VERIFY_ASSERTIONS && Plan.NEEDS_LOG_BIT_IN_HEADER)
                    VM.assertions._assert(HeaderByte.isUnlogged(newObject));
            } else {
                /* forward */
                if (VM.VERIFY_ASSERTIONS)
                    VM.assertions._assert(!ObjectHeader.isPinnedObject(object));
                newObject = ForwardingWord.forwardObject(object, allocator);
                if (VM.VERIFY_ASSERTIONS && Plan.NEEDS_LOG_BIT_IN_HEADER)
                    VM.assertions._assert(HeaderByte.isUnlogged(newObject));
            }
            if (VM.VERIFY_ASSERTIONS && Options.verbose.getValue() >= 9) {
                Log.write("C[", object);
                Log.write("/");
                Log.write(getName());
                Log.write("] -> ", newObject);
                Log.write("/");
                Log.write(Space.getSpaceForObject(newObject).getName());
                Log.writeln("]");
            }
            if (!MARK_LINE_AT_SCAN_TIME)
                markLines(newObject);
            trace.processNode(newObject);
            if (VM.VERIFY_ASSERTIONS) {
                if (!((getSpaceForObject(newObject) != this) || (newObject == object) || (nurseryCollection && willNotMoveThisNurseryGC(newObject)) || (defrag.inDefrag() && willNotMoveThisGC(newObject)))) {
                    Log.writeln("   object: ", object);
                    Log.writeln("newObject: ", newObject);
                    Log.write("    space: ");
                    Log.writeln(getName());
                    Log.writeln(" nursery?: ", nurseryCollection);
                    Log.writeln("  mature?: ", ObjectHeader.isMatureObject(object));
                    Log.writeln("  wnmngc?: ", willNotMoveThisNurseryGC(newObject));
                    Log.writeln("  pinned?: ", ObjectHeader.isPinnedObject(object));
                    Space otherSpace = getSpaceForObject(newObject);
                    Log.write(" space(o): ");
                    Log.writeln(otherSpace == null ? "<NULL>" : otherSpace.getName());
                    VM.assertions._assert(false);
                }
            }
            return newObject;
        }
    }
}
Also used : Space(org.mmtk.policy.Space) ForwardingWord(org.mmtk.utility.ForwardingWord)

Aggregations

Space (org.mmtk.policy.Space)7 MemoryUsage (java.lang.management.MemoryUsage)2 HashSet (java.util.HashSet)1 SpaceVisitor (org.mmtk.policy.Space.SpaceVisitor)1 ForwardingWord (org.mmtk.utility.ForwardingWord)1 RawMemoryFreeList (org.mmtk.utility.RawMemoryFreeList)1 Interruptible (org.vmmagic.pragma.Interruptible)1 Address (org.vmmagic.unboxed.Address)1 Extent (org.vmmagic.unboxed.Extent)1