Say hi to VMKit: JVM/LLVM, CLI/LLVM

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Say hi to VMKit: JVM/LLVM, CLI/LLVM

varth
Hi everyone,

I've just checked in a JVM and a CLI for LLVM (called JnJVM and N3).
Both are placed in the vmkit svn directory.
You can find the source code here:

svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit

Its licensed under the U of I Open Source License, so now that's in svn,
you can change whatever you want, as long as HelloWorld.java and
HelloWorld.cs work ;-)

I haven't tested the build process on many machines, mostly on gentoo
linux/x86 and linux/ppc. There are probably some dev libs that VMKit
requires and the configure script does not check. A good thing would be
to make the build process cleaner.

The README file on root explains the few steps to run the virtual machines.

I should probably say here that you currently need to patch llvm to get
things working :( Let's hope this won't be true too long.

Happy hacking!

Nicolas

PS: I won't be able to check my emails until Wednesday, so really, happy
hacking! ;-)
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Owen Anderson-2
Here's a patch that gets Mvm compiling on Darwin.

--Owen





On Mar 21, 2008, at 4:52 PM, Nicolas Geoffray wrote:

> Hi everyone,
>
> I've just checked in a JVM and a CLI for LLVM (called JnJVM and N3).
> Both are placed in the vmkit svn directory.
> You can find the source code here:
>
> svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit
>
> Its licensed under the U of I Open Source License, so now that's in  
> svn,
> you can change whatever you want, as long as HelloWorld.java and
> HelloWorld.cs work ;-)
>
> I haven't tested the build process on many machines, mostly on gentoo
> linux/x86 and linux/ppc. There are probably some dev libs that VMKit
> requires and the configure script does not check. A good thing would  
> be
> to make the build process cleaner.
>
> The README file on root explains the few steps to run the virtual  
> machines.
>
> I should probably say here that you currently need to patch llvm to  
> get
> things working :( Let's hope this won't be true too long.
>
> Happy hacking!
>
> Nicolas
>
> PS: I won't be able to check my emails until Wednesday, so really,  
> happy
> hacking! ;-)
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

mvm.patch.gz (916 bytes) Download Attachment
smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Török Edwin
In reply to this post by varth
Nicolas Geoffray wrote:
> Hi everyone,
>
> I've just checked in a JVM and a CLI for LLVM (called JnJVM and N3).
> Both are placed in the vmkit svn directory.
> You can find the source code here:
>  

Very nice!

> svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit
>
> Its licensed under the U of I Open Source License, so now that's in svn,
> you can change whatever you want, as long as HelloWorld.java and
> HelloWorld.cs work ;-)
>
> I haven't tested the build process on many machines, mostly on gentoo
> linux/x86 and linux/ppc. There are probably some dev libs that VMKit
> requires and the configure script does not check. A good thing would be
> to make the build process cleaner.
The code is not 64-bit clean, attached is a patch to get it compile on
x86-64 Linux.
I also fixed some g++-4.2 warnings (const issues, symbol visibility).

The libJnJVM directory builds, but it won't run, I get endless messages
like this:
; ****************************************************** ;
;         SIGSEGV occured during a collection            ;
;   I'm trying to let the allocator in a coherent stat   ;
; but the collector is DEAD and will never collect again ;
; ****************************************************** ;

Probably there are more 64-bit issues to solve. Unfortunately I don't
have time to look into this deeper now.

Best regards,
--Edwin

Index: include/mvm/Method.h
===================================================================
--- include/mvm/Method.h (revision 48684)
+++ include/mvm/Method.h (working copy)
@@ -47,11 +47,11 @@
 
   inline Method *method(Method *m, size_t nbb) {
     return
-      (Method *)gcset((gc **)((unsigned int)this + nbb + 4 - sizeof(Method *)), m);
+      (Method *)gcset((gc **)((size_t)this + nbb + 4 - sizeof(Method *)), m);
   }
 
   inline Method *method(size_t nbb) {
-    return ((Method **)((unsigned int)this + nbb + 4 - sizeof(Method *)))[0];
+    return ((Method **)((size_t)this + nbb + 4 - sizeof(Method *)))[0];
   }
     
   inline Method *method(Method *m) { return method(m, objectSize()); }
