jdk.nashorn.internal.ir.LocalVariableConversion Java Examples

The following examples show how to use jdk.nashorn.internal.ir.LocalVariableConversion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalVariableTypesCalculator.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private LocalVariableConversion createConversion(final Symbol symbol, final LvarType branchLvarType,
        final Map<Symbol, LvarType> joinLvarTypes, final LocalVariableConversion next) {
    if (invalidatedSymbols.contains(symbol)) {
        return next;
    }
    final LvarType targetType = joinLvarTypes.get(symbol);
    assert targetType != null;
    if(targetType == branchLvarType) {
        return next;
    }
    // NOTE: we could naively just use symbolIsUsed(symbol, branchLvarType) here, but that'd be wrong. While
    // technically a conversion will read the value of the symbol with that type, but it will also write it to a new
    // type, and that type might be dead (we can't know yet). For this reason, we don't treat conversion reads as
    // real uses until we know their target type is live. If we didn't do this, and just did a symbolIsUsed here,
    // we'd introduce false live variables which could nevertheless turn into dead ones in a subsequent
    // deoptimization, causing a shift in the list of live locals that'd cause erroneous restoration of
    // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).

    symbolIsConverted(symbol, branchLvarType, targetType);
    return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
}
 
Example #2
Source File: LocalVariableTypesCalculator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private LocalVariableConversion createConversion(final Symbol symbol, final LvarType branchLvarType,
        final Map<Symbol, LvarType> joinLvarTypes, final LocalVariableConversion next) {
    if (invalidatedSymbols.contains(symbol)) {
        return next;
    }
    final LvarType targetType = joinLvarTypes.get(symbol);
    assert targetType != null;
    if(targetType == branchLvarType) {
        return next;
    }
    // NOTE: we could naively just use symbolIsUsed(symbol, branchLvarType) here, but that'd be wrong. While
    // technically a conversion will read the value of the symbol with that type, but it will also write it to a new
    // type, and that type might be dead (we can't know yet). For this reason, we don't treat conversion reads as
    // real uses until we know their target type is live. If we didn't do this, and just did a symbolIsUsed here,
    // we'd introduce false live variables which could nevertheless turn into dead ones in a subsequent
    // deoptimization, causing a shift in the list of live locals that'd cause erroneous restoration of
    // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).

    symbolIsConverted(symbol, branchLvarType, targetType);
    return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
}
 
Example #3
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private LocalVariableConversion createConversion(final Symbol symbol, final LvarType branchLvarType,
        final Map<Symbol, LvarType> joinLvarTypes, final LocalVariableConversion next) {
    if (invalidatedSymbols.contains(symbol)) {
        return next;
    }
    final LvarType targetType = joinLvarTypes.get(symbol);
    assert targetType != null;
    if(targetType == branchLvarType) {
        return next;
    }
    // NOTE: we could naively just use symbolIsUsed(symbol, branchLvarType) here, but that'd be wrong. While
    // technically a conversion will read the value of the symbol with that type, but it will also write it to a new
    // type, and that type might be dead (we can't know yet). For this reason, we don't treat conversion reads as
    // real uses until we know their target type is live. If we didn't do this, and just did a symbolIsUsed here,
    // we'd introduce false live variables which could nevertheless turn into dead ones in a subsequent
    // deoptimization, causing a shift in the list of live locals that'd cause erroneous restoration of
    // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).

    symbolIsConverted(symbol, branchLvarType, targetType);
    return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
}
 
Example #4
Source File: LocalVariableTypesCalculator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private LocalVariableConversion createConversion(final Symbol symbol, final LvarType branchLvarType,
        final Map<Symbol, LvarType> joinLvarTypes, final LocalVariableConversion next) {
    final LvarType targetType = joinLvarTypes.get(symbol);
    assert targetType != null;
    if(targetType == branchLvarType) {
        return next;
    }
    // NOTE: we could naively just use symbolIsUsed(symbol, branchLvarType) here, but that'd be wrong. While
    // technically a conversion will read the value of the symbol with that type, but it will also write it to a new
    // type, and that type might be dead (we can't know yet). For this reason, we don't treat conversion reads as
    // real uses until we know their target type is live. If we didn't do this, and just did a symbolIsUsed here,
    // we'd introduce false live variables which could nevertheless turn into dead ones in a subsequent
    // deoptimization, causing a shift in the list of live locals that'd cause erroneous restoration of
    // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).

    symbolIsConverted(symbol, branchLvarType, targetType);
    return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
}
 
