main2: main.c
make sure no compiler optimizes this away.
If executable is a JAR, use the JAR launcher, i.e. set exec = "kaffe.jar.ExecJar".
Find the class which we want to execute ((*env)->FindClass
= Kaffe_FindClass). See if any error occurs (handleErrors).
Get the method ID of "main" ((*env)->GetStaticMethodID
= Kaffe_GetStaticMethodID). See if any error occurs (handleErrors).
Find the string class, i.e. java/lang/String ((*env)->FindClass
= Kaffe_FindClass). See if any error occurs (handleErrors).
Build an array of the string class ((*env)->NewObjectArray
= Kaffe_NewObjectArray). See if any error occurs (handleErrors).
Convert each arguments to Utf8 string ((*env)->NewStringUTF). Put them
into the string array ((*env)->SetObjectArrayElement). See if any error
occurs (handleErrors).
Call the "main" method ((*env)->CallStaticVoidMethod
= Kaffe_CallStaticVoidMethod), check for errors (handleErrors) and
then exit.
Stop the current thread from running and terminate it ((*vm)->DetachCurrentThread
= Kaffe_DetachCurrentThread).
Kaffe_FindClass: jni.c
Start exception handling system (BEGIN_EXCEPTION_HANDLING), since exception
might be thrown during the class finding.
Convert a class name to a path name (classname2pathname).
If array, look up class from array (lookupArray(getClassFromSignature(&buf[1],
NULL)), else look up the class by name (lookupClass).
Terminate the exception handling system (END_EXCEPTION_HANDLING).
Kaffe_GetStaticMethodID: jni.c
Start exception handling system (BEGIN_EXCEPTION_HANDLING), since exception
might be thrown here.
Look up class method (lookupClassMethod).
If not found or non-static, throw an exception.
Terminate the exception handling system (END_EXCEPTION_HANDLING).
Kaffe_NewObjectArray: jni.c
Start exception handling system (BEGIN_EXCEPTION_HANDLING), since exception
might be thrown nere.
Allocate a new array with given class and given size (newArray). Initialise
each element.
Add JNI reference count (ADD_REF).
Terminate the exception handling system (END_EXCEPTION_HANDLING).
Kaffe_CallStaticVoidMethod: jni.c
Start exception handling system (BEGIN_EXCEPTION_HANDLING), since exception
might be thrown nere.
Set up passing arguments
Call Kaffe_CallStaticVoidMethodV.
Terminate the exception handling system (END_EXCEPTION_HANDLING).
Kaffe_CallStaticVoidMethodV:
jni.c
Make sure the given method is static, or throw an exception.
Call callMethodV.
Kaffe_DetachCurrentThread: jni.c
Stop the current thread (Stopthread).
sysdepCallMethod: definition depends on
specific platforms.
Make a call to a native or Java (JIT) method, in this case.
Generally, it will manage the passed arguments, and make the call.
Fot JIT, if the first time executing the Java method, it also need to translate
the Java method into native code (Translate) and
cached in memory before calling the method.
Translate: jit/machine.c
Translate a method into native code.
virtualMachine: intrp/machine.c
VM -- interpreter.
If this is native, then call the real function (callMethodA).
Verify method if required (verifyMethod). Then, tidy up (tidyVerifyMethod)
after verfication data has been finished.
Allocate stack space and locals.
If we have any exception handlers we must prepare to catch them. We also
need to catch if we are synchronised, so we can release it.
Calculate number of arguments and copy in the arguments.
Sync. if required (lockMutex = _lockMutex).
Finally we get to actually execute the machine, which is implemented as
switch-case loop with Kaffe instruction definitions defined in 'kaffe.def'
and the macro 'define_insn(code)' defined in 'intrp/machine.c'.
Unsync. if required.