[vmkit-commits] [vmkit] r219392 - Creating an accurate memory monitor.

Koutheir Attouchi koutheir at gmail.com
Thu Oct 9 01:53:56 PDT 2014


Author: koutheir
Date: Thu Oct  9 03:43:38 2014
New Revision: 219392

URL: http://llvm.org/viewvc/llvm-project?rev=219392&view=rev
Log:
Creating an accurate memory monitor.

Added:
    vmkit/branches/memory-monitor/include/vmkit/StackEmbeddedList.h
    vmkit/branches/memory-monitor/include/vmkit/StackWalker.h
    vmkit/branches/memory-monitor/include/vmkit/config.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.h
    vmkit/branches/memory-monitor/lib/vmkit/CommonThread/StackEmbeddedList.cpp
    vmkit/branches/memory-monitor/osgi/
    vmkit/branches/memory-monitor/osgi/j3mgr/   (with props)
    vmkit/branches/memory-monitor/osgi/j3mgr/bundle.manifest
    vmkit/branches/memory-monitor/osgi/j3mgr/src/
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/J3Mgr.java
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/OSGi.java
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/Tier.java
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/Activator.java
    vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/J3MgrImpl.java
    vmkit/branches/memory-monitor/osgi/knopflerfish.patch
    vmkit/branches/memory-monitor/osgi/tests/
    vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/
    vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/
    vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/Main.java
    vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/TierConfigParser.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/A.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/Token.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/AImpl.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/InfiniteResurrecter.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/TokenImpl.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/B/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/B/B.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/BImpl.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/tests/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/tests/C/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/tests/C/C.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/CImpl.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/D/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/D/D.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/DImpl.java
    vmkit/branches/memory-monitor/osgi/tests/tests.A/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/tests.A/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/tests.A/src/
    vmkit/branches/memory-monitor/osgi/tests/tests.A/src/tests/
    vmkit/branches/memory-monitor/osgi/tests/tests.A/src/tests/A/
    vmkit/branches/memory-monitor/osgi/tests/tests.A/src/tests/A/A.java
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/AImpl.java
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/EImpl.java
    vmkit/branches/memory-monitor/osgi/tests/tests.B/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/tests.B/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/tests.B/src/
    vmkit/branches/memory-monitor/osgi/tests/tests.B/src/tests/
    vmkit/branches/memory-monitor/osgi/tests/tests.B/src/tests/B/
    vmkit/branches/memory-monitor/osgi/tests/tests.B/src/tests/B/BEvent.java
    vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/
    vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/
    vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/BImpl.java
    vmkit/branches/memory-monitor/osgi/tests/tests.E/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/tests.E/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/tests.E/src/
    vmkit/branches/memory-monitor/osgi/tests/tests.E/src/tests/
    vmkit/branches/memory-monitor/osgi/tests/tests.E/src/tests/E/
    vmkit/branches/memory-monitor/osgi/tests/tests.E/src/tests/E/E.java
    vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/tests/
    vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/tests/FImpl/
    vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/tests/FImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/   (with props)
    vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/bundle.manifest
    vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/
    vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/
    vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/
    vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/Activator.java
    vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/EImpl.java
    vmkit/branches/memory-monitor/tests/dacapo/2006-10-MR2/Makefile
    vmkit/branches/memory-monitor/tests/dacapo/Makefile.inc
    vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.plot
    vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.sh
    vmkit/branches/memory-monitor/tests/dacapo/jars/download.sh
    vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.plot
    vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.sh
    vmkit/branches/memory-monitor/tests/debug.txt
    vmkit/branches/memory-monitor/tests/full.xargs
    vmkit/branches/memory-monitor/tests/java-grant-all.policy
    vmkit/branches/memory-monitor/tests/min.xargs
    vmkit/branches/memory-monitor/tests/monitor-bench/   (with props)
    vmkit/branches/memory-monitor/tests/monitor-bench/Makefile
    vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-MethodCallBenchmark.png   (with props)
    vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-SmallObjectsBenchmark.png   (with props)
    vmkit/branches/memory-monitor/tests/monitor-bench/src/
    vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/
    vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Benchmark.java
    vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/BenchmarkRunner.java
    vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Main.java
    vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/MethodCallBenchmark.java
    vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/SmallObjectsBenchmark.java
    vmkit/branches/memory-monitor/tests/monitor-bench/synth.plot
    vmkit/branches/memory-monitor/tests/monitor-bench/synth.sh
    vmkit/branches/memory-monitor/tests/monitor.xargs
    vmkit/branches/memory-monitor/tests/monitoring.rules
    vmkit/branches/memory-monitor/tests/tier.description
Removed:
    vmkit/branches/memory-monitor/include/vmkit/config.h.in.orig
    vmkit/branches/memory-monitor/lib/prepare-code/
    vmkit/branches/memory-monitor/lib/vmkit/StaticGCPass/
    vmkit/branches/memory-monitor/lib/vmkit/StaticGCPrinter/
    vmkit/branches/memory-monitor/tests/AnnotationClassTest.java
    vmkit/branches/memory-monitor/tests/MyAnnotation.java
    vmkit/branches/memory-monitor/tests/benchmarks/
    vmkit/branches/memory-monitor/tests/dacapo/2006-10/
    vmkit/branches/memory-monitor/tests/dacapo/9.12-bach/
    vmkit/branches/memory-monitor/tests/dacapo/tablet-incinerator-dacapo-2006-10-MR2.logs/
    vmkit/branches/memory-monitor/tests/dacapo/tablet-j3-dacapo-2006-10-MR2.logs/
    vmkit/branches/memory-monitor/tests/ijvm.isolate.IsolateManager/
    vmkit/branches/memory-monitor/tests/ijvm.tests.A/
    vmkit/branches/memory-monitor/tests/ijvm.tests.AImpl/
    vmkit/branches/memory-monitor/tests/ijvm.tests.BImpl/
    vmkit/branches/memory-monitor/tests/ijvm.tests.BundleMgmtStress/
    vmkit/branches/memory-monitor/tests/ijvm.tests.C/
    vmkit/branches/memory-monitor/tests/ijvm.tests.CImpl/
    vmkit/branches/memory-monitor/tests/ijvm.tests.DImpl/
    vmkit/branches/memory-monitor/tests/ijvm.tests.Runner/
    vmkit/branches/memory-monitor/tests/ijvm.tests.StaticClient/
    vmkit/branches/memory-monitor/tests/ijvm.tests.StaticExposer/
    vmkit/branches/memory-monitor/tests/ijvm.tests.loopClient/
    vmkit/branches/memory-monitor/tests/ijvm.tests.looper/
    vmkit/branches/memory-monitor/tests/ijvm.tests.tier/
    vmkit/branches/memory-monitor/tests/ijvm.tests.tierImpl/
    vmkit/branches/memory-monitor/tools/precompiler/trainer/
    vmkit/branches/memory-monitor/www/publis/
Modified:
    vmkit/branches/memory-monitor/   (props changed)
    vmkit/branches/memory-monitor/Makefile.rules
    vmkit/branches/memory-monitor/README.TXT
    vmkit/branches/memory-monitor/include/debug.h
    vmkit/branches/memory-monitor/include/j3/J3Intrinsics.h
    vmkit/branches/memory-monitor/include/vmkit/GC.h
    vmkit/branches/memory-monitor/include/vmkit/System.h
    vmkit/branches/memory-monitor/include/vmkit/Thread.h
    vmkit/branches/memory-monitor/include/vmkit/UTF8.h
    vmkit/branches/memory-monitor/include/vmkit/VirtualMachine.h
    vmkit/branches/memory-monitor/include/vmkit/config.h.in
    vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/ClasspathVMMethod.inc
    vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp
    vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h
    vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp
    vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h
    vmkit/branches/memory-monitor/lib/j3/Compiler/J3Intrinsics.cpp
    vmkit/branches/memory-monitor/lib/j3/Compiler/JavaAOTCompiler.cpp
    vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.cpp
    vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.h
    vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJITOpcodes.cpp
    vmkit/branches/memory-monitor/lib/j3/Compiler/LowerConstantCalls.cpp
    vmkit/branches/memory-monitor/lib/j3/LLVMRuntime/runtime-default.ll
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaMetaJIT.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaRuntimeJIT.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.h
    vmkit/branches/memory-monitor/lib/j3/VMCore/JnjvmClassLoader.cpp
    vmkit/branches/memory-monitor/lib/j3/VMCore/Precompiled.cpp
    vmkit/branches/memory-monitor/lib/vmkit/CommonThread/CollectionRV.cpp
    vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ObjectLocks.cpp
    vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc
    vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc
    vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ctthread.cpp
    vmkit/branches/memory-monitor/lib/vmkit/Runtime/MethodInfo.cpp
    vmkit/branches/memory-monitor/lib/vmkit/Runtime/UTF8.cpp
    vmkit/branches/memory-monitor/mmtk/mmtk-alloc/Selected.cpp
    vmkit/branches/memory-monitor/tests/   (props changed)
    vmkit/branches/memory-monitor/tests/dacapo/jars/   (props changed)
    vmkit/branches/memory-monitor/tools/j3/Main.cpp
    vmkit/branches/memory-monitor/www/get_started.html
    vmkit/branches/memory-monitor/www/index.html
    vmkit/branches/memory-monitor/www/menu.html.incl
    vmkit/branches/memory-monitor/www/tuto/toy-vm-base.tar.gz

Propchange: vmkit/branches/memory-monitor/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -14,4 +14,9 @@ Release+Asserts
 Debug+Asserts
 Debug
 .project
+.cproject
+.settings
+.autotools
+fwdir
+generated.bc
 

Modified: vmkit/branches/memory-monitor/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/Makefile.rules?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/Makefile.rules (original)
+++ vmkit/branches/memory-monitor/Makefile.rules Thu Oct  9 03:43:38 2014
@@ -23,7 +23,7 @@ ifeq ($(OPTIMIZED),1)
   LLC_FLAGS+= -O=3
   OPT_FLAGS+= -disable-opt
   CPPGEN_FLAGS+=-strip-debug
-  COMMON_CFLAGS+= -O3
+  COMMON_CFLAGS+=-O3
 else
   LLC_FLAGS+=-O=0 -asm-verbose
   OPT_FLAGS+=-disable-opt -inline
@@ -36,7 +36,7 @@ LLC_FLAGS+=-disable-cfi -disable-fp-elim
 OPT_FLAGS+=-disable-cfi -disable-fp-elim 
 
 INCLUDES+=-I$(PROJ_SRC_CWD) -I$(PROJ_SRC_ROOT)/include -I$(PROJ_SRC_ROOT)/lib/vmkit/MMTk -I$(BUILD_DIR) \
-					-I$(shell $(LLVM_CONFIG) --includedir) -I$(shell $(LLVM_CONFIG) --obj-root)/include -I$(shell $(LLVM_CONFIG) --src-root)
+					-I$(shell $(LLVM_CONFIG) --includedir) -I$(shell $(LLVM_CONFIG) --bindir)/../include -I$(shell $(LLVM_CONFIG) --src-root)
 
 WARN_CFLAGS=  -Wall -Wno-long-long -Wno-variadic-macros -Wno-unused-private-field -Wno-unused-variable
 COMMON_CFLAGS+= $(INCLUDES) -ansi -pedantic $(WARN_CFLAGS) -fPIC \
@@ -44,10 +44,10 @@ COMMON_CFLAGS+= $(INCLUDES) -ansi -pedan
 								-fno-strict-aliasing -fno-omit-frame-pointer -fvisibility-inlines-hidden 
 
 CFLAGS+=$(COMMON_CFLAGS)
-CXXFLAGS+=$(COMMON_CFLAGS) -Woverloaded-virtual -Wcast-qual -fno-exceptions $(LLVM_RTTI)
+CXXFLAGS+=$(COMMON_CFLAGS) -std=c++11 -stdlib=libc++ -Woverloaded-virtual -Wcast-qual -fno-exceptions $(LLVM_RTTI)
 LDFLAGS+=$(COMMON_CFLAGS) $(shell $(LLVM_CONFIG) --ldflags) $(LDOPT)
-SHOPT+=$(COMMON_CFLAGS)
-LIBS+=$(shell $(LLVM_CONFIG) --libs) -lz
+SHOPT+=$(COMMON_CFLAGS) -lc++ -lc++abi
+LIBS+=$(shell $(LLVM_CONFIG) --libs) -lz -lpthread -ldl -lc++ -lc++abi
 
 DEPEND_OPTIONS=-MMD -MP -MF "$(BUILD_DIR)/$$*.d.tmp" -MT "$(BUILD_DIR)/$$*.bc" -MT "$(BUILD_DIR)/$$*.d"
 DOM=then mv -f "$(BUILD_DIR)/$$*.d.tmp" "$(BUILD_DIR)/$$*.d"; else rm -f "$(BUILD_DIR)/$$*.d.tmp"; exit 1; fi
@@ -262,11 +262,11 @@ DEP_LIBS=$(patsubst %,$(LIB_DIR)/lib%.a,
 
 $(BIN_DIR)/$(TOOL)$(EXEEXT): $(MODULE_A) $(DEP_LIBS) $(BUILD_DIR)/frametables.o $(SELF) $(BIN_DIR)/.dir
 	$(Echo) "Linking executable '$(notdir $@)'"
-	$(Verb) $(CLANGXX) -o $@  $(LDFLAGS) $(MODULE_A) $(BUILD_DIR)/frametables.o $(DEP_LIBS) $(DEP_LIBS) $(LIBS)
+	$(Verb) $(CLANGXX) -std=c++11 -stdlib=libc++ -o $@  $(LDFLAGS) $(MODULE_A) $(BUILD_DIR)/frametables.o $(DEP_LIBS) $(DEP_LIBS) $(LIBS)
 
 $(LIB_DIR)/$(LIBRARY)$(SHLIBEXT): $(MODULE_A) $(DEP_LIBS) $(SELF) $(LIB_DIR)/.dir
 	$(Echo) "Linking shared library '$(notdir $@)'"
-	$(Verb) $(CLANGXX) -o $@ $(SHOPT) -shared -Wl,--whole-archive $(MODULE_A) -Wl,--no-whole-archive $(DEP_LIBS)
+	$(Verb) $(CLANGXX) -std=c++11 -stdlib=libc++ -L$(shell $(LLVM_CONFIG) --bindir)/../lib -o $@ $(SHOPT) -shared -Wl,--whole-archive $(MODULE_A) -Wl,--no-whole-archive $(DEP_LIBS)
 
 ###############################################################################
 #   Frametables

Modified: vmkit/branches/memory-monitor/README.TXT
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/README.TXT?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/README.TXT (original)
+++ vmkit/branches/memory-monitor/README.TXT Thu Oct  9 03:43:38 2014
@@ -24,14 +24,14 @@ cd classpath-0.99
 ./configure --disable-plugin --disable-examples --disable-Werror --with-antlr-jar=/opt//local/share/java/antlr.jar
 make -j12
 cd lib
-ln -s ../native/jni/gtk-peer/.libs/libgtkpeer.dylib;
-ln -s ../native/jni/gconf-peer/.libs/libgconfpeer.dylib;
-ln -s ../native/jni/java-io/.libs/libjavaio.dylib;
-ln -s ../native/jni/java-lang/.libs/libjavalangreflect.dylib;
-ln -s ../native/jni/java-lang/.libs/libjavalang.dylib;
-ln -s ../native/jni/java-net/.libs/libjavanet.dylib;
-ln -s ../native/jni/java-nio/.libs/libjavanio.dylib;
-ln -s ../native/jni/java-util/.libs/libjavautil.dylib;
+ln -s ../native/jni/gtk-peer/.libs/libgtkpeer.so;
+ln -s ../native/jni/gconf-peer/.libs/libgconfpeer.so;
+ln -s ../native/jni/java-io/.libs/libjavaio.so;
+ln -s ../native/jni/java-lang/.libs/libjavalangreflect.so;
+ln -s ../native/jni/java-lang/.libs/libjavalang.so;
+ln -s ../native/jni/java-net/.libs/libjavanet.so;
+ln -s ../native/jni/java-nio/.libs/libjavanio.so;
+ln -s ../native/jni/java-util/.libs/libjavautil.so;
 
 * For Linux users:
 wget http://ftp.gnu.org/gnu/classpath/classpath-0.99.tar.gz
@@ -80,8 +80,8 @@ NOTICE:
 
 * Make it (release mode):
 
-./configure --enable-optimized --enable-assertions --enable-jit --enable-cxx11 --enable-threads --enable-pthreads --enable-pic --enable-targets=host,cpp --enable-zlib --disable-docs --disable-doxygen
-make -j12 BUILD_EXAMPLES=0 ENABLE_DOCS=0
+./configure --enable-optimized --enable-assertions --enable-jit --enable-cxx11 --enable-libcpp --enable-threads --enable-pthreads --enable-pic --enable-targets=host,cpp --enable-zlib --disable-docs --disable-doxygen
+make -j12
 
 * You can also make it in debug mode, but this is is not necessary to debug compiled programs:
 
@@ -105,15 +105,15 @@ svn co https://YOUR_USER_NAME@llvm.org/s
 
 * Make it (release mode):
 
-./configure --with-llvm-config-path=@PATH_TO_LLVM@/Release+Asserts/bin/llvm-config --with-gnu-classpath-libs=@PATH_TO_GNUCLASSPATH@/lib --with-gnu-classpath-glibj=@PATH_TO_GNUCLASSPATH@/lib/glibj.zip
+./configure --with-llvm-config-path=@PATH_TO_LLVM@/Release+Asserts/bin/llvm-config --with-clang-path=@PATH_TO_LLVM@/Release+Asserts/bin --with-gnu-classpath-libs=@PATH_TO_GNUCLASSPATH@/lib --with-gnu-classpath-glibj=@PATH_TO_GNUCLASSPATH@/lib/glibj.zip
 
 * Or you can make it in debug mode:
 
-./configure --with-llvm-config-path=@PATH_TO_LLVM@/Release+Asserts/bin/llvm-config --with-gnu-classpath-libs=@PATH_TO_GNUCLASSPATH@/lib --with-gnu-classpath-glibj=@PATH_TO_GNUCLASSPATH@/lib/glibj.zip --enable-assert=yes --disable-optimized --enable-debug=yes
+./configure --with-llvm-config-path=@PATH_TO_LLVM@/Release+Asserts/bin/llvm-config --with-clang-path=@PATH_TO_LLVM@/Release+Asserts/bin --with-gnu-classpath-libs=@PATH_TO_GNUCLASSPATH@/lib --with-gnu-classpath-glibj=@PATH_TO_GNUCLASSPATH@/lib/glibj.zip --enable-assert=yes --disable-optimized --enable-debug=yes
 
 * Or you can enable OSGi Incinerator build:
 
-./configure --with-llvm-config-path=@PATH_TO_LLVM@/Release+Asserts/bin/llvm-config --with-gnu-classpath-libs=@PATH_TO_GNUCLASSPATH@/lib --with-gnu-classpath-glibj=@PATH_TO_GNUCLASSPATH@/lib/glibj.zip --enable-incinerator=yes
+./configure --with-llvm-config-path=@PATH_TO_LLVM@/Release+Asserts/bin/llvm-config --with-clang-path=@PATH_TO_LLVM@/Release+Asserts/bin --with-gnu-classpath-libs=@PATH_TO_GNUCLASSPATH@/lib --with-gnu-classpath-glibj=@PATH_TO_GNUCLASSPATH@/lib/glibj.zip --enable-incinerator=yes
 
 * Build it:
 

Modified: vmkit/branches/memory-monitor/include/debug.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/debug.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/debug.h (original)
+++ vmkit/branches/memory-monitor/include/debug.h Thu Oct  9 03:43:38 2014
@@ -27,7 +27,7 @@
 #define _BOLD "01"
 #define _SOULIGNE "04"
 
-#define MK_COLOR(type, bg) type";"bg
+#define MK_COLOR(type, bg) type";" bg
 
 /*
 #define MK_COLOR(type, bg, fg) type";"bg";"fg

Modified: vmkit/branches/memory-monitor/include/j3/J3Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/j3/J3Intrinsics.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/j3/J3Intrinsics.h (original)
+++ vmkit/branches/memory-monitor/include/j3/J3Intrinsics.h Thu Oct  9 03:43:38 2014
@@ -45,10 +45,19 @@ public:
   llvm::Type* JavaMethodType;
   llvm::Type* JavaFieldType;
   llvm::Type* AttributeType;
+  llvm::Type* ThreadType;
   llvm::Type* JavaThreadType;
   llvm::Type* MutatorThreadType;
   llvm::Type* J3DenseMapType;
-  
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  llvm::Type* TierIDType;
+#endif
+
+#if EMBEDDED_LIST_IN_CALL_STACK
+  llvm::Type* StackEmbeddedListNodeType;
+#endif
+
   llvm::Function* VTAllocateFunction;
   llvm::Function* VTAllocateUnresolvedFunction;
 
@@ -109,6 +118,16 @@ public:
   llvm::Function* GetFinalFloatFieldFunction;
   llvm::Function* GetFinalDoubleFieldFunction;
   
+#if JAVA_CHARGED_TIER_CALL_STACK
+  llvm::Function* PushChargedTierNodeFunction;
+  llvm::Function* PopChargedTierNodeFunction;
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  llvm::Constant* InvalidTierIDConstant;
+  llvm::Constant* OffsetChargedTierIDInThreadConstant;
+#endif
+
   llvm::Constant* JavaArraySizeOffsetConstant;
   llvm::Constant* JavaArrayElementsOffsetConstant;
   llvm::Constant* HeaderObjectLockOffsetConstant;
@@ -131,6 +150,15 @@ public:
   llvm::Constant* OffsetJNIInJavaThreadConstant;
   llvm::Constant* OffsetJavaExceptionInJavaThreadConstant;
 
+#if EMBEDDED_LIST_IN_CALL_STACK
+  llvm::Constant* OffsetStackEmbeddedListHeadInThreadConstant;
+
+  llvm::Constant* OffsetCallerNodeInStackEmbeddedListNodeConstant;
+  llvm::Constant* OffsetDataInStackEmbeddedListNodeConstant;
+#endif
+
+  llvm::Constant* constantNullJavaMethodPtr;
+
   llvm::Constant* OffsetClassInVTConstant;
   llvm::Constant* OffsetDepthInVTConstant;
   llvm::Constant* OffsetDisplayInVTConstant;
@@ -140,12 +168,18 @@ public:
   llvm::Constant* OffsetBaseClassInArrayClassConstant;
   llvm::Constant* OffsetLogSizeInPrimitiveClassConstant;
   
+  llvm::Constant* OffsetOffsetInJavaMethodConstant;
+
   llvm::Constant* ClassReadyConstant;
 
   llvm::Constant* JavaObjectNullConstant;
   llvm::Constant* MaxArraySizeConstant;
   llvm::Constant* JavaArraySizeConstant;
 
+#if MONITOR_CREATED_OBJECTS_COUNT
+  llvm::Constant* OffsetTotalCalledMethodsCounterInThread;
+#endif
+
   llvm::Function* ThrowExceptionFunction;
   llvm::Function* NullPointerExceptionFunction;
   llvm::Function* IndexOutOfBoundsExceptionFunction;

Modified: vmkit/branches/memory-monitor/include/vmkit/GC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/GC.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/GC.h (original)
+++ vmkit/branches/memory-monitor/include/vmkit/GC.h Thu Oct  9 03:43:38 2014
@@ -16,17 +16,63 @@
 
 class gc;
 
+#if OSGI_OBJECT_TIER_TAGGING
+
+/*
+	TierID bits = y xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
+	y: marked bit, used to avoid counting one object twice
+	x...x: unsigned integer identifier
+*/
+
+#endif
+
 class gcHeader {
 public:
 	word_t _header;
+
+#if OSGI_OBJECT_TIER_TAGGING
+	typedef uint16_t	TierIDType;		// 16-bits wide tag
+	static const uint16_t TierIDBitMask_Mark = 0x8000, TierIDBitMask_ID = 0x7FFF;
+
+	TierIDType _tier_id;
+#endif
+
 	inline gc* toReference() { return (gc*)((uintptr_t)this + hiddenHeaderSize()); }
 	static inline size_t hiddenHeaderSize() { return sizeof(gcHeader); }
 };
 
 class gcRoot {
 public:
-  word_t& header(){return toHeader()->_header; }
-  inline gcHeader* toHeader() { return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); }
+#if OSGI_OBJECT_TIER_TAGGING
+  inline gcHeader::TierIDType getTierID() const {
+	  return (toHeader()->_tier_id & gcHeader::TierIDBitMask_ID);}
+
+  inline void setTierID(gcHeader::TierIDType tierID)
+  {
+	  gcHeader::TierIDType& tid = toHeader()->_tier_id;
+	  tid &= gcHeader::TierIDBitMask_Mark;
+	  tid |= (tierID & gcHeader::TierIDBitMask_ID);
+  }
+
+  inline bool getTierObjectMarkState() const {
+	  return ((toHeader()->_tier_id & gcHeader::TierIDBitMask_Mark) != 0);}
+
+  inline void setTierObjectMarkState(bool markState)
+  {
+	  gcHeader::TierIDType& tid = toHeader()->_tier_id;
+	  if (markState)
+		  tid |= gcHeader::TierIDBitMask_Mark;
+	  else
+		  tid &= ~gcHeader::TierIDBitMask_Mark;
+  }
+#endif
+
+  inline       word_t& header()       {return toHeader()->_header; }
+  inline const word_t& header() const {return const_cast<gcRoot*>(this)->header(); }
+
+  inline       gcHeader* toHeader()       {
+      return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); }
+  inline const gcHeader* toHeader() const {return const_cast<gcRoot*>(this)->toHeader(); }
 };
 
 namespace vmkit {

Added: vmkit/branches/memory-monitor/include/vmkit/StackEmbeddedList.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/StackEmbeddedList.h?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/StackEmbeddedList.h (added)
+++ vmkit/branches/memory-monitor/include/vmkit/StackEmbeddedList.h Thu Oct  9 03:43:38 2014
@@ -0,0 +1,63 @@
+
+#ifndef STACK_EMBEDDED_LIST_H_
+#define STACK_EMBEDDED_LIST_H_
+
+#include "vmkit/System.h"
+#include "vmkit/StackWalker.h"
+
+#include <list>
+
+#if EMBEDDED_LIST_IN_CALL_STACK
+
+namespace vmkit {
+
+class Thread;
+
+enum StackEmbeddedListID {
+	StackEmbeddedListChargedTier = 0,
+
+	StackEmbeddedListNodeCountPerThread
+};
+
+struct StackEmbeddedListNode {
+	StackEmbeddedListNode*	callerNode;
+	word_t					data[1];
+
+	void dump() const __attribute__((noinline));
+};
+
+}
+
+/*
+class StackEmbeddedListWalker
+{
+protected:
+	const StackEmbeddedListNode*	_current_node;
+	StackWalker						_stack_walker;
+	std::list<StackWalker>			_walked_stack;
+
+public:
+	StackEmbeddedListWalker(Thread* thread) :
+		_current_node(nullptr), _stack_walker(thread) {}
+	virtual ~StackEmbeddedListWalker() {}
+
+	bool findStackFrameOfEmbeddedNode();
+	bool next();
+
+	StackWalker& getStackWalker() {return _stack_walker;}
+	uint32_t getChargedTierID() const {
+		return (!_current_node)
+			? 0 : reinterpret_cast<uint32_t>(_current_node->data[0]);
+	}
+};
+
+extern "C" void pushChargedTierNode(vmkit::Thread* thread,
+	vmkit::StackEmbeddedListNode* node);
+
+extern "C" void popChargedTierNode(vmkit::Thread* thread,
+	vmkit::StackEmbeddedListNode* node);
+*/
+
+#endif
+
+#endif

Added: vmkit/branches/memory-monitor/include/vmkit/StackWalker.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/StackWalker.h?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/StackWalker.h (added)
+++ vmkit/branches/memory-monitor/include/vmkit/StackWalker.h Thu Oct  9 03:43:38 2014
@@ -0,0 +1,36 @@
+
+#ifndef _VMKIT_STACK_WALKER_H_
+#define _VMKIT_STACK_WALKER_H_
+
+namespace vmkit {
+
+class Thread;
+class KnownFrame;
+class FrameInfo;
+
+/// StackWalker - This class walks the stack of threads, returning a FrameInfo
+/// object at each iteration.
+///
+class StackWalker
+{
+public:
+  word_t callFrameAddress;
+  word_t returnAddress;
+  KnownFrame* frame;
+  Thread* thread;
+
+  StackWalker() __attribute__ ((noinline));
+  StackWalker(Thread* th) __attribute__ ((noinline));
+  void operator++();
+  word_t operator*();
+  FrameInfo* get();
+
+  FrameInfo* getNextFrameWithMetadata();
+  FrameInfo* getNextFrameWithMetadata(size_t& totalFrameSizeWithoutMetadata);
+  FrameInfo* getNextFrameWithMetadata(
+    word_t& callFrameAddress, word_t& returnAddress, KnownFrame*& frame);
+};
+
+}
+
+#endif

Modified: vmkit/branches/memory-monitor/include/vmkit/System.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/System.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/System.h (original)
+++ vmkit/branches/memory-monitor/include/vmkit/System.h Thu Oct  9 03:43:38 2014
@@ -17,6 +17,12 @@
 #include <stdint.h>
 #include <unistd.h>
 
+#include "vmkit/config.h"
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+extern "C" void Jnjvm_dumpGlobalStats();
+#endif
+
 #if defined(__linux__) || defined(__FreeBSD__)
 #define LINUX_OS 1
 #elif defined(__APPLE__)
@@ -94,11 +100,36 @@ const word_t kVmkitThreadMask = 0xF00000
 
 const word_t kGCMemorySize = 0x30000000;
 
+#if JAVA_CHARGED_TIER_CALL_STACK
+
+#define TRY {                                                       \
+	vmkit::Thread* __current_thread_ = vmkit::Thread::get();        \
+	vmkit::StackEmbeddedListNode* node = __current_thread_->        \
+		stackEmbeddedListHead[vmkit::StackEmbeddedListChargedTier]; \
+	vmkit::ExceptionBuffer __buffer__;                              \
+	if (!SETJMP(__buffer__.buffer))
+
+#define CATCH		else {  \
+	__current_thread_->     \
+		stackEmbeddedListHead[vmkit::StackEmbeddedListChargedTier] = node;
+
+#define IGNORE      else {                                                 \
+	__current_thread_->                                                    \
+		stackEmbeddedListHead[vmkit::StackEmbeddedListChargedTier] = node; \
+	__current_thread_->clearException();                                   \
+}}
+
+#define END_CATCH }}
+
+#else
+
 #define TRY { vmkit::ExceptionBuffer __buffer__; if (!SETJMP(__buffer__.buffer))
 #define CATCH else
 #define IGNORE else { vmkit::Thread::get()->clearException(); }}
 #define END_CATCH }
 
+#endif
+
 class System {
 public:
   static bool IsWordAligned(word_t ptr) {
@@ -148,7 +179,7 @@ public:
     return pagesize;
   }
 
-  static word_t GetCallerAddress() __attribute((always_inline)) {
+  static word_t GetCallFrameAddress() __attribute((always_inline)) {
 #if defined(ARCH_X86) || defined(ARCH_X64)
     return (word_t)__builtin_frame_address(0);
 #else
@@ -156,15 +187,15 @@ public:
 #endif
   }
 
-  static word_t GetCallerOfAddress(word_t addr) {
-    return ((word_t*)addr)[0];
+  static word_t GetCallerCallFrame(word_t currentCallFrame) {
+    return *(word_t*)currentCallFrame;
   }
 
-  static word_t GetIPFromCallerAddress(word_t addr) {
+  static word_t GetReturnAddressOfCallFrame(word_t currentCallFrame) {
 #if defined(MACOS_OS) && defined(ARCH_PPC)
-    return ((word_t*)addr)[2];
+    return ((word_t*)currentCallFrame)[2];
 #else
-    return ((word_t*)addr)[1];
+    return ((word_t*)currentCallFrame)[1];
 #endif
   }
 
@@ -233,7 +264,11 @@ public:
   }
 
   static void Exit(int value) {
-    _exit(value);
+#if MONITOR_CREATED_OBJECTS_COUNT
+  Jnjvm_dumpGlobalStats();
+#endif
+
+  _exit(value);
   }
 
   static bool SupportsHardwareNullCheck();

Modified: vmkit/branches/memory-monitor/include/vmkit/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/Thread.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/Thread.h (original)
+++ vmkit/branches/memory-monitor/include/vmkit/Thread.h Thu Oct  9 03:43:38 2014
@@ -18,7 +18,11 @@
 #include "types.h"
 
 #include "vmkit/System.h"
+#include "vmkit/StackWalker.h"
 
+#if EMBEDDED_LIST_IN_CALL_STACK
+#include "vmkit/StackEmbeddedList.h"
+#endif
 
 namespace vmkit {
 
@@ -117,6 +121,14 @@ public:
   Thread() {
     lastExceptionBuffer = 0;
     lastKnownFrame = 0;
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+    stackEmbeddedListHead[StackEmbeddedListChargedTier] = nullptr;
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+    total_called_methods_count = 0;
+#endif
   }
 
   /// yield - Yield the processor to another thread.
@@ -172,7 +184,7 @@ public:
   /// get - Get the thread specific data of the current thread.
   ///
   static Thread* get() {
-    return (Thread*)(System::GetCallerAddress() & System::GetThreadIDMask());
+    return (Thread*)(System::GetCallFrameAddress() & System::GetThreadIDMask());
   }
   
 private:
@@ -239,7 +251,7 @@ public:
   /// stackOverflow - Returns if there is a stack overflow in Java land.
   ///
   bool stackOverflow() {
-    return (System::GetCallerAddress() & StackOverflowMask) == 0;
+    return (System::GetCallFrameAddress() & StackOverflowMask) == 0;
   }
 
   /// operator new - Allocate the Thread object as well as the stack for this
@@ -276,6 +288,25 @@ public:
   ///
   ExceptionBuffer* lastExceptionBuffer;
 
+#if JAVA_CHARGED_TIER_CALL_STACK
+  uint32_t	chargedTierID;
+#else
+  uint32_t	unused_1;
+#endif
+
+#if EMBEDDED_LIST_IN_CALL_STACK
+  StackEmbeddedListNode*
+    stackEmbeddedListHead[StackEmbeddedListNodeCountPerThread];
+#else
+  void*	unused_2[1];
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  uint64_t total_called_methods_count;
+#else
+  uint64_t unused_3;
+#endif
+
   void internalThrowException();
 
   void startKnownFrame(KnownFrame& F) __attribute__ ((noinline));
@@ -326,23 +357,6 @@ public:
   ExceptionBuffer* previousBuffer;
 };
 
-/// StackWalker - This class walks the stack of threads, returning a FrameInfo
-/// object at each iteration.
-///
-class StackWalker {
-public:
-  word_t addr;
-  word_t ip;
-  KnownFrame* frame;
-  vmkit::Thread* thread;
-
-  StackWalker(vmkit::Thread* th) __attribute__ ((noinline));
-  void operator++();
-  word_t operator*();
-  FrameInfo* get();
-
-};
-
 
 } // end namespace vmkit
 #endif // VMKIT_THREAD_H

Modified: vmkit/branches/memory-monitor/include/vmkit/UTF8.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/UTF8.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/UTF8.h (original)
+++ vmkit/branches/memory-monitor/include/vmkit/UTF8.h Thu Oct  9 03:43:38 2014
@@ -12,6 +12,25 @@ namespace vmkit {
 
 class UTF8Map;
 
+template<class T1, class T2>
+int compare_null_terminated_arrays(const T1* array1, size_t size1, const T2* array2, size_t size2)
+{
+	// NULL array is treated as empty
+	if (!array1) size1 = 0;
+	if (!array2) size2 = 0;
+
+	// Compute real sizes, excluding null terminators
+	for (; (size1 != 0) && (array1[size1 - 1] == 0); --size1);
+	for (; (size2 != 0) && (array2[size2 - 1] == 0); --size2);
+
+	int diff = size1 - size2;	// Compare sizes
+	if (diff == 0) {	// Equal sizes, compare contents
+		for (; (size1 != 0) && (diff == 0); --size1, ++array1, ++array2)
+			diff = *array1 - *array2;
+	}
+	return diff;
+}
+
 class UTF8 {
   friend class UTF8Map;
 private:
@@ -36,8 +55,7 @@ public:
   /// equals - Are the two UTF8s equal?
   bool equals(const UTF8* other) const {
     if (other == this) return true;
-    else if (size != other->size) return false;
-    else return !memcmp(elements, other->elements, size * sizeof(uint16));
+    return (*this) == (*other);
   }
   
   /// equals - Does the UTF8 equal to the buffer? 
@@ -47,12 +65,8 @@ public:
   }
 
   /// lessThan - strcmp-like function for UTF8s, used by hash tables.
-  bool lessThan(const UTF8* other) const {
-    if (size < other->size) return true;
-    else if (size > other->size) return false;
-    else return memcmp((const char*)elements, (const char*)other->elements, 
-                       size * sizeof(uint16)) < 0;
-  }
+  bool lessThan(const UTF8* other) const
+    { return (*this) < (*other); }
 
 	static uint32_t readerHasher(const uint16* buf, sint32 size);
 	
@@ -64,9 +78,26 @@ public:
     size = n;
   }
 
+  friend bool operator < (const UTF8& str1, const UTF8& str2) {
+    return UTF8::compare(&str1, &str2) < 0;
+  }
+  friend bool operator == (const UTF8& str1, const UTF8& str2) {
+    return UTF8::compare(&str1, &str2) == 0;
+  }
   friend std::ostream& operator << (std::ostream&, const UTF8&);
+
   void dump() const __attribute__((noinline));
-  int compare(const char *) const;
+  int compare(const char *str, int length = -1) const {
+    return compare_null_terminated_arrays(
+      elements, size, str, (length == -1) ? strlen(str) : length);
+  }
+  int compare(const UTF8& str) const {return UTF8::compare(this, &str);}
+  static int compare(const UTF8* str1, const UTF8* str2) {
+    if (!str1 && !str2) return 0;
+    return compare_null_terminated_arrays(
+    	(!str1 ? NULL : str1->elements), (!str1 ? 0 : str1->size),
+    	(!str2 ? NULL : str2->elements), (!str2 ? 0 : str2->size));
+  }
   std::string& toString(std::string& buffer) const;
 };
 
@@ -83,6 +114,13 @@ struct UTF8MapKey {
   }
 };
 
