verify.cc (branch_prepass): Updated for change to exception handler type.

* verify.cc (branch_prepass): Updated for change to exception
	handler type.
	(verify_instructions_0): Likewise.
	* defineclass.cc (handleCodeAttribute): Initialize `prepared'.
	(handleExceptionTableEntry): Updated for change to exception
	handler type.
	* java/lang/Class.h (Class): Removed _Jv_InterpMethodInvocation.
	* include/java-interp.h (_Jv_InterpMethodInvocation): Removed.
	(union _Jv_InterpPC): New.
	(class _Jv_InterpException): Changed types to _Jv_InterpPC.
	(class _Jv_InterpMethod): Added new `prepared' field.
	(class _Jv_InterpMethod): Added `compile' method.  Removed
	`continue1' and `find_exception'.  Changed arguments to `run'.
	* interpret.cc (union insn_slot): New.
	(find_exception): Removed.
	(run_normal): Removed most logic.
	(run_synch_object): Likewise; also, use JvSynchronize.
	(run_synch_class): Likewise.
	(run): Removed.
	(continue1): Renamed as `run'.  Compile bytecode if required.
	Add new code to allow refinement of direct-threaded code at
	runtime.  Handle exceptions.
	(SAVE_PC): Removed.
	(compile): New method.
	(SET_ONE, SET_INSN, SET_INT, SET_DATUM): New defines.
	(NULLARRAYCHECK): Don't use SAVE_PC.
	(pc_t): New typedef.
	(TAKE_GOTO, GET1S, GET1U, GET2U, AVAL1U, AVAL2U, AVAL2UP,
	SKIP_GOTO, GOTO_VAL, PCVAL, AMPAMP): New macros.

From-SVN: r54968
This commit is contained in:
Tom Tromey 2002-06-24 20:38:47 +00:00 committed by Tom Tromey
parent 7691fc06fe
commit fdae83abe7
6 changed files with 1517 additions and 708 deletions

View File

@ -1,3 +1,35 @@
2002-06-24 Tom Tromey <tromey@redhat.com>
* verify.cc (branch_prepass): Updated for change to exception
handler type.
(verify_instructions_0): Likewise.
* defineclass.cc (handleCodeAttribute): Initialize `prepared'.
(handleExceptionTableEntry): Updated for change to exception
handler type.
* java/lang/Class.h (Class): Removed _Jv_InterpMethodInvocation.
* include/java-interp.h (_Jv_InterpMethodInvocation): Removed.
(union _Jv_InterpPC): New.
(class _Jv_InterpException): Changed types to _Jv_InterpPC.
(class _Jv_InterpMethod): Added new `prepared' field.
(class _Jv_InterpMethod): Added `compile' method. Removed
`continue1' and `find_exception'. Changed arguments to `run'.
* interpret.cc (union insn_slot): New.
(find_exception): Removed.
(run_normal): Removed most logic.
(run_synch_object): Likewise; also, use JvSynchronize.
(run_synch_class): Likewise.
(run): Removed.
(continue1): Renamed as `run'. Compile bytecode if required.
Add new code to allow refinement of direct-threaded code at
runtime. Handle exceptions.
(SAVE_PC): Removed.
(compile): New method.
(SET_ONE, SET_INSN, SET_INT, SET_DATUM): New defines.
(NULLARRAYCHECK): Don't use SAVE_PC.
(pc_t): New typedef.
(TAKE_GOTO, GET1S, GET1U, GET2U, AVAL1U, AVAL2U, AVAL2UP,
SKIP_GOTO, GOTO_VAL, PCVAL, AMPAMP): New macros.
2002-06-23 Tom Tromey <tromey@redhat.com>
* configure: Rebuilt.

View File

@ -1258,6 +1258,7 @@ void _Jv_ClassReader::handleCodeAttribute
method->exc_count = exc_table_length;
method->defining_class = def;
method->self = &def->methods[method_index];
method->prepared = NULL;
// grab the byte code!
memcpy ((void*) method->bytecode (),
@ -1267,7 +1268,7 @@ void _Jv_ClassReader::handleCodeAttribute
def->interpreted_methods[method_index] = method;
}
void _Jv_ClassReader::handleExceptionTableEntry
void _Jv_ClassReader::handleExceptionTableEntry
(int method_index, int exc_index,
int start_pc, int end_pc, int handler_pc, int catch_type)
{
@ -1275,10 +1276,10 @@ void _Jv_ClassReader::handleExceptionTableEntry
(def->interpreted_methods[method_index]);
_Jv_InterpException *exc = method->exceptions ();
exc[exc_index].start_pc = start_pc;
exc[exc_index].end_pc = end_pc;
exc[exc_index].handler_pc = handler_pc;
exc[exc_index].handler_type = catch_type;
exc[exc_index].start_pc.i = start_pc;
exc[exc_index].end_pc.i = end_pc;
exc[exc_index].handler_pc.i = handler_pc;
exc[exc_index].handler_type.i = catch_type;
}
void _Jv_ClassReader::handleMethodsEnd ()

View File

