Add AbstractInstructionReader, use it instead InstructionReader where possible

This commit is contained in:
Alexey Andreev 2016-10-22 16:25:38 +03:00
parent 3dbca7959b
commit 37d4c3349e
8 changed files with 208 additions and 792 deletions

View File

@ -26,7 +26,7 @@ import org.teavm.common.*;
import org.teavm.model.*; import org.teavm.model.*;
import org.teavm.model.instructions.*; import org.teavm.model.instructions.*;
public class DataFlowGraphBuilder implements InstructionReader { public class DataFlowGraphBuilder extends AbstractInstructionReader {
private int lastIndex; private int lastIndex;
private GraphBuilder builder = new GraphBuilder(); private GraphBuilder builder = new GraphBuilder();
private ObjectIntMap<FieldReference> fieldNodes = new ObjectIntOpenHashMap<>(); private ObjectIntMap<FieldReference> fieldNodes = new ObjectIntOpenHashMap<>();
@ -127,51 +127,6 @@ public class DataFlowGraphBuilder implements InstructionReader {
} }
} }
@Override
public void location(TextLocation location) {
}
@Override
public void nop() {
}
@Override
public void classConstant(VariableReader receiver, ValueType cst) {
}
@Override
public void nullConstant(VariableReader receiver) {
}
@Override
public void integerConstant(VariableReader receiver, int cst) {
}
@Override
public void longConstant(VariableReader receiver, long cst) {
}
@Override
public void floatConstant(VariableReader receiver, float cst) {
}
@Override
public void doubleConstant(VariableReader receiver, double cst) {
}
@Override
public void stringConstant(VariableReader receiver, String cst) {
}
@Override
public void binary(BinaryOperation op, VariableReader receiver, VariableReader first, VariableReader second,
NumericOperandType type) {
}
@Override
public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) {
}
private void connect(int a, int b) { private void connect(int a, int b) {
builder.addEdge(a, b); builder.addEdge(a, b);
join(a, b); join(a, b);
@ -187,35 +142,6 @@ public class DataFlowGraphBuilder implements InstructionReader {
builder.addEdge(value.getIndex(), receiver.getIndex()); builder.addEdge(value.getIndex(), receiver.getIndex());
} }
@Override
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
NumericOperandType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) {
}
@Override
public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) {
}
@Override
public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) {
}
@Override
public void jump(BasicBlockReader target) {
}
@Override
public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) {
}
@Override @Override
public void exit(VariableReader valueToReturn) { public void exit(VariableReader valueToReturn) {
if (valueToReturn != null && returnIndex >= 0) { if (valueToReturn != null && returnIndex >= 0) {
@ -229,18 +155,6 @@ public class DataFlowGraphBuilder implements InstructionReader {
escaping.add(exceptionIndex); escaping.add(exceptionIndex);
} }
@Override
public void createArray(VariableReader receiver, ValueType itemType, VariableReader size) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType, List<? extends VariableReader> dimensions) {
}
@Override
public void create(VariableReader receiver, String type) {
}
private int getFieldNode(FieldReference field) { private int getFieldNode(FieldReference field) {
int fieldNode = fieldNodes.getOrDefault(field, -1); int fieldNode = fieldNodes.getOrDefault(field, -1);
if (fieldNode < 0) { if (fieldNode < 0) {
@ -267,10 +181,6 @@ public class DataFlowGraphBuilder implements InstructionReader {
builder.addEdge(value.getIndex(), getFieldNode(field)); builder.addEdge(value.getIndex(), getFieldNode(field));
} }
@Override
public void arrayLength(VariableReader receiver, VariableReader array) {
}
@Override @Override
public void cloneArray(VariableReader receiver, VariableReader array) { public void cloneArray(VariableReader receiver, VariableReader array) {
builder.addEdge(array.getIndex(), receiver.getIndex()); builder.addEdge(array.getIndex(), receiver.getIndex());
@ -318,14 +228,6 @@ public class DataFlowGraphBuilder implements InstructionReader {
// Should be eliminated by bootstrap method substitutor // Should be eliminated by bootstrap method substitutor
} }
@Override
public void isInstance(VariableReader receiver, VariableReader value, ValueType type) {
}
@Override
public void initClass(String className) {
}
@Override @Override
public void nullCheck(VariableReader receiver, VariableReader value) { public void nullCheck(VariableReader receiver, VariableReader value) {
connect(value.getIndex(), receiver.getIndex()); connect(value.getIndex(), receiver.getIndex());

View File

@ -49,24 +49,14 @@ import org.teavm.model.ValueType;
import org.teavm.model.VariableReader; import org.teavm.model.VariableReader;
import org.teavm.model.emit.ProgramEmitter; import org.teavm.model.emit.ProgramEmitter;
import org.teavm.model.emit.ValueEmitter; import org.teavm.model.emit.ValueEmitter;
import org.teavm.model.instructions.AbstractInstructionReader;
import org.teavm.model.instructions.ArrayElementType; import org.teavm.model.instructions.ArrayElementType;
import org.teavm.model.instructions.AssignInstruction; import org.teavm.model.instructions.AssignInstruction;
import org.teavm.model.instructions.BinaryBranchingCondition;
import org.teavm.model.instructions.BinaryOperation;
import org.teavm.model.instructions.BranchingCondition;
import org.teavm.model.instructions.CastIntegerDirection;
import org.teavm.model.instructions.InstructionReader; import org.teavm.model.instructions.InstructionReader;
import org.teavm.model.instructions.IntegerSubtype;
import org.teavm.model.instructions.InvocationType; import org.teavm.model.instructions.InvocationType;
import org.teavm.model.instructions.NullConstantInstruction; import org.teavm.model.instructions.NullConstantInstruction;
import org.teavm.model.instructions.NumericOperandType;
import org.teavm.model.instructions.SwitchTableEntryReader;
import org.teavm.model.util.ListingBuilder; import org.teavm.model.util.ListingBuilder;
/**
*
* @author Alexey Andreev
*/
class DependencyGraphBuilder { class DependencyGraphBuilder {
private DependencyChecker dependencyChecker; private DependencyChecker dependencyChecker;
private DependencyNode[] nodes; private DependencyNode[] nodes;
@ -390,16 +380,12 @@ class DependencyGraphBuilder {
} }
} }
private InstructionReader reader = new InstructionReader() { private InstructionReader reader = new AbstractInstructionReader() {
@Override @Override
public void location(TextLocation location) { public void location(TextLocation location) {
currentLocation = location; currentLocation = location;
} }
@Override
public void nop() {
}
@Override @Override
public void classConstant(VariableReader receiver, ValueType cst) { public void classConstant(VariableReader receiver, ValueType cst) {
DependencyNode node = nodes[receiver.getIndex()]; DependencyNode node = nodes[receiver.getIndex()];
@ -428,26 +414,6 @@ class DependencyGraphBuilder {
} }
} }
@Override
public void nullConstant(VariableReader receiver) {
}
@Override
public void integerConstant(VariableReader receiver, int cst) {
}
@Override
public void longConstant(VariableReader receiver, long cst) {
}
@Override
public void floatConstant(VariableReader receiver, float cst) {
}
@Override
public void doubleConstant(VariableReader receiver, double cst) {
}
@Override @Override
public void stringConstant(VariableReader receiver, String cst) { public void stringConstant(VariableReader receiver, String cst) {
DependencyNode node = nodes[receiver.getIndex()]; DependencyNode node = nodes[receiver.getIndex()];
@ -459,15 +425,6 @@ class DependencyGraphBuilder {
method.use(); method.use();
} }
@Override
public void binary(BinaryOperation op, VariableReader receiver, VariableReader first, VariableReader second,
NumericOperandType type) {
}
@Override
public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) {
}
@Override @Override
public void assign(VariableReader receiver, VariableReader assignee) { public void assign(VariableReader receiver, VariableReader assignee) {
DependencyNode valueNode = nodes[assignee.getIndex()]; DependencyNode valueNode = nodes[assignee.getIndex()];
@ -501,36 +458,6 @@ class DependencyGraphBuilder {
valueNode.connect(receiverNode); valueNode.connect(receiverNode);
} }
} }
@Override
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
NumericOperandType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) {
}
@Override
public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) {
}
@Override
public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) {
}
@Override
public void jump(BasicBlockReader target) {
}
@Override
public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) {
}
@Override @Override
public void exit(VariableReader valueToReturn) { public void exit(VariableReader valueToReturn) {
if (valueToReturn != null) { if (valueToReturn != null) {
@ -631,10 +558,6 @@ class DependencyGraphBuilder {
initClass(field.getClassName()); initClass(field.getClassName());
} }
@Override
public void arrayLength(VariableReader receiver, VariableReader array) {
}
@Override @Override
public void cloneArray(VariableReader receiver, VariableReader array) { public void cloneArray(VariableReader receiver, VariableReader array) {
DependencyNode arrayNode = nodes[array.getIndex()]; DependencyNode arrayNode = nodes[array.getIndex()];

View File

@ -0,0 +1,192 @@
/*
* Copyright 2016 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.model.instructions;
import java.util.List;
import org.teavm.model.BasicBlockReader;
import org.teavm.model.FieldReference;
import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHandle;
import org.teavm.model.MethodReference;
import org.teavm.model.RuntimeConstant;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType;
import org.teavm.model.VariableReader;
public class AbstractInstructionReader implements InstructionReader {
@Override
public void location(TextLocation location) {
}
@Override
public void nop() {
}
@Override
public void classConstant(VariableReader receiver, ValueType cst) {
}
@Override
public void nullConstant(VariableReader receiver) {
}
@Override
public void integerConstant(VariableReader receiver, int cst) {
}
@Override
public void longConstant(VariableReader receiver, long cst) {
}
@Override
public void floatConstant(VariableReader receiver, float cst) {
}
@Override
public void doubleConstant(VariableReader receiver, double cst) {
}
@Override
public void stringConstant(VariableReader receiver, String cst) {
}
@Override
public void binary(BinaryOperation op, VariableReader receiver, VariableReader first, VariableReader second,
NumericOperandType type) {
}
@Override
public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) {
}
@Override
public void assign(VariableReader receiver, VariableReader assignee) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, ValueType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
NumericOperandType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) {
}
@Override
public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) {
}
@Override
public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) {
}
@Override
public void jump(BasicBlockReader target) {
}
@Override
public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) {
}
@Override
public void exit(VariableReader valueToReturn) {
}
@Override
public void raise(VariableReader exception) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType, VariableReader size) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType, List<? extends VariableReader> dimensions) {
}
@Override
public void create(VariableReader receiver, String type) {
}
@Override
public void getField(VariableReader receiver, VariableReader instance, FieldReference field, ValueType fieldType) {
}
@Override
public void putField(VariableReader instance, FieldReference field, VariableReader value, ValueType fieldType) {
}
@Override
public void arrayLength(VariableReader receiver, VariableReader array) {
}
@Override
public void cloneArray(VariableReader receiver, VariableReader array) {
}
@Override
public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) {
}
@Override
public void getElement(VariableReader receiver, VariableReader array, VariableReader index,
ArrayElementType elementType) {
}
@Override
public void putElement(VariableReader array, VariableReader index, VariableReader value,
ArrayElementType elementType) {
}
@Override
public void invoke(VariableReader receiver, VariableReader instance, MethodReference method,
List<? extends VariableReader> arguments, InvocationType type) {
}
@Override
public void invokeDynamic(VariableReader receiver, VariableReader instance, MethodDescriptor method,
List<? extends VariableReader> arguments, MethodHandle bootstrapMethod,
List<RuntimeConstant> bootstrapArguments) {
}
@Override
public void isInstance(VariableReader receiver, VariableReader value, ValueType type) {
}
@Override
public void initClass(String className) {
}
@Override
public void nullCheck(VariableReader receiver, VariableReader value) {
}
@Override
public void monitorEnter(VariableReader objectRef) {
}
@Override
public void monitorExit(VariableReader objectRef) {
}
}

View File

@ -29,36 +29,17 @@ import org.teavm.callgraph.CallSite;
import org.teavm.diagnostics.Diagnostics; import org.teavm.diagnostics.Diagnostics;
import org.teavm.interop.Async; import org.teavm.interop.Async;
import org.teavm.interop.Sync; import org.teavm.interop.Sync;
import org.teavm.model.BasicBlockReader;
import org.teavm.model.CallLocation; import org.teavm.model.CallLocation;
import org.teavm.model.ClassReader; import org.teavm.model.ClassReader;
import org.teavm.model.ElementModifier; import org.teavm.model.ElementModifier;
import org.teavm.model.FieldReference;
import org.teavm.model.ListableClassReaderSource; import org.teavm.model.ListableClassReaderSource;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHandle;
import org.teavm.model.MethodReader; import org.teavm.model.MethodReader;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
import org.teavm.model.ProgramReader; import org.teavm.model.ProgramReader;
import org.teavm.model.RuntimeConstant;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType;
import org.teavm.model.VariableReader; import org.teavm.model.VariableReader;
import org.teavm.model.instructions.ArrayElementType; import org.teavm.model.instructions.AbstractInstructionReader;
import org.teavm.model.instructions.BinaryBranchingCondition;
import org.teavm.model.instructions.BinaryOperation;
import org.teavm.model.instructions.BranchingCondition;
import org.teavm.model.instructions.CastIntegerDirection;
import org.teavm.model.instructions.InstructionReader;
import org.teavm.model.instructions.IntegerSubtype;
import org.teavm.model.instructions.InvocationType;
import org.teavm.model.instructions.NumericOperandType;
import org.teavm.model.instructions.SwitchTableEntryReader;
/**
*
* @author Alexey Andreev
*/
public class AsyncMethodFinder { public class AsyncMethodFinder {
private Set<MethodReference> asyncMethods = new HashSet<>(); private Set<MethodReference> asyncMethods = new HashSet<>();
private Map<MethodReference, Boolean> asyncFamilyMethods = new HashMap<>(); private Map<MethodReference, Boolean> asyncFamilyMethods = new HashMap<>();
@ -262,174 +243,12 @@ public class AsyncMethodFinder {
} }
} }
class AsyncInstructionReader implements InstructionReader { class AsyncInstructionReader extends AbstractInstructionReader {
boolean async; boolean async;
@Override
public void location(TextLocation location) {
}
@Override
public void nop() {
}
@Override
public void classConstant(VariableReader receiver, ValueType cst) {
}
@Override
public void nullConstant(VariableReader receiver) {
}
@Override
public void integerConstant(VariableReader receiver, int cst) {
}
@Override
public void longConstant(VariableReader receiver, long cst) {
}
@Override
public void floatConstant(VariableReader receiver, float cst) {
}
@Override
public void doubleConstant(VariableReader receiver, double cst) {
}
@Override
public void stringConstant(VariableReader receiver, String cst) {
}
@Override
public void binary(BinaryOperation op, VariableReader receiver, VariableReader first, VariableReader second,
NumericOperandType type) {
}
@Override
public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) {
}
@Override
public void assign(VariableReader receiver, VariableReader assignee) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, ValueType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
NumericOperandType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) {
}
@Override
public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) {
}
@Override
public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) {
}
@Override
public void jump(BasicBlockReader target) {
}
@Override
public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) {
}
@Override
public void exit(VariableReader valueToReturn) {
}
@Override
public void raise(VariableReader exception) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType, VariableReader size) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType,
List<? extends VariableReader> dimensions) {
}
@Override
public void create(VariableReader receiver, String type) {
}
@Override
public void getField(VariableReader receiver, VariableReader instance, FieldReference field,
ValueType fieldType) {
}
@Override
public void putField(VariableReader instance, FieldReference field, VariableReader value,
ValueType fieldType) {
}
@Override
public void arrayLength(VariableReader receiver, VariableReader array) {
}
@Override
public void cloneArray(VariableReader receiver, VariableReader array) {
}
@Override
public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) {
}
@Override
public void getElement(VariableReader receiver, VariableReader array, VariableReader index,
ArrayElementType type) {
}
@Override
public void putElement(VariableReader array, VariableReader index, VariableReader value,
ArrayElementType type) {
}
@Override
public void invoke(VariableReader receiver, VariableReader instance, MethodReference method,
List<? extends VariableReader> arguments, InvocationType type) {
}
@Override
public void invokeDynamic(VariableReader receiver, VariableReader instance, MethodDescriptor method,
List<? extends VariableReader> arguments, MethodHandle bootstrapMethod,
List<RuntimeConstant> bootstrapArguments) {
}
@Override
public void isInstance(VariableReader receiver, VariableReader value, ValueType type) {
}
@Override
public void initClass(String className) {
}
@Override
public void nullCheck(VariableReader receiver, VariableReader value) {
}
@Override @Override
public void monitorEnter(VariableReader objectRef) { public void monitorEnter(VariableReader objectRef) {
async = true; async = true;
} }
@Override
public void monitorExit(VariableReader objectRef) {
}
} }
} }

