[vmkit-commits] [vmkit] r139025 - in /vmkit/trunk: include/j3/ include/mvm/ include/mvm/Threads/ lib/J3/Classpath/ lib/J3/Compiler/ lib/J3/VMCore/ lib/Mvm/CommonThread/ lib/Mvm/Compiler/ lib/Mvm/Runtime/ mmtk/mmtk-j3/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Fri Sep 2 12:23:22 PDT 2011


Author: geoffray
Date: Fri Sep  2 14:23:21 2011
New Revision: 139025

URL: http://llvm.org/viewvc/llvm-project?rev=139025&view=rev
Log:
Move OS related code to mvm/System.h,


Modified:
    vmkit/trunk/include/j3/LLVMInfo.h
    vmkit/trunk/include/mvm/Allocator.h
    vmkit/trunk/include/mvm/MethodInfo.h
    vmkit/trunk/include/mvm/System.h
    vmkit/trunk/include/mvm/Threads/CollectionRV.h
    vmkit/trunk/include/mvm/Threads/ObjectLocks.h
    vmkit/trunk/include/mvm/Threads/Thread.h
    vmkit/trunk/include/mvm/VirtualMachine.h
    vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc
    vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc
    vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
    vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
    vmkit/trunk/lib/J3/VMCore/JavaArray.h
    vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/J3/VMCore/JavaThread.h
    vmkit/trunk/lib/J3/VMCore/Jni.cpp
    vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/J3/VMCore/Jnjvm.h
    vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
    vmkit/trunk/lib/J3/VMCore/Precompiled.cpp
    vmkit/trunk/lib/J3/VMCore/Reader.h
    vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h
    vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
    vmkit/trunk/lib/Mvm/CommonThread/ObjectLocks.cpp
    vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp
    vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
    vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp
    vmkit/trunk/mmtk/mmtk-j3/Memory.cpp
    vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp
    vmkit/trunk/mmtk/mmtk-j3/VM.cpp

Modified: vmkit/trunk/include/j3/LLVMInfo.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMInfo.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/j3/LLVMInfo.h (original)
+++ vmkit/trunk/include/j3/LLVMInfo.h Fri Sep  2 14:23:21 2011
@@ -36,7 +36,7 @@
   uint8_t logSizeInBytesConstant;
 };
 
-class LLVMClassInfo : public mvm::JITInfo {
+class LLVMClassInfo : public mvm::PermanentObject {
   friend class JavaAOTCompiler;
   friend class JavaJITCompiler;
   friend class JavaLLVMCompiler;
@@ -75,7 +75,7 @@
   }
 };
 
