This implementation uses two invocations of setjmp(3)/longjmp(3
) to perform non-local returns from error conditions.
Normal exit conditions are more likely to use a simple return() instead
of the error mechanism, but are not inhibited from it except that returning the normal EXIT_MAIN_OKAY cannot occur due to the design of longjmp(3),
which will force EXIT_LONGJMP_ARGERROR instead.
exit_init() must be invoked at a higher level than where pjvm is used to access anything, namely, pjvm->xxx since
the main JVM structure cannot be initialized at the same time it is being protected by a jmp_buf hook stored within it. It typically will be armed at the very entry to the JVM and will never be re-armed since it is global in its scope of coverage.
exit_exception_setup() has similar requirements. However, since it is involved more closely with jvm_init(), it is typically invoked at the beginning of that function. Once initialization proceeds and more and more facilities become available, it should be re-armed to a new handler to reflect increased capability. Once the virtual execution engine is ready, it should be re-armed to manually run JVMCLASS_JAVA_LANG_LINKAGEERROR subclasses through the virtual execution engine before shutting down the JVM.
exit_end_thread_setup() is not so much an error handler as a simplification of the JVM inner loop execution in opcode_run() that eliminates the need for two of the tests needed for continuing to run Java virtual instruction on this thread. It is invoked only once, and that before the inner look while statement
. When a member of the Java return instruction group is executed, then if the thread termination conditions have been met, the longjmp(3) exits
the loop non-locally.
Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
Definition in file exit.c.
#include "arch.h"
#include <setjmp.h>
#include "jvmcfg.h"
#include "classfile.h"
#include "jvm.h"
#include "exit.h"
Go to the source code of this file.
Defines | |
#define | I_AM_EXIT_C |
Permit localized usage of EXIT_xxx symbols. | |
Functions | |
static void | exit_c_dummy (void) |
int | exit_exception_setup (rvoid) |
Global handler setup for fatal jvm_init() errors and other java.lang.Throwable events-- implements setjmp(3). | |
rchar * | exit_get_name (exit_code_enum code) |
Return a descriptive name string for each exit code. | |
int | exit_init () |
Global handler setup for fatal JVM errors-- implements setjmp(3). | |
rvoid | exit_jvm (exit_code_enum rcenum) |
Global handler invocation for fatal JVM errors-- implements longjmp(3). | |
rvoid | exit_throw_exception (exit_code_enum rcenum, rchar *preason) |
Global handler for initialization linkage errors, per spec section 2.17.x -- implements longjmp(3). | |
Variables | |
static char * | exit_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/exit.c $ $Id: exit.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." |
static jmp_buf | exit_general_failure |
static jmp_buf | exit_LinkageError |
rchar * | exit_LinkageError_subclass |
jvm_thread_index | exit_LinkageError_thridx |
|
Permit localized usage of EXIT_xxx symbols.
|
|
|
|
|
Global handler setup for fatal JVM errors-- implements Parameters: rvoid
Definition at line 184 of file exit.c. References exit_general_failure. |
|
Global handler setup for fatal jvm_init() errors and other
Use this function to arm handler for throwing Parameters: rvoid
Definition at line 215 of file exit.c. References exit_LinkageError, exit_LinkageError_subclass, exit_LinkageError_thridx, jvm_thread_index_null, and rnull. Referenced by opcode_load_run_throwable(). |
|
Global handler for initialization linkage errors, per spec section 2.17.x -- implements
Use this function to throw This is a global handler invocation first for jvm_init() during startup and then runtime events. A wide variety of runtime conditions may be expressed in the combination of rc and preason. Judicious combinations of exit codes and error classes will greatly limit the need for expanding on the number of values for either parameter, yet can express many different nuances of errors.
Definition at line 287 of file exit.c. References CURRENT_THREAD, exit_LinkageError, exit_LinkageError_subclass, and exit_LinkageError_thridx. Referenced by class_allocate_slot(), class_load_primative(), field_find_by_cp_entry(), heap_get_common_simple_bimodal(), linkage_resolve_class(), method_find_by_cp_entry(), native_run_local_return_jdouble(), native_run_local_return_jfloat(), native_run_local_return_jint(), native_run_local_return_jlong(), native_run_local_return_jobject(), native_run_local_return_jvoid(), native_run_method(), native_verify_ordinal_definition(), object_allocate_slot(), object_run_method(), opcode_run(), thread_exception_setup(), thread_new(), and thread_state_get_name(). |
|
Global handler invocation for fatal JVM errors-- implements
Definition at line 321 of file exit.c. Referenced by argv_init(), heap_init_bimodal(), jvm_manual_thread_run(), manifest_get_main(), object_run_method(), opcode_load_run_throwable(), opcode_run(), timeslice_init(), and timeslice_run(). |
|
|
|
Handler linkage for fatal errors. Does not need global visibility, just needs file scope. Definition at line 144 of file exit.c. Referenced by exit_init(). |
|
Handler linkage for LinkageError. Does not need global visibility, just needs file scope. Definition at line 151 of file exit.c. Referenced by exit_exception_setup(), and exit_throw_exception(). |
|
Class to run on non-local return. Give global visibility for use by users of exit_throw_exception(). Definition at line 159 of file exit.c. Referenced by exit_exception_setup(), exit_throw_exception(), and opcode_load_run_throwable(). |
|
Thread where error occurred. Give global visibility for use by users of exit_throw_exception(). Definition at line 167 of file exit.c. Referenced by exit_exception_setup(), and exit_throw_exception(). |