@@ -68,12 +68,12 @@
 
   inline void *frameRegister(void *m, size_t nbb) {
     return
-      (void *)gcset((gc **)((unsigned int)this + nbb + 4 - sizeof(void *)),
+      (void *)gcset((gc **)((size_t)this + nbb + 4 - sizeof(void *)),
                             (Object*)m);
   }
 
   inline void *frameRegister(size_t nbb) {
-    return ((void **)((unsigned int)this + nbb + 4 - sizeof(void *)))[0];
+    return ((void **)((size_t)this + nbb + 4 - sizeof(void *)))[0];
   }
     
   inline void *frameRegister(void *m) { return frameRegister(m, objectSize()); }
Index: include/mvm/Threads/Key.h
===================================================================
--- include/mvm/Threads/Key.h (revision 48684)
+++ include/mvm/Threads/Key.h (working copy)
@@ -20,7 +20,7 @@
 
 class ThreadKey {
 public:
-  void * val;
+  pthread_key_t val;
   
   ThreadKey(void (*_destr)(void *));
   ThreadKey();
Index: include/mvm/Object.h
===================================================================
--- include/mvm/Object.h (revision 48684)
+++ include/mvm/Object.h (working copy)
@@ -56,7 +56,7 @@
   virtual void    destroyer(size_t) {}
   virtual void    tracer(size_t) {}
   virtual void    print(PrintBuffer *buf) const;
-  virtual int     hashCode(){ return (int)this;}
+  virtual ssize_t     hashCode(){ return (ssize_t)this;}
 
 protected:
   static Object **rootTable;
Index: include/mvm/PrintBuffer.h
===================================================================
--- include/mvm/PrintBuffer.h (revision 48684)
+++ include/mvm/PrintBuffer.h (working copy)
@@ -101,7 +101,7 @@
   
   inline PrintBuffer *writeS8(sint64 v) {
     char buf[32];
-    sprintf(buf, "%lld", v);
+    sprintf(buf, "%jd", v);
     return write(buf);
   }
   
@@ -113,7 +113,7 @@
 
   inline PrintBuffer *writePtr(void *p) {
     char buf[32];
-    sprintf(buf, "%08x", (int)p);
+    sprintf(buf, "%p", p);
     return write(buf);
   }
 
Index: vmkit-llvm-svn.patch
===================================================================
--- vmkit-llvm-svn.patch (revision 48684)
+++ vmkit-llvm-svn.patch (working copy)
@@ -87,8 +87,8 @@
 +    initConstantPool(F.getConstantPool());
 +    initJumpTableInfo(F.getJumpTableInfo());
 +  
-+    ConstantPoolBase  = (void*)(((unsigned) ConstantPoolBase) + CurBufferPtr);
-+    JumpTableBase     = (void*)(((unsigned) JumpTableBase) + CurBufferPtr);
++    ConstantPoolBase  = (void*)(((size_t) ConstantPoolBase) + CurBufferPtr);
++    JumpTableBase     = (void*)(((size_t) JumpTableBase) + CurBufferPtr);
 +  }
 +
 +  virtual bool finishFunction(MachineFunction &F) {
Index: lib/Mvm/Allocator/gcmapper.cc
===================================================================
--- lib/Mvm/Allocator/gcmapper.cc (revision 48684)
+++ lib/Mvm/Allocator/gcmapper.cc (working copy)
@@ -82,7 +82,7 @@
  void *res = ::mremap(_mapped_area, _mapped_nbb, n, 0);
 #endif
   
- if((int)res == -1)
+ if((ssize_t)res == -1)
  return -1;
  _mapped_area = res;
  _mapped_nbb = n;
@@ -97,13 +97,13 @@
  /* pbm : on n'a vraiment plus rien :) */
  area = (GCMappedArea *)::do_mmap(PAGE_SIZE);
  area->initialise(area, PAGE_SIZE);
- area_stack->fill((unsigned int)(area + 1), PAGE_SIZE - sizeof(GCMappedArea));
+ area_stack->fill((size_t)(area + 1), PAGE_SIZE - sizeof(GCMappedArea));
  area->append(&base_area);
  area = (GCMappedArea *)area_stack->alloc();
  }
  area->mmap(PAGE_SIZE);
  area->append(&base_area);
- s->fill((unsigned int)area->area(), area->nbb());
+ s->fill((size_t)area->area(), area->nbb());
 
  return s->alloc();
 }
Index: lib/Mvm/Allocator/gcmapper.h
===================================================================
--- lib/Mvm/Allocator/gcmapper.h (revision 48684)
+++ lib/Mvm/Allocator/gcmapper.h (working copy)
@@ -64,7 +64,7 @@
 };
 
 class GCMinAllocStack {
- unsigned int current;
+ size_t current;
  unsigned int max;
  unsigned int *free_list;
  unsigned short nbb;
@@ -83,9 +83,9 @@
  }
 
  inline void *alloc() {
- register unsigned int res;
+ register size_t res;
  if(free_list) {
- res = (unsigned int)free_list;
+ res = (size_t)free_list;
  free_list = *((unsigned int **)res);
  } else {
  res = current;
@@ -94,7 +94,7 @@
  return 0;
  }
 
- return (void *)res;
+ return (void*)res;
  }
 };
 
Index: lib/Mvm/Allocator/gcchunk.cc
===================================================================
--- lib/Mvm/Allocator/gcchunk.cc (revision 48684)
+++ lib/Mvm/Allocator/gcchunk.cc (working copy)
@@ -38,8 +38,8 @@
 }
 
 void GCHash::hash_unprotected(GCPage *desc, void *base, unsigned int nbb, unsigned int nbb_map) {
- unsigned int entry = GCHashConst::set_entry(base);
- unsigned int cur_sz = GCHashConst::set_entry_2_ptr(entry + 1) - (unsigned int)base; /* taille restante */
+ size_t entry = GCHashConst::set_entry(base);
+ size_t cur_sz = GCHashConst::set_entry_2_ptr(entry + 1) - (size_t)base; /* taille restante */
  cur_sz = ((cur_sz < nbb) ? cur_sz : nbb); /* on prends le min avec nbb   */
 
  // printf("Hash %p (%p %p %d) in entry %d with %d/%d\n", desc, desc->area(), base, desc->nbb(), entry, cur_sz, nbb_map);
@@ -54,7 +54,7 @@
  sets[entry] = &empty;
  }
  entry++;
- base = (void *)((unsigned int)base + cur_sz);
+ base = (void *)((size_t)base + cur_sz);
  nbb -= cur_sz;
  nbb_map = (nbb_map < cur_sz) ? 0 : nbb_map - cur_sz;
  cur_sz = (nbb < GCHashConst::set_nbb) ? nbb : GCHashConst::set_nbb;
Index: lib/Mvm/Allocator/gcalloc.cc
===================================================================
--- lib/Mvm/Allocator/gcalloc.cc (revision 48684)
+++ lib/Mvm/Allocator/gcalloc.cc (working copy)
@@ -17,24 +17,24 @@
  headers = (GCChunkNode *)(new GCMappedArea(&headers_area, rounded))->area();
  else {
  headers = used_headers;
- used_headers = (GCChunkNode *)((unsigned int)used_headers + headers_nbb);
+ used_headers = (GCChunkNode *)((size_t)used_headers + headers_nbb);
  if(used_headers >= max_headers) {
  headers = (GCChunkNode *)(new GCMappedArea(&headers_area, used_headers_nbb))->area();
- used_headers = (GCChunkNode *)((unsigned int)headers + headers_nbb);
- max_headers = (GCChunkNode *)((unsigned int)headers + used_headers_nbb);
+ used_headers = (GCChunkNode *)((size_t)headers + headers_nbb);
+ max_headers = (GCChunkNode *)((size_t)headers + used_headers_nbb);
  }
  }
 
  register GCChunkNode *cur = headers;
