jdk.nashorn.internal.codegen.CompileUnit Java Examples

The following examples show how to use jdk.nashorn.internal.codegen.CompileUnit. 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: FunctionNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset the compile unit used to compile this function
 * @see Compiler
 * @param lc lexical context
 * @param compileUnit the compile unit
 * @return function node or a new one if state was changed
 */
public FunctionNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(
            lc,
            this,
            new FunctionNode(
                    this,
                    lastToken,
                    endParserState,
                    flags,
                    name,
                    returnType,
                    compileUnit,
                    body,
                    parameters,
                    thisProperties,
                    rootClass, source, namespace));
}
 
Example #2
Source File: FunctionNode.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset the compile unit used to compile this function
 * @see Compiler
 * @param lc lexical context
 * @param compileUnit the compile unit
 * @return function node or a new one if state was changed
 */
public FunctionNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(
            lc,
            this,
            new FunctionNode(
                    this,
                    lastToken,
                    endParserState,
                    flags,
                    name,
                    returnType,
                    compileUnit,
                    body,
                    parameters,
                    thisProperties,
                    rootClass, source, namespace));
}
 
Example #3
Source File: FunctionNode.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset the compile unit used to compile this function
 * @see Compiler
 * @param lc lexical context
 * @param compileUnit the compile unit
 * @return function node or a new one if state was changed
 */
public FunctionNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(
            lc,
            this,
            new FunctionNode(
                    this,
                    lastToken,
                    endParserState,
                    flags,
                    name,
                    returnType,
                    compileUnit,
                    body,
                    parameters,
                    thisProperties,
                    rootClass, source, namespace));
}
 
Example #4
Source File: FunctionNode.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset the compile unit used to compile this function
 * @see Compiler
 * @param lc lexical context
 * @param compileUnit the compile unit
 * @return function node or a new one if state was changed
 */
public FunctionNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(
            lc,
            this,
            new FunctionNode(
                    this,
                    lastToken,
                    endParserState,
                    flags,
                    name,
                    returnType,
                    compileUnit,
                    body,
                    parameters,
                    thisProperties,
                    rootClass, source, namespace));
}
 
Example #5
Source File: FunctionNode.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset the compile unit used to compile this function
 * @see Compiler
 * @param lc lexical context
 * @param compileUnit the compile unit
 * @return function node or a new one if state was changed
 */
public FunctionNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(
            lc,
            this,
            new FunctionNode(
                    this,
                    lastToken,
                    endParserState,
                    flags,
                    name,
                    returnType,
                    compileUnit,
                    body,
                    parameters,
                    thisProperties,
                    rootClass, source, namespace));
}
 
Example #6
Source File: FunctionNode.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset the compile unit used to compile this function
 * @see Compiler
 * @param lc lexical context
 * @param compileUnit the compile unit
 * @return function node or a new one if state was changed
 */
public FunctionNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(
            lc,
            this,
            new FunctionNode(
                    this,
                    lastToken,
                    endParserState,
                    flags,
                    name,
                    returnType,
                    compileUnit,
                    body,
                    parameters,
                    thisProperties,
                    rootClass, source, namespace));
}
 
Example #7
Source File: FunctionNode.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset the compile unit used to compile this function
 * @see Compiler
 * @param lc lexical context
 * @param compileUnit the compile unit
 * @return function node or a new one if state was changed
 */
public FunctionNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(
            lc,
            this,
            new FunctionNode(
                    this,
                    lastToken,
                    endParserState,
                    flags,
                    name,
                    returnType,
                    compileUnit,
                    compilationState,
                    body,
                    parameters,
                    thisProperties,
                    rootClass, source, namespace));
}
 
Example #8
Source File: FunctionNode.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, final Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.body             = body;
    this.parameters       = parameters;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
}
 
Example #9
Source File: SplitNode.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compile unit for this split node
 * @param lc lexical context
 * @param compileUnit compile unit
 * @return new node if changed, otherwise same node
 */
public SplitNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(lc, this, new SplitNode(this, body, compileUnit));
}
 
Example #10
Source File: SplitNode.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compile unit for this split node
 * @param lc lexical context
 * @param compileUnit compile unit
 * @return new node if changed, otherwise same node
 */
public SplitNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(lc, this, new SplitNode(this, body, compileUnit));
}
 
Example #11
Source File: SplitNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compile unit for this split node
 * @param lc lexical context
 * @param compileUnit compile unit
 * @return new node if changed, otherwise same node
 */
public SplitNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(lc, this, new SplitNode(this, body, compileUnit));
}
 
Example #12
Source File: FunctionNode.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final EnumSet<CompilationState> compilationState,
    final Block body,
    final List<IdentNode> parameters,
    final FunctionNode snapshot,
    final Compiler.Hints hints) {
    super(functionNode);
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.compilationState = compilationState;
    this.body             = body;
    this.parameters       = parameters;
    this.snapshot         = snapshot;
    this.hints            = hints;

    // the fields below never change - they are final and assigned in constructor
    this.source          = functionNode.source;
    this.ident           = functionNode.ident;
    this.namespace       = functionNode.namespace;
    this.declaredSymbols = functionNode.declaredSymbols;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
    this.thisProperties  = functionNode.thisProperties;
}
 
