You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tony Wu <wu...@gmail.com> on 2009/12/01 16:48:50 UTC

Re: harmony vm as a lib

I think we could think about creating Harmony Select profiles along
with Milestone builds to help people like Tim to customize our JRE
easiler.
(A friend of mine I met on the Apache Asia Roadshow this year
complained to me that Harmony is dev-oriented and not so
user-friendly, which may block potential contributors and users :-( )

On Mon, Nov 30, 2009 at 9:51 AM, Regis <xu...@gmail.com> wrote:
> Tim Prepscius wrote:
>>
>> Thanks for all of the input.  I really appreciate it.
>>
>> I guess I'll post progress to this thread, so that if someone else
>> wishes to do something similar, my successes and failures will be
>> available as some kind of road map.
>>
>> If you see me doing something which is an incredibly stupid thing to
>> do, if I only knew this other way which is simple and nice..  Let me
>> know!
>>
>> Here is the current state of things.
>>
>> 1) I have gotten stuff.
>>
>> 1.5) the msvc solutions are not up to date.  oh well.
>>
>> 2) The full classlib doesn't fully build cause it needs atl* ... but
>> I've read online, this is because of swing.. don't need swing.
>> somehow not sure how to just tell it not to build this part
>
> try -Dexclude.module=swing,awt
>
>>
>> 2.5) The vm, amazingly, builds. :-)
>>
>> 3) I've figured out the any xml build files enough to be able to
>> change things to static libraries, and exclude the /OPT:REF options
>> (which I don't want)
>>
>> 4) I've gotten the ICU lib, and have changed things to compile as
>> static LIBs.. Except for that one dll, where the programmer *really*
>> wanted to use makefiles.. ...   sigh.  And of course his makefile is
>> non-standard as they all are.  So will take a while to figure out what
>> to change.
>>
>> 4.5) I have zlib from the main game-project compiling as static lib
>>
>> 5) I've changed the JNIEXPORT define to not do the dllexport... I
>> think I'll need to do this with all of the other libraries as well.
>> Wish they all used some underlying REALLY_DO_DLLEXPORT define or
>> something, but oh well.
>>
>> 6) I've created a msvc solution that includes all of the newly created
>> static libs.  And a simple .cpp file which   calls the
>> JNI_CreateJavaVM.  Amazingly things link, and run.  However, dieing on
>> errors of course when it tries to load dll libraries.
>>
>> Next step seems to me to be modifying the dll loading function
>> "process_properties_dlls" into a "process_properties_statics."  Don't
>> know what will be necessary for this:
>>
>> ------------------------------------------------------------------
>> I like to make batch files which can replicate work.. For an accurate
>> record, and cause I need to eventually build lots of different places.
>>
>> Here they are:
>> -------------------------------------------------------------------
>> C:\source3>type setup.bat
>> call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
>> set ANT_HOME=C:\ant
>> set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_17
>> set PATH=%PATH%;%ANT_HOME%\bin;c:\cygwin\bin
>> set ANT_OPTS=-Xms256m -Xmx512m
>>
>> rem
>> ###############################################################################
>>
>> if exist %ANT_HOME%\lib\ecj-* goto ECJ_OK
>> echo Things won't work without ECJ, get 3.4.2 from
>> http://download.eclipse.org/eclipse/downloads/ and put it in
>> %ANT_HOME%\lib
>> goto END
>> :ECJ_OK
>>
>> if exist %windir%\system32\msvcr71* goto MSVC71_OK
>> echo Somehow, they really really want msvcr71.dll, msvcp71.dll, you
>> can google and download it.. stick it in %windir%\system32
>> goto END
>> :MSVC71_OK
>>
>> rem
>> #################################################################################
>>
>>
>> :END
>>
>> C:\source3>type build1.bat
>> call setup.bat
>>
>> svn co http://svn.apache.org/repos/asf/harmony/enhanced/trunk harmony
>>
>> cd harmony
>> cmd /C ant populate-src
>> cd ..
>>
>>
>> C:\source3>type build2.bat
>> cd harmony
>> cd working_classlib
>>
>> cmd /C ant fetch-depends
>> cmd /C ant
>>
>> cd ..
>> cd ..
>>
>> C:\source3>type build3.bat
>> cd harmony
>> cd working_vm
>>
>> rmdir /s /q build\windows_x86_msvc_debug
>> rmdir /s /q build\windows_x86_msvc_release
>>
>> cmd /C ant -Dexclude.module=swing
>> cmd /C ant -Dexclude.module=swing -Dhy.cfg=release
>>
>> cd ..
>> cd ..
>>
>> --------------------------------
>>
>> Diff of files as of now:
>>
>> Index: harmony/working_vm/vm/include/jni_types.h
>> ===================================================================
>> --- harmony/working_vm/vm/include/jni_types.h   (revision 883577)
>> +++ harmony/working_vm/vm/include/jni_types.h   (working copy)
>> @@ -49,8 +49,10 @@
>>  */
>>  #if defined (_WIN32) || defined (__WIN32__) || defined (WIN32)
>>
>> -#define JNIEXPORT __declspec(dllexport)
>> -#define JNIIMPORT __declspec(dllimport)
>> +//#define JNIEXPORT __declspec(dllexport)
>> +//#define JNIIMPORT __declspec(dllimport)
>> +#define JNIEXPORT
>> +#define JNIIMPORT
>>  #define JNICALL __stdcall
>>
>>  typedef signed __int64 jlong;
>> Index: harmony/working_vm/vm/vmcore/src/init/vm_init.cpp
>> ===================================================================
>> --- harmony/working_vm/vm/vmcore/src/init/vm_init.cpp   (revision 883577)
>> +++ harmony/working_vm/vm/vmcore/src/init/vm_init.cpp   (working copy)
>> @@ -174,6 +174,11 @@
>>  #define GC_DLL (vm_env->compress_references ? GC_DLL_COMP :
>> GC_DLL_UNCOMP)
>>  #endif
>>
>> +static jint process_properties_dlls_statics (Global_Env *vm_env)
>> +{
>> +    jint status;
>> +       return status;
>> +}
>>
>>  /**
>>  * Loads DLLs.
>> Index: harmony/working_vm/make/vm/em.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/em.xml   (revision 883577)
>> +++ harmony/working_vm/make/vm/em.xml   (working copy)
>> @@ -23,7 +23,7 @@
>>
>>     <target name="build" depends="-common-vm">
>>         <init-native/>
>> -        <make-native libname="em" type="shared">
>> +        <make-native libname="em" type="static">
>>         <compiler id="cpp.compiler" extends="common.cpp.compiler">
>>             <includepath>
>>                 <dirset dir="${vm.home}">
>> Index: harmony/working_vm/make/vm/gc_gen.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/gc_gen.xml       (revision 883577)
>> +++ harmony/working_vm/make/vm/gc_gen.xml       (working copy)
>> @@ -114,7 +114,7 @@
>>         <compile-cc>
>>             <compiler refid="cpp.compiler"/>
>>         </compile-cc>
>> -        <link-lib name="gc_gen_uncomp" type="shared">
>> +        <link-lib name="gc_gen_uncomp" type="static">
>>             <linker refid="linker"/>
>>         </link-lib>
>>    </target>
>> @@ -127,7 +127,7 @@
>>             <compiler refid="cpp.compiler"/>
>>             <defineset define="COMPRESS_REFERENCE" />
>>         </compile-cc>
>> -        <link-lib name="gc_gen" type="shared">
>> +        <link-lib name="gc_gen" type="static">
>>             <linker refid="linker"/>
>>         </link-lib>
>>    </target>
>> Index: harmony/working_vm/make/vm/interpreter.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/interpreter.xml  (revision 883577)
>> +++ harmony/working_vm/make/vm/interpreter.xml  (working copy)
>> @@ -78,7 +78,7 @@
>>         </compiler>
>>         </compile-cc>
>>
>> -        <link-lib name="interpreter" type="shared">
>> +        <link-lib name="interpreter" type="static">
>>             <linker id="linker" extends="common.linker">
>>                 <linkerarg
>> value="--version-script=${vm.home}/interpreter/build/interpreter.exp"
>> if="is.unix"/>
>>                 <libset libs="harmonyvm,hythr" dir="${drlvm.shlib.dir}" />
>> Index: harmony/working_vm/make/vm/vmcore.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/vmcore.xml       (revision 883577)
>> +++ harmony/working_vm/make/vm/vmcore.xml       (working copy)
>> @@ -215,7 +215,7 @@
>>         </compiler>
>>         </compile-cc>
>>
>> -        <link-lib name="harmonyvm" type="shared">
>> +        <link-lib name="harmonyvm" type="static">
>>             <linker id="linker" extends="common.linker">
>>                 <libset libs="port,encoder,verifier,apr-1"
>>                     dir="${drlvm.lib.dir}" />
>> @@ -224,8 +224,8 @@
>>                 <libset libs="zdll" dir="${drlvm.lib.dir}"
>> if="is.windows"/>
>>                 <libset libs="ch" dir="${drlvm.shlib.dir}" />
>>
>> -                <linkerarg
>> value="/DEF:${vm.home}/vmcore/src/harmonyvm64.def"
>> if="is.windows.x86_64"/>
>> -                <linkerarg
>> value="/DEF:${vm.home}/vmcore/src/harmonyvm.def" if="is.windows.x86"/>
>> +<!--`                <linkerarg
>> value="/DEF:${vm.home}/vmcore/src/harmonyvm64.def"
>> if="is.windows.x86_64"/>
>> +                <linkerarg
>> value="/DEF:${vm.home}/vmcore/src/harmonyvm.def" if="is.windows.x86"/>
>> -->
>>                 <linkerarg
>> value="--version-script=${vm.home}/vmcore/build/vmcore.exp"
>> if="is.unix"/>
>>
>>                 <syslibset type="shared"
>> libs="m,dl,stdc++,z,xml2,pthread,gcc_s,rt" if="is.linux"/>
>> Index: harmony/working_vm/make/vm/vmi.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/vmi.xml  (revision 883577)
>> +++ harmony/working_vm/make/vm/vmi.xml  (working copy)
>> @@ -23,7 +23,7 @@
>>
>>     <target name="build" depends="-common-vm">
>>         <init-native/>
>> -        <make-native libname="vmi" type="shared">
>> +        <make-native libname="vmi" type="static">
>>             <compiler id="cpp.compiler" extends="common.cpp.compiler">
>>                 <includepath>
>>                     <pathelement location="${drlvm.include.dir}" />
>> Index: harmony/working_vm/make/vm/hythr.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/hythr.xml        (revision 883577)
>> +++ harmony/working_vm/make/vm/hythr.xml        (working copy)
>> @@ -24,7 +24,7 @@
>>     <target name="build" depends="-common-vm">
>>         <init-native/>
>>
>> -        <make-native libname="hythr" type="shared">
>> +        <make-native libname="hythr" type="static">
>>         <compiler id="c.compiler" extends="common.c.compiler">
>>             <includepath>
>>               <pathelement location="${drlvm.include.dir}" />
>> @@ -46,7 +46,7 @@
>>             <libset libs="port,apr-1"
>>                     dir="${drlvm.lib.dir}" />
>>
>> -            <linkerarg value="/DEF:${vm.home}/thread/src/hythr.def"
>> if="is.windows"/>
>> +<!--            <linkerarg
>> value="/DEF:${vm.home}/thread/src/hythr.def" if="is.windows"/> -->
>>
>>             <syslibset type="shared" libs="stdc++,rt,pthread"
>> if="is.linux"/>
>>             <syslibset type="shared" libs="stdc++,pthread"
>> if="is.freebsd"/>
>> Index: harmony/working_vm/make/vm/jitrino.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/jitrino.xml      (revision 883577)
>> +++ harmony/working_vm/make/vm/jitrino.xml      (working copy)
>> @@ -83,10 +83,10 @@
>>                 <defineset define="JIT_LOGS,JIT_STATS" if="is.cfg.debug"
>> />
>>             </compiler>
>>         </compile-cc>
>> -        <link-lib name="jitrino" type="shared">
>> +        <link-lib name="jitrino" type="static">
>>             <linker id="jitrino.linker" extends="common.linker">
>>                 <libset libs="harmonyvm,encoder,hythr"
>> dir="${drlvm.lib.dir}" if="is.windows"/>
>> -                <linkerarg value="/OPT:REF" if="is.windows"/>
>> +<!--                <linkerarg value="/OPT:REF" if="is.windows"/> -->
>>
>>                 <syslibset type="shared" libs="m" if="is.unix"/>
>>                 <syslibset type="shared" libs="dl" if="is.linux"/>
>> Index: harmony/working_vm/make/vm/port_ch.xml
>> ===================================================================
>> --- harmony/working_vm/make/vm/port_ch.xml      (revision 883577)
>> +++ harmony/working_vm/make/vm/port_ch.xml      (working copy)
>> @@ -122,7 +122,7 @@
>>             </compiler>
>>         </compile-cc>
>>
>> -        <link-lib name="ch" type="shared">
>> +        <link-lib name="ch" type="static">
>>             <linker id="linker" extends="common.linker">
>>                 <libset libs="encoder" dir="${drlvm.lib.dir}" />
>>
>> Index: harmony/working_vm/make/build-native.xml
>> ===================================================================
>> --- harmony/working_vm/make/build-native.xml    (revision 883577)
>> +++ harmony/working_vm/make/build-native.xml    (working copy)
>> @@ -151,7 +151,7 @@
>>                 <condition property="component.need.pdb">
>>                     <and>
>>                         <isset property="is.windows"/>
>> -                        <equals arg1="@{type}" arg2="shared"/>
>> +                        <equals arg1="@{type}" arg2="static"/>
>>                     </and>
>>                 </condition>
>>
>>
>> On 11/22/09, Alexei Fedotov <al...@gmail.com> wrote:
>>>
>>> Tim,
>>> As for your willingness to create a lib, VM is a lib already [1], an
>>> is successfully used in browser plug-ins.
>>>
>>> [1] http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/invocation.html
>>>
>>> On Mon, Nov 23, 2009 at 11:54 AM, Xiao-Feng Li <xi...@gmail.com>
>>> wrote:
>>>>
>>>> To reduce Harmony VM (DRLVM) is possible - and not very difficult. JIT
>>>> and GC are modules that you can easily replace with very simple ones.
>>>> Other modules can be largely reduced as well if you do not need them,
>>>> e.g., threading, verifier, profiler, etc. I don't know your
>>>> performance target, but my personal preference usually is to keep a
>>>> simple JIT for the execution engine rather than the interpreter.
>>>>
>>>> Thanks,
>>>> xiaofeng
>>>>
>>>> On Mon, Nov 23, 2009 at 10:52 AM, Tim Prepscius <ti...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Greetings,
>>>>>
>>>>> I have been searching for a non-gpl replacement for sun's java for
>>>>> quite a while now.  I can't believe I didn't see your project until
>>>>> this month.  Let me tell you, when I saw your code I almost cried.
>>>>> (haha, well, maybe not cried)
>>>>>
>>>>> It's really, really nice.  And I have not run yet into a hundred line
>>>>> #define (as in "dalvik") yet.
>>>>> Anyhow.
>>>>>
>>>>>
>>>>> This is what I'd like to do.  I'm wondering whether anyone would
>>>>> comment on accomplishing this, if it is possible.
>>>>> Who knows, maybe somebody else has fiddled around with this.
>>>>>
>>>>> What I'm looking for:
>>>>>
>>>>> 1.  I'm really not looking for java.  I'm looking for a
>>>>> micro-edition-ish java to embed in a video game engine.
>>>>>
>>>>> 2.  Don't need JIT, don't need two garbage collectors - 1 will do,
>>>>> don't need the JVM to be accessible to the outside world. Don't need
>>>>> almost *all* of the class libraries.  Don't need sockets (except for
>>>>> debugging).  Don't actually need threads (I disable their creation via
>>>>> the security manager anyway), but I suppose this is necessary for GC &
>>>>> Debug.
>>>>>
>>>>> 3. Need JNI, which I see you have.
>>>>>
>>>>> So what I'm thinking I'd like to do:
>>>>>
>>>>>
>>>>> Optimally I'd like to create a lib out of harmony-vm.  Statically link
>>>>> with my application.  Create a single jar with all of my necessary
>>>>> classes, cutting out all of the java extra stuff (everything pretty
>>>>> much)
>>>>>
>>>>> If creating a lib creates problems for JNI (what problems I don't
>>>>> know), I'd like to combine all of your dlls into one massive dll.
>>>>> Then I was thinking, that after getting this done, I'd start cutting
>>>>> out modules.  And try to reduce everything to under 1 meg.
>>>>>
>>>>> --
>>>>>
>>>>> Is this crazy?
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> -tim
>>>>>
>>>>
>>>>
>>>> --
>>>> http://people.apache.org/~xli
>>>>
>>>
>>>
>>> --
>>> With best regards / с наилучшими пожеланиями,
>>> Alexei Fedotov / Алексей Федотов,
>>> http://www.telecom-express.ru/
>>> http://harmony.apache.org/
>>> http://www.expressaas.com/
>>> http://openmeetings.googlecode.com/
>>>
>>
>
>
> --
> Best Regards,
> Regis.
>



-- 
Tony Wu
China Software Development Lab, IBM

Re: harmony vm as a lib

Posted by Alexey Varlamov <al...@gmail.com>.
2010/1/4 Regis <xu...@gmail.com>:
> On 2010-01-04 12:55, Tim Prepscius wrote:
>>
>> That was the plan.  I am linking hyluni as a static already.  I think
>> there is some additional initialization I must do somewhere.
>> But at this point, I'm more concerned with the 33 megabytes being used
>> for just a partial initialization.
>>
>>
>> If these 33 megabytes are coming because somewhere something is
>> allocating 32 megabytes reserve heap, and then is going to
>> sub-allocate that for java objects, then I can probably modify this
>> behavior somehow to allocate as needed.  But if 33 megabytes are being
>> allocated for java initializations-  then it would take a whole lot of
>> work before I can use harmony.
>>
>> It's really hard for me to believe that 33 megabytes are coming from
>> loaded classes.  I'll investigate more this week.  Hmm.. Maybe the
>> garbage collector needs to be invoked or something?
>
> IIRC, the java heap is about 4MB for simple HelloWorld, I guess the most of
> memory is consumed by vm, not classlib.
I guess most of those 33M are reserved by GC. Quick browsing shows
(working_vm\vm\gc_gen\src\common\gc_options.cpp) that by default
gc_gen sets min heap size as 1/10 of the default max heap which is
256M. Plus there are a bunch of various pools (vtables, jitted code,
classloaders, interned strings etc) pre-allocated by VM. Historically,
the DRLVM was mostly server-oriented so the default settings (size of
pools in particular) seem to be overkill for your purposes.

>>
>> Does anyone know what the minimum memory usage is for an initialized
>> jvm before executing client code.. meaning after all of the necessary
>> initialization classes are loaded, but before any client app dependent
>> classes are loaded, etc etc etc etc?
>
> Will some profiling tools like Valgrind or strace can help to figure out who
> allocate the largest memory blocks?
Trace logs might help as well, drlvm has decent support of built-in
debug logging. It is enabled with -Xtrace option in debug build (run
with -X to get more details).

>>
>> Currently the libraries I'm linking statically are:
>> apr-1.lib, ch.lib, em.lib, encoder.lib, harmonyvm.lib, hycommon.lib,
>> hyprt.lib, hythr.lib, hyzip.lib, icuuc34d.lib, interpreter.lib,
>> port.lib, verifier.lib, vmi.lib, zlib.lib, hyluni.lib,
>> gc_gen_uncomp.lib

AFAIR the icuuc is the best next candidate for ablation. It is quite
massive but useful mostly for exotic cases like fancy unicode strings
in classfile constant pools.

>>
>> I'm doing the static JNI initialization via a table I'm adding to by
>> hand.. I was hoping to add the minimal set needed for initialization
>> and things I wanted to support, and then tell the linker to remove
>> dead code, and see what it removed.
>>
Sorry for the dumb question, did you fix the classlib build to produce
static libs? I've seen you concentrated on the vm so far.

>>
>> Happy New Year!!!

Thanks, and all the best wishes to you too!

--
Alexey

Re: harmony vm as a lib

Posted by Regis <xu...@gmail.com>.
On 2010-01-04 12:55, Tim Prepscius wrote:
> That was the plan.  I am linking hyluni as a static already.  I think
> there is some additional initialization I must do somewhere.
> But at this point, I'm more concerned with the 33 megabytes being used
> for just a partial initialization.
>
>
> If these 33 megabytes are coming because somewhere something is
> allocating 32 megabytes reserve heap, and then is going to
> sub-allocate that for java objects, then I can probably modify this
> behavior somehow to allocate as needed.  But if 33 megabytes are being
> allocated for java initializations-  then it would take a whole lot of
> work before I can use harmony.
>
> It's really hard for me to believe that 33 megabytes are coming from
> loaded classes.  I'll investigate more this week.  Hmm.. Maybe the
> garbage collector needs to be invoked or something?

IIRC, the java heap is about 4MB for simple HelloWorld, I guess the most of 
memory is consumed by vm, not classlib.

>
>
>
> Does anyone know what the minimum memory usage is for an initialized
> jvm before executing client code.. meaning after all of the necessary
> initialization classes are loaded, but before any client app dependent
> classes are loaded, etc etc etc etc?

Will some profiling tools like Valgrind or strace can help to figure out who 
allocate the largest memory blocks?

>
>
>
>
> Currently the libraries I'm linking statically are:
> apr-1.lib, ch.lib, em.lib, encoder.lib, harmonyvm.lib, hycommon.lib,
> hyprt.lib, hythr.lib, hyzip.lib, icuuc34d.lib, interpreter.lib,
> port.lib, verifier.lib, vmi.lib, zlib.lib, hyluni.lib,
> gc_gen_uncomp.lib
>
> I'm doing the static JNI initialization via a table I'm adding to by
> hand.. I was hoping to add the minimal set needed for initialization
> and things I wanted to support, and then tell the linker to remove
> dead code, and see what it removed.
>
>
> Happy New Year!!!
>
> -tim
>
> ---
>
> Code for JNI hand done registry if that explanation was confusing:
>
>
> #include<map>
> #include<string>
> #include "natives_support.h"
>
> #include "org_apache_harmony_drlvm_VMHelper.h"
> #include "java_lang_VMClassRegistry.h"
> #include "java_lang_ClassLoader.h"
> #include "java_lang_System.h"
> #include "org_apache_harmony_vm_VMStack.h"
> #include "java_lang_VMExecutionEngine.h"
>
> // wherez header?
> extern "C"
> JNIEXPORT void JNICALL Java_java_io_FileDescriptor_syncImpl (JNIEnv *
> env, jobject recv);
> extern "C"
> JNIEXPORT void JNICALL
> Java_java_io_FileDescriptor_oneTimeInitialization (JNIEnv * env,
> jclass fdClazz);
>
> typedef std::map<std::string, GenericFunctionPointer>  StaticNativeMap;
> static StaticNativeMap staticNatives;
>
> struct NameFunctionPair
> {
> 	const char *name;
> 	GenericFunctionPointer ptr;
> };
>
> #define MAKE_NAMEFUNCTIONPAIR(x) { #x, (GenericFunctionPointer)&x }
>
> NameFunctionPair staticNativesToRegister[] =
> {
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_io_FileDescriptor_oneTimeInitialization),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_io_FileDescriptor_syncImpl),
>
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getPointerTypeSize),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_isCompressedRefsMode),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_isCompressedVTableMode),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeVTableBaseOffset),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeObjectBaseOffset),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getObjectVtableOffset),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getClassJLCHanldeOffset),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getVtableClassOffset),
>
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_exit),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_getAssertionStatus),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_getAvailableProcessors),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_getProperties),
> //	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_loadLibrary),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_traceInstructions),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_traceMethodCalls),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_currentTimeMillis),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_nanoTime),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_mapLibraryName),
>
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_ClassLoader_findLoadedClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_ClassLoader_registerInitiatedClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_ClassLoader_defineClass0),
>
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_loadBootstrapClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getClassNative),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getClassLoader0),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getComponentType),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredClasses),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredConstructors),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredFields),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredMethods),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaringClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getInterfaces),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getModifiers),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getName),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getSuperclass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getSystemPackages),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_initializeClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isArray),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isAssignableFrom),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isInstance),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isPrimitive),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_linkClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_loadArray),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_loadLibrary),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getEnclosingClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getEnclosingMember),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getSimpleName),
>
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_setErrUnsecure),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_setInUnsecure),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_setOutUnsecure),
> 	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_rethrow),
>
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getCallerClass),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getClasses),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getStackState),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getStackClasses),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getStackTrace),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getClassLoader0),
> 	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getThreadStackTrace),
> 	{ NULL, NULL }
> };
>
> inline void populateStaticNativesUsingSet (NameFunctionPair *nameFunctionPairs)
> {
> 	for (NameFunctionPair *i=nameFunctionPairs; i->name!=NULL; ++i)
> 		staticNatives[i->name] = i->ptr;
> }
>
> inline void populateStaticNativeMap ()
> {
> 	static bool staticNativesPopulated = false;
> 	if (staticNativesPopulated)
> 		return;
>
> 	populateStaticNativesUsingSet (staticNativesToRegister);
> 	staticNativesPopulated = true;
> }
>
> GenericFunctionPointer findStaticNative (const char *symbol)
> {
>          // lock mutex?
>
> 	populateStaticNativeMap();
>
> 	StaticNativeMap::iterator i = staticNatives.find(symbol);
> 	if (i != staticNatives.end())
> 		return i->second;
>
> 	FILE *f = fopen ("nonfoundstatics.txt", "a+t");
> 	fputs (symbol, f);
> 	fputs ("\n", f);
> 	fclose (f);
>
> 	return NULL;
> }
>
>
>
> On 1/3/10, Regis<xu...@gmail.com>  wrote:
>> On 2010-01-02 13:42, Tim Prepscius wrote:
>>> Greetings,
>>>
>>> I write to give a small update and ask a couple questions.
>>>
>>> The update is: I'm still getting everything static-ified.  It seems
>>> when I enabled the missing kernel + natives, those depended on other
>>> natives which depended on other natives which depended on other
>>> natives and jars etc etc.  It seems I must include pretty much every
>>> library just to get past startup.
>>>
>>> I'm now up to "Java_java_io_FileDescriptor_oneTimeInitialization"
>>> HARMONY_CACHE_SET is failing, not sure why, maybe I need to call some
>>> other initialization method somewhere.
>>
>> It requires hyluni.dll from classlib.
>>
>>>
>>> So as I'm statically linking libraries as I'm including more and more
>>> dependencies, the executable size keeps on growing.
>>>
>>> Here are my current two questions:
>>>
>>>
>>> 1.  Before java initialization, which means after "startup code" has
>>> run, but before I call JNI_CreateJavaVM, process explorer is reporting
>>> that the memory used is already ~5 megabytes.
>>>
>>> After initialization (well at the point where it crashes now) process
>>> explorer is reporting that the program is taking ~33 megabytes.
>>>
>>> So my question is:  What is the minimum memory foot print of this java
>>> executable?  Anyone know?  Meaning post initialization, pre execute
>>> code.
>>
>> I think the minimum memory foot print of executable java not only include
>> JVM
>> itself but also some classes needed by JVM when starting. Even to run a
>> "HelloWorld" program, hundreds of classes will be loaded and also native
>> dlls
>> required by them, will you also static link them together?
>>
>>>
>>> Is this JVM allocating a whole ton of memory to begin?  If so how can
>>> I change this.  Surely all of those ~28 megabytes (so far) aren't
>>> actually bi-products of little initializations happening everywhere.
>>>
>>>
>>>
>>> 2. Does any one know the minimum disk foot print of the executable.  I
>>> guess meaning the base executable plus absolutely essential dlls
>>> (which it seems is turning out to be all of them, but I can't believe
>>> this to be true).
>>>
>>>
>>> -tim
>>>
>>>
>>> On Sun, Dec 27, 2009 at 8:34 AM, Alexey Varlamov
>>> <al...@gmail.com>   wrote:
>>>>> At this point I'm trying to get the classes of
>>>>> "luni-kernal-stubs.jar" (which I renamed to kernal.jar)
>>>> Bad idea. This is the point of your failure - those are really
>>>> compilation stubs, just a blueprint of classlib-vm API.
>>>> There are real kernel classes implemented in DRLVM, unluckily buried
>>>> inside the source tree: working_vm\vm\vmcore\src\kernel_classes. You
>>>> should use them instead of luni-kernel-stubs.jar.
>>>>
>>>>> and "luni.jar" to load.
>>>>> It seems to be getting through a few, and is crashing on
>>>>> java/lang/String.
>>>>> Why? I have no idea as of yet.  I guess that is tomorrow or Sunday.
>>>>
>>>> Just because String.intern() delegates to kernel classes which are not
>>>> implemented in your setup. All you need is to switch to correct
>>>> kernel.jar, it is normally built as a part of DRLVM.
>>>>
>>>> Good luck!
>>>> --
>>>> Alexey
>>>>
>>>
>>
>>
>> --
>> Best Regards,
>> Regis.
>>
>


-- 
Best Regards,
Regis.

Re: harmony vm as a lib

Posted by Tim Prepscius <ti...@gmail.com>.
That was the plan.  I am linking hyluni as a static already.  I think
there is some additional initialization I must do somewhere.
But at this point, I'm more concerned with the 33 megabytes being used
for just a partial initialization.


If these 33 megabytes are coming because somewhere something is
allocating 32 megabytes reserve heap, and then is going to
sub-allocate that for java objects, then I can probably modify this
behavior somehow to allocate as needed.  But if 33 megabytes are being
allocated for java initializations-  then it would take a whole lot of
work before I can use harmony.

It's really hard for me to believe that 33 megabytes are coming from
loaded classes.  I'll investigate more this week.  Hmm.. Maybe the
garbage collector needs to be invoked or something?



Does anyone know what the minimum memory usage is for an initialized
jvm before executing client code.. meaning after all of the necessary
initialization classes are loaded, but before any client app dependent
classes are loaded, etc etc etc etc?




Currently the libraries I'm linking statically are:
apr-1.lib, ch.lib, em.lib, encoder.lib, harmonyvm.lib, hycommon.lib,
hyprt.lib, hythr.lib, hyzip.lib, icuuc34d.lib, interpreter.lib,
port.lib, verifier.lib, vmi.lib, zlib.lib, hyluni.lib,
gc_gen_uncomp.lib

I'm doing the static JNI initialization via a table I'm adding to by
hand.. I was hoping to add the minimal set needed for initialization
and things I wanted to support, and then tell the linker to remove
dead code, and see what it removed.


Happy New Year!!!

-tim

---

Code for JNI hand done registry if that explanation was confusing:


#include <map>
#include <string>
#include "natives_support.h"

#include "org_apache_harmony_drlvm_VMHelper.h"
#include "java_lang_VMClassRegistry.h"
#include "java_lang_ClassLoader.h"
#include "java_lang_System.h"
#include "org_apache_harmony_vm_VMStack.h"
#include "java_lang_VMExecutionEngine.h"

// wherez header?
extern "C"
JNIEXPORT void JNICALL Java_java_io_FileDescriptor_syncImpl (JNIEnv *
env, jobject recv);
extern "C"
JNIEXPORT void JNICALL
Java_java_io_FileDescriptor_oneTimeInitialization (JNIEnv * env,
jclass fdClazz);

typedef std::map<std::string, GenericFunctionPointer> StaticNativeMap;
static StaticNativeMap staticNatives;

struct NameFunctionPair
{
	const char *name;
	GenericFunctionPointer ptr;
};

#define MAKE_NAMEFUNCTIONPAIR(x) { #x, (GenericFunctionPointer)&x }

NameFunctionPair staticNativesToRegister[] =
{
	MAKE_NAMEFUNCTIONPAIR(Java_java_io_FileDescriptor_oneTimeInitialization),
	MAKE_NAMEFUNCTIONPAIR(Java_java_io_FileDescriptor_syncImpl),

	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getPointerTypeSize),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_isCompressedRefsMode),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_isCompressedVTableMode),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeVTableBaseOffset),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeObjectBaseOffset),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getObjectVtableOffset),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getClassJLCHanldeOffset),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_drlvm_VMHelper_getVtableClassOffset),

	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_exit),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_getAssertionStatus),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_getAvailableProcessors),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_getProperties),
//	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_loadLibrary),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_traceInstructions),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_traceMethodCalls),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_currentTimeMillis),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_nanoTime),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMExecutionEngine_mapLibraryName),

	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_ClassLoader_findLoadedClass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_ClassLoader_registerInitiatedClass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_ClassLoader_defineClass0),

	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_loadBootstrapClass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getClassNative),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getClassLoader0),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getComponentType),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredClasses),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredConstructors),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredFields),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaredMethods),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getDeclaringClass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getInterfaces),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getModifiers),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getName),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getSuperclass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getSystemPackages),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_initializeClass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isArray),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isAssignableFrom),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isInstance),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_isPrimitive),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_linkClass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_loadArray),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_loadLibrary),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getEnclosingClass),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getEnclosingMember),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_VMClassRegistry_getSimpleName),

	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_setErrUnsecure),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_setInUnsecure),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_setOutUnsecure),
	MAKE_NAMEFUNCTIONPAIR(Java_java_lang_System_rethrow),

	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getCallerClass),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getClasses),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getStackState),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getStackClasses),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getStackTrace),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getClassLoader0),
	MAKE_NAMEFUNCTIONPAIR(Java_org_apache_harmony_vm_VMStack_getThreadStackTrace),
	{ NULL, NULL }
};

inline void populateStaticNativesUsingSet (NameFunctionPair *nameFunctionPairs)
{
	for (NameFunctionPair *i=nameFunctionPairs; i->name!=NULL; ++i)
		staticNatives[i->name] = i->ptr;
}

inline void populateStaticNativeMap ()
{
	static bool staticNativesPopulated = false;
	if (staticNativesPopulated)
		return;

	populateStaticNativesUsingSet (staticNativesToRegister);
	staticNativesPopulated = true;
}

GenericFunctionPointer findStaticNative (const char *symbol)
{
        // lock mutex?

	populateStaticNativeMap();

	StaticNativeMap::iterator i = staticNatives.find(symbol);
	if (i != staticNatives.end())
		return i->second;

	FILE *f = fopen ("nonfoundstatics.txt", "a+t");
	fputs (symbol, f);
	fputs ("\n", f);
	fclose (f);

	return NULL;
}



On 1/3/10, Regis <xu...@gmail.com> wrote:
> On 2010-01-02 13:42, Tim Prepscius wrote:
>> Greetings,
>>
>> I write to give a small update and ask a couple questions.
>>
>> The update is: I'm still getting everything static-ified.  It seems
>> when I enabled the missing kernel + natives, those depended on other
>> natives which depended on other natives which depended on other
>> natives and jars etc etc.  It seems I must include pretty much every
>> library just to get past startup.
>>
>> I'm now up to "Java_java_io_FileDescriptor_oneTimeInitialization"
>> HARMONY_CACHE_SET is failing, not sure why, maybe I need to call some
>> other initialization method somewhere.
>
> It requires hyluni.dll from classlib.
>
>>
>> So as I'm statically linking libraries as I'm including more and more
>> dependencies, the executable size keeps on growing.
>>
>> Here are my current two questions:
>>
>>
>> 1.  Before java initialization, which means after "startup code" has
>> run, but before I call JNI_CreateJavaVM, process explorer is reporting
>> that the memory used is already ~5 megabytes.
>>
>> After initialization (well at the point where it crashes now) process
>> explorer is reporting that the program is taking ~33 megabytes.
>>
>> So my question is:  What is the minimum memory foot print of this java
>> executable?  Anyone know?  Meaning post initialization, pre execute
>> code.
>
> I think the minimum memory foot print of executable java not only include
> JVM
> itself but also some classes needed by JVM when starting. Even to run a
> "HelloWorld" program, hundreds of classes will be loaded and also native
> dlls
> required by them, will you also static link them together?
>
>>
>> Is this JVM allocating a whole ton of memory to begin?  If so how can
>> I change this.  Surely all of those ~28 megabytes (so far) aren't
>> actually bi-products of little initializations happening everywhere.
>>
>>
>>
>> 2. Does any one know the minimum disk foot print of the executable.  I
>> guess meaning the base executable plus absolutely essential dlls
>> (which it seems is turning out to be all of them, but I can't believe
>> this to be true).
>>
>>
>> -tim
>>
>>
>> On Sun, Dec 27, 2009 at 8:34 AM, Alexey Varlamov
>> <al...@gmail.com>  wrote:
>>>> At this point I'm trying to get the classes of
>>>> "luni-kernal-stubs.jar" (which I renamed to kernal.jar)
>>> Bad idea. This is the point of your failure - those are really
>>> compilation stubs, just a blueprint of classlib-vm API.
>>> There are real kernel classes implemented in DRLVM, unluckily buried
>>> inside the source tree: working_vm\vm\vmcore\src\kernel_classes. You
>>> should use them instead of luni-kernel-stubs.jar.
>>>
>>>> and "luni.jar" to load.
>>>> It seems to be getting through a few, and is crashing on
>>>> java/lang/String.
>>>> Why? I have no idea as of yet.  I guess that is tomorrow or Sunday.
>>>
>>> Just because String.intern() delegates to kernel classes which are not
>>> implemented in your setup. All you need is to switch to correct
>>> kernel.jar, it is normally built as a part of DRLVM.
>>>
>>> Good luck!
>>> --
>>> Alexey
>>>
>>
>
>
> --
> Best Regards,
> Regis.
>

Re: harmony vm as a lib

Posted by Regis <xu...@gmail.com>.
On 2010-01-02 13:42, Tim Prepscius wrote:
> Greetings,
>
> I write to give a small update and ask a couple questions.
>
> The update is: I'm still getting everything static-ified.  It seems
> when I enabled the missing kernel + natives, those depended on other
> natives which depended on other natives which depended on other
> natives and jars etc etc.  It seems I must include pretty much every
> library just to get past startup.
>
> I'm now up to "Java_java_io_FileDescriptor_oneTimeInitialization"
> HARMONY_CACHE_SET is failing, not sure why, maybe I need to call some
> other initialization method somewhere.

It requires hyluni.dll from classlib.

>
> So as I'm statically linking libraries as I'm including more and more
> dependencies, the executable size keeps on growing.
>
> Here are my current two questions:
>
>
> 1.  Before java initialization, which means after "startup code" has
> run, but before I call JNI_CreateJavaVM, process explorer is reporting
> that the memory used is already ~5 megabytes.
>
> After initialization (well at the point where it crashes now) process
> explorer is reporting that the program is taking ~33 megabytes.
>
> So my question is:  What is the minimum memory foot print of this java
> executable?  Anyone know?  Meaning post initialization, pre execute
> code.

I think the minimum memory foot print of executable java not only include JVM 
itself but also some classes needed by JVM when starting. Even to run a 
"HelloWorld" program, hundreds of classes will be loaded and also native dlls 
required by them, will you also static link them together?

>
> Is this JVM allocating a whole ton of memory to begin?  If so how can
> I change this.  Surely all of those ~28 megabytes (so far) aren't
> actually bi-products of little initializations happening everywhere.
>
>
>
> 2. Does any one know the minimum disk foot print of the executable.  I
> guess meaning the base executable plus absolutely essential dlls
> (which it seems is turning out to be all of them, but I can't believe
> this to be true).
>
>
> -tim
>
>
> On Sun, Dec 27, 2009 at 8:34 AM, Alexey Varlamov
> <al...@gmail.com>  wrote:
>>> At this point I'm trying to get the classes of
>>> "luni-kernal-stubs.jar" (which I renamed to kernal.jar)
>> Bad idea. This is the point of your failure - those are really
>> compilation stubs, just a blueprint of classlib-vm API.
>> There are real kernel classes implemented in DRLVM, unluckily buried
>> inside the source tree: working_vm\vm\vmcore\src\kernel_classes. You
>> should use them instead of luni-kernel-stubs.jar.
>>
>>> and "luni.jar" to load.
>>> It seems to be getting through a few, and is crashing on java/lang/String.
>>> Why? I have no idea as of yet.  I guess that is tomorrow or Sunday.
>>
>> Just because String.intern() delegates to kernel classes which are not
>> implemented in your setup. All you need is to switch to correct
>> kernel.jar, it is normally built as a part of DRLVM.
>>
>> Good luck!
>> --
>> Alexey
>>
>


-- 
Best Regards,
Regis.

Re: harmony vm as a lib

Posted by Tim Prepscius <ti...@gmail.com>.
Greetings,

I write to give a small update and ask a couple questions.

The update is: I'm still getting everything static-ified.  It seems
when I enabled the missing kernel + natives, those depended on other
natives which depended on other natives which depended on other
natives and jars etc etc.  It seems I must include pretty much every
library just to get past startup.

I'm now up to "Java_java_io_FileDescriptor_oneTimeInitialization"
HARMONY_CACHE_SET is failing, not sure why, maybe I need to call some
other initialization method somewhere.

So as I'm statically linking libraries as I'm including more and more
dependencies, the executable size keeps on growing.

Here are my current two questions:


1.  Before java initialization, which means after "startup code" has
run, but before I call JNI_CreateJavaVM, process explorer is reporting
that the memory used is already ~5 megabytes.

After initialization (well at the point where it crashes now) process
explorer is reporting that the program is taking ~33 megabytes.

So my question is:  What is the minimum memory foot print of this java
executable?  Anyone know?  Meaning post initialization, pre execute
code.

Is this JVM allocating a whole ton of memory to begin?  If so how can
I change this.  Surely all of those ~28 megabytes (so far) aren't
actually bi-products of little initializations happening everywhere.



2. Does any one know the minimum disk foot print of the executable.  I
guess meaning the base executable plus absolutely essential dlls
(which it seems is turning out to be all of them, but I can't believe
this to be true).


-tim


On Sun, Dec 27, 2009 at 8:34 AM, Alexey Varlamov
<al...@gmail.com> wrote:
>> At this point I'm trying to get the classes of
>> "luni-kernal-stubs.jar" (which I renamed to kernal.jar)
> Bad idea. This is the point of your failure - those are really
> compilation stubs, just a blueprint of classlib-vm API.
> There are real kernel classes implemented in DRLVM, unluckily buried
> inside the source tree: working_vm\vm\vmcore\src\kernel_classes. You
> should use them instead of luni-kernel-stubs.jar.
>
>> and "luni.jar" to load.
>> It seems to be getting through a few, and is crashing on java/lang/String.
>> Why? I have no idea as of yet.  I guess that is tomorrow or Sunday.
>
> Just because String.intern() delegates to kernel classes which are not
> implemented in your setup. All you need is to switch to correct
> kernel.jar, it is normally built as a part of DRLVM.
>
> Good luck!
> --
> Alexey
>

Re: harmony vm as a lib

Posted by Alexey Varlamov <al...@gmail.com>.
> At this point I'm trying to get the classes of
> "luni-kernal-stubs.jar" (which I renamed to kernal.jar)
Bad idea. This is the point of your failure - those are really
compilation stubs, just a blueprint of classlib-vm API.
There are real kernel classes implemented in DRLVM, unluckily buried
inside the source tree: working_vm\vm\vmcore\src\kernel_classes. You
should use them instead of luni-kernel-stubs.jar.

> and "luni.jar" to load.
> It seems to be getting through a few, and is crashing on java/lang/String.
> Why? I have no idea as of yet.  I guess that is tomorrow or Sunday.

Just because String.intern() delegates to kernel classes which are not
implemented in your setup. All you need is to switch to correct
kernel.jar, it is normally built as a part of DRLVM.

Good luck!
--
Alexey

Re: harmony vm as a lib

Posted by Tim Prepscius <ti...@gmail.com>.
Okay, will do.

BTW.  I think things are crashing because the VM "intern" method has
not been overridden by the native method.

Does anyone know where the VM & other luni/luni-kernal native methods
get loaded into the JVM?  I'm looking for a OnLoad or something that
registers those natives.  As of yet can't find it.  And strangely, I
have yet to find that "intern" method.


The reason I think this is assert culprit is because I'm looking at
the luni java and it looks like this:

(VM class)
    /**
     * This method must be provided by the vm vendor.
     *
     * Searches an internal table of strings for a string equal to the specified
     * String. If the string is not in the table, it is added. Answers the
     * string contained in the table which is equal to the specified String. The
     * same string object is always answered for strings which are equal.
     *
     * @param string the String to intern
     *
     * @return the interned string equal to the specified String
     */
    public static final String intern(String string) {
        return null;
    }