- register GCChunkNode *lim = (GCChunkNode *)((unsigned int)headers + headers_nbb);
+ register GCChunkNode *lim = (GCChunkNode *)((size_t)headers + headers_nbb);
  register GCChunkNode *max = lim - (1 + filled);
  for(;cur<max; cur++) {
  cur->initialise(cur+1, base);
- base = (void *)((unsigned int)base + depl);
+ base = (void *)((size_t)base + depl);
  }
  for(;cur<lim; cur++) {
  cur->initialise(0, base);
- base = (void *)((unsigned int)base + depl);
+ base = (void *)((size_t)base + depl);
  }
  return headers;
 }
Index: lib/Mvm/Allocator/gcchunk.h
===================================================================
--- lib/Mvm/Allocator/gcchunk.h (revision 48684)
+++ lib/Mvm/Allocator/gcchunk.h (working copy)
@@ -124,17 +124,17 @@
  inline void headers(GCChunkNode *h)         { _headers = h;; }
 
  inline GCChunkNode *o2node(void *ptr, signed int mask) {
- register unsigned int entry = ((unsigned int)ptr - (unsigned int)area())/_chunk_nbb;
+ register size_t entry = ((size_t)ptr - (size_t)area())/_chunk_nbb;
  register GCChunkNode *res = _headers + entry;
- return ((unsigned int)ptr - (unsigned int)res->chunk() < res->nbb())
+ return ((size_t)ptr - (size_t)res->chunk() < res->nbb())
  && (res->isCollectable() == mask)
  ? res : 0;
  }
 
  inline gc_header *o2header(void *ptr, signed int mask) {
- register unsigned int entry = ((unsigned int)ptr - (unsigned int)area())/_chunk_nbb;
+ register size_t entry = ((size_t)ptr - (size_t)area())/_chunk_nbb;
  register GCChunkNode *res = _headers + entry;
- return ((unsigned int)ptr - (unsigned int)res->chunk() < res->nbb())
+ return ((size_t)ptr - (size_t)res->chunk() < res->nbb())
  && (res->isCollectable() == mask)
  ? res->chunk() : 0;
  }
@@ -159,9 +159,9 @@
  static const unsigned int nb_set_per_hash = 1 << hash_bits;
  static const unsigned int set_nbb = 1 << (set_bits + desc_bits);
 
- static unsigned int desc_entry(void * ptr) { return ((unsigned int)ptr >> desc_bits) & (( 1 << set_bits) - 1); }
- static unsigned int set_entry(void *ptr) { return (unsigned int)ptr >> (set_bits + desc_bits); }
- static unsigned int set_entry_2_ptr(unsigned int entry) { return entry << (set_bits + desc_bits); }
+ static size_t desc_entry(void * ptr) { return ((size_t)ptr >> desc_bits) & (( 1 << set_bits) - 1); }
+ static size_t set_entry(void *ptr) { return (size_t)ptr >> (set_bits + desc_bits); }
+ static size_t set_entry_2_ptr(size_t entry) { return entry << (set_bits + desc_bits); }
 };
 
 class GCHashSet {
Index: lib/Mvm/Allocator/gcalloc.h
===================================================================
--- lib/Mvm/Allocator/gcalloc.h (revision 48684)
+++ lib/Mvm/Allocator/gcalloc.h (working copy)
@@ -156,9 +156,9 @@
  return new_header = stupid_realloc_chunk(old_header, new_nbb);
  else {
  if(depl > 0)
- GCHash::hash_unprotected(page, (void *)((unsigned int)page->area() + old_nbb), depl, depl);
+ GCHash::hash_unprotected(page, (void *)((size_t)page->area() + old_nbb), depl, depl);
  else
- GCHash::hash_unprotected(page, (void *)((unsigned int)page->area() + rounded), -depl, 0);
+ GCHash::hash_unprotected(page, (void *)((size_t)page->area() + rounded), -depl, 0);
  }
  page->chunk_nbb(rounded);
  old_header->nbb(new_nbb);
Index: lib/Mvm/EscapeAnalysis.cpp
===================================================================
--- lib/Mvm/EscapeAnalysis.cpp (revision 48684)
+++ lib/Mvm/EscapeAnalysis.cpp (working copy)
@@ -13,7 +13,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
-
+#include <map>
 using namespace llvm;
 
 namespace {
@@ -35,7 +35,6 @@
   };
   char EscapeAnalysis::ID = 0;
   RegisterPass<EscapeAnalysis> X("EscapeAnalysis", "Escape Analysis Pass");
-}
 
 bool EscapeAnalysis::runOnFunction(Function& F) {
   bool Changed = false;
@@ -59,13 +58,8 @@
   return Changed;
 }
 
-namespace mvm {
 
-EscapeAnalysis* createEscapeAnalysisPass(Function* alloc, Function* init) {
-  return new EscapeAnalysis(alloc, init);
-}
 
-}
 
 static bool escapes(Instruction* Ins, std::map<AllocaInst*, bool>& visited) {
   for (Value::use_iterator I = Ins->use_begin(), E = Ins->use_end();
@@ -140,3 +134,11 @@
   }
   return false;
 }
+}
+
+namespace mvm {
+FunctionPass* createEscapeAnalysisPass(llvm::Function* alloc, llvm::Function* init) {
+
+  return new EscapeAnalysis(alloc, init);
+}
+}
Index: lib/Mvm/GCMmap2/gcinit.cc
===================================================================
--- lib/Mvm/GCMmap2/gcinit.cc (revision 48684)
+++ lib/Mvm/GCMmap2/gcinit.cc (working copy)
@@ -86,6 +86,8 @@
 #   endif
 #  elif defined(__i386__)
  " movl %%ebp, %0 "