Example #13
Source File: FunctionNode.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final EnumSet<CompilationState> compilationState,
    final Block body,
    final List<IdentNode> parameters,
    final FunctionNode snapshot,
    final Compiler.Hints hints) {
    super(functionNode);
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.compilationState = compilationState;
    this.body             = body;
    this.parameters       = parameters;
    this.snapshot         = snapshot;
    this.hints            = hints;

    // the fields below never change - they are final and assigned in constructor
    this.source          = functionNode.source;
    this.ident           = functionNode.ident;
    this.namespace       = functionNode.namespace;
    this.declaredSymbols = functionNode.declaredSymbols;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
    this.thisProperties  = functionNode.thisProperties;
}
 
Example #14
Source File: SplitNode.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compile unit for this split node
 * @param lc lexical context
 * @param compileUnit compile unit
 * @return new node if changed, otherwise same node
 */
public SplitNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(lc, this, new SplitNode(this, body, compileUnit));
}
 
Example #15
Source File: FunctionNode.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final EnumSet<CompilationState> compilationState,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.compilationState = compilationState;
    this.body             = body;
    this.parameters       = parameters;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
}
 
Example #16
Source File: FunctionNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, final Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.body             = body;
    this.parameters       = parameters;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
}
 
Example #17
Source File: SplitNode.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compile unit for this split node
 * @param lc lexical context
 * @param compileUnit compile unit
 * @return new node if changed, otherwise same node
 */
public SplitNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(lc, this, new SplitNode(this, body, compileUnit));
}
 
Example #18
Source File: FunctionNode.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, final Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.body             = body;
    this.parameters       = parameters;
    this.parameterExpressions = functionNode.parameterExpressions;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
    this.module          = functionNode.module;
    this.debugFlags      = functionNode.debugFlags;
}
 
Example #19
Source File: SplitNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compile unit for this split node
 * @param lc lexical context
 * @param compileUnit compile unit
 * @return new node if changed, otherwise same node
 */
public SplitNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(lc, this, new SplitNode(this, body, compileUnit));
}
 
Example #20
Source File: SplitNode.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compile unit for this split node
 * @param lc lexical context
 * @param compileUnit compile unit
 * @return new node if changed, otherwise same node
 */
public SplitNode setCompileUnit(final LexicalContext lc, final CompileUnit compileUnit) {
    if (this.compileUnit == compileUnit) {
        return this;
    }
    return Node.replaceInLexicalContext(lc, this, new SplitNode(this, body, compileUnit));
}
 
Example #21
Source File: FunctionNode.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private FunctionNode(
    final FunctionNode functionNode,
    final long lastToken,
    final Object endParserState,
    final int flags,
    final String name,
    final Type returnType,
    final CompileUnit compileUnit,
    final Block body,
    final List<IdentNode> parameters,
    final int thisProperties,
    final Class<?> rootClass,
    final Source source, final Namespace namespace) {
    super(functionNode);

    this.endParserState    = endParserState;
    this.lineNumber       = functionNode.lineNumber;
    this.flags            = flags;
    this.name             = name;
    this.returnType       = returnType;
    this.compileUnit      = compileUnit;
    this.lastToken        = lastToken;
    this.body             = body;
    this.parameters       = parameters;
    this.thisProperties   = thisProperties;
    this.rootClass        = rootClass;
    this.source           = source;
    this.namespace        = namespace;

    // the fields below never change - they are final and assigned in constructor
    this.ident           = functionNode.ident;
    this.kind            = functionNode.kind;
    this.firstToken      = functionNode.firstToken;
}
 
Example #22
Source File: SplitNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the compile unit for this split node
 * @return compile unit
 */
@Override
public CompileUnit getCompileUnit() {
    return compileUnit;
}
 
Example #23
Source File: Timing.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String get() {
    final long t = System.nanoTime();

    long knownTime = 0L;
    int  maxKeyLength = 0;
    int  maxValueLength = 0;

    for (final Map.Entry<String, LongAdder> entry : timings.entrySet()) {
        maxKeyLength   = Math.max(maxKeyLength, entry.getKey().length());
        maxValueLength = Math.max(maxValueLength, toMillisPrint(entry.getValue().longValue()).length());
    }
    maxKeyLength++;

    final StringBuilder sb = new StringBuilder();
    sb.append("Accumulated compilation phase timings:\n\n");
    for (final String timingName: orderedTimingNames) {
        int len;

        len = sb.length();
        sb.append(timingName);
        len = sb.length() - len;

        while (len++ < maxKeyLength) {
            sb.append(' ');
        }

        final long duration = timings.get(timingName).longValue();
        final String strDuration = toMillisPrint(duration);
        len = strDuration.length();
        for (int i = 0; i < maxValueLength - len; i++) {
            sb.append(' ');
        }

        sb.append(strDuration).
            append(" ms\n");

        knownTime += duration;
    }

    final long total = t - startTime;
    sb.append('\n');
    sb.append("Total runtime: ").
        append(toMillisPrint(total)).
        append(" ms (Non-runtime: ").
        append(toMillisPrint(knownTime)).
        append(" ms [").
        append((int)(knownTime * 100.0 / total)).
        append("%])");

    sb.append("\n\nEmitted compile units: ").
        append(CompileUnit.getEmittedUnitCount());

    return sb.toString();
}
 
