[vmkit-commits] [vmkit] r81119 - in /vmkit/trunk: Makefile.rules include/mvm/Allocator.h lib/JnJVM/VMCore/JavaObject.cpp lib/JnJVM/VMCore/JavaObject.h lib/JnJVM/VMCore/JavaString.cpp tools/jnjvm/Makefile tools/vmkit/Makefile

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Sep 6 07:58:30 PDT 2009


Author: geoffray
Date: Sun Sep  6 09:58:29 2009
New Revision: 81119

URL: http://llvm.org/viewvc/llvm-project?rev=81119&view=rev
Log:
Build vmkit and jnjvm with .bc files.


Modified:
    vmkit/trunk/Makefile.rules
    vmkit/trunk/include/mvm/Allocator.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp
    vmkit/trunk/tools/jnjvm/Makefile
    vmkit/trunk/tools/vmkit/Makefile

Modified: vmkit/trunk/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile.rules?rev=81119&r1=81118&r2=81119&view=diff

==============================================================================
--- vmkit/trunk/Makefile.rules (original)
+++ vmkit/trunk/Makefile.rules Sun Sep  6 09:58:29 2009
@@ -97,3 +97,29 @@
 
 endif
 
+
+
+ifdef TOOLNAME
+ifdef USEDMODULES
+
+ProjLibsPaths   := $(addprefix $(LibDir)/,$(USEDMODULES))
+
+$(TOOLNAME).bc : $(ProjLibsPaths)
+	$(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
+	$(Verb) $(LLVMLD) -L$(CFERuntimeLibDir) -r -o $@ $(ProjLibsPaths)
+
+$(TOOLNAME).s : $(TOOLNAME).bc
+	$(Echo) Building $(BuildMode) Assembly file $(notdir $@)
+	$(Verb) $(LOPT) -f $(TOOLNAME).bc -o $(TOOLNAME)-optimized.bc
+	$(Verb) $(LLC) -f $(TOOLNAME)-optimized.bc -o $(TOOLNAME).s
+
+$(ObjDir)/%.o: %.s $(ObjDir)/.dir $(BUILT_SOURCES)
+	$(Echo) "Compiling $*.s for $(BuildMode) build" $(PIC_FLAG)
+	$(Verb) $(Compile.C) $< -o $(ObjDir)/$*.o
+
+clean-local::
+	$(Verb) $(RM) -f $(TOOLNAME)-optimized.bc $(TOOLNAME).bc $(TOOLNAME).s
+
+endif
+endif
+

Modified: vmkit/trunk/include/mvm/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Allocator.h?rev=81119&r1=81118&r2=81119&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Allocator.h (original)
+++ vmkit/trunk/include/mvm/Allocator.h Sun Sep  6 09:58:29 2009
@@ -21,7 +21,8 @@
 class VirtualTable;
 
 #ifdef WITH_LLVM_GCC
-extern "C" void llvm_gcroot(const void*, void*) asm("llvm.gcroot");
+extern "C" void __llvm_gcroot(const void*, void*) __attribute__((nothrow));
+#define llvm_gcroot(a, b) __llvm_gcroot(&a, b)
 #else
 #define llvm_gcroot(a, b)
 #endif

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=81119&r1=81118&r2=81119&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Sun Sep  6 09:58:29 2009
@@ -36,11 +36,12 @@
 
 void JavaObject::waitIntern(struct timeval* info, bool timed) {
   LockObj* l = 0;
-  llvm_gcroot(this, 0);
+  JavaObject* self = this;
+  llvm_gcroot(self, 0);
   llvm_gcroot(l, 0);
 
   if (owner()) {
-    l = lock.changeToFatlock(this);
+    l = self->lock.changeToFatlock(self);
     JavaThread* thread = JavaThread::get();
     thread->waitsOn = l;
     mvm::Cond& varcondThread = thread->varcond;
@@ -48,7 +49,7 @@
     if (thread->interruptFlag != 0) {
       thread->interruptFlag = 0;
       thread->waitsOn = 0;
-      thread->getJVM()->interruptedException(this);
+      thread->getJVM()->interruptedException(self);
     } else { 
       thread->state = JavaThread::StateWaiting;
       if (l->firstThread) {
@@ -122,32 +123,35 @@
 
       if (interrupted) {
         thread->interruptFlag = 0;
-        thread->getJVM()->interruptedException(this);
+        thread->getJVM()->interruptedException(self);
       }
     }
   } else {
-    JavaThread::get()->getJVM()->illegalMonitorStateException(this);
+    JavaThread::get()->getJVM()->illegalMonitorStateException(self);
   }
   assert(owner() && "Not owner after wait");
 }
 
 void JavaObject::wait() {
-  llvm_gcroot(this, 0);
+  JavaObject* self = this;
+  llvm_gcroot(self, 0);
   waitIntern(0, false);
 }
 
 void JavaObject::timedWait(struct timeval& info) {
-  llvm_gcroot(this, 0);
+  JavaObject* self = this;
+  llvm_gcroot(self, 0);
   waitIntern(&info, true);
 }
 
 void JavaObject::notify() {
   LockObj* l = 0;
-  llvm_gcroot(this, 0);
+  JavaObject* self = this;
+  llvm_gcroot(self, 0);
   llvm_gcroot(l, 0);
 
   if (owner()) {
-    l = lock.getFatLock();
+    l = self->lock.getFatLock();
     if (l) {
       JavaThread* cur = l->firstThread;
       if (cur) {
@@ -181,18 +185,19 @@
       }
     }
   } else {
-    JavaThread::get()->getJVM()->illegalMonitorStateException(this);
+    JavaThread::get()->getJVM()->illegalMonitorStateException(self);
   }
   assert(owner() && "Not owner after notify");
 }
 
 void JavaObject::notifyAll() {
   LockObj* l = 0;
-  llvm_gcroot(this, 0);
+  JavaObject* self = this;
+  llvm_gcroot(self, 0);
   llvm_gcroot(l, 0);
   
   if (owner()) {
-    l = lock.getFatLock();
+    l = self->lock.getFatLock();
     if (l) {
       JavaThread* cur = l->firstThread;
       if (cur) {
@@ -207,7 +212,7 @@
       }
     }
   } else {
-    JavaThread::get()->getJVM()->illegalMonitorStateException(this);
+    JavaThread::get()->getJVM()->illegalMonitorStateException(self);
   }
 
   assert(owner() && "Not owner after notifyAll");
@@ -359,8 +364,9 @@
 }
 
 bool JavaObject::instanceOf(UserCommonClass* cl) {
-  llvm_gcroot(this, 0);
+  JavaObject* self = this;
+  llvm_gcroot(self, 0);
 
-  if (!this) return false;
-  else return this->getClass()->isAssignableFrom(cl);
+  if (!self) return false;
+  else return self->getClass()->isAssignableFrom(cl);
 }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h?rev=81119&r1=81118&r2=81119&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h Sun Sep  6 09:58:29 2009
@@ -49,8 +49,9 @@
   /// acquire - Acquires the lock.
   ///
   void acquire() {
-    llvm_gcroot(this, 0);
-    lock.lock();
+    LockObj* self = this;
+    llvm_gcroot(self, 0);
+    self->lock.lock();
   }
   
   /// tryAcquire - Tries to acquire the lock.
@@ -61,8 +62,9 @@
   
   /// acquireAll - Acquires the lock nb times.
   void acquireAll(uint32 nb) {
-    llvm_gcroot(this, 0);
-    lock.lockAll(nb);
+    LockObj* self = this;
+    llvm_gcroot(self, 0);
+    self->lock.lockAll(nb);
   }
 
   /// release - Releases the lock.
@@ -301,8 +303,9 @@
 
   /// acquire - Acquire the lock on this object.
   void acquire() {
-    llvm_gcroot(this, 0);
-    lock.acquire();
+    JavaObject* self = this;
+    llvm_gcroot(self, 0);
+    self->lock.acquire();
   }
 
   /// release - Release the lock on this object

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp?rev=81119&r1=81118&r2=81119&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp Sun Sep  6 09:58:29 2009
@@ -49,20 +49,21 @@
 }
 
 const ArrayUInt16* JavaString::strToArray(Jnjvm* vm) {
-  llvm_gcroot(this, 0);
+  JavaString* self = this;
+  llvm_gcroot(self, 0);
 
-  assert(value && "String without an array?");
-  if (offset || (count != value->size)) {
+  assert(self->value && "String without an array?");
+  if (self->offset || (self->count != self->value->size)) {
     ArrayUInt16* array = 
-      (ArrayUInt16*)vm->upcalls->ArrayOfChar->doNew(count, vm);
+      (ArrayUInt16*)vm->upcalls->ArrayOfChar->doNew(self->count, vm);
     uint16* buf = array->elements;
 
     for (sint32 i = 0; i < count; i++) {
-      buf[i] = value->elements[i + offset];
+      buf[i] = self->value->elements[i + self->offset];
     }
     return array;
   } else {
-    return value;
+    return self->value;
   }
 }
 
@@ -92,15 +93,16 @@
 }
 
 const UTF8* JavaString::javaToInternal(UTF8Map* map) const {
-  llvm_gcroot(this, 0);
+  const JavaString* self = this;
+  llvm_gcroot(self, 0);
   
-  uint16* java = (uint16*)alloca(sizeof(uint16) * count);
+  uint16* java = (uint16*)alloca(sizeof(uint16) * self->count);
 
   for (sint32 i = 0; i < count; ++i) {
-    uint16 cur = value->elements[offset + i];
+    uint16 cur = self->value->elements[offset + i];
     if (cur == '.') java[i] = '/';
     else java[i] = cur;
   }
   
-  return map->lookupOrCreateReader(java, count);
+  return map->lookupOrCreateReader(java, self->count);
 }

Modified: vmkit/trunk/tools/jnjvm/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/jnjvm/Makefile?rev=81119&r1=81118&r2=81119&view=diff

==============================================================================
--- vmkit/trunk/tools/jnjvm/Makefile (original)
+++ vmkit/trunk/tools/jnjvm/Makefile Sun Sep  6 09:58:29 2009
@@ -11,12 +11,32 @@
 include $(LEVEL)/Makefile.config
 
 TOOLNAME = jnjvm
+
+ifeq ($(WITH_LLVM_GCC), 1)
+
+  USEDMODULES = JnJVM.bc Classpath.bc JnjvmCompiler.bc Allocator.bc CommonThread.bc \
+		Mvm.bc MvmCompiler.bc $(GCLIB).bc
+
+  ifeq ($(ISOLATE_SHARING_BUILD), 1) 
+    USEDMODULES += Isolate.bc
+  endif
+
+  BUILT_SOURCES = jnjvm.s
+  SOURCES = jnjvm.s $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp))
+
+else
+
 USEDLIBS = JnJVM.a Classpath.a JnjvmCompiler.a Allocator.a CommonThread.a \
 	   Mvm.a MvmCompiler.a $(GCLIB).a