+# elif defined(__amd64__)
+ "               movq    %%rbp, %0       "
 #  else
 #   error:
 #   error: I do not know how to read the frame pointer on this machine
Index: lib/Mvm/GCMmap2/gc.cc
===================================================================
--- lib/Mvm/GCMmap2/gc.cc (revision 48684)
+++ lib/Mvm/GCMmap2/gc.cc (working copy)
@@ -87,8 +87,8 @@
 }
 
 int gc::byteOffset(void *obj) {
- int beg = (int)GCCollector::begOf(obj);
-  int off = (int)obj;
+ int beg = (ssize_t)GCCollector::begOf(obj);
+  ssize_t off = (ssize_t)obj;
   return (off-beg);
 }
 
Index: lib/Mvm/Object.cc
===================================================================
--- lib/Mvm/Object.cc (revision 48684)
+++ lib/Mvm/Object.cc (working copy)
@@ -132,12 +132,12 @@
  write("<In Object [");
  beg->print(this);
  write("] -- offset ");
- writeS4((int)obj - (int)beg);
+ writeS4((ssize_t)obj - (ssize_t)beg);
  write(">");
  }
  } else {
  write("<DirectValue: ");
- writeS4((int)obj);
+ writeS4((ssize_t)obj);
  write(">");
  }
  return this;
Index: lib/JnJVM/Classpath/ClasspathVMSystem.cpp
===================================================================
--- lib/JnJVM/Classpath/ClasspathVMSystem.cpp (revision 48684)
+++ lib/JnJVM/Classpath/ClasspathVMSystem.cpp (working copy)
@@ -103,7 +103,7 @@
                                                                 jclass clazz,
 #endif
                                                                 jobject obj) {
-  return (jint)obj;
+  return (jint)(ssize_t)obj;
 }
 
 }
Index: lib/JnJVM/Classpath/Classpath.h.in
===================================================================
--- lib/JnJVM/Classpath/Classpath.h.in (revision 48684)
+++ lib/JnJVM/Classpath/Classpath.h.in (working copy)
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 
-char* GNUClasspathLibs  =  "@classpathlibs@";
-char* GNUClasspathGlibj =  "@classpathglibj@";
-char* GNUClasspathVersion = "@gnuclasspathversion@";
+const char* GNUClasspathLibs  =  "@classpathlibs@";
+const char* GNUClasspathGlibj =  "@classpathglibj@";
+const char* GNUClasspathVersion = "@gnuclasspathversion@";
 
Index: lib/JnJVM/Classpath/ClasspathVMThrowable.cpp
===================================================================
--- lib/JnJVM/Classpath/ClasspathVMThrowable.cpp (revision 48684)
+++ lib/JnJVM/Classpath/ClasspathVMThrowable.cpp (working copy)
@@ -72,7 +72,7 @@
   bool native = isNative(meth->access);
 
   JavaObject* res = (*Classpath::newStackTraceElement)();
-  Classpath::initStackTraceElement->invokeIntSpecial(res, sourceName, (int)ip, className, methodName, native);
+  Classpath::initStackTraceElement->invokeIntSpecial(res, sourceName, (ssize_t)ip, className, methodName, native);
   return res;
 }
 
Index: lib/JnJVM/VMCore/Zip.cpp
===================================================================
--- lib/JnJVM/VMCore/Zip.cpp (revision 48684)
+++ lib/JnJVM/VMCore/Zip.cpp (working copy)
@@ -37,7 +37,7 @@
   return 0;
 }
 