+class UTF8_Comparator {
+public:
+	bool operator() (const UTF8* str1, const UTF8* str2) const {
+		return (*str1) < (*str2);
+	}
+};
+
 // Provide VmkitDenseMapInfo for UTF8.
 template<>
 struct VmkitDenseMapInfo<const UTF8*> {

Modified: vmkit/branches/memory-monitor/include/vmkit/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/VirtualMachine.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/VirtualMachine.h (original)
+++ vmkit/branches/memory-monitor/include/vmkit/VirtualMachine.h Thu Oct  9 03:43:38 2014
@@ -19,9 +19,6 @@
 #include "vmkit/Locks.h"
 #include "vmkit/GC.h"
 
-#include <cassert>
-#include <map>
-
 namespace vmkit {
 
 class CompiledFrames;
@@ -104,7 +101,7 @@ public:
 
   /// doExit - Should the VM exit now?
   bool doExit;
-  
+
   /// setMainThread - Set the main thread of this VM.
   ///
   void setMainThread(vmkit::Thread* th) { mainThread = th; }

Added: vmkit/branches/memory-monitor/include/vmkit/config.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/config.h?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/config.h (added)
+++ vmkit/branches/memory-monitor/include/vmkit/config.h Thu Oct  9 03:43:38 2014
@@ -0,0 +1,9 @@
+/* include/vmkit/config.h.  Generated from config.h.in by configure.  */
+#define OSGI_OBJECT_TIER_TAGGING            1
+#define OSGI_BUNDLE_STATE_INFO              1
+#define EMBEDDED_LIST_IN_CALL_STACK         1
+#define JAVA_CHARGED_TIER_CALL_STACK        1
+#define OSGI_BUNDLE_TIER_TAGGING            1
+#define OSGI_STACK_SPACE_TIER_TAGGING       1
+#define EMBEDDED_LIST_UPDATE                1
+#define MONITOR_CREATED_OBJECTS_COUNT       0

Modified: vmkit/branches/memory-monitor/include/vmkit/config.h.in
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/config.h.in?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/config.h.in (original)
+++ vmkit/branches/memory-monitor/include/vmkit/config.h.in Thu Oct  9 03:43:38 2014
@@ -0,0 +1,8 @@
+#define OSGI_OBJECT_TIER_TAGGING            0
+#define OSGI_BUNDLE_STATE_INFO              0
+#define EMBEDDED_LIST_IN_CALL_STACK         0
+#define JAVA_CHARGED_TIER_CALL_STACK        0
+#define OSGI_BUNDLE_TIER_TAGGING            0
+#define OSGI_STACK_SPACE_TIER_TAGGING       0
+#define EMBEDDED_LIST_UPDATE                0
+#define MONITOR_CREATED_OBJECTS_COUNT       0

Removed: vmkit/branches/memory-monitor/include/vmkit/config.h.in.orig
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/include/vmkit/config.h.in.orig?rev=219391&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/include/vmkit/config.h.in.orig (original)
+++ vmkit/branches/memory-monitor/include/vmkit/config.h.in.orig (removed)
@@ -1,79 +0,0 @@
-/* include/vmkit/config.h.in.  Generated from autoconf/configure.ac by autoheader.  */
-
-/* Define to 1 if the system has the type `int64_t'. */
-#undef HAVE_INT64_T
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `z' library (-lz). */
-#undef HAVE_LIBZ
-
-/* Define to 1 if you have the `longjmp' function. */
-#undef HAVE_LONGJMP
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the `setjmp' function. */
-#undef HAVE_SETJMP
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if the system has the type `uint64_t'. */
-#undef HAVE_UINT64_T
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if the system has the type `u_int64_t'. */
-#undef HAVE_U_INT64_T
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
-#undef TM_IN_SYS_TIME
-
-/* Building on a platform with 64bit cas */
-#undef WITH_64
-
-/* Define to `int' if <sys/types.h> does not define. */
-#undef pid_t
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#undef size_t

Modified: vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/ClasspathVMMethod.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/ClasspathVMMethod.inc?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/ClasspathVMMethod.inc (original)
+++ vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/ClasspathVMMethod.inc Thu Oct  9 03:43:38 2014
@@ -289,6 +289,7 @@ JavaObject* proceedVMMethod(JavaObjectVM
 
   Jnjvm* vm = JavaThread::get()->getJVM();
   JavaMethod* meth = JavaObjectVMMethod::getInternalMethod(Meth);
+
   UserCommonClass* _cl =  (UserCommonClass*)JavaObjectVMMethod::getClass(Meth);
 
   sint32 nbArgs = args ? ArrayObject::getSize(args) : 0;

Modified: vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp Thu Oct  9 03:43:38 2014
@@ -206,6 +206,7 @@ JavaMethod* Classpath::InitArithmeticExc
 JavaMethod* Classpath::InitCloneNotSupportedException;
 JavaMethod* Classpath::InitObject;
 JavaMethod* Classpath::FinalizeObject;
+JavaMethod* Classpath::toString;
 JavaMethod* Classpath::IntToString;
 
 JavaMethod* Classpath::SystemArraycopy;
@@ -905,6 +906,9 @@ void Classpath::initialiseClasspath(Jnjv
   
   FinalizeObject = UPCALL_METHOD(loader, "java/lang/Object", "finalize", "()V",
                                  ACC_VIRTUAL);
+
+  toString = UPCALL_METHOD(loader, "java/lang/Object", "toString",
+          "()Ljava/lang/String;", ACC_VIRTUAL);
   
   IntToString = UPCALL_METHOD(loader, "java/lang/Integer", "toString",
                               "(II)Ljava/lang/String;", ACC_STATIC);

Modified: vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h Thu Oct  9 03:43:38 2014
@@ -251,6 +251,7 @@ public:
 
   ISOLATE_STATIC JavaMethod* InitObject;
   ISOLATE_STATIC JavaMethod* FinalizeObject;
+  ISOLATE_STATIC JavaMethod* toString;
 
   ISOLATE_STATIC JavaMethod* ErrorWithExcpNoClassDefFoundError;
   ISOLATE_STATIC JavaMethod* ErrorWithExcpExceptionInInitializerError;

Modified: vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp Thu Oct  9 03:43:38 2014
@@ -197,6 +197,7 @@ JavaMethod* Classpath::InitArithmeticExc
 JavaMethod* Classpath::InitCloneNotSupportedException;
 JavaMethod* Classpath::InitObject;
 JavaMethod* Classpath::FinalizeObject;
+JavaMethod* Classpath::toString;
 JavaMethod* Classpath::IntToString;
 
 JavaMethod* Classpath::SystemArraycopy;
@@ -787,6 +788,9 @@ void Classpath::initialiseClasspath(Jnjv
   FinalizeObject = UPCALL_METHOD(loader, "java/lang/Object", "finalize", "()V",
                                  ACC_VIRTUAL);
 
+  toString = UPCALL_METHOD(loader, "java/lang/Object", "toString",
+          "()Ljava/lang/String;", ACC_VIRTUAL);
+
   IntToString = UPCALL_METHOD(loader, "java/lang/Integer", "toString",
                               "(II)Ljava/lang/String;", ACC_STATIC);
 

Modified: vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h Thu Oct  9 03:43:38 2014
@@ -240,6 +240,7 @@ public:
 
   ISOLATE_STATIC JavaMethod* InitObject;
   ISOLATE_STATIC JavaMethod* FinalizeObject;
+  ISOLATE_STATIC JavaMethod* toString;
 
   ISOLATE_STATIC JavaMethod* ErrorWithExcpNoClassDefFoundError;
   ISOLATE_STATIC JavaMethod* ErrorWithExcpExceptionInInitializerError;

Modified: vmkit/branches/memory-monitor/lib/j3/Compiler/J3Intrinsics.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/Compiler/J3Intrinsics.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/Compiler/J3Intrinsics.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/Compiler/J3Intrinsics.cpp Thu Oct  9 03:43:38 2014
@@ -25,6 +25,7 @@
 using namespace j3;
 using namespace llvm;
 
+
 namespace j3 { 
   namespace llvm_runtime { 
     #include "LLVMRuntime.inc"
@@ -47,6 +48,9 @@ void J3Intrinsics::init(llvm::Module* mo
 
   ResolvedConstantPoolType = ptrPtrType;
  
+#if OSGI_BUNDLE_TIER_TAGGING
+  TierIDType = IntegerType::getInt32Ty(Context);
+#endif
 
   ObjectHeaderType = PointerType::getUnqual(module->getPointerSize() == Module::Pointer32 ?
   		    Type::getInt32Ty(Context) : Type::getInt64Ty(Context));
@@ -99,15 +103,21 @@ void J3Intrinsics::init(llvm::Module* mo
     PointerType::getUnqual(module->getTypeByName("UTF8"));
   AttributeType =
     PointerType::getUnqual(module->getTypeByName("Attribute"));
+  ThreadType =
+    PointerType::getUnqual(module->getTypeByName("Thread"));
   JavaThreadType =
     PointerType::getUnqual(module->getTypeByName("JavaThread"));
   MutatorThreadType =
     PointerType::getUnqual(module->getTypeByName("MutatorThread"));
   
+#if EMBEDDED_LIST_IN_CALL_STACK
+  StackEmbeddedListNodeType =
+    PointerType::getUnqual(module->getTypeByName("StackEmbeddedListNode"));
+#endif
+
   J3DenseMapType =
     PointerType::getUnqual(module->getTypeByName("J3DenseMap"));
-  
-  
+
   JavaObjectNullConstant =
     Constant::getNullValue(J3Intrinsics::JavaObjectType);
   MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(Context),
@@ -125,6 +135,9 @@ void J3Intrinsics::init(llvm::Module* mo
 
   JavaObjectVTOffsetConstant = constantZero;
 
+#if OSGI_BUNDLE_TIER_TAGGING
+  InvalidTierIDConstant = constantMinusOne;
+#endif
 
   OffsetClassInVTConstant =
     ConstantInt::get(Type::getInt32Ty(Context),
@@ -152,6 +165,16 @@ void J3Intrinsics::init(llvm::Module* mo
   OffsetBaseClassInArrayClassConstant = constantOne;
   OffsetLogSizeInPrimitiveClassConstant = constantOne;
 
+  OffsetOffsetInJavaMethodConstant = ConstantInt::get(Type::getInt32Ty(Context), 9);
+
+#if EMBEDDED_LIST_IN_CALL_STACK
+  OffsetCallerNodeInStackEmbeddedListNodeConstant	= constantZero;
+  OffsetDataInStackEmbeddedListNodeConstant			= constantOne;
+  OffsetStackEmbeddedListHeadInThreadConstant =	ConstantInt::get(Type::getInt32Ty(Context), 13);
+#endif
+
+  constantNullJavaMethodPtr = Constant::getNullValue(this->JavaMethodType);
+
   OffsetObjectSizeInClassConstant = constantOne;
   OffsetVTInClassConstant = ConstantInt::get(Type::getInt32Ty(Context), 7);
   OffsetTaskClassMirrorInClassConstant = constantThree;
@@ -166,6 +189,10 @@ void J3Intrinsics::init(llvm::Module* mo
   OffsetJNIInJavaThreadConstant =           ConstantInt::get(Type::getInt32Ty(Context), 1);
   OffsetJavaExceptionInJavaThreadConstant = ConstantInt::get(Type::getInt32Ty(Context), 2);
 
+#if OSGI_BUNDLE_TIER_TAGGING
+  OffsetChargedTierIDInThreadConstant =     	ConstantInt::get(Type::getInt32Ty(Context), 12);
+#endif
+
   ClassReadyConstant = ConstantInt::get(Type::getInt8Ty(Context), ready);
   
   InterfaceLookupFunction = module->getFunction("j3InterfaceLookup");
@@ -246,5 +273,15 @@ void J3Intrinsics::init(llvm::Module* mo
   GetLockFunction = module->getFunction("getLock");
   ThrowExceptionFromJITFunction =
     module->getFunction("j3ThrowExceptionFromJIT"); 
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+  PushChargedTierNodeFunction	= module->getFunction("pushChargedTierNode");
+  PopChargedTierNodeFunction	= module->getFunction("popChargedTierNode");
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  OffsetTotalCalledMethodsCounterInThread =
+    ConstantInt::get(Type::getInt32Ty(Context), 14);
+#endif
 }
 

Modified: vmkit/branches/memory-monitor/lib/j3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/Compiler/JavaAOTCompiler.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/Compiler/JavaAOTCompiler.cpp Thu Oct  9 03:43:38 2014
@@ -2143,7 +2143,8 @@ void mainCompilerStart(JavaThread* th) {
 
   JavaJITCompiler* Comp = NULL;
   if (!M->clinits->empty()) {
-    Comp = JavaJITCompiler::CreateCompiler("JIT");
+    Comp = JavaJITCompiler::CreateCompiler(
+      "JIT", M->isCompilingGarbageCollector());
     Comp->EmitFunctionName = true;
     if (!M->useCooperativeGC()) {
       Comp->disableCooperativeGC();

Modified: vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.cpp Thu Oct  9 03:43:38 2014
@@ -15,6 +15,7 @@
 #include <string>
 #include <sstream>
 #include <cstring>
+#include <cstdarg>
 
 #include <llvm/IR/Constants.h>
 #include <llvm/IR/DerivedTypes.h>
@@ -47,6 +48,59 @@ using namespace j3;
 using namespace llvm;
 using namespace std;
 
+#if MONITOR_CREATED_OBJECTS_COUNT
+
+void JavaJIT::incrementTotalCalledMethodsCounter()
+{
+	if (TheCompiler->isCompilingGarbageCollector()) return;
+
+	auto TotalCalledMethodsCountPtr = getElementPtr(
+		"TotalCalledMethodsCountPtr", getThreadPtr(), intrinsics->constantZero,
+		intrinsics->OffsetTotalCalledMethodsCounterInThread, nullptr);
+
+	auto value_type =
+		TotalCalledMethodsCountPtr->getType()->getPointerElementType();
+	auto ui64_one = ConstantInt::get(value_type, 1);
+	auto old_val = new LoadInst(TotalCalledMethodsCountPtr,
+		"TotalCalledMethodsCountOldValue", currentBlock);
+	auto new_val = BinaryOperator::CreateAdd(old_val, ui64_one,
+		"TotalCalledMethodsCounterNewValue", currentBlock);
+	new StoreInst(new_val, TotalCalledMethodsCountPtr, currentBlock);
+}
+
+#endif
+
+Value* JavaJIT::allocateOnStack(
+	const char* name, size_t byteCount, Type* realType)
+{
+	std::string bufferName(name);
+	bufferName += "Buffer";
+
+	auto wordCount = ConstantInt::get(
+		Type::getInt32Ty(*llvmContext),
+		vmkit::System::WordAlignUp(byteCount) / sizeof(void*));
+
+	auto buffer = new AllocaInst(intrinsics->ptrType,
+		wordCount, sizeof(void*), bufferName, currentBlock);
+	return new BitCastInst(buffer, realType, name, currentBlock);
+}
+
+Value* JavaJIT::getElementPtr(
+	const char *name, Value* element, Value* firstIndex, ...)
+{
+	std::vector<Value*> indexList;
+	indexList.push_back(firstIndex);
+
+	va_list argList;
+	Value* arg;
+	va_start(argList, firstIndex);
+	while ((arg = va_arg(argList, Value*)) != nullptr)
+		indexList.push_back(arg);
+	va_end(argList);
+
+	return GetElementPtrInst::Create(element, indexList, name, currentBlock);
+}
+
 void JavaJIT::updateStackInfo(Opinfo& info) {
   if (stackSize()) {
     if (!info.stack.size()) {
@@ -196,6 +250,10 @@ void JavaJIT::invokeVirtual(uint16 index
   FunctionType::param_iterator it  = virtualType->param_end();
   llvm::Type* retType = virtualType->getReturnType();
 
+#if OSGI_BUNDLE_TIER_TAGGING
+  calculateChargedTierIDForInvokeVirtual(index);
+#endif
+
   bool needsInit = false;
   if (canBeDirect && canBeInlined(meth, customized)) {
     makeArgs(it, index, args, signature->nbArguments + 1);
@@ -221,37 +279,47 @@ void JavaJIT::invokeVirtual(uint16 index
       indexes2[1] = Offset;
     } else {
       nullChecked = true;
-      GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(),
-                                              Type::getInt32Ty(*llvmContext),
-                                              false,
-                                              GlobalValue::ExternalLinkage,
-                                              intrinsics->constantZero, "");
-    
+      GlobalVariable* cachedMethodPtr = new GlobalVariable(
+        *llvmFunction->getParent(), intrinsics->JavaMethodType,
+        false, GlobalValue::ExternalLinkage,
+        intrinsics->constantNullJavaMethodPtr, "cachedMethodPtr");
+      Value* cachedMethod = new LoadInst(
+        cachedMethodPtr, "cachedMethod", false, currentBlock);
+
       BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual");
       BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual");
-      PHINode* node = PHINode::Create(Type::getInt32Ty(*llvmContext), 2, "",
-                                      endResolveVirtual);
-
-      Value* load = new LoadInst(GV, "", false, currentBlock);
-      Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load,
-                                 intrinsics->constantZero, "");
+      PHINode* methodPtr = PHINode::Create(
+        intrinsics->JavaMethodType, 2, "methodPtr", endResolveVirtual);
+      methodPtr->addIncoming(cachedMethod, currentBlock);
+
+      Value* test = new ICmpInst(
+        *currentBlock, ICmpInst::ICMP_EQ, cachedMethod,
+        intrinsics->constantNullJavaMethodPtr, "isCacheEmpty");
       BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock);
-      node->addIncoming(load, currentBlock);
+
       currentBlock = resolveVirtual;
       std::vector<Value*> Args;
       Args.push_back(TheCompiler->getNativeClass(compilingClass));
       Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index));
-      Args.push_back(GV);
+      Args.push_back(cachedMethodPtr);
       Value* targetObject = getTarget(signature);
-      targetObject = new LoadInst(targetObject, "", false, currentBlock);
+      targetObject = new LoadInst(
+        targetObject, "targetObject", false, currentBlock);
       if (!thisReference) JITVerifyNull(targetObject);
       Args.push_back(targetObject);
-      load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock);
-      node->addIncoming(load, currentBlock);
+      Value* calculatedMethodPtr = invoke(intrinsics->VirtualLookupFunction,
+        Args, "calculatedMethod", currentBlock);
+      methodPtr->addIncoming(calculatedMethodPtr, currentBlock);
+
       BranchInst::Create(endResolveVirtual, currentBlock);
       currentBlock = endResolveVirtual;
 
-      indexes2[1] = node;
+      Value* methodOffset = getElementPtr(
+        "methodOffsetPtr", methodPtr, intrinsics->constantZero,
+        intrinsics->OffsetOffsetInJavaMethodConstant, nullptr);
+      methodOffset = new LoadInst(methodOffset, "methodOffset", currentBlock);
+
+      indexes2[1] = methodOffset;
     }
 
     makeArgs(it, index, args, signature->nbArguments + 1);
@@ -287,22 +355,39 @@ void JavaJIT::invokeVirtual(uint16 index
       }
     }
   }
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  resetChargedTierID();
+#endif
 }
 
 llvm::Value* JavaJIT::getMutatorThreadPtr() {
-  Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress,
-                                     	intrinsics->constantZero, "", currentBlock);
-  Value* threadId = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "",
-                              			 currentBlock);
-  threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask,
-                                       "", currentBlock);
-  threadId = new IntToPtrInst(threadId, intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock);
+	return new BitCastInst(
+		getThreadPtr(), intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock);
+}
+
+llvm::Value* JavaJIT::getThreadPtr()
+{
+	if (!currentThreadPtr) {
+		Value* frameAddr = CallInst::Create(
+			intrinsics->llvm_frameaddress, intrinsics->constantZero,
+			"frameAddress", currentBlock);
+		Value* ptr = new PtrToIntInst(
+			frameAddr, intrinsics->pointerSizeType, "", currentBlock);
+		ptr = BinaryOperator::CreateAnd(
+			ptr, intrinsics->constantThreadIDMask, "", currentBlock);
+		ptr = new IntToPtrInst(
+			ptr, intrinsics->ThreadType, "threadPtr", currentBlock);
+
+		currentThreadPtr = ptr;
+	}
 
-  return threadId;
+	return currentThreadPtr;
 }
 
-llvm::Value* JavaJIT::getJavaThreadPtr(llvm::Value* mutatorThreadPtr) {
-  return new BitCastInst(mutatorThreadPtr, intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock);
+llvm::Value* JavaJIT::getJavaThreadPtr() {
+	return new BitCastInst(
+		getThreadPtr(), intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock);
 }
 
 llvm::Value* JavaJIT::getIsolateIDPtr(llvm::Value* mutatorThreadPtr) { 
@@ -420,7 +505,6 @@ llvm::Function* JavaJIT::nativeCompile(w
     return llvmFunction;
   }
   
-  
   Function* func = llvmFunction;
   if (j3) {
     Function* callee = Function::Create(llvmFunction->getFunctionType(),
@@ -429,6 +513,19 @@ llvm::Function* JavaJIT::nativeCompile(w
                                         llvmFunction->getParent());
     TheCompiler->setMethod(callee, (void*)natPtr, functionName);
     currentBlock = createBasicBlock("start");
+
+#if OSGI_BUNDLE_TIER_TAGGING
+    getThreadPtr();
+    allocateChargedTierID();
+    initializeChargedTierID();
+    calculateChargedTierIDForInvokeNative();
+    setChargedTierID();
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+    incrementTotalCalledMethodsCounter();
+#endif
+
     std::vector<Value*> args;
     for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end();
          i != e;
@@ -436,6 +533,11 @@ llvm::Function* JavaJIT::nativeCompile(w
       args.push_back(i);
     }
     Value* res = CallInst::Create(callee, args, "", currentBlock);
+
+#if OSGI_BUNDLE_TIER_TAGGING
+    restoreChargedTierID();
+#endif
+
     if (returnType != Type::getVoidTy(*llvmContext)) {
       ReturnInst::Create(*llvmContext, res, currentBlock);
     } else {
@@ -446,30 +548,37 @@ llvm::Function* JavaJIT::nativeCompile(w
 
   currentExceptionBlock = endExceptionBlock = 0;
   currentBlock = createBasicBlock("start");
-  endBlock = createBasicBlock("end block");
+  endBlock = createBasicBlock("endBlock");
   
+  getThreadPtr();
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+  allocateChargedTierID();
+#endif
+
   if (returnType != Type::getVoidTy(*llvmContext)) {
     endNode = PHINode::Create(returnType, 0, "", endBlock);
   }
   
   // Allocate currentLocalIndexNumber pointer
-  Value* temp = new AllocaInst(Type::getInt32Ty(*llvmContext), "",
-                               currentBlock);
+  Value* temp = new AllocaInst(
+	Type::getInt32Ty(*llvmContext), "currentLocalIndexNumber", currentBlock);
   new StoreInst(intrinsics->constantZero, temp, false, currentBlock);
   
   // Allocate oldCurrentLocalIndexNumber pointer
-  Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), "",
-                                  currentBlock);
+  Value* oldCLIN = new AllocaInst(
+	PointerType::getUnqual(Type::getInt32Ty(*llvmContext)),
+	"oldLocalIndexNumber", currentBlock);
   
   Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), sizeof(vmkit::KnownFrame));
-  Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock);
+  Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "knownFrame", currentBlock);
   
   uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); 
   std::vector<Value*> nativeArgs;
   nativeArgs.push_back(NULL); // Will contain the callee
   
   
-  Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+  Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr());
  
   jniEnv = new BitCastInst(jniEnv, intrinsics->ptrType, "", currentBlock);
 
@@ -487,10 +596,10 @@ llvm::Function* JavaJIT::nativeCompile(w
        index < nargs; ++i, ++index) {
     
     if (i->getType() == intrinsics->JavaObjectType) {
-      BasicBlock* BB = createBasicBlock("");
-      BasicBlock* NotZero = createBasicBlock("");
+      BasicBlock* BB = createBasicBlock("continue");
+      BasicBlock* NotZero = createBasicBlock("storeObjParamOnStack");
       Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType);
-      PHINode* node = PHINode::Create(Ty, 2, "", BB);
+      PHINode* node = PHINode::Create(Ty, 2, "stack_obj_param_", BB);
 
       Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i,
                                  intrinsics->JavaObjectNullConstant, "");
@@ -500,8 +609,9 @@ llvm::Function* JavaJIT::nativeCompile(w
 
       currentBlock = NotZero;
 
-      Instruction* temp = new AllocaInst(intrinsics->JavaObjectType, "",
-                                         func->begin()->getTerminator());
+      Instruction* temp = new AllocaInst(
+    	intrinsics->JavaObjectType, "nonNullObjParamOnStack",
+        func->begin()->getTerminator());
       if (i == func->arg_begin() && !stat) {
         this->thisObject = temp;
       }
@@ -529,11 +639,10 @@ llvm::Function* JavaJIT::nativeCompile(w
     }
   }
   
-  
   Instruction* ResultObject = 0;
   if (returnType == intrinsics->JavaObjectType) {
-    ResultObject = new AllocaInst(intrinsics->JavaObjectType, "",
-                                  func->begin()->begin());
+    ResultObject = new AllocaInst(
+    	intrinsics->JavaObjectType, "resultObjOnStack", func->begin()->begin());
     
     if (TheCompiler->useCooperativeGC()) {
       
@@ -549,14 +658,24 @@ llvm::Function* JavaJIT::nativeCompile(w
                     currentBlock);
     }
   }
-  
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  initializeChargedTierID();
+  calculateChargedTierIDForInvokeNative();
+  setChargedTierID();
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  incrementTotalCalledMethodsCounter();
+#endif
+
   Value* nativeFunc = TheCompiler->getNativeFunction(compilingMethod, (void*)natPtr);
   if (TheCompiler->isStaticCompiling()) {
     Value* Arg = TheCompiler->getMethodInClass(compilingMethod); 
     
     // If the global variable is null, then load it.
-    BasicBlock* unloadedBlock = createBasicBlock("");
-    BasicBlock* endBlock = createBasicBlock("");
+    BasicBlock* unloadedBlock = createBasicBlock("unloadedBlock");
+    BasicBlock* endBlock = createBasicBlock("endBlock");
     Value* test = new LoadInst(nativeFunc, "", currentBlock);
     Type* Ty = test->getType();
     PHINode* node = PHINode::Create(Ty, 2, "", endBlock);
@@ -595,7 +714,7 @@ llvm::Function* JavaJIT::nativeCompile(w
     Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType);
     Constant* C = Constant::getNullValue(Ty);
     Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, result, C, "");
-    BasicBlock* loadBlock = createBasicBlock("");
+    BasicBlock* loadBlock = createBasicBlock("loadBlock");
 
     endNode->addIncoming(intrinsics->JavaObjectNullConstant, currentBlock);
     BranchInst::Create(endBlock, loadBlock, cmp, currentBlock);
@@ -612,7 +731,6 @@ llvm::Function* JavaJIT::nativeCompile(w
   
   BranchInst::Create(endBlock, currentBlock);
 
-
   currentBlock = endBlock; 
  
   Value* Args2[1] = { oldCLIN };
@@ -623,21 +741,31 @@ llvm::Function* JavaJIT::nativeCompile(w
   if (isSynchro(compilingMethod->access))
     endSynchronize();
 
-  BasicBlock* ifNormal = createBasicBlock("");
-  BasicBlock* ifException = createBasicBlock("");
-  Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+  BasicBlock* ifNormal = createBasicBlock("ifNormal");
+  BasicBlock* ifException = createBasicBlock("ifException");
+  Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
   Value* obj = new LoadInst(javaExceptionPtr, "", currentBlock);
   Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, "");
   BranchInst::Create(ifException, ifNormal, test, currentBlock);
 
   currentBlock = ifException;
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  restoreChargedTierID();
+#endif
+
   // Clear exception.
   new StoreInst(intrinsics->JavaObjectNullConstant, javaExceptionPtr,
                 currentBlock);
   CallInst::Create(intrinsics->ThrowExceptionFunction, obj, "", currentBlock);
   new UnreachableInst(*llvmContext, currentBlock);
+
   currentBlock = ifNormal;
-  
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  restoreChargedTierID();
+#endif
+
   if (returnType != Type::getVoidTy(*llvmContext))
     ReturnInst::Create(*llvmContext, endNode, currentBlock);
   else
@@ -681,8 +809,8 @@ void JavaJIT::monitorEnter(Value* obj) {
   Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic,
                             lock, "");
   
-  BasicBlock* OK = createBasicBlock("synchronize passed");
-  BasicBlock* NotOK = createBasicBlock("synchronize did not pass");
+  BasicBlock* OK = createBasicBlock("synchronizePassed");
+  BasicBlock* NotOK = createBasicBlock("synchronizeDidNotPass");
 
   BranchInst::Create(OK, NotOK, cmp, currentBlock);
 
@@ -734,7 +862,7 @@ void JavaJIT::monitorExit(Value* obj) {
   Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic,
                             oldValMask, "");
   
-  BasicBlock* LockFreeCASFailed = createBasicBlock("Lock-Free CAS Failed");
+  BasicBlock* LockFreeCASFailed = createBasicBlock("LockFreeCASFailed");
 
   BranchInst::Create(EndBlock, LockFreeCASFailed, cmp, currentBlock);
 
@@ -1038,28 +1166,34 @@ llvm::Function* JavaJIT::javaCompile() {
     opcodeInfos[i].exceptionBlock = endExceptionBlock;
   }
 
+  getThreadPtr();
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+  allocateChargedTierID();
+#endif
+
   Instruction* returnValue = NULL;
   if (returnType == intrinsics->JavaObjectType &&
       TheCompiler->useCooperativeGC()) {
-    returnValue = new AllocaInst(intrinsics->JavaObjectType, "returnValue",
-                                 currentBlock);
-    Instruction* cast = 
-        new BitCastInst(returnValue, intrinsics->ptrPtrType, "", currentBlock);
+    returnValue = new AllocaInst(
+    	intrinsics->JavaObjectType, "returnValueStorage", currentBlock);
+    Instruction* cast = new BitCastInst(
+    	returnValue, intrinsics->ptrPtrType, "returnValue", currentBlock);
     Value* GCArgs[2] = { cast, intrinsics->constantPtrNull };
         
     CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, "", currentBlock);
   }
 
   for (int i = 0; i < maxLocals; i++) {
-    intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "int_%d", i), currentBlock));
+    intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_int_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, currentBlock);
-    doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "double_%d", i), currentBlock));
+    doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "local_double_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getDoubleTy(*llvmContext)), doubleLocals.back(), false, currentBlock);
-    longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "long_%d", i), currentBlock));
+    longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_long_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, currentBlock);
-    floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "float_%d", i), currentBlock));
+    floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "local_float_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, currentBlock);
-    objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "object_%d", i), currentBlock));
+    objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "local_object_%d", i), currentBlock));
     // The GCStrategy will already initialize the value.
     if (!TheCompiler->useCooperativeGC())
       new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, currentBlock);
@@ -1131,7 +1265,7 @@ llvm::Function* JavaJIT::javaCompile() {
 
   nbHandlers = readExceptionTable(reader, codeLen);
   if (nbHandlers != 0) {
-    jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "", currentBlock);
+    jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "exceptionSavePointStorage", currentBlock);
     jmpBuffer = new BitCastInst(jmpBuffer, intrinsics->ptrType, "exceptionSavePoint", currentBlock);
   }
 
@@ -1141,9 +1275,17 @@ llvm::Function* JavaJIT::javaCompile() {
   endBlock = createBasicBlock("end");
 
   if (returnType != Type::getVoidTy(*llvmContext)) {
-    endNode = llvm::PHINode::Create(returnType, 0, "", endBlock);
+    endNode = llvm::PHINode::Create(returnType, 0, "returnValuePhi", endBlock);
   }
 
+#if OSGI_BUNDLE_TIER_TAGGING
+  initializeChargedTierID();
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  incrementTotalCalledMethodsCounter();
+#endif
+
   checkYieldPoint();
   
   if (isSynchro(compilingMethod->access)) {
@@ -1165,8 +1307,8 @@ llvm::Function* JavaJIT::javaCompile() {
 
     stackCheck = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, stackCheck,
                               intrinsics->constantPtrZero, "");
-    BasicBlock* stackOverflow = createBasicBlock("stack overflow");
-    BasicBlock* noStackOverflow = createBasicBlock("no stack overflow");
+    BasicBlock* stackOverflow = createBasicBlock("stackOverflow");
+    BasicBlock* noStackOverflow = createBasicBlock("noStackOverflow");
     BranchInst::Create(stackOverflow, noStackOverflow, stackCheck,
                        currentBlock);
     currentBlock = stackOverflow;
@@ -1227,9 +1369,9 @@ llvm::Function* JavaJIT::javaCompile() {
     currentBlock->eraseFromParent();
   } else {
     if (nbHandlers != 0) {
-      BasicBlock* ifNormal = createBasicBlock("No exception was thrown");
-      BasicBlock* ifException = createBasicBlock("Rethrow Exception");
-      Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+      BasicBlock* ifNormal = createBasicBlock("noExceptionThrown");
+      BasicBlock* ifException = createBasicBlock("reThrowException");
+      Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
       Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock);
       Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, "");
       BranchInst::Create(ifException, ifNormal, test, currentBlock);
@@ -1381,8 +1523,8 @@ void JavaJIT::JITVerifyNull(Value* obj)
     } else {
       Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, intrinsics->JavaObjectNullConstant, "");
 
-      BasicBlock* nullObjBlock = createBasicBlock("object is null");
-      BasicBlock* notNullObjBlock = createBasicBlock("object is not null");
+      BasicBlock* nullObjBlock = createBasicBlock("objectIsNull");
+      BasicBlock* notNullObjBlock = createBasicBlock("objectIsNotNull");
 
       BranchInst::Create(nullObjBlock, notNullObjBlock, test, currentBlock);
       currentBlock = nullObjBlock;
@@ -1408,8 +1550,8 @@ Value* JavaJIT::verifyAndComputePtr(Valu
     Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_ULT, index, size,
                               "");
 
-    BasicBlock* ifTrue =  createBasicBlock("true verifyAndComputePtr");
-    BasicBlock* ifFalse = createBasicBlock("false verifyAndComputePtr");
+    BasicBlock* ifTrue =  createBasicBlock("trueVerifyAndComputePtr");
+    BasicBlock* ifFalse = createBasicBlock("falseVerifyAndComputePtr");
 
     BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
     
@@ -1659,6 +1801,10 @@ void JavaJIT::invokeSpecial(uint16 index
     func = TheCompiler->getMethod(meth, NULL);
   }
 
+#if OSGI_BUNDLE_TIER_TAGGING
+  calculateChargedTierIDForInvokeSpecial(index);
+#endif
+
   std::vector<Value*> args;
   FunctionType::param_iterator it  = virtualType->param_end();
   makeArgs(it, index, args, signature->nbArguments + 1);
@@ -1688,6 +1834,10 @@ void JavaJIT::invokeSpecial(uint16 index
       }
     }
   }
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  resetChargedTierID();
+#endif
 }
 
 void JavaJIT::invokeStatic(uint16 index) {
@@ -1708,7 +1858,6 @@ void JavaJIT::invokeStatic(uint16 index)
 
   JavaMethod* meth = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_STATIC,
                                                           signature);
-    
 
   uint32 clIndex = ctpInfo->getClassIndexFromMethod(index);
   UserClass* cl = 0;
@@ -1717,6 +1866,10 @@ void JavaJIT::invokeStatic(uint16 index)
     CallInst::Create(intrinsics->ForceInitialisationCheckFunction, Cl, "",
                      currentBlock);
   }
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  calculateChargedTierIDForInvokeStatic(index);
+#endif
   
   Value* func = 0;
   bool needsInit = false;