View File

@ -191,7 +191,7 @@ public class TypeInferer {
return VariableType.OBJECT_ARRAY; return VariableType.OBJECT_ARRAY;
} }
InstructionReader reader = new InstructionReader() { InstructionReader reader = new AbstractInstructionReader() {
@Override @Override
public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) { public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) {
builder.addEdge(array.getIndex(), receiver.getIndex()); builder.addEdge(array.getIndex(), receiver.getIndex());
@ -202,19 +202,6 @@ public class TypeInferer {
types[receiver.getIndex()] = VariableType.OBJECT; types[receiver.getIndex()] = VariableType.OBJECT;
} }
@Override
public void raise(VariableReader exception) {
}
@Override
public void putField(VariableReader instance, FieldReference field, VariableReader value, ValueType fieldType) {
}
@Override
public void putElement(VariableReader array, VariableReader index, VariableReader value,
ArrayElementType type) {
}
@Override @Override
public void nullConstant(VariableReader receiver) { public void nullConstant(VariableReader receiver) {
types[receiver.getIndex()] = VariableType.OBJECT; types[receiver.getIndex()] = VariableType.OBJECT;
@ -225,46 +212,16 @@ public class TypeInferer {
builder.addEdge(value.getIndex(), receiver.getIndex()); builder.addEdge(value.getIndex(), receiver.getIndex());
} }
@Override
public void nop() {
}
@Override @Override
public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) { public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) {
types[receiver.getIndex()] = convert(type); types[receiver.getIndex()] = convert(type);
} }
@Override
public void monitorExit(VariableReader objectRef) {
}
@Override
public void monitorEnter(VariableReader objectRef) {
}
@Override @Override
public void longConstant(VariableReader receiver, long cst) { public void longConstant(VariableReader receiver, long cst) {
types[receiver.getIndex()] = VariableType.LONG; types[receiver.getIndex()] = VariableType.LONG;
} }
@Override
public void location(TextLocation location) {
}
@Override
public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) {
}
@Override
public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) {
}
@Override
public void jump(BasicBlockReader target) {
}
@Override @Override
public void isInstance(VariableReader receiver, VariableReader value, ValueType type) { public void isInstance(VariableReader receiver, VariableReader value, ValueType type) {
types[receiver.getIndex()] = VariableType.INT; types[receiver.getIndex()] = VariableType.INT;
@ -292,10 +249,6 @@ public class TypeInferer {
types[receiver.getIndex()] = VariableType.INT; types[receiver.getIndex()] = VariableType.INT;
} }
@Override
public void initClass(String className) {
}
@Override @Override
public void getField(VariableReader receiver, VariableReader instance, FieldReference field, public void getField(VariableReader receiver, VariableReader instance, FieldReference field,
ValueType fieldType) { ValueType fieldType) {
@ -313,10 +266,6 @@ public class TypeInferer {
types[receiver.getIndex()] = VariableType.FLOAT; types[receiver.getIndex()] = VariableType.FLOAT;
} }
@Override
public void exit(VariableReader valueToReturn) {
}
@Override @Override
public void doubleConstant(VariableReader receiver, double cst) { public void doubleConstant(VariableReader receiver, double cst) {
types[receiver.getIndex()] = VariableType.DOUBLE; types[receiver.getIndex()] = VariableType.DOUBLE;
@ -348,11 +297,6 @@ public class TypeInferer {
types[receiver.getIndex()] = VariableType.OBJECT; types[receiver.getIndex()] = VariableType.OBJECT;
} }
@Override
public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) {
}
@Override @Override
public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type, public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) { CastIntegerDirection targetType) {
@ -381,7 +325,6 @@ public class TypeInferer {
types[receiver.getIndex()] = convert(type); types[receiver.getIndex()] = convert(type);
break; break;
} }
} }
@Override @Override

