mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-12-15 02:10:30 +08:00
Fixes bug that caused JUnit not to throw assertions in certain cases.
This commit is contained in:
parent
ad1d231094
commit
b85dfcd7a0
@ -32,7 +32,7 @@ public class StringNativeGenerator implements Injector, DependencyPlugin {
|
|||||||
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "wrap":
|
case "wrap":
|
||||||
method.getVariable(0).connect(method.getResult());
|
method.getVariable(1).connect(method.getResult());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,11 +317,11 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int bitCount(int i) {
|
public static int bitCount(int i) {
|
||||||
i = (i & 0xAAAAAAAA) >> 1 + i & 0x55555555;
|
i = ((i & 0xAAAAAAAA) >>> 1) + (i & 0x55555555);
|
||||||
i = (i & 0xCCCCCCCC) >> 2 + i & 0x33333333;
|
i = ((i & 0xCCCCCCCC) >>> 2) + (i & 0x33333333);
|
||||||
i = (i & 0x30303030) >> 4 + i & 0x03030303;
|
i = ((i & 0x70707070) >>> 4) + (i & 0x07070707);
|
||||||
i = (i & 0x07000700) >> 8 + i & 0x00070007;
|
i = ((i & 0x0F000F00) >>> 8) + (i & 0x000F000F);
|
||||||
i = (i & 0x000F0000) >> 16 + i & 0x0000000F;
|
i = ((i & 0x001F0000) >>> 16) + (i & 0x0000001F);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,17 +336,17 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int reverse(int i) {
|
public static int reverse(int i) {
|
||||||
i = (i & 0xAAAAAAAA) >> 1 | (i & 0x55555555) << 1;
|
i = ((i & 0xAAAAAAAA) >>> 1) | ((i & 0x55555555) << 1);
|
||||||
i = (i & 0xCCCCCCCC) >> 2 | (i & 0x33333333) << 2;
|
i = ((i & 0xCCCCCCCC) >>> 2) | ((i & 0x33333333) << 2);
|
||||||
i = (i & 0xF0F0F0F0) >> 4 | (i & 0x0F0F0F0F) << 4;
|
i = ((i & 0xF0F0F0F0) >>> 4) | ((i & 0x0F0F0F0F) << 4);
|
||||||
i = (i & 0xFF00FF00) >> 8 | (i & 0x00FF00FF) << 8;
|
i = ((i & 0xFF00FF00) >>> 8) | ((i & 0x00FF00FF) << 8);
|
||||||
i = (i & 0xFFFF0000) >> 16 | (i & 0x0000FFFF) << 16;
|
i = ((i & 0xFFFF0000) >>> 16) | ((i & 0x0000FFFF) << 16);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int reverseBytes(int i) {
|
public static int reverseBytes(int i) {
|
||||||
i = (i & 0xFF00FF00) >> 8 | (i & 0x00FF00FF) << 8;
|
i = ((i & 0xFF00FF00) >>> 8) | ((i & 0x00FF00FF) << 8);
|
||||||
i = i >> 16 + i << 16;
|
i = (i >>> 16) + (i << 16);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ public class ProgramParser {
|
|||||||
private List<List<Instruction>> targetInstructions;
|
private List<List<Instruction>> targetInstructions;
|
||||||
private List<Instruction> builder = new ArrayList<>();
|
private List<Instruction> builder = new ArrayList<>();
|
||||||
private List<BasicBlock> basicBlocks = new ArrayList<>();
|
private List<BasicBlock> basicBlocks = new ArrayList<>();
|
||||||
private int[] localsMap;
|
|
||||||
private int minLocal;
|
private int minLocal;
|
||||||
private Program program;
|
private Program program;
|
||||||
private String currentClassName;
|
private String currentClassName;
|
||||||
@ -81,7 +80,6 @@ public class ProgramParser {
|
|||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
prepare(method);
|
prepare(method);
|
||||||
prepareParameters(method);
|
|
||||||
program.createBasicBlock();
|
program.createBasicBlock();
|
||||||
getBasicBlock(0);
|
getBasicBlock(0);
|
||||||
JumpInstruction insn = new JumpInstruction();
|
JumpInstruction insn = new JumpInstruction();
|
||||||
@ -146,34 +144,6 @@ public class ProgramParser {
|
|||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareParameters(MethodNode method) {
|
|
||||||
int var = 0;
|
|
||||||
int offset = 0;
|
|
||||||
if ((method.access & Opcodes.ACC_STATIC) == 0) {
|
|
||||||
getVariable(var++);
|
|
||||||
++offset;
|
|
||||||
}
|
|
||||||
ValueType[] desc = MethodDescriptor.parse(method.desc).getParameterTypes();
|
|
||||||
localsMap = new int[desc.length * 2 + 1];
|
|
||||||
for (int i = 0; i < desc.length; ++i) {
|
|
||||||
ValueType paramType = desc[i];
|
|
||||||
localsMap[var] = i + offset;
|
|
||||||
getVariable(var++);
|
|
||||||
if (paramType instanceof ValueType.Primitive) {
|
|
||||||
switch (((ValueType.Primitive)paramType).getKind()) {
|
|
||||||
case LONG:
|
|
||||||
case DOUBLE:
|
|
||||||
localsMap[var] = i + offset;
|
|
||||||
getVariable(var++);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
localsMap = Arrays.copyOf(localsMap, var);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void prepare(MethodNode method) {
|
private void prepare(MethodNode method) {
|
||||||
InsnList instructions = method.instructions;
|
InsnList instructions = method.instructions;
|
||||||
minLocal = 0;
|
minLocal = 0;
|
||||||
@ -323,9 +293,6 @@ public class ProgramParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int mapLocal(int local) {
|
private int mapLocal(int local) {
|
||||||
if (local < localsMap.length) {
|
|
||||||
local = localsMap[local];
|
|
||||||
}
|
|
||||||
return local;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1528,8 +1495,7 @@ public class ProgramParser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitIincInsn(int var, int increment) {
|
public void visitIincInsn(int var, int increment) {
|
||||||
var = mapLocal(var);
|
var = minLocal + mapLocal(var);
|
||||||
var += minLocal;
|
|
||||||
int tmp = pushSingle();
|
int tmp = pushSingle();
|
||||||
popSingle();
|
popSingle();
|
||||||
IntegerConstantInstruction intInsn = new IntegerConstantInstruction();
|
IntegerConstantInstruction intInsn = new IntegerConstantInstruction();
|
||||||
|
@ -69,7 +69,7 @@ public class SSATransformer {
|
|||||||
variableMap[index] = program.variableAt(index);
|
variableMap[index] = program.variableAt(index);
|
||||||
++index;
|
++index;
|
||||||
for (int i = 0; i < arguments.length; ++i) {
|
for (int i = 0; i < arguments.length; ++i) {
|
||||||
variableMap[index] = program.variableAt(index);
|
variableMap[index] = program.variableAt(i + 1);
|
||||||
++index;
|
++index;
|
||||||
ValueType arg = arguments[i];
|
ValueType arg = arguments[i];
|
||||||
if (arg instanceof ValueType.Primitive) {
|
if (arg instanceof ValueType.Primitive) {
|
||||||
|
Loading…
Reference in New Issue
Block a user