aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2001-08-09 15:33:35 -0700
committerRichard Henderson <rth@gcc.gnu.org>2001-08-09 15:33:35 -0700
commit2cc07db4b089b8b3df05261f1d7acbc96d2e720a (patch)
treeddb2d5519f49bc33648c25225b8b8ba84df590b9 /gcc/java
parentef8d8b8922a034dfac5cff9d5fa781dc57c49ed0 (diff)
downloadgcc-2cc07db4b089b8b3df05261f1d7acbc96d2e720a.zip
gcc-2cc07db4b089b8b3df05261f1d7acbc96d2e720a.tar.gz
gcc-2cc07db4b089b8b3df05261f1d7acbc96d2e720a.tar.bz2
Move constructor/destructor handling into target hooks.
From-SVN: r44747
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog6
-rw-r--r--gcc/java/Make-lang.in2
-rw-r--r--gcc/java/class.c36
3 files changed, 31 insertions, 13 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 7734a5f..7924574 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-09 Richard Henderson <rth@redhat.com>
+
+ * Make-lang.in (class.o): Depend on TARGET_H.
+ * class.c (emit_register_classes): Use target hooks instead of
+ assemble_constructor and assemble_destructor.
+
2001-08-08 Alexandre Petit-Bianco <apbianco@redhat.com>
* check-init.c (flags.h): Include
diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index 5768225..d0ae26c 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -245,7 +245,7 @@ java/buffer.o: java/buffer.c $(CONFIG_H) java/buffer.h $(SYSTEM_H) toplev.h
java/check-init.o: java/check-init.c $(CONFIG_H) \
$(JAVA_TREE_H) $(SYSTEM_H) toplev.h
java/class.o: java/class.c $(CONFIG_H) $(JAVA_TREE_H) $(RTL_H) java/jcf.h \
- java/parse.h toplev.h $(SYSTEM_H) output.h $(GGC_H)
+ java/parse.h toplev.h $(SYSTEM_H) output.h $(GGC_H) $(TARGET_H) function.h
java/constants.o: java/constants.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \
toplev.h $(SYSTEM_H) $(GGC_H)
java/decl.o: java/decl.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \
diff --git a/gcc/java/class.c b/gcc/java/class.c
index 7e153b5..0e46a78 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -36,6 +36,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "toplev.h"
#include "output.h"
#include "parse.h"
+#include "function.h"
#include "ggc.h"
#include "target.h"
@@ -1881,6 +1882,9 @@ register_class ()
void
emit_register_classes ()
{
+ /* ??? This isn't quite the correct test. We also have to know
+ that the target is using gcc's crtbegin/crtend objects rather
+ than the ones that come with the operating system. */
if (SUPPORTS_WEAK && targetm.have_named_sections)
{
tree t;
@@ -1902,29 +1906,37 @@ emit_register_classes ()
SET_DECL_ASSEMBLER_NAME (init_decl, init_name);
TREE_STATIC (init_decl) = 1;
current_function_decl = init_decl;
- DECL_RESULT (init_decl) = build_decl(RESULT_DECL, NULL_TREE, void_type_node);
- /* DECL_EXTERNAL (init_decl) = 1;*/
- TREE_PUBLIC (init_decl) = 1;
+ DECL_RESULT (init_decl) = build_decl (RESULT_DECL, NULL_TREE,
+ void_type_node);
+
+ /* It can be a static function as long as collect2 does not have
+ to scan the object file to find its ctor/dtor routine. */
+ TREE_PUBLIC (init_decl) = ! targetm.have_ctors_dtors;
+
+ /* Suppress spurious warnings. */
+ TREE_USED (init_decl) = 1;
+
pushlevel (0);
make_decl_rtl (init_decl, NULL);
init_function_start (init_decl, input_filename, 0);
expand_function_start (init_decl, 0);
-
+
+ /* Do not allow the function to be deferred. */
+ current_function_cannot_inline
+ = "static constructors and destructors cannot be inlined";
+
for ( t = registered_class; t; t = TREE_CHAIN (t))
emit_library_call (registerClass_libfunc, 0, VOIDmode, 1,
XEXP (DECL_RTL (t), 0), Pmode);
expand_function_end (input_filename, 0, 0);
poplevel (1, 0, 1);
- {
- /* Force generation, even with -O3 or deeper. Gross hack. FIXME */
- int saved_flag = flag_inline_functions;
- flag_inline_functions = 0;
- rest_of_compilation (init_decl);
- flag_inline_functions = saved_flag;
- }
+ rest_of_compilation (init_decl);
current_function_decl = NULL_TREE;
- assemble_constructor (XEXP (DECL_RTL (init_decl), 0), DEFAULT_INIT_PRIORITY);
+
+ if (targetm.have_ctors_dtors)
+ (* targetm.asm_out.constructor) (XEXP (DECL_RTL (init_decl), 0),
+ DEFAULT_INIT_PRIORITY);
}
}