add jdk-test target, and fix failures

The intent of this target is to run our test suite against the installed jre.
This should help prevent our VM from diverging in implementation from the jdk.

The remainder of this commit fixes the problems that this exposes.
This commit is contained in:
Joshua Warner 2013-12-06 14:56:02 -07:00
parent 39e3850ed8
commit 47a7732a81
11 changed files with 44 additions and 19 deletions

View File

@ -67,7 +67,7 @@ public class Assembler {
write4(out, 0xCAFEBABE); write4(out, 0xCAFEBABE);
write2(out, 0); // minor version write2(out, 0); // minor version
write2(out, 0); // major version write2(out, 50); // major version
write2(out, pool.size() + 1); write2(out, pool.size() + 1);
for (PoolEntry e: pool) { for (PoolEntry e: pool) {

View File

@ -11,10 +11,23 @@
package avian; package avian;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.lang.reflect.Field;
public abstract class Machine { public abstract class Machine {
private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final Unsafe unsafe;
static {
Unsafe u;
try {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
u = (Unsafe)f.get(null);
} catch (Exception e) {
u = null;
}
unsafe = u;
}
public static native void dumpHeap(String outputFile); public static native void dumpHeap(String outputFile);

View File

@ -70,7 +70,7 @@ public class Handler extends URLStreamHandler {
} }
public int getContentLength() { public int getContentLength() {
return entry.getSize(); return (int)entry.getSize();
} }
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {

View File

@ -50,7 +50,7 @@ public class JarFile extends ZipFile {
} }
} }
public int getCompressedSize() { public long getCompressedSize() {
try { try {
return compressedSize(window, pointer); return compressedSize(window, pointer);
} catch (IOException e) { } catch (IOException e) {
@ -58,7 +58,7 @@ public class JarFile extends ZipFile {
} }
} }
public int getSize() { public long getSize() {
try { try {
return uncompressedSize(window, pointer); return uncompressedSize(window, pointer);
} catch (IOException e) { } catch (IOException e) {

View File

@ -42,8 +42,8 @@ public class ZipEntry {
int modTimeDate = -1; int modTimeDate = -1;
long millisTime = -1; long millisTime = -1;
int crc = -1; int crc = -1;
int compSize = 0; long compSize = 0;
int uncompSize = 0; long uncompSize = 0;
int offset = -1; int offset = -1;
public ZipEntry(String name) { public ZipEntry(String name) {
@ -191,12 +191,12 @@ public class ZipEntry {
uncompSize = size; uncompSize = size;
} }
public int getSize() { public long getSize() {
return uncompSize; return uncompSize;
} }
//Methods to set and get the compressed size of the entry //Methods to set and get the compressed size of the entry
public void setCompressedSize(int size){ public void setCompressedSize(long size){
if (size < 0){ if (size < 0){
return; return;
} }
@ -204,7 +204,7 @@ public class ZipEntry {
compSize = size; compSize = size;
} }
public int getCompressedSize() { public long getCompressedSize() {
return compSize; return compSize;
} }
} }

View File

@ -298,7 +298,7 @@ public class ZipFile {
} }
} }
public int getCompressedSize() { public long getCompressedSize() {
try { try {
return compressedSize(window, pointer); return compressedSize(window, pointer);
} catch (IOException e) { } catch (IOException e) {
@ -306,7 +306,7 @@ public class ZipFile {
} }
} }
public int getSize() { public long getSize() {
try { try {
return uncompressedSize(window, pointer); return uncompressedSize(window, pointer);
} catch (IOException e) { } catch (IOException e) {

View File

@ -147,8 +147,8 @@ public class ZipOutputStream extends DeflaterOutputStream {
addFourBytes(DATA_DESCRIPTER_HEADER, 0, tmpBuffer); // data descripter header addFourBytes(DATA_DESCRIPTER_HEADER, 0, tmpBuffer); // data descripter header
addFourBytes(currentEntry.crc, 4, tmpBuffer); // crc value addFourBytes(currentEntry.crc, 4, tmpBuffer); // crc value
addFourBytes(currentEntry.compSize, 8, tmpBuffer); // compressed size addFourBytes((int)currentEntry.compSize, 8, tmpBuffer); // compressed size
addFourBytes(currentEntry.uncompSize, 12, tmpBuffer);// uncompressed size addFourBytes((int)currentEntry.uncompSize, 12, tmpBuffer);// uncompressed size
out.write(tmpBuffer, 0, 16); out.write(tmpBuffer, 0, 16);
bytesWritten += 16; bytesWritten += 16;
} }
@ -164,8 +164,8 @@ public class ZipOutputStream extends DeflaterOutputStream {
addFourBytes(e.modTimeDate, 12, tmpBuffer); // last mod date and time addFourBytes(e.modTimeDate, 12, tmpBuffer); // last mod date and time
addFourBytes(e.crc, 16, tmpBuffer); // crc addFourBytes(e.crc, 16, tmpBuffer); // crc
addFourBytes(e.compSize, 20, tmpBuffer); // compressed size addFourBytes((int)e.compSize, 20, tmpBuffer); // compressed size
addFourBytes(e.uncompSize, 24, tmpBuffer); // uncompressed size addFourBytes((int)e.uncompSize, 24, tmpBuffer); // uncompressed size
addTwoBytes(e.getName().length(), 28, tmpBuffer); // file name length addTwoBytes(e.getName().length(), 28, tmpBuffer); // file name length

View File

@ -5,10 +5,10 @@ import java.lang.reflect.Field;
public final class Unsafe { public final class Unsafe {
private void Unsafe() { } private void Unsafe() { }
private static final Unsafe Instance = new Unsafe(); private static final Unsafe theUnsafe = new Unsafe();
public static Unsafe getUnsafe() { public static Unsafe getUnsafe() {
return Instance; return theUnsafe;
} }
public native long allocateMemory(long bytes); public native long allocateMemory(long bytes);

View File

@ -1451,6 +1451,10 @@ else
ssh -p$(remote-test-port) $(remote-test-user)@$(remote-test-host) sh "$(remote-test-dir)/$(platform)-$(arch)$(options)/run-tests.sh" ssh -p$(remote-test-port) $(remote-test-user)@$(remote-test-host) sh "$(remote-test-dir)/$(platform)-$(arch)$(options)/run-tests.sh"
endif endif
.PHONY: jdk-test
jdk-test: $(test-dep) $(build)/jdk-run-tests.sh $(build)/test.sh
/bin/sh $(build)/jdk-run-tests.sh
PHONY: audit-baseline PHONY: audit-baseline
audit-baseline: $(audit-codegen-executable) audit-baseline: $(audit-codegen-executable)
$(<) -output $(build)/codegen-audit-output/baseline.o -format macho $(<) -output $(build)/codegen-audit-output/baseline.o -format macho
@ -1495,6 +1499,13 @@ $(build)/run-tests.sh: $(test-classes) makefile $(build)/extra-dir/multi-classpa
echo "$(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \\" >> $(@) echo "$(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \\" >> $(@)
echo "$(continuation-tests) $(tail-tests)" >> $(@) echo "$(continuation-tests) $(tail-tests)" >> $(@)
$(build)/jdk-run-tests.sh: $(test-classes) makefile $(build)/extra-dir/multi-classpath-test.txt $(build)/test/multi-classpath-test.txt
echo 'cd $$(dirname $$0)' > $(@)
echo "sh ./test.sh 2>/dev/null \\" >> $(@)
echo "$(shell echo $(library-path) | sed 's|$(build)|\.|g') /bin/true $(JAVA_HOME)/bin/java $(mode) \"-Djava.library.path=. -cp test:extra-dir:classpath\" \\" >> $(@)
echo "$(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \\" >> $(@)
echo "$(continuation-tests) $(tail-tests)" >> $(@)
$(build)/extra-dir/multi-classpath-test.txt: $(build)/extra-dir/multi-classpath-test.txt:
mkdir -p $(build)/extra-dir mkdir -p $(build)/extra-dir
echo "$@" > $@ echo "$@" > $@

View File

@ -70,7 +70,7 @@ public class LazyLoading {
if (loadLazy) { if (loadLazy) {
return findClass(name); return findClass(name);
} else { } else {
throw new ClassNotFoundException(); throw new ClassNotFoundException(name);
} }
} else { } else {
return super.loadClass(name); return super.loadClass(name);

View File

@ -2,6 +2,7 @@
set -e set -e
make ${flags} jdk-test
make ${flags} test make ${flags} test
make ${flags} mode=debug test make ${flags} mode=debug test
make ${flags} process=interpret test make ${flags} process=interpret test