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

The following examples show how to use jdk.nashorn.internal.ir.FunctionNode#getId() . 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: FindScopeDepths.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (compiler.isOnDemandCompilation()) {
        return true;
    }

    if (isDynamicScopeBoundary(functionNode)) {
        increaseDynamicScopeCount(functionNode);
    }

    final int fnId = functionNode.getId();
    Map<Integer, RecompilableScriptFunctionData> nestedFunctions = fnIdToNestedFunctions.get(fnId);
    if (nestedFunctions == null) {
        nestedFunctions = new HashMap<>();
        fnIdToNestedFunctions.put(fnId, nestedFunctions);
    }

    return true;
}
 
Example 2
Source File: FindScopeDepths.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (compiler.isOnDemandCompilation()) {
        return true;
    }

    if (isDynamicScopeBoundary(functionNode)) {
        increaseDynamicScopeCount(functionNode);
    }

    final int fnId = functionNode.getId();
    Map<Integer, RecompilableScriptFunctionData> nestedFunctions = fnIdToNestedFunctions.get(fnId);
    if (nestedFunctions == null) {
        nestedFunctions = new HashMap<>();
        fnIdToNestedFunctions.put(fnId, nestedFunctions);
    }

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

    if (isDynamicScopeBoundary(functionNode)) {
        increaseDynamicScopeCount(functionNode);
    }

    final int fnId = functionNode.getId();
    Map<Integer, RecompilableScriptFunctionData> nestedFunctions = fnIdToNestedFunctions.get(fnId);
    if (nestedFunctions == null) {
        nestedFunctions = new HashMap<>();
        fnIdToNestedFunctions.put(fnId, nestedFunctions);
    }

    return true;
}
 
Example 4
Source File: FindScopeDepths.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (compiler.isOnDemandCompilation()) {
        return true;
    }

    if (isDynamicScopeBoundary(functionNode)) {
        increaseDynamicScopeCount(functionNode);
    }

    final int fnId = functionNode.getId();
    Map<Integer, RecompilableScriptFunctionData> nestedFunctions = fnIdToNestedFunctions.get(fnId);
    if (nestedFunctions == null) {
        nestedFunctions = new HashMap<>();
        fnIdToNestedFunctions.put(fnId, nestedFunctions);
    }

    return true;
}
 
Example 5
Source File: FindScopeDepths.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (compiler.isOnDemandCompilation()) {
        return true;
    }

    if (isDynamicScopeBoundary(functionNode)) {
        increaseDynamicScopeCount(functionNode);
    }

    final int fnId = functionNode.getId();
    Map<Integer, RecompilableScriptFunctionData> nestedFunctions = fnIdToNestedFunctions.get(fnId);
    if (nestedFunctions == null) {
        nestedFunctions = new HashMap<>();
        fnIdToNestedFunctions.put(fnId, nestedFunctions);
    }

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

    if (isDynamicScopeBoundary(functionNode)) {
        increaseDynamicScopeCount(functionNode);
    }

    final int fnId = functionNode.getId();
    Map<Integer, RecompilableScriptFunctionData> nestedFunctions = fnIdToNestedFunctions.get(fnId);
    if (nestedFunctions == null) {
        nestedFunctions = new HashMap<>();
        fnIdToNestedFunctions.put(fnId, nestedFunctions);
    }

    return true;
}
 
Example 7
Source File: FindScopeDepths.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    if (compiler.isOnDemandCompilation()) {
        return true;
    }

    if (isDynamicScopeBoundary(functionNode)) {
        increaseDynamicScopeCount(functionNode);
    }

    final int fnId = functionNode.getId();
    Map<Integer, RecompilableScriptFunctionData> nestedFunctions = fnIdToNestedFunctions.get(fnId);
    if (nestedFunctions == null) {
        nestedFunctions = new HashMap<>();
        fnIdToNestedFunctions.put(fnId, nestedFunctions);
    }

    return true;
}
 
Example 8
Source File: FindScopeDepths.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void addExternalSymbol(final FunctionNode functionNode, final Symbol symbol, final int depthAtStart) {
    final int fnId = functionNode.getId();
    Map<String, Integer> depths = externalSymbolDepths.get(fnId);
    if (depths == null) {
        depths = new HashMap<>();
        externalSymbolDepths.put(fnId, depths);
    }
    depths.put(symbol.getName(), depthAtStart);
}
 
Example 9
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes this function data with the eagerly generated version of the code. This method can only be invoked
 * by the compiler internals in Nashorn and is public for implementation reasons only. Attempting to invoke it
 * externally will result in an exception.
 *
 * @param functionNode FunctionNode for this data
 */
public void initializeCode(final FunctionNode functionNode) {
    // Since the method is public, we double-check that we aren't invoked with an inappropriate compile unit.
    if (!code.isEmpty() || functionNode.getId() != functionNodeId || !functionNode.getCompileUnit().isInitializing(this, functionNode)) {
        throw new IllegalStateException(name);
    }
    addCode(lookup(functionNode), null, null, functionNode.getFlags());
}
 
Example 10
Source File: FindScopeDepths.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void addExternalSymbol(final FunctionNode functionNode, final Symbol symbol, final int depthAtStart) {
    final int fnId = functionNode.getId();
    Map<String, Integer> depths = externalSymbolDepths.get(fnId);
    if (depths == null) {
        depths = new HashMap<>();
        externalSymbolDepths.put(fnId, depths);
    }
    depths.put(symbol.getName(), depthAtStart);
}
 
