Search in sources :

Example 1 with StackLockValue

use of jdk.vm.ci.code.StackLockValue in project graal by oracle.

the class HotSpotDebugInfoBuilder method computeLockValue.

@Override
protected JavaValue computeLockValue(FrameState state, int lockIndex) {
    int lockDepth = lockIndex;
    if (state.outerFrameState() != null) {
        lockDepth += state.outerFrameState().nestedLockDepth();
    }
    VirtualStackSlot slot = lockStack.makeLockSlot(lockDepth);
    ValueNode lock = state.lockAt(lockIndex);
    JavaValue object = toJavaValue(lock);
    boolean eliminated = object instanceof VirtualObject || state.monitorIdAt(lockIndex).isEliminated();
    assert state.monitorIdAt(lockIndex).getLockDepth() == lockDepth;
    return new StackLockValue(object, slot, eliminated);
}
Also used : VirtualObject(jdk.vm.ci.code.VirtualObject) JavaValue(jdk.vm.ci.meta.JavaValue) ValueNode(org.graalvm.compiler.nodes.ValueNode) StackLockValue(jdk.vm.ci.code.StackLockValue) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Example 2 with StackLockValue

use of jdk.vm.ci.code.StackLockValue in project graal by oracle.

the class LIRFrameState method processValues.

protected void processValues(LIRInstruction inst, JavaValue[] values, InstructionValueProcedure proc) {
    for (int i = 0; i < values.length; i++) {
        JavaValue value = values[i];
        if (isIllegalJavaValue(value)) {
            continue;
        }
        if (value instanceof AllocatableValue) {
            AllocatableValue allocatable = (AllocatableValue) value;
            Value result = proc.doValue(inst, allocatable, OperandMode.ALIVE, STATE_FLAGS);
            if (!allocatable.identityEquals(result)) {
                values[i] = (JavaValue) result;
            }
        } else if (value instanceof StackLockValue) {
            StackLockValue monitor = (StackLockValue) value;
            JavaValue owner = monitor.getOwner();
            if (owner instanceof AllocatableValue) {
                monitor.setOwner((JavaValue) proc.doValue(inst, (AllocatableValue) owner, OperandMode.ALIVE, STATE_FLAGS));
            }
            Value slot = monitor.getSlot();
            if (isVirtualStackSlot(slot)) {
                monitor.setSlot(asAllocatableValue(proc.doValue(inst, slot, OperandMode.ALIVE, STATE_FLAGS)));
            }
        } else {
            assert unprocessed(value);
        }
    }
}
Also used : JavaValue(jdk.vm.ci.meta.JavaValue) ValueUtil.isIllegalJavaValue(jdk.vm.ci.code.ValueUtil.isIllegalJavaValue) ValueUtil.isConstantJavaValue(jdk.vm.ci.code.ValueUtil.isConstantJavaValue) JavaValue(jdk.vm.ci.meta.JavaValue) StackLockValue(jdk.vm.ci.code.StackLockValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) ValueUtil.isIllegalJavaValue(jdk.vm.ci.code.ValueUtil.isIllegalJavaValue) Value(jdk.vm.ci.meta.Value) ValueUtil.isConstantJavaValue(jdk.vm.ci.code.ValueUtil.isConstantJavaValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) StackLockValue(jdk.vm.ci.code.StackLockValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 3 with StackLockValue

use of jdk.vm.ci.code.StackLockValue in project graal by oracle.

the class HotSpotMonitorValueTest method addMethod.

@Override
protected InstalledCode addMethod(DebugContext debug, ResolvedJavaMethod method, CompilationResult compResult) {
    for (Infopoint i : compResult.getInfopoints()) {
        if (i instanceof Call) {
            Call call = (Call) i;
            if (call.target instanceof ResolvedJavaMethod) {
                ResolvedJavaMethod target = (ResolvedJavaMethod) call.target;
                if (target.equals(lookupObjectWait())) {
                    BytecodeFrame frame = call.debugInfo.frame();
                    BytecodeFrame caller = frame.caller();
                    assertNotNull(caller);
                    assertNull(caller.caller());
                    assertDeepEquals(2, frame.numLocks);
                    assertDeepEquals(2, caller.numLocks);
                    StackLockValue lock1 = (StackLockValue) frame.getLockValue(0);
                    StackLockValue lock2 = (StackLockValue) frame.getLockValue(1);
                    StackLockValue lock3 = (StackLockValue) caller.getLockValue(0);
                    StackLockValue lock4 = (StackLockValue) caller.getLockValue(1);
                    List<StackLockValue> locks = Arrays.asList(lock1, lock2, lock3, lock4);
                    for (StackLockValue lock : locks) {
                        for (StackLockValue other : locks) {
                            if (other != lock) {
                                // Every lock must have a different stack slot
                                assertThat(lock.getSlot(), not(other.getSlot()));
                            }
                        }
                    }
                    assertDeepEquals(lock3.getOwner(), lock4.getOwner());
                    assertThat(lock1.getOwner(), not(lock2.getOwner()));
                    return super.addMethod(debug, method, compResult);
                }
            }
        }
    }
    throw new AssertionError("Could not find debug info for call to Object.wait(long)");
}
Also used : Call(jdk.vm.ci.code.site.Call) BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) StackLockValue(jdk.vm.ci.code.StackLockValue) Infopoint(jdk.vm.ci.code.site.Infopoint) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 4 with StackLockValue

