author | lagergren |
Fri, 26 Sep 2014 18:47:20 +0200 | |
changeset 26886 | 18c744ab4df2 |
parent 26506 | 7d55cc7fc301 |
child 27206 | d4a707c9db5a |
permissions | -rw-r--r-- |
24744
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
1 |
/* |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
2 |
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
4 |
* |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
10 |
* |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
15 |
* accompanied this code). |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
16 |
* |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
20 |
* |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
23 |
* questions. |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
24 |
*/ |
5290da85fc3d
8038426: Move all loggers from process wide scope into Global scope
lagergren
parents:
24731
diff
changeset
|
25 |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
26 |
package jdk.nashorn.internal.codegen; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
27 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
28 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.BUILTINS_TRANSFORMED; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
29 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.BYTECODE_GENERATED; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
30 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.BYTECODE_INSTALLED; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
31 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.CONSTANT_FOLDED; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
32 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.INITIALIZED; |
24751 | 33 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.LOCAL_VARIABLE_TYPES_CALCULATED; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
34 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.LOWERED; |
24751 | 35 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.OPTIMISTIC_TYPES_ASSIGNED; |
16523
af8b30edebce
8009718: Lazy execution architecture continued - ScriptFunctionData is either final or recompilable. Moved ScriptFunctionData creation logic away from runtime to compile time. Prepared for method generation/specialization. Got rid of ScriptFunctionImplTrampoline whose semantics could be done as part of the relinking anyway. Merge with the lookup package change.
lagergren
parents:
16262
diff
changeset
|
36 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.PARSED; |
24725
7bb1f687a852
8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents:
24719
diff
changeset
|
37 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.SCOPE_DEPTHS_COMPUTED; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
38 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.SPLIT; |
24751 | 39 |
import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.SYMBOLS_ASSIGNED; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
40 |
import static jdk.nashorn.internal.runtime.logging.DebugLogger.quote; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
41 |
import java.io.PrintWriter; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
42 |
import java.util.ArrayList; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
43 |
import java.util.EnumSet; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
44 |
import java.util.HashMap; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
45 |
import java.util.LinkedHashMap; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
46 |
import java.util.List; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
47 |
import java.util.Map; |
24769 | 48 |
import java.util.Map.Entry; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
49 |
import java.util.Set; |
26250
84bbd0e8b2b2
8056025: CompilationPhase.setStates() is hot in class installation phase
attila
parents:
26246
diff
changeset
|
50 |
import jdk.nashorn.internal.AssertsEnabled; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
51 |
import jdk.nashorn.internal.codegen.Compiler.CompilationPhases; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
52 |
import jdk.nashorn.internal.ir.FunctionNode; |
24769 | 53 |
import jdk.nashorn.internal.ir.FunctionNode.CompilationState; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
54 |
import jdk.nashorn.internal.ir.LexicalContext; |
24769 | 55 |
import jdk.nashorn.internal.ir.LiteralNode; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
56 |
import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
57 |
import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
58 |
import jdk.nashorn.internal.ir.Node; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
59 |
import jdk.nashorn.internal.ir.SplitNode; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
60 |
import jdk.nashorn.internal.ir.debug.ASTWriter; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
61 |
import jdk.nashorn.internal.ir.debug.PrintVisitor; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
62 |
import jdk.nashorn.internal.ir.visitor.NodeVisitor; |
24769 | 63 |
import jdk.nashorn.internal.runtime.CodeInstaller; |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
64 |
import jdk.nashorn.internal.runtime.FunctionInitializer; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
65 |
import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData; |
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16252
diff
changeset
|
66 |
import jdk.nashorn.internal.runtime.ScriptEnvironment; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
67 |
import jdk.nashorn.internal.runtime.logging.DebugLogger; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
68 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
69 |
/** |
17233 | 70 |
* A compilation phase is a step in the processes of turning a JavaScript |
71 |
* FunctionNode into bytecode. It has an optional return value. |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
72 |
*/ |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
73 |
enum CompilationPhase { |
24719 | 74 |
/** |
17233 | 75 |
* Constant folding pass Simple constant folding that will make elementary |
76 |
* constructs go away |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
77 |
*/ |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
78 |
CONSTANT_FOLDING_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
79 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
80 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
81 |
PARSED)) { |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
82 |
@Override |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
83 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
84 |
return (FunctionNode)fn.accept(new FoldConstants(compiler)); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
85 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
86 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
87 |
@Override |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
88 |
public String toString() { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
89 |
return "'Constant Folding'"; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
90 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
91 |
}, |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
92 |
|
24719 | 93 |
/** |
17233 | 94 |
* Lower (Control flow pass) Finalizes the control flow. Clones blocks for |
95 |
* finally constructs and similar things. Establishes termination criteria |
|
96 |
* for nodes Guarantee return instructions to method making sure control |
|
97 |
* flow cannot fall off the end. Replacing high level nodes with lower such |
|
98 |
* as runtime nodes where applicable. |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
99 |
*/ |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
100 |
LOWERING_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
101 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
102 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
103 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
104 |
CONSTANT_FOLDED)) { |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
105 |
@Override |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
106 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
24745
3a6e1477362b
8041434: Add synchronization to the common global constants structure
lagergren
parents:
24744
diff
changeset
|
107 |
return (FunctionNode)fn.accept(new Lower(compiler)); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
108 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
109 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
110 |
@Override |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
111 |
public String toString() { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
112 |
return "'Control Flow Lowering'"; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
113 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
114 |
}, |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
115 |
|
24719 | 116 |
/** |
117 |
* Phase used only when doing optimistic code generation. It assigns all potentially |
|
118 |
* optimistic ops a program point so that an UnwarrantedException knows from where |
|
119 |
* a guess went wrong when creating the continuation to roll back this execution |
|
120 |
*/ |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
121 |
PROGRAM_POINT_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
122 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
123 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
124 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
125 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
126 |
LOWERED)) { |
24719 | 127 |
@Override |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
128 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
24719 | 129 |
return (FunctionNode)fn.accept(new ProgramPoints()); |
130 |
} |
|
131 |
||
132 |
@Override |
|
133 |
public String toString() { |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
134 |
return "'Program Point Calculation'"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
135 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
136 |
}, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
137 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
138 |
TRANSFORM_BUILTINS_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
139 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
140 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
141 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
142 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
143 |
LOWERED)) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
144 |
//we only do this if we have a param type map, otherwise this is not a specialized recompile |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
145 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
146 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
147 |
final FunctionNode newFunctionNode = (FunctionNode)fn.accept(new ApplySpecialization(compiler)); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
148 |
return (FunctionNode)newFunctionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
149 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
150 |
public Node leaveFunctionNode(final FunctionNode node) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
151 |
return node.setState(lc, BUILTINS_TRANSFORMED); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
152 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
153 |
}); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
154 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
155 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
156 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
157 |
public String toString() { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
158 |
return "'Builtin Replacement'"; |
24719 | 159 |
} |
160 |
}, |
|
161 |
||
162 |
/** |
|
163 |
* Splitter Split the AST into several compile units based on a heuristic size calculation. |
|
164 |
* Split IR can lead to scope information being changed. |
|
165 |
*/ |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
166 |
SPLITTING_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
167 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
168 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
169 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
170 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
171 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
172 |
BUILTINS_TRANSFORMED)) { |
24719 | 173 |
@Override |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
174 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
175 |
final CompileUnit outermostCompileUnit = compiler.addCompileUnit(0L); |
25234
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
176 |
|
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
177 |
FunctionNode newFunctionNode; |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
178 |
|
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
179 |
//ensure elementTypes, postsets and presets exist for splitter and arraynodes |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
180 |
newFunctionNode = (FunctionNode)fn.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
181 |
@Override |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
182 |
public LiteralNode<?> leaveLiteralNode(final LiteralNode<?> literalNode) { |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
183 |
return literalNode.initialize(lc); |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
184 |
} |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
185 |
}); |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
186 |
|
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
187 |
newFunctionNode = new Splitter(compiler, newFunctionNode, outermostCompileUnit).split(newFunctionNode, true); |
24719 | 188 |
|
189 |
assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn=" + fn.getName() + ", fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
190 |
assert newFunctionNode.isStrict() == compiler.isStrict() : "functionNode.isStrict() != compiler.isStrict() for " + quote(newFunctionNode.getName()); |
24719 | 191 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
192 |
return newFunctionNode; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
193 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
194 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
195 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
196 |
public String toString() { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
197 |
return "'Code Splitting'"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
198 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
199 |
}, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
200 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
201 |
SYMBOL_ASSIGNMENT_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
202 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
203 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
204 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
205 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
206 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
207 |
BUILTINS_TRANSFORMED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
208 |
SPLIT)) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
209 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
210 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
211 |
return (FunctionNode)fn.accept(new AssignSymbols(compiler)); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
212 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
213 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
214 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
215 |
public String toString() { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
216 |
return "'Symbol Assignment'"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
217 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
218 |
}, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
219 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
220 |
SCOPE_DEPTH_COMPUTATION_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
221 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
222 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
223 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
224 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
225 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
226 |
BUILTINS_TRANSFORMED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
227 |
SPLIT, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
228 |
SYMBOLS_ASSIGNED)) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
229 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
230 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
231 |
return (FunctionNode)fn.accept(new FindScopeDepths(compiler)); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
232 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
233 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
234 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
235 |
public String toString() { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
236 |
return "'Scope Depth Computation'"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
237 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
238 |
}, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
239 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
240 |
OPTIMISTIC_TYPE_ASSIGNMENT_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
241 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
242 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
243 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
244 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
245 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
246 |
BUILTINS_TRANSFORMED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
247 |
SPLIT, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
248 |
SYMBOLS_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
249 |
SCOPE_DEPTHS_COMPUTED)) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
250 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
251 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
252 |
if (compiler.useOptimisticTypes()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
253 |
return (FunctionNode)fn.accept(new OptimisticTypesCalculator(compiler)); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
254 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
255 |
return setStates(fn, OPTIMISTIC_TYPES_ASSIGNED); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
256 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
257 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
258 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
259 |
public String toString() { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
260 |
return "'Optimistic Type Assignment'"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
261 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
262 |
}, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
263 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
264 |
LOCAL_VARIABLE_TYPE_CALCULATION_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
265 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
266 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
267 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
268 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
269 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
270 |
BUILTINS_TRANSFORMED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
271 |
SPLIT, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
272 |
SYMBOLS_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
273 |
SCOPE_DEPTHS_COMPUTED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
274 |
OPTIMISTIC_TYPES_ASSIGNED)) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
275 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
276 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
277 |
final FunctionNode newFunctionNode = (FunctionNode)fn.accept(new LocalVariableTypesCalculator(compiler)); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
278 |
|
24764
722a9603b237
8043633: In order to remove global state outside of contexts, make sure Timing class is an instance and not a static global collection of data. Move into Context. Move -Dnashorn.timing to an official logging option.
lagergren
parents:
24759
diff
changeset
|
279 |
final ScriptEnvironment senv = compiler.getScriptEnvironment(); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
280 |
final PrintWriter err = senv.getErr(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
281 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
282 |
//TODO separate phase for the debug printouts for abstraction and clarity |
26065
d15adb218527
8055107: Extension directives to turn on callsite profiling, tracing, AST print and other debug features locally
sundar
parents:
26055
diff
changeset
|
283 |
if (senv._print_lower_ast || fn.getFlag(FunctionNode.IS_PRINT_LOWER_AST)) { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
284 |
err.println("Lower AST for: " + quote(newFunctionNode.getName())); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
285 |
err.println(new ASTWriter(newFunctionNode)); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
286 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
287 |
|
26065
d15adb218527
8055107: Extension directives to turn on callsite profiling, tracing, AST print and other debug features locally
sundar
parents:
26055
diff
changeset
|
288 |
if (senv._print_lower_parse || fn.getFlag(FunctionNode.IS_PRINT_LOWER_PARSE)) { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
289 |
err.println("Lower AST for: " + quote(newFunctionNode.getName())); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
290 |
err.println(new PrintVisitor(newFunctionNode)); |
24719 | 291 |
} |
292 |
||
293 |
return newFunctionNode; |
|
294 |
} |
|
295 |
||
296 |
@Override |
|
297 |
public String toString() { |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
298 |
return "'Local Variable Type Calculation'"; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
299 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
300 |
}, |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
301 |
|
26500
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
302 |
|
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
303 |
/** |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
304 |
* Reuse compile units, if they are already present. We are using the same compiler |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
305 |
* to recompile stuff |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
306 |
*/ |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
307 |
REUSE_COMPILE_UNITS_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
308 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
309 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
310 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
311 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
312 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
313 |
BUILTINS_TRANSFORMED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
314 |
SPLIT, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
315 |
SYMBOLS_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
316 |
SCOPE_DEPTHS_COMPUTED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
317 |
OPTIMISTIC_TYPES_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
318 |
LOCAL_VARIABLE_TYPES_CALCULATED)) { |
24725
7bb1f687a852
8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents:
24719
diff
changeset
|
319 |
@Override |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
320 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
321 |
assert phases.isRestOfCompilation() : "reuse compile units currently only used for Rest-Of methods"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
322 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
323 |
final Map<CompileUnit, CompileUnit> map = new HashMap<>(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
324 |
final Set<CompileUnit> newUnits = CompileUnit.createCompileUnitSet(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
325 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
326 |
final DebugLogger log = compiler.getLogger(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
327 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
328 |
log.fine("Clearing bytecode cache"); |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
329 |
compiler.clearBytecode(); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
330 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
331 |
for (final CompileUnit oldUnit : compiler.getCompileUnits()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
332 |
assert map.get(oldUnit) == null; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
333 |
final StringBuilder sb = new StringBuilder(compiler.nextCompileUnitName()); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
334 |
if (phases.isRestOfCompilation()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
335 |
sb.append("$restOf"); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
336 |
} |
26506
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
337 |
//it's ok to not copy the initCount, methodCount and clinitCount here, as codegen is what |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
338 |
//fills those out anyway. Thus no need for a copy constructor |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
26065
diff
changeset
|
339 |
final CompileUnit newUnit = compiler.createCompileUnit(sb.toString(), oldUnit.getWeight()); |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
25243
diff
changeset
|
340 |
log.fine("Creating new compile unit ", oldUnit, " => ", newUnit); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
341 |
map.put(oldUnit, newUnit); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
342 |
assert newUnit != null; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
343 |
newUnits.add(newUnit); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
344 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
345 |
|
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
25243
diff
changeset
|
346 |
log.fine("Replacing compile units in Compiler..."); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
347 |
compiler.replaceCompileUnits(newUnits); |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
25243
diff
changeset
|
348 |
log.fine("Done"); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
349 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
350 |
//replace old compile units in function nodes, if any are assigned, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
351 |
//for example by running the splitter on this function node in a previous |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
352 |
//partial code generation |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
353 |
final FunctionNode newFunctionNode = (FunctionNode)fn.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
354 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
355 |
public Node leaveFunctionNode(final FunctionNode node) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
356 |
final CompileUnit oldUnit = node.getCompileUnit(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
357 |
assert oldUnit != null : "no compile unit in function node"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
358 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
359 |
final CompileUnit newUnit = map.get(oldUnit); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
360 |
assert newUnit != null : "old unit has no mapping to new unit " + oldUnit; |
24725
7bb1f687a852
8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents:
24719
diff
changeset
|
361 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
362 |
log.fine("Replacing compile unit: ", oldUnit, " => ", newUnit, " in ", quote(node.getName())); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
363 |
return node.setCompileUnit(lc, newUnit).setState(lc, CompilationState.COMPILE_UNITS_REUSED); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
364 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
365 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
366 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
367 |
public Node leaveSplitNode(final SplitNode node) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
368 |
final CompileUnit oldUnit = node.getCompileUnit(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
369 |
assert oldUnit != null : "no compile unit in function node"; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
370 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
371 |
final CompileUnit newUnit = map.get(oldUnit); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
372 |
assert newUnit != null : "old unit has no mapping to new unit " + oldUnit; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
373 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
374 |
log.fine("Replacing compile unit: ", oldUnit, " => ", newUnit, " in ", quote(node.getName())); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
375 |
return node.setCompileUnit(lc, newUnit); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
376 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
377 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
378 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
379 |
public Node leaveLiteralNode(final LiteralNode<?> node) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
380 |
if (node instanceof ArrayLiteralNode) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
381 |
final ArrayLiteralNode aln = (ArrayLiteralNode)node; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
382 |
if (aln.getUnits() == null) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
383 |
return node; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
384 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
385 |
final List<ArrayUnit> newArrayUnits = new ArrayList<>(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
386 |
for (final ArrayUnit au : aln.getUnits()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
387 |
final CompileUnit newUnit = map.get(au.getCompileUnit()); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
388 |
assert newUnit != null; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
389 |
newArrayUnits.add(new ArrayUnit(newUnit, au.getLo(), au.getHi())); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
390 |
} |
25234
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24769
diff
changeset
|
391 |
return aln.setUnits(lc, newArrayUnits); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
392 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
393 |
return node; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
394 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
395 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
396 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
397 |
public Node leaveDefault(final Node node) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
398 |
return node.ensureUniqueLabels(lc); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
399 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
400 |
}); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
401 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
402 |
return newFunctionNode; |
24751 | 403 |
} |
404 |
||
405 |
@Override |
|
406 |
public String toString() { |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
407 |
return "'Reuse Compile Units'"; |
24751 | 408 |
} |
409 |
}, |
|
410 |
||
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
411 |
/** |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
412 |
* Bytecode generation: |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
413 |
* |
17233 | 414 |
* Generate the byte code class(es) resulting from the compiled FunctionNode |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
415 |
*/ |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
416 |
BYTECODE_GENERATION_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
417 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
418 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
419 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
420 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
421 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
422 |
BUILTINS_TRANSFORMED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
423 |
SPLIT, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
424 |
SYMBOLS_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
425 |
SCOPE_DEPTHS_COMPUTED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
426 |
OPTIMISTIC_TYPES_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
427 |
LOCAL_VARIABLE_TYPES_CALCULATED)) { |
24751 | 428 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
429 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
430 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
24764
722a9603b237
8043633: In order to remove global state outside of contexts, make sure Timing class is an instance and not a static global collection of data. Move into Context. Move -Dnashorn.timing to an official logging option.
lagergren
parents:
24759
diff
changeset
|
431 |
final ScriptEnvironment senv = compiler.getScriptEnvironment(); |
24751 | 432 |
|
17233 | 433 |
FunctionNode newFunctionNode = fn; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
434 |
|
26506
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
435 |
//root class is special, as it is bootstrapped from createProgramFunction, thus it's skipped |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
436 |
//in CodeGeneration - the rest can be used as a working "is compile unit used" metric |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
437 |
fn.getCompileUnit().setUsed(); |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
438 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
439 |
compiler.getLogger().fine("Starting bytecode generation for ", quote(fn.getName()), " - restOf=", phases.isRestOfCompilation()); |
26506
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
440 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
441 |
final CodeGenerator codegen = new CodeGenerator(compiler, phases.isRestOfCompilation() ? compiler.getContinuationEntryPoints() : null); |
26506
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
442 |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
443 |
try { |
25236
fac419f1e889
8046921: Deoptimization type information peristence
attila
parents:
25234
diff
changeset
|
444 |
// Explicitly set BYTECODE_GENERATED here; it can not be set in case of skipping codegen for :program |
fac419f1e889
8046921: Deoptimization type information peristence
attila
parents:
25234
diff
changeset
|
445 |
// in the lazy + optimistic world. See CodeGenerator.skipFunction(). |
fac419f1e889
8046921: Deoptimization type information peristence
attila
parents:
25234
diff
changeset
|
446 |
newFunctionNode = ((FunctionNode)newFunctionNode.accept(codegen)).setState(null, BYTECODE_GENERATED); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
447 |
codegen.generateScopeCalls(); |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
448 |
} catch (final VerifyError e) { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
449 |
if (senv._verify_code || senv._print_code) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
450 |
senv.getErr().println(e.getClass().getSimpleName() + ": " + e.getMessage()); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
451 |
if (senv._dump_on_error) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
452 |
e.printStackTrace(senv.getErr()); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
453 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
454 |
} else { |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
455 |
throw e; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
456 |
} |
24751 | 457 |
} catch (final Throwable e) { |
458 |
// Provide source file and line number being compiled when the assertion occurred |
|
459 |
throw new AssertionError("Failed generating bytecode for " + fn.getSourceName() + ":" + codegen.getLastLineNumber(), e); |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
460 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
461 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
462 |
for (final CompileUnit compileUnit : compiler.getCompileUnits()) { |
26506
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
463 |
final ClassEmitter classEmitter = compileUnit.getClassEmitter(); |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
464 |
classEmitter.end(); |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
465 |
|
26500
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
466 |
if (!compileUnit.isUsed()) { |
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
467 |
compiler.getLogger().fine("Skipping unused compile unit ", compileUnit); |
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
468 |
continue; |
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
469 |
} |
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
470 |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
471 |
final byte[] bytecode = classEmitter.toByteArray(); |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
472 |
assert bytecode != null; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
473 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
474 |
final String className = compileUnit.getUnitClassName(); |
26506
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
475 |
compiler.addClass(className, bytecode); //classes are only added to the bytecode map if compile unit is used |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
476 |
|
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
26500
diff
changeset
|
477 |
CompileUnit.increaseEmitCount(); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
478 |
|
17233 | 479 |
// should we verify the generated code? |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
480 |
if (senv._verify_code) { |
16262
75513555e603
8008731: Separate configuration environment (options, error/output writer etc.) from Context
sundar
parents:
16252
diff
changeset
|
481 |
compiler.getCodeInstaller().verify(bytecode); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
482 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
483 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
484 |
DumpBytecode.dumpBytecode(senv, compiler.getLogger(), bytecode, className); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
485 |
} |
17233 | 486 |
|
487 |
return newFunctionNode; |
|
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
488 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
489 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
490 |
@Override |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
491 |
public String toString() { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
492 |
return "'Bytecode Generation'"; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
493 |
} |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
494 |
}, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
495 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
496 |
INSTALL_PHASE( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
497 |
EnumSet.of( |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
498 |
INITIALIZED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
499 |
PARSED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
500 |
CONSTANT_FOLDED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
501 |
LOWERED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
502 |
BUILTINS_TRANSFORMED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
503 |
SPLIT, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
504 |
SYMBOLS_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
505 |
SCOPE_DEPTHS_COMPUTED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
506 |
OPTIMISTIC_TYPES_ASSIGNED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
507 |
LOCAL_VARIABLE_TYPES_CALCULATED, |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
508 |
BYTECODE_GENERATED)) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
509 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
510 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
511 |
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
512 |
final DebugLogger log = compiler.getLogger(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
513 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
514 |
final Map<String, Class<?>> installedClasses = new LinkedHashMap<>(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
515 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
516 |
boolean first = true; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
517 |
Class<?> rootClass = null; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
518 |
long length = 0L; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
519 |
|
25243
7a1edca6ce94
8048079: Persistent code store is broken after optimistic types merge
hannesw
parents:
25236
diff
changeset
|
520 |
final CodeInstaller<ScriptEnvironment> codeInstaller = compiler.getCodeInstaller(); |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
521 |
final Map<String, byte[]> bytecode = compiler.getBytecode(); |
24769 | 522 |
|
523 |
for (final Entry<String, byte[]> entry : bytecode.entrySet()) { |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
524 |
final String className = entry.getKey(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
525 |
//assert !first || className.equals(compiler.getFirstCompileUnit().getUnitClassName()) : "first=" + first + " className=" + className + " != " + compiler.getFirstCompileUnit().getUnitClassName(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
526 |
final byte[] code = entry.getValue(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
527 |
length += code.length; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
528 |
|
24769 | 529 |
final Class<?> clazz = codeInstaller.install(className, code); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
530 |
if (first) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
531 |
rootClass = clazz; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
532 |
first = false; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
533 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
534 |
installedClasses.put(className, clazz); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
535 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
536 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
537 |
if (rootClass == null) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
538 |
throw new CompilationException("Internal compiler error: root class not found!"); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
539 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
540 |
|
24766
7b54e2362c6c
8043632: Parallelize class installation and various script fixes.
lagergren
parents:
24764
diff
changeset
|
541 |
final Object[] constants = compiler.getConstantData().toArray(); |
24769 | 542 |
codeInstaller.initialize(installedClasses.values(), compiler.getSource(), constants); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
543 |
|
25243
7a1edca6ce94
8048079: Persistent code store is broken after optimistic types merge
hannesw
parents:
25236
diff
changeset
|
544 |
// initialize transient fields on recompilable script function data |
24769 | 545 |
for (final Object constant: constants) { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
546 |
if (constant instanceof RecompilableScriptFunctionData) { |
25243
7a1edca6ce94
8048079: Persistent code store is broken after optimistic types merge
hannesw
parents:
25236
diff
changeset
|
547 |
((RecompilableScriptFunctionData)constant).initTransients(compiler.getSource(), codeInstaller); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
548 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
549 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
550 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
551 |
// initialize function in the compile units |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
552 |
for (final CompileUnit unit : compiler.getCompileUnits()) { |
26500
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
553 |
if (!unit.isUsed()) { |
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
554 |
continue; |
85ea77a73bb8
8057588: Lots of trivial (empty) classes were generated by the Nashorn compiler as part of restOf-method generation
lagergren
parents:
26250
diff
changeset
|
555 |
} |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
556 |
unit.setCode(installedClasses.get(unit.getUnitClassName())); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
557 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
558 |
|
24769 | 559 |
if (!compiler.isOnDemandCompilation()) { |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
560 |
// Initialize functions |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
561 |
final Map<Integer, FunctionInitializer> initializers = compiler.getFunctionInitializers(); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
562 |
if (initializers != null) { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
563 |
for (final Entry<Integer, FunctionInitializer> entry : initializers.entrySet()) { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
564 |
final FunctionInitializer initializer = entry.getValue(); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
565 |
initializer.setCode(installedClasses.get(initializer.getClassName())); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
566 |
compiler.getScriptFunctionData(entry.getKey()).initializeCode(initializer); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
567 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
25821
diff
changeset
|
568 |
} |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
569 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
570 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
571 |
if (log.isEnabled()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
572 |
final StringBuilder sb = new StringBuilder(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
573 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
574 |
sb.append("Installed class '"). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
575 |
append(rootClass.getSimpleName()). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
576 |
append('\''). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
577 |
append(" ["). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
578 |
append(rootClass.getName()). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
579 |
append(", size="). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
580 |
append(length). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
581 |
append(" bytes, "). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
582 |
append(compiler.getCompileUnits().size()). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
583 |
append(" compile unit(s)]"); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
584 |
|
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
25243
diff
changeset
|
585 |
log.fine(sb.toString()); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
586 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
587 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
588 |
return setStates(fn.setRootClass(null, rootClass), BYTECODE_INSTALLED); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
589 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
590 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
591 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
592 |
public String toString() { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
593 |
return "'Class Installation'"; |
24766
7b54e2362c6c
8043632: Parallelize class installation and various script fixes.
lagergren
parents:
24764
diff
changeset
|
594 |
} |
7b54e2362c6c
8043632: Parallelize class installation and various script fixes.
lagergren
parents:
24764
diff
changeset
|
595 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
596 |
}; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
597 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
598 |
/** pre conditions required for function node to which this transform is to be applied */ |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
599 |
private final EnumSet<CompilationState> pre; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
600 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
601 |
/** start time of transform - used for timing, see {@link jdk.nashorn.internal.runtime.Timing} */ |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
602 |
private long startTime; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
603 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
604 |
/** start time of transform - used for timing, see {@link jdk.nashorn.internal.runtime.Timing} */ |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
605 |
private long endTime; |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
606 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
607 |
/** boolean that is true upon transform completion */ |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
608 |
private boolean isFinished; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
609 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
610 |
private CompilationPhase(final EnumSet<CompilationState> pre) { |
16523
af8b30edebce
8009718: Lazy execution architecture continued - ScriptFunctionData is either final or recompilable. Moved ScriptFunctionData creation logic away from runtime to compile time. Prepared for method generation/specialization. Got rid of ScriptFunctionImplTrampoline whose semantics could be done as part of the relinking anyway. Merge with the lookup package change.
lagergren
parents:
16262
diff
changeset
|
611 |
this.pre = pre; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
612 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
613 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
614 |
private static FunctionNode setStates(final FunctionNode functionNode, final CompilationState state) { |
26250
84bbd0e8b2b2
8056025: CompilationPhase.setStates() is hot in class installation phase
attila
parents:
26246
diff
changeset
|
615 |
if (!AssertsEnabled.assertsEnabled()) { |
84bbd0e8b2b2
8056025: CompilationPhase.setStates() is hot in class installation phase
attila
parents:
26246
diff
changeset
|
616 |
return functionNode; |
84bbd0e8b2b2
8056025: CompilationPhase.setStates() is hot in class installation phase
attila
parents:
26246
diff
changeset
|
617 |
} |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
618 |
return (FunctionNode)functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
619 |
@Override |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
620 |
public Node leaveFunctionNode(final FunctionNode fn) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
621 |
return fn.setState(lc, state); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
622 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
623 |
}); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
624 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
625 |
|
24719 | 626 |
/** |
627 |
* Start a compilation phase |
|
26886
18c744ab4df2
8059211: Changed ArrayData.length accessor to use the protected field and fixed javadoc warnings related to this
lagergren
parents:
26506
diff
changeset
|
628 |
* @param compiler the compiler to use |
24719 | 629 |
* @param functionNode function to compile |
630 |
* @return function node |
|
631 |
*/ |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
632 |
protected FunctionNode begin(final Compiler compiler, final FunctionNode functionNode) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
633 |
compiler.getLogger().indent(); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
634 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
635 |
assert pre != null; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
636 |
|
26250
84bbd0e8b2b2
8056025: CompilationPhase.setStates() is hot in class installation phase
attila
parents:
26246
diff
changeset
|
637 |
if (!functionNode.hasState(pre)) { |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
638 |
final StringBuilder sb = new StringBuilder("Compilation phase "); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
639 |
sb.append(this). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
640 |
append(" is not applicable to "). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
641 |
append(quote(functionNode.getName())). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
642 |
append("\n\tFunctionNode state = "). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
643 |
append(functionNode.getState()). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
644 |
append("\n\tRequired state = "). |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
645 |
append(this.pre); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
646 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
647 |
throw new CompilationException(sb.toString()); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
648 |
} |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
649 |
|
26246 | 650 |
startTime = System.nanoTime(); |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
651 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
652 |
return functionNode; |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
653 |
} |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
654 |
|
24719 | 655 |
/** |
656 |
* End a compilation phase |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
657 |
* @param compiler the compiler |
24719 | 658 |
* @param functionNode function node to compile |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
659 |
* @return function node |
24719 | 660 |
*/ |
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
661 |
protected FunctionNode end(final Compiler compiler, final FunctionNode functionNode) { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
662 |
compiler.getLogger().unindent(); |
26246 | 663 |
endTime = System.nanoTime(); |
24764
722a9603b237
8043633: In order to remove global state outside of contexts, make sure Timing class is an instance and not a static global collection of data. Move into Context. Move -Dnashorn.timing to an official logging option.
lagergren
parents:
24759
diff
changeset
|
664 |
compiler.getScriptEnvironment()._timing.accumulateTime(toString(), endTime - startTime); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
665 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
666 |
isFinished = true; |
17233 | 667 |
return functionNode; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
668 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
669 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
670 |
boolean isFinished() { |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
671 |
return isFinished; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
672 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
673 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
674 |
long getStartTime() { |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
675 |
return startTime; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
676 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
677 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
678 |
long getEndTime() { |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
679 |
return endTime; |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
680 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
681 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
682 |
abstract FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode functionNode) throws CompilationException; |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
683 |
|
24759
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
684 |
/** |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
685 |
* Apply a transform to a function node, returning the transfored function node. If the transform is not |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
686 |
* applicable, an exception is thrown. Every transform requires the function to have a certain number of |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
687 |
* states to operate. It can have more states set, but not fewer. The state list, i.e. the constructor |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
688 |
* arguments to any of the CompilationPhase enum entries, is a set of REQUIRED states. |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
689 |
* |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
690 |
* @param compiler compiler |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
691 |
* @param phases current complete pipeline of which this phase is one |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
692 |
* @param functionNode function node to transform |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
693 |
* |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
694 |
* @return transformed function node |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
695 |
* |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
696 |
* @throws CompilationException if function node lacks the state required to run the transform on it |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
697 |
*/ |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
698 |
final FunctionNode apply(final Compiler compiler, final CompilationPhases phases, final FunctionNode functionNode) throws CompilationException { |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
699 |
assert phases.contains(this); |
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
700 |
|
31aed7d9c02a
8034206: Make parts of code pipeline reusable in order to facilitate faster warmup and faster lazy compilation.
lagergren
parents:
24754
diff
changeset
|
701 |
return end(compiler, transform(compiler, phases, begin(compiler, functionNode))); |
16233
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
702 |
} |
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
703 |
|
95d3e01c04c3
8008199: Lazy compilation and trampoline implementation
lagergren
parents:
diff
changeset
|
704 |
} |