Example 11
Source File: RecompilableScriptFunctionData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes this function data with the eagerly generated version of the code. This method can only be invoked
 * by the compiler internals in Nashorn and is public for implementation reasons only. Attempting to invoke it
 * externally will result in an exception.
 *
 * @param functionNode FunctionNode for this data
 */
public void initializeCode(final FunctionNode functionNode) {
    // Since the method is public, we double-check that we aren't invoked with an inappropriate compile unit.
    if (!code.isEmpty() || functionNode.getId() != functionNodeId || !functionNode.getCompileUnit().isInitializing(this, functionNode)) {
        throw new IllegalStateException(name);
    }
    addCode(lookup(functionNode), null, null, functionNode.getFlags());
}
 
Example 12
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes this function data with the eagerly generated version of the code. This method can only be invoked
 * by the compiler internals in Nashorn and is public for implementation reasons only. Attempting to invoke it
 * externally will result in an exception.
 *
 * @param functionNode FunctionNode for this data
 */
public void initializeCode(final FunctionNode functionNode) {
    // Since the method is public, we double-check that we aren't invoked with an inappropriate compile unit.
    if (!code.isEmpty() || functionNode.getId() != functionNodeId || !functionNode.getCompileUnit().isInitializing(this, functionNode)) {
        throw new IllegalStateException(name);
    }
    addCode(lookup(functionNode), null, null, functionNode.getFlags());
}
 
Example 13
Source File: CacheAst.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final int id = functionNode.getId();
    // It isn't necessary to keep a stack of RecompilableScriptFunctionData, but then we'd need to do a
    // potentially transitive lookup with compiler.getScriptFunctionData(id) for deeper functions; this way
    // we keep it constant time.
    dataStack.push(dataStack.isEmpty() ? compiler.getScriptFunctionData(id) : dataStack.peek().getScriptFunctionData(id));
    return true;
}
 
Example 14
Source File: FindScopeDepths.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void addExternalSymbol(final FunctionNode functionNode, final Symbol symbol, final int depthAtStart) {
    final int fnId = functionNode.getId();
    Map<String, Integer> depths = externalSymbolDepths.get(fnId);
    if (depths == null) {
        depths = new HashMap<>();
        externalSymbolDepths.put(fnId, depths);
    }
    depths.put(symbol.getName(), depthAtStart);
}
 
Example 15
Source File: CacheAst.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final int id = functionNode.getId();
    // It isn't necessary to keep a stack of RecompilableScriptFunctionData, but then we'd need to do a
    // potentially transitive lookup with compiler.getScriptFunctionData(id) for deeper functions; this way
    // we keep it constant time.
    dataStack.push(dataStack.isEmpty() ? compiler.getScriptFunctionData(id) : dataStack.peek().getScriptFunctionData(id));
    return true;
}
 
Example 16
Source File: FindScopeDepths.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private void addExternalSymbol(final FunctionNode functionNode, final Symbol symbol, final int depthAtStart) {
    final int fnId = functionNode.getId();
    Map<String, Integer> depths = externalSymbolDepths.get(fnId);
    if (depths == null) {
        depths = new HashMap<>();
        externalSymbolDepths.put(fnId, depths);
    }
    depths.put(symbol.getName(), depthAtStart);
}
 
Example 17
Source File: FindScopeDepths.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void addExternalSymbol(final FunctionNode functionNode, final Symbol symbol, final int depthAtStart) {
    final int fnId = functionNode.getId();
    Map<String, Integer> depths = externalSymbolDepths.get(fnId);
    if (depths == null) {
        depths = new HashMap<>();
        externalSymbolDepths.put(fnId, depths);
    }
    depths.put(symbol.getName(), depthAtStart);
}
 
Example 18
Source File: RecompilableScriptFunctionData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes this function data with the eagerly generated version of the code. This method can only be invoked
 * by the compiler internals in Nashorn and is public for implementation reasons only. Attempting to invoke it
 * externally will result in an exception.
 *
 * @param functionNode FunctionNode for this data
 */
public void initializeCode(final FunctionNode functionNode) {
    // Since the method is public, we double-check that we aren't invoked with an inappropriate compile unit.
    if (!code.isEmpty() || functionNode.getId() != functionNodeId || !functionNode.getCompileUnit().isInitializing(this, functionNode)) {
        throw new IllegalStateException(name);
    }
    addCode(lookup(functionNode), null, null, functionNode.getFlags());
}
 
Example 19
Source File: FindScopeDepths.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void addExternalSymbol(final FunctionNode functionNode, final Symbol symbol, final int depthAtStart) {
    final int fnId = functionNode.getId();
    Map<String, Integer> depths = externalSymbolDepths.get(fnId);
    if (depths == null) {
        depths = new HashMap<>();
        externalSymbolDepths.put(fnId, depths);
    }
    depths.put(symbol.getName(), depthAtStart);
}
 
Example 20
Source File: RecompilableScriptFunctionData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes this function data with the eagerly generated version of the code. This method can only be invoked
 * by the compiler internals in Nashorn and is public for implementation reasons only. Attempting to invoke it
 * externally will result in an exception.
 *
 * @param functionNode FunctionNode for this data
 */
public void initializeCode(final FunctionNode functionNode) {
    // Since the method is public, we double-check that we aren't invoked with an inappropriate compile unit.
    if (!code.isEmpty() || functionNode.getId() != functionNodeId || !functionNode.getCompileUnit().isInitializing(this, functionNode)) {
        throw new IllegalStateException(name);
    }
    addCode(lookup(functionNode), null, null, functionNode.getFlags());
}