use of jdk.vm.ci.code.StackLockValue in project graal by oracle.

the class LIRFrameState method visitValues.

protected void visitValues(LIRInstruction inst, JavaValue[] values, InstructionValueConsumer proc) {
    for (int i = 0; i < values.length; i++) {
        JavaValue value = values[i];
        if (isIllegalJavaValue(value)) {
            continue;
        } else if (value instanceof AllocatableValue) {
            proc.visitValue(inst, (AllocatableValue) value, OperandMode.ALIVE, STATE_FLAGS);
        } else if (value instanceof StackLockValue) {
            StackLockValue monitor = (StackLockValue) value;
            JavaValue owner = monitor.getOwner();
            if (owner instanceof AllocatableValue) {
                proc.visitValue(inst, (AllocatableValue) owner, OperandMode.ALIVE, STATE_FLAGS);
            }
            Value slot = monitor.getSlot();
            if (isVirtualStackSlot(slot)) {
                proc.visitValue(inst, slot, OperandMode.ALIVE, STATE_FLAGS);
            }
        } else {
            assert unprocessed(value);
        }
    }
}
Also used : JavaValue(jdk.vm.ci.meta.JavaValue) ValueUtil.isIllegalJavaValue(jdk.vm.ci.code.ValueUtil.isIllegalJavaValue) ValueUtil.isConstantJavaValue(jdk.vm.ci.code.ValueUtil.isConstantJavaValue) StackLockValue(jdk.vm.ci.code.StackLockValue) JavaValue(jdk.vm.ci.meta.JavaValue) StackLockValue(jdk.vm.ci.code.StackLockValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) ValueUtil.isIllegalJavaValue(jdk.vm.ci.code.ValueUtil.isIllegalJavaValue) Value(jdk.vm.ci.meta.Value) ValueUtil.isConstantJavaValue(jdk.vm.ci.code.ValueUtil.isConstantJavaValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

StackLockValue (jdk.vm.ci.code.StackLockValue)4 JavaValue (jdk.vm.ci.meta.JavaValue)3 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)2 ValueUtil.isConstantJavaValue (jdk.vm.ci.code.ValueUtil.isConstantJavaValue)2 ValueUtil.isIllegalJavaValue (jdk.vm.ci.code.ValueUtil.isIllegalJavaValue)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 Value (jdk.vm.ci.meta.Value)2 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)1 VirtualObject (jdk.vm.ci.code.VirtualObject)1 Call (jdk.vm.ci.code.site.Call)1 Infopoint (jdk.vm.ci.code.site.Infopoint)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1