-ZipFile* ZipArchive::getFile(char* filename) {
+ZipFile* ZipArchive::getFile(const char* filename) {
   ZipFile* res = filetable->lookup(filename);
   return res;
 }
Index: lib/JnJVM/VMCore/JavaTypes.cpp
===================================================================
--- lib/JnJVM/VMCore/JavaTypes.cpp (revision 48684)
+++ lib/JnJVM/VMCore/JavaTypes.cpp (working copy)
@@ -199,14 +199,14 @@
       pos++;
     } else {
       AssessorDesc * typeIntern = dTab;
-      while (name->at(++pos) == I_TAB);
+      while (name->at(++pos) == I_TAB) {}
       analyseIntern(name, pos, 1, typeIntern, pos);
     }
     ass = dTab;
     ret = pos;
   } else if (cur == I_REF) {
     if (meth != 2) {
-      while (name->at(++pos) != I_END_REF);
+      while (name->at(++pos) != I_END_REF) {}
     }
     ass = dRef;
     ret = pos + 1;
Index: lib/JnJVM/VMCore/Jni.cpp
===================================================================
--- lib/JnJVM/VMCore/Jni.cpp (revision 48684)
+++ lib/JnJVM/VMCore/Jni.cpp (working copy)
@@ -25,8 +25,8 @@
 
 using namespace jnjvm;
 
-extern "C" const struct JNIInvokeInterface JNI_JavaVMTable;
-extern "C" struct JNINativeInterface JNI_JNIEnvTable;
+extern "C" const struct JNIInvokeInterface_ JNI_JavaVMTable;
+extern "C" struct JNINativeInterface_ JNI_JNIEnvTable;
 
 #define BEGIN_EXCEPTION \
   JavaObject* excp = 0; \
@@ -248,7 +248,7 @@
 
 
 jobject NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
-                   jvalue *args) {
+                   const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -337,7 +337,7 @@
 
 
 jobject CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                          jvalue * args) {
+                          const jvalue * args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -368,7 +368,7 @@
 
 
 jboolean CallBooleanMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                            jvalue * args) {
+                            const jvalue * args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -387,7 +387,7 @@
 
 
 jbyte CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                      jvalue *args) {
+                      const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -407,7 +407,7 @@
 
 
 jchar CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                      jvalue *args) {
+                      const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -427,7 +427,7 @@
 
 
 jshort CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                        jvalue *args) {
+                        const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -459,7 +459,7 @@
 
 
 jint CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                    jvalue *args) {
+                    const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -480,7 +480,7 @@
 
 
 jlong CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                      jvalue *args) {
+                      const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -512,7 +512,7 @@
 
 
 jfloat CallFloatMethodA(JNIEnv *env, jobject _obj, jmethodID methodID,
-                        jvalue *args) {
+                        const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -552,7 +552,7 @@
 
 
 jdouble CallDoubleMethodA(JNIEnv *env, jobject _obj, jmethodID methodID,
-                          jvalue *args) {
+                          const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -588,7 +588,7 @@
 
 
 void CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                     jvalue *args) {
+                     const jvalue *args) {
   assert(0 && "implement me");
 }
 
@@ -609,7 +609,7 @@
 
 
 jobject CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                    jmethodID methodID, jvalue *args) {
+                                    jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -631,7 +631,7 @@
 
 
 jboolean CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                      jmethodID methodID, jvalue *args) {
+                                      jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -652,7 +652,7 @@
 
 
 jbyte CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                jmethodID methodID, jvalue *args) {
+                                jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -674,7 +674,7 @@
 
 
 jchar CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                jmethodID methodID, jvalue *args) {
+                                jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -696,7 +696,7 @@
 
 
 jshort CallNonvirtualShortMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                  jmethodID methodID, jvalue *args) {
+                                  jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -718,7 +718,7 @@
 
 
 jint CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                              jmethodID methodID, jvalue *args) {
+                              jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -740,7 +740,7 @@
 
 
 jlong CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                jmethodID methodID, jvalue *args) {
+                                jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -762,7 +762,7 @@
 
 
 jfloat CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                  jmethodID methodID, jvalue *args) {
+                                  jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -784,7 +784,7 @@
 
 
 jdouble CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                    jmethodID methodID, jvalue *args) {
+                                    jmethodID methodID, const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -814,7 +814,7 @@
 
 
 void CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                               jmethodID methodID, jvalue * args) {
+                               jmethodID methodID, const jvalue * args) {
   assert(0 && "implement me");
 }
 
@@ -1096,7 +1096,7 @@
 
 
 jobject CallStaticObjectMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                                jvalue *args) {
+                                const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1127,7 +1127,7 @@
 
 
 jboolean CallStaticBooleanMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                                  jvalue *args) {
+                                  const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1147,7 +1147,7 @@
 
 
 jbyte CallStaticByteMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                            jvalue *args) {
+                            const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1167,7 +1167,7 @@
 
 
 jchar CallStaticCharMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                            jvalue *args) {
+                            const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1188,7 +1188,7 @@
 
 
 jshort CallStaticShortMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                              jvalue *args) {
+                              const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1208,7 +1208,7 @@
 
 
 jint CallStaticIntMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                          jvalue *args) {
+                          const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1228,7 +1228,7 @@
 
 
 jlong CallStaticLongMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                            jvalue *args) {
+                            const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1250,7 +1250,7 @@
 
 
 jfloat CallStaticFloatMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                              jvalue *args) {
+                              const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1271,7 +1271,7 @@
 
 
 jdouble CallStaticDoubleMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                                jvalue *args) {
+                                const jvalue *args) {
   assert(0 && "implement me");
   return 0;
 }
@@ -1304,7 +1304,7 @@
 
 
 void CallStaticVoidMethodA(JNIEnv *env, jclass clazz, jmethodID methodID,
-                           jvalue * args) {
+                           const jvalue * args) {
   assert(0 && "implement me");
 }
 
@@ -1632,7 +1632,7 @@
   ClassArray* array = vm->constructArray(arrayName, loader);
   ArrayObject* res = ArrayObject::acons(length, array);
   if (initialElement) {
-    memset(res->elements, (int)initialElement,
+    memset(res->elements, (ssize_t)initialElement,
                length * sizeof(JavaObject*));
   }
   return (jobjectArray)res;
@@ -1951,49 +1951,49 @@
 
 
 void SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array, jsize start,
-   jsize len, jboolean *buf) {
+   jsize len, const jboolean *buf) {
   assert(0 && "implement me");
 }
 
 
 void SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start, jsize len,
- jbyte *buf) {
+ const jbyte *buf) {
   assert(0 && "implement me");
 }
 
 
 void SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start, jsize len,
- jchar *buf) {
+ const jchar *buf) {
   assert(0 && "implement me");
 }
 
 
 void SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
- jsize len, jshort *buf) {
+ jsize len, const jshort *buf) {
   assert(0 && "implement me");
 }
 
 
 void SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start, jsize len,
-       jint *buf) {
+       const jint *buf) {
   assert(0 && "implement me");
 }
 
 
 void SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len,
- jlong *buf) {
+ const jlong *buf) {
   assert(0 && "implement me");
 }
 
 
 void SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
- jsize len, jfloat *buf) {
+ jsize len, const jfloat *buf) {
   assert(0 && "implement me");
 }
 
 
 void SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
-  jsize len, jdouble *buf) {
+  jsize len, const jdouble *buf) {
   assert(0 && "implement me");
 }
 
@@ -2194,7 +2194,7 @@
 }
 
 