@@ -1760,6 +1913,10 @@ void JavaJIT::invokeStatic(uint16 index)
       }
     }
   }
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  resetChargedTierID();
+#endif
 }
 
 Value* JavaJIT::getConstantPoolAt(uint32 index, Function* resolver,
@@ -1880,7 +2037,11 @@ void JavaJIT::invokeNew(uint16 index) {
     Size = CallInst::Create(intrinsics->GetObjectSizeFromClassFunction, Cl,
                             "", currentBlock);
   }
- 
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  calculateChargedTierIDForNew(index);
+#endif
+
   VT = new BitCastInst(VT, intrinsics->ptrType, "", currentBlock);
   Instruction* val = invoke(cl ? intrinsics->VTAllocateFunction :
                            intrinsics->VTAllocateUnresolvedFunction,
@@ -1895,6 +2056,10 @@ void JavaJIT::invokeNew(uint16 index) {
   if (cl && cl->virtualVT->hasDestructor()) {
     CallInst::Create(intrinsics->AddFinalizationCandidate, val, "", currentBlock);
   }
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  resetChargedTierID();
+#endif
 }
 
 Value* JavaJIT::ldResolved(uint16 index, bool stat, Value* object, 
@@ -1911,10 +2076,8 @@ Value* JavaJIT::ldResolved(uint16 index,
       Value* Cl = TheCompiler->getNativeClass(field->classDef);
       bool needsCheck = needsInitialisationCheck(field->classDef);
       if (needsCheck) {
-        Cl = invoke(intrinsics->InitialisationCheckFunction, Cl, "",
-                    currentBlock);
-        CallInst::Create(intrinsics->ForceInitialisationCheckFunction, Cl, "",
-                         currentBlock);
+        Cl = invoke(intrinsics->InitialisationCheckFunction, Cl, "", currentBlock);
+        CallInst::Create(intrinsics->ForceInitialisationCheckFunction, Cl, "", currentBlock);
       }
 
       object = TheCompiler->getStaticInstance(field->classDef);
@@ -2180,6 +2343,394 @@ void JavaJIT::getVirtualField(uint16 ind
   }
 }
 
+#if JAVA_CHARGED_TIER_CALL_STACK
+
+void JavaJIT::pushChargedTier()
+{
+	if (!stackEmbeddedListNode) return;
+
+	// Save the current head of the linked list into the node.
+	// node->callerNode = (*threadHead);
+	auto threadHeadPtr = new LoadInst(threadStackEmbeddedListHeadPtrPtr,
+		"threadHeadPtr", currentBlock);
+	new StoreInst(
+		threadHeadPtr, stackEmbeddedListHeadCallerNodePtr, currentBlock);
+
+	// node->data[0] = reinterpret_cast<word_t>(chargedTierID);
+	new StoreInst(
+		chargedTierID, stackEmbeddedListHeadChargedTierPtr, currentBlock);
+
+	// *threadHead = node;
+	new StoreInst(stackEmbeddedListNode, threadStackEmbeddedListHeadPtrPtr,
+		true, currentBlock);	// volatile = true
+}
+
+void JavaJIT::popChargedTier()
+{
+	if (!stackEmbeddedListNode) return;
+
+	// Restore the linked list head.
+	// *threadHead = node->callerNode;
+	auto callerNode = new LoadInst(stackEmbeddedListHeadCallerNodePtr,
+		"callerNode", currentBlock);
+	new StoreInst(callerNode, threadStackEmbeddedListHeadPtrPtr,
+		true, currentBlock);	// volatile = true
+}
+
+void JavaJIT::allocateChargedTierID()
+{
+	if (TheCompiler->isCompilingGarbageCollector()) return;
+
+	assert(!stackEmbeddedListNode && "stackEmbeddedListNode already allocated");
+
+	// Allocate stack embedded list node
+	stackEmbeddedListNode = allocateOnStack("chargedTierNode",
+		sizeof(vmkit::StackEmbeddedListNode),
+		intrinsics->StackEmbeddedListNodeType);
+}
+
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+
+void JavaJIT::initializeChargedTierID()
+{
+	if (TheCompiler->isCompilingGarbageCollector()) return;
+
+	// j3::StackEmbeddedListNode** threadHead =
+	//    thread->stackEmbeddedListHead + StackEmbeddedListIntendedCaller;
+	threadStackEmbeddedListHeadPtrPtr =
+		getElementPtr("threadHeadPtrPtr", getThreadPtr(),
+			intrinsics->constantZero,
+			intrinsics->OffsetStackEmbeddedListHeadInThreadConstant,
+			intrinsics->constantZero, nullptr);
+
+	// node->callerNode
+	stackEmbeddedListHeadCallerNodePtr = getElementPtr(
+		"callerNodePtr", stackEmbeddedListNode,
+		intrinsics->constantZero,
+		intrinsics->OffsetCallerNodeInStackEmbeddedListNodeConstant, nullptr);
+
+	// node->data + 0
+	stackEmbeddedListHeadChargedTierPtr = getElementPtr(
+		"nodeChargedTierPtr", stackEmbeddedListNode,
+		intrinsics->constantZero,
+		intrinsics->OffsetDataInStackEmbeddedListNodeConstant,
+		intrinsics->constantZero, nullptr);
+
+	auto TierIDPtrType = PointerType::getUnqual(intrinsics->TierIDType);
+	stackEmbeddedListHeadChargedTierPtr = new BitCastInst(
+		stackEmbeddedListHeadChargedTierPtr, TierIDPtrType,
+		"nodeChargedTierPtrPtr", currentBlock);
+
+	// Determine our own tier ID
+	auto vm = JavaThread::get()->getJVM();
+	compilingClassTierID = vm->tier_manager.getAccountingConfig().
+		getTierOfCommonClass(compilingClass);
+
+	// Retrieve the thread-local charged tier ID
+	threadChargedTierIDPtr = getElementPtr("threadChargedTierIDPtr",
+		getThreadPtr(), intrinsics->constantZero,
+		intrinsics->OffsetChargedTierIDInThreadConstant, nullptr);
+
+	threadChargedTierIDOldValue = new LoadInst(threadChargedTierIDPtr,
+		"threadChargedTierIDOldValue", true, // volatile = true
+		currentBlock);
+
+	// We are in method prolog. We received a chargedTierID from the caller.
+	// If the caller thinks we should be charged, it must pass 0xffffffff,
+	// otherwise the caller should pass the tier ID to be charged.
+
+	auto threadChargedTierIDIsInvalid = new ICmpInst(*currentBlock,
+		ICmpInst::ICMP_EQ, threadChargedTierIDOldValue,
+		intrinsics->InvalidTierIDConstant, "threadChargedTierIDIsInvalid");
+
+	auto chargeCalledTierID = createBasicBlock("chargeCalledTierID");
+	auto chargeCallerTierID = createBasicBlock("chargeCallerTierID");
+	auto chargeCalledTierIDEnd = createBasicBlock("chargeCalledTierIDEnd");
+
+	chargedTierID = PHINode::Create(
+		intrinsics->TierIDType, 2, "chargedTierID", chargeCalledTierIDEnd);
+
+	BranchInst::Create(chargeCalledTierID, chargeCallerTierID,
+		threadChargedTierIDIsInvalid, currentBlock);
+
+	// If we should charge the called, then our tier id becomes charged.
+	currentBlock = chargeCalledTierID;
+
+	chargedTierID->addIncoming(ConstantInt::get(intrinsics->TierIDType,
+		compilingClassTierID, false), currentBlock);
+
+	BranchInst::Create(chargeCalledTierIDEnd, currentBlock);
+
+	// If we should charge the caller, then the charged continues to be
+	// the passed tier id.
+	currentBlock = chargeCallerTierID;
+
+	chargedTierID->addIncoming(threadChargedTierIDOldValue, currentBlock);
+
+	BranchInst::Create(chargeCalledTierIDEnd, currentBlock);
+
+	currentBlock = chargeCalledTierIDEnd;
+
+	newChargedTierID = threadChargedTierIDOldValue;
+}
+
+void JavaJIT::calculateChargedTierIDForInvokeStatic(uint16_t index)
+{
+	if (!chargedTierID) return;
+
+	// Gather information about the call destination.
+	const UTF8 *called_class_name = nullptr, *called_method_name = nullptr;
+	Signdef* signature = nullptr;
+	compilingClass->ctpInfo->nameOfStaticOrSpecialMethod(
+		index, called_class_name, called_method_name, signature);
+	auto method = compilingClass->ctpInfo->infoOfStaticOrSpecialMethod(
+		index, ACC_STATIC, signature);
+
+	auto called_tier_id = OSGi::runtimeTierID;
+	const UTF8 *called_bundle_name = nullptr;
+	if (method != nullptr) {
+		OSGi::BundleStateMonitor::BundleInfoType::const_iterator info_iterator;
+		auto vm = JavaThread::get()->getJVM();
+		if (vm->bundle_state_monitor.getBundleInfoByClassLoader(
+			method->classDef->classLoader, info_iterator))
+		{
+			auto& accountingConfig = vm->tier_manager.getAccountingConfig();
+
+			called_bundle_name = info_iterator->second.name;
+			called_tier_id =
+				accountingConfig.getTierOfBundleName(called_bundle_name);
+		}
+	}
+
+	calculateChargedTierIDForInvoke(OSGi::CallConfiguration(
+		compilingClassTierID, called_tier_id,
+		called_bundle_name, called_class_name, called_method_name));
+}
+
+void JavaJIT::calculateChargedTierIDForInvokeSpecial(uint16_t index)
+{
+	if (!chargedTierID) return;
+
+	// Gather information about the call destination.
+	const UTF8 *called_class_name = nullptr, *called_method_name = nullptr;
+	Signdef* signature = nullptr;
+	compilingClass->ctpInfo->nameOfStaticOrSpecialMethod(
+		index, called_class_name, called_method_name, signature);
+	auto method = compilingClass->ctpInfo->infoOfStaticOrSpecialMethod(
+		index, ACC_VIRTUAL, signature);
+
+	auto called_tier_id = OSGi::runtimeTierID;
+	const UTF8 *called_bundle_name = nullptr;
+	if (method != nullptr) {
+		OSGi::BundleStateMonitor::BundleInfoType::const_iterator info_iterator;
+		auto vm = JavaThread::get()->getJVM();
+		if (vm->bundle_state_monitor.getBundleInfoByClassLoader(
+			method->classDef->classLoader, info_iterator))
+		{
+			auto& accountingConfig = vm->tier_manager.getAccountingConfig();
+
+			called_bundle_name = info_iterator->second.name;
+			called_tier_id =
+				accountingConfig.getTierOfBundleName(called_bundle_name);
+		}
+	}
+
+	calculateChargedTierIDForInvoke(OSGi::CallConfiguration(
+		compilingClassTierID, called_tier_id,
+		called_bundle_name, called_class_name, called_method_name));
+}
+
+void JavaJIT::calculateChargedTierIDForInvokeInterface(uint16_t index)
+{
+	if (!chargedTierID) return;
+
+	// Gather information about the call destination.
+	auto vm = JavaThread::get()->getJVM();
+	auto& accountingConfig = vm->tier_manager.getAccountingConfig();
+	const UTF8* called_method_name = nullptr;
+	compilingClass->ctpInfo->infoOfInterfaceOrVirtualMethod(
+		index, called_method_name);
+
+	CommonClass* cl = nullptr;
+	JavaMethod* meth = nullptr;
+	compilingClass->ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth);
+
+	auto called_tier_id = OSGi::runtimeTierID;
+	const UTF8 *called_bundle_name = nullptr, *called_interface_name = nullptr;
+	if (cl != nullptr) {
+		called_interface_name = cl->name;
+
+		OSGi::BundleStateMonitor::BundleInfoType::const_iterator info_iterator;
+		if (vm->bundle_state_monitor.getBundleInfoByClassLoader(
+			cl->classLoader, info_iterator))
+		{
+			called_bundle_name = info_iterator->second.name;
+			called_tier_id =
+				accountingConfig.getTierOfBundleName(called_bundle_name);
+		}
+	} else {
+		auto entry = compilingClass->ctpInfo->ctpDef[index];
+		uint32 class_index = entry >> 16;
+		auto class_entry = compilingClass->ctpInfo->ctpDef[class_index];
+		called_interface_name = compilingClass->ctpInfo->UTF8At(class_entry);
+	}
+
+	calculateChargedTierIDForInvoke(OSGi::CallConfiguration(
+		compilingClassTierID, called_tier_id,
+		called_bundle_name, called_interface_name, called_method_name));
+}
+
+void JavaJIT::calculateChargedTierIDForInvokeVirtual(uint16_t index)
+{
+	if (!chargedTierID) return;
+
+	// Gather information about the call destination.
+	auto vm = JavaThread::get()->getJVM();
+	auto& accountingConfig = vm->tier_manager.getAccountingConfig();
+	const UTF8* called_method_name = nullptr;
+	compilingClass->ctpInfo->infoOfInterfaceOrVirtualMethod(
+		index, called_method_name);
+
+	CommonClass* cl = nullptr;
+	JavaMethod* meth = nullptr;
+	compilingClass->ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth);
+
+	auto called_tier_id = OSGi::runtimeTierID;
+	const UTF8 *called_bundle_name = nullptr, *called_interface_name = nullptr;
+	if (cl != nullptr) {
+		called_interface_name = cl->name;
+
+		OSGi::BundleStateMonitor::BundleInfoType::const_iterator info_iterator;
+		if (vm->bundle_state_monitor.getBundleInfoByClassLoader(
+			cl->classLoader, info_iterator))
+		{
+			called_bundle_name = info_iterator->second.name;
+			called_tier_id =
+				accountingConfig.getTierOfBundleName(called_bundle_name);
+		}
+	} else {
+		auto entry = compilingClass->ctpInfo->ctpDef[index];
+		uint32 class_index = entry >> 16;
+		auto class_entry = compilingClass->ctpInfo->ctpDef[class_index];
+		called_interface_name = compilingClass->ctpInfo->UTF8At(class_entry);
+	}
+
+	calculateChargedTierIDForInvoke(OSGi::CallConfiguration(
+		compilingClassTierID, called_tier_id,
+		called_bundle_name, called_interface_name, called_method_name));
+}
+
+void JavaJIT::calculateChargedTierIDForInvokeNative()
+{
+	if (!chargedTierID) return;
+
+	// Gather information about the call destination.
+	auto called_method_name = compilingMethod->name;
+
+	auto called_tier_id = OSGi::runtimeTierID;
+	const UTF8 *called_bundle_name = nullptr, *called_class_name = nullptr;
+	if (compilingMethod->classDef != nullptr) {
+		called_class_name = compilingMethod->classDef->name;
+
+		OSGi::BundleStateMonitor::BundleInfoType::const_iterator info_iterator;
+		auto vm = JavaThread::get()->getJVM();
+		if (vm->bundle_state_monitor.getBundleInfoByClassLoader(
+			compilingMethod->classDef->classLoader, info_iterator))
+		{
+			auto& accountingConfig = vm->tier_manager.getAccountingConfig();
+
+			called_bundle_name = info_iterator->second.name;
+			called_tier_id =
+				accountingConfig.getTierOfBundleName(called_bundle_name);
+		}
+	}
+
+	calculateChargedTierIDForInvoke(OSGi::CallConfiguration(
+		compilingClassTierID, called_tier_id,
+		called_bundle_name, called_class_name, called_method_name));
+}
+
+void JavaJIT::calculateChargedTierIDForNew(uint16_t index)
+{
+	// Gather information about the call destination.
+	auto called_method_name = upcalls->InitObject->name;
+	const UTF8 *called_class_name = nullptr, *called_bundle_name = nullptr;
+
+	auto called_tier_id = OSGi::runtimeTierID;
+	Class* cl = nullptr;
+	getResolvedClass(index, false, false, &cl);
+	if (cl != nullptr) {
+		called_class_name = cl->name;
+
+		auto vm = JavaThread::get()->getJVM();
+		OSGi::BundleStateMonitor::BundleInfoType::const_iterator info_iterator;
+		if (vm->bundle_state_monitor.getBundleInfoByClassLoader(
+			cl->classLoader, info_iterator))
+		{
+			auto& accountingConfig = vm->tier_manager.getAccountingConfig();
+
+			called_bundle_name = info_iterator->second.name;
+			called_tier_id =
+				accountingConfig.getTierOfBundleName(called_bundle_name);
+		}
+	} else {
+		called_class_name = compilingClass->ctpInfo->resolveClassName(index);
+	}
+
+	calculateChargedTierIDForInvoke(OSGi::CallConfiguration(
+		compilingClassTierID, called_tier_id,
+		called_bundle_name, called_class_name, called_method_name));
+}
+
+void JavaJIT::calculateChargedTierIDForInvoke(const OSGi::CallConfiguration& cc)
+{
+	// Decide who should be charged for this call.
+	auto& accountingConfig =
+		JavaThread::get()->getJVM()->tier_manager.getAccountingConfig();
+	auto chargeToCaller = accountingConfig.isAccountingChargedToCaller(cc);
+
+	// If the caller is charged then pass the currently charged tier id, which
+	// is either our own tier id, or the tier is that was passed by our caller.
+	// If the called is charged then pass "invalidTierID", and the called
+	// method will change the currently charged tier id to its own
+	// implementation tier id.
+	newChargedTierID = (chargeToCaller ?
+		static_cast<Value*>(chargedTierID) :
+		static_cast<Value*>(intrinsics->InvalidTierIDConstant));
+}
+
+void JavaJIT::setChargedTierID()
+{
+#if EMBEDDED_LIST_UPDATE
+	if (!chargedTierID) return;
+
+	new StoreInst(newChargedTierID, threadChargedTierIDPtr, currentBlock);
+
+	pushChargedTier();
+#endif
+}
+
+void JavaJIT::resetChargedTierID()
+{
+	if (!chargedTierID) return;
+
+	newChargedTierID = threadChargedTierIDOldValue;
+}
+
+void JavaJIT::restoreChargedTierID()
+{
+#if EMBEDDED_LIST_UPDATE
+	if (!chargedTierID) return;
+
+	new StoreInst(threadChargedTierIDOldValue, threadChargedTierIDPtr, currentBlock);
+
+	popChargedTier();
+#endif
+}
+
+#endif
 
 void JavaJIT::invokeInterface(uint16 index) {
   
@@ -2321,6 +2872,10 @@ void JavaJIT::invokeInterface(uint16 ind
   node = new BitCastInst(node, virtualPtrType, "", currentBlock);
 #endif
 
+#if OSGI_BUNDLE_TIER_TAGGING
+  calculateChargedTierIDForInvokeInterface(index);
+#endif
+
   std::vector<Value*> args; // size = [signature->nbIn + 3];
   FunctionType::param_iterator it  = virtualType->param_end();
   makeArgs(it, index, args, signature->nbArguments + 1);
@@ -2337,6 +2892,10 @@ void JavaJIT::invokeInterface(uint16 ind
       }
     }
   }
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  resetChargedTierID();
+#endif
 }
 
 DebugLoc JavaJIT::CreateLocation() {
@@ -2345,14 +2904,13 @@ DebugLoc JavaJIT::CreateLocation() {
 }
 
 Instruction* JavaJIT::invoke(Value *F, std::vector<llvm::Value*>& args,
-                       const char* Name,
-                       BasicBlock *InsertAtEnd) {
+  const char* Name, BasicBlock *InsertAtEnd) {
   assert(!inlining);
  
   BasicBlock* ifException = NULL;
   if (jmpBuffer != NULL) {
-    BasicBlock* doCall = createBasicBlock("Perform call");
-    ifException = createBasicBlock("Exception thrown");
+    BasicBlock* doCall = createBasicBlock("performCall");
+    ifException = createBasicBlock("exceptionThrown");
     Instruction* check = CallInst::Create(intrinsics->SetjmpFunction, jmpBuffer, "", currentBlock);
     check = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, check, intrinsics->constantZero, "");
     BranchInst::Create(doCall, ifException, check, currentBlock);
@@ -2360,17 +2918,31 @@ Instruction* JavaJIT::invoke(Value *F, s
     CallInst::Create(intrinsics->RegisterSetjmpFunction, jmpBuffer, "", currentBlock);
   }
 
+#if OSGI_BUNDLE_TIER_TAGGING
+  setChargedTierID();
+#endif
+
   Instruction* res = CallInst::Create(F, args, Name,  currentBlock);
   DebugLoc DL = CreateLocation();
   res->setDebugLoc(DL);
-  
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  restoreChargedTierID();
+#endif
+
   if (jmpBuffer != NULL) {
     CallInst::Create(intrinsics->UnregisterSetjmpFunction, jmpBuffer, "", currentBlock);
-    BasicBlock* ifNormal = createBasicBlock("no exception block");
+    BasicBlock* ifNormal = createBasicBlock("noExceptionBlock");
     BranchInst::Create(ifNormal, currentBlock);
 
     currentBlock = ifException;
+
+#if OSGI_BUNDLE_TIER_TAGGING
+    restoreChargedTierID();
+#endif
+
     CallInst::Create(intrinsics->UnregisterSetjmpFunction, jmpBuffer, "", currentBlock);
+
     BranchInst::Create(currentExceptionBlock, currentBlock);
     currentBlock = ifNormal; 
   }
@@ -2379,14 +2951,14 @@ Instruction* JavaJIT::invoke(Value *F, s
 }
 
 Instruction* JavaJIT::invoke(Value *F, Value* arg1, const char* Name,
-                       BasicBlock *InsertAtEnd) {
+  BasicBlock *InsertAtEnd) {
   std::vector<Value*> args;
   args.push_back(arg1);
   return invoke(F, args, Name, InsertAtEnd);
 }
 
 Instruction* JavaJIT::invoke(Value *F, Value* arg1, Value* arg2,
-                       const char* Name, BasicBlock *InsertAtEnd) {
+  const char* Name, BasicBlock *InsertAtEnd) {
   std::vector<Value*> args;
   args.push_back(arg1);
   args.push_back(arg2);
@@ -2394,7 +2966,7 @@ Instruction* JavaJIT::invoke(Value *F, V
 }
 
 Instruction* JavaJIT::invoke(Value *F, const char* Name,
-                       BasicBlock *InsertAtEnd) {
+  BasicBlock *InsertAtEnd) {
   std::vector<Value*> args;
   return invoke(F, args, Name, InsertAtEnd);
 }
@@ -2405,7 +2977,7 @@ void JavaJIT::throwException(Value* obj,
     CallInst::Create(intrinsics->ThrowExceptionFunction, obj, "", currentBlock);
     new UnreachableInst(*llvmContext, currentBlock);
   } else {
-    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
     if (vmkit::Collector::needsNonHeapWriteBarrier()) {
       Instruction* ptr = new BitCastInst(javaExceptionPtr, intrinsics->ptrPtrType, "", currentBlock);
       Instruction* val = new BitCastInst(obj, intrinsics->ptrType, "", currentBlock);
@@ -2557,7 +3129,7 @@ unsigned JavaJIT::readExceptionTable(Rea
     Value* VTVar = TheCompiler->getVirtualTable(cur->catchClass->virtualVT);
 
     // Get the Java exception.
-    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
     Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock);
     
     Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "objectVT",

Modified: vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJIT.h Thu Oct  9 03:43:38 2014
@@ -31,6 +31,8 @@
 #include "JavaClass.h"
 #include "JavaUpcalls.h"
 
+#include "AccountingConfiguration.h"
+
 namespace j3 {
 
 class Class;
@@ -107,6 +109,25 @@ public:
     overridesThis = false;
     nbHandlers = 0;
     jmpBuffer = NULL;
+    currentThreadPtr = nullptr;
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+    chargedTierID				= nullptr;
+    stackEmbeddedListHeadChargedTierPtr	= nullptr;
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+    threadChargedTierIDPtr		= nullptr;
+    threadChargedTierIDOldValue	= nullptr;
+    newChargedTierID			= nullptr;
+    compilingClassTierID		= OSGi::runtimeTierID;
+#endif
+
+#if EMBEDDED_LIST_IN_CALL_STACK
+    stackEmbeddedListNode				= nullptr;
+    threadStackEmbeddedListHeadPtrPtr	= nullptr;
+    stackEmbeddedListHeadCallerNodePtr	= nullptr;
+#endif
   }
 
   /// javaCompile - Compile the Java method.
@@ -168,6 +189,8 @@ private:
 
   llvm::Value* jmpBuffer;
 
+  llvm::Value* currentThreadPtr;
+
   /// return the header of an object
   llvm::Value* objectToHeader(llvm::Value* obj);
   
@@ -182,6 +205,8 @@ private:
                     llvm::BasicBlock* currentBlock, bool usign);
  
   /// getMutatorThreadPtr - Emit code to get a pointer to the current MutatorThread.
+	llvm::Value* getThreadPtr();
+	llvm::Value* getJavaThreadPtr();
 	llvm::Value* getMutatorThreadPtr();
 
   /// getIsolateIDPtr - Emit code to get a pointer to IsolateID.
@@ -570,6 +595,49 @@ private:
 //===--------------------- Yield point support  ---------------------------===//
 
   void checkYieldPoint();
+
+  llvm::Value* getElementPtr(
+    const char *name, llvm::Value* element, llvm::Value* firstIndex, ...);
+  llvm::Value* allocateOnStack(
+    const char* name, size_t byteCount, llvm::Type* realType);
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+  void allocateChargedTierID();
+  void pushChargedTier();
+  void popChargedTier();
+
+  llvm::PHINode* chargedTierID;
+  llvm::Value* stackEmbeddedListHeadChargedTierPtr;
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  void initializeChargedTierID();
+  void setChargedTierID();
+  void resetChargedTierID();
+  void restoreChargedTierID();
+  void calculateChargedTierIDForInvoke(const OSGi::CallConfiguration&);
+  void calculateChargedTierIDForInvokeStatic(uint16_t index);
+  void calculateChargedTierIDForInvokeSpecial(uint16_t index);
+  void calculateChargedTierIDForInvokeInterface(uint16_t index);
+  void calculateChargedTierIDForInvokeVirtual(uint16_t index);
+  void calculateChargedTierIDForInvokeNative();
+  void calculateChargedTierIDForNew(uint16_t index);
+
+  OSGi::tier_id_t compilingClassTierID;
+  llvm::Value* threadChargedTierIDPtr;
+  llvm::Value* threadChargedTierIDOldValue;
+  llvm::Value* newChargedTierID;
+#endif
+
+#if EMBEDDED_LIST_IN_CALL_STACK
+  llvm::Value* stackEmbeddedListNode;
+  llvm::Value* threadStackEmbeddedListHeadPtrPtr;
+  llvm::Value* stackEmbeddedListHeadCallerNodePtr;
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  void incrementTotalCalledMethodsCounter();
+#endif
 };
 
 enum Opcode {

Modified: vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJITOpcodes.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/Compiler/JavaJITOpcodes.cpp Thu Oct  9 03:43:38 2014
@@ -376,7 +376,7 @@ void JavaJIT::compileOpcodes(Reader& rea
       stack.clear();
       if (opinfo->handler) {
         // If it's a handler, put the exception object in the stack.
-        Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+        Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
         Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock);
         new StoreInst(obj, objectStack[0], "", currentBlock);
         // And clear the exception.
@@ -940,10 +940,10 @@ void JavaJIT::compileOpcodes(Reader& rea
 
           Value* res = 0;
           if (TheCompiler->isStaticCompiling()) {
-        	  BasicBlock* endBlock = createBasicBlock("end array store check");
-        	  BasicBlock* checkBlock = createBasicBlock("array store check");
+        	  BasicBlock* endBlock = createBasicBlock("endArrayStoreCheck");
+        	  BasicBlock* checkBlock = createBasicBlock("arrayStoreCheck");
         	  BasicBlock* exceptionBlock =
-        	          		  createBasicBlock("array store exception");
+        	          		  createBasicBlock("arrayStoreException");
         	  Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val,
                                     intrinsics->JavaObjectNullConstant, "");
 
@@ -1262,8 +1262,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null div");
-          BasicBlock* ifTrue = createBasicBlock("null div");
+          BasicBlock* ifFalse = createBasicBlock("nonNullDiv");
+          BasicBlock* ifTrue = createBasicBlock("nullDiv");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1272,9 +1272,9 @@ void JavaJIT::compileOpcodes(Reader& rea
         }
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                   intrinsics->constantMinusOne, "");
-        BasicBlock* ifFalse = createBasicBlock("non -1 div");
-        BasicBlock* ifTrue = createBasicBlock("-1 div");
-        BasicBlock* endBlock = createBasicBlock("End division");
+        BasicBlock* ifFalse = createBasicBlock("nonMinusOneDiv");
+        BasicBlock* ifTrue = createBasicBlock("minusOneDiv");
+        BasicBlock* endBlock = createBasicBlock("endDivision");
         PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock);
         BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
         currentBlock = ifTrue;
@@ -1300,8 +1300,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantLongZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null div");
-          BasicBlock* ifTrue = createBasicBlock("null div");
+          BasicBlock* ifFalse = createBasicBlock("nonNullDiv");
+          BasicBlock* ifTrue = createBasicBlock("nullDiv");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1339,8 +1339,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null rem");
-          BasicBlock* ifTrue = createBasicBlock("null rem");
+          BasicBlock* ifFalse = createBasicBlock("nonNullRem");
+          BasicBlock* ifTrue = createBasicBlock("nullRem");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1349,8 +1349,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         }
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                   intrinsics->constantMinusOne, "");
-        BasicBlock* ifFalse = createBasicBlock("non -1 rem");
-        BasicBlock* endBlock = createBasicBlock("end block");
+        BasicBlock* ifFalse = createBasicBlock("nonMinusOneRem");
+        BasicBlock* endBlock = createBasicBlock("endBlock");
         PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock);
         node->addIncoming(intrinsics->constantZero, currentBlock);
         BranchInst::Create(endBlock, ifFalse, cmp, currentBlock);
@@ -1372,8 +1372,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantLongZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null div");
-          BasicBlock* ifTrue = createBasicBlock("null div");
+          BasicBlock* ifFalse = createBasicBlock("nonNullDiv");
+          BasicBlock* ifTrue = createBasicBlock("nullDiv");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1911,7 +1911,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFEQ");
+        BasicBlock* ifFalse = createBasicBlock("falseIFEQ");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1928,7 +1928,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFNE");
+        BasicBlock* ifFalse = createBasicBlock("falseIFNE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1944,7 +1944,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFLT");
+        BasicBlock* ifFalse = createBasicBlock("falseIFLT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1960,7 +1960,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFGE");
+        BasicBlock* ifFalse = createBasicBlock("falseIFGE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1976,7 +1976,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFGT");
+        BasicBlock* ifFalse = createBasicBlock("falseIFGT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1992,7 +1992,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFLE");
+        BasicBlock* ifFalse = createBasicBlock("falseIFLE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2007,7 +2007,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val1,
                                          val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPEQ");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPEQ");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2022,7 +2022,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val1,
                                          val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPNE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPNE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2037,7 +2037,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_IFCMPLT");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_IFCMPLT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2052,7 +2052,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2067,7 +2067,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGT");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2082,7 +2082,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPLE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPLE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2097,7 +2097,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ACMPEQ");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPEQ");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2112,7 +2112,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ACMPNE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPNE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2178,7 +2178,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         for (sint32 cur = low; cur < high; ++cur) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ,
                                     ConstantInt::get(type, cur), index, "");
-          BasicBlock* falseBlock = createBasicBlock("continue tableswitch");
+          BasicBlock* falseBlock = createBasicBlock("continueTableswitch");
           Opinfo& info = opcodeInfos[tmp + reader.readU4()];
           i += 4;
           branch(cmp, info.newBlock, falseBlock, currentBlock, info);
@@ -2208,7 +2208,7 @@ void JavaJIT::compileOpcodes(Reader& rea
           i += 4;
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, key,
                                     "");
-          BasicBlock* falseBlock = createBasicBlock("continue lookupswitch");
+          BasicBlock* falseBlock = createBasicBlock("continueLookupswitch");
           Opinfo& info = opcodeInfos[tmp + reader.readU4()];
           i += 4;
           branch(cmp, info.newBlock, falseBlock, currentBlock, info);
@@ -2420,7 +2420,7 @@ void JavaJIT::compileOpcodes(Reader& rea
                                     "", currentBlock);
         TheVT = new BitCastInst(TheVT, intrinsics->ptrType, "", currentBlock);
         Instruction* res = invoke(intrinsics->VTAllocateFunction, size, TheVT, "",
-                                  currentBlock);
+          currentBlock);
         Value* cast = new BitCastInst(res, intrinsics->JavaArrayType, "",
                                       currentBlock);
 
@@ -2474,22 +2474,22 @@ void JavaJIT::compileOpcodes(Reader& rea
         Value* args[2] = { obj, clVar };
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj,
                                   intrinsics->JavaObjectNullConstant, "");
-        BasicBlock* endBlock = createBasicBlock("end type compare");
+        BasicBlock* endBlock = createBasicBlock("endTypeCompare");
         PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), 2, "", endBlock);
         
         if (checkcast) {
-          exceptionCheckcast = createBasicBlock("false checkcast");
+          exceptionCheckcast = createBasicBlock("falseCheckcast");
 
         
-          endCheckcast = createBasicBlock("null checkcast");
-          BasicBlock* ifFalse = createBasicBlock("non null checkcast");
+          endCheckcast = createBasicBlock("nullCheckcast");
+          BasicBlock* ifFalse = createBasicBlock("nonNullCheckcast");
 
           BranchInst::Create(endCheckcast, ifFalse, cmp, currentBlock);
           currentBlock = exceptionCheckcast;
           throwRuntimeException(intrinsics->ClassCastExceptionFunction, args, 2);
           currentBlock = ifFalse;
         } else {
-          BasicBlock* ifFalse = createBasicBlock("false type compare");
+          BasicBlock* ifFalse = createBasicBlock("falseTypeCompare");
           BranchInst::Create(endBlock, ifFalse, cmp, currentBlock);
           node->addIncoming(ConstantInt::getFalse(*llvmContext), currentBlock);
           currentBlock = ifFalse;
@@ -2607,7 +2607,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* nil = Constant::getNullValue(val->getType());
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val,
                                          nil, "");
-        BasicBlock* ifFalse = createBasicBlock("true IFNULL");
+        BasicBlock* ifFalse = createBasicBlock("trueIFNULL");
         Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()];
         i += 2;
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
@@ -2622,7 +2622,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* nil = Constant::getNullValue(val->getType());
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val,
                                          nil, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFNONNULL");
+        BasicBlock* ifFalse = createBasicBlock("falseIFNONNULL");
         Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()];
         i += 2;
         BasicBlock* ifTrue = ifTrueInfo.newBlock;

Modified: vmkit/branches/memory-monitor/lib/j3/Compiler/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/Compiler/LowerConstantCalls.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/Compiler/LowerConstantCalls.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/Compiler/LowerConstantCalls.cpp Thu Oct  9 03:43:38 2014
@@ -287,8 +287,8 @@ bool LowerConstantCalls::runOnFunction(F
           Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, 
                                     intrinsics->JavaObjectNullConstant, "");
           
-          BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "No delegatee", &F);
-          BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "Delegatee OK", &F);
+          BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "noDelegatee", &F);
+          BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "delegateeOK", &F);
           BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI);
           PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, 2, "", DelegateeOK);
           phi->addIncoming(Del, CI->getParent());
@@ -398,8 +398,8 @@ bool LowerConstantCalls::runOnFunction(F
           Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1,
                                      intrinsics->constantPtrNull, "");
  
-          BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F);
-          BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F);
+          BasicBlock* trueCl = BasicBlock::Create(*Context, "CtpOK", &F);
+          BasicBlock* falseCl = BasicBlock::Create(*Context, "CtpNotOK", &F);
           PHINode* node = llvm::PHINode::Create(returnType, 2, "", trueCl);
           node->addIncoming(arg1, CI->getParent());
           BranchInst::Create(falseCl, trueCl, test, CI);
@@ -465,8 +465,8 @@ bool LowerConstantCalls::runOnFunction(F
             Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, LoadedGV, init,
                                       "");
 
-            BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F);
-            BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F);
+            BasicBlock* OKBlock = BasicBlock::Create(*Context, "OK", &F);
+            BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "NotOK", &F);
             PHINode* node = PHINode::Create(intrinsics->VTType, 2, "",
                                             OKBlock);
             node->addIncoming(LoadedGV, CI->getParent());
@@ -509,8 +509,8 @@ bool LowerConstantCalls::runOnFunction(F
           BasicBlock* EndBlock = II->getParent()->splitBasicBlock(II);
           I->getParent()->getTerminator()->eraseFromParent();
           
-          BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "", &F);
-          BasicBlock* FailedBlock = BasicBlock::Create(*Context, "", &F);
+          BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "currentEnd", &F);
+          BasicBlock* FailedBlock = BasicBlock::Create(*Context, "failed", &F);
           PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), 2, "", CurEndBlock);
 
           ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context),

Modified: vmkit/branches/memory-monitor/lib/j3/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/LLVMRuntime/runtime-default.ll?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/branches/memory-monitor/lib/j3/LLVMRuntime/runtime-default.ll Thu Oct  9 03:43:38 2014
@@ -27,6 +27,10 @@
 ;;; Field 2: The static instance
 %TaskClassMirror = type { i8, i1, i8* }
 
+;;; Field 0: callerNode
+;;; Field 1: data
+%StackEmbeddedListNode = type { %StackEmbeddedListNode*, [1 x i8*] }
+
 %CircularBase = type { %VT*, %CircularBase*, %CircularBase* }
 
 ;;; Field 0:  the parent (circular base)
@@ -41,7 +45,13 @@
 ;;; field 9:  void*  routine
 ;;; field 10: void*  lastKnownFrame
 ;;; field 11: void*  lastExceptionBuffer
-%Thread = type { %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8* }
+;;; field 12: uint32_t chargedTierID
+;;; field 13: void*  stackEmbeddedListHead ( 1 = vmkit::StackEmbeddedListNodeCountPerThread )
+;;; field 14: uint64_t total_called_methods_count
+%Thread = type {
+	%CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8*, i32,
+	[1 x %StackEmbeddedListNode*], i64
+}
 
 %JavaThread = type { %MutatorThread, i8*, %JavaObject* }
 
