jdk.nashorn.internal.ir.JoinPredecessor Java Examples

The following examples show how to use jdk.nashorn.internal.ir.JoinPredecessor. 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 5 votes vote down vote up
/**
 * If we're in a try/catch block, add an edge from the specified node to the try node's pre-catch label.
 */
private void jumpToCatchBlock(final JoinPredecessor jumpOrigin) {
    final Label currentCatchLabel = catchLabels.peek();
    if(currentCatchLabel != null) {
        jumpToLabel(jumpOrigin, currentCatchLabel);
    }
}
 
Example #2
Source File: LocalVariableTypesCalculator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
    final Expression lhs = binaryNode.lhs();
    final LvarType lhsType;
    if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
        lhsType = visitExpression(lhs);
    } else {
        // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
        // The type is irrelevant, as only RHS is used to determine the type anyway.
        lhsType = LvarType.UNDEFINED;
    }

    final boolean isLogical = binaryNode.isLogical();
    final Label joinLabel = isLogical ? new Label("") : null;
    if(isLogical) {
        jumpToLabel((JoinPredecessor)lhs, joinLabel);
    }

    final Expression rhs = binaryNode.rhs();
    final LvarType rhsType = visitExpression(rhs);
    if(isLogical) {
        jumpToLabel((JoinPredecessor)rhs, joinLabel);
    }
    joinOnLabel(joinLabel);

    final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());

    if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
        if(binaryNode.isSelfModifying()) {
            onSelfAssignment((IdentNode)lhs, type);
        } else {
            onAssignment((IdentNode)lhs, type);
        }
    }
    typeStack.push(type);
    return false;
}
 
Example #3
Source File: LocalVariableTypesCalculator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
Example #4
Source File: LocalVariableTypesCalculator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
Example #5
Source File: LocalVariableTypesCalculator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If we're in a try/catch block, add an edge from the specified node to the try node's pre-catch label.
 */
private void jumpToCatchBlock(final JoinPredecessor jumpOrigin) {
    final Label currentCatchLabel = catchLabels.peek();
    if(currentCatchLabel != null) {
        jumpToLabel(jumpOrigin, currentCatchLabel);
    }
}
 
Example #6
Source File: LocalVariableTypesCalculator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If we're in a try/catch block, add an edge from the specified node to the try node's pre-catch label.
 */
private void jumpToCatchBlock(final JoinPredecessor jumpOrigin) {
    final Label currentCatchLabel = catchLabels.peek();
    if(currentCatchLabel != null) {
        jumpToLabel(jumpOrigin, currentCatchLabel);
    }
}
 
Example #7
Source File: LocalVariableTypesCalculator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
    final Expression lhs = binaryNode.lhs();
    final LvarType lhsType;
    if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
        lhsType = visitExpression(lhs);
    } else {
        // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
        // The type is irrelevant, as only RHS is used to determine the type anyway.
        lhsType = LvarType.UNDEFINED;
    }

    final boolean isLogical = binaryNode.isLogical();
    final Label joinLabel = isLogical ? new Label("") : null;
    if(isLogical) {
        jumpToLabel((JoinPredecessor)lhs, joinLabel);
    }

    final Expression rhs = binaryNode.rhs();
    final LvarType rhsType = visitExpression(rhs);
    if(isLogical) {
        jumpToLabel((JoinPredecessor)rhs, joinLabel);
    }
    joinOnLabel(joinLabel);

    final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());

    if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
        if(binaryNode.isSelfModifying()) {
            onSelfAssignment((IdentNode)lhs, type);
        } else {
            onAssignment((IdentNode)lhs, type);
        }
    }
    typeStack.push(type);
    return false;
}
 
Example #8
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 #9
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 #10
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
    final Expression lhs = binaryNode.lhs();
    final LvarType lhsType;
    if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
        lhsType = visitExpression(lhs);
    } else {
        // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
        // The type is irrelevant, as only RHS is used to determine the type anyway.
        lhsType = LvarType.UNDEFINED;
    }

    final boolean isLogical = binaryNode.isLogical();
    final Label joinLabel = isLogical ? new Label("") : null;
    if(isLogical) {
        jumpToLabel((JoinPredecessor)lhs, joinLabel);
    }

    final Expression rhs = binaryNode.rhs();
    final LvarType rhsType = visitExpression(rhs);
    if(isLogical) {
        jumpToLabel((JoinPredecessor)rhs, joinLabel);
    }
    joinOnLabel(joinLabel);

    final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());

    if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
        if(binaryNode.isSelfModifying()) {
            onSelfAssignment((IdentNode)lhs, type);
        } else {
            onAssignment((IdentNode)lhs, type);
        }
    }
    typeStack.push(type);
    return false;
}
 
Example #11
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
Example #12
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If we're in a try/catch block, add an edge from the specified node to the try node's pre-catch label.
 */
private void jumpToCatchBlock(final JoinPredecessor jumpOrigin) {
    final Label currentCatchLabel = catchLabels.peek();
    if(currentCatchLabel != null) {
        jumpToLabel(jumpOrigin, currentCatchLabel);
    }
}
 
Example #13
Source File: MethodEmitter.java    From openjdk-jdk8u-backup 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 #14
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
    final Expression lhs = binaryNode.lhs();
    final LvarType lhsType;
    if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
        lhsType = visitExpression(lhs);
    } else {
        // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
        // The type is irrelevant, as only RHS is used to determine the type anyway.
        lhsType = LvarType.UNDEFINED;
    }

    final boolean isLogical = binaryNode.isLogical();
    final Label joinLabel = isLogical ? new Label("") : null;
    if(isLogical) {
        jumpToLabel((JoinPredecessor)lhs, joinLabel);
    }

    final Expression rhs = binaryNode.rhs();
    final LvarType rhsType = visitExpression(rhs);
    if(isLogical) {
        jumpToLabel((JoinPredecessor)rhs, joinLabel);
    }
    joinOnLabel(joinLabel);

    final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());

    if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
        if(binaryNode.isSelfModifying()) {
            onSelfAssignment((IdentNode)lhs, type);
        } else {
            onAssignment((IdentNode)lhs, type);
        }
    }
    typeStack.push(type);
    return false;
}
 
Example #15
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
Example #16
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If we're in a try/catch block, add an edge from the specified node to the try node's pre-catch label.
 */
private void jumpToCatchBlock(final JoinPredecessor jumpOrigin) {
    final Label currentCatchLabel = catchLabels.peek();
    if(currentCatchLabel != null) {
        jumpToLabel(jumpOrigin, currentCatchLabel);
    }
}
 
Example #17
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 #18
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
    final Expression lhs = binaryNode.lhs();
    final LvarType lhsType;
    if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
        lhsType = visitExpression(lhs);
    } else {
        // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
        // The type is irrelevant, as only RHS is used to determine the type anyway.
        lhsType = LvarType.UNDEFINED;
    }

    final boolean isLogical = binaryNode.isLogical();
    final Label joinLabel = isLogical ? new Label("") : null;
    if(isLogical) {
        jumpToLabel((JoinPredecessor)lhs, joinLabel);
    }

    final Expression rhs = binaryNode.rhs();
    final LvarType rhsType = visitExpression(rhs);
    if(isLogical) {
        jumpToLabel((JoinPredecessor)rhs, joinLabel);
    }
    joinOnLabel(joinLabel);

    final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());

    if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
        if(binaryNode.isSelfModifying()) {
            onSelfAssignment((IdentNode)lhs, type);
        } else {
            onAssignment((IdentNode)lhs, type);
        }
    }
    typeStack.push(type);
    return false;
}
 
Example #19
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
Example #20
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If we're in a try/catch block, add an edge from the specified node to the try node's pre-catch label.
 */
private void jumpToCatchBlock(final JoinPredecessor jumpOrigin) {
    final Label currentCatchLabel = catchLabels.peek();
    if(currentCatchLabel != null) {
        jumpToLabel(jumpOrigin, currentCatchLabel);
    }
}
 
Example #21
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 #22
Source File: LocalVariableTypesCalculator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
    final Expression lhs = binaryNode.lhs();
    final LvarType lhsType;
    if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
        lhsType = visitExpression(lhs);
    } else {
        // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
        // The type is irrelevant, as only RHS is used to determine the type anyway.
        lhsType = LvarType.UNDEFINED;
    }

    final boolean isLogical = binaryNode.isLogical();
    final Label joinLabel = isLogical ? new Label("") : null;
    if(isLogical) {
        jumpToLabel((JoinPredecessor)lhs, joinLabel);
    }

    final Expression rhs = binaryNode.rhs();
    final LvarType rhsType = visitExpression(rhs);
    if(isLogical) {
        jumpToLabel((JoinPredecessor)rhs, joinLabel);
    }
    joinOnLabel(joinLabel);

    final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());

    if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
        if(binaryNode.isSelfModifying()) {
            onSelfAssignment((IdentNode)lhs, type);
        } else {
            onAssignment((IdentNode)lhs, type);
        }
    }
    typeStack.push(type);
    return false;
}
 
Example #23
Source File: LocalVariableTypesCalculator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
Example #24
Source File: LocalVariableTypesCalculator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If we're in a try/catch block, add an edge from the specified node to the try node's pre-catch label.
 */
private void jumpToCatchBlock(final JoinPredecessor jumpOrigin) {
    final Label currentCatchLabel = catchLabels.peek();
    if(currentCatchLabel != null) {
        jumpToLabel(jumpOrigin, currentCatchLabel);
    }
}
 
Example #25
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 #26
Source File: LocalVariableTypesCalculator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first.
    final Expression lhs = binaryNode.lhs();
    final LvarType lhsType;
    if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) {
        lhsType = visitExpression(lhs);
    } else {
        // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
        // The type is irrelevant, as only RHS is used to determine the type anyway.
        lhsType = LvarType.UNDEFINED;
    }

    final boolean isLogical = binaryNode.isLogical();
    final Label joinLabel = isLogical ? new Label("") : null;
    if(isLogical) {
        jumpToLabel((JoinPredecessor)lhs, joinLabel);
    }

    final Expression rhs = binaryNode.rhs();
    final LvarType rhsType = visitExpression(rhs);
    if(isLogical) {
        jumpToLabel((JoinPredecessor)rhs, joinLabel);
    }
    joinOnLabel(joinLabel);

    final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType());

    if(binaryNode.isAssignment() && lhs instanceof IdentNode) {
        if(binaryNode.isSelfModifying()) {
            onSelfAssignment((IdentNode)lhs, type);
        } else {
            onAssignment((IdentNode)lhs, type);
        }
    }
    typeStack.push(type);
    return false;
}
 
Example #27
Source File: LocalVariableTypesCalculator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
Example #28
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 #29
Source File: LocalVariableTypesCalculator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void jumpToLabel(final JoinPredecessor jumpOrigin, final Label label) {
    jumpToLabel(jumpOrigin, label, localVariableTypes);
}
 
Example #30
Source File: LocalVariableTypesCalculator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void jumpToLabel(final JoinPredecessor jumpOrigin, final Label label) {
    jumpToLabel(jumpOrigin, label, localVariableTypes);
}