(and this is obviously a stub)

and then the result is asserted to be not null..

any hints?

-tim

On Sat, Dec 26, 2009 at 1:02 AM, Mark Hindess
<ma...@googlemail.com> wrote:
>
> In message <6f...@mail.gmail.com>, Tim P
> repscius writes:
>>
>> ...
>>
>> Here is a diff so far:  It's getting pretty long, maybe I should post
>> it somewhere else?
>
> Perhaps attach it to a JIRA and include the URL in future messages?  It
> is probably worth creating a JIRA to track this work anyway and to make
> it easier for people to find the latest version of your patch.
>
> -Mark
>
>
>

Re: harmony vm as a lib

Posted by Mark Hindess <ma...@googlemail.com>.
In message <6f...@mail.gmail.com>, Tim P
repscius writes:
>
> ...
>
> Here is a diff so far:  It's getting pretty long, maybe I should post
> it somewhere else?

Perhaps attach it to a JIRA and include the URL in future messages?  It
is probably worth creating a JIRA to track this work anyway and to make
it easier for people to find the latest version of your patch.

-Mark



Re: harmony vm as a lib

Posted by Tim Prepscius <ti...@gmail.com>.
Greetings again,

I thought I would give an update on my latest hours of staring at working_vm.
So at this point, I've gotten everything to be a static.  I've gotten
things to link.