Example #24
Source File: Timing.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String get() {
    final long t = System.nanoTime();

    long knownTime = 0L;
    int  maxKeyLength = 0;
    int  maxValueLength = 0;

    for (final Map.Entry<String, LongAdder> entry : timings.entrySet()) {
        maxKeyLength   = Math.max(maxKeyLength, entry.getKey().length());
        maxValueLength = Math.max(maxValueLength, toMillisPrint(entry.getValue().longValue()).length());
    }
    maxKeyLength++;

    final StringBuilder sb = new StringBuilder();
    sb.append("Accumulated compilation phase timings:\n\n");
    for (final String timingName: orderedTimingNames) {
        int len;

        len = sb.length();
        sb.append(timingName);
        len = sb.length() - len;

        while (len++ < maxKeyLength) {
            sb.append(' ');
        }

        final long duration = timings.get(timingName).longValue();
        final String strDuration = toMillisPrint(duration);
        len = strDuration.length();
        for (int i = 0; i < maxValueLength - len; i++) {
            sb.append(' ');
        }

        sb.append(strDuration).
            append(" ms\n");

        knownTime += duration;
    }

    final long total = t - startTime;
    sb.append('\n');
    sb.append("Total runtime: ").
        append(toMillisPrint(total)).
        append(" ms (Non-runtime: ").
        append(toMillisPrint(knownTime)).
        append(" ms [").
        append((int)(knownTime * 100.0 / total)).
        append("%])");

    sb.append("\n\nEmitted compile units: ").
        append(CompileUnit.getEmittedUnitCount());

    return sb.toString();
}
 
Example #25
Source File: Timing.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String get() {
    final long t = System.nanoTime();

    long knownTime = 0L;
    int  maxKeyLength = 0;
    int  maxValueLength = 0;

    for (final Map.Entry<String, LongAdder> entry : timings.entrySet()) {
        maxKeyLength   = Math.max(maxKeyLength, entry.getKey().length());
        maxValueLength = Math.max(maxValueLength, toMillisPrint(entry.getValue().longValue()).length());
    }
    maxKeyLength++;

    final StringBuilder sb = new StringBuilder();
    sb.append("Accumulated compilation phase timings:\n\n");
    for (final String timingName: orderedTimingNames) {
        int len;

        len = sb.length();
        sb.append(timingName);
        len = sb.length() - len;

        while (len++ < maxKeyLength) {
            sb.append(' ');
        }

        final long duration = timings.get(timingName).longValue();
        final String strDuration = toMillisPrint(duration);
        len = strDuration.length();
        for (int i = 0; i < maxValueLength - len; i++) {
            sb.append(' ');
        }

        sb.append(strDuration).
            append(" ms\n");

        knownTime += duration;
    }

    final long total = t - startTime;
    sb.append('\n');
    sb.append("Total runtime: ").
        append(toMillisPrint(total)).
        append(" ms (Non-runtime: ").
        append(toMillisPrint(knownTime)).
        append(" ms [").
        append((int)(knownTime * 100.0 / total)).
        append("%])");

    sb.append("\n\nEmitted compile units: ").
        append(CompileUnit.getEmittedUnitCount());

    return sb.toString();
}
 
Example #26
Source File: Splittable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The array compile unit
 * @return array compile unit
 */
@Override
public CompileUnit getCompileUnit() {
    return compileUnit;
}
 
Example #27
Source File: Splittable.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The array compile unit
 * @return array compile unit
 */
@Override
public CompileUnit getCompileUnit() {
    return compileUnit;
}
 
Example #28
Source File: SplitNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private SplitNode(final SplitNode splitNode, final Block body, final CompileUnit compileUnit) {
    super(splitNode);
    this.name        = splitNode.name;
    this.body        = body;
    this.compileUnit = compileUnit;
}
 
Example #29
Source File: Splittable.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The array compile unit
 * @return array compile unit
 */
@Override
public CompileUnit getCompileUnit() {
    return compileUnit;
}
 
Example #30
Source File: Splittable.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The array compile unit
 * @return array compile unit
 */
@Override
public CompileUnit getCompileUnit() {
    return compileUnit;
}