View File

@ -16,33 +16,18 @@
package org.teavm.metaprogramming.impl; package org.teavm.metaprogramming.impl;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.teavm.common.DisjointSet; import org.teavm.common.DisjointSet;
import org.teavm.model.BasicBlockReader; import org.teavm.model.BasicBlockReader;
import org.teavm.model.FieldReference;
import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodHandle;
import org.teavm.model.MethodReference;
import org.teavm.model.PhiReader; import org.teavm.model.PhiReader;
import org.teavm.model.ProgramReader; import org.teavm.model.ProgramReader;
import org.teavm.model.RuntimeConstant;
import org.teavm.model.TextLocation;
import org.teavm.model.TryCatchBlockReader; import org.teavm.model.TryCatchBlockReader;
import org.teavm.model.TryCatchJointReader; import org.teavm.model.TryCatchJointReader;
import org.teavm.model.ValueType; import org.teavm.model.ValueType;
import org.teavm.model.VariableReader; import org.teavm.model.VariableReader;
import org.teavm.model.instructions.AbstractInstructionReader;
import org.teavm.model.instructions.ArrayElementType; import org.teavm.model.instructions.ArrayElementType;
import org.teavm.model.instructions.BinaryBranchingCondition;
import org.teavm.model.instructions.BinaryOperation;
import org.teavm.model.instructions.BranchingCondition;
import org.teavm.model.instructions.CastIntegerDirection;
import org.teavm.model.instructions.InstructionReader;
import org.teavm.model.instructions.IntegerSubtype;
import org.teavm.model.instructions.InvocationType;
import org.teavm.model.instructions.NumericOperandType;
import org.teavm.model.instructions.SwitchTableEntryReader;
class AliasFinder { class AliasFinder {
private int[] aliases; private int[] aliases;
@ -122,7 +107,7 @@ class AliasFinder {
return arrayElements.clone(); return arrayElements.clone();
} }
private static class AliasReader implements InstructionReader { private static class AliasReader extends AbstractInstructionReader {
DisjointSet disjointSet; DisjointSet disjointSet;
Object[] constants; Object[] constants;
ArrayElement[] arrayElements; ArrayElement[] arrayElements;
@ -133,23 +118,11 @@ class AliasFinder {
this.arrayElements = new ArrayElement[variableCount]; this.arrayElements = new ArrayElement[variableCount];
} }
@Override
public void location(TextLocation location) {
}
@Override
public void nop() {
}
@Override @Override
public void classConstant(VariableReader receiver, ValueType cst) { public void classConstant(VariableReader receiver, ValueType cst) {
constants[receiver.getIndex()] = cst; constants[receiver.getIndex()] = cst;
} }
@Override
public void nullConstant(VariableReader receiver) {
}
@Override @Override
public void integerConstant(VariableReader receiver, int cst) { public void integerConstant(VariableReader receiver, int cst) {
constants[receiver.getIndex()] = cst; constants[receiver.getIndex()] = cst;
@ -175,91 +148,11 @@ class AliasFinder {
constants[receiver.getIndex()] = cst; constants[receiver.getIndex()] = cst;
} }
@Override
public void binary(BinaryOperation op, VariableReader receiver, VariableReader first, VariableReader second,
NumericOperandType type) {
}
@Override
public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) {
}
@Override @Override
public void assign(VariableReader receiver, VariableReader assignee) { public void assign(VariableReader receiver, VariableReader assignee) {
disjointSet.union(receiver.getIndex(), assignee.getIndex()); disjointSet.union(receiver.getIndex(), assignee.getIndex());
} }
@Override
public void cast(VariableReader receiver, VariableReader value, ValueType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
NumericOperandType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) {
}
@Override
public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) {
}
@Override
public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) {
}
@Override
public void jump(BasicBlockReader target) {
}
@Override
public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) {
}
@Override
public void exit(VariableReader valueToReturn) {
}
@Override
public void raise(VariableReader exception) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType, VariableReader size) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType,
List<? extends VariableReader> dimensions) {
}
@Override
public void create(VariableReader receiver, String type) {
}
@Override
public void getField(VariableReader receiver, VariableReader instance, FieldReference field,
ValueType fieldType) {
}
@Override
public void putField(VariableReader instance, FieldReference field, VariableReader value, ValueType fieldType) {
}
@Override
public void arrayLength(VariableReader receiver, VariableReader array) {
}
@Override
public void cloneArray(VariableReader receiver, VariableReader array) {
}
@Override @Override
public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) { public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) {
disjointSet.union(receiver.getIndex(), array.getIndex()); disjointSet.union(receiver.getIndex(), array.getIndex());
@ -273,41 +166,5 @@ class AliasFinder {
elem.index = index.getIndex(); elem.index = index.getIndex();
arrayElements[receiver.getIndex()] = elem; arrayElements[receiver.getIndex()] = elem;
} }
@Override
public void putElement(VariableReader array, VariableReader index, VariableReader value,
ArrayElementType type) {
}
@Override
public void invoke(VariableReader receiver, VariableReader instance, MethodReference method,
List<? extends VariableReader> arguments, InvocationType type) {
}
@Override
public void invokeDynamic(VariableReader receiver, VariableReader instance, MethodDescriptor method,
List<? extends VariableReader> arguments, MethodHandle bootstrapMethod,
List<RuntimeConstant> bootstrapArguments) {
}
@Override
public void isInstance(VariableReader receiver, VariableReader value, ValueType type) {
}
@Override
public void initClass(String className) {
}
@Override
public void nullCheck(VariableReader receiver, VariableReader value) {
}
@Override
public void monitorEnter(VariableReader objectRef) {
}
@Override
public void monitorExit(VariableReader objectRef) {
}
} }
} }

