summaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-28 11:04:51 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-28 11:04:51 +0000
commitdf4b504cae7856b864a073ab9e6e61cf2ad23a97 (patch)
treea923c8785a06871784c5177530130063c4925f5a /gcc/java
parentd3ab49408bd5b876d10076caea78dc81a5f85dd7 (diff)
downloadgcc-df4b504cae7856b864a073ab9e6e61cf2ad23a97.tar.gz
IA-64 ABI Exception Handling.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40924 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog31
-rw-r--r--gcc/java/Make-lang.in2
-rw-r--r--gcc/java/check-init.c1
-rw-r--r--gcc/java/decl.c24
-rw-r--r--gcc/java/except.c66
-rw-r--r--gcc/java/expr.c12
-rw-r--r--gcc/java/java-tree.h4
-rw-r--r--gcc/java/jcf-write.c8
-rw-r--r--gcc/java/parse.h8
-rw-r--r--gcc/java/parse.y15
10 files changed, 82 insertions, 89 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 8ccb4b29d03..48dc795d4d5 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,5 +1,36 @@
2001-03-28 Richard Henderson <rth@redhat.com>
+ IA-64 ABI Exception Handling:
+ * Make-lang.in (except.o): Don't depend on eh-common.h.
+ * check-init.c (check_init): Handle EXC_PTR_EXPR.
+ * decl.c (init_decl_processing) [throw_node]: No _Jv_Sjlj_Throw.
+ [soft_exceptioninfo_call_node]: Remove.
+ [eh_personality_libfunc, lang_eh_runtime_type]: New.
+ (end_java_method): No emit_handlers.
+ * except.c (java_set_exception_lang_code): Remove.
+ (method_init_exceptions): Don't call it.
+ (prepare_eh_table_type): No CATCH_ALL_TYPE.
+ (build_exception_object_ref): New.
+ (expand_end_java_handler): Update for except.h name changes.
+ (emit_handlers, expand_resume_after_catch): Remove.
+ * expr.c (java_lang_expand_expr): Update for except.h name changes.
+ (process_jvm_instruction): Use build_exception_object_ref.
+ * java-tree.h (JTI_SOFT_EXCEPTIONINFO_CALL_NODE): Remove.
+ (soft_exceptioninfo_call_node): Remove.
+ (build_exception_object_ref): Declare.
+ * jcf-write.c (generate_bytecode_insns) [CALL_EXPR]: No
+ soft_exceptioninfo_call_node. Move processing ...
+ [EXC_PTR_EXPR]: ... here.
+ * parse.h (BUILD_ASSIGN_EXCEPTION_INFO): Remove dead code.
+ * parse.y (catch_clause_parameter): Use build_exception_object_ref.
+ (source_end_java_method): No java_set_exception_lang_code or
+ emit_handlers.
+ (build_dot_class_method): Use build_exception_object_ref.
+ (try_reference_assignconv): Check EXC_PTR_EXPR not
+ soft_exceptioninfo_call_node.
+
+2001-03-28 Richard Henderson <rth@redhat.com>
+
* java-tree.h (throw_node): Define as a single member of
java_global_trees instead of a separate array.
(JTI_THROW_NODE): New.
diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index a4f5e481307..ebfbd73896d 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -254,7 +254,7 @@ java/decl.o: java/decl.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \
toplev.h $(SYSTEM_H) function.h gcc.h
java/except.o: java/except.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \
$(RTL_H) java/javaop.h java/java-opcodes.h except.h java/java-except.h \
- eh-common.h toplev.h $(SYSTEM_H) function.h
+ toplev.h $(SYSTEM_H) function.h
java/expr.o: java/expr.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \
$(RTL_H) $(EXPR_H) java/javaop.h java/java-opcodes.h except.h \
java/java-except.h java/java-except.h java/parse.h toplev.h \
diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c
index 74144020afb..c34822084ec 100644
--- a/gcc/java/check-init.c
+++ b/gcc/java/check-init.c
@@ -681,6 +681,7 @@ check_init (exp, before)
case INTEGER_CST:
case REAL_CST:
case STRING_CST:
+ case EXC_PTR_EXPR:
break;
case NEW_CLASS_EXPR:
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index c0b67b22d7c..7d03f8a4f3e 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -29,12 +29,14 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "config.h"
#include "system.h"
#include "tree.h"
+#include "rtl.h"
#include "toplev.h"
#include "flags.h"
#include "java-tree.h"
#include "jcf.h"
#include "toplev.h"
#include "function.h"
+#include "expr.h"
#include "except.h"
#include "java-except.h"
#include "ggc.h"
@@ -725,13 +727,14 @@ init_decl_processing ()
t),
0, NOT_BUILT_IN,
NULL_PTR);
- throw_node = builtin_function ((USING_SJLJ_EXCEPTIONS
- ? "_Jv_Throw" : "_Jv_Sjlj_Throw"),
+
+ throw_node = builtin_function ("_Jv_Throw",
build_function_type (ptr_type_node, t),
0, NOT_BUILT_IN, NULL_PTR);
/* Mark throw_nodes as `noreturn' functions with side effects. */
TREE_THIS_VOLATILE (throw_node) = 1;
TREE_SIDE_EFFECTS (throw_node) = 1;
+
t = build_function_type (int_type_node, endlink);
soft_monitorenter_node
= builtin_function ("_Jv_MonitorEnter", t, 0, NOT_BUILT_IN,
@@ -834,15 +837,6 @@ init_decl_processing ()
build_function_type (double_type_node, t),
BUILT_IN_FMOD, BUILT_IN_NORMAL, "fmod");
- soft_exceptioninfo_call_node
- = build (CALL_EXPR,
- ptr_type_node,
- build_address_of
- (builtin_function ("_Jv_exception_info",
- build_function_type (ptr_type_node, endlink),
- 0, NOT_BUILT_IN, NULL_PTR)),
- NULL_TREE, NULL_TREE);
- TREE_SIDE_EFFECTS (soft_exceptioninfo_call_node) = 1;
#if 0
t = tree_cons (NULL_TREE, float_type_node,
tree_cons (NULL_TREE, float_type_node, endlink));
@@ -872,6 +866,12 @@ init_decl_processing ()
build_function_type (long_type_node, t),
0, NOT_BUILT_IN, NULL_PTR);
+ /* Initialize variables for except.c. */
+ eh_personality_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS
+ ? "__gcj_personality_sj0"
+ : "__gcj_personality_v0");
+ lang_eh_runtime_type = prepare_eh_table_type;
+
init_jcf_parse ();
/* Register nodes with the garbage collector. */
@@ -1828,8 +1828,6 @@ end_java_method ()
BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
- emit_handlers ();
-
/* Generate rtl for function exit. */
expand_function_end (input_filename, lineno, 0);
diff --git a/gcc/java/except.c b/gcc/java/except.c
index f14d9437871..184f7e5a88b 100644
--- a/gcc/java/except.c
+++ b/gcc/java/except.c
@@ -34,7 +34,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "function.h"
#include "except.h"
#include "java-except.h"
-#include "eh-common.h"
#include "toplev.h"
static void expand_start_java_handler PARAMS ((struct eh_range *));
@@ -250,14 +249,6 @@ method_init_exceptions ()
whole_range.first_child = NULL;
whole_range.next_sibling = NULL;
cache_range_start = 0xFFFFFF;
- java_set_exception_lang_code ();
-}
-
-void
-java_set_exception_lang_code ()
-{
- set_exception_lang_code (EH_LANG_Java);
- set_exception_version_code (1);
}
/* Add an exception range. If we already have an exception range
@@ -339,7 +330,7 @@ prepare_eh_table_type (type)
* (which yields a value with low-order bit 1). */
if (type == NULL_TREE)
- exp = CATCH_ALL_TYPE;
+ exp = NULL_TREE;
else if (is_compiled_class (type))
exp = build_class_ref (type);
else
@@ -350,7 +341,27 @@ prepare_eh_table_type (type)
return exp;
}
-/* if there are any handlers for this range, isssue end of range,
+
+/* Build a reference to the jthrowable object being carried in the
+ exception header. */
+
+tree
+build_exception_object_ref (type)
+ tree type;
+{
+ tree obj;
+
+ /* Java only passes object via pointer and doesn't require adjusting.
+ The java object is immediately before the generic exception header. */
+ obj = build (EXC_PTR_EXPR, build_pointer_type (type));
+ obj = build (MINUS_EXPR, TREE_TYPE (obj), obj,
+ TYPE_SIZE_UNIT (TREE_TYPE (obj)));
+ obj = build1 (INDIRECT_REF, type, obj);
+
+ return obj;
+}
+
+/* If there are any handlers for this range, isssue end of range,
and then all handler blocks */
static void
expand_end_java_handler (range)
@@ -361,11 +372,9 @@ expand_end_java_handler (range)
expand_start_all_catch ();
for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler))
{
- start_catch_handler (prepare_eh_table_type (TREE_PURPOSE (handler)));
- /* Push the thrown object on the top of the stack */
+ expand_start_catch (TREE_PURPOSE (handler));
expand_goto (TREE_VALUE (handler));
- expand_resume_after_catch ();
- end_catch_handler ();
+ expand_end_catch ();
}
expand_end_all_catch ();
#if defined(DEBUG_JAVA_BINDING_LEVELS)
@@ -432,30 +441,3 @@ maybe_end_try (start_pc, end_pc)
current_range = current_range->outer;
}
}
-
-/* Emit the handler labels and their code */
-
-void
-emit_handlers ()
-{
- if (catch_clauses)
- {
- rtx funcend = gen_label_rtx ();
- emit_jump (funcend);
-
- emit_insns (catch_clauses);
- catch_clauses = catch_clauses_last = NULL_RTX;
- expand_leftover_cleanups ();
-
- emit_label (funcend);
- }
-}
-
-/* Resume executing at the statement immediately after the end of an
- exception region. */
-
-void
-expand_resume_after_catch ()
-{
- expand_goto (top_label_entry (&caught_return_label_stack));
-}
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 42c43aad536..072be6dea94 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -2502,15 +2502,13 @@ java_lang_expand_expr (exp, target, tmode, modifier)
for (current = TREE_OPERAND (exp, 1); current;
current = TREE_CHAIN (current))
{
- tree type;
tree catch = TREE_OPERAND (current, 0);
tree decl = BLOCK_EXPR_DECLS (catch);
- type = (decl ? TREE_TYPE (TREE_TYPE (decl)) : NULL_TREE);
- start_catch_handler (prepare_eh_table_type (type));
- expand_expr_stmt (TREE_OPERAND (current, 0));
+ tree type = (decl ? TREE_TYPE (TREE_TYPE (decl)) : NULL_TREE);
- expand_resume_after_catch ();
- end_catch_handler ();
+ expand_start_catch (type);
+ expand_expr_stmt (TREE_OPERAND (current, 0));
+ expand_end_catch ();
}
expand_end_all_catch ();
return const0_rtx;
@@ -2812,7 +2810,7 @@ process_jvm_instruction (PC, byte_ops, length)
if (instruction_bits [PC] & BCODE_EXCEPTION_TARGET)
{
tree type = pop_type (ptr_type_node);
- push_value (build1 (NOP_EXPR, type, soft_exceptioninfo_call_node));
+ push_value (build_exception_object_ref (type));
}
switch (byte_ops[PC++])
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 01a0722d39b..598caf4a46a 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -339,7 +339,6 @@ enum java_tree_index
JTI_SOFT_GETJNIENVNEWFRAME_NODE,
JTI_SOFT_JNIPOPSYSTEMFRAME_NODE,
JTI_SOFT_FMOD_NODE,
- JTI_SOFT_EXCEPTIONINFO_CALL_NODE,
JTI_SOFT_IDIV_NODE,
JTI_SOFT_IREM_NODE,
JTI_SOFT_LDIV_NODE,
@@ -581,8 +580,6 @@ extern tree java_global_trees[JTI_MAX];
java_global_trees[JTI_SOFT_JNIPOPSYSTEMFRAME_NODE]
#define soft_fmod_node \
java_global_trees[JTI_SOFT_FMOD_NODE]
-#define soft_exceptioninfo_call_node \
- java_global_trees[JTI_SOFT_EXCEPTIONINFO_CALL_NODE]
#define soft_idiv_node \
java_global_trees[JTI_SOFT_IDIV_NODE]
#define soft_irem_node \
@@ -1026,6 +1023,7 @@ extern tree build_instanceof PARAMS ((tree, tree));
extern tree create_label_decl PARAMS ((tree));
extern void push_labeled_block PARAMS ((tree));
extern tree prepare_eh_table_type PARAMS ((tree));
+extern tree build_exception_object_ref PARAMS ((tree));
extern void java_set_exception_lang_code PARAMS ((void));
extern tree generate_name PARAMS ((void));
extern void pop_labeled_block PARAMS ((void));
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c
index b84c86ebde2..79ac6916679 100644
--- a/gcc/java/jcf-write.c
+++ b/gcc/java/jcf-write.c
@@ -2451,6 +2451,9 @@ generate_bytecode_insns (exp, target, state)
}
}
break;
+ case EXC_PTR_EXPR:
+ NOTE_PUSH (1); /* Pushed by exception system. */
+ break;
case NEW_CLASS_EXPR:
{
tree class = TREE_TYPE (TREE_TYPE (exp));
@@ -2527,11 +2530,6 @@ generate_bytecode_insns (exp, target, state)
NOTE_POP (1);
break;
}
- else if (exp == soft_exceptioninfo_call_node)
- {
- NOTE_PUSH (1); /* Pushed by exception system. */
- break;
- }
for ( ; x != NULL_TREE; x = TREE_CHAIN (x))
{
generate_bytecode_insns (TREE_VALUE (x), STACK_TARGET, state);
diff --git a/gcc/java/parse.h b/gcc/java/parse.h
index 9ca55d4aa47..d17dbc0d1cb 100644
--- a/gcc/java/parse.h
+++ b/gcc/java/parse.h
@@ -661,14 +661,6 @@ typedef struct _jdeplist {
build_new_invocation (wfl_string_buffer, \
(ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
-/* For exception handling, build diverse function calls */
-#define BUILD_ASSIGN_EXCEPTION_INFO(WHERE, TO) \
- { \
- (WHERE) = build (MODIFY_EXPR, void_type_node, (TO), \
- soft_exceptioninfo_call_node); \
- TREE_SIDE_EFFECTS (WHERE) = 1; \
- }
-
#define BUILD_THROW(WHERE, WHAT) \
{ \
(WHERE) = \
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index e09af7a8ebd..d377e8fe59d 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -1885,9 +1885,9 @@ catch_clause_parameter:
declared initialized by the appropriate function
call */
tree ccpb = enter_block ();
- tree init = build_assignment (ASSIGN_TK, $2.location,
- TREE_PURPOSE ($3),
- soft_exceptioninfo_call_node);
+ tree init = build_assignment
+ (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
+ build_exception_object_ref (ptr_type_node));
declare_local_variables (0, TREE_VALUE ($3),
build_tree_list (TREE_PURPOSE ($3),
init));
@@ -7124,9 +7124,6 @@ source_end_java_method ()
java_parser_context_save_global ();
lineno = ctxp->last_ccb_indent1;
- /* Set EH language codes */
- java_set_exception_lang_code ();
-
/* Turn function bodies with only a NOP expr null, so they don't get
generated at all and we won't get warnings when using the -W
-Wall flags. */
@@ -7148,8 +7145,6 @@ source_end_java_method ()
if (! flag_emit_class_files && ! flag_emit_xref)
{
lineno = DECL_SOURCE_LINE_LAST (fndecl);
- /* Emit catch-finally clauses */
- emit_handlers ();
expand_function_end (input_filename, lineno, 0);
/* Run the optimizers and output assembler code for this function. */
@@ -8405,7 +8400,7 @@ build_dot_class_method (class)
/* We initialize the variable with the exception handler. */
catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
- soft_exceptioninfo_call_node);
+ build_exception_object_ref (ptr_type_node));
add_stmt_to_block (catch_block, NULL_TREE, catch);
/* We add the statement throwing the new exception */
@@ -12609,7 +12604,7 @@ try_reference_assignconv (lhs_type, rhs)
else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
new_rhs = rhs;
/* This is a magic assignment that we process differently */
- else if (rhs == soft_exceptioninfo_call_node)
+ else if (TREE_CODE (rhs) == EXC_PTR_EXPR)
new_rhs = rhs;
}
return new_rhs;