-const struct JNIInvokeInterface JNI_JavaVMTable = {
+const struct JNIInvokeInterface_ JNI_JavaVMTable = {
  NULL,
  NULL,
  NULL,
@@ -2207,7 +2207,7 @@
 };
 
 
-struct JNINativeInterface JNI_JNIEnvTable = {
+struct JNINativeInterface_ JNI_JNIEnvTable = {
  NULL,
  NULL,
  NULL,
Index: lib/JnJVM/VMCore/JavaBacktrace.cpp
===================================================================
--- lib/JnJVM/VMCore/JavaBacktrace.cpp (revision 48684)
+++ lib/JnJVM/VMCore/JavaBacktrace.cpp (working copy)
@@ -125,15 +125,15 @@
         mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1);
       if (glob) {
         if (llvm::isa<llvm::Function>(glob)) {
-          printf("; 0x%08x in %s\n", (uint32) ip,
+          printf("; 0x%p in %s\n",  ip,
                  ((llvm::Function*)glob)->getNameStr().c_str());
         } else JavaThread::get()->isolate->unknownError("in global variable?");
-      } else printf("; 0x%08x in stub\n", (uint32) ip);
+      } else printf("; 0x%p in stub\n",  ip);
     } else {
       Dl_info info;
       int res = dladdr(begIp, &info);
       if (res != 0) {
-        printf("; 0x%08x in %s\n", (uint32) ip, info.dli_fname);
+        printf("; 0x%p in %s\n", ip, info.dli_fname);
       }
     }
     fp = debug_frame_caller_fp(fp);
@@ -156,18 +156,18 @@
           mvm::Method* m = c->method();
           JavaMethod* meth = (JavaMethod*)m->definition();
           if (meth)
-            printf("; 0x%08x in %s\n", (uint32) ips[n - 1], meth->printString());
+            printf("; 0x%p in %s\n",  ips[n - 1], meth->printString());
           else
-            printf("; 0x%08x in %s\n", (uint32) ips[n - 1], ((llvm::Function*)glob)->getNameStr().c_str());
+            printf("; 0x%p in %s\n",  ips[n - 1], ((llvm::Function*)glob)->getNameStr().c_str());
         } else JavaThread::get()->isolate->unknownError("in global variable?");
-      } else printf("; 0x%08x in stub\n", (uint32) ips[n - 1]);
+      } else printf("; 0x%p in stub\n", ips[n - 1]);
     } else {
       Dl_info info;
       int res = dladdr(begIp, &info);
       if (res != 0) {
-        printf("; 0x%08x in %s\n", (uint32) ips[n - 1], info.dli_fname);
+        printf("; 0x%p in %s\n",  ips[n - 1], info.dli_fname);
       } else {
-        printf("; 0x%08x in Unknown\n", (uint32) ips[n - 1]);
+        printf("; 0x%p in Unknown\n", ips[n - 1]);
       }
     }
   }
Index: lib/JnJVM/VMCore/LowerArrayLength.cpp
===================================================================
--- lib/JnJVM/VMCore/LowerArrayLength.cpp (revision 48684)
+++ lib/JnJVM/VMCore/LowerArrayLength.cpp (working copy)
@@ -21,7 +21,7 @@
 
 using namespace llvm;
 