View File

@ -15,21 +15,11 @@
*/ */
package org.teavm.tooling; package org.teavm.tooling;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.teavm.model.*; import org.teavm.model.TextLocation;
import org.teavm.model.instructions.ArrayElementType; import org.teavm.model.instructions.AbstractInstructionReader;
import org.teavm.model.instructions.BinaryBranchingCondition;
import org.teavm.model.instructions.BinaryOperation;
import org.teavm.model.instructions.BranchingCondition;
import org.teavm.model.instructions.CastIntegerDirection;
import org.teavm.model.instructions.InstructionReader;
import org.teavm.model.instructions.IntegerSubtype;
import org.teavm.model.instructions.InvocationType;
import org.teavm.model.instructions.NumericOperandType;
import org.teavm.model.instructions.SwitchTableEntryReader;
class InstructionLocationReader implements InstructionReader { class InstructionLocationReader extends AbstractInstructionReader {
private Set<String> resources; private Set<String> resources;
public InstructionLocationReader(Set<String> resources) { public InstructionLocationReader(Set<String> resources) {
@ -42,163 +32,4 @@ class InstructionLocationReader implements InstructionReader {
resources.add(location.getFileName()); resources.add(location.getFileName());
} }
} }
@Override
public void nop() {
}
@Override
public void classConstant(VariableReader receiver, ValueType cst) {
}
@Override
public void nullConstant(VariableReader receiver) {
}
@Override
public void integerConstant(VariableReader receiver, int cst) {
}
@Override
public void longConstant(VariableReader receiver, long cst) {
}
@Override
public void floatConstant(VariableReader receiver, float cst) {
}
@Override
public void doubleConstant(VariableReader receiver, double cst) {
}
@Override
public void stringConstant(VariableReader receiver, String cst) {
}
@Override
public void binary(BinaryOperation op, VariableReader receiver, VariableReader first, VariableReader second,
NumericOperandType type) {
}
@Override
public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) {
}
@Override
public void assign(VariableReader receiver, VariableReader assignee) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, ValueType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
NumericOperandType targetType) {
}
@Override
public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) {
}
@Override
public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) {
}
@Override
public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) {
}
@Override
public void jump(BasicBlockReader target) {
}
@Override
public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) {
}
@Override
public void exit(VariableReader valueToReturn) {
}
@Override
public void raise(VariableReader exception) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType, VariableReader size) {
}
@Override
public void createArray(VariableReader receiver, ValueType itemType, List<? extends VariableReader> dimensions) {
}
@Override
public void create(VariableReader receiver, String type) {
}
@Override
public void getField(VariableReader receiver, VariableReader instance, FieldReference field, ValueType fieldType) {
}
@Override
public void putField(VariableReader instance, FieldReference field, VariableReader value, ValueType fieldType) {
}
@Override
public void arrayLength(VariableReader receiver, VariableReader array) {
}
@Override
public void cloneArray(VariableReader receiver, VariableReader array) {
}
@Override
public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) {
}
@Override
public void getElement(VariableReader receiver, VariableReader array, VariableReader index,
ArrayElementType type) {
}
@Override
public void putElement(VariableReader array, VariableReader index, VariableReader value,
ArrayElementType type) {
}
@Override
public void invoke(VariableReader receiver, VariableReader instance, MethodReference method,
List<? extends VariableReader> arguments, InvocationType type) {
}
@Override
public void invokeDynamic(VariableReader receiver, VariableReader instance, MethodDescriptor method,
List<? extends VariableReader> arguments, MethodHandle bootstrapMethod,
List<RuntimeConstant> bootstrapArguments) {
}
@Override
public void isInstance(VariableReader receiver, VariableReader value, ValueType type) {
}
@Override
public void initClass(String className) {
}
@Override
public void nullCheck(VariableReader receiver, VariableReader value) {
}
@Override
public void monitorEnter(VariableReader objectRef) {
}
@Override
public void monitorExit(VariableReader objectRef) {
}
} }