@@ -184,7 +194,7 @@ declare i8* @getConstantPoolAt(i8* (%Jav
 
 ;;; j3VirtualTableLookup - Look up the offset in a virtual table of a
 ;;; specific function.
-declare i32 @j3VirtualTableLookup(%JavaClass*, i32, i32*, %JavaObject*)
+declare %JavaMethod* @j3VirtualTableLookup(%JavaClass*, i32, %JavaMethod**, %JavaObject*)
 
 ;;; j3ClassLookup - Look up a specific class. The function takes a class and
 ;;; an index to lookup in the constant pool and returns and stores it in the
@@ -276,3 +286,5 @@ declare void @j3StartJNI(i32*, i32**, i8
 declare void @j3PrintExecution(i32, i32, %JavaMethod*)
 declare void @j3PrintMethodStart(%JavaMethod*)
 declare void @j3PrintMethodEnd(%JavaMethod*)
+
+declare void @Jnjvm_incrementTotalCalledMethodsCounter()

Added: vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.cpp?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.cpp (added)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.cpp Thu Oct  9 03:43:38 2014
@@ -0,0 +1,578 @@
+
+#include "AccountingConfiguration.h"
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+
+
+namespace j3 {
+namespace OSGi {
+
+//#########################################################################
+//
+//                        CallConfiguration
+//
+//#########################################################################
+
+CallConfiguration::CallConfiguration(
+	tier_id_t callerTierID, tier_id_t calledTierID,
+	const vmkit::UTF8* calledBundleName, const vmkit::UTF8* calledInterfaceName,
+	const vmkit::UTF8* calledMethodName)
+{
+	set(callerTierID, calledTierID,
+		calledBundleName, calledInterfaceName, calledMethodName);
+}
+
+void CallConfiguration::set(
+	tier_id_t callerTierID, tier_id_t calledTierID,
+	const vmkit::UTF8* calledBundleName, const vmkit::UTF8* calledInterfaceName,
+	const vmkit::UTF8* calledMethodName)
+{
+	_caller_tier_id = callerTierID;
+	_called_tier_id = calledTierID;
+	_called_interface_name = calledInterfaceName;
+	_called_method_name = calledMethodName;
+
+	// The runtime does not hold a bundle name.
+	_called_bundle_name =
+		((calledBundleName != nullptr) && (calledTierID != runtimeTierID)) ?
+		calledBundleName :
+		nullptr;
+}
+
+int CallConfiguration::compare(const CallConfiguration& other) const
+{
+	// Compare based on caller tiers, if they are not equal and not generic
+	int diff = 0;
+
+	if (_caller_tier_id != invalidTierID &&
+		other._caller_tier_id != invalidTierID)
+	{
+		diff = (int)(_caller_tier_id - other._caller_tier_id);
+		if (diff != 0) return diff;
+	}
+
+	// Compare based on called tiers, if they are not equal not generic
+	if (_called_tier_id != invalidTierID &&
+		other._called_tier_id != invalidTierID)
+	{
+		diff = (int)(_called_tier_id - other._called_tier_id);
+		if (diff != 0) return diff;
+	}
+
+	// Compare based on bundleName, if they are not equal
+	diff = UTF8::compare(_called_bundle_name, other._called_bundle_name);
+	if (diff != 0) return diff;
+
+	// Compare based on interfaceName
+	diff = UTF8::compare(_called_interface_name, other._called_interface_name);
+	if (diff != 0) return diff;
+
+	return UTF8::compare(_called_method_name, other._called_method_name);
+}
+
+bool CallConfiguration::genericize()
+{
+	if (_called_method_name != nullptr) {
+		_called_method_name = nullptr; return true;
+	}
+	if (_called_interface_name != nullptr) {
+		_called_interface_name = nullptr; return true;
+	}
+	if (_called_bundle_name != nullptr) {
+		_called_bundle_name = nullptr; return true;
+	}
+	return false;
+}
+
+std::ostream& operator << (std::ostream& os, const CallConfiguration& obj)
+{
+	if (obj._caller_tier_id == invalidTierID)
+		os << '*';
+	else
+		os << (int)obj._caller_tier_id;
+
+	os << " => ";
+
+	if (obj._called_tier_id == invalidTierID)
+		os << '*';
+	else
+		os << (int)obj._called_tier_id;
+
+	if (obj._called_bundle_name != nullptr)
+		os << " bundle=" << *obj._called_bundle_name;
+
+	if (obj._called_interface_name != nullptr)
+		os << " interface=" << *obj._called_interface_name;
+
+	if (obj._called_method_name != nullptr)
+		os << " method=" << *obj._called_method_name;
+	return os;
+}
+
+void CallConfiguration::dump() const
+{
+	std::cout << *this << std::endl;
+}
+
+}
+}
+
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+
+#include <fstream>
+#include <cstdlib>
+#include <errno.h>
+
+#include "JnjvmClassLoader.h"
+#include "JavaThread.h"
+#include "Jnjvm.h"
+#include "JavaClass.h"
+
+using namespace std;
+
+template<class ContainerType, class ConstIteratorType, class IteratorType>
+IteratorType& const_cast_iterator(
+	ContainerType& cont, ConstIteratorType& const_iter, IteratorType& iter)
+{
+	iter = cont.begin();
+	std::advance(iter, std::distance<ConstIteratorType>(iter, const_iter));
+	return iter;
+}
+
+namespace j3 {
+namespace OSGi {
+
+//#########################################################################
+//
+//                     AccountingConfigurationParser
+//
+//#########################################################################
+
+const std::vector<std::string> AccountingConfigurationParser::_token_name {
+	"error",
+	"*",
+	"integer",
+	"identifier",
+	"tier",
+	"account",
+	"caller",
+	"called"
+};
+
+AccountingConfigurationParser::AccountingConfigurationParser(
+	AccountingConfiguration& config, UTF8Map* hashMap) :
+	_input(nullptr), _token_start(nullptr), _token(0), _integer_token(0),
+	_hash_map(hashMap), _errorDescription("Success"), _config(config)
+{
+}
+
+int AccountingConfigurationParser::load(
+	AccountingConfiguration& config,
+	const char* config_file, std::string& errorDescription, UTF8Map* hashMap)
+{
+	auto r = 0;
+	ifstream f;
+	f.open(config_file);
+	if (!f.is_open()) {
+		r = errno;
+		errorDescription = strerror(r);
+		return r;
+	}
+
+	f.seekg(0, fstream::end);
+	size_t fsize = f.tellg();
+	f.seekg(0, fstream::beg);
+	if (fsize == 0) return 0;
+
+	unique_ptr<char[]> buffer(new char[fsize+1]);
+	f.read(buffer.get(), fsize);
+	f.close();
+
+	buffer[fsize] = '\0';
+
+	AccountingConfigurationParser parser(config, hashMap);
+	r = parser.parse(buffer.get());
+
+	errorDescription = parser.getErrorDescription();
+	return r;
+}
+
+int AccountingConfigurationParser::parseError(int r, const std::string& message)
+{
+	_errorDescription = message + ". At: '";
+	_errorDescription.append(_token_start, 32);
+	_errorDescription += "'...";
+	return r;
+}
+
+int AccountingConfigurationParser::unexpectedToken(int r, const std::string& expected)
+{
+	return parseError(
+		r, "Expecting " + expected + ". Got '" + tokenName(_token) + "'");
+}
+
+int AccountingConfigurationParser::parseTier()
+{
+	if (_token != token_tier) return ENOENT;
+
+	if ((_token = nextToken()) != token_integer)
+		return unexpectedToken(EBADF, "tier identifier (integer)");
+
+	tier_id_t tier_id = _integer_token;
+
+	if (tier_id == unspecifiedTierID || tier_id == runtimeTierID)
+		return unexpectedToken(EBADF, "non-reserved tier identifier");
+
+	if ((_token = nextToken()) != '{')
+		return unexpectedToken(EBADF, "'{'");
+
+	auto& bundles = _config._tier_list.insert(
+		AccountingConfiguration::TierListType::value_type(
+			tier_id, AccountingConfiguration::TierInformation()))
+		.first->second;
+
+	_token = nextToken();
+	while (_token != '}') {
+		if (_token != token_identifier)
+			return unexpectedToken(EBADF, "bundle name (identifier) or '}'");
+
+		bundles.insert(getUTF8(_identifier_token.c_str()));
+
+		if ((_token = nextToken()) == ',')
+			_token = nextToken();
+	}
+
+	return 0;
+}
+
+int AccountingConfigurationParser::parseAccount()
+{
+	if (_token != token_account) return ENOENT;
+
+	if ((_token = nextToken()) != '{')
+		return unexpectedToken(EBADF, "'{'");
+
+	tier_id_t caller_tier_id, called_tier_id;
+
+	_token = nextToken();
+	if (_token == token_any_tier)
+		caller_tier_id = invalidTierID;
+	else if (_token == token_integer)
+		caller_tier_id = _integer_token;
+	else
+		return unexpectedToken(EBADF, "caller tier identifier (integer)");
+
+	if ((_token = nextToken()) != ',')
+		return unexpectedToken(EBADF, "','");
+
+	_token = nextToken();
+	if (_token == token_any_tier)
+		called_tier_id = invalidTierID;
+	else if (_token == token_integer)
+		called_tier_id = _integer_token;
+	else
+		return unexpectedToken(EBADF, "called tier identifier (integer)");
+
+	const UTF8 *bundle_name = nullptr, *interface_name = nullptr;
+	const UTF8 *method_name = nullptr;
+
+	if ((_token = nextToken()) == '/') {
+		if ((_token = nextToken()) != token_identifier)
+			return unexpectedToken(EBADF, "bundle name (identifier)");
+
+		if (_identifier_token.length() > 0 &&
+			_identifier_token.compare("_") != 0)
+		{
+			bundle_name = getUTF8(_identifier_token.c_str());
+		}
+
+		if ((_token = nextToken()) == '/') {
+			if ((_token = nextToken()) != token_identifier)
+				return unexpectedToken(EBADF, "interface name (identifier)");
+
+			if (_identifier_token.length() > 0) {
+				// Convert interface name to internal name
+				std::replace(_identifier_token.begin(), _identifier_token.end(), '.', '/');
+				interface_name = getUTF8(_identifier_token.c_str());
+			}
+
+			if ((_token = nextToken()) == '/') {
+				if ((_token = nextToken()) != token_identifier)
+					return unexpectedToken(EBADF, "method name (identifier)");
+
+				if (_identifier_token.length() > 0)
+					method_name = getUTF8(_identifier_token.c_str());
+				_token = nextToken();
+			}
+		}
+	}
+
+	if (_token != ',')
+		return unexpectedToken(EBADF, "'/' or ','");
+
+	bool charge_called;
+
+	_token = nextToken();
+	if (_token == token_called)
+		charge_called = true;
+	else if (_token == token_caller)
+		charge_called = false;
+	else
+		return unexpectedToken(EBADF, "'caller' or 'called'");
+
+	if ((_token = nextToken()) != '}')
+		return unexpectedToken(EBADF, "'}'");
+
+	_config._accounting_rule_list.insert(
+		AccountingConfiguration::AccountingRuleListType::value_type(
+			CallConfiguration(caller_tier_id, called_tier_id,
+				bundle_name, interface_name, method_name),
+			charge_called));
+
+	return 0;
+}
+
+int AccountingConfigurationParser::parse(const char* sourceText)
+{
+	if (!sourceText || !(*sourceText)) return 0;
+
+	_input = sourceText;
+
+	auto r = 0;
+
+	for (;;) {
+		if ((_token = nextToken()) == 0) return 0;	// Done
+		if (_token == token_error)
+			return unexpectedToken(EBADF, "'tier' or 'account'");
+
+		if ((r = parseTier()) == 0) continue;
+		if (r != ENOENT) return r;
+
+		if ((r = parseAccount()) == 0) continue;
+		if (r != ENOENT) return r;
+
+		return unexpectedToken(EBADF, "'tier' or 'account'");
+	}
+
+	return r;
+}
+
+int AccountingConfigurationParser::nextToken()
+{
+	while (*_input != '\0') {
+		for (; isspace(*_input); ++_input);	// Skip spaces and tabs
+
+		if (*_input == '#') {	// Comment
+			for (; (*_input != '\n') && (*_input != '\0'); ++_input);
+			for (; (*_input == '\n') || (*_input == '\r'); ++_input);
+		} else {
+			break;
+		}
+	}
+	if (!(*_input)) return 0;
+
+	_token_start = _input;
+	if (*_input == '*') {++_input; return token_any_tier;}
+
+	if (isdigit(*_input)) {
+		char *endp = nullptr;
+
+		_integer_token = (int)strtol(_input, &endp, 10);
+		if (errno == ERANGE)
+			return parseError(token_error, "Integer is out of range");
+
+		_input = endp;
+		return token_integer;
+	}
+
+	if ((*_input == '_') || (*_input == '-') || isalpha(*_input)) {
+		const char* start = _input;
+		for (++_input; (*_input == '_') || (*_input == '-') ||
+			(*_input == '.') || isalnum(*_input);
+			++_input);
+
+		size_t count = _input - start;
+		if (count == 4 && !strncmp(start, "tier", count))
+			return token_tier;
+		if (count == 7 && !strncmp(start, "account", count))
+			return token_account;
+		if (count == 6 && !strncmp(start, "caller", count))
+			return token_caller;
+		if (count == 6 && !strncmp(start, "called", count))
+			return token_called;
+
+		_identifier_token.assign(start, count);
+		return token_identifier;
+	}
+
+	return *(_input++);
+}
+
+//#########################################################################
+//
+//                        AccountingConfiguration
+//
+//#########################################################################
+
+bool RuntimeAccountingConfiguration::setFrameworkBundleName()
+{
+	BundleStateMonitor::BundleInformation bi;
+	if (!_bundle_state_monitor.getBundleInfoByID(0, bi)) return false;
+
+	TierInformation ti { bi.name };
+	_tier_list[frameworkTierID] = ti;
+	return true;
+}
+
+tier_id_t AccountingConfiguration::getTierOfBundleName(
+	const vmkit::UTF8* bundleName) const
+{
+	auto e = _tier_list.end();
+	auto f = std::find_if(_tier_list.begin(), e,
+		[bundleName] (const TierListType::value_type& element) {
+			assert(element.first != unspecifiedTierID &&
+				element.first != runtimeTierID);
+			return element.second.find(bundleName) != element.second.end();
+		});
+
+	// Some bundles are not associated with any tiers
+	return (f == e) ? unspecifiedTierID : f->first;
+}
+
+bool AccountingConfiguration::findNearestCallConfiguration(
+	const CallConfiguration& call_config,
+	AccountingRuleListType::const_iterator& found) const
+{
+	if (call_config._called_tier_id == invalidTierID) return false;
+
+	// Look for the rule, from exact form to all possible generic forms.
+	auto e = _accounting_rule_list.end();
+	auto f = e;
+	auto notFound = false;
+	auto called(call_config);
+
+	do {
+		f = std::find_if(_accounting_rule_list.begin(), e,
+			[&called] (const AccountingRuleListType::value_type& element) {
+				return element.first == called;
+		});
+		notFound = (f == e);
+	} while (notFound && called.genericize());
+
+	if (!notFound) found = f;
+	return !notFound;
+}
+
+bool AccountingConfiguration::findNearestCallConfiguration(
+	const CallConfiguration& call_config,
+	AccountingRuleListType::iterator& found)
+{
+	AccountingRuleListType::const_iterator i;
+	auto r = this->findNearestCallConfiguration(call_config, i);
+	if (r) const_cast_iterator(_accounting_rule_list, i, found);
+	return r;
+}
+
+bool AccountingConfiguration::getDefaultAccountingChargedToCaller(
+	const CallConfiguration& call_config) const
+{
+	// By default, the runtime is not charged for resources allocated
+	// in order to serve requests. However, it is charged for independent
+	// threads (running only runtime code).
+
+	if (call_config._caller_tier_id == runtimeTierID &&
+		call_config._called_tier_id == runtimeTierID)
+		return true;
+
+	if (call_config._caller_tier_id == runtimeTierID)
+		return false;
+
+	if (call_config._called_tier_id == runtimeTierID)
+		return true;
+
+	return true;	// Default behavior: charge to the caller
+}
+
+bool AccountingConfiguration::isAccountingChargedToCaller(
+	const CallConfiguration& call_config) const
+{
+	assert(((call_config._caller_tier_id != invalidTierID)
+		&& (call_config._called_tier_id != invalidTierID))
+		&& "Invalid tierID for caller and called");
+
+	if ((call_config._caller_tier_id != call_config._called_tier_id) ||
+		(call_config._called_bundle_name != nullptr) ||
+		(call_config._called_interface_name != nullptr) ||
+		(call_config._called_method_name != nullptr))
+	{
+		AccountingRuleListType::const_iterator i;
+		if (this->findNearestCallConfiguration(call_config, i))
+			return !i->second;
+	}
+
+	return getDefaultAccountingChargedToCaller(call_config);
+}
+
+std::ostream& operator << (
+	std::ostream& os, const AccountingConfiguration::TierInformation& obj)
+{
+	os << '{';
+	for (const auto& i : obj)
+		os << *i << ' ';
+	return os << '}';
+}
+
+std::ostream& operator << (std::ostream& os,
+	const AccountingConfiguration::AccountingRuleListType& obj)
+{
+	os << '{';
+	for (const auto& i : obj) {
+		os << i.first << (i.second ? ":called " : ":caller ");
+	}
+	return os << '}';
+}
+
+std::ostream& operator << (std::ostream& os, const AccountingConfiguration& obj)
+{
+	os << "AccountingConfiguration=tiers{";
+
+	for (const auto& i : obj.getTierList())
+		os << (int)i.first << '=' << i.second << ',';
+
+	return os << "},rules=" << obj.getAccountingRuleList() << endl;
+}
+
+//#########################################################################
+//
+//                    RuntimeAccountingConfiguration
+//
+//#########################################################################
+
+tier_id_t RuntimeAccountingConfiguration::getTierOfBundleID(
+	bundle_id_t bundleID) const
+{
+	BundleStateMonitor::BundleInformation bi;
+	if (!_bundle_state_monitor.getBundleInfoByID(bundleID, bi))
+		return invalidTierID;	// Invalid bundle ID
+
+	return getTierOfBundleName(bi.name);
+}
+
+tier_id_t RuntimeAccountingConfiguration::getTierOfCommonClass(
+	const j3::CommonClass* ccl) const
+{
+	BundleStateMonitor::BundleInfoType::const_iterator i;
+	if (!_bundle_state_monitor.getBundleInfoByClassLoader(ccl->classLoader, i)){
+		// Class loader without a bundle ID: Not a bundle class loader.
+		return runtimeTierID;
+	}
+
+	return getTierOfBundleName(i->second.name);
+}
+
+}
+}
+
+#endif

Added: vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.h?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.h (added)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/AccountingConfiguration.h Thu Oct  9 03:43:38 2014
@@ -0,0 +1,197 @@
+
+#ifndef ACCOUNTING_CONFIGURATION_H_
+#define ACCOUNTING_CONFIGURATION_H_
+
+#include <cstdlib>
+#include <cstdint>
+#include "vmkit/config.h"
+#include "UTF8.h"
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+
+namespace j3 {
+namespace OSGi {
+
+typedef uint16_t		tier_id_t;
+
+static const size_t tierCountBits = 16;
+static const tier_id_t invalidTierID = (1 << tierCountBits) - 1;
+static const tier_id_t unspecifiedTierID = invalidTierID - 1;
+static const tier_id_t runtimeTierID = 0;
+static const tier_id_t frameworkTierID = 1;
+
+
+class CallConfiguration
+{
+public:
+	tier_id_t			_caller_tier_id, _called_tier_id;
+	const vmkit::UTF8*	_called_bundle_name;
+	const vmkit::UTF8*	_called_interface_name;
+	const vmkit::UTF8*	_called_method_name;
+
+	CallConfiguration(
+		tier_id_t callerTierID = invalidTierID,
+		tier_id_t calledTierID = invalidTierID,
+		const vmkit::UTF8* calledBundleName = nullptr,
+		const vmkit::UTF8* calledInterfaceName = nullptr,
+		const vmkit::UTF8* calledMethodName = nullptr);
+
+	void reset() {set(invalidTierID, invalidTierID, nullptr, nullptr, nullptr);}
+	void set(
+		tier_id_t callerTierID, tier_id_t calledTierID,
+		const vmkit::UTF8* calledBundleName,
+		const vmkit::UTF8* calledInterfaceName,
+		const vmkit::UTF8* calledMethodName);
+
+	int compare(const CallConfiguration&) const;
+	bool genericize();
+
+	void dump() const __attribute__((noinline));
+
+	bool operator == (const CallConfiguration& o) const
+		{return this->compare(o) == 0;}
+	bool operator < (const CallConfiguration& o) const
+		{return this->compare(o) < 0;}
+
+	friend std::ostream& operator << (std::ostream&, const CallConfiguration&);
+};
+
+}
+}
+
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+
+#include <iostream>
+#include <map>
+#include <set>
+#include <vector>
+
+#include "OSGiBundleStateMonitor.h"
+
+namespace j3 {
+namespace OSGi {
+
+class AccountingConfigurationParser
+{
+protected:
+	enum TokenID {
+		token_error = -1,
+		token_any_tier = -100,
+		token_integer,
+		token_identifier,
+		token_tier,
+		token_account,
+		token_caller,
+		token_called
+	};
+
+	const char	*_input, *_token_start;
+	std::string	_identifier_token;
+	int			_token, _integer_token;
+	static const std::vector<std::string> _token_name;
+	UTF8Map*	_hash_map;
+	std::string	_errorDescription;
+	class AccountingConfiguration& _config;
+
+public:
+	AccountingConfigurationParser(
+		AccountingConfiguration& config, UTF8Map* hashMap);
+	virtual ~AccountingConfigurationParser() {}
+
+	static int load(AccountingConfiguration& config,
+		const char* config_file, std::string& errorDescription,
+		UTF8Map* hashMap);
+
+	const std::string& getErrorDescription() const {return _errorDescription;}
+
+protected:
+	int parse(const char* sourceText);
+	int parseTier();
+	int parseAccount();
+
+	int unexpectedToken(int r, const std::string& expected);
+	int parseError(int r, const std::string& message);
+	int nextToken();
+
+	const std::string& tokenName(int token) const
+		{return _token_name[token - token_error];}
+
+	const UTF8* getUTF8(const char* str)
+		{return _hash_map->lookupOrCreateAsciiz(str);}
+};
+
+// This configuration is supposed to be immutable before any Java code
+// starts running.
+class AccountingConfiguration
+{
+public:
+	typedef std::set<
+		const vmkit::UTF8* /* bundle name */,
+		vmkit::UTF8_Comparator>						TierInformation;
+	typedef std::map<tier_id_t, TierInformation>	TierListType;
+	typedef std::map<
+		const CallConfiguration,
+		bool /* charge called? */>					AccountingRuleListType;
+
+protected:
+	TierListType			_tier_list;
+	AccountingRuleListType	_accounting_rule_list;
+
+public:
+	virtual ~AccountingConfiguration() {}
+
+	const TierListType& getTierList() const {return _tier_list;}
+	const AccountingRuleListType& getAccountingRuleList() const
+		{return _accounting_rule_list;}
+
+	bool isValidTier(tier_id_t tierID) const
+		{return (_tier_list.find(tierID) != _tier_list.end());}
+
+	tier_id_t getTierOfBundleName(const vmkit::UTF8* bundleName) const;
+
+	bool findNearestCallConfiguration(const CallConfiguration&,
+		AccountingRuleListType::const_iterator&) const;
+	bool findNearestCallConfiguration(const CallConfiguration&,
+		AccountingRuleListType::iterator&);
+
+	bool getDefaultAccountingChargedToCaller(
+		const CallConfiguration& call_config) const;
+
+	bool isAccountingChargedToCaller(
+		const CallConfiguration& call_config) const;
+
+	friend std::ostream& operator << (
+		std::ostream&, const AccountingConfiguration&);
+	friend std::ostream& operator << (
+		std::ostream&, const TierInformation&);
+	friend std::ostream& operator << (
+		std::ostream&, const AccountingRuleListType&);
+
+	friend class AccountingConfigurationParser;
+};
+
+// This class adds the variable information to the accounting configuration.
+class RuntimeAccountingConfiguration :
+	public AccountingConfiguration
+{
+protected:
+	const BundleStateMonitor& _bundle_state_monitor;
+
+public:
+	RuntimeAccountingConfiguration(const BundleStateMonitor& bsm) :
+		_bundle_state_monitor(bsm) {}
+
+public:
+	tier_id_t getTierOfBundleID(bundle_id_t bundleID) const;
+	tier_id_t getTierOfCommonClass(const j3::CommonClass* ccl) const;
+
+	bool setFrameworkBundleName();
+};
+
+}
+}
+
+#endif
+#endif

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.cpp Thu Oct  9 03:43:38 2014
@@ -2349,8 +2349,8 @@ void JavaField::setStaticField(JavaObjec
 
 std::ostream& j3::operator << (std::ostream& os, const CommonClass& ccl)
 {
-	os << *ccl.name;
-	return (!ccl.super) ? (os << ';') : (os << ':' << *ccl.super);
+	return os << *ccl.name << ';';
+//	return (!ccl.super) ? (os << ';') : (os << ':' << *ccl.super);
 }
 
 void CommonClass::dump() const

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaClass.h Thu Oct  9 03:43:38 2014
@@ -1015,7 +1015,7 @@ public:
 // Upcalls from JnJVM code to Java code. 
 //
 //===----------------------------------------------------------------------===//
-  
+
 #define DO_TRY
 #define DO_CATCH if (th->pendingException) { th->throwFromJava(); }
 
@@ -1023,12 +1023,15 @@ private:
 	jvalue* marshalArguments(vmkit::ThreadAllocator& allocator, va_list ap);
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) {
+	TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf)
+		__attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 		verifyNull(obj);
 
 		void* func = this->compiledPtr();
-		FUNC_TYPE_VIRTUAL_BUF call = (FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf();
+		FUNC_TYPE_VIRTUAL_BUF call =
+			(FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf();
 
 		JavaThread* th = JavaThread::get();
 		th->startJava();
@@ -1043,11 +1046,14 @@ private:
 	}
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) {
+	TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf)
+		__attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 
 		UserCommonClass* theClass = JavaObject::getClass(obj);
-		UserClass* objCl = theClass->isArray() ? theClass->super : theClass->asClass();
+		UserClass* objCl =
+			theClass->isArray() ? theClass->super : theClass->asClass();
 
 		JavaMethod* meth = this;
 		if ((objCl != classDef) && !isFinal(access)) {
@@ -1057,18 +1063,22 @@ private:
 
 		assert(objCl->isSubclassOf(meth->classDef) && "Wrong type");
 
-		return meth->invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buf);
+		return meth->invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(
+			vm, cl, obj, buf);
 	}
 
 	template<class TYPE, class FUNC_TYPE_STATIC_BUF>
-	TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl, void* buf) __attribute__((noinline)) {
+	TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl, void* buf)
+		__attribute__((noinline))
+	{
 		if (!cl->isReady()) {
 			cl->resolveClass();
 			cl->initialiseClass(vm);
 		}
 
 		void* func = this->compiledPtr();
-		FUNC_TYPE_STATIC_BUF call = (FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf();
+		FUNC_TYPE_STATIC_BUF call =
+			(FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf();
 
 		JavaThread* th = JavaThread::get();
 		th->startJava();
@@ -1083,44 +1093,64 @@ private:
 	}
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) {
+	TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap)
+		__attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 		assert(cl && "Class is NULL");
 		vmkit::ThreadAllocator allocator;
 		jvalue* buffer = marshalArguments(allocator, ap);
-		return invokeVirtualBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buffer);
+		return invokeVirtualBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(
+			vm, cl, obj, buffer);
 	}
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) {
+	TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap)
+		__attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 		assert(cl && "Class is NULL");
 		vmkit::ThreadAllocator allocator;
 		jvalue* buffer = marshalArguments(allocator, ap);
-		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buffer);
+		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(
+			vm, cl, obj, buffer);
 	}
 
 	template<class TYPE, class FUNC_TYPE_STATIC_BUF>
-	TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl, va_list ap) __attribute__((noinline)) {
+	TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl, va_list ap)
+		__attribute__((noinline))
+	{
 		assert(cl && "Class is NULL");
 		vmkit::ThreadAllocator allocator;
 		jvalue* buffer = marshalArguments(allocator, ap);
 		return invokeStaticBuf<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, buffer);
 	}
 
+#undef DO_TRY
+#undef DO_CATCH
+
 #define JavaMethod_DECL_INVOKE_VA(TYPE, TYPE_NAME) \
+	TYPE invoke##TYPE_NAME##Virtual(Jnjvm* vm, JavaMethod* intendedMethodToCall, UserClass* cl, JavaObject* obj, ...) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##Virtual(Jnjvm* vm, UserClass* cl, JavaObject* obj, ...) __attribute__ ((noinline));	\
+	TYPE invoke##TYPE_NAME##Special(Jnjvm* vm, JavaMethod* intendedMethodToCall, UserClass* cl, JavaObject* obj, ...) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##Special(Jnjvm* vm, UserClass* cl, JavaObject* obj, ...) __attribute__ ((noinline));	\
+	TYPE invoke##TYPE_NAME##Static(Jnjvm* vm, JavaMethod* intendedMethodToCall, UserClass* cl, ...) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##Static(Jnjvm* vm, UserClass* cl, ...) __attribute__ ((noinline));
 
 #define JavaMethod_DECL_INVOKE_AP(TYPE, TYPE_NAME)	\
+	TYPE invoke##TYPE_NAME##VirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap, JavaMethod* intendedMethodToCall) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##VirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__ ((noinline));	\
+	TYPE invoke##TYPE_NAME##SpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap, JavaMethod* intendedMethodToCall) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##SpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__ ((noinline));	\
+	TYPE invoke##TYPE_NAME##StaticAP(Jnjvm* vm, UserClass* cl, va_list ap, JavaMethod* intendedMethodToCall) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##StaticAP(Jnjvm* vm, UserClass* cl, va_list ap) __attribute__ ((noinline));
 
 #define JavaMethod_DECL_INVOKE_BUF(TYPE, TYPE_NAME)	\
+	TYPE invoke##TYPE_NAME##VirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf, JavaMethod* intendedMethodToCall) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##VirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__ ((noinline));	\
+	TYPE invoke##TYPE_NAME##SpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf, JavaMethod* intendedMethodToCall) __attribute__ ((noinline));	\
 	TYPE invoke##TYPE_NAME##SpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__ ((noinline));	\
+ 	TYPE invoke##TYPE_NAME##StaticBuf(Jnjvm* vm, UserClass* cl, void* buf, JavaMethod* intendedMethodToCall) __attribute__ ((noinline));					\
  	TYPE invoke##TYPE_NAME##StaticBuf(Jnjvm* vm, UserClass* cl, void* buf) __attribute__ ((noinline));
 
 #define JavaMethod_DECL_INVOKE(TYPE, TYPE_NAME) \

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaMetaJIT.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaMetaJIT.cpp Thu Oct  9 03:43:38 2014
@@ -69,19 +69,19 @@ jvalue* JavaMethod::marshalArguments(vmk
 		return res;	\
 	}	\
 	TYPE JavaMethod::invoke##TYPE_NAME##Special(Jnjvm* vm, UserClass* cl, JavaObject* obj, ...) {	\
-	  llvm_gcroot(obj, 0);	\
-	  va_list ap;	\
-	  va_start(ap, obj);	\
-	  TYPE res = invokeSpecialAP<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, ap);	\
-	  va_end(ap);	\
-	  return res;	\
+		llvm_gcroot(obj, 0);	\
+		va_list ap;	\
+		va_start(ap, obj);	\
+		TYPE res = invokeSpecialAP<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, ap);	\
+		va_end(ap);	\
+		return res;	\
 	}	\
 	TYPE JavaMethod::invoke##TYPE_NAME##Static(Jnjvm* vm, UserClass* cl, ...) {	\
-	  va_list ap;	\
-	  va_start(ap, cl);	\
-	  TYPE res = invokeStaticAP<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, ap);	\
-	  va_end(ap);	\
-	  return res;	\
+		va_list ap;	\
+		va_start(ap, cl);	\
+		TYPE res = invokeStaticAP<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, ap);	\
+		va_end(ap);	\
+		return res;	\
 	}
 
 #define JavaMethod_INVOKE_AP(TYPE, TYPE_NAME, FUNC_TYPE_VIRTUAL_AP, FUNC_TYPE_STATIC_AP, FUNC_TYPE_VIRTUAL_BUF, FUNC_TYPE_STATIC_BUF)	\
@@ -104,7 +104,7 @@ jvalue* JavaMethod::marshalArguments(vmk
 	} 																										\
 	TYPE JavaMethod::invoke##TYPE_NAME##SpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) {	\
 		llvm_gcroot(obj, 0); 																				\