Example #5
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private LocalVariableConversion createConversion(final Symbol symbol, final LvarType branchLvarType,
        final Map<Symbol, LvarType> joinLvarTypes, final LocalVariableConversion next) {
    if (invalidatedSymbols.contains(symbol)) {
        return next;
    }
    final LvarType targetType = joinLvarTypes.get(symbol);
    assert targetType != null;
    if(targetType == branchLvarType) {
        return next;
    }
    // NOTE: we could naively just use symbolIsUsed(symbol, branchLvarType) here, but that'd be wrong. While
    // technically a conversion will read the value of the symbol with that type, but it will also write it to a new
    // type, and that type might be dead (we can't know yet). For this reason, we don't treat conversion reads as
    // real uses until we know their target type is live. If we didn't do this, and just did a symbolIsUsed here,
    // we'd introduce false live variables which could nevertheless turn into dead ones in a subsequent
    // deoptimization, causing a shift in the list of live locals that'd cause erroneous restoration of
    // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).

    symbolIsConverted(symbol, branchLvarType, targetType);
    return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
}
 
Example #6
Source File: LocalVariableTypesCalculator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private LocalVariableConversion createConversion(final Symbol symbol, final LvarType branchLvarType,
        final Map<Symbol, LvarType> joinLvarTypes, final LocalVariableConversion next) {
    final LvarType targetType = joinLvarTypes.get(symbol);
    assert targetType != null;
    if(targetType == branchLvarType) {
        return next;
    }
    // NOTE: we could naively just use symbolIsUsed(symbol, branchLvarType) here, but that'd be wrong. While
    // technically a conversion will read the value of the symbol with that type, but it will also write it to a new
    // type, and that type might be dead (we can't know yet). For this reason, we don't treat conversion reads as
    // real uses until we know their target type is live. If we didn't do this, and just did a symbolIsUsed here,
    // we'd introduce false live variables which could nevertheless turn into dead ones in a subsequent
    // deoptimization, causing a shift in the list of live locals that'd cause erroneous restoration of
    // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).

    symbolIsConverted(symbol, branchLvarType, targetType);
    return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
}
 
Example #7
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private LocalVariableConversion createConversion(final Symbol symbol, final LvarType branchLvarType,
        final Map<Symbol, LvarType> joinLvarTypes, final LocalVariableConversion next) {
    if (invalidatedSymbols.contains(symbol)) {
        return next;
    }
    final LvarType targetType = joinLvarTypes.get(symbol);
    assert targetType != null;
    if(targetType == branchLvarType) {
        return next;
    }
    // NOTE: we could naively just use symbolIsUsed(symbol, branchLvarType) here, but that'd be wrong. While
    // technically a conversion will read the value of the symbol with that type, but it will also write it to a new
    // type, and that type might be dead (we can't know yet). For this reason, we don't treat conversion reads as
    // real uses until we know their target type is live. If we didn't do this, and just did a symbolIsUsed here,
    // we'd introduce false live variables which could nevertheless turn into dead ones in a subsequent
    // deoptimization, causing a shift in the list of live locals that'd cause erroneous restoration of
    // continuations (since RewriteException's byteCodeSlots carries an array and not a name-value map).

    symbolIsConverted(symbol, branchLvarType, targetType);
    return new LocalVariableConversion(symbol, branchLvarType.type, targetType.type, next);
}
 
