author | attila |
Wed, 28 Jan 2015 17:58:08 +0100 | |
changeset 28690 | 78317797ab62 |
parent 27361 | 86c4ddb4797b |
child 29410 | cdfd8fbb2b1d |
permissions | -rw-r--r-- |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
1 |
/* |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
4 |
* |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
10 |
* |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
15 |
* accompanied this code). |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
16 |
* |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
20 |
* |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
23 |
* questions. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
24 |
*/ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
25 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
26 |
package jdk.nashorn.internal.codegen; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
27 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
28 |
import java.util.ArrayDeque; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
29 |
import java.util.Collection; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
30 |
import java.util.Collections; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
31 |
import java.util.Deque; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
32 |
import java.util.HashMap; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
33 |
import java.util.Map; |
24719 | 34 |
import jdk.nashorn.internal.IntDeque; |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
35 |
import jdk.nashorn.internal.codegen.types.Type; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
36 |
import jdk.nashorn.internal.ir.Block; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
37 |
import jdk.nashorn.internal.ir.FunctionNode; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
38 |
import jdk.nashorn.internal.ir.LexicalContext; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
39 |
import jdk.nashorn.internal.ir.LexicalContextNode; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
40 |
import jdk.nashorn.internal.ir.Node; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
41 |
import jdk.nashorn.internal.ir.Symbol; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
42 |
import jdk.nashorn.internal.ir.WithNode; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
43 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
44 |
/** |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
45 |
* A lexical context that also tracks if we have any dynamic scopes in the context. Such scopes can have new |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
46 |
* variables introduced into them at run time - a with block or a function directly containing an eval call. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
47 |
* Furthermore, this class keeps track of current discard state, which the current method emitter being used is, |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
48 |
* the current compile unit, and local variable indexes |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
49 |
*/ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
50 |
final class CodeGeneratorLexicalContext extends LexicalContext { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
51 |
private int dynamicScopeCount; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
52 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
53 |
/** Map of shared scope call sites */ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
54 |
private final Map<SharedScopeCall, SharedScopeCall> scopeCalls = new HashMap<>(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
55 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
56 |
/** Compile unit stack - every time we start a sub method (e.g. a split) we push one */ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
57 |
private final Deque<CompileUnit> compileUnits = new ArrayDeque<>(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
58 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
59 |
/** Method emitter stack - every time we start a sub method (e.g. a split) we push one */ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
60 |
private final Deque<MethodEmitter> methodEmitters = new ArrayDeque<>(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
61 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
62 |
/** The discard stack - whenever we enter a discard node we keep track of its return value status - |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
63 |
* i.e. should we keep it or throw it away */ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
64 |
private final Deque<Node> discard = new ArrayDeque<>(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
65 |
|
24719 | 66 |
private final Deque<Map<String, Collection<Label>>> unwarrantedOptimismHandlers = new ArrayDeque<>(); |
67 |
private final Deque<StringBuilder> slotTypesDescriptors = new ArrayDeque<>(); |
|
68 |
private final IntDeque splitNodes = new IntDeque(); |
|
69 |
||
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
70 |
/** A stack tracking the next free local variable slot in the blocks. There's one entry for every block |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
71 |
* currently on the lexical context stack. */ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
72 |
private int[] nextFreeSlots = new int[16]; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
73 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
74 |
/** size of next free slot vector */ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
75 |
private int nextFreeSlotsSize; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
76 |
|
28690 | 77 |
private boolean isWithBoundary(final Object node) { |
24749
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
78 |
return node instanceof Block && !isEmpty() && peek() instanceof WithNode; |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
79 |
} |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
80 |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
81 |
@Override |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
82 |
public <T extends LexicalContextNode> T push(final T node) { |
24749
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
83 |
if (isWithBoundary(node)) { |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
84 |
dynamicScopeCount++; |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
85 |
} else if (node instanceof FunctionNode) { |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
86 |
if (((FunctionNode)node).inDynamicContext()) { |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
87 |
dynamicScopeCount++; |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
88 |
} |
24719 | 89 |
splitNodes.push(0); |
90 |
} |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
91 |
return super.push(node); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
92 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
93 |
|
24719 | 94 |
void enterSplitNode() { |
95 |
splitNodes.getAndIncrement(); |
|
24751 | 96 |
pushFreeSlots(methodEmitters.peek().getUsedSlotsWithLiveTemporaries()); |
24719 | 97 |
} |
98 |
||
99 |
void exitSplitNode() { |
|
24751 | 100 |
final int count = splitNodes.decrementAndGet(); |
101 |
assert count >= 0; |
|
24719 | 102 |
} |
103 |
||
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
104 |
@Override |
28690 | 105 |
public <T extends Node> T pop(final T node) { |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
106 |
final T popped = super.pop(node); |
24749
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
107 |
if (isWithBoundary(node)) { |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
108 |
dynamicScopeCount--; |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
109 |
assert dynamicScopeCount >= 0; |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
110 |
} else if (node instanceof FunctionNode) { |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
111 |
if (((FunctionNode)node).inDynamicContext()) { |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
112 |
dynamicScopeCount--; |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
113 |
assert dynamicScopeCount >= 0; |
1549c85f8200
8041625: AccessorProperty currentType must only by Object.class when non-primitive, and scoping followup problem for lazily generated with bodies
lagergren
parents:
24719
diff
changeset
|
114 |
} |
24719 | 115 |
assert splitNodes.peek() == 0; |
116 |
splitNodes.pop(); |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
117 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
118 |
return popped; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
119 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
120 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
121 |
boolean inDynamicScope() { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
122 |
return dynamicScopeCount > 0; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
123 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
124 |
|
24719 | 125 |
boolean inSplitNode() { |
126 |
return !splitNodes.isEmpty() && splitNodes.peek() > 0; |
|
127 |
} |
|
128 |
||
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
129 |
MethodEmitter pushMethodEmitter(final MethodEmitter newMethod) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
130 |
methodEmitters.push(newMethod); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
131 |
return newMethod; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
132 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
133 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
134 |
MethodEmitter popMethodEmitter(final MethodEmitter oldMethod) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
135 |
assert methodEmitters.peek() == oldMethod; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
136 |
methodEmitters.pop(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
137 |
return methodEmitters.isEmpty() ? null : methodEmitters.peek(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
138 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
139 |
|
24719 | 140 |
void pushUnwarrantedOptimismHandlers() { |
141 |
unwarrantedOptimismHandlers.push(new HashMap<String, Collection<Label>>()); |
|
142 |
slotTypesDescriptors.push(new StringBuilder()); |
|
143 |
} |
|
144 |
||
145 |
Map<String, Collection<Label>> getUnwarrantedOptimismHandlers() { |
|
146 |
return unwarrantedOptimismHandlers.peek(); |
|
147 |
} |
|
148 |
||
149 |
Map<String, Collection<Label>> popUnwarrantedOptimismHandlers() { |
|
150 |
slotTypesDescriptors.pop(); |
|
151 |
return unwarrantedOptimismHandlers.pop(); |
|
152 |
} |
|
153 |
||
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
154 |
CompileUnit pushCompileUnit(final CompileUnit newUnit) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
155 |
compileUnits.push(newUnit); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
156 |
return newUnit; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
157 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
158 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
159 |
CompileUnit popCompileUnit(final CompileUnit oldUnit) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
160 |
assert compileUnits.peek() == oldUnit; |
26506
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
25865
diff
changeset
|
161 |
final CompileUnit unit = compileUnits.pop(); |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
25865
diff
changeset
|
162 |
assert unit.hasCode() : "compile unit popped without code"; |
7d55cc7fc301
8057703: More empty classes generated by Nashorn
lagergren
parents:
25865
diff
changeset
|
163 |
unit.setUsed(); |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
164 |
return compileUnits.isEmpty() ? null : compileUnits.peek(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
165 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
166 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
167 |
boolean hasCompileUnits() { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
168 |
return !compileUnits.isEmpty(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
169 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
170 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
171 |
Collection<SharedScopeCall> getScopeCalls() { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
172 |
return Collections.unmodifiableCollection(scopeCalls.values()); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
173 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
174 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
175 |
/** |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
176 |
* Get a shared static method representing a dynamic scope callsite. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
177 |
* |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
178 |
* @param unit current compile unit |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
179 |
* @param symbol the symbol |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
180 |
* @param valueType the value type of the symbol |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
181 |
* @param returnType the return type |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
182 |
* @param paramTypes the parameter types |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
183 |
* @param flags the callsite flags |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
184 |
* @return an object representing a shared scope call |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
185 |
*/ |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
186 |
SharedScopeCall getScopeCall(final CompileUnit unit, final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
187 |
final SharedScopeCall scopeCall = new SharedScopeCall(symbol, valueType, returnType, paramTypes, flags); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
188 |
if (scopeCalls.containsKey(scopeCall)) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
189 |
return scopeCalls.get(scopeCall); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
190 |
} |
22373 | 191 |
scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName(":scopeCall")); |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
192 |
scopeCalls.put(scopeCall, scopeCall); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
193 |
return scopeCall; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
194 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
195 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
196 |
/** |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
197 |
* Get a shared static method representing a dynamic scope get access. |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
198 |
* |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
199 |
* @param unit current compile unit |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
200 |
* @param symbol the symbol |
24719 | 201 |
* @param valueType the type of the variable |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
202 |
* @param flags the callsite flags |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
203 |
* @return an object representing a shared scope call |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
204 |
*/ |
24719 | 205 |
SharedScopeCall getScopeGet(final CompileUnit unit, final Symbol symbol, final Type valueType, final int flags) { |
206 |
return getScopeCall(unit, symbol, valueType, valueType, null, flags); |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
207 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
208 |
|
24751 | 209 |
void onEnterBlock(final Block block) { |
210 |
pushFreeSlots(assignSlots(block, isFunctionBody() ? 0 : getUsedSlotCount())); |
|
211 |
} |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
212 |
|
24751 | 213 |
private void pushFreeSlots(final int freeSlots) { |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
214 |
if (nextFreeSlotsSize == nextFreeSlots.length) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
215 |
final int[] newNextFreeSlots = new int[nextFreeSlotsSize * 2]; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
216 |
System.arraycopy(nextFreeSlots, 0, newNextFreeSlots, 0, nextFreeSlotsSize); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
217 |
nextFreeSlots = newNextFreeSlots; |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
218 |
} |
24751 | 219 |
nextFreeSlots[nextFreeSlotsSize++] = freeSlots; |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
220 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
221 |
|
24719 | 222 |
int getUsedSlotCount() { |
223 |
return nextFreeSlots[nextFreeSlotsSize - 1]; |
|
224 |
} |
|
225 |
||
24751 | 226 |
void releaseSlots() { |
24719 | 227 |
--nextFreeSlotsSize; |
24751 | 228 |
final int undefinedFromSlot = nextFreeSlotsSize == 0 ? 0 : nextFreeSlots[nextFreeSlotsSize - 1]; |
229 |
if(!slotTypesDescriptors.isEmpty()) { |
|
230 |
slotTypesDescriptors.peek().setLength(undefinedFromSlot); |
|
24719 | 231 |
} |
24751 | 232 |
methodEmitters.peek().undefineLocalVariables(undefinedFromSlot, false); |
24719 | 233 |
} |
234 |
||
235 |
private int assignSlots(final Block block, final int firstSlot) { |
|
24751 | 236 |
int fromSlot = firstSlot; |
237 |
final MethodEmitter method = methodEmitters.peek(); |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
238 |
for (final Symbol symbol : block.getSymbols()) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
239 |
if (symbol.hasSlot()) { |
24751 | 240 |
symbol.setFirstSlot(fromSlot); |
241 |
final int toSlot = fromSlot + symbol.slotCount(); |
|
242 |
method.defineBlockLocalVariable(fromSlot, toSlot); |
|
243 |
fromSlot = toSlot; |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
244 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
245 |
} |
24751 | 246 |
return fromSlot; |
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
247 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
248 |
|
24719 | 249 |
static Type getTypeForSlotDescriptor(final char typeDesc) { |
24751 | 250 |
// Recognizing both lowercase and uppercase as we're using both to signify symbol boundaries; see |
251 |
// MethodEmitter.markSymbolBoundariesInLvarTypesDescriptor(). |
|
27361 | 252 |
switch (typeDesc) { |
24751 | 253 |
case 'I': |
254 |
case 'i': |
|
24719 | 255 |
return Type.INT; |
24751 | 256 |
case 'J': |
257 |
case 'j': |
|
24719 | 258 |
return Type.LONG; |
24751 | 259 |
case 'D': |
260 |
case 'd': |
|
24719 | 261 |
return Type.NUMBER; |
24751 | 262 |
case 'A': |
263 |
case 'a': |
|
24719 | 264 |
return Type.OBJECT; |
24751 | 265 |
case 'U': |
266 |
case 'u': |
|
24719 | 267 |
return Type.UNKNOWN; |
24751 | 268 |
default: |
24719 | 269 |
throw new AssertionError(); |
270 |
} |
|
271 |
} |
|
272 |
||
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
273 |
void pushDiscard(final Node node) { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
274 |
discard.push(node); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
275 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
276 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
277 |
Node popDiscard() { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
278 |
return discard.pop(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
279 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
280 |
|
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
281 |
Node getCurrentDiscard() { |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
282 |
return discard.peek(); |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
283 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
284 |
|
24751 | 285 |
int quickSlot(final Type type) { |
286 |
return methodEmitters.peek().defineTemporaryLocalVariable(type.getSlots()); |
|
17769
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
287 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
288 |
} |
14ea7feaf658
8012522: Clean up lexical contexts - split out stack based functionality in CodeGenerator and generify NodeVisitors based on their LexicalContext type to avoid casts
lagergren
parents:
diff
changeset
|
289 |