-class LLVMMethodInfo : public mvm::JITInfo {
+class LLVMMethodInfo : public mvm::PermanentObject {
 private:
   /// Compiler - The compiler for this method info.
   JavaLLVMCompiler* Compiler;
@@ -110,7 +110,7 @@
 };
 
 
-class LLVMFieldInfo : public mvm::JITInfo {
+class LLVMFieldInfo : public mvm::PermanentObject {
 private:
   /// Compiler - The compiler for this field info.
   JavaLLVMCompiler* Compiler;
@@ -132,7 +132,7 @@
   }
 };
 
-class LLVMSignatureInfo : public mvm::JITInfo {
+class LLVMSignatureInfo : public mvm::PermanentObject {
 private:
   /// Compiler - The compiler for this signature info.
   JavaLLVMCompiler* Compiler;

Modified: vmkit/trunk/include/mvm/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Allocator.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Allocator.h (original)
+++ vmkit/trunk/include/mvm/Allocator.h Fri Sep  2 14:23:21 2011
@@ -10,17 +10,12 @@
 #ifndef MVM_ALLOCATOR_H
 #define MVM_ALLOCATOR_H
 
-#include <cstdlib>
-#include <cstring>
-#include <limits>
-
 #include "llvm/Support/Allocator.h"
-
 #include "mvm/Threads/Locks.h"
 
-class VirtualTable;
+#include <cstring>
 
-#define declare_gcroot(type, name) type name; llvm_gcroot(name, 0); name
+class VirtualTable;
 
 namespace mvm {
 
@@ -80,14 +75,6 @@
   }
 };
 
-/// JITInfo - This class can be derived from to hold private JIT-specific
-/// information. Objects of type are accessed/created with
-/// <Class>::getInfo and destroyed when the <Class> object is destroyed.
-struct JITInfo : public mvm::PermanentObject {
-  virtual ~JITInfo() {}
-  virtual void clear() {}
-};
-
 } // end namespace mvm
 
 #endif // MVM_ALLOCATOR_H

Modified: vmkit/trunk/include/mvm/MethodInfo.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/MethodInfo.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/MethodInfo.h (original)
+++ vmkit/trunk/include/mvm/MethodInfo.h Fri Sep  2 14:23:21 2011
@@ -19,7 +19,7 @@
 class FrameInfo {
 public:
   void* Metadata;
-  void* ReturnAddress;
+  intptr_t ReturnAddress;
   uint16_t SourceIndex;
   uint16_t FrameSize;
   uint16_t NumLiveOffsets;
@@ -28,9 +28,9 @@
  
 class MethodInfoHelper {
 public:
-  static void print(void* ip, void* addr);
+  static void print(intptr_t ip, intptr_t addr);
 
-  static void scan(uintptr_t closure, FrameInfo* FI, void* ip, void* addr);
+  static void scan(uintptr_t closure, FrameInfo* FI, intptr_t ip, intptr_t addr);
   
   static uint32_t FrameInfoSize(uint32_t NumOffsets) {
     uint32_t FrameInfoSize = sizeof(FrameInfo) + (NumOffsets - 1) * sizeof(int16_t);

Modified: vmkit/trunk/include/mvm/System.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/System.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/System.h (original)
+++ vmkit/trunk/include/mvm/System.h Fri Sep  2 14:23:21 2011
@@ -10,6 +10,10 @@
 #ifndef MVM_SYSTEM_H
 #define MVM_SYSTEM_H
 
+#include <csetjmp>
+#include <cstring>
+#include <csetjmp>
+#include <dlfcn.h>
 #include <stdint.h>
 
 namespace mvm {
@@ -17,6 +21,69 @@
 const int kWordSize = sizeof(intptr_t);
 const int kWordSizeLog2 = kWordSize == 4 ? 2 : 3;
 
+#if defined(__linux__) || defined(__FreeBSD__)
+#define LINUX_OS 1
+#elif defined(__APPLE__)
+#define MACOS_OS 1
+#else
+#error OS detection failed.
+#endif
+
+#if (__WORDSIZE == 32)
+#define ARCH_32 1
+#elif (__WORDSIZE == 64)
+#define ARCH_64 1
+#else
+#error Word size not supported.
+#endif
+
+#if defined(_M_X64) || defined(__x86_64__)
+#define ARCH_X64 1
+#elif defined(_M_IX86) || defined(__i386__)
+#define ARCH_X86 1
+#elif defined (__PPC__) && ARCH_32
+#define ARCH_PPC 1
+#define ARCH_PPC_32 1
+#elif defined (__PPC__) && ARCH_64
+#define ARCH_PPC 1
+#define ARCH_PPC_64 1
+#else
+#error Architecture detection failed.
+#endif
+
+
+
+#if 0//def ARCH_X64
+const intptr_t kThreadStart = 0x110000000;
+const intptr_t kThreadIDMask = 0xF7FF00000;
+const uintptr_t kMvmThreadMask = 0xFF0000000;
+#else
+const intptr_t kThreadStart = 0x10000000;
+const intptr_t kThreadIDMask = 0x7FF00000;
+const intptr_t kMvmThreadMask = 0xF0000000;
+#endif
+
+#if defined(MACOS_OS)
+  #define LONGJMP _longjmp
+  #define SETJMP _setjmp
+  #define DYLD_EXTENSION ".dylib"
+  #define SELF_HANDLE RTLD_DEFAULT
+  const intptr_t kGCMemoryStart = 0x30000000;
+#else
+  #define LONGJMP longjmp
+  #define SETJMP setjmp
+  #define DYLD_EXTENSION ".so"
+  #define SELF_HANDLE 0
+  const intptr_t kGCMemoryStart = 0x50000000;
+#endif
+
+static const intptr_t kGCMemorySize = 0x30000000;  
+
+#define TRY { mvm::ExceptionBuffer __buffer__; if (!SETJMP(__buffer__.buffer))
+#define CATCH else
+#define IGNORE else { mvm::Thread::get()->clearException(); }}
+#define END_CATCH }
+
 class System {
 public:
   static bool IsWordAligned(intptr_t ptr) {
@@ -29,6 +96,101 @@
     }
     return ptr;
   }
+
+  // Apply this mask to the stack pointer to get the Thread object.
+  static intptr_t GetThreadIDMask() {
+    return kThreadIDMask;
+  }
+
+  // Apply this mask to verify that the current thread was created by Mvm.
+  static intptr_t GetMvmThreadMask() {
+    return kMvmThreadMask;
+  }
+
+  // Get the memory start of thread stack addresses.
+  static intptr_t GetThreadStart() {
+    return kThreadStart;
+  }
+
+  static intptr_t GetCallerAddress() {
+#if defined(ARCH_X86) || defined(ARCH_X64)
+    return (intptr_t)__builtin_frame_address(0);
+#else
+    return ((intptr_t*)__builtin_frame_address(0))[0];
+#endif
+  }
+
+  static intptr_t GetCallerOfAddress(intptr_t addr) {
+    return ((intptr_t*)addr)[0];
+  }
+
+  static intptr_t GetIPFromCallerAddress(intptr_t addr) {
+#if defined(MACOS_OS) && defined(ARCH_PPC)
+    return ((intptr_t*)addr)[2];
+#else
+    return ((intptr_t*)addr)[1];
+#endif
+  }
+
+  static int SetJmp(jmp_buf buffer) {
+#if defined(MACOS_OS)
+    return _setjmp(buffer);
+#else
+    return setjmp(buffer);
+#endif
+  }
+
+  static void LongJmp(jmp_buf buffer, int val) {
+#if defined(MACOS_OS)
+    _longjmp(buffer, val);
+#else
+    longjmp(buffer, val);
+#endif
+  }
+
+  static void* GetSelfHandle() {
+    return SELF_HANDLE;
+  }
+
+  static const char* GetDyLibExtension() {
+    return DYLD_EXTENSION;
+  }
+
+  static double ReadDouble(int first, int second) {
+    int values[2];
+    double res[1];
+#if ARCH_PPC
+    values[0] = second;
+    values[1] = first;
+#else
+    values[0] = first;
+    values[1] = second;
+#endif
+    memcpy(res, values, 8); 
+    return res[0];
+  }
+
+  static int64_t ReadLong(int first, int second) {
+    int values[2];
+    int64_t res[1];
+#if ARCH_PPC
+    values[0] = second;
+    values[1] = first;
+#else
+    values[0] = first;
+    values[1] = second;
+#endif
+    memcpy(res, values, 8); 
+    return res[0];
+  }
+
+  static uint8_t* GetLastBytePtr(uintptr_t ptr) {
+#if ARCH_PPC
+  return ((uint8_t*)ptr) + 2 * mvm::kWordSize - 1;
+#else
+  return ((uint8_t*)ptr) + mvm::kWordSize;
+#endif
+  }
 };
 
 }

Modified: vmkit/trunk/include/mvm/Threads/CollectionRV.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/CollectionRV.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/CollectionRV.h (original)
+++ vmkit/trunk/include/mvm/Threads/CollectionRV.h Fri Sep  2 14:23:21 2011
@@ -62,7 +62,7 @@
   virtual void synchronize() = 0;
 
   virtual void join() = 0;
-  virtual void joinAfterUncooperative(void* SP) = 0;
+  virtual void joinAfterUncooperative(intptr_t SP) = 0;
   virtual void joinBeforeUncooperative() = 0;
 
   virtual void addThread(Thread* th) = 0;
@@ -74,7 +74,7 @@
   void synchronize();
 
   void join();
-  void joinAfterUncooperative(void* SP);
+  void joinAfterUncooperative(intptr_t SP);
   void joinBeforeUncooperative();
   void addThread(Thread* th);
 

Modified: vmkit/trunk/include/mvm/Threads/ObjectLocks.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/ObjectLocks.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/ObjectLocks.h (original)
+++ vmkit/trunk/include/mvm/Threads/ObjectLocks.h Fri Sep  2 14:23:21 2011
@@ -166,7 +166,7 @@
   static const uint32_t NonLockBits = HashBits + GCBits;
   static const uint64_t NonLockBitsMask = ((1 << NonLockBits) - 1);
 
-  static const uint64_t ThinCountMask = ~(FatMask + Thread::IDMask + NonLockBitsMask);
+  static const uint64_t ThinCountMask = ~(FatMask + kThreadIDMask + NonLockBitsMask);
   static const uint64_t ThinCountShift = NonLockBits;
   static const uint64_t ThinCountAdd = 1 << NonLockBits;
 

Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Fri Sep  2 14:23:21 2011
@@ -17,15 +17,8 @@
 #include "debug.h"
 #include "types.h"
 
-#include <csetjmp>
-#if defined(__MACH__)
-  #define TRY { mvm::ExceptionBuffer __buffer__; if (!_setjmp(__buffer__.buffer))
-#else
-  #define TRY { mvm::ExceptionBuffer __buffer__; if (!setjmp(__buffer__.buffer))
-#endif
-#define CATCH else
-#define IGNORE else { mvm::Thread::get()->clearException(); }}
-#define END_CATCH }
+#include "mvm/System.h"
+
 
 namespace mvm {
 
@@ -106,27 +99,10 @@
 };
 
 
-
-#if defined(__MACH__) && (defined(__PPC__) || defined(__ppc__))
-#define FRAME_IP(fp) (fp[2])
-#else
-#define FRAME_IP(fp) (fp[1])
-#endif
-
-// Apparently gcc for i386 and family considers __builtin_frame_address(0) to
-// return the caller, not the current function.
-#if defined(__i386__) || defined(i386) || defined(_M_IX86) || \
-    defined(__x86_64__) || defined(_M_AMD64)
-#define FRAME_PTR() __builtin_frame_address(0)
-#else
-#define FRAME_PTR() (((void**)__builtin_frame_address(0))[0])
-#endif
-
-
 class KnownFrame {
 public:
-  void* currentFP;
-  void* currentIP;
+  intptr_t currentFP;
+  intptr_t currentIP;
   KnownFrame* previousFrame;
 };
 
@@ -177,7 +153,7 @@
 
   /// baseSP - The base stack pointer.
   ///
-  void* baseSP;
+  intptr_t baseSP;
  
   /// doYield - Flag to tell the thread to yield for GC reasons.
   ///
@@ -194,7 +170,7 @@
   /// get - Get the thread specific data of the current thread.
   ///
   static Thread* get() {
-    return (Thread*)((uintptr_t)__builtin_frame_address(0) & IDMask);
+    return (Thread*)(System::GetCallerAddress() & System::GetThreadIDMask());
   }
   
 private:
@@ -203,7 +179,7 @@
   /// interrupted, lastSP is not null and contains the value of the
   /// stack pointer before entering native.
   ///
-  void* lastSP;
+  intptr_t lastSP;
  
   /// internalThreadID - The implementation specific thread id.
   ///
@@ -226,16 +202,16 @@
   virtual void tracer(uintptr_t closure) {}
   void scanStack(uintptr_t closure);
   
-  void* getLastSP() { return lastSP; }
-  void  setLastSP(void* V) { lastSP = V; }
+  intptr_t getLastSP() { return lastSP; }
+  void  setLastSP(intptr_t V) { lastSP = V; }
   
   void joinRVBeforeEnter();
-  void joinRVAfterLeave(void* savedSP);
+  void joinRVAfterLeave(intptr_t savedSP);
 
   void enterUncooperativeCode(unsigned level = 0) __attribute__ ((noinline));
-  void enterUncooperativeCode(void* SP);
+  void enterUncooperativeCode(intptr_t SP);
   void leaveUncooperativeCode();
-  void* waitOnSP();
+  intptr_t waitOnSP();
 
 
   /// clearException - Clear any pending exception of the current thread.
@@ -245,24 +221,12 @@
 
   bool isMvmThread() {
     if (!baseAddr) return false;
-    else return (((uintptr_t)this) & MvmThreadMask) == baseAddr;
+    else return (((uintptr_t)this) & System::GetMvmThreadMask()) == baseAddr;
   }
 
   /// baseAddr - The base address for all threads.
   static uintptr_t baseAddr;
 
-  /// IDMask - Apply this mask to the stack pointer to get the Thread object.
-  ///
-#if 0//(__WORDSIZE == 64)
-  static const uint64_t IDMask = 0xF7FF00000;
-#else
-  static const uint64_t IDMask = 0x7FF00000;
-#endif
-  /// MvmThreadMask - Apply this mask to verify that the current thread was
-  /// created by Mvm.
-  ///
-  static const uint64_t MvmThreadMask = 0xF0000000;
-
   /// OverflowMask - Apply this mask to implement overflow checks. For
   /// efficiency, we lower the available size of the stack: it can never go
   /// under 0xC0000
@@ -272,7 +236,7 @@
   /// stackOverflow - Returns if there is a stack overflow in Java land.
   ///
   bool stackOverflow() {
-    return ((uintptr_t)__builtin_frame_address(0) & StackOverflowMask) == 0;
+    return (System::GetCallerAddress() & StackOverflowMask) == 0;
   }
 
   /// operator new - Allocate the Thread object as well as the stack for this
@@ -295,7 +259,7 @@
  
   /// getFrameContext - Fill the buffer with frames currently on the stack.
   ///
-  void getFrameContext(void** buffer);
+  void getFrameContext(intptr_t* buffer);
   
   /// getFrameContextLength - Get the length of the frame context.
   ///
@@ -339,14 +303,14 @@
 ///
 class StackWalker {
 public:
-  void** addr;
-  void*  ip;
+  intptr_t addr;
+  intptr_t ip;
   KnownFrame* frame;
   mvm::Thread* thread;
 
   StackWalker(mvm::Thread* th) __attribute__ ((noinline));
   void operator++();
-  void* operator*();
+  intptr_t operator*();
   FrameInfo* get();
 
 };

Modified: vmkit/trunk/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/VirtualMachine.h (original)
+++ vmkit/trunk/include/mvm/VirtualMachine.h Fri Sep  2 14:23:21 2011
@@ -32,7 +32,7 @@
   /// used when walking the stack so that VMKit knows which applicative method
   /// is executing on the stack.
   ///
-  llvm::DenseMap<void*, FrameInfo*> Functions;
+  llvm::DenseMap<intptr_t, FrameInfo*> Functions;
 
   /// FunctionMapLock - Spin lock to protect the Functions map.
   ///
@@ -40,12 +40,12 @@
 
   /// IPToFrameInfo - Map a code start instruction instruction to the FrameInfo.
   ///
-  FrameInfo* IPToFrameInfo(void* ip);
+  FrameInfo* IPToFrameInfo(intptr_t ip);
 
   /// addFrameInfo - A new instruction pointer in the function map.
   ///
-  void addFrameInfo(void* ip, FrameInfo* meth);
-  void addFrameInfoNoLock(void* ip, FrameInfo* meth) {
+  void addFrameInfo(intptr_t ip, FrameInfo* meth);
+  void addFrameInfoNoLock(intptr_t ip, FrameInfo* meth) {
     Functions[ip] = meth;
   }
   /// removeFrameInfos - Remove all FrameInfo owned by the given owner.
@@ -208,14 +208,14 @@
 //===----------------------------------------------------------------------===//
 
   FunctionMap FunctionsCache;
-  FrameInfo* IPToFrameInfo(void* ip) {
+  FrameInfo* IPToFrameInfo(intptr_t ip) {
     return FunctionsCache.IPToFrameInfo(ip);
   }
   void removeFrameInfos(void* owner) {
     FunctionsCache.removeFrameInfos(owner);
   }
 
-  virtual void printMethod(FrameInfo* FI, void* ip, void* addr) = 0;
+  virtual void printMethod(FrameInfo* FI, intptr_t ip, intptr_t addr) = 0;
   
 //===----------------------------------------------------------------------===//
 // (4) Launch-related methods.

Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc (original)
+++ vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc Fri Sep  2 14:23:21 2011
@@ -21,7 +21,6 @@
 #include "JavaUpcalls.h"
 #include "Jnjvm.h"
 
-#include <csetjmp>
 #include <cstring>
 #include <unistd.h>
 

Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc (original)
+++ vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc Fri Sep  2 14:23:21 2011
@@ -50,7 +50,7 @@
   mvm::StackWalker Walker(th);
   uint32_t i = 0;
 
-  while (void* ip = *Walker) {
+  while (intptr_t ip = *Walker) {
     ArrayPtr::setElement(result, ip, i);
     ++i;
     ++Walker;
@@ -83,7 +83,7 @@
 }
 
 
-JavaObject* consStackElement(mvm::FrameInfo* FI, void* ip) {
+JavaObject* consStackElement(mvm::FrameInfo* FI, intptr_t ip) {
 
   JavaString* methodName = 0;
   JavaString* className = 0;

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Fri Sep  2 14:23:21 2011
@@ -2062,17 +2062,10 @@
           uint8 id = reader.readU1();
           i += 1;
           uint8 charId = arrayType(compilingMethod, id);
-#ifndef ISOLATE_SHARING
           JnjvmBootstrapLoader* loader = 
             compilingClass->classLoader->bootstrapLoader;
           dcl = loader->getArrayClass(id);
           valCl = TheCompiler->getNativeClass(dcl);
-#else
-          Value* args[2] = { isolateLocal,
-                             ConstantInt::get(Type::getInt32Ty(*llvmContext), id - 4) };
-          valCl = CallInst::Create(intrinsics->GetJnjvmArrayClassFunction,
-                                   args, "", currentBlock);
-#endif
 
           LLVMAssessorInfo& LAI = TheCompiler->AssessorInfo[charId];
           sizeElement = ConstantInt::get(Type::getInt32Ty(*llvmContext),

Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Fri Sep  2 14:23:21 2011
@@ -157,7 +157,7 @@
       
       bool j3 = false;
       if (isNative(methodDef->access)) {
-        // Verify if it's defined by JnJVM
+        // Verify if it's defined by J3
         JCL->nativeLookup(methodDef, j3, buf);
       }
 

Modified: vmkit/trunk/lib/J3/VMCore/JavaArray.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaArray.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaArray.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaArray.h Fri Sep  2 14:23:21 2011
@@ -117,7 +117,7 @@
 ARRAYCLASS(ArrayLong,   sint64);
 ARRAYCLASS(ArrayFloat,  float);
 ARRAYCLASS(ArrayDouble, double);
-ARRAYCLASS(ArrayPtr, void*);
+ARRAYCLASS(ArrayPtr, intptr_t);
 
 #undef ARRAYCLASS
 

Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Fri Sep  2 14:23:21 2011
@@ -343,15 +343,15 @@
   th->currentAddedReferences = *oldLRN;
 }
 
-extern "C" void* j3StartJNI(uint32* localReferencesNumber,
-                            uint32** oldLocalReferencesNumber,
-                            mvm::KnownFrame* Frame) 
+extern "C" intptr_t j3StartJNI(uint32* localReferencesNumber,
+                               uint32** oldLocalReferencesNumber,
+                               mvm::KnownFrame* Frame) 
   __attribute__((noinline));
 
 // Never throws. Does not call Java code. Can not yield a GC. May join a GC.
-extern "C" void* j3StartJNI(uint32* localReferencesNumber,
-                            uint32** oldLocalReferencesNumber,
-                            mvm::KnownFrame* Frame) {
+extern "C" intptr_t j3StartJNI(uint32* localReferencesNumber,
+                               uint32** oldLocalReferencesNumber,
+                               mvm::KnownFrame* Frame) {
   
   JavaThread* th = JavaThread::get();
  

Modified: vmkit/trunk/lib/J3/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaThread.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaThread.h Fri Sep  2 14:23:21 2011
@@ -39,7 +39,7 @@
 
 #define BEGIN_JNI_EXCEPTION \
   JavaThread* th = JavaThread::get(); \
-  void* SP = th->getLastSP(); \
+  intptr_t SP = th->getLastSP(); \
   th->leaveUncooperativeCode(); \
   mvm::KnownFrame Frame; \
   th->startKnownFrame(Frame); \
@@ -157,7 +157,7 @@
 
   /// throwFromJNI - Throw an exception after executing JNI code.
   ///
-  void throwFromJNI(void* SP) {
+  void throwFromJNI(intptr_t SP) {
     endKnownFrame();
     enterUncooperativeCode(SP);
   }

Modified: vmkit/trunk/lib/J3/VMCore/Jni.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jni.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jni.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jni.cpp Fri Sep  2 14:23:21 2011
@@ -9,6 +9,8 @@
 
 #include <jni.h>
 
+#include "mvm/System.h"
+
 #include "ClasspathReflect.h"
 #include "JavaArray.h"
 #include "JavaClass.h"
@@ -3602,11 +3604,11 @@
 
   res = BB->doNew(myvm);
 
-#if (__WORDSIZE == 32)
+#if ARCH_32
   UserClass* PP = myvm->upcalls->newPointer32;
   p = PP->doNew(myvm);
   myvm->upcalls->dataPointer32->setInstanceInt32Field(p, (uint32)address);
-#else
+#elif ARCH_64
   UserClass* PP = myvm->upcalls->newPointer64;
   p = PP->doNew(myvm);
   myvm->upcalls->dataPointer64->setInstanceLongField(p, (jlong)address);

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Fri Sep  2 14:23:21 2011
@@ -1443,14 +1443,16 @@
   return 0; 
 }
 
-void Jnjvm::printMethod(mvm::FrameInfo* FI, void* ip, void* addr) {
+void Jnjvm::printMethod(mvm::FrameInfo* FI, intptr_t ip, intptr_t addr) {
   if (FI->Metadata == NULL) {
     mvm::MethodInfoHelper::print(ip, addr);
     return;
   }
   JavaMethod* meth = (JavaMethod*)FI->Metadata;
 
-  fprintf(stderr, "; %p (%p) in %s.%s (line %d, bytecode %d, code start %p)", ip, addr,
+  fprintf(stderr, "; %p (%p) in %s.%s (line %d, bytecode %d, code start %p)",
+          (void*)ip,
+          (void*)addr,
           UTF8Buffer(meth->classDef->name).cString(),
           UTF8Buffer(meth->name).cString(),
           meth->lookupLineNumber(FI),

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.h Fri Sep  2 14:23:21 2011
@@ -130,7 +130,7 @@
   virtual void addFinalizationCandidate(gc* obj);
   virtual size_t getObjectSize(gc* obj);
   virtual const char* getObjectTypeName(gc* obj);
-  virtual void printMethod(mvm::FrameInfo* FI, void* ip, void* addr);
+  virtual void printMethod(mvm::FrameInfo* FI, intptr_t ip, intptr_t addr);
 
 
   /// CreateError - Creates a Java object of the specified exception class

Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Fri Sep  2 14:23:21 2011
@@ -23,14 +23,6 @@
 
 #include <string>
 
-#if defined(__MACH__)
-#define SELF_HANDLE RTLD_DEFAULT
-#define DYLD_EXTENSION ".dylib"
-#else
-#define SELF_HANDLE 0
-#define DYLD_EXTENSION ".so"
-#endif
-
 #include "debug.h"
 #include "mvm/Allocator.h"
 
@@ -170,7 +162,7 @@
   clinitType = asciizConstructUTF8("()V");
   runName = asciizConstructUTF8("run");
   prelib = asciizConstructUTF8("lib");
-  postlib = asciizConstructUTF8(DYLD_EXTENSION);
+  postlib = asciizConstructUTF8(mvm::System::GetDyLibExtension());
   mathName = asciizConstructUTF8("java/lang/Math");
   stackWalkerName = asciizConstructUTF8("gnu/classpath/VMStackWalker");
   NoClassDefFoundError = asciizConstructUTF8("java/lang/NoClassDefFoundError");
@@ -239,7 +231,7 @@
 }
 
 ClassBytes* JnjvmBootstrapLoader::openName(const UTF8* utf8) {
-  ClassBytes* res = reinterpret_cast<ClassBytes*>(dlsym(SELF_HANDLE,
+  ClassBytes* res = reinterpret_cast<ClassBytes*>(dlsym(mvm::System::GetSelfHandle(),
       UTF8Buffer(utf8).toCompileName("_bytes")->cString()));
   if (res != NULL) return res;
 
@@ -977,7 +969,7 @@
 }
 
 intptr_t JnjvmClassLoader::loadInLib(const char* buf, bool& j3) {
-  uintptr_t res = (uintptr_t)TheCompiler->loadMethod(SELF_HANDLE, buf);
+  uintptr_t res = (uintptr_t)TheCompiler->loadMethod(mvm::System::GetSelfHandle(), buf);
   
   if (!res) {
     for (std::vector<void*>::iterator i = nativeLibs.begin(),

Modified: vmkit/trunk/lib/J3/VMCore/Precompiled.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Precompiled.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Precompiled.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Precompiled.cpp Fri Sep  2 14:23:21 2011
@@ -9,15 +9,6 @@
 
 // for dlopen and dlsym
 #include <dlfcn.h> 
-
-#if defined(__MACH__)
-#define SELF_HANDLE RTLD_DEFAULT
-#define DYLD_EXTENSION ".dylib"
-#else
-#define SELF_HANDLE 0
-#define DYLD_EXTENSION ".so"
-#endif
-
 #include "mvm/MethodInfo.h"
 
 #include "JavaClass.h"
@@ -123,7 +114,7 @@
 
 bool Precompiled::Init(JnjvmBootstrapLoader* loader) {
   Class* javaLangObject = (Class*)dlsym(SELF_HANDLE, "java_lang_Object");
-  void* nativeHandle = SELF_HANDLE;
+  void* nativeHandle = mvm::System::GetSelfHandle();
   if (javaLangObject == NULL) {
     void* handle = dlopen("libvmjc"DYLD_EXTENSION, RTLD_LAZY | RTLD_GLOBAL);
     if (handle != NULL) {

Modified: vmkit/trunk/lib/J3/VMCore/Reader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Reader.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Reader.h (original)
+++ vmkit/trunk/lib/J3/VMCore/Reader.h Fri Sep  2 14:23:21 2011
@@ -59,32 +59,12 @@
   }
 
   static double readDouble(int first, int second) {
-    int values[2];
-    double res[1];
-#if defined(__PPC__)
-    values[0] = second;
-    values[1] = first;
-#else
-    values[0] = first;
-    values[1] = second;
-#endif
-    memcpy(res, values, 8); 
-    return res[0];
-  }
+    return mvm::System::ReadDouble(first, second);
+   }
 
 
   static sint64 readLong(int first, int second) {
-    int values[2];
-    sint64 res[1];
-#if defined(__PPC__)
-    values[0] = second;
-    values[1] = first;
-#else
-    values[0] = first;
-    values[1] = second;
-#endif
-    memcpy(res, values, 8); 
-    return res[0];
+    return mvm::System::ReadLong(first, second);
   }
 
   static const int SeekSet;
@@ -149,7 +129,6 @@
   }
   
   void seek(uint32 pos, int from);
-
 };
 
 } // end namespace j3

Modified: vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h (original)
+++ vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h Fri Sep  2 14:23:21 2011
@@ -57,11 +57,11 @@
     if (CurrentIndex >= QueueLength) {
       uint32 newLength = QueueLength * GROW_FACTOR;
       gc** newQueue = new gc*[newLength];
-      memset(newQueue, 0, newLength * sizeof(gc*));
       if (!newQueue) {
         fprintf(stderr, "I don't know how to handle reference overflow yet!\n");
         abort();
       }
+      memset(newQueue, 0, newLength * sizeof(gc*));
       for (uint32 i = 0; i < QueueLength; ++i) newQueue[i] = References[i];
       delete[] References;
       References = newQueue;

Modified: vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp Fri Sep  2 14:23:21 2011
@@ -15,11 +15,11 @@
 
 #include "debug.h"
 
-using namespace mvm;
+namespace mvm {
 
 void CollectionRV::another_mark() {
   mvm::Thread* th = mvm::Thread::get();
-  assert(th->getLastSP() != NULL);
+  assert(th->getLastSP() != 0);
   assert(nbJoined < th->MyVM->numberOfThreads);
   nbJoined++;
   if (nbJoined == th->MyVM->numberOfThreads) {
@@ -29,7 +29,7 @@
 
 void CollectionRV::waitEndOfRV() {
   mvm::Thread* th = mvm::Thread::get();
-  assert(th->getLastSP() != NULL);
+  assert(th->getLastSP() != 0);
 
   while (th->doYield) {
     condEndRV.wait(&_lockRV);
@@ -85,12 +85,12 @@
 void CooperativeCollectionRV::join() {
   mvm::Thread* th = mvm::Thread::get();
   assert(th->doYield && "No yield");
-  assert((th->getLastSP() == NULL) && "SP present in cooperative code");
+  assert((th->getLastSP() == 0) && "SP present in cooperative code");
 
   th->inRV = true;
   
   lockRV();
-  th->setLastSP(FRAME_PTR());
+  th->setLastSP(System::GetCallerAddress());
   th->joinedRV = true;
   another_mark();
   waitEndOfRV();
@@ -102,7 +102,7 @@
 
 void CooperativeCollectionRV::joinBeforeUncooperative() {
   mvm::Thread* th = mvm::Thread::get();
-  assert((th->getLastSP() != NULL) &&
+  assert((th->getLastSP() != 0) &&
          "SP not set before entering uncooperative code");
 
   th->inRV = true;
@@ -120,9 +120,9 @@
   th->inRV = false;
 }
 
-void CooperativeCollectionRV::joinAfterUncooperative(void* SP) {
+void CooperativeCollectionRV::joinAfterUncooperative(intptr_t SP) {
   mvm::Thread* th = mvm::Thread::get();
-  assert((th->getLastSP() == NULL) &&
+  assert((th->getLastSP() == 0) &&
          "SP set after entering uncooperative code");
 
   th->inRV = true;
@@ -135,7 +135,7 @@
       another_mark();
     }
     waitEndOfRV();
-    th->setLastSP(NULL);
+    th->setLastSP(0);
   }
   unlockRV();
 
@@ -172,3 +172,5 @@
 void CooperativeCollectionRV::addThread(Thread* th) {
   // Nothing to do.
 }
+
+}

Modified: vmkit/trunk/lib/Mvm/CommonThread/ObjectLocks.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ObjectLocks.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ObjectLocks.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ObjectLocks.cpp Fri Sep  2 14:23:21 2011
@@ -20,7 +20,7 @@
 #include <pthread.h>
 
 
-using namespace mvm;
+namespace mvm {
 
 void ThinLock::overflowThinLock(gc* object, LockSystem& table) {
   llvm_gcroot(object, 0);
@@ -109,7 +109,7 @@
   uintptr_t newValue = 0;
   uintptr_t yieldedValue = 0;
 
-  if ((object->header & Thread::IDMask) == id) {
+  if ((object->header & System::GetThreadIDMask()) == id) {
     assert(owner(object, table) && "Inconsistent lock");
     if ((object->header & ThinCountMask) != ThinCountMask) {
       uint32 count = object->header & ThinCountMask;
@@ -225,7 +225,7 @@
     if (obj != NULL) return obj->owner();
   } else {
     uint64 id = mvm::Thread::get()->getThreadID();
-    if ((object->header & Thread::IDMask) == id) return true;
+    if ((object->header & System::GetThreadIDMask()) == id) return true;
   }
   return false;
 }
@@ -534,3 +534,5 @@
   l->firstThread = NULL;
   assert(mvm::ThinLock::owner(self, table) && "Not owner after notifyAll");
 }
+
+}

Modified: vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp Fri Sep  2 14:23:21 2011
@@ -19,7 +19,7 @@
 #include <pthread.h>
 
 
-using namespace mvm;
+namespace mvm {
 
 Lock::Lock() {
   pthread_mutexattr_t attr;
@@ -187,3 +187,5 @@
 
   return res;
 }
+
+}

Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Fri Sep  2 14:23:21 2011
@@ -17,10 +17,7 @@
 #include "mvm/Threads/Thread.h"
 
 #include <cassert>
-#include <csetjmp>
 #include <cstdio>
-#include <ctime>
-#include <dlfcn.h>
 #include <errno.h>
 #include <pthread.h>
 #include <sys/mman.h>
@@ -56,47 +53,43 @@
   MyVM->rendezvous.joinBeforeUncooperative(); 
 }
 
-void Thread::joinRVAfterLeave(void* savedSP) {
+void Thread::joinRVAfterLeave(intptr_t savedSP) {
   MyVM->rendezvous.joinAfterUncooperative(savedSP); 
 }
 
 void Thread::startKnownFrame(KnownFrame& F) {
   // Get the caller of this function
-  void** cur = (void**)FRAME_PTR();
+  intptr_t cur = System::GetCallerAddress();
   F.previousFrame = lastKnownFrame;
   F.currentFP = cur;
   // This is used as a marker.
-  F.currentIP = NULL;
+  F.currentIP = 0;
   lastKnownFrame = &F;
 }
 
 void Thread::endKnownFrame() {
-  assert(lastKnownFrame->currentIP == NULL);
+  assert(lastKnownFrame->currentIP == 0);
   lastKnownFrame = lastKnownFrame->previousFrame;
 }
 
 void Thread::startUnknownFrame(KnownFrame& F) {
   // Get the caller of this function
-  void** cur = (void**)FRAME_PTR();
+  intptr_t cur = System::GetCallerAddress();
   // Get the caller of the caller.
-  cur = (void**)cur[0];
+  cur = System::GetCallerOfAddress(cur);
   F.previousFrame = lastKnownFrame;
   F.currentFP = cur;
-  F.currentIP = FRAME_IP(cur);
+  F.currentIP = System::GetIPFromCallerAddress(cur);
   lastKnownFrame = &F;
 }
 
 void Thread::endUnknownFrame() {
-  assert(lastKnownFrame->currentIP != NULL);
+  assert(lastKnownFrame->currentIP != 0);
   lastKnownFrame = lastKnownFrame->previousFrame;
 }
 
 void Thread::internalThrowException() {
-#if defined(__MACH__)
-  _longjmp(lastExceptionBuffer->buffer, 1);
-#else
-  longjmp(lastExceptionBuffer->buffer, 1);
-#endif
+  LONGJMP(lastExceptionBuffer->buffer, 1);
 }
 
 void Thread::printBacktrace() {
@@ -108,11 +101,11 @@
   }
 }
 
-void Thread::getFrameContext(void** buffer) {
+void Thread::getFrameContext(intptr_t* buffer) {
   mvm::StackWalker Walker(this);
   uint32_t i = 0;
 
-  while (void* ip = *Walker) {
+  while (intptr_t ip = *Walker) {
     buffer[i++] = ip;
     ++Walker;
   }
@@ -131,29 +124,29 @@
 
 FrameInfo* StackWalker::get() {
   if (addr == thread->baseSP) return 0;
-  ip = FRAME_IP(addr);
+  ip = System::GetIPFromCallerAddress(addr);
   return thread->MyVM->IPToFrameInfo(ip);
 }
 
-void* StackWalker::operator*() {
+intptr_t StackWalker::operator*() {
   if (addr == thread->baseSP) return 0;
-  ip = FRAME_IP(addr);
+  ip = System::GetIPFromCallerAddress(addr);
   return ip;
 }
 
 void StackWalker::operator++() {
   if (addr != thread->baseSP) {
     assert((addr < thread->baseSP) && "Corrupted stack");
-    assert((addr < addr[0]) && "Corrupted stack");
+    assert((addr < System::GetCallerOfAddress(addr)) && "Corrupted stack");
     if ((frame != NULL) && (addr == frame->currentFP)) {
-      assert(frame->currentIP == NULL);
+      assert(frame->currentIP == 0);
       frame = frame->previousFrame;
       assert(frame != NULL);
-      assert(frame->currentIP != NULL);
-      addr = (void**)frame->currentFP;
+      assert(frame->currentIP != 0);
+      addr = frame->currentFP;
       frame = frame->previousFrame;
     } else {
-      addr = (void**)addr[0];
+      addr = System::GetCallerOfAddress(addr);
     }
   }
 }
@@ -162,16 +155,16 @@
   thread = th;
   frame = th->lastKnownFrame;
   if (mvm::Thread::get() == th) {
-    addr = (void**)FRAME_PTR();
-    addr = (void**)addr[0];
+    addr = System::GetCallerAddress();
+    addr = System::GetCallerOfAddress(addr);
   } else {
-    addr = (void**)th->waitOnSP();
+    addr = th->waitOnSP();
     if (frame) {
       assert(frame->currentFP >= addr);
     }
     if (frame && (addr == frame->currentFP)) {
       frame = frame->previousFrame;
-      assert((frame == NULL) || (frame->currentIP == NULL));
+      assert((frame == NULL) || (frame->currentIP == 0));
     }
   }
   assert(addr && "No address to start with");
@@ -191,10 +184,10 @@
     if (!inRV) {
       assert(!lastSP && "SP already set when entering uncooperative code");
       // Get the caller.
-      void* temp = FRAME_PTR();
+      intptr_t temp = System::GetCallerAddress();
       // Make sure to at least get the caller of the caller.
       ++level;
-      while (level--) temp = ((void**)temp)[0];
+      while (level--) temp = System::GetCallerOfAddress(temp);
       // The cas is not necessary, but it does a memory barrier.
       __sync_bool_compare_and_swap(&lastSP, 0, temp);
       if (doYield) joinRVBeforeEnter();
@@ -203,7 +196,7 @@
   }
 }
 
-void Thread::enterUncooperativeCode(void* SP) {
+void Thread::enterUncooperativeCode(intptr_t SP) {
   if (isMvmThread()) {
     if (!inRV) {
       assert(!lastSP && "SP already set when entering uncooperative code");
@@ -219,7 +212,7 @@
   if (isMvmThread()) {
     if (!inRV) {
       assert(lastSP && "No last SP when leaving uncooperative code");
-      void* savedSP = lastSP;
+      intptr_t savedSP = lastSP;
       // The cas is not necessary, but it does a memory barrier.
       __sync_bool_compare_and_swap(&lastSP, lastSP, 0);
       // A rendezvous has just been initiated, join it.
@@ -229,9 +222,9 @@
   }
 }
 
-void* Thread::waitOnSP() {
+intptr_t Thread::waitOnSP() {
   // First see if we can get lastSP directly.
-  void* sp = lastSP;
+  intptr_t sp = lastSP;
   if (sp) return sp;
   
   // Then loop a fixed number of iterations to get lastSP.
@@ -241,9 +234,9 @@
   }
   
   // Finally, yield until lastSP is not set.
-  while ((sp = lastSP) == NULL) mvm::Thread::yield();
+  while ((sp = lastSP) == 0) mvm::Thread::yield();
 
-  assert(sp != NULL && "Still no sp");
+  assert(sp != 0 && "Still no sp");
   return sp;
 }
 
@@ -254,14 +247,6 @@
 #define STACK_SIZE 0x100000
 #define NR_THREADS 255
 
-#if 0//(__WORDSIZE == 64)
-#define START_ADDR 0x110000000
-#define END_ADDR 0x170000000
-#else
-#define START_ADDR 0x10000000
-#define END_ADDR 0x70000000
-#endif
-
 /// StackThreadManager - This class allocates all stacks for threads. Because
 /// we want fast access to thread local data, and can not rely on platform
 /// dependent thread local storage (eg pthread keys are inefficient, tls is
@@ -282,13 +267,9 @@
 
   StackThreadManager() {
     baseAddr = 0;
-    uintptr_t ptr = START_ADDR;
+    uintptr_t ptr = kThreadStart;
 
-#if defined (__MACH__)
     uint32 flags = MAP_PRIVATE | MAP_ANON | MAP_FIXED;
-#else
-    uint32 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED;
-#endif
     baseAddr = (uintptr_t)mmap((void*)ptr, STACK_SIZE * NR_THREADS, 
                                PROT_READ | PROT_WRITE, flags, -1, 0);
 
@@ -344,7 +325,7 @@
 /// given routine of th.
 ///
 void Thread::internalThreadStart(mvm::Thread* th) {
-  th->baseSP  = FRAME_PTR();
+  th->baseSP  = System::GetCallerAddress();
 
   // Set the SIGSEGV handler to diagnose errors.
   struct sigaction sa;
@@ -405,7 +386,7 @@
     // Wait for the thread to die.
     pthread_join((pthread_t)thread_id, NULL);
   }
-  uintptr_t index = ((uintptr_t)th & Thread::IDMask);
+  uintptr_t index = ((uintptr_t)th & System::GetThreadIDMask());
   index = (index & ~TheStackManager.baseAddr) >> 20;
   TheStackManager.used[index] = 0;
 }

Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Fri Sep  2 14:23:21 2011
@@ -39,6 +39,7 @@
 
 #include "mvm/JIT.h"
 #include "mvm/Threads/Locks.h"
+#include "mvm/Threads/ObjectLocks.h"
 #include "mvm/Threads/Thread.h"
 #include "mvm/VirtualMachine.h"
 #include "mvm/GC/GC.h"
@@ -303,17 +304,16 @@
   constantDoubleMinusInfinity = ConstantFP::get(Type::getDoubleTy(Context), MinDouble);
   constantDoubleMinusZero = ConstantFP::get(Type::getDoubleTy(Context), -0.0);
   constantFloatMinusZero = ConstantFP::get(Type::getFloatTy(Context), -0.0f);
-  constantThreadIDMask = ConstantInt::get(pointerSizeType, mvm::Thread::IDMask);
+  constantThreadIDMask = ConstantInt::get(pointerSizeType, mvm::System::GetThreadIDMask());
   constantStackOverflowMask = 
-    ConstantInt::get(pointerSizeType, mvm::Thread::StackOverflowMask);
-  constantFatMask = ConstantInt::get(pointerSizeType, 
-      pointerSizeType == Type::getInt32Ty(Context) ? 0x80000000 : 0x8000000000000000LL);
+    ConstantInt::get(pointerSizeType, Thread::StackOverflowMask);
+  constantFatMask = ConstantInt::get(pointerSizeType, ThinLock::FatMask);
   constantPtrOne = ConstantInt::get(pointerSizeType, 1);
   constantPtrZero = ConstantInt::get(pointerSizeType, 0);
 
   constantPtrNull = Constant::getNullValue(ptrType); 
   constantPtrLogSize = 
-    ConstantInt::get(Type::getInt32Ty(Context), sizeof(void*) == 8 ? 3 : 2);
+    ConstantInt::get(Type::getInt32Ty(Context), kWordSizeLog2);
   arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::getInt8Ty(Context), 0));
   
   printFloatLLVM = module->getFunction("printFloat");
@@ -403,7 +403,7 @@
     frame->FrameSize = FI->getFrameSize();
     frame->Metadata = meta;
     frame->SourceIndex = I->Loc.getLine();
-    frame->ReturnAddress = reinterpret_cast<void*>(JCE->getLabelAddress(I->Label));
+    frame->ReturnAddress = JCE->getLabelAddress(I->Label);
     int i = 0;
     for (llvm::GCFunctionInfo::live_iterator KI = FI->live_begin(I),
          KE = FI->live_end(I); KI != KE; ++KI) {

Modified: vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp Fri Sep  2 14:23:21 2011
@@ -16,13 +16,12 @@
 #include "MvmGC.h"
 
 #include <dlfcn.h>
-#include <map>
 
-using namespace mvm;
+namespace mvm {
 
-void MethodInfoHelper::scan(uintptr_t closure, FrameInfo* FI, void* ip, void* addr) {
+void MethodInfoHelper::scan(uintptr_t closure, FrameInfo* FI, intptr_t ip, intptr_t addr) {
   //uintptr_t spaddr = (uintptr_t)addr + FI->FrameSize + sizeof(void*);
-  uintptr_t spaddr = ((uintptr_t*)addr)[0];
+  uintptr_t spaddr = System::GetCallerOfAddress(addr);
   for (uint16 i = 0; i < FI->NumLiveOffsets; ++i) {
     intptr_t obj = *(intptr_t*)(spaddr + FI->LiveOffsets[i]);    
     // Verify that obj does not come from a JSR bytecode.
@@ -32,13 +31,13 @@
   }
 }
 
-void MethodInfoHelper::print(void* ip, void* addr) {
+void MethodInfoHelper::print(intptr_t ip, intptr_t addr) {
   Dl_info info;
-  int res = dladdr(ip, &info);
+  int res = dladdr((void*)ip, &info);
   if (res != 0 && info.dli_sname != NULL) {
-    fprintf(stderr, "; %p (%p) in %s\n",  ip, addr, info.dli_sname);
+    fprintf(stderr, "; %p (%p) in %s\n",  (void*)ip, (void*)addr, info.dli_sname);
   } else {
-    fprintf(stderr, "; %p in Unknown method\n", ip);
+    fprintf(stderr, "; %p in Unknown method\n", (void*)ip);
   }
 }
 
@@ -72,9 +71,9 @@
 // Create a dummy FrameInfo, so that methods don't have to null check.
 static FrameInfo emptyInfo;
 
-FrameInfo* FunctionMap::IPToFrameInfo(void* ip) {
+FrameInfo* FunctionMap::IPToFrameInfo(intptr_t ip) {
   FunctionMapLock.acquire();
-  llvm::DenseMap<void*, FrameInfo*>::iterator I = Functions.find(ip);
+  llvm::DenseMap<intptr_t, FrameInfo*>::iterator I = Functions.find(ip);
   FrameInfo* res = NULL;
   if (I != Functions.end()) {
     res = I->second;
@@ -88,8 +87,10 @@
 }
 
 
-void FunctionMap::addFrameInfo(void* ip, FrameInfo* meth) {
+void FunctionMap::addFrameInfo(intptr_t ip, FrameInfo* meth) {
   FunctionMapLock.acquire();
   addFrameInfoNoLock(ip, meth);
   FunctionMapLock.release();
 }
+
+}

Modified: vmkit/trunk/mmtk/mmtk-j3/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/Memory.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/Memory.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/Memory.cpp Fri Sep  2 14:23:21 2011
@@ -15,26 +15,14 @@
 
 namespace mmtk {
 
-#if defined (__MACH__)
-static const uintptr_t MemoryStart = 0x30000000;
-#else
-static const uintptr_t MemoryStart = 0x50000000;
-#endif
-
-static const uintptr_t MemorySize = 0x30000000;
-
 class InitCollector {
 public:
   InitCollector() {
-#if defined (__MACH__)
     uint32 flags = MAP_PRIVATE | MAP_ANON | MAP_FIXED;
-#else
-    uint32 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED;
-#endif
-    void* baseAddr = mmap((void*)MemoryStart, MemorySize, PROT_READ | PROT_WRITE,
+    void* baseAddr = mmap((void*)mvm::kGCMemoryStart, mvm::kGCMemorySize, PROT_READ | PROT_WRITE,
                           flags, -1, 0);
     if (baseAddr == MAP_FAILED) {
-      perror("mmap");
+      perror("mmap for GC memory");
       abort();
     }
   }
@@ -44,11 +32,11 @@
 InitCollector initCollector;
 
 extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapStartConstant__ (MMTkObject* M) {
-  return MemoryStart;
+  return mvm::kGCMemoryStart;
 }
 
 extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapEndConstant__ (MMTkObject* M) {
-  return MemoryStart + MemorySize;
+  return mvm::kGCMemoryStart + mvm::kGCMemorySize;
 }
 
 extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableStartConstant__ (MMTkObject* M) {

Modified: vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp Fri Sep  2 14:23:21 2011
@@ -40,19 +40,11 @@
 }
 
 extern "C" uint8_t Java_org_j3_mmtk_ObjectModel_readAvailableByte__Lorg_vmmagic_unboxed_ObjectReference_2 (MMTkObject* OM, gc* obj) {
-#if defined(__PPC__)
-  return ((uint8_t*)obj)[2 * mvm::kWordSize - 1];
-#else
-  return ((uint8_t*)obj)[mvm::kWordSize];
-#endif
+  return *mvm::System::GetLastBytePtr(reinterpret_cast<intptr_t>(obj));
 }
 
 extern "C" void Java_org_j3_mmtk_ObjectModel_writeAvailableByte__Lorg_vmmagic_unboxed_ObjectReference_2B (MMTkObject* OM, gc* obj, uint8_t val) {
-#if defined(__PPC__)
-  ((uint8_t*)obj)[2 * mvm::kWordSize - 1] = val;
-#else
-  ((uint8_t*)obj)[mvm::kWordSize] = val;
-#endif
+  *mvm::System::GetLastBytePtr(reinterpret_cast<intptr_t>(obj)) = val;
 }
 
 extern "C" gc* Java_org_j3_mmtk_ObjectModel_getObjectFromStartAddress__Lorg_vmmagic_unboxed_Address_2 (MMTkObject* OM, gc* obj) {

Modified: vmkit/trunk/mmtk/mmtk-j3/VM.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/VM.cpp?rev=139025&r1=139024&r2=139025&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/VM.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/VM.cpp Fri Sep  2 14:23:21 2011
@@ -64,15 +64,11 @@
 }
 
 extern "C" bool Java_org_j3_runtime_VM_buildFor64Addr__ () { 
-#if (__WORDSIZE==64)
-  return true;
-#else
-  return false;
-#endif
+  return mvm::kWordSize == 8;
 }
 
 extern "C" bool Java_org_j3_runtime_VM_buildForIA32__ () { 
-#if defined(__i386__) || defined(i386) || defined(_M_IX86)
+#if ARCH_X86
   return true;
 #else
   return false;





More information about the vmkit-commits mailing list