Example #8
Source File: MethodEmitter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void beforeTry(final TryNode tryNode, final Label recovery) {
    LocalVariableConversion next = tryNode.getLocalVariableConversion();
    while(next != null) {
        if(next.isLive()) {
            final Type to = emitLocalVariableConversion(next, false);
            recovery.getStack().onLocalStore(to, next.getSymbol().getSlot(to), true);
        }
        next = next.getNext();
    }
}
 
Example #9
Source File: MethodEmitter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void beforeJoinPoint(final JoinPredecessor joinPredecessor) {
    LocalVariableConversion next = joinPredecessor.getLocalVariableConversion();
    while(next != null) {
        final Symbol symbol = next.getSymbol();
        if(next.isLive()) {
            emitLocalVariableConversion(next, true);
        } else {
            markDeadLocalVariable(symbol);
        }
        next = next.getNext();
    }
}
 
Example #10
Source File: MethodEmitter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private Type emitLocalVariableConversion(final LocalVariableConversion conversion, final boolean onlySymbolLiveValue) {
    final Type from = conversion.getFrom();
    final Type to = conversion.getTo();
    final Symbol symbol = conversion.getSymbol();
    assert symbol.isBytecodeLocal();
    if(from == Type.UNDEFINED) {
        loadUndefined(to);
    } else {
        load(symbol, from).convert(to);
    }
    store(symbol, to, onlySymbolLiveValue);
    return to;
}
 
Example #11
Source File: BranchOptimizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void optimizeLogicalOperand(final Expression expr, final Label label, final boolean state, final boolean isRhs) {
    final JoinPredecessorExpression jpexpr = (JoinPredecessorExpression)expr;
    if(LocalVariableConversion.hasLiveConversion(jpexpr)) {
        final Label after = new Label("after");
        branchOptimizer(jpexpr.getExpression(), after, !state);
        method.beforeJoinPoint(jpexpr);
        method._goto(label);
        method.label(after);
        if(isRhs) {
            method.beforeJoinPoint(jpexpr);
        }
    } else {
        branchOptimizer(jpexpr.getExpression(), label, state);
    }
}
 
Example #12
Source File: MethodEmitter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void beforeJoinPoint(final JoinPredecessor joinPredecessor) {
    LocalVariableConversion next = joinPredecessor.getLocalVariableConversion();
    while(next != null) {
        final Symbol symbol = next.getSymbol();
        if(next.isLive()) {
            emitLocalVariableConversion(next, true);
        } else {
            markDeadLocalVariable(symbol);
        }
        next = next.getNext();
    }
}
 
Example #13
Source File: MethodEmitter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void beforeTry(final TryNode tryNode, final Label recovery) {
    LocalVariableConversion next = tryNode.getLocalVariableConversion();
    while(next != null) {
        if(next.isLive()) {
            final Type to = emitLocalVariableConversion(next, false);
            recovery.getStack().onLocalStore(to, next.getSymbol().getSlot(to), true);
        }
        next = next.getNext();
    }
}
 
Example #14
Source File: MethodEmitter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private Type emitLocalVariableConversion(final LocalVariableConversion conversion, final boolean onlySymbolLiveValue) {
    final Type from = conversion.getFrom();
    final Type to = conversion.getTo();
    final Symbol symbol = conversion.getSymbol();
    assert symbol.isBytecodeLocal();
    if(from == Type.UNDEFINED) {
        loadUndefined(to);
    } else {
        load(symbol, from).convert(to);
    }
    store(symbol, to, onlySymbolLiveValue);
    return to;
}
 
Example #15
Source File: BranchOptimizer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void optimizeLogicalOperand(final Expression expr, final Label label, final boolean state, final boolean isRhs) {
    final JoinPredecessorExpression jpexpr = (JoinPredecessorExpression)expr;
    if(LocalVariableConversion.hasLiveConversion(jpexpr)) {
        final Label after = new Label("after");
        branchOptimizer(jpexpr.getExpression(), after, !state);
        method.beforeJoinPoint(jpexpr);
        method._goto(label);
        method.label(after);
        if(isRhs) {
            method.beforeJoinPoint(jpexpr);
        }
    } else {
        branchOptimizer(jpexpr.getExpression(), label, state);
    }
}
 