-		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buf); 							\
+		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buf);								\
 	}																										\
 	TYPE JavaMethod::invoke##TYPE_NAME##StaticBuf(Jnjvm* vm, UserClass* cl, void* buf) {					\
 		return invokeStaticBuf<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, buf); 									\

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.cpp Thu Oct  9 03:43:38 2014
@@ -387,9 +387,11 @@ bool JavaObject::instanceOf(JavaObject*
 std::ostream& j3::operator << (std::ostream& os, const JavaObject& obj)
 {
 	JavaObject* javaLoader = NULL;
-	const JavaString* threadNameObj = NULL;
+	const JavaString* jstr = NULL;
+	const JavaObjectVMThread* vmthObj = NULL;
 	llvm_gcroot(javaLoader, 0);
-	llvm_gcroot(threadNameObj, 0);
+	llvm_gcroot(jstr, 0);
+	llvm_gcroot(vmthObj, 0);
 
 	if (VMClassLoader::isVMClassLoader(&obj)) {
 		JnjvmClassLoader* loader = ((const VMClassLoader&)obj).getClassLoader();
@@ -416,24 +418,31 @@ std::ostream& j3::operator << (std::ostr
 		os << &obj << "(class=" << *ccl;
 
 		if (ccl == vm->upcalls->newThread) {
-			threadNameObj = static_cast<const JavaString*>(
+			jstr = static_cast<const JavaString*>(
 				vm->upcalls->threadName->getInstanceObjectField(
 					const_cast<JavaObject*>(&obj)));
 
-			char *threadName = JavaString::strToAsciiz(threadNameObj);
-			os << ",name=\"" << threadName << '\"';
-			delete [] threadName;
+			os << ",name=" << *jstr;
 		}
 #ifndef	 OpenJDKPath
 		else if (ccl == vm->upcalls->newVMThread) {
-			const JavaObjectVMThread& vmthObj = (const JavaObjectVMThread&)obj;
-			for (int retries = 10; (!vmthObj.vmdata) && (retries >= 0); --retries)
+			vmthObj = static_cast<const JavaObjectVMThread*>(&obj);
+			for (int retries = 10; (!vmthObj->vmdata) && (retries >= 0); --retries)
 				usleep(100);
 
-			if (const JavaObject* thObj = vmthObj.vmdata->currentThread())
+			if (const JavaObject* thObj = vmthObj->vmdata->currentThread())
 				os << ",thread=" << *thObj;
 		}
 #endif
+		else if (ccl == vm->upcalls->newClass) {
+			ccl = JavaObjectClass::getClass(
+				const_cast<JavaObjectClass*>(
+					static_cast<const JavaObjectClass*>(&obj)));
+
+			os << ",name=\"" << *ccl->asClass() << '\"';
+		} else if (ccl == vm->upcalls->newString) {
+			os << ',' << static_cast<const JavaString&>(obj);
+		}
 
 		os << ')';
 	}
@@ -450,3 +459,22 @@ void JavaObject::dumpClass() const
 {
 	JavaObject::getClass(this)->dump();
 }
+
+void JavaObject::dumpToString() const
+{
+	JavaString* jstr = NULL;
+	llvm_gcroot(jstr, 0);
+
+	if (VMClassLoader::isVMClassLoader(this) || VMStaticInstance::isVMStaticInstance(this))
+	{cerr << "<invalid>" << endl; return;}
+
+	Class* cl = JavaObject::getClass(this)->asClass();
+	if (!cl) {cerr << "<invalid>" << endl; return;}
+
+	Jnjvm* vm = cl->classLoader->getJVM();
+	jstr = static_cast<JavaString*>(
+		vm->upcalls->toString->invokeJavaObjectVirtual(
+			vm, cl, const_cast<JavaObject*>(this)));
+
+	cerr << *jstr << endl;
+}

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaObject.h Thu Oct  9 03:43:38 2014
@@ -334,6 +334,7 @@ public:
   void dumpClass() const __attribute__((noinline));
   void dump() const __attribute__((noinline));
   friend std::ostream& operator << (std::ostream&, const JavaObject&);
+  void dumpToString() const __attribute__((noinline));
 };
 
 

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaRuntimeJIT.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaRuntimeJIT.cpp Thu Oct  9 03:43:38 2014
@@ -110,10 +110,9 @@ extern "C" void* j3StaticFieldLookup(Use
 }
 
 // Throws if the method is not found.
-extern "C" uint32 j3VirtualTableLookup(UserClass* caller, uint32 index,
-                                       uint32* offset, JavaObject* obj) {
+extern "C" void* j3VirtualTableLookup(UserClass* caller, uint32 index,
+                                       void** javaMethod, JavaObject* obj) {
   llvm_gcroot(obj, 0);
-  uint32 res = 0;
   
   UserCommonClass* cl = 0;
   const UTF8* utf8 = 0;
@@ -134,15 +133,13 @@ extern "C" uint32 j3VirtualTableLookup(U
       JavaObject::getClass(obj)->asClass();
     dmeth = lookup->lookupMethod(utf8, sign->keyName, false, true, 0);
   } else {
-    *offset = dmeth->offset;
+    *javaMethod = dmeth;
   }
 
   assert(dmeth->classDef->isInitializing() && 
          "Class not ready in a virtual lookup.");
 
-  res = dmeth->offset;
-
-  return res;
+  return dmeth;
 }
 
 // Throws if the class is not found.

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.cpp Thu Oct  9 03:43:38 2014
@@ -120,4 +120,28 @@ const UTF8* JavaString::javaToInternal(c
   return res;
 }
 
+std::ostream& operator << (std::ostream& os, const JavaString& jstr)
+{
+	char *str = JavaString::strToAsciiz(&jstr);
+	os << '\"' << str << '\"';
+	delete [] str;
+	return os;
+}
+
+const UTF8* JavaString::toUTF8(const JavaString* self, UTF8Map* hashMap)
+{
+	if (!self) return NULL;
+	if (!hashMap) {
+		Jnjvm* vm = JavaThread::get()->getJVM();
+		hashMap = vm->bootstrapLoader->hashUTF8;
+	}
+
+	const j3::ArrayUInt16 *array = j3::JavaString::getValue(self);
+	const j3::ArrayUInt16::ElementType *elts =
+		j3::ArrayUInt16::getElements(array);
+	size_t count = j3::ArrayUInt16::getSize(array);
+
+	return hashMap->lookupOrCreateReader(elts, count);
+}
+
 }

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaString.h Thu Oct  9 03:43:38 2014
@@ -59,9 +59,12 @@ class JavaString : public JavaObject {
   static char* strToAsciiz(const JavaString* self);
   static char* strToAsciiz(const JavaString* self, vmkit::ThreadAllocator* allocator);
   static const ArrayUInt16* strToArray(JavaString* self, Jnjvm* vm);
+  static const UTF8* toUTF8(const JavaString* self, UTF8Map* hashMap);
 
   /// javaToInternal - Replaces all '/' into '.'.
   static const UTF8* javaToInternal(const JavaString* self, UTF8Map* map);
+
+  friend std::ostream& operator << (std::ostream&, const JavaString&);
 };
 
 } // end namespace j3

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.cpp Thu Oct  9 03:43:38 2014
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <sstream>
+#include <errno.h>
 
 #include "vmkit/Locks.h"
 #include "vmkit/Thread.h"
@@ -132,7 +133,7 @@ void JavaThread::printJavaBacktrace() {
 
   while (vmkit::FrameInfo* FI = Walker.get()) {
     if (FI->Metadata != NULL) {
-      MyVM->printMethod(FI, Walker.ip, Walker.addr);
+      MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress);
     }
     ++Walker;
   }

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JavaThread.h Thu Oct  9 03:43:38 2014
@@ -11,6 +11,7 @@
 #define JNJVM_JAVA_THREAD_H
 
 #include <ostream>
+#include <vector>
 
 #include "vmkit/Cond.h"
 #include "vmkit/Locks.h"

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.cpp Thu Oct  9 03:43:38 2014
@@ -44,6 +44,7 @@ const char* Jnjvm::dirSeparator = "/";
 const char* Jnjvm::envSeparator = ":";
 const unsigned int Jnjvm::Magic = 0xcafebabe;
 
+
 /**
  * In JVM specification, the virtual machine should execute some code when
  *  the application finish.
@@ -1079,18 +1080,42 @@ JnjvmClassLoader* Jnjvm::loadAppClassLoa
   JavaObject* loader = 0;
   llvm_gcroot(loader, 0);
   
-  if (appClassLoader == NULL) {
-    UserClass* cl = upcalls->newClassLoader;
-    loader = upcalls->getSystemClassLoader->invokeJavaObjectStatic(this, cl);
-    appClassLoader = JnjvmClassLoader::getJnjvmLoaderFromJavaObject(loader,
-                                                                    this);
-    if (argumentsInfo.jarFile) {
-      appClassLoader->loadLibFromJar(this, argumentsInfo.jarFile,
-                                     argumentsInfo.className);
-    } else if (argumentsInfo.className) {
-      appClassLoader->loadLibFromFile(this, argumentsInfo.className);
+  if (appClassLoader != nullptr) return appClassLoader;
+
+  UserClass* cl = upcalls->newClassLoader;
+  loader = upcalls->getSystemClassLoader->invokeJavaObjectStatic(this, cl);
+  appClassLoader = JnjvmClassLoader::getJnjvmLoaderFromJavaObject(loader, this);
+
+#if OSGI_BUNDLE_STATE_INFO
+  if (argumentsInfo.className != nullptr) {
+    bundle_state_monitor.setFrameworkFromMainClass(
+      argumentsInfo.className, appClassLoader);
+  }
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  if (argumentsInfo.className != nullptr) {
+    const char* filename = "./tests/monitoring.rules";
+    std::string errorDescription;
+    auto r = tier_manager.loadAccountingRules(filename, errorDescription);
+
+    if (!r) {
+      std::cout << "Accounting configuration rules loaded from '" << filename
+        << "'. Status: " << errorDescription << "." << std::endl;
+    } else {
+      std::cout << "Failed to load accounting configuration rules from '"
+        << filename << "'. Error: " << errorDescription << "." << std::endl;
     }
   }
+#endif
+
+  if (argumentsInfo.jarFile) {
+    appClassLoader->loadLibFromJar(this, argumentsInfo.jarFile,
+                                   argumentsInfo.className);
+  } else if (argumentsInfo.className) {
+    appClassLoader->loadLibFromFile(this, argumentsInfo.className);
+  }
+
   return appClassLoader;
 }
 
@@ -1320,6 +1345,7 @@ void Jnjvm::mainJavaStart(JavaThread* th
 
     vm->executeClass(info.className, args);
   }
+
   vm->threadSystem.leave();
 }
 
@@ -1350,6 +1376,10 @@ Jnjvm::Jnjvm(vmkit::BumpPtrAllocator& Al
              vmkit::CompiledFrames** frames,
              JnjvmBootstrapLoader* loader) : 
   VirtualMachine(Alloc, frames), lockSystem(Alloc)
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  , tier_manager(bundle_state_monitor, loader->hashUTF8)
+#endif
 {
   classpath = getenv("CLASSPATH");
   if (classpath == NULL) classpath = ".";
@@ -1553,3 +1583,37 @@ void Jnjvm::printBacktrace()
 	std::cerr << "Back trace:" << std::endl;
 	JavaThread::get()->printJavaBacktrace();
 }
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+
+static std::atomic<uint64_t>	total_created_objects(0);
+static std::atomic<uint64_t>	total_called_methods_count(0);
+
+extern "C" void Jnjvm_newlyCreatedObject()
+{
+	++total_created_objects;
+}
+
+extern "C" void Jnjvm_incrementTotalCalledMethodsCounter(vmkit::Thread* thread)
+{
+	total_called_methods_count += thread->total_called_methods_count;
+	thread->total_called_methods_count = 0;
+}
+
+extern "C" void Jnjvm_dumpGlobalStats()
+{
+	auto th = vmkit::Thread::get();
+	auto tcur = th;
+
+	do {
+		Jnjvm_incrementTotalCalledMethodsCounter(tcur);
+		tcur = (vmkit::Thread*)tcur->next();
+	} while (tcur != th);
+
+	std::cout << "==== STATS ====" << std::endl
+		<< "TotalCreatedObjectsCount=" << total_created_objects
+		<< ",TotalCalledMethodsCount=" << total_called_methods_count
+		<< std::endl;
+}
+
+#endif

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.h?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/Jnjvm.h Thu Oct  9 03:43:38 2014
@@ -27,6 +27,14 @@
 #include "JNIReferences.h"
 #include "LockedMap.h"
 
+#if OSGI_BUNDLE_STATE_INFO
+#include "OSGiBundleStateMonitor.h"
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+#include "OSGiTierManager.h"
+#endif
+
 namespace j3 {
 
 class ArrayUInt16;
@@ -365,6 +373,14 @@ public:
   void loadBootstrap();
 
   static void printBacktrace() __attribute__((noinline));
+
+#if OSGI_BUNDLE_STATE_INFO
+  OSGi::BundleStateMonitor bundle_state_monitor;
+#endif
+
+#if OSGI_BUNDLE_TIER_TAGGING
+  OSGi::TierManager tier_manager;
+#endif
 };
 
 } // end namespace j3

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/JnjvmClassLoader.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/JnjvmClassLoader.cpp Thu Oct  9 03:43:38 2014
@@ -44,7 +44,6 @@
 #include "Reader.h"
 #include "Zip.h"
 
-
 using namespace j3;
 using namespace std;
 
@@ -883,6 +882,10 @@ const UTF8* JnjvmClassLoader::readerCons
 
 JnjvmClassLoader::~JnjvmClassLoader() {
 
+#if OSGI_BUNDLE_STATE_INFO
+  OSGi::BundleStateMonitor::get()->onClassLoaderUnloaded(this);
+#endif
+
   if (vm) {
     vm->removeFrameInfos(TheCompiler);
   }

Added: vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.cpp?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.cpp (added)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.cpp Thu Oct  9 03:43:38 2014
@@ -0,0 +1,340 @@
+
+#include "OSGiBundleStateMonitor.h"
+
+#if OSGI_BUNDLE_STATE_INFO
+
+#include "ClasspathReflect.h"
+#include "Jnjvm.h"
+
+#include <iostream>
+#include <algorithm>
+
+#define DEBUG_VERBOSE_OSGI_STATE_CHANGE	0
+
+using namespace std;
+
+namespace j3 {
+namespace OSGi {
+
+void BundleStateMonitor::BundleInformation::reset()
+{
+	loader = NULL;
+	name = NULL;
+	previousLoaders.clear();
+}
+
+BundleStateMonitor::BundleStateMonitor() :
+	stateEL(NULL), stateEL_user_param(NULL), frameworkFromMainClassSet(false)
+{
+	stateEL = new BundleStateEventListener;
+}
+
+BundleStateMonitor* BundleStateMonitor::get()
+{
+	vmkit::Thread* th = vmkit::Thread::get();
+	assert(th && "Invalid current thread.");
+	if (!th) return NULL;
+
+	Jnjvm* vm = static_cast<Jnjvm*>(th->MyVM);
+	if (!vm) return NULL;
+
+	return &vm->bundle_state_monitor;
+}
+
+void BundleStateMonitor::setStateEventListener(
+	void *user_param, BundleStateEventListener& l)
+{
+	stateEL_user_param = user_param;
+	stateEL = &l;
+}
+
+bool BundleStateMonitor::getBundleInfoByID(
+	bundle_id_t id, BundleInformation& info) const
+{
+	vmkit::LockGuard lg(lock);
+	BundleInfoType::const_iterator i = bundleInfo.find(id), e=bundleInfo.end();
+	if (i == e) return false;
+
+	info = i->second;
+	return true;
+}
+
+bool BundleStateMonitor::getBundleInfoByID(
+	bundle_id_t id, BundleInfoType::iterator& iterator)
+{
+	vmkit::LockGuard lg(lock);
+	iterator = bundleInfo.find(id);
+	return (iterator != bundleInfo.end());
+}
+
+bool BundleStateMonitor::getBundleInfoByClassLoader(
+	const j3::JnjvmClassLoader* loader,
+	BundleInfoType::const_iterator& iterator) const
+{
+	vmkit::LockGuard lg(lock);
+	BundleInfoType::const_iterator i = bundleInfo.begin(), e = bundleInfo.end();
+	for (; i != e; ++i) {
+		if (i->second.loader != loader) {
+			ClassLoaderQueue::const_iterator
+				plb = i->second.previousLoaders.begin(),
+				ple = i->second.previousLoaders.end();
+
+			if (std::find(plb, ple, loader) == ple)
+				continue;
+		}
+
+		iterator = i;
+		return true;
+	}
+
+	return false;
+}
+
+bool BundleStateMonitor::getBundleInfoByClassLoader(
+	const j3::JnjvmClassLoader* loader, BundleInfoType::iterator& iterator)
+{
+	vmkit::LockGuard lg(lock);
+	BundleInfoType::iterator i = bundleInfo.begin(), e = bundleInfo.end();
+	for (; i != e; ++i) {
+		if (i->second.loader != loader) {
+			ClassLoaderQueue::const_iterator
+				plb = i->second.previousLoaders.begin(),
+				ple = i->second.previousLoaders.end();
+
+			if (std::find(plb, ple, loader) == ple)
+				continue;
+		}
+
+		iterator = i;
+		return true;
+	}
+
+	return false;
+}
+
+bool BundleStateMonitor::getBundleInfoByClassLoader(
+	const j3::JnjvmClassLoader* loader,
+	bundle_id_t &id, BundleInformation& info) const
+{
+	vmkit::LockGuard lg(lock);
+	BundleInfoType::const_iterator i;
+	bool found = const_cast<BundleStateMonitor*>(this)->
+		getBundleInfoByClassLoader(loader, i);
+
+	if (found) {
+		id = i->first;
+		info = i->second;
+	} else {
+		id = invalidBundleID;
+		info.reset();
+	}
+	return found;
+}
+
+size_t BundleStateMonitor::getBundleInfoByName(
+	const vmkit::UTF8* name, BundleInfoType& info) const
+{
+	info.clear();
+	size_t count = 0;
+
+	vmkit::LockGuard lg(lock);
+	BundleInfoType::const_iterator i = bundleInfo.begin(), e = bundleInfo.end();
+	for (; i != e; ++i) {
+		if (i->second.name->equals(name)) {
+			info.insert(BundleInfoType::value_type(i->first, i->second));
+			++count;
+		}
+	}
+
+	return count;
+}
+
+void BundleStateMonitor::onBundleResolved(
+	const j3::JavaString* bundleNameObj,
+	jlong bundleID, j3::JavaObject* loaderObject)
+{
+	llvm_gcroot(bundleNameObj, 0);
+	llvm_gcroot(loaderObject, 0);
+
+	Jnjvm* vm = JavaThread::get()->getJVM();
+	j3::JnjvmClassLoader* loader =
+		j3::JnjvmClassLoader::getJnjvmLoaderFromJavaObject(loaderObject, vm);
+	assert((loader != NULL) && "Invalid class loader");
+
+	const vmkit::UTF8* bundleName =
+		j3::JavaString::toUTF8(bundleNameObj, loader->hashUTF8);
+
+	vmkit::LockGuard lg(lock);
+
+	BundleInfoType::iterator info_iterator;
+	if (getBundleInfoByID(bundleID, info_iterator) == false) {
+		// Bundle installed and resolved
+		BundleInformation info;
+		info.loader = loader;
+		info.name = bundleName;
+		bundleInfo.insert(BundleInfoType::value_type(bundleID, info));
+
+		stateEL->onBundleClassLoaderSet(
+			stateEL_user_param, bundleName, bundleID, *loader);
+
+#if DEBUG_VERBOSE_OSGI_STATE_CHANGE
+		cerr << "Bundle resolved: ID=" << bundleID
+			<< "\tclassLoader=" << loader << "\tname=" << *bundleName << endl;
+#endif
+	} else {
+		BundleInformation& info = info_iterator->second;
+		if (info.loader == loader)
+			return;	// Same class loader already associated with the bundle
+
+		// Bundle updated
+		const j3::JnjvmClassLoader* previous_loader = info.loader;
+		if (info.loader == NULL) {
+			if (!info.previousLoaders.empty())
+				previous_loader = info.previousLoaders.front();
+		} else {
+			info.previousLoaders.push_front(info.loader);
+		}
+		info.loader = loader;
+		info.name = bundleName;
+
+		stateEL->onBundleClassLoaderUpdated(
+			stateEL_user_param, bundleName, bundleID,
+			*previous_loader, *loader);
+
+#if DEBUG_VERBOSE_OSGI_STATE_CHANGE
+	cerr << "Bundle updated/resolved: ID=" << bundleID
+		<< "\tclassLoader=" << loader
+		<< "\tpreviousClassLoader=" << previous_loader
+		<< "\tname=" << *bundleName << endl;
+#endif
+	}
+}
+
+void BundleStateMonitor::onBundleUnresolved(
+	const j3::JavaString* bundleNameObj, jlong bundleID)
+{
+	llvm_gcroot(bundleNameObj, 0);
+
+	vmkit::LockGuard lg(lock);
+
+	// Uninstalled bundle
+	BundleInfoType::iterator info_iterator;
+	bool got_state = getBundleInfoByID(bundleID, info_iterator);
+	assert(got_state && "Bundle unresolved but never seen.");
+
+	BundleInformation& info = info_iterator->second;
+	const vmkit::UTF8* bundleName =
+		j3::JavaString::toUTF8(bundleNameObj,
+			(info.loader == NULL) ? NULL : info.loader->hashUTF8);
+
+	const j3::JnjvmClassLoader* previous_loader = info.loader;
+	info.previousLoaders.push_front(info.loader);
+	info.loader = NULL;
+
+	stateEL->onBundleClassLoaderCleared(
+		stateEL_user_param, bundleName, bundleID, *previous_loader);
+
+#if DEBUG_VERBOSE_OSGI_STATE_CHANGE
+	cerr << "Bundle unresolved: ID=" << bundleID
+		<< "\tclassLoader=" << previous_loader
+		<< "\tname=" << *bundleName << endl;
+#endif
+}
+
+void BundleStateMonitor::onClassLoaderUnloaded(
+	const j3::JnjvmClassLoader* loader)
+{
+	vmkit::LockGuard lg(lock);
+	BundleInfoType::iterator info_iterator;
+	if (!getBundleInfoByClassLoader(loader, info_iterator)) return;
+
+	BundleInformation& info = info_iterator->second;
+	assert((info.loader != loader) && "Bundle being unloaded while resolved.");
+
+	info.previousLoaders.remove(loader);
+
+#if DEBUG_VERBOSE_OSGI_STATE_CHANGE
+	cerr << "Bundle class loader unloaded: ID=" << info_iterator->first
+		<< "\tclassLoader=" << loader
+		<< "\tname=" << *info.name << endl;
+#endif
+
+	if ((info.loader == NULL) && info.previousLoaders.empty()) {
+#if DEBUG_VERBOSE_OSGI_STATE_CHANGE
+	cerr << "Bundle unloaded: ID=" << info_iterator->first
+		<< "\tname=" << *info.name << endl;
+#endif
+
+		bundleInfo.erase(info_iterator);
+	}
+}
+
+void BundleStateMonitor::dump() const
+{
+	vmkit::LockGuard lg(lock);
+	BundleInfoType::const_iterator i = bundleInfo.begin(), e = bundleInfo.end();
+	ClassLoaderQueue::const_iterator cli, cle;
+
+	for (; i != e; ++i) {
+		cerr << "Bundle ID=" << i->first
+			<< "\tname=" << *i->second.name
+			<< "\tclassLoader=" << i->second.loader
+			<< "\tpreviousClassLoaders={";
+
+		cli = i->second.previousLoaders.begin();
+		cle = i->second.previousLoaders.end();
+		for (; cli != cle; ++cli)
+			cerr << *cli << ',';
+
+		cerr << '}' << endl;
+	}
+}
+
+void BundleStateMonitor::setFrameworkFromMainClass(
+	const char* mainClassName, const j3::JnjvmClassLoader* loader)
+{
+	// We suppose the framework bundle is the bundle loaded by the main class.
+
+	const auto lastOccurence = strrchr(mainClassName, '.');
+	if (!lastOccurence)
+		return;
+	string packageName(mainClassName, lastOccurence - mainClassName);
+
+	BundleInformation info;
+	info.loader = loader;
+	info.name = loader->hashUTF8->lookupOrCreateAsciiz(packageName.c_str());
+
+	vmkit::LockGuard lg(lock);
+	bundleInfo.insert(BundleInfoType::value_type(0, info));
+
+	frameworkFromMainClassSet = true;
+}
+
+}
+}
+
+extern "C" void Java_j3_vm_OSGi_bundleResolved(
+	j3::JavaString* bundleName, jlong bundleID, j3::JavaObject* loaderObject)
+{
+	llvm_gcroot(bundleName, 0);
+	llvm_gcroot(loaderObject, 0);
+
+	j3::OSGi::BundleStateMonitor::get()->
+		onBundleResolved(bundleName, bundleID, loaderObject);
+}
+
+extern "C" void Java_j3_vm_OSGi_bundleUnresolved(
+	j3::JavaString* bundleName, jlong bundleID)
+{
+	llvm_gcroot(bundleName, 0);
+
+	j3::OSGi::BundleStateMonitor::get()->
+		onBundleUnresolved(bundleName, bundleID);
+}
+
+extern "C" void Java_j3_vm_OSGi_dumpClassLoaderBundles()
+{
+	j3::OSGi::BundleStateMonitor::get()->dump();
+}
+
+#endif

Added: vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.h?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.h (added)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiBundleStateMonitor.h Thu Oct  9 03:43:38 2014
@@ -0,0 +1,119 @@
+
+#ifndef OSGIGATEWAY_H_
+#define OSGIGATEWAY_H_
+
+#include <vmkit/config.h>
+
+#if OSGI_BUNDLE_STATE_INFO
+
+#include "vmkit/Locks.h"
+#include "vmkit/UTF8.h"
+#include "j3/jni.h"
+#include "JavaString.h"
+
+#include <map>
+#include <list>
+
+#include <stdint.h>
+
+namespace j3 {
+
+class JnjvmClassLoader;
+class JavaObjectClass;
+class JavaObject;
+
+namespace OSGi {
+
+typedef int64_t	bundle_id_t;
+static const bundle_id_t invalidBundleID = (bundle_id_t)-1;
+
+
+class BundleStateEventListener
+{
+public:
+	virtual ~BundleStateEventListener() {}
+
+	virtual void onBundleClassLoaderSet(void *user_param,
+		const vmkit::UTF8* bundleName, bundle_id_t bundleID,
+		const j3::JnjvmClassLoader& loader) {}
+
+	virtual void onBundleClassLoaderUpdated(void *user_param,
+		const vmkit::UTF8* bundleName, bundle_id_t bundleID,
+		const j3::JnjvmClassLoader& previous_loader,
+		const j3::JnjvmClassLoader& new_loader) {}
+
+	virtual void onBundleClassLoaderCleared(void *user_param,
+		const vmkit::UTF8* bundleName, bundle_id_t bundleID,
+		const j3::JnjvmClassLoader& previous_loader) {}
+};
+
+
+class BundleStateMonitor
+{
+public:
+	typedef std::list<const j3::JnjvmClassLoader*>	ClassLoaderQueue;
+
+	struct BundleInformation {
+		const j3::JnjvmClassLoader*	loader;
+		const vmkit::UTF8*			name;
+		ClassLoaderQueue			previousLoaders;
+
+		BundleInformation() : loader(nullptr), name(nullptr) {}
+		void reset();
+	};
+
+	typedef std::map<bundle_id_t, BundleInformation> BundleInfoType;
+
+protected:
+
+	mutable vmkit::LockRecursive lock;
+	BundleInfoType bundleInfo;
+	BundleStateEventListener *stateEL;
+	void *stateEL_user_param;
+	bool frameworkFromMainClassSet;
+
+public:
+	BundleStateMonitor();
+	virtual ~BundleStateMonitor() {}
+
+	static BundleStateMonitor* get();
+
+	bool getBundleInfoByID(
+		bundle_id_t id, BundleInformation& info) const;
+	bool getBundleInfoByID(
+		bundle_id_t id, BundleInfoType::iterator& iterator);
+	bool getBundleInfoByClassLoader(const j3::JnjvmClassLoader* loader,
+		bundle_id_t &id, BundleInformation& info) const;
+	bool getBundleInfoByClassLoader(const j3::JnjvmClassLoader* loader,
+		BundleInfoType::iterator& iterator);
+	bool getBundleInfoByClassLoader(const j3::JnjvmClassLoader* loader,
+		BundleInfoType::const_iterator& iterator) const;
+	size_t getBundleInfoByName(
+		const vmkit::UTF8* name, BundleInfoType& info) const;
+
+	void dump() const;
+
+	void setFrameworkFromMainClass(
+		const char* mainClassName, const j3::JnjvmClassLoader* loader);
+	bool isFrameworkFromMainClassSet() {return frameworkFromMainClassSet;}
+
+	void setStateEventListener(
+		void *user_param, BundleStateEventListener& l);
+
+	void onBundleResolved(const j3::JavaString* bundleName, jlong bundleID,
+		j3::JavaObject* loaderObject);
+	void onBundleUnresolved(const j3::JavaString* bundleName, jlong bundleID);
+	void onClassLoaderUnloaded(const j3::JnjvmClassLoader* loader);
+};
+
+}
+}
+
+extern "C" void Java_j3_vm_OSGi_bundleResolved(
+	j3::JavaString* bundleName, jlong bundleID, j3::JavaObject* loaderObject);
+extern "C" void Java_j3_vm_OSGi_bundleUnresolved(
+	j3::JavaString* bundleName, jlong bundleID);
+extern "C" void Java_j3_vm_OSGi_dumpClassLoaderBundles();
+
+#endif
+#endif

Added: vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.cpp?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.cpp (added)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.cpp Thu Oct  9 03:43:38 2014
@@ -0,0 +1,328 @@
+
+#include "OSGiTierManager.h"
+#include "vmkit/StackEmbeddedList.h"
+
+#if OSGI_BUNDLE_TIER_TAGGING
+
+#include "JavaThread.h"
+#include "Jnjvm.h"
+#include "VMStaticInstance.h"
+
+#include <iostream>
+#include <stack>
+
+#include <dlfcn.h>
+
+using namespace std;
+
+#define DEBUG_VERBOSE_ACCOUNTING_OBJECTS	0
+#define DEBUG_VERBOSE_ACCOUNTING_STACK		1
+
+namespace j3 {
+namespace OSGi {
+
+//#########################################################################
+//
+//                         AccountingStatsDataBase
+//
+//#########################################################################
+
+AccountingStatsDataBase::AccountingStatsDataBase() :
+	_now_collecting_stats(false)
+
+#if OSGI_OBJECT_TIER_TAGGING
+	, _mark_state(false)
+#endif
+{
+}
+
+void AccountingStatsDataBase::collectStats()
+{
+	// Initialize counters
+	_db.clear();
+
+#if OSGI_OBJECT_TIER_TAGGING
+	_mark_state = !_mark_state;
+#endif
+
+	// Perform a garbage collection to stop all threads and count memory usage
+	_now_collecting_stats.store(true, memory_order_release);
+
+	vmkit::Collector::collect();
+
+	_now_collecting_stats.store(false, memory_order_release);
+}
+
+std::ostream& operator << (std::ostream& os, const AccountingStatsDataBase& db)
+{
+	os << "Tier memory dump:" << endl;
+
+	for (const auto& i : db._db) {
+		os << "Tier " << (int)i.first;
+#if OSGI_STACK_SPACE_TIER_TAGGING
+		os << "\tstackSize=" << i.second.stack_size;
+#endif
+
+#if OSGI_OBJECT_TIER_TAGGING
+		os << "\tobjectCount=" << i.second.object_count <<
+			"\tclassCount=" << i.second.classes.size() <<
+			"\theapStaticSize=" << i.second.heap_static_size <<
+			"\theapVirtualSize=" << i.second.heap_virtual_size;
+#endif
+		os << endl;
+	}
+	return os << "Tier memory dump [done]." << endl;
+}
+
+//#########################################################################
+//
+//                            TierManager
+//
+//#########################################################################
+
+TierManager::TierManager(const BundleStateMonitor& bsm, UTF8Map* hashMap) :
+	_bundle_state_monitor(bsm), _accounting_config(bsm), _hash_map(hashMap)
+{
+}
+
+int TierManager::loadAccountingRules(
+	const char* config_file, std::string& errorDescription)
+{
+	_accounting_config.setFrameworkBundleName();
+
+	return AccountingConfigurationParser::load(
+		_accounting_config, config_file, errorDescription, _hash_map);
+}
+
+void TierManager::dumpStats()
+{
+	_stats_data_base.collectStats();
+	cout << _stats_data_base << endl;
+}
+
+#if OSGI_OBJECT_TIER_TAGGING
+
+void TierManager::updateTierChargedToNewlyCreatedObject(j3::JavaObject* obj)
+{
+	llvm_gcroot(obj, 0);
+
+	auto thread = j3::JavaThread::get();
+
+	obj->setTierID(
+		(thread->chargedTierID == (uint32_t)-1) ?
+			runtimeTierID :
+			(tier_id_t)thread->chargedTierID);
+
+	obj->setTierObjectMarkState(
+		thread->getJVM()->tier_manager._stats_data_base._mark_state);
+}
+
+void TierManager::accountForLiveObject(j3::JavaObject* obj)
+{
+	llvm_gcroot(obj, 0);
+
+	auto& tm = j3::JavaThread::get()->getJVM()->tier_manager;
+	if (!tm.isCollectingStats()) return;
+
+	if (j3::VMClassLoader::isVMClassLoader(obj) ||
+		j3::VMStaticInstance::isVMStaticInstance(obj))
+		return;
+
+	if (obj->getTierObjectMarkState() == tm._stats_data_base._mark_state)
+		return;	// Already accounted for
+
+	obj->setTierObjectMarkState(tm._stats_data_base._mark_state);
+
+	const auto cl = j3::JavaObject::getClass(obj)->asClass();
+	if (!cl) return;
+
+	tier_id_t tierID = (tier_id_t)obj->getTierID();
+	auto& tier_iter = tm._stats_data_base._db[tierID];
+
+#if DEBUG_VERBOSE_ACCOUNTING_OBJECTS
+	if (tierID != 0)
+		std::cerr << "Tier " << (int)tierID << " object " << *obj << std::endl;
+#endif
+
+	++tier_iter.object_count;
+	tier_iter.heap_virtual_size += cl->getVirtualSize();
+
+	if (tier_iter.classes.insert(cl).second)
+		tier_iter.heap_static_size += cl->getStaticSize();
+}
+
+#endif
+
+#if OSGI_STACK_SPACE_TIER_TAGGING
+
+void TierManager::accountForThreadStack(vmkit::Thread* thread)
+{
+	/* x86 stack frame:
+
+|-| (last method called)
+| |     ...
+| | BP(i-2)
+| |  |  ret addr(i-2)
+| |  |  args(i-2)
+|a|  |  saved regs(i-1)
+|d|  V  locals(i-1)
+|d| BP(i-1)
+|r|  |  ret addr(i-1)
+|e|  |  args(i-1)
+|s|  |  saved regs(i)
+|s|  V  locals(i)
+| | BP(i  )
+| |    ret addr(i)
+| |    args(i)
+| |    ...
+|+| (first caller method)
+
+    BP := call frame address (base pointer).
+*/
+
+	auto& tm = j3::JavaThread::get()->getJVM()->tier_manager;
+	if (!tm.isCollectingStats()) return;
+
+	auto& db = tm._stats_data_base._db;
+	vmkit::StackWalker stackWalker(thread);
+	std::stack<vmkit::StackWalker> stackFrames;
+	auto lastFrameAddress = stackWalker.callFrameAddress;
+	size_t frameSize;
+
+	vmkit::StackEmbeddedListNode *current_node =
+		thread->stackEmbeddedListHead[vmkit::StackEmbeddedListChargedTier];
+
+	for (; current_node != nullptr; current_node = current_node->callerNode) {
+		// Look for the method frame holding the node
+		auto nodeStart = reinterpret_cast<word_t>(current_node);
+		auto nodeEnd = nodeStart + sizeof(*current_node);
+		auto callFrameStart = stackWalker.callFrameAddress;
+		auto callFrameEnd = callFrameStart;
+		auto checkPointFrameAddress = stackWalker.callFrameAddress;
+		auto found = false;
+
+		for (;
+			!found && stackWalker.get() != nullptr;
+			stackFrames.push(stackWalker), ++stackWalker)
+		{
+			callFrameEnd = stackWalker.callFrameAddress;
+			found = (nodeStart >= callFrameStart) && (nodeEnd <= callFrameEnd);
+			callFrameStart = callFrameEnd;
+		}
+
+		if (!found) {
+			// Incomplete stack :-(
+			while (stackFrames.size() != 0 &&
+				stackFrames.top().callFrameAddress != checkPointFrameAddress)
+			{
+				stackFrames.pop();
+			}
+
+			stackWalker = stackFrames.top();
+			stackFrames.pop();
+			continue;
+		}
+
+		if (stackFrames.size() < 2) {
+			// Incomplete stack :-(
+			continue;
+		}
+
+		// Method frame found
+		callFrameEnd = stackFrames.top().callFrameAddress;
+		frameSize = callFrameEnd - lastFrameAddress;
+
+		stackFrames.pop();
+		stackWalker = stackFrames.top();
+		stackFrames.pop();
+
+#if DEBUG_VERBOSE_ACCOUNTING_STACK
+		cout << "# [" << current_node->data[0] << " += "
+			<< frameSize << "]\t";
+
+		if (const auto FI = stackWalker.get()) {
+			if (!FI->Metadata) {
+				Dl_info si = {};
+				auto ra =reinterpret_cast<void*>(stackWalker.returnAddress);
+				if (dladdr(ra, &si) != 0 && si.dli_sname != nullptr)
+					cout << si.dli_sname << endl;
+				else
+					cout << "<native>" << endl;
+			} else {
+				cout << *reinterpret_cast<const JavaMethod*>(FI->Metadata)
+					<< endl;
+			}
+		}
+#endif
+
+		db[current_node->data[0]].stack_size += frameSize;
+		lastFrameAddress = callFrameEnd;
+	}
+
+	frameSize = thread->baseSP - lastFrameAddress;
+	db[runtimeTierID].stack_size += frameSize;
+
+#if DEBUG_VERBOSE_ACCOUNTING_STACK
+	cout << "# [0 += " << frameSize << "]\t<native>" << endl << endl;
+#endif
+}
+
+#endif
+
+}
+}
+
+#if OSGI_STACK_SPACE_TIER_TAGGING
+
+extern "C" void OSGi_TierManager_accountForThreadStack(vmkit::Thread* thread)
+{
+	if (!thread) return;
+	j3::OSGi::TierManager::accountForThreadStack(thread);
+}
+
+#endif
+
+extern "C" void Java_j3_vm_Tier_dumpTierStats()
+{
+	auto& tm = j3::JavaThread::get()->getJVM()->tier_manager;
+	tm.dumpStats();
+}
+
+#endif
+
+#if OSGI_OBJECT_TIER_TAGGING
+
+extern "C" void OSGi_TierManager_updateTierChargedToNewlyCreatedObject(gc* obj)
+{
+#if OSGI_BUNDLE_TIER_TAGGING
+	llvm_gcroot(obj, 0);
+
+	if (!obj) return;
+	j3::OSGi::TierManager::updateTierChargedToNewlyCreatedObject(
+		static_cast<j3::JavaObject*>(obj));
+#endif
+}
+
+extern "C" void OSGi_TierManager_accountForLiveObject(void* obj)
+{
+#if OSGI_BUNDLE_TIER_TAGGING
+	llvm_gcroot(obj, 0);
+
+	if (!obj) return;
+	j3::OSGi::TierManager::accountForLiveObject(
+		static_cast<j3::JavaObject*>(obj));
+#endif
+}
+
+extern "C" jlong Java_j3_vm_Tier_getTierChargedForObject(
+	const j3::JavaObject* obj)
+{
+#if OSGI_BUNDLE_TIER_TAGGING
+	llvm_gcroot(obj, 0);
+	return obj->getTierID();
+#else
+	return 0;
+#endif
+}
+
+#endif

Added: vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.h?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.h (added)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/OSGiTierManager.h Thu Oct  9 03:43:38 2014
@@ -0,0 +1,125 @@
+
+#ifndef OSGITIER_H_
+#define OSGITIER_H_
+
+#include "vmkit/config.h"
+#include "j3/jni.h"
+
+class gc;
+
+
+namespace vmkit {
+
+class UTF8Map;
+class Thread;
+
+}
+
+namespace j3 {
+
+class JnjvmClassLoader;
+class CommonClass;
+class JavaObject;
+
+}
+
+#if OSGI_BUNDLE_TIER_TAGGING
+
+#include "AccountingConfiguration.h"
+
+#include <set>
+#include <map>
+#include <atomic>
+
+namespace j3 {
+namespace OSGi {
+
+class AccountingStatsDataBase
+{
+public:
+	struct Record {
+		size_t	object_count;
+
+#if OSGI_STACK_SPACE_TIER_TAGGING
+		size_t stack_size;
+#endif
+
+#if OSGI_OBJECT_TIER_TAGGING
+		size_t heap_virtual_size, heap_static_size;
+		std::set<const j3::CommonClass*> classes;
+#endif
+	};
+
+	std::atomic<bool>			_now_collecting_stats;
+	std::map<tier_id_t, Record>	_db;
+
+#if OSGI_OBJECT_TIER_TAGGING
+	bool _mark_state;
+#endif
+
+	AccountingStatsDataBase();
+	virtual ~AccountingStatsDataBase() {}
+
+	bool isCollectingStats() const
+		{return _now_collecting_stats.load(std::memory_order_acquire);}
+	void collectStats();
+
+	friend std::ostream& operator << (
+		std::ostream&, const AccountingStatsDataBase&);
+};
+
+
+class TierManager
+{
+protected:
+	const BundleStateMonitor&		_bundle_state_monitor;
+	AccountingStatsDataBase			_stats_data_base;
+	RuntimeAccountingConfiguration	_accounting_config;
+	vmkit::UTF8Map*					_hash_map;
+
+public:
+	TierManager(const BundleStateMonitor& bsm, UTF8Map* hashMap);
+	virtual ~TierManager() {}
+
+	int loadAccountingRules(
+		const char* config_file, std::string& errorDescription);
+
+	const RuntimeAccountingConfiguration& getAccountingConfig() const
+		{return _accounting_config;}
+
+	bool isCollectingStats() const
+		{return _stats_data_base.isCollectingStats();}
+	void dumpStats();
+
+#if OSGI_OBJECT_TIER_TAGGING
+	static void updateTierChargedToNewlyCreatedObject(j3::JavaObject* obj);
+	static void accountForLiveObject(j3::JavaObject* obj);
+#endif
+
+#if OSGI_STACK_SPACE_TIER_TAGGING
+	static void accountForThreadStack(vmkit::Thread* thread);
+#endif
+};
+
+}
+}
+
+#if OSGI_STACK_SPACE_TIER_TAGGING
+
+extern "C" void OSGi_TierManager_accountForThreadStack(vmkit::Thread* th);
+
+#endif
+
+extern "C" void Java_j3_vm_Tier_dumpTierStats();
+
+#endif
+#endif
+
+#if OSGI_OBJECT_TIER_TAGGING
+
+extern "C" void OSGi_TierManager_updateTierChargedToNewlyCreatedObject(gc*);
+extern "C" void OSGi_TierManager_accountForLiveObject(void* obj);
+extern "C" jlong Java_j3_vm_Tier_getTierChargedForObject(
+	const j3::JavaObject* obj);
+
+#endif

Modified: vmkit/branches/memory-monitor/lib/j3/VMCore/Precompiled.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/j3/VMCore/Precompiled.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/j3/VMCore/Precompiled.cpp (original)
+++ vmkit/branches/memory-monitor/lib/j3/VMCore/Precompiled.cpp Thu Oct  9 03:43:38 2014
@@ -119,7 +119,7 @@ bool Precompiled::Init(JnjvmBootstrapLoa
   Class* javaLangObject = (Class*)dlsym(SELF_HANDLE, "java_lang_Object");
   void* nativeHandle = vmkit::System::GetSelfHandle();
   if (javaLangObject == NULL) {
-    void* handle = dlopen("libvmjc"DYLD_EXTENSION, RTLD_LAZY | RTLD_GLOBAL);
+    void* handle = dlopen("libvmjc" DYLD_EXTENSION, RTLD_LAZY | RTLD_GLOBAL);
     if (handle != NULL) {
       nativeHandle = handle;
       javaLangObject = (Class*)dlsym(nativeHandle, "java_lang_Object");

Modified: vmkit/branches/memory-monitor/lib/vmkit/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/CommonThread/CollectionRV.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/CommonThread/CollectionRV.cpp (original)
+++ vmkit/branches/memory-monitor/lib/vmkit/CommonThread/CollectionRV.cpp Thu Oct  9 03:43:38 2014
@@ -103,7 +103,7 @@ void CooperativeCollectionRV::join() {
   th->inRV = true;
   
   lockRV();
-  th->setLastSP(System::GetCallerAddress());
+  th->setLastSP(System::GetCallFrameAddress());
   th->joinedRV = true;
   another_mark();
   waitEndOfRV();

Modified: vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ObjectLocks.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ObjectLocks.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ObjectLocks.cpp (original)
+++ vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ObjectLocks.cpp Thu Oct  9 03:43:38 2014
@@ -7,21 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <cassert>
-
-#include "vmkit/Cond.h"
-#include "vmkit/Locks.h"
 #include "vmkit/ObjectLocks.h"
-#include "vmkit/Thread.h"
-#include "vmkit/VirtualMachine.h"
 #include "VmkitGC.h"
-#include <cerrno>
-#include <sys/time.h>
-#include <pthread.h>
-
-#include "../../j3/VMCore/JavaObject.h"
-#include "../../j3/VMCore/JavaClass.h"
-#include "../../j3/VMCore/UTF8.h"
+#include "vmkit/VirtualMachine.h"
 
 namespace vmkit {
 
@@ -336,8 +324,8 @@ bool FatLock::acquire(gc* obj, LockSyste
 //	if (lockingThreads == 0)
 //      table.deallocate(this);
 
-	word_t methodIP = System::GetCallerAddress();
-	methodIP = System::GetIPFromCallerAddress(methodIP);
+	word_t methodIP = System::GetCallFrameAddress();
+	methodIP = System::GetReturnAddressOfCallFrame(methodIP);
     Thread::get()->throwNullPointerException(methodIP);
   }
 

Modified: vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc (original)
+++ vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc Thu Oct  9 03:43:38 2014
@@ -38,7 +38,7 @@ void Handler::UpdateRegistersForNPE() {
 
 void Handler::UpdateRegistersForStackOverflow() {
   word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart();
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]);
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]);
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSI] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP];
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSP] = alt_stack;
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_RIP] = (word_t)HandleStackOverflow;

Modified: vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc (original)
+++ vmkit/branches/memory-monitor/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc Thu Oct  9 03:43:38 2014
@@ -40,7 +40,7 @@ void Handler::UpdateRegistersForNPE() {
 
 void Handler::UpdateRegistersForStackOverflow() {
   word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart();
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]);
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]);
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_EAX] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP];
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_ESP] = alt_stack;
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP] = (word_t)HandleStackOverflow;

Added: vmkit/branches/memory-monitor/lib/vmkit/CommonThread/StackEmbeddedList.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/CommonThread/StackEmbeddedList.cpp?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/CommonThread/StackEmbeddedList.cpp (added)
+++ vmkit/branches/memory-monitor/lib/vmkit/CommonThread/StackEmbeddedList.cpp Thu Oct  9 03:43:38 2014
@@ -0,0 +1,134 @@
+
+#include "vmkit/StackEmbeddedList.h"
+#include "vmkit/MethodInfo.h"
+
+#include <iostream>
+
+#if 0
+// #if EMBEDDED_LIST_IN_CALL_STACK
+
+namespace vmkit {
+
+bool StackEmbeddedListWalker::findStackFrameOfEmbeddedNode()
+{
+	/* Consider the following x86 stack frame:
+
+|-| (last method called)
+| |     ...
+| | BP(i-2)
+| |  |  ret addr(i-2)
+| |  |  args(i-2)
+|a|  |  saved regs(i-1)
+|d|  V  locals(i-1)
+|d| BP(i-1)
+|r|  |  ret addr(i-1)
+|e|  |  args(i-1)
+|s|  |  saved regs(i)
+|s|  V  locals(i)
+| | BP(i  )
+| |    ret addr(i)
+| |    args(i)
+| |    ...
+|+| (first caller method)
+
+    BP := call frame address (base pointer).
+    The intended caller linked list nodes are generated in the locals area of
+    the caller method frame.
+
+    In order to find the given node in "locals(i)", we need to know where
+    "locals(i)" is located = [BP(i-1), BP(i)].
+    If the node is found in "locals(i)", this means that the frame "i-1" is the
+    caller of the intended method, so the intended method frame itself is "i-2".
+    This is why we need to keep track of the last two stack frames when walking
+    the stack.
+    Because some frames are Java method stub frames, we need to know which
+    frame they call (the actual called Java method). Thus we need to keep the
+    last three stack frames.
+    Because we need to preserve those 4 stack frames, and because we might go
+    backward in the stack queue by at most 3 elements, we need to preserve the
+    stack queue. This is the purpose of walkedStack.
+	*/
+
+	word_t nodeStart = (word_t)_current_node;
+	word_t nodeEnd = nodeStart + sizeof(*_current_node);
+
+	auto callFrameStart = _walked_stack.empty() ?
+		_stack_walker.callFrameAddress :
+		_walked_stack.front().callFrameAddress;
+
+	for (; _stack_walker.get() != nullptr;
+		_walked_stack.push_front(_stack_walker), ++_stack_walker)
+	{
+		auto callFrameEnd = _stack_walker.callFrameAddress;
+
+		if ((nodeStart >= callFrameStart) && (nodeEnd <= callFrameEnd)) {
+			// Found the node, go backward two frames, if possible.
+			switch (_walked_stack.size()) {
+			case 0:
+				// We actually have an incomplete stack frame (VMKit bug).
+				// We don't have access neither to the called frame nor the
+				// called frame.
+				// Report the caller of the caller frame (basically no op).
+				break;
+
+			case 1:
+				// We actually have an incomplete stack frame (VMKit bug).
+				// We don't have access to the called frame.
+				// Report the caller frame.
+				_stack_walker = _walked_stack.front();
+				_walked_stack.pop_front();
+				break;
+
+			default:	// _walked_stack.size() >= 2
+				_walked_stack.pop_front();			// Remove the frame -1.
+				_stack_walker = _walked_stack.front();	// Get the frame -2.
+				_walked_stack.pop_front();			// Remove the frame -2.
+
+				// If the frame is a stub, then return the actual Java method.
+				auto FI = _stack_walker.get();
+				if (!FI->Metadata && (FI->FrameSize > 0) &&
+					!_walked_stack.empty())
+				{
+					_stack_walker = _walked_stack.front();	// Get the frame -3.
+					_walked_stack.pop_front();			// Remove the frame -3.
+				}
+			}
+
+			return true;
+		}
+
+		callFrameStart = callFrameEnd;
+	}
+
+	return false;	// Node not found
+}
+
+bool StackEmbeddedListWalker::next()
+{
+	if (!_current_node) {	// Initial _current_node
+		_current_node = _stack_walker.thread->
+			stackEmbeddedListHead[StackEmbeddedListChargedTier];
+	} else {
+		_current_node = _current_node->callerNode;	// Get the next node
+	}
+
+	while (_current_node != nullptr) {	// Find the caller Java method frame.
+		if (findStackFrameOfEmbeddedNode())
+			break;
+
+		_current_node = _current_node->callerNode;
+	}
+
+	return _current_node != nullptr;
+}
+
+void StackEmbeddedListNode::dump() const
+{
+	std::cout << "tierID=" << reinterpret_cast<uint32_t>(data[0]) << std::endl;
+	if (!callerNode) return;
+	callerNode->dump();
+}
+
+}
+
+#endif

