src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Splitter.java

Print this page

        

*** 40,56 **** import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.SplitNode; import jdk.nashorn.internal.ir.Statement; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.logging.DebugLogger; import jdk.nashorn.internal.runtime.options.Options; /** * Split the IR into smaller compile units. */ ! final class Splitter extends NodeVisitor<LexicalContext> { /** Current compiler. */ private final Compiler compiler; /** IR to be broken down. */ private final FunctionNode outermost; --- 40,60 ---- import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.SplitNode; import jdk.nashorn.internal.ir.Statement; import jdk.nashorn.internal.ir.visitor.NodeVisitor; + import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.logging.DebugLogger; + import jdk.nashorn.internal.runtime.logging.Loggable; + import jdk.nashorn.internal.runtime.logging.Logger; import jdk.nashorn.internal.runtime.options.Options; /** * Split the IR into smaller compile units. */ ! @Logger(name="splitter") ! final class Splitter extends NodeVisitor<LexicalContext> implements Loggable { /** Current compiler. */ private final Compiler compiler; /** IR to be broken down. */ private final FunctionNode outermost;
*** 76,106 **** public Splitter(final Compiler compiler, final FunctionNode functionNode, final CompileUnit outermostCompileUnit) { super(new LexicalContext()); this.compiler = compiler; this.outermost = functionNode; this.outermostCompileUnit = outermostCompileUnit; ! this.log = compiler.getLogger(); } /** * Execute the split. * @param fn the function to split * @param top whether this is the topmost compiled function (it's either a program, or we're doing a recompilation). */ FunctionNode split(final FunctionNode fn, final boolean top) { FunctionNode functionNode = fn; ! log.finest("Initiating split of '", functionNode.getName(), "'"); long weight = WeighNodes.weigh(functionNode); // We know that our LexicalContext is empty outside the call to functionNode.accept(this) below, // so we can pass null to all methods expecting a LexicalContext parameter. assert lc.isEmpty() : "LexicalContext not empty"; if (weight >= SPLIT_THRESHOLD) { ! log.finest("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); functionNode = (FunctionNode)functionNode.accept(this); if (functionNode.isSplit()) { // Weight has changed so weigh again, this time using block weight cache weight = WeighNodes.weigh(functionNode, weightCache); --- 80,120 ---- public Splitter(final Compiler compiler, final FunctionNode functionNode, final CompileUnit outermostCompileUnit) { super(new LexicalContext()); this.compiler = compiler; this.outermost = functionNode; this.outermostCompileUnit = outermostCompileUnit; ! this.log = initLogger(compiler.getContext()); ! } ! ! @Override ! public DebugLogger initLogger(final Context context) { ! return context.getLogger(this.getClass()); ! } ! ! @Override ! public DebugLogger getLogger() { ! return log; } /** * Execute the split. * @param fn the function to split * @param top whether this is the topmost compiled function (it's either a program, or we're doing a recompilation). */ FunctionNode split(final FunctionNode fn, final boolean top) { FunctionNode functionNode = fn; ! log.fine("Initiating split of '", functionNode.getName(), "'"); long weight = WeighNodes.weigh(functionNode); // We know that our LexicalContext is empty outside the call to functionNode.accept(this) below, // so we can pass null to all methods expecting a LexicalContext parameter. assert lc.isEmpty() : "LexicalContext not empty"; if (weight >= SPLIT_THRESHOLD) { ! log.info("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); functionNode = (FunctionNode)functionNode.accept(this); if (functionNode.isSplit()) { // Weight has changed so weigh again, this time using block weight cache weight = WeighNodes.weigh(functionNode, weightCache);