-namespace {
+namespace mvm {
 
   class VISIBILITY_HIDDEN LowerArrayLength : public FunctionPass {
   public:
@@ -33,7 +33,6 @@
   };
   char LowerArrayLength::ID = 0;
   RegisterPass<LowerArrayLength> X("LowerArrayLength", "Lower Array length");
-}
 
 bool LowerArrayLength::runOnFunction(Function& F) {
   bool Changed = false;
@@ -63,10 +62,8 @@
   return Changed;
 }
 
-namespace mvm {
 
-LowerArrayLength* createLowerArrayLengthPass() {
+FunctionPass* createLowerArrayLengthPass() {
   return new LowerArrayLength();
 }
-
 }
Index: lib/JnJVM/VMCore/JavaIsolate.cpp
===================================================================
--- lib/JnJVM/VMCore/JavaIsolate.cpp (revision 48684)
+++ lib/JnJVM/VMCore/JavaIsolate.cpp (working copy)
@@ -63,14 +63,14 @@
   assert(0 && "implement me");
 }
 
-extern "C" int strnstr(char *haystack, char *needle) {
+extern "C" int strnstr(const char *haystack, const char *needle) {
   char * res = strstr(haystack, needle);
-  if (res) return (int)res - (int)haystack;
+  if (res) return res - haystack;
   else return -1;
 }
 
 
-static char* findInformation(ArrayUInt8* manifest, char* entry, uint32 len) {
+static char* findInformation(ArrayUInt8* manifest, const char* entry, uint32 len) {
   uint8* ptr = manifest->elements;
   sint32 index = strnstr((char*)ptr, entry);
   if (index != -1) {
Index: lib/JnJVM/VMCore/LockedMap.h
===================================================================
--- lib/JnJVM/VMCore/LockedMap.h (revision 48684)
+++ lib/JnJVM/VMCore/LockedMap.h (working copy)
@@ -30,8 +30,8 @@
 
 class JavaObject;
 class Jnjvm;
-class llvm::Function;
-class llvm::GlobalVariable;
+//class llvm::Function;
+//class llvm::GlobalVariable;
 
 template<class Key, class Container, class Compare>
 class LockedMap : public mvm::Object {
Index: lib/JnJVM/VMCore/Zip.h
===================================================================
--- lib/JnJVM/VMCore/Zip.h (revision 48684)
+++ lib/JnJVM/VMCore/Zip.h (working copy)
@@ -59,7 +59,7 @@
 
   static ZipArchive* hashedArchive(char* archname);
   static ZipArchive* singleArchive(char* archname);
-  ZipFile* getFile(char* filename);
+  ZipFile* getFile(const char* filename);
   int readFile(ArrayUInt8* array, const ZipFile* file);
   void remove();
 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Anton Korobeynikov
In reply to this post by varth
Hello, Edwin

> Probably there are more 64-bit issues to solve. Unfortunately I don't
> have time to look into this deeper now.
At least these "4" looks pretty suspicious:

-      (void *)gcset((gc **)((unsigned int)this + nbb + 4 - sizeof(void
*)),
+      (void *)gcset((gc **)((size_t)this + nbb + 4 - sizeof(void *)),
                             (Object*)m);
--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Ramón García-5
In reply to this post by varth
Thanks, I am going to download now.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Bill Wendling
In reply to this post by Török Edwin
On Mar 22, 2008, at 3:39 AM, Török Edwin wrote:

>> I haven't tested the build process on many machines, mostly on gentoo
>> linux/x86 and linux/ppc. There are probably some dev libs that VMKit
>> requires and the configure script does not check. A good thing  
>> would be
>> to make the build process cleaner.
>
> The code is not 64-bit clean, attached is a patch to get it compile on
> x86-64 Linux.
> I also fixed some g++-4.2 warnings (const issues, symbol visibility).
>
> The libJnJVM directory builds, but it won't run, I get endless  
> messages
> like this:
> ; ****************************************************** ;
> ;         SIGSEGV occured during a collection            ;
> ;   I'm trying to let the allocator in a coherent stat   ;
> ; but the collector is DEAD and will never collect again ;
> ; ****************************************************** ;
>
> Probably there are more 64-bit issues to solve. Unfortunately I don't
> have time to look into this deeper now.
>
> Best regards,
> --Edwin
> Index: include/mvm/Method.h
> ===================================================================
> --- include/mvm/Method.h (revision 48684)
> +++ include/mvm/Method.h (working copy)
> @@ -47,11 +47,11 @@
>
>   inline Method *method(Method *m, size_t nbb) {
>     return
> -      (Method *)gcset((gc **)((unsigned int)this + nbb + 4 -  
> sizeof(Method *)), m);
> +      (Method *)gcset((gc **)((size_t)this + nbb + 4 -  
> sizeof(Method *)), m);

Instead of "size_t" and "ssize_t", it be better to use "uintptr_t" and  
"intptr_t" in all cases, since they were made for these situations.

-bw


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Török Edwin
In reply to this post by Anton Korobeynikov
Anton Korobeynikov wrote:
> Hello, Edwin
>  
Hi Anton,

>> Probably there are more 64-bit issues to solve. Unfortunately I don't
>> have time to look into this deeper now.
>>    
> At least these "4" looks pretty suspicious:
>
> -      (void *)gcset((gc **)((unsigned int)this + nbb + 4 - sizeof(void
> *)),
> +      (void *)gcset((gc **)((size_t)this + nbb + 4 - sizeof(void *)),
>                              (Object*)m);
>  

Good point.

I think it would be best to review the code Class by Class to locate
64-bit problems.
Having unit-tests for this code would make this a lot easier ....

Maybe somebody participating at GSoC could take care of this ;)

Best regards,
--Edwin
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

varth
In reply to this post by Owen Anderson-2
Owen Anderson wrote:
> Here's a patch that gets Mvm compiling on Darwin.

Applied! Thanks Owen.

I've also modified configure.ac so that libopcodes is not used on darwin.

Nicolas

>
> --Owen
>
>
>
>
> On Mar 21, 2008, at 4:52 PM, Nicolas Geoffray wrote:
>
>> Hi everyone,
>>
>> I've just checked in a JVM and a CLI for LLVM (called JnJVM and N3).
>> Both are placed in the vmkit svn directory.
>> You can find the source code here:
>>
>> svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit
>>
>> Its licensed under the U of I Open Source License, so now that's in svn,
>> you can change whatever you want, as long as HelloWorld.java and
>> HelloWorld.cs work ;-)
>>
>> I haven't tested the build process on many machines, mostly on gentoo
>> linux/x86 and linux/ppc. There are probably some dev libs that VMKit
>> requires and the configure script does not check. A good thing would be
>> to make the build process cleaner.
>>
>> The README file on root explains the few steps to run the virtual
>> machines.
>>
>> I should probably say here that you currently need to patch llvm to get
>> things working :( Let's hope this won't be true too long.
>>
>> Happy hacking!
>>
>> Nicolas
>>
>> PS: I won't be able to check my emails until Wednesday, so really, happy
>> hacking! ;-)
>> _______________________________________________
>> LLVM Developers mailing list
>> [hidden email]         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>  

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

varth
In reply to this post by Török Edwin
Very nice Torok! I applied most of the patch. A few comments:

1) What is your jni.h file? I can't compile the Jni.cpp file with your
changes.
2) ISO C++ does not support %jd. x86_64 does not know about %lld?

Thanks!
Nicolas

Török Edwin wrote:

> Nicolas Geoffray wrote:
>  
>> Hi everyone,
>>
>> I've just checked in a JVM and a CLI for LLVM (called JnJVM and N3).
>> Both are placed in the vmkit svn directory.
>> You can find the source code here:
>>  
>>    
>
> Very nice!
>  
>> svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit
>>
>> Its licensed under the U of I Open Source License, so now that's in svn,
>> you can change whatever you want, as long as HelloWorld.java and
>> HelloWorld.cs work ;-)
>>
>> I haven't tested the build process on many machines, mostly on gentoo
>> linux/x86 and linux/ppc. There are probably some dev libs that VMKit
>> requires and the configure script does not check. A good thing would be
>> to make the build process cleaner.
>>    
>
> The code is not 64-bit clean, attached is a patch to get it compile on
> x86-64 Linux.
> I also fixed some g++-4.2 warnings (const issues, symbol visibility).
>
> The libJnJVM directory builds, but it won't run, I get endless messages
> like this:
> ; ****************************************************** ;
> ;         SIGSEGV occured during a collection            ;
> ;   I'm trying to let the allocator in a coherent stat   ;
> ; but the collector is DEAD and will never collect again ;
> ; ****************************************************** ;
>
> Probably there are more 64-bit issues to solve. Unfortunately I don't
> have time to look into this deeper now.
>
> Best regards,
> --Edwin
> ------------------------------------------------------------------------
>
> This body part will be downloaded on demand.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

varth
In reply to this post by Török Edwin
Török Edwin wrote:
>
> Good point.
>
> I think it would be best to review the code Class by Class to locate
> 64-bit problems.
>  

Indeed, the source code is very x86_64 unfriendly. Most of the errors should
be in the GC and the Allocator though.

> Having unit-tests for this code would make this a lot easier ....
>
> Maybe somebody participating at GSoC could take care of this ;)
>  

Yeah, porting to all LLVM supported architectures, that would be great!  
As well as a test suite.  As well as.... ;-)

Nicolas

> Best regards,
> --Edwin
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>  

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Török Edwin
In reply to this post by varth
Nicolas Geoffray wrote:
> Very nice Torok! I applied most of the patch. A few comments:
>  

Thanks!

> 1) What is your jni.h file? I can't compile the Jni.cpp file with your
> changes.
>  

Ouch, did they change 'const'-ness between gcj versions?
I was using gcj-4.2.3, and jni.h is from libgcj8-dev.

> 2) ISO C++ does not support %jd. x86_64 does not know about %lld?
>  

