diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index dc76e5f3ab..2ca5ee04d1 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -232,6 +232,8 @@ static inline void releaseChars(JNIEnv* e, jstring path, string_t chars) e->RELEASE_CHARS(path, chars); } +#ifndef SGX + extern "C" JNIEXPORT jstring JNICALL Java_java_io_File_toCanonicalPath(JNIEnv* /*e*/, jclass, jstring path) { @@ -802,6 +804,8 @@ extern "C" JNIEXPORT jint JNICALL } } +#endif // !SGX + extern "C" JNIEXPORT void JNICALL Java_java_io_FileOutputStream_write__II(JNIEnv* e, jclass, jint fd, jint c) { @@ -838,6 +842,8 @@ extern "C" JNIEXPORT void JNICALL doClose(e, fd); } +#ifndef SGX + extern "C" JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_open(JNIEnv* e, jclass, @@ -1005,3 +1011,5 @@ extern "C" JNIEXPORT void JNICALL CloseHandle(hFile); #endif } + +#endif // !SGX \ No newline at end of file diff --git a/classpath/java-net.cpp b/classpath/java-net.cpp index 71a128a1d8..cafb02238a 100644 --- a/classpath/java-net.cpp +++ b/classpath/java-net.cpp @@ -8,6 +8,8 @@ There is NO WARRANTY for this software. See license.txt for details. */ +#ifndef SGX + #include "jni.h" #include "avian/machine.h" #include "sockets.h" @@ -139,3 +141,5 @@ extern "C" JNIEXPORT jint JNICALL return 0; } } + +#endif // !SGX \ No newline at end of file diff --git a/classpath/java-nio.cpp b/classpath/java-nio.cpp index 9f8a44aee2..e04adc2d70 100644 --- a/classpath/java-nio.cpp +++ b/classpath/java-nio.cpp @@ -8,6 +8,8 @@ There is NO WARRANTY for this software. See license.txt for details. */ +#ifndef SGX + #include #include #include @@ -1096,3 +1098,5 @@ extern "C" JNIEXPORT jboolean JNICALL return JNI_TRUE; return JNI_FALSE; } + +#endif // !SGX \ No newline at end of file diff --git a/classpath/sockets.cpp b/classpath/sockets.cpp index becccfd237..ddffc18576 100644 --- a/classpath/sockets.cpp +++ b/classpath/sockets.cpp @@ -13,6 +13,8 @@ * It is used from different classes of the default Avian classpath */ +#ifndef SGX + #include "sockets.h" namespace avian { @@ -199,3 +201,5 @@ void close_output(JNIEnv* e, SOCKET sock) } } } + +#endif \ No newline at end of file diff --git a/makefile b/makefile index da193feab0..d7db2484bb 100755 --- a/makefile +++ b/makefile @@ -524,6 +524,10 @@ build-system = posix system = posix asm = x86 +ifeq ($(system),sgx) + cflags += -DSGX +endif + pointer-size = 8 so-prefix = lib diff --git a/src/avian/machine.h b/src/avian/machine.h index d1fa2cced9..8b59bb85a2 100644 --- a/src/avian/machine.h +++ b/src/avian/machine.h @@ -1831,6 +1831,15 @@ inline uint64_t runThread(Thread* t, uintptr_t*) inline bool startThread(Thread* t, Thread* p) { p->setFlag(Thread::JoinFlag); +#ifdef SGX + static const char16_t *nameToSkip = u"Reference Handler"; + if (p->javaThread->name()->length(t) == 17) { + if (!memcmp(nameToSkip, cast(t, p->javaThread->name()->data())->body().begin(), 17 * 2)) { + printf("Skipping start of reference handler thread\n"); + return true; + } + } +#endif return t->m->system->success(t->m->system->start(&(p->runnable))); } diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 82eb3d3169..57613ab2d2 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -70,6 +70,7 @@ jint JNICALL DetachCurrentThread(Machine* m) uint64_t destroyJavaVM(Thread* t, uintptr_t*) { +#ifndef SGX // wait for other non-daemon threads to exit { ACQUIRE(t, t->m->stateLock); @@ -77,13 +78,13 @@ uint64_t destroyJavaVM(Thread* t, uintptr_t*) t->m->stateLock->wait(t->systemThread, 0); } } - +#endif { ENTER(t, Thread::ActiveState); t->m->classpath->shutDown(t); } - +#ifndef SGX // wait again in case the Classpath::shutDown process started new // threads: { @@ -94,7 +95,7 @@ uint64_t destroyJavaVM(Thread* t, uintptr_t*) enter(t, Thread::ExclusiveState); } - +#endif shutDown(t); return 1; @@ -3349,11 +3350,12 @@ uint64_t boot(Thread* t, uintptr_t*) t->javaThread->peer() = reinterpret_cast(t); +#ifndef SGX GcThread* jthread = t->m->classpath->makeThread(t, t); // sequence point, for gc (don't recombine statements) roots(t)->setFinalizerThread(t, jthread); - roots(t)->finalizerThread()->daemon() = true; +#endif t->m->classpath->boot(t); diff --git a/src/machine.cpp b/src/machine.cpp index 086218312e..50768edc2e 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -3541,6 +3541,7 @@ void doCollect(Thread* t, Heap::CollectionType type, int pendingAllocation) function(t, finalizeQueue->target()); } +#ifndef SGX if ((roots(t)->objectsToFinalize() or roots(t)->objectsToClean()) and m->finalizeThread == 0 and t->state != Thread::ExitState) { m->finalizeThread = m->processor->makeThread( @@ -3553,6 +3554,7 @@ void doCollect(Thread* t, Heap::CollectionType type, int pendingAllocation) m->finalizeThread = 0; } } +#endif } uint64_t invokeLoadClass(Thread* t, uintptr_t* arguments)