-LINK_COMPONENTS = jit nativecodegen scalaropts instrumentation ipa ipo
 
-ifeq ($(ISOLATE_SHARING_BUILD), 1) 
+  ifeq ($(ISOLATE_SHARING_BUILD), 1) 
     USEDLIBS += Isolate
+  endif
+
 endif
 
+
+LINK_COMPONENTS = jit nativecodegen scalaropts instrumentation ipa ipo
+
+
 include $(LEVEL)/Makefile.common

Modified: vmkit/trunk/tools/vmkit/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Makefile?rev=81119&r1=81118&r2=81119&view=diff

==============================================================================
--- vmkit/trunk/tools/vmkit/Makefile (original)
+++ vmkit/trunk/tools/vmkit/Makefile Sun Sep  6 09:58:29 2009
@@ -12,19 +12,44 @@
 
 TOOLNAME = vmkit
 
-ifeq ($(WITH_JNJVM), 1)
-USEDLIBS += JnJVM.a Classpath.a JnjvmCompiler.a
-endif
 
-ifeq ($(ISOLATE_SHARING_BUILD), 1) 
+ifeq ($(WITH_LLVM_GCC), 1)
+
+  ifeq ($(WITH_JNJVM), 1)
+    USEDMODULES += JnJVM.bc Classpath.bc JnjvmCompiler.bc
+  endif
+
+  ifeq ($(ISOLATE_SHARING_BUILD), 1) 
+    USEDMODULES += Isolate.bc
+  endif
+
+  ifeq ($(WITH_N3_PNETLIB), 1)
+    USEDMODULES += N3.bc PNetLib.bc
+  endif
+
+  USEDMODULES += Allocator.bc CommonThread.bc Mvm.bc MvmCompiler.bc $(GCLIB).bc
+
+  BUILT_SOURCES = vmkit.s
+  SOURCES = vmkit.s $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp))
+
+
+else
+
+  ifeq ($(WITH_JNJVM), 1)
+    USEDLIBS += JnJVM.a Classpath.a JnjvmCompiler.a
+  endif
+
+  ifeq ($(ISOLATE_SHARING_BUILD), 1) 
     USEDLIBS += Isolate.a
-endif
+  endif
 
-ifeq ($(WITH_N3_PNETLIB), 1)
-  USEDLIBS += N3.a PNetLib.a
-endif
+  ifeq ($(WITH_N3_PNETLIB), 1)
+    USEDLIBS += N3.a PNetLib.a
+  endif
+
+  USEDLIBS += Allocator.a CommonThread.a Mvm.a MvmCompiler.a $(GCLIB).a
 
-USEDLIBS += Allocator.a CommonThread.a Mvm.a MvmCompiler.a $(GCLIB).a
+endif
 
 LINK_COMPONENTS = jit nativecodegen scalaropts instrumentation ipa ipo
 





More information about the vmkit-commits mailing list