View File

@ -15,12 +15,13 @@
*/ */
package org.teavm.tooling.sources; package org.teavm.tooling.sources;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.teavm.model.*; import org.teavm.model.BasicBlockReader;
import org.teavm.model.instructions.*; import org.teavm.model.ProgramReader;
import org.teavm.model.TextLocation;
import org.teavm.model.instructions.AbstractInstructionReader;
class ProgramSourceAggregator implements InstructionReader { class ProgramSourceAggregator extends AbstractInstructionReader {
private Set<String> sourceFiles; private Set<String> sourceFiles;
public ProgramSourceAggregator(Set<String> sourceFiles) { public ProgramSourceAggregator(Set<String> sourceFiles) {
@ -40,56 +41,4 @@ class ProgramSourceAggregator implements InstructionReader {
sourceFiles.add(location.getFileName()); sourceFiles.add(location.getFileName());
} }
} }
@Override public void nop() { }
@Override public void classConstant(VariableReader receiver, ValueType cst) { }
@Override public void nullConstant(VariableReader receiver) { }
@Override public void integerConstant(VariableReader receiver, int cst) { }
@Override public void longConstant(VariableReader receiver, long cst) { }
@Override public void floatConstant(VariableReader receiver, float cst) { }
@Override public void doubleConstant(VariableReader receiver, double cst) { }
@Override public void stringConstant(VariableReader receiver, String cst) { }
@Override public void binary(BinaryOperation op, VariableReader receiver, VariableReader first,
VariableReader second, NumericOperandType type) { }
@Override public void negate(VariableReader receiver, VariableReader operand, NumericOperandType type) { }
@Override public void assign(VariableReader receiver, VariableReader assignee) { }
@Override public void cast(VariableReader receiver, VariableReader value, ValueType targetType) { }
@Override public void cast(VariableReader receiver, VariableReader value, NumericOperandType sourceType,
NumericOperandType targetType) { }
@Override public void cast(VariableReader receiver, VariableReader value, IntegerSubtype type,
CastIntegerDirection targetType) { }
@Override public void jumpIf(BranchingCondition cond, VariableReader operand, BasicBlockReader consequent,
BasicBlockReader alternative) { }
@Override public void jumpIf(BinaryBranchingCondition cond, VariableReader first, VariableReader second,
BasicBlockReader consequent, BasicBlockReader alternative) { }
@Override public void jump(BasicBlockReader target) { }
@Override public void choose(VariableReader condition, List<? extends SwitchTableEntryReader> table,
BasicBlockReader defaultTarget) { }
@Override public void exit(VariableReader valueToReturn) { }
@Override public void raise(VariableReader exception) { }
@Override public void createArray(VariableReader receiver, ValueType itemType, VariableReader size) { }
@Override public void createArray(VariableReader receiver, ValueType itemType,
List<? extends VariableReader> dimensions) { }
@Override public void create(VariableReader receiver, String type) { }
@Override public void getField(VariableReader receiver, VariableReader instance, FieldReference field,
ValueType fieldType) { }
@Override public void putField(VariableReader instance, FieldReference field, VariableReader value,
ValueType fieldType) { }
@Override public void arrayLength(VariableReader receiver, VariableReader array) { }
@Override public void cloneArray(VariableReader receiver, VariableReader array) { }
@Override public void unwrapArray(VariableReader receiver, VariableReader array, ArrayElementType elementType) { }
@Override public void getElement(VariableReader receiver, VariableReader array, VariableReader index,
ArrayElementType type) { }
@Override public void putElement(VariableReader array, VariableReader index, VariableReader value,
ArrayElementType type) { }
@Override public void invoke(VariableReader receiver, VariableReader instance, MethodReference method,
List<? extends VariableReader> arguments, InvocationType type) { }
@Override public void invokeDynamic(VariableReader receiver, VariableReader instance, MethodDescriptor method,
List<? extends VariableReader> arguments, MethodHandle bootstrapMethod,
List<RuntimeConstant> bootstrapArguments) { }
@Override public void isInstance(VariableReader receiver, VariableReader value, ValueType type) { }
@Override public void initClass(String className) { }
@Override public void nullCheck(VariableReader receiver, VariableReader value) { }
@Override public void monitorEnter(VariableReader objectRef) { }
@Override public void monitorExit(VariableReader objectRef) { }
} }