From bc5661d6f387675b40b4805ca9e7be37df20a0ce Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 18 Feb 2012 15:17:10 -0700 Subject: [PATCH 01/35] start work on OpenJDK 7 class library port --- .../lang/ReflectiveOperationException.java | 13 ++ openjdk-src.mk | 19 +- src/classpath-openjdk.cpp | 209 +++++++++--------- src/types.def | 2 + 4 files changed, 139 insertions(+), 104 deletions(-) create mode 100644 classpath/java/lang/ReflectiveOperationException.java diff --git a/classpath/java/lang/ReflectiveOperationException.java b/classpath/java/lang/ReflectiveOperationException.java new file mode 100644 index 0000000000..e3c8c0872f --- /dev/null +++ b/classpath/java/lang/ReflectiveOperationException.java @@ -0,0 +1,13 @@ +/* Copyright (c) 2012, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +package java.lang; + +public class ReflectiveOperationException extends Exception { } diff --git a/openjdk-src.mk b/openjdk-src.mk index 28166a9542..a2dd051cce 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -45,7 +45,6 @@ openjdk-sources = \ $(openjdk-src)/share/native/java/util/zip/CRC32.c \ $(openjdk-src)/share/native/java/util/zip/Deflater.c \ $(openjdk-src)/share/native/java/util/zip/Inflater.c \ - $(openjdk-src)/share/native/java/util/zip/ZipEntry.c \ $(openjdk-src)/share/native/java/util/zip/ZipFile.c \ $(openjdk-src)/share/native/java/util/zip/zip_util.c \ $(openjdk-src)/share/native/sun/management/VMManagementImpl.c \ @@ -76,6 +75,7 @@ openjdk-headers-classes = \ java.lang.Double \ java.lang.Float \ java.lang.Integer \ + java.lang.Long \ java.lang.Object \ java.lang.Package \ java.lang.Runtime \ @@ -124,7 +124,7 @@ openjdk-headers-classes = \ sun.net.spi.DefaultProxySelector \ sun.nio.ch.FileKey \ sun.nio.ch.FileChannelImpl \ - sun.nio.ch.FileDispatcher \ + sun.nio.ch.FileDispatcherImpl \ sun.nio.ch.DatagramChannelImpl \ sun.nio.ch.DatagramDispatcher \ sun.nio.ch.IOStatus \ @@ -235,6 +235,10 @@ ifeq ($(platform),windows) else openjdk-sources += \ $(openjdk-src)/solaris/native/common/jdk_util_md.c \ + $(openjdk-src)/solaris/native/common/jni_util_md.c \ + $(openjdk-src)/solaris/native/common/deps/syscalls_fp.c \ + $(openjdk-src)/solaris/native/common/deps/gconf2/gconf_fp.c \ + $(openjdk-src)/solaris/native/common/deps/glib2/gio_fp.c \ $(openjdk-src)/solaris/native/java/io/canonicalize_md.c \ $(openjdk-src)/solaris/native/java/io/Console_md.c \ $(openjdk-src)/solaris/native/java/io/FileDescriptor_md.c \ @@ -265,7 +269,7 @@ else $(openjdk-src)/solaris/native/sun/nio/ch/DatagramChannelImpl.c \ $(openjdk-src)/solaris/native/sun/nio/ch/DatagramDispatcher.c \ $(openjdk-src)/solaris/native/sun/nio/ch/FileChannelImpl.c \ - $(openjdk-src)/solaris/native/sun/nio/ch/FileDispatcher.c \ + $(openjdk-src)/solaris/native/sun/nio/ch/FileDispatcherImpl.c \ $(openjdk-src)/solaris/native/sun/nio/ch/FileKey.c \ $(openjdk-src)/solaris/native/sun/nio/ch/IOUtil.c \ $(openjdk-src)/solaris/native/sun/nio/ch/Net.c \ @@ -276,6 +280,7 @@ else $(openjdk-src)/solaris/native/sun/nio/ch/PollArrayWrapper.c \ $(openjdk-src)/solaris/native/sun/nio/ch/InheritedChannel.c \ $(openjdk-src)/solaris/native/sun/nio/ch/NativeThread.c \ + $(openjdk-src)/solaris/native/sun/nio/fs/UnixNativeDispatcher.c \ ifeq ($(platform),linux) openjdk-sources += \ @@ -287,6 +292,7 @@ else java.io.UnixFileSystem \ sun.nio.ch.InheritedChannel \ sun.nio.ch.EPollArrayWrapper \ + sun.nio.fs.UnixNativeDispatcher \ openjdk-cflags += "-I$(openjdk-src)/solaris/javavm/export" \ "-I$(openjdk-src)/solaris/native/common" \ @@ -297,7 +303,12 @@ else "-I$(openjdk-src)/solaris/native/sun/management" \ "-I$(openjdk-src)/solaris/native/sun/nio/ch" \ "-I$(openjdk-src)/solaris/javavm/include" \ - "-I$(openjdk-src)/solaris/hpi/include" + "-I$(openjdk-src)/solaris/hpi/include" \ + "-I$(openjdk-src)/solaris/native/common/deps" \ + "-I$(openjdk-src)/solaris/native/common/deps/glib2" \ + "-I$(openjdk-src)/solaris/native/common/deps/gconf2" \ + $(shell pkg-config --cflags glib-2.0) \ + $(shell pkg-config --cflags gconf-2.0) endif openjdk-local-sources = \ diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index c2b8471dde..a7f8539e79 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -551,31 +551,12 @@ class MyClasspath : public Classpath { expect(t, loadLibrary(t, libraryPath, "java", true, true)); #endif // not AVIAN_OPENJDK_SRC - object constructor = resolveMethod - (t, type(t, Machine::ClassLoaderType), "", - "(Ljava/lang/ClassLoader;)V"); + object assertionLock = resolveField + (t, type(t, Machine::ClassLoaderType), "assertionLock", + "Ljava/lang/Object;"); - PROTECT(t, constructor); - - t->m->processor->invoke(t, constructor, root(t, Machine::BootLoader), 0); - - t->m->processor->invoke - (t, constructor, root(t, Machine::AppLoader), - root(t, Machine::BootLoader)); - - object scl = resolveField - (t, type(t, Machine::ClassLoaderType), "scl", "Ljava/lang/ClassLoader;"); - - PROTECT(t, scl); - - object sclSet = resolveField - (t, type(t, Machine::ClassLoaderType), "sclSet", "Z"); - - set(t, classStaticTable(t, type(t, Machine::ClassLoaderType)), - fieldOffset(t, scl), root(t, Machine::AppLoader)); - - cast(classStaticTable(t, type(t, Machine::ClassLoaderType)), - fieldOffset(t, sclSet)) = true; + set(t, root(t, Machine::BootLoader), fieldOffset(t, assertionLock), + root(t, Machine::BootLoader)); t->m->processor->invoke (t, root(t, Machine::BootLoader), "java/lang/System", @@ -1318,15 +1299,17 @@ getZipFileEntry(Thread* t, object method, uintptr_t* arguments) ZipFile* file = reinterpret_cast(peer); if (file->region) { - THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 2); - stringChars(t, path, RUNTIME_ARRAY_BODY(p)); + THREAD_RUNTIME_ARRAY(t, char, p, byteArrayLength(t, path) + 2); + memcpy(RUNTIME_ARRAY_BODY(p), &byteArrayBody(t, path, 0), + byteArrayLength(t, path)); + RUNTIME_ARRAY_BODY(p)[byteArrayLength(t, path)] = 0; replace('\\', '/', RUNTIME_ARRAY_BODY(p)); if (addSlash) { - RUNTIME_ARRAY_BODY(p)[stringLength(t, path)] = '/'; - RUNTIME_ARRAY_BODY(p)[stringLength(t, path) + 1] = 0; + RUNTIME_ARRAY_BODY(p)[byteArrayLength(t, path)] = '/'; + RUNTIME_ARRAY_BODY(p)[byteArrayLength(t, path) + 1] = 0; } - return reinterpret_cast(find(file, p, stringLength(t, path))); + return reinterpret_cast(find(file, p, byteArrayLength(t, path))); } else { int64_t entry = longValue (t, t->m->processor->invoke @@ -1340,6 +1323,43 @@ getZipFileEntry(Thread* t, object method, uintptr_t* arguments) } } +int64_t JNICALL +getZipFileEntryBytes(Thread* t, object method, uintptr_t* arguments) +{ + int64_t peer; memcpy(&peer, arguments, 8); + int type = arguments[2]; + + ZipFile::Entry* entry = reinterpret_cast(peer); + if (entry->start) { + switch (type) { + case 0: { // name + unsigned nameLength = fileNameLength(entry->start); + object array = makeByteArray(t, nameLength + 1); + memcpy(&byteArrayBody(t, array, 0), fileName(entry->start), nameLength); + byteArrayBody(t, array, nameLength) = 0; + return reinterpret_cast(array); + } break; + + case 1: { // extra + return 0; + } break; + + case 2: { // comment + return 0; + } break; + + default: abort(t); + } + return compressedSize(entry->start); + } else { + return reinterpret_cast + (t->m->processor->invoke + (t, nativeInterceptOriginal + (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))), + 0, entry->entry, type)); + } +} + int64_t JNICALL getNextZipFileEntry(Thread* t, object method, uintptr_t* arguments) { @@ -1703,6 +1723,11 @@ intercept(Thread* t, object c, const char* name, const char* spec, object runtimeData = getMethodRuntimeData(t, m); set(t, runtimeData, MethodRuntimeDataNative, native); + } else { + fprintf(stderr, "unable to find %s%s in %s\n", + name, spec, &byteArrayBody(t, className(t, c), 0)); + + abort(t); } } @@ -1770,60 +1795,6 @@ interceptFileOperations(Thread* t) } } - { object zipEntryClass = resolveClass - (t, root(t, Machine::BootLoader), "java/util/zip/ZipEntry", false); - - if (zipEntryClass) { - PROTECT(t, zipEntryClass); - - object zipEntryNameField = findFieldInClass2 - (t, zipEntryClass, "name", "Ljava/lang/String;"); - - if (zipEntryNameField) { - cp->zipEntryNameField = fieldOffset(t, zipEntryNameField); - - object zipEntryTimeField = findFieldInClass2 - (t, zipEntryClass, "time", "J"); - - if (zipEntryTimeField) { - cp->zipEntryTimeField = fieldOffset(t, zipEntryTimeField); - - object zipEntryCrcField = findFieldInClass2 - (t, zipEntryClass, "crc", "J"); - - if (zipEntryCrcField) { - cp->zipEntryCrcField = fieldOffset(t, zipEntryCrcField); - - object zipEntrySizeField = findFieldInClass2 - (t, zipEntryClass, "size", "J"); - - if (zipEntrySizeField) { - cp->zipEntrySizeField = fieldOffset(t, zipEntrySizeField); - - object zipEntryCsizeField = findFieldInClass2 - (t, zipEntryClass, "csize", "J"); - - if (zipEntryCsizeField) { - cp->zipEntryCsizeField = fieldOffset(t, zipEntryCsizeField); - - object zipEntryMethodField = findFieldInClass2 - (t, zipEntryClass, "method", "I"); - - if (zipEntryMethodField) { - cp->zipEntryMethodField = fieldOffset - (t, zipEntryMethodField); - - intercept(t, zipEntryClass, "initFields", "(J)V", - voidPointer(initializeZipEntryFields)); - } - } - } - } - } - } - } - } - { object zipFileClass = resolveClass (t, root(t, Machine::BootLoader), "java/util/zip/ZipFile", false); @@ -1836,19 +1807,22 @@ interceptFileOperations(Thread* t) if (zipFileJzfileField) { cp->zipFileJzfileField = fieldOffset(t, zipFileJzfileField); - intercept(t, zipFileClass, "open", "(Ljava/lang/String;IJ)J", + intercept(t, zipFileClass, "open", "(Ljava/lang/String;IJZ)J", voidPointer(openZipFile)); intercept(t, zipFileClass, "getTotal", "(J)I", voidPointer(getZipFileEntryCount)); - intercept(t, zipFileClass, "getEntry", "(JLjava/lang/String;Z)J", + intercept(t, zipFileClass, "getEntry", "(J[BZ)J", voidPointer(getZipFileEntry)); + intercept(t, zipFileClass, "getEntryBytes", "(JI)[B", + voidPointer(getZipFileEntryBytes)); + intercept(t, zipFileClass, "getNextEntry", "(JI)J", voidPointer(getNextZipFileEntry)); - intercept(t, zipFileClass, "getMethod", "(J)I", + intercept(t, zipFileClass, "getEntryMethod", "(J)I", voidPointer(getZipFileEntryMethod)); intercept(t, zipFileClass, "freeEntry", "(JJ)V", @@ -1857,10 +1831,10 @@ interceptFileOperations(Thread* t) intercept(t, zipFileClass, "read", "(JJJ[BII)I", voidPointer(readZipFileEntry)); - intercept(t, zipFileClass, "getCSize", "(J)J", + intercept(t, zipFileClass, "getEntryCSize", "(J)J", voidPointer(getZipFileEntryCompressedSize)); - intercept(t, zipFileClass, "getSize", "(J)J", + intercept(t, zipFileClass, "getEntrySize", "(J)J", voidPointer(getZipFileEntryUncompressedSize)); intercept(t, zipFileClass, "getZipMessage", "(J)Ljava/lang/String;", @@ -2560,6 +2534,13 @@ Avian_sun_misc_Unsafe_putObjectVolatile storeLoadMemoryBarrier(); } +extern "C" JNIEXPORT void JNICALL +Avian_sun_misc_Unsafe_putOrderedObject +(Thread* t, object method, uintptr_t* arguments) +{ + Avian_sun_misc_Unsafe_putObjectVolatile(t, method, arguments); +} + extern "C" JNIEXPORT int64_t JNICALL Avian_sun_misc_Unsafe_compareAndSwapInt (Thread*, object, uintptr_t* arguments) @@ -2782,6 +2763,32 @@ Avian_sun_misc_Unsafe_park monitorRelease(t, local::interruptLock(t, t->javaThread)); } +extern "C" JNIEXPORT void JNICALL +Avian_sun_misc_Unsafe_copyMemory +(Thread* t, object, uintptr_t* arguments) +{ + object srcBase = reinterpret_cast(arguments[1]); + int64_t srcOffset; memcpy(&srcOffset, arguments + 2, 8); + object dstBase = reinterpret_cast(arguments[4]); + int64_t dstOffset; memcpy(&dstOffset, arguments + 5, 8); + int64_t count; memcpy(&count, arguments + 7, 8); + + PROTECT(t, srcBase); + PROTECT(t, dstBase); + + ACQUIRE(t, t->m->referenceLock); + + void* src = srcBase + ? &cast(srcBase, srcOffset) + : reinterpret_cast(srcOffset); + + void* dst = dstBase + ? &cast(dstBase, dstOffset) + : reinterpret_cast(dstOffset); + + memcpy(dst, src, count); +} + namespace { namespace local { @@ -3153,7 +3160,7 @@ jvmFillInStackTrace(Thread* t, uintptr_t* arguments) { jobject throwable = reinterpret_cast(arguments[0]); - object trace = getTrace(t, 1); + object trace = getTrace(t, 2); set(t, *throwable, ThrowableTrace, trace); return 1; @@ -3834,10 +3841,9 @@ EXPORT(JVM_FindClassFromClassLoader)(Thread* t, const char* name, } extern "C" JNIEXPORT jclass JNICALL -EXPORT(JVM_FindClassFromBootLoader)(Thread* t, const char* name, - jboolean throwError) +EXPORT(JVM_FindClassFromBootLoader)(Thread* t, const char* name) { - return EXPORT(JVM_FindClassFromClassLoader)(t, name, false, 0, throwError); + return EXPORT(JVM_FindClassFromClassLoader)(t, name, false, 0, false); } extern "C" JNIEXPORT jclass JNICALL @@ -4265,9 +4271,9 @@ jvmGetClassDeclaredMethods(Thread* t, uintptr_t* arguments) } object method = makeJmethod - (t, true, *c, i, name, returnType, parameterTypes, exceptionTypes, + (t, true, 0, *c, i, name, returnType, parameterTypes, exceptionTypes, methodFlags(t, vmMethod), signature, 0, annotationTable, 0, - annotationDefault, 0, 0, 0, 0, 0); + annotationDefault, 0, 0, 0); assert(t, ai < objectArrayLength(t, array)); @@ -4354,8 +4360,8 @@ jvmGetClassDeclaredFields(Thread* t, uintptr_t* arguments) } object field = makeJfield - (t, true, *c, i, name, type, fieldFlags - (t, vmField), signature, 0, annotationTable, 0, 0, 0, 0, 0, 0); + (t, true, 0, *c, i, name, type, fieldFlags + (t, vmField), signature, 0, annotationTable, 0, 0, 0, 0); assert(t, ai < objectArrayLength(t, array)); @@ -4445,8 +4451,8 @@ jvmGetClassDeclaredConstructors(Thread* t, uintptr_t* arguments) } object method = makeJconstructor - (t, true, *c, i, parameterTypes, exceptionTypes, methodFlags - (t, vmMethod), signature, 0, annotationTable, 0, 0, 0, 0, 0); + (t, true, 0, *c, i, parameterTypes, exceptionTypes, methodFlags + (t, vmMethod), signature, 0, annotationTable, 0, 0, 0, 0); assert(t, ai < objectArrayLength(t, array)); @@ -5298,8 +5304,11 @@ extern "C" JNIEXPORT jobjectArray JNICALL EXPORT(JVM_GetThreadStateNames)(JNIEnv*, jint, jintArray) { abort(); } extern "C" JNIEXPORT void JNICALL -EXPORT(JVM_GetVersionInfo)(JNIEnv*, local::jvm_version_info*, size_t) -{ abort(); } +EXPORT(JVM_GetVersionInfo)(JNIEnv*, local::jvm_version_info* info, size_t size) +{ + memset(info, 0, size); + info->jvm_version = 0x01070000; +} extern "C" JNIEXPORT jboolean JNICALL EXPORT(JVM_CX8Field)(JNIEnv*, jobject*, jfieldID*, jlong, jlong) diff --git a/src/types.def b/src/types.def index c95ed03a0a..8bac2a7bce 100644 --- a/src/types.def +++ b/src/types.def @@ -219,6 +219,8 @@ (type negativeArraySizeException java/lang/NegativeArraySizeException) +(type reflectiveOperationException java/lang/ReflectiveOperationException) + (type classCastException java/lang/ClassCastException) (type classNotFoundException java/lang/ClassNotFoundException) From 3111f0743090e2094afe94d362c7583badd6a288 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 20 Feb 2012 17:23:18 -0700 Subject: [PATCH 02/35] add "throws IOException" to java.io.File.createTempFile --- classpath/java/io/File.java | 9 +++++++-- test/Files.java | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/classpath/java/io/File.java b/classpath/java/io/File.java index bfae0da9b6..a77502c041 100644 --- a/classpath/java/io/File.java +++ b/classpath/java/io/File.java @@ -35,11 +35,16 @@ public class File implements Serializable { this(parent.getPath() + FileSeparator + child); } - public static File createTempFile(String prefix, String suffix) { + public static File createTempFile(String prefix, String suffix) + throws IOException + { return createTempFile(prefix, suffix, null); } - public static File createTempFile(String prefix, String suffix, File directory) { + public static File createTempFile(String prefix, String suffix, + File directory) + throws IOException + { if(directory == null) { directory = new File(System.getProperty("java.io.tmpdir")); } diff --git a/test/Files.java b/test/Files.java index 7661e79018..f3d1988f31 100644 --- a/test/Files.java +++ b/test/Files.java @@ -21,7 +21,9 @@ public class Files { } - private static void setExecutableTestWithPermissions(boolean executable) { + private static void setExecutableTestWithPermissions(boolean executable) + throws Exception + { File file = File.createTempFile("avian.", null); file.setExecutable(executable); if (executable) { @@ -33,7 +35,7 @@ public class Files { } } - public static void main(String[] args) { + public static void main(String[] args) throws Exception { isAbsoluteTest(true); isAbsoluteTest(false); setExecutableTestWithPermissions(true); From d94fd952e99901df7e96f70b76168170c714cf92 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 20 Feb 2012 17:38:41 -0700 Subject: [PATCH 03/35] fix some OpenJDK update regressions --- src/classpath-openjdk.cpp | 70 ++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index a7f8539e79..055b2f1350 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -551,12 +551,61 @@ class MyClasspath : public Classpath { expect(t, loadLibrary(t, libraryPath, "java", true, true)); #endif // not AVIAN_OPENJDK_SRC - object assertionLock = resolveField - (t, type(t, Machine::ClassLoaderType), "assertionLock", - "Ljava/lang/Object;"); + { object class_ = resolveClass + (t, root(t, Machine::BootLoader), "java/util/Properties", true, + Machine::NoClassDefFoundErrorType); - set(t, root(t, Machine::BootLoader), fieldOffset(t, assertionLock), - root(t, Machine::BootLoader)); + PROTECT(t, class_); + + object instance = makeNew(t, class_); + + PROTECT(t, instance); + + object constructor = resolveMethod(t, class_, "", "()V"); + + t->m->processor->invoke(t, constructor, instance); + + t->m->processor->invoke + (t, root(t, Machine::BootLoader), "java/lang/System", + "setProperties", "(Ljava/util/Properties;)V", 0, instance); + } + + { object constructor = resolveMethod + (t, type(t, Machine::ClassLoaderType), "", + "(Ljava/lang/ClassLoader;)V"); + + PROTECT(t, constructor); + + t->m->processor->invoke(t, constructor, root(t, Machine::BootLoader), 0); + + t->m->processor->invoke + (t, constructor, root(t, Machine::AppLoader), + root(t, Machine::BootLoader)); + } + + { object assertionLock = resolveField + (t, type(t, Machine::ClassLoaderType), "assertionLock", + "Ljava/lang/Object;"); + + set(t, root(t, Machine::BootLoader), fieldOffset(t, assertionLock), + root(t, Machine::BootLoader)); + } + + { object scl = resolveField + (t, type(t, Machine::ClassLoaderType), "scl", + "Ljava/lang/ClassLoader;"); + + PROTECT(t, scl); + + object sclSet = resolveField + (t, type(t, Machine::ClassLoaderType), "sclSet", "Z"); + + set(t, classStaticTable(t, type(t, Machine::ClassLoaderType)), + fieldOffset(t, scl), root(t, Machine::AppLoader)); + + cast(classStaticTable(t, type(t, Machine::ClassLoaderType)), + fieldOffset(t, sclSet)) = true; + } t->m->processor->invoke (t, root(t, Machine::BootLoader), "java/lang/System", @@ -2622,11 +2671,14 @@ extern "C" JNIEXPORT void JNICALL Avian_sun_misc_Unsafe_setMemory (Thread*, object, uintptr_t* arguments) { - int64_t p; memcpy(&p, arguments + 1, 8); - int64_t count; memcpy(&count, arguments + 3, 8); - int8_t v = arguments[5]; + object base = reinterpret_cast(arguments[1]); + int64_t offset; memcpy(&offset, arguments + 2, 8); + int64_t count; memcpy(&count, arguments + 4, 8); + int8_t v = arguments[6]; - memset(reinterpret_cast(p), v, count); + memset(base + ? &cast(base, offset) + : reinterpret_cast(offset), v, count); } extern "C" JNIEXPORT void JNICALL From 747f22115f872fb03cb9242684ba99a99da07b84 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 21 Feb 2012 17:32:20 -0700 Subject: [PATCH 04/35] handle JMM_THREAD_ALLOCATED_MEMORY in JMX GetBoolAttribute implementation --- src/classpath-openjdk.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 055b2f1350..ea7012e921 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -5271,9 +5271,11 @@ jboolean JNICALL GetBoolAttribute(Thread* t, jmmBoolAttribute attribute) { const unsigned JMM_THREAD_CPU_TIME = 24; + const unsigned JMM_THREAD_ALLOCATED_MEMORY = 25; switch (attribute) { case JMM_THREAD_CPU_TIME: + case JMM_THREAD_ALLOCATED_MEMORY: return false; default: From c3b72a3dd544b9362bbed58de0d0207b52ddaeca Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 29 Feb 2012 11:46:50 -0700 Subject: [PATCH 05/35] set sun.boot.class.path property in jvmInitProperties --- src/classpath-openjdk.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index ea7012e921..e1fde3ba5d 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -3015,22 +3015,22 @@ jvmInitProperties(Thread* t, uintptr_t* arguments) GetCurrentDirectory(MAX_PATH, buffer); local::setProperty(t, method, *properties, "user.dir", buffer); -#else +#else // not PLATFORM_WINDOWS local::setProperty(t, method, *properties, "line.separator", "\n"); local::setProperty(t, method, *properties, "file.separator", "/"); local::setProperty(t, method, *properties, "path.separator", ":"); # ifdef __APPLE__ local::setProperty(t, method, *properties, "os.name", "Mac OS X"); -# else +# else // not __APPLE__ local::setProperty(t, method, *properties, "os.name", "Linux"); -# endif +# endif // not __APPLE__ local::setProperty(t, method, *properties, "java.io.tmpdir", "/tmp"); local::setProperty(t, method, *properties, "user.home", getenv("HOME")); char buffer[PATH_MAX]; local::setProperty(t, method, *properties, "user.dir", getcwd(buffer, PATH_MAX)); -#endif +#endif // not PLATFORM_WINDOWS local::setProperty(t, method, *properties, "java.protocol.handler.pkgs", "avian"); @@ -3046,6 +3046,11 @@ jvmInitProperties(Thread* t, uintptr_t* arguments) (t, method, *properties, "sun.boot.library.path", static_cast(t->m->classpath)->libraryPath); + local::setProperty + (t, method, *properties, "sun.boot.class.path", + static_cast + (systemClassLoaderFinder(t, root(t, Machine::BootLoader)))->path()); + local::setProperty(t, method, *properties, "file.encoding", "ASCII"); #ifdef ARCH_x86_32 local::setProperty(t, method, *properties, "os.arch", "x86"); From 0be731863798d6015d60c4686616e1239fea301a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 29 Feb 2012 11:48:06 -0700 Subject: [PATCH 06/35] minor whitespace change --- src/jnienv.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 34f82efc65..a4460689ed 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -3358,8 +3358,7 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args) *(argumentPointer++) = a->options[i].optionString; } - *m = new (h->allocate(sizeof(Machine))) - Machine + *m = new (h->allocate(sizeof(Machine))) Machine (s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions); *t = p->makeThread(*m, 0, 0); From 3820fec9d75b5312f2898dad82ac8f6b839c7081 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 11 Mar 2012 16:26:46 -0600 Subject: [PATCH 07/35] fix OS X OpenJDK 7 build --- makefile | 3 ++- openjdk-src.mk | 46 +++++++++++++++++++++++++-------------- src/classpath-openjdk.cpp | 31 ++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/makefile b/makefile index 9408df6d9c..636bbf2147 100755 --- a/makefile +++ b/makefile @@ -310,7 +310,8 @@ ifeq ($(platform),darwin) version-script-flag = lflags = $(common-lflags) -ldl -framework CoreFoundation ifneq ($(arch),arm) - lflags += -framework CoreServices + lflags += -framework CoreServices -framework SystemConfiguration \ + -framework Security endif ifeq ($(bootimage),true) bootimage-lflags = -Wl,-segprot,__RWX,rwx,rwx diff --git a/openjdk-src.mk b/openjdk-src.mk index a2dd051cce..dfe455b4bb 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -236,9 +236,6 @@ else openjdk-sources += \ $(openjdk-src)/solaris/native/common/jdk_util_md.c \ $(openjdk-src)/solaris/native/common/jni_util_md.c \ - $(openjdk-src)/solaris/native/common/deps/syscalls_fp.c \ - $(openjdk-src)/solaris/native/common/deps/gconf2/gconf_fp.c \ - $(openjdk-src)/solaris/native/common/deps/glib2/gio_fp.c \ $(openjdk-src)/solaris/native/java/io/canonicalize_md.c \ $(openjdk-src)/solaris/native/java/io/Console_md.c \ $(openjdk-src)/solaris/native/java/io/FileDescriptor_md.c \ @@ -276,25 +273,19 @@ else $(openjdk-src)/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c \ $(openjdk-src)/solaris/native/sun/nio/ch/SocketChannelImpl.c \ $(openjdk-src)/solaris/native/sun/nio/ch/SocketDispatcher.c \ - $(openjdk-src)/solaris/native/sun/nio/ch/EPollArrayWrapper.c \ $(openjdk-src)/solaris/native/sun/nio/ch/PollArrayWrapper.c \ $(openjdk-src)/solaris/native/sun/nio/ch/InheritedChannel.c \ $(openjdk-src)/solaris/native/sun/nio/ch/NativeThread.c \ $(openjdk-src)/solaris/native/sun/nio/fs/UnixNativeDispatcher.c \ - ifeq ($(platform),linux) - openjdk-sources += \ - $(openjdk-src)/solaris/native/java/net/linux_close.c - endif - openjdk-headers-classes += \ java.net.PlainDatagramSocketImpl \ java.io.UnixFileSystem \ sun.nio.ch.InheritedChannel \ - sun.nio.ch.EPollArrayWrapper \ sun.nio.fs.UnixNativeDispatcher \ - openjdk-cflags += "-I$(openjdk-src)/solaris/javavm/export" \ + openjdk-cflags += \ + "-I$(openjdk-src)/solaris/javavm/export" \ "-I$(openjdk-src)/solaris/native/common" \ "-I$(openjdk-src)/solaris/native/java/io" \ "-I$(openjdk-src)/solaris/native/java/lang" \ @@ -304,11 +295,34 @@ else "-I$(openjdk-src)/solaris/native/sun/nio/ch" \ "-I$(openjdk-src)/solaris/javavm/include" \ "-I$(openjdk-src)/solaris/hpi/include" \ - "-I$(openjdk-src)/solaris/native/common/deps" \ - "-I$(openjdk-src)/solaris/native/common/deps/glib2" \ - "-I$(openjdk-src)/solaris/native/common/deps/gconf2" \ - $(shell pkg-config --cflags glib-2.0) \ - $(shell pkg-config --cflags gconf-2.0) + "-I$(openjdk-src)/solaris/native/common/deps" + + ifeq ($(platform),linux) + openjdk-sources += \ + $(openjdk-src)/solaris/native/java/net/linux_close.c \ + $(openjdk-src)/solaris/native/common/deps/syscalls_fp.c \ + $(openjdk-src)/solaris/native/common/deps/gconf2/gconf_fp.c \ + $(openjdk-src)/solaris/native/common/deps/glib2/gio_fp.c \ + $(openjdk-src)/solaris/native/sun/nio/ch/EPollArrayWrapper.c + + openjdk-headers-classes += \ + sun.nio.ch.EPollArrayWrapper + + openjdk-cflags += \ + "-I$(openjdk-src)/solaris/native/common/deps/glib2" \ + "-I$(openjdk-src)/solaris/native/common/deps/gconf2" \ + $(shell pkg-config --cflags glib-2.0) \ + $(shell pkg-config --cflags gconf-2.0) + endif + + ifeq ($(platform),darwin) + openjdk-sources += \ + $(openjdk-src)/solaris/native/java/lang/java_props_macosx.c \ + $(openjdk-src)/solaris/native/java/net/bsd_close.c + + openjdk-cflags += \ + -DMACOSX + endif endif openjdk-local-sources = \ diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 713bea71ec..184fd81667 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -440,9 +440,14 @@ class MyClasspath : public Classpath { PROTECT(t, class_); object name = makeClassNameString(t, getClassName(t, class_)); + PROTECT(t, name); - return vm::makeJclass - (t, 0, 0, name, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, class_); + object c = allocate(t, FixedSizeOfJclass, true); + setObjectClass(t, c, type(t, Machine::JclassType)); + set(t, c, JclassName, name); + set(t, c, JclassVmClass, class_); + + return c; } virtual object @@ -2299,6 +2304,24 @@ Avian_sun_misc_Unsafe_registerNatives // ignore } +extern "C" JNIEXPORT void +Avian_sun_misc_Perf_registerNatives +(Thread*, object, uintptr_t*) +{ + // ignore +} + +extern "C" JNIEXPORT int64_t +Avian_sun_misc_Perf_createLong +(Thread* t, object, uintptr_t*) +{ + return reinterpret_cast + (t->m->processor->invoke + (t, resolveMethod + (t, root(t, Machine::BootLoader), "java/nio/ByteBuffer", "allocate", + "(I)Ljava/nio/ByteBuffer;"), 0, 8)); +} + extern "C" JNIEXPORT int64_t Avian_sun_misc_Unsafe_addressSize (Thread*, object, uintptr_t*) @@ -2750,6 +2773,7 @@ Avian_sun_misc_Unsafe_copyMemory memcpy(dst, src, count); } +extern "C" JNIEXPORT void JNICALL Avian_sun_misc_Unsafe_monitorEnter (Thread* t, object, uintptr_t* arguments) { @@ -5308,6 +5332,9 @@ extern "C" JNIEXPORT jboolean JNICALL EXPORT(JVM_CX8Field)(JNIEnv*, jobject*, jfieldID*, jlong, jlong) { abort(); } +extern "C" JNIEXPORT void JNICALL +JVM_SetNativeThreadName(JNIEnv*, jobject, jstring) { abort(); } + } // namespace local } // namespace From 3817bc280e583bcd21c894879ab23cc75c8fe87f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 11 Mar 2012 17:46:36 -0600 Subject: [PATCH 08/35] heretofore untested iOS OpenJDK support --- makefile | 48 ++++++++++++++++++++++++++++++ openjdk-src.mk | 11 +++++-- src/openjdk/my_java_props_macosx.c | 28 +++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/openjdk/my_java_props_macosx.c diff --git a/makefile b/makefile index 636bbf2147..64429c1725 100755 --- a/makefile +++ b/makefile @@ -990,6 +990,18 @@ $(openjdk-objects): $(build)/openjdk/%-openjdk.o: $(openjdk-src)/%.c \ @echo "compiling $(@)" @mkdir -p $(dir $(@)) sed 's/^static jclass ia_class;//' < $(<) > $(build)/openjdk/$(notdir $(<)) +ifeq ($(ios),true) + sed \ + -e 's/^#ifndef __APPLE__/#if 1/' \ + -e 's/^#ifdef __APPLE__/#if 0/' \ + < "$(openjdk-src)/solaris/native/java/lang/ProcessEnvironment_md.c" \ + > $(build)/openjdk/ProcessEnvironment_md.c + sed \ + -e 's/^#ifndef __APPLE__/#if 1/' \ + -e 's/^#ifdef __APPLE__/#if 0/' \ + < "$(openjdk-src)/solaris/native/java/lang/UNIXProcess_md.c" \ + > $(build)/openjdk/UNIXProcess_md.c +endif $(cc) -fPIC $(openjdk-extra-cflags) $(openjdk-cflags) \ $(optimization-cflags) -w -c $(build)/openjdk/$(notdir $(<)) \ $(call output,$(@)) @@ -1020,6 +1032,42 @@ ifeq ($(platform),windows) < "$(openjdk-src)/windows/native/java/net/NetworkInterface.h" \ > $(build)/openjdk/NetworkInterface.h echo 'static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);' >> $(build)/openjdk/NetworkInterface.h +endif +ifeq ($(platform),darwin) + mkdir -p $(build)/openjdk/netinet + for file in \ + /usr/include/netinet/ip.h \ + /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip_icmp.h \ + /usr/include/netinet/in_var.h \ + /usr/include/netinet/icmp6.h \ + /usr/include/netinet/ip_var.h; do \ + if [ ! -f "$(build)/openjdk/netinet/$$(basename $${file})" ]; then \ + ln "$${file}" "$(build)/openjdk/netinet/$$(basename $${file})"; \ + fi; \ + done + mkdir -p $(build)/openjdk/netinet6 + for file in \ + /usr/include/netinet6/in6_var.h; do \ + if [ ! -f "$(build)/openjdk/netinet6/$$(basename $${file})" ]; then \ + ln "$${file}" "$(build)/openjdk/netinet6/$$(basename $${file})"; \ + fi; \ + done + mkdir -p $(build)/openjdk/net + for file in \ + /usr/include/net/if_arp.h; do \ + if [ ! -f "$(build)/openjdk/net/$$(basename $${file})" ]; then \ + ln "$${file}" "$(build)/openjdk/net/$$(basename $${file})"; \ + fi; \ + done + mkdir -p $(build)/openjdk/sys + for file in \ + /usr/include/sys/kern_event.h \ + /usr/include/sys/sys_domain.h; do \ + if [ ! -f "$(build)/openjdk/sys/$$(basename $${file})" ]; then \ + ln "$${file}" "$(build)/openjdk/sys/$$(basename $${file})"; \ + fi; \ + done endif @touch $(@) diff --git a/openjdk-src.mk b/openjdk-src.mk index dfe455b4bb..6735471fea 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -317,15 +317,22 @@ else ifeq ($(platform),darwin) openjdk-sources += \ - $(openjdk-src)/solaris/native/java/lang/java_props_macosx.c \ $(openjdk-src)/solaris/native/java/net/bsd_close.c + ifeq ($(ios),true) + openjdk-local-sources += \ + $(src)/openjdk/my_java_props_macosx.c + else + openjdk-sources += \ + $(openjdk-src)/solaris/native/java/lang/java_props_macosx.c + endif + openjdk-cflags += \ -DMACOSX endif endif -openjdk-local-sources = \ +openjdk-local-sources += \ $(src)/openjdk/my_net_util.c \ $(src)/openjdk/my_management.c diff --git a/src/openjdk/my_java_props_macosx.c b/src/openjdk/my_java_props_macosx.c new file mode 100644 index 0000000000..8a1850010f --- /dev/null +++ b/src/openjdk/my_java_props_macosx.c @@ -0,0 +1,28 @@ +#include "java_props_macosx.h" + +PreferredToolkit +getPreferredToolkit() +{ + return unset; +} + +void +setOSNameAndVersion(java_props_t* props) +{ + props->os_name = strdup("iOS"); + props->os_version = strdup("Unknown"); +} + +void +setProxyProperties(java_props_t* props) +{ + // ignore +} + +char* +setupMacOSXLocale(int cat) +{ + return 0; +} + +char* environ[0]; From f8934b2c9df5e4137c33e9f47950bcfce6988367 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 Mar 2012 11:38:20 -0600 Subject: [PATCH 09/35] fix race condition in System::Monitor::wait If we clear Thread::flags before releasing the thread mutex and re-acquiring the monitor mutex, it's possible that we will be notified between the release and re-acquire, which will confuse us later if we try to wait on the same monitor again such that we well not remove ourselves from the wait list because we think we've been removed by the notifier. The solution is to wait until we've acquired both mutexes before we clear Thread::flags. --- src/posix.cpp | 34 ++++++++++++++++++++++++++++------ src/windows.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/posix.cpp b/src/posix.cpp index 074c6b379c..35d2d6b7b1 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -122,8 +122,7 @@ pathOfExecutable(System* s, const char** retBuf, unsigned* size) const bool Verbose = false; -const unsigned Waiting = 1 << 0; -const unsigned Notified = 1 << 1; +const unsigned Notified = 1 << 0; class MySystem: public System { public: @@ -256,7 +255,14 @@ class MySystem: public System { } void append(Thread* t) { +#ifndef NDEBUG + for (Thread* x = first; x; x = x->next) { + expect(s, t != x); + } +#endif + if (last) { + expect(s, t != last); last->next = t; last = t; } else { @@ -271,6 +277,7 @@ class MySystem: public System { if (current == first) { first = t->next; } else { + expect(s, previous != t->next); previous->next = t->next; } @@ -286,6 +293,12 @@ class MySystem: public System { current = current->next; } } + +#ifndef NDEBUG + for (Thread* x = first; x; x = x->next) { + expect(s, t != x); + } +#endif } virtual void wait(System::Thread* context, int64_t time) { @@ -308,13 +321,13 @@ class MySystem: public System { { ACQUIRE(t->mutex); + expect(s, (t->flags & Notified) == 0); + interrupted = t->r->interrupted(); if (interrupted and clearInterrupted) { t->r->setInterrupted(false); } - t->flags |= Waiting; - append(t); depth = this->depth; @@ -343,14 +356,22 @@ class MySystem: public System { } notified = ((t->flags & Notified) != 0); - - t->flags = 0; } pthread_mutex_lock(&mutex); + { ACQUIRE(t->mutex); + t->flags = 0; + } + if (not notified) { remove(t); + } else { +#ifndef NDEBUG + for (Thread* x = first; x; x = x->next) { + expect(s, t != x); + } +#endif } t->next = 0; @@ -380,6 +401,7 @@ class MySystem: public System { Thread* t = first; first = first->next; if (t == last) { + expect(s, first == 0); last = 0; } diff --git a/src/windows.cpp b/src/windows.cpp index 42a79d3024..37c9251726 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -215,6 +215,12 @@ class MySystem: public System { } void append(Thread* t) { +#ifndef NDEBUG + for (Thread* x = first; x; x = x->next) { + expect(s, t != x); + } +#endif + if (last) { last->next = t; last = t; @@ -245,6 +251,12 @@ class MySystem: public System { current = current->next; } } + +#ifndef NDEBUG + for (Thread* x = first; x; x = x->next) { + expect(s, t != x); + } +#endif } virtual void wait(System::Thread* context, int64_t time) { @@ -270,6 +282,8 @@ class MySystem: public System { { ACQUIRE(s, t->mutex); + expect(s, (t->flags & Notified) == 0); + interrupted = t->r->interrupted(); if (interrupted and clearInterrupted) { t->r->setInterrupted(false); @@ -306,15 +320,23 @@ class MySystem: public System { } notified = ((t->flags & Notified) != 0); - - t->flags = 0; } r = WaitForSingleObject(mutex, INFINITE); assert(s, r == WAIT_OBJECT_0); + { ACQUIRE(s, t->mutex); + t->flags = 0; + } + if (not notified) { remove(t); + } else { +#ifndef NDEBUG + for (Thread* x = first; x; x = x->next) { + expect(s, t != x); + } +#endif } t->next = 0; @@ -346,6 +368,7 @@ class MySystem: public System { Thread* t = first; first = first->next; if (t == last) { + expect(s, first == 0); last = 0; } From c4722fa843b0902d73a1a206f0771e5fe9e7a433 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 Mar 2012 11:54:03 -0600 Subject: [PATCH 10/35] update Unsafe.setMemory to reflect new OpenJDK 7 signature and semantics --- classpath/sun/misc/Unsafe.java | 3 ++- src/builtin.cpp | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/classpath/sun/misc/Unsafe.java b/classpath/sun/misc/Unsafe.java index 84f22b88db..b7613d2559 100644 --- a/classpath/sun/misc/Unsafe.java +++ b/classpath/sun/misc/Unsafe.java @@ -11,7 +11,8 @@ public final class Unsafe { public native long allocateMemory(long bytes); - public native void setMemory(long address, long count, byte value); + public native void setMemory + (Object base, long offset, long count, byte value); public native void freeMemory(long address); diff --git a/src/builtin.cpp b/src/builtin.cpp index f7f2c12d29..0efc8fbbd2 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -352,13 +352,24 @@ Avian_sun_misc_Unsafe_freeMemory extern "C" JNIEXPORT void JNICALL Avian_sun_misc_Unsafe_setMemory -(Thread*, object, uintptr_t* arguments) +(Thread* t, object, uintptr_t* arguments) { - int64_t p; memcpy(&p, arguments + 1, 8); - int64_t count; memcpy(&count, arguments + 3, 8); - int8_t v = arguments[5]; + object base = reinterpret_cast(arguments[1]); + int64_t offset; memcpy(&offset, arguments + 2, 8); + int64_t count; memcpy(&count, arguments + 4, 8); + int8_t value = arguments[6]; - memset(reinterpret_cast(p), v, count); + fprintf(stderr, "base %p offset %p count %ld value %d\n", base, reinterpret_cast(offset), count, value); + + PROTECT(t, base); + + ACQUIRE(t, t->m->referenceLock); + + if (base) { + memset(&cast(base, offset), value, count); + } else { + memset(reinterpret_cast(offset), value, count); + } } // NB: The following primitive get/put methods are only used by the From b6cdf4efcb55afe5893e3f9590241f4fb3792dad Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 Mar 2012 12:08:14 -0600 Subject: [PATCH 11/35] remove debug logging --- src/builtin.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 0efc8fbbd2..6988dcf8eb 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -359,8 +359,6 @@ Avian_sun_misc_Unsafe_setMemory int64_t count; memcpy(&count, arguments + 4, 8); int8_t value = arguments[6]; - fprintf(stderr, "base %p offset %p count %ld value %d\n", base, reinterpret_cast(offset), count, value); - PROTECT(t, base); ACQUIRE(t, t->m->referenceLock); From d718bbf8335e4ede4e9e1568a63da4feeb9955df Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 Mar 2012 12:35:22 -0600 Subject: [PATCH 12/35] implement Unsafe.getByte(Object, long) --- src/classpath-openjdk.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index d767522803..9c6b2e191d 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -2566,13 +2566,20 @@ Avian_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF } extern "C" JNIEXPORT int64_t JNICALL -Avian_sun_misc_Unsafe_getBoolean +Avian_sun_misc_Unsafe_getByte (Thread*, object, uintptr_t* arguments) { object o = reinterpret_cast(arguments[1]); int64_t offset; memcpy(&offset, arguments + 2, 8); - return cast(o, offset); + return cast(o, offset); +} + +extern "C" JNIEXPORT int64_t JNICALL +Avian_sun_misc_Unsafe_getBoolean +(Thread* t, object method, uintptr_t* arguments) +{ + return Avian_sun_misc_Unsafe_getByte(t, method, arguments); } extern "C" JNIEXPORT void JNICALL From d78247ab9a5659f98b51ed249cb85cf897186f21 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 Mar 2012 12:36:42 -0600 Subject: [PATCH 13/35] implement -Xss command line option --- src/compile.cpp | 2 +- src/interpret.cpp | 22 +++++++++++----------- src/jnienv.cpp | 8 +++++++- src/machine.cpp | 4 +++- src/machine.h | 12 ++++++++---- src/main.cpp | 1 + 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 2b415588db..1f5f82d852 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -8303,7 +8303,7 @@ invoke(Thread* thread, object method, ArgumentList* arguments) uintptr_t stackLimit = t->stackLimit; uintptr_t stackPosition = reinterpret_cast(&t); if (stackLimit == 0) { - t->stackLimit = stackPosition - StackSizeInBytes; + t->stackLimit = stackPosition - t->m->stackSizeInBytes; } else if (stackPosition < stackLimit) { throwNew(t, Machine::StackOverflowErrorType); } diff --git a/src/interpret.cpp b/src/interpret.cpp index 6f3c853ec6..57b2e9836b 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -40,7 +40,7 @@ class Thread: public vm::Thread { unsigned sp; int frame; object code; - uintptr_t stack[StackSizeInWords]; + uintptr_t stack[0]; }; inline void @@ -50,7 +50,7 @@ pushObject(Thread* t, object o) fprintf(stderr, "push object %p at %d\n", o, t->sp); } - assert(t, t->sp + 1 < StackSizeInWords / 2); + assert(t, t->sp + 1 < stackSizeInWords(t) / 2); t->stack[(t->sp * 2) ] = ObjectTag; t->stack[(t->sp * 2) + 1] = reinterpret_cast(o); ++ t->sp; @@ -63,7 +63,7 @@ pushInt(Thread* t, uint32_t v) fprintf(stderr, "push int %d at %d\n", v, t->sp); } - assert(t, t->sp + 1 < StackSizeInWords / 2); + assert(t, t->sp + 1 < stackSizeInWords(t) / 2); t->stack[(t->sp * 2) ] = IntTag; t->stack[(t->sp * 2) + 1] = v; ++ t->sp; @@ -156,7 +156,7 @@ peekObject(Thread* t, unsigned index) index); } - assert(t, index < StackSizeInWords / 2); + assert(t, index < stackSizeInWords(t) / 2); assert(t, t->stack[index * 2] == ObjectTag); return *reinterpret_cast(t->stack + (index * 2) + 1); } @@ -170,7 +170,7 @@ peekInt(Thread* t, unsigned index) index); } - assert(t, index < StackSizeInWords / 2); + assert(t, index < stackSizeInWords(t) / 2); assert(t, t->stack[index * 2] == IntTag); return t->stack[(index * 2) + 1]; } @@ -226,7 +226,7 @@ inline object* pushReference(Thread* t, object o) { if (o) { - expect(t, t->sp + 1 < StackSizeInWords / 2); + expect(t, t->sp + 1 < stackSizeInWords(t) / 2); pushObject(t, o); return reinterpret_cast(t->stack + ((t->sp - 1) * 2) + 1); } else { @@ -405,7 +405,7 @@ checkStack(Thread* t, object method) + codeMaxLocals(t, methodCode(t, method)) + FrameFootprint + codeMaxStack(t, methodCode(t, method)) - > StackSizeInWords / 2)) + > stackSizeInWords(t) / 2)) { throwNew(t, Machine::StackOverflowErrorType); } @@ -2879,7 +2879,7 @@ class MyProcessor: public Processor { virtual vm::Thread* makeThread(Machine* m, object javaThread, vm::Thread* parent) { - Thread* t = new (m->heap->allocate(sizeof(Thread))) + Thread* t = new (m->heap->allocate(sizeof(Thread) + m->stackSizeInBytes)) Thread(m, javaThread, parent); t->init(); return t; @@ -2996,7 +2996,7 @@ class MyProcessor: public Processor { assert(t, ((methodFlags(t, method) & ACC_STATIC) == 0) xor (this_ == 0)); if (UNLIKELY(t->sp + methodParameterFootprint(t, method) + 1 - > StackSizeInWords / 2)) + > stackSizeInWords(t) / 2)) { throwNew(t, Machine::StackOverflowErrorType); } @@ -3020,7 +3020,7 @@ class MyProcessor: public Processor { assert(t, ((methodFlags(t, method) & ACC_STATIC) == 0) xor (this_ == 0)); if (UNLIKELY(t->sp + methodParameterFootprint(t, method) + 1 - > StackSizeInWords / 2)) + > stackSizeInWords(t) / 2)) { throwNew(t, Machine::StackOverflowErrorType); } @@ -3043,7 +3043,7 @@ class MyProcessor: public Processor { or t->state == Thread::ExclusiveState); if (UNLIKELY(t->sp + parameterFootprint(vmt, methodSpec, false) - > StackSizeInWords / 2)) + > stackSizeInWords(t) / 2)) { throwNew(t, Machine::StackOverflowErrorType); } diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 52106c3085..ffc0937789 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -3269,6 +3269,7 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args) local::JavaVMInitArgs* a = static_cast(args); unsigned heapLimit = 0; + unsigned stackLimit = 0; const char* bootLibrary = 0; const char* classpath = 0; const char* javaHome = AVIAN_JAVA_HOME; @@ -3285,6 +3286,8 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args) const char* p = a->options[i].optionString + 2; if (strncmp(p, "mx", 2) == 0) { heapLimit = local::parseSize(p + 2); + } else if (strncmp(p, "ss", 2) == 0) { + stackLimit = local::parseSize(p + 2); } else if (strncmp(p, BOOTCLASSPATH_PREPEND_OPTION ":", sizeof(BOOTCLASSPATH_PREPEND_OPTION)) == 0) { @@ -3327,6 +3330,8 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args) } if (heapLimit == 0) heapLimit = 128 * 1024 * 1024; + + if (stackLimit == 0) stackLimit = 128 * 1024; if (classpath == 0) classpath = "."; @@ -3378,7 +3383,8 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args) } *m = new (h->allocate(sizeof(Machine))) Machine - (s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions); + (s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions, + stackLimit); *t = p->makeThread(*m, 0, 0); diff --git a/src/machine.cpp b/src/machine.cpp index 47b53dccbf..e4dcf2ad2c 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2425,7 +2425,8 @@ namespace vm { Machine::Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder, Processor* processor, Classpath* classpath, const char** properties, unsigned propertyCount, - const char** arguments, unsigned argumentCount): + const char** arguments, unsigned argumentCount, + unsigned stackSizeInBytes): vtable(&javaVMVTable), system(system), heapClient(new (heap->allocate(sizeof(HeapClient))) @@ -2448,6 +2449,7 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder, liveCount(0), daemonCount(0), fixedFootprint(0), + stackSizeInBytes(stackSizeInBytes), localThread(0), stateLock(0), heapLock(0), diff --git a/src/machine.h b/src/machine.h index a52cf30a73..08884e40d0 100644 --- a/src/machine.h +++ b/src/machine.h @@ -112,9 +112,6 @@ const unsigned ThreadBackupHeapSizeInBytes = 2 * 1024; const unsigned ThreadBackupHeapSizeInWords = ThreadBackupHeapSizeInBytes / BytesPerWord; -const unsigned StackSizeInBytes = 128 * 1024; -const unsigned StackSizeInWords = StackSizeInBytes / BytesPerWord; - const unsigned ThreadHeapPoolSize = 64; const unsigned FixedFootprintThresholdInBytes @@ -1281,7 +1278,7 @@ class Machine { Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder, Processor* processor, Classpath* classpath, const char** properties, unsigned propertyCount, const char** arguments, - unsigned argumentCount); + unsigned argumentCount, unsigned stackSizeInBytes); ~Machine() { dispose(); @@ -1310,6 +1307,7 @@ class Machine { unsigned liveCount; unsigned daemonCount; unsigned fixedFootprint; + unsigned stackSizeInBytes; System::Local* localThread; System::Monitor* stateLock; System::Monitor* heapLock; @@ -1639,6 +1637,12 @@ objectClass(Thread*, object o) return mask(cast(o, 0)); } +inline unsigned +stackSizeInWords(Thread* t) +{ + return t->m->stackSizeInBytes / BytesPerWord; +} + void enter(Thread* t, Thread::State state); diff --git a/src/main.cpp b/src/main.cpp index a84630b68c..f5358e985c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -143,6 +143,7 @@ usageAndExit(const char* name) (stderr, "usage: %s\n" "\t[{-cp|-classpath} ]\n" "\t[-Xmx]\n" + "\t[-Xss]\n" "\t[-Xbootclasspath/p:]\n" "\t[-Xbootclasspath:]\n" "\t[-Xbootclasspath/a:]\n" From 333b6c59d46e79d6083ff65af0ec5ae5770cfe5d Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 16 Mar 2012 11:01:20 -0600 Subject: [PATCH 14/35] fix non-embedded openjdk build on OS X The JRE lib dir for OpenJDK 7 on OS X seems to be just "lib", not e.g. "lib/amd64" by default, so we use that now. Also, the default library compatibility version for libjvm.dylib is 0.0.0, but OpenJDK wants 1.0.0, so we set it explicitly. --- makefile | 12 +++++++++--- src/classpath-openjdk.cpp | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 64429c1725..c0b0d320dc 100755 --- a/makefile +++ b/makefile @@ -113,8 +113,13 @@ ifneq ($(openjdk),) else options := $(options)-openjdk test-executable = $(shell pwd)/$(executable-dynamic) - library-path = \ - $(library-path-variable)=$(build):$(openjdk)/jre/lib/$(openjdk-arch) + ifeq ($(build-platform),darwin) + library-path = \ + $(library-path-variable)=$(build):$(openjdk)/jre/lib + else + library-path = \ + $(library-path-variable)=$(build):$(openjdk)/jre/lib/$(openjdk-arch) + endif javahome = "$$($(native-path) "$(openjdk)/jre")" endif @@ -308,7 +313,8 @@ ifeq ($(platform),darwin) endif version-script-flag = - lflags = $(common-lflags) -ldl -framework CoreFoundation + lflags = $(common-lflags) -ldl -framework CoreFoundation \ + -Wl,-compatibility_version,1.0.0 ifneq ($(arch),arm) lflags += -framework CoreServices -framework SystemConfiguration \ -framework Security diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 9c6b2e191d..6959abafec 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -410,6 +410,8 @@ class MyClasspath : public Classpath { sb.append(javaHome); #ifdef PLATFORM_WINDOWS sb.append("/bin"); +#elif defined __APPLE__ + sb.append("/lib"); #elif defined ARCH_x86_64 sb.append("/lib/amd64"); #else From 8cb6446bec95dba05052280f3e536628e7190840 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 17 Mar 2012 12:57:59 -0600 Subject: [PATCH 15/35] handle zero-length arrays in truncate functions --- src/compile.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 1f5f82d852..6b1a63f414 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -6216,8 +6216,10 @@ truncateIntArray(Thread* t, object array, unsigned length) PROTECT(t, array); object newArray = makeIntArray(t, length); - memcpy(&intArrayBody(t, newArray, 0), &intArrayBody(t, array, 0), - length * 4); + if (length) { + memcpy(&intArrayBody(t, newArray, 0), &intArrayBody(t, array, 0), + length * 4); + } return newArray; } @@ -6230,8 +6232,10 @@ truncateArray(Thread* t, object array, unsigned length) PROTECT(t, array); object newArray = makeArray(t, length); - memcpy(&arrayBody(t, newArray, 0), &arrayBody(t, array, 0), - length * BytesPerWord); + if (length) { + memcpy(&arrayBody(t, newArray, 0), &arrayBody(t, array, 0), + length * BytesPerWord); + } return newArray; } @@ -6244,9 +6248,11 @@ truncateLineNumberTable(Thread* t, object table, unsigned length) PROTECT(t, table); object newTable = makeLineNumberTable(t, length); - memcpy(&lineNumberTableBody(t, newTable, 0), - &lineNumberTableBody(t, table, 0), - length * sizeof(uint64_t)); + if (length) { + memcpy(&lineNumberTableBody(t, newTable, 0), + &lineNumberTableBody(t, table, 0), + length * sizeof(uint64_t)); + } return newTable; } From 8abe9bf469b60c45bd7dea5ba045f30138928ef2 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 17 Mar 2012 12:58:41 -0600 Subject: [PATCH 16/35] fix memory leak in freeZipFileEntry --- src/classpath-openjdk.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 6959abafec..813870ad10 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -1538,6 +1538,8 @@ freeZipFileEntry(Thread* t, object method, uintptr_t* arguments) (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))), 0, file->file, entry->entry); } + + t->m->heap->free(entry, sizeof(ZipFile::Entry)); } int64_t JNICALL From 75b5d3df4aa827ead558fd02f8cba123364ccf20 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 17 Mar 2012 12:59:22 -0600 Subject: [PATCH 17/35] fix Windows OpenJDK 7 build --- makefile | 2 +- openjdk-src.mk | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index c0b0d320dc..efa44b1769 100755 --- a/makefile +++ b/makefile @@ -384,7 +384,7 @@ ifeq ($(platform),windows) so-suffix = .dll exe-suffix = .exe - lflags = -L$(lib) $(common-lflags) -lws2_32 -mwindows -mconsole + lflags = -L$(lib) $(common-lflags) -lws2_32 -liphlpapi -mwindows -mconsole cflags = -I$(inc) $(common-cflags) -DWINVER=0x0500 -DTARGET_PLATFORM_WINDOWS diff --git a/openjdk-src.mk b/openjdk-src.mk index 6735471fea..0c16a86a21 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -173,6 +173,7 @@ endif ifeq ($(platform),windows) openjdk-sources += \ + $(openjdk-src)/windows/native/common/jni_util_md.c \ $(openjdk-src)/windows/native/java/io/canonicalize_md.c \ $(openjdk-src)/windows/native/java/io/Console_md.c \ $(openjdk-src)/windows/native/java/io/FileDescriptor_md.c \ @@ -193,7 +194,6 @@ ifeq ($(platform),windows) $(openjdk-src)/windows/native/java/net/Inet6AddressImpl.c \ $(openjdk-src)/windows/native/java/net/NetworkInterface.c \ $(openjdk-src)/windows/native/java/net/NetworkInterface_winXP.c \ - $(openjdk-src)/windows/native/java/net/NetworkInterface_win9x.c \ $(openjdk-src)/windows/native/java/net/SocketInputStream.c \ $(openjdk-src)/windows/native/java/net/SocketOutputStream.c \ $(openjdk-src)/windows/native/java/util/WindowsPreferences.c \ @@ -203,7 +203,6 @@ ifeq ($(platform),windows) $(openjdk-src)/windows/native/sun/nio/ch/DatagramChannelImpl.c \ $(openjdk-src)/windows/native/sun/nio/ch/DatagramDispatcher.c \ $(openjdk-src)/windows/native/sun/nio/ch/FileChannelImpl.c \ - $(openjdk-src)/windows/native/sun/nio/ch/FileDispatcher.c \ $(openjdk-src)/windows/native/sun/nio/ch/FileKey.c \ $(openjdk-src)/windows/native/sun/nio/ch/IOUtil.c \ $(openjdk-src)/windows/native/sun/nio/ch/Net.c \ @@ -211,6 +210,7 @@ ifeq ($(platform),windows) $(openjdk-src)/windows/native/sun/nio/ch/SocketChannelImpl.c \ $(openjdk-src)/windows/native/sun/nio/ch/SocketDispatcher.c \ $(openjdk-src)/windows/native/sun/nio/ch/WindowsSelectorImpl.c \ + $(openjdk-src)/windows/native/sun/nio/fs/WindowsNativeDispatcher.c \ $(openjdk-src)/windows/native/sun/security/provider/WinCAPISeedGenerator.c openjdk-headers-classes += \ @@ -218,6 +218,7 @@ ifeq ($(platform),windows) java.lang.ProcessImpl \ sun.io.Win32ErrorMode \ sun.nio.ch.WindowsSelectorImpl \ + sun.nio.fs.WindowsNativeDispatcher \ openjdk-cflags += \ "-I$(openjdk-src)/windows/javavm/export" \ @@ -228,6 +229,9 @@ ifeq ($(platform),windows) "-I$(openjdk-src)/windows/native/sun/nio/ch" \ "-I$(openjdk-src)/windows/javavm/include" \ "-I$(root)/win32/include" \ + -DLOCALE_SNAME=0x0000005c \ + -DLOCALE_SISO3166CTRYNAME2=0x00000068 \ + -DLOCALE_SISO639LANGNAME2=0x00000067 \ -D_JNI_IMPLEMENTATION_ \ -D_JAVASOFT_WIN32_TYPEDEF_MD_H_ \ -Ds6_words=_s6_words \ From 0167868797bad47505512e413a886f77a8d63be6 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 17 Mar 2012 18:47:22 -0600 Subject: [PATCH 18/35] various Windows OpenJDK 7 fixes --- makefile | 3 ++- openjdk-src.mk | 1 + src/classpath-openjdk.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index efa44b1769..53ca635f7f 100755 --- a/makefile +++ b/makefile @@ -387,7 +387,6 @@ ifeq ($(platform),windows) lflags = -L$(lib) $(common-lflags) -lws2_32 -liphlpapi -mwindows -mconsole cflags = -I$(inc) $(common-cflags) -DWINVER=0x0500 -DTARGET_PLATFORM_WINDOWS - ifeq (,$(filter mingw32 cygwin,$(build-platform))) openjdk-extra-cflags += -I$(src)/openjdk/caseSensitive cxx = x86_64-w64-mingw32-g++ -m32 @@ -425,6 +424,8 @@ ifeq ($(platform),windows) strip = x86_64-w64-mingw32-strip inc = "$(win64)/include" lib = "$(win64)/lib" + else + shared += -Wl,--add-stdcall-alias endif endif diff --git a/openjdk-src.mk b/openjdk-src.mk index 0c16a86a21..027b6a79b5 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -203,6 +203,7 @@ ifeq ($(platform),windows) $(openjdk-src)/windows/native/sun/nio/ch/DatagramChannelImpl.c \ $(openjdk-src)/windows/native/sun/nio/ch/DatagramDispatcher.c \ $(openjdk-src)/windows/native/sun/nio/ch/FileChannelImpl.c \ + $(openjdk-src)/windows/native/sun/nio/ch/FileDispatcherImpl.c \ $(openjdk-src)/windows/native/sun/nio/ch/FileKey.c \ $(openjdk-src)/windows/native/sun/nio/ch/IOUtil.c \ $(openjdk-src)/windows/native/sun/nio/ch/Net.c \ diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 813870ad10..feb468b083 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -3863,7 +3863,7 @@ EXPORT(JVM_FindClassFromClassLoader)(Thread* t, const char* name, } extern "C" JNIEXPORT jclass JNICALL -EXPORT(JVM_FindClassFromBootLoader)(Thread* t, const char* name) +JVM_FindClassFromBootLoader(Thread* t, const char* name) { return EXPORT(JVM_FindClassFromClassLoader)(t, name, false, 0, false); } @@ -5344,7 +5344,7 @@ EXPORT(JVM_CX8Field)(JNIEnv*, jobject*, jfieldID*, jlong, jlong) { abort(); } extern "C" JNIEXPORT void JNICALL -JVM_SetNativeThreadName(JNIEnv*, jobject, jstring) { abort(); } +EXPORT(JVM_SetNativeThreadName)(JNIEnv*, jobject, jstring) { abort(); } } // namespace local From 9a50e6958790e85956a553c9f8f66d52f0064312 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 17 Mar 2012 22:42:15 -0600 Subject: [PATCH 19/35] remove debug logging --- classpath/java-io.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index c1373a3c58..d08601a465 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -405,11 +405,9 @@ Java_java_io_File_createNewFile(JNIEnv* e, jclass, jstring path) bool result = false; string_t chars = getChars(e, path); if (chars) { - fprintf(stderr, "create file \"%s\"\n", chars); if (not exists(chars)) { int fd = OPEN(chars, O_CREAT | O_WRONLY | O_EXCL, 0600); if (fd == -1) { - fprintf(stderr, "errno %d\n", errno); if (errno != EEXIST) { throwNewErrno(e, "java/io/IOException"); } From 674c5604945848ee62b3d8ca77b8d065a2f50e93 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 17 Mar 2012 22:45:35 -0600 Subject: [PATCH 20/35] fix static field alignment calculation The previous code caused overlap between 64-bit fields and subsequent fields under certain circumstances on 32-bit systems. --- src/bootimage.cpp | 6 ++---- src/machine.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 3d75f4401c..dd408705e2 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -502,10 +502,8 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, } if (fieldFlags(t, field) & ACC_STATIC) { - unsigned excess = (targetStaticOffset % targetSize) - % TargetBytesPerWord; - if (excess) { - targetStaticOffset += TargetBytesPerWord - excess; + while (targetStaticOffset % targetSize) { + ++ targetStaticOffset; } buildStaticOffset = fieldOffset(t, field); diff --git a/src/machine.cpp b/src/machine.cpp index e4dcf2ad2c..182308f8d4 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1164,9 +1164,8 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool) unsigned size = fieldSize(t, code); if (flags & ACC_STATIC) { - unsigned excess = (staticOffset % size) % BytesPerWord; - if (excess) { - staticOffset += BytesPerWord - excess; + while (staticOffset % size) { + ++ staticOffset; } fieldOffset(t, field) = staticOffset; @@ -1205,9 +1204,8 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool) for (unsigned i = 0, offset = 0; i < staticCount; ++i) { unsigned size = fieldSize(t, RUNTIME_ARRAY_BODY(staticTypes)[i]); - unsigned excess = offset % size; - if (excess) { - offset += BytesPerWord - excess; + while (offset % size) { + ++ offset; } unsigned value = intArrayBody(t, staticValueTable, i); From 4f0d275e133f51ba8e949191f2b3b069a008c82f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 18 Mar 2012 20:10:42 -0600 Subject: [PATCH 21/35] run JNI_OnLoad if found in ClassLoader.loadLibrary --- src/classpath-common.h | 10 ++++++++++ src/classpath-openjdk.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/classpath-common.h b/src/classpath-common.h index 99e042162c..5f769ae00f 100644 --- a/src/classpath-common.h +++ b/src/classpath-common.h @@ -120,6 +120,16 @@ void runOnLoadIfFound(Thread* t, System::Library* library) { void* p = library->resolve("JNI_OnLoad"); + +#ifdef PLATFORM_WINDOWS + if (p == 0) { + p = library->resolve("_JNI_OnLoad@8"); + if (p == 0) { + p = library->resolve("JNI_OnLoad@8"); + } + } +#endif + if (p) { jint (JNICALL * JNI_OnLoad)(Machine*, void*); memcpy(&JNI_OnLoad, &p, sizeof(void*)); diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index feb468b083..cbb705d8d9 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -1747,7 +1747,7 @@ loadLibrary(Thread* t, object, uintptr_t* arguments) loadLibrary (t, static_cast(t->m->classpath)->libraryPath, - RUNTIME_ARRAY_BODY(n), not absolute, false); + RUNTIME_ARRAY_BODY(n), not absolute, true); } // only safe to call during bootstrap when there's only one thread From a10ce99302d8060f97a90e181a1ce84a21669793 Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Mon, 26 Mar 2012 11:12:07 -0600 Subject: [PATCH 22/35] Use latest iOS SDK found on local machine --- makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 53ca635f7f..3c96d2edca 100755 --- a/makefile +++ b/makefile @@ -327,12 +327,24 @@ ifeq ($(platform),darwin) so-suffix = .dylib shared = -dynamiclib + sdk-dir = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/SDKs + + ios-version := $(shell if test -d $(sdk-dir)/iPhoneOS5.1.sdk; then echo 5.1; \ + elif test -d $(sdk-dir)/iPhoneOS5.0.sdk; then echo 5.0; \ + elif test -d $(sdk-dir)/iPhoneOS4.3.sdk; then echo 4.3; \ + elif test -d $(sdk-dir)/iPhoneOS4.2.sdk; then echo 4.2; \ + else echo; fi) + + ifeq ($(ios-version),) + x := $(error "couldn't find SDK for iOS version") + endif + ifeq ($(arch),arm) ifeq ($(build-arch),powerpc) converter-cflags += -DOPPOSITE_ENDIAN endif flags = -arch armv7 -isysroot \ - $(developer-dir)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/ + $(sdk-dir)/iPhoneOS$(ios-version).sdk/ openjdk-extra-cflags += $(flags) cflags += $(flags) asmflags += $(flags) From 031852daec60100e741d06c918cce16f0d542468 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 26 Mar 2012 18:02:43 -0600 Subject: [PATCH 23/35] add -march=i586 to lflags as well as cflags where appropriate When link time optimization is enabled, we need to remind the compiler that we're targeting i586 when linking so it can resolve atomic operations like __sync_bool_compare_and_swap. --- makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile b/makefile index 53ca635f7f..635fb052c9 100755 --- a/makefile +++ b/makefile @@ -472,6 +472,7 @@ ifneq ($(platform),darwin) ifeq ($(arch),i386) # this is necessary to support __sync_bool_compare_and_swap: cflags += -march=i586 + lflags += -march=i586 endif endif From 2ee377112599facd0571e168660182331c486004 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 26 Mar 2012 18:06:16 -0600 Subject: [PATCH 24/35] make find[Field|Method]InClass non-inline functions It seems that GCC 4.6.1 gets confused at LTO time when we take the address of inline functions, so I'm switching them to non-inline linkage to make it happy. --- src/machine.cpp | 68 +++++++++++++++++++++++++++++-------------------- src/machine.h | 19 +++----------- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index 182308f8d4..744d6d2a46 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2416,6 +2416,38 @@ isInitializing(Thread* t, object c) return false; } +object +findInTable(Thread* t, object table, object name, object spec, + object& (*getName)(Thread*, object), + object& (*getSpec)(Thread*, object)) +{ + if (table) { + for (unsigned i = 0; i < arrayLength(t, table); ++i) { + object o = arrayBody(t, table, i); + if (vm::strcmp(&byteArrayBody(t, getName(t, o), 0), + &byteArrayBody(t, name, 0)) == 0 and + vm::strcmp(&byteArrayBody(t, getSpec(t, o), 0), + &byteArrayBody(t, spec, 0)) == 0) + { + return o; + } + } + +// fprintf(stderr, "%s %s not in\n", +// &byteArrayBody(t, name, 0), +// &byteArrayBody(t, spec, 0)); + +// for (unsigned i = 0; i < arrayLength(t, table); ++i) { +// object o = arrayBody(t, table, i); +// fprintf(stderr, "\t%s %s\n", +// &byteArrayBody(t, getName(t, o), 0), +// &byteArrayBody(t, getSpec(t, o), 0)); +// } + } + + return 0; +} + } // namespace namespace vm { @@ -3884,35 +3916,17 @@ makeObjectArray(Thread* t, object elementClass, unsigned count) } object -findInTable(Thread* t, object table, object name, object spec, - object& (*getName)(Thread*, object), - object& (*getSpec)(Thread*, object)) +findFieldInClass(Thread* t, object class_, object name, object spec) { - if (table) { - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - object o = arrayBody(t, table, i); - if (vm::strcmp(&byteArrayBody(t, getName(t, o), 0), - &byteArrayBody(t, name, 0)) == 0 and - vm::strcmp(&byteArrayBody(t, getSpec(t, o), 0), - &byteArrayBody(t, spec, 0)) == 0) - { - return o; - } - } + return findInTable + (t, classFieldTable(t, class_), name, spec, fieldName, fieldSpec); +} -// fprintf(stderr, "%s %s not in\n", -// &byteArrayBody(t, name, 0), -// &byteArrayBody(t, spec, 0)); - -// for (unsigned i = 0; i < arrayLength(t, table); ++i) { -// object o = arrayBody(t, table, i); -// fprintf(stderr, "\t%s %s\n", -// &byteArrayBody(t, getName(t, o), 0), -// &byteArrayBody(t, getSpec(t, o), 0)); -// } - } - - return 0; +object +findMethodInClass(Thread* t, object class_, object name, object spec) +{ + return findInTable + (t, classMethodTable(t, class_), name, spec, methodName, methodSpec); } object diff --git a/src/machine.h b/src/machine.h index 08884e40d0..cdb3ecf039 100644 --- a/src/machine.h +++ b/src/machine.h @@ -2595,16 +2595,7 @@ makeObjectArray(Thread* t, unsigned count) } object -findInTable(Thread* t, object table, object name, object spec, - object& (*getName)(Thread*, object), - object& (*getSpec)(Thread*, object)); - -inline object -findFieldInClass(Thread* t, object class_, object name, object spec) -{ - return findInTable - (t, classFieldTable(t, class_), name, spec, fieldName, fieldSpec); -} +findFieldInClass(Thread* t, object class_, object name, object spec); inline object findFieldInClass2(Thread* t, object class_, const char* name, const char* spec) @@ -2616,12 +2607,8 @@ findFieldInClass2(Thread* t, object class_, const char* name, const char* spec) return findFieldInClass(t, class_, n, s); } -inline object -findMethodInClass(Thread* t, object class_, object name, object spec) -{ - return findInTable - (t, classMethodTable(t, class_), name, spec, methodName, methodSpec); -} +object +findMethodInClass(Thread* t, object class_, object name, object spec); inline object makeThrowable From 4800518a316613c9f8ec990b51e2b5c86594e29a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 08:22:35 -0600 Subject: [PATCH 25/35] fix bootimage.cpp build regression I forgot to update bootimage.cpp when I added a parameter to Machine's constructor in d78247a. --- src/bootimage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index dd408705e2..6ece510972 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -1671,7 +1671,7 @@ main(int ac, const char** av) p->initialize(&image, code, CodeCapacity); Machine* m = new (h->allocate(sizeof(Machine))) Machine - (s, h, f, 0, p, c, 0, 0, 0, 0); + (s, h, f, 0, p, c, 0, 0, 0, 0, 128 * 1024); Thread* t = p->makeThread(m, 0, 0); enter(t, Thread::ActiveState); From a2e0151728e443f2b901f830092fbc68de702312 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 17:57:11 -0600 Subject: [PATCH 26/35] initialize Machine::OutOfMemoryError in writeBootImage2 If we don't initialize that at our first opportunity, it's possible we'll run out of memory later and exit silently instead of printing the error and returning a nonzero exit code. --- src/bootimage.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 6ece510972..834431f7b4 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -1287,6 +1287,9 @@ writeBootImage2(Thread* t, FILE* bootimageOutput, FILE* codeOutput, BootImage* image, uint8_t* code, const char* className, const char* methodName, const char* methodSpec) { + setRoot(t, Machine::OutOfMemoryError, + make(t, type(t, Machine::OutOfMemoryErrorType))); + Zone zone(t->m->system, t->m->heap, 64 * 1024); object classPoolMap; From 48bb1e4f41e976c61f2197421e025811af2d1d3e Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 17:58:52 -0600 Subject: [PATCH 27/35] include charsets.jar in openjdk-src build The other JARs we were including refer to classes in this jar, so we need to include it as well. --- makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile b/makefile index 635fb052c9..3c1f98bfb2 100755 --- a/makefile +++ b/makefile @@ -1087,6 +1087,7 @@ $(openjdk-jar-dep): $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/rt.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jsse.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jce.jar")" && \ + $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/charsets.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/ext/sunjce_provider.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/resources.jar")") @touch $(@) From ae2b58ee40424e84dd7d656d5a221c4feee88fcd Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 18:14:29 -0600 Subject: [PATCH 28/35] increase bootimage.cpp heap and code size limits OpenJDK is huge, so building a bootimage out of the whole thing (as opposed to an app shrunk using ProGuard) requires a lot of space. Note that we still can't handle this on ARM or PowerPC due to a limitation in the compiler, but we don't expect people to ship binaries with the entire OpenJDK class library anyway, so it shouldn't be a problem in practice. --- src/bootimage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 834431f7b4..3447dff69a 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -25,7 +25,7 @@ using namespace vm; namespace { -const unsigned HeapCapacity = 256 * 1024 * 1024; +const unsigned HeapCapacity = 512 * 1024 * 1024; const unsigned TargetFixieSizeInBytes = 8 + (TargetBytesPerWord * 2); const unsigned TargetFixieSizeInWords = ceiling @@ -1667,7 +1667,11 @@ main(int ac, const char** av) // in a branch instruction for the target architecture (~32MB on // PowerPC and ARM). When that limitation is removed, we'll be able // to specify a capacity as large as we like here: +#if (defined ARCH_x86_64) || (defined ARCH_x86_32) + const unsigned CodeCapacity = 128 * 1024 * 1024; +#else const unsigned CodeCapacity = 30 * 1024 * 1024; +#endif uint8_t* code = static_cast(h->allocate(CodeCapacity)); BootImage image; From 1120d8f91d976fb89b5b6de50d7ca61f757a403c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 10 Apr 2012 08:18:52 -0600 Subject: [PATCH 29/35] fix ProGuarded openjdk-src build This makes a simple "hello, world!" app work, at least. Further changes may be needed for more sophisticated apps. --- openjdk.pro | 6 ++++++ src/classpath-openjdk.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/openjdk.pro b/openjdk.pro index dd9e07a910..953b5e205b 100644 --- a/openjdk.pro +++ b/openjdk.pro @@ -11,6 +11,7 @@ -keep class java.lang.System { private static void initializeSystemClass(); + public static void setProperties(java.util.Properties); } -keep class java.lang.ClassLoader { @@ -33,6 +34,11 @@ -keep class java.util.Properties { public java.lang.Object setProperty(java.lang.String, java.lang.String); + public java.lang.String getProperty(java.lang.String); + } + +-keep class java.util.Hashtable { + public java.lang.Object remove(java.lang.Object); } -keep class avian.OpenJDK { diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index cbb705d8d9..5b23b4019f 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -1777,10 +1777,14 @@ intercept(Thread* t, object c, const char* name, const char* spec, set(t, runtimeData, MethodRuntimeDataNative, native); } else { - fprintf(stderr, "unable to find %s%s in %s\n", - name, spec, &byteArrayBody(t, className(t, c), 0)); + // If we can't find the method, just ignore it, since ProGuard may + // have stripped it out as unused. Otherwise, the code below can + // be uncommented for debugging purposes. - abort(t); + // fprintf(stderr, "unable to find %s%s in %s\n", + // name, spec, &byteArrayBody(t, className(t, c), 0)); + + // abort(t); } } From 01aa1e2bfdbccf89a3fe220a3603ee6bbc8d47a3 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 11 Apr 2012 11:29:10 -0600 Subject: [PATCH 30/35] add note to readme.txt about using ProGuard with an OpenJDK build --- readme.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index a81b6b2693..03b3b28d04 100644 --- a/readme.txt +++ b/readme.txt @@ -550,7 +550,12 @@ Step 5: Run ProGuard with stage1 as input and stage2 as output. -injars stage1 -outjars stage2 @../vm.pro @hello.pro (note: pass -dontusemixedcaseclassnames to ProGuard when building on -systems with case-insensitive filesystems such as Windows and OS X) +systems with case-insensitive filesystems such as Windows and OS X. +Also, you'll need to add -ignorewarnings if you use the OpenJDK class +library since the openjdk-src build does not include all the JARs from +OpenJDK, and thus ProGuard will not be able to resolve all referenced +classes. If you actually plan to use such classes at runtime, you'll +need to add them to stage1 before running ProGuard.) Step 6: Build the boot and code images. From 07f330967ffde70f01e591dc9d45e734a2b3e9e0 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 20 Apr 2012 16:05:04 -0600 Subject: [PATCH 31/35] update readme.txt based on recent feedback from the mailing list This clarifies the need to include both openjdk.pro and vm.pro when building with OpenJDK and ProGuard. It also makes -dontusemixedcaseclassnames the default in the ProGuard command and gives different names to the C++ files used in the embedding and bootimage examples to avoid confusion. --- readme.txt | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/readme.txt b/readme.txt index 03b3b28d04..9b0c1d28e1 100644 --- a/readme.txt +++ b/readme.txt @@ -260,7 +260,9 @@ an LZMA-enabled version: You can reduce the size futher for embedded builds by using ProGuard and the supplied openjdk.pro configuration file (see "Embedding with -ProGuard and a Boot Image" below). Also see app.mk in +ProGuard and a Boot Image" below). Note that you'll still need to use +vm.pro in that case -- openjdk.pro just adds additional constraints +specific to the OpenJDK port. Also see app.mk in git://oss.readytalk.com/avian-swt-examples.git for an example of using Avian, OpenJDK, ProGuard, and UPX in concert. @@ -364,7 +366,7 @@ method. Note the bootJar function, which will be called by the VM to get a handle to the embedded jar. We tell the VM about this jar by setting the boot classpath to "[bootJar]". - $ cat >main.cpp <embedded-jar-main.cpp <main.cpp <bootimage-main.cpp < Date: Wed, 25 Apr 2012 17:47:07 -0600 Subject: [PATCH 32/35] interpret time of zero as infinity when isAbsolute is false in Unsafe.park This behavior is not covered in the documentation, but LockSupport.park clearly relies on it. --- src/classpath-openjdk.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 5b23b4019f..78cb98083a 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -2739,12 +2739,15 @@ Avian_sun_misc_Unsafe_park if (time <= 0) { return; } - } else { - time /= 1000 * 1000; + } else if (time) { + // if not absolute, interpret time as nanoseconds, but make sure + // it doesn't become zero when we convert to milliseconds, since + // zero is interpreted as infinity below + time = (time / (1000 * 1000)) + 1; } monitorAcquire(t, local::interruptLock(t, t->javaThread)); - while (time > 0 + while (time >= 0 and (not (threadUnparked(t, t->javaThread) or monitorWait (t, local::interruptLock(t, t->javaThread), time)))) @@ -2752,6 +2755,10 @@ Avian_sun_misc_Unsafe_park int64_t now = t->m->system->now(); time -= now - then; then = now; + + if (time == 0) { + break; + } } threadUnparked(t, t->javaThread) = false; monitorRelease(t, local::interruptLock(t, t->javaThread)); From e6afc6c321181871ac4a0b707d40e3ebc2490e5b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 2 May 2012 11:41:36 -0600 Subject: [PATCH 33/35] set Thread.interrupted to true if thread is interrupted outside wait or sleep This is the correct behavior according to the Thread.interrupt JavaDoc, and it fixes an intermittent hang on exit in Eclipse. --- src/classpath-avian.cpp | 6 ++++++ src/classpath-openjdk.cpp | 20 ++++++++++++++++++-- src/machine.h | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index 39cde4ff83..5df85fa6b6 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -54,6 +54,12 @@ class MyClasspath : public Classpath { root(t, Machine::BootLoader), 0, 0, group, 0); } + virtual void + clearInterrupted(Thread*) + { + // ignore + } + virtual void runThread(Thread* t) { diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 78cb98083a..721889e452 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -344,6 +344,9 @@ makeClassNameString(Thread* t, object name) void interceptFileOperations(Thread*); +void +clearInterrupted(Thread*); + class MyClasspath : public Classpath { public: static const unsigned BufferSize = 1024; @@ -506,6 +509,12 @@ class MyClasspath : public Classpath { return thread; } + virtual void + clearInterrupted(Thread* t) + { + local::clearInterrupted(t); + } + virtual void runThread(Thread* t) { @@ -2212,6 +2221,14 @@ interruptLock(Thread* t, object thread) return threadInterruptLock(t, thread); } +void +clearInterrupted(Thread* t) +{ + monitorAcquire(t, local::interruptLock(t, t->javaThread)); + threadInterrupted(t, t->javaThread) = false; + monitorRelease(t, local::interruptLock(t, t->javaThread)); +} + bool pipeAvailable(int fd, int* available) { @@ -3350,9 +3367,8 @@ jvmInterrupt(Thread* t, uintptr_t* arguments) Thread* p = reinterpret_cast(threadPeer(t, *thread)); if (p) { interrupt(t, p); - } else { - threadInterrupted(t, *thread) = true; } + threadInterrupted(t, *thread) = true; monitorRelease(t, local::interruptLock(t, *thread)); return 1; diff --git a/src/machine.h b/src/machine.h index cdb3ecf039..eea9cc506b 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1577,6 +1577,9 @@ class Classpath { virtual object makeThread(Thread* t, Thread* parent) = 0; + virtual void + clearInterrupted(Thread* t) = 0; + virtual void runThread(Thread* t) = 0; @@ -3215,6 +3218,7 @@ wait(Thread* t, object o, int64_t milliseconds) if (interrupted) { if (t->m->alive or (t->flags & Thread::DaemonFlag) == 0) { + t->m->classpath->clearInterrupted(t); throwNew(t, Machine::InterruptedExceptionType); } else { throw_(t, root(t, Machine::Shutdown)); From 189340954a7b5a3402551270c5989a12de3783e1 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 4 May 2012 18:59:15 -0600 Subject: [PATCH 34/35] fix build regression due to last merge --- src/compile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compile.cpp b/src/compile.cpp index e4b49ed373..0823af833a 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -612,7 +612,7 @@ class MyStackWalker: public Processor::StackWalker { } void next() { - expect(t, count_ <= StackSizeInWords); + expect(t, count_ <= stackSizeInWords(t)); switch (state) { case Continuation: From b09a388be5ab202175450144d4af6c6b32464629 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 4 May 2012 20:31:50 -0600 Subject: [PATCH 35/35] update readme.txt to reflect OpenJDK 7 dependency --- readme.txt | 59 ++++++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/readme.txt b/readme.txt index d0299875c3..45bc4add45 100644 --- a/readme.txt +++ b/readme.txt @@ -220,11 +220,11 @@ features beyond that subset, you may want to tell Avian to use OpenJDK's class library instead. To do so, specify the directory where OpenJDK is installed, e.g.: - $ make openjdk=/usr/lib/jvm/java-6-openjdk + $ make openjdk=/usr/lib/jvm/java-7-openjdk This will build Avian as a conventional JVM (e.g. libjvm.so) which loads its boot class library and native libraries (e.g. libjava.so) -from /usr/lib/jvm/java-6-openjdk/jre at runtime. To run an +from /usr/lib/jvm/java-7-openjdk/jre at runtime. To run an application in this configuration, you'll need to make sure the VM is in your library search path. For example: @@ -235,8 +235,8 @@ in your library search path. For example: Alternatively, you can enable a stand-alone build using OpenJDK by specifying the location of the OpenJDK source code, e.g.: - $ make openjdk=$(pwd)/../jdk6/build/linux-amd64/j2sdk-image \ - openjdk-src=$(pwd)/../jdk6/jdk/src + $ make openjdk=$(pwd)/../jdk7/build/linux-amd64/j2sdk-image \ + openjdk-src=$(pwd)/../jdk7/jdk/src You must ensure that the path specified for openjdk-src does not have any spaces in it; make gets confused when dependency paths include @@ -271,49 +271,42 @@ it on various OSes: Debian-based Linux: # conventional build: - apt-get install openjdk-6-jdk - make openjdk=/usr/lib/jvm/java-6-openjdk test + apt-get install openjdk-7-jdk + make openjdk=/usr/lib/jvm/java-7-openjdk test # stand-alone build: - apt-get install openjdk-6-jdk - apt-get source openjdk-6-jdk - apt-get build-dep openjdk-6-jdk - (cd openjdk-6-6b18-1.8.3 && ./debian/rules patch) - make openjdk=/usr/lib/jvm/java-6-openjdk \ - openjdk-src=$(pwd)/openjdk-6-6b18-1.8.3/build/openjdk/jdk/src \ + apt-get install openjdk-7-jdk + apt-get source openjdk-7-jdk + apt-get build-dep openjdk-7-jdk + (cd openjdk-7-7~b147-2.0 && dpkg-buildpackage) + make openjdk=/usr/lib/jvm/java-7-openjdk \ + openjdk-src=$(pwd)/openjdk-7-7~b147-2.0/build/openjdk/jdk/src \ test Mac OS X: - # Prerequisite: install MacPorts (http://www.macports.org/) - sudo port selfupdate + # Prerequisite: build OpenJDK 7 according to + # https://wikis.oracle.com/display/OpenJDK/Mac+OS+X+Port # conventional build: - sudo port install openjdk6 - make openjdk=/opt/local/share/java/openjdk6 test + make openjdk=$(pwd)/../jdk7u-dev/build/macosx-amd64/j2sdk-image test # stand-alone build: - sudo port fetch openjdk6 - sudo port patch openjdk6 - make openjdk=/opt/local/share/java/openjdk6 \ - openjdk-src=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_java_openjdk6/work/jdk/src \ - test + make openjdk=$(pwd)/../jdk7u-dev/build/macosx-amd64/j2sdk-image \ + openjdk-src=$(pwd)/../p/jdk7u-dev/jdk/src test Windows (Cygwin): + # Prerequisite: build OpenJDK 7 according to + # http://weblogs.java.net/blog/simonis/archive/2011/10/28/yaojowbi-yet-another-openjdk-windows-build-instruction + # conventional build: - # Prerequisite: download and install the latest Windows OpenJDK - # build from http://www.openscg.com/se/openjdk/ - make openjdk=/cygdrive/c/OpenSCG/openjdk-6.21 test + make openjdk=$(pwd)/../jdk7u-dev/build/windows-i586/j2sdk-image test # stand-alone build: - # Prerequisite: install OpenSCG build as above, plus the - # corresponding source bundle from - # http://download.java.net/openjdk/jdk6/promoted/, e.g.: - wget http://download.java.net/openjdk/jdk6/promoted/b21/openjdk-6-src-b21-20_jan_2011.tar.gz - mkdir openjdk - (cd openjdk && tar xzf ../openjdk-6-src-b21-20_jan_2011.tar.gz) - make openjdk=/cygdrive/c/OpenSCG/openjdk-6.21 \ - openjdk-src=$(pwd)/openjdk/jdk/src \ - test + make openjdk=$(pwd)/../jdk7u-dev/build/windows-i586/j2sdk-image \ + openjdk-src=$(pwd)/../p/jdk7u-dev/jdk/src test + +Currently, only OpenJDK 7 is supported. Later versions might work, +but have not yet been tested. Installing