Example #16
Source File: MethodEmitter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void beforeJoinPoint(final JoinPredecessor joinPredecessor) {
    LocalVariableConversion next = joinPredecessor.getLocalVariableConversion();
    while(next != null) {
        final Symbol symbol = next.getSymbol();
        if(next.isLive()) {
            emitLocalVariableConversion(next, true);
        } else {
            markDeadLocalVariable(symbol);
        }
        next = next.getNext();
    }
}
 
Example #17
Source File: MethodEmitter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void beforeTry(final TryNode tryNode, final Label recovery) {
    LocalVariableConversion next = tryNode.getLocalVariableConversion();
    while(next != null) {
        if(next.isLive()) {
            final Type to = emitLocalVariableConversion(next, false);
            recovery.getStack().onLocalStore(to, next.getSymbol().getSlot(to), true);
        }
        next = next.getNext();
    }
}
 
Example #18
Source File: MethodEmitter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private Type emitLocalVariableConversion(final LocalVariableConversion conversion, final boolean onlySymbolLiveValue) {
    final Type from = conversion.getFrom();
    final Type to = conversion.getTo();
    final Symbol symbol = conversion.getSymbol();
    assert symbol.isBytecodeLocal();
    if(from == Type.UNDEFINED) {
        loadUndefined(to);
    } else {
        load(symbol, from).convert(to);
    }
    store(symbol, to, onlySymbolLiveValue);
    return to;
}
 
Example #19
Source File: BranchOptimizer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void optimizeLogicalOperand(final Expression expr, final Label label, final boolean state, final boolean isRhs) {
    final JoinPredecessorExpression jpexpr = (JoinPredecessorExpression)expr;
    if(LocalVariableConversion.hasLiveConversion(jpexpr)) {
        final Label after = new Label("after");
        branchOptimizer(jpexpr.getExpression(), after, !state);
        method.beforeJoinPoint(jpexpr);
        method._goto(label);
        method.label(after);
        if(isRhs) {
            method.beforeJoinPoint(jpexpr);
        }
    } else {
        branchOptimizer(jpexpr.getExpression(), label, state);
    }
}
 
Example #20
Source File: MethodEmitter.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
void beforeJoinPoint(final JoinPredecessor joinPredecessor) {
    LocalVariableConversion next = joinPredecessor.getLocalVariableConversion();
    while(next != null) {
        final Symbol symbol = next.getSymbol();
        if(next.isLive()) {
            emitLocalVariableConversion(next, true);
        } else {
            markDeadLocalVariable(symbol);
        }
        next = next.getNext();
    }
}
 
Example #21
Source File: MethodEmitter.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
void beforeTry(final TryNode tryNode, final Label recovery) {
    LocalVariableConversion next = tryNode.getLocalVariableConversion();
    while(next != null) {
        if(next.isLive()) {
            final Type to = emitLocalVariableConversion(next, false);
            recovery.getStack().onLocalStore(to, next.getSymbol().getSlot(to), true);
        }
        next = next.getNext();
    }
}
 
Example #22
Source File: MethodEmitter.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private Type emitLocalVariableConversion(final LocalVariableConversion conversion, final boolean onlySymbolLiveValue) {
    final Type from = conversion.getFrom();
    final Type to = conversion.getTo();
    final Symbol symbol = conversion.getSymbol();
    assert symbol.isBytecodeLocal();
    if(from == Type.UNDEFINED) {
        loadUndefined(to);
    } else {
        load(symbol, from).convert(to);
    }
    store(symbol, to, onlySymbolLiveValue);
    return to;
}
 
Example #23
Source File: BranchOptimizer.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private void optimizeLogicalOperand(final Expression expr, final Label label, final boolean state, final boolean isRhs) {
    final JoinPredecessorExpression jpexpr = (JoinPredecessorExpression)expr;
    if(LocalVariableConversion.hasLiveConversion(jpexpr)) {
        final Label after = new Label("after");
        branchOptimizer(jpexpr.getExpression(), after, !state);
        method.beforeJoinPoint(jpexpr);
        method._goto(label);
        method.label(after);
        if(isRhs) {
            method.beforeJoinPoint(jpexpr);
        }
    } else {
        branchOptimizer(jpexpr.getExpression(), label, state);
    }
}
 
