[vmkit-commits] [vmkit] r120424 - in /vmkit/branches/multi-vm: ./ autoconf/ include/j3/ include/mvm/ include/mvm/GC/ include/mvm/Threads/ lib/J3/Classpath/ lib/J3/Compiler/ lib/J3/LLVMRuntime/ lib/J3/VMCore/ lib/Mvm/CommonThread/ lib/Mvm/Compiler/ lib/Mvm/GCMmap2/ lib/Mvm/MMTk/ lib/Mvm/Runtime/ mmtk/ mmtk/config/copyms/ mmtk/config/marksweep/ mmtk/inline/ mmtk/java/ mmtk/java/src/org/j3/config/ mmtk/java/src/org/j3/mmtk/ mmtk/mmtk-alloc/ mmtk/mmtk-j3/ tools/j3/ tools/llcj/ tools/vmjc/ tools/vmkit/ www/ www/releases/
Gael Thomas
gael.thomas at lip6.fr
Tue Nov 30 04:21:30 PST 2010
Author: gthomas
Date: Tue Nov 30 06:21:29 2010
New Revision: 120424
URL: http://llvm.org/viewvc/llvm-project?rev=120424&view=rev
Log:
Merge the trunk inside the multi-vm branch
Added:
vmkit/branches/multi-vm/include/mvm/Threads/ObjectLocks.h
- copied unchanged from r120292, vmkit/trunk/include/mvm/Threads/ObjectLocks.h
vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp
- copied, changed from r120292, vmkit/trunk/lib/J3/VMCore/ReferenceQueue.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h
- copied, changed from r120292, vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h
vmkit/branches/multi-vm/lib/Mvm/CommonThread/ObjectLocks.cpp
- copied unchanged from r120292, vmkit/trunk/lib/Mvm/CommonThread/ObjectLocks.cpp
vmkit/branches/multi-vm/mmtk/inline/ (props changed)
- copied from r120292, vmkit/trunk/mmtk/inline/
vmkit/branches/multi-vm/mmtk/inline/InlineMethods.cpp
- copied unchanged from r120292, vmkit/trunk/mmtk/inline/InlineMethods.cpp
vmkit/branches/multi-vm/mmtk/inline/Makefile
- copied unchanged from r120292, vmkit/trunk/mmtk/inline/Makefile
vmkit/branches/multi-vm/mmtk/java/src/org/j3/config/ (props changed)
- copied from r120292, vmkit/trunk/mmtk/java/src/org/j3/config/
vmkit/branches/multi-vm/mmtk/java/src/org/j3/config/Selected.java.in
- copied unchanged from r120292, vmkit/trunk/mmtk/java/src/org/j3/config/Selected.java.in
vmkit/branches/multi-vm/mmtk/mmtk-j3/MMTkObject.h
- copied unchanged from r120292, vmkit/trunk/mmtk/mmtk-j3/MMTkObject.h
Removed:
vmkit/branches/multi-vm/include/mvm/CompilationUnit.h
vmkit/branches/multi-vm/lib/J3/VMCore/JavaInitialise.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.h
vmkit/branches/multi-vm/mmtk/config/copyms/Selected.java
vmkit/branches/multi-vm/mmtk/config/marksweep/Selected.java
vmkit/branches/multi-vm/mmtk/java/build.xml.in
Modified:
vmkit/branches/multi-vm/ (props changed)
vmkit/branches/multi-vm/Makefile.common.in
vmkit/branches/multi-vm/Makefile.config.in
vmkit/branches/multi-vm/Makefile.rules
vmkit/branches/multi-vm/autoconf/configure.ac
vmkit/branches/multi-vm/configure
vmkit/branches/multi-vm/include/j3/J3Intrinsics.h
vmkit/branches/multi-vm/include/j3/JavaAOTCompiler.h
vmkit/branches/multi-vm/include/j3/JavaCompiler.h
vmkit/branches/multi-vm/include/j3/JavaJITCompiler.h
vmkit/branches/multi-vm/include/j3/JavaLLVMCompiler.h
vmkit/branches/multi-vm/include/j3/LLVMMaterializer.h
vmkit/branches/multi-vm/include/mvm/GC/GC.h
vmkit/branches/multi-vm/include/mvm/JIT.h
vmkit/branches/multi-vm/include/mvm/MethodInfo.h
vmkit/branches/multi-vm/include/mvm/Threads/CollectionRV.h
vmkit/branches/multi-vm/include/mvm/Threads/Locks.h
vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
vmkit/branches/multi-vm/include/mvm/VirtualMachine.h
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMRuntime.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystemProperties.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThrowable.inc
vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/ExceptionsCheck.inc
vmkit/branches/multi-vm/lib/J3/Compiler/J3Intrinsics.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.h
vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITOpcodes.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/JavaLLVMCompiler.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/LLVMInfo.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/LLVMMaterializer.cpp
vmkit/branches/multi-vm/lib/J3/Compiler/LowerConstantCalls.cpp
vmkit/branches/multi-vm/lib/J3/LLVMRuntime/runtime-default.ll
vmkit/branches/multi-vm/lib/J3/VMCore/JavaArray.h
vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.h
vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.h
vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.h
vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaString.h
vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.h
vmkit/branches/multi-vm/lib/J3/VMCore/LockedMap.h
vmkit/branches/multi-vm/lib/J3/VMCore/Reader.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/Reader.h
vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/Zip.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/Zip.h
vmkit/branches/multi-vm/lib/Mvm/CommonThread/CollectionRV.cpp
vmkit/branches/multi-vm/lib/Mvm/CommonThread/Sigsegv.cpp
vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctlock.cpp
vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
vmkit/branches/multi-vm/lib/Mvm/Compiler/JIT.cpp
vmkit/branches/multi-vm/lib/Mvm/Compiler/LoopSafePoints.cpp
vmkit/branches/multi-vm/lib/Mvm/Compiler/VmkitGC.cpp
vmkit/branches/multi-vm/lib/Mvm/Compiler/mvm-runtime.ll
vmkit/branches/multi-vm/lib/Mvm/GCMmap2/ObjectHeader.h
vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp
vmkit/branches/multi-vm/lib/Mvm/MMTk/MutatorThread.h
vmkit/branches/multi-vm/lib/Mvm/Runtime/MethodInfo.cpp
vmkit/branches/multi-vm/lib/Mvm/Runtime/Object.cpp
vmkit/branches/multi-vm/mmtk/Makefile
vmkit/branches/multi-vm/mmtk/config/copyms/ObjectHeader.h
vmkit/branches/multi-vm/mmtk/config/marksweep/ObjectHeader.h
vmkit/branches/multi-vm/mmtk/java/src/org/j3/mmtk/Barriers.java
vmkit/branches/multi-vm/mmtk/mmtk-alloc/Selected.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/ActivePlan.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Assert.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/FinalizableProcessor.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Lock.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/MMTk_Events.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Memory.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/ObjectModel.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/ReferenceProcessor.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/RuntimeHelpers.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Scanning.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Selected.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Statistics.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/Strings.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/SynchronizedCounter.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/TraceInterface.cpp
vmkit/branches/multi-vm/mmtk/mmtk-j3/VM.cpp
vmkit/branches/multi-vm/tools/j3/Makefile
vmkit/branches/multi-vm/tools/llcj/llcj.cpp
vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp
vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp
vmkit/branches/multi-vm/tools/vmkit/Makefile
vmkit/branches/multi-vm/www/get_started.html
vmkit/branches/multi-vm/www/index.html
vmkit/branches/multi-vm/www/releases/index.html
vmkit/branches/multi-vm/www/use_aot.html
vmkit/branches/multi-vm/www/use_mmtk.html
Propchange: vmkit/branches/multi-vm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 30 06:21:29 2010
@@ -1 +1,3 @@
+/vmkit/branches/precise:112509-120199
/vmkit/branches/release_028:115466-116298
+/vmkit/trunk:120068-120292
Modified: vmkit/branches/multi-vm/Makefile.common.in
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/Makefile.common.in?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/Makefile.common.in (original)
+++ vmkit/branches/multi-vm/Makefile.common.in Tue Nov 30 06:21:29 2010
@@ -18,6 +18,12 @@
# Set the root directory of this project's install prefix
PROJ_INSTALL_ROOT := @prefix@
+# Define BYTECODE_LIBRARY before including LLVM's Makefile.common to get
+# dependencies right.
+ifeq ($(WITH_LLVM_GCC), 1)
+ BYTECODE_LIBRARY = 1
+endif
+
# Include LLVM's Master Makefile.
include $(LLVM_OBJ_ROOT)/Makefile.common
@@ -38,9 +44,3 @@
endif
include $(PROJ_SRC_ROOT)/Makefile.rules
-
-ifndef DISABLE_AUTO_DEPENDENCIES
-ifndef IS_CLEANING_TARGET
--include $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
-endif
-endif
Modified: vmkit/branches/multi-vm/Makefile.config.in
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/Makefile.config.in?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/Makefile.config.in (original)
+++ vmkit/branches/multi-vm/Makefile.config.in Tue Nov 30 06:21:29 2010
@@ -10,6 +10,7 @@
GC_MMAP2 = @GC_MMAP2@
GC_MMTK = @GC_MMTK@
MMTK_PLAN = @MMTK_PLAN@
+MMTK_PLAN_HEADER = @MMTK_PLAN_HEADER@
ISOLATE_BUILD = @ISOLATE_BUILD@
SERVICE_BUILD = @SERVICE_BUILD@
SINGLE_BUILD = @SINGLE_BUILD@
Modified: vmkit/branches/multi-vm/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/Makefile.rules?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/Makefile.rules (original)
+++ vmkit/branches/multi-vm/Makefile.rules Tue Nov 30 06:21:29 2010
@@ -135,11 +135,11 @@
$(Verb) $(ANT) -buildfile $(PROJ_OBJ_ROOT)/mmtk/java/build.xml
$(Echo) Building $(BuildMode) $(JARNAME).jar $(notdir $@)
$(Verb) $(LOPT) -load=$(LibDir)/JITGCPass$(SHLIBEXT) -std-compile-opts -JITGCPass -f $(LibDir)/MMTKAlloc.bc -o $(LibDir)/MMTKAlloc.bc
- $(Verb) $(VMJC) -std-compile-opts $(ADDITIONAL_ARGS) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -LowerMagic -verify $(PROJ_OBJ_ROOT)/mmtk/java/$(JARNAME).jar -disable-exceptions -disable-cooperativegc -with-clinit=org/mmtk/vm/VM,org/mmtk/utility/*,org/mmtk/policy/*,org/j3/config/* -Dmmtk.hostjvm=org.j3.mmtk.Factory -o $(JARNAME).bc -Dmmtk.properties=$(PROJ_SRC_ROOT)/mmtk/java/vmkit.properties -disable-stubs -assume-compiled -llvm-lazy
+ $(Verb) $(VMJC) -std-compile-opts $(ADDITIONAL_ARGS) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -LowerMagic $(PROJ_OBJ_ROOT)/mmtk/java/$(JARNAME).jar -disable-exceptions -disable-cooperativegc -with-clinit=org/mmtk/vm/VM,org/mmtk/utility/*,org/mmtk/policy/*,org/j3/config/* -Dmmtk.hostjvm=org.j3.mmtk.Factory -o $(JARNAME).bc -Dmmtk.properties=$(PROJ_SRC_ROOT)/mmtk/java/vmkit.properties -disable-stubs -assume-compiled -llvm-lazy
$(Verb) $(LOPT) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -std-compile-opts -LowerJavaRT -f $(JARNAME).bc -o $(JARNAME)-optimized.bc
$(Verb) $(LLVMLD) -r -o $(LibDir)/FinalMMTk.bc $(LibDir)/MMTKAlloc.bc $(JARNAME)-optimized.bc $(LibDir)/MMTKRuntime.bc
$(Verb) $(LOPT) -std-compile-opts $(LibDir)/FinalMMTk.bc -o $(LibDir)/FinalMMTk.bc
- #$(Verb) $(LLC) -march=cpp -cppgen=function -cppfor=gcmalloc $(LibDir)/FinalMMTk.bc -o $(PROJ_SRC_ROOT)/mmtk/config/$(MMTK_PLAN)/MMTkInline.inc
+ $(Verb) $(LLC) -march=cpp -cppgen=function -cppfor=gcmalloc $(LibDir)/FinalMMTk.bc -o $(PROJ_SRC_ROOT)/mmtk/inline/MMTkInline.inc
endif
endif
Modified: vmkit/branches/multi-vm/autoconf/configure.ac
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/autoconf/configure.ac?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/autoconf/configure.ac (original)
+++ vmkit/branches/multi-vm/autoconf/configure.ac Tue Nov 30 06:21:29 2010
@@ -223,8 +223,8 @@
AC_ARG_WITH(mmtk-plan,
[AS_HELP_STRING(--with-mmtk-plan=something,
[MMTk plan type ('marksweep')])],
- [[MMTK_PLAN=$withval]],
- [[MMTK_PLAN=marksweep]]
+ [[MMTK_PLAN_HEADER=$withval]],
+ [[MMTK_PLAN_HEADER=marksweep]]
)
if test "x$gc" = "xboehm"; then
@@ -247,7 +247,7 @@
AC_SUBST(GC_BOEHM, [0])
AC_SUBST(GC_MMTK, [1])
GC_LIBS=MMTk
- GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/MMTk -DWITH_MMTK -I\$(PROJ_SRC_ROOT)/mmtk/config/\$(MMTK_PLAN)"
+ GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/MMTk -DWITH_MMTK -I\$(PROJ_SRC_ROOT)/mmtk/config/\$(MMTK_PLAN_HEADER)"
else
GC_LIBS=GCMmap2
if test "x$gc" = "xmulti-mmap"; then
@@ -265,10 +265,24 @@
AC_SUBST(GC_MMTK, [0])
fi
fi
+
+
+if test "x$MMTK_PLAN_HEADER" = "xmarksweep"; then
+ MMTK_PLAN=org.mmtk.plan.marksweep.MS
+else
+ if test "x$MMTK_PLAN_HEADER" = "xcopyms"; then
+ MMTK_PLAN=org.mmtk.plan.copyms.CopyMS
+ else
+ if test "x$MMTK_PLAN_HEADER" != "x"; then
+ error Unknown or unsupported MMTK plan
+ fi
+ fi
+fi
AC_SUBST([GC_FLAGS])
AC_SUBST([GC_LIBS])
AC_SUBST([MMTK_PLAN])
+AC_SUBST([MMTK_PLAN_HEADER])
dnl **************************************************************************
dnl Virtual Machine type
@@ -625,7 +639,7 @@
AC_CONFIG_FILES(Makefile.config)
AC_CONFIG_FILES([lib/J3/Classpath/Classpath.h])
AC_CONFIG_FILES([tools/llcj/LinkPaths.h])
-AC_CONFIG_FILES([mmtk/java/build.xml])
+AC_CONFIG_FILES([mmtk/java/src/org/j3/config/Selected.java])
dnl Do special configuration of Makefiles
AC_CONFIG_MAKEFILE(Makefile)
Modified: vmkit/branches/multi-vm/configure
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/configure?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/configure (original)
+++ vmkit/branches/multi-vm/configure Tue Nov 30 06:21:29 2010
@@ -641,6 +641,7 @@
ISOLATE_BUILD
SERVICE_BUILD
SINGLE_BUILD
+MMTK_PLAN_HEADER
MMTK_PLAN
GC_LIBS
GC_FLAGS
@@ -3860,9 +3861,9 @@
# Check whether --with-mmtk-plan was given.
if test "${with_mmtk_plan+set}" = set; then :
- withval=$with_mmtk_plan; MMTK_PLAN=$withval
+ withval=$with_mmtk_plan; MMTK_PLAN_HEADER=$withval
else
- MMTK_PLAN=marksweep
+ MMTK_PLAN_HEADER=marksweep
fi
@@ -3897,7 +3898,7 @@
GC_MMTK=1
GC_LIBS=MMTk
- GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/MMTk -DWITH_MMTK -I\$(PROJ_SRC_ROOT)/mmtk/config/\$(MMTK_PLAN)"
+ GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/MMTk -DWITH_MMTK -I\$(PROJ_SRC_ROOT)/mmtk/config/\$(MMTK_PLAN_HEADER)"
else
GC_LIBS=GCMmap2
if test "x$gc" = "xmulti-mmap"; then
@@ -3926,6 +3927,20 @@
fi
+if test "x$MMTK_PLAN_HEADER" = "xmarksweep"; then
+ MMTK_PLAN=org.mmtk.plan.marksweep.MS
+else
+ if test "x$MMTK_PLAN_HEADER" = "xcopyms"; then
+ MMTK_PLAN=org.mmtk.plan.copyms.CopyMS
+ else
+ if test "x$MMTK_PLAN_HEADER" != "x"; then
+ error Unknown or unsupported MMTK plan
+ fi
+ fi
+fi
+
+
+
@@ -6133,7 +6148,7 @@
ac_config_files="$ac_config_files tools/llcj/LinkPaths.h"
-ac_config_files="$ac_config_files mmtk/java/build.xml"
+ac_config_files="$ac_config_files mmtk/java/src/org/j3/config/Selected.java"
ac_config_commands="$ac_config_commands Makefile"
@@ -6842,7 +6857,7 @@
"Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
"lib/J3/Classpath/Classpath.h") CONFIG_FILES="$CONFIG_FILES lib/J3/Classpath/Classpath.h" ;;
"tools/llcj/LinkPaths.h") CONFIG_FILES="$CONFIG_FILES tools/llcj/LinkPaths.h" ;;
- "mmtk/java/build.xml") CONFIG_FILES="$CONFIG_FILES mmtk/java/build.xml" ;;
+ "mmtk/java/src/org/j3/config/Selected.java") CONFIG_FILES="$CONFIG_FILES mmtk/java/src/org/j3/config/Selected.java" ;;
"Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
"lib/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS lib/Makefile" ;;
Modified: vmkit/branches/multi-vm/include/j3/J3Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/j3/J3Intrinsics.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/j3/J3Intrinsics.h (original)
+++ vmkit/branches/multi-vm/include/j3/J3Intrinsics.h Tue Nov 30 06:21:29 2010
@@ -64,6 +64,7 @@
llvm::Function* ResolveVirtualStubFunction;
llvm::Function* ResolveSpecialStubFunction;
llvm::Function* ResolveStaticStubFunction;
+ llvm::Function* ResolveInterfaceFunction;
#ifndef WITHOUT_VTABLE
llvm::Function* VirtualLookupFunction;
Modified: vmkit/branches/multi-vm/include/j3/JavaAOTCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/j3/JavaAOTCompiler.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/j3/JavaAOTCompiler.h (original)
+++ vmkit/branches/multi-vm/include/j3/JavaAOTCompiler.h Tue Nov 30 06:21:29 2010
@@ -67,7 +67,7 @@
virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp);
virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr);
- virtual void setMethod(JavaMethod* meth, void* ptr, const char* name);
+ virtual void setMethod(llvm::Function* func, void* ptr, const char* name);
#ifdef SERVICE
Modified: vmkit/branches/multi-vm/include/j3/JavaCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/j3/JavaCompiler.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/j3/JavaCompiler.h (original)
+++ vmkit/branches/multi-vm/include/j3/JavaCompiler.h Tue Nov 30 06:21:29 2010
@@ -46,9 +46,6 @@
return 0;
}
- virtual void setMethod(JavaMethod* meth, void* ptr, const char* name) {
- }
-
virtual bool isStaticCompiling() {
return false;
}
@@ -105,10 +102,6 @@
virtual ~JavaCompiler() {}
- virtual mvm::StackScanner* createStackScanner() {
- return new mvm::UnpreciseStackScanner();
- }
-
virtual void* loadMethod(void* handle, const char* symbol) {
return dlsym(handle, symbol);
}
Modified: vmkit/branches/multi-vm/include/j3/JavaJITCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/j3/JavaJITCompiler.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/j3/JavaJITCompiler.h (original)
+++ vmkit/branches/multi-vm/include/j3/JavaJITCompiler.h Tue Nov 30 06:21:29 2010
@@ -10,6 +10,7 @@
#ifndef J3_JIT_COMPILER_H
#define J3_JIT_COMPILER_H
+#include "llvm/CodeGen/GCMetadata.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "j3/JavaLLVMCompiler.h"
@@ -38,9 +39,9 @@
bool EmitFunctionName;
JavaJITListener listener;
llvm::ExecutionEngine* executionEngine;
- llvm::GCStrategy* TheGCStrategy;
+ llvm::GCModuleInfo* GCInfo;
- JavaJITCompiler(const std::string &ModuleID, bool trusted = false);
+ JavaJITCompiler(const std::string &ModuleID);
~JavaJITCompiler();
virtual bool isStaticCompiling() {
@@ -72,28 +73,13 @@
virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp);
virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr);
- virtual void setMethod(JavaMethod* meth, void* ptr, const char* name);
+ virtual void setMethod(llvm::Function* func, void* ptr, const char* name);
-
-#ifdef SERVICE
- virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where);
-#endif
-
virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign,
bool stat, llvm::BasicBlock* insert) = 0;
virtual uintptr_t getPointerOrStub(JavaMethod& meth, int type) = 0;
-#ifdef WITH_LLVM_GCC
- virtual mvm::StackScanner* createStackScanner() {
- if (useCooperativeGC())
- return new mvm::PreciseStackScanner();
-
- return new mvm::UnpreciseStackScanner();
- }
-#endif
-
static JavaJITCompiler* CreateCompiler(const std::string& ModuleID);
-
};
class JavaJ3LazyJITCompiler : public JavaJITCompiler {
@@ -104,10 +90,10 @@
virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side);
virtual JavaCompiler* Create(const std::string& ModuleID) {
- return new JavaJ3LazyJITCompiler(ModuleID, false);
+ return new JavaJ3LazyJITCompiler(ModuleID);
}
- JavaJ3LazyJITCompiler(const std::string& ModuleID, bool trusted);
+ JavaJ3LazyJITCompiler(const std::string& ModuleID);
};
} // end namespace j3
Modified: vmkit/branches/multi-vm/include/j3/JavaLLVMCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/j3/JavaLLVMCompiler.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/j3/JavaLLVMCompiler.h (original)
+++ vmkit/branches/multi-vm/include/j3/JavaLLVMCompiler.h Tue Nov 30 06:21:29 2010
@@ -80,7 +80,7 @@
virtual bool isStaticCompiling() = 0;
virtual bool emitFunctionName() = 0;
virtual void* GenerateStub(llvm::Function* F) = 0;
- void addJavaPasses(bool trusted);
+ void addJavaPasses();
llvm::DIFactory* getDebugFactory() {
return DebugFactory;
@@ -195,7 +195,7 @@
virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp) = 0;
virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr) = 0;
- virtual void setMethod(JavaMethod* meth, void* ptr, const char* name) = 0;
+ virtual void setMethod(llvm::Function* func, void* ptr, const char* name) = 0;
#ifdef SERVICE
virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where) = 0;
Modified: vmkit/branches/multi-vm/include/j3/LLVMMaterializer.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/j3/LLVMMaterializer.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/j3/LLVMMaterializer.h (original)
+++ vmkit/branches/multi-vm/include/j3/LLVMMaterializer.h Tue Nov 30 06:21:29 2010
@@ -41,10 +41,10 @@
virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side);
virtual JavaCompiler* Create(const std::string& ModuleID) {
- return new JavaLLVMLazyJITCompiler(ModuleID, false);
+ return new JavaLLVMLazyJITCompiler(ModuleID);
}
- JavaLLVMLazyJITCompiler(const std::string& ModuleID, bool trusted);
+ JavaLLVMLazyJITCompiler(const std::string& ModuleID);
virtual ~JavaLLVMLazyJITCompiler();
Removed: vmkit/branches/multi-vm/include/mvm/CompilationUnit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/CompilationUnit.h?rev=120423&view=auto
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/CompilationUnit.h (original)
+++ vmkit/branches/multi-vm/include/mvm/CompilationUnit.h (removed)
@@ -1,33 +0,0 @@
-//===---- CompilingUnit.h - A compilation unit to compile source files ----===//
-//
-// The VMKit project
-//
-// This file is distributed under the University of Pierre et Marie Curie
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// A compilation unit contains a module and a module provider to compile source
-// files of a virtual machine, e.g .java files in Java.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MVM_COMPILATION_UNIT_H
-#define MVM_COMPILATION_UNIT_H
-
-#include "mvm/Object.h"
-
-namespace mvm {
-
-class MvmModule;
-
-class CompilationUnit : public mvm::Object {
-public:
- MvmModule* TheModule;
-
- void AddStandardCompilePasses();
-};
-}
-
-
-#endif
Modified: vmkit/branches/multi-vm/include/mvm/GC/GC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/GC/GC.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/GC/GC.h (original)
+++ vmkit/branches/multi-vm/include/mvm/GC/GC.h Tue Nov 30 06:21:29 2010
@@ -12,6 +12,7 @@
#define MVM_GC_H
#include <stdint.h>
+#include "ObjectHeader.h"
struct VirtualTable;
@@ -35,25 +36,8 @@
};
namespace mvm {
-
-class Thread;
-
-class StackScanner {
-public:
- virtual void scanStack(mvm::Thread* th, uintptr_t closure) = 0;
- virtual ~StackScanner() {}
-};
-
-class UnpreciseStackScanner : public StackScanner {
-public:
- virtual void scanStack(mvm::Thread* th, uintptr_t closure);
-};
-
-class PreciseStackScanner : public StackScanner {
-public:
- virtual void scanStack(mvm::Thread* th, uintptr_t closure);
-};
-
+ static const uint32_t HashBits = 8;
+ static const uint64_t GCBitMask = ((1 << GCBits) - 1);
}
#endif
Modified: vmkit/branches/multi-vm/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/JIT.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/JIT.h (original)
+++ vmkit/branches/multi-vm/include/mvm/JIT.h Tue Nov 30 06:21:29 2010
@@ -30,6 +30,7 @@
class FunctionPassManager;
class GCFunctionInfo;
class GCStrategy;
+ class JIT;
class Module;
class PointerType;
class TargetData;
@@ -186,15 +187,13 @@
class MvmModule {
-private:
- static llvm::ExecutionEngine* executionEngine;
-
public:
static llvm::GCStrategy* TheGCStrategy;
static mvm::LockRecursive protectEngine;
static llvm::Module *globalModule;
static const llvm::TargetData* TheTargetData;
static mvm::BumpPtrAllocator* Allocator;
+ static llvm::ExecutionEngine* executionEngine;
//static unsigned MetadataTypeKind;
static uint64 getTypeSize(const llvm::Type* type);
@@ -219,15 +218,18 @@
public:
virtual void scan(uintptr_t closure, void* ip, void* addr);
JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {}
+ void addToVM(VirtualMachine* vm, llvm::JIT* jit);
};
class MvmJITMethodInfo : public JITMethodInfo {
public:
virtual void print(void* ip, void* addr);
- MvmJITMethodInfo(llvm::GCFunctionInfo* GFI, const llvm::Function* F) :
+ MvmJITMethodInfo(llvm::GCFunctionInfo* GFI,
+ const llvm::Function* F,
+ void* owner) :
JITMethodInfo(GFI) {
MetaInfo = const_cast<llvm::Function*>(F);
- MethodType = 0;
+ Owner = owner;
}
};
Modified: vmkit/branches/multi-vm/include/mvm/MethodInfo.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/MethodInfo.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/MethodInfo.h (original)
+++ vmkit/branches/multi-vm/include/mvm/MethodInfo.h Tue Nov 30 06:21:29 2010
@@ -19,6 +19,9 @@
public:
virtual void print(void* ip, void* addr) = 0;
virtual void scan(uintptr_t closure, void* ip, void* addr) = 0;
+ virtual bool isHighLevelMethod() {
+ return false;
+ }
static void* isStub(void* ip, void* addr) {
bool isStub = ((unsigned char*)ip)[0] == 0xCE;
@@ -26,11 +29,8 @@
return ip;
}
- void* getMetaInfo() const { return MetaInfo; }
-
- unsigned MethodType;
- void* InstructionPointer;
void* MetaInfo;
+ void* Owner;
};
class CamlFrame {
@@ -45,17 +45,21 @@
public:
CamlFrame* CF;
virtual void scan(uintptr_t closure, void* ip, void* addr);
- CamlMethodInfo(CamlFrame* C, void* ip);
+ CamlMethodInfo(CamlFrame* C) : CF(C) {
+ Owner = NULL;
+ MetaInfo = NULL;
+ }
};
class StaticCamlMethodInfo : public CamlMethodInfo {
const char* name;
public:
virtual void print(void* ip, void* addr);
- StaticCamlMethodInfo(CamlFrame* CF, void* ip, const char* n) :
- CamlMethodInfo(CF, ip) {
+ StaticCamlMethodInfo(CamlFrame* CF, const char* n) :
+ CamlMethodInfo(CF) {
+ Owner = NULL;
+ MetaInfo = NULL;
name = n;
- MethodType = 0;
}
};
@@ -66,7 +70,8 @@
static DefaultMethodInfo DM;
DefaultMethodInfo() {
- MethodType = -1;
+ Owner = NULL;
+ MetaInfo = NULL;
}
};
Modified: vmkit/branches/multi-vm/include/mvm/Threads/CollectionRV.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/Threads/CollectionRV.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/Threads/CollectionRV.h (original)
+++ vmkit/branches/multi-vm/include/mvm/Threads/CollectionRV.h Tue Nov 30 06:21:29 2010
@@ -34,7 +34,7 @@
CollectionRV() {
nbJoined = 0;
}
-
+
void lockRV() { _lockRV.lock(); }
void unlockRV() { _lockRV.unlock(); }
@@ -57,8 +57,10 @@
virtual void synchronize() = 0;
virtual void join() = 0;
- virtual void joinAfterUncooperative() = 0;
+ virtual void joinAfterUncooperative(void* SP) = 0;
virtual void joinBeforeUncooperative() = 0;
+
+ virtual void addThread(Thread* th) = 0;
};
class CooperativeCollectionRV : public CollectionRV {
@@ -67,8 +69,9 @@
void synchronize();
void join();
- void joinAfterUncooperative();
+ void joinAfterUncooperative(void* SP);
void joinBeforeUncooperative();
+ void addThread(Thread* th);
};
class UncooperativeCollectionRV : public CollectionRV {
@@ -77,8 +80,9 @@
void synchronize();
void join();
- void joinAfterUncooperative();
+ void joinAfterUncooperative(void* SP);
void joinBeforeUncooperative();
+ void addThread(Thread* th);
};
Modified: vmkit/branches/multi-vm/include/mvm/Threads/Locks.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/Threads/Locks.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/Threads/Locks.h (original)
+++ vmkit/branches/multi-vm/include/mvm/Threads/Locks.h Tue Nov 30 06:21:29 2010
@@ -110,7 +110,7 @@
/// lock - Acquire the lock.
///
- virtual void lock() = 0;
+ virtual void lock() __attribute__ ((noinline)) = 0;
/// unlock - Release the lock.
///
@@ -141,7 +141,7 @@
public:
LockNormal() : Lock() {}
- virtual void lock();
+ virtual void lock() __attribute__ ((noinline));
virtual void unlock();
};
@@ -170,7 +170,7 @@
public:
LockRecursive() : Lock() { n = 0; }
- virtual void lock();
+ virtual void lock() __attribute__ ((noinline));
virtual void unlock();
virtual int tryLock();
@@ -185,39 +185,9 @@
/// lockAll - Acquire the lock count times.
///
- void lockAll(int count);
+ void lockAll(int count) __attribute__ ((noinline));
};
-class ThinLock {
-public:
-
- /// initialise - Initialise the value of the lock.
- ///
- static void initialise(gc* object);
-
- /// overflowThinlock - Change the lock of this object to a fat lock because
- /// we have reached 0xFF locks.
- static void overflowThinLock(gc* object);
-
- /// changeToFatlock - Change the lock of this object to a fat lock. The lock
- /// may be in a thin lock or fat lock state.
- static FatLock* changeToFatlock(gc* object);
-
- /// acquire - Acquire the lock.
- static void acquire(gc* object);
-
- /// release - Release the lock.
- static void release(gc* object);
-
- /// owner - Returns true if the curren thread is the owner of this object's
- /// lock.
- static bool owner(gc* object);
-
- /// getFatLock - Get the fat lock is the lock is a fat lock, 0 otherwise.
- static FatLock* getFatLock(gc* object);
-};
-
-
/// SpinLock - This class implements a spin lock. A spin lock is OK to use
/// when it is held during short period of times. It is CPU expensive
/// otherwise.
Modified: vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/Threads/Thread.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/Threads/Thread.h (original)
+++ vmkit/branches/multi-vm/include/mvm/Threads/Thread.h Tue Nov 30 06:21:29 2010
@@ -14,12 +14,13 @@
#include <cstdio>
#include <stdlib.h>
+#include "debug.h"
#include "types.h"
#ifdef RUNTIME_DWARF_EXCEPTIONS
#define TRY try
#define CATCH catch(...)
- #define IGNORE catch(...) { mvm::Thread::get()->clearException(); }
+ #define IGNORE catch(...) { mvm::Thread::get()->clearPendingException(); }
#define END_CATCH
#else
#include <csetjmp>
@@ -29,7 +30,7 @@
#define TRY { mvm::ExceptionBuffer __buffer__; if (!setjmp(__buffer__.buffer))
#endif
#define CATCH else
- #define IGNORE else { mvm::Thread::get()->clearException(); }}
+ #define IGNORE else { mvm::Thread::get()->clearPendingException(); }}
#define END_CATCH }
#endif
@@ -131,8 +132,9 @@
class KnownFrame {
public:
- KnownFrame* previousFrame;
void* currentFP;
+ void* currentIP;
+ KnownFrame* previousFrame;
};
@@ -177,10 +179,6 @@
///
int kill(int signo);
- /// killForRendezvous - Kill the given thread for a rendezvous.
- ///
- void killForRendezvous();
-
/// exit - Exit the current thread.
///
static void exit(int value);
@@ -207,15 +205,15 @@
/// doYield - Flag to tell the thread to yield for GC reasons.
///
- char doYield;
+ bool doYield;
/// inRV - Flag to tell that the thread is being part of a rendezvous.
///
- char inRV;
+ bool inRV;
/// joinedRV - Flag to tell that the thread has joined a rendezvous.
///
- char joinedRV;
+ bool joinedRV;
/// get - Get the thread specific data of the current thread.
///
@@ -240,88 +238,31 @@
///
static void internalThreadStart(mvm::Thread* th);
- /// internalClearException - Clear any pending exception.
- ///
- virtual void internalClearException() {}
-
public:
/// tracer - Does nothing. Used for child classes which may defined
/// a tracer.
///
virtual void tracer(uintptr_t closure) {}
+ void scanStack(uintptr_t closure);
void* getLastSP() { return lastSP; }
void setLastSP(void* V) { lastSP = V; }
void joinRVBeforeEnter();
- void joinRVAfterLeave();
+ void joinRVAfterLeave(void* savedSP);
- void enterUncooperativeCode(unsigned level = 0) __attribute__ ((noinline)) {
- if (isMvmThread()) {
- if (!inRV) {
- assert(!lastSP && "SP already set when entering uncooperative code");
- ++level;
- void* temp = __builtin_frame_address(0);
- while (level--) temp = ((void**)temp)[0];
- // The cas is not necessary, but it does a memory barrier.
- __sync_bool_compare_and_swap(&lastSP, 0, temp);
- if (doYield) joinRVBeforeEnter();
- assert(lastSP && "No last SP when entering uncooperative code");
- }
- }
- }
-
- void enterUncooperativeCode(void* SP) {
- if (isMvmThread()) {
- if (!inRV) {
- assert(!lastSP && "SP already set when entering uncooperative code");
- // The cas is not necessary, but it does a memory barrier.
- __sync_bool_compare_and_swap(&lastSP, 0, SP);
- if (doYield) joinRVBeforeEnter();
- assert(lastSP && "No last SP when entering uncooperative code");
- }
- }
- }
-
- void leaveUncooperativeCode() {
- if (isMvmThread()) {
- if (!inRV) {
- assert(lastSP && "No last SP when leaving uncooperative code");
- // 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.
- if (doYield) joinRVAfterLeave();
- assert(!lastSP && "SP has a value after leaving uncooperative code");
- }
- }
- }
-
- void* waitOnSP() {
- // First see if we can get lastSP directly.
- void* sp = lastSP;
- if (sp) return sp;
-
- // Then loop a fixed number of iterations to get lastSP.
- for (uint32 count = 0; count < 1000; ++count) {
- sp = lastSP;
- if (sp) return sp;
- }
-
- // Finally, yield until lastSP is not set.
- while ((sp = lastSP) == NULL) mvm::Thread::yield();
-
- assert(sp != NULL && "Still no sp");
- return sp;
- }
+ void enterUncooperativeCode(unsigned level = 0) __attribute__ ((noinline));
+ void enterUncooperativeCode(void* SP);
+ void leaveUncooperativeCode();
+ void* waitOnSP();
- /// clearException - Clear any pending exception of the current thread.
- void clearException() {
+ /// clearPendingException - Clear any pending exception of the current thread.
+ void clearPendingException() {
#ifdef RUNTIME_DWARF_EXCEPTIONS
internalPendingException = 0;
#endif
- internalClearException();
}
bool isMvmThread() {
@@ -360,11 +301,11 @@
/// Thread. The thread object is inlined in the stack.
///
void* operator new(size_t sz);
- void operator delete(void* th) {}
+ void operator delete(void* th) { UNREACHABLE(); }
/// releaseThread - Free the stack so that another thread can use it.
///
- static void releaseThread(void* th);
+ static void releaseThread(mvm::Thread* th);
/// routine - The function to invoke when the thread starts.
///
@@ -404,7 +345,8 @@
void startKnownFrame(KnownFrame& F) __attribute__ ((noinline));
void endKnownFrame();
-
+ void startUnknownFrame(KnownFrame& F) __attribute__ ((noinline));
+ void endUnknownFrame();
/// vmData - vm specific data
///
@@ -440,17 +382,9 @@
KnownFrame* frame;
mvm::Thread* thread;
- StackWalker(mvm::Thread* th) {
- thread = th;
- addr = mvm::Thread::get() == th ? (void**)FRAME_PTR() :
- (void**)th->waitOnSP();
- frame = th->lastKnownFrame;
- assert(addr && "No address to start with");
- }
-
+ StackWalker(mvm::Thread* th) __attribute__ ((noinline));
void operator++();
void* operator*();
-
MethodInfo* get();
};
Modified: vmkit/branches/multi-vm/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/VirtualMachine.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/VirtualMachine.h (original)
+++ vmkit/branches/multi-vm/include/mvm/VirtualMachine.h Tue Nov 30 06:21:29 2010
@@ -6,34 +6,22 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// Ultimately, this would be like a generic way of defining a VM. But we're not
-// quite there yet.
-//
-//===----------------------------------------------------------------------===//
#ifndef MVM_VIRTUALMACHINE_H
#define MVM_VIRTUALMACHINE_H
#include "mvm/Allocator.h"
-#include "mvm/MethodInfo.h"
#include "mvm/Threads/CollectionRV.h"
-#include "mvm/Threads/Cond.h"
#include "mvm/Threads/Locks.h"
#include "mvm/GC/GC.h"
#include <cassert>
#include <map>
-namespace j3 {
- class JavaCompiler;
- class JnjvmClassLoader;
-}
-
-class gc;
-
namespace mvm {
+class MethodInfo;
+
class FunctionMap {
public:
/// Functions - Map of applicative methods to function pointers. This map is
@@ -48,192 +36,32 @@
/// IPToMethodInfo - Map a code start instruction instruction to the MethodInfo.
///
- MethodInfo* CodeStartToMethodInfo(void* ip) {
- FunctionMapLock.acquire();
- std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);
- MethodInfo* res = NULL;
- if (I != Functions.end()) {
- res = I->second;
- }
- FunctionMapLock.release();
- return res;
- }
-};
-
-/// StartEndFunctionMap - This map is for functions for which we have
-/// a start and end address.
-///
-class StartEndFunctionMap : public FunctionMap {
-public:
- /// addMethodInFunctionMap - A new method pointer in the function map.
- ///
- void addMethodInfo(MethodInfo* meth, void* start, void* end) {
- FunctionMapLock.acquire();
- Functions.insert(std::make_pair(start, meth));
- Functions.insert(std::make_pair(end, meth));
- FunctionMapLock.release();
- }
-
- /// IPToMethodInfo - Map an instruction pointer to the MethodInfo.
- ///
- MethodInfo* IPToMethodInfo(void* ip) {
- FunctionMapLock.acquire();
- std::map<void*, MethodInfo*>::iterator I = Functions.upper_bound(ip);
- MethodInfo* res = 0;
- if (I != Functions.end() && I != Functions.begin()) {
- res = I->second;
- if ((--I)->second != res) res = 0;
- }
- FunctionMapLock.release();
- return res;
- }
-};
-
-/// StartFunctionMap - This map is for static functions where getting an end
-/// address is cumbersome.
-///
-class StartFunctionMap : public FunctionMap {
-public:
- /// addMethodInFunctionMap - A new method pointer in the function map.
- ///
- void addMethodInfo(MethodInfo* meth, void* addr) {
- FunctionMapLock.acquire();
- Functions.insert(std::make_pair((void*)addr, meth));
- FunctionMapLock.release();
- }
-
- /// IPToMethodInfo - Map an instruction pointer to the MethodInfo.
- ///
MethodInfo* IPToMethodInfo(void* ip);
-
-};
-
-class SharedStartFunctionMap : public StartFunctionMap {
-public:
- BumpPtrAllocator* StaticAllocator;
- bool initialized;
- SharedStartFunctionMap() {
- initialized = false;
- }
-
- void initialize();
-};
-
-
-
-// Same values than JikesRVM
-#define INITIAL_QUEUE_SIZE 256
-#define GROW_FACTOR 2
-
-class CompilationUnit;
-class VirtualMachine;
-
-class ReferenceQueue {
-private:
- gc** References;
- uint32 QueueLength;
- uint32 CurrentIndex;
- mvm::SpinLock QueueLock;
- uint8_t semantics;
-
- gc* processReference(gc*, VirtualMachine*, uintptr_t closure);
-public:
-
- static const uint8_t WEAK = 1;
- static const uint8_t SOFT = 2;
- static const uint8_t PHANTOM = 3;
-
-
-
- ReferenceQueue(uint8_t s) {
- References = new gc*[INITIAL_QUEUE_SIZE];
- QueueLength = INITIAL_QUEUE_SIZE;
- CurrentIndex = 0;
- semantics = s;
- }
- ~ReferenceQueue() {
- delete[] References;
- }
-
- void addReference(gc* ref) {
- QueueLock.acquire();
- if (CurrentIndex >= QueueLength) {
- uint32 newLength = QueueLength * GROW_FACTOR;
- gc** newQueue = new gc*[newLength];
- if (!newQueue) {
- fprintf(stderr, "I don't know how to handle reference overflow yet!\n");
- abort();
- }
- for (uint32 i = 0; i < QueueLength; ++i) newQueue[i] = References[i];
- delete[] References;
- References = newQueue;
- QueueLength = newLength;
- }
- References[CurrentIndex++] = ref;
- QueueLock.release();
- }
-
- void acquire() {
- QueueLock.acquire();
- }
-
- void release() {
- QueueLock.release();
- }
+ /// addMethodInfo - A new instruction pointer in the function map.
+ ///
+ void addMethodInfo(MethodInfo* meth, void* ip);
- void scan(VirtualMachine* vm, uintptr_t closure);
-};
+ /// removeMethodInfos - Remove all MethodInfo owned by the given owner.
+ void removeMethodInfos(void* owner);
-class FatLock : public mvm::PermanentObject {
-public:
- virtual void deallocate() = 0;
- virtual uintptr_t getID() = 0;
- virtual bool acquire(gc* object) = 0;
- virtual void acquireAll(gc* object, uint32_t count) = 0;
- virtual void release(gc* object) = 0;
- virtual mvm::Thread* getOwner() = 0;
- virtual bool owner() = 0;
+ FunctionMap();
};
/// VirtualMachine - This class is the root of virtual machine classes. It
/// defines what a VM should be.
///
class VirtualMachine : public mvm::PermanentObject {
- friend class ReferenceQueue;
-
protected:
-
VirtualMachine(mvm::BumpPtrAllocator &Alloc) :
- allocator(Alloc),
- WeakReferencesQueue(ReferenceQueue::WEAK),
- SoftReferencesQueue(ReferenceQueue::SOFT),
- PhantomReferencesQueue(ReferenceQueue::PHANTOM) {
-#ifdef SERVICE
- memoryLimit = ~0;
- executionLimit = ~0;
- GCLimit = ~0;
- threadLimit = ~0;
- parent = this;
- status = 1;
- _since_last_collection = 4*1024*1024;
-#endif
- FinalizationQueue = new gc*[INITIAL_QUEUE_SIZE];
- QueueLength = INITIAL_QUEUE_SIZE;
- CurrentIndex = 0;
-
- ToBeFinalized = new gc*[INITIAL_QUEUE_SIZE];
- ToBeFinalizedLength = INITIAL_QUEUE_SIZE;
- CurrentFinalizedIndex = 0;
-
- ToEnqueue = new gc*[INITIAL_QUEUE_SIZE];
- ToEnqueueLength = INITIAL_QUEUE_SIZE;
- ToEnqueueIndex = 0;
-
+ allocator(Alloc) {
mainThread = 0;
NumberOfThreads = 0;
- if (!SharedStaticFunctions.initialized) SharedStaticFunctions.initialize();
}
+
+ virtual ~VirtualMachine() {
+ }
+
public:
/// allocator - Bump pointer allocator to allocate permanent memory
@@ -241,6 +69,10 @@
///
mvm::BumpPtrAllocator& allocator;
+//===----------------------------------------------------------------------===//
+// (1) Thread-related methods.
+//===----------------------------------------------------------------------===//
+
/// mainThread - The main thread of this VM.
///
mvm::Thread* mainThread;
@@ -284,239 +116,55 @@
ThreadLock.unlock();
}
+//===----------------------------------------------------------------------===//
+// (2) GC-related methods.
+//===----------------------------------------------------------------------===//
- virtual void tracer(uintptr_t closure);
-
- virtual ~VirtualMachine() {
- if (scanner) delete scanner;
- delete[] FinalizationQueue;
- delete[] ToBeFinalized;
- delete[] ToEnqueue;
- }
-
- /// runApplication - Run an application. The application name is in
- /// the arguments, hence it is the virtual machine's job to parse them.
- virtual void runApplication(int argc, char** argv) = 0;
-
- /// waitForExit - Wait until the virtual machine stops its execution.
- virtual void waitForExit() = 0;
-
- virtual FatLock* allocateFatLock(gc* object) = 0;
- virtual FatLock* getFatLockFromID(uintptr_t header) = 0;
-
- static j3::JnjvmClassLoader* initialiseJVM(j3::JavaCompiler* C,
- bool dlLoad = true);
- static VirtualMachine* createJVM(j3::JnjvmClassLoader* C = 0);
-
- static CompilationUnit* initialiseCLIVM();
- static VirtualMachine* createCLIVM(CompilationUnit* C = 0);
-
-private:
- /// WeakReferencesQueue - The queue of weak references.
- ///
- ReferenceQueue WeakReferencesQueue;
-
- /// SoftReferencesQueue - The queue of soft references.
- ///
- ReferenceQueue SoftReferencesQueue;
-
- /// PhantomReferencesQueue - The queue of phantom references.
- ///
- ReferenceQueue PhantomReferencesQueue;
-
-
- /// FinalizationQueueLock - A lock to protect access to the queue.
- ///
- mvm::SpinLock FinalizationQueueLock;
-
- /// finalizationQueue - A list of allocated objets that contain a finalize
- /// method.
- ///
- gc** FinalizationQueue;
-
- /// CurrentIndex - Current index in the queue of finalizable objects.
- ///
- uint32 CurrentIndex;
-
- /// QueueLength - Current length of the queue of finalizable objects.
- ///
- uint32 QueueLength;
-
- /// growFinalizationQueue - Grow the queue of finalizable objects.
- ///
- void growFinalizationQueue();
-
- /// ToBeFinalized - List of objects that are scheduled to be finalized.
- ///
- gc** ToBeFinalized;
-
- /// ToBeFinalizedLength - Current length of the queue of objects scheduled
- /// for finalization.
- ///
- uint32 ToBeFinalizedLength;
-
- /// CurrentFinalizedIndex - The current index in the ToBeFinalized queue
- /// that will be sceduled for finalization.
- ///
- uint32 CurrentFinalizedIndex;
-
- /// growToBeFinalizedQueue - Grow the queue of the to-be finalized objects.
- ///
- void growToBeFinalizedQueue();
-
- /// finalizationCond - Condition variable to wake up finalization threads.
- ///
- mvm::Cond FinalizationCond;
-
- /// finalizationLock - Lock for the condition variable.
- ///
- mvm::LockNormal FinalizationLock;
-
- gc** ToEnqueue;
- uint32 ToEnqueueLength;
- uint32 ToEnqueueIndex;
-
- /// ToEnqueueLock - A lock to protect access to the queue.
- ///
- mvm::LockNormal EnqueueLock;
- mvm::Cond EnqueueCond;
- mvm::SpinLock ToEnqueueLock;
-
- void addToEnqueue(gc* obj) {
- if (ToEnqueueIndex >= ToEnqueueLength) {
- uint32 newLength = ToEnqueueLength * GROW_FACTOR;
- gc** newQueue = new gc*[newLength];
- if (!newQueue) {
- fprintf(stderr, "I don't know how to handle reference overflow yet!\n");
- abort();
- }
- for (uint32 i = 0; i < ToEnqueueLength; ++i) {
- newQueue[i] = ToEnqueue[i];
- }
- delete[] ToEnqueue;
- ToEnqueue = newQueue;
- ToEnqueueLength = newLength;
- }
- ToEnqueue[ToEnqueueIndex++] = obj;
- }
-
-public:
- /// invokeFinalizer - Invoke the finalizer of the object. This may involve
- /// changing the environment, e.g. going to native to Java.
- ///
- virtual void invokeFinalizer(gc*) {}
-
- /// enqueueReference - Calls the enqueue method. Should be overriden
- /// by the VM.
- ///
- virtual bool enqueueReference(gc*) { return false; }
-
- /// finalizerStart - The start function of a finalizer. Will poll the
- /// finalizationQueue.
- ///
- static void finalizerStart(mvm::Thread*);
-
- /// enqueueStart - The start function of a thread for references. Will poll
- /// ToEnqueue.
- ///
- static void enqueueStart(mvm::Thread*);
-
- /// addFinalizationCandidate - Add an object to the queue of objects with
- /// a finalization method.
- ///
- void addFinalizationCandidate(gc*);
-
- /// scanFinalizationQueue - Scan objets with a finalized method and schedule
- /// them for finalization if they are not live.
- ///
- void scanFinalizationQueue(uintptr_t closure);
-
- /// wakeUpFinalizers - Wake the finalizers.
+ /// startCollection - Preliminary code before starting a GC.
///
- void wakeUpFinalizers() { FinalizationCond.broadcast(); }
+ virtual void startCollection() {}
- /// wakeUpEnqueue - Wake the threads for enqueueing.
+ /// endCollection - Code after running a GC.
///
- void wakeUpEnqueue() { EnqueueCond.broadcast(); }
-
- virtual void startCollection() {
- FinalizationQueueLock.acquire();
- ToEnqueueLock.acquire();
- SoftReferencesQueue.acquire();
- WeakReferencesQueue.acquire();
- PhantomReferencesQueue.acquire();
- }
-
- virtual void endCollection() {
- FinalizationQueueLock.release();
- ToEnqueueLock.release();
- SoftReferencesQueue.release();
- WeakReferencesQueue.release();
- PhantomReferencesQueue.release();
- }
+ virtual void endCollection() {}
/// scanWeakReferencesQueue - Scan all weak references. Called by the GC
/// before scanning the finalization queue.
///
- void scanWeakReferencesQueue(uintptr_t closure) {
- WeakReferencesQueue.scan(this, closure);
- }
+ virtual void scanWeakReferencesQueue(uintptr_t closure) {}
/// scanSoftReferencesQueue - Scan all soft references. Called by the GC
/// before scanning the finalization queue.
///
- void scanSoftReferencesQueue(uintptr_t closure) {
- SoftReferencesQueue.scan(this, closure);
- }
+ virtual void scanSoftReferencesQueue(uintptr_t closure) {}
/// scanPhantomReferencesQueue - Scan all phantom references. Called by the GC
/// after the finalization queue.
///
- void scanPhantomReferencesQueue(uintptr_t closure) {
- PhantomReferencesQueue.scan(this, closure);
- }
-
- /// addWeakReference - Add a weak reference to the queue.
- ///
- void addWeakReference(gc* ref) {
- WeakReferencesQueue.addReference(ref);
- }
-
- /// addSoftReference - Add a weak reference to the queue.
- ///
- void addSoftReference(gc* ref) {
- SoftReferencesQueue.addReference(ref);
- }
-
- /// addPhantomReference - Add a weak reference to the queue.
- ///
- void addPhantomReference(gc* ref) {
- PhantomReferencesQueue.addReference(ref);
- }
+ virtual void scanPhantomReferencesQueue(uintptr_t closure) {}
- /// clearReferent - Clear the referent in a reference. Should be overriden
- /// by the VM.
- ///
- virtual void clearReferent(gc*) {}
+ /// scanFinalizationQueue - Scan objets with a finalized method and schedule
+ /// them for finalization if they are not live.
+ ///
+ virtual void scanFinalizationQueue(uintptr_t closure) {}
- /// getReferent - Get the referent of the reference. Should be overriden
- /// by the VM.
- //
- virtual gc** getReferentPtr(gc*) { return 0; }
-
- /// setReferent - Set the referent of the reference. Should be overriden
- /// by the VM.
- virtual void setReferent(gc* reference, gc* referent) { }
+ /// addFinalizationCandidate - Add an object to the queue of objects with
+ /// a finalization method.
+ ///
+ virtual void addFinalizationCandidate(gc* object) {}
-public:
+ /// tracer - Trace this virtual machine's GC-objects.
+ ///
+ virtual void tracer(uintptr_t closure) {}
- /// scanner - Scanner of threads' stacks.
+ /// getObjectSize - Get the size of this object. Used by copying collectors.
///
- mvm::StackScanner* scanner;
+ virtual size_t getObjectSize(gc* object) = 0;
- mvm::StackScanner* getScanner() {
- return scanner;
- }
+ /// getObjectTypeName - Get the type of this object. Used by the GC for
+ /// debugging purposes.
+ ///
+ virtual const char* getObjectTypeName(gc* object) { return "An object"; }
/// rendezvous - The rendezvous implementation for garbage collection.
///
@@ -526,38 +174,29 @@
UncooperativeCollectionRV rendezvous;
#endif
+//===----------------------------------------------------------------------===//
+// (3) Backtrace-related methods.
+//===----------------------------------------------------------------------===//
- StartEndFunctionMap RuntimeFunctions;
- static StartEndFunctionMap SharedRuntimeFunctions;
- StartFunctionMap StaticFunctions;
- static SharedStartFunctionMap SharedStaticFunctions;
-
- MethodInfo* IPToMethodInfo(void* ip);
-
-#ifdef ISOLATE
- size_t IsolateID;
-#endif
-
-#ifdef SERVICE
- uint64_t memoryUsed;
- uint64_t gcTriggered;
- uint64_t executionTime;
- uint64_t numThreads;
- CompilationUnit* CU;
- virtual void stopService() {}
-
- uint64_t memoryLimit;
- uint64_t executionLimit;
- uint64_t threadLimit;
- uint64_t GCLimit;
-
- int _since_last_collection;
- VirtualMachine* parent;
- uint32 status;
-#endif
+ FunctionMap FunctionsCache;
+ MethodInfo* IPToMethodInfo(void* ip) {
+ return FunctionsCache.IPToMethodInfo(ip);
+ }
+ void removeMethodInfos(void* owner) {
+ FunctionsCache.removeMethodInfos(owner);
+ }
+
+//===----------------------------------------------------------------------===//
+// (4) Launch-related methods.
+//===----------------------------------------------------------------------===//
+ /// runApplication - Run an application. The application name is in
+ /// the arguments, hence it is the virtual machine's job to parse them.
+ virtual void runApplication(int argc, char** argv) = 0;
+
+ /// waitForExit - Wait until the virtual machine stops its execution.
+ virtual void waitForExit() = 0;
};
-
} // end namespace mvm
#endif // MVM_VIRTUALMACHINE_H
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc Tue Nov 30 06:21:29 2010
@@ -120,13 +120,13 @@
TRY {
meth->invokeIntSpecialBuf(vm, cl, res, buf);
} CATCH {
- excp = JavaThread::get()->getJavaException();
+ excp = JavaThread::get()->getPendingException();
} END_CATCH;
mvm::Thread* mut = mvm::Thread::get();
JavaThread* th = JavaThread::j3Thread(mut);
if (excp) {
if (JavaObject::getClass(excp)->isAssignableFrom(vm->upcalls->newException)) {
- mut->clearException();
+ mut->clearPendingException();
// If it's an exception, we encapsule it in an
// invocationTargetException
vm->invocationTargetException(excp);
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc Tue Nov 30 06:21:29 2010
@@ -164,14 +164,14 @@
VAR = meth->invoke##TYPE##StaticBuf(vm, cl, buf); \
} \
} CATCH { \
- exc = JavaThread::get()->getJavaException(); \
+ exc = JavaThread::get()->getPendingException(); \
} END_CATCH; \
mvm::Thread* mut = mvm::Thread::get(); \
JavaThread* th = JavaThread::j3Thread(mut); \
if (exc) { \
if (JavaObject::getClass(exc)->isAssignableFrom( \
vm->upcalls->newException)) { \
- mut->clearException(); \
+ mut->clearPendingException(); \
th->getJVM()->invocationTargetException(exc); \
} else { \
th->throwPendingException(); \
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h Tue Nov 30 06:21:29 2010
@@ -14,6 +14,7 @@
#include "JavaClass.h"
#include "JavaObject.h"
+#include <JavaThread.h>
extern "C" j3::JavaObject* internalFillInStackTrace(j3::JavaObject*);
@@ -150,7 +151,7 @@
public:
static void staticDestructor(JavaObjectVMThread* obj) {
llvm_gcroot(obj, 0);
- mvm::Thread::releaseThread(obj->vmdata);
+ mvm::Thread::releaseThread(obj->vmdata->mut);
}
static void staticTracer(JavaObjectVMThread* obj, uintptr_t closure) {
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc Tue Nov 30 06:21:29 2010
@@ -131,22 +131,27 @@
BEGIN_NATIVE_EXCEPTION(0)
Jnjvm* vm = JavaThread::get()->getJVM();
+
+ JnjvmClassLoader* JCL =
+ JnjvmClassLoader::getJnjvmLoaderFromJavaObject(loader, vm);
+ int32_t size = JavaArray::getSize(bytes);
+ ClassBytes* classBytes = new (JCL->allocator, size) ClassBytes(size);
+ memcpy(classBytes->elements, JavaArray::getElements(bytes), size);
+
// Before creating a class, do a check on the bytes.
- Reader reader(&bytes);
+ Reader reader(classBytes);
uint32 magic = reader.readU4();
if (magic != Jnjvm::Magic) {
JavaThread::get()->getJVM()->classFormatError("bad magic number");
}
- JnjvmClassLoader* JCL =
- JnjvmClassLoader::getJnjvmLoaderFromJavaObject(loader, vm);
const UTF8* name = JavaString::javaToInternal(str, JCL->hashUTF8);
UserCommonClass* cl = JCL->lookupClass(name);
if (!cl) {
- UserClass* cl = JCL->constructClass(name, bytes);
+ UserClass* cl = JCL->constructClass(name, classBytes);
cl->resolveClass();
res = cl->getClassDelegatee(vm, pd);
@@ -351,7 +356,7 @@
"org.xml.sax.helpers"
};
-extern "C" ArrayObject* nativeGetBootPackages() {
+extern "C" ArrayObject* Java_java_lang_VMClassLoader_getBootPackages__() {
ArrayObject* obj = 0;
llvm_gcroot(obj, 0);
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMRuntime.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMRuntime.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMRuntime.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMRuntime.inc Tue Nov 30 06:21:29 2010
@@ -150,8 +150,7 @@
jclass clazz,
#endif
) {
- Jnjvm* vm = JavaThread::get()->getJVM();
- vm->wakeUpFinalizers();
+ mvm::Collector::collect();
// Sleep a bit.
sleep(1);
return;
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc Tue Nov 30 06:21:29 2010
@@ -35,6 +35,8 @@
llvm_gcroot(src, 0);
llvm_gcroot(dst, 0);
llvm_gcroot(cur, 0);
+ assert(src->getVirtualTable());
+ assert(dst->getVirtualTable());
JavaThread* th = JavaThread::get();
Jnjvm *vm = th->getJVM();
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystemProperties.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystemProperties.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystemProperties.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystemProperties.inc Tue Nov 30 06:21:29 2010
@@ -136,7 +136,7 @@
END_NATIVE_EXCEPTION
}
-extern "C" void nativePropertiesPostInit(JavaObject* prop) {
+extern "C" void Java_gnu_classpath_VMSystemProperties_postInit__Ljava_util_Properties_2(JavaObject* prop) {
llvm_gcroot(prop, 0);
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc Tue Nov 30 06:21:29 2010
@@ -40,11 +40,16 @@
llvm_gcroot(javaThread, 0);
Jnjvm* vm = thread->getJVM();
+ // Wait some time to let the creator initialise these fields.
+ while ((thread->javaThread == NULL) || (thread->vmThread == NULL)) {
+ mvm::Thread::yield();
+ }
// Ok, now that the thread is created we can set the the value of vmdata,
// which is the JavaThread object.
vmThread = (JavaObjectVMThread*)thread->vmThread;
assert(vmThread && "Didn't fix the vmThread of a j3 thread");
+ assert(vmThread->getVirtualTable());
JavaObjectVMThread::setVmdata(vmThread, thread);
UserClass* vmthClass = (UserClass*)JavaObject::getClass(vmThread);
@@ -58,7 +63,9 @@
if (!isDaemon) {
vm->threadSystem.enter();
}
-
+
+ assert(vmThread->getVirtualTable());
+ assert(javaThread->getVirtualTable());
// Run the VMThread::run function
vm->upcalls->runVMThread->invokeIntSpecial(vm, vmthClass, vmThread);
@@ -86,9 +93,13 @@
javaThread = vm->upcalls->assocThread->getInstanceObjectField(vmThread);
assert(javaThread && "VMThread with no Java equivalent");
- mvm::Thread* th = JavaThread::create(javaThread, vmThread, vm);
- if (!th) vm->outOfMemoryError();
- th->start((void (*)(mvm::Thread*))start);
+ mvm::Thread* mut = JavaThread::create(vm);
+
+ if (!mut) vm->outOfMemoryError();
+ mut->start((void (*)(mvm::Thread*))start);
+ // Now that the thread has been created, initialise its object fields.
+
+ JavaThread::j3Thread(mut)->initialise(javaThread, vmThread);
END_NATIVE_EXCEPTION
}
@@ -112,13 +123,13 @@
mvm::Thread::yield();
JavaThread* th = (JavaThread*)field->getInstanceObjectField(vmthread);
- th->interruptFlag = 1;
- JavaLock* lock = th->waitsOn;
+ th->lockingThread.interruptFlag = 1;
+ mvm::FatLock* lock = th->lockingThread.waitsOn;
// If the thread is blocked on a wait. We also verify nextWaiting in case
// the thread has been notified.
- if (lock && th->nextWaiting) {
- th->state = JavaThread::StateInterrupted;
+ if (lock && th->lockingThread.nextWaiting) {
+ th->lockingThread.state = mvm::LockingThread::StateInterrupted;
// Make sure the thread is waiting.
uint32 locked = 0;
@@ -130,10 +141,10 @@
}
// Interrupt the thread.
- th->varcond.signal();
+ th->lockingThread.varcond.signal();
// Release the lock if we acquired it.
- if (locked) lock->release(lock->getAssociatedObject());
+ if (locked) lock->release(lock->getAssociatedObject(), vm->lockSystem);
}
// Here we could also raise a signal for interrupting I/O
@@ -150,8 +161,8 @@
#endif
) {
JavaThread* th = JavaThread::get();
- uint32 interrupt = th->interruptFlag;
- th->interruptFlag = 0;
+ uint32 interrupt = th->lockingThread.interruptFlag;
+ th->lockingThread.interruptFlag = 0;
return (jboolean)interrupt;
}
@@ -168,7 +179,7 @@
Jnjvm* vm = JavaThread::get()->getJVM();
JavaField* field = vm->upcalls->vmdataVMThread;
JavaThread* th = (JavaThread*)field->getInstanceObjectField(vmthread);
- return (jboolean)th->interruptFlag;
+ return (jboolean)th->lockingThread.interruptFlag;
}
// Never throws.
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThrowable.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThrowable.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThrowable.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThrowable.inc Tue Nov 30 06:21:29 2010
@@ -105,7 +105,7 @@
// We don't have the bytes if the class was vmjc'ed.
if (sourceAtt && cl->getBytes()) {
- Reader reader(sourceAtt, cl->getBytesPtr());
+ Reader reader(sourceAtt, cl->bytes);
uint16 index = reader.readU2();
sourceName = vm->internalUTF8ToStr(cl->getConstantPool()->UTF8At(index));
}
@@ -146,9 +146,9 @@
sint32 index = 2;;
while (index != JavaArray::getSize(stack)) {
mvm::MethodInfo* MI = vm->IPToMethodInfo(ArrayPtr::getElement((ArrayPtr*)stack, index));
- if (MI->MethodType != 1) ++index;
+ if (!MI->isHighLevelMethod()) ++index;
else {
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
assert(meth && "Wrong stack trace");
if (meth->classDef->isAssignableFrom(vm->upcalls->newThrowable)) {
++index;
@@ -161,7 +161,7 @@
while (cur < JavaArray::getSize(stack)) {
mvm::MethodInfo* MI = vm->IPToMethodInfo(ArrayPtr::getElement((ArrayPtr*)stack, cur));
++cur;
- if (MI->MethodType == 1) ++size;
+ if (MI->isHighLevelMethod()) ++size;
}
result = (ArrayObject*)
@@ -170,8 +170,8 @@
cur = 0;
for (sint32 i = index; i < JavaArray::getSize(stack); ++i) {
mvm::MethodInfo* MI = vm->IPToMethodInfo(ArrayPtr::getElement((ArrayPtr*)stack, i));
- if (MI->MethodType == 1) {
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ if (MI->isHighLevelMethod()) {
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
ArrayObject::setElement(result, consStackElement(meth, ArrayPtr::getElement((ArrayPtr*)stack, i)), cur);
cur++;
}
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp Tue Nov 30 06:21:29 2010
@@ -15,6 +15,7 @@
#include "JavaThread.h"
#include "JavaUpcalls.h"
#include "Jnjvm.h"
+#include "ReferenceQueue.h"
#define COMPILE_METHODS(cl) \
for (CommonClass::method_iterator i = cl->virtualMethods.begin(), \
@@ -292,28 +293,28 @@
CreateJavaThread(vm, JavaThread::j3Thread(vm->getFinalizerThread()), "Finalizer", SystemGroup);
// Create the enqueue thread.
- assert(vm->getEnqueueThread() && "VM did not set its enqueue thread");
- CreateJavaThread(vm, JavaThread::j3Thread(vm->getEnqueueThread()), "Reference", SystemGroup);
+ assert(vm->getReferenceThread() && "VM did not set its enqueue thread");
+ CreateJavaThread(vm, JavaThread::j3Thread(vm->getReferenceThread()), "Reference", SystemGroup);
}
-extern "C" void nativeInitWeakReference(JavaObjectReference* reference,
- JavaObject* referent) {
-
+extern "C" void Java_java_lang_ref_WeakReference__0003Cinit_0003E__Ljava_lang_Object_2(
+ JavaObjectReference* reference, JavaObject* referent) {
llvm_gcroot(reference, 0);
llvm_gcroot(referent, 0);
BEGIN_NATIVE_EXCEPTION(0)
JavaObjectReference::init(reference, referent, 0);
- JavaThread::get()->getJVM()->addWeakReference(reference);
+ JavaThread::get()->getJVM()->getReferenceThread()->addWeakReference(reference);
END_NATIVE_EXCEPTION
}
-extern "C" void nativeInitWeakReferenceQ(JavaObjectReference* reference,
- JavaObject* referent,
- JavaObject* queue) {
+extern "C" void Java_java_lang_ref_WeakReference__0003Cinit_0003E__Ljava_lang_Object_2Ljava_lang_ref_ReferenceQueue_2(
+ JavaObjectReference* reference,
+ JavaObject* referent,
+ JavaObject* queue) {
llvm_gcroot(reference, 0);
llvm_gcroot(referent, 0);
llvm_gcroot(queue, 0);
@@ -321,29 +322,30 @@
BEGIN_NATIVE_EXCEPTION(0)
JavaObjectReference::init(reference, referent, queue);
- JavaThread::get()->getJVM()->addWeakReference(reference);
+ JavaThread::get()->getJVM()->getReferenceThread()->addWeakReference(reference);
END_NATIVE_EXCEPTION
}
-extern "C" void nativeInitSoftReference(JavaObjectReference* reference,
- JavaObject* referent) {
+extern "C" void Java_java_lang_ref_SoftReference__0003Cinit_0003E__Ljava_lang_Object_2(
+ JavaObjectReference* reference, JavaObject* referent) {
llvm_gcroot(reference, 0);
llvm_gcroot(referent, 0);
BEGIN_NATIVE_EXCEPTION(0)
JavaObjectReference::init(reference, referent, 0);
- JavaThread::get()->getJVM()->addSoftReference(reference);
+ JavaThread::get()->getJVM()->getReferenceThread()->addSoftReference(reference);
END_NATIVE_EXCEPTION
}
-extern "C" void nativeInitSoftReferenceQ(JavaObjectReference* reference,
- JavaObject* referent,
- JavaObject* queue) {
+extern "C" void Java_java_lang_ref_SoftReference__0003Cinit_0003E__Ljava_lang_Object_2Ljava_lang_ref_ReferenceQueue_2(
+ JavaObjectReference* reference,
+ JavaObject* referent,
+ JavaObject* queue) {
llvm_gcroot(reference, 0);
llvm_gcroot(referent, 0);
llvm_gcroot(queue, 0);
@@ -351,15 +353,16 @@
BEGIN_NATIVE_EXCEPTION(0)
JavaObjectReference::init(reference, referent, queue);
- JavaThread::get()->getJVM()->addSoftReference(reference);
+ JavaThread::get()->getJVM()->getReferenceThread()->addSoftReference(reference);
END_NATIVE_EXCEPTION
}
-extern "C" void nativeInitPhantomReferenceQ(JavaObjectReference* reference,
- JavaObject* referent,
- JavaObject* queue) {
+extern "C" void Java_java_lang_ref_PhantomReference__0003Cinit_0003E__Ljava_lang_Object_2Ljava_lang_ref_ReferenceQueue_2(
+ JavaObjectReference* reference,
+ JavaObject* referent,
+ JavaObject* queue) {
llvm_gcroot(reference, 0);
llvm_gcroot(referent, 0);
llvm_gcroot(queue, 0);
@@ -367,12 +370,13 @@
BEGIN_NATIVE_EXCEPTION(0)
JavaObjectReference::init(reference, referent, queue);
- JavaThread::get()->getJVM()->addPhantomReference(reference);
+ JavaThread::get()->getJVM()->getReferenceThread()->addPhantomReference(reference);
END_NATIVE_EXCEPTION
}
-extern "C" JavaString* nativeInternString(JavaString* obj) {
+extern "C" JavaString* Java_java_lang_VMString_intern__Ljava_lang_String_2(
+ JavaString* obj) {
const ArrayUInt16* array = 0;
JavaString* res = 0;
llvm_gcroot(obj, 0);
@@ -392,7 +396,7 @@
return res;
}
-extern "C" uint8 nativeIsArray(JavaObjectClass* klass) {
+extern "C" uint8 Java_java_lang_Class_isArray__(JavaObjectClass* klass) {
llvm_gcroot(klass, 0);
UserCommonClass* cl = 0;
@@ -405,7 +409,7 @@
return (uint8)cl->isArray();
}
-extern "C" JavaObject* nativeGetCallingClass() {
+extern "C" JavaObject* Java_gnu_classpath_VMStackWalker_getCallingClass__() {
JavaObject* res = 0;
llvm_gcroot(res, 0);
@@ -421,7 +425,7 @@
return res;
}
-extern "C" JavaObject* nativeGetCallingClassLoader() {
+extern "C" JavaObject* Java_gnu_classpath_VMStackWalker_getCallingClassLoader__() {
JavaObject* res = 0;
llvm_gcroot(res, 0);
@@ -437,7 +441,7 @@
return res;
}
-extern "C" JavaObject* nativeFirstNonNullClassLoader() {
+extern "C" JavaObject* Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader__() {
JavaObject* res = 0;
llvm_gcroot(res, 0);
@@ -451,7 +455,7 @@
return res;
}
-extern "C" JavaObject* nativeGetCallerClass(uint32 index) {
+extern "C" JavaObject* Java_sun_reflect_Reflection_getCallerClass__I(uint32 index) {
JavaObject* res = 0;
llvm_gcroot(res, 0);
@@ -468,12 +472,13 @@
return res;
}
-extern "C" JavaObject* nativeGetAnnotation(JavaObject* obj) {
+extern "C" JavaObject* Java_java_lang_reflect_AccessibleObject_getAnnotation__Ljava_lang_Class_2(
+ JavaObject* obj) {
llvm_gcroot(obj, 0);
return 0;
}
-extern "C" JavaObject* nativeGetDeclaredAnnotations() {
+extern "C" JavaObject* Java_java_lang_reflect_AccessibleObject_getDeclaredAnnotations__() {
JavaObject* res = 0;
llvm_gcroot(res, 0);
@@ -488,8 +493,6 @@
return res;
}
-extern "C" void nativePropertiesPostInit(JavaObject* prop);
-
extern "C" void nativeJavaObjectClassTracer(
JavaObjectClass* obj, uintptr_t closure) {
JavaObjectClass::staticTracer(obj, closure);
@@ -520,10 +523,7 @@
JavaObjectVMThread::staticDestructor(obj);
}
-// Defined in Classpath/ClasspathVMClassLoader.cpp
-extern "C" ArrayObject* nativeGetBootPackages();
-
-extern "C" JavaString* nativeGetenv(JavaString* str) {
+extern "C" JavaString* Java_java_lang_VMSystem_getenv__Ljava_lang_String_2(JavaString* str) {
JavaString* ret = 0;
llvm_gcroot(str, 0);
llvm_gcroot(ret, 0);
@@ -748,12 +748,11 @@
JavaMethod* internString =
UPCALL_METHOD(loader, "java/lang/VMString", "intern",
"(Ljava/lang/String;)Ljava/lang/String;", ACC_STATIC);
- internString->setCompiledPtr((void*)(intptr_t)nativeInternString,
- "nativeInternString");
+ internString->setNative();
JavaMethod* isArray =
UPCALL_METHOD(loader, "java/lang/Class", "isArray", "()Z", ACC_VIRTUAL);
- isArray->setCompiledPtr((void*)(intptr_t)nativeIsArray, "nativeIsArray");
+ isArray->setNative();
UPCALL_REFLECT_CLASS_EXCEPTION(loader, InvocationTargetException);
@@ -944,61 +943,51 @@
JavaMethod* getEnv =
UPCALL_METHOD(loader, "java/lang/VMSystem", "getenv",
"(Ljava/lang/String;)Ljava/lang/String;", ACC_STATIC);
- getEnv->setCompiledPtr((void*)(intptr_t)nativeGetenv, "nativeGetenv");
+ getEnv->setNative();
JavaMethod* getCallingClass =
UPCALL_METHOD(loader, "gnu/classpath/VMStackWalker", "getCallingClass",
"()Ljava/lang/Class;", ACC_STATIC);
- getCallingClass->setCompiledPtr((void*)(intptr_t)nativeGetCallingClass,
- "nativeGetCallingClass");
+ getCallingClass->setNative();
JavaMethod* getCallingClassLoader =
UPCALL_METHOD(loader, "gnu/classpath/VMStackWalker", "getCallingClassLoader",
"()Ljava/lang/ClassLoader;", ACC_STATIC);
- getCallingClassLoader->setCompiledPtr((void*)(intptr_t)
- nativeGetCallingClassLoader,
- "nativeGetCallingClassLoader");
+ getCallingClassLoader->setNative();
JavaMethod* firstNonNullClassLoader =
UPCALL_METHOD(loader, "gnu/classpath/VMStackWalker", "firstNonNullClassLoader",
"()Ljava/lang/ClassLoader;", ACC_STATIC);
- firstNonNullClassLoader->setCompiledPtr((void*)(intptr_t)
- nativeFirstNonNullClassLoader,
- "nativeFirstNonNullClassLoader");
+ firstNonNullClassLoader->setNative();
JavaMethod* getCallerClass =
UPCALL_METHOD(loader, "sun/reflect/Reflection", "getCallerClass",
"(I)Ljava/lang/Class;", ACC_STATIC);
- getCallerClass->setCompiledPtr((void*)(intptr_t)nativeGetCallerClass,
- "nativeGetCallerClass");
+ getCallerClass->setNative();
JavaMethod* postProperties =
UPCALL_METHOD(loader, "gnu/classpath/VMSystemProperties", "postInit",
"(Ljava/util/Properties;)V", ACC_STATIC);
- postProperties->setCompiledPtr((void*)(intptr_t)nativePropertiesPostInit,
- "nativePropertiesPostInit");
+ postProperties->setNative();
// Also implement these twos, implementation in GNU Classpath 0.97.2 is buggy.
JavaMethod* getAnnotation =
UPCALL_METHOD(loader, "java/lang/reflect/AccessibleObject", "getAnnotation",
"(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;",
ACC_VIRTUAL);
- getAnnotation->setCompiledPtr((void*)(intptr_t)nativeGetAnnotation,
- "nativeGetAnnotation");
+ getAnnotation->setNative();
JavaMethod* getAnnotations =
UPCALL_METHOD(loader, "java/lang/reflect/AccessibleObject",
"getDeclaredAnnotations",
"()[Ljava/lang/annotation/Annotation;",
ACC_VIRTUAL);
- getAnnotations->setCompiledPtr((void*)(intptr_t)nativeGetDeclaredAnnotations,
- "nativeGetDeclaredAnnotations");
+ getAnnotations->setNative();
JavaMethod* getBootPackages =
UPCALL_METHOD(loader, "java/lang/VMClassLoader", "getBootPackages",
"()[Ljava/lang/String;", ACC_STATIC);
- getBootPackages->setCompiledPtr((void*)(intptr_t)nativeGetBootPackages,
- "nativeGetBootPackages");
+ getBootPackages->setNative();
//===----------------------------------------------------------------------===//
//
@@ -1044,58 +1033,31 @@
UPCALL_METHOD(loader, "java/lang/ref/WeakReference", "<init>",
"(Ljava/lang/Object;)V",
ACC_VIRTUAL);
- initWeakReference->setCompiledPtr((void*)(intptr_t)nativeInitWeakReference,
- "nativeInitWeakReference");
+ initWeakReference->setNative();
initWeakReference =
UPCALL_METHOD(loader, "java/lang/ref/WeakReference", "<init>",
"(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V",
ACC_VIRTUAL);
- initWeakReference->setCompiledPtr((void*)(intptr_t)nativeInitWeakReferenceQ,
- "nativeInitWeakReferenceQ");
+ initWeakReference->setNative();
JavaMethod* initSoftReference =
UPCALL_METHOD(loader, "java/lang/ref/SoftReference", "<init>",
"(Ljava/lang/Object;)V",
ACC_VIRTUAL);
- initSoftReference->setCompiledPtr((void*)(intptr_t)nativeInitSoftReference,
- "nativeInitSoftReference");
+ initSoftReference->setNative();
initSoftReference =
- UPCALL_METHOD(loader, "java/lang/ref/WeakReference", "<init>",
+ UPCALL_METHOD(loader, "java/lang/ref/SoftReference", "<init>",
"(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V",
ACC_VIRTUAL);
- initSoftReference->setCompiledPtr((void*)(intptr_t)nativeInitSoftReferenceQ,
- "nativeInitSoftReferenceQ");
+ initSoftReference->setNative();
JavaMethod* initPhantomReference =
UPCALL_METHOD(loader, "java/lang/ref/PhantomReference", "<init>",
"(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V",
ACC_VIRTUAL);
- initPhantomReference->setCompiledPtr(
- (void*)(intptr_t)nativeInitPhantomReferenceQ,
- "nativeInitPhantomReferenceQ");
-
-
-}
-
-gc** Jnjvm::getReferentPtr(gc* _obj) {
- JavaObjectReference* obj = (JavaObjectReference*)_obj;
- llvm_gcroot(obj, 0);
- return (gc**)JavaObjectReference::getReferentPtr(obj);
-}
-
-void Jnjvm::setReferent(gc* _obj, gc* val) {
- JavaObjectReference* obj = (JavaObjectReference*)_obj;
- llvm_gcroot(obj, 0);
- llvm_gcroot(val, 0);
- JavaObjectReference::setReferent(obj, (JavaObject*)val);
-}
-
-void Jnjvm::clearReferent(gc* _obj) {
- JavaObjectReference* obj = (JavaObjectReference*)_obj;
- llvm_gcroot(obj, 0);
- JavaObjectReference::setReferent(obj, NULL);
+ initPhantomReference->setNative();
}
#include "ClasspathConstructor.inc"
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/ExceptionsCheck.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/ExceptionsCheck.inc?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/ExceptionsCheck.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/ExceptionsCheck.inc Tue Nov 30 06:21:29 2010
@@ -501,7 +501,6 @@
// Restore currentBlock.
currentBlock = temp;
return nbe;
-
}
void JavaJIT::finishExceptions() {
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/J3Intrinsics.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/J3Intrinsics.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/J3Intrinsics.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/J3Intrinsics.cpp Tue Nov 30 06:21:29 2010
@@ -185,6 +185,7 @@
ResolveVirtualStubFunction = module->getFunction("j3ResolveVirtualStub");
ResolveStaticStubFunction = module->getFunction("j3ResolveStaticStub");
ResolveSpecialStubFunction = module->getFunction("j3ResolveSpecialStub");
+ ResolveInterfaceFunction = module->getFunction("j3ResolveInterface");
NullPointerExceptionFunction =
module->getFunction("j3NullPointerException");
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp Tue Nov 30 06:21:29 2010
@@ -167,6 +167,7 @@
}
Constant* JavaAOTCompiler::getString(JavaString* str) {
+ assert(!useCooperativeGC());
string_iterator SI = strings.find(str);
if (SI != strings.end()) {
return SI->second;
@@ -306,6 +307,7 @@
Constant* JavaAOTCompiler::getFinalObject(JavaObject* obj, CommonClass* objCl) {
+ assert(!useCooperativeGC());
llvm::GlobalVariable* varGV = 0;
final_object_iterator End = finalObjects.end();
final_object_iterator I = finalObjects.find(obj);
@@ -444,7 +446,7 @@
Elts.push_back(Constant::getNullValue(Ty));
}
} else {
- Reader reader(attribut, &(cl->bytes));
+ Reader reader(attribut, cl->bytes);
JavaConstantPool * ctpInfo = cl->ctpInfo;
uint16 idx = reader.readU2();
if (type->isPrimitive()) {
@@ -1482,6 +1484,7 @@
if (!VT->IMT) {
Elemts.push_back(Constant::getNullValue(PTy));
} else {
+ // TODO: add a null element at the end to diagnose errors.
Class* cl = classDef->asClass();
assert(cl && "Not a class");
std::set<JavaMethod*> contents[InterfaceMethodTable::NumIndexes];
@@ -1851,8 +1854,7 @@
void JavaAOTCompiler::makeIMT(Class* cl) {
}
-void JavaAOTCompiler::setMethod(JavaMethod* meth, void* ptr, const char* name) {
- Function* func = getMethodInfo(meth)->getMethod();
+void JavaAOTCompiler::setMethod(Function* func, void* ptr, const char* name) {
func->setName(name);
func->setLinkage(GlobalValue::ExternalLinkage);
}
@@ -1903,14 +1905,14 @@
-void extractFiles(ArrayUInt8* bytes,
+void extractFiles(ClassBytes* bytes,
JavaAOTCompiler* M,
JnjvmBootstrapLoader* bootstrapLoader,
std::vector<Class*>& classes) {
ZipArchive archive(bytes, bootstrapLoader->allocator);
- mvm::ThreadAllocator allocator;
- char* realName = (char*)allocator.Allocate(4096);
+ mvm::BumpPtrAllocator allocator;
+ char* realName = (char*)allocator.Allocate(4096, "temp");
for (ZipArchive::table_iterator i = archive.filetable.begin(),
e = archive.filetable.end(); i != e; ++i) {
ZipFile* file = i->second;
@@ -1927,9 +1929,7 @@
classes.push_back(cl);
} else if (size > 4 && (!strcmp(&name[size - 4], ".jar") ||
!strcmp(&name[size - 4], ".zip"))) {
- UserClassArray* array = bootstrapLoader->upcalls->ArrayOfByte;
- ArrayUInt8* res =
- (ArrayUInt8*)array->doNew(file->ucsize, JavaThread::get()->getJVM());
+ ClassBytes* res = new (allocator, file->ucsize) ClassBytes(file->ucsize);
int ok = archive.readFile(res, file);
if (!ok) return;
@@ -1958,6 +1958,9 @@
if (!M->clinits->empty()) {
Comp = JavaJITCompiler::CreateCompiler("JIT");
Comp->EmitFunctionName = true;
+ if (!M->useCooperativeGC()) {
+ Comp->disableCooperativeGC();
+ }
bootstrapLoader->setCompiler(Comp);
bootstrapLoader->analyseClasspathEnv(vm->classpath);
} else {
@@ -1970,7 +1973,7 @@
(!strcmp(&name[size - 4], ".jar") || !strcmp(&name[size - 4], ".zip"))) {
std::vector<Class*> classes;
- ArrayUInt8* bytes = Reader::openFile(bootstrapLoader, name);
+ ClassBytes* bytes = Reader::openFile(bootstrapLoader, name);
if (!bytes) {
fprintf(stderr, "Can't find zip file.\n");
@@ -1979,7 +1982,7 @@
extractFiles(bytes, M, bootstrapLoader, classes);
// Now that we know if we can trust this compiler, add the Java passes.
- M->addJavaPasses(M->compileRT);
+ M->addJavaPasses();
// First resolve everyone so that there can not be unknown references in
@@ -2057,7 +2060,7 @@
}
} else {
- M->addJavaPasses(false);
+ M->addJavaPasses();
char* realName = (char*)allocator.Allocate(size + 1);
if (size > 6 && !strcmp(&name[size - 6], ".class")) {
memcpy(realName, name, size - 6);
@@ -2130,7 +2133,7 @@
void JavaAOTCompiler::compileFile(Jnjvm* vm, const char* n) {
name = n;
- mvm::Thread* th = JavaThread::create(0, 0, vm);
+ mvm::Thread* th = JavaThread::create(vm);
vm->setMainThread(th);
th->start(mainCompilerStart);
vm->waitForExit();
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.cpp Tue Nov 30 06:21:29 2010
@@ -202,8 +202,7 @@
Args.push_back(TheCompiler->getNativeClass(compilingClass));
Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index));
Args.push_back(GV);
- Value* targetObject = getTarget(virtualType->param_end(),
- signature->nbArguments + 1);
+ Value* targetObject = getTarget(signature);
Args.push_back(new LoadInst(
targetObject, "", TheCompiler->useCooperativeGC(), currentBlock));
load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock);
@@ -354,20 +353,23 @@
sint32 mnlen = jniConsName->size;
sint32 mtlen = jniConsType->size;
- char* functionName = (char*)alloca(3 + JNI_NAME_PRE_LEN +
- ((mnlen + clen + mtlen) << 3));
+ mvm::ThreadAllocator allocator;
+ char* functionName = (char*)allocator.Allocate(
+ 3 + JNI_NAME_PRE_LEN + ((mnlen + clen + mtlen) << 3));
- if (!natPtr)
+ if (!natPtr) {
natPtr = compilingClass->classLoader->nativeLookup(compilingMethod, j3,
functionName);
+ }
if (!natPtr && !TheCompiler->isStaticCompiling()) {
currentBlock = createBasicBlock("start");
CallInst::Create(intrinsics->ThrowExceptionFromJITFunction, "", currentBlock);
- if (returnType != Type::getVoidTy(*llvmContext))
+ if (returnType != Type::getVoidTy(*llvmContext)) {
ReturnInst::Create(*llvmContext, Constant::getNullValue(returnType), currentBlock);
- else
+ } else {
ReturnInst::Create(*llvmContext, currentBlock);
+ }
PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s.%s\n",
UTF8Buffer(compilingClass->name).cString(),
@@ -379,8 +381,25 @@
Function* func = llvmFunction;
if (j3) {
- compilingMethod->setCompiledPtr((void*)natPtr, functionName);
- llvmFunction->clearGC();
+ Function* callee = Function::Create(llvmFunction->getFunctionType(),
+ GlobalValue::ExternalLinkage,
+ functionName,
+ llvmFunction->getParent());
+ TheCompiler->setMethod(callee, (void*)natPtr, functionName);
+ currentBlock = createBasicBlock("start");
+ std::vector<Value*> args;
+ for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end();
+ i != e;
+ i++) {
+ args.push_back(i);
+ }
+ Value* res = CallInst::Create(
+ callee, args.begin(), args.end(), "", currentBlock);
+ if (returnType != Type::getVoidTy(*llvmContext)) {
+ ReturnInst::Create(*llvmContext, res, currentBlock);
+ } else {
+ ReturnInst::Create(*llvmContext, currentBlock);
+ }
return llvmFunction;
}
@@ -402,7 +421,7 @@
Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), "",
currentBlock);
- Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), 2 * sizeof(void*));
+ Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), sizeof(mvm::KnownFrame));
Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock);
uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0);
@@ -576,18 +595,6 @@
UTF8Buffer(compilingClass->name).cString(),
UTF8Buffer(compilingMethod->name).cString());
- if (codeInfo.size()) {
- compilingMethod->codeInfo = new CodeLineInfo[codeInfo.size()];
- for (uint32 i = 0; i < codeInfo.size(); i++) {
- compilingMethod->codeInfo[i].lineNumber = codeInfo[i].lineNumber;
- compilingMethod->codeInfo[i].ctpIndex = codeInfo[i].ctpIndex;
- compilingMethod->codeInfo[i].bytecodeIndex = codeInfo[i].bytecodeIndex;
- compilingMethod->codeInfo[i].bytecode = codeInfo[i].bytecode;
- }
- } else {
- compilingMethod->codeInfo = NULL;
- }
-
return llvmFunction;
}
@@ -601,7 +608,7 @@
Value* lock = new LoadInst(lockPtr, "", currentBlock);
lock = new PtrToIntInst(lock, intrinsics->pointerSizeType, "", currentBlock);
Value* NonLockBitsMask = ConstantInt::get(intrinsics->pointerSizeType,
- mvm::NonLockBitsMask);
+ mvm::ThinLock::NonLockBitsMask);
lock = BinaryOperator::CreateAnd(lock, NonLockBitsMask, "", currentBlock);
@@ -651,7 +658,7 @@
"", currentBlock);
Value* lock = new LoadInst(lockPtr, "", currentBlock);
Value* NonLockBitsMask = ConstantInt::get(
- intrinsics->pointerSizeType, mvm::NonLockBitsMask);
+ intrinsics->pointerSizeType, mvm::ThinLock::NonLockBitsMask);
Value* lockedMask = BinaryOperator::CreateAnd(
lock, NonLockBitsMask, "", currentBlock);
@@ -794,7 +801,7 @@
abort();
}
- Reader reader(codeAtt, &(compilingClass->bytes));
+ Reader reader(codeAtt, compilingClass->bytes);
uint16 maxStack = reader.readU2();
uint16 maxLocals = reader.readU2();
uint32 codeLen = reader.readU4();
@@ -931,23 +938,6 @@
readExceptionTable(reader, codeLen);
- // Lookup line number table attribute.
- uint16 nba = reader.readU2();
- for (uint16 i = 0; i < nba; ++i) {
- const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2());
- uint32 attLen = reader.readU4();
- if (attName->equals(Attribut::lineNumberTableAttribut)) {
- uint16 lineLength = reader.readU2();
- for (uint16 i = 0; i < lineLength; ++i) {
- uint16 pc = reader.readU2();
- uint16 ln = reader.readU2();
- opcodeInfos[pc].lineNumber = ln;
- }
- } else {
- reader.seek(attLen, Reader::SeekCur);
- }
- }
-
reader.cursor = start;
exploreOpcodes(reader, codeLen);
@@ -1001,7 +991,7 @@
abort();
}
- Reader reader(codeAtt, &(compilingClass->bytes));
+ Reader reader(codeAtt, compilingClass->bytes);
uint16 maxStack = reader.readU2();
uint16 maxLocals = reader.readU2();
uint32 codeLen = reader.readU4();
@@ -1179,23 +1169,6 @@
readExceptionTable(reader, codeLen);
- // Lookup line number table attribute.
- uint16 nba = reader.readU2();
- for (uint16 i = 0; i < nba; ++i) {
- const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2());
- uint32 attLen = reader.readU4();
- if (attName->equals(Attribut::lineNumberTableAttribut)) {
- uint16 lineLength = reader.readU2();
- for (uint16 i = 0; i < lineLength; ++i) {
- uint16 pc = reader.readU2();
- uint16 ln = reader.readU2();
- opcodeInfos[pc].lineNumber = ln;
- }
- } else {
- reader.seek(attLen, Reader::SeekCur);
- }
- }
-
reader.cursor = start;
exploreOpcodes(reader, codeLen);
@@ -1213,7 +1186,6 @@
Value* YieldPtr = getDoYieldPtr(getMutatorThreadPtr());
Value* Yield = new LoadInst(YieldPtr, "", currentBlock);
- Yield = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, Yield, intrinsics->constantInt8Zero, "");
BasicBlock* continueBlock = createBasicBlock("After safe point");
BasicBlock* yieldBlock = createBasicBlock("In safe point");
@@ -1360,7 +1332,7 @@
compilingMethod->lookupAttribut(Attribut::annotationsAttribut);
if (annotationsAtt) {
- Reader reader(annotationsAtt, &(compilingClass->bytes));
+ Reader reader(annotationsAtt, compilingClass->bytes);
AnnotationReader AR(reader, compilingClass);
uint16 numAnnotations = reader.readU2();
for (uint16 i = 0; i < numAnnotations; ++i) {
@@ -1375,18 +1347,6 @@
}
}
- if (codeInfo.size()) {
- compilingMethod->codeInfo = new CodeLineInfo[codeInfo.size()];
- for (uint32 i = 0; i < codeInfo.size(); i++) {
- compilingMethod->codeInfo[i].lineNumber = codeInfo[i].lineNumber;
- compilingMethod->codeInfo[i].ctpIndex = codeInfo[i].ctpIndex;
- compilingMethod->codeInfo[i].bytecodeIndex = codeInfo[i].bytecodeIndex;
- compilingMethod->codeInfo[i].bytecode = codeInfo[i].bytecode;
- }
- } else {
- compilingMethod->codeInfo = NULL;
- }
-
return llvmFunction;
}
@@ -1553,26 +1513,16 @@
}
}
-Value* JavaJIT::getTarget(FunctionType::param_iterator it, uint32 nb) {
-#if defined(ISOLATE_SHARING)
- nb += 1;
-#endif
-#if defined(ISOLATE_SHARING)
- sint32 start = nb - 2;
- it--;
- it--;
-#else
- sint32 start = nb - 1;
-#endif
- uint32 nbObjects = 0;
- for (sint32 i = start; i >= 0; --i) {
- it--;
- if (it->get() == intrinsics->JavaObjectType) {
- nbObjects++;
+Value* JavaJIT::getTarget(Signdef* signature) {
+ int offset = 0;
+ Typedef* const* arguments = signature->getArgumentsType();
+ for (uint32 i = 0; i < signature->nbArguments; i++) {
+ if (arguments[i]->isDouble() || arguments[i]->isLong()) {
+ offset++;
}
+ offset++;
}
- assert(nbObjects > 0 && "No this");
- return objectStack[currentStackIndex - nbObjects];
+ return objectStack[currentStackIndex - 1 - offset];
}
Instruction* JavaJIT::lowerMathOps(const UTF8* name,
@@ -1997,14 +1947,15 @@
intrinsics->AllocateUnresolvedFunction,
Size, VT, "", currentBlock);
+ addHighLevelType(val, cl ? cl : upcalls->OfObject);
+ Instruction* res = new BitCastInst(val, intrinsics->JavaObjectType, "", currentBlock);
+ push(res, false, cl ? cl : upcalls->OfObject);
+
+ // Make sure to add the object to the finalization list after it has been
+ // pushed.
if (cl && cl->virtualVT->destructor) {
CallInst::Create(intrinsics->AddFinalizationCandidate, val, "", currentBlock);
}
-
-
- addHighLevelType(val, cl ? cl : upcalls->OfObject);
- val = new BitCastInst(val, intrinsics->JavaObjectType, "", currentBlock);
- push(val, false, cl ? cl : upcalls->OfObject);
}
Value* JavaJIT::ldResolved(uint16 index, bool stat, Value* object,
@@ -2168,7 +2119,7 @@
abort();
}
} else {
- if (TheCompiler->isStaticCompiling()) {
+ if (TheCompiler->isStaticCompiling() && !TheCompiler->useCooperativeGC()) {
JavaObject* val = field->getStaticObjectField();
JnjvmClassLoader* JCL = field->classDef->classLoader;
Value* V = TheCompiler->getFinalObject(val, sign->assocClass(JCL));
@@ -2280,7 +2231,7 @@
}
-void JavaJIT::invokeInterface(uint16 index, bool buggyVirtual) {
+void JavaJIT::invokeInterface(uint16 index) {
// Do the usual
JavaConstantPool* ctpInfo = compilingClass->ctpInfo;
@@ -2292,13 +2243,7 @@
const llvm::PointerType* virtualPtrType = LSI->getVirtualPtrType();
const llvm::Type* retType = virtualType->getReturnType();
- BasicBlock* endBlock = createBasicBlock("end interface invoke");
- PHINode * node = 0;
- if (retType != Type::getVoidTy(*llvmContext)) {
- node = PHINode::Create(retType, "", endBlock);
- }
-
-
+
CommonClass* cl = 0;
JavaMethod* meth = 0;
ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth);
@@ -2311,13 +2256,17 @@
intrinsics->JavaMethodType, 0, true);
}
- // Compute the arguments after calling getConstantPoolAt because the
- // arguments will be loaded and the runtime may trigger GC.
- std::vector<Value*> args; // size = [signature->nbIn + 3];
-
- FunctionType::param_iterator it = virtualType->param_end();
- makeArgs(it, index, args, signature->nbArguments + 1);
- JITVerifyNull(args[0]);
+ uint32_t tableIndex = InterfaceMethodTable::getIndex(name, signature->keyName);
+ Constant* Index = ConstantInt::get(Type::getInt32Ty(*llvmContext),
+ tableIndex);
+ Value* targetObject = getTarget(signature);
+ targetObject = new LoadInst(
+ targetObject, "", TheCompiler->useCooperativeGC(), currentBlock);
+ JITVerifyNull(targetObject);
+ // TODO: The following code needs more testing.
+#if 0
+ BasicBlock* endBlock = createBasicBlock("end interface invoke");
+ PHINode * node = PHINode::Create(virtualPtrType, "", endBlock);
BasicBlock* label_bb = createBasicBlock("bb");
BasicBlock* label_bb4 = createBasicBlock("bb4");
@@ -2325,14 +2274,11 @@
BasicBlock* label_bb7 = createBasicBlock("bb7");
// Block entry (label_entry)
- Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "",
+ Value* VT = CallInst::Create(intrinsics->GetVTFunction, targetObject, "",
currentBlock);
Value* IMT = CallInst::Create(intrinsics->GetIMTFunction, VT, "",
currentBlock);
- uint32_t tableIndex = InterfaceMethodTable::getIndex(name, signature->keyName);
- Constant* Index = ConstantInt::get(Type::getInt32Ty(*llvmContext),
- tableIndex);
Value* indices[2] = { intrinsics->constantZero, Index };
Instruction* ptr_18 = GetElementPtrInst::Create(IMT, indices, indices + 2, "",
@@ -2351,8 +2297,8 @@
// Block bb (label_bb)
currentBlock = label_bb;
CastInst* ptr_22 = new IntToPtrInst(int32_19, virtualPtrType, "", currentBlock);
- Value* ret = invoke(ptr_22, args, "", currentBlock);
- if (node) node->addIncoming(ret, currentBlock);
+
+ node->addIncoming(ptr_22, currentBlock);
BranchInst::Create(endBlock, currentBlock);
// Block bb4 (label_bb4)
@@ -2381,8 +2327,8 @@
LoadInst* int32_32 = new LoadInst(ptr_31, "", false, currentBlock);
CastInst* ptr_33 = new BitCastInst(int32_32, virtualPtrType, "",
currentBlock);
- ret = invoke(ptr_33, args, "", currentBlock);
- if (node) node->addIncoming(ret, currentBlock);
+ node->addIncoming(ptr_33, currentBlock);
+
BranchInst::Create(endBlock, currentBlock);
// Block bb7 (label_bb7)
@@ -2413,12 +2359,27 @@
ptr_table_0_lcssa->addIncoming(ptr_37, currentBlock);
currentBlock = endBlock;
- if (node) {
- if (node->getType() == intrinsics->JavaObjectType) {
+#else
+ std::vector<Value*> Args;
+ Args.push_back(targetObject);
+ Args.push_back(Meth);
+ Args.push_back(Index);
+ Value* node =
+ invoke(intrinsics->ResolveInterfaceFunction, Args, "", currentBlock);
+ node = new BitCastInst(node, virtualPtrType, "", currentBlock);
+#endif
+
+ std::vector<Value*> args; // size = [signature->nbIn + 3];
+ FunctionType::param_iterator it = virtualType->param_end();
+ makeArgs(it, index, args, signature->nbArguments + 1);
+ JITVerifyNull(args[0]);
+ Value* ret = invoke(node, args, "", currentBlock);
+ if (retType != Type::getVoidTy(*llvmContext)) {
+ if (ret->getType() == intrinsics->JavaObjectType) {
JnjvmClassLoader* JCL = compilingClass->classLoader;
- push(node, false, signature->getReturnType()->findAssocClass(JCL));
+ push(ret, false, signature->getReturnType()->findAssocClass(JCL));
} else {
- push(node, signature->getReturnType()->isUnsigned());
+ push(ret, signature->getReturnType()->isUnsigned());
if (retType == Type::getDoubleTy(*llvmContext) ||
retType == Type::getInt64Ty(*llvmContext)) {
push(intrinsics->constantZero, false);
@@ -2661,10 +2622,7 @@
}
DebugLoc JavaJIT::CreateLocation() {
- LineInfo LI = { currentLineNumber, currentCtpIndex, currentBytecodeIndex,
- currentBytecode };
- codeInfo.push_back(LI);
- DebugLoc DL = DebugLoc::get(callNumber++, 0, DbgSubprogram);
+ DebugLoc DL = DebugLoc::get(currentBytecodeIndex, 0, DbgSubprogram);
return DL;
}
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaJIT.h Tue Nov 30 06:21:29 2010
@@ -58,19 +58,9 @@
/// stack - The stack at this location if there is a new block
///
std::vector<CommonClass*> stack;
-
- /// lineNumber - The line number of this bytecode.
- uint16 lineNumber;
};
-struct LineInfo {
- uint16 lineNumber;
- uint16 ctpIndex;
- uint16 bytecodeIndex;
- uint16 bytecode;
-};
-
/// JavaJIT - The compilation engine of J3. Parses the bycode and returns
/// its LLVM representation.
///
@@ -90,11 +80,7 @@
callsStackWalker = false;
endNode = 0;
currentStackIndex = 0;
- currentLineNumber = 0;
currentBytecodeIndex = 0;
- currentCtpIndex = -1;
- currentBytecode = -1;
- callNumber = 0;
thisObject = NULL;
}
@@ -180,27 +166,12 @@
llvm::MDNode* DbgSubprogram;
- /// currentLineIndex - The current line being processed.
- uint16 currentLineNumber;
-
/// currentBytecodeIndex - The current bytecode being processed.
uint16 currentBytecodeIndex;
- /// currentCtpIndex - The constant pool index being processed.
- uint16 currentCtpIndex;
-
- /// currentBytecode - The bytecode being processed.
- uint16 currentBytecode;
-
- /// callNumber - The number of a call for a single opcode.
- uint16 callNumber;
-
/// CreateLocation - Create debug information for a call.
llvm::DebugLoc CreateLocation();
- // codeInfo - List of LineInfo for this method.
- std::vector<LineInfo> codeInfo;
-
//===--------------------------- Inline support ---------------------------===//
/// inlineCompile - Parse the method and start its LLVM representation
@@ -494,15 +465,13 @@
uint32 index, std::vector<llvm::Value*>& result, uint32 nb);
/// getTarget - Get the target object for invocation.
- llvm::Value* getTarget(llvm::FunctionType::param_iterator it, uint32 nb);
+ llvm::Value* getTarget(Signdef* signature);
/// invokeVirtual - Invoke a Java virtual method.
void invokeVirtual(uint16 index);
- /// invokeInterface - Invoke a Java interface method. The buggyVirtual
- /// argument is for buggy java to bytecode compilers which emit a virtual
- /// call instead of an interface call in some occasions.
- void invokeInterface(uint16 index, bool buggyVirtual = false);
+ /// invokeInterface - Invoke a Java interface method.
+ void invokeInterface(uint16 index);
/// invokeSpecial - Invoke an instance Java method directly.
void invokeSpecial(uint16 index);
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp Tue Nov 30 06:21:29 2010
@@ -15,12 +15,14 @@
#include "llvm/Module.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/CodeGen/GCStrategy.h"
+#include <llvm/CodeGen/JITCodeEmitter.h>
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include <../lib/ExecutionEngine/JIT/JIT.h>
#include "MvmGC.h"
#include "mvm/VirtualMachine.h"
@@ -38,15 +40,18 @@
using namespace j3;
using namespace llvm;
-
class JavaJITMethodInfo : public mvm::JITMethodInfo {
public:
virtual void print(void* ip, void* addr);
+ virtual bool isHighLevelMethod() {
+ return true;
+ }
- JavaJITMethodInfo(llvm::GCFunctionInfo* GFI, JavaMethod* m) :
- mvm::JITMethodInfo(GFI) {
+ JavaJITMethodInfo(llvm::GCFunctionInfo* GFI,
+ JavaMethod* m) :
+ mvm::JITMethodInfo(GFI) {
MetaInfo = m;
- MethodType = 1;
+ Owner = m->classDef->classLoader->getCompiler();
}
};
@@ -55,10 +60,17 @@
if (ip) new_ip = isStub(ip, addr);
JavaMethod* meth = (JavaMethod*)MetaInfo;
CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip);
- fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", new_ip,
- UTF8Buffer(meth->classDef->name).cString(),
- UTF8Buffer(meth->name).cString(), info->lineNumber,
- info->bytecodeIndex, meth->code);
+ if (info != NULL) {
+ fprintf(stderr, "; %p (%p) in %s.%s (line %d, bytecode %d, code start %p)", new_ip, addr,
+ UTF8Buffer(meth->classDef->name).cString(),
+ UTF8Buffer(meth->name).cString(),
+ meth->lookupLineNumber((uintptr_t)ip),
+ info->bytecodeIndex, meth->code);
+ } else {
+ fprintf(stderr, "; %p (%p) in %s.%s (native method, code start %p)", new_ip, addr,
+ UTF8Buffer(meth->classDef->name).cString(),
+ UTF8Buffer(meth->name).cString(), meth->code);
+ }
if (ip != new_ip) fprintf(stderr, " (from stub)");
fprintf(stderr, "\n");
}
@@ -68,72 +80,17 @@
void *Code, size_t Size,
const EmittedFunctionDetails &Details) {
- // The following could be changed to an assert when -load-bc supports
- // the verifier.
+ // The following is necessary for -load-bc.
if (F.getParent() != TheCompiler->getLLVMModule()) return;
-
- Jnjvm* vm = JavaThread::get()->getJVM();
- mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator;
- llvm::GCFunctionInfo* GFI = 0;
-
- if (F.hasGC()) {
- if (TheCompiler->TheGCStrategy == NULL) {
- assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy");
- TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy;
- mvm::MvmModule::TheGCStrategy = NULL;
- }
- GCStrategy::iterator I = TheCompiler->TheGCStrategy->end();
- I--;
- while (&(*I)->getFunction() != &F) {
- // This happens when the compilation of a function was post-poned.
- assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info");
- I--;
- }
- assert(&(*I)->getFunction() == &F &&
- "GC Info and method do not correspond");
- GFI = *I;
- }
-
- JavaMethod* meth = TheCompiler->getJavaMethod(F);
- if (meth == NULL) {
- // This is a stub.
- mvm::MvmJITMethodInfo* MI = new(Alloc, "JITMethodInfo")
- mvm::MvmJITMethodInfo(GFI, &F);
- vm->RuntimeFunctions.addMethodInfo(MI, Code,
- (void*)((uintptr_t)Code + Size));
- } else {
- JavaJITMethodInfo* MI = new(Alloc, "JavaJITMethodInfo")
- JavaJITMethodInfo(GFI, meth);
- vm->RuntimeFunctions.addMethodInfo(MI, Code,
- (void*)((uintptr_t)Code + Size));
- uint32 infoLength = Details.LineStarts.size();
- meth->codeInfoLength = infoLength;
- if (infoLength > 0) {
- mvm::BumpPtrAllocator& JavaAlloc = meth->classDef->classLoader->allocator;
- CodeLineInfo* infoTable =
- new(JavaAlloc, "CodeLineInfo") CodeLineInfo[infoLength];
- for (uint32 i = 0; i < infoLength; ++i) {
- DebugLoc DL = Details.LineStarts[i].Loc;
- uint32_t first = DL.getLine();
- uint32_t second = DL.getCol();
- assert(second == 0 && "Wrong column number");
- infoTable[i].address = Details.LineStarts[i].Address;
- infoTable[i].lineNumber = meth->codeInfo[first].lineNumber;
- infoTable[i].bytecodeIndex = meth->codeInfo[first].bytecodeIndex;
- infoTable[i].ctpIndex = meth->codeInfo[first].ctpIndex;
- infoTable[i].bytecode = meth->codeInfo[first].bytecode;
- }
- delete[] meth->codeInfo;
- meth->codeInfo = infoTable;
- } else {
- if (meth->codeInfo != NULL) {
- delete[] meth->codeInfo;
- meth->codeInfo = NULL;
- }
- }
+ assert(F.hasGC());
+ if (TheCompiler->GCInfo != NULL) {
+ assert(TheCompiler->GCInfo == Details.MF->getGMI());
+ return;
}
+ TheCompiler->GCInfo = Details.MF->getGMI();
}
+
Constant* JavaJITCompiler::getNativeClass(CommonClass* classDef) {
const llvm::Type* Ty = classDef->isClass() ? JavaIntrinsics.JavaClassType :
JavaIntrinsics.JavaCommonClassType;
@@ -238,22 +195,17 @@
return ConstantExpr::getIntToPtr(CI, valPtrType);
}
-JavaJITCompiler::JavaJITCompiler(const std::string &ModuleID, bool trusted) :
+JavaJITCompiler::JavaJITCompiler(const std::string &ModuleID) :
JavaLLVMCompiler(ModuleID), listener(this) {
EmitFunctionName = false;
+ GCInfo = NULL;
- // Protect IR for the GC.
- mvm::MvmModule::protectIR();
executionEngine = ExecutionEngine::createJIT(TheModule, 0,
0, llvm::CodeGenOpt::Default, false);
- TheGCStrategy = mvm::MvmModule::TheGCStrategy;
- mvm::MvmModule::TheGCStrategy = NULL;
- mvm::MvmModule::unprotectIR();
-
executionEngine->RegisterJITEventListener(&listener);
- addJavaPasses(trusted);
+ addJavaPasses();
}
JavaJITCompiler::~JavaJITCompiler() {
@@ -320,6 +272,7 @@
std::set<JavaMethod*> contents[InterfaceMethodTable::NumIndexes];
cl->fillIMT(contents);
+
for (uint32_t i = 0; i < InterfaceMethodTable::NumIndexes; ++i) {
std::set<JavaMethod*>& atIndex = contents[i];
@@ -348,7 +301,7 @@
if (OldMethod && OldMethod != Cmeth) SameMethod = false;
else OldMethod = Cmeth;
- if (Cmeth) methods.push_back(Cmeth);
+ methods.push_back(Cmeth);
}
if (SameMethod) {
@@ -360,45 +313,81 @@
}
} else {
- uint32_t length = 2 * size * sizeof(uintptr_t);
+ // Add one to have a NULL-terminated table.
+ uint32_t length = (2 * size + 1) * sizeof(uintptr_t);
uintptr_t* table = (uintptr_t*)
cl->classLoader->allocator.Allocate(length, "IMT");
IMT->contents[i] = (uintptr_t)table | 1;
- int j = 0;
+ uint32_t j = 0;
std::set<JavaMethod*>::iterator Interf = atIndex.begin();
for (std::vector<JavaMethod*>::iterator it = methods.begin(),
et = methods.end(); it != et; ++it, j += 2, ++Interf) {
JavaMethod* Imeth = *Interf;
JavaMethod* Cmeth = *it;
-
+ assert(Imeth != NULL);
+ assert(j < 2 * size - 1);
table[j] = (uintptr_t)Imeth;
if (Cmeth) {
- table[j + 1] = getPointerOrStub(*Cmeth, JavaMethod::Interface);
+ table[j + 1] = getPointerOrStub(*Cmeth, JavaMethod::Interface);
} else {
table[j + 1] = (uintptr_t)ThrowUnfoundInterface;
}
}
+ assert(Interf == atIndex.end());
}
}
}
}
-void JavaJITCompiler::setMethod(JavaMethod* meth, void* ptr, const char* name) {
- Function* func = getMethodInfo(meth)->getMethod();
+void JavaJITCompiler::setMethod(Function* func, void* ptr, const char* name) {
+ func->setLinkage(GlobalValue::ExternalLinkage);
func->setName(name);
assert(ptr && "No value given");
executionEngine->updateGlobalMapping(func, ptr);
- func->setLinkage(GlobalValue::ExternalLinkage);
}
void* JavaJITCompiler::materializeFunction(JavaMethod* meth) {
mvm::MvmModule::protectIR();
Function* func = parseFunction(meth);
void* res = executionEngine->getPointerToGlobal(func);
- // Now that it's compiled, we don't need the IR anymore
+
+ if (!func->isDeclaration()) {
+ llvm::GCFunctionInfo* GFI = &(GCInfo->getFunctionInfo(*func));
+ assert((GFI != NULL) && "No GC information");
+
+ Jnjvm* vm = JavaThread::get()->getJVM();
+ mvm::JITMethodInfo* MI =
+ new(allocator, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth);
+ MI->addToVM(vm, (JIT*)executionEngine);
+
+ uint32_t infoLength = GFI->size();
+ meth->codeInfoLength = infoLength;
+ if (infoLength == 0) {
+ meth->codeInfo = NULL;
+ } else {
+ mvm::BumpPtrAllocator& JavaAlloc = meth->classDef->classLoader->allocator;
+ CodeLineInfo* infoTable =
+ new(JavaAlloc, "CodeLineInfo") CodeLineInfo[infoLength];
+ uint32_t index = 0;
+ for (GCFunctionInfo::iterator I = GFI->begin(), E = GFI->end();
+ I != E;
+ I++, index++) {
+ DebugLoc DL = I->Loc;
+ uint32_t bytecodeIndex = DL.getLine();
+ uint32_t second = DL.getCol();
+ assert(second == 0 && "Wrong column number");
+ uintptr_t address =
+ ((JIT*)executionEngine)->getCodeEmitter()->getLabelAddress(I->Label);
+ infoTable[index].address = address;
+ infoTable[index].bytecodeIndex = bytecodeIndex;
+ }
+ meth->codeInfo = infoTable;
+ }
+ }
+ // Now that it's compiled, we don't need the IR anymore
func->deleteBody();
mvm::MvmModule::unprotectIR();
return res;
@@ -407,6 +396,15 @@
void* JavaJITCompiler::GenerateStub(llvm::Function* F) {
mvm::MvmModule::protectIR();
void* res = executionEngine->getPointerToGlobal(F);
+
+ llvm::GCFunctionInfo* GFI = &(GCInfo->getFunctionInfo(*F));
+ assert((GFI != NULL) && "No GC information");
+
+ Jnjvm* vm = JavaThread::get()->getJVM();
+ mvm::JITMethodInfo* MI =
+ new(allocator, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, F, this);
+ MI->addToVM(vm, (JIT*)executionEngine);
+
// Now that it's compiled, we don't need the IR anymore
F->deleteBody();
mvm::MvmModule::unprotectIR();
@@ -426,9 +424,11 @@
newArgv[0] = newArgv[1];
newArgv[1] = mainClass;
+ mvm::BumpPtrAllocator Allocator;
JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
- JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp);
- mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM(JCL);
+ JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
+ JnjvmBootstrapLoader(Allocator, Comp, true);
+ Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader);
vm->runApplication(argc + 1, newArgv);
vm->waitForExit();
@@ -478,9 +478,8 @@
return (meth == NULL || meth->code == NULL);
}
-JavaJ3LazyJITCompiler::JavaJ3LazyJITCompiler(const std::string& ModuleID,
- bool trusted)
- : JavaJITCompiler(ModuleID, trusted) {}
+JavaJ3LazyJITCompiler::JavaJ3LazyJITCompiler(const std::string& ModuleID)
+ : JavaJITCompiler(ModuleID) {}
static llvm::cl::opt<bool> LLVMLazy("llvm-lazy",
@@ -490,7 +489,7 @@
JavaJITCompiler* JavaJITCompiler::CreateCompiler(const std::string& ModuleID) {
// This is called for the first compiler.
if (LLVMLazy) {
- return new JavaLLVMLazyJITCompiler(ModuleID, true);
+ return new JavaLLVMLazyJITCompiler(ModuleID);
}
- return new JavaJ3LazyJITCompiler(ModuleID, true);
+ return new JavaJ3LazyJITCompiler(ModuleID);
}
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITOpcodes.cpp Tue Nov 30 06:21:29 2010
@@ -148,13 +148,7 @@
currentExceptionBlock = opinfo->exceptionBlock;
- // Update the line number information.
- if (opinfo->lineNumber)
- currentLineNumber = opinfo->lineNumber;
-
- currentCtpIndex = -1;
currentBytecodeIndex = i;
- currentBytecode = bytecode;
// To prevent a gcj bug with useless goto
if (currentBlock->getTerminator() != 0) {
@@ -2016,7 +2010,6 @@
case INVOKEVIRTUAL : {
uint16 index = reader.readU2();
i += 2;
- currentCtpIndex = index;
invokeVirtual(index);
break;
}
@@ -2024,7 +2017,6 @@
case INVOKESPECIAL : {
uint16 index = reader.readU2();
i += 2;
- currentCtpIndex = index;
invokeSpecial(index);
break;
}
@@ -2032,7 +2024,6 @@
case INVOKESTATIC : {
uint16 index = reader.readU2();
i += 2;
- currentCtpIndex = index;
invokeStatic(index);
break;
}
@@ -2040,7 +2031,6 @@
case INVOKEINTERFACE : {
uint16 index = reader.readU2();
i += 2;
- currentCtpIndex = index;
invokeInterface(index);
i += 2;
break;
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaLLVMCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaLLVMCompiler.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaLLVMCompiler.cpp Tue Nov 30 06:21:29 2010
@@ -116,7 +116,7 @@
llvm::FunctionPass* createLowerConstantCallsPass(JavaLLVMCompiler* I);
}
-void JavaLLVMCompiler::addJavaPasses(bool trusted) {
+void JavaLLVMCompiler::addJavaPasses() {
JavaNativeFunctionPasses = new FunctionPassManager(TheModule);
JavaNativeFunctionPasses->add(new TargetData(TheModule));
// Lower constant calls to lower things like getClass used
@@ -124,9 +124,7 @@
JavaNativeFunctionPasses->add(createLowerConstantCallsPass(this));
JavaFunctionPasses = new FunctionPassManager(TheModule);
- // Add safe points in loops if we don't trust the code (trusted code doesn't
- // do infinite loops).
- if (cooperativeGC && !trusted)
+ if (cooperativeGC)
JavaFunctionPasses->add(mvm::createLoopSafePointsPass());
// Add other passes after the loop pass, because safepoints may move objects.
// Moving objects disable many optimizations.
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/LLVMInfo.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/LLVMInfo.cpp Tue Nov 30 06:21:29 2010
@@ -157,10 +157,8 @@
JCL->nativeLookup(methodDef, j3, buf);
}
- if (!j3) {
- methodDef->jniConsFromMethOverloaded(buf + 1);
- memcpy(buf, "JnJVM", 5);
- }
+ methodDef->jniConsFromMethOverloaded(buf + 1);
+ memcpy(buf, "JnJVM", 5);
methodFunction = Function::Create(getFunctionType(),
GlobalValue::ExternalWeakLinkage, buf,
@@ -171,13 +169,11 @@
"", Compiler->getLLVMModule());
}
- if (Compiler->useCooperativeGC()) {
- methodFunction->setGC("vmkit");
- }
+ methodFunction->setGC("vmkit");
Compiler->functions.insert(std::make_pair(methodFunction, methodDef));
if (Compiler != JCL->getCompiler() && methodDef->code) {
- Compiler->setMethod(methodDef, methodDef->code, methodFunction->getName().data());
+ Compiler->setMethod(methodFunction, methodDef->code, methodFunction->getName().data());
}
}
return methodFunction;
@@ -406,10 +402,13 @@
Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",
currentBlock);
- if (!signature->getReturnType()->isVoid())
+ if (!signature->getReturnType()->isVoid()) {
ReturnInst::Create(context, val, currentBlock);
- else
+ } else {
ReturnInst::Create(context, currentBlock);
+ }
+
+ res->setGC("vmkit");
return res;
}
@@ -483,15 +482,14 @@
Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",
currentBlock);
- if (!signature->getReturnType()->isVoid())
+ if (!signature->getReturnType()->isVoid()) {
ReturnInst::Create(context, val, currentBlock);
- else
+ } else {
ReturnInst::Create(context, currentBlock);
-
- if (Compiler->useCooperativeGC()) {
- res->setGC("vmkit");
}
+ res->setGC("vmkit");
+
return res;
}
@@ -547,7 +545,7 @@
if (virt) {
if (Compiler->useCooperativeGC()) {
Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock));
- }else {
+ } else {
Args.push_back(TempArgs[0]);
}
}
@@ -589,9 +587,7 @@
ReturnInst::Create(context, currentBlock);
}
- if (Compiler->useCooperativeGC()) {
- stub->setGC("vmkit");
- }
+ stub->setGC("vmkit");
return stub;
}
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/LLVMMaterializer.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/LLVMMaterializer.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/LLVMMaterializer.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/LLVMMaterializer.cpp Tue Nov 30 06:21:29 2010
@@ -27,9 +27,8 @@
using namespace j3;
-JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID,
- bool trusted)
- : JavaJITCompiler(ModuleID, trusted) {
+JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID)
+ : JavaJITCompiler(ModuleID) {
TheMaterializer = new LLVMMaterializer(TheModule, this);
executionEngine->DisableLazyCompilation(false);
}
Modified: vmkit/branches/multi-vm/lib/J3/Compiler/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/LowerConstantCalls.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/LowerConstantCalls.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/LowerConstantCalls.cpp Tue Nov 30 06:21:29 2010
@@ -388,8 +388,9 @@
PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, "", DelegateeOK);
phi->addIncoming(Del, CI->getParent());
- Value* Res = CallInst::Create(intrinsics->RuntimeDelegateeFunction,
- Call.getArgument(0), "", NoDelegatee);
+ Instruction* Res = CallInst::Create(intrinsics->RuntimeDelegateeFunction,
+ Call.getArgument(0), "", NoDelegatee);
+ Res->setDebugLoc(CI->getDebugLoc());
BranchInst::Create(DelegateeOK, NoDelegatee);
phi->addIncoming(Res, NoDelegatee);
@@ -428,7 +429,7 @@
BranchInst::Create(trueCl, falseCl, test, CI);
- Value* res = 0;
+ Instruction* res = 0;
if (InvokeInst* Invoke = dyn_cast<InvokeInst>(CI)) {
Value* Args[1] = { Cl };
BasicBlock* UI = Invoke->getUnwindDest();
@@ -462,6 +463,7 @@
Cl, "", falseCl);
BranchInst::Create(trueCl, falseCl);
}
+ res->setDebugLoc(CI->getDebugLoc());
node->addIncoming(res, falseCl);
@@ -512,7 +514,7 @@
Args.push_back(Call.getArgument(i));
}
- Value* res = 0;
+ Instruction* res = 0;
if (InvokeInst* Invoke = dyn_cast<InvokeInst>(CI)) {
BasicBlock* UI = Invoke->getUnwindDest();
res = InvokeInst::Create(resolver, trueCl, UI, Args.begin(),
@@ -544,9 +546,9 @@
BranchInst::Create(trueCl, falseCl);
}
+ res->setDebugLoc(CI->getDebugLoc());
node->addIncoming(res, falseCl);
-
CI->replaceAllUsesWith(node);
CI->eraseFromParent();
BranchInst::Create(NBB, trueCl);
@@ -578,8 +580,9 @@
BranchInst::Create(NotOKBlock, OKBlock, cmp, CI);
Value* args[3] = { Call.getArgument(0), Call.getArgument(1), GV };
- Value* res = CallInst::Create(intrinsics->GetArrayClassFunction, args,
- args + 3, "", NotOKBlock);
+ Instruction* res = CallInst::Create(intrinsics->GetArrayClassFunction, args,
+ args + 3, "", NotOKBlock);
+ res->setDebugLoc(CI->getDebugLoc());
BranchInst::Create(OKBlock, NotOKBlock);
node->addIncoming(res, NotOKBlock);
@@ -629,7 +632,8 @@
CurVT = new LoadInst(CurVT, "", false, CI);
CurVT = new BitCastInst(CurVT, intrinsics->VTType, "", CI);
- Value* res = new ICmpInst(CI, ICmpInst::ICMP_EQ, CurVT, VT2, "");
+ Instruction* res =
+ new ICmpInst(CI, ICmpInst::ICMP_EQ, CurVT, VT2, "");
node->addIncoming(ConstantInt::getTrue(*Context), CI->getParent());
BranchInst::Create(CurEndBlock, FailedBlock, res, CI);
@@ -637,6 +641,7 @@
Value* Args[2] = { VT1, VT2 };
res = CallInst::Create(intrinsics->IsSecondaryClassFunction, Args,
Args + 2, "", FailedBlock);
+ res->setDebugLoc(CI->getDebugLoc());
node->addIncoming(res, FailedBlock);
BranchInst::Create(CurEndBlock, FailedBlock);
Modified: vmkit/branches/multi-vm/lib/J3/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/LLVMRuntime/runtime-default.ll?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/branches/multi-vm/lib/J3/LLVMRuntime/runtime-default.ll Tue Nov 30 06:21:29 2010
@@ -26,6 +26,7 @@
%JavaThread = type { %VMThreadData, i8*, %JavaObject* }
+%JavaConstantPool = type { %JavaClass*, i32, i8*, i32*, i8** }
%Attribut = type { %UTF8*, i32, i32 }
@@ -35,7 +36,7 @@
%JavaField = type { i8*, i16, %UTF8*, %UTF8*, %Attribut*, i16, %JavaClass*, i32,
i16 }
-%CodeLineInfo = type { i8*, i16, i16, %JavaMethod*, %CodeLineInfo* }
+%CodeLineInfo = type { i8*, %JavaMethod*, %CodeLineInfo* }
%JavaMethod = type { i8*, i16, %Attribut*, i16, %JavaClass*,
%UTF8*, %UTF8*, i8, i8*, %CodeLineInfo*, i16, i32 }
@@ -188,6 +189,7 @@
declare i8* @j3ResolveVirtualStub(%JavaObject*)
declare i8* @j3ResolveSpecialStub()
declare i8* @j3ResolveStaticStub()
+declare i8* @j3ResolveInterface(%JavaObject*, %JavaMethod*, i32)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Exception methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaArray.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaArray.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaArray.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaArray.h Tue Nov 30 06:21:29 2010
@@ -36,7 +36,7 @@
/// {JavaObject, size, [0 * T]}.
template <class T>
class TJavaArray : public JavaObject {
-private:
+public:
/// size - The (constant) size of the array.
ssize_t size;
@@ -75,7 +75,7 @@
};
class ArrayObject : public JavaObject {
-private:
+public:
/// size - The (constant) size of the array.
ssize_t size;
@@ -98,6 +98,7 @@
static void setElement(ArrayObject* self, JavaObject* value, uint32_t i) {
llvm_gcroot(self, 0);
llvm_gcroot(value, 0);
+ if (value != NULL) assert(value->getVirtualTable());
self->elements[i] = value;
}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.cpp Tue Nov 30 06:21:29 2010
@@ -216,9 +216,8 @@
logSize = nb;
}
-Class::Class(JnjvmClassLoader* loader, const UTF8* n, ArrayUInt8* B) :
+Class::Class(JnjvmClassLoader* loader, const UTF8* n, ClassBytes* B) :
CommonClass(loader, n) {
- llvm_gcroot(B, 0);
virtualVT = 0;
bytes = B;
super = 0;
@@ -287,31 +286,8 @@
return code;
}
-void JavaStaticMethodInfo::print(void* ip, void* addr) {
- void* new_ip = NULL;
- if (ip) new_ip = mvm::MethodInfo::isStub(ip, addr);
- JavaMethod* meth = (JavaMethod*)MetaInfo;
- fprintf(stderr, "; %p in %s.%s", new_ip,
- UTF8Buffer(meth->classDef->name).cString(),
- UTF8Buffer(meth->name).cString());
- if (ip != new_ip) fprintf(stderr, " (from stub)");
- fprintf(stderr, "\n");
-}
-
-void JavaMethod::setCompiledPtr(void* ptr, const char* name) {
- classDef->acquire();
- if (code == 0) {
- code = ptr;
- Jnjvm* vm = JavaThread::get()->getJVM();
- mvm::MethodInfo* MI = vm->SharedStaticFunctions.CodeStartToMethodInfo(ptr);
- JavaStaticMethodInfo* JMI =
- new (classDef->classLoader->allocator, "JavaStaticMethodInfo")
- JavaStaticMethodInfo((mvm::CamlMethodInfo*)MI, code, this);
- vm->StaticFunctions.addMethodInfo(JMI, code);
- classDef->classLoader->getCompiler()->setMethod(this, ptr, name);
- }
+void JavaMethod::setNative() {
access |= ACC_NATIVE;
- classDef->release();
}
void JavaVirtualTable::setNativeTracer(uintptr_t ptr, const char* name) {
@@ -624,7 +600,7 @@
if (!attribut) {
InitNullStaticField();
} else {
- Reader reader(attribut, &(classDef->bytes));
+ Reader reader(attribut, classDef->bytes);
JavaConstantPool * ctpInfo = classDef->ctpInfo;
uint16 idx = reader.readU2();
if (type->isPrimitive()) {
@@ -710,7 +686,7 @@
Attribut* codeAtt = meth.lookupAttribut(Attribut::codeAttribut);
if (codeAtt) {
- Reader reader(codeAtt, &(meth.classDef->bytes));
+ Reader reader(codeAtt, meth.classDef->bytes);
//uint16 maxStack =
reader.readU2();
//uint16 maxLocals =
@@ -789,14 +765,16 @@
interfaces[i]->fillIMT(meths);
}
- if (super) super->fillIMT(meths);
+ if (super != NULL) {
+ super->fillIMT(meths);
+ }
- if (isInterface()) {
+ // Specification says that an invokeinterface also looks at j.l.Object.
+ if (isInterface() || (super == NULL)) {
for (uint32 i = 0; i < nbVirtualMethods; ++i) {
JavaMethod& meth = virtualMethods[i];
uint32_t index = InterfaceMethodTable::getIndex(meth.name, meth.type);
- if (meths[index].find(&meth) == meths[index].end())
- meths[index].insert(&meth);
+ meths[index].insert(&meth);
}
}
}
@@ -911,7 +889,7 @@
PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "reading ", 0);
PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", mvm::PrintBuffer(this).cString());
- Reader reader(&bytes);
+ Reader reader(bytes);
uint32 magic = reader.readU4();
assert(magic == Jnjvm::Magic && "I've created a class but magic is no good!");
@@ -946,14 +924,22 @@
interfaces[i]->resolveClass();
}
-
#ifndef ISOLATE_SHARING
+#ifdef ISOLATE
+void Class::resolveClass() {
+ UNIMPLEMENTED();
+}
+#else
void Class::resolveClass() {
if (isResolved() || isErroneous()) return;
resolveParents();
loadExceptions();
- setResolved();
+ // Do a compare and swap in case another thread initialized the class.
+ __sync_val_compare_and_swap(
+ &(getCurrentTaskClassMirror().status), loaded, resolved);
+ assert(isResolved() || isErroneous());
}
+#endif
#else
void Class::resolveClass() {
assert(status >= resolved &&
@@ -965,7 +951,7 @@
if (!innerOuterResolved) {
Attribut* attribut = lookupAttribut(Attribut::innerClassesAttribut);
if (attribut != 0) {
- Reader reader(attribut, getBytesPtr());
+ Reader reader(attribut, bytes);
uint16 nbi = reader.readU2();
for (uint16 i = 0; i < nbi; ++i) {
uint16 inner = reader.readU2();
@@ -1042,7 +1028,7 @@
return (ArrayObject*)vm->upcalls->classArrayClass->doNew(0, vm);
} else {
UserConstantPool* ctp = classDef->getConstantPool();
- Reader reader(exceptionAtt, classDef->getBytesPtr());
+ Reader reader(exceptionAtt, classDef->bytes);
uint16 nbe = reader.readU2();
res = (ArrayObject*)vm->upcalls->classArrayClass->doNew(nbe, vm);
@@ -1144,19 +1130,35 @@
for (sint32 i =0; i < mnlen; ++i) {
cur = jniConsName->elements[i];
- if (cur == '/') ptr[0] = '_';
- else if (cur == '_') {
+ if (cur == '/') {
+ ptr[0] = '_';
+ ++ptr;
+ } else if (cur == '_') {
ptr[0] = '_';
ptr[1] = '1';
+ ptr += 2;
+ } else if (cur == '<') {
+ ptr[0] = '_';
+ ptr[1] = '0';
+ ptr[2] = '0';
+ ptr[3] = '0';
+ ptr[4] = '3';
+ ptr[5] = 'C';
+ ptr += 6;
+ } else if (cur == '>') {
+ ptr[0] = '_';
+ ptr[1] = '0';
+ ptr[2] = '0';
+ ptr[3] = '0';
+ ptr[4] = '3';
+ ptr[5] = 'E';
+ ptr += 6;
+ } else {
+ ptr[0] = (uint8)cur;
++ptr;
}
- else ptr[0] = (uint8)cur;
- ++ptr;
- }
-
+ }
ptr[0] = 0;
-
-
}
void JavaMethod::jniConsFromMethOverloaded(char* buf, const UTF8* jniConsClName,
@@ -1752,32 +1754,56 @@
CodeLineInfo* JavaMethod::lookupCodeLineInfo(uintptr_t ip) {
for(uint16 i = 0; i < codeInfoLength; ++i) {
- if (codeInfo[i].address > ip) {
- assert(i > 0 && "Wrong ip address for method");
- return &(codeInfo[i - 1]);
+ if (codeInfo[i].address == ip) {
+ return &(codeInfo[i]);
}
}
- if (codeInfoLength) return &(codeInfo[codeInfoLength - 1]);
return NULL;
}
uint16 JavaMethod::lookupLineNumber(uintptr_t ip) {
- for(uint16 i = 1; i < codeInfoLength; ++i) {
- if (codeInfo[i].address > ip) {
- return codeInfo[i - 1].lineNumber;
+ for(uint16 i = 0; i < codeInfoLength; ++i) {
+ if (codeInfo[i].address == ip) {
+ Attribut* codeAtt = lookupAttribut(Attribut::codeAttribut);
+ if (codeAtt == NULL) return 0;
+ Reader reader(codeAtt, classDef->bytes);
+ reader.readU2(); // max_stack
+ reader.readU2(); // max_locals;
+ uint32_t codeLength = reader.readU4();
+ reader.seek(codeLength, Reader::SeekCur);
+ uint16_t exceptionTableLength = reader.readU2();
+ reader.seek(8 * exceptionTableLength, Reader::SeekCur);
+ uint16_t nba = reader.readU2();
+ for (uint16 att = 0; att < nba; ++att) {
+ const UTF8* attName = classDef->ctpInfo->UTF8At(reader.readU2());
+ uint32 attLen = reader.readU4();
+ if (attName->equals(Attribut::lineNumberTableAttribut)) {
+ uint16_t lineLength = reader.readU2();
+ uint16_t currentLine = 0;
+ for (uint16 j = 0; j < lineLength; ++j) {
+ uint16 pc = reader.readU2();
+ if (pc > codeInfo[i].bytecodeIndex + 1) return currentLine;
+ currentLine = reader.readU2();
+ }
+ return currentLine;
+ } else {
+ reader.seek(attLen, Reader::SeekCur);
+ }
+ }
}
}
- if (codeInfoLength) return codeInfo[codeInfoLength - 1].lineNumber;
return 0;
}
uint16 JavaMethod::lookupCtpIndex(uintptr_t ip) {
- for(uint16 i = 1; i < codeInfoLength; ++i) {
- if (codeInfo[i].address > ip) {
- return codeInfo[i - 1].ctpIndex;
+ for(uint16 i = 0; i < codeInfoLength; ++i) {
+ if (codeInfo[i].address == ip) {
+ Attribut* codeAtt = lookupAttribut(Attribut::codeAttribut);
+ Reader reader(codeAtt, classDef->bytes);
+ reader.cursor = reader.cursor + 2 + 2 + 4 + codeInfo[i].bytecodeIndex + 1;
+ return reader.readU2();
}
}
- if (codeInfoLength) return codeInfo[codeInfoLength - 1].ctpIndex;
return 0;
}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaClass.h Tue Nov 30 06:21:29 2010
@@ -34,6 +34,7 @@
class ArrayUInt16;
class Class;
class ClassArray;
+class ClassBytes;
class JavaArray;
class JavaConstantPool;
class JavaField;
@@ -457,7 +458,7 @@
/// bytes - The .class file of this class.
///
- ArrayUInt8* bytes;
+ ClassBytes* bytes;
/// ctpInfo - The constant pool info of this class.
///
@@ -621,7 +622,7 @@
/// Class - Create a class in the given virtual machine and with the given
/// name.
- Class(JnjvmClassLoader* loader, const UTF8* name, ArrayUInt8* bytes);
+ Class(JnjvmClassLoader* loader, const UTF8* name, ClassBytes* bytes);
/// readParents - Reads the parents, i.e. super and interfaces, of the class.
///
@@ -656,14 +657,10 @@
/// getBytes - Get the bytes of the class file.
///
- ArrayUInt8* getBytes() const {
+ ClassBytes* getBytes() const {
return bytes;
}
- ArrayUInt8** getBytesPtr() {
- return &bytes;
- }
-
/// resolveInnerOuterClasses - Resolve the inner/outer information.
///
void resolveInnerOuterClasses();
@@ -873,25 +870,10 @@
};
-class JavaStaticMethodInfo : public mvm::CamlMethodInfo {
-public:
- virtual void print(void* ip, void* addr);
-
- JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) :
- mvm::CamlMethodInfo(super != NULL ? super->CF : NULL, ip) {
- MetaInfo = M;
- MethodType = 1;
- }
-
-};
-
class CodeLineInfo : public mvm::PermanentObject {
public:
uintptr_t address;
- uint16 lineNumber;
- uint16 ctpIndex;
uint16 bytecodeIndex;
- uint16 bytecode;
// TODO: Use these fields when inlining.
JavaMethod* executingMethod;
// The code where the inlined method starts.
@@ -925,9 +907,9 @@
///
void* compiledPtr();
- /// setCompiledPtr - Set the pointer function to the method.
+ /// setNative - Set the method as native.
///
- void setCompiledPtr(void*, const char*);
+ void setNative();
/// JavaMethod - Delete the method as well as the cache enveloppes and
/// attributes of the method.
@@ -1315,6 +1297,7 @@
void setStaticObjectField(JavaObject* val) {
llvm_gcroot(val, 0);
+ if (val != NULL) assert(val->getVirtualTable());
assert(classDef->isResolved());
void* ptr = (void*)((uint64)classDef->getStaticInstance() + ptrOffset);
((JavaObject**)ptr)[0] = val;
@@ -1330,6 +1313,7 @@
void setInstanceObjectField(JavaObject* obj, JavaObject* val) {
llvm_gcroot(obj, 0);
llvm_gcroot(val, 0);
+ if (val != NULL) assert(val->getVirtualTable());
assert(classDef->isResolved());
void* ptr = (void*)((uint64)obj + ptrOffset);
((JavaObject**)ptr)[0] = val;
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.cpp Tue Nov 30 06:21:29 2010
@@ -190,7 +190,7 @@
if (!ctpRes[entry]) {
mvm::ThreadAllocator allocator;
- Reader reader(&(classDef->bytes), ctpDef[entry]);
+ Reader reader(classDef->bytes, ctpDef[entry]);
uint32 len = reader.readU2();
uint16* buf = (uint16*)allocator.Allocate(len * sizeof(uint16));
uint32 n = 0;
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaConstantPool.h Tue Nov 30 06:21:29 2010
@@ -52,7 +52,7 @@
/// ctpRes - Objects resolved dynamically, e.g. UTF8s, classes, methods,
/// fields, string pointers.
///
- void** ctpRes;
+ void** ctpRes;
/// operator new - Redefine the operator to allocate the arrays of a
/// constant pool inline.
Removed: vmkit/branches/multi-vm/lib/J3/VMCore/JavaInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaInitialise.cpp?rev=120423&view=auto
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaInitialise.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaInitialise.cpp (removed)
@@ -1,56 +0,0 @@
-//===-------- JavaInitialise.cpp - Initialization of JnJVM ----------------===//
-//
-// The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/VirtualMachine.h"
-#include "j3/JavaCompiler.h"
-
-#include "JavaArray.h"
-#include "JavaClass.h"
-#include "JavaObject.h"
-#include "Jnjvm.h"
-#include "JnjvmClassLoader.h"
-
-#ifdef ISOLATE_SHARING
-#include "SharedMaps.h"
-#include "IsolateSharedLoader.h"
-#endif
-
-using namespace j3;
-
-
-#ifdef ISOLATE_SHARING
-JnjvmClassLoader* mvm::VirtualMachine::initialiseJVM(JavaCompiler* Comp) {
- JnjvmSharedLoader::sharedLoader = JnjvmSharedLoader::createSharedLoader(Comp);
- return JnjvmSharedLoader::sharedLoader;
-}
-
-mvm::VirtualMachine* mvm::VirtualMachine::createJVM(JnjvClassLoader* JCL) {
- mvm::BumpPtrAllocator* A = new mvm::BumpPtrAllocator();
- mvm::BumpPtrAllocator* C = new mvm::BumpPtrAllocator();
- JnjvmBootstraLoader* bootstrapLoader =
- new(*C) JnjvmBootstrapLoader(*C, JCL->getCompiler());
- Jnjvm* vm = new(*A, "VM") Jnjvm(*A, bootstrapLoader);
- vm->scanner = JCL->getCompiler()->createStackScanner();
- return vm;
-}
-#else
-
-JnjvmClassLoader*
-mvm::VirtualMachine::initialiseJVM(JavaCompiler* Comp, bool dlLoad) {
- mvm::BumpPtrAllocator* A = new mvm::BumpPtrAllocator();
- return new(*A, "Bootstrap loader") JnjvmBootstrapLoader(*A, Comp, dlLoad);
-}
-
-mvm::VirtualMachine* mvm::VirtualMachine::createJVM(JnjvmClassLoader* C) {
- mvm::BumpPtrAllocator* A = new mvm::BumpPtrAllocator();
- Jnjvm* vm = new(*A, "VM") Jnjvm(*A, (JnjvmBootstrapLoader*)C);
- return vm;
-}
-
-#endif
Removed: vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.cpp?rev=120423&view=auto
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.cpp (removed)
@@ -1,133 +0,0 @@
-//===------------- JavaLocks.cpp - Fat lock management --------------------===//
-//
-// The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "JavaLocks.h"
-#include "JavaThread.h"
-#include "Jnjvm.h"
-
-using namespace j3;
-
-JavaLock* Jnjvm::allocateFatLock(gc* obj) {
- llvm_gcroot(obj, 0);
- JavaLock* res = lockSystem.allocate((JavaObject*)obj);
- return res;
-}
-
-void JavaLock::deallocate() {
- Jnjvm* vm = JavaThread::get()->getJVM();
- vm->lockSystem.deallocate(this);
-}
-
-JavaLock* LockSystem::allocate(JavaObject* obj) {
-
- llvm_gcroot(obj, 0);
- JavaLock* res = 0;
- threadLock.lock();
-
- // Try the freeLock list.
- if (freeLock != NULL) {
- res = freeLock;
- freeLock = res->nextFreeLock;
- res->nextFreeLock = 0;
- assert(res->associatedObject == NULL);
- threadLock.unlock();
- res->associatedObject = obj;
- } else {
- // Get an index.
- uint32_t index = currentIndex++;
- if (index == MaxLocks) {
- fprintf(stderr, "Ran out of space for allocating locks");
- abort();
- }
-
- JavaLock** tab = LockTable[index >> BitIndex];
-
- if (tab == NULL) {
- tab = (JavaLock**)associatedVM->allocator.Allocate(
- IndexSize * sizeof(JavaLock*), "Index LockTable");
- }
- threadLock.unlock();
-
- // Allocate the lock.
- res = new(associatedVM->allocator, "Lock") JavaLock(index, obj);
-
- // Add the lock to the table.
- uint32_t internalIndex = index & BitMask;
- tab[internalIndex] = res;
- }
-
- // Return the lock.
- return res;
-}
-
-void LockSystem::deallocate(JavaLock* lock) {
- lock->associatedObject = NULL;
- threadLock.lock();
- lock->nextFreeLock = freeLock;
- freeLock = lock;
- threadLock.unlock();
-}
-
-LockSystem::LockSystem(Jnjvm* vm) {
- associatedVM = vm;
- LockTable = (JavaLock* **)
- vm->allocator.Allocate(GlobalSize * sizeof(JavaLock**), "Global LockTable");
- LockTable[0] = (JavaLock**)
- vm->allocator.Allocate(IndexSize * sizeof(JavaLock*), "Index LockTable");
- currentIndex = 0;
- freeLock = NULL;
-}
-
-uintptr_t JavaLock::getID() {
- return (index << mvm::NonLockBits) | mvm::FatMask;
-}
-
-JavaLock* Jnjvm::getFatLockFromID(uintptr_t ID) {
- if (ID & mvm::FatMask) {
- uint32_t index = (ID & ~mvm::FatMask) >> mvm::NonLockBits;
- JavaLock* res = lockSystem.getLock(index);
- return res;
- } else {
- return NULL;
- }
-}
-
-void JavaLock::release(gc* obj) {
- llvm_gcroot(obj, 0);
- assert(associatedObject && "No associated object when releasing");
- assert(associatedObject == obj && "Mismatch object in lock");
- if (!waitingThreads && !lockingThreads &&
- internalLock.recursionCount() == 1) {
- mvm::ThinLock::initialise(associatedObject);
- deallocate();
- }
- internalLock.unlock();
-}
-
-/// acquire - Acquires the internalLock.
-///
-bool JavaLock::acquire(gc* obj) {
- llvm_gcroot(obj, 0);
-
- spinLock.lock();
- lockingThreads++;
- spinLock.unlock();
-
- internalLock.lock();
-
- spinLock.lock();
- lockingThreads--;
- spinLock.unlock();
-
- if (associatedObject != obj) {
- internalLock.unlock();
- return false;
- }
- return true;
-}
Removed: vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.h?rev=120423&view=auto
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaLocks.h (removed)
@@ -1,159 +0,0 @@
-//===--------------- JavaLocks.h - Fat lock management --------------------===//
-//
-// The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef JAVA_LOCKS_H
-#define JAVA_LOCKS_H
-
-#include "mvm/Allocator.h"
-#include "mvm/Threads/Locks.h"
-#include "mvm/VirtualMachine.h"
-
-namespace mvm {
- class Thread;
-}
-
-namespace j3 {
-
-class JavaObject;
-class JavaThread;
-class Jnjvm;
-
-class JavaLock : public mvm::FatLock {
-
-friend class JavaObject;
-friend class LockSystem;
-
-private:
- mvm::LockRecursive internalLock;
- mvm::SpinLock spinLock;
- uint32_t waitingThreads;
- uint32_t lockingThreads;
- JavaThread* firstThread;
- JavaObject* associatedObject;
- uint32_t index;
- JavaLock* nextFreeLock;
-
-public:
-
- JavaObject* getAssociatedObject() {
- return associatedObject;
- }
-
- JavaObject** getAssociatedObjectPtr() {
- return &associatedObject;
- }
-
- /// acquire - Acquires the internalLock.
- ///
- bool acquire(gc* obj);
-
- /// tryAcquire - Tries to acquire the lock.
- ///
- int tryAcquire() {
- return internalLock.tryLock();
- }
-
-
- /// acquireAll - Acquires the lock nb times.
- void acquireAll(gc* obj, uint32 nb) {
- internalLock.lockAll(nb);
- }
-
- /// release - Releases the internalLock.
- ///
- void release(gc* obj);
-
- /// owner - Returns if the current thread owns this internalLock.
- ///
- bool owner() {
- return internalLock.selfOwner();
- }
-
- /// getOwner - Get the owner of this internalLock.
- ///
- mvm::Thread* getOwner() {
- return internalLock.getOwner();
- }
-
- /// JavaLock - Default constructor.
- JavaLock(uint32_t i, JavaObject* a) {
- llvm_gcroot(a, 0);
- firstThread = 0;
- index = i;
- associatedObject = a;
- waitingThreads = 0;
- lockingThreads = 0;
- nextFreeLock = NULL;
- }
-
- void deallocate();
-
- uintptr_t getID();
-};
-
-/// LockSystem - This class manages all Java locks used by the applications.
-/// Each JVM must own an instance of this class and allocate Java locks
-/// with it.
-///
-class LockSystem {
- friend class JavaLock;
-public:
-
- // Fixed values. With these values, an index is on 18 bits.
- static const uint32_t GlobalSize = 128;
- static const uint32_t BitIndex = 11;
- static const uint32_t IndexSize = 1 << BitIndex;
- static const uint32_t BitMask = IndexSize - 1;
- static const uint32_t MaxLocks = GlobalSize * IndexSize;
-
- /// LockTable - The global table that will hold the locks. The table is
- /// a two-dimensional array, and only one entry is created, so that
- /// the lock system does not eat up all memory on startup.
- ///
- JavaLock* ** LockTable;
-
- /// currentIndex - The current index in the tables. Always incremented,
- /// never decremented.
- ///
- uint32_t currentIndex;
-
- /// freeLock - The list of locks that are allocated and available.
- ///
- JavaLock* freeLock;
-
- /// threadLock - Spin lock to protect the currentIndex field.
- ///
- mvm::SpinLock threadLock;
-
- /// associatedVM - The JVM associated with this lock system.
- ///
- Jnjvm* associatedVM;
-
- /// allocate - Allocate a JavaLock.
- ///
- JavaLock* allocate(JavaObject* obj);
-
- /// deallocate - Put a lock in the free list lock.
- ///
- void deallocate(JavaLock* lock);
-
- /// LockSystem - Default constructor. Initialize the table.
- ///
- LockSystem(Jnjvm* vm);
-
- /// getLock - Get a lock from an index in the table.
- ///
- JavaLock* getLock(uint32_t index) {
- return LockTable[index >> BitIndex][index & BitMask];
- }
-};
-
-}
-
-#endif
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp Tue Nov 30 06:21:29 2010
@@ -289,19 +289,3 @@
INVOKE(float, Float, float_virtual_ap, float_static_ap, float_virtual_buf, float_static_buf)
INVOKE(double, Double, double_virtual_ap, double_static_ap, double_virtual_buf, double_static_buf)
INVOKE(JavaObject*, JavaObject, object_virtual_ap, object_static_ap, object_virtual_buf, object_static_buf)
-
-void Jnjvm::invokeFinalizer(gc* _obj) {
- JavaObject* obj = (JavaObject*)_obj;
- llvm_gcroot(obj, 0);
- JavaMethod* meth = upcalls->FinalizeObject;
- UserClass* cl = JavaObject::getClass(obj)->asClass();
- meth->invokeIntVirtualBuf(this, cl, obj, 0);
-}
-
-bool Jnjvm::enqueueReference(gc* _obj) {
- JavaObject* obj = (JavaObject*)_obj;
- llvm_gcroot(obj, 0);
- JavaMethod* meth = upcalls->EnqueueReference;
- UserClass* cl = JavaObject::getClass(obj)->asClass();
- return (bool)meth->invokeIntSpecialBuf(this, cl, obj, 0);
-}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.cpp Tue Nov 30 06:21:29 2010
@@ -17,26 +17,31 @@
#include "Jnjvm.h"
#include <jni.h>
+#include "debug.h"
using namespace j3;
static const int hashCodeIncrement = mvm::GCBitMask + 1;
uint16_t JavaObject::hashCodeGenerator = hashCodeIncrement;
+static const uint64_t HashMask = ((1 << mvm::HashBits) - 1) << mvm::GCBits;
+
/// hashCode - Return the hash code of this object.
uint32_t JavaObject::hashCode(JavaObject* self) {
llvm_gcroot(self, 0);
if (!mvm::MovesObject) return (uint32_t)(long)self;
+ assert(HashMask != 0);
+ assert(mvm::HashBits != 0);
uintptr_t header = self->header;
uintptr_t GCBits = header & mvm::GCBitMask;
- uintptr_t val = header & mvm::HashMask;
+ uintptr_t val = header & HashMask;
if (val != 0) {
return val ^ (uintptr_t)getClass(self);
}
val = hashCodeGenerator;
hashCodeGenerator += hashCodeIncrement;
- val = val % mvm::HashMask;
+ val = val & HashMask;
if (val == 0) {
// It is possible that in the same time, a thread is in this method and
// gets the same hash code value than this thread. This is fine.
@@ -44,123 +49,39 @@
hashCodeGenerator += hashCodeIncrement;
}
assert(val > mvm::GCBitMask);
- assert(val <= mvm::HashMask);
- assert(val != hashCodeGenerator);
+ assert(val <= HashMask);
do {
header = self->header;
- if ((header & mvm::HashMask) != 0) break;
+ if ((header & HashMask) != 0) break;
uintptr_t newHeader = header | val;
- assert((newHeader & ~mvm::HashMask) == header);
+ assert((newHeader & ~HashMask) == header);
__sync_val_compare_and_swap(&(self->header), header, newHeader);
} while (true);
- assert((self->header & mvm::HashMask) != 0);
+ assert((self->header & HashMask) != 0);
assert(GCBits == (self->header & mvm::GCBitMask));
- return (self->header & mvm::HashMask) ^ (uintptr_t)getClass(self);
+ return (self->header & HashMask) ^ (uintptr_t)getClass(self);
}
void JavaObject::waitIntern(
JavaObject* self, struct timeval* info, bool timed) {
llvm_gcroot(self, 0);
- JavaLock* l = 0;
+ JavaThread* thread = JavaThread::get();
+ mvm::LockSystem& table = thread->getJVM()->lockSystem;
- if (owner(self)) {
- l = (JavaLock*)mvm::ThinLock::changeToFatlock(self);
- JavaThread* thread = JavaThread::get();
- thread->waitsOn = l;
- mvm::Cond& varcondThread = thread->varcond;
-
- if (thread->interruptFlag != 0) {
- thread->interruptFlag = 0;
- thread->waitsOn = 0;
- thread->getJVM()->interruptedException(self);
- } else {
- thread->state = JavaThread::StateWaiting;
- if (l->firstThread) {
- assert(l->firstThread->prevWaiting && l->firstThread->nextWaiting &&
- "Inconsistent list");
- if (l->firstThread->nextWaiting == l->firstThread) {
- l->firstThread->nextWaiting = thread;
- } else {
- l->firstThread->prevWaiting->nextWaiting = thread;
- }
- thread->prevWaiting = l->firstThread->prevWaiting;
- thread->nextWaiting = l->firstThread;
- l->firstThread->prevWaiting = thread;
- } else {
- l->firstThread = thread;
- thread->nextWaiting = thread;
- thread->prevWaiting = thread;
- }
- assert(thread->prevWaiting && thread->nextWaiting && "Inconsistent list");
- assert(l->firstThread->prevWaiting && l->firstThread->nextWaiting &&
- "Inconsistent list");
-
- bool timeout = false;
-
- l->waitingThreads++;
-
- while (!thread->interruptFlag && thread->nextWaiting) {
- if (timed) {
- timeout = varcondThread.timedWait(&l->internalLock, info);
- if (timeout) break;
- } else {
- varcondThread.wait(&l->internalLock);
- }
- }
-
- l->waitingThreads--;
-
- assert((!l->firstThread || (l->firstThread->prevWaiting &&
- l->firstThread->nextWaiting)) && "Inconsistent list");
-
- bool interrupted = (thread->interruptFlag != 0);
-
- if (interrupted || timeout) {
-
- if (thread->nextWaiting) {
- assert(thread->prevWaiting && "Inconsistent list");
- if (l->firstThread != thread) {
- thread->nextWaiting->prevWaiting = thread->prevWaiting;
- thread->prevWaiting->nextWaiting = thread->nextWaiting;
- assert(l->firstThread->prevWaiting &&
- l->firstThread->nextWaiting && "Inconsistent list");
- } else if (thread->nextWaiting == thread) {
- l->firstThread = 0;
- } else {
- l->firstThread = thread->nextWaiting;
- l->firstThread->prevWaiting = thread->prevWaiting;
- thread->prevWaiting->nextWaiting = l->firstThread;
- assert(l->firstThread->prevWaiting &&
- l->firstThread->nextWaiting && "Inconsistent list");
- }
- thread->nextWaiting = 0;
- thread->prevWaiting = 0;
- } else {
- assert(!thread->prevWaiting && "Inconstitent state");
- // Notify lost, notify someone else.
- notify(self);
- }
- } else {
- assert(!thread->prevWaiting && !thread->nextWaiting &&
- "Inconsistent state");
- }
-
- thread->state = JavaThread::StateRunning;
- thread->waitsOn = 0;
-
- if (interrupted) {
- thread->interruptFlag = 0;
- thread->getJVM()->interruptedException(self);
- }
- }
- } else {
- JavaThread::get()->getJVM()->illegalMonitorStateException(self);
+ if (!owner(self)) {
+ thread->getJVM()->illegalMonitorStateException(self);
+ UNREACHABLE();
+ }
+
+ bool interrupted = thread->lockingThread.wait(self, table, info, timed);
+
+ if (interrupted) {
+ thread->getJVM()->interruptedException(self);
+ UNREACHABLE();
}
-
- assert(owner(self) && "Not owner after wait");
}
void JavaObject::wait(JavaObject* self) {
@@ -175,72 +96,46 @@
void JavaObject::notify(JavaObject* self) {
llvm_gcroot(self, 0);
- JavaLock* l = 0;
+ JavaThread* thread = JavaThread::get();
+ mvm::LockSystem& table = thread->getJVM()->lockSystem;
- if (owner(self)) {
- l = (JavaLock*)mvm::ThinLock::getFatLock(self);
- if (l) {
- JavaThread* cur = l->firstThread;
- if (cur) {
- do {
- if (cur->interruptFlag != 0) {
- cur = cur->nextWaiting;
- } else {
- assert(cur->javaThread && "No java thread");
- assert(cur->prevWaiting && cur->nextWaiting &&
- "Inconsistent list");
- if (cur != l->firstThread) {
- cur->prevWaiting->nextWaiting = cur->nextWaiting;
- cur->nextWaiting->prevWaiting = cur->prevWaiting;
- assert(l->firstThread->prevWaiting &&
- l->firstThread->nextWaiting && "Inconsistent list");
- } else if (cur->nextWaiting == cur) {
- l->firstThread = 0;
- } else {
- l->firstThread = cur->nextWaiting;
- l->firstThread->prevWaiting = cur->prevWaiting;
- cur->prevWaiting->nextWaiting = l->firstThread;
- assert(l->firstThread->prevWaiting &&
- l->firstThread->nextWaiting && "Inconsistent list");
- }
- cur->prevWaiting = 0;
- cur->nextWaiting = 0;
- cur->varcond.signal();
- break;
- }
- } while (cur != l->firstThread);
- }
- }
- } else {
- JavaThread::get()->getJVM()->illegalMonitorStateException(self);
+ if (!owner(self)) {
+ thread->getJVM()->illegalMonitorStateException(self);
+ UNREACHABLE();
}
- assert(owner(self) && "Not owner after notify");
+ thread->lockingThread.notify(self, table);
}
void JavaObject::notifyAll(JavaObject* self) {
llvm_gcroot(self, 0);
- JavaLock* l = 0;
-
- if (owner(self)) {
- l = (JavaLock*)mvm::ThinLock::getFatLock(self);
- if (l) {
- JavaThread* cur = l->firstThread;
- if (cur) {
- do {
- JavaThread* temp = cur->nextWaiting;
- cur->prevWaiting = 0;
- cur->nextWaiting = 0;
- cur->varcond.signal();
- cur = temp;
- } while (cur != l->firstThread);
- l->firstThread = 0;
- }
- }
- } else {
- JavaThread::get()->getJVM()->illegalMonitorStateException(self);
+ JavaThread* thread = JavaThread::get();
+ mvm::LockSystem& table = thread->getJVM()->lockSystem;
+
+ if (!owner(self)) {
+ thread->getJVM()->illegalMonitorStateException(self);
+ UNREACHABLE();
}
+ thread->lockingThread.notifyAll(self, table);
+}
+
+void JavaObject::overflowThinLock(JavaObject* self) {
+ llvm_gcroot(self, 0);
+ mvm::ThinLock::overflowThinLock(self, JavaThread::get()->getJVM()->lockSystem);
+}
- assert(owner(self) && "Not owner after notifyAll");
+void JavaObject::acquire(JavaObject* self) {
+ llvm_gcroot(self, 0);
+ mvm::ThinLock::acquire(self, JavaThread::get()->getJVM()->lockSystem);
+}
+
+void JavaObject::release(JavaObject* self) {
+ llvm_gcroot(self, 0);
+ mvm::ThinLock::release(self, JavaThread::get()->getJVM()->lockSystem);
+}
+
+bool JavaObject::owner(JavaObject* self) {
+ llvm_gcroot(self, 0);
+ return mvm::ThinLock::owner(self, JavaThread::get()->getJVM()->lockSystem);
}
void JavaObject::decapsulePrimitive(JavaObject* obj, Jnjvm *vm, jvalue* buf,
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaObject.h Tue Nov 30 06:21:29 2010
@@ -18,7 +18,6 @@
#include "types.h"
-#include "JavaLocks.h"
#include "JnjvmConfig.h"
union jvalue;
@@ -244,6 +243,10 @@
llvm_gcroot(self, 0);
return ((JavaVirtualTable*)self->getVirtualTable())->cl;
}
+
+ /// instanceOf - Is this object's class of type the given class?
+ ///
+ static bool instanceOf(JavaObject* self, UserCommonClass* cl);
/// wait - Java wait. Makes the current thread waiting on a monitor.
///
@@ -264,35 +267,19 @@
///
static void notifyAll(JavaObject* self);
- /// overflowmvm::ThinLock - Notify that the thin lock has overflowed.
- ///
- static void overflowThinLock(JavaObject* self) {
- llvm_gcroot(self, 0);
- mvm::ThinLock::overflowThinLock(self);
- }
-
- /// instanceOf - Is this object's class of type the given class?
+ /// overflowThinLock - Notify that the thin lock has overflowed.
///
- static bool instanceOf(JavaObject* self, UserCommonClass* cl);
+ static void overflowThinLock(JavaObject* self);
/// acquire - Acquire the lock on this object.
- static void acquire(JavaObject* self) {
- llvm_gcroot(self, 0);
- mvm::ThinLock::acquire(self);
- }
+ static void acquire(JavaObject* self);
/// release - Release the lock on this object
- static void release(JavaObject* self) {
- llvm_gcroot(self, 0);
- mvm::ThinLock::release(self);
- }
+ static void release(JavaObject* self);
/// owner - Returns true if the current thread is the owner of this object's
/// lock.
- static bool owner(JavaObject* self) {
- llvm_gcroot(self, 0);
- return mvm::ThinLock::owner(self);
- }
+ static bool owner(JavaObject* self);
#ifdef SIGSEGV_THROW_NULL
#define verifyNull(obj) {}
@@ -301,12 +288,6 @@
if (obj == NULL) JavaThread::get()->getJVM()->nullPointerException();
#endif
- /// lockObj - Get the LockObj if the lock is a fat lock.
- static JavaLock* lockObj(JavaObject* self) {
- llvm_gcroot(self, 0);
- return (JavaLock*)mvm::ThinLock::getFatLock(self);
- }
-
/// decapsulePrimitive - Based on the signature argument, decapsule
/// obj as a primitive and put it in the buffer.
///
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp Tue Nov 30 06:21:29 2010
@@ -16,6 +16,7 @@
#include "JavaString.h"
#include "JavaThread.h"
#include "JavaTypes.h"
+#include "JavaUpcalls.h"
#include "Jnjvm.h"
#include "j3/OpcodeNames.def"
@@ -361,9 +362,10 @@
*oldLocalReferencesNumber = th->currentAddedReferences;
th->currentAddedReferences = localReferencesNumber;
- mut->startKnownFrame(*Frame);
-
- th->startJNI(1);
+ th->startJNI();
+ mut->startUnknownFrame(*Frame);
+ mut->enterUncooperativeCode();
+ assert(mut->getLastSP() == mut->lastKnownFrame->currentFP);
return Frame->currentFP;
}
@@ -609,15 +611,14 @@
// Lookup the caller of this class.
mvm::StackWalker Walker(mut);
- while (Walker.get()->MethodType != 1) ++Walker;
+ ++Walker; // Remove the stub.
mvm::MethodInfo* MI = Walker.get();
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ assert(MI->isHighLevelMethod() && "Wrong stack trace");
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
void* ip = *Walker;
// Lookup the method info in the constant pool of the caller.
- CodeLineInfo* CLInfo =
- meth->lookupCodeLineInfo(reinterpret_cast<uintptr_t>(ip));
- uint16 ctpIndex = CLInfo->ctpIndex;
+ uint16 ctpIndex = meth->lookupCtpIndex(reinterpret_cast<uintptr_t>(ip));
assert(ctpIndex && "No constant pool index");
JavaConstantPool* ctpInfo = meth->classDef->getConstantPool();
CommonClass* ctpCl = 0;
@@ -649,8 +650,7 @@
uint32_t index = InterfaceMethodTable::getIndex(Virt->name, Virt->type);
if ((IMT->contents[index] & 1) == 0) {
IMT->contents[index] = (uintptr_t)result;
- } else {
-
+ } else {
JavaMethod* Imeth =
ctpCl->asClass()->lookupInterfaceMethodDontThrow(utf8, sign->keyName);
assert(Imeth && "Method not in hierarchy?");
@@ -674,10 +674,10 @@
// Lookup the caller of this class.
mvm::StackWalker Walker(mut);
- while (Walker.get()->MethodType != 1) ++Walker;
+ ++Walker; // Remove the stub.
mvm::MethodInfo* MI = Walker.get();
- assert(MI->MethodType == 1 && "Wrong call to stub");
- JavaMethod* caller = (JavaMethod*)MI->getMetaInfo();
+ assert(MI->isHighLevelMethod() && "Wrong stack trace");
+ JavaMethod* caller = (JavaMethod*)MI->MetaInfo;
void* ip = *Walker;
// Lookup the method info in the constant pool of the caller.
@@ -712,10 +712,10 @@
// Lookup the caller of this class.
mvm::StackWalker Walker(mut);
- while (Walker.get()->MethodType != 1) ++Walker;
+ ++Walker; // Remove the stub.
mvm::MethodInfo* MI = Walker.get();
- assert(MI->MethodType == 1 && "Wrong call to stub");
- JavaMethod* caller = (JavaMethod*)MI->getMetaInfo();
+ assert(MI->isHighLevelMethod() && "Wrong stack trace");
+ JavaMethod* caller = (JavaMethod*)MI->MetaInfo;
void* ip = *Walker;
// Lookup the method info in the constant pool of the caller.
@@ -747,6 +747,27 @@
return result;
}
+// Does not throw an exception.
+extern "C" void* j3ResolveInterface(JavaObject* obj, JavaMethod* meth, uint32_t index) {
+ uintptr_t result = NULL;
+ InterfaceMethodTable* IMT = JavaObject::getClass(obj)->virtualVT->IMT;
+ assert(JavaObject::instanceOf(obj, meth->classDef));
+ assert(meth->classDef->isInterface() ||
+ (meth->classDef == meth->classDef->classLoader->bootstrapLoader->upcalls->OfObject));
+ assert(index == InterfaceMethodTable::getIndex(meth->name, meth->type));
+ if ((IMT->contents[index] & 1) == 0) {
+ result = IMT->contents[index];
+ } else {
+ uintptr_t* table = (uintptr_t*)(IMT->contents[index] & ~1);
+ uint32 i = 0;
+ while (table[i] != (uintptr_t)meth && table[i] != 0) { i += 2; }
+ assert(table[i] != 0);
+ result = table[i + 1];
+ }
+ assert((result != 0) && "Bad IMT");
+ return (void*)result;
+}
+
extern "C" void j3PrintMethodStart(JavaMethod* meth) {
fprintf(stderr, "[%p] executing %s.%s\n", (void*)mvm::Thread::get(),
UTF8Buffer(meth->classDef->name).cString(),
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaString.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaString.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaString.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaString.h Tue Nov 30 06:21:29 2010
@@ -21,10 +21,9 @@
class Jnjvm;
class JavaString : public JavaObject {
-private:
+public:
// CLASSPATH FIELDS!!
const ArrayUInt16* value;
-public:
sint32 count;
sint32 cachedHashCode;
sint32 offset;
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp Tue Nov 30 06:21:29 2010
@@ -19,23 +19,14 @@
using namespace j3;
-const unsigned int JavaThread::StateRunning = 0;
-const unsigned int JavaThread::StateWaiting = 1;
-const unsigned int JavaThread::StateInterrupted = 2;
-
-JavaThread::JavaThread(mvm::Thread* mut, JavaObject* thread, JavaObject* vmth, Jnjvm* isolate)
+JavaThread::JavaThread(mvm::Thread* mut, Jnjvm* isolate)
: mvm::VMThreadData(mut) {
- llvm_gcroot(thread, 0);
- llvm_gcroot(vmth, 0);
-
- javaThread = thread;
- vmThread = vmth;
- interruptFlag = 0;
- state = StateRunning;
- pendingException = 0;
+ pendingException = NULL;
jniEnv = isolate->jniEnv;
localJNIRefs = new JNILocalReferences();
- currentAddedReferences = 0;
+ currentAddedReferences = NULL;
+ javaThread = NULL;
+ vmThread = NULL;
jnjvm = isolate;
#ifdef SERVICE
@@ -51,14 +42,21 @@
return (JavaThread*)mut->vmData;
}
-mvm::Thread *JavaThread::create(JavaObject* thread, JavaObject* vmth, Jnjvm* isolate) {
+mvm::Thread *JavaThread::create(Jnjvm* isolate) {
mvm::Thread *mut = new mvm::MutatorThread();
- JavaThread *th = new JavaThread(mut, thread, vmth, isolate);
+ JavaThread *th = new JavaThread(mut, isolate);
mut->MyVM = isolate;
mut->vmData = th;
return mut;
}
+void JavaThread::initialise(JavaObject* thread, JavaObject* vmth) {
+ llvm_gcroot(thread, 0);
+ llvm_gcroot(vmth, 0);
+ javaThread = thread;
+ vmThread = vmth;
+}
+
JavaThread::~JavaThread() {
delete localJNIRefs;
#ifdef SERVICE
@@ -66,12 +64,22 @@
#endif
}
+void JavaThread::preparePendingException(JavaObject *obj) {
+ llvm_gcroot(obj, 0);
+ assert(JavaThread::get()->pendingException == 0 && "pending exception already there?");
+ mvm::Thread* mut = mvm::Thread::get();
+ j3Thread(mut)->pendingException = obj;
+#ifdef DWARF_EXCEPTIONS
+ throwPendingException();
+#endif
+}
+
void JavaThread::throwException(JavaObject* obj) {
llvm_gcroot(obj, 0);
assert(JavaThread::get()->pendingException == 0 && "pending exception already there?");
mvm::Thread* mut = mvm::Thread::get();
j3Thread(mut)->pendingException = obj;
- mut->internalThrowException();
+ throwPendingException();
}
void JavaThread::throwPendingException() {
@@ -79,9 +87,16 @@
mvm::Thread::get()->internalThrowException();
}
-void JavaThread::startJNI(int level) {
- // Start uncooperative mode.
- mut->enterUncooperativeCode(level);
+void JavaThread::startJNI() {
+ // Interesting, but no need to do anything.
+}
+
+void JavaThread::endJNI() {
+ localJNIRefs->removeJNIReferences(this, *currentAddedReferences);
+ mut->endUnknownFrame();
+
+ // Go back to cooperative mode.
+ mut->leaveUncooperativeCode();
}
uint32 JavaThread::getJavaFrameContext(void** buffer) {
@@ -89,8 +104,8 @@
uint32 i = 0;
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1) {
- JavaMethod* M = (JavaMethod*)MI->getMetaInfo();
+ if (MI->isHighLevelMethod()) {
+ JavaMethod* M = (JavaMethod*)MI->MetaInfo;
buffer[i++] = M;
}
++Walker;
@@ -103,9 +118,9 @@
uint32 index = 0;
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1) {
+ if (MI->isHighLevelMethod()) {
if (index == level) {
- return (JavaMethod*)MI->getMetaInfo();
+ return (JavaMethod*)MI->MetaInfo;
}
++index;
}
@@ -128,8 +143,8 @@
mvm::StackWalker Walker(mut);
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1) {
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ if (MI->isHighLevelMethod() == 1) {
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
JnjvmClassLoader* loader = meth->classDef->classLoader;
obj = loader->getJavaClassLoader();
if (obj) return obj;
@@ -144,7 +159,7 @@
mvm::StackWalker Walker(mut);
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1)
+ if (MI->isHighLevelMethod())
MI->print(Walker.ip, Walker.addr);
++Walker;
}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h Tue Nov 30 06:21:29 2010
@@ -13,6 +13,7 @@
#include "mvm/Object.h"
#include "mvm/Threads/Cond.h"
#include "mvm/Threads/Locks.h"
+#include "mvm/Threads/ObjectLocks.h"
#include "mvm/Threads/Thread.h"
#include "MutatorThread.h"
@@ -83,33 +84,7 @@
///
JavaObject* vmThread;
- /// varcond - Condition variable when the thread needs to be awaken from
- /// a wait.
- ///
- mvm::Cond varcond;
-
- /// interruptFlag - Has this thread been interrupted?
- ///
- uint32 interruptFlag;
-
- /// nextWaiting - Next thread waiting on the same monitor.
- ///
- JavaThread* nextWaiting;
-
- /// prevWaiting - Previous thread waiting on the same monitor.
- ///
- JavaThread* prevWaiting;
-
- /// waitsOn - The monitor on which the thread is waiting on.
- ///
- JavaLock* waitsOn;
-
- static const unsigned int StateRunning;
- static const unsigned int StateWaiting;
- static const unsigned int StateInterrupted;
-
- /// state - The current state of this thread: Running, Waiting or Interrupted.
- uint32 state;
+ mvm::LockingThread lockingThread;
/// currentAddedReferences - Current number of added local references.
///
@@ -148,25 +123,29 @@
///
~JavaThread();
- /// JavaThread - Creates a Java thread. Link the JavaThread to the mutator thread.
+ /// JavaThread - Creates a Java thread.
///
- JavaThread(mvm::Thread* mut, JavaObject* thread, JavaObject* vmThread, Jnjvm* isolate);
+ JavaThread(mvm::Thread*, Jnjvm* isolate);
/// create - Creates a Java thread and a mutator thread.
///
- static mvm::Thread* create(JavaObject* thread, JavaObject* vmThread, Jnjvm* isolate);
+ static mvm::Thread* create(Jnjvm* isolate);
/// j3Thread - gives the JavaThread associated with the mutator thread
///
static JavaThread* j3Thread(mvm::Thread* mut);
- /// get - Get the current thread as a JnJVM object.
+ /// initialise - initialise the thread
+ ///
+ void initialise(JavaObject* thread, JavaObject* vmth);
+
+ /// get - Get the current thread as a J3 object.
///
static JavaThread* get() {
return j3Thread(mvm::Thread::get());
}
- /// getJVM - Get the JnJVM in which this thread executes.
+ /// getJVM - Get the Java VM in which this thread executes.
///
Jnjvm* getJVM() {
return jnjvm;
@@ -177,6 +156,10 @@
JavaObject* currentThread() {
return javaThread;
}
+
+ /// preparePendingException - set the pending exception and throw it if in dwarf
+ ///
+ void preparePendingException(JavaObject *obj);
/// throwException - Throw the given exception in the current thread.
///
@@ -185,10 +168,14 @@
/// throwPendingException - Throw a pending exception.
///
void throwPendingException();
+
+ /// clearPendingException - Clear the pending exception.
+ //
+ void clearPendingException() { pendingException = 0; }
- /// getJavaException - Return the pending exception.
+ /// getPendingException - Return the pending exception.
///
- JavaObject* getJavaException() {
+ JavaObject* getPendingException() {
return pendingException;
}
@@ -221,15 +208,9 @@
/// startJNI - Record that we are entering native code.
///
- void startJNI(int level) __attribute__ ((noinline));
+ void startJNI();
- void endJNI() {
- localJNIRefs->removeJNIReferences(this, *currentAddedReferences);
-
- // Go back to cooperative mode.
- mut->leaveUncooperativeCode();
- mut->endKnownFrame();
- }
+ void endJNI();
/// getCallingMethod - Get the Java method in the stack at the specified
/// level.
@@ -256,16 +237,6 @@
///
uint32 getJavaFrameContext(void** buffer);
-private:
- /// internalClearException - Clear the C++ and Java exceptions
- /// currently pending.
- ///
- virtual void internalClearException() {
- pendingException = NULL;
- }
-
-public:
-
#ifdef SERVICE
/// ServiceException - The exception that will be thrown if a bundle is
/// stopped.
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Tue Nov 30 06:21:29 2010
@@ -34,6 +34,7 @@
#include "LinkJavaRuntime.h"
#include "LockedMap.h"
#include "Reader.h"
+#include "ReferenceQueue.h"
#include "Zip.h"
using namespace j3;
@@ -42,12 +43,6 @@
const char* Jnjvm::envSeparator = ":";
const unsigned int Jnjvm::Magic = 0xcafebabe;
-#ifdef ISOLATE
-Jnjvm* Jnjvm::RunningIsolates[NR_ISOLATES];
-mvm::LockNormal Jnjvm::IsolateLock;
-#endif
-
-
/// initialiseClass - Java class initialisation. Java specification §2.17.5.
void UserClass::initialiseClass(Jnjvm* vm) {
@@ -123,16 +118,12 @@
bool vmjced = (getInitializationState() == vmjc);
setInitializationState(inClinit);
UserClass* cl = (UserClass*)this;
-#if defined(ISOLATE) || defined(ISOLATE_SHARING)
- // Isolate environments allocate the static instance on their own, not when
- // the class is being resolved.
- cl->allocateStaticInstance(vm);
-#else
+
// Single environment allocates the static instance during resolution, so
// that compiled code can access it directly (with an initialization
// check just before the access)
if (!cl->getStaticInstance()) cl->allocateStaticInstance(vm);
-#endif
+
release();
@@ -157,17 +148,12 @@
} END_CATCH;
JavaThread* th = JavaThread::get();
- if (th->pendingException != NULL) {
+ if (th->getPendingException() != NULL) {
th->throwPendingException();
return;
}
}
-#ifdef SERVICE
- if (classLoader == classLoader->bootstrapLoader ||
- classLoader->getIsolate() == vm) {
-#endif
-
// 8. Next, execute either the class variable initializers and static
// initializers of the class or the field initializers of the interface,
// in textual order, as though they were a single block, except that
@@ -197,14 +183,11 @@
TRY {
meth->invokeIntStatic(vm, cl);
} CATCH {
- exc = JavaThread::get()->getJavaException();
+ exc = JavaThread::get()->getPendingException();
assert(exc && "no exception?");
- mvm::Thread::get()->clearException();
+ mvm::Thread::get()->clearPendingException();
} END_CATCH;
}
-#ifdef SERVICE
- }
-#endif
// 9. If the execution of the initializers completes normally, then lock
// this Class object, label it fully initialized, notify all waiting
@@ -831,19 +814,18 @@
}
-char* findInformation(Jnjvm* vm, ArrayUInt8* manifest, const char* entry,
- uint32 len) {
- llvm_gcroot(manifest, 0);
- sint32 index = sys_strnstr((char*)ArrayUInt8::getElements(manifest), entry);
+static char* findInformation(Jnjvm* vm, ClassBytes* manifest, const char* entry,
+ uint32 len) {
+ sint32 index = sys_strnstr((char*)manifest->elements, entry);
if (index != -1) {
index += len;
- sint32 end = sys_strnstr((char*)ArrayUInt8::getElements(manifest) + index, "\n");
- if (end == -1) end = ArrayUInt8::getSize(manifest);
+ sint32 end = sys_strnstr((char*)manifest->elements + index, "\n");
+ if (end == -1) end = manifest->size;
else end += index;
sint32 length = end - index - 1;
char* name = (char*)vm->allocator.Allocate(length + 1, "class name");
- memcpy(name, ArrayUInt8::getElements(manifest) + index, length);
+ memcpy(name, manifest->elements + index, length);
name[length] = 0;
return name;
} else {
@@ -853,10 +835,8 @@
void ClArgumentsInfo::extractClassFromJar(Jnjvm* vm, int argc, char** argv,
int i) {
- ArrayUInt8* bytes = NULL;
- ArrayUInt8* res = NULL;
- llvm_gcroot(bytes, 0);
- llvm_gcroot(res, 0);
+ ClassBytes* bytes = NULL;
+ ClassBytes* res = NULL;
jarFile = argv[i];
vm->setClasspath(jarFile);
@@ -871,13 +851,10 @@
mvm::BumpPtrAllocator allocator;
ZipArchive* archive = new(allocator, "TempZipArchive")
ZipArchive(bytes, allocator);
- // Make sure it gets GC'd.
- vm->bootstrapLoader->bootArchives.push_back(archive);
if (archive->getOfscd() != -1) {
ZipFile* file = archive->getFile(PATH_MANIFEST);
if (file != NULL) {
- UserClassArray* array = vm->bootstrapLoader->upcalls->ArrayOfByte;
- res = (ArrayUInt8*)array->doNew(file->ucsize, vm);
+ res = new (allocator, file->ucsize) ClassBytes(file->ucsize);
int ok = archive->readFile(res, file);
if (ok) {
char* mainClass = findInformation(vm, res, MAIN_CLASS,
@@ -900,8 +877,6 @@
} else {
printf("Can't find archive %s\n", jarFile);
}
- // We don't need this archive anymore.
- vm->bootstrapLoader->bootArchives.pop_back();
}
void ClArgumentsInfo::nyi() {
@@ -1091,11 +1066,13 @@
JnjvmClassLoader* loader = bootstrapLoader;
// First create system threads.
- finalizerThread = JavaThread::create(0, 0, this);
- finalizerThread->start(finalizerStart);
+ finalizerThread = new FinalizerThread(this);
+ finalizerThread->start(
+ (void (*)(mvm::Thread*))FinalizerThread::finalizerStart);
- enqueueThread = JavaThread::create(0, 0, this);
- enqueueThread->start(enqueueStart);
+ referenceThread = new ReferenceThread(this);
+ referenceThread->start(
+ (void (*)(mvm::Thread*))ReferenceThread::enqueueStart);
// Initialise the bootstrap class loader if it's not
// done already.
@@ -1130,9 +1107,6 @@
}
upcalls->newString->initialiseClass(this);
-#ifdef SERVICE
- if (!IsolateID)
-#endif
// The initialization code of the classes initialized below may require
// to get the Java thread, so we create the Java thread object first.
upcalls->InitializeThreading(this);
@@ -1191,9 +1165,6 @@
obj = JavaThread::get()->currentThread();
javaLoader = appClassLoader->getJavaClassLoader();
-#ifdef SERVICE
- if (!IsolateID)
-#endif
upcalls->setContextClassLoader->invokeIntSpecial(this, upcalls->newThread,
obj, &javaLoader);
// load and initialise math since it is responsible for dlopen'ing
@@ -1240,7 +1211,7 @@
exc = JavaThread::get()->pendingException;
if (exc != NULL) {
mvm::Thread* mut = mvm::Thread::get();
- mut->clearException();
+ mut->clearPendingException();
JavaThread* th = JavaThread::j3Thread(mut);
obj = th->currentThread();
group = upcalls->group->getInstanceObjectField(obj);
@@ -1322,10 +1293,6 @@
fprintf(stderr, "Exception %s while bootstrapping VM.",
UTF8Buffer(JavaObject::getClass(exc)->name).cString());
} else {
-#ifdef SERVICE
- thread->ServiceException = vm->upcalls->newThrowable->doNew(vm);
-#endif
-
ClArgumentsInfo& info = vm->argumentsInfo;
if (info.agents.size()) {
@@ -1362,51 +1329,15 @@
nonDaemonLock.unlock();
}
-#ifdef SERVICE
-
-#include <signal.h>
-
-extern void terminationHandler(int);
-
-static void serviceCPUMonitor(mvm::Thread* th) {
- while (true) {
- sleep(1);
- for(JavaThread* cur = (Java*)th->next(); cur != th;
- cur = (JavaThread*)cur->next()) {
- JavaThread* th = (JavaThread*)cur;
- if (!(th->StateWaiting)) {
- mvm::VirtualMachine* executingVM = cur->MyVM;
- assert(executingVM && "Thread with no VM!");
- ++executingVM->executionTime;
- }
- }
- }
-}
-#endif
-
void Jnjvm::runApplication(int argc, char** argv) {
argumentsInfo.argc = argc;
argumentsInfo.argv = argv;
-#ifdef SERVICE
- struct sigaction sa;
- sigset_t mask;
- sigfillset(&mask);
- sigaction(SIGUSR1, 0, &sa);
- sa.sa_mask = mask;
- sa.sa_handler = terminationHandler;
- sa.sa_flags |= SA_RESTART;
- sigaction(SIGUSR1, &sa, NULL);
-
- mvm::Thread* th = JavaThread::create(0, 0, this);
- th->start(serviceCPUMonitor);
-#endif
-
- mainThread = JavaThread::create(0, 0, this);
- mainThread->start(mainJavaStart);
+ mainThread = JavaThread::create(this);
+ mainThread->start((void (*)(mvm::Thread*))mainJavaStart);
}
Jnjvm::Jnjvm(mvm::BumpPtrAllocator& Alloc, JnjvmBootstrapLoader* loader) :
- VirtualMachine(Alloc), lockSystem(this) {
+ VirtualMachine(Alloc), lockSystem(Alloc) {
classpath = getenv("CLASSPATH");
if (!classpath) classpath = ".";
@@ -1415,7 +1346,6 @@
jniEnv = &JNI_JNIEnvTable;
javavmEnv = &JNI_JavaVMTable;
-
bootstrapLoader = loader;
upcalls = bootstrapLoader->upcalls;
@@ -1431,26 +1361,9 @@
}
bootstrapLoader->insertAllMethodsInVM(this);
-
-#ifdef ISOLATE
- IsolateLock.lock();
- for (uint32 i = 0; i < NR_ISOLATES; ++i) {
- if (RunningIsolates[i] == 0) {
- RunningIsolates[i] = this;
- IsolateID = i;
- break;
- }
- }
- IsolateLock.unlock();
-#endif
-
- scanner = loader->getCompiler()->createStackScanner();
}
Jnjvm::~Jnjvm() {
-#ifdef ISOLATE
- RunningIsolates[IsolateID] = 0;
-#endif
}
ArrayUInt16* Jnjvm::asciizToArray(const char* asciiz) {
@@ -1466,49 +1379,84 @@
return tmp;
}
-void Jnjvm::internalRemoveMethods(JnjvmClassLoader* loader, mvm::FunctionMap& Map) {
- // Loop over all methods in the map to find which ones belong
- // to this class loader.
- Map.FunctionMapLock.acquire();
- std::map<void*, mvm::MethodInfo*>::iterator temp;
- for (std::map<void*, mvm::MethodInfo*>::iterator i = Map.Functions.begin(),
- e = Map.Functions.end(); i != e;) {
- mvm::MethodInfo* MI = i->second;
- if (MI->MethodType == 1) {
- JavaMethod* meth = (JavaMethod*)i->second->getMetaInfo();
- if (meth->classDef->classLoader == loader) {
- temp = i;
- ++i;
- Map.Functions.erase(temp);
- } else {
- ++i;
- }
- } else {
- ++i;
- }
- }
- Map.FunctionMapLock.release();
+void Jnjvm::startCollection() {
+ finalizerThread->FinalizationQueueLock.acquire();
+ referenceThread->ToEnqueueLock.acquire();
+ referenceThread->SoftReferencesQueue.acquire();
+ referenceThread->WeakReferencesQueue.acquire();
+ referenceThread->PhantomReferencesQueue.acquire();
+}
+
+void Jnjvm::endCollection() {
+ finalizerThread->FinalizationQueueLock.release();
+ referenceThread->ToEnqueueLock.release();
+ referenceThread->SoftReferencesQueue.release();
+ referenceThread->WeakReferencesQueue.release();
+ referenceThread->PhantomReferencesQueue.release();
+ finalizerThread->FinalizationCond.broadcast();
+ referenceThread->EnqueueCond.broadcast();
+}
+
+void Jnjvm::scanWeakReferencesQueue(uintptr_t closure) {
+ referenceThread->WeakReferencesQueue.scan(referenceThread, closure);
+}
+
+void Jnjvm::scanSoftReferencesQueue(uintptr_t closure) {
+ referenceThread->SoftReferencesQueue.scan(referenceThread, closure);
+}
+
+void Jnjvm::scanPhantomReferencesQueue(uintptr_t closure) {
+ referenceThread->PhantomReferencesQueue.scan(referenceThread, closure);
+}
+
+void Jnjvm::scanFinalizationQueue(uintptr_t closure) {
+ finalizerThread->scanFinalizationQueue(closure);
}
-void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) {
- internalRemoveMethods(loader, RuntimeFunctions);
- internalRemoveMethods(loader, StaticFunctions);
+void Jnjvm::addFinalizationCandidate(gc* object) {
+ llvm_gcroot(object, 0);
+ finalizerThread->addFinalizationCandidate(object);
}
+size_t Jnjvm::getObjectSize(gc* object) {
+ // TODO: because this is called during GC, there is no need to do
+ // llvm_gcroot. For clarity, it may be useful to have a special type
+ // in this case.
+ size_t size = 0;
+ JavaObject* src = (JavaObject*)object;
+ if (VMClassLoader::isVMClassLoader(src)) {
+ size = sizeof(VMClassLoader);
+ } else {
+ CommonClass* cl = JavaObject::getClass(src);
+ if (cl->isArray()) {
+ UserClassArray* array = cl->asArrayClass();
+ UserCommonClass* base = array->baseClass();
+ uint32 logSize = base->isPrimitive() ?
+ base->asPrimitiveClass()->logSize : (sizeof(JavaObject*) == 8 ? 3 : 2);
-/// JavaStaticCompiler - Compiler for AOT-compiled programs that
-/// do not use the JIT.
-class JavaStaticCompiler : public JavaCompiler {
-public:
-#ifdef WITH_LLVM_GCC
- virtual mvm::StackScanner* createStackScanner() {
- return new mvm::PreciseStackScanner();
+ size = sizeof(JavaObject) + sizeof(ssize_t) +
+ (JavaArray::getSize(src) << logSize);
+ } else {
+ assert(cl->isClass() && "Not a class!");
+ size = cl->asClass()->getVirtualSize();
+ }
}
-#endif
-};
+ return size;
+}
+const char* Jnjvm::getObjectTypeName(gc* object) {
+ JavaObject* src = (JavaObject*)object;
+ if (VMClassLoader::isVMClassLoader(src)) {
+ return "VMClassLoader";
+ } else {
+ CommonClass* cl = JavaObject::getClass(src);
+ // This code is only used for debugging on a fatal error. It is fine to
+ // allocate in the C++ heap.
+ return (new UTF8Buffer(cl->name))->cString();
+ }
+}
-// Helper function to run Jnjvm without JIT.
+// Helper function to run J3 without JIT.
extern "C" int StartJnjvmWithoutJIT(int argc, char** argv, char* mainClass) {
mvm::Collector::initialise();
@@ -1518,9 +1466,12 @@
newArgv[0] = newArgv[1];
newArgv[1] = mainClass;
- JavaCompiler* Comp = new JavaStaticCompiler();
- JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp);
- mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM(JCL);
+ mvm::BumpPtrAllocator Allocator;
+ JavaCompiler* Comp = new JavaCompiler();
+ JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
+ JnjvmBootstrapLoader(Allocator, Comp, true);
+ Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader);
+
vm->runApplication(argc + 1, newArgv);
vm->waitForExit();
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h Tue Nov 30 06:21:29 2010
@@ -19,8 +19,8 @@
#include "mvm/VirtualMachine.h"
#include "mvm/Threads/Cond.h"
#include "mvm/Threads/Locks.h"
+#include "mvm/Threads/ObjectLocks.h"
-#include "JavaLocks.h"
#include "JnjvmConfig.h"
#include "JNIReferences.h"
#include "LockedMap.h"
@@ -34,6 +34,7 @@
class ArrayObject;
class Classpath;
class CommonClass;
+class FinalizerThread;
class JavaField;
class JavaMethod;
class JavaObject;
@@ -42,6 +43,7 @@
class JavaVirtualTable;
class JnjvmBootstrapLoader;
class JnjvmClassLoader;
+class ReferenceThread;
class UserClass;
class UserClassArray;
class UserClassPrimitive;
@@ -124,11 +126,21 @@
/// finalizerThread - The thread that finalizes Java objects.
///
- mvm::Thread* finalizerThread;
+ FinalizerThread* finalizerThread;
/// enqueueThread - The thread that enqueue Java references.
///
- mvm::Thread* enqueueThread;
+ ReferenceThread* referenceThread;
+
+ virtual void startCollection();
+ virtual void endCollection();
+ virtual void scanWeakReferencesQueue(uintptr_t closure);
+ virtual void scanSoftReferencesQueue(uintptr_t closure);
+ virtual void scanPhantomReferencesQueue(uintptr_t closure);
+ virtual void scanFinalizationQueue(uintptr_t closure);
+ virtual void addFinalizationCandidate(gc* obj);
+ virtual size_t getObjectSize(gc* obj);
+ virtual const char* getObjectTypeName(gc* obj);
/// CreateError - Creates a Java object of the specified exception class
/// and calling its <init> function.
@@ -201,7 +213,7 @@
/// lockSystem - The lock system to allocate and manage Java locks.
///
- LockSystem lockSystem;
+ mvm::LockSystem lockSystem;
/// argumentsInfo - The command line arguments given to the vm
///
@@ -299,19 +311,19 @@
/// setFinalizerThread - Set the finalizer thread of this VM.
///
- void setFinalizerThread(mvm::Thread* th) { finalizerThread = th; }
+ void setFinalizerThread(FinalizerThread* th) { finalizerThread = th; }
/// getFinalizerThread - Get the finalizer thread of this VM.
///
- mvm::Thread* getFinalizerThread() const { return finalizerThread; }
+ FinalizerThread* getFinalizerThread() const { return finalizerThread; }
- /// setEnqueueThread - Set the enqueue thread of this VM.
+ /// setReferenceThread - Set the enqueue thread of this VM.
///
- void setEnqueueThread(mvm::Thread* th) { enqueueThread = th; }
+ void setReferenceThread(ReferenceThread* th) { referenceThread = th; }
- /// getEnqueueThread - Get the enqueue thread of this VM.
+ /// getReferenceThread - Get the enqueue thread of this VM.
///
- mvm::Thread* getEnqueueThread() const { return enqueueThread; }
+ ReferenceThread* getReferenceThread() const { return referenceThread; }
/// ~Jnjvm - Destroy the JVM.
///
@@ -340,44 +352,11 @@
///
virtual void waitForExit();
- virtual JavaLock* allocateFatLock(gc*);
- virtual JavaLock* getFatLockFromID(uintptr_t val);
-
-private:
- /// internalRemoveMethodsInFunctionMap - Removes all methods compiled by this
- /// class loader from the function map.
- ///
- void internalRemoveMethods(JnjvmClassLoader* loader, mvm::FunctionMap& Map);
-
-public:
- /// removeMethodsInFunctionMaps - Removes all methods compiled by this
- /// class loader from the function maps.
- ///
- void removeMethodsInFunctionMaps(JnjvmClassLoader* loader);
-
/// loadBootstrap - Bootstraps the JVM, getting the class loader, initializing
- /// bootstrap classes (e.g. java/lang/Class, java/lang/*Exception) and
+ /// bootstrap classes (e.g. java/lang/Class, java/lang/Exception) and
/// mapping the initial thread.
///
void loadBootstrap();
-
-#ifdef ISOLATE
- static Jnjvm* RunningIsolates[NR_ISOLATES];
- static mvm::LockNormal IsolateLock;
-#endif
-
-#ifdef SERVICE
- virtual void stopService();
-#endif
-
- virtual void clearReferent(gc*);
- virtual gc** getReferentPtr(gc*);
- virtual void setReferent(gc*, gc*);
- virtual bool enqueueReference(gc*);
-
-protected:
- virtual void invokeFinalizer(gc*);
-
};
} // end namespace j3
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp Tue Nov 30 06:21:29 2010
@@ -308,9 +308,8 @@
TheCompiler = Comp;
}
-ArrayUInt8* JnjvmBootstrapLoader::openName(const UTF8* utf8) {
- ArrayUInt8* res = 0;
- llvm_gcroot(res, 0);
+ClassBytes* JnjvmBootstrapLoader::openName(const UTF8* utf8) {
+ ClassBytes* res = 0;
mvm::ThreadAllocator threadAllocator;
char* asciiz = (char*)threadAllocator.Allocate(utf8->size + 1);
@@ -348,8 +347,7 @@
UserClass* JnjvmBootstrapLoader::internalLoad(const UTF8* name,
bool doResolve,
JavaString* strName) {
- ArrayUInt8* bytes = NULL;
- llvm_gcroot(bytes, 0);
+ ClassBytes* bytes = NULL;
llvm_gcroot(strName, 0);
UserCommonClass* cl = lookupClass(name);
@@ -667,9 +665,8 @@
}
UserClass* JnjvmClassLoader::constructClass(const UTF8* name,
- ArrayUInt8* bytes) {
+ ClassBytes* bytes) {
JavaObject* excp = NULL;
- llvm_gcroot(bytes, 0);
llvm_gcroot(excp, 0);
UserClass* res = NULL;
lock.lock();
@@ -688,12 +685,14 @@
getCompiler()->resolveVirtualClass(res);
getCompiler()->resolveStaticClass(res);
classes->lock.lock();
+ assert(res->getDelegatee() == NULL);
+ assert(res->getStaticInstance() == NULL);
bool success = classes->map.insert(std::make_pair(internalName, res)).second;
classes->lock.unlock();
assert(success && "Could not add class in map");
} CATCH {
excp = JavaThread::get()->pendingException;
- mvm::Thread::get()->clearException();
+ mvm::Thread::get()->clearPendingException();
} END_CATCH;
}
if (excp != NULL) {
@@ -912,8 +911,9 @@
JnjvmClassLoader::~JnjvmClassLoader() {
- if (isolate)
- isolate->removeMethodsInFunctionMaps(this);
+ if (isolate) {
+ isolate->removeMethodInfos(TheCompiler);
+ }
if (classes) {
classes->~ClassMap();
@@ -966,8 +966,7 @@
}
void JnjvmBootstrapLoader::analyseClasspathEnv(const char* str) {
- ArrayUInt8* bytes = NULL;
- llvm_gcroot(bytes, 0);
+ ClassBytes* bytes = NULL;
mvm::ThreadAllocator threadAllocator;
if (str != 0) {
unsigned int len = strlen(str);
@@ -1087,8 +1086,32 @@
return res;
}
+class JavaStaticMethodInfo : public mvm::CamlMethodInfo {
+public:
+ virtual void print(void* ip, void* addr);
+ virtual bool isHighLevelMethod() {
+ return true;
+ }
+
+ JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) :
+ mvm::CamlMethodInfo(super->CF) {
+ MetaInfo = M;
+ Owner = M->classDef->classLoader->getCompiler();
+ }
+};
+
+void JavaStaticMethodInfo::print(void* ip, void* addr) {
+ void* new_ip = NULL;
+ if (ip) new_ip = mvm::MethodInfo::isStub(ip, addr);
+ JavaMethod* meth = (JavaMethod*)MetaInfo;
+ fprintf(stderr, "; %p in %s.%s", new_ip,
+ UTF8Buffer(meth->classDef->name).cString(),
+ UTF8Buffer(meth->name).cString());
+ if (ip != new_ip) fprintf(stderr, " (from stub)");
+ fprintf(stderr, "\n");
+}
+
void JnjvmClassLoader::insertAllMethodsInVM(Jnjvm* vm) {
- JavaCompiler* M = getCompiler();
for (ClassMap::iterator i = classes->map.begin(), e = classes->map.end();
i != e; ++i) {
CommonClass* cl = i->second;
@@ -1100,8 +1123,7 @@
if (!isAbstract(meth.access) && meth.code) {
JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")
JavaStaticMethodInfo(0, meth.code, &meth);
- vm->StaticFunctions.addMethodInfo(MI, meth.code);
- M->setMethod(&meth, meth.code, "");
+ vm->FunctionsCache.addMethodInfo(MI, meth.code);
}
}
@@ -1110,8 +1132,7 @@
if (!isAbstract(meth.access) && meth.code) {
JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")
JavaStaticMethodInfo(0, meth.code, &meth);
- vm->StaticFunctions.addMethodInfo(MI, meth.code);
- M->setMethod(&meth, meth.code, "");
+ vm->FunctionsCache.addMethodInfo(MI, meth.code);
}
}
}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.h Tue Nov 30 06:21:29 2010
@@ -26,9 +26,9 @@
namespace j3 {
-class ArrayUInt8;
class UserClass;
class UserClassArray;
+class ClassBytes;
class ClassMap;
class Classpath;
class UserCommonClass;
@@ -209,7 +209,7 @@
/// constructClass - Hashes a runtime representation of a class with
/// the given name.
///
- UserClass* constructClass(const UTF8* name, ArrayUInt8* bytes);
+ UserClass* constructClass(const UTF8* name, ClassBytes* bytes);
/// constructType - Hashes a Typedef, an internal representation of a class
/// still not loaded.
@@ -326,7 +326,7 @@
/// openName - Opens a file of the given name and returns it as an array
/// of byte.
///
- ArrayUInt8* openName(const UTF8* utf8);
+ ClassBytes* openName(const UTF8* utf8);
public:
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/LockedMap.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/LockedMap.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/LockedMap.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/LockedMap.h Tue Nov 30 06:21:29 2010
@@ -31,6 +31,7 @@
namespace j3 {
class JavaString;
+class JnjvmClassLoader;
class Signdef;
class Typedef;
class UserCommonClass;
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Reader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Reader.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Reader.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Reader.cpp Tue Nov 30 06:21:29 2010
@@ -12,10 +12,7 @@
#include "types.h"
-#include "Jnjvm.h"
-#include "JavaArray.h"
-#include "JavaThread.h"
-#include "JavaUpcalls.h"
+#include "JnjvmClassLoader.h"
#include "Reader.h"
#include "Zip.h"
@@ -25,17 +22,15 @@
const int Reader::SeekCur = SEEK_CUR;
const int Reader::SeekEnd = SEEK_END;
-ArrayUInt8* Reader::openFile(JnjvmBootstrapLoader* loader, const char* path) {
- ArrayUInt8* res = NULL;
- llvm_gcroot(res, 0);
+ClassBytes* Reader::openFile(JnjvmClassLoader* loader, const char* path) {
+ ClassBytes* res = NULL;
FILE* fp = fopen(path, "r");
if (fp != 0) {
fseek(fp, 0, SeekEnd);
long nbb = ftell(fp);
fseek(fp, 0, SeekSet);
- UserClassArray* array = loader->upcalls->ArrayOfByte;
- res = (ArrayUInt8*)array->doNew((sint32)nbb, JavaThread::get()->getJVM());
- if (fread(ArrayUInt8::getElements(res), nbb, 1, fp) == 0) {
+ res = new (loader->allocator, nbb) ClassBytes(nbb);
+ if (fread(res->elements, nbb, 1, fp) == 0) {
fprintf(stderr, "fread error\n");
abort();
}
@@ -44,14 +39,12 @@
return res;
}
-ArrayUInt8* Reader::openZip(JnjvmBootstrapLoader* loader, ZipArchive* archive,
+ClassBytes* Reader::openZip(JnjvmClassLoader* loader, ZipArchive* archive,
const char* filename) {
- ArrayUInt8* res = 0;
- llvm_gcroot(res, 0);
+ ClassBytes* res = 0;
ZipFile* file = archive->getFile(filename);
if (file != 0) {
- UserClassArray* array = loader->upcalls->ArrayOfByte;
- res = (ArrayUInt8*)array->doNew((sint32)file->ucsize, JavaThread::get()->getJVM());
+ res = new (loader->allocator, file->ucsize) ClassBytes(file->ucsize);
if (archive->readFile(res, file) != 0) {
return res;
}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Reader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Reader.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Reader.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Reader.h Tue Nov 30 06:21:29 2010
@@ -20,18 +20,35 @@
namespace j3 {
class JnjvmBootstrapLoader;
+class JnjvmClassLoader;
class ZipArchive;
+
+class ClassBytes {
+ public:
+ ClassBytes(int l) {
+ size = l;
+ }
+
+ void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator, int n) {
+ return allocator.Allocate(sizeof(uint32_t) + n * sizeof(uint8_t),
+ "Class bytes");
+ }
+
+ uint32_t size;
+ uint8_t elements[1];
+};
+
class Reader {
public:
// bytes - Pointer to a reference array. The array is not manipulated directly
// in order to support copying GC.
- ArrayUInt8** bytes;
+ ClassBytes* bytes;
uint32 min;
uint32 cursor;
uint32 max;
- Reader(Attribut* attr, ArrayUInt8** bytes) {
+ Reader(Attribut* attr, ClassBytes* bytes) {
this->bytes = bytes;
this->cursor = attr->start;
this->min = attr->start;
@@ -78,18 +95,18 @@
static const int SeekCur;
static const int SeekEnd;
- static ArrayUInt8* openFile(JnjvmBootstrapLoader* loader, const char* path);
- static ArrayUInt8* openZip(JnjvmBootstrapLoader* loader, ZipArchive* archive,
+ static ClassBytes* openFile(JnjvmClassLoader* loader, const char* path);
+ static ClassBytes* openZip(JnjvmClassLoader* loader, ZipArchive* archive,
const char* filename);
uint8 readU1() {
++cursor;
- return ArrayUInt8::getElement(*bytes, cursor - 1);
+ return bytes->elements[cursor - 1];
}
sint8 readS1() {
++cursor;
- return ArrayUInt8::getElement(*bytes, cursor - 1);
+ return bytes->elements[cursor - 1];
}
uint16 readU2() {
@@ -122,8 +139,8 @@
return tmp | ((sint64)(readU4()));
}
- Reader(ArrayUInt8** array, uint32 start = 0, uint32 end = 0) {
- if (!end) end = ArrayUInt8::getSize(*array);
+ Reader(ClassBytes* array, uint32 start = 0, uint32 end = 0) {
+ if (!end) end = array->size;
this->bytes = array;
this->cursor = start;
this->min = start;
Copied: vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp (from r120292, vmkit/trunk/lib/J3/VMCore/ReferenceQueue.cpp)
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp?p2=vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp&p1=vmkit/trunk/lib/J3/VMCore/ReferenceQueue.cpp&r1=120292&r2=120424&rev=120424&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/ReferenceQueue.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp Tue Nov 30 06:21:29 2010
@@ -15,7 +15,7 @@
using namespace j3;
-ReferenceThread::ReferenceThread(Jnjvm* vm) : JavaThread(vm),
+ReferenceThread::ReferenceThread(Jnjvm* vm) : Thread(),
WeakReferencesQueue(ReferenceQueue::WEAK),
SoftReferencesQueue(ReferenceQueue::SOFT),
PhantomReferencesQueue(ReferenceQueue::PHANTOM) {
@@ -23,6 +23,9 @@
ToEnqueue = new gc*[INITIAL_QUEUE_SIZE];
ToEnqueueLength = INITIAL_QUEUE_SIZE;
ToEnqueueIndex = 0;
+
+ MyVM = vm;
+ vmData = new JavaThread(this, vm);
}
@@ -40,7 +43,7 @@
TRY {
enqueueReference(res);
} IGNORE;
- mvm::Thread::get()->clearException();
+ mvm::Thread::get()->clearPendingException();
}
void ReferenceThread::enqueueStart(ReferenceThread* th) {
@@ -156,7 +159,7 @@
}
-FinalizerThread::FinalizerThread(Jnjvm* vm) : JavaThread(vm) {
+FinalizerThread::FinalizerThread(Jnjvm* vm) : Thread() {
FinalizationQueue = new gc*[INITIAL_QUEUE_SIZE];
QueueLength = INITIAL_QUEUE_SIZE;
CurrentIndex = 0;
@@ -164,6 +167,9 @@
ToBeFinalized = new gc*[INITIAL_QUEUE_SIZE];
ToBeFinalizedLength = INITIAL_QUEUE_SIZE;
CurrentFinalizedIndex = 0;
+
+ MyVM = vm;
+ vmData = new JavaThread(this, vm);
}
void FinalizerThread::growFinalizationQueue() {
@@ -247,7 +253,7 @@
TRY {
invokeFinalizer(res);
} IGNORE;
- mvm::Thread::get()->clearException();
+ mvm::Thread::get()->clearPendingException();
}
void FinalizerThread::finalizerStart(FinalizerThread* th) {
Copied: vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h (from r120292, vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h)
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h?p2=vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h&p1=vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h&r1=120292&r2=120424&rev=120424&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/ReferenceQueue.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h Tue Nov 30 06:21:29 2010
@@ -82,7 +82,7 @@
void scan(ReferenceThread* thread, uintptr_t closure);
};
-class ReferenceThread : public JavaThread {
+class ReferenceThread : public mvm::Thread {
public:
/// WeakReferencesQueue - The queue of weak references.
///
@@ -138,7 +138,7 @@
}
};
-class FinalizerThread : public JavaThread {
+class FinalizerThread : public mvm::Thread {
public:
/// FinalizationQueueLock - A lock to protect access to the queue.
///
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp Tue Nov 30 06:21:29 2010
@@ -30,6 +30,7 @@
#include "Jnjvm.h"
#include "JnjvmClassLoader.h"
#include "LockedMap.h"
+#include "ReferenceQueue.h"
#include "Zip.h"
using namespace j3;
@@ -141,8 +142,7 @@
// (2) The delegatee object (java.lang.Class) if it exists.
//
// Additionaly, non-primitive and non-array classes must trace:
-// (3) The bytes that represent the class file.
-// (4) The static instance.
+// (3) The static instance.
//===----------------------------------------------------------------------===//
void CommonClass::tracer(uintptr_t closure) {
@@ -173,7 +173,6 @@
void Class::tracer(uintptr_t closure) {
CommonClass::tracer(closure);
- mvm::Collector::markAndTraceRoot(&bytes, closure);
for (uint32 i = 0; i < NR_ISOLATES; ++i) {
TaskClassMirror &M = IsolateInfo[i];
@@ -242,11 +241,6 @@
TRACE_DELEGATEE(upcalls->OfLong);
TRACE_DELEGATEE(upcalls->OfDouble);
#undef TRACE_DELEGATEE
-
- for (std::vector<ZipArchive*>::iterator i = bootArchives.begin(),
- e = bootArchives.end(); i != e; i++) {
- mvm::Collector::markAndTraceRoot(&((*i)->bytes), closure);
- }
}
//===----------------------------------------------------------------------===//
@@ -264,15 +258,16 @@
void Jnjvm::tracer(uintptr_t closure) {
-
- VirtualMachine::tracer(closure);
+ // (1) Trace the bootrap loader.
bootstrapLoader->tracer(closure);
+ // (2) Trace the application class loader.
if (appClassLoader != NULL) {
mvm::Collector::markAndTraceRoot(
appClassLoader->getJavaClassLoaderPtr(), closure);
}
+ // (3) Trace JNI global references.
JNIGlobalReferences* start = &globalRefs;
while (start != NULL) {
for (uint32 i = 0; i < start->length; ++i) {
@@ -282,6 +277,7 @@
start = start->next;
}
+ // (4) Trace the interned strings.
for (StringMap::iterator i = hashStr.map.begin(), e = hashStr.map.end();
i!= e; ++i) {
JavaString** str = &(i->second);
@@ -289,24 +285,37 @@
ArrayUInt16** key = const_cast<ArrayUInt16**>(&(i->first));
mvm::Collector::markAndTraceRoot(key, closure);
}
+
+ // (5) Trace the finalization queue.
+ for (uint32 i = 0; i < finalizerThread->CurrentFinalizedIndex; ++i) {
+ mvm::Collector::markAndTraceRoot(finalizerThread->ToBeFinalized + i, closure);
+ }
+
+ // (6) Trace the reference queue
+ for (uint32 i = 0; i < referenceThread->ToEnqueueIndex; ++i) {
+ mvm::Collector::markAndTraceRoot(referenceThread->ToEnqueue + i, closure);
+ }
+ // (7) Trace the locks and their associated object.
uint32 i = 0;
- for (; i < LockSystem::GlobalSize; i++) {
- JavaLock** array = lockSystem.LockTable[i];
+ for (; i < mvm::LockSystem::GlobalSize; i++) {
+ mvm::FatLock** array = lockSystem.LockTable[i];
if (array == NULL) break;
uint32 j = 0;
- for (; j < LockSystem::IndexSize; j++) {
+ for (; j < mvm::LockSystem::IndexSize; j++) {
if (array[j] == NULL) break;
- JavaLock* lock = array[j];
+ mvm::FatLock* lock = array[j];
mvm::Collector::markAndTraceRoot(lock->getAssociatedObjectPtr(), closure);
}
- for (j = j + 1; j < LockSystem::IndexSize; j++) {
+ for (j = j + 1; j < mvm::LockSystem::IndexSize; j++) {
assert(array[j] == NULL);
}
}
- for (i = i + 1; i < LockSystem::GlobalSize; i++) {
+ for (i = i + 1; i < mvm::LockSystem::GlobalSize; i++) {
assert(lockSystem.LockTable[i] == NULL);
}
+
+
#if defined(ISOLATE_SHARING)
mvm::Collector::markAndTraceRoot(&JnjvmSharedLoader::sharedLoader, closure);
#endif
@@ -317,10 +326,9 @@
}
void JavaThread::tracer(uintptr_t closure) {
- if (pendingException != NULL) {
- mvm::Collector::markAndTraceRoot(&pendingException, closure);
- }
+ mvm::Collector::markAndTraceRoot(&pendingException, closure);
mvm::Collector::markAndTraceRoot(&javaThread, closure);
+ mvm::Collector::markAndTraceRoot(&vmThread, closure);
#ifdef SERVICE
mvm::Collector::markAndTraceRoot(&ServiceException, closure);
#endif
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Zip.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Zip.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Zip.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Zip.cpp Tue Nov 30 06:21:29 2010
@@ -17,8 +17,7 @@
using namespace j3;
-ZipArchive::ZipArchive(ArrayUInt8* bytes, mvm::BumpPtrAllocator& A) : allocator(A) {
- llvm_gcroot(bytes, 0);
+ZipArchive::ZipArchive(ClassBytes* bytes, mvm::BumpPtrAllocator& A) : allocator(A) {
this->bytes = bytes;
findOfscd();
if (ofscd > -1) addFiles();
@@ -74,7 +73,7 @@
sint32 minOffs = 0;
sint32 st = END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4;
- Reader reader(&bytes);
+ Reader reader(bytes);
curOffs = reader.max;
if (curOffs >= (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4)) {
minOffs = curOffs - (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4);
@@ -104,8 +103,8 @@
if (searchPos >= st) {
sint32 searchPtr = temp + (searchPos - st);
while (searchPtr > temp) {
- if (ArrayUInt8::getElement(bytes, searchPtr) == 'P' &&
- !(memcmp(ArrayUInt8::getElements(bytes) + searchPtr, HDR_ENDCENTRAL, 4))) {
+ if (bytes->elements[searchPtr] == 'P' &&
+ !(memcmp(bytes->elements + searchPtr, HDR_ENDCENTRAL, 4))) {
sint32 offset = searchPtr + 4 + E_OFFSET_START_CENTRAL_DIRECTORY;
reader.cursor = offset;
this->ofscd = readEndianDep4(reader);
@@ -120,11 +119,11 @@
void ZipArchive::addFiles() {
sint32 temp = ofscd;
- Reader reader(&bytes);
+ Reader reader(bytes);
reader.cursor = temp;
while (true) {
- if (memcmp(ArrayUInt8::getElements(bytes) + temp, HDR_CENTRAL, 4)) return;
+ if (memcmp(bytes->elements + temp, HDR_CENTRAL, 4)) return;
ZipFile* ptr = new(allocator, "ZipFile") ZipFile();
reader.cursor = temp + 4 + C_COMPRESSION_METHOD;
ptr->compressionMethod = readEndianDep2(reader);
@@ -148,7 +147,7 @@
ptr->filename = (char*)allocator.Allocate(ptr->filenameLength + 1,
"Zip file name");
- memcpy(ptr->filename, ArrayUInt8::getElements(bytes) + temp,
+ memcpy(ptr->filename, bytes->elements + temp,
ptr->filenameLength);
ptr->filename[ptr->filenameLength] = 0;
@@ -161,17 +160,16 @@
}
}
-sint32 ZipArchive::readFile(ArrayUInt8* array, const ZipFile* file) {
- llvm_gcroot(array, 0);
+sint32 ZipArchive::readFile(ClassBytes* array, const ZipFile* file) {
uint32 bytesLeft = 0;
uint32 filenameLength = 0;
uint32 extraFieldLength = 0;
uint32 temp = 0;
- Reader reader(&bytes);
+ Reader reader(bytes);
reader.cursor = file->rolh;
- if (!(memcmp(ArrayUInt8::getElements(bytes) + file->rolh, HDR_LOCAL, 4))) {
+ if (!(memcmp(bytes->elements + file->rolh, HDR_LOCAL, 4))) {
reader.cursor += 4;
temp = reader.cursor;
reader.cursor += L_FILENAME_LENGTH;
@@ -182,14 +180,14 @@
temp + extraFieldLength + filenameLength + LOCAL_FILE_HEADER_SIZE;
if (file->compressionMethod == ZIP_STORE) {
- memcpy(ArrayUInt8::getElements(array), ArrayUInt8::getElements(bytes) + reader.cursor, file->ucsize);
+ memcpy(array->elements, bytes->elements + reader.cursor, file->ucsize);
return 1;
} else if (file->compressionMethod == ZIP_DEFLATE) {
z_stream stre;
sint32 err = 0;
bytesLeft = file->csize;
- stre.next_out = (Bytef*)ArrayUInt8::getElements(array);
+ stre.next_out = (Bytef*)array->elements;
stre.avail_out = file->ucsize;
stre.zalloc = 0;
stre.zfree = 0;
@@ -202,7 +200,7 @@
while (bytesLeft) {
uint32 size = 0;
- stre.next_in = ArrayUInt8::getElements(bytes) + reader.cursor;
+ stre.next_in = bytes->elements + reader.cursor;
if (bytesLeft > 1024) size = 1024;
else size = bytesLeft;
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Zip.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Zip.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Zip.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Zip.h Tue Nov 30 06:21:29 2010
@@ -16,7 +16,7 @@
namespace j3 {
-class ArrayUInt8;
+class classBytes;
class JnjvmBootstrapLoader;
struct ZipFile : public mvm::PermanentObject {
@@ -49,7 +49,7 @@
public:
std::map<const char*, ZipFile*, ltstr> filetable;
typedef std::map<const char*, ZipFile*, ltstr>::iterator table_iterator;
- ArrayUInt8* bytes;
+ ClassBytes* bytes;
private:
@@ -70,9 +70,9 @@
}
int getOfscd() { return ofscd; }
- ZipArchive(ArrayUInt8* bytes, mvm::BumpPtrAllocator& allocator);
+ ZipArchive(ClassBytes* bytes, mvm::BumpPtrAllocator& allocator);
ZipFile* getFile(const char* filename);
- int readFile(ArrayUInt8* array, const ZipFile* file);
+ int readFile(ClassBytes* array, const ZipFile* file);
};
Modified: vmkit/branches/multi-vm/lib/Mvm/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/CommonThread/CollectionRV.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/CollectionRV.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/CollectionRV.cpp Tue Nov 30 06:21:29 2010
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include <cassert>
+#include <signal.h>
#include "MvmGC.h"
#include "mvm/VirtualMachine.h"
#include "mvm/Threads/CollectionRV.h"
@@ -80,6 +81,13 @@
unlockRV();
}
+
+#if defined(__MACH__)
+# define SIGGC SIGXCPU
+#else
+# define SIGGC SIGPWR
+#endif
+
void UncooperativeCollectionRV::synchronize() {
assert(nbJoined == 0);
mvm::Thread* self = mvm::Thread::get();
@@ -89,7 +97,8 @@
for (mvm::Thread* cur = (mvm::Thread*)self->next(); cur != self;
cur = (mvm::Thread*)cur->next()) {
- cur->killForRendezvous();
+ int res = cur->kill(SIGGC);
+ assert(!res && "Error on kill");
}
// And wait for other threads to finish.
@@ -154,7 +163,7 @@
th->inRV = false;
}
-void CooperativeCollectionRV::joinAfterUncooperative() {
+void CooperativeCollectionRV::joinAfterUncooperative(void* SP) {
mvm::Thread* th = mvm::Thread::get();
assert((th->getLastSP() == NULL) &&
"SP set after entering uncooperative code");
@@ -163,7 +172,7 @@
lockRV();
if (th->doYield) {
- th->setLastSP(FRAME_PTR());
+ th->setLastSP(SP);
if (!th->joinedRV) {
th->joinedRV = true;
another_mark();
@@ -213,10 +222,36 @@
initiator->inRV = false;
}
-void UncooperativeCollectionRV::joinAfterUncooperative() {
+void UncooperativeCollectionRV::joinAfterUncooperative(void* SP) {
UNREACHABLE();
}
void UncooperativeCollectionRV::joinBeforeUncooperative() {
UNREACHABLE();
}
+
+void CooperativeCollectionRV::addThread(Thread* th) {
+ // Nothing to do.
+}
+
+static void siggcHandler(int) {
+ mvm::Thread* th = mvm::Thread::get();
+ th->MyVM->rendezvous.join();
+}
+
+void UncooperativeCollectionRV::addThread(Thread* th) {
+ // Set the SIGGC handler for uncooperative rendezvous.
+ struct sigaction sa;
+ sigset_t mask;
+ sigaction(SIGGC, 0, &sa);
+ sigfillset(&mask);
+ sa.sa_mask = mask;
+ sa.sa_handler = siggcHandler;
+ sa.sa_flags |= SA_RESTART;
+ sigaction(SIGGC, &sa, NULL);
+
+ if (nbJoined != 0) {
+ // In uncooperative mode, we may have missed a signal.
+ join();
+ }
+}
Modified: vmkit/branches/multi-vm/lib/Mvm/CommonThread/Sigsegv.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/CommonThread/Sigsegv.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/Sigsegv.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/Sigsegv.cpp Tue Nov 30 06:21:29 2010
@@ -54,8 +54,8 @@
"the bottom of the stack is always available when entering"
"\nthe VM.\n");
} else {
- fprintf(stderr, "I received a SIGSEGV: either the VM code or an external\n"
- "native method is bogus. Aborting...\n");
+ fprintf(stderr, "Thread %p received a SIGSEGV: either the VM code or an external\n"
+ "native method is bogus. Aborting...\n", (void*)th);
}
th->printBacktrace();
abort();
Modified: vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctlock.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctlock.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctlock.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctlock.cpp Tue Nov 30 06:21:29 2010
@@ -188,176 +188,3 @@
return res;
}
-
-void ThinLock::overflowThinLock(gc* object) {
- llvm_gcroot(object, 0);
- FatLock* obj = Thread::get()->MyVM->allocateFatLock(object);
- obj->acquireAll(object, (ThinCountMask >> ThinCountShift) + 1);
- uintptr_t oldValue = 0;
- uintptr_t newValue = 0;
- uintptr_t yieldedValue = 0;
- do {
- oldValue = object->header;
- newValue = obj->getID() | (oldValue & NonLockBitsMask);
- yieldedValue = __sync_val_compare_and_swap(&(object->header), oldValue, newValue);
- } while (yieldedValue != oldValue);
-}
-
-/// initialise - Initialise the value of the lock.
-///
-void ThinLock::initialise(gc* object) {
- llvm_gcroot(object, 0);
- uintptr_t oldValue = 0;
- uintptr_t newValue = 0;
- uintptr_t yieldedValue = 0;
- do {
- oldValue = object->header;
- newValue = oldValue & NonLockBitsMask;
- yieldedValue = __sync_val_compare_and_swap(&object->header, oldValue, newValue);
- } while (yieldedValue != oldValue);
-}
-
-FatLock* ThinLock::changeToFatlock(gc* object) {
- llvm_gcroot(object, 0);
- if (!(object->header & FatMask)) {
- FatLock* obj = Thread::get()->MyVM->allocateFatLock(object);
- uint32 count = (object->header & ThinCountMask) >> ThinCountShift;
- obj->acquireAll(object, count + 1);
- uintptr_t oldValue = 0;
- uintptr_t newValue = 0;
- uintptr_t yieldedValue = 0;
- do {
- oldValue = object->header;
- newValue = obj->getID() | (oldValue & NonLockBitsMask);
- yieldedValue = __sync_val_compare_and_swap(&(object->header), oldValue, newValue);
- } while (yieldedValue != oldValue);
- return obj;
- } else {
- FatLock* res = Thread::get()->MyVM->getFatLockFromID(object->header);
- assert(res && "Lock deallocated while held.");
- return res;
- }
-}
-
-void ThinLock::acquire(gc* object) {
- llvm_gcroot(object, 0);
- uint64_t id = mvm::Thread::get()->getThreadID();
- uintptr_t oldValue = 0;
- uintptr_t newValue = 0;
- uintptr_t yieldedValue = 0;
- do {
- oldValue = object->header & NonLockBitsMask;
- newValue = oldValue | id;
- yieldedValue = __sync_val_compare_and_swap(&(object->header), oldValue, newValue);
- } while ((object->header & ~NonLockBitsMask) == 0);
-
- if (yieldedValue == oldValue) {
- assert(owner(object) && "Not owner after quitting acquire!");
- return;
- }
-
- if ((yieldedValue & Thread::IDMask) == id) {
- assert(owner(object) && "Inconsistent lock");
- if ((yieldedValue & ThinCountMask) != ThinCountMask) {
- do {
- oldValue = object->header;
- newValue = oldValue + ThinCountAdd;
- yieldedValue = __sync_val_compare_and_swap(&(object->header), oldValue, newValue);
- } while (oldValue != yieldedValue);
- } else {
- overflowThinLock(object);
- }
- assert(owner(object) && "Not owner after quitting acquire!");
- return;
- }
-
- while (true) {
- if (object->header & FatMask) {
- FatLock* obj = Thread::get()->MyVM->getFatLockFromID(object->header);
- if (obj != NULL) {
- if (obj->acquire(object)) {
- break;
- }
- }
- }
-
- while (object->header & ~NonLockBitsMask) {
- if (object->header & FatMask) {
- break;
- } else {
- mvm::Thread::yield();
- }
- }
-
- if ((object->header & ~NonLockBitsMask) == 0) {
- FatLock* obj = Thread::get()->MyVM->allocateFatLock(object);
- do {
- oldValue = object->header & NonLockBitsMask;
- newValue = oldValue | obj->getID();
- yieldedValue = __sync_val_compare_and_swap(&object->header, oldValue, newValue);
- } while ((object->header & ~NonLockBitsMask) == 0);
-
- if (oldValue != yieldedValue) {
- assert((getFatLock(object) != obj) && "Inconsistent lock");
- obj->deallocate();
- } else {
- assert((getFatLock(object) == obj) && "Inconsistent lock");
- }
- assert(!owner(object) && "Inconsistent lock");
- }
- }
-
- assert(owner(object) && "Not owner after quitting acquire!");
-}
-
-/// release - Release the lock.
-void ThinLock::release(gc* object) {
- llvm_gcroot(object, 0);
- assert(owner(object) && "Not owner when entering release!");
- uint64 id = mvm::Thread::get()->getThreadID();
- uintptr_t oldValue = 0;
- uintptr_t newValue = 0;
- uintptr_t yieldedValue = 0;
- if ((object->header & ~NonLockBitsMask) == id) {
- do {
- oldValue = object->header;
- newValue = oldValue & NonLockBitsMask;
- yieldedValue = __sync_val_compare_and_swap(&object->header, oldValue, newValue);
- } while (yieldedValue != oldValue);
- } else if (object->header & FatMask) {
- FatLock* obj = Thread::get()->MyVM->getFatLockFromID(object->header);
- assert(obj && "Lock deallocated while held.");
- obj->release(object);
- } else {
- assert(((object->header & ThinCountMask) > 0) && "Inconsistent state");
- do {
- oldValue = object->header;
- newValue = oldValue - ThinCountAdd;
- yieldedValue = __sync_val_compare_and_swap(&(object->header), oldValue, newValue);
- } while (yieldedValue != oldValue);
- }
-}
-
-/// owner - Returns true if the curren thread is the owner of this object's
-/// lock.
-bool ThinLock::owner(gc* object) {
- llvm_gcroot(object, 0);
- if (object->header & FatMask) {
- FatLock* obj = Thread::get()->MyVM->getFatLockFromID(object->header);
- if (obj != NULL) return obj->owner();
- } else {
- uint64 id = mvm::Thread::get()->getThreadID();
- if ((object->header & Thread::IDMask) == id) return true;
- }
- return false;
-}
-
-/// getFatLock - Get the fat lock is the lock is a fat lock, 0 otherwise.
-FatLock* ThinLock::getFatLock(gc* object) {
- llvm_gcroot(object, 0);
- if (object->header & FatMask) {
- return Thread::get()->MyVM->getFatLockFromID(object->header);
- } else {
- return NULL;
- }
-}
Modified: vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp Tue Nov 30 06:21:29 2010
@@ -10,13 +10,14 @@
#include "debug.h"
#include "MvmGC.h"
+#include "mvm/MethodInfo.h"
#include "mvm/VirtualMachine.h"
#include "mvm/Threads/Cond.h"
#include "mvm/Threads/Locks.h"
#include "mvm/Threads/Thread.h"
#include <cassert>
-#include <signal.h>
+#include <csetjmp>
#include <cstdio>
#include <ctime>
#include <dlfcn.h>
@@ -24,6 +25,7 @@
#include <pthread.h>
#include <sys/mman.h>
#include <sched.h>
+#include <signal.h>
#include <unistd.h>
using namespace mvm;
@@ -54,8 +56,8 @@
MyVM->rendezvous.joinBeforeUncooperative();
}
-void Thread::joinRVAfterLeave() {
- MyVM->rendezvous.joinAfterUncooperative();
+void Thread::joinRVAfterLeave(void* savedSP) {
+ MyVM->rendezvous.joinAfterUncooperative(savedSP);
}
void Thread::startKnownFrame(KnownFrame& F) {
@@ -65,10 +67,29 @@
cur = (void**)cur[0];
F.previousFrame = lastKnownFrame;
F.currentFP = cur;
+ // This is used as a marker.
+ F.currentIP = NULL;
lastKnownFrame = &F;
}
void Thread::endKnownFrame() {
+ assert(lastKnownFrame->currentIP == NULL);
+ lastKnownFrame = lastKnownFrame->previousFrame;
+}
+
+void Thread::startUnknownFrame(KnownFrame& F) {
+ // Get the caller of this function
+ void** cur = (void**)FRAME_PTR();
+ // Get the caller of the caller.
+ cur = (void**)cur[0];
+ F.previousFrame = lastKnownFrame;
+ F.currentFP = cur;
+ F.currentIP = FRAME_IP(cur);
+ lastKnownFrame = &F;
+}
+
+void Thread::endUnknownFrame() {
+ assert(lastKnownFrame->currentIP != NULL);
lastKnownFrame = lastKnownFrame->previousFrame;
}
@@ -153,22 +174,127 @@
}
void StackWalker::operator++() {
- if (addr < thread->baseSP && addr < addr[0]) {
- if (frame && addr == frame->currentFP) {
+ if (addr != thread->baseSP) {
+ assert((addr < thread->baseSP) && "Corrupted stack");
+ assert((addr < addr[0]) && "Corrupted stack");
+ if ((frame != NULL) && (addr == frame->currentFP)) {
+ assert(frame->currentIP == NULL);
+ frame = frame->previousFrame;
+ assert(frame != NULL);
+ assert(frame->currentIP != NULL);
+ addr = (void**)frame->currentFP;
frame = frame->previousFrame;
- if (frame) {
- addr = (void**)frame->currentFP;
- frame = frame->previousFrame;
- } else {
- addr = (void**)addr[0];
- }
} else {
addr = (void**)addr[0];
}
+ }
+}
+
+StackWalker::StackWalker(mvm::Thread* th) {
+ thread = th;
+ frame = th->lastKnownFrame;
+ if (mvm::Thread::get() == th) {
+ addr = (void**)FRAME_PTR();
+ addr = (void**)addr[0];
+ } else {
+ addr = (void**)th->waitOnSP();
+ if (frame) {
+ assert(frame->currentFP >= addr);
+ }
+ if (frame && (addr == frame->currentFP)) {
+ frame = frame->previousFrame;
+ assert((frame == NULL) || (frame->currentIP == NULL));
+ }
+ }
+ assert(addr && "No address to start with");
+}
+
+
+#ifdef WITH_LLVM_GCC
+void Thread::scanStack(uintptr_t closure) {
+ StackWalker Walker(this);
+ while (MethodInfo* MI = Walker.get()) {
+ MI->scan(closure, Walker.ip, Walker.addr);
+ ++Walker;
+ }
+}
+
+#else
+
+void Thread::scanStack(uintptr_t closure) {
+ register unsigned int **max = (unsigned int**)(void*)this->baseSP;
+ if (mvm::Thread::get() != this) {
+ register unsigned int **cur = (unsigned int**)this->waitOnSP();
+ for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
} else {
- addr = (void**)thread->baseSP;
+ jmp_buf buf;
+ setjmp(buf);
+ register unsigned int **cur = (unsigned int**)&buf;
+ for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
}
}
+#endif
+
+void Thread::enterUncooperativeCode(unsigned level) {
+ if (isMvmThread()) {
+ if (!inRV) {
+ assert(!lastSP && "SP already set when entering uncooperative code");
+ // Get the caller.
+ void* temp = FRAME_PTR();
+ // Make sure to at least get the caller of the caller.
+ ++level;
+ while (level--) temp = ((void**)temp)[0];
+ // The cas is not necessary, but it does a memory barrier.
+ __sync_bool_compare_and_swap(&lastSP, 0, temp);
+ if (doYield) joinRVBeforeEnter();
+ assert(lastSP && "No last SP when entering uncooperative code");
+ }
+ }
+}
+
+void Thread::enterUncooperativeCode(void* SP) {
+ if (isMvmThread()) {
+ if (!inRV) {
+ assert(!lastSP && "SP already set when entering uncooperative code");
+ // The cas is not necessary, but it does a memory barrier.
+ __sync_bool_compare_and_swap(&lastSP, 0, SP);
+ if (doYield) joinRVBeforeEnter();
+ assert(lastSP && "No last SP when entering uncooperative code");
+ }
+ }
+}
+
+void Thread::leaveUncooperativeCode() {
+ if (isMvmThread()) {
+ if (!inRV) {
+ assert(lastSP && "No last SP when leaving uncooperative code");
+ void* 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.
+ if (doYield) joinRVAfterLeave(savedSP);
+ assert(!lastSP && "SP has a value after leaving uncooperative code");
+ }
+ }
+}
+
+void* Thread::waitOnSP() {
+ // First see if we can get lastSP directly.
+ void* sp = lastSP;
+ if (sp) return sp;
+
+ // Then loop a fixed number of iterations to get lastSP.
+ for (uint32 count = 0; count < 1000; ++count) {
+ sp = lastSP;
+ if (sp) return sp;
+ }
+
+ // Finally, yield until lastSP is not set.
+ while ((sp = lastSP) == NULL) mvm::Thread::yield();
+
+ assert(sp != NULL && "Still no sp");
+ return sp;
+}
uintptr_t Thread::baseAddr = 0;
@@ -267,24 +393,12 @@
extern void sigsegvHandler(int, siginfo_t*, void*);
-
-#if defined(__MACH__)
-# define SIGGC SIGXCPU
-#else
-# define SIGGC SIGPWR
-#endif
-
-static void siggcHandler(int) {
- mvm::Thread* th = mvm::Thread::get();
- th->MyVM->rendezvous.join();
-}
-
/// internalThreadStart - The initial function called by a thread. Sets some
/// thread specific data, registers the thread to the GC and calls the
/// given routine of th.
///
void Thread::internalThreadStart(mvm::Thread* th) {
- th->baseSP = (void*)&th;
+ th->baseSP = FRAME_PTR();
// Set the SIGSEGV handler to diagnose errors.
struct sigaction sa;
@@ -295,22 +409,14 @@
sa.sa_sigaction = sigsegvHandler;
sigaction(SIGSEGV, &sa, NULL);
- // Set the SIGGC handler for uncooperative rendezvous.
- sigaction(SIGGC, 0, &sa);
- sigfillset(&mask);
- sa.sa_mask = mask;
- sa.sa_handler = siggcHandler;
- sa.sa_flags |= SA_RESTART;
- sigaction(SIGGC, &sa, NULL);
assert(th->MyVM && "VM not set in a thread");
#ifdef ISOLATE
th->IsolateID = th->MyVM->IsolateID;
#endif
- th->MyVM->addThread(th);
+ th->MyVM->rendezvous.addThread(th);
th->routine(th);
th->MyVM->removeThread(th);
- delete th;
}
@@ -323,6 +429,9 @@
pthread_attr_init(&attributs);
pthread_attr_setstack(&attributs, this, STACK_SIZE);
routine = fct;
+ // Make sure to add it in the list of threads before leaving this function:
+ // the garbage collector wants to trace this thread.
+ MyVM->addThread(this);
int res = pthread_create((pthread_t*)(void*)(&internalThreadID), &attributs,
(void* (*)(void *))internalThreadStart, this);
pthread_detach((pthread_t)internalThreadID);
@@ -346,18 +455,23 @@
res = (void*)TheStackManager.allocate();
}
}
+ // Make sure the thread information is cleared.
+ memset(res, 0, sz);
return res;
}
/// releaseThread - Remove the stack of the thread from the list of stacks
/// in use.
-void Thread::releaseThread(void* th) {
+void Thread::releaseThread(mvm::Thread* th) {
+ // It seems like the pthread implementation in Linux is clearing with NULL
+ // the stack of the thread. So we have to get the thread id before
+ // calling pthread_join.
+ void* thread_id = th->internalThreadID;
+ if (thread_id != NULL) {
+ // Wait for the thread to die.
+ pthread_join((pthread_t)thread_id, NULL);
+ }
uintptr_t index = ((uintptr_t)th & Thread::IDMask);
index = (index & ~TheStackManager.baseAddr) >> 20;
TheStackManager.used[index] = 0;
}
-
-void Thread::killForRendezvous() {
- int res = kill(SIGGC);
- assert(!res && "Error on kill");
-}
Modified: vmkit/branches/multi-vm/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Compiler/JIT.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Compiler/JIT.cpp Tue Nov 30 06:21:29 2010
@@ -22,6 +22,7 @@
#include <llvm/Analysis/Verifier.h>
#include <llvm/Assembly/Parser.h>
#include <llvm/CodeGen/GCStrategy.h>
+#include <llvm/CodeGen/JITCodeEmitter.h>
#include <llvm/Config/config.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include "llvm/ExecutionEngine/JITEventListener.h"
@@ -35,6 +36,7 @@
#include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/Target/TargetSelect.h>
+#include <../lib/ExecutionEngine/JIT/JIT.h>
#include "mvm/JIT.h"
#include "mvm/Threads/Locks.h"
@@ -69,12 +71,6 @@
namespace llvm_runtime {
#include "LLVMRuntime.inc"
}
-
-#ifdef WITH_MMTK
- namespace mmtk_runtime {
- #include "MMTkInline.inc"
- }
-#endif
void linkVmkitGC();
}
@@ -83,7 +79,7 @@
}
void MvmJITMethodInfo::print(void* ip, void* addr) {
- fprintf(stderr, "; %p in %s LLVM method\n", ip,
+ fprintf(stderr, "; %p (%p) in %s LLVM method\n", ip, addr,
((llvm::Function*)MetaInfo)->getName().data());
}
@@ -93,24 +89,33 @@
void *Code, size_t Size,
const EmittedFunctionDetails &Details) {
assert(F.getParent() == MvmModule::globalModule);
- llvm::GCFunctionInfo* GFI = 0;
+ assert(F.hasGC());
// We know the last GC info is for this method.
- if (F.hasGC()) {
- GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end();
- I--;
- DEBUG(errs() << (*I)->getFunction().getName() << '\n');
- DEBUG(errs() << F.getName() << '\n');
- assert(&(*I)->getFunction() == &F &&
+ GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end();
+ I--;
+ DEBUG(errs() << (*I)->getFunction().getName() << '\n');
+ DEBUG(errs() << F.getName() << '\n');
+ assert(&(*I)->getFunction() == &F &&
"GC Info and method do not correspond");
- GFI = *I;
- }
- MethodInfo* MI =
- new(*MvmModule::Allocator, "MvmJITMethodInfo") MvmJITMethodInfo(GFI, &F);
- VirtualMachine::SharedRuntimeFunctions.addMethodInfo(MI, Code,
- (void*)((uintptr_t)Code + Size));
+ llvm::GCFunctionInfo* GFI = *I;
+ JITMethodInfo* MI = new(*MvmModule::Allocator, "MvmJITMethodInfo")
+ MvmJITMethodInfo(GFI, &F, MvmModule::executionEngine);
+ MI->addToVM(mvm::Thread::get()->MyVM, (JIT*)MvmModule::executionEngine);
}
};
+void JITMethodInfo::addToVM(VirtualMachine* VM, JIT* jit) {
+ JITCodeEmitter* JCE = jit->getCodeEmitter();
+ assert(GCInfo != NULL);
+ for (GCFunctionInfo::iterator I = GCInfo->begin(), E = GCInfo->end();
+ I != E;
+ I++) {
+ uintptr_t address = JCE->getLabelAddress(I->Label);
+ assert(address != 0);
+ VM->FunctionsCache.addMethodInfo(this, (void*)address);
+ }
+}
+
static MvmJITListener JITListener;
void MvmModule::loadBytecodeFile(const std::string& str) {
@@ -182,26 +187,22 @@
module->setDataLayout(MvmModule::globalModule->getDataLayout());
module->setTargetTriple(MvmModule::globalModule->getTargetTriple());
LLVMContext& Context = module->getContext();
-
-#ifdef WITH_MMTK
- static const char* MMTkSymbol =
- "JnJVM_org_j3_bindings_Bindings_gcmalloc__"
- "ILorg_vmmagic_unboxed_ObjectReference_2";
- if (dlsym(SELF_HANDLE, MMTkSymbol)) {
- // If we have found MMTk, read the gcmalloc function.
- mvm::mmtk_runtime::makeLLVMFunction(module);
- }
-#endif
+
+ typedef void (*init_inline_t)(llvm::Module* module);
+ static const char* MMTkSymbol = "MMTk_InlineMethods";
+ init_inline_t init_inline =
+ (init_inline_t)(uintptr_t)dlsym(SELF_HANDLE, MMTkSymbol);
+ if (init_inline != NULL) init_inline(module);
+
mvm::llvm_runtime::makeLLVMModuleContents(module);
-
-
+
// Type declaration
ptrType = PointerType::getUnqual(Type::getInt8Ty(Context));
ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context));
ptrPtrType = PointerType::getUnqual(ptrType);
pointerSizeType = module->getPointerSize() == Module::Pointer32 ?
Type::getInt32Ty(Context) : Type::getInt64Ty(Context);
-
+
// Constant declaration
constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1);
constantLongZero = ConstantInt::get(Type::getInt64Ty(Context), 0);
@@ -253,9 +254,7 @@
constantPtrLogSize =
ConstantInt::get(Type::getInt32Ty(Context), sizeof(void*) == 8 ? 3 : 2);
arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::getInt8Ty(Context), 0));
-
-
-
+
printFloatLLVM = module->getFunction("printFloat");
printDoubleLLVM = module->getFunction("printDouble");
printLongLLVM = module->getFunction("printLong");
@@ -317,6 +316,7 @@
unconditionalSafePoint = module->getFunction("unconditionalSafePoint");
conditionalSafePoint = module->getFunction("conditionalSafePoint");
AllocateFunction = module->getFunction("gcmalloc");
+ AllocateFunction->setGC("vmkit");
assert(AllocateFunction && "No allocate function");
AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved");
assert(AllocateUnresolvedFunction && "No allocateUnresolved function");
Modified: vmkit/branches/multi-vm/lib/Mvm/Compiler/LoopSafePoints.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Compiler/LoopSafePoints.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Compiler/LoopSafePoints.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Compiler/LoopSafePoints.cpp Tue Nov 30 06:21:29 2010
@@ -60,7 +60,6 @@
BranchInst::Create(SU, yield);
L->addBasicBlockToLoop(yield, LI->getBase());
-
}
Modified: vmkit/branches/multi-vm/lib/Mvm/Compiler/VmkitGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Compiler/VmkitGC.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Compiler/VmkitGC.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Compiler/VmkitGC.cpp Tue Nov 30 06:21:29 2010
@@ -32,5 +32,4 @@
VmkitGC::VmkitGC() {
NeededSafePoints = 1 << GC::PostCall;
- mvm::MvmModule::TheGCStrategy = this;
}
Modified: vmkit/branches/multi-vm/lib/Mvm/Compiler/mvm-runtime.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Compiler/mvm-runtime.ll?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Compiler/mvm-runtime.ll (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Compiler/mvm-runtime.ll Tue Nov 30 06:21:29 2010
@@ -20,7 +20,7 @@
;;; field 10: void* lastKnownFrame
;;; field 11: void* lastExceptionBuffer
;;; field 12: void* vmData
-%Thread = type { %CircularBase, i32, i8*, i8*, i8, i8, i8, i8*, i8*, i8*, i8*, i8*, i8* }
+%Thread = type { %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8*, i8* }
%VMThreadData = type { %VT*, %Thread* }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Modified: vmkit/branches/multi-vm/lib/Mvm/GCMmap2/ObjectHeader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/GCMmap2/ObjectHeader.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/GCMmap2/ObjectHeader.h (original)
+++ vmkit/branches/multi-vm/lib/Mvm/GCMmap2/ObjectHeader.h Tue Nov 30 06:21:29 2010
@@ -13,24 +13,8 @@
#include <stdint.h>
namespace mvm {
-#if (__WORDSIZE == 64)
- static const uint64_t FatMask = 0x8000000000000000;
-#else
- static const uint64_t FatMask = 0x80000000;
-#endif
-
- static const uint64_t ThinCountMask = 0xFF000;
- static const uint64_t ThinCountShift = 12;
- static const uint64_t ThinCountAdd = 0x1000;
-
- static const uint64_t NonLockBitsMask = 0xFFF;
- static const uint64_t HashMask = 0xFFC;
- static const uint64_t GCBitMask = 0x3;
-
static const uint32_t GCBits = 2;
- static const uint32_t HashBits = 10;
- static const uint32_t NonLockBits = 12;
-
+ static const uint64_t GCBitMask = 0x3;
static const bool MovesObject = false;
}
Modified: vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp Tue Nov 30 06:21:29 2010
@@ -33,18 +33,13 @@
void Collector::do_collect() {
GCChunkNode *cur;
-#ifdef SERVICE
- mvm::Thread::get()->MyVM->_since_last_collection = _collect_freq_auto;
-#else
_since_last_collection = _collect_freq_auto;
-#endif
current_mark++;
unused_nodes->attrape(used_nodes);
mvm::Thread* th = mvm::Thread::get();
- mvm::StackScanner* sc = th->MyVM->getScanner();
th->MyVM->rendezvous.startRV();
th->MyVM->startCollection();
@@ -57,7 +52,7 @@
// (2) Trace the threads.
do {
- sc->scanStack(tcur, 0);
+ tcur->scanStack(0);
tcur->tracer(0);
tcur = (mvm::Thread*)tcur->next();
} while (tcur != th);
@@ -94,10 +89,8 @@
status = stat_alloc;
// Wake up all threads.
- th->MyVM->endCollection();
th->MyVM->rendezvous.finishRV();
- th->MyVM->wakeUpFinalizers();
- th->MyVM->wakeUpEnqueue();
+ th->MyVM->endCollection();
// Kill unreachable objects.
GCChunkNode *next = 0;
Modified: vmkit/branches/multi-vm/lib/Mvm/MMTk/MutatorThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/MMTk/MutatorThread.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/MMTk/MutatorThread.h (original)
+++ vmkit/branches/multi-vm/lib/Mvm/MMTk/MutatorThread.h Tue Nov 30 06:21:29 2010
@@ -21,7 +21,7 @@
MutatorThread() : mvm::Thread() {
MutatorContext = 0;
}
- mvm::BumpPtrAllocator Allocator;
+ mvm::ThreadAllocator Allocator;
uintptr_t MutatorContext;
/// realRoutine - The function to invoke when the thread starts.
Modified: vmkit/branches/multi-vm/lib/Mvm/Runtime/MethodInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Runtime/MethodInfo.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Runtime/MethodInfo.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Runtime/MethodInfo.cpp Tue Nov 30 06:21:29 2010
@@ -24,19 +24,11 @@
using namespace mvm;
void CamlMethodInfo::scan(uintptr_t closure, void* ip, void* addr) {
- if (!CF && InstructionPointer) {
- MethodInfo* MI = VirtualMachine::SharedStaticFunctions.IPToMethodInfo(ip);
- if (MI != &DefaultMethodInfo::DM) {
- CF = ((CamlMethodInfo*)MI)->CF;
- }
- }
-
- if (CF) {
- //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*);
- uintptr_t spaddr = ((uintptr_t*)addr)[0];
- for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) {
- Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure);
- }
+ assert(CF != NULL);
+ //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*);
+ uintptr_t spaddr = ((uintptr_t*)addr)[0];
+ for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) {
+ Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure);
}
}
@@ -59,52 +51,6 @@
void DefaultMethodInfo::scan(uintptr_t closure, void* ip, void* addr) {
}
-
-MethodInfo* StartFunctionMap::IPToMethodInfo(void* ip) {
- FunctionMapLock.acquire();
- std::map<void*, MethodInfo*>::iterator E = Functions.end();
- std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);
- MethodInfo* MI = 0;
- if (I == E) {
- Dl_info info;
- int res = dladdr(ip, &info);
- if (res != 0) {
- I = Functions.find(info.dli_saddr);
- if (I == E) {
- // The method is static, and we have no information for it.
- // Just return the Default MethodInfo object.
- MI = &DefaultMethodInfo::DM;
- } else {
- MI = I->second;
- }
- } else {
- // The method is jitted, and no-one has intercepted its compilation.
- // Just return the Default MethodInfo object.
- MI = &DefaultMethodInfo::DM;
- }
- // Add it to the map, so that we don't need to call dladdr again.
- Functions.insert(std::make_pair(ip, MI));
- } else {
- MI = I->second;
- }
- FunctionMapLock.release();
- return MI;
-}
-
-MethodInfo* VirtualMachine::IPToMethodInfo(void* ip) {
- MethodInfo* MI = RuntimeFunctions.IPToMethodInfo(ip);
- if (MI) return MI;
-
- MI = SharedRuntimeFunctions.IPToMethodInfo(ip);
- if (MI) return MI;
-
- MI = StaticFunctions.IPToMethodInfo(ip);
- if (MI != &DefaultMethodInfo::DM) return MI;
-
- MI = SharedStaticFunctions.IPToMethodInfo(ip);
- return MI;
-}
-
struct CamlFrames {
uint16_t NumDescriptors;
CamlFrame frames[1];
@@ -114,14 +60,11 @@
CamlFrames* frames ;
uint32 currentDescriptor;
CamlFrame* currentFrame;
- Dl_info info;
CamlFrameDecoder(CamlFrames* frames) {
this->frames = frames;
currentDescriptor = 0;
currentFrame = &(frames->frames[0]);
- int res = dladdr(currentFrame->ReturnAddress, &info);
- assert(res != 0 && "No frame");
}
bool hasNext() {
@@ -135,55 +78,67 @@
(currentFrame->NumLiveOffsets % 2) * sizeof(uint16_t) +
currentFrame->NumLiveOffsets * sizeof(uint16_t) +
sizeof(void*) + sizeof(uint16_t) + sizeof(uint16_t));
- int res = dladdr(currentFrame->ReturnAddress, &info);
- assert(res != 0 && "No frame");
}
- CamlFrame* next(void** funcAddress, const char** funcName) {
+ CamlFrame* next() {
assert(hasNext());
CamlFrame* result = currentFrame;
- *funcAddress = info.dli_saddr;
- *funcName = info.dli_sname;
-
- // Skip the remaining ones.
- do {
- advance();
- } while (hasNext() && (info.dli_saddr == *funcAddress));
-
- // Skip the entries that start at another method.
- while (hasNext() && (info.dli_saddr == currentFrame->ReturnAddress)) {
- advance();
- }
-
- while (hasNext() && (info.dli_saddr == NULL)) {
- advance();
- }
+ advance();
return result;
}
};
-void SharedStartFunctionMap::initialize() {
+static BumpPtrAllocator* StaticAllocator = NULL;
+
+FunctionMap::FunctionMap() {
CamlFrames* frames =
(CamlFrames*)dlsym(SELF_HANDLE, "camlVmkitoptimized__frametable");
+ if (frames == NULL) return;
+
StaticAllocator = new BumpPtrAllocator();
- const char* name = NULL;
- void* address = NULL;
+ CamlFrameDecoder decoder(frames);
+ Dl_info info;
+ while (decoder.hasNext()) {
+ CamlFrame* frame = decoder.next();
+ int res = dladdr(frame->ReturnAddress, &info);
+ assert(res != 0 && "No frame");
+ StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo")
+ StaticCamlMethodInfo(frame, info.dli_sname);
+ addMethodInfo(MI, frame->ReturnAddress);
+ }
+}
- if (frames != NULL) {
- CamlFrameDecoder decoder(frames);
- while (decoder.hasNext()) {
- CamlFrame* frame = decoder.next(&address, &name);
- StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo")
- StaticCamlMethodInfo(frame, address, name);
- addMethodInfo(MI, address);
- }
+MethodInfo* FunctionMap::IPToMethodInfo(void* ip) {
+ FunctionMapLock.acquire();
+ std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);
+ MethodInfo* res = NULL;
+ if (I != Functions.end()) {
+ res = I->second;
+ } else {
+ res = &DefaultMethodInfo::DM;
}
+ FunctionMapLock.release();
+ return res;
}
-CamlMethodInfo::CamlMethodInfo(CamlFrame* C, void* ip) {
- InstructionPointer = ip;
- CF = C;
+void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) {
+ FunctionMapLock.acquire();
+ Functions.insert(std::make_pair(ip, meth));
+ FunctionMapLock.release();
}
-StartEndFunctionMap VirtualMachine::SharedRuntimeFunctions;
-SharedStartFunctionMap VirtualMachine::SharedStaticFunctions;
+
+void FunctionMap::removeMethodInfos(void* owner) {
+ FunctionMapLock.acquire();
+ std::map<void*, mvm::MethodInfo*>::iterator temp;
+ for (std::map<void*, mvm::MethodInfo*>::iterator i = Functions.begin(),
+ e = Functions.end(); i != e;) {
+ mvm::MethodInfo* MI = i->second;
+ temp = i;
+ i++;
+ if (MI->Owner == owner) {
+ Functions.erase(temp);
+ }
+ }
+ FunctionMapLock.release();
+}
Modified: vmkit/branches/multi-vm/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Runtime/Object.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Runtime/Object.cpp Tue Nov 30 06:21:29 2010
@@ -9,14 +9,10 @@
#include <cstdio>
#include <cstdlib>
-#include <csetjmp>
#include "MvmGC.h"
-#include "mvm/Allocator.h"
#include "mvm/Object.h"
#include "mvm/PrintBuffer.h"
-#include "mvm/VirtualMachine.h"
-#include "mvm/Threads/Thread.h"
using namespace mvm;
@@ -58,222 +54,3 @@
buf->writePtr((void*)o);
buf->write(">");
}
-
-typedef void (*destructor_t)(void*);
-
-void invokeFinalize(mvm::Thread* th, gc* res) {
- llvm_gcroot(res, 0);
- TRY {
- th->MyVM->invokeFinalizer(res);
- } IGNORE;
- th->clearException();
-}
-
-void invokeEnqueue(mvm::Thread* th, gc* res) {
- llvm_gcroot(res, 0);
- TRY {
- th->MyVM->enqueueReference(res);
- } IGNORE;
- th->clearException();
-}
-
-void VirtualMachine::finalizerStart(mvm::Thread* th) {
- VirtualMachine* vm = th->MyVM;
- gc* res = 0;
- llvm_gcroot(res, 0);
-
- while (true) {
- vm->FinalizationLock.lock();
- while (vm->CurrentFinalizedIndex == 0) {
- vm->FinalizationCond.wait(&vm->FinalizationLock);
- }
- vm->FinalizationLock.unlock();
-
- while (true) {
- vm->FinalizationQueueLock.acquire();
- if (vm->CurrentFinalizedIndex != 0) {
- res = vm->ToBeFinalized[vm->CurrentFinalizedIndex - 1];
- --vm->CurrentFinalizedIndex;
- }
- vm->FinalizationQueueLock.release();
- if (!res) break;
-
- VirtualTable* VT = res->getVirtualTable();
- if (VT->operatorDelete) {
- destructor_t dest = (destructor_t)VT->destructor;
- dest(res);
- } else {
- invokeFinalize(th, res);
- }
- res = 0;
- }
- }
-}
-
-void VirtualMachine::enqueueStart(mvm::Thread* th) {
- VirtualMachine* vm = th->MyVM;
- gc* res = 0;
- llvm_gcroot(res, 0);
-
- while (true) {
- vm->EnqueueLock.lock();
- while (vm->ToEnqueueIndex == 0) {
- vm->EnqueueCond.wait(&vm->EnqueueLock);
- }
- vm->EnqueueLock.unlock();
-
- while (true) {
- vm->ToEnqueueLock.acquire();
- if (vm->ToEnqueueIndex != 0) {
- res = vm->ToEnqueue[vm->ToEnqueueIndex - 1];
- --vm->ToEnqueueIndex;
- }
- vm->ToEnqueueLock.release();
- if (!res) break;
-
- invokeEnqueue(th, res);
- res = 0;
- }
- }
-}
-
-void VirtualMachine::growFinalizationQueue() {
- if (CurrentIndex >= QueueLength) {
- uint32 newLength = QueueLength * GROW_FACTOR;
- gc** newQueue = new gc*[newLength];
- if (!newQueue) {
- fprintf(stderr, "I don't know how to handle finalizer overflows yet!\n");
- abort();
- }
- for (uint32 i = 0; i < QueueLength; ++i) newQueue[i] = FinalizationQueue[i];
- delete[] FinalizationQueue;
- FinalizationQueue = newQueue;
- QueueLength = newLength;
- }
-}
-
-void VirtualMachine::growToBeFinalizedQueue() {
- if (CurrentFinalizedIndex >= ToBeFinalizedLength) {
- uint32 newLength = ToBeFinalizedLength * GROW_FACTOR;
- gc** newQueue = new gc*[newLength];
- if (!newQueue) {
- fprintf(stderr, "I don't know how to handle finalizer overflows yet!\n");
- abort();
- }
- for (uint32 i = 0; i < ToBeFinalizedLength; ++i) newQueue[i] = ToBeFinalized[i];
- delete[] ToBeFinalized;
- ToBeFinalized = newQueue;
- ToBeFinalizedLength = newLength;
- }
-}
-
-
-void VirtualMachine::addFinalizationCandidate(gc* obj) {
- FinalizationQueueLock.acquire();
-
- if (CurrentIndex >= QueueLength) {
- growFinalizationQueue();
- }
-
- FinalizationQueue[CurrentIndex++] = obj;
- FinalizationQueueLock.release();
-}
-
-
-void VirtualMachine::scanFinalizationQueue(uintptr_t closure) {
- uint32 NewIndex = 0;
- for (uint32 i = 0; i < CurrentIndex; ++i) {
- gc* obj = FinalizationQueue[i];
-
- if (!Collector::isLive(obj, closure)) {
- obj = Collector::retainForFinalize(FinalizationQueue[i], closure);
-
- if (CurrentFinalizedIndex >= ToBeFinalizedLength)
- growToBeFinalizedQueue();
-
- /* Add to object table */
- ToBeFinalized[CurrentFinalizedIndex++] = obj;
- } else {
- FinalizationQueue[NewIndex++] =
- Collector::getForwardedFinalizable(obj, closure);
- }
- }
- CurrentIndex = NewIndex;
-}
-
-void VirtualMachine::tracer(uintptr_t closure) {
- for (uint32 i = 0; i < CurrentFinalizedIndex; ++i) {
- Collector::markAndTraceRoot(ToBeFinalized + i, closure);
- }
-}
-
-gc* ReferenceQueue::processReference(
- gc* reference, VirtualMachine* vm, uintptr_t closure) {
- if (!Collector::isLive(reference, closure)) {
- vm->clearReferent(reference);
- return NULL;
- }
-
- gc* referent = *(vm->getReferentPtr(reference));
-
- if (!referent) {
- return NULL;
- }
-
- if (semantics == SOFT) {
- // TODO: are we are out of memory? Consider that we always are for now.
- if (false) {
- Collector::retainReferent(referent, closure);
- }
- } else if (semantics == PHANTOM) {
- // Nothing to do.
- }
-
- gc* newReference =
- mvm::Collector::getForwardedReference(reference, closure);
- if (Collector::isLive(referent, closure)) {
- gc* newReferent = mvm::Collector::getForwardedReferent(referent, closure);
- vm->setReferent(newReference, newReferent);
- return newReference;
- } else {
- vm->clearReferent(newReference);
- vm->addToEnqueue(newReference);
- return NULL;
- }
-}
-
-
-void ReferenceQueue::scan(VirtualMachine* vm, uintptr_t closure) {
- uint32 NewIndex = 0;
-
- for (uint32 i = 0; i < CurrentIndex; ++i) {
- gc* obj = References[i];
- gc* res = processReference(obj, vm, closure);
- if (res) References[NewIndex++] = res;
- }
-
- CurrentIndex = NewIndex;
-}
-
-void PreciseStackScanner::scanStack(mvm::Thread* th, uintptr_t closure) {
- StackWalker Walker(th);
-
- while (MethodInfo* MI = Walker.get()) {
- MI->scan(closure, Walker.ip, Walker.addr);
- ++Walker;
- }
-}
-
-
-void UnpreciseStackScanner::scanStack(mvm::Thread* th, uintptr_t closure) {
- register unsigned int **max = (unsigned int**)(void*)th->baseSP;
- if (mvm::Thread::get() != th) {
- register unsigned int **cur = (unsigned int**)th->waitOnSP();
- for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
- } else {
- jmp_buf buf;
- setjmp(buf);
- register unsigned int **cur = (unsigned int**)&buf;
- for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
- }
-}
Modified: vmkit/branches/multi-vm/mmtk/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/Makefile?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/Makefile (original)
+++ vmkit/branches/multi-vm/mmtk/Makefile Tue Nov 30 06:21:29 2010
@@ -8,7 +8,7 @@
##===----------------------------------------------------------------------===##
LEVEL = ..
-DIRS = magic mmtk-j3 mmtk-alloc java
+DIRS = magic mmtk-j3 mmtk-alloc java inline
EXTRA_DIST = config/marksweep
include $(LEVEL)/Makefile.config
Modified: vmkit/branches/multi-vm/mmtk/config/copyms/ObjectHeader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/config/copyms/ObjectHeader.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/config/copyms/ObjectHeader.h (original)
+++ vmkit/branches/multi-vm/mmtk/config/copyms/ObjectHeader.h Tue Nov 30 06:21:29 2010
@@ -13,24 +13,7 @@
#include <stdint.h>
namespace mvm {
-#if (__WORDSIZE == 64)
- static const uint64_t FatMask = 0x8000000000000000;
-#else
- static const uint64_t FatMask = 0x80000000;
-#endif
-
- static const uint64_t ThinCountMask = 0xFF000;
- static const uint64_t ThinCountShift = 12;
- static const uint64_t ThinCountAdd = 0x1000;
-
- static const uint64_t NonLockBitsMask = 0xFFF;
- static const uint64_t HashMask = 0xFF0;
- static const uint64_t GCBitMask = 0xF;
-
- static const uint32_t NonLockBits = 12;
- static const uint32_t HashBits = 8;
- static const uint32_t GCBits = 4;
-
+ static const uint32_t GCBits = 8;
static const bool MovesObject = true;
}
Removed: vmkit/branches/multi-vm/mmtk/config/copyms/Selected.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/config/copyms/Selected.java?rev=120423&view=auto
==============================================================================
--- vmkit/branches/multi-vm/mmtk/config/copyms/Selected.java (original)
+++ vmkit/branches/multi-vm/mmtk/config/copyms/Selected.java (removed)
@@ -1,68 +0,0 @@
-/*
- * This file is part of the Jikes RVM project (http://jikesrvm.org).
- *
- * This file is licensed to You under the Eclipse Public License (EPL);
- * You may not use this file except in compliance with the License. You
- * may obtain a copy of the License at
- *
- * http://www.opensource.org/licenses/eclipse-1.0.php
- *
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- */
-package org.j3.config;
-
-import org.mmtk.utility.Log;
-
-import org.vmmagic.pragma.*;
-
-public class Selected {
- public static final String name = "org.mmtk.plan.copyms.CopyMS";
- @Uninterruptible
- public static final class Plan extends org.mmtk.plan.copyms.CopyMS
- {
- private static final Plan plan = new Plan();
-
- @Inline
- public static Plan get() { return plan; }
- }
-
- @Uninterruptible
- public static final class Constraints extends org.mmtk.plan.copyms.CopyMSConstraints
- {
- private static final Constraints constraints = new Constraints();
-
- @Inline
- public static Constraints get() { return constraints; }
- }
-
- @Uninterruptible
- public static class Collector extends org.mmtk.plan.copyms.CopyMSCollector
- {
- private static final Collector bootstrapCollector = new Collector();
-
- public static void staticCollect() {
- bootstrapCollector.collect();
- }
-
- public Collector() {}
- @Inline
- public static Collector get() {
- return bootstrapCollector;
- }
- }
-
- @Uninterruptible
- public static class Mutator extends org.mmtk.plan.copyms.CopyMSMutator
- {
- // Unused mutator used by the AOT compiler to know what instances
- // will be alive during MMTk execution. This allows to inline
- // virtual calls of singleton objects.
- private static final Mutator unusedMutator = new Mutator();
-
- public Mutator() {}
-
- @Inline
- public static native Mutator get();
- }
-}
Modified: vmkit/branches/multi-vm/mmtk/config/marksweep/ObjectHeader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/config/marksweep/ObjectHeader.h?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/config/marksweep/ObjectHeader.h (original)
+++ vmkit/branches/multi-vm/mmtk/config/marksweep/ObjectHeader.h Tue Nov 30 06:21:29 2010
@@ -13,24 +13,7 @@
#include <stdint.h>
namespace mvm {
-#if (__WORDSIZE == 64)
- static const uint64_t FatMask = 0x8000000000000000;
-#else
- static const uint64_t FatMask = 0x80000000;
-#endif
-
- static const uint64_t ThinCountMask = 0xFF000;
- static const uint64_t ThinCountShift = 12;
- static const uint64_t ThinCountAdd = 0x1000;
-
- static const uint64_t NonLockBitsMask = 0xFFF;
- static const uint64_t HashMask = 0xFF0;
- static const uint64_t GCBitMask = 0xF;
-
- static const uint32_t NonLockBits = 12;
- static const uint32_t HashBits = 0;
- static const uint32_t GCBits = 4;
-
+ static const uint32_t GCBits = 8;
static const bool MovesObject = false;
}
Removed: vmkit/branches/multi-vm/mmtk/config/marksweep/Selected.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/config/marksweep/Selected.java?rev=120423&view=auto
==============================================================================
--- vmkit/branches/multi-vm/mmtk/config/marksweep/Selected.java (original)
+++ vmkit/branches/multi-vm/mmtk/config/marksweep/Selected.java (removed)
@@ -1,66 +0,0 @@
-//===------------------------- Selected.java ------------------------------===//
-//
-// The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-package org.j3.config;
-
-import org.mmtk.utility.Log;
-
-import org.vmmagic.pragma.*;
-
-public class Selected {
- public static final String name = "org.mmtk.plan.marksweep.MS";
- @Uninterruptible
- public static final class Plan extends org.mmtk.plan.marksweep.MS
- {
- private static final Plan plan = new Plan();
-
- @Inline
- public static Plan get() { return plan; }
- }
-
- @Uninterruptible
- public static final class Constraints extends org.mmtk.plan.marksweep.MSConstraints
- {
- private static final Constraints constraints = new Constraints();
-
- @Inline
- public static Constraints get() { return constraints; }
- }
-
- @Uninterruptible
- public static class Collector extends org.mmtk.plan.marksweep.MSCollector
- {
- private static final Collector bootstrapCollector = new Collector();
-
- public static void staticCollect() {
- bootstrapCollector.collect();
- }
-
- public Collector() {}
- @Inline
- public static Collector get() {
- return bootstrapCollector;
- }
- }
-
- @Uninterruptible
- public static class Mutator extends org.mmtk.plan.marksweep.MSMutator
- {
-
- // Unused mutator used by the AOT compiler to know what instances
- // will be alive during MMTk execution. This allows to inline
- // virtual calls of singleton objects.
- private static final Mutator unusedMutator = new Mutator();
-
- public Mutator() {}
-
- @Inline
- public static native Mutator get();
- }
-}
Propchange: vmkit/branches/multi-vm/mmtk/inline/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 06:21:29 2010
@@ -0,0 +1,2 @@
+MMTkInline.inc
+Release
Removed: vmkit/branches/multi-vm/mmtk/java/build.xml.in
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/java/build.xml.in?rev=120423&view=auto
==============================================================================
--- vmkit/branches/multi-vm/mmtk/java/build.xml.in (original)
+++ vmkit/branches/multi-vm/mmtk/java/build.xml.in (removed)
@@ -1,9 +0,0 @@
-<project name="MMTK-VMKit" default="main" basedir=".">
- <target name="main">
- <mkdir dir="classes"/>
- <javac srcdir="@abs_top_srcdir@/mmtk/java/src:@abs_top_srcdir@/mmtk/config/@MMTK_PLAN@" destdir="classes" source="1.5"/>
- <jar jarfile="mmtk-vmkit.jar">
- <fileset dir="classes"/>
- </jar>
- </target>
-</project>
Propchange: vmkit/branches/multi-vm/mmtk/java/src/org/j3/config/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 06:21:29 2010
@@ -0,0 +1 @@
+Selected.cpp
Modified: vmkit/branches/multi-vm/mmtk/java/src/org/j3/mmtk/Barriers.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/java/src/org/j3/mmtk/Barriers.java?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/java/src/org/j3/mmtk/Barriers.java (original)
+++ vmkit/branches/multi-vm/mmtk/java/src/org/j3/mmtk/Barriers.java Tue Nov 30 06:21:29 2010
@@ -600,7 +600,8 @@
@Override
public final void objectArrayStoreNoGCBarrier(Object[] dst, int index, Object value) {
Address base = ObjectReference.fromObject(dst).toAddress();
- Address slot = base.plus(Offset.fromIntZeroExtend(index << LOG_BYTES_IN_ADDRESS));
+ // Add 3 for the header, the class, and the length.
+ Address slot = base.plus(Offset.fromIntZeroExtend((index + 3) << LOG_BYTES_IN_ADDRESS));
VM.activePlan.global().storeObjectReference(slot, ObjectReference.fromObject(value));
}
}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-alloc/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-alloc/Selected.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-alloc/Selected.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-alloc/Selected.cpp Tue Nov 30 06:21:29 2010
@@ -51,7 +51,7 @@
extern "C" void* gcmalloc(uint32_t sz, void* VT) {
sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
- return JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2(sz, VT);
+ return (gc*)JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2(sz, VT);
}
extern "C" void addFinalizationCandidate(void* obj) __attribute__((always_inline));
@@ -84,14 +84,26 @@
}
void Collector::scanObject(void** ptr, uintptr_t closure) {
+ if ((*ptr) != NULL) {
+ assert(((gc*)(*ptr))->getVirtualTable());
+ }
JnJVM_org_j3_bindings_Bindings_reportDelayedRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2(closure, ptr);
}
void Collector::markAndTrace(void* source, void* ptr, uintptr_t closure) {
+ void** ptr_ = (void**)ptr;
+ if ((*ptr_) != NULL) {
+ assert(((gc*)(*ptr_))->getVirtualTable());
+ }
+ if ((*(void**)ptr) != NULL) assert(((gc*)(*(void**)ptr))->getVirtualTable());
JnJVM_org_j3_bindings_Bindings_processEdge__Lorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2(closure, source, ptr);
}
void Collector::markAndTraceRoot(void* ptr, uintptr_t closure) {
+ void** ptr_ = (void**)ptr;
+ if ((*ptr_) != NULL) {
+ assert(((gc*)(*ptr_))->getVirtualTable());
+ }
JnJVM_org_j3_bindings_Bindings_processRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2Z(closure, ptr, true);
}
@@ -127,7 +139,7 @@
#else
uint32 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED;
#endif
- void* baseAddr = mmap((void*)0x30000000, 0x40000000, PROT_READ | PROT_WRITE,
+ void* baseAddr = mmap((void*)0x30000000, 0x30000000, PROT_READ | PROT_WRITE,
flags, -1, 0);
if (baseAddr == MAP_FAILED) {
perror("mmap");
@@ -138,7 +150,7 @@
}
extern "C" void* MMTkMutatorAllocate(uint32_t size, VirtualTable* VT) {
- void* val = MutatorThread::get()->Allocator.Allocate(size, "MMTk");
+ void* val = MutatorThread::get()->Allocator.Allocate(size);
((void**)val)[0] = VT;
return val;
}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/ActivePlan.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/ActivePlan.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/ActivePlan.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/ActivePlan.cpp Tue Nov 30 06:21:29 2010
@@ -7,22 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "mvm/VirtualMachine.h"
-
-#include "JavaClass.h"
-#include "JavaObject.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "mvm/VirtualMachine.h"
+#include "MMTkObject.h"
+#include "MutatorThread.h"
-using namespace j3;
-
-struct ActivePlan {
- JavaObject obj;
- mvm::MutatorThread* current;
-};
+namespace mmtk {
-extern "C" JavaObject* Java_org_j3_mmtk_ActivePlan_getNextMutator__ (ActivePlan* A) {
+extern "C" MMTkObject* Java_org_j3_mmtk_ActivePlan_getNextMutator__(MMTkActivePlan* A) {
assert(A && "No active plan");
if (A->current == NULL) {
@@ -37,11 +29,15 @@
if (A->current->MutatorContext == 0) {
return Java_org_j3_mmtk_ActivePlan_getNextMutator__(A);
}
- return (JavaObject*)A->current->MutatorContext;
+ return (MMTkObject*)A->current->MutatorContext;
}
-extern "C" void Java_org_j3_mmtk_ActivePlan_resetMutatorIterator__ (ActivePlan* A) {
+extern "C" void Java_org_j3_mmtk_ActivePlan_resetMutatorIterator__(MMTkActivePlan* A) {
A->current = NULL;
}
-extern "C" void Java_org_j3_mmtk_ActivePlan_collectorCount__ (ActivePlan* A) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_ActivePlan_collectorCount__ (MMTkActivePlan* A) {
+ UNIMPLEMENTED();
+}
+
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Assert.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Assert.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Assert.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Assert.cpp Tue Nov 30 06:21:29 2010
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "mvm/VirtualMachine.h"
-#include "JavaObject.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "MMTkObject.h"
+
+namespace mmtk {
-using namespace j3;
+extern "C" void Java_org_j3_mmtk_Assert_dumpStack__ (MMTkObject* self) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_Assert_dumpStack__ () { UNIMPLEMENTED(); }
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp Tue Nov 30 06:21:29 2010
@@ -7,39 +7,31 @@
//
//===----------------------------------------------------------------------===//
-#include "mvm/VirtualMachine.h"
-
-#include "JavaObject.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "mvm/VirtualMachine.h"
+#include "MMTkObject.h"
+#include "MvmGC.h"
-using namespace j3;
+namespace mmtk {
extern "C" void JnJVM_org_mmtk_plan_Plan_setCollectionTriggered__();
-
extern "C" void JnJVM_org_j3_config_Selected_00024Collector_staticCollect__();
-
extern "C" void JnJVM_org_mmtk_plan_Plan_collectionComplete__();
-
extern "C" uint8_t JnJVM_org_mmtk_utility_heap_HeapGrowthManager_considerHeapSize__();
-
extern "C" void JnJVM_org_mmtk_utility_heap_HeapGrowthManager_reset__();
-
extern "C" int64_t Java_org_j3_mmtk_Statistics_nanoTime__ ();
-
extern "C" void JnJVM_org_mmtk_utility_heap_HeapGrowthManager_recordGCTime__D(double);
-extern "C" bool Java_org_j3_mmtk_Collection_isEmergencyAllocation__ (JavaObject* C) {
+extern "C" bool Java_org_j3_mmtk_Collection_isEmergencyAllocation__ (MMTkObject* C) {
// TODO: emergency when OOM.
return false;
}
-extern "C" void Java_org_j3_mmtk_Collection_reportAllocationSuccess__ (JavaObject* C) {
+extern "C" void Java_org_j3_mmtk_Collection_reportAllocationSuccess__ (MMTkObject* C) {
// TODO: clear internal data.
}
-extern "C" void Java_org_j3_mmtk_Collection_triggerCollection__I (JavaObject* C, int why) {
+extern "C" void Java_org_j3_mmtk_Collection_triggerCollection__I (MMTkObject* C, int why) {
mvm::Thread* th = mvm::Thread::get();
// Verify that another collection is not happening.
@@ -81,40 +73,38 @@
}
th->MyVM->rendezvous.finishRV();
-
- th->MyVM->wakeUpFinalizers();
- th->MyVM->wakeUpEnqueue();
-
th->MyVM->endCollection();
}
}
-extern "C" void Java_org_j3_mmtk_Collection_joinCollection__ (JavaObject* C) {
+extern "C" void Java_org_j3_mmtk_Collection_joinCollection__ (MMTkObject* C) {
mvm::Thread* th = mvm::Thread::get();
assert(th->inRV && "Joining collection without a rendezvous");
th->MyVM->rendezvous.join();
}
-extern "C" int Java_org_j3_mmtk_Collection_rendezvous__I (JavaObject* C, int where) {
+extern "C" int Java_org_j3_mmtk_Collection_rendezvous__I (MMTkObject* C, int where) {
return 1;
}
-extern "C" int Java_org_j3_mmtk_Collection_maximumCollectionAttempt__ (JavaObject* C) {
+extern "C" int Java_org_j3_mmtk_Collection_maximumCollectionAttempt__ (MMTkObject* C) {
return 0;
}
-extern "C" void Java_org_j3_mmtk_Collection_prepareCollector__Lorg_mmtk_plan_CollectorContext_2 (JavaObject* C, JavaObject* CC) {
+extern "C" void Java_org_j3_mmtk_Collection_prepareCollector__Lorg_mmtk_plan_CollectorContext_2 (MMTkObject* C, MMTkObject* CC) {
// Nothing to do.
}
-extern "C" void Java_org_j3_mmtk_Collection_prepareMutator__Lorg_mmtk_plan_MutatorContext_2 (JavaObject* C, JavaObject* MC) {
+extern "C" void Java_org_j3_mmtk_Collection_prepareMutator__Lorg_mmtk_plan_MutatorContext_2 (MMTkObject* C, MMTkObject* MC) {
}
-extern "C" void Java_org_j3_mmtk_Collection_reportPhysicalAllocationFailed__ (JavaObject* C) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_Collection_triggerAsyncCollection__I (JavaObject* C, sint32 val) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_Collection_noThreadsInGC__ (JavaObject* C) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_Collection_activeGCThreads__ (JavaObject* C) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_Collection_activeGCThreadOrdinal__ (JavaObject* C) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_Collection_requestMutatorFlush__ (JavaObject* C) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_Collection_reportPhysicalAllocationFailed__ (MMTkObject* C) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_Collection_triggerAsyncCollection__I (MMTkObject* C, sint32 val) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_Collection_noThreadsInGC__ (MMTkObject* C) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_Collection_activeGCThreads__ (MMTkObject* C) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_Collection_activeGCThreadOrdinal__ (MMTkObject* C) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_Collection_requestMutatorFlush__ (MMTkObject* C) { UNIMPLEMENTED(); }
+
+} // namespace mmtk
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/FinalizableProcessor.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/FinalizableProcessor.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/FinalizableProcessor.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/FinalizableProcessor.cpp Tue Nov 30 06:21:29 2010
@@ -8,26 +8,25 @@
//
//===----------------------------------------------------------------------===//
-#include "mvm/VirtualMachine.h"
-
-#include "JavaObject.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "mvm/VirtualMachine.h"
+#include "MMTkObject.h"
-using namespace j3;
+namespace mmtk {
-extern "C" void Java_org_j3_mmtk_FinalizableProcessor_clear__ (JavaObject* P) {
+extern "C" void Java_org_j3_mmtk_FinalizableProcessor_clear__ (MMTkObject* P) {
UNIMPLEMENTED();
}
extern "C" void
-Java_org_j3_mmtk_FinalizableProcessor_forward__Lorg_mmtk_plan_TraceLocal_2Z (JavaObject* P, uintptr_t TL, uint8_t nursery) {
+Java_org_j3_mmtk_FinalizableProcessor_forward__Lorg_mmtk_plan_TraceLocal_2Z (MMTkObject* P, uintptr_t TL, uint8_t nursery) {
UNIMPLEMENTED();
}
extern "C" void
-Java_org_j3_mmtk_FinalizableProcessor_scan__Lorg_mmtk_plan_TraceLocal_2Z (JavaObject* FP, JavaObject* TL, uint8_t nursery) {
+Java_org_j3_mmtk_FinalizableProcessor_scan__Lorg_mmtk_plan_TraceLocal_2Z (MMTkObject* FP, MMTkObject* TL, uint8_t nursery) {
mvm::Thread* th = mvm::Thread::get();
th->MyVM->scanFinalizationQueue(reinterpret_cast<uintptr_t>(TL));
}
+
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Lock.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Lock.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Lock.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Lock.cpp Tue Nov 30 06:21:29 2010
@@ -7,28 +7,30 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaObject.h"
-#include "JavaString.h"
-#include "JavaThread.h"
-#include "mvm/Threads/Locks.h"
-#include "mvm/VirtualMachine.h"
-
#include "debug.h"
-using namespace j3;
+#include "MMTkObject.h"
+
+namespace mmtk {
-struct Lock {
- JavaObject base;
- mvm::SpinLock spin;
- JavaString* name;
-};
+extern "C" void Java_org_j3_mmtk_Lock_acquire__(MMTkLock* l) {
+ for (uint32 count = 0; count < 1000; ++count) {
+ uint32 res = __sync_val_compare_and_swap(&(l->state), 0, 1);
+ if (!res) return;
+ }
+
+ while (__sync_val_compare_and_swap(&(l->state), 0, 1)) {
+ sched_yield();
+ }
+}
+
+extern "C" void Java_org_j3_mmtk_Lock_release__(MMTkLock* l) {
+ l->state = 0;
+}
-extern "C" void Java_org_j3_mmtk_Lock_acquire__(Lock* l) {
- l->spin.acquire();
+extern "C" void Java_org_j3_mmtk_Lock_check__I (MMTkLock* l, int i) {
+ UNIMPLEMENTED();
}
-extern "C" void Java_org_j3_mmtk_Lock_check__I () { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_Lock_release__(Lock* l) {
- l->spin.release();
}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/MMTk_Events.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/MMTk_Events.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/MMTk_Events.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/MMTk_Events.cpp Tue Nov 30 06:21:29 2010
@@ -7,31 +7,29 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaArray.h"
-#include "JavaClass.h"
-#include "JavaObject.h"
-#include "JavaThread.h"
-#include "MutatorThread.h"
+#include "MMTkObject.h"
-using namespace j3;
+namespace mmtk {
extern "C" void Java_org_j3_mmtk_MMTk_1Events_tracePageAcquired__Lorg_mmtk_policy_Space_2Lorg_vmmagic_unboxed_Address_2I(
- JavaObject* event, JavaObject* space, uintptr_t address, int numPages) {
-#ifdef DEBUG
+ MMTkObject* event, MMTkObject* space, uintptr_t address, int numPages) {
+#if 0
fprintf(stderr, "Pages acquired by thread %p from space %p at %x (%d)\n", (void*)mvm::Thread::get(), (void*)space, address, numPages);
#endif
}
extern "C" void Java_org_j3_mmtk_MMTk_1Events_tracePageReleased__Lorg_mmtk_policy_Space_2Lorg_vmmagic_unboxed_Address_2I(
- JavaObject* event, JavaObject* space, uintptr_t address, int numPages) {
-#ifdef DEBUG
+ MMTkObject* event, MMTkObject* space, uintptr_t address, int numPages) {
+#if 0
fprintf(stderr, "Pages released by thread %p from space %p at %x (%d)\n", (void*)mvm::Thread::get(), (void*)space, address, numPages);
#endif
}
extern "C" void Java_org_j3_mmtk_MMTk_1Events_heapSizeChanged__Lorg_vmmagic_unboxed_Extent_2(
- JavaObject* event, uintptr_t heapSize) {
-#ifdef DEBUG
+ MMTkObject* event, uintptr_t heapSize) {
+#if 0
fprintf(stderr, "New heap size : %d\n", (int)heapSize);
#endif
}
+
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Memory.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Memory.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Memory.cpp Tue Nov 30 06:21:29 2010
@@ -7,63 +7,65 @@
//
//===----------------------------------------------------------------------===//
-#include <sys/mman.h>
-
+#include "debug.h"
#include "mvm/VirtualMachine.h"
-#include "JavaObject.h"
-#include "JavaThread.h"
+#include "MMTkObject.h"
-#include "debug.h"
+#include <sys/mman.h>
-using namespace j3;
+namespace mmtk {
-extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapStartConstant__ (JavaObject* M) {
+extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapStartConstant__ (MMTkObject* M) {
return (uintptr_t)0x30000000;
}
-extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapEndConstant__ (JavaObject* M) {
- return (uintptr_t)0x70000000;
+extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapEndConstant__ (MMTkObject* M) {
+ return (uintptr_t)0x60000000;
}
-extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableStartConstant__ (JavaObject* M) {
+extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableStartConstant__ (MMTkObject* M) {
return (uintptr_t)0x30000000;
}
-extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableEndConstant__ (JavaObject* M) {
- return (uintptr_t)0x70000000;
+extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableEndConstant__ (MMTkObject* M) {
+ return (uintptr_t)0x60000000;
}
extern "C" sint32
-Java_org_j3_mmtk_Memory_dzmmap__Lorg_vmmagic_unboxed_Address_2I(JavaObject* M,
+Java_org_j3_mmtk_Memory_dzmmap__Lorg_vmmagic_unboxed_Address_2I(MMTkObject* M,
void* start,
sint32 size) {
// Already mmapped during initialization.
return 0;
}
-extern "C" void
-Java_org_j3_mmtk_Memory_mprotect__Lorg_vmmagic_unboxed_Address_2I (JavaObject* M, uintptr_t address, sint32 size) {
- mprotect((void*)address, size, PROT_NONE);
+extern "C" uint8_t
+Java_org_j3_mmtk_Memory_mprotect__Lorg_vmmagic_unboxed_Address_2I (MMTkObject* M, uintptr_t address, sint32 size) {
+ int val = mprotect((void*)address, size, PROT_NONE);
+ return (val == 0);
}
-extern "C" void
-Java_org_j3_mmtk_Memory_munprotect__Lorg_vmmagic_unboxed_Address_2I (JavaObject* M, uintptr_t address, sint32 size) {
- mprotect((void*)address, size, PROT_READ | PROT_WRITE);
+extern "C" uint8_t
+Java_org_j3_mmtk_Memory_munprotect__Lorg_vmmagic_unboxed_Address_2I (MMTkObject* M, uintptr_t address, sint32 size) {
+ int val = mprotect((void*)address, size, PROT_READ | PROT_WRITE);
+ return (val == 0);
}
extern "C" void
-Java_org_j3_mmtk_Memory_zero__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Extent_2(JavaObject* M,
+Java_org_j3_mmtk_Memory_zero__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Extent_2(MMTkObject* M,
void* addr,
uintptr_t len) {
memset(addr, 0, len);
}
extern "C" void
-Java_org_j3_mmtk_Memory_zeroPages__Lorg_vmmagic_unboxed_Address_2I (JavaObject* M, uintptr_t address, sint32 size) {
+Java_org_j3_mmtk_Memory_zeroPages__Lorg_vmmagic_unboxed_Address_2I (MMTkObject* M, uintptr_t address, sint32 size) {
UNIMPLEMENTED();
}
extern "C" void
-Java_org_j3_mmtk_Memory_dumpMemory__Lorg_vmmagic_unboxed_Address_2II (JavaObject* M, uintptr_t address, sint32 before, sint32 after) {
+Java_org_j3_mmtk_Memory_dumpMemory__Lorg_vmmagic_unboxed_Address_2II (MMTkObject* M, uintptr_t address, sint32 before, sint32 after) {
UNIMPLEMENTED();
}
+
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/ObjectModel.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/ObjectModel.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/ObjectModel.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/ObjectModel.cpp Tue Nov 30 06:21:29 2010
@@ -7,41 +7,38 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaArray.h"
-#include "JavaClass.h"
-#include "JavaObject.h"
-#include "JavaThread.h"
-
+#include "mvm/VirtualMachine.h"
+#include "MMTkObject.h"
#include "debug.h"
-using namespace j3;
+namespace mmtk {
-extern "C" intptr_t Java_org_j3_mmtk_ObjectModel_getArrayBaseOffset__ (JavaObject* OM) {
- return sizeof(JavaObject) + sizeof(ssize_t);
+extern "C" intptr_t Java_org_j3_mmtk_ObjectModel_getArrayBaseOffset__ (MMTkObject* OM) {
+ return sizeof(MMTkObject) + sizeof(ssize_t);
}
-extern "C" intptr_t Java_org_j3_mmtk_ObjectModel_GC_1HEADER_1OFFSET__ (JavaObject* OM) {
+extern "C" intptr_t Java_org_j3_mmtk_ObjectModel_GC_1HEADER_1OFFSET__ (MMTkObject* OM) {
return sizeof(void*);
}
-extern "C" uintptr_t Java_org_j3_mmtk_ObjectModel_readAvailableBitsWord__Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* OM, JavaObject* obj) {
+extern "C" uintptr_t Java_org_j3_mmtk_ObjectModel_readAvailableBitsWord__Lorg_vmmagic_unboxed_ObjectReference_2 (MMTkObject* OM, gc* obj) {
return obj->header;
}
extern "C" void Java_org_j3_mmtk_ObjectModel_writeAvailableBitsWord__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Word_2 (
- JavaObject* OM, JavaObject* obj, uintptr_t val) {
+ MMTkObject* OM, gc* obj, uintptr_t val) {
obj->header = val;
}
-extern "C" JavaObject* Java_org_j3_mmtk_ObjectModel_objectStartRef__Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* OM, JavaObject* obj) {
+extern "C" gc* Java_org_j3_mmtk_ObjectModel_objectStartRef__Lorg_vmmagic_unboxed_ObjectReference_2 (MMTkObject* OM, gc* obj) {
return obj;
}
-extern "C" JavaObject* Java_org_j3_mmtk_ObjectModel_refToAddress__Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* OM, JavaObject* obj) {
+extern "C" gc* Java_org_j3_mmtk_ObjectModel_refToAddress__Lorg_vmmagic_unboxed_ObjectReference_2 (MMTkObject* OM, gc* obj) {
return obj;
}
-extern "C" uint8_t Java_org_j3_mmtk_ObjectModel_readAvailableByte__Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* OM, JavaObject* obj) {
+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)[7];
#else
@@ -49,7 +46,7 @@
#endif
}
-extern "C" void Java_org_j3_mmtk_ObjectModel_writeAvailableByte__Lorg_vmmagic_unboxed_ObjectReference_2B (JavaObject* OM, JavaObject* obj, uint8_t val) {
+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)[7] = val;
#else
@@ -57,17 +54,17 @@
#endif
}
-extern "C" JavaObject* Java_org_j3_mmtk_ObjectModel_getObjectFromStartAddress__Lorg_vmmagic_unboxed_Address_2 (JavaObject* OM, JavaObject* obj) {
+extern "C" gc* Java_org_j3_mmtk_ObjectModel_getObjectFromStartAddress__Lorg_vmmagic_unboxed_Address_2 (MMTkObject* OM, gc* obj) {
return obj;
}
-extern "C" uintptr_t Java_org_j3_mmtk_ObjectModel_prepareAvailableBits__Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* OM, JavaObject* obj) {
+extern "C" uintptr_t Java_org_j3_mmtk_ObjectModel_prepareAvailableBits__Lorg_vmmagic_unboxed_ObjectReference_2 (MMTkObject* OM, gc* obj) {
return obj->header;
}
extern "C" uint8_t
Java_org_j3_mmtk_ObjectModel_attemptAvailableBits__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Word_2Lorg_vmmagic_unboxed_Word_2(
- JavaObject* OM, JavaObject* obj, intptr_t oldValue, intptr_t newValue) {
+ MMTkObject* OM, gc* obj, intptr_t oldValue, intptr_t newValue) {
intptr_t val = __sync_val_compare_and_swap(&(obj->header), oldValue, newValue);
return (val == oldValue);
}
@@ -81,76 +78,84 @@
}
extern "C" uintptr_t JnJVM_org_j3_bindings_Bindings_copy__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2II(
- JavaObject* obj, VirtualTable* VT, int size, int allocator) ALWAYS_INLINE;
+ gc* obj, VirtualTable* VT, int size, int allocator) ALWAYS_INLINE;
extern "C" uintptr_t Java_org_j3_mmtk_ObjectModel_copy__Lorg_vmmagic_unboxed_ObjectReference_2I (
- JavaObject* OM, JavaObject* src, int allocator) ALWAYS_INLINE;
+ MMTkObject* OM, gc* src, int allocator) ALWAYS_INLINE;
extern "C" uintptr_t Java_org_j3_mmtk_ObjectModel_copy__Lorg_vmmagic_unboxed_ObjectReference_2I (
- JavaObject* OM, JavaObject* src, int allocator) {
- size_t size = 0;
- VirtualTable* VT = src->getVirtualTable();
- if (VMClassLoader::isVMClassLoader(src)) {
- size = sizeof(VMClassLoader);
- } else {
- CommonClass* cl = JavaObject::getClass(src);
- if (cl->isArray()) {
- UserClassArray* array = cl->asArrayClass();
- UserCommonClass* base = array->baseClass();
- uint32 logSize = base->isPrimitive() ?
- base->asPrimitiveClass()->logSize : (sizeof(JavaObject*) == 8 ? 3 : 2);
-
- size = sizeof(JavaObject) + sizeof(ssize_t) +
- (JavaArray::getSize(src) << logSize);
- } else {
- assert(cl->isClass() && "Not a class!");
- size = cl->asClass()->getVirtualSize();
- }
- }
+ MMTkObject* OM, gc* src, int allocator) {
+ size_t size = mvm::Thread::get()->MyVM->getObjectSize(src);
size = llvm::RoundUpToAlignment(size, sizeof(void*));
- uintptr_t res = JnJVM_org_j3_bindings_Bindings_copy__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2II(src, VT, size, allocator);
+ uintptr_t res = JnJVM_org_j3_bindings_Bindings_copy__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2II(
+ src, src->getVirtualTable(), size, allocator);
assert((((uintptr_t*)res)[1] & ~mvm::GCBitMask) == (((uintptr_t*)src)[1] & ~mvm::GCBitMask));
return res;
}
extern "C" void Java_org_j3_mmtk_ObjectModel_copyTo__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2 (
- JavaObject* OM, uintptr_t from, uintptr_t to, uintptr_t region) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t from, uintptr_t to, uintptr_t region) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_getReferenceWhenCopiedTo__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2 (
- JavaObject* OM, uintptr_t from, uintptr_t to) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t from, uintptr_t to) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_getObjectEndAddress__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_getSizeWhenCopied__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_getAlignWhenCopied__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_getAlignOffsetWhenCopied__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_getCurrentSize__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_getNextObject__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_ObjectModel_getTypeDescriptor__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+
+class FakeByteArray : public MMTkObject {
+ public:
+ void* operator new(size_t size, int length) {
+ return new char[size + length];
+ }
+
+ FakeByteArray(const char* name) {
+ length = strlen(name);
+ for (uint32 i = 0; i < length; i++) {
+ elements[i] = name[i];
+ }
+ }
+ private:
+ size_t length;
+ uint8_t elements[1];
+};
+
+extern "C" FakeByteArray* Java_org_j3_mmtk_ObjectModel_getTypeDescriptor__Lorg_vmmagic_unboxed_ObjectReference_2 (
+ MMTkObject* OM, gc* src) {
+ const char* name = mvm::Thread::get()->MyVM->getObjectTypeName(src);
+ // This code is only used for debugging on a fatal error. It is fine to
+ // allocate in the C++ heap.
+ return new (strlen(name)) FakeByteArray(name);
+}
extern "C" void Java_org_j3_mmtk_ObjectModel_getArrayLength__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_isArray__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_isPrimitiveArray__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_isAcyclic__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_ObjectModel_dumpObject__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+ MMTkObject* OM, uintptr_t object) { UNIMPLEMENTED(); }
+
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/ReferenceProcessor.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/ReferenceProcessor.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/ReferenceProcessor.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/ReferenceProcessor.cpp Tue Nov 30 06:21:29 2010
@@ -8,22 +8,13 @@
//
//===----------------------------------------------------------------------===//
-#include "mvm/VirtualMachine.h"
-
-#include "JavaObject.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "mvm/VirtualMachine.h"
+#include "MMTkObject.h"
-using namespace j3;
-
-struct ReferenceProcessor {
- JavaObject obj;
- JavaObject* semantics;
- uint32_t ordinal;
-};
+namespace mmtk {
-extern "C" void Java_org_j3_mmtk_ReferenceProcessor_scan__Lorg_mmtk_plan_TraceLocal_2Z (ReferenceProcessor* RP, uintptr_t TL, uint8_t nursery) {
+extern "C" void Java_org_j3_mmtk_ReferenceProcessor_scan__Lorg_mmtk_plan_TraceLocal_2Z (MMTkReferenceProcessor* RP, uintptr_t TL, uint8_t nursery) {
mvm::Thread* th = mvm::Thread::get();
uint32_t val = RP->ordinal;
@@ -35,9 +26,10 @@
assert(val == 2);
th->MyVM->scanPhantomReferencesQueue(TL);
}
-
}
-extern "C" void Java_org_j3_mmtk_ReferenceProcessor_forward__Lorg_mmtk_plan_TraceLocal_2Z (ReferenceProcessor* RP, uintptr_t TL, uint8_t nursery) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_ReferenceProcessor_clear__ (ReferenceProcessor* RP) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_ReferenceProcessor_countWaitingReferences__ (ReferenceProcessor* RP) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_ReferenceProcessor_forward__Lorg_mmtk_plan_TraceLocal_2Z (MMTkReferenceProcessor* RP, uintptr_t TL, uint8_t nursery) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_ReferenceProcessor_clear__ (MMTkReferenceProcessor* RP) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_ReferenceProcessor_countWaitingReferences__ (MMTkReferenceProcessor* RP) { UNIMPLEMENTED(); }
+
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/RuntimeHelpers.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/RuntimeHelpers.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/RuntimeHelpers.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/RuntimeHelpers.cpp Tue Nov 30 06:21:29 2010
@@ -7,18 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaArray.h"
-#include "JavaClass.h"
-#include "JavaString.h"
+#include "MMTkObject.h"
-using namespace j3;
+namespace mmtk {
-extern "C" uint16_t MMTkCharAt(JavaString* str, uint32_t index) {
- llvm_gcroot(str, 0);
- return ArrayUInt16::getElement(JavaString::getValue(str), index);
+extern "C" uint16_t MMTkCharAt(MMTkString* str, uint32_t index) {
+ return str->value->elements[index];
+}
+
+extern "C" MMTkObject* MMTkGetClass(MMTkObject* obj) {
+ return obj->virtualTable->cl->delegatee;
}
-extern "C" JavaObject* MMTkGetClass(JavaObject* obj) {
- llvm_gcroot(obj, 0);
- return JavaObject::getClass(obj)->delegatee[0];
}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Scanning.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Scanning.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Scanning.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Scanning.cpp Tue Nov 30 06:21:29 2010
@@ -7,29 +7,26 @@
//
//===----------------------------------------------------------------------===//
-#include "mvm/VirtualMachine.h"
-
-#include "JavaObject.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "mvm/VirtualMachine.h"
+#include "MMTkObject.h"
+#include "MvmGC.h"
-using namespace j3;
+namespace mmtk {
-extern "C" void Java_org_j3_mmtk_Scanning_computeThreadRoots__Lorg_mmtk_plan_TraceLocal_2 (JavaObject* Scanning, JavaObject* TL) {
+extern "C" void Java_org_j3_mmtk_Scanning_computeThreadRoots__Lorg_mmtk_plan_TraceLocal_2 (MMTkObject* Scanning, MMTkObject* TL) {
// When entering this function, all threads are waiting on the rendezvous to
// finish.
mvm::Thread* th = mvm::Thread::get();
- mvm::StackScanner* sc = th->MyVM->getScanner();
mvm::Thread* tcur = th;
do {
- sc->scanStack(tcur, reinterpret_cast<uintptr_t>(TL));
+ tcur->scanStack(reinterpret_cast<uintptr_t>(TL));
tcur = (mvm::Thread*)tcur->next();
} while (tcur != th);
}
-extern "C" void Java_org_j3_mmtk_Scanning_computeGlobalRoots__Lorg_mmtk_plan_TraceLocal_2 (JavaObject* Scanning, JavaObject* TL) {
+extern "C" void Java_org_j3_mmtk_Scanning_computeGlobalRoots__Lorg_mmtk_plan_TraceLocal_2 (MMTkObject* Scanning, MMTkObject* TL) {
mvm::Thread::get()->MyVM->tracer(reinterpret_cast<uintptr_t>(TL));
mvm::Thread* th = mvm::Thread::get();
@@ -39,32 +36,31 @@
tcur->tracer(reinterpret_cast<uintptr_t>(TL));
tcur = (mvm::Thread*)tcur->next();
} while (tcur != th);
-
}
-extern "C" void Java_org_j3_mmtk_Scanning_computeStaticRoots__Lorg_mmtk_plan_TraceLocal_2 (JavaObject* Scanning, JavaObject* TL) {
+extern "C" void Java_org_j3_mmtk_Scanning_computeStaticRoots__Lorg_mmtk_plan_TraceLocal_2 (MMTkObject* Scanning, MMTkObject* TL) {
// Nothing to do.
}
-extern "C" void Java_org_j3_mmtk_Scanning_resetThreadCounter__ (JavaObject* Scanning) {
+extern "C" void Java_org_j3_mmtk_Scanning_resetThreadCounter__ (MMTkObject* Scanning) {
// Nothing to do.
}
-extern "C" void Java_org_j3_mmtk_Scanning_specializedScanObject__ILorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* Scanning, uint32_t id, JavaObject* TC, JavaObject* obj) ALWAYS_INLINE;
+extern "C" void Java_org_j3_mmtk_Scanning_specializedScanObject__ILorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2 (MMTkObject* Scanning, uint32_t id, MMTkObject* TC, gc* obj) ALWAYS_INLINE;
-extern "C" void Java_org_j3_mmtk_Scanning_specializedScanObject__ILorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* Scanning, uint32_t id, JavaObject* TC, JavaObject* obj) {
+extern "C" void Java_org_j3_mmtk_Scanning_specializedScanObject__ILorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2 (MMTkObject* Scanning, uint32_t id, MMTkObject* TC, gc* obj) {
assert(obj && "No object to trace");
assert(obj->getVirtualTable() && "No virtual table");
assert(obj->getVirtualTable()->tracer && "No tracer in VT");
obj->tracer(reinterpret_cast<uintptr_t>(TC));
}
-extern "C" void Java_org_j3_mmtk_Scanning_preCopyGCInstances__Lorg_mmtk_plan_TraceLocal_2 (JavaObject* Scanning, JavaObject* TL) {
+extern "C" void Java_org_j3_mmtk_Scanning_preCopyGCInstances__Lorg_mmtk_plan_TraceLocal_2 (MMTkObject* Scanning, MMTkObject* TL) {
// Nothing to do, there are no GC objects on which the GC depends.
}
extern "C" void Java_org_j3_mmtk_Scanning_scanObject__Lorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* Scanning, uintptr_t TC, JavaObject* obj) {
+ MMTkObject* Scanning, uintptr_t TC, gc* obj) {
assert(obj && "No object to trace");
assert(obj->getVirtualTable() && "No virtual table");
assert(obj->getVirtualTable()->tracer && "No tracer in VT");
@@ -72,4 +68,6 @@
}
extern "C" void Java_org_j3_mmtk_Scanning_precopyChildren__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* Scanning, JavaObject TL, uintptr_t ref) { UNIMPLEMENTED(); }
+ MMTkObject* Scanning, MMTkObject TL, uintptr_t ref) { UNIMPLEMENTED(); }
+
+}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Selected.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Selected.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Selected.cpp Tue Nov 30 06:21:29 2010
@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaArray.h"
-#include "JavaClass.h"
-#include "JavaObject.h"
-#include "JavaThread.h"
#include "MutatorThread.h"
+#include "MMTkObject.h"
-using namespace j3;
+namespace mmtk {
+
+extern "C" MMTkObject* Java_org_j3_config_Selected_00024Mutator_get__() {
+ return (MMTkObject*)mvm::MutatorThread::get()->MutatorContext;
+}
-extern "C" JavaObject* Java_org_j3_config_Selected_00024Mutator_get__() {
- return (JavaObject*)mvm::MutatorThread::get()->MutatorContext;
}
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Statistics.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Statistics.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Statistics.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Statistics.cpp Tue Nov 30 06:21:29 2010
@@ -7,19 +7,18 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaObject.h"
-#include "JavaThread.h"
+#include "MMTkObject.h"
#include <sys/time.h>
#include <ctime>
-using namespace j3;
+namespace mmtk {
-extern "C" int64_t Java_org_j3_mmtk_Statistics_cycles__ (JavaObject* S) {
+extern "C" int64_t Java_org_j3_mmtk_Statistics_cycles__ (MMTkObject* S) {
return 0;
}
-extern "C" int64_t Java_org_j3_mmtk_Statistics_nanoTime__ (JavaObject* S) {
+extern "C" int64_t Java_org_j3_mmtk_Statistics_nanoTime__ (MMTkObject* S) {
int64_t result;
struct timeval tp;
@@ -35,12 +34,14 @@
}
-extern "C" int32_t Java_org_j3_mmtk_Statistics_getCollectionCount__ (JavaObject* S) {
+extern "C" int32_t Java_org_j3_mmtk_Statistics_getCollectionCount__ (MMTkObject* S) {
return 0;
}
-extern "C" void Java_org_j3_mmtk_Statistics_perfEventInit__Ljava_lang_String_2(JavaObject* S, JavaObject* Str) {
+extern "C" void Java_org_j3_mmtk_Statistics_perfEventInit__Ljava_lang_String_2(MMTkObject* S, MMTkObject* Str) {
}
-extern "C" void Java_org_j3_mmtk_Statistics_perfEventRead__I_3J(JavaObject* S, int id, int64_t* values) {
+extern "C" void Java_org_j3_mmtk_Statistics_perfEventRead__I_3J(MMTkObject* S, int id, int64_t* values) {
}
+
+} // namespace mmtk
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Strings.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Strings.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Strings.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Strings.cpp Tue Nov 30 06:21:29 2010
@@ -7,54 +7,45 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaArray.h"
-#include "JavaObject.h"
-#include "JavaString.h"
-#include "JavaThread.h"
+#include "mvm/Threads/Thread.h"
-using namespace j3;
+#include "MMTkObject.h"
-extern "C" void Java_org_j3_mmtk_Strings_write___3CI(JavaObject* str,
- ArrayUInt16* msg,
+namespace mmtk {
+
+extern "C" void Java_org_j3_mmtk_Strings_write___3CI(MMTkObject* str,
+ MMTkArray* msg,
sint32 len) {
- llvm_gcroot(str, 0);
- llvm_gcroot(msg, 0);
for (sint32 i = 0; i < len; ++i) {
- fprintf(stderr, "%c", ArrayUInt16::getElement(msg, i));
+ fprintf(stderr, "%c", msg->elements[i]);
}
}
-extern "C" void Java_org_j3_mmtk_Strings_writeThreadId___3CI(JavaObject* str,
- ArrayUInt16* msg,
+extern "C" void Java_org_j3_mmtk_Strings_writeThreadId___3CI(MMTkObject* str,
+ MMTkArray* msg,
sint32 len) {
- llvm_gcroot(str, 0);
- llvm_gcroot(msg, 0);
-
- fprintf(stderr, "[%p] ", (void*)JavaThread::get());
+ fprintf(stderr, "[%p] ", (void*)mvm::Thread::get());
for (sint32 i = 0; i < len; ++i) {
- fprintf(stderr, "%c", ArrayUInt16::getElement(msg, i));
+ fprintf(stderr, "%c", msg->elements[i]);
}
}
extern "C" sint32
Java_org_j3_mmtk_Strings_copyStringToChars__Ljava_lang_String_2_3CII(
- JavaObject* obj, JavaString* str, ArrayUInt16* dst, uint32 dstBegin,
+ MMTkObject* obj, MMTkString* str, MMTkArray* dst, uint32 dstBegin,
uint32 dstEnd) {
- llvm_gcroot(str, 0);
- llvm_gcroot(obj, 0);
- llvm_gcroot(dst, 0);
sint32 len = str->count;
sint32 n = (dstBegin + len <= dstEnd) ? len : (dstEnd - dstBegin);
for (sint32 i = 0; i < n; i++) {
- ArrayUInt16::setElement(dst,
- ArrayUInt16::getElement(JavaString::getValue(str), str->offset + i), dstBegin + i);
+ dst->elements[dstBegin + i] = str->value->elements[str->offset + i];
}
return n;
}
+} // end namespace mmtk
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/SynchronizedCounter.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/SynchronizedCounter.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/SynchronizedCounter.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/SynchronizedCounter.cpp Tue Nov 30 06:21:29 2010
@@ -8,13 +8,12 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaObject.h"
-#include "JavaThread.h"
-
+#include "MMTkObject.h"
#include "debug.h"
-using namespace j3;
+namespace mmtk {
-extern "C" void Java_org_j3_mmtk_SynchronizedCounter_reset__ () { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_mmtk_SynchronizedCounter_increment__ () { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_SynchronizedCounter_reset__ (MMTkObject* self) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_mmtk_SynchronizedCounter_increment__ (MMTkObject* self) { UNIMPLEMENTED(); }
+} // end namespace mmtk
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/TraceInterface.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/TraceInterface.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/TraceInterface.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/TraceInterface.cpp Tue Nov 30 06:21:29 2010
@@ -7,51 +7,50 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaObject.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "MMTkObject.h"
-using namespace j3;
+namespace mmtk {
-extern "C" bool Java_org_j3_mmtk_TraceInterface_gcEnabled__ (JavaObject* TI) { UNIMPLEMENTED(); }
+extern "C" bool Java_org_j3_mmtk_TraceInterface_gcEnabled__ (MMTkObject* TI) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_adjustSlotOffset__ZLorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2 (
- JavaObject* TI, bool scalar, uintptr_t src, uintptr_t slot) { UNIMPLEMENTED(); }
+ MMTkObject* TI, bool scalar, uintptr_t src, uintptr_t slot) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_skipOwnFramesAndDump__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* TI, uintptr_t typeRef) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t typeRef) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_updateDeathTime__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* TI, uintptr_t obj) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t obj) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_setDeathTime__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Word_2 (
- JavaObject* TI, uintptr_t ref, uintptr_t time) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t ref, uintptr_t time) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_setLink__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* TI, uintptr_t ref, uintptr_t link) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t ref, uintptr_t link) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_updateTime__Lorg_vmmagic_unboxed_Word_2 (
- JavaObject* TI, uintptr_t obj) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t obj) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_getOID__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* TI, uintptr_t ref) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t ref) { UNIMPLEMENTED(); }
extern "C" uintptr_t Java_org_j3_mmtk_TraceInterface_getDeathTime__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* TI, uintptr_t ref) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t ref) { UNIMPLEMENTED(); }
extern "C" uintptr_t Java_org_j3_mmtk_TraceInterface_getLink__Lorg_vmmagic_unboxed_ObjectReference_2 (
- JavaObject* TI, uintptr_t ref) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t ref) { UNIMPLEMENTED(); }
extern "C" uintptr_t Java_org_j3_mmtk_TraceInterface_getBootImageLink__ (
- JavaObject* TI) { UNIMPLEMENTED(); }
+ MMTkObject* TI) { UNIMPLEMENTED(); }
extern "C" uintptr_t Java_org_j3_mmtk_TraceInterface_getOID__ (
- JavaObject* TI) { UNIMPLEMENTED(); }
+ MMTkObject* TI) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_mmtk_TraceInterface_setOID__Lorg_vmmagic_unboxed_Word_2 (
- JavaObject* TI, uintptr_t oid) { UNIMPLEMENTED(); }
+ MMTkObject* TI, uintptr_t oid) { UNIMPLEMENTED(); }
-extern "C" sint32 Java_org_j3_mmtk_TraceInterface_getHeaderSize__ (JavaObject* TI) { UNIMPLEMENTED(); }
-extern "C" sint32 Java_org_j3_mmtk_TraceInterface_getHeaderEndOffset__ (JavaObject* TI) { UNIMPLEMENTED(); }
+extern "C" sint32 Java_org_j3_mmtk_TraceInterface_getHeaderSize__ (MMTkObject* TI) { UNIMPLEMENTED(); }
+extern "C" sint32 Java_org_j3_mmtk_TraceInterface_getHeaderEndOffset__ (MMTkObject* TI) { UNIMPLEMENTED(); }
+} // namespace mmtk
Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/VM.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/VM.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/VM.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/VM.cpp Tue Nov 30 06:21:29 2010
@@ -7,23 +7,20 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaObject.h"
-#include "JavaString.h"
-#include "JavaThread.h"
-
#include "debug.h"
+#include "MMTkObject.h"
-using namespace j3;
+namespace mmtk {
extern "C" void Java_org_j3_runtime_VM_sysWrite__Lorg_vmmagic_unboxed_Extent_2 (uintptr_t e) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_runtime_VM_sysWrite__Lorg_vmmagic_unboxed_Address_2 (uintptr_t a) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_runtime_VM_sysWrite__F (float f) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_runtime_VM_sysWrite__I (int i) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWrite__Ljava_lang_String_2 (JavaString* msg) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_runtime_VM_sysWrite__Ljava_lang_String_2 (MMTkString* msg) { UNIMPLEMENTED(); }
extern "C" void Java_org_j3_runtime_VM_sysWriteln__ () { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWriteln__Ljava_lang_String_2 (JavaString* msg) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_runtime_VM_sysWriteln__Ljava_lang_String_2 (MMTkString* msg) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM__1assert__ZLjava_lang_String_2 (bool cond, JavaString* msg) {
+extern "C" void Java_org_j3_runtime_VM__1assert__ZLjava_lang_String_2 (bool cond, MMTkString* msg) {
ABORT();
}
@@ -31,7 +28,7 @@
ABORT();
}
-extern "C" void Java_org_j3_runtime_VM_sysFail__Ljava_lang_String_2 (JavaString* msg) {
+extern "C" void Java_org_j3_runtime_VM_sysFail__Ljava_lang_String_2 (MMTkString* msg) {
// Just call abort because gcmalloc calls this function. If it were to
// call printf, MMTkInline.inc could not be JIT-compiled.
abort();
@@ -58,9 +55,14 @@
}
extern "C" bool Java_org_j3_runtime_VM_verifyAssertions__ () {
-#ifdef DEBUG
+ // Note that DEBUG is defined in make ENABLE_OPTIMIZED=1.
+ // You must provide DISABLE_ASSERTIONS=1 to not have DEBUG defined.
+ // To generate MMTkInline.inc, this function returns false.
+#if 0
return true;
#else
return false;
#endif
}
+
+} // namespace mmtk
Modified: vmkit/branches/multi-vm/tools/j3/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/j3/Makefile?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/j3/Makefile (original)
+++ vmkit/branches/multi-vm/tools/j3/Makefile Tue Nov 30 06:21:29 2010
@@ -19,7 +19,7 @@
Mvm.bc MvmCompiler.bc
ifeq ($(GC_MMTK), 1)
- USEDMODULES += FinalMMTk.bc
+ USEDMODULES += FinalMMTk.bc InlineMMTk.bc
else
USEDMODULES += $(GCLIB).bc
endif
Modified: vmkit/branches/multi-vm/tools/llcj/llcj.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/llcj/llcj.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/llcj/llcj.cpp (original)
+++ vmkit/branches/multi-vm/tools/llcj/llcj.cpp Tue Nov 30 06:21:29 2010
@@ -8,9 +8,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/ManagedStatic.h"
-#include "llvm/System/Path.h"
-#include "llvm/System/Program.h"
-#include "llvm/System/Signals.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
#include "LinkPaths.h"
Modified: vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp (original)
+++ vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp Tue Nov 30 06:21:29 2010
@@ -31,7 +31,7 @@
#include "llvm/Support/RegistryParser.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/System/Signals.h"
+#include "llvm/Support/Signals.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
@@ -178,15 +178,16 @@
mvm::Collector::initialise();
- JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp, false);
+ mvm::BumpPtrAllocator allocator;
+ JnjvmBootstrapLoader* loader = new(allocator, "Bootstrap loader")
+ JnjvmBootstrapLoader(allocator, Comp, false);
if (DisableExceptions) Comp->disableExceptions();
if (DisableStubs) Comp->generateStubs = false;
if (AssumeCompiled) Comp->assumeCompiled = true;
if (DisableCooperativeGC) Comp->disableCooperativeGC();
- mvm::BumpPtrAllocator A;
- Jnjvm* vm = new(A, "Bootstrap loader") Jnjvm(A, (JnjvmBootstrapLoader*)JCL);
+ Jnjvm* vm = new(allocator, "Bootstrap loader") Jnjvm(allocator, loader);
for (std::vector<std::string>::iterator i = Properties.begin(),
e = Properties.end(); i != e; ++i) {
Modified: vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp (original)
+++ vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp Tue Nov 30 06:21:29 2010
@@ -26,6 +26,8 @@
#include "mvm/Threads/Thread.h"
#include "j3/JavaJITCompiler.h"
+#include "../../lib/J3/VMCore/JnjvmClassLoader.h"
+#include "../../lib/J3/VMCore/Jnjvm.h"
#include "CommandLine.h"
@@ -33,14 +35,12 @@
using namespace llvm;
enum VMType {
- Interactive, RunJava, RunNet
+ RunJava
};
static llvm::cl::opt<VMType> VMToRun(llvm::cl::desc("Choose VM to run:"),
llvm::cl::values(
- clEnumValN(Interactive , "i", "Run in interactive mode"),
clEnumValN(RunJava , "java", "Run the JVM"),
- clEnumValN(RunNet, "net", "Run the CLI VM"),
clEnumValEnd));
static llvm::cl::opt<bool> Fast("fast",
@@ -57,55 +57,26 @@
}
int main(int argc, char** argv) {
- // Disable the lcean shutdown, as deamon threads may still
- // continue to execute and use LLVM things.
- //llvm::llvm_shutdown_obj X;
-
+ llvm::llvm_shutdown_obj X;
int pos = found(argv, argc, "-java");
if (pos) {
llvm::cl::ParseCommandLineOptions(pos, argv);
} else {
- pos = found(argv, argc, "-net");
- if (pos) {
- llvm::cl::ParseCommandLineOptions(pos, argv);
- } else {
- llvm::cl::ParseCommandLineOptions(argc, argv);
- }
+ fprintf(stderr, "Only -java is supported\n");
+ return 0;
}
mvm::MvmModule::initialise(Fast ? CodeGenOpt::None : CodeGenOpt::Aggressive);
mvm::Collector::initialise();
if (VMToRun == RunJava) {
-#if WITH_J3
+ mvm::BumpPtrAllocator Allocator;
JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
- JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp);
- mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM(JCL);
- vm->runApplication(argc, argv);
- vm->waitForExit();
-#endif
- } else if (VMToRun == RunNet) {
-#if WITH_N3
- mvm::CompilationUnit* CU = mvm::VirtualMachine::initialiseCLIVM();
- mvm::VirtualMachine* vm = mvm::VirtualMachine::createCLIVM(CU);
+ JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
+ JnjvmBootstrapLoader(Allocator, Comp, true);
+ Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader);
vm->runApplication(argc, argv);
vm->waitForExit();
-#endif
- } else {
- mvm::CommandLine MyCl;
-#if WITH_J3
- JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
- JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp);
- MyCl.vmlets["java"] = (create_vm_t)(mvm::VirtualMachine::createJVM);
- MyCl.compilers["java"] = (mvm::Object*)JCL;
-#endif
-#if WITH_N3
- mvm::CompilationUnit* CLICompiler =
- mvm::VirtualMachine::initialiseCLIVM();
- MyCl.vmlets["net"] = (create_vm_t)(mvm::VirtualMachine::createCLIVM);
- MyCl.compilers["net"] = (mvm::Object*)CLICompiler;
-#endif
- MyCl.start();
}
return 0;
Modified: vmkit/branches/multi-vm/tools/vmkit/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/vmkit/Makefile?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/vmkit/Makefile (original)
+++ vmkit/branches/multi-vm/tools/vmkit/Makefile Tue Nov 30 06:21:29 2010
@@ -32,7 +32,7 @@
USEDMODULES += Allocator.bc CommonThread.bc Mvm.bc MvmCompiler.bc
ifeq ($(GC_MMTK), 1)
- USEDMODULES += FinalMMTk.bc
+ USEDMODULES += FinalMMTk.bc InlineMMTk.bc
else
USEDMODULES += $(GCLIB).bc
endif
Modified: vmkit/branches/multi-vm/www/get_started.html
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/www/get_started.html?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/www/get_started.html (original)
+++ vmkit/branches/multi-vm/www/get_started.html Tue Nov 30 06:21:29 2010
@@ -24,27 +24,19 @@
<h2>A word of warning</h2>
-<p>While this work aims to provide a fully functional JVM and CLI runtime, it
+<p>While this work aims to provide a fully functional JVM, it
is <em>still early work</em> and is under heavy development.
-<p>Some of the more notable missing pieces in the CLI runtime are:</p>
-
-<ol>
- <li>Support for arithmetic overflow.</li>
- <li>Support for CLI object finalization semantics.</li>
- <li>Thread support.</li>
-</ol>
-
<p>Some of the common missing pieces in vmkit/llvm are:</p>
<ol>
- <li>Hotspot-like virtual machine (e.g mixed interpretation/compilation).</li>
+ <li> Mixed interpretation/compilation.</li>
+ <li> Adaptive optimization.</li>
</ol>
<h2 id="build">Building vmkit / working with the code</h2>
<p>If you would like to check out and build the project, the current scheme
-is (if you only want the JVM, you can skip the Pnet part. If you only want the CLI
-VM, you can skip the GNU Classpath part):</p>
+is:</p>
<ol>
<li><a href="http://www.llvm.org/docs/GettingStarted.html#checkout">Checkout
@@ -89,22 +81,6 @@
</ul>
</ul>
- <li><a href="http://download.savannah.gnu.org/releases/dotgnu-pnet/pnet-0.8.0.tar.gz">Download
- PNet 0.8.0</a>:</li>
- <ul>
- <li><tt>tar zxvf pnet-0.8.0.tar.gz</tt></li>
- <li><tt>cd pnet-0.8.0</tt></li>
- <li><tt>./configure; make</tt></li>
- </ul>
-
- <li><a href="http://download.savannah.gnu.org/releases/dotgnu-pnet/pnetlib-0.8.0.tar.gz">Download
- PNetlib 0.8.0</a>:</li>
- <ul>
- <li><tt>tar zxvf pnetlib-0.8.0.tar.gz</tt></li>
- <li><tt>cd pnetlib-0.8.0</tt></li>
- <li><tt>./configure; make</tt></li>
- </ul>
-
<li>Checkout vmkit:</li>
<ul>
<li><tt>svn co http://llvm.org/svn/llvm-project/vmkit/trunk vmkit</tt></li>
@@ -122,10 +98,6 @@
<dd>Tell vmkit where GNU Classpath glibj.zip is located.</dd>
<dt><br/><tt>--with-gnu-classpath-libs=<directory></tt></dt>
<dd>Tell vmkit where GNU Classpath libs are located.</dd>
- <dt><br/><tt>--with-pnet-local-prefix=<directory></tt></dt>
- <dd>Tell vmkit where PNet is located.</dd>
- <dt><br/><tt>--with-pnetlib=<directory></tt></dt>
- <dd>Tell vmkit where pnetlib's mscorlib.dll is located.</dd>
</dl>
</ul>
@@ -140,8 +112,6 @@
<ul>
<li><tt>j3 --help</tt></li>
<li><tt>j3 HelloWorld</tt></li>
- <li><tt>n3-pnetlib --help</tt></li>
- <li><tt>n3-pnetlib HelloWorld.exe</tt></li>
</ul>
</ol>
Modified: vmkit/branches/multi-vm/www/index.html
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/www/index.html?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/www/index.html (original)
+++ vmkit/branches/multi-vm/www/index.html Tue Nov 30 06:21:29 2010
@@ -4,7 +4,7 @@
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
- <title>"VMKit" JVM and .Net runtimes for LLVM</title>
+ <title>VMKit: a substrate for virtual machines</title>
<link type="text/css" rel="stylesheet" href="menu.css" />
<link type="text/css" rel="stylesheet" href="content.css" />
</head>
@@ -12,16 +12,15 @@
<!--#include virtual="menu.html.incl"-->
<div id="content">
<!--*********************************************************************-->
- <h1>VMKit: JVM and .Net runtimes for LLVM</h1>
+ <h1>VMKit: a substrate for virtual machines</h1>
<!--*********************************************************************-->
- <p>The VMKit project is an implementation of a JVM and CLI virtual machine
- (.Net is an implementation of the CLI). It translates Java bytecode and
- MSIL in the LLVM IR and uses the <a href="http://llvm.org">LLVM framework</a>
- for optimizations and compilation. For garbage collection, it uses
- <a href="http://jikesrvm.org/MMTk">MMTk</a>.
- You can <a href="get_started.html">get and build</a> the
- source today.</p>
+ <p>The VMKit project is a framework for building virtual machines. It uses
+ <a href="http://llvm.org">LLVM</a> for compiling and optimizing high-level
+ languages to machine code, and <a href="http://jikesrvm.org/MMTk">MMTk</a>
+ to manage memory. J3 is an implementation of a JVM with VMKit.
+ You can <a href="get_started.html">get and build</a> the source of J3
+ today.</p>
<!--=====================================================================-->
<h2 id="goals">Features</h2>
@@ -32,7 +31,6 @@
<p><b>End-User Features</a></b>:</p>
<ul>
- <li>Runs any Java and .Net applications on MacOSX and Unix-based systems.</li>
<li>Precise garbage collection.</li>
<li>Just-in-Time and Ahead-of-Time compilation.</li>
<li>Portable on many architectures (x86, x64, ppc32, ppc64, arm).</li>
@@ -85,20 +83,14 @@
<h2>Current Status</h2>
<!--=====================================================================-->
- <p>VMKit is still in its early development stages. If you are looking to
- experiment virtual machine technologies, VMKit is probably a great solution
- for you. If you want to use it as a drop in JVM or .Net, it is not yet
- ready.</p>
-
- <p>VMKit currently has a decent implementation of the JVM. It executes
+ <p>VMKit currently has a decent implementation of a JVM. It executes
large projects (e.g. OSGi Felix, Tomcat, Eclipse) and the
<a href="http://dacapobench.org">DaCapo benchmarks</a>.
- The CLI implementation is still in its early stages, but can execute
- simple applications.</p>
+ </p>
<p>The JVM has been tested on Linux/x64, Linux/x86, Linux/ppc32, MacOSX/x64,
MacOSX/x86, MacOSX/ppc32. The JVM may work on ppc64. Support for
- Windows has not been investigated
+ Windows has not been investigated.
</p>
Modified: vmkit/branches/multi-vm/www/releases/index.html
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/www/releases/index.html?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/www/releases/index.html (original)
+++ vmkit/branches/multi-vm/www/releases/index.html Tue Nov 30 06:21:29 2010
@@ -27,6 +27,11 @@
<!--=====================================================================-->
<ul>
+ <li><a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/release_028/www/releases/vmkit-0.28.tar.bz2?revision=116299">
+ VMKit release 0.28 </a> (
+ <a href="http://llvm.org/releases/2.8/docs/ReleaseNotes.html#vmkit">
+ Release notes </a>)
+ </li>
<li><a href="http://llvm.org/releases/2.7/vmkit-0.27.tar.bz2">
VMKit release 0.27 </a> (
<a href="http://llvm.org/releases/2.7/docs/ReleaseNotes.html#vmkit">
Modified: vmkit/branches/multi-vm/www/use_aot.html
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/www/use_aot.html?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/www/use_aot.html (original)
+++ vmkit/branches/multi-vm/www/use_aot.html Tue Nov 30 06:21:29 2010
@@ -29,8 +29,7 @@
<ul>
<li><tt>cd tools/vmjc/libvmjc</tt></li>
- <li><tt>make ENABLE_OPTIMIZED=1 REQUIRES_FRAME_POINTER=1
- (go get coffee)</tt></li>
+ <li><tt>make ENABLE_OPTIMIZED=1 (go get coffee)</tt></li>
</ul>
<li>Update PATH to include LLVM and VMKit binaries (replace *_OBJ with your
Modified: vmkit/branches/multi-vm/www/use_mmtk.html
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/www/use_mmtk.html?rev=120424&r1=120423&r2=120424&view=diff
==============================================================================
--- vmkit/branches/multi-vm/www/use_mmtk.html (original)
+++ vmkit/branches/multi-vm/www/use_mmtk.html Tue Nov 30 06:21:29 2010
@@ -16,8 +16,7 @@
<h1>Getting Started: VMKit and MMTk</h1>
-<p>This page gives you the instructions on how to build VMKit with MMTk's Mark and
-Sweep Garbage Collector.</p>
+<p>This page gives you the instructions on how to build VMKit with a MMTk garbage collector.</p>
<ol>
@@ -25,15 +24,12 @@
and build LLVM-GCC</a> from SVN head.</li>
<li> Update PATH to include the <tt>llvm-gcc</tt> binary. </li>
<li> Re-configure LLVM. </li>
- <li> Configure VMKit with two additional options: <tt>--with-gc=mmtk</tt> and <tt>--with-llvmgcc</tt>. </li>
- <li> Clean and make VMKit (do that each time you change the source code of VMKit):</li>
-
+ <li> Configure VMKit with three additional options: <tt>--with-gc=mmtk</tt>, <tt>--with-llvmgcc</tt>, and <tt>--with-mmtk-plan={marksweep|copyms}</tt> </li>
+ <li> Build VMKit:</li>
<ul>
- <li><tt>make ENABLE_OPTIMIZED=1 clean</tt></li>
<li><tt>make ENABLE_OPTIMIZED=1 </tt></li>
</ul>
-
- <li>Run VMKit with MMTk:</li>
+ <li>Run VMKit:</li>
<ul>
<li><tt>Release/bin/j3 Foo </tt></li>
</ul>
More information about the vmkit-commits
mailing list