@ -1,6 +1,6 @@
// java-interp.h - Header file for the bytecode interpreter. -*- c++ -*-
/* Copyright (C) 1999, 2000, 2001 Free Software Foundation
/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj.
@ -49,14 +49,22 @@ void _Jv_VerifyMethod (_Jv_InterpMethod *method);
class _Jv_InterpClass;
class _Jv_InterpMethod;
class _Jv_InterpMethodInvocation;
// Before a method is "compiled" we store values as the bytecode PC,
// an int. Afterwards we store them as pointers into the prepared
// code itself.
union _Jv_InterpPC
{
int i;
void *p;
};
class _Jv_InterpException
{
int start_pc;
int end_pc;
int handler_pc;
int handler_type;
_Jv_InterpPC start_pc;
_Jv_InterpPC end_pc;
_Jv_InterpPC handler_pc;
_Jv_InterpPC handler_type;
friend class _Jv_ClassReader;
friend class _Jv_InterpMethod;
@ -92,6 +100,8 @@ class _Jv_InterpMethod : public _Jv_MethodBase
_Jv_ushort exc_count;
void *prepared;
unsigned char* bytecode ()
{
return
@ -99,7 +109,7 @@ class _Jv_InterpMethod : public _Jv_MethodBase
+ ROUND((sizeof (_Jv_InterpMethod)
+ exc_count*sizeof (_Jv_InterpException)), 4);
}
_Jv_InterpException * exceptions ()
{
return (_Jv_InterpException*) (this+1);
@ -115,40 +125,23 @@ class _Jv_InterpMethod : public _Jv_MethodBase
// return the method's invocation pointer (a stub).
void *ncode ();
void continue1 (_Jv_InterpMethodInvocation *inv);
void compile (const void * const *);
static void run_normal (ffi_cif*, void*, ffi_raw*, void*);
static void run_synch_object (ffi_cif*, void*, ffi_raw*, void*);
static void run_synch_class (ffi_cif*, void*, ffi_raw*, void*);
inline jobject run (ffi_cif*, void*, ffi_raw*,
_Jv_InterpMethodInvocation*);
bool find_exception (jobject ex,
_Jv_InterpMethodInvocation *inv);
void run (void*, ffi_raw *);
public:
static void dump_object(jobject o);
friend class _Jv_ClassReader;
friend class _Jv_InterpMethodInvocation;
friend class _Jv_BytecodeVerifier;
friend void _Jv_PrepareClass(jclass);
};
class _Jv_InterpMethodInvocation {
_Jv_InterpMethod *running;
_Jv_word *sp;
unsigned char *pc;
_Jv_word state[0];
_Jv_word* stack_base () { return &state[0]; }
_Jv_word* local_base () { return &state[running->max_stack]; }
friend class _Jv_InterpMethod;
};
class _Jv_InterpClass : public java::lang::Class
{
_Jv_MethodBase **interpreted_methods;

File diff suppressed because it is too large Load Diff

View File

@ -338,7 +338,6 @@ private:
friend class _Jv_ClassReader;
friend class _Jv_InterpClass;
friend class _Jv_InterpMethod;
friend class _Jv_InterpMethodInvocation;
#endif
#ifdef JV_MARKOBJ_DECL

View File

@ -1882,18 +1882,18 @@ private:
// Verify exception handlers.
for (int i = 0; i < current_method->exc_count; ++i)
{
if (! (flags[exception[i].handler_pc] & FLAG_INSN_START))
if (! (flags[exception[i].handler_pc.i] & FLAG_INSN_START))
verify_fail ("exception handler not at instruction start",
exception[i].handler_pc);
if (! (flags[exception[i].start_pc] & FLAG_INSN_START))
exception[i].handler_pc.i);
if (! (flags[exception[i].start_pc.i] & FLAG_INSN_START))
verify_fail ("exception start not at instruction start",
exception[i].start_pc);
if (exception[i].end_pc != current_method->code_length
&& ! (flags[exception[i].end_pc] & FLAG_INSN_START))
exception[i].start_pc.i);
if (exception[i].end_pc.i != current_method->code_length
&& ! (flags[exception[i].end_pc.i] & FLAG_INSN_START))
verify_fail ("exception end not at instruction start",
exception[i].end_pc);
exception[i].end_pc.i);
flags[exception[i].handler_pc] |= FLAG_BRANCH_TARGET;
flags[exception[i].handler_pc.i] |= FLAG_BRANCH_TARGET;
}
}
@ -2186,12 +2186,12 @@ private:
// through them all.
for (int i = 0; i < current_method->exc_count; ++i)
{
if (PC >= exception[i].start_pc && PC < exception[i].end_pc)
if (PC >= exception[i].start_pc.i && PC < exception[i].end_pc.i)
{
type handler (&java::lang::Throwable::class$);
if (exception[i].handler_type != 0)
handler = check_class_constant (exception[i].handler_type);
push_exception_jump (handler, exception[i].handler_pc);
if (exception[i].handler_type.i != 0)
handler = check_class_constant (exception[i].handler_type.i);
push_exception_jump (handler, exception[i].handler_pc.i);
}
}