コード例 #1
0
// Create an exception then throws it.
extern "C" void j3ThrowExceptionFromJIT() {
  JavaObject *exc = 0;
  llvm_gcroot(exc, 0);
  JavaThread *th = JavaThread::get();
  JavaMethod* meth = th->getCallingMethodLevel(0);
  exc = th->getJVM()->CreateUnsatisfiedLinkError(meth);
  j3ThrowException(exc);
}
コード例 #2
0
ファイル: JavaUpcalls.cpp プロジェクト: ChrisKitching/vmkit
extern "C" JavaObject* Java_gnu_classpath_VMStackWalker_getCallingClass__() {
  
  JavaObject* res = 0;
  llvm_gcroot(res, 0);

  BEGIN_NATIVE_EXCEPTION(0)

  JavaThread* th = JavaThread::get();
  UserClass* cl = th->getCallingClassLevel(2);
  if (cl != NULL) res = cl->getClassDelegatee(th->getJVM());
  
  END_NATIVE_EXCEPTION

  return res;
}
コード例 #3
0
ファイル: JavaUpcalls.cpp プロジェクト: chanwit/vmkit
extern "C" JavaObject* nativeGetCallingClass() {
  
  JavaObject* res = 0;
  llvm_gcroot(res, 0);

  BEGIN_NATIVE_EXCEPTION(0)

  JavaThread* th = JavaThread::get();
  UserClass* cl = th->getCallingClassLevel(2);
  if (cl != NULL) res = cl->getClassDelegatee(th->getJVM());
  
  END_NATIVE_EXCEPTION

  return res;
}
コード例 #4
0
ファイル: JavaUpcalls.cpp プロジェクト: ChrisKitching/vmkit
extern "C" JavaObject* Java_sun_reflect_Reflection_getCallerClass__I(uint32 index) {
  
  JavaObject* res = 0;
  llvm_gcroot(res, 0);
  
  BEGIN_NATIVE_EXCEPTION(0)
  
  JavaThread* th = JavaThread::get();
  Jnjvm* vm = th->getJVM();
  UserClass* cl = th->getCallingClassLevel(index);
  if (cl) res = cl->getClassDelegatee(vm);
  
  END_NATIVE_EXCEPTION

  return res;
}
コード例 #5
0
inline ArraySInt8* getAttrBytes(JavaAttribute* annotationsAtt, Class* cl) {
  ArraySInt8* ret = 0;
  llvm_gcroot(ret, 0);

  if (!annotationsAtt) return 0;

  JavaThread* th = JavaThread::get();
  Jnjvm* vm = th->getJVM();

  uint32 len = annotationsAtt->nbb;
  ret = (ArraySInt8*)vm->upcalls->ArrayOfByte->doNew(len, vm);

  Reader reader(annotationsAtt, cl->bytes);
  for(uint32 i = 0; i < len; ++i) {
    ArraySInt8::setElement(ret, reader.readS1(), i);
  }

  return ret;
}
コード例 #6
0
extern "C" void* j3ResolveSpecialStub() {
  JavaThread *th = JavaThread::get();
  void* result = NULL;

  // Lookup the caller of this class.
  vmkit::StackWalker Walker(th);
  ++Walker; // Remove the stub.
  vmkit::FrameInfo* FI = Walker.get();
  assert(FI->Metadata != NULL && "Wrong stack trace");
  JavaMethod* caller = (JavaMethod*)FI->Metadata;

  // Lookup the method info in the constant pool of the caller.
  uint16 ctpIndex = caller->lookupCtpIndex(FI);
  assert(ctpIndex && "No constant pool index");
  JavaConstantPool* ctpInfo = caller->classDef->getConstantPool();
  CommonClass* cl = 0;
  const UTF8* utf8 = 0;
  Signdef* sign = 0;

  ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign);
  UserClass* lookup = cl->isArray() ? cl->super : cl->asClass();
  assert(lookup->isInitializing() && "Class not ready");
  JavaMethod* callee =
    lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, caller->classDef);
  
  if (!callee) {
    th->getJVM()->noSuchMethodError(lookup, utf8);
  }
  if (isAbstract(callee->access)) {
    JavaThread::get()->getJVM()->abstractMethodError(callee->classDef, callee->name);
  }

  // Compile the found method.
  result = callee->compiledPtr();
    
  // Update the entry in the constant pool.
  ctpInfo->ctpRes[ctpIndex] = result;

  return result;
}
コード例 #7
0
ファイル: JavaObject.cpp プロジェクト: chanwit/vmkit
void JavaObject::waitIntern(
    JavaObject* self, struct timeval* info, bool timed) {
  llvm_gcroot(self, 0);
  JavaLock* l = 0;

  if (owner(self)) {
    l = self->lock.changeToFatlock(self);
    JavaThread* thread = JavaThread::get();
    thread->waitsOn = l;
    mvm::Cond& varcondThread = thread->varcond;

    if (thread->interruptFlag != 0) {
      thread->interruptFlag = 0;
      thread->waitsOn = 0;
      thread->getJVM()->interruptedException(self);
    } else { 
      thread->state = JavaThread::StateWaiting;
      if (l->firstThread) {
        assert(l->firstThread->prevWaiting && l->firstThread->nextWaiting &&
               "Inconsistent list");
        if (l->firstThread->nextWaiting == l->firstThread) {
          l->firstThread->nextWaiting = thread;
        } else {
          l->firstThread->prevWaiting->nextWaiting = thread;
        } 
        thread->prevWaiting = l->firstThread->prevWaiting;
        thread->nextWaiting = l->firstThread;
        l->firstThread->prevWaiting = thread;
      } else {
        l->firstThread = thread;
        thread->nextWaiting = thread;
        thread->prevWaiting = thread;
      }
      assert(thread->prevWaiting && thread->nextWaiting && "Inconsistent list");
      assert(l->firstThread->prevWaiting && l->firstThread->nextWaiting &&
             "Inconsistent list");
      
      bool timeout = false;

      l->waitingThreads++;

      while (!thread->interruptFlag && thread->nextWaiting) {
        if (timed) {
          timeout = varcondThread.timedWait(&l->internalLock, info);
          if (timeout) break;
        } else {
          varcondThread.wait(&l->internalLock);
        }
      }
      
      l->waitingThreads--;
     
      assert((!l->firstThread || (l->firstThread->prevWaiting && 
             l->firstThread->nextWaiting)) && "Inconsistent list");
 
      bool interrupted = (thread->interruptFlag != 0);

      if (interrupted || timeout) {
        
        if (thread->nextWaiting) {
          assert(thread->prevWaiting && "Inconsistent list");
          if (l->firstThread != thread) {
            thread->nextWaiting->prevWaiting = thread->prevWaiting;
            thread->prevWaiting->nextWaiting = thread->nextWaiting;
            assert(l->firstThread->prevWaiting && 
                   l->firstThread->nextWaiting && "Inconsistent list");
          } else if (thread->nextWaiting == thread) {
            l->firstThread = 0;
          } else {
            l->firstThread = thread->nextWaiting;
            l->firstThread->prevWaiting = thread->prevWaiting;
            thread->prevWaiting->nextWaiting = l->firstThread;
            assert(l->firstThread->prevWaiting && 
                   l->firstThread->nextWaiting && "Inconsistent list");
          }
          thread->nextWaiting = 0;
          thread->prevWaiting = 0;
        } else {
          assert(!thread->prevWaiting && "Inconstitent state");
          // Notify lost, notify someone else.
          notify(self);
        }
      } else {
        assert(!thread->prevWaiting && !thread->nextWaiting &&
               "Inconsistent state");
      }
      
      thread->state = JavaThread::StateRunning;
      thread->waitsOn = 0;

      if (interrupted) {
        thread->interruptFlag = 0;
        thread->getJVM()->interruptedException(self);
      }
    }
  } else {
    JavaThread::get()->getJVM()->illegalMonitorStateException(self);
  }
  
  assert(owner(self) && "Not owner after wait");
}