mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Speed-up TeaVM compiler on large applications
This commit is contained in:
parent
93c7fb52b4
commit
fe2adc4675
|
@ -129,7 +129,7 @@ public class ServiceLoaderSupport implements Generator, DependencyListener {
|
||||||
method.getResult().propagate(agent.getType("[java.lang.Object"));
|
method.getResult().propagate(agent.getType("[java.lang.Object"));
|
||||||
allClassesNode.connect(method.getResult().getArrayItem());
|
allClassesNode.connect(method.getResult().getArrayItem());
|
||||||
method.getResult().getArrayItem().addConsumer(new DependencyConsumer() {
|
method.getResult().getArrayItem().addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
initConstructor(agent, type.getName(), location);
|
initConstructor(agent, type.getName(), location);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
|
||||||
|
|
||||||
private void achieveGetLength(final DependencyAgent agent, final MethodDependency method) {
|
private void achieveGetLength(final DependencyAgent agent, final MethodDependency method) {
|
||||||
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
if (!type.getName().startsWith("[")) {
|
if (!type.getName().startsWith("[")) {
|
||||||
MethodReference cons = new MethodReference(IllegalArgumentException.class, "<init>", void.class);
|
MethodReference cons = new MethodReference(IllegalArgumentException.class, "<init>", void.class);
|
||||||
agent.linkMethod(cons, null).use();
|
agent.linkMethod(cons, null).use();
|
||||||
|
@ -128,7 +128,7 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
|
||||||
private void achieveGet(final DependencyAgent agent, final MethodDependency method) {
|
private void achieveGet(final DependencyAgent agent, final MethodDependency method) {
|
||||||
method.getVariable(1).getArrayItem().connect(method.getResult());
|
method.getVariable(1).getArrayItem().connect(method.getResult());
|
||||||
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
method.getVariable(1).addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
if (type.getName().startsWith("[")) {
|
if (type.getName().startsWith("[")) {
|
||||||
String typeName = type.getName().substring(1);
|
String typeName = type.getName().substring(1);
|
||||||
for (int i = 0; i < primitiveTypes.length; ++i) {
|
for (int i = 0; i < primitiveTypes.length; ++i) {
|
||||||
|
|
|
@ -71,7 +71,15 @@ public final class FileNameEncoder {
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
String str = sb.toString();
|
||||||
|
sb.setLength(0);
|
||||||
|
for (int i = 0; i < str.length(); i += 100) {
|
||||||
|
if (i > 0) {
|
||||||
|
sb.append('/');
|
||||||
|
}
|
||||||
|
int j = Math.min(i + 100, str.length());
|
||||||
|
sb.append(str.substring(i, j));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.dependency;
|
package org.teavm.dependency;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import org.teavm.callgraph.CallGraph;
|
||||||
import org.teavm.common.ServiceRepository;
|
import org.teavm.common.ServiceRepository;
|
||||||
import org.teavm.diagnostics.Diagnostics;
|
import org.teavm.diagnostics.Diagnostics;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
|
@ -23,20 +25,97 @@ import org.teavm.model.*;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface DependencyAgent extends DependencyInfo, ServiceRepository {
|
public class DependencyAgent implements DependencyInfo, ServiceRepository {
|
||||||
DependencyNode createNode();
|
private DependencyChecker checker;
|
||||||
|
|
||||||
DependencyAgentType getType(String name);
|
DependencyAgent(DependencyChecker checker) {
|
||||||
|
this.checker = checker;
|
||||||
|
}
|
||||||
|
|
||||||
String generateClassName();
|
public DependencyNode createNode() {
|
||||||
|
return checker.createNode();
|
||||||
|
}
|
||||||
|
|
||||||
void submitClass(ClassHolder cls);
|
public DependencyType getType(String name) {
|
||||||
|
return checker.getType(name);
|
||||||
|
}
|
||||||
|
|
||||||
MethodDependency linkMethod(MethodReference methodRef, CallLocation callLocation);
|
public String generateClassName() {
|
||||||
|
return checker.generateClassName();
|
||||||
|
}
|
||||||
|
|
||||||
ClassDependency linkClass(String className, CallLocation callLocation);
|
public void submitClass(ClassHolder cls) {
|
||||||
|
checker.submitClass(cls);
|
||||||
|
}
|
||||||
|
|
||||||
FieldDependency linkField(FieldReference fieldRef, CallLocation callLocation);
|
public MethodDependency linkMethod(MethodReference methodRef, CallLocation callLocation) {
|
||||||
|
return checker.linkMethod(methodRef, callLocation);
|
||||||
|
}
|
||||||
|
|
||||||
Diagnostics getDiagnostics();
|
public ClassDependency linkClass(String className, CallLocation callLocation) {
|
||||||
|
return checker.linkClass(className, callLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldDependency linkField(FieldReference fieldRef, CallLocation callLocation) {
|
||||||
|
return checker.linkField(fieldRef, callLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Diagnostics getDiagnostics() {
|
||||||
|
return checker.getDiagnostics();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T getService(Class<T> type) {
|
||||||
|
return checker.getService(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassReaderSource getClassSource() {
|
||||||
|
return checker.getClassSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassLoader getClassLoader() {
|
||||||
|
return checker.getClassLoader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<MethodReference> getAchievableMethods() {
|
||||||
|
return checker.getAchievableMethods();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<FieldReference> getAchievableFields() {
|
||||||
|
return checker.getAchievableFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> getAchievableClasses() {
|
||||||
|
return checker.getAchievableClasses();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FieldDependencyInfo getField(FieldReference fieldRef) {
|
||||||
|
return checker.getField(fieldRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MethodDependencyInfo getMethod(MethodReference methodRef) {
|
||||||
|
return checker.getMethod(methodRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MethodDependencyInfo getMethodImplementation(MethodReference methodRef) {
|
||||||
|
return checker.getMethodImplementation(methodRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassDependencyInfo getClass(String className) {
|
||||||
|
return checker.getClass(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CallGraph getCallGraph() {
|
||||||
|
return checker.getCallGraph();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2014 Alexey Andreev.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.teavm.dependency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public interface DependencyAgentType {
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
DependencyAgent getDependencyAgent();
|
|
||||||
}
|
|
|
@ -48,7 +48,7 @@ import org.teavm.model.util.ModelUtils;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
public class DependencyChecker implements DependencyInfo {
|
||||||
static final boolean shouldLog = System.getProperty("org.teavm.logDependencies", "false").equals("true");
|
static final boolean shouldLog = System.getProperty("org.teavm.logDependencies", "false").equals("true");
|
||||||
private int classNameSuffix;
|
private int classNameSuffix;
|
||||||
private DependencyClassSource classSource;
|
private DependencyClassSource classSource;
|
||||||
|
@ -67,6 +67,7 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
private boolean interrupted;
|
private boolean interrupted;
|
||||||
private Diagnostics diagnostics;
|
private Diagnostics diagnostics;
|
||||||
DefaultCallGraph callGraph = new DefaultCallGraph();
|
DefaultCallGraph callGraph = new DefaultCallGraph();
|
||||||
|
private DependencyAgent agent;
|
||||||
|
|
||||||
public DependencyChecker(ClassReaderSource classSource, ClassLoader classLoader, ServiceRepository services,
|
public DependencyChecker(ClassReaderSource classSource, ClassLoader classLoader, ServiceRepository services,
|
||||||
Diagnostics diagnostics) {
|
Diagnostics diagnostics) {
|
||||||
|
@ -108,6 +109,12 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
return createClassDependency(preimage);
|
return createClassDependency(preimage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
agent = new DependencyAgent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DependencyAgent getAgent() {
|
||||||
|
return agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DependencyCheckerInterruptor getInterruptor() {
|
public DependencyCheckerInterruptor getInterruptor() {
|
||||||
|
@ -122,7 +129,6 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
return interrupted;
|
return interrupted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DependencyType getType(String name) {
|
public DependencyType getType(String name) {
|
||||||
DependencyType type = typeMap.get(name);
|
DependencyType type = typeMap.get(name);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
|
@ -133,7 +139,6 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DependencyNode createNode() {
|
public DependencyNode createNode() {
|
||||||
return new DependencyNode(this);
|
return new DependencyNode(this);
|
||||||
}
|
}
|
||||||
|
@ -148,19 +153,17 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
return classLoader;
|
return classLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String generateClassName() {
|
public String generateClassName() {
|
||||||
return "$$teavm_generated_class$$" + classNameSuffix++;
|
return "$$teavm_generated_class$$" + classNameSuffix++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submitClass(ClassHolder cls) {
|
public void submitClass(ClassHolder cls) {
|
||||||
classSource.submit(ModelUtils.copyClass(cls));
|
classSource.submit(ModelUtils.copyClass(cls));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDependencyListener(DependencyListener listener) {
|
public void addDependencyListener(DependencyListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
listener.started(this);
|
listener.started(agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addClassTransformer(ClassHolderTransformer transformer) {
|
public void addClassTransformer(ClassHolderTransformer transformer) {
|
||||||
|
@ -199,7 +202,6 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ClassDependency linkClass(String className, CallLocation callLocation) {
|
public ClassDependency linkClass(String className, CallLocation callLocation) {
|
||||||
ClassDependency dep = classCache.map(className);
|
ClassDependency dep = classCache.map(className);
|
||||||
boolean added = true;
|
boolean added = true;
|
||||||
|
@ -211,7 +213,7 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
}
|
}
|
||||||
if (!dep.isMissing() && added) {
|
if (!dep.isMissing() && added) {
|
||||||
for (DependencyListener listener : listeners) {
|
for (DependencyListener listener : listeners) {
|
||||||
listener.classAchieved(DependencyChecker.this, className, callLocation);
|
listener.classAchieved(agent, className, callLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dep;
|
return dep;
|
||||||
|
@ -247,7 +249,6 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
return dependency;
|
return dependency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MethodDependency linkMethod(MethodReference methodRef, CallLocation callLocation) {
|
public MethodDependency linkMethod(MethodReference methodRef, CallLocation callLocation) {
|
||||||
if (methodRef == null) {
|
if (methodRef == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
@ -265,7 +266,7 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
MethodDependency graph = methodCache.map(methodRef);
|
MethodDependency graph = methodCache.map(methodRef);
|
||||||
if (!graph.isMissing() && added) {
|
if (!graph.isMissing() && added) {
|
||||||
for (DependencyListener listener : listeners) {
|
for (DependencyListener listener : listeners) {
|
||||||
listener.methodAchieved(this, graph, callLocation);
|
listener.methodAchieved(agent, graph, callLocation);
|
||||||
}
|
}
|
||||||
activateDependencyPlugin(graph, callLocation);
|
activateDependencyPlugin(graph, callLocation);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +393,6 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
return classCache.getCachedPreimages();
|
return classCache.getCachedPreimages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDependency linkField(final FieldReference fieldRef, final CallLocation location) {
|
public FieldDependency linkField(final FieldReference fieldRef, final CallLocation location) {
|
||||||
boolean added = true;
|
boolean added = true;
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
@ -408,7 +408,7 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
}
|
}
|
||||||
if (!dep.isMissing() && added) {
|
if (!dep.isMissing() && added) {
|
||||||
for (DependencyListener listener : listeners) {
|
for (DependencyListener listener : listeners) {
|
||||||
listener.fieldAchieved(DependencyChecker.this, dep, location);
|
listener.fieldAchieved(agent, dep, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dep;
|
return dep;
|
||||||
|
@ -443,7 +443,7 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
private void activateDependencyPlugin(MethodDependency methodDep, CallLocation location) {
|
private void activateDependencyPlugin(MethodDependency methodDep, CallLocation location) {
|
||||||
attachDependencyPlugin(methodDep);
|
attachDependencyPlugin(methodDep);
|
||||||
if (methodDep.dependencyPlugin != null) {
|
if (methodDep.dependencyPlugin != null) {
|
||||||
methodDep.dependencyPlugin.methodAchieved(this, methodDep, location);
|
methodDep.dependencyPlugin.methodAchieved(agent, methodDep, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,12 +497,10 @@ public class DependencyChecker implements DependencyInfo, DependencyAgent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T getService(Class<T> type) {
|
public <T> T getService(Class<T> type) {
|
||||||
return services.getService(type);
|
return services.getService(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Diagnostics getDiagnostics() {
|
public Diagnostics getDiagnostics() {
|
||||||
return diagnostics;
|
return diagnostics;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,5 +20,5 @@ package org.teavm.dependency;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface DependencyConsumer {
|
public interface DependencyConsumer {
|
||||||
void consume(DependencyAgentType type);
|
void consume(DependencyType type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ class DependencyGraphBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void consume(DependencyAgentType type) {
|
public void consume(DependencyType type) {
|
||||||
for (int i = 0; i < exceptions.length; ++i) {
|
for (int i = 0; i < exceptions.length; ++i) {
|
||||||
if (exceptions[i] == null || isAssignableFrom(checker.getClassSource(), exceptions[i],
|
if (exceptions[i] == null || isAssignableFrom(checker.getClassSource(), exceptions[i],
|
||||||
type.getName())) {
|
type.getName())) {
|
||||||
|
@ -139,7 +139,7 @@ class DependencyGraphBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void consume(DependencyAgentType type) {
|
public void consume(DependencyType type) {
|
||||||
String className = type.getName();
|
String className = type.getName();
|
||||||
if (DependencyChecker.shouldLog) {
|
if (DependencyChecker.shouldLog) {
|
||||||
System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". " +
|
System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". " +
|
||||||
|
@ -262,7 +262,7 @@ class DependencyGraphBuilder {
|
||||||
final ClassReader targetClass = dependencyChecker.getClassSource().get(targetClsName);
|
final ClassReader targetClass = dependencyChecker.getClassSource().get(targetClsName);
|
||||||
if (targetClass != null) {
|
if (targetClass != null) {
|
||||||
valueNode.connect(receiverNode, new DependencyTypeFilter() {
|
valueNode.connect(receiverNode, new DependencyTypeFilter() {
|
||||||
@Override public boolean match(DependencyAgentType type) {
|
@Override public boolean match(DependencyType type) {
|
||||||
if (targetClass.getName().equals("java.lang.Object")) {
|
if (targetClass.getName().equals("java.lang.Object")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ class DependencyGraphBuilder {
|
||||||
DependencyNode arrayNode = nodes[array.getIndex()];
|
DependencyNode arrayNode = nodes[array.getIndex()];
|
||||||
final DependencyNode receiverNode = nodes[receiver.getIndex()];
|
final DependencyNode receiverNode = nodes[receiver.getIndex()];
|
||||||
arrayNode.addConsumer(new DependencyConsumer() {
|
arrayNode.addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
receiverNode.propagate(type);
|
receiverNode.propagate(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,11 +39,7 @@ public class DependencyNode implements ValueDependencyInfo {
|
||||||
this.degree = degree;
|
this.degree = degree;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propagate(DependencyAgentType agentType) {
|
public void propagate(DependencyType type) {
|
||||||
if (!(agentType instanceof DependencyType)) {
|
|
||||||
throw new IllegalArgumentException("The given type does not belong to the same dependency checker");
|
|
||||||
}
|
|
||||||
DependencyType type = (DependencyType)agentType;
|
|
||||||
if (type.getDependencyChecker() != dependencyChecker) {
|
if (type.getDependencyChecker() != dependencyChecker) {
|
||||||
throw new IllegalArgumentException("The given type does not belong to the same dependency checker");
|
throw new IllegalArgumentException("The given type does not belong to the same dependency checker");
|
||||||
}
|
}
|
||||||
|
@ -61,15 +57,11 @@ public class DependencyNode implements ValueDependencyInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propagate(DependencyAgentType[] agentTypes) {
|
public void propagate(DependencyType[] agentTypes) {
|
||||||
DependencyType[] types = new DependencyType[agentTypes.length];
|
DependencyType[] types = new DependencyType[agentTypes.length];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < agentTypes.length; ++i) {
|
for (int i = 0; i < agentTypes.length; ++i) {
|
||||||
DependencyAgentType agentType = agentTypes[i];
|
DependencyType type = agentTypes[i];
|
||||||
if (!(agentType instanceof DependencyType)) {
|
|
||||||
throw new IllegalArgumentException("The given type does not belong to the same dependency checker");
|
|
||||||
}
|
|
||||||
DependencyType type = (DependencyType)agentType;
|
|
||||||
if (type.getDependencyChecker() != dependencyChecker) {
|
if (type.getDependencyChecker() != dependencyChecker) {
|
||||||
throw new IllegalArgumentException("The given type does not belong to the same dependency checker");
|
throw new IllegalArgumentException("The given type does not belong to the same dependency checker");
|
||||||
}
|
}
|
||||||
|
@ -121,7 +113,7 @@ public class DependencyNode implements ValueDependencyInfo {
|
||||||
arrayItemNode.tag = tag + "[";
|
arrayItemNode.tag = tag + "[";
|
||||||
}
|
}
|
||||||
arrayItemNode.addConsumer(new DependencyConsumer() {
|
arrayItemNode.addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
DependencyNode.this.propagate(type);
|
DependencyNode.this.propagate(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -134,12 +126,8 @@ public class DependencyNode implements ValueDependencyInfo {
|
||||||
return arrayItemNode != null && arrayItemNode.types.isEmpty();
|
return arrayItemNode != null && arrayItemNode.types.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasType(DependencyAgentType type) {
|
public boolean hasType(DependencyType type) {
|
||||||
if (!(type instanceof DependencyType)) {
|
return type.getDependencyChecker() == dependencyChecker && types.get(type.index);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DependencyType typeImpl = (DependencyType)type;
|
|
||||||
return typeImpl.getDependencyChecker() == dependencyChecker && types.get(typeImpl.index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,7 @@ class DependencyNodeToNodeTransition implements DependencyConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void consume(DependencyAgentType type) {
|
public void consume(DependencyType type) {
|
||||||
if (filter != null && !filter.match(type)) {
|
if (filter != null && !filter.match(type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.teavm.dependency;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class DependencyType implements DependencyAgentType {
|
public class DependencyType {
|
||||||
private DependencyChecker dependencyChecker;
|
private DependencyChecker dependencyChecker;
|
||||||
private String name;
|
private String name;
|
||||||
int index;
|
int index;
|
||||||
|
@ -30,17 +30,15 @@ public class DependencyType implements DependencyAgentType {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DependencyChecker getDependencyChecker() {
|
DependencyChecker getDependencyChecker() {
|
||||||
return dependencyChecker;
|
return dependencyChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DependencyAgent getDependencyAgent() {
|
public DependencyAgent getDependencyAgent() {
|
||||||
return dependencyChecker;
|
return dependencyChecker.getAgent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,5 +20,5 @@ package org.teavm.dependency;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface DependencyTypeFilter {
|
public interface DependencyTypeFilter {
|
||||||
boolean match(DependencyAgentType type);
|
boolean match(DependencyType type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class MethodDependency implements MethodDependencyInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DependencyAgent getDependencyAgent() {
|
public DependencyAgent getDependencyAgent() {
|
||||||
return dependencyChecker;
|
return dependencyChecker.getAgent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -240,7 +240,8 @@ public class TeaVMTool {
|
||||||
}
|
}
|
||||||
vmBuilder.setClassLoader(classLoader).setClassSource(cachedClassSource);
|
vmBuilder.setClassLoader(classLoader).setClassSource(cachedClassSource);
|
||||||
} else {
|
} else {
|
||||||
vmBuilder.setClassLoader(classLoader).setClassSource(new ClasspathClassHolderSource(classLoader));
|
vmBuilder.setClassLoader(classLoader).setClassSource(new PreOptimizingClassHolderSource(
|
||||||
|
new ClasspathClassHolderSource(classLoader)));
|
||||||
}
|
}
|
||||||
vm = vmBuilder.build();
|
vm = vmBuilder.build();
|
||||||
if (progressListener != null) {
|
if (progressListener != null) {
|
||||||
|
|
|
@ -20,22 +20,8 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.java.html.js.JavaScriptBody;
|
import net.java.html.js.JavaScriptBody;
|
||||||
import org.teavm.dependency.DependencyAgent;
|
import org.teavm.dependency.*;
|
||||||
import org.teavm.dependency.DependencyAgentType;
|
import org.teavm.model.*;
|
||||||
import org.teavm.dependency.DependencyConsumer;
|
|
||||||
import org.teavm.dependency.DependencyListener;
|
|
||||||
import org.teavm.dependency.DependencyNode;
|
|
||||||
import org.teavm.dependency.FieldDependency;
|
|
||||||
import org.teavm.dependency.MethodDependency;
|
|
||||||
import org.teavm.model.AnnotationReader;
|
|
||||||
import org.teavm.model.AnnotationValue;
|
|
||||||
import org.teavm.model.CallLocation;
|
|
||||||
import org.teavm.model.ClassReader;
|
|
||||||
import org.teavm.model.ClassReaderSource;
|
|
||||||
import org.teavm.model.ElementModifier;
|
|
||||||
import org.teavm.model.MethodDescriptor;
|
|
||||||
import org.teavm.model.MethodReader;
|
|
||||||
import org.teavm.model.MethodReference;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -56,7 +42,7 @@ public class JavaScriptBodyDependency implements DependencyListener {
|
||||||
public OneDirectionalConnection(DependencyNode target) {
|
public OneDirectionalConnection(DependencyNode target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
target.propagate(type);
|
target.propagate(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +176,7 @@ public class JavaScriptBodyDependency implements DependencyListener {
|
||||||
this.caller = caller;
|
this.caller = caller;
|
||||||
this.superClass = agent.getClassSource().get(superMethod.getOwnerName());
|
this.superClass = agent.getClassSource().get(superMethod.getOwnerName());
|
||||||
}
|
}
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
if (!isAssignableFrom(superClass, type.getName())) {
|
if (!isAssignableFrom(superClass, type.getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class JSNativeGenerator implements Injector, DependencyPlugin {
|
||||||
case "function":
|
case "function":
|
||||||
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
|
for (int i = 0; i < method.getReference().parameterCount(); ++i) {
|
||||||
method.getVariable(i).addConsumer(new DependencyConsumer() {
|
method.getVariable(i).addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
achieveFunctorMethods(agent, type.getName(), method);
|
achieveFunctorMethods(agent, type.getName(), method);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class ClassLookupDependencySupport implements DependencyListener {
|
||||||
MethodReference ref = method.getReference();
|
MethodReference ref = method.getReference();
|
||||||
if (ref.getClassName().equals(Platform.class.getName()) && ref.getName().equals("lookupClass")) {
|
if (ref.getClassName().equals(Platform.class.getName()) && ref.getName().equals("lookupClass")) {
|
||||||
allClasses.addConsumer(new DependencyConsumer() {
|
allClasses.addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
ClassReader cls = agent.getClassSource().get(type.getName());
|
ClassReader cls = agent.getClassSource().get(type.getName());
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class EnumDependencySupport implements DependencyListener {
|
||||||
allEnums.connect(method.getResult().getArrayItem());
|
allEnums.connect(method.getResult().getArrayItem());
|
||||||
final MethodReference ref = method.getReference();
|
final MethodReference ref = method.getReference();
|
||||||
allEnums.addConsumer(new DependencyConsumer() {
|
allEnums.addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
ClassReader cls = agent.getClassSource().get(type.getName());
|
ClassReader cls = agent.getClassSource().get(type.getName());
|
||||||
MethodReader method = cls.getMethod(new MethodDescriptor("values",
|
MethodReader method = cls.getMethod(new MethodDescriptor("values",
|
||||||
ValueType.arrayOf(ValueType.object(cls.getName()))));
|
ValueType.arrayOf(ValueType.object(cls.getName()))));
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class NewInstanceDependencySupport implements DependencyListener {
|
||||||
allClassesNode.connect(method.getResult());
|
allClassesNode.connect(method.getResult());
|
||||||
final MethodReference methodRef = reader.getReference();
|
final MethodReference methodRef = reader.getReference();
|
||||||
method.getResult().addConsumer(new DependencyConsumer() {
|
method.getResult().addConsumer(new DependencyConsumer() {
|
||||||
@Override public void consume(DependencyAgentType type) {
|
@Override public void consume(DependencyType type) {
|
||||||
attachConstructor(agent, type.getName(), new CallLocation(methodRef));
|
attachConstructor(agent, type.getName(), new CallLocation(methodRef));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user