I've gotten all of the EM stuff to work.  (with a hack).  I've gotten
the interpreter to become the default _execute_method (with a hack).

At this point I'm trying to get the classes of
"luni-kernal-stubs.jar" (which I renamed to kernal.jar) and "luni.jar"
to load.

It seems to be getting through a few, and is crashing on java/lang/String.
Why? I have no idea as of yet.  I guess that is tomorrow or Sunday.


Hmm.. If any one looks over the changes and thinks, "man there is a
much easier way for him to be doing this.."   I would gladly take any
comments.  It is pretty cumbersome stepping through things and trying
to figure out what initializations actually do what.  Anyway.
Hopefully, soon I'll have a complete interpreter with kernal classes
.. (which is pretty much all I need)

Here's where it's crashing  (if you are interested):


runs runs runs....  gets to the initializing the java lang string

[trace] initializing class java/lang/String STEP 8
[trace]
{{{ interpreter_invoke: 013F7758.<clinit>()V
[trace] interpreter: 013F7758.<clinit>()V
[trace] StartLoading class java/lang/String$CaseInsensitiveComparator
with loader 013A12A8
[trace] 013A12A8 013BD608 I java/lang/String$CaseInsensitiveComparator
[trace] Loader (013A12A8) loading class:
java/lang/String$CaseInsensitiveComparator...
[trace] Defining class java/lang/String$CaseInsensitiveComparator with
loader 013A12A8
[trace] 013A12A8 013BD608 DC java/lang/String$CaseInsensitiveComparator
[trace] 013A12A8 013BD608 CDAI 013BD608
java/lang/String$CaseInsensitiveComparator
[trace] allocating Class for "java/lang/String$CaseInsensitiveComparator"
[trace] NewClass inserting class
"java/lang/String$CaseInsensitiveComparator" with key
java/lang/String$CaseInsensitiveComparator and object 01
[trace] classloader_name: <null> is trusted: 1
[trace] number of local vars:1
[trace] number of local vars:3
[trace] number of local vars:0
[trace] number of local vars:0
[trace] ByteReader::have: EOB
[trace] StartLoading class java/lang/Object with loader 013A12A8
[trace] StartLoading class java/util/Comparator with loader 013A12A8
[trace] 013A12A8 013BD608 I java/util/Comparator
[trace] Loader (013A12A8) loading class: java/util/Comparator...
[trace] Defining class java/util/Comparator with loader 013A12A8
[trace] 013A12A8 013BD608 DC java/util/Comparator
[trace] 013A12A8 013BD608 CDAI 013BD608 java/util/Comparator
[trace] allocating Class for "java/util/Comparator"
[trace] NewClass inserting class "java/util/Comparator" with key
java/util/Comparator and object 013A1B50@20770540
[trace] classloader_name: <null> is trusted: 1
[trace] ByteReader::have: EOB
[trace] StartLoading class java/lang/Object with loader 013A12A8
[trace] 013A12A8 013BD608 R java/util/Comparator
[Loaded java/util/Comparator from
c:\source3\harmony\working_vm\vm\executable\javaexe\luni.jar]
[trace] BEGIN class prepare, class name = java/util/Comparator
[trace] interface java/util/Comparator prepared
[trace] END class prepare, class name = java/util/Comparator
[trace] StartLoading class java/io/Serializable with loader 013A12A8
[trace] 013A12A8 013BD608 R java/lang/String$CaseInsensitiveComparator
[Loaded java/lang/String$CaseInsensitiveComparator from
c:\source3\harmony\working_vm\vm\executable\javaexe\luni.jar]
[trace] BEGIN class prepare, class name =
java/lang/String$CaseInsensitiveComparator
[trace] class 013F9A48 allocated size 8
[trace] class java/lang/String$CaseInsensitiveComparator prepared
[trace] END class prepare, class name =
java/lang/String$CaseInsensitiveComparator
[trace] initializing class java/lang/String$CaseInsensitiveComparator
[trace] initializing class java/lang/String$CaseInsensitiveComparator STEP 2
[trace] initializing class java/lang/String$CaseInsensitiveComparatorSTEP 6
[trace] class java/lang/String$CaseInsensitiveComparator initialized
[trace]
{{{ invoke_special    :
013F9A48.<init>(Ljava/lang/String$CaseInsensitiveComparator;)V
[trace] interpreter:
013F9A48.<init>(Ljava/lang/String$CaseInsensitiveComparator;)V
[trace]
{{{ invoke_special    : 013F9A48.<init>()V
[trace] interpreter: 013F9A48.<init>()V
[trace]
{{{ invoke_special    : 013A14E8.<init>()V
[trace] interpreter: 013A14E8.<init>()V
[trace] invoke_special }}}

[trace] invoke_special }}}

[trace] invoke_special }}}

[trace] initializing class java/lang/String
[trace] initializing class java/lang/String STEP 2
[trace] initializing class java/lang/String
[trace] initializing class java/lang/String STEP 2

... does STEP 2 for a while ...

[trace] initializing class java/lang/String
[trace] initializing class java/lang/String STEP 2
[trace] initializing class java/lang/String
[trace] initializing class java/lang/String STEP 2
[trace]
{{{ interpreter_invoke: 013F7C00.intern(Ljava/lang/String;)Ljava/lang/String;
[trace] interpreter: 013F7C00.intern(Ljava/lang/String;)Ljava/lang/String;
[trace] interpreter_invoke }}}

*** CRASH ***
well actually assert on

   vm_execute_java_method_array((jmethodID)env->VM_intern,
        (jvalue*)&string, args);

    if (exn_raised()) { //if RuntimeException or Error
        return NULL;
    }
    assert(string);  <<-------------- HERE


**************************************************

Here is a diff so far:  It's getting pretty long, maybe I should post
it somewhere else?
After I get finally a working VM, I'll go in an minimize the changes necessary.

Index: harmony/working_vm/vm/em/src/DrlEMImpl.cpp
===================================================================
--- harmony/working_vm/vm/em/src/DrlEMImpl.cpp	(revision 883577)
+++ harmony/working_vm/vm/em/src/DrlEMImpl.cpp	(working copy)
@@ -43,6 +43,8 @@
 #include "port_threadunsafe.h"
 #include "port_mutex.h"

+#include "dll_jit_intf.h"
+
 #define EDGE_PROFILER_STR  "EDGE_PROFILER"
 #define VALUE_PROFILER_STR  "VALUE_PROFILER"
 #define ENTRY_BACKEDGE_PROFILER_STR  "EB_PROFILER"
@@ -267,15 +269,32 @@
 }


-static std::string readFile(const std::string& fileName) {
+static std::string readFile(const std::string& fileName)
+{
+	char *c_string_tmp_value =
vm_properties_get_value("em.config_override", VM_PROPERTIES);
+	std::string configOverride = c_string_tmp_value ? c_string_tmp_value : "";
+	vm_properties_destroy_value (c_string_tmp_value);
+
     std::string config;
-    std::ifstream configFile;
-    configFile.open(fileName.c_str(), std::ios::in);
+    std::istream *configFile;
+
+	if (configOverride.empty())
+	{
+		configFile = new std::ifstream (fileName.c_str(), std::ios::in);
+		if (!((std::ifstream*)configFile)->is_open())
+		{
+			delete configFile;
+			configFile = NULL;
+		}
+	}
+	else
+		configFile = new std::istringstream (configOverride);
+
     bool rc = false;
-    if (configFile.is_open()) {
+    if (configFile) {
         std::string line;
         size_t idx = std::string::npos;
-        while (getline(configFile, line)) {
+        while (getline(*configFile, line)) {
             if (startsWith(line, "#")) {
                 continue;
             } else if (startsWith(line, "-D") && (idx =
line.find('=')) != std::string::npos) {
@@ -325,6 +344,8 @@
     if (!rc) {
         LECHO(1, "EM: Can't read configuration from '{0}'" <<
fileName.c_str());
     }
+
+	delete configFile;
     return config;
 }

@@ -439,30 +460,51 @@
         for (StringList::const_iterator jitIt = jitsInChain.begin(),
jitEnd = jitsInChain.end(); jitIt!=jitEnd; ++jitIt) {
             std::string jitName= *jitIt;
             std::string jitLib = getJITLibFromCmdLine(jitName);
+
             if (jitLib.empty()) {
                 jitLib = getParam(config, jitName+".file");
             }
-            if (jitLib.empty()) {
+
+			if (jitLib.empty()) {
                 LECHO(4, "EM: No JIT library specified for JIT
:'{0}'" << jitLib.c_str());
                 failed = true;
                 break;
             }
-            std::string fullJitLibPath = prepareLibPath(jitLib);
-            apr_dso_handle_t* libHandle;
-            JIT_Handle jh = vm_load_jit(fullJitLibPath.c_str(),
&libHandle); //todo: do not load the same dll twice!!!
-            if (jh == NULL) {
-                LECHO(5, "EM: JIT library loading error:'{0}'" <<
fullJitLibPath.c_str());
-                failed = true;
-                break;
-            }
-            RStep* step = new RStep(jh, jitName, chain, libHandle);
-            step->loggingEnabled = loggingEnabled ||
log_is_info_enabled(step->catName.c_str());
-            chain->steps.push_back(step);

-            if (!initJIT(fullJitLibPath, libHandle, *step)) {
-                failed = true;
-                break;
-            }
+			if (jitLib == "_static_")
+			{
+				apr_dso_handle_t* libHandle;
+				jh = vm_load_jit(NULL, &libHandle);
+				JIT_init (jh, jitName.c_str(), NULL);
+
+				RStep* step = new RStep(jh, jitName, chain, libHandle);
+				step->loggingEnabled = loggingEnabled ||
log_is_info_enabled(step->catName.c_str());
+				chain->steps.push_back(step);
+
+	            _execute_method =
+					(void(*)(JIT_Handle,jmethodID, jvalue*, jvalue*))
+						(((Dll_JIT *)jh)->_execute_method);
+			}
+			else
+			{
+				std::string fullJitLibPath = prepareLibPath(jitLib);
+				apr_dso_handle_t* libHandle;
+
+				JIT_Handle jh = vm_load_jit(fullJitLibPath.c_str(), &libHandle);
//todo: do not load the same dll twice!!!
+				if (jh == NULL) {
+					LECHO(5, "EM: JIT library loading error:'{0}'" << fullJitLibPath.c_str());
+					failed = true;
+					break;
+				}
+				RStep* step = new RStep(jh, jitName, chain, libHandle);
+				step->loggingEnabled = loggingEnabled ||
log_is_info_enabled(step->catName.c_str());
+				chain->steps.push_back(step);
+
+				if (!initJIT(fullJitLibPath, libHandle, *step)) {
+					failed = true;
+					break;
+				}
+			}
         }
         failed = failed || chain->steps.empty();
         if (!failed) {
Index: harmony/working_vm/vm/gc_gen/src/common/gc_for_vm.cpp
===================================================================
--- harmony/working_vm/vm/gc_gen/src/common/gc_for_vm.cpp	(revision 883577)
+++ harmony/working_vm/vm/gc_gen/src/common/gc_for_vm.cpp	(working copy)
@@ -36,6 +36,7 @@
 #include "../finalizer_weakref/finalizer_weakref.h"
 #include "collection_scheduler.h"
 #include "gc_concurrent.h"
+#include "open/gc.h"
 #ifdef USE_32BITS_HASHCODE
 #include "hashcode.h"
 #endif
@@ -65,6 +66,10 @@
     vm_helper_register_magic_helper(VM_RT_GET_IDENTITY_HASHCODE,
"org/apache/harmony/drlvm/gc_gen/GCHelper", "get_hashcode");
 }

+#pragma message("WHERE DOES THIS COMPILE?")
+
+
+
 int gc_init()
 {
   INFO2("gc.process", "GC: call GC init...\n");
@@ -177,6 +182,9 @@
 #endif
 }

+#pragma message("WHERE DOES THIS COMPILE?")
+
+
 /* this interface need reconsidering. is_pinned is unused. */
 void gc_add_root_set_entry(Managed_Object_Handle *ref, Boolean is_pinned)
 {
Index: harmony/working_vm/vm/include/jni_types.h
===================================================================
--- harmony/working_vm/vm/include/jni_types.h	(revision 883577)
+++ harmony/working_vm/vm/include/jni_types.h	(working copy)
@@ -49,8 +49,13 @@
  */
 #if defined (_WIN32) || defined (__WIN32__) || defined (WIN32)

+#if defined(STATIC_BUILD)
+#define JNIEXPORT
+#define JNIIMPORT
+#else
 #define JNIEXPORT __declspec(dllexport)
 #define JNIIMPORT __declspec(dllimport)
+#endif
 #define JNICALL __stdcall

 typedef signed __int64 jlong;
Index: harmony/working_vm/vm/include/open/gc.h
===================================================================
--- harmony/working_vm/vm/include/open/gc.h	(revision 883577)
+++ harmony/working_vm/vm/include/open/gc.h	(working copy)
@@ -61,6 +61,7 @@
 #define GCExport
 #endif /* #ifndef PLATFORM_POSIX */

+	
 #define BITS_PER_BYTE 8

 // Signed arithmetic is used when we do allocation pointer/limit compares.
@@ -75,6 +76,8 @@

 #if defined(USE_GC_STATIC) || defined(BUILDING_GC)

+#pragma message("USE_GC_STATIC OR BUILDING_GC defined")
+
 /**
  * @name Routines to support the initialization and termination of GC
  */
@@ -762,7 +765,7 @@
 /**
  * Get object hashcode.
  */
-GCExport I_32 gc_get_hashcode (Managed_Object_Handle p_object);
+GCExport I_32 gc_get_hashcode0 (Managed_Object_Handle p_object);

 /**
  * Iterate all live objects in heap.
Index: harmony/working_vm/vm/include/open/platform_types.h
===================================================================
--- harmony/working_vm/vm/include/open/platform_types.h	(revision 883577)
+++ harmony/working_vm/vm/include/open/platform_types.h	(working copy)
@@ -25,7 +25,8 @@
 /**
  * DLL stuff
  */
-#if defined(PLATFORM_POSIX) || (defined(USE_STATIC_GC) && defined(BUILDING_GC))
+#if defined(PLATFORM_POSIX) || (defined(USE_STATIC_GC) &&
defined(BUILDING_GC)) || defined(STATIC_BUILD)
+#pragma message("CORRECT VMEXPORT")

 #define VMEXPORT
 #define VMIMPORT
@@ -33,13 +34,9 @@
 #define EMEXPORT

 #else  // !PLATFORM_POSIX
+#pragma message("NOT CORRECt VMEXPORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

-#if defined(STATIC_BUILD)
-#define VMEXPORT
-#define JITEXPORT
-#define EMEXPORT
-#define VMIMPORT
-#elif defined(BUILDING_VM)
+#if defined(BUILDING_VM)
 #define VMEXPORT __declspec(dllexport)
 #define JITEXPORT __declspec(dllimport)
 #define EMEXPORT __declspec(dllimport)
Index: harmony/working_vm/vm/include/em_intf.h
===================================================================
--- harmony/working_vm/vm/include/em_intf.h	(revision 883577)
+++ harmony/working_vm/vm/include/em_intf.h	(working copy)
@@ -22,6 +22,7 @@

 #include "open/types.h"
 #include "open/em.h"
+#include "open/compmgr.h"
 #include <apr_dso.h>

 #ifdef __cplusplus
@@ -30,6 +31,11 @@

 VMEXPORT JIT_Handle vm_load_jit(const char* file_name,
apr_dso_handle_t** handle);

+EMEXPORT
+int EmInitialize(OpenComponentHandle* p_component,
+                 OpenInstanceAllocatorHandle* p_allocator,
+                 apr_pool_t* pool);
+
 #ifdef __cplusplus
 }
 #endif
Index: harmony/working_vm/vm/interpreter/src/interp_exports.cpp
===================================================================
--- harmony/working_vm/vm/interpreter/src/interp_exports.cpp	(revision 883577)
+++ harmony/working_vm/vm/interpreter/src/interp_exports.cpp	(working copy)
@@ -25,18 +25,14 @@

 typedef void *GC_Enumeration_Handle;

-#ifndef PLATFORM_POSIX
-#define EXPORT __declspec(dllexport)
-#else
-#define EXPORT
-#endif
+#define EXPORT JITEXPORT

 extern "C" {
     extern void EXPORT JIT_init(JIT_Handle h, const char* name,
vm_adaptor_t adaptor);
     EXPORT extern void JIT_deinit(JIT_Handle h);
     EXPORT extern void JIT_unwind_stack_frame(JIT_Handle,
Method_Handle, JitFrameContext *);
-    EXPORT extern void JIT_get_root_set_from_stack_frame(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, JitFrameContext *);
-    EXPORT extern void JIT_get_root_set_for_thread_dump(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, JitFrameContext *);
+    EXPORT extern void JIT_get_root_set_from_stack_frame(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, const JitFrameContext *);
+    EXPORT extern void JIT_get_root_set_for_thread_dump(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, const JitFrameContext *);
     EXPORT extern void JIT_fix_handler_context(JIT_Handle,
Method_Handle, JitFrameContext *);
     EXPORT extern void * JIT_get_address_of_this(JIT_Handle,
Method_Handle, const JitFrameContext *);
     EXPORT extern Boolean JIT_supports_compressed_references(JIT_Handle);
@@ -44,8 +40,8 @@
 }

 EXPORT void JIT_unwind_stack_frame(JIT_Handle, Method_Handle,
JitFrameContext *) { LDIE(51, "Not implemented"); }
-EXPORT void JIT_get_root_set_from_stack_frame(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, JitFrameContext *) { LDIE(51,
"Not implemented"); }
-EXPORT void JIT_get_root_set_for_thread_dump(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, JitFrameContext *) {return;}
+EXPORT void JIT_get_root_set_from_stack_frame(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, const JitFrameContext *) {
LDIE(51, "Not implemented"); }
+EXPORT void JIT_get_root_set_for_thread_dump(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, const JitFrameContext *)
{return;}
 EXPORT void JIT_fix_handler_context(JIT_Handle, Method_Handle,
JitFrameContext *) { LDIE(51, "Not implemented"); }
 EXPORT void * JIT_get_address_of_this(JIT_Handle, Method_Handle,
const JitFrameContext *) { LDIE(51, "Not implemented"); return (void
*)JIT_FAILURE;}

Index: harmony/working_vm/vm/port/include/cxxlog.h
===================================================================
--- harmony/working_vm/vm/port/include/cxxlog.h	(revision 883577)
+++ harmony/working_vm/vm/port/include/cxxlog.h	(working copy)
@@ -64,8 +64,12 @@
  * and debugging <code>printf</code>.
  */
 #ifdef NDEBUG
+#pragma message("NO DEBUG")
+
 #    define TRACE2(category, message)
 #else
+#pragma message("DEBUG!!!!!!")
+
 #    define TRACE2(category, message) LOG_SITE(trace, category, \
         log_printf("[trace] "); \
         log_header(category, __FILELINE__, __PRETTY_FUNCTION__); \
Index: harmony/working_vm/vm/port/src/logger/logger.cpp
===================================================================
--- harmony/working_vm/vm/port/src/logger/logger.cpp	(revision 883577)
+++ harmony/working_vm/vm/port/src/logger/logger.cpp	(working copy)
@@ -104,11 +104,12 @@
 }  light_logger = {
     NULL, &vfprintf, &exit, &abort, stdout, NULL, LOG_EMPTY, NULL,
NULL, NULL };

-Logger default_logger = {
-    NULL, &vfprintf, &exit, &abort, stdout, NULL, LOG_EMPTY, NULL,
NULL, NULL };

 static Logger* get()
 {
+	static Logger default_logger = {
+		NULL, &vfprintf, &exit, &abort, stdout, NULL, LOG_EMPTY, NULL, NULL, NULL };
+
     return &default_logger;
 }

@@ -382,7 +383,7 @@
  */
 static LogState is_enabled(const char *category, LogCategory *log_category) {
     int max_size = -1;
-    LogState enabled = LOG_DISABLED;
+    LogState enabled = LOG_ENABLED;
     while (log_category) {
         if (strncmp(log_category->name, category, log_category->len) == 0) {
             if (log_category->len > max_size) {
Index: harmony/working_vm/vm/vmcore/include/dll_jit_intf.h
===================================================================
--- harmony/working_vm/vm/vmcore/include/dll_jit_intf.h	(revision 883577)
+++ harmony/working_vm/vm/vmcore/include/dll_jit_intf.h	(working copy)
@@ -286,9 +286,13 @@
     Boolean
     (*_supports_compressed_references)(JIT_Handle jit);

+
+public:
     void
     (*_execute_method) (JIT_Handle jit, jmethodID method, jvalue
*return_value, jvalue *args);

+private:
+
     OpenExeJpdaError
         (*_get_bc_location_for_native)(JIT_Handle jit, Method_Handle  method,
         NativeCodePtr   native_pc, uint16 *bc_pc);
Index: harmony/working_vm/vm/vmcore/src/jit/dll_jit.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/jit/dll_jit.cpp	(revision 883577)
+++ harmony/working_vm/vm/vmcore/src/jit/dll_jit.cpp	(working copy)
@@ -23,7 +23,54 @@
 #include "open/gc.h"
 #include "compile.h"

+//#ifdef STATIC_BUILD

+#include <stdlib.h>
+#include <stdio.h>
+#include "open/types.h"
+#include "open/vm.h"
+#include "platform_lowlevel.h"
+#include "interpreter_exports.h"
+#include "jit_export.h"
+#include "cxxlog.h"
+
+extern "C" {
+    extern void JIT_init(JIT_Handle h, const char* name, vm_adaptor_t adaptor);
+    extern void JIT_deinit(JIT_Handle h);
+    extern void JIT_unwind_stack_frame(JIT_Handle, Method_Handle,
JitFrameContext *);
+    extern void JIT_get_root_set_from_stack_frame(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, const JitFrameContext *);
+    extern void JIT_get_root_set_for_thread_dump(JIT_Handle,
Method_Handle, GC_Enumeration_Handle, const JitFrameContext *);
+    extern void JIT_fix_handler_context(JIT_Handle, Method_Handle,
JitFrameContext *);
+    extern void * JIT_get_address_of_this(JIT_Handle, Method_Handle,
const JitFrameContext *);
+    extern Boolean JIT_supports_compressed_references(JIT_Handle);
+    extern void JIT_execute_method(JIT_Handle,jmethodID method,
jvalue *return_value, jvalue *args);
+}
+
+Dll_JIT::Dll_JIT () :
+	_deinit(&JIT_deinit),
+	_next_command_line_argument(NULL),
+	_compile_method_with_params(NULL),
+	_unwind_stack_frame(&JIT_unwind_stack_frame),
+	_get_root_set_from_stack_frame(&JIT_get_root_set_from_stack_frame),
+	_get_root_set_for_thread_dump(&JIT_get_root_set_for_thread_dump),
+	_fix_handler_context(&JIT_fix_handler_context),
+	_get_address_of_this(&JIT_get_address_of_this),
+	_recompiled_method_callback(NULL),
+	_execute_method(&JIT_execute_method),
+	_get_bc_location_for_native(NULL),
+	_get_native_location_for_bc(NULL),
+	_get_local_var(NULL),
+	_set_local_var(NULL),
+	jit_dll_filename(NULL),
+	lib_handle(NULL)
+{
+	apr_pool_t *pool;
+	apr_pool_create_ex(&pool, NULL, NULL, NULL);
+	apr_os_dso_handle_put (&lib_handle, NULL, pool);
+}
+
+//#endif
+
 Dll_JIT::Dll_JIT(const char *dll_filename) :
 _deinit(NULL),
 _next_command_line_argument(NULL),
Index: harmony/working_vm/vm/vmcore/src/gc/dll_gc.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/gc/dll_gc.cpp	(revision 883577)
+++ harmony/working_vm/vm/vmcore/src/gc/dll_gc.cpp	(working copy)
@@ -17,8 +17,6 @@
 #define LOG_DOMAIN "vm.core"
 #include "cxxlog.h"

-#ifndef USE_GC_STATIC
-
 #include <apr_dso.h>
 #include <apr_errno.h>
 #include "dll_gc.h"
@@ -67,6 +65,8 @@

 static Boolean default_gc_supports_class_unloading();

+#if !defined(USE_GC_STATIC)
+
 Boolean (*gc_supports_compressed_references)() = 0;
 void (*gc_add_root_set_entry)(Managed_Object_Handle *ref, Boolean
is_pinned) = 0;
 void (*gc_add_weak_root_set_entry)(Managed_Object_Handle *ref,
Boolean is_pinned,Boolean is_short_weak) = 0;
@@ -353,6 +353,8 @@
     return result;
 } //vm_is_a_gc_dll

+#endif
+
 static Boolean default_gc_requires_barriers()
 {
     return FALSE;
@@ -558,4 +560,28 @@
 {
     return TRUE;
 } //default_gc_supports_class_unloading
-#endif // !USE_GC_STATIC
+
+#ifdef USE_GC_STATIC
+
+void gc_add_root_set_entry_managed_pointer(void **slot, Boolean is_pinned)
+{
+	default_gc_add_root_set_entry_managed_pointer(slot, is_pinned);
+}
+
+Boolean gc_supports_frontier_allocation (unsigned *offset_of_current,
unsigned *offset_of_limit)
+{
+	return default_gc_supports_frontier_allocation(offset_of_current,
offset_of_limit);
+}
+
+void gc_add_compressed_root_set_entry (U_32 * UNREF ref, Boolean is_pinned)
+{
+	default_gc_add_compressed_root_set_entry(ref);
+}
+
+I_32 gc_get_hashcode0 (Managed_Object_Handle handle)
+{
+	return default_gc_get_hashcode(handle);
+}
+
+#endif// !USE_GC_STATIC
+
Index: harmony/working_vm/vm/vmcore/src/jvmti/jvmti_roots.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/jvmti/jvmti_roots.cpp	(revision 883577)
+++ harmony/working_vm/vm/vmcore/src/jvmti/jvmti_roots.cpp	(working copy)
@@ -337,7 +337,11 @@

 void ti_enumerate_roots(TIEnv *ti_env, hythread_iterator_t iterator)
 {
-    TRACE2("ti.trace", "enumerating roots");
+#if defined(USE_GC_STATIC)
+	// TJP.. THIS FUNCTION WON'T WORK WITH STATIC GC
+	assert(false);
+#else
+	TRACE2("ti.trace", "enumerating roots");

     // FIXME: weird function table manipulations
     void (*save_gc_add_root_set_entry)
@@ -392,4 +396,5 @@
         save_gc_add_compressed_root_set_entry;

     TRACE2("ti.trace", "completed root enumeration");
+#endif
 }
Index: harmony/working_vm/vm/vmcore/src/class_support/classloader.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/class_support/classloader.cpp	(revision
883577)
+++ harmony/working_vm/vm/vmcore/src/class_support/classloader.cpp	(working
copy)
@@ -1563,7 +1563,7 @@
     char *lib_list = m_env->VmProperties()->get("vm.other_natives_dlls");

     // separate natives libraries
-    char *lib_name = strtok( lib_list, PORT_PATH_SEPARATOR_STR );
+	char *lib_name = lib_list ? strtok( lib_list,
PORT_PATH_SEPARATOR_STR ) : NULL;

     while( lib_name != NULL )
     {
Index: harmony/working_vm/vm/vmcore/src/init/vm_properties.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/init/vm_properties.cpp	(revision 883577)
+++ harmony/working_vm/vm/vmcore/src/init/vm_properties.cpp	(working copy)
@@ -289,6 +289,21 @@
 //vm part
 static void init_vm_properties(Properties & properties)
 {
+		properties.set_new(
+			"em.config_override",
+
+			"chains=chain1\n"
+			"chain1.jits=int\n"
+			"int.file=_static_\n"
+			"#system properties\n"
+			"-Djava.compiler=interpreter\n"
+			"-XX:+vm.use_interpreter\n"
+		);
+
+		properties.set_new (
+			"-Xbootclasspath:", "kernal.jar;luni.jar"
+			);
+
 #ifdef _DEBUG
         properties.set_new("vm.assert_dialog", "true");
 #else
@@ -313,7 +328,7 @@
         *  any path pre-pended
         */
         const char* path_buf =
compose_full_files_path_names_list(NULL, api_dll_files,
n_api_dll_files, true);
-        properties.set_new("vm.other_natives_dlls", path_buf);
+//        properties.set_new("vm.other_natives_dlls", path_buf);
 }

 jint initialize_properties(Global_Env * p_env)
Index: harmony/working_vm/vm/vmcore/src/init/vm_init.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/init/vm_init.cpp	(revision 883577)
+++ harmony/working_vm/vm/vmcore/src/init/vm_init.cpp	(working copy)
@@ -53,6 +53,9 @@
 #include "jit_intf.h"
 #include "signals.h"

+#include "em_intf.h"
+#include <string.h>
+
 #ifdef _WIN32
 // 20040427 Used to turn on heap checking on every allocation
 #include <crtdbg.h>
@@ -174,18 +177,48 @@
 #define GC_DLL (vm_env->compress_references ? GC_DLL_COMP : GC_DLL_UNCOMP)
 #endif

+static jint process_properties_dlls_statics (Global_Env *vm_env)
+{
+    jint status;

+	CmAddComponent (&EmInitialize);
+
+    status = vm_env->cm->GetComponent(&(vm_env->em_component), OPEN_EM);
+    if (JNI_OK != status) {
+        return status;
+    }
+
+    status = vm_env->cm->CreateInstance(&(vm_env->em_instance), OPEN_EM);
+    if (JNI_OK != status) {
+        LWARN(14, "Cannot instantiate EM");
+        return status;
+    }
+
+	// this actually sets the em_interface pointer
+    status = vm_env->em_component->GetInterface((OpenInterfaceHandle*)
&(vm_env->em_interface), OPEN_INTF_EM_VM);
+    if (JNI_OK != status) {
+        LWARN(15, "Cannot get EM_VM interface");
+        return status;
+    }
+
+	return JNI_OK;
+}
+
 /**
  * Loads DLLs.
  */
 static jint process_properties_dlls(Global_Env * vm_env) {
+#ifdef STATIC_BUILD
+	return process_properties_dlls_statics (vm_env);
+#endif
+
     jint status;

     if (!vm_env->VmProperties()->is_set("vm.em_dll")) {
         vm_env->VmProperties()->set("vm.em_dll", PORT_DSO_NAME("em"));
     }

-    char* dll = vm_env->VmProperties()->get("vm.em_dll");
+	char* dll = vm_env->VmProperties()->get("vm.em_dll");
     TRACE("analyzing em dll " << dll);
     status = CmLoadComponent(dll, "EmInitialize");
     vm_env->VmProperties()->destroy(dll);
@@ -1084,7 +1117,13 @@
 }

 JIT_Handle vm_load_jit(const char* file_name, apr_dso_handle_t** handle) {
-        Dll_JIT* jit = new Dll_JIT(file_name);
+		Dll_JIT* jit;
+
+		if (!file_name)
+			jit = new Dll_JIT();
+		else
+			jit = new Dll_JIT(file_name);
+
         *handle = jit->get_lib_handle();
         if(!*handle) {
             delete jit;
Index: harmony/working_vm/vm/vmcore/src/interpreter/interp_exports.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/interpreter/interp_exports.cpp	(revision
883577)
+++ harmony/working_vm/vm/vmcore/src/interpreter/interp_exports.cpp	(working
copy)
@@ -24,7 +24,7 @@
 #include "interpreter_exports.h"
 #include "cxxlog.h"

-char const * * opcodeNames = 0;
+//extern char const * * opcodeNames = 0;
 #define JVMTI_NYI 0

 static bool interp_enabled = false;
Index: harmony/working_vm/vm/vmcore/src/thread/verify_stack_enumeration.cpp
===================================================================
--- harmony/working_vm/vm/vmcore/src/thread/verify_stack_enumeration.cpp	(revision
883577)
+++ harmony/working_vm/vm/vmcore/src/thread/verify_stack_enumeration.cpp	(working
copy)
@@ -96,6 +96,11 @@

 void verify_stack_enumeration() {

+#if defined(USE_STATIC_GC) || defined(STATIC_BUILD)
+	// TJP THIS FUNCTION WILL NOT WORK WITH STATIC GC
+	assert (false);
+#else
+
     // XXX: workaround to avoid infinite recursion
     // due to suspend_enable() in vm_gc_lock_enum()
     verify_stack_enumeration_flag = false;
@@ -194,6 +199,7 @@
     // switch back to verification enabled
     // mode after releasing gc lock.
     verify_stack_enumeration_flag = true;
+#endif
 }

 // Let it be literate :)
Index: harmony/working_vm/vm/jitrino/src/vm/VMInterface.cpp
===================================================================
--- harmony/working_vm/vm/jitrino/src/vm/VMInterface.cpp	(revision 883577)
+++ harmony/working_vm/vm/jitrino/src/vm/VMInterface.cpp	(working copy)
@@ -22,7 +22,7 @@

 #include "mkernel.h"

-#define DYNAMIC_OPEN
+//#define DYNAMIC_OPEN
 #include "VMInterface.h"
 #include "open/vm_properties.h"
 #include "open/vm_class_manipulation.h"
@@ -46,11 +46,14 @@
 #include "PlatformDependant.h"

 #include "VMMagic.h"
+#include "open/hythread.h"
+#include "open/hythread_ext.h"

 namespace Jitrino {

 vm_adaptor_t VMInterface::vm = 0;

+#if defined(DYNAMIC_OPEN)

 static  allocation_handle_get_class_t  allocation_handle_get_class = 0;

@@ -433,8 +436,16 @@
         return NULL != vm(id);
     }

+#else

+IDATA vm_tls_alloc (hythread_tls_key_t * handle) {  return
hythread_tls_alloc(handle); }
+UDATA vm_tls_get_offset (hythread_tls_key_t key) { return
hythread_tls_get_offset(key); }
+UDATA vm_tls_get_request_offset () { return
hythread_tls_get_request_offset(); }
+UDATA vm_tls_is_fast () { return hythread_uses_fast_tls(); }
+IDATA vm_get_tls_offset_in_segment () { return
hythread_get_hythread_offset_in_tls(); }

+#endif
+
 // The JIT info block is laid out as:
 //    header
 //    stack info
Index: harmony/working_vm/make/vm/em.xml
===================================================================
--- harmony/working_vm/make/vm/em.xml	(revision 883577)
+++ harmony/working_vm/make/vm/em.xml	(working copy)
@@ -23,7 +23,7 @@

     <target name="build" depends="-common-vm">
         <init-native/>
-        <make-native libname="em" type="shared">
+        <make-native libname="em" type="static">
         <compiler id="cpp.compiler" extends="common.cpp.compiler">
             <includepath>
                 <dirset dir="${vm.home}">
@@ -36,6 +36,8 @@
                 <pathelement location="${drlvm.include.dir}" />
             </includepath>

+          <defineset define="APR_DECLARE_STATIC,STATIC_BUILD" />
+
             <fileset dir="${vm.home}/em/src">
                 <include name="*.cpp" />
             </fileset>
Index: harmony/working_vm/make/vm/gc_gen.xml
===================================================================
--- harmony/working_vm/make/vm/gc_gen.xml	(revision 883577)
+++ harmony/working_vm/make/vm/gc_gen.xml	(working copy)
@@ -114,7 +114,7 @@
         <compile-cc>
             <compiler refid="cpp.compiler"/>
         </compile-cc>
-        <link-lib name="gc_gen_uncomp" type="shared">
+        <link-lib name="gc_gen_uncomp" type="static">
             <linker refid="linker"/>
         </link-lib>
    </target>
@@ -127,7 +127,7 @@
             <compiler refid="cpp.compiler"/>
             <defineset define="COMPRESS_REFERENCE" />
         </compile-cc>
-        <link-lib name="gc_gen" type="shared">
+        <link-lib name="gc_gen" type="static">
             <linker refid="linker"/>
         </link-lib>
    </target>
Index: harmony/working_vm/make/vm/interpreter.xml
===================================================================
--- harmony/working_vm/make/vm/interpreter.xml	(revision 883577)
+++ harmony/working_vm/make/vm/interpreter.xml	(working copy)
@@ -78,7 +78,7 @@
         </compiler>
         </compile-cc>

-        <link-lib name="interpreter" type="shared">
+        <link-lib name="interpreter" type="static">
             <linker id="linker" extends="common.linker">
                 <linkerarg
value="--version-script=${vm.home}/interpreter/build/interpreter.exp"
if="is.unix"/>
                 <libset libs="harmonyvm,hythr" dir="${drlvm.shlib.dir}" />
Index: harmony/working_vm/make/vm/port.xml
===================================================================
--- harmony/working_vm/make/vm/port.xml	(revision 883577)
+++ harmony/working_vm/make/vm/port.xml	(working copy)
@@ -83,7 +83,7 @@
         <compile-cc>
             <includepath><path refid="port.includes"/></includepath>

-            <defineset define="APR_DECLARE_EXPORT" />
+            <defineset define="APR_DECLARE_STATIC" />
             <defineset define="BUILDING_VM" />

             <compiler id="c.compiler" extends="common.c.compiler">
Index: harmony/working_vm/make/vm/verifier.xml
===================================================================
--- harmony/working_vm/make/vm/verifier.xml	(revision 883577)
+++ harmony/working_vm/make/vm/verifier.xml	(working copy)
@@ -36,7 +36,7 @@
                     <include name="java6/*.cpp" />
                     <include name="x_verifier/*.cpp" if="cfg.is.debug" />
                 </fileset>
-	            <defineset define="BUILDING_VM" />
+	            <defineset define="STATIC_BUILD,BUILDING_VM" />
             </compiler>
         </make-native>
     </target>
Index: harmony/working_vm/make/vm/vmcore.xml
===================================================================
--- harmony/working_vm/make/vm/vmcore.xml	(revision 883577)
+++ harmony/working_vm/make/vm/vmcore.xml	(working copy)
@@ -211,11 +211,11 @@
             </fileset>

             <compilerarg value="/Qwd94" if="is.icl"/>
-            <defineset define="BUILDING_VM,APR_DECLARE_STATIC" />
+            <defineset define="BUILDING_VM,APR_DECLARE_STATIC,USE_GC_STATIC" />
         </compiler>
         </compile-cc>

-        <link-lib name="harmonyvm" type="shared">
+        <link-lib name="harmonyvm" type="static">
             <linker id="linker" extends="common.linker">
                 <libset libs="port,encoder,verifier,apr-1"
                     dir="${drlvm.lib.dir}" />
@@ -224,8 +224,8 @@
                 <libset libs="zdll" dir="${drlvm.lib.dir}" if="is.windows"/>
                 <libset libs="ch" dir="${drlvm.shlib.dir}" />

-                <linkerarg
value="/DEF:${vm.home}/vmcore/src/harmonyvm64.def"
if="is.windows.x86_64"/>
-                <linkerarg
value="/DEF:${vm.home}/vmcore/src/harmonyvm.def" if="is.windows.x86"/>
+<!--`                <linkerarg
value="/DEF:${vm.home}/vmcore/src/harmonyvm64.def"
if="is.windows.x86_64"/>
+                <linkerarg
value="/DEF:${vm.home}/vmcore/src/harmonyvm.def" if="is.windows.x86"/>
-->
                 <linkerarg
value="--version-script=${vm.home}/vmcore/build/vmcore.exp"
if="is.unix"/>

                 <syslibset type="shared"
libs="m,dl,stdc++,z,xml2,pthread,gcc_s,rt" if="is.linux"/>
Index: harmony/working_vm/make/vm/vmi.xml
===================================================================
--- harmony/working_vm/make/vm/vmi.xml	(revision 883577)
+++ harmony/working_vm/make/vm/vmi.xml	(working copy)
@@ -23,7 +23,7 @@

     <target name="build" depends="-common-vm">
         <init-native/>
-        <make-native libname="vmi" type="shared">
+        <make-native libname="vmi" type="static">
             <compiler id="cpp.compiler" extends="common.cpp.compiler">
                 <includepath>
                     <pathelement location="${drlvm.include.dir}" />
@@ -35,8 +35,9 @@
                     </dirset>
                     <pathelement location="${hy.hdk}/include" />
                 </includepath>
+              <defineset define="APR_DECLARE_STATIC,STATIC_BUILD" />

-                <fileset dir="${vm.home}/vmi/src" includes="*.cpp" />
+              <fileset dir="${vm.home}/vmi/src" includes="*.cpp" />
             </compiler>

             <linker id="linker" extends="common.linker">
Index: harmony/working_vm/make/vm/hythr.xml
===================================================================
--- harmony/working_vm/make/vm/hythr.xml	(revision 883577)
+++ harmony/working_vm/make/vm/hythr.xml	(working copy)
@@ -24,7 +24,7 @@
     <target name="build" depends="-common-vm">
         <init-native/>

-        <make-native libname="hythr" type="shared">
+        <make-native libname="hythr" type="static">
         <compiler id="c.compiler" extends="common.c.compiler">
             <includepath>
               <pathelement location="${drlvm.include.dir}" />
@@ -39,14 +39,14 @@
                 <include name="linux/*.c" if="is.unix"/>
             </fileset>

-            <defineset define="APR_DECLARE_STATIC" />
+            <defineset define="STATIC_BUILD,APR_DECLARE_STATIC" />
         </compiler>

         <linker id="linker" extends="common.linker">
             <libset libs="port,apr-1"
                     dir="${drlvm.lib.dir}" />

-            <linkerarg value="/DEF:${vm.home}/thread/src/hythr.def"
if="is.windows"/>
+<!--            <linkerarg
value="/DEF:${vm.home}/thread/src/hythr.def" if="is.windows"/> -->

             <syslibset type="shared" libs="stdc++,rt,pthread" if="is.linux"/>
             <syslibset type="shared" libs="stdc++,pthread" if="is.freebsd"/>
Index: harmony/working_vm/make/vm/jitrino.xml
===================================================================
--- harmony/working_vm/make/vm/jitrino.xml	(revision 883577)
+++ harmony/working_vm/make/vm/jitrino.xml	(working copy)
@@ -83,10 +83,10 @@
                 <defineset define="JIT_LOGS,JIT_STATS" if="is.cfg.debug" />
             </compiler>
         </compile-cc>
-        <link-lib name="jitrino" type="shared">
+        <link-lib name="jitrino" type="static">
             <linker id="jitrino.linker" extends="common.linker">
                 <libset libs="harmonyvm,encoder,hythr"
dir="${drlvm.lib.dir}" if="is.windows"/>
-                <linkerarg value="/OPT:REF" if="is.windows"/>
+<!--                <linkerarg value="/OPT:REF" if="is.windows"/> -->

                 <syslibset type="shared" libs="m" if="is.unix"/>
                 <syslibset type="shared" libs="dl" if="is.linux"/>
Index: harmony/working_vm/make/vm/port_ch.xml
===================================================================
--- harmony/working_vm/make/vm/port_ch.xml	(revision 883577)
+++ harmony/working_vm/make/vm/port_ch.xml	(working copy)
@@ -100,7 +100,7 @@
         <compile-cc>
             <includepath><path refid="ch.includes"/></includepath>

-            <defineset define="APR_DECLARE_EXPORT" />
+            <defineset define="APR_DECLARE_STATIC" />
             <defineset define="BUILDING_VM" />
             <defineset define="STRESS_MALLOC" />

@@ -122,7 +122,7 @@
             </compiler>
         </compile-cc>

-        <link-lib name="ch" type="shared">
+        <link-lib name="ch" type="static">
             <linker id="linker" extends="common.linker">
                 <libset libs="encoder" dir="${drlvm.lib.dir}" />

Index: harmony/working_vm/make/vm/encoder.xml
===================================================================
--- harmony/working_vm/make/vm/encoder.xml	(revision 883577)
+++ harmony/working_vm/make/vm/encoder.xml	(working copy)
@@ -36,6 +36,10 @@
             <compiler id="encoder.compiler" extends="common.cpp.compiler">
                 <!--defineset define="NO_EBCODER_INLINE" /-->
                 <fileset refid="encoder.src"/>
+
+              <defineset define="STATIC_BUILD" />
+              <defineset define="USE_GC_STATIC" />
+              <defineset define="APR_DECLARE_STATIC"/>
             </compiler>
         </make-native>
     </target>
Index: harmony/working_vm/make/build-native.xml
===================================================================
--- harmony/working_vm/make/build-native.xml	(revision 883577)
+++ harmony/working_vm/make/build-native.xml	(working copy)
@@ -140,6 +140,10 @@
                 <compilerarg value="/Fd${component.obj.dir}\" if="is.windows"/>
                 <compilerarg value="/Zi" if="is.windows"/>
                 <compilerarg value="-fpic" if="is.unix"/>
+
+                <defineset define="STATIC_BUILD" />
+                <defineset define="USE_GC_STATIC" />
+                <defineset define="APR_DECLARE_STATIC"/>
             </cc>
         </presetdef>

@@ -151,7 +155,7 @@
                 <condition property="component.need.pdb">
                     <and>
                         <isset property="is.windows"/>
-                        <equals arg1="@{type}" arg2="shared"/>
+                        <equals arg1="@{type}" arg2="static"/>
                     </and>
                 </condition>

Index: harmony/working_vm/make/extra/apr.xml
===================================================================
--- harmony/working_vm/make/extra/apr.xml	(revision 883577)
+++ harmony/working_vm/make/extra/apr.xml	(working copy)
@@ -133,7 +133,7 @@
                 <include name="poll/unix/select.c" />
             </fileset>

-            <defineset define="APR_DECLARE_EXPORT,WIN32,_WINDOWS" />
+            <defineset
define="STATIC_BUILD,APR_DECLARE_STATIC,WIN32,_WINDOWS" />
         </make-native>
     </target>






2009/12/1 Tony Wu <wu...@gmail.com>:
> I think we could think about creating Harmony Select profiles along
> with Milestone builds to help people like Tim to customize our JRE
> easiler.
> (A friend of mine I met on the Apache Asia Roadshow this year
> complained to me that Harmony is dev-oriented and not so
> user-friendly, which may block potential contributors and users :-( )
>
> On Mon, Nov 30, 2009 at 9:51 AM, Regis <xu...@gmail.com> wrote:
>> Tim Prepscius wrote:
>>>
>>> Thanks for all of the input.  I really appreciate it.
>>>
>>> I guess I'll post progress to this thread, so that if someone else
>>> wishes to do something similar, my successes and failures will be
>>> available as some kind of road map.
>>>
>>> If you see me doing something which is an incredibly stupid thing to
>>> do, if I only knew this other way which is simple and nice..  Let me
>>> know!
>>>
>>> Here is the current state of things.
>>>
>>> 1) I have gotten stuff.
>>>
>>> 1.5) the msvc solutions are not up to date.  oh well.
>>>
>>> 2) The full classlib doesn't fully build cause it needs atl* ... but
>>> I've read online, this is because of swing.. don't need swing.
>>> somehow not sure how to just tell it not to build this part
>>
>> try -Dexclude.module=swing,awt
>>
>>>
>>> 2.5) The vm, amazingly, builds. :-)
>>>
>>> 3) I've figured out the any xml build files enough to be able to
>>> change things to static libraries, and exclude the /OPT:REF options
>>> (which I don't want)
>>>
>>> 4) I've gotten the ICU lib, and have changed things to compile as
>>> static LIBs.. Except for that one dll, where the programmer *really*
>>> wanted to use makefiles.. ...   sigh.  And of course his makefile is
>>> non-standard as they all are.  So will take a while to figure out what
>>> to change.
>>>
>>> 4.5) I have zlib from the main game-project compiling as static lib
>>>
>>> 5) I've changed the JNIEXPORT define to not do the dllexport... I
>>> think I'll need to do this with all of the other libraries as well.
>>> Wish they all used some underlying REALLY_DO_DLLEXPORT define or
>>> something, but oh well.
>>>
>>> 6) I've created a msvc solution that includes all of the newly created
>>> static libs.  And a simple .cpp file which   calls the
>>> JNI_CreateJavaVM.  Amazingly things link, and run.  However, dieing on
>>> errors of course when it tries to load dll libraries.
>>>
>>> Next step seems to me to be modifying the dll loading function
>>> "process_properties_dlls" into a "process_properties_statics."  Don't
>>> know what will be necessary for this:
>>>
>>> ------------------------------------------------------------------
>>> I like to make batch files which can replicate work.. For an accurate
>>> record, and cause I need to eventually build lots of different places.
>>>
>>> Here they are:
>>> -------------------------------------------------------------------
>>> C:\source3>type setup.bat
>>> call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
>>> set ANT_HOME=C:\ant
>>> set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_17
>>> set PATH=%PATH%;%ANT_HOME%\bin;c:\cygwin\bin
>>> set ANT_OPTS=-Xms256m -Xmx512m
>>>
>>> rem
>>> ###############################################################################
>>>
>>> if exist %ANT_HOME%\lib\ecj-* goto ECJ_OK
>>> echo Things won't work without ECJ, get 3.4.2 from
>>> http://download.eclipse.org/eclipse/downloads/ and put it in
>>> %ANT_HOME%\lib
>>> goto END
>>> :ECJ_OK
>>>
>>> if exist %windir%\system32\msvcr71* goto MSVC71_OK
>>> echo Somehow, they really really want msvcr71.dll, msvcp71.dll, you
>>> can google and download it.. stick it in %windir%\system32
>>> goto END
>>> :MSVC71_OK
>>>
>>> rem
>>> #################################################################################
>>>
>>>
>>> :END
>>>
>>> C:\source3>type build1.bat
>>> call setup.bat
>>>
>>> svn co http://svn.apache.org/repos/asf/harmony/enhanced/trunk harmony
>>>
>>> cd harmony
>>> cmd /C ant populate-src
>>> cd ..
>>>
>>>
>>> C:\source3>type build2.bat
>>> cd harmony
>>> cd working_classlib
>>>
>>> cmd /C ant fetch-depends
>>> cmd /C ant
>>>
>>> cd ..
>>> cd ..
>>>
>>> C:\source3>type build3.bat
>>> cd harmony
>>> cd working_vm
>>>
>>> rmdir /s /q build\windows_x86_msvc_debug
>>> rmdir /s /q build\windows_x86_msvc_release
>>>
>>> cmd /C ant -Dexclude.module=swing
>>> cmd /C ant -Dexclude.module=swing -Dhy.cfg=release
>>>
>>> cd ..
>>> cd ..
>>>
>>> --------------------------------
>>>
>>> Diff of files as of now:
>>>
>>> Index: harmony/working_vm/vm/include/jni_types.h
>>> ===================================================================
>>> --- harmony/working_vm/vm/include/jni_types.h   (revision 883577)
>>> +++ harmony/working_vm/vm/include/jni_types.h   (working copy)
>>> @@ -49,8 +49,10 @@
>>>  */
>>>  #if defined (_WIN32) || defined (__WIN32__) || defined (WIN32)
>>>
>>> -#define JNIEXPORT __declspec(dllexport)
>>> -#define JNIIMPORT __declspec(dllimport)
>>> +//#define JNIEXPORT __declspec(dllexport)
>>> +//#define JNIIMPORT __declspec(dllimport)
>>> +#define JNIEXPORT
>>> +#define JNIIMPORT
>>>  #define JNICALL __stdcall
>>>
>>>  typedef signed __int64 jlong;
>>> Index: harmony/working_vm/vm/vmcore/src/init/vm_init.cpp
>>> ===================================================================
>>> --- harmony/working_vm/vm/vmcore/src/init/vm_init.cpp   (revision 883577)
>>> +++ harmony/working_vm/vm/vmcore/src/init/vm_init.cpp   (working copy)
>>> @@ -174,6 +174,11 @@
>>>  #define GC_DLL (vm_env->compress_references ? GC_DLL_COMP :
>>> GC_DLL_UNCOMP)
>>>  #endif
>>>
>>> +static jint process_properties_dlls_statics (Global_Env *vm_env)
>>> +{
>>> +    jint status;
>>> +       return status;
>>> +}
>>>
>>>  /**
>>>  * Loads DLLs.
>>> Index: harmony/working_vm/make/vm/em.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/em.xml   (revision 883577)
>>> +++ harmony/working_vm/make/vm/em.xml   (working copy)
>>> @@ -23,7 +23,7 @@
>>>
>>>     <target name="build" depends="-common-vm">
>>>         <init-native/>
>>> -        <make-native libname="em" type="shared">
>>> +        <make-native libname="em" type="static">
>>>         <compiler id="cpp.compiler" extends="common.cpp.compiler">
>>>             <includepath>
>>>                 <dirset dir="${vm.home}">
>>> Index: harmony/working_vm/make/vm/gc_gen.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/gc_gen.xml       (revision 883577)
>>> +++ harmony/working_vm/make/vm/gc_gen.xml       (working copy)
>>> @@ -114,7 +114,7 @@
>>>         <compile-cc>
>>>             <compiler refid="cpp.compiler"/>
>>>         </compile-cc>
>>> -        <link-lib name="gc_gen_uncomp" type="shared">
>>> +        <link-lib name="gc_gen_uncomp" type="static">
>>>             <linker refid="linker"/>
>>>         </link-lib>
>>>    </target>
>>> @@ -127,7 +127,7 @@
>>>             <compiler refid="cpp.compiler"/>
>>>             <defineset define="COMPRESS_REFERENCE" />
>>>         </compile-cc>
>>> -        <link-lib name="gc_gen" type="shared">
>>> +        <link-lib name="gc_gen" type="static">
>>>             <linker refid="linker"/>
>>>         </link-lib>
>>>    </target>
>>> Index: harmony/working_vm/make/vm/interpreter.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/interpreter.xml  (revision 883577)
>>> +++ harmony/working_vm/make/vm/interpreter.xml  (working copy)
>>> @@ -78,7 +78,7 @@
>>>         </compiler>
>>>         </compile-cc>
>>>
>>> -        <link-lib name="interpreter" type="shared">
>>> +        <link-lib name="interpreter" type="static">
>>>             <linker id="linker" extends="common.linker">
>>>                 <linkerarg
>>> value="--version-script=${vm.home}/interpreter/build/interpreter.exp"
>>> if="is.unix"/>
>>>                 <libset libs="harmonyvm,hythr" dir="${drlvm.shlib.dir}" />
>>> Index: harmony/working_vm/make/vm/vmcore.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/vmcore.xml       (revision 883577)
>>> +++ harmony/working_vm/make/vm/vmcore.xml       (working copy)
>>> @@ -215,7 +215,7 @@
>>>         </compiler>
>>>         </compile-cc>
>>>
>>> -        <link-lib name="harmonyvm" type="shared">
>>> +        <link-lib name="harmonyvm" type="static">
>>>             <linker id="linker" extends="common.linker">
>>>                 <libset libs="port,encoder,verifier,apr-1"
>>>                     dir="${drlvm.lib.dir}" />
>>> @@ -224,8 +224,8 @@
>>>                 <libset libs="zdll" dir="${drlvm.lib.dir}"
>>> if="is.windows"/>
>>>                 <libset libs="ch" dir="${drlvm.shlib.dir}" />
>>>
>>> -                <linkerarg
>>> value="/DEF:${vm.home}/vmcore/src/harmonyvm64.def"
>>> if="is.windows.x86_64"/>
>>> -                <linkerarg
>>> value="/DEF:${vm.home}/vmcore/src/harmonyvm.def" if="is.windows.x86"/>
>>> +<!--`                <linkerarg
>>> value="/DEF:${vm.home}/vmcore/src/harmonyvm64.def"
>>> if="is.windows.x86_64"/>
>>> +                <linkerarg
>>> value="/DEF:${vm.home}/vmcore/src/harmonyvm.def" if="is.windows.x86"/>
>>> -->
>>>                 <linkerarg
>>> value="--version-script=${vm.home}/vmcore/build/vmcore.exp"
>>> if="is.unix"/>
>>>
>>>                 <syslibset type="shared"
>>> libs="m,dl,stdc++,z,xml2,pthread,gcc_s,rt" if="is.linux"/>
>>> Index: harmony/working_vm/make/vm/vmi.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/vmi.xml  (revision 883577)
>>> +++ harmony/working_vm/make/vm/vmi.xml  (working copy)
>>> @@ -23,7 +23,7 @@
>>>
>>>     <target name="build" depends="-common-vm">
>>>         <init-native/>
>>> -        <make-native libname="vmi" type="shared">
>>> +        <make-native libname="vmi" type="static">
>>>             <compiler id="cpp.compiler" extends="common.cpp.compiler">
>>>                 <includepath>
>>>                     <pathelement location="${drlvm.include.dir}" />
>>> Index: harmony/working_vm/make/vm/hythr.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/hythr.xml        (revision 883577)
>>> +++ harmony/working_vm/make/vm/hythr.xml        (working copy)
>>> @@ -24,7 +24,7 @@
>>>     <target name="build" depends="-common-vm">
>>>         <init-native/>
>>>
>>> -        <make-native libname="hythr" type="shared">
>>> +        <make-native libname="hythr" type="static">
>>>         <compiler id="c.compiler" extends="common.c.compiler">
>>>             <includepath>
>>>               <pathelement location="${drlvm.include.dir}" />
>>> @@ -46,7 +46,7 @@
>>>             <libset libs="port,apr-1"
>>>                     dir="${drlvm.lib.dir}" />
>>>
>>> -            <linkerarg value="/DEF:${vm.home}/thread/src/hythr.def"
>>> if="is.windows"/>
>>> +<!--            <linkerarg
>>> value="/DEF:${vm.home}/thread/src/hythr.def" if="is.windows"/> -->
>>>
>>>             <syslibset type="shared" libs="stdc++,rt,pthread"
>>> if="is.linux"/>
>>>             <syslibset type="shared" libs="stdc++,pthread"
>>> if="is.freebsd"/>
>>> Index: harmony/working_vm/make/vm/jitrino.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/jitrino.xml      (revision 883577)
>>> +++ harmony/working_vm/make/vm/jitrino.xml      (working copy)
>>> @@ -83,10 +83,10 @@
>>>                 <defineset define="JIT_LOGS,JIT_STATS" if="is.cfg.debug"
>>> />
>>>             </compiler>
>>>         </compile-cc>
>>> -        <link-lib name="jitrino" type="shared">
>>> +        <link-lib name="jitrino" type="static">
>>>             <linker id="jitrino.linker" extends="common.linker">
>>>                 <libset libs="harmonyvm,encoder,hythr"
>>> dir="${drlvm.lib.dir}" if="is.windows"/>
>>> -                <linkerarg value="/OPT:REF" if="is.windows"/>
>>> +<!--                <linkerarg value="/OPT:REF" if="is.windows"/> -->
>>>
>>>                 <syslibset type="shared" libs="m" if="is.unix"/>
>>>                 <syslibset type="shared" libs="dl" if="is.linux"/>
>>> Index: harmony/working_vm/make/vm/port_ch.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/vm/port_ch.xml      (revision 883577)
>>> +++ harmony/working_vm/make/vm/port_ch.xml      (working copy)
>>> @@ -122,7 +122,7 @@
>>>             </compiler>
>>>         </compile-cc>
>>>
>>> -        <link-lib name="ch" type="shared">
>>> +        <link-lib name="ch" type="static">
>>>             <linker id="linker" extends="common.linker">
>>>                 <libset libs="encoder" dir="${drlvm.lib.dir}" />
>>>
>>> Index: harmony/working_vm/make/build-native.xml
>>> ===================================================================
>>> --- harmony/working_vm/make/build-native.xml    (revision 883577)
>>> +++ harmony/working_vm/make/build-native.xml    (working copy)
>>> @@ -151,7 +151,7 @@
>>>                 <condition property="component.need.pdb">
>>>                     <and>
>>>                         <isset property="is.windows"/>
>>> -                        <equals arg1="@{type}" arg2="shared"/>
>>> +                        <equals arg1="@{type}" arg2="static"/>
>>>                     </and>
>>>                 </condition>
>>>
>>>
>>> On 11/22/09, Alexei Fedotov <al...@gmail.com> wrote:
>>>>
>>>> Tim,
>>>> As for your willingness to create a lib, VM is a lib already [1], an
>>>> is successfully used in browser plug-ins.
>>>>
>>>> [1] http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/invocation.html
>>>>
>>>> On Mon, Nov 23, 2009 at 11:54 AM, Xiao-Feng Li <xi...@gmail.com>
>>>> wrote:
>>>>>
>>>>> To reduce Harmony VM (DRLVM) is possible - and not very difficult. JIT
>>>>> and GC are modules that you can easily replace with very simple ones.
>>>>> Other modules can be largely reduced as well if you do not need them,
>>>>> e.g., threading, verifier, profiler, etc. I don't know your
>>>>> performance target, but my personal preference usually is to keep a
>>>>> simple JIT for the execution engine rather than the interpreter.
>>>>>
>>>>> Thanks,
>>>>> xiaofeng
>>>>>
>>>>> On Mon, Nov 23, 2009 at 10:52 AM, Tim Prepscius <ti...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Greetings,
>>>>>>
>>>>>> I have been searching for a non-gpl replacement for sun's java for
>>>>>> quite a while now.  I can't believe I didn't see your project until
>>>>>> this month.  Let me tell you, when I saw your code I almost cried.
>>>>>> (haha, well, maybe not cried)
>>>>>>
>>>>>> It's really, really nice.  And I have not run yet into a hundred line
>>>>>> #define (as in "dalvik") yet.
>>>>>> Anyhow.
>>>>>>
>>>>>>
>>>>>> This is what I'd like to do.  I'm wondering whether anyone would
>>>>>> comment on accomplishing this, if it is possible.
>>>>>> Who knows, maybe somebody else has fiddled around with this.
>>>>>>
>>>>>> What I'm looking for:
>>>>>>
>>>>>> 1.  I'm really not looking for java.  I'm looking for a
>>>>>> micro-edition-ish java to embed in a video game engine.
>>>>>>
>>>>>> 2.  Don't need JIT, don't need two garbage collectors - 1 will do,
>>>>>> don't need the JVM to be accessible to the outside world. Don't need
>>>>>> almost *all* of the class libraries.  Don't need sockets (except for
>>>>>> debugging).  Don't actually need threads (I disable their creation via
>>>>>> the security manager anyway), but I suppose this is necessary for GC &
>>>>>> Debug.
>>>>>>
>>>>>> 3. Need JNI, which I see you have.
>>>>>>
>>>>>> So what I'm thinking I'd like to do:
>>>>>>
>>>>>>
>>>>>> Optimally I'd like to create a lib out of harmony-vm.  Statically link
>>>>>> with my application.  Create a single jar with all of my necessary
>>>>>> classes, cutting out all of the java extra stuff (everything pretty
>>>>>> much)
>>>>>>
>>>>>> If creating a lib creates problems for JNI (what problems I don't
>>>>>> know), I'd like to combine all of your dlls into one massive dll.
>>>>>> Then I was thinking, that after getting this done, I'd start cutting
>>>>>> out modules.  And try to reduce everything to under 1 meg.
>>>>>>
>>>>>> --
>>>>>>
>>>>>> Is this crazy?
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> -tim
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> http://people.apache.org/~xli
>>>>>
>>>>
>>>>
>>>> --
>>>> With best regards / с наилучшими пожеланиями,
>>>> Alexei Fedotov / Алексей Федотов,
>>>> http://www.telecom-express.ru/
>>>> http://harmony.apache.org/
>>>> http://www.expressaas.com/
>>>> http://openmeetings.googlecode.com/
>>>>
>>>
>>
>>
>> --
>> Best Regards,
>> Regis.
>>
>
>
>
> --
> Tony Wu
> China Software Development Lab, IBM
>