Example #24
Source File: MethodEmitter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void beforeJoinPoint(final JoinPredecessor joinPredecessor) {
    LocalVariableConversion next = joinPredecessor.getLocalVariableConversion();
    while(next != null) {
        final Symbol symbol = next.getSymbol();
        if(next.isLive()) {
            emitLocalVariableConversion(next, true);
        } else {
            markDeadLocalVariable(symbol);
        }
        next = next.getNext();
    }
}
 
Example #25
Source File: MethodEmitter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void beforeJoinPoint(final JoinPredecessor joinPredecessor) {
    LocalVariableConversion next = joinPredecessor.getLocalVariableConversion();
    while(next != null) {
        final Symbol symbol = next.getSymbol();
        if(next.isLive()) {
            emitLocalVariableConversion(next, true);
        } else {
            markDeadLocalVariable(symbol);
        }
        next = next.getNext();
    }
}
 
Example #26
Source File: MethodEmitter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void beforeTry(final TryNode tryNode, final Label recovery) {
    LocalVariableConversion next = tryNode.getLocalVariableConversion();
    while(next != null) {
        if(next.isLive()) {
            final Type to = emitLocalVariableConversion(next, false);
            recovery.getStack().onLocalStore(to, next.getSymbol().getSlot(to), true);
        }
        next = next.getNext();
    }
}
 
Example #27
Source File: MethodEmitter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private Type emitLocalVariableConversion(final LocalVariableConversion conversion, final boolean onlySymbolLiveValue) {
    final Type from = conversion.getFrom();
    final Type to = conversion.getTo();
    final Symbol symbol = conversion.getSymbol();
    assert symbol.isBytecodeLocal();
    if(from == Type.UNDEFINED) {
        loadUndefined(to);
    } else {
        load(symbol, from).convert(to);
    }
    store(symbol, to, onlySymbolLiveValue);
    return to;
}
 
Example #28
Source File: BranchOptimizer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void optimizeLogicalOperand(final Expression expr, final Label label, final boolean state, final boolean isRhs) {
    final JoinPredecessorExpression jpexpr = (JoinPredecessorExpression)expr;
    if(LocalVariableConversion.hasLiveConversion(jpexpr)) {
        final Label after = new Label("after");
        branchOptimizer(jpexpr.getExpression(), after, !state);
        method.beforeJoinPoint(jpexpr);
        method._goto(label);
        method.label(after);
        if(isRhs) {
            method.beforeJoinPoint(jpexpr);
        }
    } else {
        branchOptimizer(jpexpr.getExpression(), label, state);
    }
}
 
Example #29
Source File: BranchOptimizer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void optimizeLogicalOperand(final Expression expr, final Label label, final boolean state, final boolean isRhs) {
    final JoinPredecessorExpression jpexpr = (JoinPredecessorExpression)expr;
    if(LocalVariableConversion.hasLiveConversion(jpexpr)) {
        final Label after = new Label("after");
        branchOptimizer(jpexpr.getExpression(), after, !state);
        method.beforeJoinPoint(jpexpr);
        method._goto(label);
        method.label(after);
        if(isRhs) {
            method.beforeJoinPoint(jpexpr);
        }
    } else {
        branchOptimizer(jpexpr.getExpression(), label, state);
    }
}
 
Example #30
Source File: MethodEmitter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void beforeTry(final TryNode tryNode, final Label recovery) {
    LocalVariableConversion next = tryNode.getLocalVariableConversion();
    while(next != null) {
        if(next.isLive()) {
            final Type to = emitLocalVariableConversion(next, false);
            recovery.getStack().onLocalStore(to, next.getSymbol().getSlot(to), true);
        }
        next = next.getNext();
    }
}