[llvm-commits] [vmkit] r51144 - in /vmkit/trunk: ./ lib/JnJVM/ lib/JnJVM/LLVMRuntime/ lib/JnJVM/VMCore/ lib/Mvm/ lib/Mvm/BoehmGC/ lib/Mvm/GCMmap2/
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Thu May 15 03:48:09 PDT 2008
Author: geoffray
Date: Thu May 15 05:48:07 2008
New Revision: 51144
URL: http://llvm.org/viewvc/llvm-project?rev=51144&view=rev
Log:
Use llc -march=cpp to generate runtime function declarations in JnJVM.
The generated file is included in JavaJITInitialise.cpp to add the
declarations in the JnJVM/LLVM bootstrap module.
Added:
vmkit/trunk/lib/JnJVM/LLVMRuntime/
vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-boehm.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-multi-mmap.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-service.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single-mmap.ll
vmkit/trunk/lib/Mvm/BoehmGC/Makefile.am
vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp
Modified:
vmkit/trunk/configure.ac
vmkit/trunk/lib/JnJVM/Makefile.am
vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
vmkit/trunk/lib/JnJVM/VMCore/Makefile.am
vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp
vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h
vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
vmkit/trunk/lib/Mvm/Makefile.am
vmkit/trunk/lib/Mvm/Object.cpp
Modified: vmkit/trunk/configure.ac
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/configure.ac (original)
+++ vmkit/trunk/configure.ac Thu May 15 05:48:07 2008
@@ -49,6 +49,8 @@
)
LLVMDYLIB="`$llvmprefix/Release/bin/llvm-config --ldflags all` `$llvmprefix/Release/bin/llvm-config --libs all`"
+AC_SUBST([llvmprefix])
+
dnl Force some compilation flags
CXXFLAGS="$CXXFLAGS -fsigned-char -felide-constructors -fno-keep-static-consts -D_REENTRANT -I$PWD/include -I$llvmprefix/include -D__STDC_LIMIT_MACROS -rdynamic"
CFLAGS="$CFLAGS -D_REENTRANT"
@@ -192,7 +194,7 @@
AC_CHECK_HEADER([gc/gc.h], [], \
AC_MSG_ERROR([You need to install the boehm-gc devel package (gc/gc.h).])
)
- GC_LIBS="-lgccpp -gc"
+ GC_LIBS="-lgccpp -gc $PWD/lib/Mvm/BoehmGC/libuvm_gc_boehm.a"
CFLAGS="$CFLAGS -I$PWD/lib/Mvm/BoehmGC -DGC_THREADS"
CXXFLAGS="$CXXFLAGS -I$PWD/lib/Mvm/BoehmGC -DGC_THREADS"
AC_DEFINE([USE_GC_BOEHM], [1], [Using the boehm gc])
@@ -216,6 +218,10 @@
AC_SUBST([GC_LIBS])
+AM_CONDITIONAL([GC_BOEHM], [test "x$gc" = "xboehm"])
+AM_CONDITIONAL([GC_MULTI_MMAP], [test "x$gc" = "xmulti-mmap"])
+AM_CONDITIONAL([GC_SINGLE_MMAP], [test "x$gc" = "xsingle-mmap"])
+
dnl **************************************************************************
dnl Virtual Machine type
dnl **************************************************************************
@@ -239,6 +245,7 @@
fi
AM_CONDITIONAL([SERVICE_BUILD], [test "x$vmtype" = "xservice"])
+AM_CONDITIONAL([ISOLATE_BUILD], [test "x$vmtype" = "xmulti"])
dnl **************************************************************************
dnl GNU CLASSPATH version
@@ -321,9 +328,11 @@
lib/JnJVM/Makefile
lib/JnJVM/Classpath/Makefile
lib/JnJVM/VMCore/Makefile
+ lib/JnJVM/LLVMRuntime/Makefile
lib/JnJVM/Classpath/Classpath.h
lib/Mvm/Makefile
lib/Mvm/GCMmap2/Makefile
+ lib/Mvm/BoehmGC/Makefile
lib/Mvm/CommonThread/Makefile
lib/Mvm/Allocator/Makefile
])
Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am Thu May 15 05:48:07 2008
@@ -0,0 +1,38 @@
+all: llvmruntimecpp
+
+LLVMAS = @llvmprefix@/Release/bin/llvm-as
+LLC = @llvmprefix@/Release/bin/llc
+
+llvmruntimebc : llvmruntimell
+ $(LLVMAS) -f LLVMRuntime.ll
+
+llvmruntimecpp : llvmruntimebc
+ $(LLC) -march=cpp -cppgen=contents -f LLVMRuntime.bc
+
+LL_FILES = runtime-default.ll
+
+if ISOLATE_BUILD
+LL_FILES += runtime-isolate.ll
+endif
+
+if SERVICE_BUILD
+LL_FILES += runtime-service.ll runtime-isolate.ll runtime-multi-mmap.ll
+else
+if GC_MULTI_MMAP
+LL_FILES += runtime-multi-mmap.ll
+else
+if GC_SINGLE_MMAP
+LL_FILES += runtime-single-mmap.ll
+else
+if GC_BOEHM
+LL_FILES += runtime-boehm.ll
+endif
+endif
+endif
+endif
+
+llvmruntimell: $(LL_FILES)
+ cat $(LL_FILES) > LLVMRuntime.ll
+
+clean:
+ rm LLVMRuntime.ll LLVMRuntime.bc LLVMRuntime.cpp
Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-boehm.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-boehm.ll?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-boehm.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-boehm.ll Thu May 15 05:48:07 2008
@@ -0,0 +1,5 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;; Collector specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare %JavaObject* @gcmalloc(i32, %VT)
Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Thu May 15 05:48:07 2008
@@ -0,0 +1,135 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;; Type definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; A virtual table is an array of function pointers.
+%VT = type i32**
+
+;;; The type of internal classes. This is not complete, but we only need
+;;; the two first fields for now.
+;;; Field 1 - The VT of a class C++ object.
+;;; Field 2 - The size of instances of this class.
+;;; Field 3 - The VT of instances of this class.
+%JavaClass = type { %VT, i32, %VT }
+
+;;; The root of all Java Objects: a VT, a class and a lock.
+%JavaObject = type { %VT, %JavaClass*, i8* }
+
+;;; Types for Java arrays. A size of 0 means an undefined size.
+%JavaArray = type { %JavaObject, i32 }
+%ArrayDouble = type { %JavaObject, i32, [0 x double] }
+%ArrayFloat = type { %JavaObject, i32, [0 x float] }
+%ArrayLong = type { %JavaObject, i32, [0 x i64] }
+%ArrayObject = type { %JavaObject, i32, [0 x %JavaObject*] }
+%ArraySInt16 = type { %JavaObject, i32, [0 x i16] }
+%ArraySInt32 = type { %JavaObject, i32, [0 x i32] }
+%ArraySInt8 = type { %JavaObject, i32, [0 x i8] }
+%ArrayUInt16 = type { %JavaObject, i32, [0 x i16] }
+%ArrayUInt32 = type { %JavaObject, i32, [0 x i32] }
+%ArrayUInt8 = type { %JavaObject, i32, [0 x i8] }
+
+;;; The CacheNode type. The second field is the last called method
+%CacheNode = type { %VT, i8*, %JavaClass*, %CacheNode*, %Enveloppe* }
+
+;;; The Enveloppe type, which contains the first cache and all the info
+;;; to lookup in the constant pool.
+%Enveloppe = type { %VT, %CacheNode*, i8*, i8*, i32 }
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;; Constant calls for Jnjvm runtime internal objects field accesses ;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; initialisationCheck - Checks if the class has been initialized and
+;;; initializes if not. This is used for initialization barriers in an isolate
+;;; environment, and in some specific scenario in a single environment.
+declare %JavaClass* @initialisationCheck(%JavaClass*) readnone
+
+;;; arrayLength - Get the length of an array.
+declare i32 @arrayLength(%JavaObject*) readnone
+
+;;; getVT - Get the VT of the object.
+declare %VT @getVT(%JavaObject*) readnone
+
+;;; getClass - Get the class of an object
+declare %JavaClass* @getClass(%JavaObject*) readnone
+
+;;; getVTFromClass - Get the VT of a class from its runtime representation.
+declare %VT @getVTFromClass(%JavaClass*) readnone
+
+;;; getObjectSizeFromClass - Get the size of a class from its runtime
+;;; representation.
+declare i32 @getObjectSizeFromClass(%JavaClass*) readnone
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;; Generic Runtime methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; virtualLookup - Used for interface calls.
+declare i8* @virtualLookup(%CacheNode*, %JavaObject*)
+
+;;; multiCallNew - Allocate multi-dimensional arrays. This will go to allocation
+;;; specific methods.
+declare %JavaObject* @multiCallNew(%JavaClass*, i32, ...)
+
+;;; forceInitialisationCheck - Force to check initialization. The difference
+;;; between this function and the initialisationCheck function is that the
+;;; latter is readnone and can thus be removed.
+declare void @forceInitialisationCheck(%JavaClass*)
+
+;;; vtableLookup - Look up the offset in a virtual table of a specific
+;;; function. This function takes a class and an index to lookup in the
+;;; constant pool and returns and sets in the last argument the offset.
+declare i32 @vtableLookup(%JavaObject*, %JavaClass*, i32, i32*) readnone
+
+;;; newLookup - Look up a specific class. The function takes a class and an
+;;; index to lookup in the constant pool and returns and sets in the third
+;;; argument the found class. The last argument tells if the class has to be
+;;; initialized.
+declare %JavaClass* @newLookup(%JavaClass*, i32, %JavaClass**, i32) readnone
+
+;;; fieldLookup - Look up a specific field.
+declare i8* @fieldLookup(%JavaObject*, %JavaClass*, i32, i32, i8**, i32*)
+ readnone
+
+;;; JavaObjectAquire - This function is called when starting a synchronized
+;;; block or method.
+declare void @JavaObjectAquire(%JavaObject*)
+
+;;; JavaObjectRelease - This function is called when leaving a synchronized
+;;; block or method.
+declare void @JavaObjectRelease(%JavaObject*)
+
+;;; JavaObjectInstanceOf - Returns if a Java object implements the given class.
+declare i32 @JavaObjectInstanceOf(%JavaObject*, %JavaClass*) readnone
+
+;;; getClassDelegatee - Returns the java/lang/Class representation of the
+;;; class.
+declare %JavaObject* @getClassDelegatee(%JavaClass*) readnone
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Exception methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare void @nullPointerException()
+declare void @classCastException(%JavaObject*, %JavaClass*)
+declare void @indexOutOfBoundsException(%JavaObject*, i32)
+declare void @negativeArraySizeException(i32)
+declare void @outOfMemoryError(i32)
+
+declare void @JavaThreadThrowException(%JavaObject*)
+declare void @JavaThreadClearException()
+declare i8* @JavaThreadGetException()
+declare %JavaObject* @JavaThreadGetJavaException()
+declare i1 @JavaThreadCompareException(%JavaClass*)
+
+declare void @jniProceedPendingException()
+declare i8* @getSJLJBuffer()
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Debugging methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare void @printExecution(i32, i32, i32)
+declare void @printMethodStart(i32)
+declare void @printMethodEnd(i32)
Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll Thu May 15 05:48:07 2008
@@ -0,0 +1,10 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;; Isolate specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; getStaticInstance - Get the static instance of a class.
+declare %JavaObject* @getStaticInstance(%JavaClass*, i8*) readnone
+
+;;; runtimeUTF8ToStr - Convert the UTF8 in a string.
+declare %JavaObject* @runtimeUTF8ToStr(%ArraySInt16*)
Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-multi-mmap.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-multi-mmap.ll?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-multi-mmap.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-multi-mmap.ll Thu May 15 05:48:07 2008
@@ -0,0 +1,8 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;; Collector specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare void @MarkAndTrace(%JavaObject*, i8*)
+declare void @JavaObjectTracer(%JavaObject*, i8*)
+declare %JavaObject* @gcmalloc(i32, %VT, i8*)
+declare i8* @getCollector(i8*) readnone
Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-service.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-service.ll?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-service.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-service.ll Thu May 15 05:48:07 2008
@@ -0,0 +1,17 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;; Service specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; JavaObjectAquireInSharedDomain - This function is called when starting a
+;;; synchronized block or method inside a shared method.
+declare void @JavaObjectAquireInSharedDomain(%JavaObject*)
+
+;;; JavaObjectReleaseInSharedDomain - This function is called when leaving a
+;;; synchronized block or method inside a shared method.
+declare void @JavaObjectReleaseInSharedDomain(%JavaObject*)
+
+;;; serviceCallStart - Mark the switching between services.
+declare void @serviceCallStart(i8*, i8*)
+
+;;; serviceCallStop - Mark the switching between services.
+declare void @serviceCallStop(i8*, i8*)
Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single-mmap.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single-mmap.ll?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single-mmap.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single-mmap.ll Thu May 15 05:48:07 2008
@@ -0,0 +1,7 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;; Collector specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare void @MarkAndTrace(%JavaObject*)
+declare void @JavaObjectTracer(%JavaObject*)
+declare %JavaObject* @gcmalloc(i32, %VT)
Modified: vmkit/trunk/lib/JnJVM/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Makefile.am?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Makefile.am (original)
+++ vmkit/trunk/lib/JnJVM/Makefile.am Thu May 15 05:48:07 2008
@@ -1,5 +1,5 @@
# $Id: Makefile.am,v 1.6 2008/03/21 11:12:38 varth Exp $
-SUBDIRS = VMCore Classpath
+SUBDIRS = LLVMRuntime VMCore Classpath
EXTRA_DIST = OpcodeNames.def
bin_PROGRAMS = main
#lib_LTLIBRARIES = libjnjvm.la
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp Thu May 15 05:48:07 2008
@@ -235,10 +235,16 @@
}
char* UTF8::UTF8ToAsciiz() const {
- mvm::NativeString* buf = mvm::NativeString::alloc(size + 1);
+ /*mvm::NativeString* buf = mvm::NativeString::alloc(size + 1);
for (sint32 i = 0; i < size; ++i) {
buf->setAt(i, elements[i]);
}
buf->setAt(size, 0);
- return buf->cString();
+ return buf->cString();*/
+ char* buf = (char*)malloc(size + 1);
+ for (sint32 i = 0; i < size; ++i) {
+ buf[i] = elements[i];
+ }
+ buf[size] = 0;
+ return buf;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Thu May 15 05:48:07 2008
@@ -37,11 +37,6 @@
void CacheNode::print(mvm::PrintBuffer* buf) const {
buf->write("CacheNode<");
- if (lastCible) {
- lastCible->print(buf);
- buf->write(" -- ");
- ((mvm::Object*)((void**)methPtr - 1))->print(buf);
- }
buf->write(" in ");
enveloppe->print(buf);
buf->write(">");
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Thu May 15 05:48:07 2008
@@ -126,7 +126,6 @@
this->condVar = mvm::Cond::allocCond();
this->status = hashed;
this->isolate = isolate;
- this->dim = -1;
this->isArray = isArray;
this->_llvmVar = 0;
#ifndef MULTIPLE_VM
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Thu May 15 05:48:07 2008
@@ -75,41 +75,117 @@
class CommonClass : public mvm::Object {
public:
- JavaObject* classLoader;
-private:
- llvm::GlobalVariable* _llvmVar;
-#ifndef MULTIPLE_VM
- llvm::GlobalVariable* _llvmDelegatee;
-#endif
-public:
- static VirtualTable* VT;
- const llvm::Type * virtualType;
- const llvm::Type * staticType;
+
+ /// virtualSize - The size of instances of this class.
+ ///
+ uint32 virtualSize;
+
+ /// virtualVT - The virtual table of instances of this class.
+ ///
+ VirtualTable* virtualVT;
+
+ /// virtualTableSize - The size of the virtual table of this class.
+ ///
+ uint32 virtualTableSize;
+
+ /// virtualSizeLLVM - The LLVM constant size of instances of this class.
+ ///
+ llvm::ConstantInt* virtualSizeLLVM;
+
+ /// access - {public, private, protected}.
+ ///
+ uint32 access;
+
+ /// isArray - Is the class an array class?
+ ///
+ uint8 isArray;
+
+ /// name - The name of the class.
+ ///
const UTF8* name;
+
+ /// isolate - Which isolate defined this class.
+ ///
+ Jnjvm *isolate;
+
+ /// status - The loading/resolve/initialization state of the class.
+ ///
+ JavaState status;
+
+ /// super - The parent of this class.
+ ///
CommonClass * super;
+
+ /// superUTF8 - The name of the parent of this class.
const UTF8* superUTF8;
- std::vector<const UTF8*> interfacesUTF8;
+
+ /// interfaces - The interfaces this class implements.
+ ///
std::vector<Class*> interfaces;
+
+ /// interfacesUTF8 - The names of the interfaces this class implements.
+ ///
+ std::vector<const UTF8*> interfacesUTF8;
+
+ /// lockVar - When multiple threads want to load/resolve/initialize a class,
+ /// they must be synchronized so that these steps are only performned once
+ /// for a given class.
mvm::Lock* lockVar;
+
+ /// condVar - Used to wake threads waiting on the load/resolve/initialize process
+ /// of this class, done by another thread.
mvm::Cond* condVar;
+
+ /// classLoader - The Java class loader that loaded the class.
+ ///
+ JavaObject* classLoader;
+
+ /// _llvmVar - The LLVM global variable representing this class.
+ ///
+ llvm::GlobalVariable* _llvmVar;
+
+#ifndef MULTIPLE_VM
+ /// _llvmDelegatee - The LLVM global variable representing the
+ /// java/lang/Class instance of this class.
+ llvm::GlobalVariable* _llvmDelegatee;
+
+ /// delegatee - The java/lang/Class object representing this class
+ ///
+ JavaObject* delegatee;
+#endif
+
+ /// virtualMethods - List of all the virtual methods defined by this class.
+ /// This does not contain non-redefined super methods.
std::vector<JavaMethod*> virtualMethods;
+
+ /// staticMethods - List of all the static methods defined by this class.
+ ///
std::vector<JavaMethod*> staticMethods;
+
+ /// virtualFields - List of all the virtual fields defined in this class.
+ /// This does not contain non-redefined super fields.
std::vector<JavaField*> virtualFields;
+
+ /// staticFields - List of all the static fields defined in this class.
+ ///
std::vector<JavaField*> staticFields;
-#ifndef MULTIPLE_VM
- JavaObject* delegatee;
-#endif
+
+ /// display - The class hierarchy of supers for this class.
+ ///
std::vector<CommonClass*> display;
- unsigned int dim;
- unsigned int depth;
- bool isArray;
- JavaState status;
- unsigned int access;
- Jnjvm *isolate;
- unsigned int virtualTableSize;
- static const int MaxDisplay;
- static JavaObject* jnjvmClassLoader;
+ /// depth - The depth of this class in its class hierarchy.
+ /// display[depth - 1] contains the class.
+ uint32 depth;
+
+ /// virtualType - The LLVM type of instance of this class.
+ ///
+ const llvm::Type * virtualType;
+
+ /// staticType - The LLVM type of the static instance of this class.
+ ///
+ const llvm::Type * staticType;
+
llvm::GlobalVariable* llvmVar(llvm::Module* compilingModule);
llvm::Value* llvmDelegatee(llvm::Module* M, llvm::BasicBlock* BB);
@@ -164,6 +240,10 @@
bool isResolved() {
return status >= resolved;
}
+
+ static VirtualTable* VT;
+ static const int MaxDisplay;
+ static JavaObject* jnjvmClassLoader;
};
class Class : public CommonClass {
@@ -191,9 +271,6 @@
llvm::Value* staticVar(JavaJIT* jit);
llvm::Value* llvmVT(JavaJIT* jit);
- llvm::ConstantInt* virtualSizeLLVM;
- uint32 virtualSize;
- VirtualTable* virtualVT;
uint32 staticSize;
VirtualTable* staticVT;
JavaObject* doNew(Jnjvm* vm);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Thu May 15 05:48:07 2008
@@ -497,7 +497,8 @@
JavaIsolate *isolate= gc_new(JavaIsolate)();
#ifdef MULTIPLE_GC
- isolate->GC = Collector::allocate();
+ isolate->GC = mvm::Thread::get()->GC;
+ isolate->GC->enable(0);
#endif
isolate->classpath = getenv("CLASSPATH");
@@ -532,9 +533,6 @@
void* baseSP = mvm::Thread::get()->baseSP;
#ifdef MULTIPLE_GC
isolate->bootstrapThread->GC = isolate->GC;
-#ifndef SERVICE_VM
- isolate->GC->inject_my_thread(baseSP);
-#endif
mvm::jit::memoryManager->addGCForModule(isolate->module, isolate->GC);
#endif
isolate->bootstrapThread->baseSP = baseSP;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Thu May 15 05:48:07 2008
@@ -217,7 +217,7 @@
BasicBlock* executeBlock = createBasicBlock("execute");
endBlock = createBasicBlock("end block");
-#if defined(MULTIPLE_VM)
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
Value* lastArg = 0;
for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end();
i != e; ++i) {
@@ -415,7 +415,7 @@
uint32 index = 0;
uint32 count = 0;
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
uint32 max = args.size() - 1;
#else
uint32 max = args.size();
@@ -456,7 +456,7 @@
}
}
-#if defined(MULTIPLE_VM)
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
#if !defined(SERVICE_VM)
isolateLocal = args[args.size() - 1];
#else
@@ -582,7 +582,7 @@
uint32 index = 0;
uint32 count = 0;
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
uint32 max = func->arg_size() - 1;
#else
uint32 max = func->arg_size();
@@ -622,7 +622,7 @@
}
}
-#if defined(MULTIPLE_VM)
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
#if !defined(SERVICE_VM)
isolateLocal = i;
#else
@@ -1239,12 +1239,12 @@
void JavaJIT::makeArgs(FunctionType::param_iterator it,
uint32 index, std::vector<Value*>& Args, uint32 nb) {
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
nb++;
#endif
Args.reserve(nb + 2);
Value* args[nb];
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
args[nb - 1] = isolateLocal;
sint32 start = nb - 2;
it--;
@@ -1427,20 +1427,6 @@
if (!val) {
Function* func = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL,
signature, meth);
-#if 0//def SERVICE_VM
- bool serviceCall = false;
- if (meth && meth->classDef->classLoader != compilingClass->classLoader &&
- meth->classDef->isolate != Jnjvm::bootstrapVM){
- JavaObject* loader = meth->classDef->classLoader;
- ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
- serviceCall = true;
- std::vector<Value*> Args;
- Args.push_back(isolateLocal);
- Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock));
- CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(),
- Args.end(), "", currentBlock);
- }
-#endif
if (meth && meth->canBeInlined && meth != compilingMethod &&
inlineMethods[meth] == 0) {
@@ -1449,18 +1435,6 @@
val = invoke(func, args, "", currentBlock);
}
-#if 0//def SERVICE_VM
- if (serviceCall) {
- JavaObject* loader = meth->classDef->classLoader;
- ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
- serviceCall = true;
- std::vector<Value*> Args;
- Args.push_back(isolateLocal);
- Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock));
- CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(),
- Args.end(), "", currentBlock);
- }
-#endif
}
const llvm::Type* retType = signature->virtualType->getReturnType();
@@ -1507,20 +1481,6 @@
}
#endif
-#if 0//def SERVICE_VM
- bool serviceCall = false;
- if (meth && meth->classDef->classLoader != compilingClass->classLoader &&
- meth->classDef->isolate != Jnjvm::bootstrapVM){
- JavaObject* loader = meth->classDef->classLoader;
- ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
- serviceCall = true;
- std::vector<Value*> Args;
- Args.push_back(isolateLocal);
- Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock));
- CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(),
- Args.end(), "", currentBlock);
- }
-#endif
if (meth && meth->canBeInlined && meth != compilingMethod &&
inlineMethods[meth] == 0) {
@@ -1529,17 +1489,6 @@
val = invoke(func, args, "", currentBlock);
}
-#if 0//def SERVICE_VM
- if (serviceCall) {
- JavaObject* loader = meth->classDef->classLoader;
- ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
- std::vector<Value*> Args;
- Args.push_back(isolateLocal);
- Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock));
- CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(), Args.end(), "",
- currentBlock);
- }
-#endif
}
const llvm::Type* retType = signature->staticType->getReturnType();
@@ -1552,23 +1501,22 @@
}
Value* JavaJIT::getResolvedClass(uint16 index, bool clinit) {
- const Type* PtrTy = mvm::jit::ptrType;
compilingClass->isolate->protectModule->lock();
GlobalVariable * gv =
- new GlobalVariable(PtrTy, false,
+ new GlobalVariable(JavaClassType, false,
GlobalValue::ExternalLinkage,
- mvm::jit::constantPtrNull, "",
+ constantJavaClassNull, "",
compilingClass->isolate->module);
compilingClass->isolate->protectModule->unlock();
Value* arg1 = new LoadInst(gv, "", false, currentBlock);
Value* test = new ICmpInst(ICmpInst::ICMP_EQ, arg1,
- mvm::jit::constantPtrNull, "", currentBlock);
+ constantJavaClassNull, "", currentBlock);
BasicBlock* trueCl = createBasicBlock("Cl OK");
BasicBlock* falseCl = createBasicBlock("Cl Not OK");
- PHINode* node = llvm::PHINode::Create(PtrTy, "", trueCl);
+ PHINode* node = llvm::PHINode::Create(JavaClassType, "", trueCl);
node->addIncoming(arg1, currentBlock);
llvm::BranchInst::Create(falseCl, trueCl, test, currentBlock);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Thu May 15 05:48:07 2008
@@ -213,7 +213,7 @@
uint16 maxLocals;
uint32 codeLen;
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
llvm::Value* isolateLocal;
#endif
@@ -285,6 +285,8 @@
#endif
static const llvm::Type* VTType;
+ static const llvm::Type* JavaClassType;
+ static llvm::Constant* constantJavaClassNull;
static llvm::Constant* constantJavaObjectNull;
static llvm::Constant* constantUTF8Null;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Thu May 15 05:48:07 2008
@@ -9,9 +9,11 @@
#include <stddef.h>
+#include "llvm/CallingConv.h"
#include "llvm/Instructions.h"
#include "llvm/LinkAllPasses.h"
#include "llvm/Module.h"
+#include "llvm/ParameterAttributes.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Support/MutexGuard.h"
@@ -59,45 +61,30 @@
mvm::jit::protectEngine->unlock();
}
+#include "LLVMRuntime.cpp"
+
void JavaJIT::initialiseJITBootstrapVM(Jnjvm* vm) {
- //llvm::PrintMachineCode = true;
Module* module = vm->module;
mvm::jit::protectEngine->lock();
mvm::jit::executionEngine->addModuleProvider(vm->TheModuleProvider);
mvm::jit::protectEngine->unlock();
-
-
- mvm::jit::protectTypes();//->lock();
- // Create JavaObject::llvmType
- const llvm::Type* Pty = mvm::jit::ptrType;
- VTType = PointerType::getUnqual(PointerType::getUnqual(Type::Int32Ty));
-
- std::vector<const llvm::Type*> objectFields;
- objectFields.push_back(VTType); // VT
- objectFields.push_back(Pty); // Class
- objectFields.push_back(Pty); // Lock
+ mvm::jit::protectTypes();
+ makeLLVMModuleContents(module);
+
+ VTType = module->getTypeByName("VT");
+
JavaObject::llvmType =
- llvm::PointerType::getUnqual(llvm::StructType::get(objectFields, false));
+ PointerType::getUnqual(module->getTypeByName("JavaObject"));
- // Create JavaArray::llvmType
- {
- std::vector<const llvm::Type*> arrayFields;
- arrayFields.push_back(JavaObject::llvmType->getContainedType(0));
- arrayFields.push_back(llvm::Type::Int32Ty);
JavaArray::llvmType =
- llvm::PointerType::getUnqual(llvm::StructType::get(arrayFields, false));
- }
-
-#define ARRAY_TYPE(name, type) \
- { \
- std::vector<const Type*> arrayFields; \
- arrayFields.push_back(JavaObject::llvmType->getContainedType(0)); \
- arrayFields.push_back(Type::Int32Ty); \
- arrayFields.push_back(ArrayType::get(type, 0)); \
- name::llvmType = PointerType::getUnqual(StructType::get(arrayFields, false)); \
- }
+ PointerType::getUnqual(module->getTypeByName("JavaArray"));
+
+ JavaClassType =
+ PointerType::getUnqual(module->getTypeByName("JavaClass"));
+#define ARRAY_TYPE(name, type) \
+ name::llvmType = PointerType::getUnqual(module->getTypeByName(#name));
ARRAY_TYPE(ArrayUInt8, Type::Int8Ty);
ARRAY_TYPE(ArraySInt8, Type::Int8Ty);
ARRAY_TYPE(ArrayUInt16, Type::Int16Ty);
@@ -108,603 +95,94 @@
ARRAY_TYPE(ArrayDouble, Type::DoubleTy);
ARRAY_TYPE(ArrayFloat, Type::FloatTy);
ARRAY_TYPE(ArrayObject, JavaObject::llvmType);
-
#undef ARRAY_TYPE
- // Create CacheNode::llvmType
- {
- std::vector<const llvm::Type*> arrayFields;
- arrayFields.push_back(mvm::jit::ptrType); // VT
- arrayFields.push_back(mvm::jit::ptrType); // methPtr
- arrayFields.push_back(mvm::jit::ptrType); // lastCible
- arrayFields.push_back(mvm::jit::ptrType); // next
- arrayFields.push_back(mvm::jit::ptrType); // enveloppe
CacheNode::llvmType =
- PointerType::getUnqual(StructType::get(arrayFields, false));
- }
+ PointerType::getUnqual(module->getTypeByName("CacheNode"));
- // Create Enveloppe::llvmType
- {
- std::vector<const llvm::Type*> arrayFields;
- arrayFields.push_back(mvm::jit::ptrType); // VT
- arrayFields.push_back(CacheNode::llvmType); // firstCache
- arrayFields.push_back(mvm::jit::ptrType); // ctpInfo
- arrayFields.push_back(mvm::jit::ptrType); // cacheLock
- arrayFields.push_back(Type::Int32Ty); // index
Enveloppe::llvmType =
- PointerType::getUnqual(StructType::get(arrayFields, false));
- }
+ PointerType::getUnqual(module->getTypeByName("Enveloppe"));
-
- // Create javaObjectTracerLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
-#ifdef MULTIPLE_GC
- args.push_back(mvm::jit::ptrType);
-#endif
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
- javaObjectTracerLLVM = Function::Create(type,
- GlobalValue::ExternalLinkage,
- "JavaObjectTracer",
- module);
- }
-
- // Create virtualLookupLLVM
- {
- std::vector<const Type*> args;
- //args.push_back(JavaObject::llvmType);
- //args.push_back(mvm::jit::ptrType);
- //args.push_back(llvm::Type::Int32Ty);
- args.push_back(CacheNode::llvmType);
- args.push_back(JavaObject::llvmType);
- const FunctionType* type =
- FunctionType::get(mvm::jit::ptrType, args, false);
-
- virtualLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "virtualLookup",
- module);
- }
-
- // Create multiCallNewLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
- true);
-
- multiCallNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "multiCallNew",
- module);
- }
-
- // Create initialisationCheckLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
- false);
-
- initialisationCheckLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "initialisationCheck",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- initialisationCheckLLVM->setParamAttrs(func_toto_PAL);
- }
- // Create forceInitialisationCheckLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args,
- false);
-
- forceInitialisationCheckLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "forceInitialisationCheck",
- module);
- }
-
-
- // Create arrayLengthLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false);
-
- arrayLengthLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "arrayLength",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- arrayLengthLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create getVTLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- const FunctionType* type = FunctionType::get(
- PointerType::getUnqual(PointerType::getUnqual(Type::Int32Ty)),
- args, false);
-
- getVTLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getVT",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- getVTLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create getClassLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false);
-
- getClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getClass",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- getClassLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create newLookupLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- args.push_back(Type::Int32Ty);
- args.push_back(PointerType::getUnqual(mvm::jit::ptrType));
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
- false);
-
- newLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "newLookup",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- newLookupLLVM->setParamAttrs(func_toto_PAL);
- }
-
-#ifdef MULTIPLE_GC
- // Create getCollectorLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
- false);
-
- getCollectorLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getCollector",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- getCollectorLLVM->setParamAttrs(func_toto_PAL);
- }
-#endif
-
- // Create getVTFromClassLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(VTType, args,
- false);
-
- getVTFromClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getVTFromClass",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- getVTFromClassLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create getSizeFromClassLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(Type::Int32Ty, args,
- false);
-
- getObjectSizeFromClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getObjectSizeFromClass",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- getObjectSizeFromClassLLVM->setParamAttrs(func_toto_PAL);
- }
-
-#ifndef WITHOUT_VTABLE
- // Create vtableLookupLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType); // obj
- args.push_back(mvm::jit::ptrType); // cl
- args.push_back(Type::Int32Ty); // index
- args.push_back(PointerType::getUnqual(Type::Int32Ty)); // vtable index
- const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false);
-
- vtableLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "vtableLookup", module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- vtableLookupLLVM->setParamAttrs(func_toto_PAL);
- }
-#endif
+ mvm::jit::unprotectTypes();
- // Create fieldLookupLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- args.push_back(mvm::jit::ptrType);
- args.push_back(llvm::Type::Int32Ty);
- args.push_back(llvm::Type::Int32Ty);
- args.push_back(PointerType::getUnqual(mvm::jit::ptrType));
- args.push_back(PointerType::getUnqual(llvm::Type::Int32Ty));
- const FunctionType* type =
- FunctionType::get(mvm::jit::ptrType, args,
- false);
-
- fieldLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "fieldLookup",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- fieldLookupLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create nullPointerExceptionLLVM
- {
- std::vector<const Type*> args;
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- nullPointerExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "nullPointerException",
- module);
- }
-
- // Create classCastExceptionLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- classCastExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "classCastException",
- module);
- }
-
- // Create indexOutOfBoundsExceptionLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- indexOutOfBoundsExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "indexOutOfBoundsException",
- module);
- }
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
-
- negativeArraySizeExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "negativeArraySizeException",
- module);
-
- outOfMemoryErrorLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "outOfMemoryError",
- module);
- }
-
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int32Ty);
- args.push_back(VTType);
-#ifdef MULTIPLE_GC
- args.push_back(mvm::jit::ptrType);
-#endif
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false);
-
-
- javaObjectAllocateLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "gcmalloc",
- module);
- }
-
- // Create proceedPendingExceptionLLVM
- {
- std::vector<const Type*> args;
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- jniProceedPendingExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "jniProceedPendingException",
- module);
- }
-
- // Create printExecutionLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int32Ty);
- args.push_back(Type::Int32Ty);
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printExecutionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "printExecution",
- module);
- }
-
- // Create printMethodStartLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printMethodStartLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "printMethodStart",
- module);
- }
-
- // Create printMethodEndLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printMethodEndLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "printMethodEnd",
- module);
- }
-
- // Create throwExceptionLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- throwExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaThreadThrowException",
- module);
- }
-
- // Create clearExceptionLLVM
- {
- std::vector<const Type*> args;
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- clearExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaThreadClearException",
- module);
- }
-
-
-
- // Create getExceptionLLVM
- {
- std::vector<const Type*> args;
- const FunctionType* type = FunctionType::get(mvm::jit::ptrType,
- args, false);
-
- getExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaThreadGetException",
- module);
- }
-
- // Create getJavaExceptionLLVM
- {
- std::vector<const Type*> args;
- const FunctionType* type = FunctionType::get(JavaObject::llvmType,
- args, false);
-
- getJavaExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaThreadGetJavaException",
- module);
- }
-
- // Create compareExceptionLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(Type::Int1Ty, args, false);
-
- compareExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaThreadCompareException",
- module);
- }
-
- // Create getStaticInstanceLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType); // cl
- args.push_back(mvm::jit::ptrType); // vm
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false);
-
- getStaticInstanceLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getStaticInstance",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- getStaticInstanceLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create getClassDelegateeLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false);
-
- getClassDelegateeLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getClassDelegatee",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- getClassDelegateeLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create instanceOfLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false);
-
- instanceOfLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaObjectInstanceOf",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- instanceOfLLVM->setParamAttrs(func_toto_PAL);
- }
-
- // Create aquireObjectLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- aquireObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaObjectAquire",
- module);
-#ifdef SERVICE_VM
- aquireObjectInSharedDomainLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "aquireObjectInSharedDomain",
- module);
+ virtualLookupLLVM = module->getFunction("virtualLookup");
+ multiCallNewLLVM = module->getFunction("multiCallNew");
+ initialisationCheckLLVM = module->getFunction("initialisationCheck");
+ forceInitialisationCheckLLVM =
+ module->getFunction("forceInitialisationCheck");
+
+ arrayLengthLLVM = module->getFunction("arrayLength");
+ getVTLLVM = module->getFunction("getVT");
+ getClassLLVM = module->getFunction("getClass");
+ newLookupLLVM = module->getFunction("newLookup");
+ getVTFromClassLLVM = module->getFunction("getVTFromClass");
+ getObjectSizeFromClassLLVM = module->getFunction("getObjectSizeFromClass");
+
+ getClassDelegateeLLVM = module->getFunction("getClassDelegatee");
+ instanceOfLLVM = module->getFunction("JavaObjectInstanceOf");
+ aquireObjectLLVM = module->getFunction("JavaObjectAquire");
+ releaseObjectLLVM = module->getFunction("JavaObjectRelease");
+
+ fieldLookupLLVM = module->getFunction("fieldLookup");
+
+ getExceptionLLVM = module->getFunction("JavaThreadGetException");
+ getJavaExceptionLLVM = module->getFunction("JavaThreadGetJavaException");
+ compareExceptionLLVM = module->getFunction("JavaThreadCompareException");
+ jniProceedPendingExceptionLLVM =
+ module->getFunction("jniProceedPendingException");
+ getSJLJBufferLLVM = module->getFunction("getSJLJBuffer");
+
+ nullPointerExceptionLLVM = module->getFunction("nullPointerException");
+ classCastExceptionLLVM = module->getFunction("classCastException");
+ indexOutOfBoundsExceptionLLVM =
+ module->getFunction("indexOutOfBoundsException");
+ negativeArraySizeExceptionLLVM =
+ module->getFunction("negativeArraySizeException");
+ outOfMemoryErrorLLVM = module->getFunction("outOfMemoryError");
+
+ javaObjectAllocateLLVM = module->getFunction("gcmalloc");
+
+ printExecutionLLVM = module->getFunction("printExecution");
+ printMethodStartLLVM = module->getFunction("printMethodStart");
+ printMethodEndLLVM = module->getFunction("printMethodEnd");
+
+ throwExceptionLLVM = module->getFunction("JavaThreadThrowException");
+
+ clearExceptionLLVM = module->getFunction("JavaThreadClearException");
+
+
+#ifdef MULTIPLE_VM
+ getStaticInstanceLLVM = module->getFunction("getStaticInstance");
+ runtimeUTF8ToStrLLVM = module->getFunction("runtimeUTF8ToStr");
#endif
- }
- // Create releaseObjectLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- releaseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "JavaObjectRelease",
- module);
#ifdef SERVICE_VM
- releaseObjectInSharedDomainLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "releaseObjectInSharedDomain",
- module);
+ aquireObjectInSharedDomainLLVM =
+ module->getFunction("JavaObjectAquireInSharedDomain");
+ releaseObjectInSharedDomainLLVM =
+ module->getFunction("JavaObjectReleaseInSharedDomain");
+ ServiceDomain::serviceCallStartLLVM = module->getFunction("serviceCallStart");
+ ServiceDomain::serviceCallStopLLVM = module->getFunction("serviceCallStop");
#endif
- }
-
-
- {
- std::vector<const Type*> args;
- args.push_back(ArrayUInt16::llvmType);
- FunctionType* FuncTy = FunctionType::get(
- /*Result=*/JavaObject::llvmType,
- /*Params=*/args,
- /*isVarArg=*/false);
- runtimeUTF8ToStrLLVM = Function::Create(FuncTy, GlobalValue::ExternalLinkage,
- "runtimeUTF8ToStr", module);
- }
-
-
- // Create getSJLJBufferLLVM
- {
- std::vector<const Type*> args;
- const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
- false);
-
- getSJLJBufferLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getSJLJBuffer",
- module);
- }
-
#ifdef WITH_TRACER
- // Create markAndTraceLLVM
- {
- std::vector<const Type*> args;
- args.push_back(JavaObject::llvmType);
-#ifdef MULTIPLE_GC
- args.push_back(mvm::jit::ptrType);
+ markAndTraceLLVM = module->getFunction("MarkAndTrace");
+ markAndTraceLLVMType = markAndTraceLLVM->getFunctionType();
+ javaObjectTracerLLVM = module->getFunction("JavaObjectTracer");
#endif
- markAndTraceLLVMType = FunctionType::get(llvm::Type::VoidTy, args, false);
- markAndTraceLLVM = Function::Create(markAndTraceLLVMType,
- GlobalValue::ExternalLinkage,
- "MarkAndTrace",
- module);
- }
+
+#ifndef WITHOUT_VTABLE
+ vtableLookupLLVM = module->getFunction("vtableLookup");
#endif
-#ifdef SERVICE_VM
- // Create serviceCallStart/Stop
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- args.push_back(mvm::jit::ptrType);
- const FunctionType* type = FunctionType::get(llvm::Type::VoidTy, args, false);
- ServiceDomain::serviceCallStartLLVM =
- Function::Create(type, GlobalValue::ExternalLinkage, "serviceCallStart",
- module);
-
- ServiceDomain::serviceCallStopLLVM =
- Function::Create(type, GlobalValue::ExternalLinkage, "serviceCallStop",
- module);
- }
+
+#ifdef MULTIPLE_GC
+ getCollectorLLVM = module->getFunction("getCollector");
#endif
- mvm::jit::unprotectTypes();//->unlock();
- mvm::jit::protectConstants();//->lock();
+
+
+ mvm::jit::protectConstants();
constantUTF8Null = Constant::getNullValue(ArrayUInt16::llvmType);
+ constantJavaClassNull = Constant::getNullValue(JavaClassType);
constantJavaObjectNull = Constant::getNullValue(JavaObject::llvmType);
constantMaxArraySize = ConstantInt::get(Type::Int32Ty,
JavaArray::MaxArraySize);
@@ -728,25 +206,23 @@
GlobalValue::ExternalLinkage,
cons, "",
module);
- {
- Class fake;
- int offset = (intptr_t)&(fake.virtualSize) - (intptr_t)&fake;
- constantOffsetObjectSizeInClass = ConstantInt::get(Type::Int32Ty, offset);
- offset = (intptr_t)&(fake.virtualVT) - (intptr_t)&fake;
- constantOffsetVTInClass = ConstantInt::get(Type::Int32Ty, offset);
- }
-
- mvm::jit::unprotectConstants();//->unlock();
+ mvm::jit::unprotectConstants();
+
+ constantOffsetObjectSizeInClass = mvm::jit::constantOne;
+ constantOffsetVTInClass = mvm::jit::constantTwo;
+
}
llvm::Constant* JavaJIT::constantJavaObjectNull;
llvm::Constant* JavaJIT::constantUTF8Null;
+llvm::Constant* JavaJIT::constantJavaClassNull;
llvm::Constant* JavaJIT::constantMaxArraySize;
llvm::Constant* JavaJIT::constantJavaObjectSize;
llvm::GlobalVariable* JavaJIT::JavaObjectVT;
llvm::GlobalVariable* JavaJIT::ArrayObjectVT;
llvm::ConstantInt* JavaJIT::constantOffsetObjectSizeInClass;
llvm::ConstantInt* JavaJIT::constantOffsetVTInClass;
+const llvm::Type* JavaJIT::JavaClassType;
namespace mvm {
@@ -787,7 +263,6 @@
addPass(PM, createLICMPass()); // Hoist loop invariants
addPass(PM, createLoopUnswitchPass()); // Unswitch loops.
addPass(PM, createLoopIndexSplitPass()); // Index split loops.
- addPass(PM, createInstructionCombiningPass()); // Clean up after LICM/reassoc
addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars
addPass(PM, createLoopDeletionPass()); // Delete dead loops
addPass(PM, createLoopUnrollPass()); // Unroll small loops
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Thu May 15 05:48:07 2008
@@ -78,16 +78,15 @@
return _llvmVar;
}
#endif
- const Type* pty = mvm::jit::ptrType;
mvm::jit::protectConstants();//->lock();
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
- pty);
+ JavaJIT::JavaClassType);
mvm::jit::unprotectConstants();//->unlock();
isolate->protectModule->lock();
- _llvmVar = new GlobalVariable(pty, true,
+ _llvmVar = new GlobalVariable(JavaJIT::JavaClassType, true,
GlobalValue::ExternalLinkage,
cons, "",
isolate->module);
@@ -834,7 +833,7 @@
BasicBlock* currentBlock = BasicBlock::Create("enter", res);
Function::arg_iterator i = res->arg_begin();
Value *obj, *ptr, *func;
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
Value* vm = i;
#endif
++i;
@@ -862,7 +861,7 @@
}
}
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
Args.push_back(vm);
#endif
@@ -889,7 +888,7 @@
BasicBlock* currentBlock = BasicBlock::Create("enter", res);
Function::arg_iterator i = res->arg_begin();
Value *obj, *ap, *func;
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
Value* vm = i;
#endif
++i;
@@ -908,7 +907,7 @@
Args.push_back(new VAArgInst(ap, (*i)->funcs->llvmType, "", currentBlock));
}
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
Args.push_back(vm);
#endif
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Thu May 15 05:48:07 2008
@@ -24,6 +24,10 @@
#include "Jnjvm.h"
#include "LockedMap.h"
+#ifdef SERVICE_VM
+#include "ServiceDomain.h"
+#endif
+
using namespace jnjvm;
#ifdef WITH_TRACER
@@ -94,10 +98,10 @@
ctpInfo->resolveInterfaceOrMethod(index, cl, utf8, sign);
+ enveloppe->cacheLock->lock();
CacheNode* rcache = 0;
CacheNode* tmp = enveloppe->firstCache;
CacheNode* last = tmp;
- enveloppe->cacheLock->lock();
while (tmp) {
if (ocl == tmp->lastCible) {
@@ -356,11 +360,11 @@
}
#ifdef SERVICE_VM
-extern "C" void aquireObjectInSharedDomain(JavaObject* obj) {
- myLock(obj)->aquire();
+extern "C" void JavaObjectAquireInSharedDomain(JavaObject* obj) {
+ LockObj::myLock(obj)->aquire();
}
-extern "C" void releaseObjectInSharedDomain(JavaObject* obj) {
+extern "C" void JavaObjectReleaseInSharedDomain(JavaObject* obj) {
verifyNull(obj);
obj->lockObj->release();
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Thu May 15 05:48:07 2008
@@ -479,7 +479,7 @@
llvmArgs.push_back(args->at(i)->funcs->llvmType);
}
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
llvmArgs.push_back(mvm::jit::ptrType); // domain
#endif
@@ -502,7 +502,7 @@
llvmArgs.push_back(args->at(i)->funcs->llvmType);
}
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
llvmArgs.push_back(mvm::jit::ptrType); // domain
#endif
@@ -526,7 +526,7 @@
llvmArgs.push_back(args->at(i)->funcs->llvmType);
}
-#ifdef MULTIPLE_VM
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
llvmArgs.push_back(mvm::jit::ptrType); // domain
#endif
Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Thu May 15 05:48:07 2008
@@ -83,22 +83,21 @@
Changed = true;
Value* val = CI->getOperand(1);
std::vector<Value*> indexes;
+ indexes.push_back(mvm::jit::constantZero);
indexes.push_back(jnjvm::JavaJIT::constantOffsetVTInClass);
Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
- VTPtr = new BitCastInst(VTPtr, mvm::jit::ptrPtrType, "", CI);
Value* VT = new LoadInst(VTPtr, "", CI);
- VT = new BitCastInst(VT, jnjvm::JavaJIT::VTType, "", CI);
CI->replaceAllUsesWith(VT);
CI->eraseFromParent();
} else if (V == jnjvm::JavaJIT::getObjectSizeFromClassLLVM) {
Changed = true;
Value* val = CI->getOperand(1);
std::vector<Value*> indexes;
+ indexes.push_back(mvm::jit::constantZero);
indexes.push_back(jnjvm::JavaJIT::constantOffsetObjectSizeInClass);
Value* SizePtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
- SizePtr = new BitCastInst(SizePtr, mvm::jit::ptr32Type, "", CI);
Value* Size = new LoadInst(SizePtr, "", CI);
CI->replaceAllUsesWith(Size);
CI->eraseFromParent();
Modified: vmkit/trunk/lib/JnJVM/VMCore/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Makefile.am?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Makefile.am (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Thu May 15 05:48:07 2008
@@ -19,4 +19,4 @@
libJnJVM_la_SOURCES += ServiceDomain.cpp
endif
-libJnJVM_la_CXXFLAGS =-DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2
+libJnJVM_la_CXXFLAGS =-DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 -I../LLVMRuntime
Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Thu May 15 05:48:07 2008
@@ -86,6 +86,9 @@
service->functions = vm_new(service, FunctionMap)();
service->functionDefs = vm_new(service, FunctionDefMap)();
service->module = new llvm::Module("Service Domain");
+ std::string str =
+ mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
+ service->module->setDataLayout(str);
service->protectModule = mvm::Lock::allocNormal();
service->TheModuleProvider = new JnjvmModuleProvider(service->module,
service->functions,
Added: vmkit/trunk/lib/Mvm/BoehmGC/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/BoehmGC/Makefile.am?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/BoehmGC/Makefile.am (added)
+++ vmkit/trunk/lib/Mvm/BoehmGC/Makefile.am Thu May 15 05:48:07 2008
@@ -0,0 +1,6 @@
+noinst_LIBRARIES = libuvm_gc_boehm.a
+
+libuvm_gc_boehm_a_SOURCES = gc.cpp
+libuvm_gc_boehm_a_CXXFLAGS = -O2 -W -Wall -ansi -pedantic -Wno-unused-parameter -Wno-variadic-macros
+
+CLEANFILES = *~ *.bak .*.sw?
Modified: vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h Thu May 15 05:48:07 2008
@@ -77,10 +77,7 @@
typedef void (*markerFn)(void*);
- static void initialise(markerFn mark, void *base_sp) {
- mvm::Thread::get()->baseSP = base_sp;
- GC_INIT();
- }
+ static void initialise(markerFn mark, void *base_sp);
static void destroy() {}
static void die_if_sigsegv_occured_during_collection(void *addr){}
@@ -110,10 +107,7 @@
GC_gcollect();
}
- static void inject_my_thread(void *sp) {
- mvm::Thread::get()->baseSP = base_sp;
- GC_init();
- }
+ static void inject_my_thread(void *sp);
static void remove_my_thread() {}
static Collector* allocate() { return 0; }
Added: vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp?rev=51144&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp (added)
+++ vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp Thu May 15 05:48:07 2008
@@ -0,0 +1,27 @@
+//===------------ gc.cc - Boehm GC Garbage Collector ----------------------===//
+//
+// Mvm
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MvmGC.h"
+#include "mvm/Threads/Thread.h"
+
+using namespace mvm;
+
+void Collector::inject_my_thread(void* base_sp) {
+ mvm::Thread::get()->baseSP = base_sp;
+ GC_init();
+}
+
+void Collector::initialise(markerFn mark, void *base_sp) {
+ mvm::Thread::get()->baseSP = base_sp;
+ GC_INIT();
+}
+
+extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT) {
+ return (gc*)gc::operator new(sz, VT);
+}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Thu May 15 05:48:07 2008
@@ -234,20 +234,20 @@
if(!loc) /* a key is being destroyed */
COLLECTOR threads->another_mark();
else {
- register unsigned int **cur = (unsigned int **)&cur;
- register unsigned int **max = loc->base_sp();
+ register unsigned int **cur = (unsigned int **)&cur;
+ register unsigned int **max = loc->base_sp();
- GCChunkNode *node;
+ GCChunkNode *node;
- for(; cur<max; cur++) {
- if((node = o2node(*cur)) && (!COLLECTOR isMarked(node))) {
- node->remove();
- node->append(COLLECTOR used_nodes);
- COLLECTOR mark(node);
- }
- }
+ for(; cur<max; cur++) {
+ if((node = o2node(*cur)) && (!COLLECTOR isMarked(node))) {
+ node->remove();
+ node->append(COLLECTOR used_nodes);
+ COLLECTOR mark(node);
+ }
+ }
- COLLECTOR threads->another_mark();
+ COLLECTOR threads->another_mark();
COLLECTOR threads->waitCollection();
}
COLLECTOR threads->stackUnlock();
Modified: vmkit/trunk/lib/Mvm/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Makefile.am?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/Makefile.am Thu May 15 05:48:07 2008
@@ -1,5 +1,5 @@
-SUBDIRS = CommonThread Allocator GCMmap2
-DIST_SUBDIRS = CommonThread Allocator GCMmap2
+SUBDIRS = CommonThread Allocator GCMmap2 BoehmGC
+DIST_SUBDIRS = CommonThread Allocator GCMmap2 BoehmGC
bin_PROGRAMS = main
Modified: vmkit/trunk/lib/Mvm/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Object.cpp?rev=51144&r1=51143&r2=51144&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Object.cpp Thu May 15 05:48:07 2008
@@ -19,17 +19,6 @@
using namespace mvm;
-
-#ifdef USE_GC_BOEHM
-#ifdef MULTIPLE_GC
-extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT, Collector* GC) {
-#else
-extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT) {
-#endif
- return (gc*)gc::operator new(sz, VT);
-}
-#endif
-
VirtualTable *Object::VT = 0;
VirtualTable *Method::VT = 0;
VirtualTable *Code::VT = 0;
More information about the llvm-commits
mailing list