It does, but gcc gives a warning, if I use %lld I get a warning on
x86_64, if I %ld I get a warning on x86-32.
int64_t is long int on x86-64. However sizeof(long int) == sizeof(long
long int), so I don't know why gcc insists it is wrong.
I only found %jd which doesn't give warnings on either:

#include <stdio.h>
#include <stdint.h>
int main()
{
        int64_t x=0;
        printf("%ld",x);
        printf("%lld",x);
        printf("%jd",x);
        return 0;
}

$ gcc -Wall -O2 p.c
p.c: In function ‘main’:
p.c:7: warning: format ‘%lld’ expects type ‘long long int’, but argument
2 has type ‘int64_t’
$ gcc -Wall -O2 p.c -m32
p.c: In function ‘main’:
p.c:6: warning: format ‘%ld’ expects type ‘long int’, but argument 2 has
type ‘int64_t’

Best regards,
--Edwin
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Tom Tromey
>>>>> "Török" == Török Edwin <[hidden email]> writes:

>> 1) What is your jni.h file? I can't compile the Jni.cpp file with your
>> changes.

Török> Ouch, did they change 'const'-ness between gcj versions?
Török> I was using gcj-4.2.3, and jni.h is from libgcj8-dev.

It looks like we did change it, in Classpath, in 2007.  I assume it
was for compatibility with the JNI spec; JNI is supposed to be both
source- and binary-compatible across VMs, and we try very hard to
preserve this.

Tom

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Eric Gouriou-2
In reply to this post by Török Edwin

On Mar 26, 2008, at 12:23 PM, Török Edwin wrote:
[...]

>> 2) ISO C++ does not support %jd. x86_64 does not know about %lld?
>>
>
> It does, but gcc gives a warning, if I use %lld I get a warning on
> x86_64, if I %ld I get a warning on x86-32.
> int64_t is long int on x86-64. However sizeof(long int) == sizeof(long
> long int), so I don't know why gcc insists it is wrong.
> I only found %jd which doesn't give warnings on either:
>
> #include <stdio.h>
> #include <stdint.h>
> int main()
> {
>        int64_t x=0;
>        printf("%ld",x);
>        printf("%lld",x);
>        printf("%jd",x);
>        return 0;
> }
>
> $ gcc -Wall -O2 p.c
> p.c: In function ‘main’:
> p.c:7: warning: format ‘%lld’ expects type ‘long long int’, but  
> argument
> 2 has type ‘int64_t’
> $ gcc -Wall -O2 p.c -m32
> p.c: In function ‘main’:
> p.c:6: warning: format ‘%ld’ expects type ‘long int’, but argument 2  
> has
> type ‘int64_t’

  To print a int64_t value, use PRId64 from inttypes.h if you can.

#include <inttypes.h>

int64_t x = ...;
printf("x=%"PRId64"\n", x);

  It's ugly at first, but portable (provided inttypes.h ...).

  Eric


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Chris Lattner
On Mar 27, 2008, at 2:18 PM, Eric Gouriou wrote:

>
> On Mar 26, 2008, at 12:23 PM, Török Edwin wrote:
> [...]
>>> 2) ISO C++ does not support %jd. x86_64 does not know about %lld?
>>>
>>
>> It does, but gcc gives a warning, if I use %lld I get a warning on
>> x86_64, if I %ld I get a warning on x86-32.
>> int64_t is long int on x86-64. However sizeof(long int) ==  
>> sizeof(long
>> long int), so I don't know why gcc insists it is wrong.
>> I only found %jd which doesn't give warnings on either:

>
>  To print a int64_t value, use PRId64 from inttypes.h if you can.
>
> #include <inttypes.h>
>
> int64_t x = ...;
> printf("x=%"PRId64"\n", x);
>
>  It's ugly at first, but portable (provided inttypes.h ...).

Unfortunately, inttypes.h isn't portable either :(.

I'd suggest:

   printf("%lld", (long long)x);

which is guaranteed to work and is fine on any system where  
sizeof(int64_t) == sizeof(long long).  LLVM already makes lots of  
assumptions that this is true already, so one more won't hurt.

-Chris


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

Jon Harrop
In reply to this post by varth
On Friday 21 March 2008 21:52:32 Nicolas Geoffray wrote:
> Hi everyone,
>
> I've just checked in a JVM and a CLI for LLVM (called JnJVM and N3).
> Both are placed in the vmkit svn directory.
> You can find the source code here:
>
> svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit

This looks really exciting but I'm having trouble finding information about
this project. Is there documentation? I am particularly interested in the
GC...

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Say hi to VMKit: JVM/LLVM, CLI/LLVM

varth
Hi Jon,

Jon Harrop wrote:

> On Friday 21 March 2008 21:52:32 Nicolas Geoffray wrote:
>  
>> Hi everyone,
>>
>> I've just checked in a JVM and a CLI for LLVM (called JnJVM and N3).
>> Both are placed in the vmkit svn directory.
>> You can find the source code here:
>>
>> svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit
>>    
>
> This looks really exciting but I'm having trouble finding information about
> this project. Is there documentation? I am particularly interested in the
> GC...
>
>  

You can find an overview of the project here:
http://pagesperso-systeme.lip6.fr/Gael.Thomas/papers/spe-thomas-java-flexibility.pdf

And if you speak french, a detailed description of the GC
http://pagesperso-systeme.lip6.fr/Gael.Thomas/papers/these-gael.thomas.pdf


Note that things have changed since, and the vms are developped in C++
using LLVM (instead of Lisp using VPU)

Nicolas
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev