Java Code Examples for jdk.nashorn.internal.ir.FunctionNode#hasScopeBlock()

The following examples show how to use jdk.nashorn.internal.ir.FunctionNode#hasScopeBlock() . 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: AssignSymbols.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if various symbols that were provisionally marked as needing a slot ended up unused, and marks them as not
 * needing a slot after all.
 * @param functionNode the function node
 * @return the passed in node, for easy chaining
 */
private static FunctionNode removeUnusedSlots(final FunctionNode functionNode) {
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }
    // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
    if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
        final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
        if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
            selfSymbol.setNeedsSlot(false);
            selfSymbol.clearFlag(Symbol.IS_VAR);
        }
    }
    return functionNode;
}
 
Example 2
Source File: AssignSymbols.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if various symbols that were provisionally marked as needing a slot ended up unused, and marks them as not
 * needing a slot after all.
 * @param functionNode the function node
 * @return the passed in node, for easy chaining
 */
private static FunctionNode removeUnusedSlots(final FunctionNode functionNode) {
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }
    // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
    if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
        final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
        if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
            selfSymbol.setNeedsSlot(false);
            selfSymbol.clearFlag(Symbol.IS_VAR);
        }
    }
    return functionNode;
}
 
Example 3
Source File: AssignSymbols.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if various symbols that were provisionally marked as needing a slot ended up unused, and marks them as not
 * needing a slot after all.
 * @param functionNode the function node
 * @return the passed in node, for easy chaining
 */
private static FunctionNode removeUnusedSlots(final FunctionNode functionNode) {
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }
    // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
    if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
        final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
        if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
            selfSymbol.setNeedsSlot(false);
            selfSymbol.clearFlag(Symbol.IS_VAR);
        }
    }
    return functionNode;
}
 
Example 4
Source File: AssignSymbols.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if various symbols that were provisionally marked as needing a slot ended up unused, and marks them as not
 * needing a slot after all.
 * @param functionNode the function node
 * @return the passed in node, for easy chaining
 */
private static FunctionNode removeUnusedSlots(final FunctionNode functionNode) {
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }
    // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
    if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
        final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
        if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
            selfSymbol.setNeedsSlot(false);
            selfSymbol.clearFlag(Symbol.IS_VAR);
        }
    }
    return functionNode;
}
 
Example 5
Source File: AssignSymbols.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if various symbols that were provisionally marked as needing a slot ended up unused, and marks them as not
 * needing a slot after all.
 * @param functionNode the function node
 * @return the passed in node, for easy chaining
 */
private static FunctionNode removeUnusedSlots(final FunctionNode functionNode) {
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }
    // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
    if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
        final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
        if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
            selfSymbol.setNeedsSlot(false);
            selfSymbol.clearFlag(Symbol.IS_VAR);
        }
    }
    return functionNode;
}
 
Example 6
Source File: AssignSymbols.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if various symbols that were provisionally marked as needing a slot ended up unused, and marks them as not
 * needing a slot after all.
 * @param functionNode the function node
 * @return the passed in node, for easy chaining
 */
private static FunctionNode removeUnusedSlots(final FunctionNode functionNode) {
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }
    // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
    if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
        final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
        if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
            selfSymbol.setNeedsSlot(false);
            selfSymbol.clearFlag(Symbol.IS_VAR);
        }
    }
    return functionNode;
}
 
Example 7
Source File: FinalizeTypes.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (functionNode.isLazy()) {
        return false;
    }

    // If the function doesn't need a callee, we ensure its __callee__ symbol doesn't get a slot. We can't do
    // this earlier, as access to scoped variables, self symbol, etc. in previous phases can all trigger the
    // need for the callee.
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    // Similar reasoning applies to __scope__ symbol: if the function doesn't need either parent scope and none of
    // its blocks create a scope, we ensure it doesn't get a slot, but we can't determine whether it needs a scope
    // earlier than this phase.
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }

    return true;
}
 
Example 8
Source File: FinalizeTypes.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (functionNode.isLazy()) {
        return false;
    }

    // If the function doesn't need a callee, we ensure its __callee__ symbol doesn't get a slot. We can't do
    // this earlier, as access to scoped variables, self symbol, etc. in previous phases can all trigger the
    // need for the callee.
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    // Similar reasoning applies to __scope__ symbol: if the function doesn't need either parent scope and none of
    // its blocks create a scope, we ensure it doesn't get a slot, but we can't determine whether it needs a scope
    // earlier than this phase.
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }

    return true;
}
 
Example 9
Source File: AssignSymbols.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks if various symbols that were provisionally marked as needing a slot ended up unused, and marks them as not
 * needing a slot after all.
 * @param functionNode the function node
 * @return the passed in node, for easy chaining
 */
private static FunctionNode removeUnusedSlots(final FunctionNode functionNode) {
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }
    // Named function expressions that end up not referencing themselves won't need a local slot for the self symbol.
    if(functionNode.isNamedFunctionExpression() && !functionNode.usesSelfSymbol()) {
        final Symbol selfSymbol = functionNode.getBody().getExistingSymbol(functionNode.getIdent().getName());
        if(selfSymbol != null && selfSymbol.isFunctionSelf()) {
            selfSymbol.setNeedsSlot(false);
            selfSymbol.clearFlag(Symbol.IS_VAR);
        }
    }
    return functionNode;
}
 
Example 10
Source File: FinalizeTypes.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (functionNode.isLazy()) {
        return false;
    }

    // If the function doesn't need a callee, we ensure its __callee__ symbol doesn't get a slot. We can't do
    // this earlier, as access to scoped variables, self symbol, etc. in previous phases can all trigger the
    // need for the callee.
    if (!functionNode.needsCallee()) {
        functionNode.compilerConstant(CALLEE).setNeedsSlot(false);
    }
    // Similar reasoning applies to __scope__ symbol: if the function doesn't need either parent scope and none of
    // its blocks create a scope, we ensure it doesn't get a slot, but we can't determine whether it needs a scope
    // earlier than this phase.
    if (!(functionNode.hasScopeBlock() || functionNode.needsParentScope())) {
        functionNode.compilerConstant(SCOPE).setNeedsSlot(false);
    }

    return true;
}