Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

exit.c File Reference


Detailed Description

Abort strategy functions for the JVM.

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.

Control

$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.

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.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

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).
rcharexit_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
rcharexit_LinkageError_subclass
jvm_thread_index exit_LinkageError_thridx


Define Documentation

#define I_AM_EXIT_C
 

Permit localized usage of EXIT_xxx symbols.

Definition at line 92 of file exit.c.


Function Documentation

static void exit_c_dummy void   )  [static]
 

Definition at line 80 of file exit.c.

rchar* exit_get_name exit_code_enum  code  ) 
 

Return a descriptive name string for each exit code.

Parameters:
code Exit code enumeration
Returns:
Null-terminated string describing the exit code.

Definition at line 105 of file exit.c.

References EXIT_ARGV_COPYRIGHT, EXIT_ARGV_COPYRIGHT_DESC, EXIT_ARGV_ENVIRONMENT, EXIT_ARGV_ENVIRONMENT_DESC, EXIT_ARGV_HELP, EXIT_ARGV_HELP_DESC, EXIT_ARGV_LICENSE, EXIT_ARGV_LICENSE_DESC, EXIT_ARGV_VERSION, EXIT_ARGV_VERSION_DESC, EXIT_CLASSPATH_JAR, EXIT_CLASSPATH_JAR_DESC, EXIT_GC_ALLOC, EXIT_GC_ALLOC_DESC, EXIT_HEAP_ALLOC, EXIT_HEAP_ALLOC_DESC, EXIT_JVM_ATTRIBUTE, EXIT_JVM_ATTRIBUTE_DESC, EXIT_JVM_BYTECODE, EXIT_JVM_BYTECODE_DESC, EXIT_JVM_CLASS, EXIT_JVM_CLASS_DESC, EXIT_JVM_FIELD, EXIT_JVM_FIELD_DESC, EXIT_JVM_GC, EXIT_JVM_GC_DESC, EXIT_JVM_INTERNAL, EXIT_JVM_INTERNAL_DESC, EXIT_JVM_METHOD, EXIT_JVM_METHOD_DESC, EXIT_JVM_OBJECT, EXIT_JVM_OBJECT_DESC, EXIT_JVM_SIGNAL, EXIT_JVM_SIGNAL_DESC, EXIT_JVM_THREAD, EXIT_JVM_THREAD_DESC, EXIT_JVM_THROWABLE, EXIT_JVM_THROWABLE_DESC, EXIT_LONGJMP_ARGERROR, EXIT_LONGJMP_ARGERROR_DESC, EXIT_MAIN_OKAY, EXIT_MAIN_OKAY_DESC, EXIT_MANIFEST_JAR, EXIT_MANIFEST_JAR_DESC, EXIT_THREAD_STACK, EXIT_THREAD_STACK_DESC, EXIT_TIMESLICE_START, EXIT_TIMESLICE_START_DESC, EXIT_TMPAREA_MKDIR, EXIT_TMPAREA_MKDIR_DESC, EXIT_TMPAREA_RMDIR, and EXIT_TMPAREA_RMDIR_DESC.

Referenced by opcode_load_run_throwable().

int exit_init  ) 
 

Global handler setup for fatal JVM errors-- implements setjmp(3).

Parameters: rvoid

Returns:
From normal setup, integer EXIT_MAIN_OKAY. Otherwise, return error code from exit_jvm(), typically using a code found in exit.h

Definition at line 184 of file exit.c.

References exit_general_failure.

int exit_exception_setup rvoid   ) 
 

Global handler setup for fatal jvm_init() errors and other java.lang.Throwable events-- implements setjmp(3).

Use this function to arm handler for throwing java.lang.Error and java.lang.Exception throwable events.

Parameters: rvoid

Returns:
From normal setup, integer EXIT_MAIN_OKAY. Otherwise, return exit code enumeration from exit_jvm().

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().

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).

Use this function to throw java.lang.Error and java.lang.Exception throwable events.

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.

Parameters:
rcenum Return code to pass back out of failed routine, which must be an exit code enumeration other than EXIT_MAIN_OKAY, which will get translated into EXIT_LONGJMP_ARGERROR.
preason Error class, which must be a subclass of java.lang.LinkageError , namely:

Returns:
non-local state restoration from setup via setjmp(3) as stored in exit_LinkageError buffer by exit_init() in jvm_init() before any of these errors could occur. All code invoking this function should use the standard lint(1) comment for "code not reached" as shown after the longjmp(3) function call in the source code of this function: /*NOTREACHED*/
< Access structures of the thread now running in the JVM.

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().

rvoid exit_jvm exit_code_enum  rcenum  ) 
 

Global handler invocation for fatal JVM errors-- implements longjmp(3).

Parameters:
rcenum Return code to pass back out of JVM.
Returns:
non-local state restoration from setup via setjmp(3) above as stored in exit_general_failure. All code invoking this function should use the standard lint(1) comment for "code not reached" as shown after the longjmp(3) function call in the source code of this function: /*NOTREACHED*/

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().


Variable Documentation

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]
 

Definition at line 80 of file exit.c.

jmp_buf exit_general_failure [static]
 

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().

jmp_buf exit_LinkageError [static]
 

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().

rchar* exit_LinkageError_subclass
 

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().

jvm_thread_index exit_LinkageError_thridx
 

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().


Generated on Fri Sep 30 19:00:05 2005 by  doxygen 1.4.4