Modified: vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ctthread.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/memory-monitor/lib/vmkit/CommonThread/ctthread.cpp Thu Oct  9 03:43:38 2014
@@ -26,6 +26,10 @@
 #include <signal.h>
 #include <unistd.h>
 
+#if MONITOR_CREATED_OBJECTS_COUNT
+extern "C" void Jnjvm_incrementTotalCalledMethodsCounter(vmkit::Thread*);
+#endif
+
 using namespace vmkit;
 
 int Thread::kill(void* tid, int signo) {
@@ -60,7 +64,7 @@ void Thread::joinRVAfterLeave(word_t sav
 
 void Thread::startKnownFrame(KnownFrame& F) {
   // Get the caller of this function
-  word_t cur = System::GetCallerAddress();
+  word_t cur = System::GetCallFrameAddress();
   F.previousFrame = lastKnownFrame;
   F.currentFP = cur;
   // This is used as a marker.
@@ -75,12 +79,12 @@ void Thread::endKnownFrame() {
 
 void Thread::startUnknownFrame(KnownFrame& F) {
   // Get the caller of this function
-  word_t cur = System::GetCallerAddress();
+  word_t cur = System::GetCallFrameAddress();
   // Get the caller of the caller.
-  cur = System::GetCallerOfAddress(cur);
+  cur = System::GetCallerCallFrame(cur);
   F.previousFrame = lastKnownFrame;
   F.currentFP = cur;
-  F.currentIP = System::GetIPFromCallerAddress(cur);
+  F.currentIP = System::GetReturnAddressOfCallFrame(cur);
   lastKnownFrame = &F;
 }
 
@@ -97,7 +101,7 @@ void Thread::printBacktrace() {
   StackWalker Walker(this);
 
   while (FrameInfo* FI = Walker.get()) {
-    MyVM->printMethod(FI, Walker.ip, Walker.addr);
+    MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress);
     ++Walker;
   }
 }
@@ -124,42 +128,89 @@ uint32_t Thread::getFrameContextLength()
 }
 
 FrameInfo* StackWalker::get() {
-  if (addr == thread->baseSP) return 0;
-  ip = System::GetIPFromCallerAddress(addr);
-  return thread->MyVM->IPToFrameInfo(ip);
+  if (callFrameAddress == thread->baseSP) return 0;
+  returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress);
+  return thread->MyVM->IPToFrameInfo(returnAddress);
+}
+
+FrameInfo* StackWalker::getNextFrameWithMetadata()
+{
+	FrameInfo* FI;
+	for (void *metadata = NULL;							// (1)
+		(!metadata) && ((FI = this->get()) != NULL);	// (2)+
+		metadata = FI->Metadata, ++(*this));			// (3)*
+	return FI;
+}
+
+FrameInfo* StackWalker::getNextFrameWithMetadata(
+	size_t& totalFrameSizeWithoutMetadata)
+{
+	size_t frameSize = 0;
+	FrameInfo* FI = NULL;
+	for (void *metadata = NULL;							// (1)
+		(!metadata) && ((FI = this->get()) != NULL);	// (2)+
+
+		frameSize += FI->FrameSize,						// (3)*
+		metadata = FI->Metadata,
+		++(*this));
+
+	if (FI != NULL) frameSize -= FI->FrameSize;
+	totalFrameSizeWithoutMetadata = frameSize;
+	return FI;
+}
+
+FrameInfo* StackWalker::getNextFrameWithMetadata(
+	word_t& callFrameAddress_, word_t& returnAddress_, KnownFrame*& frame_)
+{
+	FrameInfo* FI;
+	word_t _callFrameAddress, _returnAddress;
+	KnownFrame* _frame;
+	void *metadata = NULL;
+
+	for (; (!metadata) && ((FI = this->get()) != NULL);	// (1)+
+		metadata = FI->Metadata,						// (2)*
+		_callFrameAddress = callFrameAddress, _returnAddress = returnAddress, _frame = frame,
+		++(*this));
+
+	callFrameAddress_ = _callFrameAddress;
+	returnAddress_ = _returnAddress;
+	frame_ = _frame;
+	return FI;
 }
 
 word_t StackWalker::operator*() {
-  if (addr == thread->baseSP) return 0;
-  ip = System::GetIPFromCallerAddress(addr);
-  return ip;
+  if (callFrameAddress == thread->baseSP) return 0;
+  returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress);
+  return returnAddress;
 }
 
 void StackWalker::operator++() {
-  if (addr != thread->baseSP) {
-    //assert((addr < thread->baseSP) && "Corrupted stack");
-    //assert((addr < System::GetCallerOfAddress(addr)) && "Corrupted stack");
-    if ((frame != NULL) && (addr == frame->currentFP)) {
+  if (callFrameAddress != thread->baseSP) {
+    assert((callFrameAddress < thread->baseSP) && "Corrupted stack");
+    assert((callFrameAddress < System::GetCallerCallFrame(callFrameAddress)) && "Corrupted stack");
+    if ((frame != NULL) && (callFrameAddress == frame->currentFP)) {
       assert(frame->currentIP == 0);
       frame = frame->previousFrame;
       assert(frame != NULL);
       assert(frame->currentIP != 0);
-      addr = frame->currentFP;
+      callFrameAddress = frame->currentFP;
       frame = frame->previousFrame;
     } else {
-      addr = System::GetCallerOfAddress(addr);
+      callFrameAddress = System::GetCallerCallFrame(callFrameAddress);
     }
   }
 }
 
-StackWalker::StackWalker(vmkit::Thread* th) {
+StackWalker::StackWalker(vmkit::Thread* th) :
+	returnAddress(0)
+{
   thread = th;
   frame = th->lastKnownFrame;
   if (vmkit::Thread::get() == th) {
-    addr = System::GetCallerAddress();
-    addr = System::GetCallerOfAddress(addr);
+    callFrameAddress = System::GetCallFrameAddress();
+    callFrameAddress = System::GetCallerCallFrame(callFrameAddress);
   } else {
-    addr = th->waitOnSP();
+    callFrameAddress = th->waitOnSP();
     if (frame) {
 //    	if (frame->currentFP < addr) {
 //    		fprintf(stderr, "Error in thread with pointer %p because %x < %x\n", th, frame->currentFP, addr);
@@ -167,9 +218,9 @@ StackWalker::StackWalker(vmkit::Thread*
 //    	}
 
 
-    	assert(frame->currentFP >= addr);
+    	assert(frame->currentFP >= callFrameAddress);
     }
-    if (frame && (addr == frame->currentFP)) {
+    if (frame && (callFrameAddress == frame->currentFP)) {
       frame = frame->previousFrame;
       // Let this be called from JNI, as in
       // OpenJDK's JVM_FillInStackTrace:
@@ -178,14 +229,32 @@ StackWalker::StackWalker(vmkit::Thread*
       assert((frame == NULL) || (frame->currentIP == 0));
     }
   }
-  assert(addr && "No address to start with");
+  assert(callFrameAddress && "No address to start with");
 }
 
+StackWalker::StackWalker() :
+	returnAddress(0)
+{
+  thread = vmkit::Thread::get();
+  frame = thread->lastKnownFrame;
+  callFrameAddress = System::GetCallFrameAddress();
+  callFrameAddress = System::GetCallerCallFrame(callFrameAddress);
+  assert(callFrameAddress && "No address to start with");
+}
+
+#if OSGI_STACK_SPACE_TIER_TAGGING
+extern "C" void OSGi_TierManager_accountForThreadStack(vmkit::Thread* thread);
+#endif
 
 void Thread::scanStack(word_t closure) {
+
+#if OSGI_STACK_SPACE_TIER_TAGGING
+  OSGi_TierManager_accountForThreadStack(this);
+#endif
+
   StackWalker Walker(this);
   while (FrameInfo* MI = Walker.get()) {
-    MethodInfoHelper::scan(closure, MI, Walker.ip, Walker.addr);
+    MethodInfoHelper::scan(closure, MI, Walker.returnAddress, Walker.callFrameAddress);
     ++Walker;
   }
 }
@@ -195,11 +264,11 @@ void Thread::enterUncooperativeCode(uint
   	if (!inRV) {
   		assert(!lastSP && "SP already set when entering uncooperative code");
       // Get the caller.
-      word_t temp = System::GetCallerAddress();
+      word_t temp = System::GetCallFrameAddress();
       // Make sure to at least get the caller of the caller.
       ++level;
       while (level--)
-    	  temp = System::GetCallerOfAddress(temp);
+    	  temp = System::GetCallerCallFrame(temp);
       // The cas is not necessary, but it does a memory barrier.
       __sync_bool_compare_and_swap(&lastSP, 0, temp);
       if (doYield) joinRVBeforeEnter();
@@ -337,7 +406,20 @@ extern void sigsTermHandler(int n, sigin
 /// given routine of th.
 ///
 void Thread::internalThreadStart(vmkit::Thread* th) {
-  th->baseSP  = System::GetCallerAddress();
+  th->baseSP  = System::GetCallFrameAddress();
+
+#if JAVA_CHARGED_TIER_CALL_STACK
+  th->chargedTierID = (uint32_t)-1;
+#endif
+
+#if EMBEDDED_LIST_IN_CALL_STACK
+  memset(th->stackEmbeddedListHead, 0,
+    sizeof(*th->stackEmbeddedListHead) * StackEmbeddedListNodeCountPerThread);
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  th->total_called_methods_count = 0;
+#endif
 
   // Set the alternate stack as the second page of the thread's
   // stack.
@@ -374,6 +456,10 @@ void Thread::internalThreadStart(vmkit::
   th->MyVM->rendezvous.addThread(th);
   th->routine(th);
   th->MyVM->removeThread(th);
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  Jnjvm_incrementTotalCalledMethodsCounter(th);
+#endif
 }
 
 
@@ -420,6 +506,10 @@ void Thread::releaseThread(vmkit::Thread
   word_t index = ((word_t)th & System::GetThreadIDMask());
   index = (index & ~TheStackManager.baseAddr) >> 20;
   TheStackManager.used[index] = 0;
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+  Jnjvm_incrementTotalCalledMethodsCounter(th);
+#endif
 }
 
 void Thread::throwNullPointerException(word_t methodIP)

Modified: vmkit/branches/memory-monitor/lib/vmkit/Runtime/MethodInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/Runtime/MethodInfo.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/Runtime/MethodInfo.cpp (original)
+++ vmkit/branches/memory-monitor/lib/vmkit/Runtime/MethodInfo.cpp Thu Oct  9 03:43:38 2014
@@ -21,7 +21,7 @@ namespace vmkit {
 
 void MethodInfoHelper::scan(word_t closure, FrameInfo* FI, word_t ip, word_t addr) {
   //word_t spaddr = (word_t)addr + FI->FrameSize + sizeof(void*);
-  word_t spaddr = System::GetCallerOfAddress(addr);
+  word_t spaddr = System::GetCallerCallFrame(addr);
   for (uint16 i = 0; i < FI->NumLiveOffsets; ++i) {
     word_t obj = *(word_t*)(spaddr + FI->LiveOffsets[i]);    
     // Verify that obj does not come from a JSR bytecode.

Modified: vmkit/branches/memory-monitor/lib/vmkit/Runtime/UTF8.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/lib/vmkit/Runtime/UTF8.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/lib/vmkit/Runtime/UTF8.cpp (original)
+++ vmkit/branches/memory-monitor/lib/vmkit/Runtime/UTF8.cpp Thu Oct  9 03:43:38 2014
@@ -41,17 +41,6 @@ uint32 UTF8::readerHasher(const uint16*
   return (r1 & 255) + ((r0 & 255) << 8);
 }
 
-int UTF8::compare(const char *s) const
-{
-	int len = strlen(s);
-	int diff = size - len;
-	if (diff != 0) return diff;
-
-	for (int i = 0; (i < size) && (diff == 0); ++i)
-		diff = (char)(elements[i]) - s[i];
-	return diff;
-}
-
 std::string& UTF8::toString(std::string& buffer) const
 {
 	buffer.resize(size);
@@ -64,7 +53,7 @@ std::string& UTF8::toString(std::string&
 
 std::ostream& operator << (std::ostream& os, const UTF8& utf8)
 {
-	for (ssize_t i = 0; i < utf8.size; ++i)
+	for (ssize_t i = 0; (i < utf8.size) && (utf8.elements[i] != 0); ++i)
 		os << (std::string::value_type)(utf8.elements[i]);
 	return os;
 }

Modified: vmkit/branches/memory-monitor/mmtk/mmtk-alloc/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/mmtk/mmtk-alloc/Selected.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/mmtk/mmtk-alloc/Selected.cpp (original)
+++ vmkit/branches/memory-monitor/mmtk/mmtk-alloc/Selected.cpp Thu Oct  9 03:43:38 2014
@@ -98,12 +98,29 @@ extern "C" void postalloc(gc* obj, void*
 	JnJVM_org_j3_bindings_Bindings_postalloc__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2I(obj, type, size);
 }
 
+#if OSGI_OBJECT_TIER_TAGGING
+extern "C" void OSGi_TierManager_updateTierChargedToNewlyCreatedObject(gc*);
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+extern "C" void Jnjvm_newlyCreatedObject();
+#endif
+
 extern "C" void* vmkitgcmalloc(uint32_t sz, void* type) {
 	gc* res = 0;
 	llvm_gcroot(res, 0);
 	sz += gcHeader::hiddenHeaderSize();
 	sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
 	res = ((gcHeader*)JnJVM_org_j3_bindings_Bindings_vmkitgcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2(sz, type))->toReference();
+
+#if OSGI_OBJECT_TIER_TAGGING
+	OSGi_TierManager_updateTierChargedToNewlyCreatedObject(res);
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+	Jnjvm_newlyCreatedObject();
+#endif
+
 	return res;
 }
 
@@ -125,6 +142,15 @@ extern "C" void* VTgcmalloc(uint32_t sz,
 	sz += gcHeader::hiddenHeaderSize();
 	sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
 	res = ((gcHeader*)JnJVM_org_j3_bindings_Bindings_VTgcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2(sz, VT))->toReference();
+
+#if OSGI_OBJECT_TIER_TAGGING
+	OSGi_TierManager_updateTierChargedToNewlyCreatedObject(res);
+#endif
+
+#if MONITOR_CREATED_OBJECTS_COUNT
+	Jnjvm_newlyCreatedObject();
+#endif
+
 	return res;
 }
 
@@ -180,10 +206,19 @@ bool Collector::isLive(gc* ptr, word_t c
   return JnJVM_org_j3_bindings_Bindings_isLive__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_ObjectReference_2(closure, ptr);
 }
 
+#if OSGI_OBJECT_TIER_TAGGING
+extern "C" void OSGi_TierManager_accountForLiveObject(void* obj);
+#endif
+
 void Collector::scanObject(FrameInfo* FI, void** ptr, word_t closure) {
   if ((*ptr) != NULL) {
     assert(vmkit::Thread::get()->MyVM->isCorruptedType((gc*)(*ptr)));
   }
+
+#if OSGI_OBJECT_TIER_TAGGING
+  OSGi_TierManager_accountForLiveObject(*ptr);
+#endif
+
   JnJVM_org_j3_bindings_Bindings_reportDelayedRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2(closure, ptr);
 }
  
@@ -194,6 +229,11 @@ void Collector::markAndTrace(void* sourc
 		assert(vmkit::Thread::get()->MyVM->isCorruptedType((gc*)(*ptr_)));
 	}
 	if ((*(void**)ptr) != NULL) assert(vmkit::Thread::get()->MyVM->isCorruptedType((gc*)(*(void**)ptr)));
+
+#if OSGI_OBJECT_TIER_TAGGING
+	OSGi_TierManager_accountForLiveObject(*ptr_);
+#endif
+
 	JnJVM_org_j3_bindings_Bindings_processEdge__Lorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2(closure, source, ptr);
 }
   
@@ -203,6 +243,11 @@ void Collector::markAndTraceRoot(void* s
   if ((*ptr_) != NULL) {
     assert(vmkit::Thread::get()->MyVM->isCorruptedType((gc*)(*ptr_)));
   }
+
+#if OSGI_OBJECT_TIER_TAGGING
+  OSGi_TierManager_accountForLiveObject(*ptr_);
+#endif
+
   JnJVM_org_j3_bindings_Bindings_processRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2Z(closure, ptr, true);
 }
 

Propchange: vmkit/branches/memory-monitor/osgi/j3mgr/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/j3mgr/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/j3mgr/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/j3mgr/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/j3mgr/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: J3 Manager
+Bundle-ManifestVersion: 2
+Bundle-Activator: j3mgr.Activator
+Bundle-SymbolicName: j3mgr
+Bundle-Vendor: Koutheir Attouchi
+Export-Package: j3
+Import-Package: org.osgi.framework

Added: vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/J3Mgr.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/J3Mgr.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/J3Mgr.java (added)
+++ vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/J3Mgr.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,10 @@
+package j3;
+
+public interface J3Mgr
+{
+	// THE FOLLOWING METHODS ARE DEBUGGING HELPERS
+	// THEY SHOULD BE REMOVED IN PRODUCTION
+	
+	public void dumpClassLoaderBundles() throws Throwable;
+	public void dumpTierStats(String delayedSec) throws Throwable;
+}

Added: vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/OSGi.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/OSGi.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/OSGi.java (added)
+++ vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/OSGi.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,10 @@
+package j3.vm;
+
+public class OSGi
+{
+	public static native void bundleResolved(
+		String bundleName, long bundleID, ClassLoader loaderObject);
+	public static native void bundleUnresolved(
+		String bundleName, long bundleID);
+	public static native void dumpClassLoaderBundles();
+}

Added: vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/Tier.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/Tier.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/Tier.java (added)
+++ vmkit/branches/memory-monitor/osgi/j3mgr/src/j3/vm/Tier.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,7 @@
+package j3.vm;
+
+public class Tier
+{
+	public static native long getTierChargedForObject(Object obj);
+	public static native void dumpTierStats();
+}

Added: vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,28 @@
+
+package j3mgr;
+
+import j3.J3Mgr;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator
+	implements BundleActivator
+{
+	J3MgrImpl j3mgr;
+	
+	public void start(BundleContext context) throws Exception
+	{
+		j3mgr = new J3MgrImpl();
+		try {
+			j3mgr.open(context);
+		} catch (Throwable e) {throw new Exception(e);}
+		
+		context.registerService(J3Mgr.class, j3mgr, null);
+	}
+	
+	public void stop(BundleContext context) throws Exception
+	{
+		j3mgr.close();
+	}
+}
\ No newline at end of file

Added: vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/J3MgrImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/J3MgrImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/J3MgrImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/j3mgr/src/j3mgr/J3MgrImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,87 @@
+package j3mgr;
+
+import j3.J3Mgr;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+public class J3MgrImpl
+	implements J3Mgr
+{
+	class dumpTierStatsRunner implements Runnable
+	{
+		final long delayedMillisec;
+		
+		public dumpTierStatsRunner(long delayedMillisec)
+		{
+			this.delayedMillisec = delayedMillisec;
+		}
+		
+		public void run() {
+			try {
+				Thread.sleep(delayedMillisec);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			
+			j3.vm.Tier.dumpTierStats();
+		}
+	}
+
+	BundleContext context;
+	
+	public void open(BundleContext bundleContext) throws Throwable
+	{
+		context = bundleContext;
+	}
+
+	public void close()
+	{
+		context = null;
+	}
+		
+	// THE FOLLOWING METHODS ARE DEBUGGING HELPERS
+	// THEY SHOULD BE REMOVED IN PRODUCTION
+
+	long getBundleID(String symbolicNameOrID)
+	{
+		try {
+			long bundleID = Long.parseLong(symbolicNameOrID);
+			
+			if (context.getBundle(bundleID) == null) {
+				System.out.println(
+					"WARNING: bundleID=" + bundleID +
+					" is invalid, probably already uninstalled.");
+			}
+			
+			return (bundleID < 0) ? -1 : bundleID;
+		} catch (NumberFormatException e) {
+			// This is not a bundle ID, it must be a symbolic name
+		}
+		
+		Bundle[] bundles = context.getBundles();
+		for (int i=0; i < bundles.length; ++i) {
+			if (symbolicNameOrID.equals(bundles[i].getSymbolicName()))
+				return bundles[i].getBundleId();
+		}
+		return -1;
+	}
+
+	public void dumpClassLoaderBundles() throws Throwable
+	{
+		j3.vm.OSGi.dumpClassLoaderBundles();
+	}
+			
+	public void dumpTierStats(String delayedSec) throws Throwable
+	{
+		long delay = Long.parseLong(delayedSec);
+		Runnable runner = new dumpTierStatsRunner(delay * 1000);
+		
+		if (delay <= 0) {
+			runner.run();
+		} else {
+			System.out.println("dumpTierStats runs in delayed mode...");
+			new Thread(runner, "dumpTierStats").start();
+		}
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/knopflerfish.patch
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/knopflerfish.patch?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/knopflerfish.patch (added)
+++ vmkit/branches/memory-monitor/osgi/knopflerfish.patch Thu Oct  9 03:43:38 2014
@@ -0,0 +1,46 @@
+diff -U 4 -H -d -p -r -N -- a/osgi/framework/src/j3/vm/OSGi.java b/osgi/framework/src/j3/vm/OSGi.java
+--- a/osgi/framework/src/j3/vm/OSGi.java	1970-01-01 01:00:00.000000000 +0100
++++ b/osgi/framework/src/j3/vm/OSGi.java	2013-12-09 17:26:46.738542108 +0100
+@@ -0,0 +1,9 @@
++package j3.vm;
++
++public class OSGi
++{
++	public static native void bundleResolved(
++		String bundleName, long bundleID, ClassLoader loaderObject);
++	public static native void bundleUnresolved(
++		String bundleName, long bundleID);
++}
+diff -U 4 -H -d -p -r -N -- a/osgi/framework/src/org/knopflerfish/framework/BundleGeneration.java b/osgi/framework/src/org/knopflerfish/framework/BundleGeneration.java
+--- a/osgi/framework/src/org/knopflerfish/framework/BundleGeneration.java	2013-12-06 11:47:15.745783303 +0100
++++ b/osgi/framework/src/org/knopflerfish/framework/BundleGeneration.java	2013-12-09 17:55:39.705198422 +0100
+@@ -212,8 +212,9 @@ public class BundleGeneration implements
+     timeStamp = System.currentTimeMillis();
+     bpkgs = new BundlePackages(this, exportStr);
+     bundleRevision = new BundleRevisionImpl(this);
+     classLoader = b.getClassLoader();
++	j3.vm.OSGi.bundleResolved(symbolicName, bundle.getBundleId(), classLoader);
+     processCapabilities(capabilityStr);
+     identity = new BundleCapabilityImpl(this);
+   }
+ 
+@@ -546,8 +547,9 @@ public class BundleGeneration implements
+             }
+           }
+         }
+         classLoader = bundle.secure.newBundleClassLoader(this);
++		j3.vm.OSGi.bundleResolved(symbolicName, bundle.getBundleId(), classLoader);
+ 
+         return true;
+       }
+       if (isFragmentHost()) {
+@@ -920,8 +922,9 @@ public class BundleGeneration implements
+     final BundleClassLoader tmp = (BundleClassLoader)classLoader;
+     if (tmp != null) {
+       classLoader = null;
+       tmp.close();
++	  j3.vm.OSGi.bundleUnresolved(symbolicName, bundle.getBundleId());
+     }
+   }
+ 
+ 

Propchange: vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+.settings

Added: vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/Main.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/Main.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/Main.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/Main.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,13 @@
+
+package j3mgr;
+
+public class Main {
+
+	public static void main(String[] args) throws Throwable
+	{
+		TierConfigParser parser = new TierConfigParser();
+		
+		parser.parse(
+			"/home/koutheir/PhD/VMKit/vmkit-monitor/tests/tier.description");
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/TierConfigParser.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/TierConfigParser.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/TierConfigParser.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/TierConfigParser/src/j3mgr/TierConfigParser.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,224 @@
+package j3mgr;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Scanner;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class TierConfigParser
+{
+	String token_identifier;
+	int token_integer;
+	int lastChar;
+	InputStream source;
+	
+	public void parse(String fileName) throws Throwable
+	{
+		InputStream is = new FileInputStream(fileName);
+		parse(is);
+	}
+	
+	public void parse(InputStream is) throws NoSuchElementException, IOException
+	{
+		source = is;
+		lastChar = source.read();
+		token_identifier = "";
+		
+		for (;;) {
+			skipWhiteSpaceAndComments();
+			if (lastChar == -1) break;
+			
+			if (!parseIdentifier()) {
+				throw new NoSuchElementException(
+					"'tier' or 'account' expected.");
+			}
+			
+			if (parseTier()) {}
+			else if (parseAccount()) {}
+			else {
+				if (lastChar == -1)
+					break;
+				
+				throw new NoSuchElementException(
+					"'tier' or 'account' expected.");
+			}
+		}
+	}
+	
+	void skipWhiteSpaceAndComments() throws IOException
+	{
+		for (;;) {
+			// Skip white space
+			for (; (lastChar != -1) && Character.isWhitespace(lastChar);
+				lastChar = source.read());
+			
+			if (lastChar != '#') break;
+			
+			// Skip a comment line
+			lastChar = source.read();
+			while (lastChar != '\n')
+				lastChar = source.read();
+			lastChar = source.read();
+		}
+	}
+	
+	boolean parseIdentifier() throws IOException
+	{
+		skipWhiteSpaceAndComments();
+		
+		if (!Character.isLetter(lastChar) && lastChar != '_') return false;
+		
+		StringBuilder sb = new StringBuilder();
+		sb.appendCodePoint(lastChar);
+		lastChar = source.read();
+		
+		while (Character.isLetterOrDigit(lastChar) || lastChar == '_') {
+			sb.appendCodePoint(lastChar);
+			lastChar = source.read();
+		}
+		
+		token_identifier = sb.toString();
+		return true;
+	}
+
+	boolean parseInteger() throws IOException
+	{
+		skipWhiteSpaceAndComments();
+		
+		StringBuilder sb = new StringBuilder();
+		
+		if (lastChar == '+' || lastChar == '-') {
+			sb.appendCodePoint(lastChar);
+			lastChar = source.read();
+			
+			if (!Character.isDigit(lastChar))
+				throw new NoSuchElementException("Digit expected.");
+		} else if (!Character.isDigit(lastChar))
+			return false;
+		
+		do {
+			sb.appendCodePoint(lastChar);
+			lastChar = source.read();
+		} while (Character.isDigit(lastChar));
+
+		token_identifier = sb.toString();
+		token_integer = Integer.parseInt(token_identifier);
+		return true;
+	}
+	
+	boolean parseTier() throws IOException
+	{
+		if (token_identifier.compareTo("tier") != 0) return false;
+		
+		if (!parseInteger())
+			throw new NoSuchElementException("Integer expected.");
+		
+		skipWhiteSpaceAndComments();
+		if (lastChar != '{')
+			throw new NoSuchElementException("'{' expected.");
+		lastChar = source.read();
+		
+		ArrayList<String> bundles = new ArrayList<String>();
+		
+		skipWhiteSpaceAndComments();
+		if (lastChar != '}') {
+			for (;;) {
+				if (!parseIdentifier())
+					throw new NoSuchElementException("bundle name expected.");
+				
+				bundles.add(token_identifier);
+				
+				skipWhiteSpaceAndComments();
+				if (lastChar == '}') break;
+				
+				if (lastChar != ',')
+					throw new NoSuchElementException("',' expected.");
+				lastChar = source.read();
+			}
+		}
+		
+		if (lastChar != '}')
+			throw new NoSuchElementException("'}' expected.");
+		lastChar = source.read();
+		
+		return createTier(token_integer, bundles);
+	}
+
+	boolean parseAccount() throws IOException
+	{
+		if (token_identifier.compareTo("account") != 0) return false;
+
+		skipWhiteSpaceAndComments();
+		if (lastChar != '{')
+			throw new NoSuchElementException("'{' expected.");
+		lastChar = source.read();
+		
+		long callerTierID = -1;
+		skipWhiteSpaceAndComments();
+		if (lastChar != '*') {
+			if (!parseInteger())
+				throw new NoSuchElementException("Integer or '*' expected.");
+			callerTierID = token_integer;
+		} else
+			lastChar = source.read();
+		
+		skipWhiteSpaceAndComments();
+		if (lastChar != ',')
+			throw new NoSuchElementException("',' expected.");
+		lastChar = source.read();
+		
+		long calleeTierID = -1;
+		skipWhiteSpaceAndComments();
+		if (lastChar != '*') {
+			if (!parseInteger())
+				throw new NoSuchElementException("Integer or '*' expected.");
+			calleeTierID = token_integer;
+		} else
+			lastChar = source.read();
+		
+		skipWhiteSpaceAndComments();
+		if (lastChar != ',')
+			throw new NoSuchElementException("',' expected.");
+		lastChar = source.read();
+
+		if (!parseIdentifier())
+			throw new NoSuchElementException("'caller' or 'callee' expected.");
+		
+		boolean chargeCaller = (token_identifier.compareTo("caller") == 0);
+		if (!chargeCaller && (token_identifier.compareTo("callee") != 0))
+			throw new NoSuchElementException("'caller' or 'callee' expected.");
+		
+		skipWhiteSpaceAndComments();
+		if (lastChar != '}')
+			throw new NoSuchElementException("'}' expected.");
+		lastChar = source.read();
+		
+		return createAccount(callerTierID, calleeTierID, chargeCaller);
+	}
+	
+	boolean createTier(long tierID, List<String> bundleList)
+	{
+		System.out.print(tierID + "=");
+		if (bundleList != null) {
+			for (String bundleID : bundleList)
+				System.out.print(bundleID + " ");
+		}
+		System.out.println();
+		return true;
+	}
+	
+	boolean createAccount(
+		long callerTierID, long calleeTierID, boolean chargeCaller)
+	{
+		System.out.println(
+			callerTierID + "=>" + calleeTierID + ":" +
+			(chargeCaller ? "caller" : "callee"));
+		return true;
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: A
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ijvm.tests.A
+Export-Package: ijvm.tests.A
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/A.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/A.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/A.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/A.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,7 @@
+package ijvm.tests.A;
+
+public interface A
+{
+	public void performA();
+	public Token getToken();
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/Token.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/Token.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/Token.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.A/src/ijvm/tests/A/Token.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+package ijvm.tests.A;
+
+public interface Token
+{
+	public int getValue();
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: AImpl
+Bundle-Activator: ijvm.tests.AImpl.Activator
+Bundle-ManifestVersion: 2
+Import-Package: ijvm.tests.A, ijvm.tests.C, org.osgi.util.tracker, org
+ .osgi.framework
+Bundle-SymbolicName: ijvm.tests.AImpl
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/AImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/AImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/AImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/AImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,28 @@
+package ijvm.tests.AImpl;
+
+import java.util.ArrayList;
+
+import ijvm.tests.A.A;
+import ijvm.tests.A.Token;
+import ijvm.tests.C.C;
+
+public class AImpl
+	implements A
+{
+	public ArrayList<C> c;
+
+	public AImpl()
+	{
+		c = new ArrayList<C>();
+	}
+	
+	public void performA()
+	{
+		System.out.println("AImpl.performA");
+	}
+
+	public Token getToken()
+	{
+		return new TokenImpl((int)(Math.random() * 100.0));
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,98 @@
+package ijvm.tests.AImpl;
+
+import ijvm.tests.A.A;
+import ijvm.tests.C.C;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator
+	implements BundleActivator, ServiceListener
+{
+	private BundleContext context;
+	private ServiceTracker cST;
+	private AImpl a;
+	private C c;
+
+	public void start(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("AImpl provides A");
+		context = bundleContext;
+
+		a = new AImpl();
+
+		cST = new ServiceTracker(context, C.class.getName(), null);
+		cST.open();
+				
+		C service = (C)cST.getService();
+		if (service != null) {
+			System.out.println("AImpl got C @ startup");
+			
+			a.c.add(service);
+			this.registerMyself();
+		}
+		
+		InfiniteResurrecter.class.getName();
+		
+		context.addServiceListener(this, "(objectclass=" + C.class.getName() + ")");
+		context.registerService(A.class.getName(), a, null);	
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("AImpl no more provides A");
+		
+		context.removeServiceListener(this);
+		context = null;
+
+		System.out.println("AImpl lost C but keeps a stale reference to it");
+		cST.close();
+		cST = null;
+		
+		//a = null;
+	}
+
+	public void serviceChanged(ServiceEvent event)
+	{
+		Object service = context.getService(event.getServiceReference());
+		
+		switch(event.getType()) {
+		case ServiceEvent.REGISTERED:
+			if (C.class.isInstance(service)) {
+				System.out.println("AImpl got C");
+				a.c.add((C)service);
+				
+				this.registerMyself();
+			}
+			break;
+			
+		case ServiceEvent.UNREGISTERING:
+			if (C.class.isInstance(service)) {
+				System.out.println("AImpl lost C but keeps a stale reference to it");
+			}
+			break;
+		}
+	}
+	
+	private void registerMyself()
+	{
+		C oneC = a.c.get(a.c.size() - 1);
+		c = oneC;
+		
+		oneC.registerObject(this);
+	}
+/*	
+	protected void finalize()
+	{
+		try {
+			System.out.println(getClass().getName() + ".finalize()");
+			new InfiniteResurrecter(c, this);
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+	}
+*/
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/InfiniteResurrecter.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/InfiniteResurrecter.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/InfiniteResurrecter.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/InfiniteResurrecter.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,24 @@
+package ijvm.tests.AImpl;
+
+import ijvm.tests.C.C;
+
+public class InfiniteResurrecter
+{
+	C c;
+	Object target;
+	
+	public InfiniteResurrecter(C c, Object o)
+	{
+		System.out.println(getClass().getName() + ": resurrecting " + o);
+		
+		this.c = c;
+		this.target = o;
+		
+		c.registerObject(this);
+	}
+	
+	protected void finalize()
+	{
+		new InfiniteResurrecter(this.c, target);
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/TokenImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/TokenImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/TokenImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.AImpl/src/ijvm/tests/AImpl/TokenImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,34 @@
+package ijvm.tests.AImpl;
+
+import java.util.ArrayList;
+
+import ijvm.tests.A.Token;
+
+public class TokenImpl
+	implements Token
+{
+	static final int ChunkSize = 2 * 1024;
+	static final int ChunkCount = 64;
+	
+	ArrayList<byte[]> BigData;
+	
+	public TokenImpl(int value)
+	{
+		BigData = new ArrayList<byte[]>();
+		
+		for (int i=0; i<ChunkCount; ++i) {
+			byte[] chunk = new byte[ChunkSize];
+		
+			for (int j=0; j<ChunkSize; ++j)
+				chunk[j] = (byte)(j % 256);
+				
+			BigData.add(chunk);
+		}
+	}
+	
+	public int getValue()
+	{
+		byte[] chunk = BigData.get((int)(Math.random() * ChunkCount));
+		return chunk[(int)(Math.random() * ChunkSize)];
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: BImpl
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ijvm.tests.BImpl
+Export-Package: ijvm.tests.B
+Bundle-Activator: ijvm.tests.BImpl.Activator
+Import-Package: ijvm.tests.A, org.osgi.framework, org.osgi.util.tracke
+ r
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/B/B.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/B/B.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/B/B.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/B/B.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+package ijvm.tests.B;
+
+public interface B
+{
+	public void performB();
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,90 @@
+package ijvm.tests.BImpl;
+
+import ijvm.tests.A.A;
+import ijvm.tests.A.Token;
+import ijvm.tests.B.B;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator
+	implements BundleActivator, ServiceListener
+{
+	private BundleContext context;
+
+	private ServiceTracker aST;
+	private BImpl b;
+	
+	public void start(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("BImpl exports and provides B");
+		context = bundleContext;
+
+		b = new BImpl();
+		
+		aST = new ServiceTracker(context, A.class.getName(), null);
+		aST.open();
+		
+		A service = (A)aST.getService();
+		if (service != null) {
+			System.out.println("BImpl got A @ startup");
+			
+			b.a.add(service);
+			this.useA();
+		}
+		
+		context.addServiceListener(this, "(objectclass=" + A.class.getName() + ")");
+		context.registerService(B.class.getName(), b, null);
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("BImpl no more provides B");
+
+		context.removeServiceListener(this);
+		context = null;
+		
+		System.out.println("BImpl lost A but keeps a stale reference to it");
+		aST.close();
+		aST = null;
+		// a = null;
+		
+		b = null;
+	}
+
+	public void serviceChanged(ServiceEvent event)
+	{
+		Object service = context.getService(event.getServiceReference());
+		
+		switch(event.getType()) {
+		case ServiceEvent.REGISTERED:
+			if (A.class.isInstance(service)) {
+				System.out.println("BImpl got A");
+				b.a.add((A)service);
+				
+				this.useA();
+			}
+			break;
+			
+		case ServiceEvent.UNREGISTERING:
+			if (A.class.isInstance(service)) {
+				System.out.println("BImpl lost A but keeps a stale reference to it");
+			}
+			break;
+		}
+	}
+	
+	private void useA()
+	{
+		A oneA = b.a.get(b.a.size() - 1);
+		Token token = oneA.getToken();
+		token.getValue();
+		
+		b.tokens.add(token);
+		
+		System.out.println("BImpl got Token from A");
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/BImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/BImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/BImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.BImpl/src/ijvm/tests/BImpl/BImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,25 @@
+package ijvm.tests.BImpl;
+
+import java.util.ArrayList;
+
+import ijvm.tests.A.A;
+import ijvm.tests.A.Token;
+import ijvm.tests.B.B;
+
+public class BImpl
+	implements B
+{
+	public ArrayList<A> a;
+	public ArrayList<Token> tokens;
+	
+	public BImpl()
+	{
+		a = new ArrayList<A>();
+		tokens = new ArrayList<Token>();
+	}
+	
+	public void performB()
+	{
+		System.out.println("BImpl.performB");
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: C
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ijvm.tests.C
+Export-Package: ijvm.tests.C
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/tests/C/C.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/tests/C/C.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/tests/C/C.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.C/src/ijvm/tests/C/C.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,7 @@
+package ijvm.tests.C;
+
+public interface C
+{
+	public void performC();
+	public void registerObject(Object o);
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: CImpl
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ijvm.tests.CImpl
+Bundle-Activator: ijvm.tests.CImpl.Activator
+Import-Package: ijvm.tests.B, ijvm.tests.C, org.osgi.framework, org.os
+ gi.util.tracker
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,75 @@
+package ijvm.tests.CImpl;
+
+import ijvm.tests.B.B;
+import ijvm.tests.C.C;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator
+	implements BundleActivator, ServiceListener
+{
+	private BundleContext context;
+
+	private ServiceTracker bST;
+	private CImpl c;
+
+	public void start(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("CImpl exports and provides C");
+		context = bundleContext;
+
+		c = new CImpl();
+
+		bST = new ServiceTracker(context, B.class.getName(), null);
+		bST.open();
+		
+		B service = (B)bST.getService();
+		if (service != null) {
+			System.out.println("CImpl got B @ startup");
+			
+			c.b.add(service);
+		}
+		
+		context.addServiceListener(this, "(objectclass=" + B.class.getName() + ")");
+		context.registerService(C.class.getName(), c, null);
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("CImpl no more provides C");
+
+		context.removeServiceListener(this);
+		context = null;
+		
+		System.out.println("CImpl lost B but keeps a stale reference to it");
+		bST.close();
+		bST = null;
+		// b = null;
+		
+		c = null;
+	}
+
+	public void serviceChanged(ServiceEvent event)
+	{
+		Object service = context.getService(event.getServiceReference());
+		
+		switch(event.getType()) {
+		case ServiceEvent.REGISTERED:
+			if (B.class.isInstance(service)) {
+				System.out.println("CImpl got B");
+				c.b.add((B)service);
+			}
+			break;
+			
+		case ServiceEvent.UNREGISTERING:
+			if (B.class.isInstance(service)) {
+				System.out.println("CImpl lost B but keeps a stale reference to it");
+			}
+			break;
+		}
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/CImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/CImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/CImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.CImpl/src/ijvm/tests/CImpl/CImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,36 @@
+package ijvm.tests.CImpl;
+
+import java.util.ArrayList;
+
+import ijvm.tests.B.B;
+import ijvm.tests.C.C;
+
+public class CImpl
+	implements C
+{
+	ArrayList<Object> registeredObjects;
+	public ArrayList<B> b;
+	
+	CImpl()
+	{
+		b = new ArrayList<B>();
+		registeredObjects = new ArrayList<Object>();
+	}
+	
+	public void performC()
+	{
+		System.out.println("CImpl.performC");
+	}
+
+	public void registerObject(Object o)
+	{
+		System.out.println("CImpl.registerObject");
+		
+		Object obj = new Object();
+		synchronized (obj) {
+			obj.notify();			
+		}
+		
+		registeredObjects.add(o);
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: DImpl
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ijvm.tests.DImpl
+Export-Package: ijvm.tests.D
+Bundle-Activator: ijvm.tests.DImpl.Activator
+Import-Package: ijvm.tests.C, org.osgi.framework, org.osgi.util.tracke
+ r
+

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/D/D.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/D/D.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/D/D.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/D/D.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+package ijvm.tests.D;
+
+public interface D
+{
+	public void performD();
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,75 @@
+package ijvm.tests.DImpl;
+
+import ijvm.tests.C.C;
+import ijvm.tests.D.D;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator
+	implements BundleActivator, ServiceListener
+{
+	private BundleContext context;
+
+	private ServiceTracker cST;
+	private DImpl d;
+	
+	public void start(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("DImpl exports and provides D");
+		context = bundleContext;
+
+		d = new DImpl();
+
+		cST = new ServiceTracker(context, C.class.getName(), null);
+		cST.open();
+		
+		C service = (C)cST.getService();
+		if (service != null) {
+			System.out.println("DImpl got C @ startup");
+			
+			d.c.add(service);
+		}
+		
+		context.addServiceListener(this, "(objectclass=" + C.class.getName() + ")");
+		context.registerService(D.class.getName(), d, null);
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println("DImpl no more provides D");
+
+		context.removeServiceListener(this);
+		context = null;
+		
+		System.out.println("DImpl lost C but keeps a stale reference to it");
+		cST.close();
+		cST = null;
+		// c = null;
+		
+		d = null;
+	}
+
+	public void serviceChanged(ServiceEvent event)
+	{
+		Object service = context.getService(event.getServiceReference());
+		
+		switch(event.getType()) {
+		case ServiceEvent.REGISTERED:
+			if (C.class.isInstance(service)) {
+				System.out.println("DImpl got C");
+				d.c.add((C)service);
+			}
+			break;
+			
+		case ServiceEvent.UNREGISTERING:
+			if (C.class.isInstance(service)) {
+				System.out.println("DImpl lost C but keeps a stale reference to it");
+			}
+			break;
+		}
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/DImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/DImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/DImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/ijvm.tests.DImpl/src/ijvm/tests/DImpl/DImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,22 @@
+package ijvm.tests.DImpl;
+
+import java.util.ArrayList;
+
+import ijvm.tests.C.C;
+import ijvm.tests.D.D;
+
+public class DImpl
+	implements D
+{
+	public ArrayList<C> c;
+	
+	public DImpl()
+	{
+		c = new ArrayList<C>();
+	}
+	
+	public void performD()
+	{
+		System.out.println("DImpl.performB");
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/tests.A/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,5 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project

Added: vmkit/branches/memory-monitor/osgi/tests/tests.A/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.A/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.A/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.A/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: Tests A
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: tests.A
+Export-Package: tests.A

Added: vmkit/branches/memory-monitor/osgi/tests/tests.A/src/tests/A/A.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.A/src/tests/A/A.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.A/src/tests/A/A.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.A/src/tests/A/A.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,8 @@
+package tests.A;
+
+public interface A
+{
+	public void a();
+	public int b(long x, long y);
+	public long[] c(int n);
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: Tests A Impl
+Bundle-Activator: tests.AImpl.Activator
+Bundle-ManifestVersion: 2
+Import-Package: org.osgi.framework, tests.A, tests.B, tests.E
+Bundle-SymbolicName: tests.AImpl
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/AImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/AImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/AImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/AImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,66 @@
+package tests.AImpl;
+
+import java.util.ArrayList;
+
+import tests.A.A;
+import tests.B.BEvent;
+
+public class AImpl
+	implements A, BEvent
+{
+	ArrayList<Integer> items;
+	
+	public AImpl()
+	{
+		items = new ArrayList<Integer>();
+	}
+	
+	public void a()
+	{
+		allocObj(100);
+		
+		System.out.println(A.class.getName() + ".a() called.");
+		
+		sleep(1);
+	}
+	
+	void allocObj(int count)
+	{
+		try {p(count);} catch (Exception e) {}
+	}
+	
+	void p(int count)
+	{
+		for (int i=0; i<count; ++i)
+			items.add(new Integer((int)Math.random()));
+	}
+
+	public int b(long x, long y)
+	{
+		return 0;
+	}
+
+	public long[] c(int n)
+	{
+		return null;
+	}
+
+	public void handler()
+	{
+//		allocObj(10000);
+//		System.out.println(BEvent.class.getName() + ".handler() called.");
+
+		ArrayList<Double> T = new ArrayList<Double>();
+		for (int i=0; i < 49999; ++i)
+			T.add(new Double(Math.random()));
+		
+		sleep(5);
+	}
+	
+	void sleep(long sec)
+	{
+		try {
+			Thread.sleep(sec * 1000);
+		} catch (Exception e) {e.printStackTrace();}
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,34 @@
+package tests.AImpl;
+
+import tests.A.A;
+import tests.B.BEvent;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator
+	implements BundleActivator
+{
+	BundleContext context;
+	AImpl a;
+//	EImpl e;
+
+	public void start(BundleContext bundleContext) throws Exception
+	{	
+		System.out.println(this.getClass().getPackage().getName() + " provides " + A.class.getName());
+		context = bundleContext;
+
+		a = new AImpl();
+		
+		String[] classes = {A.class.getName(), BEvent.class.getName()};
+		context.registerService(classes, a, null);
+
+		// e = new EImpl();
+		// context.registerService(E.class, e, null);	
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println(this.getClass().getPackage().getName() + " no more provides " + A.class.getName());
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/EImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/EImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/EImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.AImpl/src/tests/AImpl/EImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,21 @@
+package tests.AImpl;
+
+import tests.E.E;
+
+public class EImpl
+	implements E
+{
+	public void e()
+	{
+		try {
+			someProcessing();
+		} catch (InterruptedException e1) {
+			e1.printStackTrace();
+		}
+	}
+	
+	private void someProcessing() throws InterruptedException
+	{
+		Thread.sleep(10000);
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/tests.B/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.B/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.B/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.B/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.B/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: Tests B
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: tests.B
+Export-Package: tests.B

Added: vmkit/branches/memory-monitor/osgi/tests/tests.B/src/tests/B/BEvent.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.B/src/tests/B/BEvent.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.B/src/tests/B/BEvent.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.B/src/tests/B/BEvent.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+package tests.B;
+
+public interface BEvent
+{
+	public void handler();
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: Tests B Impl
+Bundle-Activator: tests.BImpl.Activator
+Bundle-ManifestVersion: 2
+Import-Package: org.osgi.util.tracker, tests.A, tests.B, org.osgi.fram
+ ework
+Bundle-SymbolicName: tests.BImpl
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,103 @@
+package tests.BImpl;
+
+import tests.A.A;
+import tests.B.BEvent;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator
+	implements BundleActivator, ServiceListener
+{
+	BundleContext context;
+	BImpl b;
+	ServiceTracker<A, A> serviceTrackerA;
+	ServiceTracker<BEvent, BEvent> serviceTrackerBEvent;
+
+	public void start(BundleContext bundleContext) throws Exception
+	{	
+		System.out.println(this.getClass().getPackage().getName()
+			+ " consumes " + A.class.getName());
+		System.out.println(this.getClass().getPackage().getName()
+			+ " consumes " + BEvent.class.getName());
+		context = bundleContext;
+
+		b = new BImpl();
+		b.start();
+		
+		serviceTrackerA = new ServiceTracker<A, A>(context, A.class, null);
+		serviceTrackerA.open();
+		
+		if (serviceTrackerA.getService() != null) {
+			this.serviceChanged(new ServiceEvent(
+				ServiceEvent.REGISTERED,
+				serviceTrackerA.getServiceReference()));
+		}
+		
+		context.addServiceListener(
+			this, "(objectclass=" + A.class.getName() + ")");
+		
+		serviceTrackerBEvent =
+			new ServiceTracker<BEvent, BEvent>(context, BEvent.class, null);
+		serviceTrackerBEvent.open();
+		
+		if (serviceTrackerBEvent.getService() != null) {
+			this.serviceChanged(new ServiceEvent(
+				ServiceEvent.REGISTERED,
+				serviceTrackerBEvent.getServiceReference()));
+		}
+		
+		context.addServiceListener(
+			this, "(objectclass=" + BEvent.class.getName() + ")");
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println(this.getClass().getPackage().getName()
+			+ " no more consumes " + A.class.getName());
+		System.out.println(this.getClass().getPackage().getName()
+			+ " no more consumes " + BEvent.class.getName());
+		
+		b.stop();
+		
+		serviceTrackerA.close();
+		serviceTrackerBEvent.close();
+	}
+
+	public void serviceChanged(ServiceEvent event)
+	{
+		Object service = context.getService(event.getServiceReference());
+		String[] objClassList =
+			(String[])event.getServiceReference().getProperty("objectclass");
+		
+		switch(event.getType()) {
+		case ServiceEvent.REGISTERED:
+			for (String cl : objClassList) {
+				if (cl.equals(A.class.getName())) {
+					b.setA((A)service);
+				}
+				
+				if (cl.equals(BEvent.class.getName())) {
+					b.setBEvent((BEvent)service);
+				}
+			}
+				
+			break;
+			
+		case ServiceEvent.UNREGISTERING:
+			for (String cl : objClassList) {
+				if (cl.equals(A.class.getName())) {
+					b.setA(null);
+				}
+				
+				if (cl.equals(BEvent.class.getName())) {
+					b.setBEvent(null);
+				}
+			}
+			break;
+		}
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/BImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/BImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/BImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.BImpl/src/tests/BImpl/BImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,137 @@
+package tests.BImpl;
+
+import tests.A.A;
+import tests.B.BEvent;
+
+public class BImpl
+	implements Runnable
+{
+	A a;
+	BEvent b;
+	boolean termThread;
+	Thread th;
+	
+	public BImpl()
+	{
+		th = new Thread(this, this.getClass().getName());
+	}
+	
+	public void start()
+	{
+		termThread = false;
+		th.start();
+	}
+	
+	public void stop()
+	{
+		termThread = true;
+		
+		try {
+			th.join();
+		} catch (Exception e) {e.printStackTrace();}
+	}
+
+	public void setA(A a)
+	{
+		this.a = a;
+		
+		if (a == null)
+			System.out.println(this.getClass().getPackage().getName() + " no more references " + A.class.getName());
+		else
+			System.out.println(this.getClass().getPackage().getName() + " references " + A.class.getName());
+	}
+	
+	public void setBEvent(BEvent b)
+	{
+		this.b = b;
+		
+		if (b == null)
+			System.out.println(this.getClass().getPackage().getName() + " no more references " + BEvent.class.getName());
+		else
+			System.out.println(this.getClass().getPackage().getName() + " references " + BEvent.class.getName());
+	}
+	
+	void dummy
+	(
+		long d00, long d01, long d02, long d03, long d04, long d05, long d06, long d07, long d08, long d09,
+		long d10, long d11, long d12, long d13, long d14, long d15, long d16, long d17, long d18, long d19,
+		long d20, long d21, long d22, long d23, long d24, long d25, long d26, long d27, long d28, long d29,
+		long d30, long d31, long d32, long d33, long d34, long d35, long d36, long d37, long d38, long d39,
+		long d40, long d41, long d42, long d43, long d44, long d45, long d46, long d47, long d48, long d49,
+		long d50, long d51, long d52, long d53, long d54, long d55, long d56, long d57, long d58, long d59,
+		long d60, long d61, long d62, long d63, long d64, long d65, long d66, long d67, long d68, long d69,
+		long d70, long d71, long d72, long d73, long d74, long d75, long d76, long d77, long d78, long d79,
+		long d80, long d81, long d82, long d83, long d84, long d85, long d86, long d87, long d88, long d89,
+		long d90, long d91, long d92, long d93, long d94, long d95, long d96, long d97, long d98, long d99)
+	{
+		try {
+			Thread.sleep(1000);
+		} catch (Exception e) {}
+	}
+
+	public void run()
+	{
+		long v00 = 0, v01 = 0, v02 = 0, v03 = 0, v04 = 0, v05 = 0, v06 = 0, v07 = 0, v08 = 0, v09 = 0;
+		long v10 = 0, v11 = 0, v12 = 0, v13 = 0, v14 = 0, v15 = 0, v16 = 0, v17 = 0, v18 = 0, v19 = 0;
+		long v20 = 0, v21 = 0, v22 = 0, v23 = 0, v24 = 0, v25 = 0, v26 = 0, v27 = 0, v28 = 0, v29 = 0;
+		long v30 = 0, v31 = 0, v32 = 0, v33 = 0, v34 = 0, v35 = 0, v36 = 0, v37 = 0, v38 = 0, v39 = 0;
+		long v40 = 0, v41 = 0, v42 = 0, v43 = 0, v44 = 0, v45 = 0, v46 = 0, v47 = 0, v48 = 0, v49 = 0;
+		long v50 = 0, v51 = 0, v52 = 0, v53 = 0, v54 = 0, v55 = 0, v56 = 0, v57 = 0, v58 = 0, v59 = 0;
+		long v60 = 0, v61 = 0, v62 = 0, v63 = 0, v64 = 0, v65 = 0, v66 = 0, v67 = 0, v68 = 0, v69 = 0;
+		long v70 = 0, v71 = 0, v72 = 0, v73 = 0, v74 = 0, v75 = 0, v76 = 0, v77 = 0, v78 = 0, v79 = 0;
+		long v80 = 0, v81 = 0, v82 = 0, v83 = 0, v84 = 0, v85 = 0, v86 = 0, v87 = 0, v88 = 0, v89 = 0;
+		long v90 = 0, v91 = 0, v92 = 0, v93 = 0, v94 = 0, v95 = 0, v96 = 0, v97 = 0, v98 = 0, v99 = 0;
+
+		dummy(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10,
+			v11, v12, v13, v14, v15, v16, v17, v18, v19, v20,
+			v21, v22, v23, v24, v25, v26, v27, v28, v29, v30,
+			v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,
+			v41, v42, v43, v44, v45, v46, v47, v48, v49, v50,
+			v51, v52, v53, v54, v55, v56, v57, v58, v59, v60,
+			v61, v62, v63, v64, v65, v66, v67, v68, v69, v70,
+			v71, v72, v73, v74, v75, v76, v77, v78, v79, v80,
+			v81, v82, v83, v84, v85, v86, v87, v88, v89, v90,
+			v91, v92, v93, v94, v95, v96, v97, v98, v99);
+
+		System.out.println(this.getClass().getPackage().getName() + " running...");
+/*
+		Object[] o = new Object[100];
+		for (int i=0; i < 100; ++i)
+			o[i] = new Object();
+
+		for (int i=0; i < 100; ++i) {
+			synchronized(o[i]) {
+				o[i].notify();
+			}
+		}
+*/		
+		do_it();
+		
+		System.out.println(this.getClass().getPackage().getName() + " stopped.");
+	}
+	
+	void do_it()
+	{
+//		long v01 = 0, v02 = 0, v03 = 0, v04 = 0, v05 = 0, v06 = 0, v07 = 0, v08 = 0, v09 = 0, v10 = 0, v11 = 0, v12 = 0, v13 = 0, v14 = 0, v15 = 0, v16 = 0, v17 = 0, v18 = 0, v19 = 0, v20 = 0, v21 = 0, v22 = 0, v23 = 0, v24 = 0, v25 = 0, v26 = 0, v27 = 0, v28 = 0, v29 = 0, v30 = 0, v31 = 0, v32 = 0, v33 = 0, v34 = 0, v35 = 0, v36 = 0, v37 = 0, v38 = 0, v39 = 0, v40 = 0, v41 = 0, v42 = 0, v43 = 0, v44 = 0, v45 = 0, v46 = 0, v47 = 0, v48 = 0, v49 = 0, v50 = 0, v51 = 0;
+//		dummy(v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51);
+				
+		while (!termThread) {
+			if (a == null)
+				sleep(1);
+			else
+				a.a();
+
+			if (b == null)
+				sleep(1);
+			else
+				b.handler();
+		}
+	}
+	
+	void sleep(long sec)
+	{
+		try {
+			Thread.sleep(sec * 1000);
+		} catch (Exception e) {e.printStackTrace();}
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/tests.E/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.E/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.E/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.E/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.E/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: Tests E
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: tests.E
+Export-Package: tests.E

Added: vmkit/branches/memory-monitor/osgi/tests/tests.E/src/tests/E/E.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.E/src/tests/E/E.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.E/src/tests/E/E.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.E/src/tests/E/E.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+package tests.E;
+
+public interface E
+{
+	public void e();
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: Tests F Impl
+Bundle-Activator: tests.FImpl.Activator
+Bundle-ManifestVersion: 2
+Import-Package: org.osgi.framework, tests.E, org.osgi.util.tracker
+Bundle-SymbolicName: tests.FImpl
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/tests/FImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/tests/FImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/tests/FImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.FImpl/src/tests/FImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,47 @@
+package tests.FImpl;
+
+import java.util.ArrayList;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+import tests.E.E;
+
+public class Activator
+	implements BundleActivator
+{
+	BundleContext context;
+	ServiceTracker<E, E> serviceTrackerE;
+
+	public void start(BundleContext bundleContext) throws Exception
+	{	
+		context = bundleContext;
+		
+		serviceTrackerE = new ServiceTracker<E, E>(context, E.class, null);
+		serviceTrackerE.open();
+		
+		heavyInitialization();
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println(this.getClass().getPackage().getName()
+			+ " consumes " + E.class.getName());
+		
+		serviceTrackerE.close();
+	}
+	
+	void heavyInitialization() throws Exception
+	{
+		E e = serviceTrackerE.getService();
+		if (e == null)
+			throw new Exception("Service not found: " + E.class.getName());
+		
+		ArrayList<Double> T = new ArrayList<Double>();
+		for (int i=0; i < 499; ++i)
+			T.add(new Double(Math.random()));
+		
+		e.e();	
+	}
+}

Propchange: vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,6 @@
+out
+.bundle-pack
+.classpath
+.git*
+.project
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/bundle.manifest
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/bundle.manifest?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/bundle.manifest (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/bundle.manifest Thu Oct  9 03:43:38 2014
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: Tests G Impl
+Bundle-ManifestVersion: 2
+Bundle-Activator: tests.GImpl.Activator
+Bundle-SymbolicName: tests.GImpl
+Import-Package: org.osgi.framework, tests.E, tests.B
+

Added: vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/Activator.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/Activator.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/Activator.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,30 @@
+package tests.GImpl;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import tests.E.E;
+
+public class Activator
+	implements BundleActivator
+{
+	BundleContext context;
+	EImpl e;
+
+	public void start(BundleContext bundleContext) throws Exception
+	{
+		context = bundleContext;
+		
+		System.out.println(this.getClass().getPackage().getName()
+			+ " provides " + E.class.getName());
+
+		e = new EImpl(context);
+		context.registerService(E.class, e, null);	
+	}
+
+	public void stop(BundleContext bundleContext) throws Exception
+	{
+		System.out.println(this.getClass().getPackage().getName()
+			+ " no more provides " + E.class.getName());
+	}
+}

Added: vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/EImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/EImpl.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/EImpl.java (added)
+++ vmkit/branches/memory-monitor/osgi/tests/tests.GImpl/src/tests/GImpl/EImpl.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,48 @@
+package tests.GImpl;
+
+import java.util.ArrayList;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import tests.E.E;
+import tests.B.BEvent;
+
+public class EImpl
+	implements E
+{
+	BundleContext context;
+	
+	public EImpl(BundleContext context)
+	{
+		this.context = context;
+	}
+	
+	public void e()
+	{
+		try {
+			someProcessing();
+		} catch (Exception e1) {
+			e1.printStackTrace();
+		}
+	}
+	
+	private void someProcessing() throws Exception
+	{
+		ServiceReference<BEvent> refBEvent =
+			context.getServiceReference(BEvent.class);
+		
+		if (refBEvent == null)
+			throw new Exception("Service not found: " + BEvent.class.getName());
+		
+		BEvent b = context.getService(refBEvent);
+		if (b == null)
+			throw new Exception("Service not found: " + BEvent.class.getName());
+
+		ArrayList<Double> T = new ArrayList<Double>();
+		for (int i=0; i < 4999; ++i)
+			T.add(new Double(Math.random()));
+
+		b.handler();
+	}
+}

Propchange: vmkit/branches/memory-monitor/tests/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1 @@
+*.odt

Removed: vmkit/branches/memory-monitor/tests/AnnotationClassTest.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/AnnotationClassTest.java?rev=219391&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/AnnotationClassTest.java (original)
+++ vmkit/branches/memory-monitor/tests/AnnotationClassTest.java (removed)
@@ -1,52 +0,0 @@
-import java.lang.Deprecated;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-
-public class AnnotationClassTest {
-
-	@MyAnnotation (property = 13, property4 = System.class)
-  static class Sample {
-    @Deprecated
-    @MyAnnotation (property=5, property4=String.class)
-    public int x;
-    
-    @MyAnnotation (property=7, property4=String.class)
-    public int y() {
-    	return x*x;
-    }
-  }
-
-  public static void main(String[] args) throws Exception {
-    Field f = Sample.class.getField("x");
-    Method m = Sample.class.getMethod("y");
-    Sample sample = new Sample();
-    sample.x = 14;
-    
-    Annotation [] fAnno = f.getDeclaredAnnotations();
-    Annotation [] mAnno = m.getAnnotations();
-    Annotation [] cAnno = Sample.class.getDeclaredAnnotations();
-
-    MyAnnotation xx = (MyAnnotation)f.getAnnotation(MyAnnotation.class);
-		MyAnnotation yy = (MyAnnotation)m.getAnnotation(MyAnnotation.class);
-		
-		
-
-    check(f.getInt(sample) == 14);
-    f.setInt(sample, 17);
-    check(f.getInt(sample) == 17);
-    check(xx != null);
-    check(yy != null);
-    check(mAnno.length == 1);
-		check(fAnno.length == 2);
-		check(cAnno != null && cAnno.length == 1 && cAnno[0]!= null);
-    //int s = yy.property();
-    //check(s == 5);
-    
-  }
-
-  private static void check(boolean b) throws Exception {
-    if (!b) throw new Exception("Test failed!!!");
-  }
-}

Removed: vmkit/branches/memory-monitor/tests/MyAnnotation.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/MyAnnotation.java?rev=219391&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/MyAnnotation.java (original)
+++ vmkit/branches/memory-monitor/tests/MyAnnotation.java (removed)
@@ -1,8 +0,0 @@
-import java.lang.annotation.*;
- at Retention(value=RetentionPolicy.RUNTIME)
-public @interface MyAnnotation {
-	int property();
-	int[] primes() default {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
-	String property3() default "Default value";
-	Class property4();
-}

Added: vmkit/branches/memory-monitor/tests/dacapo/2006-10-MR2/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/dacapo/2006-10-MR2/Makefile?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/dacapo/2006-10-MR2/Makefile (added)
+++ vmkit/branches/memory-monitor/tests/dacapo/2006-10-MR2/Makefile Thu Oct  9 03:43:38 2014
@@ -0,0 +1,10 @@
+
+LEVEL             := ..
+DACAPO_VERSION    := 2006-10-MR2
+DACAPO_ARGS       := -s default
+
+ifndef DECAPO_BENCHMARKS
+    DECAPO_BENCHMARKS := antlr bloat chart eclipse fop hsqldb jython luindex lusearch pmd xalan
+endif
+
+include ../Makefile.inc

Added: vmkit/branches/memory-monitor/tests/dacapo/Makefile.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/dacapo/Makefile.inc?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/dacapo/Makefile.inc (added)
+++ vmkit/branches/memory-monitor/tests/dacapo/Makefile.inc Thu Oct  9 03:43:38 2014
@@ -0,0 +1,40 @@
+
+ifdef DEBUG
+    BUILD_MODE := Debug+Asserts
+else
+    BUILD_MODE := Release+Asserts
+endif
+
+ifndef BENCHMARK_REPEATS
+    BENCHMARK_REPEATS := 12
+endif
+
+ifndef VERBOSE
+    QUIET := @
+endif
+
+DACAPO_JAR    := $(abspath $(PWD)/$(LEVEL)/jars/dacapo-$(DACAPO_VERSION).jar)
+JVM_PATH      := $(abspath $(PWD)/$(LEVEL)/../../$(BUILD_MODE)/bin/j3)
+WORK_DIR      := $(HOME)/dacapo_benchmarks
+TMP_DIR       := $(shell mkdir -p $(WORK_DIR) 2>/dev/null ; mktemp -d --suffix=.$(DACAPO_VERSION) --tmpdir=$(WORK_DIR))
+DEPS          := $(shell for i in $(DECAPO_BENCHMARKS); do seq -f "dacapoBenchmark_%g_$$i" $(BENCHMARK_REPEATS); done)
+
+all: _PRINT_TMP_DIR $(DEPS)
+
+_PRINT_TMP_DIR:
+	$(QUIET) echo "Target dir: " $(TMP_DIR)
+
+$(DEPS):: $(DACAPO_JAR)
+
+$(DACAPO_JAR):
+	$(QUIET) wget "http://sourceforge.net/projects/dacapobench/files/archive/2006-10-MR2/dacapo-2006-10-MR2.jar/download" -O "$(DACAPO_JAR)"
+
+dacapoBenchmark_%:
+	$(eval BENCH_COUNT_$@ := $$(shell echo $@ | cut -d '_' -f 2))
+	$(eval BENCH_NAME_$@ := $$(shell echo $@ | cut -d '_' -f 3-))
+	$(eval TEMP_DIR_$@ := $(TMP_DIR)/$(BENCH_NAME_$@)/$(BENCH_COUNT_$@))
+	$(QUIET) mkdir -p "$(TEMP_DIR_$@)" 2>/dev/null
+	$(QUIET) cd "$(TEMP_DIR_$@)" && "$(JVM_PATH)" -jar "$(DACAPO_JAR)" $(DACAPO_ARGS) "$(BENCH_NAME_$@)" > "$(TMP_DIR)/$(BENCH_NAME_$@).$(BENCH_COUNT_$@).log" 2>&1
+
+clean:
+	$(QUIET) -rm -rf $(WORK_DIR)/tmp.* $(WORK_DIR)/*.log 2>/dev/null

Added: vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.plot
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.plot?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.plot (added)
+++ vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.plot Thu Oct  9 03:43:38 2014
@@ -0,0 +1,40 @@
+#!/usr/bin/gnuplot -p
+
+set datafile separator ","
+set datafile missing '_'
+set datafile commentschars "#"
+
+set ylabel "Average relative overhead (lower is better)"
+set ytics border nomirror
+set grid ytics
+set format y "%.0f %%"
+
+set style data histogram
+set style histogram clustered gap 1
+set bars fullwidth
+set style fill solid border 0
+set boxwidth 1
+
+# set title "Monitoring overhead in Dacapo benchmarks"
+
+set xtics axis nomirror
+set border 3
+
+set term png size 900, 600
+set output "overhead.png"
+plot	\
+	'/home/koutheir/dacapo_benchmarks/overhead-0-1.csv' using 3:xtic(1) linecolor rgb "#e5e5e5" title "0 vs 1",	 \
+	'/home/koutheir/dacapo_benchmarks/overhead-0-6.csv' using 3:xtic(1) linecolor rgb "#b2b2b2" title "0 vs 6",	 \
+	'/home/koutheir/dacapo_benchmarks/overhead-0-7.csv' using 3:xtic(1) linecolor rgb "#7f7f7f" title "0 vs 7"
+
+set output "overhead-0-1.png"
+plot	\
+	'/home/koutheir/dacapo_benchmarks/overhead-0-1.csv' using 3:xtic(1) linecolor rgb "#808080" title "0 vs 1"
+
+set output "overhead-0-6.png"
+plot	\
+	'/home/koutheir/dacapo_benchmarks/overhead-0-6.csv' using 3:xtic(1) linecolor rgb "#808080" title "0 vs 6"
+
+set output "overhead-0-7.png"
+plot	\
+	'/home/koutheir/dacapo_benchmarks/overhead-0-7.csv' using 3:xtic(1) linecolor rgb "#808080" title "0 vs 7"

Added: vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.sh
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.sh?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.sh (added)
+++ vmkit/branches/memory-monitor/tests/dacapo/compare-dacapo-synthesized-logs.sh Thu Oct  9 03:43:38 2014
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+synth_file_1=$1
+synth_file_2=$2
+
+if [ \( -z "$synth_file_1" \) -o \( -z "$synth_file_2" \) ]; then
+	exit 1
+fi
+
+echo '#benchmark,min_duration_overhead,average_duration_overhead,max_duration_overhead,std_dev_duration_overhead'
+
+while read -r line ; do
+	if ! echo $line | grep '^#' >/dev/null 2>&1; then
+		cur_bench=$(echo $line | cut -d ',' -f 1)
+		min_duration_1=$(echo $line | cut -d ',' -f 2)
+		average_duration_1=$(echo $line | cut -d ',' -f 3)
+		max_duration_1=$(echo $line | cut -d ',' -f 4)
+		std_dev_duration_1=$(echo $line | cut -d ',' -f 5)
+		
+		line_2=$(grep "^$cur_bench," "$synth_file_2")
+		min_duration_2=$(echo $line_2 | cut -d ',' -f 2)
+		average_duration_2=$(echo $line_2 | cut -d ',' -f 3)
+		max_duration_2=$(echo $line_2 | cut -d ',' -f 4)
+		std_dev_duration_2=$(echo $line_2 | cut -d ',' -f 5)
+		
+		min_duration_overhead=$(echo "scale=4; 100.0 * (($min_duration_2 / $min_duration_1) - 1.0)" | bc -q 2>/dev/null)
+		average_duration_overhead=$(echo "scale=4; 100.0 * (($average_duration_2 / $average_duration_1) - 1.0)" | bc -q 2>/dev/null)
+		max_duration_overhead=$(echo "scale=4; 100.0 * (($max_duration_2 / $max_duration_1) - 1.0)" | bc -q 2>/dev/null)
+		std_dev_duration_overhead=$(echo "scale=4; 100.0 * (($std_dev_duration_2 / $std_dev_duration_1) - 1.0)" | bc -q 2>/dev/null)
+		
+		printf "%s,%.2f,%.2f,%.2f,%.2f\n" "$cur_bench" "$min_duration_overhead" "$average_duration_overhead" "$max_duration_overhead" "$std_dev_duration_overhead"
+	fi
+done < "$synth_file_1"

Propchange: vmkit/branches/memory-monitor/tests/dacapo/jars/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,2 @@
+*.jar
+

Added: vmkit/branches/memory-monitor/tests/dacapo/jars/download.sh
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/dacapo/jars/download.sh?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/dacapo/jars/download.sh (added)
+++ vmkit/branches/memory-monitor/tests/dacapo/jars/download.sh Thu Oct  9 03:43:38 2014
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+wget http://sourceforge.net/projects/dacapobench/files/archive/2006-10-MR2/dacapo-2006-10-MR2.jar/download -O dacapo-2006-10-MR2.jar
+#wget http://sourceforge.net/projects/dacapobench/files/archive/2006-10/dacapo-2006-10.jar/download -O dacapo-2006-10.jar
+#wget http://sourceforge.net/projects/dacapobench/files/9.12-bach/dacapo-9.12-bach.jar/download -O dacapo-9.12-bach.jar

Added: vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.plot
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.plot?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.plot (added)
+++ vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.plot Thu Oct  9 03:43:38 2014
@@ -0,0 +1,32 @@
+#!/usr/bin/gnuplot -p
+
+set datafile separator ","
+set datafile missing '_'
+set datafile commentschars "#"
+
+set ylabel "Duration (lower is better)"
+set ytics border nomirror
+set grid ytics
+set yrange [0:*]
+set ydata time
+set timefmt "%S"
+set format y "%M:%S"
+
+set xtics axis nomirror
+set border 3
+
+set style data histogram
+set style histogram errorbars gap 1 lw 1
+set bars fullwidth
+set style fill solid border 0
+set boxwidth 1
+
+# set title "Monitoring overhead in Dacapo benchmarks"
+
+set term png size 900, 600
+set output "dacapo.png"
+plot	\
+	'/home/koutheir/dacapo_benchmarks/0.csv' using (column(3)/1000.0):(column(5)/1000.0):xtic(1) linecolor rgb "#e5e5e5" title "0",	\
+	'/home/koutheir/dacapo_benchmarks/1.csv' using (column(3)/1000.0):(column(5)/1000.0):xtic(1) linecolor rgb "#b2b2b2" title "1",	\
+	'/home/koutheir/dacapo_benchmarks/6.csv' using (column(3)/1000.0):(column(5)/1000.0):xtic(1) linecolor rgb "#7f7f7f" title "6",	\
+	'/home/koutheir/dacapo_benchmarks/7.csv' using (column(3)/1000.0):(column(5)/1000.0):xtic(1) linecolor rgb "#4c4c4c" title "7"

Added: vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.sh
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.sh?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.sh (added)
+++ vmkit/branches/memory-monitor/tests/dacapo/synth-dacapo-logs.sh Thu Oct  9 03:43:38 2014
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+log_dir=$1
+
+if [ -z "$log_dir" ]; then
+	exit 1
+fi
+
+stage1_file=/tmp/$0.$$.stage1
+stage2_file=/tmp/$0.$$.stage2
+stage3_file=/tmp/$0.$$.stage3
+
+rm -f "$stage1_file" "$stage2_file" "$stage3_file"
+
+# Filter successful results and print them in the format: benchmark,duration
+grep '^===== DaCapo [A-Za-z]\+ PASSED' $log_dir/*.log | sed "s/^.*:===== DaCapo //g ; s/ msec =====//g ; s/ PASSED in /,/g" | sort > $stage1_file
+
+# Calculate minimum, maximum and average durations
+
+count=0
+while read -r line ; do
+	cur_bench=$(echo $line | cut -d ',' -f 1)
+	cur_duration=$(echo $line | cut -d ',' -f 2)
+	
+	if [ -z "$last_bench" ]; then
+		last_bench=$cur_bench
+		count=1
+		average_duration=$cur_duration
+		min_duration=$cur_duration
+		max_duration=$cur_duration
+	else
+		if [ "$last_bench" == "$cur_bench" ]; then
+			count=$(($count + 1))
+			average_duration=$(($average_duration + $cur_duration))
+			if [ "$cur_duration" -lt "$min_duration" ]; then
+				min_duration=$cur_duration
+			fi
+			if [ "$cur_duration" -gt "$max_duration" ]; then
+				max_duration=$cur_duration
+			fi
+		else
+			average_duration=$(($average_duration / $count))
+			echo "$last_bench,$min_duration,$average_duration,$max_duration" >> $stage2_file
+			
+			last_bench=$cur_bench
+			count=1
+			average_duration=$cur_duration
+			min_duration=$cur_duration
+			max_duration=$cur_duration
+		fi
+	fi
+done < $stage1_file
+
+if [ "$count" -gt 0 ]; then
+	average_duration=$(($average_duration / $count))
+	echo "$last_bench,$min_duration,$average_duration,$max_duration" >> $stage2_file
+fi
+
+echo '#benchmark,min_duration_ms,average_duration_ms,max_duration_ms,std_dev_duration_ms'
+
+# Calculate the standard deviation
+while read -r line ; do
+	cur_bench=$(echo $line | cut -d ',' -f 1)
+	cur_average=$(echo $line | cut -d ',' -f 3)
+	
+	grep "^$cur_bench," "$stage1_file" > "$stage3_file"
+	
+	count=0
+	std_dev='sqrt((0'
+	
+	while read -r line2 ; do
+		cur_duration=$(echo $line2 | cut -d ',' -f 2)
+		
+		std_dev+="+(($cur_duration - $cur_average)^2)"
+		count=$(($count+1))
+	done < "$stage3_file"
+	
+	std_dev+=")/$count)"
+	std_dev=$(echo "scale=0; $std_dev" | bc -q 2>/dev/null)
+	echo "$line,$std_dev"
+done < $stage2_file
+
+rm -f "$stage1_file" "$stage2_file" "$stage3_file"

Added: vmkit/branches/memory-monitor/tests/debug.txt
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/debug.txt?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/debug.txt (added)
+++ vmkit/branches/memory-monitor/tests/debug.txt Thu Oct  9 03:43:38 2014
@@ -0,0 +1,70 @@
+-X:gc:verbose=0 -jar framework.jar -xargs /home/koutheir/PhD/VMKit/incinerator/incinerator/tests/minimal.bug.xargs
+framework call j3.J3Mgr setBundleStaleReferenceCorrected ijvm.tests.AImpl yes
+framework call j3.J3Mgr setBundleStaleReferenceCorrected ijvm.tests.BImpl yes
+framework call j3.J3Mgr setBundleStaleReferenceCorrected ijvm.tests.CImpl yes
+stop 12
+stop 13
+stop 14
+
+start 12 13 14
+stop 12
+
+framework call j3.J3Mgr isBundleStaleReferenceCorrected 39
+framework call j3.J3Mgr setBundleStaleReferenceCorrected 8 yes
+
+enter framework
+call j3.J3Mgr isBundleStaleReferenceCorrected 14
+call j3.J3Mgr setBundleStaleReferenceCorrected 14 yes
+update 14
+
+framework call j3.J3Mgr dumpClassLoaderBundles
+
+stop 8
+uninstall 8
+refresh
+meminfo -gc
+call j3.J3Mgr setBundleStaleReferenceCorrected 14 yes
+call j3.J3Mgr dumpReferencesToObject 0x51934ab4
+
+refresh
+meminfo -gc
+
+
+enter framework
+call j3.J3Mgr setBundleStaleReferenceCorrected 11 no
+meminfo -gc
+update 11
+refresh
+meminfo -gc
+
+STALE = {http/http_all-3.1.2.jar, useradmin/useradmin_all-3.0.3.jar, device/device_all-3.0.0.jar, kxml/kxml-2.3.0.kf3.jar}
+
+call j3.J3Mgr forceStaleReferenceScanning
+
+fromupdate 15 file:/media/Data/Documents/PhD/VMKit/incinerator/incinerator/tests/ijvm.tests.Alarm_v2.0/out/ijvm.tests.Alarm_v2.0-2.0.0.jar
+
+enter framework
+call j3.J3Mgr loadTierConfigFile /home/koutheir/PhD/VMKit/vmkit-monitor/tests/tier.description
+install ijvm.tests.A/out/ijvm.tests.A-1.0.0.jar
+install ijvm.tests.C/out/ijvm.tests.C-1.0.0.jar
+install ijvm.tests.AImpl/out/ijvm.tests.AImpl-1.0.0.jar
+install ijvm.tests.BImpl/out/ijvm.tests.BImpl-1.0.0.jar
+install ijvm.tests.CImpl/out/ijvm.tests.CImpl-1.0.0.jar
+install ijvm.tests.DImpl/out/ijvm.tests.DImpl-1.0.0.jar
+resolve 11 12 13 14 15 16
+
+enter framework
+call j3.J3Mgr dumpTierStats
+
+enter framework
+resolve 14 15
+start 15
+call j3.J3Mgr dumpTierStats
+start 14
+call j3.J3Mgr dumpTierStats
+
+enter framework
+start 14 17
+resolve 16
+call j3.J3Mgr dumpTierStats 2
+start 16

Added: vmkit/branches/memory-monitor/tests/full.xargs
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/full.xargs?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/full.xargs (added)
+++ vmkit/branches/memory-monitor/tests/full.xargs Thu Oct  9 03:43:38 2014
@@ -0,0 +1,88 @@
+-Dorg.osgi.framework.dir=/tmp/fwdir
+#-Dorg.knopflerfish.framework.bundlestorage=memory
+-Dorg.knopflerfish.framework.system.export.all_13=false
+-Dorg.knopflerfish.framework.verbosity=0
+
+-Forg.knopflerfish.framework.debug.errors=true
+-Forg.knopflerfish.framework.debug.packages=false
+-Forg.knopflerfish.framework.debug.classloader=false
+#-Forg.knopflerfish.framework.debug.permissions=false
+
+#-Forg.osgi.framework.system.packages.extra=
+
+-Forg.knopflerfish.http.dnslookup=true
+-Forg.osgi.service.http.port=8080
+
+#-Dhttp.proxyHost=proxy
+#-Dhttp.proxyPort=3128
+
+#-Forg.knopflerfish.framework.all_signed=false
+
+-Dorg.knopflerfish.gosg.jars=file:///home/koutheir/PhD/VMKit/knopflerfish/osgi/jars/;file:///home/koutheir/PhD/VMKit/incinerator/incinerator/tests/plugins/
+
+-Forg.knopflerfish.startlevel.use=true
+
+-init
+
+-install log/log_all-3.1.3.jar
+-install cm/cm_all-3.0.4.jar
+-install util/util-2.0.1.jar
+-istart console/console_all-3.0.4.jar
+-istart frameworkcommands/frameworkcommands-3.2.0.jar
+-istart logcommands/logcommands-3.1.1.jar
+-istart cm_cmd/cm_cmd-3.0.2.jar
+-istart consoletty/consoletty-3.0.1.jar
+-istart useradmin/useradmin_api-3.0.3.jar
+-istart util/util-2.0.1.jar
+
+-launch
+
+-istart  j3mgr-1.0.0.jar
+
+#-istart  ijvm.tests.A-1.0.0.jar
+#-istart  ijvm.tests.C-1.0.0.jar
+#-istart  ijvm.tests.AImpl-1.0.0.jar
+#-istart  ijvm.tests.BImpl-1.0.0.jar
+#-istart  ijvm.tests.CImpl-1.0.0.jar
+#-istart  ijvm.tests.DImpl-1.0.0.jar
+#-install ijvm.tests.Runner-1.0.0.jar
+-install BundleReloader-1.0.0.jar
+
+-install desktop/desktop_all-3.2.5.jar
+-install comm-linux/comm-linux_all-2.0.0.jar
+-install command/command_all-0.1.jar
+-install jsdk/jsdk_api-2.5.0.kf3-2.jar
+
+-istart kxml/kxml-2.3.0.kf3.jar
+-istart metatype/metatype-3.0.0.jar
+-istart kf_metatype/kf_metatype_all-3.0.2.jar
+-istart component/component_all-3.1.14.jar
+-istart event/event_all-3.0.8.jar
+-istart cm_desktop/cm_desktop_all-3.0.0.jar
+-istart threadio/threadio_all-0.1.0.jar
+-istart consoletcp/consoletcp_all-2.0.0.jar
+-istart soapobject/soapobject_all-0.0.2.jar
+-istart crimson/crimson-2.1.0.kf3.jar
+-istart measurement/measurement-3.0.1.jar
+-istart position/position-3.0.1.jar
+-istart sslj2sp/sslj2sp-2.0.0.jar
+-istart xerces/xerces-2.10.1.kf3.jar
+-istart xml/xml-3.0.1.jar
+-istart cm/cm_all-3.0.4.jar
+-istart commons-logging/commons-logging_all-2.0.0.kf3.jar
+-istart console/console_all-3.0.4.jar
+-istart prefs/prefs_all-3.0.1.jar
+-istart io/io_all-3.0.1.jar
+-istart device/device_all-3.0.0.jar
+-istart xalan/xalan-2.7.1.kf3_01.jar
+-istart basicdriverlocator/basicdriverlocator_all-3.0.0.jar
+-istart connectors/connectors_all-2.0.1.jar
+#-istart http/http_all-3.1.2.jar
+#-istart httpconsole/httpconsole_all-3.0.2.jar
+#-istart httproot/httproot-3.0.1.jar
+-istart useradmin/useradmin_all-3.0.3.jar
+-istart scrcommands/scrcommands-1.1.0.jar
+-istart serialportdevice/serialportdevice_all-2.0.1.jar
+-istart bundlerepository/bundlerepository_all-3.1.2.jar
+-istart commandtty/commandtty-2.0.0.jar
+-istart console2command/console2command-1.0.0.jar

Added: vmkit/branches/memory-monitor/tests/java-grant-all.policy
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/java-grant-all.policy?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/java-grant-all.policy (added)
+++ vmkit/branches/memory-monitor/tests/java-grant-all.policy Thu Oct  9 03:43:38 2014
@@ -0,0 +1 @@
+grant { permission java.security.AllPermission; };

Added: vmkit/branches/memory-monitor/tests/min.xargs
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/min.xargs?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/min.xargs (added)
+++ vmkit/branches/memory-monitor/tests/min.xargs Thu Oct  9 03:43:38 2014
@@ -0,0 +1,47 @@
+-Dorg.osgi.framework.dir=/tmp/fwdir
+-Dorg.knopflerfish.framework.system.export.all_13=false
+-Dorg.knopflerfish.framework.verbosity=0
+
+-Forg.knopflerfish.framework.debug.errors=true
+-Forg.knopflerfish.framework.debug.packages=false
+-Forg.knopflerfish.framework.debug.classloader=false
+#-Forg.knopflerfish.framework.debug.permissions=false
+
+#-Forg.osgi.framework.system.packages.extra=
+
+-Forg.knopflerfish.http.dnslookup=true
+-Forg.osgi.service.http.port=8080
+
+-Dhttp.proxyHost=proxy
+-Dhttp.proxyPort=3128
+
+#-Forg.knopflerfish.framework.all_signed=false
+
+-Dorg.knopflerfish.gosg.jars=file:///home/koutheir/PhD/VMKit/knopflerfish.vmkit/osgi/jars/;file:///home/koutheir/PhD/VMKit/vmkit-monitor/osgi/j3mgr/out/;file:///home/koutheir/PhD/VMKit/vmkit-monitor/osgi/tests/
+
+-Forg.knopflerfish.startlevel.use=true
+
+-init
+
+-istart j3mgr-1.0.0.jar
+
+-istart log/log_all-5.0.0.jar
+-istart cm/cm_all-5.0.0.jar
+-istart util/util-4.1.0.jar
+-istart console/console_all-4.0.1.jar
+-istart frameworkcommands/frameworkcommands-4.0.1.jar
+-istart logcommands/logcommands-5.0.0.jar
+-istart cm_cmd/cm_cmd-5.0.1.jar
+-istart consoletty/consoletty-4.0.1.jar
+-istart useradmin/useradmin_api-4.0.0.jar
+-istart util/util-4.1.0.jar
+
+-launch
+
+-install ijvm.tests.A/out/ijvm.tests.A-1.0.0.jar
+-install ijvm.tests.C/out/ijvm.tests.C-1.0.0.jar
+
+-install ijvm.tests.AImpl/out/ijvm.tests.AImpl-1.0.0.jar
+-install ijvm.tests.BImpl/out/ijvm.tests.BImpl-1.0.0.jar
+-install ijvm.tests.CImpl/out/ijvm.tests.CImpl-1.0.0.jar
+#-install ijvm.tests.DImpl/out/ijvm.tests.DImpl-1.0.0.jar

Propchange: vmkit/branches/memory-monitor/tests/monitor-bench/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct  9 03:43:38 2014
@@ -0,0 +1,8 @@
+bin
+out
+.bundle-pack
+.classpath
+.git*
+.project
+.settings
+

Added: vmkit/branches/memory-monitor/tests/monitor-bench/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/Makefile?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/Makefile (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/Makefile Thu Oct  9 03:43:38 2014
@@ -0,0 +1,44 @@
+ifndef J3_ROOT_PATH
+    J3_ROOT_PATH := /home/koutheir/phd/vmkit/vmkit-monitor
+endif
+
+ifndef BENCHMARK_NAMES
+    BENCHMARK_NAMES := MethodCallBenchmark SmallObjectsBenchmark
+endif
+
+ifdef DEBUG
+    BUILD_MODE := Debug+Asserts
+else
+    BUILD_MODE := Release+Asserts
+endif
+
+ifndef BENCHMARK_REPEATS
+    BENCHMARK_REPEATS := 4
+endif
+
+ifndef VERBOSE
+    QUIET := @
+endif
+
+BENCHMARK_CLASSPATH := $(abspath $(PWD)/bin)
+J3_PATH      := $(abspath $(J3_ROOT_PATH)/$(BUILD_MODE)/bin/j3)
+WORK_DIR      := $(HOME)/vmkit_monitor_benchmarks
+TMP_DIR       := $(shell mkdir -p $(WORK_DIR) 2>/dev/null ; mktemp -d --suffix=.monitor-bench --tmpdir=$(WORK_DIR))
+DEPS          := $(shell for i in $(BENCHMARK_NAMES); do seq -f "instancesOfBenchmark_%g_$$i" $(BENCHMARK_REPEATS); done)
+
+all: _PRINT_TMP_DIR $(DEPS)
+
+_PRINT_TMP_DIR:
+	$(QUIET) echo "Target dir: " $(TMP_DIR)
+
+$(DEPS):: $(BENCHMARK_CLASSPATH)/MonitorBench/Main.class
+
+instancesOfBenchmark_%:
+	$(eval BENCH_COUNT_$@ := $$(shell echo $@ | cut -d '_' -f 2))
+	$(eval BENCH_NAME_$@ := $$(shell echo $@ | cut -d '_' -f 3-))
+	$(eval TEMP_DIR_$@ := $(TMP_DIR)/$(BENCH_NAME_$@)/$(BENCH_COUNT_$@))
+	$(QUIET) mkdir -p "$(TEMP_DIR_$@)" 2>/dev/null
+	$(QUIET) cd "$(TEMP_DIR_$@)" && "$(J3_PATH)" -cp "$(BENCHMARK_CLASSPATH)" "MonitorBench.Main" "$(BENCH_NAME_$@)" > "$(TMP_DIR)/$(BENCH_NAME_$@).$(BENCH_COUNT_$@).log" 2>&1
+
+clean:
+	$(QUIET) -rm -rf $(WORK_DIR)/tmp.* $(WORK_DIR)/*.log 2>/dev/null

Added: vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-MethodCallBenchmark.png
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-MethodCallBenchmark.png?rev=219392&view=auto
==============================================================================
Binary file - no diff available.

Propchange: vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-MethodCallBenchmark.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-SmallObjectsBenchmark.png
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-SmallObjectsBenchmark.png?rev=219392&view=auto
==============================================================================
Binary file - no diff available.

Propchange: vmkit/branches/memory-monitor/tests/monitor-bench/micro-benchmarks-SmallObjectsBenchmark.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Benchmark.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Benchmark.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Benchmark.java (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Benchmark.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,49 @@
+package MonitorBench;
+
+public abstract class Benchmark
+	implements Runnable
+{
+	String name;
+	int result;
+	
+	protected Benchmark(String name_)
+	{
+		name = name_;
+	}
+	
+	public String toString() {return name;}
+	
+	public int getResult() {return result;}
+	protected int setResult(int r) {result = r; return result;}
+	
+	public static String[] listBenchmarkNames()
+	{
+		int count = 2, i = 0;
+		
+		String[] r = new String[count];
+		r[i++] = MethodCallBenchmark.class.getSimpleName();
+		r[i++] = SmallObjectsBenchmark.class.getSimpleName();
+		
+		return r;
+	}
+	
+	public static boolean isValidBenchmarkName(String name)
+	{
+		String[] list = listBenchmarkNames();
+		for (int i=0; i < list.length; ++i)
+			if (name.equalsIgnoreCase(list[i]))
+				return true;
+		
+		return false;
+	}
+	
+	public static Benchmark create(String name)
+	{
+		if (MethodCallBenchmark.class.getSimpleName().equalsIgnoreCase(name))
+			return new MethodCallBenchmark();
+		else if (SmallObjectsBenchmark.class.getSimpleName().equalsIgnoreCase(name))
+			return new SmallObjectsBenchmark();
+		else
+			return null;
+	}
+}

Added: vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/BenchmarkRunner.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/BenchmarkRunner.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/BenchmarkRunner.java (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/BenchmarkRunner.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,73 @@
+package MonitorBench;
+
+public class BenchmarkRunner
+	implements Runnable
+{
+	volatile Benchmark bench;
+	volatile long durationMS;
+	volatile int result;
+	volatile boolean running;
+	volatile Object runningEvent;
+
+	public BenchmarkRunner()
+	{
+		runningEvent = new Object();
+	}
+	
+	public boolean setBenchmark(Benchmark b)
+	{
+		if (running) return false;
+		
+		bench = b;
+		return true;
+	}
+	
+	public boolean waitBenchmark() throws InterruptedException
+	{
+		if (!running) return false;
+		
+		synchronized(runningEvent) {
+			while (running)
+				runningEvent.wait();
+		}
+		
+		return true;
+	}
+	
+	public void run()
+	{
+		running = true;
+		
+		long startTime;
+		durationMS = 0;
+		result = 0;
+		
+		System.out.println("BENCHMARK STARTED: " + bench.toString());
+		
+		startTime = System.nanoTime();
+		bench.run();
+		durationMS = System.nanoTime();
+		
+		durationMS -= startTime;
+		durationMS /= 1000000; // ns ==> ms
+		
+		result = bench.getResult();
+
+		if (result == 0)
+			System.out.println("BENCHMARK SUCCEEDED [" + durationMS + " ms]: " + bench.toString());
+		else
+			System.out.println("BENCHMARK FAILED [" + result + "]: " + bench.toString());
+		
+		running = false;
+		
+		synchronized (runningEvent) {
+			runningEvent.notify();
+		}
+	}
+	
+	public boolean benchmarkRunning() {return running;}
+	
+	public long getDuration() {return durationMS;}
+	
+	public long getBenchmarkResult() {return result;}
+}

Added: vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Main.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Main.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Main.java (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/Main.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,47 @@
+package MonitorBench;
+
+import java.security.InvalidParameterException;
+
+import javax.naming.InvalidNameException;
+
+public class Main
+{
+	static String benchmarkName;
+	
+	public static void main(String[] args) throws Exception
+	{
+		if (!parseCommandLine(args)) return;
+		
+		BenchmarkRunner br = new BenchmarkRunner();
+		Benchmark bench = Benchmark.create(benchmarkName);
+		
+		br.setBenchmark(bench);
+		br.run();
+	}
+	
+	static boolean parseCommandLine(String[] args) throws Exception
+	{
+		if (args.length != 1)
+			throw new InvalidParameterException("Usage: monitor-bench {-h | --help | -l | --list | benchmark_name}");
+		
+		if (args[0].startsWith("-")) {
+			if (args[0].equals("-h") || args[0].equals("--help")) {
+				System.out.println("Usage: monitor-bench {-h | --help | -l | --list | benchmark_name}");
+				return false;
+			} else if (args[0].equals("-l") || args[0].equals("--list")) {
+				String[] list = Benchmark.listBenchmarkNames();
+				for (int i = 0; i < list.length; ++i)
+					System.out.println(list[i]);
+				return false;
+			} else {
+				throw new InvalidParameterException("Unrecognized parameter: " + args[0]);
+			}
+		} else {
+			if (!Benchmark.isValidBenchmarkName(args[0]))
+				throw new InvalidNameException("Unrecognized benchmark name: " + args[0]);
+			benchmarkName = args[0];
+		}
+		
+		return true; // Proceed
+	}
+}

Added: vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/MethodCallBenchmark.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/MethodCallBenchmark.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/MethodCallBenchmark.java (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/MethodCallBenchmark.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,51 @@
+package MonitorBench;
+
+public class MethodCallBenchmark
+	extends Benchmark
+{
+	private interface DummyInterface
+	{
+		public void dummy();
+	}
+	
+	private class DummyClass implements DummyInterface
+	{
+		public void dummy()
+		{
+			try {
+				System.nanoTime();
+			} catch (Exception e) {
+				e.toString();
+			}
+		}
+	}
+
+	private class DummyClass2 implements DummyInterface
+	{
+		public void dummy()
+		{
+			System.out.println("Avoid some heuristics");
+		}
+	}
+	
+	DummyInterface dummy_int;
+	
+	public MethodCallBenchmark()
+	{
+		super("Method Call Benchmark");
+		
+		if (System.nanoTime() % 2 == 3)
+			dummy_int = new DummyClass2();	// Unreachable (see condition above)
+		else
+			dummy_int = new DummyClass();
+	}
+	
+	public void run()
+	{
+		for (int count = 100000000; count != 0; --count) {
+			dummy_int.dummy();
+		}
+		
+		setResult(0);
+	}
+}

Added: vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/SmallObjectsBenchmark.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/SmallObjectsBenchmark.java?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/SmallObjectsBenchmark.java (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/src/MonitorBench/SmallObjectsBenchmark.java Thu Oct  9 03:43:38 2014
@@ -0,0 +1,24 @@
+package MonitorBench;
+
+public class SmallObjectsBenchmark
+	extends Benchmark
+{
+	int count = 3000000;
+	Object[] objects;
+	
+	public SmallObjectsBenchmark()
+	{
+		super("Small Objects Benchmark");
+		
+		objects = new Object[count]; 
+	}
+
+	public void run()
+	{
+		for (int i=0; i < count; ++i) {
+			objects[i] = new String();
+		}
+		
+		setResult(0);
+	}
+}

Added: vmkit/branches/memory-monitor/tests/monitor-bench/synth.plot
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/synth.plot?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/synth.plot (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/synth.plot Thu Oct  9 03:43:38 2014
@@ -0,0 +1,35 @@
+#!/usr/bin/gnuplot -p
+
+set datafile separator ","
+set datafile missing '_'
+set datafile commentschars "#"
+
+set ylabel "Duration in microseconds (lower is better)"
+set ytics border nomirror
+set grid ytics
+set yrange [0:*]
+# set ydata time
+# set timefmt "%S"
+# set format y "%M:%S"
+
+set xtics axis nomirror
+set border 3
+
+set style data histogram
+set style histogram errorbars gap 1 lw 1
+set bars fullwidth
+set style fill solid border 0
+set boxwidth 1
+
+# set title "Monitoring overhead in micro-benchmarks"
+
+# set term wxt 0
+set term png size 800, 600
+
+set output "micro-benchmarks-MethodCallBenchmark.png"
+plot	\
+	'/home/koutheir/vmkit_monitor_benchmarks/MethodCallBenchmark.csv' using (column(3)):(column(5)):xtic(1) linecolor rgb "orange" title "MethodCallBenchmark"
+
+set output "micro-benchmarks-SmallObjectsBenchmark.png"
+plot	\
+	'/home/koutheir/vmkit_monitor_benchmarks/SmallObjectsBenchmark.csv' using (column(3)):(column(5)):xtic(1) linecolor rgb "blue" title "SmallObjectsBenchmark"

Added: vmkit/branches/memory-monitor/tests/monitor-bench/synth.sh
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor-bench/synth.sh?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor-bench/synth.sh (added)
+++ vmkit/branches/memory-monitor/tests/monitor-bench/synth.sh Thu Oct  9 03:43:38 2014
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+log_dir=$1
+
+if [ -z "$log_dir" ]; then
+	exit 1
+fi
+
+stage1_file=/tmp/$0.$$.stage1
+stage2_file=/tmp/$0.$$.stage2
+stage3_file=/tmp/$0.$$.stage3
+
+rm -f "$stage1_file" "$stage2_file" "$stage3_file"
+
+# Filter successful results and print them in the format: benchmark,duration
+cd $log_dir && grep '^BENCHMARK SUCCEEDED' *.log | sed 's/\.[0-9]\+.log:BENCHMARK SUCCEEDED \[/,/g ; s/ ms\]:.*$//g' | sort > $stage1_file
+
+# Calculate minimum, maximum and average durations
+
+count=0
+while read -r line ; do
+	cur_bench=$(echo $line | cut -d ',' -f 1)
+	cur_duration=$(echo $line | cut -d ',' -f 2)
+	
+	if [ -z "$last_bench" ]; then
+		last_bench=$cur_bench
+		count=1
+		average_duration=$cur_duration
+		min_duration=$cur_duration
+		max_duration=$cur_duration
+	else
+		if [ "$last_bench" == "$cur_bench" ]; then
+			count=$(($count + 1))
+			average_duration=$(($average_duration + $cur_duration))
+			if [ "$cur_duration" -lt "$min_duration" ]; then
+				min_duration=$cur_duration
+			fi
+			if [ "$cur_duration" -gt "$max_duration" ]; then
+				max_duration=$cur_duration
+			fi
+		else
+			average_duration=$(($average_duration / $count))
+			echo "$last_bench,$min_duration,$average_duration,$max_duration" >> $stage2_file
+			
+			last_bench=$cur_bench
+			count=1
+			average_duration=$cur_duration
+			min_duration=$cur_duration
+			max_duration=$cur_duration
+		fi
+	fi
+done < $stage1_file
+
+if [ "$count" -gt 0 ]; then
+	average_duration=$(($average_duration / $count))
+	echo "$last_bench,$min_duration,$average_duration,$max_duration" >> $stage2_file
+fi
+
+echo '#benchmark,min_duration_ms,average_duration_ms,max_duration_ms,std_dev_duration_ms'
+
+# Calculate the standard deviation
+while read -r line ; do
+	cur_bench=$(echo $line | cut -d ',' -f 1)
+	cur_average=$(echo $line | cut -d ',' -f 3)
+	
+	grep "^$cur_bench," "$stage1_file" > "$stage3_file"
+	
+	count=0
+	std_dev='sqrt((0'
+	
+	while read -r line2 ; do
+		cur_duration=$(echo $line2 | cut -d ',' -f 2)
+		
+		std_dev+="+(($cur_duration - $cur_average)^2)"
+		count=$(($count+1))
+	done < "$stage3_file"
+	
+	std_dev+=")/$count)"
+	std_dev=$(echo "scale=0; $std_dev" | bc -q 2>/dev/null)
+	echo "$line,$std_dev"
+done < $stage2_file
+
+rm -f "$stage1_file" "$stage2_file" "$stage3_file"

Added: vmkit/branches/memory-monitor/tests/monitor.xargs
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitor.xargs?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitor.xargs (added)
+++ vmkit/branches/memory-monitor/tests/monitor.xargs Thu Oct  9 03:43:38 2014
@@ -0,0 +1,47 @@
+-Dorg.osgi.framework.storage=/tmp/fwdir
+-Dorg.knopflerfish.framework.system.export.all_13=false
+-Dorg.knopflerfish.framework.verbosity=0
+
+-Forg.knopflerfish.framework.debug.errors=true
+-Forg.knopflerfish.framework.debug.packages=false
+-Forg.knopflerfish.framework.debug.classloader=false
+#-Forg.knopflerfish.framework.debug.permissions=false
+
+#-Forg.osgi.framework.system.packages.extra=
+
+-Forg.knopflerfish.http.dnslookup=true
+-Forg.osgi.service.http.port=8080
+
+-Dhttp.proxyHost=proxy
+-Dhttp.proxyPort=3128
+
+#-Forg.knopflerfish.framework.all_signed=false
+
+-Dorg.knopflerfish.gosg.jars=file:///home/koutheir/phd/vmkit/knopflerfish.vmkit/osgi/jars/;file:///home/koutheir/phd/vmkit/vmkit-monitor/osgi/j3mgr/out/;file:///home/koutheir/phd/vmkit/vmkit-monitor/osgi/tests/
+
+-Forg.knopflerfish.startlevel.use=true
+
+-init
+
+-istart j3mgr-1.0.0.jar
+
+-istart log/log_all-5.0.0.jar
+-istart cm/cm_all-5.0.0.jar
+-istart util/util-4.1.0.jar
+-istart console/console_all-4.0.1.jar
+-istart frameworkcommands/frameworkcommands-4.0.1.jar
+-istart logcommands/logcommands-5.0.0.jar
+-istart cm_cmd/cm_cmd-5.0.1.jar
+-istart consoletty/consoletty-4.0.1.jar
+-istart useradmin/useradmin_api-4.0.0.jar
+-istart util/util-4.1.0.jar
+
+-launch
+
+-install tests.A/out/tests.A-1.0.0.jar
+-install tests.B/out/tests.B-1.0.0.jar
+-install tests.E/out/tests.E-1.0.0.jar
+-install tests.AImpl/out/tests.AImpl-1.0.0.jar
+-install tests.BImpl/out/tests.BImpl-1.0.0.jar
+-install tests.FImpl/out/tests.FImpl-1.0.0.jar
+-install tests.GImpl/out/tests.GImpl-1.0.0.jar

Added: vmkit/branches/memory-monitor/tests/monitoring.rules
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/monitoring.rules?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/monitoring.rules (added)
+++ vmkit/branches/memory-monitor/tests/monitoring.rules Thu Oct  9 03:43:38 2014
@@ -0,0 +1,39 @@
+tier 1 { org.knopflerfish.framework }
+
+tier 11 {
+	org.knopflerfish.bundle.cm,
+	org.knopflerfish.bundle.util-LIB,
+	org.knopflerfish.bundle.console,
+	org.knopflerfish.bundle.frameworkcommands-IMPL,
+	org.knopflerfish.bundle.logcommands-IMPL,
+	org.knopflerfish.bundle.cm_cmd-IMPL,
+	org.knopflerfish.bundle.consoletty-IMPL,
+	org.knopflerfish.bundle.useradmin-API
+}
+tier 12 { org.knopflerfish.log }
+
+tier 20 { tests.A }
+tier 30 { tests.B }
+tier 40 { tests.E }
+tier 50 { tests.AImpl }
+tier 60 { tests.BImpl }
+tier 70 { tests.FImpl }
+tier 80 { tests.GImpl }
+
+tier 200 { j3mgr }
+
+account { 0, 1, called }
+account { 1, 0, caller }
+account { *, 1, caller }
+account { 1, *, called }
+
+account { *, */_/org.osgi.framework.BundleActivator, called }
+
+account { 0, 0/_/java.lang.Runnable/run, called }
+account { 0, 0/_/java.lang.Thread/run,   called }
+account { 0, 0/_/java.lang.VMThread/run, called }
+
+account { *, 200/j3mgr/j3.J3Mgr, caller }
+
+account { *, 20/tests.A/tests.A.A, caller }
+# account { *, */_/tests.B.BEvent, called }

Added: vmkit/branches/memory-monitor/tests/tier.description
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tests/tier.description?rev=219392&view=auto
==============================================================================
--- vmkit/branches/memory-monitor/tests/tier.description (added)
+++ vmkit/branches/memory-monitor/tests/tier.description Thu Oct  9 03:43:38 2014
@@ -0,0 +1,15 @@
+tier 1 { ijvm.tests.BImpl, ijvm.tests.DImpl }
+tier 2 { ijvm.tests.A, ijvm.tests.AImpl }
+tier 3 { ijvm.tests.C, ijvm.tests.CImpl }
+
+account { 0, *, callee }
+account { *, 0, caller }
+
+account { 1, 2, caller }
+account { 1, 3, caller }
+
+account { 2, 1, callee }
+account { 2, 3, callee }
+
+account { 3, 1, caller }
+account { 3, 2, caller }

Modified: vmkit/branches/memory-monitor/tools/j3/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/tools/j3/Main.cpp?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/tools/j3/Main.cpp (original)
+++ vmkit/branches/memory-monitor/tools/j3/Main.cpp Thu Oct  9 03:43:38 2014
@@ -40,6 +40,7 @@ int main(int argc, char **argv, char **e
   // Run the application. 
   vm->runApplication(argc, argv);
   vm->waitForExit();
+
   System::Exit(0);
 
   // Destroy everyone.

Modified: vmkit/branches/memory-monitor/www/get_started.html
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/www/get_started.html?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/www/get_started.html (original)
+++ vmkit/branches/memory-monitor/www/get_started.html Thu Oct  9 03:43:38 2014
@@ -13,19 +13,6 @@
 
 <div id="content">
 
-  <!--*********************************************************************-->
-  <h1 style="background:red"><center>The VMKit project is retired</center></h1>
-  <!--*********************************************************************-->
-
-	<font color="red">
-		<p>You can still play with the last VMKit release, but the project is not more maintained.
-		Moreover, the information on these pages may be out of date.</p>
-
-		<p>If you are interested in restarting the project, 
-			please contact <a href="mailto:gael.thomas00 at gmail.com">Gaël Thomas</a></p>
-	</font>
-
-
 <h1>Getting Started: Building and Running VMKit</h1>
 
 
@@ -39,9 +26,9 @@ involved</a> with the vmkit community.</
 <p>If you would like to check out and build the project, the current scheme
 is:</p>
 
-<!-- <p><b>Prerequisites</b><br/> -->
-<!-- You will have to install a C++ compiler and Java 1.5 or more in order to -->
-<!-- compile vmkit2</p> -->
+<p><b>Prerequisites</b><br/>
+You will have to install a C++ compiler and Java 1.5 or more in order to
+compile vmkit2</p>
 
 <ol>
   <li>Download <a href="http://llvm.org/releases/3.3/llvm-3.3.src.tar.gz">
@@ -52,53 +39,51 @@ is:</p>
 
   <ul>
     <li><tt>tar zxvf llvm-3.3.src.tar.gz</tt></li>
-    <li><tt>cd llvm-3.3.src/tools</li></tt>
+    <li><tt>cd llvm-3.2.src/tools</li></tt>
     <li><tt>tar zxvf ../../cfe-3.3.src.tar.gz</tt></li>
     <li><tt>mv cfe-3.3.src clang</li></tt>
     <li><tt>cd ..</li></tt>
     <li><tt>./configure --enable-optimized; make</tt></li>
   </ul>
   <br>Note: To compile LLVM and VMKit with RTTI enabled, one can pass the parameter
-REQUIRES_RTTI=1 to llvm make. Passing this argument removes the flag -fno-rtti from
+REQUIRES_RTTI=1 to make. Passing this argument removes the flag -fno-rtti from
 the compiler options. Ex: $ make REQUIRES_RTTI=1
-	
-	<p>
-	<li>Download, compile and install <a href="http://openjdk.java.net/">Openjdk</a> version 6u23
-<!--   <p><b>Skip the Classpath steps if you plan to use OpenJDK.</b><br/> -->
-<!--   <li><a href="ftp://ftp.gnu.org/gnu/classpath/classpath-0.99.tar.gz">Download -->
-<!--    GNU Classpath 0.99</a>:</li> -->
-
-<!--   <ul> -->
-<!--     <li><tt>tar zxvf classpath-0.99.tar.gz</tt></li> -->
-<!--     <li><tt>cd classpath-0.99</tt></li> -->
-<!--     <li><tt>./configure --disable-plugin --disable-examples --disable-Werror; -->
-<!--     make</tt></li> -->
-<!--     <li><tt>cd lib</li></tt> -->
-<!--     <li><tt>If you are running on Linux:</li></tt> -->
-<!--     <ul> -->
-<!--       <li><tt>ln -s ../native/jni/gtk-peer/.libs/libgtkpeer.so;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/gconf-peer/.libs/libgconfpeer.so;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-io/.libs/libjavaio.so;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalangreflect.so;</li> -->
-<!--       </tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalang.so;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-net/.libs/libjavanet.so;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-nio/.libs/libjavanio.so;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-util/.libs/libjavautil.so;</li></tt> -->
-<!--     </ul> -->
-<!--     <li><tt>If you are running on MacOS:</li></tt> -->
-<!--     <ul> -->
-<!--       <li><tt>ln -s ../native/jni/gtk-peer/.libs/libgtkpeer.dylib;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/gconf-peer/.libs/libgconfpeer.dylib;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-io/.libs/libjavaio.dylib;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalangreflect.dylib; -->
-<!--       </li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalang.dylib;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-net/.libs/libjavanet.dylib;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-nio/.libs/libjavanio.dylib;</li></tt> -->
-<!--       <li><tt>ln -s ../native/jni/java-util/.libs/libjavautil.dylib;</li></tt> -->
-<!--     </ul> -->
-<!--   </ul> -->
+
+  <p><b>Skip the Classpath steps if you plan to use OpenJDK.</b><br/>
+  <li><a href="ftp://ftp.gnu.org/gnu/classpath/classpath-0.99.tar.gz">Download
+   GNU Classpath 0.99</a>:</li>
+
+  <ul>
+    <li><tt>tar zxvf classpath-0.99.tar.gz</tt></li>
+    <li><tt>cd classpath-0.99</tt></li>
+    <li><tt>./configure --disable-plugin --disable-examples --disable-Werror;
+    make</tt></li>
+    <li><tt>cd lib</li></tt>
+    <li><tt>If you are running on Linux:</li></tt>
+    <ul>
+      <li><tt>ln -s ../native/jni/gtk-peer/.libs/libgtkpeer.so;</li></tt>
+      <li><tt>ln -s ../native/jni/gconf-peer/.libs/libgconfpeer.so;</li></tt>
+      <li><tt>ln -s ../native/jni/java-io/.libs/libjavaio.so;</li></tt>
+      <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalangreflect.so;</li>
+      </tt>
+      <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalang.so;</li></tt>
+      <li><tt>ln -s ../native/jni/java-net/.libs/libjavanet.so;</li></tt>
+      <li><tt>ln -s ../native/jni/java-nio/.libs/libjavanio.so;</li></tt>
+      <li><tt>ln -s ../native/jni/java-util/.libs/libjavautil.so;</li></tt>
+    </ul>
+    <li><tt>If you are running on MacOS:</li></tt>
+    <ul>
+      <li><tt>ln -s ../native/jni/gtk-peer/.libs/libgtkpeer.dylib;</li></tt>
+      <li><tt>ln -s ../native/jni/gconf-peer/.libs/libgconfpeer.dylib;</li></tt>
+      <li><tt>ln -s ../native/jni/java-io/.libs/libjavaio.dylib;</li></tt>
+      <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalangreflect.dylib;
+      </li></tt>
+      <li><tt>ln -s ../native/jni/java-lang/.libs/libjavalang.dylib;</li></tt>
+      <li><tt>ln -s ../native/jni/java-net/.libs/libjavanet.dylib;</li></tt>
+      <li><tt>ln -s ../native/jni/java-nio/.libs/libjavanio.dylib;</li></tt>
+      <li><tt>ln -s ../native/jni/java-util/.libs/libjavautil.dylib;</li></tt>
+    </ul>
+  </ul>
   
   <li>Checkout vmkit:</li>
   <ul>
@@ -123,15 +108,32 @@ the compiler options. Ex: $ make REQUIRE
           <li><tt>org.mmtk.plan.generational.immix.GenImmix</tt></li>
         </ul>
       </dd>
-      <dt>
-        <tt>--with-classpath-impl=openjdk</tt>
-      </dt>
-      <dd>Tell vmkit to use OpenJDK classpath implementation.</dd>
-      <br/>
-      <dt>
-        <tt>--with-openjdk-path=<directory></tt>
-      </dt>
-      <dd>Tell vmkit where OpenJDK is located.</dd>
+      <ul>
+        <li>
+          <p>you can use GNU Classpath by configuring the following :</p>
+          <dt>
+            <tt>--with-gnu-classpath-glibj=<path/to/file/glibj.zip></tt>
+          </dt>
+          <dd>Tell vmkit where GNU Classpath glibj.zip is located.</dd>
+          <br/>
+          <dt>
+            <tt>--with-gnu-classpath-libs=<path/to/libs/directory></tt>
+          </dt>
+          <dd>Tell vmkit where GNU Classpath libs are located.</dd>
+        </li>
+        <li>
+          <p>or OpenJDK by configuring :</p>
+          <dt>
+            <tt>--with-classpath-impl=openjdk</tt>
+          </dt>
+          <dd>Tell vmkit to use OpenJDK classpath implementation.</dd>
+          <br/>
+          <dt>
+            <tt>--with-openjdk-path=<directory></tt>
+          </dt>
+          <dd>Tell vmkit where OpenJDK is located.</dd>
+        </li>
+      </ul>
     </dl>
   </ul>
 

Modified: vmkit/branches/memory-monitor/www/index.html
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/www/index.html?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/www/index.html (original)
+++ vmkit/branches/memory-monitor/www/index.html Thu Oct  9 03:43:38 2014
@@ -12,18 +12,6 @@
 <!--#include virtual="menu.html.incl"-->
 <div id="content">
   <!--*********************************************************************-->
-  <h1 style="background:red"><center>The VMKit project is retired</center></h1>
-  <!--*********************************************************************-->
-
-	<font color="red">
-		<p>You can still play with the last VMKit release, but the project is not more maintained.
-		Moreover, the information on these pages may be out of date.</p>
-		
-		<p>If you are interested in restarting the project, 
-			please contact <a href="mailto:gael.thomas00 at gmail.com">Gaël Thomas</a></p>
-	</font>
-
-  <!--*********************************************************************-->
   <h1>VMKit: a substrate for virtual machines</h1>
   <!--*********************************************************************-->
 

Modified: vmkit/branches/memory-monitor/www/menu.html.incl
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/www/menu.html.incl?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
--- vmkit/branches/memory-monitor/www/menu.html.incl (original)
+++ vmkit/branches/memory-monitor/www/menu.html.incl Thu Oct  9 03:43:38 2014
@@ -16,7 +16,7 @@
     <label>Quick Links</label>
     <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">llvm-dev</a>
     <a href="http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits">vmkit-commits</a>
-<!--     <a href="http://llvm.org/bugs/">Bug Reports</a> -->
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
     <a href="http://llvm.org/viewvc/llvm-project/vmkit/trunk/">Browse Source</a>
   </div>
 </div>

Modified: vmkit/branches/memory-monitor/www/tuto/toy-vm-base.tar.gz
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/memory-monitor/www/tuto/toy-vm-base.tar.gz?rev=219392&r1=219391&r2=219392&view=diff
==============================================================================
Binary files vmkit/branches/memory-monitor/www/tuto/toy-vm-base.tar.gz (original) and vmkit/branches/memory-monitor/www/tuto/toy-vm-base.tar.gz Thu Oct  9 03:43:38 2014 differ





More information about the vmkit-commits mailing list