[vmkit-commits] [vmkit] r180530 - experimenting
Peter Senna Tschudin
peter.senna at gmail.com
Thu Apr 25 10:22:16 PDT 2013
Author: peter.senna
Date: Thu Apr 25 12:20:45 2013
New Revision: 180530
URL: http://llvm.org/viewvc/llvm-project?rev=180530&view=rev
Log:
experimenting
(cherry picked from commit dea7d850cd88dd49ee9159a556623fc7d2c39d92)
Modified:
vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc
vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp
vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp
vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp
Modified: vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc?rev=180530&r1=180529&r2=180530&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc (original)
+++ vmkit/trunk/lib/j3/ClassLib/OpenJDK/OpenJDK.inc Thu Apr 25 12:20:45 2013
@@ -786,8 +786,10 @@ JVM_Interrupt(JNIEnv *env, jobject _thre
JavaThread* jth = (JavaThread*)field->getInstanceLongField(thread);
jth->lockingThread.interruptFlag = 1;
+ //jth->parkLock.unpark();
+ jth->parkLock.interrupt();
vmkit::FatLock* lock = jth->lockingThread.waitsOn;
- jth->parkLock.unpark();
+
// If the thread is blocked on a wait. We also verify nextWaiting in case
// the thread has been notified.
@@ -2585,7 +2587,19 @@ JVM_Close(jint fd) {
JNIEXPORT jint JNICALL
JVM_Read(jint fd, char *buf, jint nbytes) {
BEGIN_JNI_EXCEPTION
- jint res = read(fd, buf, nbytes);
+ vmkit::Thread* th = vmkit::Thread::get();
+ assert(th && "Thread was not found");
+ //void* ptr = __builtin_frame_address(0);
+ jint res = 0;
+ if (fd)
+ res = read(fd, buf, nbytes);
+ else {
+ //th->enterUncooperativeCode((uint16_t)2);
+ //res = read(fd, buf, nbytes);
+ //th->leaveUncooperativeCode();
+ res = 1;
+ buf[0] = 'a';
+ }
RETURN_FROM_JNI(res);
END_JNI_EXCEPTION
return -1;
Modified: vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp?rev=180530&r1=180529&r2=180530&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp Thu Apr 25 12:20:45 2013
@@ -41,7 +41,18 @@ void CollectionRV::waitRV() {
// Add myself.
nbJoined++;
+ fprintf(stderr, "waitRV: %d from %d\n", nbJoined, self->MyVM->numberOfThreads);
+
while (nbJoined != self->MyVM->numberOfThreads) {
+ vmkit::Thread* cur = self;
+ fprintf(stderr, "Wasting time : ");
+ for (cur = (vmkit::Thread*)self->next(); cur != self;
+ cur = (vmkit::Thread*)cur->next()) {
+ if (!cur->getLastSP() && cur != self) {
+ fprintf(stderr, "%p,", cur);
+ }
+ }
+ fprintf(stderr, "\n");
condInitiator.wait(&_lockRV);
}
}
@@ -74,6 +85,8 @@ void CooperativeCollectionRV::synchroniz
}
}
+ fprintf(stderr, "synchronize: %d from %d\n", nbJoined, self->MyVM->numberOfThreads);
+
// And wait for other threads to finish.
waitRV();
Modified: vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp?rev=180530&r1=180529&r2=180530&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp Thu Apr 25 12:20:45 2013
@@ -264,7 +264,7 @@ int Cond::myTimeWait(Lock* l, bool isAbs
absTime.tv_nsec = 0;
}
else {
- absTime.tv_sec = now.tv_sec + secs + 1100; // 150 / 850 / 1000
+ absTime.tv_sec = now.tv_sec + secs + 0; // 150 / 850 / 1000
absTime.tv_nsec = (nsec % NANOSECS_PER_SEC) + now.tv_usec*1000;
if (absTime.tv_nsec >= NANOSECS_PER_SEC) {
absTime.tv_nsec -= NANOSECS_PER_SEC;
Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp?rev=180530&r1=180529&r2=180530&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Thu Apr 25 12:20:45 2013
@@ -21,6 +21,7 @@
#include <errno.h>
#include <pthread.h>
#include <sys/mman.h>
+#include <sys/syscall.h>
#include <sched.h>
#include <signal.h>
#include <unistd.h>
@@ -160,6 +161,9 @@ StackWalker::StackWalker(vmkit::Thread*
} else {
addr = th->waitOnSP();
if (frame) {
+ if (frame->currentFP < addr) {
+ fprintf(stderr, "Error in thread with pointer %p because %x < %x\n", th, frame->currentFP, addr);
+ }
assert(frame->currentFP >= addr);
}
if (frame && (addr == frame->currentFP)) {
@@ -362,6 +366,7 @@ void Thread::internalThreadStart(vmkit::
//sigaction(SIGTERM, &sa, NULL);
assert(th->MyVM && "VM not set in a thread");
+ fprintf(stderr, "Thread %p has TID %ld\n", th,syscall(SYS_gettid) );
th->MyVM->rendezvous.addThread(th);
th->routine(th);
th->MyVM->removeThread(th);
More information about the vmkit-commits
mailing list