1 /* Java(TM) language-specific utility routines.
2 Copyright (C) 1996-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>.
20 Java and all Java-based marks are trademarks or registered trademarks
21 of Sun Microsystems, Inc. in the United States and other countries.
22 The Free Software Foundation is independent of Sun Microsystems, Inc. */
24 /* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */
28 #include "coretypes.h"
33 #include "double-int.h"
41 #include "java-tree.h"
43 #include "langhooks.h"
44 #include "langhooks-def.h"
47 #include "diagnostic.h"
48 #include "tree-inline.h"
49 #include "splay-tree.h"
50 #include "tree-dump.h"
56 static bool java_init (void);
57 static void java_finish (void);
58 static unsigned int java_option_lang_mask (void);
59 static void java_init_options_struct (struct gcc_options
*);
60 static void java_init_options (unsigned int, struct cl_decoded_option
*);
61 static bool java_post_options (const char **);
63 static bool java_handle_option (size_t, const char *, int, int, location_t
,
64 const struct cl_option_handlers
*);
65 static void put_decl_string (const char *, int);
66 static void put_decl_node (tree
, int);
67 static void java_print_error_function (diagnostic_context
*, const char *,
69 static bool java_dump_tree (void *, tree
);
70 static void dump_compound_expr (dump_info_p
, tree
);
71 static bool java_decl_ok_for_sibcall (const_tree
);
73 static enum classify_record
java_classify_record (tree type
);
75 static tree
java_eh_personality (void);
77 #ifndef TARGET_OBJECT_SUFFIX
78 # define TARGET_OBJECT_SUFFIX ".o"
81 /* Table of machine-independent attributes. */
82 const struct attribute_spec java_attribute_table
[] =
84 { "nonnull", 0, -1, false, true, true,
86 { NULL
, 0, 0, false, false, false, NULL
, false }
89 /* Used to avoid printing error messages with bogus function
90 prototypes. Starts out false. */
91 static bool inhibit_error_function_printing
;
93 const char *resource_name
;
95 /* When nonzero, -Wall was turned on. */
98 /* When nonzero, report use of deprecated classes, methods, or fields. */
99 int flag_deprecated
= 1;
101 /* When zero, don't optimize static class initialization. This flag shouldn't
102 be tested alone, use STATIC_CLASS_INITIALIZATION_OPTIMIZATION_P instead. */
103 /* FIXME: Make this work with gimplify. */
104 /* int flag_optimize_sci = 0; */
106 /* Don't attempt to verify invocations. */
107 int flag_verify_invocations
= 0;
109 /* When nonzero, print extra version information. */
110 static int v_flag
= 0;
114 /* Variable controlling how dependency tracking is enabled in
116 static int dependency_tracking
= 0;
118 /* Flag values for DEPENDENCY_TRACKING. */
119 #define DEPEND_SET_FILE 1
120 #define DEPEND_ENABLE 2
121 #define DEPEND_TARGET_SET 4
122 #define DEPEND_FILE_ALREADY_SET 8
124 struct GTY(()) language_function
{
128 #undef LANG_HOOKS_NAME
129 #define LANG_HOOKS_NAME "GNU Java"
130 #undef LANG_HOOKS_INIT
131 #define LANG_HOOKS_INIT java_init
132 #undef LANG_HOOKS_FINISH
133 #define LANG_HOOKS_FINISH java_finish
134 #undef LANG_HOOKS_OPTION_LANG_MASK
135 #define LANG_HOOKS_OPTION_LANG_MASK java_option_lang_mask
136 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
137 #define LANG_HOOKS_INIT_OPTIONS_STRUCT java_init_options_struct
138 #undef LANG_HOOKS_INIT_OPTIONS
139 #define LANG_HOOKS_INIT_OPTIONS java_init_options
140 #undef LANG_HOOKS_HANDLE_OPTION
141 #define LANG_HOOKS_HANDLE_OPTION java_handle_option
142 #undef LANG_HOOKS_POST_OPTIONS
143 #define LANG_HOOKS_POST_OPTIONS java_post_options
144 #undef LANG_HOOKS_PARSE_FILE
145 #define LANG_HOOKS_PARSE_FILE java_parse_file
146 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
147 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl
148 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
149 #define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name
150 #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
151 #define LANG_HOOKS_PRINT_ERROR_FUNCTION java_print_error_function
152 #undef LANG_HOOKS_WRITE_GLOBALS
153 #define LANG_HOOKS_WRITE_GLOBALS java_write_globals
155 #undef LANG_HOOKS_TYPE_FOR_MODE
156 #define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode
157 #undef LANG_HOOKS_TYPE_FOR_SIZE
158 #define LANG_HOOKS_TYPE_FOR_SIZE java_type_for_size
159 #undef LANG_HOOKS_CLASSIFY_RECORD
160 #define LANG_HOOKS_CLASSIFY_RECORD java_classify_record
162 #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
163 #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
165 #undef LANG_HOOKS_GIMPLIFY_EXPR
166 #define LANG_HOOKS_GIMPLIFY_EXPR java_gimplify_expr
168 #undef LANG_HOOKS_DECL_OK_FOR_SIBCALL
169 #define LANG_HOOKS_DECL_OK_FOR_SIBCALL java_decl_ok_for_sibcall
171 #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
172 #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME java_mangle_decl
174 #undef LANG_HOOKS_ATTRIBUTE_TABLE
175 #define LANG_HOOKS_ATTRIBUTE_TABLE java_attribute_table
177 #undef LANG_HOOKS_EH_PERSONALITY
178 #define LANG_HOOKS_EH_PERSONALITY java_eh_personality
180 #undef LANG_HOOKS_EH_USE_CXA_END_CLEANUP
181 #define LANG_HOOKS_EH_USE_CXA_END_CLEANUP true
183 /* Each front end provides its own. */
184 struct lang_hooks lang_hooks
= LANG_HOOKS_INITIALIZER
;
187 * process java-specific compiler command-line options
188 * return false, but do not complain if the option is not recognized.
191 java_handle_option (size_t scode
, const char *arg
, int value
,
192 int kind ATTRIBUTE_UNUSED
, location_t loc ATTRIBUTE_UNUSED
,
193 const struct cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
195 enum opt_code code
= (enum opt_code
) scode
;
200 jcf_path_include_arg (arg
);
204 jcf_dependency_init (1);
205 dependency_tracking
|= DEPEND_ENABLE
;
209 jcf_dependency_init (1);
210 dependency_tracking
|= DEPEND_SET_FILE
| DEPEND_ENABLE
;
214 jcf_dependency_set_dep_file (arg
);
215 dependency_tracking
|= DEPEND_FILE_ALREADY_SET
;
219 jcf_dependency_init (0);
220 dependency_tracking
|= DEPEND_ENABLE
;
224 jcf_dependency_init (0);
225 dependency_tracking
|= DEPEND_SET_FILE
| DEPEND_ENABLE
;
229 jcf_dependency_print_dummies ();
233 jcf_dependency_set_target (arg
);
234 dependency_tracking
|= DEPEND_TARGET_SET
;
239 /* When -Wall given, enable -Wunused. We do this because the C
240 compiler does it, and people expect it. */
244 case OPT_fenable_assertions_
:
245 add_enable_assert (arg
, value
);
248 case OPT_fenable_assertions
:
249 add_enable_assert ("", value
);
252 case OPT_fdisable_assertions_
:
253 add_enable_assert (arg
, !value
);
256 case OPT_fdisable_assertions
:
257 add_enable_assert ("", !value
);
260 case OPT_fassume_compiled_
:
261 add_assume_compiled (arg
, !value
);
264 case OPT_fassume_compiled
:
265 add_assume_compiled ("", !value
);
268 case OPT_fbootclasspath_
:
269 jcf_path_bootclasspath_arg (arg
);
272 case OPT_faux_classpath
:
273 case OPT_fclasspath_
:
274 jcf_path_classpath_arg (arg
);
277 case OPT_fcompile_resource_
:
282 if (!g
->get_dumps ()->dump_switch_p (arg
))
291 jcf_path_extdirs_arg (arg
);
294 case OPT_foutput_class_dir_
:
295 /* FIXME: remove; this is handled by ecj1 now. */
302 case OPT_fsource_filename_
:
303 java_read_sourcefilenames (arg
);
307 if (cl_options
[code
].flags
& CL_Java
)
315 /* Global open file. */
321 /* FIXME: Indirect dispatch isn't yet compatible with static class
322 init optimization. */
323 if (flag_indirect_dispatch
)
324 always_initialize_class_p
= true;
326 if (!flag_indirect_dispatch
)
327 flag_indirect_classes
= false;
329 jcf_path_seal (v_flag
);
331 java_init_decl_processing ();
333 using_eh_for_cleanups ();
341 jcf_dependency_write ();
344 /* Buffer used by lang_printable_name. */
345 static char *decl_buf
= NULL
;
347 /* Allocated size of decl_buf. */
348 static int decl_buflen
= 0;
350 /* Length of used part of decl_buf; position for next character. */
351 static int decl_bufpos
= 0;
353 /* Append the string STR to decl_buf.
354 It length is given by LEN; -1 means the string is nul-terminated. */
357 put_decl_string (const char *str
, int len
)
361 if (decl_bufpos
+ len
>= decl_buflen
)
363 if (decl_buf
== NULL
)
365 decl_buflen
= len
+ 100;
366 decl_buf
= XNEWVEC (char, decl_buflen
);
371 decl_buf
= XRESIZEVAR (char, decl_buf
, decl_buflen
);
374 strcpy (decl_buf
+ decl_bufpos
, str
);
378 /* Append to decl_buf a printable name for NODE.
379 Depending on VERBOSITY, more information about NODE
380 is printed. Read the comments of decl_printable_name in
381 langhooks.h for more. */
384 put_decl_node (tree node
, int verbosity
)
387 if (TREE_CODE (node
) == POINTER_TYPE
)
389 node
= TREE_TYPE (node
);
392 if (DECL_P (node
) && DECL_NAME (node
) != NULL_TREE
)
394 if (TREE_CODE (node
) == FUNCTION_DECL
)
396 if (verbosity
== 0 && DECL_NAME (node
))
397 /* We have been instructed to just print the bare name
400 put_decl_node (DECL_NAME (node
), 0);
404 /* We want to print the type the DECL belongs to. We don't do
405 that when we handle constructors. */
406 if (! DECL_CONSTRUCTOR_P (node
)
407 && ! DECL_ARTIFICIAL (node
) && DECL_CONTEXT (node
)
408 /* We want to print qualified DECL names only
409 if verbosity is higher than 1. */
412 put_decl_node (TREE_CODE (DECL_CONTEXT (node
)) == FUNCTION_DECL
413 ? DECL_CONTEXT (node
)
414 : TYPE_NAME (DECL_CONTEXT (node
)),
416 put_decl_string (".", 1);
418 if (! DECL_CONSTRUCTOR_P (node
))
419 put_decl_node (DECL_NAME (node
), verbosity
);
420 if (TREE_TYPE (node
) != NULL_TREE
421 /* We want to print function parameters only if verbosity
426 tree args
= TYPE_ARG_TYPES (TREE_TYPE (node
));
427 if (TREE_CODE (TREE_TYPE (node
)) == METHOD_TYPE
)
428 args
= TREE_CHAIN (args
);
429 put_decl_string ("(", 1);
430 for ( ; args
!= NULL_TREE
&& args
!= end_params_node
;
431 args
= TREE_CHAIN (args
), i
++)
434 put_decl_string (",", 1);
435 put_decl_node (TREE_VALUE (args
), verbosity
);
437 put_decl_string (")", 1);
441 put_decl_node (DECL_NAME (node
), verbosity
);
443 else if (TYPE_P (node
) && TYPE_NAME (node
) != NULL_TREE
)
445 if (TREE_CODE (node
) == RECORD_TYPE
&& TYPE_ARRAY_P (node
)
446 /* Print detailed array information only if verbosity is higher
450 put_decl_node (TYPE_ARRAY_ELEMENT (node
), verbosity
);
451 put_decl_string("[]", 2);
453 else if (node
== promoted_byte_type_node
)
454 put_decl_string ("byte", 4);
455 else if (node
== promoted_short_type_node
)
456 put_decl_string ("short", 5);
457 else if (node
== promoted_char_type_node
)
458 put_decl_string ("char", 4);
459 else if (node
== promoted_boolean_type_node
)
460 put_decl_string ("boolean", 7);
461 else if (node
== void_type_node
&& was_pointer
)
462 put_decl_string ("null", 4);
464 put_decl_node (TYPE_NAME (node
), verbosity
);
466 else if (TREE_CODE (node
) == IDENTIFIER_NODE
)
467 put_decl_string (IDENTIFIER_POINTER (node
), IDENTIFIER_LENGTH (node
));
469 put_decl_string ("<unknown>", -1);
472 /* Return a user-friendly name for DECL.
473 The resulting string is only valid until the next call.
474 The value of the hook decl_printable_name is this function,
475 which is also called directly by java_print_error_function. */
478 lang_printable_name (tree decl
, int v
)
481 put_decl_node (decl
, v
);
482 put_decl_string ("", 1);
486 /* Print on stderr the current class and method context. This function
487 is the value of the hook print_error_function. */
489 static GTY(()) tree last_error_function_context
;
490 static GTY(()) tree last_error_function
;
492 java_print_error_function (diagnostic_context
*context ATTRIBUTE_UNUSED
,
494 diagnostic_info
*diagnostic ATTRIBUTE_UNUSED
)
496 /* Don't print error messages with bogus function prototypes. */
497 if (inhibit_error_function_printing
)
500 if (current_function_decl
!= NULL
501 && DECL_CONTEXT (current_function_decl
) != NULL
502 && DECL_CONTEXT (current_function_decl
) != last_error_function_context
)
505 fprintf (stderr
, "%s: ", file
);
507 last_error_function_context
= DECL_CONTEXT (current_function_decl
);
508 fprintf (stderr
, "In class '%s':\n",
509 lang_printable_name (last_error_function_context
, 0));
511 if (last_error_function
!= current_function_decl
)
514 fprintf (stderr
, "%s: ", file
);
516 if (current_function_decl
== NULL
)
517 fprintf (stderr
, "At top level:\n");
520 const char *name
= lang_printable_name (current_function_decl
, 2);
521 fprintf (stderr
, "In %s '%s':\n",
522 (DECL_CONSTRUCTOR_P (current_function_decl
) ? "constructor"
527 last_error_function
= current_function_decl
;
532 /* Called to install the PRINT_ERROR_FUNCTION hook differently
533 according to LEVEL. LEVEL is 1 during early parsing, when function
534 prototypes aren't fully resolved. java_print_error_function is set
535 so it doesn't print incomplete function prototypes. When LEVEL is
536 2, function prototypes are fully resolved and can be printed when
540 lang_init_source (int level
)
542 inhibit_error_function_printing
= (level
== 1);
546 java_option_lang_mask (void)
551 /* Initialize options structure OPTS. */
554 java_init_options_struct (struct gcc_options
*opts
)
556 opts
->x_flag_bounds_check
= 1;
557 opts
->x_flag_exceptions
= 1;
558 opts
->x_flag_non_call_exceptions
= 1;
560 /* In Java floating point operations never trap. */
561 opts
->x_flag_trapping_math
= 0;
562 opts
->frontend_set_flag_trapping_math
= true;
564 /* In Java arithmetic overflow always wraps around. */
565 opts
->x_flag_wrapv
= 1;
567 /* Java requires left-to-right evaluation of subexpressions. */
568 opts
->x_flag_evaluation_order
= 1;
570 /* Java catches NULL pointer exceptions, thus we can not necessarily
571 rely on a pointer having a non-NULL value after a dereference. */
572 opts
->x_flag_delete_null_pointer_checks
= 0;
576 java_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED
,
577 struct cl_decoded_option
*decoded_options ATTRIBUTE_UNUSED
)
582 /* Post-switch processing. */
584 java_post_options (const char **pfilename
)
586 const char *filename
= *pfilename
;
588 /* Excess precision other than "fast" requires front-end
590 if (flag_excess_precision_cmdline
== EXCESS_PRECISION_STANDARD
591 && TARGET_FLT_EVAL_METHOD_NON_DEFAULT
)
592 sorry ("-fexcess-precision=standard for Java");
593 flag_excess_precision_cmdline
= EXCESS_PRECISION_FAST
;
595 /* An absolute requirement: if we're not using indirect dispatch, we
596 must always verify everything. */
597 if (! flag_indirect_dispatch
)
598 flag_verify_invocations
= true;
600 if (flag_reduced_reflection
)
602 if (flag_indirect_dispatch
)
603 error ("-findirect-dispatch is incompatible "
604 "with -freduced-reflection");
606 error ("-fjni is incompatible with -freduced-reflection");
609 /* Open input file. */
611 if (filename
== 0 || !strcmp (filename
, "-"))
616 if (dependency_tracking
)
617 error ("can%'t do dependency tracking with input from stdin");
621 if (dependency_tracking
)
625 /* If the target is set and the output filename is set, then
626 there's no processing to do here. Otherwise we must
627 compute one or the other. */
628 if (! ((dependency_tracking
& DEPEND_TARGET_SET
)
629 && (dependency_tracking
& DEPEND_FILE_ALREADY_SET
)))
631 dot
= strrchr (filename
, '.');
633 error ("couldn%'t determine target name for dependency tracking");
636 char *buf
= XNEWVEC (char, dot
- filename
+
637 3 + sizeof (TARGET_OBJECT_SUFFIX
));
638 strncpy (buf
, filename
, dot
- filename
);
640 /* If emitting class files, we might have multiple
641 targets. The class generation code takes care of
642 registering them. Otherwise we compute the
644 if ((dependency_tracking
& DEPEND_TARGET_SET
))
648 strcpy (buf
+ (dot
- filename
), TARGET_OBJECT_SUFFIX
);
649 jcf_dependency_set_target (buf
);
652 if ((dependency_tracking
& DEPEND_FILE_ALREADY_SET
))
654 else if ((dependency_tracking
& DEPEND_SET_FILE
))
656 strcpy (buf
+ (dot
- filename
), ".d");
657 jcf_dependency_set_dep_file (buf
);
660 jcf_dependency_set_dep_file ("-");
667 linemap_add (line_table
, LC_ENTER
, false, filename
, 0);
668 linemap_add (line_table
, LC_RENAME
, false, "<built-in>", 0);
670 /* Initialize the compiler back end. */
674 /* Return either DECL or its known constant value (if it has one). */
677 decl_constant_value (tree decl
)
679 if (/* Don't change a variable array bound or initial value to a constant
680 in a place where a variable is invalid. */
681 current_function_decl
!= 0
682 && ! TREE_THIS_VOLATILE (decl
)
683 && TREE_READONLY (decl
)
684 && DECL_INITIAL (decl
) != 0
685 && TREE_CODE (DECL_INITIAL (decl
)) != ERROR_MARK
686 /* This is invalid if initial value is not constant.
687 If it has either a function call, a memory reference,
688 or a variable, then re-evaluating it could give different results. */
689 && TREE_CONSTANT (DECL_INITIAL (decl
))
690 /* Check for cases where this is sub-optimal, even though valid. */
691 && TREE_CODE (DECL_INITIAL (decl
)) != CONSTRUCTOR
)
692 return DECL_INITIAL (decl
);
696 /* Every call to a static constructor has an associated boolean
697 variable which is in the outermost scope of the calling method.
698 This variable is used to avoid multiple calls to the static
699 constructor for each class.
701 It looks something like this:
705 boolean dummy = OtherClass.is_initialized;
710 OtherClass.initialize();
712 ... use OtherClass.data ...
715 Each of these boolean variables has an entry in the
716 DECL_FUNCTION_INIT_TEST_TABLE of a method. When inlining a method
717 we must merge the DECL_FUNCTION_INIT_TEST_TABLE from the function
718 being inlined and create the boolean variables in the outermost
719 scope of the method being inlined into. */
721 /* Create a mapping from a boolean variable in a method being inlined
722 to one in the scope of the method being inlined into. */
725 merge_init_test_initialization (treetreehash_entry
**entry
, void *x
)
727 struct treetreehash_entry
*ite
= *entry
;
728 splay_tree decl_map
= (splay_tree
)x
;
730 tree
*init_test_decl
;
732 /* See if we have remapped this declaration. If we haven't there's
733 a bug in the inliner. */
734 n
= splay_tree_lookup (decl_map
, (splay_tree_key
) ite
->value
);
737 /* Create a new entry for the class and its remapped boolean
738 variable. If we already have a mapping for this class we've
739 already initialized it, so don't overwrite the value. */
740 init_test_decl
= java_treetreehash_new
741 (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl
), ite
->key
);
742 if (!*init_test_decl
)
743 *init_test_decl
= (tree
)n
->value
;
745 /* This fixes a weird case.
747 The front end assumes that once we have called a method that
748 initializes some class, we can assume the class is initialized. It
749 does this by setting the DECL_INITIAL of the init_test_decl for that
750 class, and no initializations are emitted for that class.
752 However, what if the method that is supposed to do the initialization
753 is itself inlined in the caller? When expanding the called method
754 we'll assume that the class initialization has already been done,
755 because the DECL_INITIAL of the init_test_decl is set.
757 To fix this we remove the DECL_INITIAL (in the caller scope) of all
758 the init_test_decls corresponding to classes initialized by the
759 inlined method. This makes the caller no longer assume that the
760 method being inlined does any class initializations. */
761 DECL_INITIAL (*init_test_decl
) = NULL
;
766 /* Merge the DECL_FUNCTION_INIT_TEST_TABLE from the function we're
770 java_inlining_merge_static_initializers (tree fn
, void *decl_map
)
772 DECL_FUNCTION_INIT_TEST_TABLE (fn
)
773 ->traverse
<void *, merge_init_test_initialization
> (decl_map
);
776 /* Lookup a DECL_FUNCTION_INIT_TEST_TABLE entry in the method we're
777 inlining into. If we already have a corresponding entry in that
778 class we don't need to create another one, so we create a mapping
779 from the variable in the inlined class to the corresponding
783 inline_init_test_initialization (treetreehash_entry
**entry
, void *x
)
785 struct treetreehash_entry
*ite
= *entry
;
786 splay_tree decl_map
= (splay_tree
)x
;
788 tree h
= java_treetreehash_find
789 (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl
), ite
->key
);
792 splay_tree_insert (decl_map
,
793 (splay_tree_key
) ite
->value
,
794 (splay_tree_value
) h
);
798 /* Look up the boolean variables in the DECL_FUNCTION_INIT_TEST_TABLE
799 of a method being inlined. For each hone, if we already have a
800 variable associated with the same class in the method being inlined
801 into, create a new mapping for it. */
804 java_inlining_map_static_initializers (tree fn
, void *decl_map
)
806 DECL_FUNCTION_INIT_TEST_TABLE (fn
)
807 ->traverse
<void *, inline_init_test_initialization
> (decl_map
);
810 /* Avoid voluminous output for deep recursion of compound exprs. */
813 dump_compound_expr (dump_info_p di
, tree t
)
819 switch (TREE_CODE (TREE_OPERAND (t
, i
)))
822 dump_compound_expr (di
, TREE_OPERAND (t
, i
));
826 dump_child ("expr", TREE_OPERAND (t
, i
));
832 java_dump_tree (void *dump_info
, tree t
)
835 dump_info_p di
= (dump_info_p
) dump_info
;
837 /* Figure out what kind of node this is. */
838 code
= TREE_CODE (t
);
843 dump_child ("args", DECL_ARGUMENTS (t
));
844 if (DECL_EXTERNAL (t
))
845 dump_string (di
, "undefined");
847 dump_string (di
, "extern");
849 dump_string (di
, "static");
850 if (DECL_LANG_SPECIFIC (t
) && !dump_flag (di
, TDF_SLIM
, t
))
851 dump_child ("inline body", DECL_SAVED_TREE (t
));
855 dump_child ("expr", TREE_OPERAND (t
, 0));
859 dump_child ("goto", TREE_OPERAND (t
, 0));
863 dump_child ("label", TREE_OPERAND (t
, 0));
867 if (BLOCK_EXPR_BODY (t
))
869 tree local
= BLOCK_VARS (t
);
872 tree next
= TREE_CHAIN (local
);
873 dump_child ("var", local
);
878 tree block
= BLOCK_EXPR_BODY (t
);
879 dump_child ("body", block
);
880 block
= TREE_CHAIN (block
);
886 if (!dump_flag (di
, TDF_SLIM
, t
))
888 dump_compound_expr (di
, t
);
897 /* Java calls can't, in general, be sibcalls because we need an
898 accurate stack trace in order to guarantee correct operation of
899 methods such as Class.forName(String) and
900 SecurityManager.getClassContext(). */
903 java_decl_ok_for_sibcall (const_tree decl
)
905 return (decl
!= NULL
&& DECL_CONTEXT (decl
) == output_class
906 && !DECL_UNINLINABLE (decl
));
909 static enum classify_record
910 java_classify_record (tree type
)
912 if (! CLASS_P (type
))
913 return RECORD_IS_STRUCT
;
915 if (CLASS_INTERFACE (TYPE_NAME (type
)))
916 return RECORD_IS_INTERFACE
;
918 return RECORD_IS_CLASS
;
921 static GTY(()) tree java_eh_personality_decl
;
924 java_eh_personality (void)
926 if (!java_eh_personality_decl
)
927 java_eh_personality_decl
= build_personality_function ("gcj");
928 return java_eh_personality_decl
;
931 #include "gt-java-lang.h"