diff options
Diffstat (limited to 'gcc/java')
43 files changed, 54430 insertions, 0 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog new file mode 100644 index 000000000..9afa594b7 --- /dev/null +++ b/gcc/java/ChangeLog @@ -0,0 +1,22473 @@ +2013-04-12 Release Manager + + * GCC 4.6.4 released. + +2012-03-01 Release Manager + + * GCC 4.6.3 released. + +2012-01-23 Andreas Schwab <schwab@linux-m68k.org> + + * lang.c (java_init_options_struct): Set + frontend_set_flag_trapping_math. + +2011-10-26 Release Manager + + * GCC 4.6.2 released. + +2011-06-27 Release Manager + + * GCC 4.6.1 released. + +2011-03-25 Release Manager + + * GCC 4.6.0 released. + +2011-02-13 Joseph Myers <joseph@codesourcery.com> + + * jvspec.c (jvgenmain_spec): Remove %{a*}. + +2011-01-21 Kai Tietz <kai.tietz@onevision.com> + + PR bootstrap/47215 + * decl.c (java_init_decl_processing): Remove + va_list_type_node related type initializations. + +2011-01-11 Kai Tietz <kai.tietz@onevision.com> + + PR bootstrap/47215 + * decl.c (java_init_decl_processing): Initialize + long_integer_type_node. + +2011-01-07 Kai Tietz <kai.tietz@onevision.com> + + PR bootstrap/47215 + * decl.c (java_init_decl_processing): Initialize unsigned_type_node. + +2011-01-07 Kai Tietz <kai.tietz@onevision.com> + + * decl.c (java_init_decl_processing): Setup va_list_type_node. + +2011-01-03 Jakub Jelinek <jakub@redhat.com> + + * jcf-dump.c (version): Update copyright notice dates. + +2010-12-15 Dave Korn <dave.korn.cygwin@gmail.com> + + * decl.c (java_init_decl_processing): Initialise integer_three_node. + * lang.c (put_decl_node): Handle nested function decls. + +2010-12-07 Joseph Myers <joseph@codesourcery.com> + + * jcf-parse.c: Don't include assert.h. + (java_parse_file): Use gcc_assert. + +2010-12-03 Joseph Myers <joseph@codesourcery.com> + + * lang.opt (static-libgcj): New option. + +2010-12-01 Joseph Myers <joseph@codesourcery.com> + + * jcf-parse.c: Don't include toplev.h. + * Make-lang.in (java/jcf-parse.o): Don't depend on toplev.h. + +2010-11-30 Joseph Myers <joseph@codesourcery.com> + + * boehm.c: Don't include toplev.h. + * Make-lang.in (java/boehm.o): Don't depend on toplev.h. + +2010-11-30 Joseph Myers <joseph@codesourcery.com> + + * expr.c, lang.c, mangle.c, mangle_name.c, typeck.c, + verify-glue.c: Don't include toplev.h. + * Make-lang.in: Dependencies for above files changed to remove + toplev.h. + +2010-11-29 Joseph Myers <joseph@codesourcery.com> + + * boehm.c: Include "config.h" instead of <config.h>. + * builtins.c: Don't include <stdarg.h>. + * class.c: Don't include "stdio.h". + (O_BINARY): Don't define here. + * jcf-depend.c: Don't include <assert.h>. + (jcf_dependency_set_dep_file, jcf_dependency_init, + jcf_dependency_write): Use gcc_assert. + * jcf-io.c (O_BINARY): Don't define here. + * jcf-path.c: Don't include "tm.h". + (jcf_path_init): Use getenv instead of GET_ENVIRONMENT. + * resource.c: Don't include "stdio.h". + (O_BINARY): Don't define here. + * verify-impl.c: Don't include <stdio.h>. + +2010-11-17 Joseph Myers <joseph@codesourcery.com> + + * jcf-parse.c (java_parse_file): Take no arguments. + * java-tree.h (java_parse_file): Update prototype. + +2010-11-09 Joern Rennecke <amylaar@spamcop.net> + Andrew Haley <aph@redhat.com> + + PR java/46386 + * config/pdp11/t-pdp11 (java/constants.o-warn): Remove. + +2010-11-12 Joseph Myers <joseph@codesourcery.com> + + * Make-lang.in (jvspec.o, java/lang.o): Use $(OPTS_H). + * lang.c (java_handle_option): Take location_t parameter. + +2010-11-10 Joseph Myers <joseph@codesourcery.com> + + * expr.c (expand_java_field_op): Use %' in diagnostic. + * jcf-parse.c (java_parse_file): Use %' in diagnostics. + * jvspec.c (lang_specific_driver): Use %' in diagnostic. + * lang.c (java_post_options): Use %' in diagnostics. + +2010-11-06 Joern Rennecke <amylaar@spamcop.net> + + PR middle-end/46314 + * class.c: Include target.h. + (make_local_function_alias): + Use targetm.asm_out.generate_internal_label. + * expr.c (lookup_label, generate_name): Likewise. + +2010-11-03 Joern Rennecke <joern.rennecke@embecosm.com> + + PR bootstrap/44335 + * jfc-parse.c (target.h): Include. + (handle_constant): Use targetm.words_big_endian and + targetm.float_words_big_endian. + (get_constant): Use targetm.float_words_big_endian. + +2010-10-13 Richard Henderson <rth@redhat.com> + + * lang.c (java_eh_personality): Update call to + build_personality_function. + +2010-10-12 Joseph Myers <joseph@codesourcery.com> + + * Make-lang.in (java/lang.o): Use $(OPTIONS_H) instead of + options.h. + +2010-10-11 Nathan Froyd <froydnj@codesourcery.com> + + * decl.c (java_init_decl_processing): Use build_function_type_list + instead of build_function_type. + * jcf-parse.c (java_emit_static_constructor): Likewise. + * builtins.c (initialize_builtins): Likewise. + +2010-10-08 Joseph Myers <joseph@codesourcery.com> + + * lang.c (java_init_options_struct): New. Split out from + java_init_options. + (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. + +2010-10-04 Andi Kleen <ak@linux.intel.com> + + * Make-lang.in (xgcj, jc1, jcf-dump, jvgenmain): + Add + to build rule. + +2010-09-29 Joseph Myers <joseph@codesourcery.com> + + * lang.opt: Don't use VarExists. + +2010-09-29 Joseph Myers <joseph@codesourcery.com> + + * java-tree.h (flag_filelist_file, flag_assert, flag_jni, + flag_force_classes_archive_check, flag_redundant, flag_newer, + flag_use_divide_subroutine, flag_use_atomic_builtins, + flag_use_boehm_gc, flag_hash_synchronization, + flag_check_references, flag_optimize_sci, flag_indirect_classes, + flag_indirect_dispatch, flag_store_check, + flag_reduced_reflection): Remove. + * jcf-dump.c (flag_newer): Remove. + * jcf.h (quiet_flag): Remove. + * parse.h (quiet_flag): Remove. + +2010-09-28 Richard Henderson <rth@redhat.com> + + * lang.c: Include "target.h". + (java_eh_personality): Use targetm.except_unwind_info. + * Make-lang.in (lang.o): Update deps. + +2010-09-27 Andrew Haley <aph@redhat.com> + + PR java/45773 + * jvgenmain.c (main): Fix arg processing. + +2010-09-22 Joseph Myers <joseph@codesourcery.com> + + * jvspec.c (lang_specific_driver): Handle OPT__help instead of + OPT_fhelp. + * lang.opt (-CLASSPATH, -all-warnings, -bootclasspath, -classpath, + -dependencies, -encoding, -extdirs, -include-directory, + -include-directory=, -output-class-directory, + -output-class-directory=, -resource, -resource=, + -user-dependencies): New. + +2010-09-16 Richard Guenther <rguenther@suse.de> + + * jcf-parse.c (current_file_list): Remove. + (java_parse_file): Use build_translation_unit_decl. Adjust. + +2010-09-03 Joseph Myers <joseph@codesourcery.com> + + * lang.opt (d): New. + +2010-09-03 H.J. Lu <hongjiu.lu@intel.com> + + PR java/45504 + * jvgenmain.c (main): Check "-D XXX=YYY". + +2010-09-02 Joseph Myers <joseph@codesourcery.com> + + * jvspec.c (jvgenmain_spec): Don't handle -fnew-verifier. + +2010-09-02 Joseph Myers <joseph@codesourcery.com> + + * lang.opt (CLASSPATH, bootclasspath, classpath, encoding, + fCLASSPATH=): Mark as Java options and as aliases. + * jvspec.c (jvgenmain_spec): Don't handle -fCLASSPATH*. + (lang_specific_driver): Don't handle options marked as aliases. + * lang.c (java_handle_option): Don't handle OPT_fCLASSPATH_. + +2010-08-22 Joseph Myers <joseph@codesourcery.com> + + * Make-lang.in (jvspec.o): Update dependencies. + * jvspec.c: Include opts.h. + (PARAM_ARG): Remove. + (find_spec_file): Do not add leading -specs=. + (lang_specific_driver): Use cl_decoded_option structures. + * lang.opt (C, CLASSPATH, D, bootclasspath, classpath, encoding, + extdirs, fmain=, s-bc-abi): New options. + +2010-08-20 Nathan Froyd <froydnj@codesourcery.com> + + * class.c: Use FOR_EACH_VEC_ELT. + * expr.c: Likewise. + * jcf-parse.c: Likewise. + * resource.c: Likewise. + +2010-08-16 Joseph Myers <joseph@codesourcery.com> + + * lang.opt (MD_, MMD_, version): Mark RejectDriver. + +2010-08-05 David Daney <ddaney@caviumnetworks.com> + + * class.c (build_utf8_ref): Fix code formatting from previous commit. + +2010-08-05 David Daney <ddaney@caviumnetworks.com> + + * class.c (build_utf8_ref): Make decl DECL_USER_ALIGN. + +2010-07-27 Joseph Myers <joseph@codesourcery.com> + + * lang.c (java_handle_option): Update prototype and return value + type. + +2010-07-27 Joseph Myers <joseph@codesourcery.com> + + * lang.c (java_option_lang_mask): New. + (java_init_options): Update prototype. + (LANG_HOOKS_OPTION_LANG_MASK): Define. + +2010-07-15 Nathan Froyd <froydnj@codesourcery.com> + + * java-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. + * boehm.c: Likewise. + * class.c: Likewise. + * decl.c: Likewise. + * expr.c: Likewise. + * jcf-parse.c: Likewise. + * typeck.c: Likewise. + * verify-glue.c: Likewise. + +2010-07-08 Manuel López-Ibáñez <manu@gcc.gnu.org> + + * boehm.c: Include diagnostic-core.h in every file that includes + toplev.h. + * class.c: Likewise. + * constants.c: Likewise. + * decl.c: Likewise. + * except.c: Likewise. + * expr.c: Likewise. + * jcf-parse.c: Likewise. + * mangle.c: Likewise. + * mangle_name.c: Likewise. + * resource.c: Likewise. + * typeck.c: Likewise. + * verify-glue.c: Likewise. + +2010-07-05 Nathan Froyd <froydnj@codesourcery.com> + + PR bootstrap/44825 + * class.c (make_class_data): Cast result of VEC_length calls to int. + +2010-07-05 Nathan Froyd <froydnj@codesourcery.com> + + * constants.c (build_constants_constructor): Use build_constructor + instead of build_constructor_from_list. + * class.c (make_method_value): Likewise. + (get_dispatch_table): Likewise. + (make_class_data): Likewise. + (emit_indirect_register_classes): Likewise. + (emit_symbol_table): Likewise. + (add_assertion_table_entry): Likewise. + (emit_assertion_table): Likewise. + (make_field_value): Use build_constructor_single instead of + build_constructor_from_list. + +2010-06-28 Nathan Froyd <froydnj@codesourcery.com> + + * java-tree.h (struct lang_type) [catch_classes]: Change type to a + VEC. + * except.c (prepare_eh_table_type): Call CONSTRUCTOR_APPEND_ELT + instead of tree_cons. + * class.c (make_class): Add dummy entry to TYPE_CATCH_CLASSES. + (emit_catch_table): Adjust for new type of TYPE_CATCH_CLASSES. + +2010-06-28 Steven Bosscher <steven@gcc.gnu.org> + + * lang.c: Do not include except.h + * except.c: Likewise. + (doing_eh): New, moved from except.c (in gcc/) but removed the + do_warning flag. + (maybe_start_try): Update doing_eh call. + * Make-lang.in: Update dependencies. + +2010-06-23 Anatoly Sokolov <aesok@post.ru> + + * decl.c (java_init_decl_processing): Use double_int_to_tree instead + of build_int_cst_wide. + * boehm.c (set_bit): Remove. + (mark_reference_fields): Use double_int type for 'mask' argument. + Use double_int_setbit instead of set_bit. + (get_boehm_type_descriptor): Use double_int_setbit instead of + set_bit. Use double_int_to_tree instead of build_int_cst_wide. + +2010-06-10 Gerald Pfeifer <gerald@pfeifer.com> + + * gcj.texi: Move to GFDL version 1.3. Fix copyright years. + +2010-06-08 Laurynas Biveinis <laurynas.biveinis@gmail.com> + + * jcf-reader.c (jcf_parse_constant_pool): Use typed GC allocation. + + * jcf-parse.c (java_parse_file): Likewise. + (process_zip_dir): Likewise. + + * java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Likewise. + (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Likewise. + + * expr.c (add_type_assertion): Likewise. + + * decl.c (make_binding_level): Likewise. + (java_dup_lang_specific_decl): Likewise. + + * constants.c (set_constant_entry): Likewise. + (cpool_for_class): Likewise. + + * class.c (add_method_1): Likewise. + (java_treetreehash_new): Likewise. + + * java-tree.h (struct lang_type): Add variable_size GTY option. + (struct lang_decl): Likewise. + + * jch.h (struct cpool_entry): Likewise. + + * java-tree.h (java_treetreehash_create): Remove parameter ggc. + + * except.c (prepare_eh_table_type): Update + java_treetreehash_create call. + + * class.c (add_method_1): Update java_treetreehash_create call. + (java_treetreehash_create): Remove parameter gc. Use + htab_create_ggc. + +2010-06-04 Joseph Myers <joseph@codesourcery.com> + + * jvspec.c (lang_specific_driver): Use GCC-specific formats in + diagnostics. + +2010-05-30 Steven Bosscher <steven@gcc.gnu.org> + + * except.c: Include tm.h. + +2010-05-28 Joseph Myers <joseph@codesourcery.com> + + * jvspec.c (lang_specific_driver): Use fatal_error instead of + fatal. Use warning instead of error for warnings. + +2010-05-28 Nathan Froyd <froydnj@codesourcery.com> + + * expr.c (get_symbol_table_index): Add spaces in expression. + +2010-05-28 Nathan Froyd <froydnj@codesourcery.com> + + * java-tree.h (method_entry): Declare. Declare VECs containing it. + (struct lang_type): Change type of otable_methods, atable_methods, and + itable_methods to VECs. Fix comment for atable_methods. + (emit_symbol_table): Take a VEC instead of a tree. + (get_symbol_table_index): Take a VEC * instead of a tree *. + * class.c (add_table_and_syms): Take a VEC instead of a tree. + (emit_symbol_table): Update for changed parameter type. + * expr.c (get_symbol_table_index): Likewise. + +2010-05-27 Steven Bosscher <steven@gcc.gnu.org> + + * buildings.c: Pretend to be a backend file by undefining + IN_GCC_FRONTEND (still need rtl.h here). + +2010-05-26 Nathan Froyd <froydnj@codesourcery.com> + + * java-tree.h (struct lang_decl_func): Change type of throws_list + field to a VEC. + * jcf-parse.c (HANDLE_EXCEPTIONS_ATTRIBUTE): Adjust for changed type + of DECL_FUNCTION_THROWS. + * class.c (make_method_value): Likewise. + +2010-05-26 Nathan Froyd <froydnj@codesourcery.com> + + * class.c (utf8_decl_list): Delete. + (build_utf8_ref): Remove references to it. + * java-tree.h (all_class_list): Delete. + (predef_filenames): Delete. + (enum java_tree_index) [JTI ALL_CLASS_LIST,JTI_PREDEF_FILENAMES]: + Delete. + * jcf-parse.c (parse_roots): Decrease size to 2. + (current_file_list): Convert to a VEC. + (all_class_list): Declare. + (jcf_parse): Adjust for new type of all_class_list. + (java_layout_seen_class_methods): Likewise. + (predefined_filenames): Declare. + (add_predefined_file): Use it. + (predefined_filename_p): Likewise. + (java_parse_file): Adjust for new type of current_file_list. * + +2010-05-25 Jakub Jelinek <jakub@redhat.com> + + * lang.c (java_classify_record): Return RECORD_IS_INTERFACE + for interfaces. + + PR debug/43260 + * java-tree.h (pending_static_fields): New extern declaration. + (java_write_globals): New prototype. + * lang.c (LANG_HOOKS_WRITE_GLOBALS): Define. + * decl.c (java_mark_class_local): When clearing DECL_EXTERNAL + of a static field push it into pending_static_fields vector. + * class.c (pending_static_fields): New variable. + (add_field): If static field is not DECL_EXTERNAL, push it into + pending_static_fields vector. + (java_write_globals): New function. + +2010-05-24 Nathan Froyd <froydnj@codesourcery.com> + + * expr.c (quick_stack): Change type to a VEC. Update comment. + (tree_list_free_list): Delete. + (flush_quick_stack): Update for quick_stack type change. + (push_value): Likewise. + (pop_value): Likewise. + +2010-05-23 Steven Bosscher <steven@gcc.gnu.org> + + * java-gimplify.c: Do not include tm.h, toplev.h. + * typeck.c: Do not include tm.h. + * mangle_name.c: Do not include tm.h. + * jcf-dump.c: Do not include tm.h, ggc.h. + * class.c: Do not include rtl.h, tm_p.h, target.h, except.h, cgraph.h. + * decl.c: Do not include tm.h, rtl.h, function.h, expr.h, except.h, + and timevar.h. + * jcf-parse.c: Do not include tm.h and tm_p.h. + * resource.c: Do not include tm.h, rtl.h, flags.h, obstack.h, + target.h, and expr.h. + * except.c: Do not include tm.h, rtl.h, function.h. + * builtins.c: Do not include convert.h. Explain why RTL headers + have to be included here. + * verify-glue.c: Do not include tm.h. + * jcf-depend.c: Do not include tm.h. + * jcf-reader.c: Include ggc.h. + * jcf-io.c: Do not include tm.h, toplev.h. + * expr.c: Do not include tm.h, rtl.h, expr.h, except.h, tm_p.h, + gimple.h. + * lang.c: Do not include rtl.h, expr.h. + * Make-lang.in: Update dependencies. + +2010-05-23 Steven Bosscher <steven@gcc.gnu.org> + + * jcf-parse.c: Include bitmap.h. + * Make-lang.in: Update dependencies. + +2010-05-20 Jakub Jelinek <jakub@redhat.com> + + PR debug/43521 + * decl.c (start_java_method): Set DECL_ARTIFICIAL on the 'this' + PARM_DECL. + +2010-05-19 Anatoly Sokolov <aesok@post.ru> + + * jcf-parse.c (get_constant): Use double_int_to_tree instead of + build_int_cst_wide_type. + +2010-05-18 Nathan Froyd <froydnj@codesourcery.com> + + * expr.c (pop_arguments): Fix use of undeclared variable. + +2010-05-18 Nathan Froyd <froydnj@codesourcery.com> + + * expr.c (expand_java_multianewarray): Use build_call_vec instead of + build_call_list. + (pop_arguments): Return a VEC instead of a tree. Take a method type + rather than a list of argument types. + (rewrite_rule): Change signature. of rewrite_arglist member. + (rewrite_arglist_getcaller): Update signature. + (rewrite_arglist_getclass): Likewise. + (maybe_rewrite_invocation): Update for rewrite_arglist change. + (build_known_method_ref): Take a VEC instead of a tree. + (invoke_build_dtable): Likewise. + (expand_invoke): Update calls to pop_arguments. Use build_call_vec + instead of build_call_list. + (build_jni_stub): Use build_call_vec instead of build_call_list. + * java-tree.h (maybe_rewrite_invocation): Update declaration. + (build_known_method_ref): Likewise. + (invoke_build_dtable): Likewise. + +2010-05-14 Nathan Froyd <froydnj@codesourcery.com> + + PR 44103 + * java-tree.h (START_RECORD_CONSTRUCTOR): Change first argument to a + vector. Move call to build_constructor... + (FINISH_RECORD_CONSTRUCTOR): ...here. Add necessary arguments. Clear + TREE_CONSTANT on the constructor. + (PUSH_SUPER_VALUE): Change first argument to a vector. + (PUSH_FIELD_VALUE): Likewise. + * resource.c (compile_resource_data): Update calls to above macros. + * constants.c (build_constants_constructor): Likewise. + * class.c (build_utf8_ref): Likewise. + (make_field_value): Likewise. + (make_method_value): Likewise. + (add_table_and_syms): New function. + (make_class_data): Call it. Update calls to above macros. + (build_symbol_table_entry): New function. + (build_symbol_entry): Call it. Update calls to above macros. + (emit_symbol_table): Likewise. + (make_catch_class_record): Update calls to above macros. + (build_assertion_table_entry): New function. + (add_assertion_table_entry): Call it. + (emit_assertion_table): Likewise. + +2010-05-06 Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR 40989 + * lang.c (java_handle_option): Add argument kind. + +2010-04-18 Eric Botcazou <ebotcazou@adacore.com> + + * decl.c (java_init_decl_processing): Remove argument in call to + initialize_sizetypes + +2010-04-07 Jakub Jelinek <jakub@redhat.com> + + * exception.cc (_Jv_Throw): Avoid set but not used warning. + * include/java-assert.h (JvAssertMessage, JvAssert): Use argument in + sizeof to avoid set but not used warnings. + +2010-01-20 Joern Rennecke <amylaar@spamcop.net> + + * lang.c (java_post_options): Constify variable "dot". + + * jcf-parse.c (set_source_filename): Constify variable "dot". + (load_class): Constify variable "separator". + Use get_identifier_with_length. + + * jvspec.c (lang_specific_driver): Constify two variables named "p". + +2010-01-09 Jakub Jelinek <jakub@redhat.com> + + * jcf-dump.c (version): Update copyright notice dates. + +2009-11-28 Jakub Jelinek <jakub@redhat.com> + + * jvspec.c (lang_specific_driver): Remove unused + saw_verbose_flag variable. + * jcf-dump.c (main): Remove unused general_purpose_bits + variable. + * builtins.c (initialize_builtins): Remove unused float_ftype_float + variable. + * expr.c (java_stack_pop): Remove unused val variable. + (build_jni_stub): Remove unused res_type variable. + * verify-impl.c (check_field_constant): Remove unused len variable. + +2009-10-20 Joel Dice <dicej@mailsnare.net> + + PR java/28474 + * mangle_name.c (append_unicode_mangled_name): Fix mangling + of names with multiple underscores and "U". + (unicode_mangling_length): Likewise. + +2009-10-03 Simon Baldwin <simonb@google.com> + + * config-lang.in (lang_dirs): Remove zlib. + +2009-09-28 Richard Henderson <rth@redhat.com> + + * builtins.c (initialize_builtins): Update call to + build_common_builtin_nodes. + * lang.c (LANG_HOOKS_EH_USE_CXA_END_CLEANUP): New. + +2009-09-14 Richard Henderson <rth@redhat.com> + + * builtins.c (initialize_builtins): Update call to + build_common_builtin_nodes. + * decl.c (java_init_decl_processing): Don't call + default_init_unwind_resume_libfunc. + * except.c: Include tree-iterator.h. + (build_exception_object_var): New. + (build_exception_object_ref): Use it. + (expand_end_java_handler): Initialize it from __builtin_eh_pointer. + Attach all CATCH_EXPRs to a single TRY_CATCH_EXPR. + * java-tree.h (DECL_FUNCTION_EXC_OBJ): New. + +2009-09-13 Richard Guenther <rguenther@suse.de> + Rafael Avila de Espindola <espindola@google.com> + + * decl.c (do_nothing): Remove. + (java_init_decl_processing): Do not set lang_eh_runtime_type. + * Make-lang.in (lang.o): Add $(EXCEPT_H) dependency. + * lang.c (java_eh_personality): New. + (java_eh_personality_decl): Likewise. + (LANG_HOOKS_EH_PERSONALITY): Define. + +2009-09-03 Diego Novillo <dnovillo@google.com> + + * lang.c (lang_hooks): Remove const qualifier. + +2009-09-01 Jakub Jelinek <jakub@redhat.com> + + * boehm.c (mark_reference_fields): Compute % in HOST_WIDE_INT + type. + +2009-09-01 Richard Guenther <rguenther@suse.de> + + * lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Remove. + * java-tree.h (java_mark_addressable): Likewise. + * typeck.c (java_mark_addressable): Likewise. + +2009-08-17 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + + * Make-lang.in (java.install-pdf): Install gcj.pdf in + $(pdfdir)/gcc, alongside the other manuals. + +2009-08-12 Andrew Haley <aph@redhat.com> + + * builtins.c (compareAndSwapInt_builtin): Use + flag_use_atomic_builtins. + (compareAndSwapLong_builtin): Likewise. + (compareAndSwapObject_builtin): Likewise. + * jvspec.c: Add flag_use_atomic_builtins. + * gcj.texi: Likewise. + * java-tree.h: Likewise. + * lang.opt: Likewise. + +2009-08-11 Dodji Seketeli <dodji@redhat.com> + + PR debug/40990 + * lang.c (put_decl_node): Outputs different level of information + depending on the verbosity level. + +2009-07-31 Andrew Haley <aph@redhat.com> + + PR java/40867 + * decl.c (java_replace_references): Set EXPR_LOCATION on all + generated expressions. + (binding_level.loc): new field. + (clear_binding_level): Initialize loc. + (set_input_location): New function. + (pushlevel): Set new binding_level.loc. + (poplevel): Set EXPR_LOCATION on the new BIND_EXPR_BODY. + (start_java_method): Set DECL_SOURCE_LOCATION of this new method. + (java_add_stmt): Set the EXPR_LOCATION on all subtrees of new_stmt. + +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR c/40401 + * java-gimplify.c (java_genericize): Do not gimplify here. + But replace all local references. + (java_gimplify_expr): Do not replace local references here. + (java_gimplify_modify_expr): Likewise. + * jcf-parse.c (java_parse_file): Do not finalize the CU or + optimize the cgraph here. + * decl.c (java_replace_reference): Make static. + (java_replace_references): New function. + (end_java_method): Clear base_decl_map. + * java-tree.h (java_replace_references): Declare. + (java_replace_reference): Remove. + +2009-07-14 Taras Glek <tglek@mozilla.com> + Rafael Espindola <espindola@google.com> + + * Make-lang.in (java.install-plugin): New target for + installing plugin headers. + +2009-07-07 Manuel López-Ibáñez <manu@gcc.gnu.org> + + * class.c: Replace %J by an explicit location. Update all calls. + +2009-07-07 Manuel López-Ibáñez <manu@gcc.gnu.org> + + * jcf-parse.c: Replace %H by an explicit location. Update all calls. + +2009-06-29 Andrew Haley <aph@redhat.com> + + PR java/40590 + * java-tree.h (cxx_keyword_p): New declaration. + * mangle_name.c (utf8_cmp): Move here from mangle.c. + (cxx_keywords): Likewise. + (cxx_keyword_p): Likewise. + (MANGLE_CXX_KEYWORDS): New macro. + (append_gpp_mangled_name): Use MANGLE_CXX_KEYWORDS. + (append_gpp_mangled_name): Likewise. + * mangle.c: Move code to mangle_name.c. + (mangle_member_name): Don't call cxx_keyword_p. + +2009-06-12 Aldy Hernandez <aldyh@redhat.com> + + * java-gimplify.c (java_gimplify_block): New argument to + build_empty_stmt. + * expr.c (force_evaluation_order): Same. + * typeck.c: Add location to build_decl or PUSH_FIELD calls. + * class.c: Same. + * decl.c: Same. + * jcf-parse.c: Same. + * constants.c: Same. + * resource.c: Same. + * except.c: Same. + * builtins.c: Same. + * expr.c: Same. + * java-tree.h (PUSH_FIELD): Add location field. + +2009-06-09 Ian Lance Taylor <iant@google.com> + + * verify.h: Remove extern "C". + +2009-06-07 Ian Lance Taylor <iant@google.com> + + * jcf-parse.c (handle_constant): Change local variable 'kind' to + unsigned int. + +2009-06-01 Ian Lance Taylor <iant@google.com> + + * jcf-io.c (find_class): Use CONST_CAST. + +2009-05-27 Ian Lance Taylor <iant@google.com> + + * Make-lang.in ($(XGCJ)$(exeext)): Change $(COMPILER) to + $(LINKER). + (jc1$(exeext), jcf-dump$(exeext), jvgenmain$(exeext)): Likewise. + +2009-05-26 Ian Lance Taylor <iant@google.com> + + * Make-lang.in (jvspec.o): Use $(COMPILER). + ($(XGCJ)$(exeext), jc1$(exeext), jcf-dump$(exeext)): Likewise. + (jvgenmain$(exeext), java/jcf-io.o, java/jcf-path.o): Likewise. + +2009-05-12 Alexandre Oliva <aoliva@redhat.com> + + * Make-lang.in (GCJ): Renamed to... + (XGCJ): ... this. + +2009-04-27 Ian Lance Taylor <iant@google.com> + + * builtins.c (java_builtins): Add casts to enum type. + * verify-impl.c (check_class_constant): Add cast to enum type. + (check_constant, check_wide_constant): Likewise. + +2009-04-27 Richard Guenther <rguenther@suse.de> + + PR java/38374 + * constants.c (build_constants_constructor): Retain the old + pointer type as valid TYPE_POINTER_TO after patching the + type of the constant pool decl. + +2009-04-24 Ian Lance Taylor <iant@google.com> + + * jcf-parse.c (handle_constant): Add cast to enum type. + +2009-04-21 Taras Glek <tglek@mozilla.com> + + * builtins.c: Update GTY annotations to new syntax + * decl.c: Likewise + * java-tree.h: Likewise + * jcf.h: Likewise + * lang.c: Likewise + +2009-04-21 Joseph Myers <joseph@codesourcery.com> + + * ChangeLog, ChangeLog.ptr, ChangeLog.tree-ssa: Add copyright and + license notices. + +2009-04-18 Ian Lance Taylor <iant@google.com> + + * verify-impl.c (verify_instructions_0): Add cast to enum type. + +2009-04-09 Paolo Bonzini <bonzini@gnu.org> + + * builtins.c (compareAndSwapLong_builtin, + compareAndSwapInt_builtin, compareAndSwapObject_builtin, + VMSupportsCS8_builtin): Do not look at sync_compare_and_swap_cc. + +2009-03-31 Richard Guenther <rguenther@suse.de> + + * java-gimplify.c (java_gimplify_expr): Do not manually gimplify + the first operand of binary and comaprison expressions. + +2009-03-30 Joseph Myers <joseph@codesourcery.com> + + PR rtl-optimization/323 + * lang.c (java_post_options): Set flag_excess_precision_cmdline. + Give an error for -fexcess-precision=standard for processors where + the option is significant. + +2009-03-18 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + + * lang.opt: Unify help text for -Wdeprecated. + +2009-02-03 Jakub Jelinek <jakub@redhat.com> + + * jcf-dump.c (version): Update copyright notice dates. + +2009-01-16 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/38835 + PR middle-end/36227 + * builtins.c (build_addr_sum): Use POINTER_PLUS_EXPR. + +2008-12-05 Sebastian Pop <sebastian.pop@amd.com> + + PR bootstrap/38262 + * Make-lang.in (jc1): Add BACKENDLIBS, remove GMPLIBS. + +2008-11-04 Andrew Haley <aph@redhat.com> + + PR java/37068 + * jcf-parse.c (java_emit_static_constructor): Don't call + cgraph_build_static_cdtor. Rewrite. + +2008-10-24 Jakub Jelinek <jakub@redhat.com> + + * Make-lang.in (check-java-subtargets): New target. + +2008-10-16 David Edelsohn <edelsohn@gnu.org> + + PR target/35483 + * Make-lang.in (class.o): Depend on $(TM_P_H). + (expr.o): Same. + * class.c: Include tm_p.h. + * expr.c: Include tm_p.h. + +2008-10-14 Andrew Haley <aph@redhat.com> + + * constants.c (build_constant_data_ref): Make sure we only build + one copy of the decl for the constant pool. + +2008-09-22 Andrew Haley <aph@redhat.com> + + * expr.c (rules): Add new rule for + gnu.java.lang.VMCPStringBuilder.toString. + (rewrite_rule.new_classname): New field. + (maybe_rewrite_invocation): Use new_classname field instead of + DECL_CONTEXT (*method_p). + Allow rewrite_arglist to be NULL. + +2008-09-17 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): Don't define. + (java_get_callee_fndecl): Kill. + +2008-09-17 Jan Hubicka <jh@suse.cz> + + PR c++/18071 + * class.c (add_method_1): Do not initialize DECL_INLINE. + (make_local_function_alias): Likewise. + * expr.c (rewrite_arglist_getcaller): Set DECL_UNINLINABLE. + * lang.c (java_decl_ok_for_sibcall): Use DECL_UNINLINABLE. + +2008-09-09 Richard Guenther <rguenther@suse.de> + + * decl.c (build_result_decl): Remove no longer applicable + promotion. + +2008-09-05 David Daney <ddaney@avtrex.com> + + * gcj.texi (-freduced-reflection): Clarify option's restrictions. + +2008-08-21 David Daney <ddaney@avtrex.com> + + * class.c (make_class_data): Don't add field_index when + flag_reduced_reflection set. + +2008-08-12 Ulrich Weigand <uweigand@de.ibm.com> + + * typeck.c (convert): Do not check for TARGET_FLOAT_FORMAT. + +2008-08-08 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR 28875 + * lang.c (java_handle_option): Replace set_Wunused with + warn_unused. + +2008-07-30 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + + * gcj.texi: Update copyright years. Do not list GPL as + Invariant Section. + +2008-07-29 Jakub Jelinek <jakub@redhat.com> + + * class.c (build_utf8_ref): Set DECL_SIZE and DECL_SIZE_UNIT + from ctype's sizes. + + * class.c (build_utf8_ref): Pad initializer string to utf8const_type's + alignment. + +2008-07-29 Jan Hubicka <jh@suse.cz> + + * lang.c (java_post_options): Remove handling of flag_no_inline. + +2008-07-28 Richard Guenther <rguenther@suse.de> + + Merge from gimple-tuples-branch. + + 2008-07-18 Richard Guenther <rguenther@suse.de> + + * expr.c: Include tree-iterator.h. + * Make-lang.in (expr.o): Add tree-iterator.h dependency. + + 2008-07-18 Aldy Hernandez <aldyh@redhat.com> + + * java-gimplify.c: Include gimple.h instead of tree-gimple.h. + * expr.c: Same. + + 2008-07-14 Aldy Hernandez <aldyh@redhat.com> + + * java-gimplify.c (java_gimplify_expr): Same. + (java_gimplify_modify_expr): Same. + * java-tree.h: Rename GENERIC_NEXT to TREE_CHAIN. + + 2008-05-02 Diego Novillo <dnovillo@google.com> + + * expr.c (build_java_throw_out_of_bounds_exception): Fix + mixed declarations and code. + + 2008-05-02 Doug Kwan <dougkwan@google.com> + + * expr.c (build_java_throw_out_of_bounds_exception ): Wrap call to + _Jv_ThrowBadArrayIndex with a COMPOUND_EXPR to return 0. + + 2008-02-19 Diego Novillo <dnovillo@google.com> + + http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00804.html + + * java-gimplify.c (java_gimplify_self_mod_expr): Change + gimple_seq arguments to gimple_seq *. Update all users. + + 2007-11-26 Aldy Hernandez <aldyh@redhat.com> + + * java-gimplify.c (java_gimplify_expr): Make pre_p and post_p + sequences. + (java_gimplify_self_mod_expr): Same. + * java-tree.h (java_gimplify_expr): Make pre_p and post_p + sequences. + +2008-07-24 Jan Hubicka <jh@suse.cz> + + * java/decl.c: Include cgraph.h + (end_java_method): Remove non-unit-at-a-time code. + (java_mark_decl_local): Likewise; sanity check that we don't touch + finalized nodes. + +2008-07-15 Jan Hubicka <jh@suse.cz> + + * lang.c (java_init_options): Enable unit-at-a-time by default. + +2008-07-14 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + + * Make-lang.in (jvspec.o): Fix dependencies. + +2008-07-06 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java/parse.o-warn): Remove. + (java/jcf-io.o-warn): Remove. + +2008-07-05 Tom Tromey <tromey@redhat.com> + + * jcf-io.c: Don't include fnmatch.h. Don't use JCF_USE_SCANDIR. + (compare_path): Remove. + (java_or_class_file): Likewise. + (memoized_dirlist_entry): Likewise. + (memoized_dirlist_hash): Likewise. + (memoized_dirlist_lookup_eq): Likewise. + (memoized_dirlists): Likewise. + (caching_stat): Likewise. + (find_class): Use stat. + * jcf.h (JCF_USE_SCANDIR): Remove. + +2008-06-30 Joshua Sumali <jsumali@redhat.com> + + * Make-lang.in (JAVA_MANFILES): Add doc/aot-compile.1 and + doc/rebuild-gcj-db.1 + (java.uninstall): Likewise. + (java.maintainer-clean): Likewise. + (aot-compile.pod): New rule. + (rebuild-gcj-db.pod): New rule. + (java.install-man): Install doc/aot-compile.1 and doc/rebuild-gcj-db.1 + * gcj.texi: Add new sections for aot-compile and rebuild-gcj-db. + +2008-06-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (java/jcf-io.o-warn): New. + +2008-06-24 Tom Tromey <tromey@redhat.com> + + * jcf-path.c (jcf_path_init): Don't name variable 'try'. + * expr.c (add_type_assertion): Rename argument. + (build_java_arrayaccess): Don't name variable 'throw'. + (ARRAY_NEW_MULTI): Don't name variable 'class'. + * jcf-io.c (find_class): Don't name variable 'class'. + * mangle.c (compression_table_add): Don't name variable 'new'. + * constants.c (cpool_for_class): Rename argument. + (alloc_constant_fieldref): Likewise. + * jcf-parse.c (handle_innerclass_attribute): Don't name variable + 'class'. + (read_class): Likewise. + (parse_zip_file_entries): Likewise. + (process_zip_dir): Likewise. + * decl.c (java_mark_class_local): Rename argument. + * class.c (GEN_TABLE): Use type_name, not typename. + (gen_indirect_dispatch_tables): Likewise. + (add_field): Rename argument. + (is_compiled_class): Likewise. + (safe_layout_class): Likewise. + (emit_assertion_table): Likewise. + * typeck.c (has_method): Rename argument. + +2008-06-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (ident_subst, mangled_classname, unmangle_classname, + gen_indirect_dispatch_tables, add_method_1, + build_fieldref_cache_entry, make_local_function_alias, + layout_class, java_treetreehash_find, java_treetreehash_new, + split_qualified_name): Fix for -Wc++-compat. + * constants.c (set_constant_entry, cpool_for_class): Likewise. + * decl.c (make_binding_level, java_dup_lang_specific_decl, + start_java_method): Likewise. + * except.c (prepare_eh_table_type): Likewise. + * expr.c (type_assertion_hash, note_instructions): Likewise. + * java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC, + MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Likewise. + * jcf-io.c (jcf_filbuf_from_stdio, opendir_in_zip, find_class): + Likewise. + * jcf-parse.c (reverse, java_read_sourcefilenames, + annotation_grow, rewrite_reflection_indexes, java_parse_file, + process_zip_dir): Likewise. + * jcf-path.c (add_entry, add_path, jcf_path_init, + jcf_path_extdirs_arg): Likewise. + * jcf-reader.c (jcf_parse_constant_pool): Likewise. + * jvgenmain.c (do_mangle_classname): Likewise. + * lang.c (put_decl_string): Likewise. + * verify-impl.c (make_state_copy, make_state, add_new_state): + Likewise. + +2008-06-15 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + + * gcj.texi: Expand TABs, remove whitespace from blank lines. + +2008-06-14 Tom Tromey <tromey@redhat.com> + + PR java/36247: + * class.c (build_class_ref): Initialize this_classdollar when + needed. + +2008-05-23 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (give_name_to_class): Call find_sourcefile to find full + pathname of source file. + +2008-05-12 Aaron W. LaFramboise <aaronavay62@aaronwl.com> + + * jcf-dump.c (print_constant): Use + HOST_LONG_LONG_FORMAT. + +2008-05-07 Kenneth Zadeck <zadeck@naturalbridge.com> + + * decl.c (java_init_decl_processing): Change DECL_IS_PURE to + DECL_PURE_P. + +2008-04-23 Paolo Bonzini <bonzini@gnu.org> + + * class.c (build_utf8_ref): Don't set TREE_INVARIANT. + (build_classdollar_field): Don't set TREE_INVARIANT. + (get_dispatch_table): Don't set TREE_INVARIANT. + (make_class_data): Don't set TREE_INVARIANT. + (build_symbol_entry): Don't set TREE_INVARIANT. + (emit_symbol_table): Don't set TREE_INVARIANT. + * constants.c (build_constant_data_ref): Don't set TREE_INVARIANT. + (build_ref_from_constant_pool): Don't set TREE_INVARIANT. + * resource.c (compile_resource_data): Don't set TREE_INVARIANT. + * expr.c (cache_cpool_data_ref): Don't set TREE_INVARIANT. + +2008-04-03 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java_OBJS): New variable. + +2008-04-03 Paolo Bonzini <bonzini@gnu.org> + + * java-tree.h (insert_block): Kill. + * decl.c (insert_block): Kill. + +2008-04-01 Joseph Myers <joseph@codesourcery.com> + + * gcj.texi: Include gpl_v3.texi instead of gpl.texi + * Make-lang.in (TEXI_JAVA_FILES): Include gpl_v3.texi instead of + gpl.texi. + +2008-03-27 Tom Tromey <tromey@redhat.com> + + * Make-lang.in: Revert automatic dependency patch. + +2008-03-25 Tom Tromey <tromey@redhat.com> + + * Make-lang.in: Removed most explicit .o targets. + (java/jvspec.o): Reduce to variable setting. Moved to java/. + ($(GCJ)$(exeext)): Update. + (JAVA_OBJS): New variable. + (JCFDUMP_OBJS): Reformat. + (java_OBJS): New variable. + (java/jvspec.o-warn): Update. + (java/parse.o-warn): Remove. + (JAVA_TREE_H): Remove. + (java/jcf-io.o): Reduce to variable setting. + (ALL_CPPFLAGS): Likewise. + +2008-03-12 Paolo Bonzini <bonzini@gnu.org> + + * mangle.c (java_mangle_decl): Remove dead check. + +2008-03-11 Paolo Bonzini <bonzini@gnu.org> + + * jcf-parse.c (java_parse_file): Assert binding levels are + left in order. + * lang.c (LANG_HOOKS_CLEAR_BINDING_STACK, java_clear_binding_stack): + Delete. + +2008-03-02 Jakub Jelinek <jakub@redhat.com> + + * jcf-dump.c (version): Update copyright notice dates. + +2008-02-29 Tom Tromey <tromey@redhat.com> + + * expr.c (expand_byte_code): Set DECL_FUNCTION_LAST_LINE on + method. + * java-tree.h (struct lang_decl_func): Remove obsolete comment. + +2008-02-26 Tom Tromey <tromey@redhat.com> + + * lang.c (java_post_options): Remove conditional. + * expr.c (expand_byte_code): Remove old location code. + * jcf-parse.c (set_source_filename): Remove old location code. + (give_name_to_class): Likewise. + (jcf_parse): Likewise. + (duplicate_class_warning): Likewise. + (parse_class_file): Likewise. + (java_parse_file): Likewise. + * decl.c (finish_method): Remove old location code. + * class.c (push_class): Remove old location code. + +2008-02-06 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + PR other/35107 + * Make-lang.in (jc1): Add $(GMPLIBS). + +2008-01-23 David Daney <ddaney@avtrex.com> + + * class.c (hide) Rename to... + (java_hide_decl) ... this throughout, and make public. + * resource.c (Jr_count): Remove. + (compile_resource_data): Call java_mangle_resource_name to generate + decl name. Make resource decl public and hidden. + * mangle.c (java_mangle_resource_name): New function. + * java-tree.h (java_hide_decl, java_mangle_resource_name): Declare + functions. + +2008-01-04 Andrew Haley <aph@redhat.com> + + PR java/17779 + * jcf-parse.c (parse_zip_file_entries): Move decl to compile on + C90. + +2008-01-03 Andrew Haley <aph@redhat.com> + + PR java/17779 + * jcf-parse.c (parse_zip_file_entries): Unset TYPE_ALIAS_SET if + we're about to re-layout the type. + +2007-12-20 Alexandre Oliva <aoliva@redhat.com> + + * lang.c (java_classify_record): Don't return + RECORD_IS_INTERFACE for now. + +2007-12-18 Andrew Haley <aph@redhat.com> + + PR java/27643 + * jcf-parse.c (java_parse_file): Remove call to + java_mark_class_local. + (parse_class_file): Reinstate call to java_mark_class_local here. + * decl.c (java_mark_cni_decl_local): If the ASSEMBLER_NAME is + already set, call java_mangle_decl() and make_decl_rtl() to + rewrite its name as a hidden alias. + +2007-12-15 Alexandre Oliva <aoliva@redhat.com> + + PR debug/7081 + * lang.c (java_classify_record): New. + (LANG_HOOKS_CLASSIFY_RECORD): Override. + +2007-11-26 Andreas Krebbel <krebbel1@de.ibm.com> + + PR 34081/C++ + * decl.c (finish_method): Pass 'false' for the new + allocate_struct_function parameter. + +2007-11-26 Alexandre Oliva <aoliva@redhat.com> + + * expr.c (build_jni_stub): Use the computed jni func type for + variable meth. + +2007-11-26 Alexandre Oliva <aoliva@redhat.com> + + * class.c (JAVA_TREEHASHHASH_H): Use TYPE_UID. + +2007-11-26 Alexandre Oliva <aoliva@redhat.com> + + * expr.c (type_assertion_hash): Hash type uids rather than + tree pointers. + +2007-11-17 David Daney <ddaney@avtrex.com> + Andrew Haley <aph@redhat.com> + + * constants.c (build_constants_constructor): Use POINTER_SIZE + insead of BITS_PER_WORD in big-endian work around. + +2007-11-07 Tom Tromey <tromey@redhat.com> + + PR java/34019: + * gcj.texi (Input Options): Add missing noun. + +2007-11-02 Tom Tromey <tromey@redhat.com> + + PR java/33765: + * jcf-parse.c (java_parse_file): Ignore ZIPEMPTYMAGIC files. + * zipfile.h (ZIPEMPTYMAGIC): New define. + +2007-11-01 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java/jcf-dump.o): Depend on zipfile.h. + (java/jcf-parse.o): Depend on jcf-reader.c, zipfile.h, and jcf.h. + (java/jcf-io.o): Depend on zipfile.h. + +2007-10-17 Richard Guenther <rguenther@suse.de> + + * Make-lang.in (java/builtins.o): Add $(OPTABS_H) and $(EXPR_H) + dependencies. + +2007-10-03 Andrew Haley <aph@redhat.com> + + PR java/33639 + * class.c (mangled_classname): Detect and replace illegal + characters in assembly language symbols. + (gen_indirect_dispatch_tables): Call mangled_classname() on + the type. + +2007-09-27 Jakub Jelinek <jakub@redhat.com> + + * lang.c (java_print_error_function): Add third argument. + +2007-09-15 Tom Tromey <tromey@redhat.com> + + * java-tree.h (struct lang_decl_func) <function_decl_body>: + Remove. + <init_final>: Likewise. + * lang.c (java_dump_tree): Update. + * java-tree.h (DECL_FUNCTION_BODY): Remove. + +2007-09-11 Jan Hubicka <jh@suse.cz> + + * decl.c (java_expand_body): Kill. + (LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION): Kill. + +2007-09-06 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (parse_class_file): Re-enter the current file. + +2007-09-07 Roman Zippel <zippel@linux-m68k.org> + + * boehm.c (mark_reference_fields): Move misaligned pointer check + after JREFERENCE_TYPE_P test + +2007-09-06 Roman Zippel <zippel@linux-m68k.org> + + * boehm.c (mark_reference_fields): Don't use bitmap as gc_descr + if pointer is misaligned. + +2007-09-06 Tom Tromey <tromey@redhat.com> + + * lang.c (java_post_options): Update. + * jcf-parse.c (set_source_filename): Update. + (give_name_to_class): Update. + (jcf_parse): Update. + (duplicate_class_warning): Update. + (parse_class_file): Update. + (java_parse_file): Update. + * expr.c (expand_byte_code): Update. + +2007-09-05 Sandra Loosemore <sandra@codesourcery.com> + + * decl.c (finish_method): Use set_cfun. + +2007-09-04 Andrew Haley <aph@redhat.com> + + * decl.c (java_init_decl_processing): Call "__cxa_end_cleanup" + when using the ARM EABI. + +2007-09-03 Daniel Jacobowitz <dan@codesourcery.com> + + * Make-lang.in (jvspec.o): Remove SHLIB_MULTILIB. + +2007-09-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-parse.c (read_class, java_parse_file): Supply a TYPE for + CONST_CAST. + * jcf.h (JCF_FINISH): Likewise. + +2007-08-28 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java.tags): Don't tag '*.y' files. + +2007-08-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lang.c (java_decl_ok_for_sibcall): Likewise. + +2007-08-21 Paul Brook <paul@codesourcery.com> + Nathan Sidwell <nathan@codesourcery.com> + Mark Mitchell <mark@codesourcery.com> + Joseph Myers <joseph@codesourcery.com> + + * jcf-dump.c (version): Use pkgversion_string. Update copyright + date. + +2007-08-20 Richard Guenther <rguenther@suse.de> + + * lang.c (java_tree_inlining_walk_subtrees): Remove. + (LANG_HOOKS_TREE_INLINING_WALK_SUBTREES): Remove. + +2007-08-17 Tom Tromey <tromey@redhat.com> + + * typeck.c (find_method_in_interfaces): Update. + * jcf-parse.c (load_class): Update. + * java-gimplify.c (java_gimplify_component_ref): Removed. + (java_gimplify_modify_expr): Update. Removed pre_p and post_p + arguments. + (java_gimplify_expr): Update. + * decl.c (java_init_decl_processing): Update. + * class.c (set_constant_value): Update. + (make_class_data): Update. + (finish_class): Update. + (build_static_field_ref): Update. + (is_compiled_class): Update. + (maybe_layout_super_class): Update. + (layout_class): Update. + (layout_class_method): Update. + * java-tree.h (CAN_COMPLETE_NORMALLY): Removed. + (lang_decl_var) <am, final_iud, cif>: Removed fields. + (lang_decl_func) <init_calls_this>: Removed field. + (lang_type) <dot_class, verify_method>: Removed fields. + (FIELD_NESTED_ACCESS): Removed. + (FIELD_NESTED_ACCESS_P): Removed. + (DECL_FIELD_FINAL_IUD): Removed. + (DECL_LOCAL_FINAL_IUD): Removed + (LOCAL_FINAL_P): Removed. + (FINAL_VARIABLE_P): Removed. + (CLASS_FINAL_VARIABLE_P): Removed. + (DECL_BIT_INDEX): Removed. + (DECL_INIT_CALLS_THIS): Removed. + (FIELD_LOCAL_ALIAS): Removed. + (FIELD_LOCAL_ALIAS_USED): Removed. + (FIELD_THISN): Removed. + (DECL_FUNCTION_INIT_TEST_CLASS): Removed. + (LOCAL_CLASS_INITIALIZATION_FLAG): Removed. + (LOCAL_CLASS_INITIALIZATION_FLAG_P): Removed. + (TYPE_DOT_CLASS): Removed. + (TYPE_VERIFY_METHOD): Removed. + (ID_CLASSDOLLAR_P): Removed. + (enum java_tree_index) <JTI_CLASSDOLLAR_IDENTIFIER_NODE>: + Removed. + (classdollar_identifier_node): Removed. + (TYPE_UNKNOWN): Removed. + (CLASS_FROM_SOURCE_P): Removed. + * expr.c (build_jni_stub): Update. + (force_evaluation_order): Update. + (build_java_empty_stmt): Update. + (build_class_init): Update. + (java_stack_swap): Update. + (build_jni_stub): Update. + +2007-08-17 Tom Tromey <tromey@redhat.com> + + * java-tree.h (LABEL_TYPE_STATE): Removed. + (load_type_state): Removed. + (LABEL_PC): Removed. + (LABEL_VERIFIED): Removed. + (type_states): Declare. + * expr.c (type_states): New global. + (load_type_state): Now static. Use type_states. Changed + argument. + (lookup_label): Don't set LABEL_PC. + (expand_byte_code): Don't use LABEL_VERIFIED. + (note_instructions): Initialize type_states. + * verify-glue.c (vfy_note_stack_depth): Rewrote. + (vfy_note_stack_type): Use type_states. + (vfy_note_local_type): Likewise. + +2007-08-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-parse.c (read_class, java_parse_file): Use CONST_CAST. + * jcf.h (JCF_FINISH): Likewise. + +2007-07-31 Nick Clifton <nickc@redhat.com> + + * java-gimplify.c: Change copyright header to refer to version 3 + of the GNU General Public License and to point readers at the + COPYING3 file and the FSF's license web page. + * typeck.c, lang-specs.h, mangle_name.c, jcf-dump.c, class.c, + decl.c, config-lang.in, jcf-parse.c, constants.c, Make-lang.in, + resource.c, except.c, builtins.c, jvspec.c, java-tree.def, + javaop.def, jcf-path.c, verify-glue.c, jcf-depend.c, lang.opt, + jcf-reader.c, mangle.c, zextract.c, jcf-io.c, jcf.h, zipfile.h, + verify.h, java-except.h, win32-host.c, expr.c, jvgenmain.c, + parse.h, lang.c, java-tree.h, javaop.h, boehm.c: Likewise. + +2007-07-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-io.c (find_class): Fix -Wcast-qual warnings. + +2007-07-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lang.c (java_get_callee_fndecl): Constify. + +2007-07-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * mangle.c (set_type_package_list): Constify. + * verify-glue.c (vfy_make_string): Delete. + * verify.h (vfy_make_string): Likewise. + +2007-07-26 Tom Tromey <tromey@redhat.com> + + * java-tree.h (push_labeled_block, pop_labeled_block): Remove. + (LABELED_BLOCK_LABEL, LABELED_BLOCK_BODY, + EXIT_BLOCK_LABELED_BLOCK): Likewise. + * lang.c (java_tree_inlining_walk_subtrees): Update. + (java_dump_tree): Likewise. + * java-tree.def (LABELED_BLOCK_EXPR, EXIT_BLOCK_EXPR, TRY_EXPR): + Remove. + * decl.c (push_labeled_block, pop_labeled_block): Remove. + * java-gimplify.c (java_gimplify_labeled_block_expr, + java_gimplify_exit_block_expr, java_gimplify_try_expr): Remove. + (java_gimplify_expr): Update. + +2007-07-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (java_treetreehash_hash, java_treetreehash_compare): + Constify. + * expr.c (type_assertion_eq): Likewise. + * jcf-io.c (compare_path): Likewise. + * jcf-parse.c (cmpstringp): Likewise. + * verify-impl.c (get_one_type, compute_argument_types, + compute_return_type): Likewise. + +2007-07-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + PR target/32462 + PR libgcj/32465 + * class.c (hide): Wrap in HAVE_GAS_HIDDEN. + +2007-07-12 Richard Guenther <rguenther@suse.de> + + * expr.c (expand_java_return): RETURN_EXPR has void type. + (build_jni_stub): Likewise. Use a comparison against zero + for null-pointer test in COND_EXPR. + (build_field_ref): Build POINTER_PLUS_EXPR with correct + type. Convert result instead. + (build_invokevirtual): Likewise. + +2007-07-09 Geoffrey Keating <geoffk@apple.com> + + PR 32617 + * lang.c (java_init): Remove setting of force_align_functions_log. + * class.c (add_method_1): Set DECL_ALIGN of non-static method + to cope with ptrmemfunc_vbit_in_pfn. + +2007-07-03 David Daney <ddaney@avtrex.com> + + * java/Make-lang.in (doc/gcj.info): Add $(gcc_docdir) to + include path. + (doc/gcj.dvi): Same. + (doc/gcj.pdf): Same. + (java/index.html): Same. + +2007-06-15 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * class.c (make_class_data): Build the index in sizetype. + Use POINTER_PLUS_EXPR instead of PLUS_EXPR when + adding to a pointer type. + (build_symbol_entry): Likewise. + * expr.c (build_java_arrayaccess): Likewise. + (build_field_ref): Likewise. + (build_known_method_ref): Likewise. + (build_invokevirtual): Likewise. + * except.c (build_exception_object_ref): Do a + NEGATIVE and then a POINTER_PLUS_EXPR instead + of a MINUS_EXPR. + +2007-06-11 Rafael Ávila de Espíndola <espindola@google.com> + + * typeck.c (java_signed_type): Remove. + * lang.c (LANG_HOOKS_SIGNED_TYPE): Remove. + * java-tree.h (java_signed_type): Remove. + +2007-05-18 Geoffrey Keating <geoffk@apple.com> + + * jcf-dump.c (HANDLE_MAGIC): Use 'unsigned long' for %lx. + (print_constant): Likewise. + +2007-05-14 Rafael Ávila de Espíndola <espindola@google.com> + + * expr.c (build_java_binop): Use unsigned_type_for instead of + java_unsigned_type. + * java-tree.h (java_unsigned_type): Remove. + * lang.c (LANG_HOOKS_UNSIGNED_TYPE): Remove. + * typeck.c (java_unsigned_type): Remove. + +2007-04-21 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * java-tree.h (lang_tree_node): Use GENERIC_NEXT + instead of checking GIMPLE_STMT_P in chain_next. + +2007-04-06 Colin Walters <walters@redhat.com> + + https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=161701 + * jcf-io.c (open_class): Copy 'filename'. + +2007-04-03 Andrew Haley <aph@redhat.com> + + * jvgenmain.c (main): Change main to use class$, not class$$. + (do_mangle_classname): Likewise. + * class.c (hide): New function. + (add_field): Hide everything that shouldn't be visible outside a + DSO. + (build_static_class_ref): Likewise. + (build_classdollar_field): Likewise. + (make_class_data): Likewise. + (layout_class_method): Likewise. + * expr.c (special_method_p): New function. + + * class.c (push_class): Don't bogusly guess the source filename. + * jcf-parse.c (give_name_to_class): Don't set input_location from + DECL_ARTIFICIAL decls. + +2007-03-30 Rafael Ávila de Espíndola <espindola@google.com> + + * typeck.c (java_signed_or_unsigned_type): Removed. + (java_signed_type): use get_signed_or_unsigned_type instead of + java_signed_or_unsigned_type. + (java_unsigned_type): Ditto. + * lang.c (LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): Removed. + * java-tree.h (java_signed_or_unsigned_type): Removed. + +2007-03-26 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (JAVA_MANFILES): Removed grmiregistry.1. + (java.maintainer-clean): Likewise. + (java.install-man): Likewise. + (.INTERMEDIATE): Removed grmiregistry.pod. + (grmiregistry.pod): Removed. + * gcj.texi (Invoking gcjh): Removed. + (Invoking gjnih): Likewise. + (Invoking grmiregistry): Likewise. + (direntry): Updated. + (Top): Likewise. + (which-gcj): Removed. + +2007-03-01 Brooks Moses <brooks.moses@codesourcery.com> + + * Make-lang.in: Add install-pdf target as copied from + automake v1.10 rules. + +2007-02-27 Brooks Moses <brooks.moses@codesourcery.com> + + * gcj.texi: Standardize title page. + +2007-02-18 Kazu Hirata <kazu@codesourcery.com> + + * class.c: Fix a comment typo. + +2007-02-15 Sandra Loosemore <sandra@codesourcery.com> + Brooks Moses <brooks.moses@codesourcery.com> + Lee Millward <lee.millward@codesourcery.com> + + * java-tree.h (BUILD_MONITOR_ENTER): Use build_call_nary instead + of build3. + (BUILD_MONITOR_EXIT): Likewise. + + * java-gimplify.c (java_gimplify_component_ref): Use build_call_expr. + (java_gimplify_modify_expr): Likewise. + + * class.c (cache_this_class_ref): Use build_call_expr. + (build_static_field_ref): Likewise. + (emit_indirect_register_classes): Likewise. + (emit_register_classes): Likewise. + + * resource.c (write_resource_constructor): Use build_call_expr. + + * builtins.c (builtin_creator_function): Change interpretation of + the second parameter to be the whole CALL_EXPR instead of the arglist. + (max_builtin): Tweak parameter list. Use new CALL_EXPR accessors. + (min_builtin): Likewise. + (abs_builtin): Likewise. + (java_build_function_call_expr): Likewise. + (convert_real): Likewise. + (UNMARSHAL3): Likewise. + (UNMARSHAL4): Likewise. + (UNMARSHAL5): Likewise. + (build_arglist_for_builtin): Delete. Fix callers to use + build_call_expr instead. + (putObject_builtin): Tweak parameter list. Use new CALL_EXPR + accessors. + (compareAndSwapInt_builtin): Likewise. + (compareAndSwapLong_builtin): Likewise. + (compareAndSwapObject_builtin): Likewise. + (putVolatile_builtin): Likewise. + (getVolatile_builtin): Likewise. + (VMSupportsCS8_builtin): Likewise. + (check_for_builtin): Pass entire CALL_EXPR to builtin expander + instead of arglist. + + * expr.c (build_java_athrow): Use build_call_nary instead of build3. + (build_java_throw_out_of_bounds_exception): Likewise. + (java_check_reference): Likewise. + (build_java_arraystore_check): Likewise. + (build_newarray): Likewise. + (build_anewarray): Likewise. + (expand_java_multinewarray): Use build_call_list instead of build3. + (build_java_monitor): Use build_call_nary instead of build3. + (java_create_object): Likewise. + (expand_java_NEW): Likewise. + (build_instanceof): Likewise. + (expand_java_CHECKCAST): Likewise. + (build_java_soft_divmod): Likewise. + (build_java_binop): Likewise. + (build_field_ref): Likewise. + (build_class_init): Likewise. + (rewrite_arglist_getcaller): Use build_call_expr. + (build_invokeinterface): Use build_call_nary instead of build3. + (expand_invoke): Use build_call_list instead of build3. + (build_jni_stub): Use build_call_nary, build_call_list, or + build_call_expr instead of build3. + (expand_java_field_op): Use build_call_expr instead of build3. + (force_evaluation_order): Use new CALL_EXPR accessors. + + * lang.c (java_get_callee_fndecl): Use new CALL_EXPR accessors. + +2007-02-15 David Daney <ddaney@avtrex.com> + + * Make-lang.in (JAVA_MANFILES): Add doc/gc-analyze.1. + (java.maintainer-clean):Add gc-analyze.1. + (.INTERMEDIATE): Add gc-analyze.pod. + (gc-analyze.pod): New rule. + (java.install-man): Install gc-analyze.1 + * gcj.texi: Add new section for the gc-analyze program. + +2007-02-07 Andrew Haley <aph@redhat.com> + + * class.c (uncache_this_class_ref): New. + * expr.c (build_jni_stub): Initialize the class. + (expand_byte_code): Call uncache_this_class_ref after generating + code. + +2007-02-06 Tom Tromey <tromey@redhat.com> + + PR java/30714: + * jvspec.c (lang_specific_driver): Check for the '-' in '-I'. + +2007-02-03 Kazu Hirata <kazu@codesourcery.com> + + * java-tree.h, javaop.def, jcf-parse.c: Fix comment typos. + +2007-02-02 Andrew Haley <aph@redhat.com> + + * expr.c (expand_byte_code): Call cache_this_class_ref() and + cache_cpool_data_ref(). + Set TYPE_CPOOL_DATA_REF. + (cache_cpool_data_ref): New function. + * constants.c (build_ref_from_constant_pool): Remove special-case + code for flag_indirect_classes. + (build_constant_data_ref): Move special-case code for + flag_indirect_classes here from build_ref_from_constant_pool. + * decl.c (finish_method): Move class initialization from here to + cache_this_class_ref. + * class.c (cache_this_class_ref): New function. + (build_class_ref): Use this_classdollar for the ouput class. + +2007-02-02 David Daney <ddaney@avtrex.com> + + * class.c (is_compiled_class): Move check to avoid reloading + current class. + (layout_class_method): Don't calculate DECL_EXTERNAL if it is + already set. + +2007-02-01 Andrew Haley <aph@redhat.com> + + PR java/30641 + * jcf-parse.c (jcf_parse): Clear the field_offsets bitmap. + +2007-01-31 Kazu Hirata <kazu@codesourcery.com> + + * class.c, jcf-parse.c: Fix comment typos. + +2007-01-30 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Strings): Fix documentation for JvNewString. + +2007-01-30 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + + * gcj.texi (Invoking gcjh, Invoking gjnih, Arrays): Fix some + typos. + +2007-01-30 Ben Elliston <bje@au.ibm.com> + + * jvspec.c (lang_specific_driver): Remove unused classpath_args. + +2007-01-29 Tom Tromey <tromey@redhat.com> + + PR java/30607: + * jvspec.c (lang_specific_driver): Handle separate -I argument. + * lang.opt (-I): Add 'Separate'. + +2007-01-29 Andrew Haley <aph@redhat.com> + + * class.c (add_method_1): Mark fndecl as external unless we are + compiling it into this object file. + +2007-01-24 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (HANDLE_SYNTHETIC_ATTRIBUTE): current_class is a + type node, not a decl, so use TYPE_SYNTHETIC not CLASS_SYNTHETIC. + +2007-01-22 Andrew Haley <aph@redhat.com> + + * builtins.c (VMSupportsCS8_builtin): New function. + +2007-01-23 Andrew Pinski <pinskia@gmail.com> + + PR java/30454 + * jcf-io.c (opendir_in_zip): Close the file + and free zipf before returning after an error. + +2007-01-16 Tom Tromey <tromey@redhat.com> + + * java-tree.def: Added copyright header. + +2007-01-15 Tom Tromey <tromey@redhat.com> + + * lang.c (dump_compound_expr) <EXPR_WITH_FILE_LOCATION>: Removed + case. + * java-gimplify.c (java_gimplify_expr) <EXPR_WITH_FILE_LOCATION>: + Removed case. + * java-tree.h (EXPR_WFL_EMIT_LINE_NOTE): Removed. + (EXPR_WFL_NODE): Likewise. + (EXPR_WFL_LINECOL): Likewise. + (EXPR_WFL_FILENAME): Likewise. + (EXPR_WFL_LINENO): Likewise. + (build_expr_wfl, expr_add_location): Don't declare. + (build_unknown_wfl): Removed. + (EXPR_WFL_FILENAME_NODE): Removed. + (EXPR_WFL_COLNO): Removed. + (EXPR_WFL_SET_LINECOL): Removed. + (DECL_FUNCTION_WFL): Removed. + (DECL_FIELD_FINAL_WFL): Removed. + (struct lang_decl_func) <wfl>: Removed field. + <called_constructor>: Likewise. + <inner_access>: Likewise. + (struct lang_decl_var) <wfl>: Removed field. + (DECL_CONSTRUCTOR_CALLS): Removed. + (DECL_FUNCTION_ACCESS_DECL): Likewise. + (DECL_FUNCTION_INNER_ACCESS): Likewise. + (DECL_SPECIFIC_COUNT): Likewise. + * java-tree.def (EXPR_WITH_FILE_LOCATION): Removed. + * expr.c (build_expr_wfl): Removed. + (expr_add_location): Likewise. + +2007-01-12 Tom Tromey <tromey@redhat.com> + + * jcf-dump.c (main): Updated call to find_class. + * lang.c (java_init): Removed dead code. + * jcf-parse.c (read_class): Don't use java_source field. Removed + dead code. + (parse_zip_file_entries): Don't use java_source field. + (process_zip_dir): Likewise. + (jcf_parse): Removed dead code. + (java_parse_file): Likewise. + (read_class): Updated call to find_class. + * jcf-io.c (find_class): Don't use java_source field. Removed + 'source_ok' argument, .java logic. + * jcf.h (JCF) <java_source>: Removed field. + (JCF_ZERO): Updated. (find_class): Updated. + * decl.c: Removed dead code. + * class.c: Removed dead code. + +2007-01-11 Tom Tromey <tromey@redhat.com> + + * typeck.c (convert): Don't use flag_emit_class_files. + * lang.c (java_post_options): Don't use flag_emit_class_files. + (java_handle_option): Don't use flag_extraneous_semicolon or + flag_redundant. + * jcf-parse.c (HANDLE_CONSTANTVALUE): Don't use + flag_emit_class_files. + (load_class): Likewise. + * java-tree.h (flag_emit_class_files): Don't declare. + (STATIC_CLASS_INIT_OPT_P): Don't use flag_emit_class_files. + (flag_extraneous_semicolon): Don't declare. + (flag_not_overriding): Likewise. + (flag_static_local_jdk1_1): Likewise. + (flag_redundant): Likewise. + * expr.c (build_newarray): Don't use flag_emit_class_files. + * class.c (DEFAULT_ENABLE_ASSERT): Don't use + flag_emit_class_files. + (build_class_ref): Likewise. + * builtins.c (check_for_builtin): Don't use + flag_emit_class_files. + +2007-01-10 Tom Tromey <tromey@redhat.com> + + * lang.c (java_can_use_bit_fields_p): Removed. + (LANG_HOOKS_CAN_USE_BIT_FIELDS_P): Removed. + +2007-01-09 Andrew Haley <aph@redhat.com> + + * expr.c (build_java_arrayaccess): Rewrite to generate array + access in canonical form. + (expand_java_arraystore): Use build_fold_addr_expr() on address of + array access. + +2007-01-03 Andrew Haley <aph@redhat.com> + + PR java/28754 + * expr.c (expand_java_field_op): If we're initializing a field's + declaring interface we should not also initialize the class + context in which it was referenced. + +2007-01-02 Tom Tromey <tromey@redhat.com> + + * java-tree.h (compiling_from_source, current_encoding, + JTI_FINIT_IDENTIFIER_NODE, JTI_INSTINIT_IDENTIFIER_NODE, + JTI_LENGTH_IDENTIFIER_NODE, JTI_SUPER_IDENTIFIER_NODE, + JTI_CONTINUE_IDENTIFIER_NODE, JTI_ACCESS0_IDENTIFIER_NODE, + JTI_WFL_OPERATOR): Removed + (finit_identifier_node, instinit_identifier_node, + length_identifier_node, super_identifier_node, + continue_identifier_node, access0_identifier_node, wfl_operator): + Removed. + (cyclic_inheritance_report, + DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND, + DECL_FUNCTION_NAP, DECL_FUNCTION_SYNTHETIC_CTOR, + DECL_FIXED_CONSTRUCTOR_P): Removed. + (struct lang_decl_func) <smic, nap, synthetic_ctor, fixed_ctor>: + Removed. + (TYPE_FINIT_STMT_LIST, TYPE_CLINIT_STMT_LIST, TYPE_II_STMT_LIST, + TYPE_IMPORT_LIST, TYPE_IMPORT_DEMAND_LIST): Removed. + (struct lang_type) <finit_stmt_list, clinit_stmt_list, ii_block, + import_list, import_demand_list>: Removed. + (java_layout_seen_class_methods, init_jcf_parse, init_src_parse, + cxx_keyword_p): Removed. + (DECL_FINIT_P, DECL_INSTINIT_P, ID_FINIT_P, ID_INSTINIT_P, + TYPE_UNUSED, TYPE_UNDERFLOW, TYPE_UNEXPECTED, + CLASS_ACCESS0_GENERATED_P, CLASS_HAS_FINIT_P, + IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P, IS_A_CLASSFILE_NAME, + IS_AN_IMPORT_ON_DEMAND_P, COMPOUND_ASSIGN_P, SWITCH_HAS_DEFAULT, + PRIMARY_P, MODIFY_EXPR_FROM_INITIALIZATION_P, + CLASS_METHOD_CHECKED_P, FOR_LOOP_P, ANONYMOUS_CLASS_P, + LOCAL_CLASS_P, ARG_FINAL_P, SUPPRESS_UNREACHABLE_ERROR, + RESOLVE_PACKAGE_NAME_P, RESOLVE_TYPE_NAME_P, IS_BREAK_STMT_P, + IS_CRAFTED_STRING_BUFFER_P, IS_INIT_CHECKED, CALL_USING_SUPER, + NESTED_FIELD_ACCESS_IDENTIFIER_P, TOPLEVEL_CLASS_DECL_P, + PURE_INNER_CLASS_TYPE_P, TOPLEVEL_CLASS_TYPE_P, + CALL_CONSTRUCTOR_P, CALL_EXPLICIT_CONSTRUCTOR_P, + CALL_THIS_CONSTRUCTOR_P, CALL_SUPER_CONSTRUCTOR_P, + FINALLY_EXPR_LABEL, FINALLY_EXPR_BLOCK, BLOCK_IS_IMPLICIT, + BLOCK_EMPTY_P, IS_UNCHECKED_EXCEPTION_P, java_error_count, + java_parse_abort_on_error, extract_field_decl): Removed. + (finput): Declare. + * lang.c: (compiling_from_source, current_encoding): Removed. + (java_handle_option): Ignore -fencoding. + * parse.h: Don't include lex.h. + (java_error_count, int_fits_type_p, stabilize_reference, RULE, + RECOVERED, DRECOVERED, RECOVER, DRECOVER, YYERROR_NOW, + YYNOT_TWICE, CLASS_MODIFIERS, FIELD_MODIFIERS, METHOD_MODIFIERS, + INTERFACE_MODIFIERS, INTERFACE_INNER_MODIFIERS, + INTERFACE_METHOD_MODIFIERS, INTERFACE_FIELD_MODIFIERS, + MODIFIER_WFL, THIS_MODIFIER_ONLY, parse_error_context, + ABSTRACT_CHECK, JCONSTRUCTOR_CHECK, exit_java_complete_class, + CLASS_OR_INTERFACE, GET_REAL_TYPE, GET_TYPE_NAME, + OBSOLETE_MODIFIER_WARNING, OBSOLETE_MODIFIER_WARNING2, + BUILD_PTR_FROM_NAME, INCOMPLETE_TYPE_P, + JAVA_MAYBE_GENERATE_DEBUG_INFO, JBSC_TYPE_P, JSTRING_P, + JNULLP_TYPE_P, JDECL_P, TYPE_INTERFACE_P, TYPE_CLASS_P, + IDENTIFIER_INNER_CLASS_OUTER_FIELD_ACCESS, + MANGLE_OUTER_LOCAL_VARIABLE_NAME, + MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID, + MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STRING, + SKIP_THIS_AND_ARTIFICIAL_PARMS, MARK_FINAL_PARMS, + UNMARK_FINAL_PARMS, CRAFTED_PARAM_LIST_FIXUP, + AIPL_FUNCTION_CREATION, AIPL_FUNCTION_DECLARATION, + AIPL_FUNCTION_CTOR_INVOCATION, AIPL_FUNCTION_FINIT_INVOCATION, + ERROR_CANT_CONVERT_TO_BOOLEAN, ERROR_CANT_CONVERT_TO_NUMERIC, + ERROR_CAST_NEEDED_TO_INTEGRAL, ERROR_VARIABLE_NOT_INITIALIZED, + LOOP_EXPR_BODY_MAIN_BLOCK, LOOP_EXPR_BODY_UPDATE_BLOCK, + LOOP_EXPR_BODY_CONDITION_EXPR, LOOP_EXPR_BODY_LABELED_BODY, + LOOP_EXPR_BODY_BODY_EXPR, PUSH_LABELED_BLOCK, POP_LABELED_BLOCK, + PUSH_LOOP, POP_LOOP, PUSH_EXCEPTIONS, POP_EXCEPTIONS, + IN_TRY_BLOCK_P, EXCEPTIONS_P, ANONYMOUS_ARRAY_BASE_TYPE, + ANONYMOUS_ARRAY_DIMS_SIG, ANONYMOUS_ARRAY_INITIALIZER, + INVOKE_STATIC, INVOKE_NONVIRTUAL, INVOKE_SUPER, INVOKE_INTERFACE, + INVOKE_VIRTUAL, jdep_code, struct _jdep, JDEP_DECL, JDEP_DECL_WFL, + JDEP_KIND, JDEP_WFL, JDEP_MISC, JDEP_ENCLOSING, JDEP_CLASS, + JDEP_APPLY_PATCH, JDEP_GET_PATCH, JDEP_CHAIN, JDEP_TO_RESOLVE, + JDEP_RESOLVED_DECL, JDEP_RESOLVED, JDEP_RESOLVED_P, struct + jdeplist_s, jdeplists, CLASSD_FIRST, CLASSD_LAST, CLASSD_CHAIN, + JDEP_INSERT, SET_TYPE_FOR_RESOLUTION, WFL_STRIP_BRACKET, + STRING_STRIP_BRACKETS, PROMOTE_RECORD_IF_COMPLETE, + BLOCK_CHAIN_DECL, GET_CURRENT_BLOCK, EXPR_WFL_GET_LINECOL, + EXPR_WFL_QUALIFICATION, QUAL_WFL, QUAL_RESOLUTION, QUAL_DECL_TYPE, + GET_SKIP_TYPE, COMPLETE_CHECK_OP, COMPLETE_CHECK_OP_0, + COMPLETE_CHECK_OP_1, COMPLETE_CHECK_OP_2, BUILD_APPEND, + BUILD_STRING_BUFFER, BUILD_THROW, SET_WFL_OPERATOR, + PATCH_METHOD_RETURN_ERROR, CHECK_METHODS, CLEAR_DEPRECATED, + CHECK_DEPRECATED_NO_RESET, CHECK_DEPRECATED, REGISTER_IMPORT, + CURRENT_OSB, struct parser_ctxt, GET_CPC_LIST, CPC_INNER_P, + GET_CPC, GET_CPC_UN, GET_CPC_UN_MODE, GET_CPC_DECL_NODE, + GET_ENCLOSING_CPC, GET_NEXT_ENCLOSING_CPC, + GET_ENCLOSING_CPC_CONTEXT, INNER_ENCLOSING_SCOPE_CHECK, PUSH_CPC, + PUSH_ERROR, POP_CPC, DEBUG_CPC, CPC_INITIALIZER_LIST, + CPC_STATIC_INITIALIZER_LIST, CPC_INSTANCE_INITIALIZER_LIST, + CPC_INITIALIZER_STMT, CPC_STATIC_INITIALIZER_STMT, + CPC_INSTANCE_INITIALIZER_STMT, SET_CPC_INITIALIZER_STMT, + SET_CPC_STATIC_INITIALIZER_STMT, + SET_CPC_INSTANCE_INITIALIZER_STMT, JAVA_NOT_RADIX10_FLAG, + java_complete_class, java_check_circular_reference, + java_fix_constructors, java_layout_classes, java_reorder_fields, + java_method_add_stmt, java_get_line_col, reset_report, + java_init_lex, yyparse, java_parse, yyerror, java_expand_classes, + java_finish_classes, ctxp, ctxp_for_generation, + ctxp_for_generation_last): Removed. + * expr.c (force_evaluation_order): Don't mention NEW_CLASS_EXPR. + * mangle.c (utf8_cmp): New function. + (cxx_keywords): New global. + (cxx_keyword_p): New function. + * jvspec.c (JAVA_START_CHAR): Removed obsolete comment. + * java-tree.def (UNARY_PLUS_EXPR, NEW_ARRAY_EXPR, + NEW_ANONYMOUS_ARRAY_EXPR, NEW_CLASS_EXPR, THIS_EXPR, + CASE_EXPR, DEFAULT_EXPR, JAVA_CATCH_EXPR, SYNCHRONIZED_EXPR, + THROW_EXPR, CONDITIONAL_EXPR, INSTANCEOF_EXPR, NEW_ARRAY_INIT, + CLASS_LITERAL, JAVA_EXC_OBJ_EXPR): Removed. + * Make-lang.in (java.srcextra): Do nothing. + (parse.c, keyword.h, gt-java-parse.h): Removed targets. + (JAVA_OBJS): Don't mention deleted files. + (java.mostlyclean): Likewise. + (java.clean): Likewise. + (JAVA_LEX_C): Removed. + (buffer.o, check-init.o, parse.o): Remove unused targets. + (typeck.o): Updated. + * jcf-parse.c (read_class): Comment out unused code. + (java_layout_seen_class_methods): New function. + (parse_source_file_1, parse_source_file_2, parse_source_file_3): + Removed. + (java_parse_file): Comment out unused code. Don't use 'ctxp'. + (init_jcf_parse): Removed. + * config-lang.in (gtfiles): Remove deleted files. + * decl.c (java_init_decl_processing): Don't initialize + finit_identifier_node, instinit_identifier_node, + length_identifier_node, super_identifier_node, + continue_identifier_node, access0_identifier_node. Don't call + init_jcf_parse. + * class.c (cyclic_inheritance_report): New global. + (add_method_1): Don't use + DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND. + (maybe_layout_super_class): Comment out code. + (safe_layout_class): New function. + * java-gimplify.c (java_gimplify_expr): Removed CASE_EXPR, + DEFAULT_EXPR, NEW_ARRAY_INIT, JAVA_CATCH_EXPR, JAVA_EXC_OBJ_EXPR, + UNARY_PLUS_EXPR, NEW_ARRAY_EXPR, NEW_ANONYMOUS_ARRAY_EXPR, + NEW_CLASS_EXPR, SYNCHRONIZED_EXPR, CONDITIONAL_EXPR, + INSTANCEOF_EXPR, CLASS_LITERAL, THIS_EXPR. + (java_gimplify_case_expr): Removed. + (java_gimplify_default_expr): Likewise. + (java_gimplify_new_array_init): Likewise. + * parse.y: Removed. + * keyword.gperf, keyword.h: Removed. + * chartables.h: Removed. + * check-init.c: Removed. + * buffer.c, buffer.h: Removed. + * convert.h: Removed. + * gen-table.pl: Removed. + * lex.c, lex.h: Removed. + +2007-01-02 Andrew Haley <aph@redhat.com> + + * expr.c (expand_java_arraystore): Make sure we perform a bounds + check at runtime before we perform a type check. + +2006-12-19 Andrew Haley <aph@redhat.com> + + * decl.c: Bump minor BC ABI version. + +2006-12-13 Gary Benson <gbenson@redhat.com> + + * jcf-depend.c (jcf_dependency_add_file): Mark filename unused. + +2006-12-12 Tom Tromey <tromey@redhat.com> + + * lang-specs.h: Pass -M options to jc1. + * jcf-depend.c (jcf_dependency_add_file): Don't emit + dependencies. + +2006-12-07 Mohan Embar <gnustuff@thisiscool.com> + + * jcf-path.c (jcf_path_compute): Use platform PATH_SEPARATOR. + +2006-12-06 Mohan Embar <gnustuff@thisiscool.com> + + * lang-specs.h: Pass '%U'-based options as separate arguments. + +2006-12-05 Tom Tromey <tromey@redhat.com> + + PR java/29495: + * jcf-parse.c (HANDLE_SYNTHETIC_ATTRIBUTE): Mark fields and + classes as well. + * class.c (add_field): Handle ACC_SYNTHETIC. + (add_method_1): Likewise. Handle bridge and varargs. + (get_access_flags_from_decl): Handle synthetic, bridge, varargs, + annotation. + (set_class_decl_access_flags): Handle synthetic and annotation. + * java-tree.h (METHOD_BRIDGE): New macro. + (METHOD_VARARGS): Likewise. + (TYPE_SYNTHETIC): Likewise. + (TYPE_ANNOTATION): Likewise. + (lang_type): New fields 'synthetic' and 'annotation'. + (lang_decl_func): New fields 'varargs' and 'bridge'. + +2006-12-04 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (rewrite_reflection_indexes): Don't do anything if + there's no map. + +2006-11-29 Gary Benson <gbenson@redhat.com> + + * expr.c (rewrite_arglist_getcaller): Reorder. + +2006-11-29 Andrew Haley <aph@redhat.com> + + * expr.c (rewrite_arglist_getcaller): Remove DECL_INLINE. + * lang.c (java_decl_ok_for_sibcall): Check for DECL_INLINE. + +2006-11-23 Andrew Haley <aph@redhat.com> + + * expr.c (rewrite_arglist_getcaller): New. + (rewrite_arglist_getclass): Fix indentation. + (rules): Add gnu.classpath.VMStackWalker.getCallingClass() and + gnu.classpath.VMStackWalker.getCallingClassLoader(). + * builtins.c (initialize_builtins): Remove duplicate def'n of + __sync_synchronize. + Add __builtin_return_address. + +2006-11-22 Andrew Haley <aph@redhat.com> + + * jcf-reader.c (get_attribute): Mark attr_type unused. + + * builtins.c (compareAndSwapObject_builtin): Fix declaration. + +2007-01-08 Richard Guenther <rguenther@suse.de> + + * lex.c (do_java_lex): Use build_int_cst_wide_type. + * jcf-parse.c (get_constant): Likewise. + +2006-11-12 Jan Hubicka <jh@suse.cz> + + * resource.c (compile_resource_data): Update for new varpool names. + * java/class.c (build_utf8_ref): Likewise. + +2006-11-12 David Daney <ddaney@avtrex.com> + + PR java/29805 + * typeck.c (build_java_array_type): Increase buffer sizes. + +2006-11-11 Richard Guenther <rguenther@suse.de> + + * check-init.c (check_init): Remove handling of FIX_CEIL_EXPR, + FIX_FLOOR_EXPR and FIX_ROUND_EXPR. + +2006-11-06 Andrew Haley <aph@redhat.com> + + * java-tree.h (CONSTANT_LazyFlag): New. + * constants.c (build_constants_constructor): Mask CONSTANT_LazyFlag. + * jcf-parse.c (handle_innerclass_attribute): Write attribute to + reflection_data. + (handle_constant): Return 0 for dummy cpool entries. + Handle constants of kind Class. + Handle constants of kind NameAndType. + (handle_enclosingmethod_attribute): New. + (handle_signature_attribute): New. + (HANDLE_ENCLOSINGMETHOD_ATTRIBUTE): New. + (HANDLE_SIGNATURE_ATTRIBUTE): New. + (handle_constant): Use unmangle_classname()rather than calling + identifier_subst() directly. + +2006-11-02 Andrew Haley <aph@redhat.com> + + * java-tree.h (FIELD_ENUM): New. + (lang_decl_var.field_enum): New. + (lang_type.enum_class): New. + (CLASS_ENUM): New. + * class.c (set_class_decl_access_flags): Handle enum types. + (add_field): Handle enum fields. + (get_access_flags_from_decl): Likewise. + + * class.c (make_class_data): Put reflection_data into rodata. + +2006-11-01 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (field_offsets, bit_obstack): New variables. + (jcf_parse): Write end marker to annotation_data. + (java_parse_file): Create field_offsets bitmap. Destroy it. + (annotation_grow, annotation_rewrite_byte) + (annotation_rewrite_short, annotation_rewrite_int) + (annotation_read_short, annotation_write_byte) + (annotation_write_short, annotation_write_int) + (handle_long_constant, handle_constant, handle_element_value) + (handle_annotation, handle_annotations) + (handle_annotation_attribute, rewrite_reflection_indexes) + (handle_member_annotations, handle_parameter_annotations) + (handle_default_annotation): New functions. + (HANDLE_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE) + (HANDLE_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE) + (HANDLE_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE) + (HANDLE_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE) + (HANDLE_ANNOTATIONDEFAULT_ATTRIBUTE): New definitions. + * java-tree.h (enum jv_attr_type, enum jv_attr_kind): New. + (TYPE_REFLECTION_DATA): New. + (TYPE_REFLECTION_DATASIZE): New. + * jcf.h (enum cpool_tag): Convert a bunch of #define constants to + an enum. + * jcf-reader.c (get_attribute): Pass field/method index and + attribute type to get_attribute(). + * constants.c (find_class_or_string_constant): Make nonstatic. + (cpool_for_class): Likewise. + (build_constants_constructor): Separate string and scalar types. + * class.c (make_class_data): Generate field_indexes permutation. + Pass it to rewrite_reflection_indexes(). + (make_class_data): Generate constructor for reflection_data field. + +2006-10-20 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Top): Don't mention jv-scan. + (Invoking gcj): Likewise. + (Invoking gcjh): Likewise. + (Invoking gjnih): Likewise. + (Invoking gij): Likewise. + (Invoking gcj-dbtool): Likewise. + (Invoking jv-scan): Removed. + * parse-scan.y: Removed. + * jv-scan.c: Removed. + * config-lang.in (stagestuff): Don't mention jv-scan. + * Make-lang.in (java): Removed jv-scan. + (JAVA_TARGET_INDEPENDENT_BIN_TOOLS): Likewise. + (JVSCAN_OBJS): Removed. + (jv-scan$(exeext)): Likewise. + (JAVA_MANFILES): Removed jv-scan.1. + (java.uninstall): Don't mention jv-scan. + (java.mostlyclean): Likewise. + (java.maintainer-clean): Likewise. + (.INTERMEDIATE): Likewise. + (java/jv-scan.o): Removed. + (jv-scan.pod): Likewise. + (java.srcextra): Don't mention parse-scan.c. + (java.mostlyclean): Likewise. + (java/parse-scan.c): Removed. + (java/parse-scan.o-warn): Removed. + (java/parse-scan.o): Removed. + +2006-10-20 Tom Tromey <tromey@redhat.com> + + * lang.c (java_handle_option): Don't use + jcf_write_base_directory. + * jcf.h (jcf_write_base_directory): Removed. + * parse.y (java_expand_classes): Don't call write_classfile. + * config-lang.in (gtfiles): Removed jcf-write.c. + * Make-lang.in (JAVA_OBJS): Removed jcf-write.o. + (java/jcf-write.o): Removed. + * jcf-parse.c (parse_class_file): Don't call write_classfile. + * java-tree.h (write_classfile): Removed declaration. + * jcf-write.c: Removed. + +2006-10-20 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java): Removed gjnih, gcjh. + (JAVA_TARGET_INDEPENDENT_BIN_TOOLS): Likewise. + (GCJH_OBJS): Removed. + (GJNIH_OBJS): Likewise. + (gjnih$(exeext)): Likewise. + (gcjh$(exeext)): Likewise. + (JAVA_MANFILES): Removed gcjh.1, gjnih.1. + (java.install-common): Don't special case gcjh. + (java.uninstall): Don't mention gcjh, gjnih. + (java.mostlyclean): Likewise. + (java.maintainer-clean): Likewise. + (.INTERMEDIATE): Likewise. + (gcjh.pod): Removed. + (gjnih.pod): Likewise. + (GCJH_TARGET_INSTALL_NAME): Removed. + (java/gjavah-jni.o): Removed. + (java/gjavah.o): Likewise. + * config-lang.in (stagestuff): Removed gjnih, gcjh. + * gjavah.c: Removed. + +2006-10-17 Tom Tromey <tromey@redhat.com> + + * jcf-dump.c (print_element_value): Expect a utf8 constant in the + "string" case. + +2006-10-17 Tom Tromey <tromey@redhat.com> + + * jvgenmain.c (main): Handle -findirect-dispatch. + * jvspec.c (jvgenmain_spec): Pass -findirect-dispatch to + jvgenmain. + +2006-10-06 Andrew Haley <aph@redhat.com> + + * builtins.c (compareAndSwapInt_builtin): Check that we really do + have a compare_and_swap builtin. + (compareAndSwapLong_builtin): Likewise. + (compareAndSwapObject_builtin): Likewise. + +2006-10-04 Andrew Haley <aph@redhat.com> + + * builtins.c (java_builtins): Add compareAndSwapInt, + compareAndSwapLong, compareAndSwapObject, putOrderedInt, + putOrderedLong, putOrderedObject, putIntVolatile, putLongVolatile, + putObjectVolatile, getObjectVolatile, getIntVolatile, + getLongVolatile, getLong. + (UNMARSHAL3): New macro. + (UNMARSHAL4): Likewise. + (UNMARSHAL5): Likewise. + (build_arglist_for_builtin): New function. + (build_addr_sum, build_check_this): New functions. + (putObject_builtin. compareAndSwapInt_builtin, + compareAndSwapLong_builtin, compareAndSwapObject_builtin, + putVolatile_builtin, getVolatile_builtin): New builtins. + +2006-06-08 Andrew Haley <aph@redhat.com> + + * expr.c (build_field_ref): Pass NULL_TREE as SPECIAL arg to + get_symbol_table_index(). + (maybe_rewrite_invocation): Set SPECIAL if we need to access a + private method. + (build_known_method_ref): New arg: special. Pass it to + get_symbol_table_index. + (get_symbol_table_index): Put SPECIAL in the TREE_PURPOSE field of + the method list. + (build_invokevirtual): New arg: special. Pass it to + get_symbol_table_index. + (expand_invoke): New variable: special. + Pass it to maybe_rewrite_invocation(). + Pass it to build_known_method_ref(). + * class.c (build_symbol_entry): Add new arg: special. Use it to + build the symbol table conbstructor. + (emit_symbol_table): Extract SPECIAL from the method list and pass + it to build_symbol_entry(). + * parse.y (patch_invoke): Call maybe_rewrite_invocation() and set + special accordingly. + +2006-09-08 Andrew Haley <aph@redhat.com> + + * class.c (layout_class_method): Use build_java_signature, not + build_java_argument_signature. Use lookup_java_method, not + lookup_argument_method. + +2006-08-16 Jakub Jelinek <jakub@redhat.com> + Bryce McKinlay <bryce@mckinlay.net.nz> + + * jvspec.c (lang_specific_driver): Add -s-bc-abi when needed. + +2006-07-18 Tom Tromey <tromey@redhat.com> + + * lang.opt: Added missing -W options. + +2006-07-12 Tom Tromey <tromey@redhat.com> + + PR java/28329: + * lang-specs.h: Pass '%U'-based options as separate arguments. + Use -faux-classpath. + * lang.c (java_handle_option): Handle OPT_faux_classpath. + * lang.opt (faux-classpath): New option. + +2006-07-07 Tom Tromey <tromey@redhat.com> + + * class.c (make_class_data): Set value for reflection_data field. + * decl.c (java_init_decl_processing): Add reflection_data field. + +2006-07-07 Tom Tromey <tromey@redhat.com> + + * jcf-dump.c (HANDLE_ENCLOSINGMETHOD_ATTRIBUTE): Declare locals + earlier. + (HANDLE_SIGNATURE_ATTRIBUTE): Likewise. + +2006-07-07 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (set_source_filename): Don't check for + CLASS_FROM_CURRENTLY_COMPILED_P. + Remove // comments. + +2006-07-07 Andrew Haley <aph@redhat.com> + + * java-tree.h (java_read_sourcefilenames): Declare. + * lang.c (java_handle_option): Call java_read_sourcefilenames(). + * lang.opt (fsource-filename): New opt. + * lang-specs.h: Add -fsource-filename. + * jcf-parse.c (num_files, filenames): New variables. + (reverse, cmpstringp, java_read_sourcefilenames, + find_sourcefile): New. + (set_source_filename): Call find_sourcefile to find the real name + of a source file. + +2006-06-27 Tom Tromey <tromey@redhat.com> + + * jcf-reader.c (get_attribute): Handle EnclosingMethod, + Signature, LocalVariableTypeTable, annotation attributes. + * jcf-dump.c (HANDLE_ENCLOSINGMETHOD_ATTRIBUTE): New macro. + (HANDLE_SIGNATURE_ATTRIBUTE): Likewise. + (HANDLE_START_FIELD): Mention 'descriptor', not 'signature'. + (HANDLE_METHOD): Likewise. + (HANDLE_LOCALVARIABLETYPETABLE_ATTRIBUTE): New macro. + (print_annotation): New function. + (print_element_value): Likewise. + (indent): Likewise. + (HANDLE_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE): New macro. + (HANDLE_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE): Likewise. + (print_parameter_annotations): New function. + (HANDLE_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE): New macro. + (HANDLE_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE): + Likewise. + (HANDLE_ANNOTATIONDEFAULT_ATTRIBUTE): Likewise. + (print_annotations): New function. + +2006-06-23 Tom Tromey <tromey@redhat.com> + + * lang-specs.h: Default -fsource and -ftarget to 1.5. If + emitting class files, always use 1.5. + * gcj.texi (Input Options): Document -fsource. + (Code Generation): Document -ftarget. + +2006-06-21 Tom Tromey <tromey@redhat.com> + + PR java/28089: + * expr.c (expand_java_field_op): Initialize field's declaring + class. + +2006-06-20 Tom Tromey <tromey@redhat.com> + + * expr.c (push_value): Always flush quick stack. + +2006-06-19 Tom Tromey <tromey@redhat.com> + + * expr.c (push_value): Also flush quick stack if value is a + component_ref. + +2006-06-19 Tom Tromey <tromey@redhat.com> + + * expr.c (push_value): Flush quick stack if value has side + effects. + +2006-06-13 Tom Tromey <tromey@redhat.com> + + * class.c (is_compiled_class): Explicitly check for current + class. + +2006-06-09 Tom Tromey <tromey@redhat.com> + + * gjavah.c (decompile_method): Don't decompile a static field + accessor method. + +2006-06-06 Tom Tromey <tromey@redhat.com> + + * lang-specs.h <jc1>: Add .jar file to command line if + -fsaw-java-file. Also, remove -ffilelist-file in this case. + +2006-06-05 Tom Tromey <tromey@redhat.com> + + * jcf-dump.c (print_access_flags): Handle varargs, bridge, + synthetic, enum, annotation. + * jcf.h (ACC_BRIDGE): New macro. + (ACC_VARARGS): Likewise. + (ACC_SYNTHETIC): Likewise. + (ACC_ENUM): Likewise. + (ACC_ANNOTATION): Likewise. + +2006-06-04 Tom Tromey <tromey@redhat.com> + + * lang.opt (-fsaw-java-file, -fsource, -ftarget): New options. + * jvspec.c (jvgenmain_spec): Remove -fsaw-java-file, -fsource, + and -ftarget. + (lang_specific_driver): Removed dead code. Add -fsaw-java-file + when needed. Handle classpath-setting. + * Make-lang.in ($(GCJ)$(exeext)): Link in jcf-path.o. + * lang-specs.h: Rewrote. + +2006-06-04 Tom Tromey <tromey@redhat.com> + + * jcf-io.c (find_class): Set source_ok to 0. + * jcf-parse.c (jcf_parse): Disable gnu.gcj.gcj-compiled warning. + (parse_class_file): Don't call java_mark_class_local. + (java_parse_file): Skip .java files. Call java_mark_class_local + before lowering any code. + (parse_zip_file_entries): Don't call duplicate_class_warning + here. + (process_zip_dir): ... call it here. + * class.c (add_field): Don't mark field external if it is being + compiled into this object. + (make_class_data): Handle situation where class_dtable_decl is + created before Class is compiled. + (is_compiled_class): Don't assume files in zip are compiled into + this object. + (layout_class_method): Don't mark method external if it is being + compiled into this object. + +2006-06-04 Tom Tromey <tromey@redhat.com> + + * jcf-path.c (jcf_path_compute): New function. + * jcf.h (jcf_path_compute): Declare. + +2006-10-23 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + + * decl.c: Include langhooks.h. + (builtin_function): Remove. + (java_init_decl_processing): Replace calls to builtin_function + with add_builtin_function. + * Make-lang.in (jc1$(exeext)): Depend on and link with attribs.o. + (java/decl.o): Depend on langhooks.h. + * java-tree.h (builtin_function): Remove. + +2006-10-10 Brooks Moses <bmoses@stanford.edu> + + * Make-lang.in: Added "java.pdf", "gcj.pdf" target support. + +2006-09-12 Tom Tromey <tromey@redhat.com> + + * expr.c (push_value): Always flush quick stack. + +2006-09-12 Tom Tromey <tromey@redhat.com> + + PR java/29013: + * jcf-write.c (generate_bytecode_insns) <CALL_EXPR>: Always note + the push of the called method's return result. + +2006-09-12 Tom Tromey <tromey@redhat.com> + + * jvspec.c (lang_specific_driver): Read spec file even if + -fsyntax-only. + +2006-09-12 Tom Tromey <tromey@redhat.com> + + PR java/28754: + * expr.c (expand_java_field_op): Initialize field's declaring + interface if necessary. + +2006-09-12 Tom Tromey <tromey@redhat.com> + + PR java/28892: + * expr.c (expand_java_field_op): No error for assignments not in + class initializer or constructor. + +2006-08-22 Andrew Haley <aph@redhat.com> + + * decl.c (java_add_stmt): Give the statement list a type. + +2006-08-16 Jakub Jelinek <jakub@redhat.com> + Bryce McKinlay <bryce@mckinlay.net.nz> + + * jvspec.c (lang_specific_driver): Add -s-bc-abi when needed. + +2006-08-10 Simon Martin <simartin@users.sourceforge.net> + + PR java/8923 + * parse.y (build_incdec): Emit an error instead of an ICE if '++' + or '--' is used with a constant operand. + (java_complete_lhs): When processing a '++' or '--' expression, + don't call java_complete_tree but java_complete_lhs, so that a + static final variable operand is never replaced by its value. This + avoids an ICE later on. + (patch_unaryop): Fixed typo in comment. + +2006-07-28 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + + * Make-lang.in: Use $(HEADER_H) instead of header.h in dependencies. + +2006-07-12 Bryce McKinlay <mckinlay@redhat.com> + + * builtins.c (check_for_builtin): If a builtin could result in a + direct call being generated, don't use it if flag_indirect_dispatch + is set. + +2006-07-12 Bryce McKinlay <mckinlay@redhat.com> + + * gcj.texi (Invocation): Corrections for Invocation API example. + +2006-07-04 Andrew Haley <aph@redhat.com> + + * class.c (build_fieldref_cache_entry): Set DECL_IGNORED_P on the + entry. + +2006-06-21 Andrew Haley <aph@redhat.com> + + * java-tree.h (update_aliases): Remove + * expr.c (expand_iinc): Remove call to update_aliases(). + (STORE_INTERNAL): Likewise. + * decl.c (update_aliases, initialize_local_variable) + (maybe_pushlevels): Set DECL_VALUE_EXPR for debugging decls. + +2006-06-19 Andrew Haley <aph@redhat.com> + + PR java/1305 + PR java/27908 + * expr.c (java_modify_addr_for_volatile): New function. + (expand_java_field_op): Handle volatile fields. + * java-gimplify.c (java_gimplify_component_ref): Call + java_modify_addr_for_volatile to give the field_ref the correct + volatile type. + (java_gimplify_modify_expr): Likewise. + * java-tree.h (java_modify_addr_for_volatile): New decl. + +2006-06-17 Karl Berry <karl@gnu.org> + + * gcj.texi (@dircategory): Use "Software development" instead + of "Programming", following the Free Software Directory. + +2006-06-16 Andrew Haley <aph@redhat.com> + + * class.c (make_class_data): When using flag_indirect_classes, + don't initialize the vtable of Class instances. + +2006-06-09 Andrew Haley <aph@redhat.com> + + PR java/1305 + PR java/27908 + * builtins.c (initialize_builtins): Add __sync_synchronize(). + * class.c (add_field): Mark volatile fields. + * java-gimplify.c (java_gimplify_expr): Call new functions to + handle self-modifying exprs and COMPONENT_REFs. + (java_gimplify_component_ref): New. + (java_gimplify_modify_expr): Add handling for volatiles. + +2006-06-08 Tom Tromey <tromey@redhat.com> + + * gcj.texi (libgcj Runtime Properties): Document + gnu.gcj.user.realname. + +2006-06-08 Andrew Haley <aph@redhat.com> + + * expr.c (build_field_ref): Pass NULL_TREE as SPECIAL arg to + get_symbol_table_index(). + (maybe_rewrite_invocation): Set SPECIAL if we need to access a + private method. + (build_known_method_ref): New arg: special. Pass it to + get_symbol_table_index. + (get_symbol_table_index): Put SPECIAL in the TREE_PURPOSE field of + the method list. + (build_invokevirtual): New arg: special. Pass it to + get_symbol_table_index. + (expand_invoke): New variable: special. + Pass it to maybe_rewrite_invocation(). + Pass it to build_known_method_ref(). + * class.c (build_symbol_entry): Add new arg: special. Use it to + build the symbol table conbstructor. + (emit_symbol_table): Extract SPECIAL from the method list and pass + it to build_symbol_entry(). + * parse.y (patch_invoke): Call maybe_rewrite_invocation() and set + special accordingly. + +2006-06-06 David Daney <ddaney@avtrex.com> + + * gcj.texi (libgcj Runtime Properties): Document + gnu.gcj.runtime.NameFinder.show_raw and + gnu.gcj.runtime.NameFinder.remove_unknown. + +2006-06-06 Tom Tromey <tromey@redhat.com> + + * jcf-dump.c (print_access_flags): Handle varargs, bridge, + synthetic, enum, annotation. + * jcf.h (ACC_BRIDGE): New macro. + (ACC_VARARGS): Likewise. + (ACC_SYNTHETIC): Likewise. + (ACC_ENUM): Likewise. + (ACC_ANNOTATION): Likewise. + +2006-06-06 Mike Stump <mrs@apple.com> + + * Make-lang.in: Rename to htmldir to build_htmldir to avoid + installing during build. + +2006-05-31 Thomas Fitzsimmons <fitzsim@redhat.com> + + * gcj.texi (Extensions): Document the new gcj-dbtool-based + classname-to-library resolution mechanism. + Declare the old gnu.gcj.runtime.VMClassLoader.library_control + mechanism deprecated. + (libgcj Runtime Properties): Document + gnu.gcj.runtime.VMClassLoader.library_control's new default. + +2006-05-29 Jakub Jelinek <jakub@redhat.com> + + * javaop.h (int16, int32, int64): Define to exactly 16 (resp. 32, 64) + bit wide type. + (jword): Define to uint64 on 64-bit arches. + * jcf-dump.c (print_constant): Cast JPOOL_UINT to long. + +2006-05-28 Kazu Hirata <kazu@codesourcery.com> + + * class.c, except.c, expr.c, java-gimplify.c: Fix comment + typos. + +2006-05-26 Tom Tromey <tromey@redhat.com> + + * expr.c (java_push_constant_from_pool): Handle 'ldc class'. + * verify-glue.c (vfy_class_type): New function. + * verify-impl.c (check_constant): Allow 'ldc class'. + * verify.h (vfy_class_type): Declare. + +2006-05-25 Andrew Haley <aph@redhat.com> + + PR java/27756 + * decl.c (maybe_pushlevels): When variable ranges are non-nested + update all lifetimes, not just the first one. + +2006-05-24 Tom Tromey <tromey@redhat.com> + + * java-tree.h: Fixed flag documentation. + +2006-05-24 Tom Tromey <tromey@redhat.com> + + PR libgcj/27729: + * jcf.h (ACC_INVISIBLE): Changed value. + +2006-05-24 Andrew Haley <aph@redhat.com> + + PR java/27754 + * decl.c (java_add_stmt): Use a STATEMENT_LIST rather than a + COMPOUND_EXPR. + +2006-05-16 H.J. Lu <hongjiu.lu@intel.com> + + * lang.opt (femit-class-file): Remove VarExists. + +2006-05-16 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (verify_instructions_0) <op_return>: Special case + for Object.<init>. + +2006-05-16 H.J. Lu <hongjiu.lu@intel.com> + + PR driver/26885 + * Make-lang.in ($(GCJ)$(exeext)): Replace gcc.o with + $(GCC_OBJS). + +2006-05-14 H.J. Lu <hongjiu.lu@intel.com> + + * Make-lang.in (java/decl.o): Add dependency on $(TARGET_H). + (java/expr.o): Replace target.h with $(TARGET_H). + (java/parse.o): Likewise. + +2006-05-10 Andrew Haley <aph@redhat.com> + + * class.c (emit_indirect_register_classes): Fix comment. + +2006-05-04 Tom Tromey <tromey@redhat.com> + + * java-tree.h (uses_jv_markobj_p): Declare. + * class.c (uses_jv_markobj_p): Removed. + * boehm.c (PROCEDURE_OBJECT_DESCRIPTOR): New define. + (get_boehm_type_descriptor): Use it. + (uses_jv_markobj_p): Moved from class.c. Return bool. + +2006-05-04 Tom Tromey <tromey@redhat.com> + + * java-tree.def (THIS_EXPR): Now a tcc_expression. + +2006-05-04 Andrew Haley <aph@redhat.com> + + * class.c (make_field_value): Always build_address_of fdecl if + there is an initializer. + +2006-05-03 Andrew Haley <aph@redhat.com> + + PR libgcj/27352 + * expr.c (maybe_rewrite_invocation): New function. + (rewrite_arglist_getclass): Likewise. + (rules): New. + (expand_invoke): Call maybe_rewrite_invocation. + * parse.y (patch_invoke): Likewise. + * java-tree.h: (maybe_rewrite_invocation): New function. + +2006-04-21 Andrew Haley <aph@redhat.com> + + * lang.c (java_init): Handle flag_indirect_classes. + * jvgenmain.c: Use "class$$" instead of "class$". + * mangle.c (java_mangle_decl): Accept RECORD_TYPEs sw well as + DECLs. + (mangle_class_field): Special case "class$$" as well as "class$". + * constants.c (build_ref_from_constant_pool): If + flag_indirect_classes, generate a ref into the heap. + * decl.c (constants_field_decl_node, + constants_data_field_decl_node): New. + * class.c (build_static_class_ref): New. + (build_classdollar_field): Factor out from build_class_ref(). + (make_field_value): Handle static fields in heap. + (make_class_data): Make sure we get a static ref to class. + Make class initializer const if flag_indirect_classes. + (register_class): Build a class_ref for initialization if + flag_indirect_classes. + (emit_indirect_register_classes): New. + +2006-04-08 Kazu Hirata <kazu@codesourcery.com> + + * expr.c, gjavah.c: Fix comment typos. + +2006-04-03 Andrew Haley <aph@redhat.com> + + PR java/26858 + * expr.c (build_field_ref): Don't check the field offset if + flag_syntax_only. + +2006-03-30 Andrew Haley <aph@redhat.com> + + PR java/26858 + * lang.c (java_attribute_table): New. + (LANG_HOOKS_ATTRIBUTE_TABLE): Define. + * expr.c (build_field_ref): Add a null pointer check for all + fields of offset > 4k. Don't do so for accesses via the this + pointer, which we know can never be null. + * class.c (build_java_method_type): Mark arg 1 of all nonstatic + methods nonnull. + +2006-03-30 Carlos O'Donell <carlos@codesourcery.com> + + * Make-lang.in: Rename docdir to gcc_docdir. + +2006-03-30 Tom Tromey <tromey@redhat.com> + + PR java/26042: + * parse.y (java_reorder_fields): Reset superclass field's size as + well. + +2006-03-28 Tom Tromey <tromey@redhat.com> + + PR java/26390: + * parse.y (find_most_specific_methods_list): Added 'class' + argument. + (lookup_method_invoke): Updated. + +2006-03-15 Tom Tromey <tromey@redhat.com> + + * jcf-write.c (generate_bytecode_insns): Use qualifying type for + non-static method calls. + +2006-03-15 David Daney <ddaney@avtrex.com> + + * java-tree.h : Moved comment for TYPE_DOT_CLASS adjacent to its + declaration. + +2006-03-15 David Daney <ddaney@avtrex.com> + + * lang.opt (-freduced-reflection): New option. + * lang.c (java_post_options): Generate an error if + -freduced-reflection used with -fjni or -findirect-dispatch. + * java-tree.h (flag_reduced_reflection): Declare new variable. + * boehm.c (get_boehm_type_descriptor): Indicate all pointers + if bitmap overflows and flag_reduced_reflection set. + * class.c (uses_jv_markobj_p): New function. + (make_class_data): Moved generation of vtable to before + reflection data, generate less reflection data if + flag_reduced_reflection set. + * gcj.texi: Document -freduced-reflection. + +2006-03-15 Tom Tromey <tromey@redhat.com> + + PR java/26638: + * class.c (get_interface_method_index): Don't put <clinit> into + interface table. + +2006-03-15 Tom Tromey <tromey@redhat.com> + + * parse.y (analyze_clinit_body): Ignore empty statements. + +2006-03-08 David Daney <ddaney@avtrex.com> + + * gcj.texi: Document -static-libgcj option. + +2006-02-20 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (parse_class_file): Set input_location from + current_class. + +2006-02-15 Andrew Haley <aph@redhat.com> + + * class.c (GEN_TABLE): Don't pushdecl *_SYMS_DECL here. + (make_class_data): pushdecl_top_level TYPE_OTABLE_SYMS_DECL, + TYPE_ATABLE_SYMS_DECL, TYPE_ITABLE_SYMS_DECL here. + +2006-02-09 Andrew Haley <aph@redhat.com> + + PR java/26192 + * expr.c (expand_invoke): Allow methods in arrays to be resolved + in their superclass. + + * typeck.c (build_java_array_type): Generate TYPE_STUB_DECLs for + array types. + +2006-02-08 Tom Tromey <tromey@redhat.com> + + PR java/22578: + * check-init.c (check_init): Handle VIEW_CONVERT_EXPR. + * builtins.c (convert_real): New function. + (java_builtins): Handle Float.intBitsToFloat, + Float.floatToRawIntBits, Double.longBitsToDouble, + Double.doubleToRawLongBits. + +2006-02-07 Andrew Haley <aph@redhat.com> + + * expr.c (expand_invoke): (BC mode.) If we find a method in a + class other than the one in which we expected to find it, ignore + the result. + + PR java/25535 + * constants.c (build_constants_constructor): move initializer into + first halfword on a 64-bit big-endian machine. + +2006-02-04 Tom Tromey <tromey@redhat.com> + + PR java/25676: + * builtins.c (max_builtin): Skip floating point 'max'. + (min_builtin): Skip floating point 'min'. + (check_for_builtin): Never return NULL_TREE. + +2006-02-04 Tom Tromey <tromey@redhat.com> + + PR java/26097: + * expr.c (push_type): Avoid side effect in gcc_assert. + +2006-02-04 Roger Sayle <roger@eyesopen.com> + + * decl.c (java_init_decl_processing): Create char_type_node as a + regular INTEGER_TYPE node. + (push_promoted_type): Preserve TYPE_STRING_FLAG on types. + * typeck.c (convert): No longer check for CHAR_TYPEs but instead + test for char_type_node and promoted_char_type_node as special + instances of INTEGER_TYPE tree codes. + (promote_type,build_java_signature): Likewise. + * jcf-write.c (adjust_typed_op): Likewise. + * mangle.c (mangle_type): Likewise. + * parse.y (do_unary_numeric_promotion): No longer handle CHAR_TYPE. + * parse.h (JINTEGRAL_TYPE_P): Likewise. + +2006-02-04 Andreas Tobler <a.tobler@schweiz.ch> + + * expr.c (java_stack_swap): Revert gcc_assert patch. + +2006-02-03 Ben Elliston <bje@au.ibm.com> + + * java-gimplify.c: Use gcc_assert and gcc_unreachable throughout. + * typeck.c: Likewise. + * verify-impl.c: Likewise. + * class.c: Likewise. + * decl.c: Likewise. + * jcf-parse.c: Likewise. + * constants.c: Likewise. + * check-init.c: Likewise. + * jcf-write.c: Likewise. + * verify-glue.c: Likewise. + * mangle.c: Likewise. + * expr.c: Likewise. + * lang.c: Likewise. + * boehm.c: Likewise. + +2006-02-01 Jan Hubicka <jh@suse.cz> + + * decl.c (end_java_method): Kill hack disabling unit-at-a-time. + * lang.c (java_init_options): Set no_unit_at_a_time_default. + +2006-01-30 Andrew Haley <aph@redhat.com> + + PR java/21428 + * parse.y: (source_start_java_method): Mark DECL_ARTIFICIAL("this"). + +2006-01-21 Joseph S. Myers <joseph@codesourcery.com> + + * jv-scan.c (version), jcf-dump.c (version), gjavah.c (version): + Update copyright notice dates. + +2006-01-16 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + + * jvspec.c (lang_specific_spec_functions): Remove. + +2006-01-06 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Arrays): Added more documentation for + JvNewObjectArray. + (Primitive types): Correct information about primitive classes. + (Reference types): New node. + (Index): New node. + +2005-12-16 Alexandre Oliva <aoliva@redhat.com> + + * jcf-parse.c (set_source_filename): Set the decl source location + even when returning early. + +2005-12-15 Tom Tromey <tromey@redhat.com> + Andrew Haley <aph@redhat.com> + + PR java/25429 + * parse.y (resolve_expression_name): Don't generate accessor + methods for constant fields. + +2005-12-13 Andrew Haley <aph@redhat.com> + + PR java/25366 + PR java/25368 + * class.c (maybe_layout_super_class): Update current_class before + calling do_resolve_class. + +2005-12-12 H.J. Lu <hongjiu.lu@intel.com> + + PR java/25330 + * jcf-write.c (write_classfile): Use PID in temporary class + file. Save/restore errno when reporting error. + +2005-12-10 Terry Laurenzo <tlaurenzo@gmail.com> + + PR java/9861 + * mangle.c (mangle_method_decl): Mangle Java methods by prepending 'J' + to bare_function_type and including the return type + * builtins.c (initialize_builtins) : Change builtin mangled name + constants to conform to new mangling scheme + +2005-12-08 Andrew Haley <aph@redhat.com> + + PR libgcj/25265 + * java-tree.h (enum java_tree_index): Add JTI_SOFT_NOSUCHFIELD_NODE. + (soft_abstractmethod_node): New. + * expr.c (build_field_ref): Add in-line check for missing field. + * decl.c (java_init_decl_processing): Add soft_nosuchfield_node. + +2005-12-07 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + + * Make-lang.in (java.all.build, java.install-normal): Remove. + +2005-12-07 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + + * Make-lang.in: Remove all dependencies on s-gtype, except for + gt-java-parse.h. + +2005-12-07 Richard Sandiford <richard@codesourcery.com> + + * class.c (build_utf8_ref, emit_register_classes): Use + switch_to_section and get_section. + +2005-12-06 Tom Tromey <tromey@redhat.com> + + PR java/25283: + * parse.y (patch_new_array_init): Revert previous patch. + (lookup_method_invoke): Use size-less array type when creating an + anonymous constructor. + +2005-12-05 Tom Tromey <tromey@redhat.com> + + * parse.y (patch_new_array_init): Don't set length on array. + +2005-12-02 Richard Guenther <rguenther@suse.de> + + * java-gimplify.c (java_gimplify_labeled_block_expr): Use + buildN instead of build. + * class.c (finish_class): Likewise. + * expr.c (java_create_object): Likewise. + +2005-11-28 Tom Tromey <tromey@redhat.com> + + PR java/18278: + * expr.c (build_jni_stub): Unwrap the return value. + * java-tree.h (soft_unwrapjni_node): New define. + (enum java_tree_index): Added JTI_SOFT_UNWRAPJNI_NODE. + * decl.c (java_init_decl_processing): Initialize + soft_unwrapjni_node. + +2005-11-24 Bryce McKinlay <mckinlay@redhat.com> + + * gcj.texi (gij options): Add -Xss documentation. + +2005-11-08 Wil Mahan <wmahan@gmail.com> + + PR java/23617 + * zextract.c (read_zip_archive): Fix out of memory error when + reading jar files with zip-style comments. + +2005-11-07 Terry Laurenzo <tlaurenzo@gmail.com> + + * gjavah.c (HANDLE_CODE_ATTRIBUTE): Only define for ELF Object + formats. + * gjavah.c (decompile_method): Add ATTRIBUTE_UNUSED + +2005-10-12 Nathan Sidwell <nathan@codesourcery.com> + Wil Mahan <wmahan@gmail.com> + + PR java/23620 + * class.c (make_class): Create empty binfo here. + (set_super_info): Only create binfo if we have superclasses. + +2005-10-03 Ranjit Mathew <rmathew@gcc.gnu.org> + + PR java/24127 + * parse.y (method_header): Make the result of the rule a NULL_TREE + when a parsing error occurs. + +2005-09-29 Tom Tromey <tromey@redhat.com> + + PR java/24120: + * jcf-io.c (memoized_dirlist_hash): New function. + (caching_stat): Use it. + +2005-09-21 Ranjit Mathew <rmathew@gcc.gnu.org> + + PR java/21418 + * class.c (inherits_from_p): Try to lay out super class + if it is not already laid out. + (maybe_layout_super_class): Handle the case where SUPER_CLASS + is a NULL_TREE. + +2005-09-18 James A. Morrison <phython@gcc.gnu.org> + + * builtins.c (max_builtin, min_builtin, abs_builtin, + java_build_function_call_expr): Use fold_buildN. + * class.c (layout_class_method): Likewise. + * expr.c (java_truthvalue_conversion, build_java_jsr, + build_java_arrayaccess, expand_java_arrayload, expand_iinc, + build_java_binop, build_field_ref, expand_compare, + build_known_method_ref, build_invokevirtual, + process_jvm_instruction): Likewise. + * parse.y (patch_binop, patch_exit_expr): Likewise. + * typeck.c (convert_ieee_real_to_integer): Likewise. + (convert): Don't call fold after convert_ieee_real_to_integer. + +2005-09-14 Bryce McKinlay <mckinlay@redhat.com> + + PR java/23891 + * parse.y (maybe_create_class_interface_decl): Set TYPE_PACKAGE for + the newly created type. Set import lists here, not in create_class. + (jdep_resolve_class): Set current_class. + (do_resolve_class): Use current_class's TYPE_PACKAGE to determine + the current package context, not ctxp->package. + (cicp_cache): Removed. + (class_in_current_package): Simplify implementation using TYPE_PACKAGE. + * jcf-parse.c (give_name_to_class): Set TYPE_PACKAGE. + * java-tree.h (TYPE_PACKAGE): New macro. + (struct lang_type): New member 'package'. + +2005-09-09 Andrew Haley <aph@redhat.com> + + PR libgcj/23182 + * expr.c (pop_type_0): If the expected type is object or ptr + (i.e. void*), return the type of the object we just popped from + the stack. + +2005-09-06 Andrew Pinski <pinskia@physics.uc.edu> + + * java-gimplify.c (java_gimplify_block): NULL out the old BLOCK's + BLOCK_EXPR_BODY before returning the new BIND_EXPR. + +2005-09-06 Kazu Hirata <kazu@codesourcery.com> + + * check-init.c, decl.c, expr.c, gcj.texi, java-tree.h, + jcf-parse.c, jcf.h, parse.h, parse.y, typeck.c: Fix comment + typos. Follow spelling conventions. + +2005-09-05 Ranjit Mathew <rmathew@hotmail.com> + + PR java/23431 + * typeck.c (lookup_do): Look up interfaces for the original class, + not the base class. + * parse.y (java_check_regular_methods): Fix diagnostic message for + more restrictive overriding of a method from an interface. + +2005-08-16 Tom Tromey <tromey@redhat.com> + + * class.c (make_class_data): Always emit JV_STATE_PRELOADING for + class' initial state. + +2005-08-16 Ranjit Mathew <rmathew@hotmail.com> + + PR java/22113 + * lex.c (do_java_lex): Define MAX_TOKEN_LEN. Avoid overflowing + `literal_token' for large numeric input tokens. + +2005-08-16 Ranjit Mathew <rmathew@hotmail.com> + + PR java/19870 + * parse.y (nested_field_access_p): Rename to nested_member_access_p + and expand to handle method accesses across nested classes. + (build_outer_method_access_method): Rename to + build_nested_method_access_method. Minor adjustments to comments. + (resolve_expression_name): Use the newly-renamed + nested_member_access_p method. + (resolve_qualified_expression_name): Likewise. + (patch_method_invocation): Also consider static methods for access + method generation. Minor adjustments to comments. + (maybe_use_access_method): Use the more general + nested_memeber_access_p to determine access across nested class + boundaries. Allow THIS_ARG to be NULL (for static methods). + +2005-08-15 Tom Tromey <tromey@redhat.com> + + PR java/23300. + * expr.c (build_field_ref): Don't generate otable reference when + DECL_FIELD_OFFSET is 0. + * class.c (maybe_layout_super_class): Pass outer class to + do_resolve_class. + +2005-08-15 Tom Tromey <tromey@redhat.com> + + * java-tree.h (LABEL_IN_SUBR): Removed. + (LABEL_IN_SUBR): Likewise. + (LABEL_IS_SUBR_START): Likewise. + (LABEL_SUBR_START): Likewise. + (LABEL_SUBR_CONTEXT): Likewise. + (LABEL_CHANGED): Likewise. + (LABEL_RETURN_LABEL): Likewise. + (LABEL_RETURN_TYPE_STATE): Likewise. + (LABEL_RETURN_LABELS): Likewise. + (RETURN_MAP_ADJUSTED): Likewise. + (LABEL_PENDING_CHAIN): Likewise. + +2005-08-15 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (JAVA_OBJS): Removed verify.o + (java/verify.o): Removed. + * verify.c: Removed. + * lang.c (flag_new_verifier): Removed. + (java_post_options): Updated. + * java-tree.h (flag_new_verifier): Removed. + (verify_jvm_instructions): Removed. + * expr.c (pop_type_0): Assume flag_new_verifier is true. + (build_java_check_indexed_type): Likewise. + (expand_java_arraystore): Likewise. + (expand_java_arrayload): Likewise. + (pop_arguments): Likewise. + (expand_byte_code): Likewise. + (process_jvm_instruction): Likewise. + +2005-08-10 Andrew Haley <aph@redhat.com> + + * java-gimplify.c (java_gimplify_modify_expr): Fix any pointer + type mismatches to make legal GIMPLE. + +2005-08-10 Robin Green <greenrd@greenrd.org> + + PR java/23230: + * parse.y (maybe_use_access_method): Generalize check from + java.lang.Object to any superclass of current_class + +2005-08-08 Nathan Sidwell <nathan@codesourcery.com> + + * class.c (build_class_ref): Wrap the primary class type in a + NOP_EXPR. + * parse.y (java_complete_lhs) <COMPONENT_REF case>: Extract the + primary class type from the NOP_EXPR in which it was placed. + +2005-07-28 Diego Novillo <dnovillo@redhat.com> + + * expr.c (expand_load_internal): Fix missing parens in + predicate. + +2005-07-28 Andrew Haley <aph@redhat.com> + + * expr.c (expand_load_internal): Convert to destination type. + +2005-07-22 Manfred Hollstein <mh@suse.com> + + * verify-impl.c (check_class_constant): Fix uninitialised warnings. + (check_constant): Likewise. + (check_wide_constant): Likewise. + +2005-07-20 Giovanni Bajo <giovannibajo@libero.it> + + Make CONSTRUCTOR use VEC to store initializers. + * check-init.c (check_init): Update to cope with VEC in + CONSTRUCTOR_ELTS. + * class.c (make_field_value, make_method_value, get_dispatch_table, + make_class_data, emit_symbol_table, emit_catch_table, + emit_assertion_table): Use build_constructor_from_list instead of + build_constructor. + * constants.c (build_constants_constructor): Likewise. + * java-gimplify.c (java_gimplify_new_array_init): Update to cope with + VEC in CONSTRUCTOR_ELTS. + * java-tree.h (START_RECORD_CONSTRUCTOR, PUSH_SUPER_VALUE, + PUSH_FIELD_VALUE, FINISH_RECORD_CONSTRUCTOR): Create a VEC instead + of a TREE_LIST. + * jcf-write.c (generate_bytecode_insns): Update to cope with VEC in + CONSTRUCTOR_ELTS. + * parse.y (build_new_array_init): Use build_constructor_from_list + instead of build_constructor. + (patch_new_array_init): Update to cope with VEC in + CONSTRUCTOR_ELTS. + (array_constructor_check_entry): Likewise. + +2005-07-12 Tom Tromey <tromey@redhat.com> + + * jvspec.c (lang_specific_driver): Put filelist_filename first on + command line. + +2005-07-12 Tom Tromey <tromey@redhat.com> + + PR java/19674: + * parse-scan.y (interface_member_declaration): Added + empty_statement. + +2005-07-08 Daniel Berlin <dberlin@dberlin.org> + + * java-tree.h (LABEL_RETURN_LABELS): Use decl_non_common. + (LABEL_PENDING_CHAIN): Ditto. + (LABEL_PC): Ditto. + (DECL_BIT_INDEX): Ditto. + +2005-07-07 Bryce McKinlay <mckinlay@redhat.com> + + PR java/18119 + * parse.y (inner_class_accessible): New function. Logic moved from + check_inner_class_access. + (check_inner_class_access): Use inner_class_accessible. + (resolve_inner_class): Simplify arguments. Create circularity hash + here. Keep looking for classes if we found one that was inaccessible. + Return the inaccessible class only if there is no other match. + (do_resolve_class): Update for new resolve_inner_class arguments. + Don't create circularity_hash here. + +2005-07-07 Bryce McKinlay <mckinlay@redhat.com> + + PR java/21045 + * parse.y (add_exception_to_throws): New function. + (purge_unchecked_exceptions): Removed. + (get_constructor_super): Renamed from verify_constructor_super. Now + returns the super constructor after verification. + (java_complete_expand_method): Don't use purge_unchecked_exceptions + or save/restore the exception list. + (check_thrown_exceptions): Add uncaught exceptions in anonymous + class initializers and constructors to the throws clause of the method. + +2005-07-05 Bryce McKinlay <mckinlay@redhat.com> + + PR java/19674 + * parse.y (interface_member_declaration): Allow empty statements in + interface declarations. + +2005-07-05 Paolo Bonzini <bonzini@gnu.org> + + * Makefile.in (parse.o): Adjust dependencies. + * parse.y: Include tree-dump.h. + +2005-07-02 Joseph S. Myers <joseph@codesourcery.com> + + * class.c, decl.c, expr.c: Use '+' flag instead of %J. Use 'q' + flag for quoting. + +2005-07-01 Andrew Pinski <pinskia@physics.uc.edu> + + * parse.y (issue_warning_error_from_context): Call + pp_output_formatted_text to be able to get the buffer. + +2005-06-30 Andrew Pinski <pinskia@physics.uc.edu> + + * parse.y (issue_warning_error_from_context): Update for the + renaming of pp_format_text to pp_format. + +2005-06-28 Paul Brook <paul@codesourcery.com> + + * decl.c (java_init_decl_processing): Call + default_init_unwind_resume_libfunc. + +2005-06-27 Tom Tromey <tromey@redhat.com> + + PR java/21540, PR java/13788: + * parse.y (java_complete_lhs) <CASE_EXPR>: Use + fold_constant_for_init. + (patch_binop): Added 'folding' argument. Updated all callers. + (patch_unaryop) <NOP_EXPR>: New case. + (fold_constant_for_init) <NOP_EXPR>: Likewise. + (fold_constant_for_init) <COND_EXPR>: Fix sense of test. + +2005-06-25 Jan Hubicka <jh@suse.cz> + + * builtins.c (define_builtin): Accept new flags parameter. + (initialize_builtins): Mark the builtins const and nothrow accordingly. + +2005-06-25 Kelley Cook <kcook@gcc.gnu.org> + + * all files: Update FSF address in copyright headers. + +2005-06-24 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (verify_instructions_0): Correctly handle + situation where PC falls off end. + +2005-06-23 Bryce McKinlay <mckinlay@redhat.com> + + PR java/20697 + * parse.y (find_most_specific_methods_list): Remove special case for + inner classes. + +2005-06-15 Tom Tromey <tromey@redhat.com> + + PR libgcj/21906: + * class.c (make_method_value): Use soft_abstractmethod_node for + abstract method. + * java-tree.h (soft_abstractmethod_node): New define. + (JTI_SOFT_ABSTRACTMETHOD_NODE): New enum constant. + * decl.c (java_init_decl_processing): Initialize + soft_abstractmethod_node. + +2005-06-13 Geoffrey Keating <geoffk@apple.com> + + * Make-lang.in (rule for installing gcj.1): Depends on installdirs. + +2005-06-13 Per Bothner <per@bothner.com> + + * expr.c (int highest_label_pc_this_method, + start_label_pc_this_method): New globals. + (lookup_label): Add start_label_pc_this_method to pc for label, and + update highest_label_pc_this_method. This prevents conflicts between + labels from different methods. + * java-tree.h: Declare new globals. + * jcf-parse.c (parse_class_file): If needed bump + start_label_pc_this_method and reset highest_label_pc_this_method. + +2005-06-13 Tom Tromey <tromey@redhat.com> + + PR java/21844: + * parse.y (nested_field_access_p): Handle case where outer field + is inherited by enclosing class. + +2005-06-12 Per Bothner <per@bothner.com> + + * class.c (inherits_from_p): Do load_class if needed. + +2005-06-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (error): Add ATTRIBUTE_PRINTF_1. + * java-tree.h (parse_error_context): Move... + * parse.h (parse_error_context): ... here, add ATTRIBUTE_GCC_DIAG. + * parse.y (parse_warning_context): Add ATTRIBUTE_GCC_DIAG. + * verify-impl.c (debug_print): Add ATTRIBUTE_PRINTF_1. + +2005-06-08 Roger Sayle <roger@eyesopen.com> + + * typeck.c (convert): Only clear TREE_OVERFLOW on INTEGER_CST nodes. + +2005-06-06 Jakub Jelinek <jakub@redhat.com> + + * jv-scan.c (fatal_error, warning, warning0): Use gmsgid instead of + msgid for argument name. + * gjavah.c (error): Likewise. + * java-tree.h (parse_error_context): Likewise. + * parse.y (parse_error_context, parse_warning_context, + issue_warning_error_from_context): Likewise. + +2005-06-01 Tom Tromey <tromey@redhat.com> + + PR java/21722: + * class.c (build_static_field_ref): Don't fold constant fields if + current class is from a .class file and we're using indirect + dispatch. + +2005-05-31 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * java/verify-glue.c: Don't include errors.h and include toplev.h. + * java/Make-lang.in: Updates dependencies. + +2005-05-26 Ranjit Mathew <rmathew@hotmail.com> + + PR java/19870. + * java-tree.h (OUTER_FIELD_ACCESS_IDENTIFIER_P): Rename to + NESTED_FIELD_ACCESS_IDENTIFIER_P. + (FIELD_INNER_ACCESS): Rename to FIELD_NESTED_ACCESS. + (FIELD_INNER_ACCESS_P): Rename to FIELD_NESTED_ACCESS_P. + * jcf-write.c (generate_classfile): Use + NESTED_FIELD_ACCESS_IDENTIFIER_P instead of + OUTER_FIELD_ACCESS_IDENTIFIER_P. + * parse.y (build_outer_field_access): Rename to + build_nested_field_access. Support static fields and outer-to-inner + class accesses. + (outer_field_access_p): Rename to nested_field_access_p. Support + static fields and generalise to outer-to-inner class and sibling + inner class accesses. + (outer_field_expanded_access_p): Rename to + nested_field_expanded_access_p and support static fields. + (outer_field_access_fix): Rename to nested_field_access_fix and + support static fields. + (build_outer_field_access_expr): Rename to + build_nested_field_access_expr and support static fields. + (build_outer_field_access_methods): Rename to + build_nested_field_access_methods and support static fields. For + static fields, generate accessors without class instance parameters. + (build_outer_field_access_method): Rename to + build_nested_field_access_method and support static fields. + (build_outer_method_access_method): Use + NESTED_FIELD_ACCESS_IDENTIFIER_P instead of + OUTER_FIELD_ACCESS_IDENTIFIER_P. + (resolve_expression_name): Consider static field accesses across + nested classes. + (resolve_qualified_expression_name): Likewise. + (java_complete_lhs): Use nested_field_access_fix instead of + outer_field_access_fix. + (patch_unary_op): Rename outer_field_flag to nested_field_flag. + Use nested_field_expanded_access_p instead of + outer_field_expanded_access_p. Use nested_field_access_fix instead + of outer_field_access_fix. + (check_thrown_exceptions): Use NESTED_FIELD_ACCESS_IDENTIFIER_P + instead of OUTER_FIELD_ACCESS_IDENTIFIER_P. + +2005-05-26 Bryce McKinlay <mckinlay@redhat.com> + + * decl.c (GCJ_BINARYCOMPAT_ADDITION, + GCJ_BOOTSTRAP_LOADER_ADDITION): Removed. + (FLAG_BINARYCOMPAT_ABI, FLAG_BOOTSTRAP_LOADER, + MINOR_BINARYCOMPAT_ABI_VERSION): New. + (GCJ_CURRENT_BC_ABI_VERSION): Use new method to calculate version ID. + (parse_version): Calculate version ID using new method. Use bit-flags + for flag_indirect_dispatch and flag_bootstrap_classes. + +2005-05-25 Richard Henderson <rth@redhat.com> + + PR libgcj/21692 + * Make-lang.in (java/mangle.o): Depend on LANGHOOKS_DEF_H. + * class.c (build_class_ref): Set DECL_CLASS_FIELD_P and + DECL_CONTEXT; avoid pushdecl_top_level. + (build_dtable_decl): Set DECL_VTABLE_P and DECL_CONTEXT. + (layout_class): Don't SET_DECL_ASSEMBLER_NAME. + (layout_class_method): Likewise. + * decl.c (java_mark_cni_decl_local): New. + (java_mark_class_local): Use it. + * java-tree.h (DECL_LOCAL_CNI_METHOD_P): New. + (DECL_CLASS_FIELD_P, DECL_VTABLE_P): New. + (struct lang_decl_func): Add local_cni; + (struct lang_decl_var): Add class_field, vtable. + (java_mangle_decl): Declare. + * lang.c (LANG_HOOKS_SET_DECL_ASSEMBLER_NAME): New. + * mangle.c: Remove dup obstack.h; include langhooks-def.h. + (mangle_obstack_1): New. + (java_mangle_decl): Remove obstack argument. Call mangle_class_field, + mangle_vtable, and mangle_local_cni_method_decl. Fall back to + lhd_set_decl_assembler_name for things that don't need mangling. + (mangle_class_field): Rename from java_mangle_class_field, make + static, don't call init_mangling or finish_mangling. + (mangle_vtable): Similarly. + (mangle_local_cni_method_decl): New. + (init_mangling): Remove obstack argument. Use &mangle_obstack_1, + gcc_assert, and MANGLE_RAW_STRING. + (finish_mangling): Use gcc_assert, remove if 0 debugging code. + +2005-05-25 DJ Delorie <dj@redhat.com> + + * class.c (set_constant_value): Move warning control from if() to + warning(OPT_*). + +2005-05-24 Richard Henderson <rth@redhat.com> + + * builtins.c (define_builtin): Don't call make_decl_rtl. + * constants.c (build_constant_data_ref): Likewise. + * class.c (build_utf8_ref): Likewise. + (build_fieldref_cache_entry, build_static_field_ref): Likewise. + (get_dispatch_table, layout_class_method): Likewise. + (build_class_ref): Likewise. Don't set DECL_SIZE or DECL_SIZE_UNIT + by hand. + (make_local_function_alias): Don't SET_DECL_ASSEMBLER_NAME. + (make_method_value): Use METHOD_ABSTRACT instead of DECL_RTL_SET_P + to determine if we need a non-zero address. + * decl.c (builtin_function): Don't call make_decl_rtl. + (give_name_to_locals): Don't SET_DECL_ASSEMBLER_NAME. + * expr.c (build_known_method_ref): Don't call make_decl_rtl. + * resource.c (compile_resource_data): Likewise. + * parse.y (resolve_field_access): Re-word comment to avoid + building DECL_RTL. + +2005-05-24 Richard Henderson <rth@redhat.com> + + * class.c (registered_class): Take it out of class_roots; turn into + a vec of trees. + (register_class): Make static. Don't duplicate decl node. Use + VEC_safe_push. + (emit_register_classes): Use VEC_iterate. Use output_constant + instead of assemble_integer. Don't call mark_decl_referenced + directly. + * java-tree.h (register_class): Remove decl. + +2005-05-19 Paolo Bonzini <bonzini@gnu.org> + + PR java/17845 + + * parse.y (register_package, package_list): Remove. + (package_declaration): Do not call register_package. + (do_resolve_class): Do not use package_list. + +2005-05-15 Gerald Pfeifer <gerald@pfeifer.com> + + * jcf-write.c (generate_bytecode_insns) <SAVE_EXPR>: Remove + unused variable. + +2005-05-15 Tom Tromey <tromey@redhat.com> + + PR java/21519: + * jcf-write.c (generate_bytecode_insns) <SAVE_EXPR>: Don't call + NOTE_PUSH. + +2005-05-12 Aaron Luchko <aluchko@redhat.com> + + * gcj.texi: Add '-verify', '-noverify', and '-verifyremote'. + +2005-05-11 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Code Generation): Document -fbootstrap-classes. + * decl.c (GCJ_BOOTSTRAP_LOADER_ADDITION): New macro. + (parse_version): Use it. + * lang.opt (-fbootstrap-classes): New option. + +2005-05-10 Paolo Bonzini <bonzini@gnu.org> + + PR java/21436 + * class.c (maybe_layout_super_class): Look for imports in this_class. + * parse.h (ctxp_for_generation_last): New. + (do_resolve_class): Add a parameter. + * parse.y (ctxp_for_generation_last): New. + (java_pop_parser_context): Add at end of list. + (find_in_imports, find_in_imports_on_demand): Look in ctxp + if the TYPE_IMPORT_LIST or respectively the TYPE_IMPORT_DEMAND_LIST of + the given type are NULL. + (do_resolve_class): Look into the imports of the new second parameter. + Adjust recursive calls. + (resolve_class, resolve_inner_class, find_as_inner_class): Adjust + calls to do_resolve_class. + (create_class): Set the TYPE_IMPORT_LIST and TYPE_IMPORT_DEMAND_LIST. + (java_complete_class): Do not do that here. + +2005-05-03 Thomas Fitzsimmons <fitzsim@redhat.com> + + PR java/20309 + * Make-lang.in (java): Add gjnih. + (JAVA_TARGET_INDEPENDENT_BIN_TOOLS): Likewise. + (GJNIH_OBJS): New variable. + (gjnih$(exeext)): New target. + (JAVA_MANFILES): Add gjnih.1. + (java.uninstall): Add gjnih.1. + (java.mostlyclean): Add gjnih. + (java.maintainer-clean): Add gjnih.1. + (java/gjavah-jni.o): New target. + (.INTERMEDIATE): Add gjnih.pod. + (gjnih.pod): New target. + * config-lang.in (stagestuff): Add gjnih. + * gcj.texi (Top): Add gjnih node. + (Invoking gcjh): Add descriptions of -force, -old, -trace, -J and + -bootclasspath options. + (Invoking gjnih): New node. + * gjavah.c Initialize flag_jni to 1 if JNI_DEFAULT is defined. + (TOOLNAME): New macro. + (error): Replace hard-coded gcjh with TOOLNAME. + (process_file): Likewise. + (usage): Likewise. + (version): Likewise. + (help): Likewise. Add help output for -force, -old, -trace and -J + options. + (OPT_FORCE, OPT_OLD, OPT_TRACE): New macros. + (options): Add force, old, trace and J fields. + (main): Handle -force, -old, -trace and -J options. + +2005-05-03 Tom Tromey <tromey@redhat.com> + + PR java/21245: + * gjavah.c (main): Unlink output file on error. + +2005-05-03 Kazu Hirata <kazu@cs.umass.edu> + + * constants.c, jvgenmain.c, lang.opt, resource.c: Update + copyright. + +2005-04-29 Tom Tromey <tromey@redhat.com> + + * expr.c (build_jni_stub): Updated for change to build_block. + +2005-04-29 Andrew Pinski <pinskia@gcc.gnu.org> + + * expr.c (force_evaluation_order): Declare 'saved' earlier. + +2005-04-28 Andrew Haley <aph@redhat.com> + + PR java/19285 + * java-tree.h (soft_resolvepoolentry_node): New. + (alloc_constant_fieldref): Declare. + * expr.c (expand_java_field_op): Don't call class_init for + accesses to static fields with indirect dispatch. + * builtins.c (initialize_builtins): Add "__builtin_expect". + * decl.c (soft_resolvepoolentry_node): New variable. + (java_init_decl_processing): Create a decl for + "_Jv_ResolvePoolEntry". + * class.c (build_fieldref_cache_entry): New function. + (build_static_field_ref): Rewrite for indirect dispatch. + * constants.c (find_name_and_type_constant_tree): New function. + (alloc_constant_fieldref): Likewise. + (build_constants_constructor): Handle CONSTANT_Fieldref and + CONSTANT_NameAndType. + + PR java/21115 + * expr.c (force_evaluation_order): Convert outgoing args smaller + than integer. + +2005-04-27 Bryce McKinlay <mckinlay@redhat.com> + + * gcj.texi (libgcj Runtime Properties): Remove obsolete + gnu.gcj.runtime.NameFinder.* system properties. Update documentation + for gnu.gcj.runtime.NameFinder.use_addr2line and gnu.gcj.progname. + +2005-04-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c, jcf-dump.c, jv-scan.c, jvgenmain.c: Replace calls + to `unlock_stream' with `unlock_std_streams'. + +2005-04-25 Jakub Jelinek <jakub@redhat.com> + + * Make-lang.in (java/decl.o, java/resource.o): Depend on $(EXPR_H) + instead of just expr.h. + +2005-04-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (main): Unlock the stdio streams. + * jcf-dump.c (main): Likewise. + * jv-scan.c (main): Likewise. + * jvgenmain.c (main): Likewise. + +2005-04-23 DJ Delorie <dj@redhat.com> + + * class.c, decl.c, expr.c, jcf-io.c, jcf-parse.c, jv-scan.c, + parse.y: Adjust warning() callers. + +2005-04-21 Bryce McKinlay <mckinlay@redhat.com> + + * gcj.texi (Object fields): Change "Integer" to "Int" in example + contructor. + +2005-04-20 Bryce McKinlay <mckinlay@redhat.com> + + * gcj.texi: Fix typos and bogus example. + +2005-04-19 Kazu Hirata <kazu@cs.umass.edu> + + * except.c: Fix a comment typo. + +2005-04-19 Julian Brown <julian@codesourcery.com> + + * decl.c (finish_method): Revert patch from 2005-04-13 for breaking + indirect dispatch with PIC. + +2005-04-18 Andrew Haley <aph@redhat.com> + + * java-except.h (struct eh_range.handler): Remove unused field. + (handle_nested_ranges): Remove function declaration. + (sanity_check_exception_range): Add function declaration. + * verify.c (verify_jvm_instructions): Remove call to + handle_nested_ranges. + * verify-glue.c (verify_jvm_instructions_new): Call + sanity_check_exception_range. + * except.c (link_handler, eh_range_freelist, link_handler, + handle_nested_ranges): Remove. + (add_handler): Rewrite. + (sanity_check_exception_range): New function. + (print_ranges): New function. + +2005-04-13 Julian Brown <julian@codesourcery.com> + + * decl.c (finish_method): Give methods once-only linkage. + +2005-04-11 Richard Sandiford <rsandifo@redhat.com> + + * lang.opt: Refer to the GCC internals documentation instead of c.opt. + +2005-04-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * java-tree.h: Don't use PARAMS(). + +2005-04-07 Per Bothner <per@bothner.com> + + * class.c (push_class): By default, suppress debug output. + (finish_class): Enable debug output for classes we're emitting. + +2005-04-07 Andrew Haley <aph@redhat.com> + + * gcj.texi: Correct gcj-dbtool instructions. + +2005-04-04 Kazu Hirata <kazu@cs.umass.edu> + + * gcj.texi: Fix a typo. + * lang.c: Fix a comment typo. + +2005-04-01 Thomas Fitzsimmons <fitzsim@redhat.com> + + * gcj.texi (Invoking gij): Add descriptions of new -X options. + Mention recognized-and-ignored compatibility options. + (Memory allocation): Add descriptions of JvMalloc, JvRealloc and + JvFree. + (About CNI): Add Memory allocation section. + +2005-04-01 Tom Tromey <tromey@redhat.com> + + * decl.c (java_init_decl_processing): Fix types of + _Jv_MonitorEnter, _Jv_MonitorExit, _Jv_AllocObject, + _Jv_AllocObjectNoFinalizer, _Jv_Throw, _Jv_NewPrimArray, + _Jv_JNI_PopSystemFrame, _Jv_divI, _Jv_remI, _Jv_divJ, _Jv_remJ. + +2005-03-31 Jan Hubicka <jh@suse.cz> + + * Make-lang.in (class.o, decl.o): Depend on cgraph.h. + * class.c: Include cgraph.h + (make_local_functoin_alias): Mark aslias as needed. + * resource.c: Include cgraph.h + (compile_resource_data): Go via cgraph interface. + +2005-03-30 Ian Lance Taylor <ian@airs.com> + + * parse.y (maybe_yank_clinit): Don't crash if bbody is NULL. + +2005-03-30 Tom Tromey <tromey@redhat.com> + + * jcf-dump.c (HANDLE_INNERCLASSES_ATTRIBUTE): Handle cases where + inner_class_info_index==0 or outer_class_info_index==0. + +2005-03-29 Tom Tromey <tromey@redhat.com> + + * gcj.texi (libgcj Runtime Properties): Document + gnu.gcj.runtime.endorsed.dirs. + +2005-03-24 Anthony Green <green@redhat.com> + + * gcj.texi (Invoking gcj-dbtool): Document new LIBDIR option to + 'gcj-dbtool -p'. + +2005-03-23 Tom Tromey <tromey@redhat.com> + + * decl.c (GCJ_CURRENT_BC_ABI_VERSION): New define. + (parse_version): Use it. + +2005-03-23 Joseph S. Myers <joseph@codesourcery.com> + + * lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Remove. + +2005-03-18 Andrew Haley <aph@redhat.com> + + PR java/20522 + * decl.c (update_aliases): Don't update variables that are about + to die. + (maybe_poplevels): Add comment. + +2005-03-17 Bryce McKinlay <mckinlay@redhat.com> + + PR java/20502 + * jcf-parse.c (duplicate_class_warning): New function. + (java_parse_file): Call duplicate_class_warning if + CLASS_FROM_CURRENTLY_COMPILED_P is already set. + (parse_zip_file_entries): Likewise. Also set + CLASS_FROM_CURRENTLY_COMPILED_P. + +2005-03-16 Andrew Haley <aph@redhat.com> + + * expr.c (expand_java_arrayload): Don't generate a + NullPointerException based on the type of the node. + (build_java_array_length_access): Likewise. + +2005-03-15 Zack Weinberg <zack@codesourcery.com> + + * Make-lang.in (TEXI_JAVA_FILES): Add gcc-vers.texi. + +2005-03-11 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Invoking gcj-dbtool): Document 'gcj-dbtool -p'. + (libgcj Runtime Properties): Document the default .db. + +2005-03-10 Ranjit Mathew <rmathew@hotmail.com> + + PR java/20312 + * parse.y (checks_throws_clauses): Check exceptions list even when + the base class does not come from a source file being compiled. + (java_complete_lhs): Remove unused variable 'wfl'. + +2005-03-09 Ranjit Mathew <rmathew@hotmail.com> + + PR java/20338 + * decl.c (finish_method): Emit _Jv_InitClass for private static + methods inside inner classes as well. + +2005-03-08 Julian Brown <julian@codesourcery.com> + * Revert patch from 2005-03-08 for causing bootstrap failure on + ppc-darwin. + +2005-03-08 Julian Brown <julian@codesourcery.com> + + * decl.c (finish_method): Give methods once-only linkage. + +2005-03-07 Ranjit Mathew <rmathew@hotmail.com> + + * lang.c (flag_new_verifier): Enable by default, regardless of ABI. + +2005-03-07 Bryce McKinlay <mckinlay@redhat.com> + + * verify-glue.c (vfy_is_assignable_from): Perform static check using + can_widen_reference_to if the C++ ABI is in use. + (vfy_get_interface_count, vfy_get_interface): Remove unused functions. + * verify-impl.c (debug_print, make_utf8_const, init_type, copy_type, + type_isresolved, init_state, set_pc, state_get_pc, + _Jv_BytecodeVerifier): Clean up unused and disabled functions. + (verify_fail): Report the current PC from the verifier context. + (free_state): Remove #if 0 block to enable this function. + (free_verifier_context): Call free_state on state_list iterator + values before freeing them. + * expr.c (pop_type_0): Pop correct type for error message when stack + contains a multi-word type. + +2005-03-07 Ranjit Mathew <rmathew@hotmail.com> + + * expr.c (build_java_array_length_access): Remove !flag_new_verifier + for known NULL array length access. + +2005-03-07 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Invoking gcj-dbtool): Document '-f'. + +2005-03-06 Kazu Hirata <kazu@cs.umass.edu> + + * jcf-dump.c, jcf-io.c, jcf-reader.c, lang.c, parse.h, + typeck.c: Update copyright. + +2005-03-06 Ranjit Mathew <rmathew@hotmail.com> + + Remove xref code. + * xref.c, xref.h: Remove file. + * Make-lang.in (java/xref.o): Remove. + * java-tree.h (flag_emit_xref, do_not_fold): Remove declaration. + * lang.c (flag_emit_xref): Remove definition. + * parse.h (DECL_END_SOURCE_LINE, DECL_INHERITED_SOURCE_LINE): Remove. + * typeck.c (convert): Remove use of do_not_fold. + * parse.y (do_not_fold): Remove definition. + (parser grammar): Remove xref code. + (maybe_create_class_interface_decl, create_class): Likewise. + (register_fields, method_header, finish_method_declaration): Likewise. + (declare_local_variables, source_end_java_method): Likewise. + (java_complete_expand_classes): Do not set do_not_fold. + (java_complete_expand_method): Remove xref code. + (java_expand_classes, resolve_field_access, patch_invoke): Likewise. + (java_complete_tree, java_complete_lhs, patch_assignment): Likewise. + (patch_binop, build_string_concatenation, patch_array_ref): Likewise. + (patch_synchronized_statement, patch_throw_statement): Likewise. + (maybe_build_class_init_for_field): Likewise. + +2005-03-05 Kazu Hirata <kazu@cs.umass.edu> + + * expr.c (build_expr_wfl, expr_add_location): Use TYPE_P + instead of IS_NON_TYPE_CODE_CLASS. + +2005-03-04 Andrew Haley <aph@redhat.com> + + PR java/18362 + * class.c (set_method_index): Don't set method_index if it is + NULL_TREE. + (layout_class_method): Don't complain about "non-static method foo + overrides static method" in the case of indirect dispatch. + +2005-03-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-io.c (caching_stat): Use __extension__ to avoid pedantic + warning. + * Make-lang.in: Don't elide warnings in jcf-io.c. + +2005-03-01 Per Bothner <per@bothner.com> + + PR java/8608 + * check-init.c (wfl): Remove static. + (final_assign_error, check_init): Replace calls to parse_error_context + by plain error. + (check_init): Save, set, and restore input_location for each exp. + +2005-03-01 Per Bothner <per@bothner.com> + + * jcf-reader.c (get_attribute): Handle SourceDebugExtension (JSR 45) + if HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE is defined. + * jcf-dump.c (HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE): Print contents. + +2005-03-01 Per Bothner <per@bothner.com> + + * java-tree.h (IDENTIFIER_HANDLECLASS_VALUE): Remove ancient macro. + +2005-02-23 Thomas Fitzsimmons <fitzsim@redhat.com> + + PR libgcj/16923 + * gcj.texi (Invocation): Add descriptions of JvVMInitArgs and + JvVMOption. + +2005-02-22 Tom Tromey <tromey@redhat.com> + + PR java/20056: + * verify-impl.c (EITHER): New define. + (types_compatible): Handle it. + (check_field_constant): Use it. + +2005-02-18 Tom Tromey <tromey@redhat.com> + + PR java/20056: + * verify-impl.c (types_equal): Fixed test. + + PR java/20056: + * verify-glue.c (vfy_class_has_field): New function. + * verify.h (vfy_class_has_field): Declare. + * verify-impl.c (check_field_constant): Added 'putfield' + argument. + (verify_instructions_0): Updated. + (types_equal): New function. + +2005-02-14 Tom Tromey <tromey@redhat.com> + + PR java/19921: + * jcf-write.c (generate_bytecode_insns) <CALL_EXPR>: Note the + stack effect of multianewarray. + +2005-02-14 Andrew Haley <aph@redhat.com> + + PR java/19907 + * expr.c (expand_byte_code): Call promote_arguments(). + (promote_arguments): New function. + * decl.c (check_local_unnamed_variable): Remove special case for + new verifier. + (find_local_variable): Promote all boolean types to int + when searching for local variable decls. + +2005-02-12 Kazu Hirata <kazu@cs.umass.edu> + + * builtins.c, java-except.h, jcf-parse.c, jv-scan.c, lex.c, + parse-scan.y: Update copyright. + +2005-02-11 Per Bothner <per@bothner.com> + + PR java/15543 + * parse-scan.y (input_location): Remove variable. + (main_input_filename): New - replaces input_filename, which isn't + settable if USE_MAPPED_LOCATION. + * lex.c (java_init_lex): Wrap some more places in #ifndef JC1-LITE, + so we don't reference input_location or wfl_operator in that case. + * jv-scan.c (expand_location): Remove - no longer used. + (main): Set main_input_filename rather than input_filename. + +2005-02-09 Richard Henderson <rth@redhat.com> + + * builtins.c (initialize_builtins): Call build_common_builtin_nodes. + * decl.c (java_init_decl_processing): Initialize const_ptr_type_node. + +2005-02-08 Marcin Dalecki <martin@dalecki.de> + + * expr.c (add_type_assertion): Use the proper enumeration type, + since this is what htab_find_slot() is expecting. + +2005-02-06 Joseph S. Myers <joseph@codesourcery.com> + + * gcj.texi: Update copyright dates. + +2005-02-02 Tom Tromey <tromey@redhat.com> + + * gcj.texi (libgcj Runtime Properties): Default library_control + to 'cache'. + +2005-02-02 Ranjit Mathew <rmathew@hotmail.com> + + PR java/15543 + * parse-scan.y (formal_parameter): Use $2 (type) instead of $$ + (modifiers) when square brackets are present in a declaration for + a final paramter. + * jv-scan.c (main): Set input_filename and input_line. + +2005-02-01 Tom Tromey <tromey@redhat.com> + + PR java/19742: + * gjavah.c (get_field_name): Don't override name for JNI header. + +2005-02-01 Roger Sayle <roger@eyesopen.com> + + * jcf-write.c (generate_bytecode_insns): Implement RSHIFT_EXPR + of unsigned types using iushr and lushr JVM bytecodes. + +2005-02-01 Ranjit Mathew <rmathew@hotmail.com> + + PR java/19738 + * gjavah.c (jni_print_float): Do not emit floating-point + initialiser for a static final field. + (jni_print_double): Likewise. + +2005-02-01 Mark Mitchell <mark@codesourcery.com> + + Revert: + 2005-01-31 Mark Mitchell <mark@codesourcery.com> + * gjavah.c (print_field_info): Mark static data members of + floating-point type with "__extension__". + +2005-01-31 Mark Mitchell <mark@codesourcery.com> + + * gjavah.c (print_field_info): Mark static data members of + floating-point type with "__extension__". + +2005-02-01 Ranjit Mathew <rmathew@hotmail.com> + + PR java/9157 + * parse.y (build_string_concatenation): Remove redundant if. + (patch_conditional_expr): Attempt to patch_string() the condition + of a ?: as well, in addition to its other operands. + +2005-01-25 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java/java-tree-inline.o): Removed. + +2005-01-25 Ranjit Mathew <rmathew@hotmail.com> + + PR java/19070 + * parse.y (patch_binop): Allow comparisons against NULL only + if the other operand is of a reference type. + +2005-01-24 Tom Tromey <tromey@redhat.com> + + * java-tree.h (gcj_abi_version): Declare. + * class.c (make_class_data): Push gcj_abi_version into "next" + field. Renamed field. + * decl.c (gcj_abi_version): New global. + (parse_version): New function. + (java_init_decl_processing): Call it. Renamed 'next' field. + Include version.h. + (GCJ_BINARYCOMPAT_ADDITION): New define. + +2005-01-24 Roger Sayle <roger@eyesopen.com> + + PR java/19295 + * jcf-write.c (generate_bytecode_insns): Conversions between + integer types of the same precision shouldn't generate widening + or narrowing conversion bytecodes. + +2005-01-22 Kazu Hirata <kazu@cs.umass.edu> + + * java-except.h, java-tree.h: Remove unused prototypes. + +2005-01-20 Andrew Pinski <pinskia@gcc.gnu.org> + + PR java/18091: + * jcf-write.c (perform_relocations): Don't call memcpy if source + and destination are the same. + +2005-01-17 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (get_short): Sign extend. + (get_int): Likewise. + +2005-01-12 Ranjit Mathew <rmathew@hotmail.com> + + * expr.c (build_jni_stub): Replace mistaken use of TYPE_SIZE_UNIT + with TYPE_SIZE. + +2005-01-10 Ranjit Mathew <rmathew@hotmail.com> + + * verify.c: Revert to the version before the BC-ABI merge. + +2005-01-10 Ranjit Mathew <rmathew@hotmail.com> + + PR java/19277 + * check-init.c (check_init): Take care of references that do not + have an explicit final variable declaration (e.g. array length + access) for pre/post in/de-crement operators. + +2005-01-08 Mark Wielaard <mark@klomp.org> + + * parse.y (process_imports): Allocate (and free) original_name only + when not already defined. + * jcf-parse.c (read_class): Free results of find_class() and + lrealpath(). + (java_parse_file): Keep pointer to head of file_list and free when + done. Free result of lrealpath(). + +2005-01-05 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Standard Properties): java.ext.dirs is now used. + +2004-12-20 Andrew Haley <aph@redhat.com> + + * typeck.c: Use fold_convert for ints and booleans. + +2004-12-17 Andrew Haley <aph@redhat.com> + + PR java/18931 + * typeck.c (convert): Use a CONVERT_EXPR when converting to + BOOLEAN_TYPE or CHAR_TYPE. + (convert_to_boolean, convert_to_char) : Remove. + * convert.h (convert_to_boolean, convert_to_char) : Remove. + * expr.c (expand_load_internal): Do type conversion if type is not + as required. + +2004-12-13 Danny Smith <dannysmith@users.sourceforge.net> + + PR target/18459 + * class.c (emit_register_classes): Use TARGET_USE_JCR_SECTION. + Update comment. + +2004-12-07 Andrew Haley <aph@redhat.com> + + PR java/18811: + * jcf-parse.c (load_class): Remove sanity test for missing inner + class file. + +2004-12-06 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (JAVA_MANFILES): Added gcj-dbtool. + (java.uninstall): Likewise. + (java.maintainer-clean): Likewise. + (.INTERMEDIATE): Likewise. + (java.install-man): Likewise. + (gcj-dbtool.pod): New target. + * gcj.texi (Code Generation): Document -findirect-dispatch. + (libgcj Runtime Properties): Document + gnu.gcj.precompiled.db.path. + (Top): Link to "Invoking gcj-dbtool". + +2004-12-06 Tom Tromey <tromey@redhat.com> + + PR java/14853: + * java-tree.h (extract_field_decl): Declare. + * parse.y (extract_field_decl): Renamed from + strip_out_static_field_access_decl. No longer static. + * check-init.c (get_variable_decl): Unwrap COMPOUND_EXPRs. + +2004-12-03 Tom Tromey <tromey@redhat.com> + + * lang.c (flag_new_verifier): Define. + (java_post_options): Set flag_new_verifier if indirect dispatch + is being used. + * lang.opt (fnew-verifier): Removed. + +2004-12-03 Tom Tromey <tromey@redhat.com> + + PR bootstrap/14614: + * Make-lang.in (java.install-common): Only install transformed + gcjh if gcj-cross exists. + +2004-12-03 Andrew Haley <aph@redhat.com> + + PR java/18812 + * except.c (link_handler): Patch 'outer' field of siblings of the + range we're demoting. + +2004-12-03 Andrew Haley <aph@redhat.com> + + PR java/18697 + * class.c (layout_class_method): Don't fail to override a method + simply because it has DECL_ARTIFICIAL set. + +2004-12-02 Tom Tromey <tromey@redhat.com> + + PR java/16675: + * parse.y (craft_constructor): Special case null_pointer_node. + +2004-12-02 Tom Tromey <tromey@redhat.com> + + PR java/18741: + * java-gimplify.c (java_gimplify_expr): Don't call + SET_EXPR_LOCATION unless wrapped tree is an expression. + +2004-11-27 Per Bothner <per@bothner.com> + + * jcf-parse.c (set_source_filename): Improvement to Andrew's fix: + Fix fencepost error in 'i', which got executed one too many times. + Also, fold memcpy into explicit loop, as originally intended. + Also, free temporary 'buf' which otherwise leaks. + +2004-11-27 Per Bothner <per@bothner.com> + + * expr.c (build_expr_wfl): Only declare last_file and last_filenode + local static variables if not USE_MAPPED_LOCATION. + +2004-11-27 Kazu Hirata <kazu@cs.umass.edu> + + * class.c, decl.c, expr.c: Fix comment typos. + +2004-11-26 Andrew Pinski <pinskia@physics.uc.edu> + + PR java/18305 + * decl.c (end_java_method): Call + attach_init_test_initialization_flags on all the init_decls. + * parse.y (attach_init_test_initialization_flags): Move to ... + * expr.c (attach_init_test_initialization_flags): here and + support BIND_EXPR also. + * java-tree.h (attach_init_test_initialization_flags): Prototype. + * jcf-parse.c (parse_class_file): Don't disable class init + optimization. + +2004-11-25 Joseph S. Myers <joseph@codesourcery.com> + + * gjavah.c, jcf-dump.c, jv-scan.c, jvspec.c: Avoid ` as left quote + in diagnostics. + +2004-11-24 Richard Henderson <rth@redhat.com> + + * verify-glue.c (vfy_init_name, vfy_clinit_name, vfy_object_type, + vfy_string_type, vfy_throwable_type): Use ANSI declaration form. + +2004-11-24 Tom Tromey <tromey@redhat.com> + + * verify.c (defer_merging): Don't use C++-style comment. + * verify.h (java_opcode): Added java_opcode_end. + * class.c (build_class_ref): Remove C++ comment and old FIXME. + + * verify-impl.c (vfy_push_type): Removed bogus "return". + (initialize_stack): Use vfy_alloc and vfy_free. + (verify_instructions_0): Likewise. + + * Merged gcj-abi-2-dev-branch to trunk. + +2004-11-24 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (parse_class_file): Set file_start_location. + +2004-11-10 Tom Tromey <tromey@redhat.com> + + * class.c (make_field_value): Don't call build_static_field_ref. + (build_static_field_ref): Don't emit direct references when using + indirect dispatch. + + * gcj.texi (Invoking gij): Document -verbose. Put -verbose and + -verbose:class into man page synopsis. + +2004-11-09 Tom Tromey <tromey@redhat.com> + + * expr.c (build_java_arraystore_check): Still generate check if + element type is itself an array. + +2004-11-08 Tom Tromey <tromey@redhat.com> + + * java-tree.h (soft_check_assignment_node): Removed. + (enum java_tree_index): Removed JTI_SOFT_CHECK_ASSIGNMENT_NODE. + * decl.c (java_init_decl_processing): Don't initialize + soft_check_assignment_node. + +2004-11-05 Tom Tromey <tromey@redhat.com> + + * class.c (layout_class_methods): Don't add Miranda methods when + using indirect dispatch. + +2004-11-05 Bryce McKinlay <mckinlay@redhat.com> + + * class.c (make_class_data): Call emit_assertion_table to set the + 'assertion_table' field. + (build_signature_for_libgcj): Move here from expr.c. + (add_assertion_table_entry): New function. Callback for assertion + hashtable traversal. + (emit_assertion_table): New. Take class argument, and generate + assertion table DECL based on the TYPE_ASSERTIONS hashtable. + * decl.c (init_decl_processing): Define assertion_entry_type record. + Push 'assertion_table' class field instead of 'verify'. + * expr.c (type_assertion_eq): Compare 'assertion_code' field. + (type_assertion_hash): Include 'assertion_code' in hash. + (add_type_assertion): Rewritten. Take class and assertion_code + arguments. Add assertions to the TYPE_ASSERTIONS hashtable. + (can_widen_reference_to): Use new add_type_assertion() arguments. + * java-tree.h (java_tree_index): Add JTI_ASSERTION_ENTRY_TYPE, + JTI_ASSERTION_TABLE_TYPE. Remove JTI_VERIFY_IDENTIFIER_NODE. + (verify_identifier_node): Removed. + (assertion_entry_type, assertion_table_type): New. + (ASSERTION_TYPES_COMPATIBLE, ASSERTION_IS_INSTANTIABLE): New. Type + assertion code definitions. + (struct type_assertion): Add assertion_code. Rename 'source_type' and + 'target_type' to 'op1' and 'op2'. + (add_type_assertion): Declare. + (lang_printable_name_wls): Remove unused definition. + * verify-glue.c: (vfy_is_assignable_from): New. Call add_type_assertion + to emit runtime assertion. + (vfy_note_stack_type): Clean up non-C90 declarations. + (vfy_note_local_type): Likewise. + * verify.h (vfy_is_assignable_from): Declare. + * verify-impl.c (is_assignable_from_slow): Remove unused function. + (ref_compatible): Rename arguments. Call vfy_is_assignable_from() + instead of is_assignable_from_slow(). + (types_compatible): Reinstate ref_compatible() call. + +2004-11-04 Tom Tromey <tromey@redhat.com> + + * class.c (build_static_field_ref): Reverted previous patch. + + * class.c (build_static_field_ref): Don't emit direct references + when using indirect dispatch. + +2004-11-03 Tom Tromey <tromey@redhat.com> + + * expr.c (expand_java_arrayload): Set lhs_type_node. + (expand_java_arraystore): Set rhs_type_node. + +2004-11-02 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (compute_class_name): Use filename length from zip + directory, not strlen. + + * expr.c (expand_invoke): Mark new interface methods as abstract. + +2004-11-01 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (push_jump): Removed check for uninitialized + objects. + (push_exception_jump): Likewise. + (handle_ret_insn): Likewise. + (handle_jsr_insn): Likewise. + (state_check_no_uninitialized_objects): Removed. + + * decl.c (check_local_unnamed_variable): Recognize + promoted-to-int parameters when using the new verifier. + * expr.c (expand_java_arraystore): Explicitly request array type + when using new verifier. + (expand_java_arrayload): Likewise. + (invoke_build_dtable): Don't pass object_type_node as + expression argument to build_java_indirect_ref. + (build_java_check_indexed_type): Do nothing. + (build_java_arraystore_check): Handle case where array doesn't + have array type. + (build_java_array_length_access): Likewise. + (expand_invoke): Handle case where interface overrides a method + from Object. + (pop_type_0): Always succeed for reference types. + (process_jvm_instruction): Don't pop a value in a dead + exception handler. + (pop_arguments): Convert arguments to correct types. + +2004-10-29 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (give_name_to_class): Remove line that was + incorrectly merged. + +2004-10-29 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (set_source_filename): Add code to build new sfname. + +2004-10-20 Andrew Haley <aph@redhat.com> + + * decl.c (end_java_method): Don't expand if flag_syntax_only. + +2004-10-26 Tom Tromey <tromey@redhat.com> + + * verify.h (vfy_notify_verified): Removed. + * verify-glue.c (vfy_notify_verified): Removed. + +2004-10-26 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (debug_print_state): Declare `i' before code. + (merge_types): Modify `t' when it is null_type. + +2004-10-26 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (type_print): Renamed from print. Now static and + takes an argument. + (debug_print_state): Use type_print. + +2004-10-25 Tom Tromey <tromey@redhat.com> + + * expr.c (build_invokeinterface): Compute correct offset for + index into interface methods. + +2004-10-20 Tom Tromey <tromey@redhat.com> + + * java-tree.h (verify_jvm_instructions_new): Declare. + + * jvspec.c (jvgenmain_spec): Remove -fnew-verifier from cc1 + command line. + + * verify-impl.c (verify_instructions): Correctly handle wide + types on the stack. + * verify-glue.c (vfy_get_class_name): Use DECL_NAME. + (vfy_get_component_type): Strip pointer types. + (vfy_find_class): Use get_type_from_signature. Strip pointer + types. + Include java-except.h. + +2004-10-20 Bryce McKinlay <mckinlay@redhat.com> + + * verify-impl.c (type_array_elementpop_raw, vfy_pop_type_t, + vfy_push_type_t, set_variable, add_new_state, merge_into, + handle_jsr_insn, branch_prepass, check_class_constant, + check_wide_constant, get_one_type, compute_static_types, + verify_instructions_0): Clean up C99 declarations after statements. + +2004-10-20 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (merge_refs): Compare reference against iterator, + not ref2. + + * verify-glue.c (vfy_tag): Mask off resolved flag. + +2004-10-19 Tom Tromey <tromey@redhat.com> + + * verify-impl.c (verify_instructions): Call vfy_note_local_type. + (init_state_with_stack): Initialize `this_type' in state. + (verify_method): Use debug_print. + * verify-glue.c (vfy_is_primitive): Removed debugging print. + (vfy_note_stack_depth): Reverted last patch. + (vfy_note_stack_type): Note pointer to Object, not Object. + (vfy_note_local_type): Likewise. + + * verify.h (vfy_note_instruction_seen): Declare. + * verify-glue.c (verify_jvm_instructions_new): Set + BCODE_EXCEPTION_TARGET on target instruction. + (vfy_note_instruction_seen): New function. + * verify-impl.c (FLAG_INSN_SEEN): New define. + (verify_instructions_0): Set flag on instruction. Save state for + PC=0 later. + (verify_instructions): Call vfy_note_instruction_seen. + + * verify-glue.c (vfy_note_stack_depth): Fix off-by-one error. + (verify_jvm_instructions_new): Call method_init_exceptions, + add_handler, and handle_nested_ranges. + * verify-impl.c (verify_method): Return 1 on success. + (verify_instructions_0): Save the state at PC=0. + + * verify-impl.c (init_type_from_class): Set is_resolved and + ref_next on new ref_intersection. + (init_type_from_string): Likewise. + +2004-10-15 Bryce McKinlay <mckinlay@redhat.com> + + * expr.c (expand_bytecode): Use verify_jvm_instructions_new + if flag_new_verifier is set. + * java-tree.h (flag_new_verifier): Declare. + * lang.opt (fnew-verifier): New option. + * verify-impl.c: Work around namespace pollution by undef'ing + 'current_class'. + (struct verifier_context): Make 'bytecode' const. + (verify_fail_pc): Pass -1 PC argument to vfy_fail. + (types_compatible): For the BC-ABI, always consider reference types + compatible. + (check_class_constant): Use vfr->current_class. + (check_constant): Likewise. + (check_wide_constant): Likewise. + (check_field_constant): Check for 'L' at start of type name. + (get_one_type): Return pointer instead of type. Set type result in + caller via passed type pointer. + (compute_argument_types): Update to use new get_one_type arguments. + (compute_return_type): Likewise. + (make_verifier_context): New. Allocate and initialize 'vfr'. + (free_verifier_context): New. Free 'vfr' and its contents. + (verify_method): Remove ATTRIBUTE_UNUSED. Call make_verifier_context + and free_verifier_context. + +2004-10-15 Tom Tromey <tromey@redhat.com> + + * verify-glue.c (vfy_note_local_type): Mark argument as unused. + * verify.h (vfy_fail): Fixed formatting. + + * verify-impl.c (vfr): Fixed comment formatting. + (collapse_type): New function. + (verify_instructions): Notify compiler about type map. + * verify.h (vfy_note_stack_depth): Updated. + (vfy_note_stack_type): Likewise. + (vfy_note_local_type): Likewise. + (vfy_unsuitable_type, vfy_return_address_type, vfy_null_type): + Declare. + * verify-glue.c (vfy_note_stack_depth): Correctly size type + state. Added `method' argument. + (vfy_note_stack_type): Renamed from vfy_note_type. Added `method' + argument. + (vfy_note_local_type): New function. + (vfy_unsuitable_type): Likewise. + (vfy_return_address_type): Likewise. + (vfy_null_type): Likewise. + + * verify.h (VFY_IN_GCC): Removed. + (VFY_WANT_TYPEMAP): Removed. + * verify-impl.c (verify_instructions_0): Removed useless "\". + (struct state) <next>: Uncomment. + +2004-10-13 Bryce McKinlay <mckinlay@redhat.com> + + * verify-impl.c: Formatting fixes. Reformat C++-style comments to + C-style. + +2004-10-06 Bryce McKinlay <mckinlay@redhat.com> + + * Make-lang.in (verify.o): Re-enabled this target. + * verify-glue.c (vfy_get_interface_count): Add ATTRIBUTE_UNUSED. + (vfy_get_interface): Likewise. + (verify_jvm_instructions_new): Renamed from verify_jvm_instructions. + * verify.h (verify_jvm_instructions_new): Declare. + * verify-impl.c (free_state): Temporarily comment out unused + function. + +2004-10-06 Tom Tromey <tromey@redhat.com> + + * java-tree.h (JV_STATE_READ): New enum value. + +2004-10-06 Bryce McKinlay <mckinlay@redhat.com> + + * verify.h: New file. + +2004-10-05 Bryce McKinlay <mckinlay@redhat.com> + + * verify-impl.c, verify-glue.c, verify.h: New files. + * Make-lang.in: Add rules for verify-impl.o and verify-glue.o. + +2004-09-24 Andrew Haley <aph@redhat.com> + + * decl.c (check_local_unnamed_variable): Always use the PARM_DECL + for a slot if it's of pointer type. + +2004-09-14 Tom Tromey <tromey@redhat.com> + + * class.c (make_class_data): Correctly initialize "state" field. + Initialize "engine" field. + * decl.c (java_init_decl_processing): Add "engine" field. + +2004-09-10 Andrew Haley <aph@redhat.com> + + PR java/12760 + * expr.c (build_invokeinterface): Use fast method for interface + dispatch. + * java-tree.h (enum java_tree_index): Add JTI_ITABLE_TYPE, + JTI_ITABLE_PTR_TYPE. + (struct lang_type): Add itable_methods, itable_decl, itable_syms_decl. + (emit_symbol_table): Add new arg, element_size. + * decl.c (java_init_decl_processing): Initialize Class.itable. + * class.c (GEN_TABLE): New macro. + (gen_indirect_dispatch_tables): Use it. Add itable. + (make_class_data): Add new arg for emit_symbol_table(). + Emit itable. + (add_miranda_methods): Make sure search_class has been parsed. + (emit_symbol_table): Add new arg, element_size. + +2004-09-06 Andrew Haley <aph@redhat.com> + + * verify.c (merge_types): Return Object for all merges of + interfaces. + * expr.c (add_type_assertion): Don't generate assertions when + source type is array of Object. + +2004-09-03 Andrew Haley <aph@redhat.com> + + * class.c (finish_class): Nullify TYPE_VERIFY_METHOD. + + * lang.c (java_post_options): Force flag_verify_invocations if + we're not using indirect dispatch. + + * expr.c (pop_type_0): Move test for interfaces before call to + can_widen_reference_to(). + (build_signature_for_libgcj): Remove generation of canonical array + type. + (add_type_assertion): Canonicalize both arrays. + Don't assert that type X can be assigned to Object. + Don't assert that type X an be assigned to type X. + Don't assert that Object can be assigned to type X. + (can_widen_reference_to): Warn whenever we generate an assertion. + (process_jvm_instruction): Use throwable_type_node for the type of + an exception class. + +2004-09-01 Andrew Haley <aph@redhat.com> + + * decl.c (java_init_decl_processing): Change + verify_identifier_node to "__verify". + * expr.c (add_type_assertion): Use verify_identifier_node for name. + * java-tree.h (verify_identifier_node): Change to "__verify". + + * expr.c (build_signature_for_libgcj): New function. + (add_type_assertion): Use it to construct signatures for + source_type and target_type. + +2004-08-27 Andrew Haley <aph@redhat.com> + + * java-tree.h (enum java_tree_index): Add JTI_VERIFY_IDENTIFIER_NODE. + (verify_identifier_node): New. + (TYPE_VERIFY_METHOD): New. + (struct type_assertion): New type. + * expr.c (type_assertion_eq): New function. + (type_assertion_hash): New function. + (add_type_assertion): New function. + (can_widen_reference_to): Call add_type_assertion(). + * decl.c (java_init_decl_processing): Add verify_identifier_node. + * class.c (make_class_data): Initialize TYPE_VERIFY_METHOD (type). + (finish_class): Output TYPE_VERIFY_METHOD (type). + + * decl.c (end_java_method): Nullify unused fields. + +2004-08-17 Andrew Haley <aph@redhat.com> + + * verify.c (defer_merging): Quieten. + * jcf-parse.c (load_class): Only try to open a class file if it's + java.lang.Object or if it's part of the current compilation. + Check that the class we just tried to load is the class we just + loaded. Quieten. + (java_parse_file): Set flag_verify_invocations off if we're + compiling from .class. + (parse_zip_file_entries): Abort if we try to read a dummy class. + * expr.c (can_widen_reference_to): Quieten. + (build_invokevirtual): Abort if we try to invokevirtual an + interface. + (expand_invoke): Don't build a non-interface call to an interface. + (build_instanceof): Don't do premature optimization if + flag_verify_invocations is not set. + * class.c (set_super_info): Disable code that inherits TYPE_DUMMY + from superclass. + (build_static_field_ref): Add correct type conversion for + field_address. + (add_miranda_methods): Disable generation of Miranda methods for + dummy classes. + (layout_class_method): Don't complain about non-static method + overrides static method with dummy classes. + +2004-08-13 Tom Tromey <tromey@redhat.com> + + * class.c (build_static_field_ref): Re-enable atable lookups for + static fields. + + * parse.y (strip_out_static_field_access_decl): Indentation fix. + +2004-08-11 Tom Tromey <tromey@redhat.com> + + * gcj.texi (libgcj Runtime Properties): Document new properties. + +2004-08-06 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (load_class): Check that we really have loaded the + class we're looking for. + +2004-07-19 Andrew Haley <aph@redhat.com> + + * verify.c (verify_jvm_instructions): Comment change only. + + * typeck.c (build_java_array_type): Add size field to array name. + + * java-tree.h (LOCAL_SLOT_P): New. + (update_aliases): Add PC argument. + (pushdecl_function_level): New function. + + * java-gimplify.c (java_gimplify_expr): Handle VAR_DECL, + MODIFY_EXPR, and SAVE_EXPR. + (java_gimplify_modify_expr): New function. + + * expr.c (push_type_0): Call find_stack_slot() to create temporary. + (expand_iinc): Pass PC to update_aliases(). + (STORE_INTERNAL): Likewise. + (process_jvm_instruction): Likewise. + + * decl.c (base_decl_map): New variable. + (uniq): New variable. + (update_aliases): Rewrite with more thorough checking. + (debug_variable_p): New function. + (push_jvm_slot): Don't initialize local variable. Don't pushdecl. + (check_local_named_variable): Delete whole function. + (initialize_local_variable): New function. + (check_local_unnamed_variable): Add checks and comments. + (find_local_variable): Rewrite. + (java_replace_reference): New function. + (function_binding_level): New variable. + (pushdecl_function_level): New function. + (maybe_pushlevels): Set DECL_LOCAL_END_PC. + (maybe_pushlevels): Call pushdecl() on each of the new decls. + (start_java_method): Reset uniq. Create base_decl_map. Set + function_binding_level. + (end_java_method): Null unused fields to save memory. + +2004-06-29 Andrew Haley <aph@redhat.com> + + * except.c (expand_start_java_handler): Push a new binding level. + Don't build a TRY_CATCH_EXPR now, we'll do it later. Call + register_exception_range() to register where we'll do it. + (expand_end_java_handler): Remove old bogus code. Replace with + new logic that simply builds TRY_CATCH_EXPRs and inserts them at + the top of the expression we're curently building. + (maybe_end_try): Delete. + * decl.c (binding_level.exception_range): New field. + (clear_binding_level): Add field exception_range. Reformat. + (poplevel): Call expand_end_java_handler(). + (poplevel): Call java_add_stmt only if functionbody is false. + (maybe_poplevels): Don't call maybe_end_try() from here. + (end_java_method): Clear no longer used trees in function decl. + (register_exception_range): New function. + * java-tree.h (register_exception_range, struct eh_range): Declare. + +2004-06-22 Andrew Haley <aph@redhat.com> + + * class.c (gen_indirect_dispatch_tables): Set the DECL_OWNER of + the otable. + * check-init.c (get_variable_decl): Teach check-init about + FIELD_DECLs addressed via the otable. + * jcf-parse.c (load_class): Check CLASS_LOADED_P, not + CLASS_PARSED_P. + +2004-05-28 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (load_class): Don't try to read a class that we've + already read. + + * expr.c (build_invokeinterface): Use the old-fashioned way of + doing indirect dispatch: look up interfaces by name. + * java-tree.h (enum java_tree_index): Add + JTI_SOFT_LOOKUPINTERFACEMETHODBYNAME_NODE + * decl.c (java_init_decl_processing): Add + soft_lookupinterfacemethodbyname_node. + + * gjavah.c (print_method_info): Final methods have vtable entries, + so gjavah needs to output them. + * class.c (layout_class_method): Generate vtable entries for final + methods. + * parse.y (invocation_mode): Use INVOKE_VIRTUAL for indirect + dispatch, even if a method is final. + +2004-05-25 Andrew Haley <aph@redhat.com> + + * class.c (build_symbol_entry): Convert the names of constructors + to init_identifier_node when generating an entry for the indirect + dispatch table. + + * expr.c (build_known_method_ref): Generate indirect calls for + all methods marked DECL_EXTERNAL or TREE_PUBLIC. + +2004-05-24 Andrew Haley <aph@redhat.com> + + * expr.c (build_known_method_ref): Make sure ARRAY_REF access to + atable element is of the right type. + + * class.c (build_static_field_ref): Cast pointer to correct type + for field. + +2004-04-20 Bryce McKinlay <mckinlay@redhat.com> + + * Merged with HEAD as of 20040514. Diff against + gcj-abi-2-merge-20040514. + +2004-04-16 Andrew Haley <aph@redhat.com> + + * verify.c (check_pending_block): Disable subroutine checks. + (defer_merging): New function. + (merge_types): If types are dummy, use defer_merging to combine them. + (verify_jvm_instructions): If invocation is invokeinterface and + target is dummy, assume target really is an interface. + + * parse.y (patch_invoke): Break out call to java_create_object. + + * lang.c (flag_verify_invocations): New. + + * jcf-parse.c (load_class): If we've already failed to load a + class, don't try again. + (load_class): If we can't find a .class file, don't fail, but emit + a warning. + (parse_class_file): Don't act on dummy methods. + + * java-tree.h (flag_verify_invocations): New. + (TYPE_DUMMY): New. + (lang_type.dummy_class): New field. + (java_create_object): New function. + (METHOD_DUMMY): New. + + * expr.c (build_field_ref): Widen field offset. + (pop_type_0): If the type in stack_type_map is a TREE_LIST, check + that each of its elements is compatible with the one we're + popping. + (pop_type_0): Issue a warning to say that we need to generate a + runtime check. + (java_create_object): New function. + (build_field_ref): Only generate hard refs if we're not using + indirect dispatch. + (expand_java_field_op): If we're using !verify_invocations and we + see a missing field, generate a decl for it. + + (expand_invoke): If a class doesn't have the method we seek and + we're using !flag_verify_invocations, generate a decl for the + method now. + + (build_known_method_ref): Always use indirect dispatch via the + atable for static methods. + + (expand_java_NEW): Break out object creation into new function, + java_create_object. + + (can_widen_reference_to): Issue a warning to say that we need to + generate a runtime check. + + * class.c (set_super_info): Inherit TYPE_DUMMY from sureclass. + (make_method_value): Also use index for interfaces. + (make_class_data): Skip dummy field for inherited data. + Don't build method array for dummy methods. + Set size_in_byte to -1 when using inirect dispatch + Don't build a hard class ref if we don't have a hard ref to our + superclass, or if we're using inirect dispatch. + Null out dispatch tables. + + (layout_class_method): Don't complain about non-static method + overrides static method is method is artificial. + + (build_static_field_ref): Disable atable references to static + fields for the time being. + + (layout_class_methods): Check for CLASS_INTERFACE as + well as CLASS_ABSTRACT. + +2004-11-24 Steven Bosscher <stevenb@suse.de> + + * class.c (make_class_data): Don't check flag_inline_functions. + * lang.c (flag_really_inline): Remove unused flag. + (java_handle_option): Don't set it here. Remove special handling + of flag_inline_functions for Java. + (java_init): Don't set flag_inline_trees here. Already done... + (java_post_options): ...here. Don't clear flag_inline_functions. + +2004-11-24 Steven Bosscher <stevenb@suse.de> + + * java-gimplify.c (java_gimplify_labeled_block_expr): New function. + (java_gimplify_exit_block_expr): New function. + (java_gimplify_expr): Use them to gimplify EXIT_BLOCK_EXPR and + LABELED_BLOCK_EXPR. + * java-tree.def (LABELED_BLOCK_EXPR): Moved from tree.def. + (EXIT_BLOCK_EXPR): Likewise. + * java-tree.h (LABELED_BLOCK_LABEL): Moved from tree.h. + (LABELED_BLOCK_BODY): Likewise. + (EXIT_BLOCK_LABELED_BLOCK): Likewise. + * jcf-write.c (generate_bytecode_insns): Don't handle the unused + EXIT_BLOCK_RETURN operand. Use EXIT_BLOCK_LABELED_BLOCK instead of + TREE_OPERAND. + * lang.c (java_tree_inlining_walk_subtrees): Handle EXIT_BLOCK_EXPR. + (java_dump_tree): Use LABELED_BLOCK_LABEL, LABELED_BLOCK_BODY, and + EXIT_BLOCK_LABELED_BLOCK instead of TREE_OPERAND. Don't handle the + second operand of EXIT_BLOCK_EXPR. + * parse.y (find_expr_with_wfl): Use LABELED_BLOCK_BODY instead of + TREE_OPERAND. + (build_bc_statement): Use build1 to build EXIT_BLOCK_EXPR nodes. + +2004-11-23 Ben Elliston <bje@au.ibm.com> + + * xref.h (xref_flag_value): Remove. + (xref_set_data, xref_get_data): Likewise. + (xref_set_current_fp): Likewise. + (XREF_NONE): Likewise. + (XREF_GET_DATA): Likewise. + * xref.c (xref_flag_value): Remove. + (xref_set_data, xref_get_data): Likewise. + (xref_set_current_fp): Likewise. + +2004-11-23 Ben Elliston <bje@au.ibm.com> + + * gjavah.c (output_directory): Make static. + (temp_directory): Likewise. + +2004-11-15 Tom Tromey <tromey@redhat.com> + + * decl.c (instn_ptr_type_node): Removed. + (lineNumbers_ptr_type_node): Removed. + (jint_type): Removed. + (jint_ptr_type): Removed. + +2004-11-09 Andrew Pinski <pinskia@physics.uc.edu> + + PR java/15576 + * check-init.c (check_init): Ignore DECL_EXPR. + * expr.c (always_initialize_class_p): Reenable. + (build_class_init): Use a variable to store the decl. Also use + boolean_false_node instead of integer_zero_node. + * parse.y (attach_init_test_initialization_flags): Add a decl_expr + to the block. + +2004-11-08 Tom Tromey <tromey@redhat.com> + + PR java/16843: + * gjavah.c (HANDLE_END_FIELD): Call print_field_info when + generating a JNI header. + (print_field_info): Handle JNI headers. + (jni_print_float): Likewise. + (jni_print_double): Likewise. + +2004-11-08 Andrew Pinski <pinskia@physics.uc.edu> + + * decl.c (end_java_method): Remove duplicated code. + +2004-11-06 Zack Weinberg <zack@codesourcery.com> + Gerald Pfeifer <gerald@pfeifer.com> + + * lex.h (HAVE_ICONV): Undefine if we do not have HAVE_ICONV_H + as well. + +2004-11-02 Bryce McKinlay <mckinlay@redhat.com> + + PR java/17265 + * class.c: Reinstate 2004-08-18 patch. + (make_local_function_alias): Don't create an alias for extern (native) + functions. + +2004-10-22 Eric Botcazou <ebotcazou@libertysurf.fr> + + PR java/17265 + * class.c (make_local_function_alias): Revert 2004-08-18 change. + (make_method_value): Likewise. + +2004-10-21 Andrew Haley <aph@redhat.com> + + PR java/18091: + * jcf-parse.c (set_source_filename): Add code to build new sfname. + +2004-10-20 Andrew Haley <aph@redhat.com> + + * decl.c (end_java_method): Don't expand if flag_syntax_only. + Remove duplicated code block. + +2004-10-18 Steven Bosscher <stevenb@suse.de> + + * Make-lang.in (java/parse.o-warn, java/parse-scan.o-warn): + New rules to work around old Bison warnings. + +2004-10-17 Steven Bosscher <stevenb@suse.de> + + * class.c (ident_subst): Always alloca buffer. + * java-opcodes.h (LAST_AND_UNUSED_JAVA_OPCODE): Add this dummy + opcode after including javaop.def. + * jcf-dump.c (CHECK_PC_IN_RANGE): Return 0 from the arm of the + conditional expression that exits, to avoid warnings. + * verify.c (CHECK_PC_IN_RANGE): Mark the __GNUC__ definition as + a user of an extension. + * win32-host.c: Move check down to have non-empty file when + WIN32 is not defined. + + * Make-lang.in (java-warn): Add STRICT_WARN. + (java/jcf-io.o-warn): Don't have Werror for this file. + * jcf-io.c (caching_stat): Add FIXME for non-POSIX scandir use. + +2004-10-16 Hans-Peter Nilsson <hp@bitrange.com> + + * expr.c (expr_add_location): Move declaration to before all + statements. + * parse.y (java_expand_classes): Ditto. + * lex.c (java_peek_unicode): Ditto. + +2004-10-16 Ranjit Mathew <rmathew@hotmail.com> + + * check-init.c: Use %<, %> and %q for quoting in diagnostics, + if possible, else convert `foo' to 'foo'. + * class.c: Likewise. + * decl.c: Likewise. + * expr.c: Likewise. + * jcf-io.c: Likewise. + * jcf-parse.c: Likewise. + * lang.c: Likewise. + * lex.c: Likewise. + * parse.h: Likewise. + +2004-10-16 Ranjit Mathew <rmathew@hotmail.com> + + * parse.y (parse_warning_context): Remove ATTRIBUTE_PRINTF_2 and + rename parameter 'msg' to 'msgid' in function declaration. + (issue_warning_error_from_context): Likewise. + (yyerror): Rename parameter 'msg' to 'msgid'. + (all over): Use new quoting style for diagnostics. + +2004-10-15 Kazu Hirata <kazu@cs.umass.edu> + + * boehm.c, builtins.c, java-except.h, jcf-io.c, jcf-path.c, + jcf.h, lang-specs.h, lex.c, lex.h, resource.c, win32-host.c: + Update copyright. + +2004-10-14 Matt Austern <austern@apple.com> + + * lang.c (java_tree_inlining_walk_subtrees): Last arg is struct + pointer_set_t* now. + +2004-10-13 Tom Tromey <tromey@redhat.com> + + PR java/15578: + * lang.opt (--extdirs): Document. + * jvspec.c (lang_specific_driver): Recognize -encoding and + -extdirs. + +2004-10-06 Ulrich Weigand <uweigand@de.ibm.com> + + * parse.y (issue_warning_error_from_context): Use va_list * + instead of va_list parameter. + (parse_error_context): Update call. + (parse_warning_context): Likewise. + +2004-10-05 Zack Weinberg <zack@codesourcery.com> + + * parse.y, parse-scan.y: Add list of diagnostic messages to + insulate translation template from version of yacc/bison used + to compile the grammar. + +2004-10-05 Ranjit Mathew <rmathew@hotmail.com> + + Prepare for %q, %< and %> in diagnostic message strings. + * java-tree.h (parse_error_context): remove ATTRIBUTE_PRINTF_2. + Name second parameter 'msgid'. + * parse.y: Additionally include pretty-print.h and diagnostic.h. + (issue_warning_error_from_context): Use pretty-printer functions + instead of vsprintf for constructing formatted messages. Rename + parameter 'msg' to 'msgid'. + (parse_error_context): Rename parameter 'msg' to 'msgid'. + (parse_warning_context): Likewise. + +2004-10-05 Andrew Haley <aph@redhat.com> + + PR java/17779 + * jcf-parse.c (parse_zip_file_entries): If a class has a + superclass and a TYPE_SIZE of zero, lay it out. + +2004-09-30 Andrew Haley <aph@redhat.com> + + PR java/17733 + * jcf-parse.c (compute_class_name): Rewrite. + +2004-10-01 Jan Hubicka <jh@suse.cz> + + * java.c (java_expand_body): Update call of tree_rest_of_compilation. + +2004-10-01 Kazu Hirata <kazu@cs.umass.edu> + + * lex.c: Fix a comment typo. + +2004-10-01 Kazu Hirata <kazu@cs.umass.edu> + + * java-tree.h: Fix a comment typo. + +2004-09-30 Per Bothner <per@bothner.com> + + Simplify lexer. Implement --enable-mapped-location support. + * jcf-parse.c (parse_class_file): Use linemap_line_start. + (parse_source_file_1): Pass filename as extra parameter, so we can call + linemap_add and set input_location here, rather than in both callers. + (read_class): Pass copied filename to parse_source_file_1. + Don't initialize wfl_operator - only needed for source compilation. + (read_class, jcf_parse): Call linemap_add with LC_LEAVE. + * lex.h: Remove a bunch of debugging macros. + * lex.h (struct_java_line, struct java_error): Remove types. + (JAVA_COLUMN_DELTA): Remove - use java_lexer.next_colums instead. + (struct java_lc_s): Remove prev_col field. + (struct java_lexer): New fields next_unicode, next_columns, and + avail_unicode. New position field, and maybe token_start field. + Don't need hit_eof field - use next_unicode == -1 instead. + (JAVA_INTEGERAL_RANGE_ERROR): Rename to JAVA_RANGE_ERROR. + (JAVA_RANGE_ERROR, JAVA_FLOAT_ANGE_ERROR): Update accordingly. + * parse.h: Various changes for USE_MAPPED_LOCATION. + (EXPR_WFL_EMIT_LINE_NOTE): XXX + (BUILD_EXPR_WFL, EXPR_WFL_ADD_COL): Remove no-longer-used macros. + (struct parser_ctxt): New file_start_location field. + Remove p_line, c_line fields since we no longer save lines. + Remove elc, lineno, and current_jcf fields - no longer used. + * parse.y: Updates for USE_MAPPED_LOCATION and new lexer. + Don't use EXPR_WFL_ADD_COL since that isn't trivial with + source_location and is probably not needed anymore anyway. + Use new expr_add_Location function. + (SET_EXPR_LOCATION_FROM_TOKEN): New convenience macro. + (java_pop_parser_context): Minor cleanup. + (java_parser_context_save_global, java_parser_context_restore_global, + java_pop_parser_context): Save/restore input_location as a unit. + (issue_warning_error_from_context): If USE_MAPPED_LOCATION take + a source_location instead of a wfl context node. + (check_class_interface_creation): input_filename is not addressable. + (create_artificial_method): Calling java_parser_context_save_global + and java_parser_context_restore_global is overkill. Instead, + temporarily set input_location from class decl. + (java_layout_seen_class_methods): Set input_location from method decl. + (fix_constructors): Make more robust if no EXPR_WITH_FILE_LOCATION. + (finish_loop_body): Likewise. + * lex.c: Updates for USE_MAPPED_LOCATION. Use build_unknwon_wfl. + (java_sprint_unicode): Take a character, not index in line. + (java_sneak_uncode): Replaced by java_peek_unicode. + (java_unget_unicode): No longer used. + (java_allocate_new_line. java_store_unicode): Removed, since we + no longer remember "lines". + (java_new_lexer): Update for new data structures. + (java_read_char): Move unget_value checking to java_read_unicode. + (java_get_unicode, java_peek_unicode, java_next_unicode): New more + efficient functions that are used directly when lexing. + (java_read_unicode_collapsing_terminators): No longer needed. + (java_parse_end_comment, java_parse_escape_sequence, do_java_lex): + Re-organize to use java_peek_unicode to avoid java_unget_unicode. + (java_parse_escape_sequence): Rewrite to be simpler / more efficient. + (do_java_lex): Lots of movings around to avoid java_unget_unicode, + combine switch branches, and test for common token kinds earlier. + (java_lex_error): Rewrite. + * jv-scan.c (expand_location): New function, copied from tree.c. + (main): Set ctxp->filename instead of setting input_filename directly. + +2004-09-30 Per Bothner <per@bothner.com> + + More cleanup for --enable-mapped-location. + * class.c (push_class): If USE_MAPPED_LOCATION don't set + input_location here. Instead do it in give_name_to_class. + (build_class_ref): Set DECL_ARTIFICIAL, for the sake of dwarf2out. + * expr.c (expand_byte_code): Call linemap_line_start. + * expr.c (build_expr_wfl): If USE_MAPPED_LOCATION, change final + parameters to a source_location. Don't need EXPR_WFL_FILENAME_NODE. + (expr_add_location): New function, if USE_MAPPED_LOCATION. + * class.c (maybe_layout_super_class): Adjust build_expr_wfl call + to USE_MAPPED_LOCATION case. + + * java-tree.h (JAVA_FILE_P, ZIP_FILE_P): Remove unused macros. + * jcf-parse.c (java_parse_file): Don't set input_filename. + Use IS_A_COMMAND_LINE_FILENAME_P to check for duplicate filenames. + Create a list of TRANSLATION_UNIT_DECL. + (current_file_list): Is now a TRANSLATION_UNIT_DECL chain. The + reason is so we can set a DECL_SOURCE_LOCATION for each file. + (java_parse_file): Don't set unused ZIP_FILE_P, JAVA_FILE_P.. + Create line-map LC_ENTER/LC_LEAVE entries for archive itself. + (file_start_location): New static. + (set_source_filename): Avoid extra access to input_filename macro. + Concatenate new name with class's package prefix. + (set_source_filename, give_name_to_class): Update. + (give_name_to_class): Set class's "line 0" input_location here. + (parse_class_file): Set input_location as a unit. + + * jcf-parse.c (load_class): Sanity test if missing inner class file. + +2004-09-29 Per Bothner <per@bothner.com> + + * java-tree.h: Redefine some macros and add some declaration + to handle the USE_MAPPED_LOCATION case. + * parse.h (EXPR_WFL_QUALIFICATION): Use operand 1, not 2. + * java-tree.h (EXPR_WFL_FILENAME_NODE): Use operand 2, not 1. + * java-tree.def (EXPR_WITH_FILE_LOCATION): Only need two operands in + USE_MAPPED_LOCATION case, since EXPR_WFL_FILENAME_NODE is gone. + + * check-init.c (check_init): Handle USE_MAPPED_LOCATION case. + * decl.c (finish_method, java_add_stmt): Likewise. + * java-gimplify.c (java-gimplify.c): Likewise. + * jcf-write.c (generate_bytecode_insns): Likewise. + * lang.c (java_post_options): Likewise - call linemap_add. + +2004-09-29 Andrew Haley <aph@redhat.com> + + PR java/17007 + * parse.y (patch_binop): Don't mess with the TREE_SIDE_EFFECTS of the + result of TRUNC_MOD_EXPR. + (patch_unaryop): Likewise for CONVERT_EXPR, which may throw. + * decl.c (java_init_decl_processing): Mark + soft_lookupinterfacemethod_node and soft_instanceof_node pure. + +2004-09-28 Tom Tromey <tromey@redhat.com> + + PR java/15710: + * class.c (add_miranda_methods): Load superinterface if not + already loaded. + +2004-09-28 Andrew Haley <aph@redhat.com> + + PR java/17586 + * jcf-parse.c (load_class): Don't try to read a class that we've + already read. + +2004-09-28 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (load_class): Back out previous broken patch. + +2004-09-28 Andrew Haley <aph@redhat.com> + + PR java/17586 + * jcf-parse.c (load_class): Don't try to read a class that we've + already read. + Check that we really did read the right class. + +2004-09-25 Tom Tromey <tromey@redhat.com> + + PR java/17500: + * parse.y (create_artificial_method): Use add_method_1. + +2004-09-25 Kazu Hirata <kazu@cs.umass.edu> + + * expr.c, jcf-dump.c, parse-scan.y, parse.y: Fix + comment typos. + * gcj.texi: Fix typos. + +2004-09-24 Tom Tromey <tromey@redhat.com> + + PR java/15656: + * parse.y (class_instance_creation_expression): Set `$$' to NULL + in error parts of rule. + (unary_expression): Don't call error_if_numeric_overflow when $1 + is NULL. + +2004-09-24 Tom Tromey <tromey@redhat.com> + + PR java/16789: + * parse.y (resolve_qualified_expression_name): Set + CAN_COMPLETE_NORMALLY on first call when chaining static calls. + * expr.c (force_evaluation_order): Check for empty argument list + after stripping COMPOUND_EXPR. + +2004-09-23 Andrew Haley <aph@redhat.com> + + PR java/16927: + * parse.y (java_complete_lhs): Call patch_string() on Operand 1 of + COND_EXPRs. + +2004-09-23 Tom Tromey <tromey@redhat.com> + + PR java/17329: + * java-gimplify.c (java_gimplify_expr) <SAVE_EXPR>: Ignore case + where operand is null. + +2004-09-23 Tom Tromey <tromey@redhat.com> + + PR java/17380: + * parse.y (not_accessible_p): Allow access to protected members + even when class is not static. + +2004-09-22 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in: Revert the gcc-none.o change. + +2004-09-22 Nathan Sidwell <nathan@codesourcery.com> + + * parse.y (patch_anonymous_class): VEC_space returns true if there + is space. + +2004-09-21 Matt Austern <austern@apple.com> + + Fix bootstrap. + * gjavah.c (free_method_name_list): Fix function definition so + it's a proper C prototype. + +2004-09-21 Tom Tromey <tromey@redhat.com> + + PR java/17575: + * gjavah.c (free_method_name_list): New method. + (main): Call it. + +2004-09-17 Jeffrey D. Oldham <oldham@codesourcery.com> + Zack Weinberg <zack@codesourcery.com> + + * java-tree.def: Use tree_code_class enumeration constants + instead of code letters. + * java-gimplify.c, jcf-write.c, lang.c, parse.y: Update for + new tree-class enumeration constants. + +2004-09-13 Tom Tromey <tromey@redhat.com> + + PR java/17216: + * class.c (layout_class_method): Put synthetic methods into the + vtable. + +2004-09-11 Andrew Pinski <apinski@apple.com> + + * Make-lang.in (java/ggc-none.c): Change dependency + for ggc.h into $(GGC_H). + +2004-09-11 Mohan Embar <gnustuff@thisiscool.com> + + * Make-lang.in (java/win32-host.o): Add dependency on + coretypes.h. + * win32-host.c: Add includes for coretypes.h, jcf.h + +2004-09-11 Mohan Embar <gnustuff@thisiscool.com> + + * Make-lang.in (GCJH_OBJS): Change dependency from + ggc-none.o to java/ggc-none.o + (JCFDUMP_OBJS): Likewise. + (java/ggc-none.o): New target. + +2004-08-25 Nathan Sidwell <nathan@codesourcery.com> + + * boehm.c (get_boehm_type_descriptor): Adjust build_int_cst calls. + * class.c (build_utf8_ref, build_static_field_ref, + make_field_value, make_method_value, get_dispatch_table, + make_class_data, emit_symbol_table, emit_catch_table): Likewise. + * constants.c (get_tag_node, build_ref_from_constant_pool, + build_constants_constructor): Likewise. + * decl.c (java_init_decl_processing): Likewise. + * expr.c (build_java_array_length_access, build_newarray, + expand_java_multianewarray, expand_java_pushc, expand_iinc, + build_java_binop, build_field_ref, expand_java_add_case, + expand_java_call, build_known_method_ref, build_invokevirtual, + build_invokeinterface, build_jni_stub): Likewise. + * java-gimplify.c (java_gimplify_new_array_init): Likewise. + * jcf-parse.c (get_constant): Likewise. + * lex.c (do_java_lex): Likewise. + * parse.y (patch_binop, patch_unaryop, patch_cast, + build_newarray_node, patch_newarray): Likewise. + * resource.c (compile_resource_data): Likewise. + * typeck.c (build_prim_array_type): Likewise. + +2004-08-24 Nathan Sidwell <nathan@codesourcery.com> + + * decl.c (java_init_decl_processing): Adjust + initialize_sizetypes call. + +2004-08-23 Nathan Sidwell <nathan@codesourcery.com> + + * jv-scan.c (fancy_abort): Add. + +2004-08-20 Nathan Sidwell <nathan@codesourcery.com> + + * expr.c (build_java_arrayaccess): Use convert to change + len's type. + +2004-08-19 Bryce McKinlay <mckinlay@redhat.com> + + * class.c (make_local_function_alias): Allocate extra space for 'L' + in name buffer. Reported by Thomas Neumann. + +2004-08-19 Nathan Sidwell <nathan@codesourcery.com> + + * parse.h (JAVA_RADIX10_FLAG): Rename to ... + (JAVA_NOT_RADIX10_FLAG): ... here. Invert meaning. + * lex.c (do_java_lex): Adjust. + (error_if_numeric_overflow): Likewise. + +2004-08-18 Andrew Pinski <apinski@apple.com> + + * class.c (make_local_function_alias): Only make a new decl if we + support alias attribute on all decls. + +2004-08-18 Bryce McKinlay <mckinlay@redhat.com> + + * class.c (make_local_function_alias): New function. Create local + alias for public method DECL. + (make_method_value): Use make_local_function_alias. + * parse.y (craft_constructor): Don't special-case anonymous classes. + Always set ctor_name to init_identifier_node. + (lookup_method_invoke): Call layout_class_method when creating + anonymous class constructor. + +2004-08-18 Richard Henderson <rth@redhat.com> + + * java-gimplify.c (java_gimplify_expr): Move '2' handling into + default case. Treat '<' similarly. Update for + is_gimple_formal_tmp_var name change. + +2004-08-17 Andrew Haley <aph@redhat.com> + + * lang.c (lang_printable_name): Obey verbose flag. + * parse.y (constructor_circularity_msg): Set VERBOSE arg for + lang_printable_name(). + (verify_constructor_circularity, get_printable_method_name, + check_abstract_method_definitions, java_check_regular_methods, + java_check_abstract_methods, check_inner_class_access, + fix_constructors, patch_method_invocation, patch_return): + Likewise. + * expr.c (pop_type_0): Likewise. + + * java-tree.h (lang_printable_name_wls): Delete. + +2004-08-16 Tom Tromey <tromey@redhat.com> + + PR java/8473: + * parse.y (primary): Changed for initialized and uninitialized + array creations. + (array_access): Handle array_creation_initialized. + (array_creation_expression): Split into + array_creation_initialized and array_creation_uninitialized. + +2004-08-16 Andrew Haley <aph@redhat.com> + + * jcf-write.c (find_constant_index): Canonicalize NaNs when + generating bytecode. + +2004-08-16 Elliot Lee <sopwith@redhat.com> + + PR java/9677 + * jcf-parse.c (java_parse_file): Handle filenames with embedded + spaces, and quoted filelists. + +2004-08-15 Nathan Sidwell <nathan@codesourcery.com> + + * boehm.c (get_boehm_type_descriptor): Use build_int_cst. + * class.c (build_utf8_ref, build_static_field_ref, + make_field_value, make_method_value, get_dispatch_table, + make_class_data, emit_symbol_table, emit_catch_table): Likewise. + * constants.c (get_tag_node, build_ref_from_constant_pool, + build_constants_constructor): Likewise. + * decl.c (java_init_decl_processing): Likewise. + * expr.c (build_java_array_length_access, build_newarray, + expand_java_multianewarray, expand_java_pushc, expand_iinc, + build_java_binop, build_field_ref, expand_java_add_case, + expand_java_call, build_known_method_ref, build_invokevirtual, + build_invokeinterface, build_jni_stub): Likewise. + * java-gimplify.c (java_gimplify_new_array_init): Likewise. + * jcf-parse.c (get_constant): Likewise. + * lex.c (do_java_lex): Likewise. + * parse.y (patch_binop, patch_unaryop, patch_cast, + build_null_of_type, patch_newarray): Likewise. + * resource.c (compile_resource_data): Likewise. + * typeck.c (build_prim_array_type): Likewise. + +2004-08-10 Bryce McKinlay <mckinlay@redhat.com> + + * java-gimplify.c (java_gimplify_new_array_init): Use create_tmp_var. + Don't create BLOCK here or call java_gimplify_block. + +2004-08-09 H.J. Lu <hongjiu.lu@intel.com> + + * java-tree.h (flag_deprecated): Removed. + * lang.opt (Wdeprecated): Use existing Var(warn_deprecated). + * parse.y (check_deprecation): Check warn_deprecated instead of + flag_deprecated. + +2004-08-06 Kelley Cook <kcook@gcc.gnu.org> + + * lang.c (flag_emit_class_files, flag_filelist_file, flag_redundant, + flag_use_divide_subroutine, flag_use_boehm_gc, flag_store_check, + flag_hash_synchronization, flag_assert, flag_jni, flag_newer, + flag_check_references, flag_extraneous_semicolon, flag_deprecated, + flag_force_classes_archive_check, flag_optimize_sci, + flag_indirect_dispatch): Remove explicit declarations. + * lang.opt: Add implicit declare/define/assign. Remove obsolete + final comment. + +2004-08-05 Michael Chastain <mec.gnu@mindspring.com> + + PR bootstrap/14893 + * Make-lang.in (java.install-man): Install from either build + tree or source tree, whichever has the file first. + +2004-08-05 Nathan Sidwell <nathan@codesourcery.com> + + * jcf-parse.c (get_constant): Adjust force_fit_type call. + * lex.h (SET_LVAL_NODE_TYPE): Remove. + * lex.c (java_perform_atof): Use SET_LVAL_NODE directly. + (do_java_lex): Likewise. Adjust force_fit_type call. + +2004-08-04 Roger Sayle <roger@eyesopen.com> + Andrew Haley <aph@redhat.com> + + * typeck.c (convert_ieee_real_to_integer): Call fold on the range + checking trees as they're being built. + (convert): Call convert_ieee_real_to_integer if we're + converting a constant, even if we're writing a class file. + +2004-08-02 Bryce McKinlay <mckinlay@redhat.com> + + PR java/16701 + * parse.y (fold_constant_for_init): Call resolve_field_access with + correct current_class context. + +2004-08-01 Roger Sayle <roger@eyesopen.com> + + * decl.c (update_aliases, initialize_local_variable): Replace calls + to build with calls to buildN. + * java-gimplify.c (java_gimplify_modify_expr): Likewise. + * java-tree.h (BUILD_MONITOR_ENTER, BUILD_MONITOR_EXIT): Likewise. + * parse.h (BUILD_THROW): Likewise. + * parse.y (switch_expression, synchronized_statement, + catch_clause_parameter, array_creation_expression, + conditional_expression, make_qualified_name, + resolve_qualified_expression_name, patch_method_invocation, + patch_invoke, build_method_invocation, build_new_invocation, + build_assignment, patch_assignment, build_binop, patch_binop, + build_string_concatenation, build_incdec, patch_unaryop, + patch_cast, build_array_ref, build_newarray_node, patch_newarray, + patch_return, build_if_else_statement, build_labeled_block, + build_new_loop, build_loop_body, build_bc_statement, + build_assertion, encapsulate_with_try_catch, build_try_statement, + build_try_finally_statement, patch_synchronized_statement, + emit_test_initialization): Likewise, replace build with buildN. + +2004-07-28 Eric Christopher <echristo@redhat.com> + + * lang.c (LANG_HOOKS_UNSAFE_FOR_REEVAL): Delete. + (java_unsafe_for_reeval): Ditto. + +2004-07-26 <hp@bitrange.com> + + * parse.y (build_super_invocation): Adjust declaration order to + avoid declaration after statement. + +2004-07-25 Bernardo Innocenti <bernie@develer.com> + + * decl.c: Rename all identifiers named `class' to `cl'. + +2004-07-25 Richard Henderson <rth@redhat.com> + + * decl.c (build_result_decl): Set DECL_ARTIFICIAL and DECL_IGNORED_P. + +2004-07-23 Mike Stump <mrs@apple.com> + + * boehm.c (set_bit): Improve type safety wrt unsignedness. + * gjavah.c (throwable_p, decode_signature_piece, + print_full_cxx_name, print_include, add_namelet, add_class_decl, + process_file): Likewise. + * jcf-dump.c (main): Likewise. + * jcf-io.c (read_zip_member): Likewise. + * jcf-parse.c (HANDLE_CONSTANT_Utf8, get_constant, + give_name_to_class, get_class_constant): Likewise. + * jcf-write.c (find_constant_wide, push_long_const, + generate_classfile): Likewise. + * lex.c (java_new_lexer, java_read_char, cxx_keyword_p): Likewise. + * parse.y (read_import_dir): Likewise. + * typeck.c (parse_signature_type): Likewise. + * verify.c (verify_jvm_instructions): Likewise. + * zextract.c (find_zip_file_start, read_zip_archive): Likewise. + +2004-07-23 Thomas Fitzsimmons <fitzsim@redhat.com> + + * Make-lang.in: Replace rmic and rmiregistry references with + grmic and grmiregistry. + * gcj.texi: Likewise. + +2004-07-20 Andrew Haley <aph@redhat.com> + + PR java/16431. + * verify.c (verify_jvm_instructions): Comment change only. + + * typeck.c (build_java_array_type): Add size field to array name. + + * java-tree.h (LOCAL_SLOT_P): New. + (update_aliases): Add PC argument. + (pushdecl_function_level): New function. + + * java-gimplify.c (java_gimplify_expr): Handle VAR_DECL, + MODIFY_EXPR, and SAVE_EXPR. + (java_gimplify_modify_expr): New function. + + * expr.c (push_type_0): Call find_stack_slot() to create temporary. + (expand_iinc): Pass PC to update_aliases(). + (STORE_INTERNAL): Likewise. + (process_jvm_instruction): Likewise. + + * decl.c (base_decl_map): New variable. + (uniq): New variable. + (update_aliases): Rewrite with more thorough checking. + (debug_variable_p): New function. + (push_jvm_slot): Don't initialize local variable. Don't pushdecl. + (check_local_named_variable): Delete whole function. + (initialize_local_variable): New function. + (check_local_unnamed_variable): Add checks and comments. + (find_local_variable): Rewrite. + (java_replace_reference): New function. + (function_binding_level): New variable. + (pushdecl_function_level): New function. + (maybe_pushlevels): Set DECL_LOCAL_END_PC. + (maybe_pushlevels): Call pushdecl() on each of the new decls. + (start_java_method): Reset uniq. Create base_decl_map. Set + function_binding_level. + (end_java_method): Null unused fields to save memory. + +2004-07-20 Nathan Sidwell <nathan@codesourcery.com> + + * class.c (add_interface_do): Remove. + (set_super_info, interface_of_p, maybe_add_interface, + add_interface, make_class_data, layout_class, + add_miranda_methods): Adjust BINFO accessors and addition. + * expr.c (can_widen_reference_to, lookup_field): Adjust BINFO + accessors. + * jcf-write.c (generate_classfile): Likewise. + * parse.y (patch_anonymous_class, check_inner_circular_reference, + check_circular_reference, java_complete_class, + check_abstract_method_definitions, + java_check_abstract_method_definitions, + check_interface_throws_clauses, java_check_abstract_methods, + lookup_java_interface_method2, + find_applicable_accessible_methods_list): Adjust BINFO accessors + and addition. + * typeck.c (find_method_in_interfaces): Adjust BINFO accessors. + +2004-07-18 Roger Sayle <roger@eyesopen.com> + + * builtins.c (max_builtin, min_builtin, + java_build_function_call_expr): Replace calls to build with buildN. + * class.c (build_class_ref, build_static_field_ref, + get_dispatch_table, make_class_data, layout_class_method): Likewise. + * constants.c (build_ref_from_constant_pool): Likewise. + * decl.c (update_aliases, push_jvm_slot, poplevel, finish_method, + add_stmt_to_compound): Likewise. + * except.c (build_exception_object_ref, expand_end_java_handler): + Likewise. + * java-gimplify.c (java_gimplify_case_expr, + java_gimplify_default_expr, java_gimplify_block, + java_gimplify_new_array_init, java_gimplify_try_expr): Likewise. + * jcf-write.c (generate_bytecode_insns): Likewise. + * typeck.c (convert_ieee_real_to_integer): Likewise. + +2004-07-17 Joseph S. Myers <jsm@polyomino.org.uk> + + * java-tree.h (builtin_function): Declare. + +2004-07-16 Steven Bosscher <stevenb@suse.de> + + * parse.y (java_complete_expand_methods, java_expand_classes): Don't + abuse restore_line_number_status. + +2004-07-15 Frank Ch. Eigler <fche@redhat.com> + + g++/15861 + * jcf-parse.c (java_emit_static_constructor): Specify default + priority. + +2004-07-13 Per Bothner <per@bothner.com> + + * java-tree.h (all_class_filename): Remove useless macro. + (enum java_tree_index): Remove JTI_ALL_CLASS_FILENAME constant. + (BUILD_FILENAME_IDENTIFIER_NODE): Remove useless macro. + * parse.y (java_parser_context_restore_global): Replace + BUILD_FILENAME_IDENTIFIER_NODE by plain get_identifier. + * jcf-parse.c (read_class, java_parse_file): Likewise. + +2004-07-12 Bryce McKinlay <mckinlay@redhat.com> + + PR java/16474 + gjavah.c (print_field_info): Emit constant only if field is static. + +2004-07-11 Roger Sayle <roger@eyesopen.com> + + * expr.c (java_truthvalue_conversion, flush_quick_stack, + java_stack_swap, java_stack_dup, build_java_athrow, build_java_jsr, + build_java_ret, build_java_throw_out_of_bounds_exception, + build_java_array_length_access, java_check_reference, + build_java_arrayaccess, build_java_arraystore_check, build_newarray, + build_anewarray, expand_java_multianewarray, expand_java_arraystore, + expand_java_arrayload, build_java_monitor, expand_java_return, + expand_load_internal, expand_java_NEW, build_get_class, + build_instanceof, expand_java_CHECKCAST, expand_iinc, + build_java_soft_divmod, build_java_binop, build_field_ref, + expand_compare, expand_java_goto, expand_java_switch, + expand_java_add_case, build_class_init, build_known_method_ref, + invoke_build_dtable, build_invokevirtual, build_invokeinterface, + expand_invoke, build_jni_stub, expand_java_field_op, + java_expand_expr, expand_byte_code, STORE_INTERNAL, + force_evaluation_order, emit_init_test_initialization): Convert + calls to "build" into calls to the prefered "buildN" functions. + +2004-07-11 Joseph S. Myers <jsm@polyomino.org.uk> + + * java-tree.h (set_block): Remove. + * lang.c (java_clear_binding_stack): New. + (LANG_HOOKS_CLEAR_BINDING_STACK): Define. + * decl.c (struct binding_level): Remove this_block. + (clear_binding_level): Likewise. + (poplevel): Don't handle this_block. + (set_block): Remove. + +2004-07-10 Bryce McKinlay <mckinlay@redhat.com> + + * class.c (common_enclosing_context_p): Remove statement with no + side-effects. + +2004-07-09 Bryce McKinlay <mckinlay@redhat.com> + + PR java/8618 + * parse.y (create_anonymous_class): Remove 'location' argument. Use + the WFL from TYPE_NAME to get line number for the decl. Fix comment. + (craft_constructor): Inherit access flags for implicit constructor + from the enclosing class. + (create_class): Fix comment typo. + (resolve_qualified_expression_name): Pass type of qualifier to + not_accessible_p, not the type in which target field was found. + (not_accessible_p): Handle inner classes. Expand protected + qualifier-subtype check to enclosing instances, but don't apply this + check to static members. Allow protected access to inner classes + of a subtype. Allow private access within common enclosing context. + (build_super_invocation): Get WFL line number info from current + class decl. + (build_incomplete_class_ref): Update for new create_anonymous_class + signature. + * parse.h (INNER_ENCLOSING_SCOPE_CHECK): Use + common_enclosing_instance_p. + * class.c (common_enclosing_context_p): New. Determine if types + share a common enclosing context, even across static contexts. + (common_enclosing_instance_p): Renamed from + common_enclosing_context_p. Determines if types share a common + non-static enclosing instance. + * java-tree.h (common_enclosing_instance_p): Declare. + * jcf-write.c (get_method_access_flags): New. Surpress private flag + for inner class constructors. + (generate_classfile): Use get_method_access_flags. + +2004-07-09 Bryce McKinlay <mckinlay@redhat.com> + + * class.c (interface_of_p): Check for null TYPE_BINFO. + +2004-07-09 Nathan Sidwell <nathan@codesourcery.com> + + * class.c (make_class): Do not create binfo here. + (set_super_info): Create it here. + * java-tree.h (CLASS_HAS_SUPER): Cope with lack of a binfo. + +2004-07-08 Richard Henderson <rth@redhat.com> + + * expr.c (case_identity, get_primitive_array_vtable, + java_expand_expr, emit_init_test_initialization): Remove. + * java-tree.h (java_expand_expr): Remove. + * lang.c (LANG_HOOKS_EXPAND_EXPR): Remove. + +2004-07-07 Per Bothner <per@bothner.com> + + * class.c (build_static_field_ref): Add a NOP_EXPR; otherwise we + get internal error due to mismatched types. + + * gcj.texi (Invoking gij): Document new -verbose:class flag. + + * gcj.texi (Linking): New node. Document -lgij usage. + +2004-07-07 Nathan Sidwell <nathan@codesourcery.com> + + * java-tree.h (CLASSTYPE_SPUER): Adjust BINFO macros. + (TYPE_NVIRTUALS, TYPE_VTABLE): Likewise. + * java/class.c (set_super_info, class_depth, interface_of_p, + maybe_add_interface, add_interface, make_class_data, + layout_class, add_miranda_methods): Adjust BINFO macros. + * expr.c (can_widen_reference_to, lookup_field): Likewise. + * jcf-write.c (generate_classfile): Likewise. + * parse.y (patch_anonymous_class, + check_inner_circular_reference, check_circular_reference, + java_complete_class, check_abstract_method_definitions, + java_check_abstract_method_definitions, + check_interface_throws_clauses, java_check_abstract_methods, + lookup_java_interface_method2, + find_applicable_accessible_methods_list): Likewise. + * typeck.c (find_method_in_interface): Likewise. + * verify.c (merge_types): Likewise. + +2004-07-06 Nathan Sidwell <nathan@codesourcery.com> + + * java-tree.h (CLASS_HAS_SUPER_FLAG): Use BINFO_FLAG_1. + * class.c (add_interface_do): Use BINFO_VIRTUAL_P. + +2004-07-05 Nathan Sidwell <nathan@codesourcery.com> + + * class.c (make_class): Use make_tree_binfo. + (set_super_info, add_interface_do): Likewise. + * java-tree.h (CLASS_HAS_SUPER_FLAG): Expect a BINFO. + +2004-07-04 Ranjit Mathew <rmathew@hotmail.com> + + * verify.c: Correct array element access formatting thinko. + +2004-07-04 Ranjit Mathew <rmathew@hotmail.com> + + * verify.c: Insert a short blurb at the start referring to the JVMS. + (merge_type_state): Remove redundant nested if statement. + (verify_jvm_instructions): Ensure current_subr is initialised to + NULL_TREE. + Minor formatting fixes all over the place. + +2004-07-02 Richard Henderson <rth@redhat.com> + + * jcf-write.c (generate_bytecode_insns <case SAVE_EXPR>): Rewrite. + +2004-07-01 Richard Henderson <rth@redhat.com> + + * class.c (registerClass_libfunc): Remove. + (init_class_processing): Don't set it. + (emit_register_classes): Take list_p parameter. Fill it in + with _Jv_RegisterClass calls. + * decl.c (java_init_decl_processing): Don't call + init_resource_processing. + * jcf-parse.c (java_emit_static_constructor): New. + (java_parse_file): Call it. + * resource.c (registerResource_libfunc): Remove. + (init_resource_processing): Remove. + (write_resource_constructor): Take list_p parameter. Fill it in + with _Jv_RegisterResource calls. + * java-tree.h: Update prototypes. + +2004-06-29 Bryce McKinlay <mckinlay@redhat.com> + + PR java/1262 + * class.c (layout_class_method): Do not override package-private + method if its in a different package. + (split_qualified_name): Move here from parse.y. Rename from + breakdown_qualified. Add comment. + (in_same_package): Move here from parse.y. Add comment. + * java-tree.h (break_down_qualified, in_same_package): Declare. + (in_same_package): Likewise. + * parse.y (breakdown_qualified, in_same_package): Moved to class.c. + Callers updated. + +2004-06-29 Andrew Haley <aph@redhat.com> + + * except.c (expand_start_java_handler): Push a new binding level. + Don't build a TRY_CATCH_EXPR now, we'll do it later. Call + register_exception_range() to register where we'll do it. + (expand_end_java_handler): Remove old bogus code. Replace with + new logic that simply builds TRY_CATCH_EXPRs and inserts them at + the top of the expression we're curently building. + (maybe_end_try): Delete. + * decl.c (binding_level.exception_range): New field. + (clear_binding_level): Add field exception_range. Reformat. + (poplevel): Call expand_end_java_handler(). + (poplevel): Call java_add_stmt only if functionbody is false. + (maybe_poplevels): Don't call maybe_end_try() from here. + (end_java_method): Clear no longer used trees in function decl. + (register_exception_range): New function. + * java-tree.h (register_exception_range, struct eh_range): Declare. + +2004-06-28 Bryce McKinlay <mckinlay@redhat.com> + + * jcf-write.c (get_classfile_modifiers): Formatting fixes. + +2004-06-27 Ranjit Mathew <rmathew@hotmail.com> + + Formatting fixes. + * expr.c (class_has_finalize_method): Fix method name indentation. + (expand_java_call): Remove K&R style parameter declaration. + (expand_invoke): Fix statement indentation. + (expand_java_field_op): Likewise. + * parse-scan.y: Fix typo. + (reset_report): Fix method name indentation. + * parse.y (unresolved_type_p, build_expr_block): Remove extra blank + line. Fix typos. + * verify.c (verify_jvm_instructions): Document parameters, insert + page break. + * lang.c (lang_init_source): Fix method name indentation. + * class.c (common_enclosing_context_p): Likewise. + (emit_symbol_table): Fix parameter list indentation. + * decl.c (add_stmt_to_compound, java_add_stmt): Remove K&R style + parameter declaration. + * constants.c: Fix copyright notice indentation. + * typeck.c (find_method_in_superclasses): Fix parameter list + indentation. + (find_method_in_interfaces): Likewise. + * zextract.c (makelong): Fix method name indentation. + +2004-06-26 Bryce McKinlay <mckinlay@redhat.com> + + PR java/15715. + * parse.y (create_interface): Set correct access modifiers for + interfaces. + * jcf-write.c (get_classfile_modifiers): New function. + (generate_classfile): Use get_classfile_modifiers, not + get_access_flags. + +2004-06-26 Bryce McKinlay <mckinlay@redhat.com> + + * parse.y (register_incomplete_type): Set JDEP_ENCLOSING for "super" + dependency to current parser context, not NULL_TREE, for top-level + classes. + (jdep_resolve_class): Enable member access check for all inner + class dependencies. + +2004-06-26 Bryce McKinlay <mckinlay@redhat.com> + + * parse.y (qualify_and_find): Pass type decl, not identifier, to + load_class. + +2004-06-26 Bryce McKinlay <mckinlay@redhat.com> + + PR java/15734 + * expr.c (expand_java_field_op): Ensure that target class for static + field access has been loaded. + +2004-06-26 Bryce McKinlay <mckinlay@redhat.com> + Ranjit Mathew <rmathew@hotmail.com> + + PR java/1207, java/16178 + * jcf-parse.c (load_class): Return immediately if passed a type decl + where CLASS_FROM_SOURCE_P is set. Remove FIXME. + * parse.y (do_resolve_class): Remove checks for CLASS_FROM_SOURCE_P + before calling load_class. + (qualify_and_find): Likewise. + (find_in_imports_on_demand): Likewise. + (find_applicable_accessible_methods_list): Likewise. + +2004-06-24 Bryce McKinlay <mckinlay@redhat.com> + + * parse.y (java_layout_seen_class_methods): Don't call load_class + on class defined by source parser. + +2004-06-23 Bryce McKinlay <mckinlay@redhat.com> + + * parse.y (set_nested_class_simple_name_value): Removed. + (java_complete_expand_class): Remove calls to + set_nested_class_simple_name_value. + +2004-06-22 Andrew Haley <aph@redhat.com> + Ranjit Mathew <rmathew@hotmail.com> + + Fixes PR java/16113. + * decl.c (force_poplevels): Remove call to expand_end_bindings. + +2004-06-22 Ranjit Mathew <rmathew@hotmail.com> + + * parse.y (create_class): Correct diagnostic message about + java.lang.Object extending anything else. + +2004-06-21 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * class.c (build_class_ref): Add new operand for COMPONENT_REF. + (build_static_field_ref): Likewise and add new operands for ARRAY_REF. + * constants.c (build_ref_from_constant_pool): Likewise. + * expr.c (build_java_array_length_access): Likewise. + (build_get_class, build_field_ref, build_known_method_ref): Likewise. + (invoke_build_dtable, build_invokevirtual): Likewise. + (build_invokeinterface, java_expand_expr): Likewise. + (emit_init_test_initialization): Likewise. + * java-gimplify.c (java_gimplify_new_array_init): Likewise. + * parse.y (make_qualifed_name, build_array_ref): Likewise. + +2004-06-21 Andrew Haley <aph@redhat.com> + + * java-gimplify.c (java_gimplify_block): set TREE_USED on the new + block. + +2004-06-21 Joseph S. Myers <jsm@polyomino.org.uk> + + * jcf.h (struct JCF): Change java_source, right_zip and finished + to unsigned int. + * lex.h (struct java_lexer): Change hit_eof, read_anything, + byte_swap and use_fallback to unsigned int. + * parse.h (struct _jdep): Change flag0 to unsigned int. + +2004-06-17 Ranjit Mathew <rmathew@hotmail.com> + + Fixes PR java/13948 + * parse.y (java_layout_seen_class_methods): Ensure class is loaded + before trying to lay out its methods. + * jcf-parse.c (read_class): Track parsed files using canonical paths + obtained via lrealpath from libiberty. + (java_parse_file): Likewise. + (parse_source_file_1): Rename formal parameter to reflect its + modified purpose. Minor formatting fix. + +2004-06-15 Paolo Bonzini <bonzini@gnu.org> + + * class.c (emit_register_classes): Make the function uninlinable, + do not set current_function_cannot_inline. + * resource.c (write_resource_constructor): Do not reset + flag_inline_functions around rest_of_compilation. + +2004-06-08 Andrew Pinski <pinskia@physics.uc.edu> + + PR java/15769 + * expr.c (java_truthvalue_conversion): Handle + UNEQ_EXPR, UNLE_EXPR, UNGE_EXPR, UNLT_EXPR, UNGT_EXPR, + ORDERED_EXPR, and UNORDERED_EXPR as comparison operators, + i.e. return the expression. + +2004-06-03 Mark G. Adams <mark.g.adams@sympatico.ca> + + * gjavah.c: Include version.h + +2004-05-31 Bryce McKinlay <mckinlay@redhat.com> + + * jcf-write.c (generate_bytecode_conditional): Correct handling + of unordered conditionals. Add comment. + +2004-05-29 Ranjit Mathew <rmathew@hotmail.com> + Per Bothner <per@bothner.com> + + * java-tree.h (DECL_LOCAL_FINAL_IUD): New macro to test if a + local variable was initialised upon declaration. + * parse.y (declare_local_variables): Set DECL_LOCAL_FINAL_IUD if + variable was final and initialised upon declaration. + * check-init.c (check_final_reassigned): Give error only if a blank + final is not definitely unassigned or if an initialised final is + reassigned. + (check_bool_init): Respect JLS2 16.1.7 requirements for boolean + assignment expressions. Remove case MODIFY_EXPR, label do_default. + (check_init): Perform initialised-variable-removing-optimisation + only on non-final local variables. + +2004-05-28 Bryce McKinlay <mckinlay@redhat.com> + + * jcf-write.c (generate_bytecode_conditional): Handle binops + UNLT_EXPR, UNLE_EXPR, UNGT_EXPR, UNGE_EXPR, UNEQ_EXPR, + and LTGT_EXPR. + (generate_bytecode_insns): Likewise. + +2004-05-28 Bryce McKinlay <mckinlay@redhat.com> + + * check-init.c (check_init): Handle binops UNLT_EXPR, UNLE_EXPR, + UNGT_EXPR, UNGE_EXPR, UNEQ_EXPR, and LTGT_EXPR. + +2004-05-28 Bryce McKinlay <mckinlay@redhat.com> + + * gcj.texi (Object allocation): Remove _Jv_AllocBytes. + (Mixing with C++): Document JvAllocBytes and RawDataManaged. + +2004-05-26 Bryce McKinlay <mckinlay@redhat.com> + + * decl.c (struct binding_level): Add GTY marker. Compile + binding_depth unconditionally. + (current_binding_level, free_binding_level, global_binding_level): + Likewise. + (clear_binding_level): Unconditionally set binding_depth. + (make_binding_level): Use ggc_alloc_cleared, not xmalloc. + +2004-05-26 Bryce McKinlay <mckinlay@redhat.com> + + * lex.c (java_new_lexer): Set 'encoding'. + (java_read_char): Improve error message for unrecognized characters. + * lex.h (struct java_lexer): New field 'encoding'. + +2004-05-23 Paolo Bonzini <bonzini@gnu.org> + + * Make-lang.in: Link in $(LIBCPP) instead of mkdeps.o. + +2004-05-21 Mark Wielaard <mark@klomp.org> + + * gjavah.c (print_stub_or_jni): Mark functions only JNIEXPORT, not + extern. + +2004-05-19 Paolo Bonzini <bonzini@gnu.org> + + * typeck.c: Remove non-printable character 160. + +2004-05-17 Ranjit Mathew <rmathew@hotmail.com> + + * check-init.c: Correct minor typos. + +2004-05-13 Diego Novillo <dnovillo@redhat.com> + + * Make-lang.in, expr.c, java-gimplify.c: Rename + tree-simple.[ch] to tree-gimple.[ch]. + +2004-05-14 Ranjit Mathew <rmathew@hotmail.com> + + * java-gimplify.c (java_gimplify_expr): Correct minor typos. + +2004-05-13 Diego Novillo <dnovillo@redhat.com> + + Merge from tree-ssa-20020619-branch. See + ChangeLog.tree-ssa for details. + + * Make-lang.in, builtins.c, check-init.c, class.c, + constants.c, decl.c, except.c, expr.c, java-except.h, + java-tree.def, java-tree.h, jcf-parse.c, jcf-write.c, + lang.c, lang.opt, parse.y, resource.c: Merged. + * java-gimplify.c: New file. + +2004-05-10 Andrew Haley <aph@redhat.com> + + * parse.y (create_class): Set TYPE_VFIELD. + * decl.c (java_init_decl_processing): Likewise. + + * expr.c (build_invokevirtual): Remove DECL_VINDEX offset adjustment. + * class.c (make_method_value): Replace DECL_VINDEX with call to + get_method_index(). + (get_dispatch_vector): Likewise. + (layout_class_method): Likewise. + Replace set of DECL_VINDEX with call to set_method_index(). + (set_method_index): New function. + (get_method_index): New function. + * java-tree.h (set_method_index): New function decl. + (get_method_index): New function decl. + +2004-05-10 Andrew Pinski <pinskia@physics.uc.edu> + + * parse.y (check_pkg_class_access): Add new argument + and use it when cl is NULL to call lookup_cl on it. + (parser_check_super_interface): Do not call lookup_cl. + Pass this_decl to check_pkg_class_access and NULL + instead of lookup_cl. + (parser_check_super): Update for change in + check_pkg_class_access. + (do_resolve_class): Likewise. + (process_imports): Likewise. + (find_in_imports_on_demand): Likewise. + (resolve_qualified_expression_name): Likewise. + +2004-05-06 Ranjit Mathew <rmathew@hotmail.com> + + Fixes PR java/9685, PR java/15073 + * parse.y (accessibility_string): New method. + (not_accessible_field_error): Use accessibility_string() + instead of java_accstring_lookup(). + (resolve_qualified_expression_name): Check with + check_pkg_class_access() before allowing access using + qualified names. + Fix comment typo. + Use check_pkg_class_access() instead of not_accessible_p() + for unqualified types. + (not_accessible_p): Use DECL_CONTEXT (member) instead of + REFERENCE for package-private access checking. + (patch_method_invocation): Use accessibility_string() instead + of java_accstring_lookup(). + +2004-04-30 Ranjit Mathew <rmathew@hotmail.com> + + Fixes PR java/15133 + * gjavah.c (struct method_name): Add member is_native. + (overloaded_jni_method_exists_p): Match candidate method only if + it is native. + (print_method_info): Initialise is_native flag from the method's + access flags. + +2004-04-30 Roger Sayle <roger@eyesopen.com> + + * builtins.c (java_builtins): Add acos, asin, ceil and floor. + (initialize_builtins): Likewise, define acos, asin, ceil and floor. + +2004-04-22 Roger Sayle <roger@eyesopen.com> + + * resource.c (write_resource_constructor): Guard call to possibly + NULL targetm.asm_out.constructor with targetm.have_ctors_dtors. + +2004-04-19 Bryce McKinlay <mckinlay@redhat.com> + + * class.c (make_class_data): Add new field aux_info. + * decl.c (java_init_decl_processing): Push type and decl for + `aux_info'. + +2004-04-15 Bryce McKinlay <mckinlay@redhat.com> + + * expr.c (expand_java_NEW): Don't use size argument for + _Jv_AllocObject calls. + * parse.y (patch_invoke): Likewise. + +2004-04-12 Bryce McKinlay <mckinlay@redhat.com> + + * expr.c (build_invokeinterface): Remove unused variables to + fix warnings. + +2004-04-12 Bryce McKinlay <mckinlay@redhat.com> + + * class.c (get_interface_method_index): New function. Return dispatch + index for interface method. + (make_method_value): For interface methods, set index field to + iface dispatch index, not DECL_VINDEX. + * expr.c (build_invokeinterface): Use get_interface_method_index. + +2004-03-31 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * jcf-write.c (generate_bytecode_insns): Use TYPE_UNSIGNED. + +2004-03-31 Andrew Haley <aph@redhat.com> + + PR java/14104 + * jcf-io.c (opendir_in_zip): Tidy up error handling. + +2004-03-30 Zack Weinberg <zack@codesourcery.com> + + * builtins.c, expr.c, jcf.h, parse.h: Use new shorter + form of GTY markers. + +2004-03-25 Marcus Meissner <meissner@suse.de> + + PR java/14689: + * jcf-path.c (jcf_path_extdirs_arg): Add missing closedir. + +2004-03-23 Tom Tromey <tromey@redhat.com> + + PR java/14315: + * jcf-write.c (make_class_file_name): Don't report if mkdir + failed with EEXIST. + +2004-03-23 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Extensions): Document GCJ_PROPERTIES. + +2004-03-20 Kazu Hirata <kazu@cs.umass.edu> + + * class.c, gjavah.c, lang.c: Fix comment typos. + * gcj.texi: Fix typos. + +2004-03-19 Per Bothner <per@bothner.com> + + * gcj.texi (Code Generation): Document new flags and assert defaults. + + * class.c (assume_compiled_node_struct): Rename type to + class_flag_node_struct, as it is now also used for enable_assertions. + Rename assume_compiled_node typedef. Rename excludep field to value. + (find_assume_compiled_node): Rename function to find_class_flag_node. + Minor optimization - avoid needless strlen. + (add_assume_compiled): Some tweaking and optimization. + Rename and generalize to add_class_flag takem an extra parameter. + (add_assume_compled): New just calls add_class_flag. + (add_enable_assert, enable_assertions): New functions. + (enable_assert_tree): New static. + * java-tree.h (add_enable_assert, enable_assertions): New declarations. + * lang.opt (fenable-assertions, fenable-assertions=, + fdisable-assertions, fdisable-assertions=): New options. + * lang.c (java_handle_option): Handle new options. + * parse.y (build_incomplete_class_ref): Handle class$ in an inner + class in an interface - create helper class nested in outer interface. + (build_assertion): Short-circuit if enable_assertions is false. + +2004-03-18 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * java-tree.h: Changes throughout to add checking to macros + and numerous whitespace changes. + (VAR_OR_FIELD_CHECK): New macro. + * jcf-write.c (get_access_flags): Use FIELD_PUBLIC, METHOD_PUBLIC, + FIELD_FINAL, and METHOD_FINAL instead of CLASS_PUBLIC and CLASS_FINAL. + +2004-03-16 Per Bothner <per@bothner.com> + + * jcf-jump.c (options): New --print-constants option. + * gcj.texi (Invoking jcf-dump): Document --print-constants. + + * jcf-dump.c (flag_print_constant_pool): Default to off. + (print_constant_terse_with_index): New helper function. + (various places): Check flag_print_constant_pool where missing. + (main): If verbose set flag_print_constant_pool. + (HANDLE_INNERCLASSES_ATTRIBUTE): Null inner class name is anonymous. + +2004-03-15 Andrew Haley <aph@redhat.com> + + PR java/14581 + * parse.y (java_complete_lhs): Check that final variable has an + initializer. + +2004-03-12 Andrew Haley <aph@redhat.com> + + PR java/14551 + * typeck.c (convert): Clear TREE_OVERFLOW after an integer + conversion. + +2004-02-29 Roger Sayle <roger@eyesopen.com> + + * jcf-parse.c (java_parse_file): Handle the case that input_filename + is NULL. + +2004-02-27 Per Bothner <per@bothner.com> + + * parse.y (build_assertion): Re-do 02-25 change following Jeff Sturm + suggestion: Use build_incomplete_class_ref. + This fixes PR java/13508, java/11714. + +2004-02-27 Kazu Hirata <kazu@cs.umass.edu> + + * java/parse.h: Update copyright. + +2004-02-26 Andrew Haley <aph@redhat.com> + + PR java/14231: + * parse.y (check_interface_throws_clauses): Check for + !METHOD_INVISIBLE (iface_method). + * class.c (layout_class_methods): Check for CLASS_INTERFACE as + well as CLASS_ABSTRACT. + +2004-02-25 Per Bothner <per@bothner.com> + + * parse.y (build_assertion): If we're in an inner class, create the + class$ helper routine in the outer class. + +2004-02-19 Richard Henderson <rth@redhat.com> + + * parse.y (switch_label): Use make_node for DEFAULT_EXPR. + +2004-02-16 Geoffrey Keating <geoffk@apple.com> + + * Make-lang.in (java.install-man): Add extra dependencies. + +2004-02-13 Geoffrey Keating <geoffk@apple.com> + + * Make-lang.in: Install man pages under the same names + (possibly transformed) as the program they document. + +2004-02-10 Joseph S. Myers <jsm@polyomino.org.uk> + + * gjavah.c: Include "intl.h". + (error): New function. + (main): Call gcc_init_libintl. + (get_field_name, throwable_p, print_c_decl, print_full_cxx_name, + print_stub_or_jni, process_file, main): Use error rather than + fprintf. + (print_method_info, usage, help, version, main): Mark strings for + translation with _. Avoid splitting up sentences. Send + information messages to stdout. + * jcf-dump.c: Include "intl.h". + (main): Call gcc_init_libintl. + (process_class, usage, help, version, main, CHECK_PC_IN_RANGE): + Mark error, usage and version messages for translation with _. + Avoid splitting up sentences. + * jv-scan.c: Include "intl.h". + (fatal_error, warning): Change parameter s to msgid. Translate + messages. + (main): Call gcc_init_libintl. + (usage, help, version): Mark error, usage and version messages for + translation with _. Avoid splitting up sentences. + * jvgenmain.c: Include "intl.h". + (main): Call gcc_init_libintl. + (usage, main): Mark error messages for translation with _. + * Make-lang.in (GCJH_OBJS, JVSCAN_OBJS, JCFDUMP_OBJS, + JVGENMAIN_OBJS): Add intl.o. + (java/jcf-dump.o, java/gjavah.o, java/jv-scan.o, + java/jvgenmain.o): Update dependencies. + +2004-02-08 Per Bothner <per@bothner.com> + + * parse.y (resolve_qualified_expression_name): In case of inaccessible + class don't use not_accessible_field_error, which can get confused. + +2004-02-05 Kelley Cook <kcook@gcc.gnu.org> + + Make-lang.in (po-generated): Delete. + +2004-02-05 Kazu Hirata <kazu@cs.umass.edu> + + * Make-lang.in (java/decl.o, java/expr.o, java/parse.o): + Depend on target.h. + * decl.c: Include target.h. + (start_java_method): Replace PROMOTE_PROTOTYPES with + targetm.calls.promote_prototypes. + * expr.c: Include target.h. + (pop_arguments): Replace PROMOTE_PROTOTYPES with + targetm.calls.promote_prototypes. + * parse.y: Include target.h. + (start_complete_expand_method): Replace PROMOTE_PROTOTYPES + with targetm.calls.promote_prototypes. + +2004-02-04 Kazu Hirata <kazu@cs.umass.edu> + + * typeck.c: Update copyright. + +2004-02-02 Tom Tromey <tromey@redhat.com> + + * decl.c (java_init_decl_processing): Remove duplicate + gnu/gcj/RawData. + +2004-01-30 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in (doc/gcj.dvi): Use $(abs_docdir). + +2004-01-28 Andrew Pinski <pinskia@physics.uc.edu> + + * expr.c (build_field_ref): Move variable + definition up. + +2004-01-28 Andrew Haley <aph@redhat.com> + + * expr.c (build_field_ref): Widen field offset. + +2004-01-27 Andrew Haley <aph@redhat.com> + + java/13273 + * parse.y (check_interface_throws_clauses): Make sure class_decl + has been loaded. + +2004-01-22 Jeff Sturm <jsturm@one-point.com> + + PR java/13733 + * parse.y (patch_assignment): Don't modify lhs_type for + reference assignments. + +2004-01-20 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in: Replace $(docdir) with doc. + (java.info, java.srcinfo, java.man, java.srcman): New rules. + (java.install-man): Revamp rule. + +2004-01-20 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in (JAVA_INSTALL_NAME, JAVA_TARGET_INSTALL_NAME, + GCJH_TARGET_INSTALL_NAME): Define via a immediate $(shell) + instead of deferred backquote. + +2004-01-16 Andrew Pinski <pinskia@physics.uc.edu> + + * typeck.c (find_method_in_interfaces): Move variable + definition up. + +2004-01-16 Andrew Haley <aph@redhat.com> + + PR java/13273: + * typeck.c (shallow_find_method): New. + (find_method_in_superclasses): New. + (find_method_in_interfaces): New. + (lookup_do): Rewrite. + * java-tree.h (SEARCH_ONLY_INTERFACE): Delete. + + * jcf-parse.c (read_class): Save and restore output_class. + * decl.c (java_expand_body): Set output_class from fndecl. + +2004-01-15 Michael Chastain <mec.gnu@mindspring.com> + + * class.c (gen_indirect_dispatch_tables): Fix string length + calculations. + +2004-01-15 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in (parse.c, parse-scan.c): Always build in doc directory. + (java.srcextra): Copy above back to source directory if requested. + (po-generated): Delete reference to $(parsedir). + (java/parse.o, java/parse-scan.o): Delete reference to $(parsedir). + Use implicit rule. + +2004-01-14 Jan Hubicka <jh@suse.cz> + + * lang.c (java_estimate_num_insns_1): Fix bug in MODIFY_EXPR cost + estimation. + +2004-01-09 Mark Mitchell <mark@codesourcery.com> + + * java-tree.h (java_expand_expr): Change prototype. + * expr.c (java_expand_expr): Add alt_rtl parameter. + +2004-01-09 Andrew Haley <aph@redhat.com> + + PR java/12755: + * parse.y (java_fix_constructors): Set output_class. + (java_reorder_fields): Likewise. + (java_layout_classes): Likewise. + (java_expand_classes): Generate indirect dispatch tables. + (java_expand_classes): Set output_class. + (java_finish_classes): Likewise. + * lang.c (java_init): Turn on always_initialize_class_p if we're + using indirect dis[atch. + (java_decl_ok_for_sibcall): Use output_class, not current_class. + (java_get_callee_fndecl): Use class local atable. + * jcf-parse.c + (always_initialize_class_p): Decl moved to java-tree.h. + (HANDLE_CLASS_INFO): Set output_class. + (read_class): Likewise. + (parse_class_file): Call gen_indirect_dispatch_tables. + (parse_zip_file_entries): Set output_class. + (java_parse_file): Set output_class. Don't emit symbol tables. + * java-tree.h (output_class): New. + Remove global declarations for otable, atable, and ctable. + (always_initialize_class_p): moved here from decl.c. + (DECL_OWNER): New. + (TYPE_ATABLE_METHODS, TYPE_ATABLE_SYMS_DECL, TYPE_ATABLE_DECL, + TYPE_OTABLE_METHODS, TYPE_OTABLE_SYMS_DECL, TYPE_OTABLE_DECL, + TYPE_CTABLE_DECL, TYPE_CATCH_CLASSES): New. + (struct lang_type): Add otable_methods, otable_decl, + otable_syms_decl, atable_methods, atable_decl, atable_syms_decl, + ctable_decl, catch_classes, type_to_runtime_map. + * expr.c (build_field_ref): Make otable, atable, and ctable class + local rather than global. + (build_known_method_ref): Likewise. + (build_invokeinterface): Likewise. + (java_expand_expr): Pass runtime type (rather than actual type) to + expand_start_catch. + * except.c (prepare_eh_table_type): Create TYPE_TO_RUNTIME_MAP for + this class. Look up each class in that map to delete duplicates. + (expand_end_java_handler): Pass runtime type (rather than actual + type) to expand_start_catch. + * decl.c: (always_initialize_class_p): Decl moved to java-tree.h. + (do_nothing): New. + (java_init_decl_processing): Rearrange things. Remove global + declarations of otable, atable, and ctable. + (java_init_decl_processing): Make lang_eh_runtime_type do_nothing. + (java_expand_body): Set output_class. + * constants.c (build_constant_data_ref): Use output_class, not + current_class. + (alloc_name_constant): Likewise. + * class.c (gen_indirect_dispatch_tables): New. + (build_class_ref): Generate hard reference to superclass, even if + using indirect dispatch. + (build_static_field_ref): Use class local atable. + (make_class_data): Generate hard reference to superclass, even if + using indirect dispatch. + Generate symbolic references to interfaces when using indirect + dispatch. + (make_class_data): Emit otable, atable, and ctable. + Make otable, atable, and ctable class local rather than global. + (emit_catch_table): Make otable, atable, and ctable class local + rather than global. + +2003-12-25 Andrew Pinski <pinskia@physics.uc.edu> + + * parse.y (catch_clause_parameter): Fix typo. + + PR java/13404 + * parse.y: (catch_clause_parameter): Return early if $3, aka + formal_parameter, is null. + +2003-12-20 Kazu Hirata <kazu@cs.umass.edu> + + * class.c: Remove uses of "register" specifier in + declarations of arguments and local variables. + * decl.c: Likewise. + * expr.c: Likewise. + * gjavah.c: Likewise. + * jcf-dump.c: Likewise. + * jcf-io.c: Likewise. + * jcf-parse.c: Likewise. + * jcf-write.c: Likewise. + * keyword.h: Likewise. + * parse.y: Likewise. + * typeck.c: Likewise. + * verify.c: Likewise. + +2003-12-06 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in (GCJ_CROSS_NAME): Delete. + (java.install_common, java.install-man): Adjust for above. + (java.uninstall): Likewise. + +2003-12-03 Michael Koch <konqueror@gmx.de> + + * class.c (make_class_data): + Push field value to 'hack_signers' instead of 'signers'. + * decl.c (java_init_decl_processing): + Push field 'hack_signers' instead of 'signers'. + +2003-12-03 Zack Weinberg <zack@codesourcery.com> + + * lex.h: Check both HAVE_ICONV and HAVE_ICONV_H before + including iconv.h. + +2003-12-03 Ralph Loader <rcl@ihug.co.nz> + + PR java/12374: + * parse.y (qualify_ambiguous_name): Remove lots of broken + field access processing - there's no need to do that here, + because we have resolve_field_access. Remove + RESOLVE_EXPRESSION_NAME_P as it isn't used anywhere else. + * java-tree.h: Remove RESOLVE_EXPRESSION_NAME_P as it isn't + used. + +2003-12-01 Jeff Sturm <jsturm@one-point.com> + + Fix PR java/13237 + * parse.y (java_complete_lhs): Save location prior to patching + CALL_EXPR. + +2003-11-25 Mohan Embar <gnustuff@thisiscool.com> + + PR java/12548 + * resource.c (write_resource_constructor): Append + "_resource" to constructor identifier name. + +2003-11-25 Jeff Sturm <jsturm@one-point.com> + + Fix PR java/13183. + * constants.c (cpool_for_class): New function. + (outgoing_cpool): Remove global variable. + (alloc_name_constant): Use cpool_for_class. + (build_constants_constructor): Likewise. + * decl.c (java_expand_body): Set current_class. + * java-tree.h (outgoing_cpool) Remove declaration. + (init_outgoing_cpool): Likewise. + * jcf-parse.c (init_outgoing_cpool): Remove function. + (parse_class_file): Don't call init_outgoing_cpool. + * parse.y (java_complete_expand_methods): Don't call + init_outgoing_cpool. Don't save outgoing_cpool. + (java_expand_classes): Don't restore outgoing_cpool. + (java_finish_classes): Likewise. + +2003-11-24 Mohan Embar <gnustuff@thisiscool.com> + + * Make-lang.in: (java.install-common) Add + symlink for $(target_noncanonical)-gcjh for + native builds. + +2003-11-20 Joseph S. Myers <jsm@polyomino.org.uk> + + * Make-lang.in (java.extraclean): Delete. + +2003-11-20 Joseph S. Myers <jsm@polyomino.org.uk> + + * Make-lang.in (check-java): Add. + +2003-11-19 Jeff Sturm <jsturm@one-point.com> + + Fix PR java/13024. + * except.c (prepare_eh_table_type): Allocate variable-sized + buffer `buf' with alloca. + +2003-11-17 Jeff Sturm <jsturm@one-point.com> + + Fix PR java/12857. + + decl.c (java_init_decl_processing): Don't initialize + class_not_found_type_node, no_class_def_found_type_node. + + java-tree.h (JTI_CLASS_NOT_FOUND_TYPE_NODE, + JTI_NO_CLASS_DEF_FOUND_TYPE_NODE): Remove from java_tree_index. + (class_not_found_type_node, no_class_def_found_type_node): + Don't define. + + parse.y (build_dot_class_method_invocation): Add this_class + argument. Qualify method invocations to a different class. + (create_new_parser_context): Initialize saved_data_ctx to 0. + (java_parser_context_save_global): Initialize saved_data_ctx to 1. + (build_dot_class_method): Don't load classes. Register + incomplete types. + (build_incomplete_class_ref): Special cases for interfaces + and inner classes. Move build_dot_class_method call to here... + (patch_incomplete_class_ref): ...from here. Pass current_class + to build_dot_class_method_invocation. + (build_assertion): Pass class_type to + build_dot_class_method_invocation. + (encapsulate_with_try_catch): Handle EXPR_WITH_FILE_LOCATION node. + +2003-11-17 Jeff Sturm <jsturm@one-point.com> + + Fix PR java/12739. + * java-tree.h (BLOCK_EMPTY_P): Define. + * parse.y (java_complete_lhs): Check for empty blocks + in TRY_FINALLY_EXPR case. + +2003-11-17 Andrew Haley <aph@redhat.com> + + * java-tree.h (LOCAL_VAR_OUT_OF_SCOPE_P): New. + (struct lang_decl_var:freed): New variable. + * decl.c (poplevel): Mark local vars that have gone out of scope. + (push_jvm_slot): Don't use the RTL of a var that has gone out of + scope. + +2003-11-16 Jason Merrill <jason@redhat.com> + + * Make-lang.in (java.tags): Create TAGS.sub files in each directory + and TAGS files that include them for each front end. + +2003-11-15 Tom Tromey <tromey@redhat.com> + + * gjavah.c (print_stub_or_jni): Pass `env' to FatalError. + +2003-11-12 Jason Merrill <jason@redhat.com> + + PR optimization/12547 + * lang.c (java_tree_inlining_walk_subtrees): Just walk + BLOCK_EXPR_BODY directly. + +2003-11-12 Andrew Haley <aph@redhat.com> + + PR java/11045 + * parse.y (fold_constant_for_init): Check that we really do have a + constant. + + PR java/11533 + * lang.c (merge_init_test_initialization): Clear DECL_INITIAL for + init_test_decls being inlined. + + PR java/12890: + * parse.y (do_resolve_class): Check return value from + breakdown_qualified(). + +2003-11-11 Tom Tromey <tromey@redhat.com> + + PR java/12915: + * parse.y (merge_string_cste): Handle case where we have a + pointer that happens to be zero, not null_pointer_node. + +2003-11-10 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (classify_zip_file): Correctly compare + filename_length against length of manifest file's name. + +2003-11-08 Tom Tromey <tromey@redhat.com> + + PR java/12894: + * jcf-parse.c (classify_zip_file): Only skip MANIFEST.MF file. + +2003-11-06 Andrew Haley <aph@redhat.com> + + * expr.c (java_stack_swap): Make sure destination stack slots are + of the correct type. + +2003-11-03 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in (dvi): Move targets to $(docobjdir). + (gcj.dvi): Simplify rule and adjust target. + (gcj.info): Simplify rule. + (gcj.pod): New intermediate rule. + (gcjh.pod): Likewise. + (jv-scan.pod): Likewise. + (jcf-dump.pod): Likewise. + (gij.pod): Likewise. + (jv-convert.pod): Likewise. + (rmic.pod): Likewise. + (rmiregistry.pod): Likewise. + (gcj.1): Delete. + (gcjh.1): Delete. + (jv-scan.1): Delete. + (jcf-dump.1): Delete. + (gij.1): Delete. + (jv-convert.1): Delete. + (rmic.1): Delete. + (rmiregistry.1): Delete. + +2003-11-02 Jeff Sturm <jsturm@one-point.com> + + Fixes PR java/12866. + * parse.y (resolve_qualified_expression_name): Move test + for outer field access methods from here... + (check_thrown_exceptions) ...to here. + +2003-11-01 Kelley Cook <kcook@gcc.gnu.org> + + * .cvsignore: Delete. + +2003-10-28 Frank Ch. Eigler <fche@redhat.com> + + * verify.c (verify_jvm_instructions): Don't warn about legal + eh binding regions generated for example by jdk 1.4.1. + +2003-10-24 David S. Miller <davem@redhat.com> + + * jcf-parse.c (jcf_parse): Fix args to fatal_error(). + +2003-10-22 Andrew Haley <aph@redhat.com> + + * lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. + (java_get_callee_fndecl): New. + + * jcf-parse.c (java_parse_file): Call emit_catch_table(). + + * java-tree.h (ctable_decl): New. + (catch_classes): New. + (java_tree_index): Add JTI_CTABLE_DECL, JTI_CATCH_CLASSES. + + * decl.c (java_init_decl_processing): Add catch_class_type. + Add ctable_decl. + Add catch_classes field. + + * class.c (build_indirect_class_ref): Break out from + build_class_ref. + (make_field_value): Check flag_indirect_dispatch. + (make_class_data): Ditto. + Tidy uses of PUSH_FIELD_VALUE. + Add field catch_classes. + (make_catch_class_record): New. + + * java-tree.h (PUSH_FIELD_VALUE): Tidy. + +2003-10-22 Kazu Hirata <kazu@cs.umass.edu> + + * jcf-write.c: Follow spelling conventions. + * parse.y: Likewise. + +2003-10-22 Kazu Hirata <kazu@cs.umass.edu> + + * ChangeLog: Fix typos. + * expr.c: Fix comment typos. + * jcf-write.c: Likewise. + * lang.c: Likewise. + * lex.c: Likewise. + * mangle.c: Likewise. + * parse-scan.y: Likewise. + * parse.y: Likewise. + +2003-10-22 Tom Tromey <tromey@redhat.com> + + * expr.c (expand_byte_code): Only warn about dead bytecode when + extra_warnings is set. + +2003-10-22 Bryce McKinlay <bryce@mckinlay.net.nz> + + Fix for PR java/12586. + * mangle.c (find_compression_record_match): Don't iterate through + package namespace elements unless they all match compression_table + entries. + +2003-10-20 Kelley Cook <kcook@gcc.gnu.org> + + * Make-lang.in (info): Honor $(parsedir) and $(docobjdir). + (generate-manpages): Likewise. + (java.maintainer-clean): Likewise. + (gcj.info): Likewise. + (gcj.1): Likewise. + (gcjh.1): Likewise. + (jv-scan.1): Likewise. + (jcf-dump.1): Likewise. + (gij.1): Likewise. + (jv-convert.1): Likewise. + (rmic.1): Likewise. + (rmiregistry.1): Likewise. + (java.install-man): Likewise. + (parse-scan.o): Move and define complete compile line. + (parse.o): Likewise. + (jcf-tree-inline.o): Move. + +2003-10-20 Mark Mitchell <mark@codesourcery.com> + + * Make-lang.in (info): Update dependencies. + (java.install-info): Remove. + ($(srcdir)/java/gcj.info): Replace with ... + ($(docobjdir)/gcj.info): ... this. + +2003-10-14 Nathanael Nerode <neroden@gcc.gnu.org> + + * Make-lang.in: Replace uses of $(target_alias) with + $(target_noncanonical). + +2003-10-09 Tom Tromey <tromey@redhat.com> + + * decl.c (java_init_decl_processing): Declare signers field. + * class.c (make_class_data): Set signers field. + +2003-10-09 Jason Merrill <jason@redhat.com> + + * parse.y (patch_assignment): Use make_node to create a BLOCK. + * parse.h (BUILD_PTR_FROM_NAME): Use make_node to create a + POINTER_TYPE. + +2003-10-06 Mark Mitchell <mark@codesourcery.com> + + * Make-lang.in (java.info): Replace with ... + (info): ... this. + (java.dvi): Replace with ... + (dvi): ... this. + (java.generated-manpages): Replace with ... + +2003-10-03 Kelley Cook <kelleycook@wideopenwest.com> + + * builtins.c, jcf.h, jvspec.c: Remove PARAMS macros. + +2003-10-01 Andrew Haley <aph@redhat.com> + + * jcf-parse.c (java_parse_file): Write otable and atable. + * java-tree.h (atable_methods): New. + (atable_decl): New. + (atable_syms_decl): New. + (enum java_tree_index): Add JTI_ATABLE_METHODS, JTI_ATABLE_DECL, + JTI_ATABLE_SYMS_DECL. Rename JTI_METHOD_SYMBOL* to JTI_SYMBOL*. + (symbol_*type): Rename method_symbol* to symbol*type. + (emit_offset_symbol_table): Delete. + (emit_symbol_table): New. + (get_symbol_table_index): New. + (atable_type): New. + * expr.c (build_field_ref): Handle flag_indirect_dispatch. + (build_known_method_ref): Likewise. + (get_symbol_table_index): Rename from get_offset_table_index. + Parameterize to allow re-use by differing types of symbol table. + (build_invokevirtual): Pass table to get_offset_table_index. + * decl.c (java_init_decl_processing): Push types and decls for + atable and atable_syyms. + * class.c (build_static_field_ref): Handle flag_indirect_dispatch. + (make_class_data): Add new fields atable and atable_syms. + (emit_symbol_table): Rename from emit_offset_symbol_table. + Parameterize to allow re-use by different types of symbol table. + (build_symbol_entry): Renamed from build_method_symbols_entry. + +2003-09-30 Roger Sayle <roger@eyesopen.com> + + * jcf-write.c (generate_bytecode_insns): Implement evaluate-once + semantics for SAVE_EXPR, by caching the result in a temporary. + +2003-09-28 Richard Henderson <rth@redhat.com> + + * check-init.c (check_init): Save and restore input_location + instead of file and line separately. + * decl.c (java_expand_body): Likewise. + * jcf-write.c (generate_bytecode_insns): Likewise. + * parse.y (safe_layout_class): Likewise. + * jcf-parse.c (read_class, parse_class_file): Likewise. + (java_parse_file): Use %H for warning locator. + +2003-09-28 Roger Sayle <roger@eyesopen.com> + + * expr.c (java_check_reference): Use the semantics of COND_EXPRs + with void-type branches instead of using a COMPOUND_EXPR. + +2003-09-28 Jeff Sturm <jsturm@one-point.com> + + * decl.c (java_optimize_inline, dump_function): Remove. + * java-tree.h (java_optimize_inline): Remove declaration. + * jcf-parse.c (java_parse_file): Assume flag_unit_at_a_time is set. + * parse.y (source_end_java_method, java_expand_classes): + Likewise. Remove dead code. + +2003-09-27 Roger Sayle <roger@eyesopen.com> + + * lang.c (java_init_options): Set flag_evaluation_order. + * expr.c (force_evaluation_order): Don't attempt to force + evaluation order of binary operations using save_expr. + * parse.y (java_complete_lhs): No longer need to call + force_evaluation_order when constructing binary operators. + +2003-09-27 Alexandre Petit-Bianco <apbianco@redhat.com> + Bryce McKinlay <bryce@mckinlay.net.nz> + + PR java/1333: + * parse.y (not_accessible_field_error): New function. + (resolve_expression_name): Check field access permissions. + (resolve_qualified_expression_name): Use + not_accessible_field_error. + (resolve_qualified_expression_name): Likewise. + +2003-09-24 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + * class.c (build_utf8_ref): Test for HAVE_GAS_SHF_MERGE value. + +2003-09-23 Roger Sayle <roger@eyesopen.com> + + * jcf-write.c (generate_bytecode_insns): Optimize binary operations + with equal operands without side-effects. + +2003-09-22 Jeff Sturm <jsturm@one-point.com> + + * decl.c (java_init_decl_processing): Don't emit otable decls + if flag_indirect_dispatch is not set. + +2003-09-21 Richard Henderson <rth@redhat.com> + + * class.c, decl.c, jcf-parse.c, jcf-write.c, parse.y, + resource.c: Revert. + +2003-09-21 Richard Henderson <rth@redhat.com> + + * class.c, decl.c, jcf-parse.c, jcf-write.c, parse.y, + resource.c: Update for DECL_SOURCE_LOCATION rename and change to const. + +2003-09-20 Richard Henderson <rth@redhat.com> + + * check-init.c, class.c, decl.c, expr.c: Use %J in diagnostics. + +2003-09-18 Roger Sayle <roger@eyesopen.com> + + * expr.c (java_truthvalue_conversion): Remove FFS_EXPR case. + * check-init.c (check_init): Likewise. + +2003-09-18 Roger Sayle <roger@eyesopen.com> + + * jcf-write.c (generate_bytecode_insns): Add support for fconst_2. + +2003-09-16 Andrew Haley <aph@redhat.com> + + * jcf-write.c (generate_bytecode_insns): Add MIN_EXPR and MAX_EXPR. + +2003-09-17 Ranjit Mathew <rmathew@hotmail.com> + + Fixes PR java/9577 + * mangle.c (find_compression_record_match): Skip + over a "6JArray" (the array template mangled string) + IDENTIFIER_NODE. + (mangle_array_type): Correct minor typo. + (atms): Move definition to the beginning. + +2003-09-16 Bryce McKinlay <bryce@mckinlay.net.nz> + + * class.c (add_miranda_methods): Ensure super-interfaces are laid + out. Fix for PR java/12254. + +2003-09-11 Richard Henderson <rth@redhat.com> + + * parse.y (source_end_java_method): Update for new + cgraph_finalize_function argument. + +2003-09-09 Richard Henderson <rth@redhat.com> + + * parse.y (source_end_java_method): Update call to + cgraph_finalize_function. + +2003-09-03 Jeff Sturm <jsturm@one-point.com> + + * decl.c (java_expand_body): New function. + * expr.c (build_class_init): Set DECL_IGNORED_P. + * java-tree.h (start_complete_expand_method, + java_expand_body): Declare. + * jcf-parse.c (cgraph.h): Include. + (java_parse_file): Handle flag_unit_at_a_time. + * lang.c (LANG_HOOKS_TREE_INLINING_START_INLINING, + LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION): Define. + (java_estimate_num_insns): Use walk_tree_without_duplicates. + (java_start_inlining): New function. + * parse.h (java_finish_classes): Declare. + * parse.y: Include cgraph.h. + (block): Don't special-case empty block production. + (craft_constructor): Set DECL_INLINE. + (source_end_java_method): Handle flag_unit_at_a_time. + Replace inline code with call to java_expand_body. + (start_complete_expand_method): Remove static modifier. + (java_expand_method_bodies): Patch function tree for + class initialization and/or synchronization as needed. + Don't begin RTL expansion yet. + (java_expand_classes): Check flag_unit_at_a_time before + calling finish_class. + (java_finish_classes): New function. + (java_complete_lhs): Ensure COMPOUND_EXPR has non-NULL type. + (patch_assignment): Set DECL_CONTEXT on temporary variable. + (emit_test_initialization): Set DECL_IGNORED_P. + +2003-09-03 Roger Sayle <roger@eyesopen.com> + + * builtins.c (enum builtin_type): Delete unused enumeration. + * Make-lang.in (java/builtins.o): Remove built-types.def dependency. + +2003-08-28 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Extensions): Document gcjlib URLs. + +2003-08-20 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Extensions): Added xref. + (libgcj Runtime Properties): Document + gnu.gcj.runtime.VMClassLoader.library_control. + +2003-08-20 Andrew Haley <aph@redhat.com> + + * except.c (prepare_eh_table_type): Use new encoding for exception + handlers when using -fno-assume-compiled. + +2003-08-13 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Invoking gij): Document -X and -?. + +2003-08-13 Mohan Embar <gnustuff@thisiscool.com> + + * Make-lang.in: Added missing win32-host.o to JAVA_OBJS, + GCJH_OBJS, JCFDUMP_OBJS + * win32-host.c: Removed the unnecessary and broken dependency + on jcf.h + +2003-08-11 Tom Tromey <tromey@redhat.com> + + * parse.y (java_check_regular_methods): Typo fixes. Call + check_interface_throws_clauses. Use + check_concrete_throws_clauses. + (check_interface_throws_clauses): New function. + (check_concrete_throws_clauses): New function. + (hack_is_accessible_p): New function. + (find_most_specific_methods_list): Added FIXME. + * typeck.c (lookup_do): Use `flags' argument to decide what to + do. Reimplemented. + (lookup_argument_method_generic): New function. + (lookup_argument_method2): Removed. + * jcf.h (ACC_INVISIBLE): New define. + * jcf-write.c (generate_classfile): Skip invisible methods. + * class.c (add_miranda_methods): New function. + (layout_class_methods): Use it. + (get_access_flags_from_decl): Use ACC_INVISIBLE. + * java-tree.h (METHOD_INVISIBLE): New define. + (lang_decl_func) [invisible]: New field. + (lookup_argument_method_generic): Declare. + (SEARCH_INTERFACE): New define. + (SEARCH_SUPER): Likewise. + (SEARCH_ONLY_INTERFACE): Likewise. + (SEARCH_VISIBLE): Likewise. + (lookup_argument_method2): Removed declaration. + +2003-08-05 Tom Tromey <tromey@redhat.com> + + Fix for PR java/11600: + * parse.y (java_complete_lhs): See whether we're calling a method + on an array. + (check_thrown_exceptions): Added `is_array_call' argument; + fixed `clone' checking; updated all callers. + +2003-08-05 Steven Bosscher <steven@gcc.gnu.org> + + * java-tree.h (DECL_ESTIMATED_INSNS): Remove (moved to tree.h). + +2003-08-03 Tom Tromey <tromey@redhat.com> + + * java-tree.h (METHOD_TRANSIENT): Removed. + * decl.c (pushdecl): Removed some dead code. + * class.c (get_access_flags_from_decl): Can't have transient + method. + (add_method_1): Can't have a transient method. + +2003-07-28 Andreas Jaeger <aj@suse.de> + + * jvspec.c: Convert to ISO C90 prototypes. + +2003-07-25 Nathan Sidwell <nathan@codesourcery.com> + + * decl.c (force_poplevels): Fix warning call. + +2003-07-25 Gabriel Dos Reis <gdr@integrable-solutions.net> + + * expr.c (expand_java_field_op): Don't use xxx_with_decl + (expand_java_field_op): Likewise. + * class.c (layout_class_method): Likewise + (emit_register_classes): Likewise. + * decl.c (pushdecl): Likewise. + (poplevel): Likewise. + (force_poplevels): Likewise. + (give_name_to_locals): Likewise. + * check-init.c (check_for_initialization): Likewise. + +2003-07-24 Jason Merrill <jason@redhat.com> + + * java-tree.h: Move boolean_type_node et al to the back end. + +2003-07-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c java-tree.h jcf-write.c jvspec.c: Remove unnecessary + casts. + +2003-07-19 Neil Booth <neil@daikokuya.co.uk> + + * lang.opt: Don't show -MD_ and -MDD_. + +2003-07-18 Neil Booth <neil@daikokuya.co.uk> + + * lang-options.h: Remove. + * lang.opt: Add help text. + +2003-07-15 Kazu Hirata <kazu@cs.umass.edu> + + * expr.c: Remove the last argument to expand_assignment(). + +2003-07-09 Jan Hubicka <jh@suse.cz> + + * java-tree.h (DECL_NUM_STMTS): Rename to... + (DECL_ESTIMATED_INSNS): ... this. + * lang.c (java_estimate_num_insns, java_estimate_num_insns_1): + New static functions. + (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Define. + * parser.y (add_stmt_to_compound): Do not account statements. + +2003-07-08 Mark Wielaard <mark@klomp.org> + + * gcj.texi: CNI now expands to Compiled Native Interface. + +2003-07-08 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + * Make-lang.in (java/gcj.dvi): Use PWD_COMMAND. + +2003-07-07 Nathan Sidwell <nathan@codesourcery.com> + + * expr.c (expand_byte_code): Adjist emit_line_note call. + +2003-07-06 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_handle_option): Don't handle filenames. + +2003-07-02 Zack Weinberg <zack@codesourcery.com> + + * jcf-path.c: Don't default-define PATH_SEPARATOR nor + DIR_SEPARATOR. + Use FILENAME_CMP. + * jcf-write.c: Don't default-define DIR_SEPARATOR. + * jcf.h: Delete COMPARE_FILENAMES definition. + +2003-07-02 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_init_options): Update prototype. + +2003-07-01 Nathan Sidwell <nathan@codesourcery.com> + + * decl.c (poplevel): Adjust define_label call. + +2003-06-27 Zack Weinberg <zack@codesourcery.com> + + * gjavah.c (flag_jni): Make non-static. + * parse-scan.y (ctxp): Make non-static. + + * class.c (build_method_symbols_entry) + * expr.c (get_offset_table_index) + * jcf-parse.c (jcf_parse): + Mark the definition static, matching the forward declaration. + +2003-06-26 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_handle_option): Don't check for missing arguments. + +2003-06-20 Nathan Sidwell <nathan@codesourcery.com> + + * class.c (push_class): Use a location_t to save place. + (emit_register_classes): Set input_location. Adjust + expand_function_end call. + * resource.c (write_resource_constructor): Likewise. + * decl.c (end_java_method): Adjust expand_function_end call. + * parse.y (source_end_java_method): Likewise. + +2003-06-17 Robert Abeles <rabeles@archaelogic.com> + + * lang.c (java_handle_option): Likewise. + +2003-06-16 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_handle_option): Special-casing of optional + joined arguments no longer needed. + * lang.opt: Update switches that take optional argument. + +2003-06-15 Neil Booth <neil@daikokuya.co.uk> + + * lang.opt: Declare Java. + * lang.c (java_init_options): Update. + +2003-06-15 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (version_flag): Rename to v_flag to avoid clash w/ toplev.h. + +2003-06-14 Neil Booth <neil@daikokuya.co.uk> + + * lang-specs.h: Rewrite -MD and -MMD to append an underscore. + * lang.c (java_handle_option): -MD and -MMD have an underscore. + * lang.opt: -MD and -MMD have an underscore. + +2003-06-14 Nathan Sidwell <nathan@codesourcery.com> + + * class.c (emit_register_classes): Adjust init_function_start + call. + * decl.c (complete_start_java_method): Likewise. + * resource.c (write_resource_constructor): Likewise. + +2003-06-14 Neil Booth <neil@daikokuya.co.uk> + + * Make-lang.in: Update to use options.c and options.h. + * lang.c: Include options.h not j-options.h. + (java_handle_option): Abort on unrecognized option. + (java_init_options): Request Java switches. + +2003-06-11 Neil Booth <neil@daikokuya.co.uk> + + * Make-lang.in: Handle mostlyclean. + +2003-06-11 Tom Tromey <tromey@redhat.com> + + * lang.c (java_handle_option): Update dependency_tracking for + OPT_MF case. + + * lang.c (java_handle_option): OPT_fbootclasspath_ can take an + empty argument. + +2003-06-10 Andrew Haley <aph@redhat.com> + + * resource.c (write_resource_constructor): Use expand_expr to + generate the address of the label attached to a resource. + * Make-lang.in (java/resource.o): Add expr.h + +2003-06-10 Andrew Haley <aph@redhat.com> + + * lang.c (LANG_HOOKS_DECL_OK_FOR_SIBCALL): New. + (java_decl_ok_for_sibcall): New. + +2003-06-09 Neil Booth <neil@daikokuya.co.uk> + + * Make-lang.in (JAVA_OBJS, java/lang.o): Update. + (java/j-options.c, java/j-options.h): New. + * java-tree.h (resource_name, compile_resource_file, + compile_resource_data): Constify. + * jcf-write.c (jcf_write_base_directory): Similarly. + * jcf.h (jcf_write_base_directory): Similarly. + * lang.c: Include j-options.h. + (cl_options_count, cl_options, string_option, java_decode_option, + lang_f_options, lang_W_options, LANG_HOOKS_DECODE_OPTION, + process_option_with_no): Remove. + (resource_name): Constify. + (LANG_HOOKS_HANDLE_OPTION): Override. + (java_handle_option): New. + (java_init): Don't call jcf_path_init. + (java_init_options): Call jcf_path_init. + * lang.opt: New. + * resource.c (compile_resource_data, compile_resource_file): Constify. + +2003-06-09 Nathan Sidwell <nathan@codesourcery.com> + + * java-tree.h (DECL_FUNCTION_LAST_LINE): New. + (struct lang_decl_func): Add last_line field. + * parse.h (DECL_SOURCE_LINE_MERGE, DECL_SOURCE_LINE_FIRST, + DECL_SOURCE_LINE_LAST): Remove. + * parse.y (missing_return_error, finish_method_declaration, + lookup_cl, start_artificial_method_body, source_end_java_method, + start_complete_expand_method): Adjust. + +2003-06-08 Tom Tromey <tromey@redhat.com> + + * jvspec.c (jvgenmain_spec): Added `*' after fassume-compiled and + fno-assume-compiled. + +2003-06-08 Roger Sayle <roger@eyesopen.com> + + * builtins.c (define_builtin_type, builtin_types): Delete. + (define_builtin): Rewritten to take just the built-in code, + the function's name, type and fallback library function name. + All built-ins used by Java are implicit and BUILT_IN_NORMAL. + (initialize_builtins): Overhaul to define the GCC builtins + used by gcj manually, providing the Java run-time's + implementations as the fallback library function. + +2003-06-08 Anthony Green <green@redhat.com> + + * parse.y (patch_cast): Fix conversions from floating-point to + integral types. + +2003-06-08 Neil Booth <neil@daikokuya.co.uk> + + * Make-lang.in: Update. + * lang.c: Include opts.h. Define cl_options_count and cl_options. + +2003-06-07 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_init_options): Update. + +2003-06-05 Jan Hubicka <jh@suse.cz> + + * Make-lang.in: Add support for stageprofile and stagefeedback + +2003-05-31 Roger Sayle <roger@eyesopen.com> + + * lang.c (java_init_options): Prescribe wrap-around two's + complement arithmetic overflow by setting flag_wrapv. + +2003-05-29 Roger Sayle <roger@eyesopen.com> + + * builtins.c (cos_builtin, sin_builtin, sqrt_builtin): Delete. + (builtin_record): Add an additional builtin_code field to + record which GCC built-in corresponds to the Java function. + (java_builtins): Add new entries for atan, atan2, exp, log, + pow and tan. + (max_builtin, min_builtin, abs_builtin): Perform constant + folding on the resulting tree. + (java_build_function_call_expr): Likewise, perform constant + folding on the resulting tree. + (initialize_builtins): The NULL creators are now allowed in + the java_builtins table, which is now terminated by an entry + with builtin_code == END_BUILTINS. + (check_for_builtin): Likewise. If the matching creator is + NULL, construct the call using java_build_function_call_expr + directly with the decl for the corresponding builtin_code. + +2003-05-23 Nathanael Nerode <neroden@gcc.gnu.org> + + * win32-host.c: Normalize copyright boilerplate. + +2003-05-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * parse.y (print_int_node): Use string concatentation on + HOST_WIDE_INT_PRINT_* format specifier to collapse multiple + function calls into one. + +2003-05-13 Zack Weinberg <zack@codesourcery.com> + + * jcf-parse.c, jcf-write.c, lex.c: Replace all calls to + fatal_io_error with calls to fatal_error; add ": %m" to the end of + all the affected error messages. + +2003-05-13 Richard Henderson <rth@redhat.com> + + * class.c (layout_class_method): Set DECL_EXTERNAL. + * decl.c (java_mark_decl_local, java_mark_class_local): New. + * java-tree.h (java_mark_class_local): Declare. + * jcf-parse.c (parse_class_file): Use it. + * parse.y (java_expand_classes): Likewise. + +2003-05-04 Nathan Sidwell <nathan@codesourcery.com> + + * Make-lang.in (java/parse.o, java/parse-scan.o): Depend on input.h. + * lex.h: #include input.h. + * jv-scan.c (input_filename): Remove. + +2003-05-02 Tom Tromey <tromey@redhat.com> + + PR java/10491: + * gjavah.c (HANDLE_INNERCLASSES_ATTRIBUTE): New macro. + (handle_inner_classes): New function. + +2003-05-01 Tom Tromey <tromey@redhat.com> + + PR java/10459: + * parse.y (finish_for_loop): Do nothing if update expression is a + EXPR_WFL_NODE wrapping nothing. + (java_complete_lhs) <COMPOUND_EXPR>: Likewise. + +2003-05-02 Nathan Sidwell <nathan@codesourcery.com> + + * lex.h (input_lineno): Remove declaration. + * parse-scan.y: #include input.h. + (input_filename): Remove declaration. + (input_location): Add definition. + (input_line): Remove definition. + +2003-05-01 Nathan Sidwell <nathan@codesourcery.com> + + * lex.h (lineno): Rename to ... + (input_line): ... here + * parse-scan.y (lineno): Rename to ... + (input_line): ... here. + (reset_report): Rename lineno to input_line. + * check-init.c (check_init): Likewise. + * class.c (push_class): Likewise. + * decl.c (complete_start_java_method, end_java_method): Likewise. + * expr.c (expand_byte_code): Likewise. + * jcf-parse.c (give_name_to_class, parse_class_file): Likewise. + * jcf-write.c (generate_bytecode_insns): Likewise. + * lex.c (java_init_lex, java_allocate_new_line, + do_java_lex): Likewise. + * parse.h (YYNOT_TWICE): Likewise. + * parse.y (empty_statement, expression_statement, + java_pop_parser_context, java_parser_context_save_global, + yyerror, register_fields, method_header, safe_layout_class, + find_in_imports_on_demand, create_artificial_method, + source_end_java_method, start_complete_expand_method, + build_thisn_assign, java_complete_lhs, + maybe_absorb_scoping_block): Likewise. + +2003-04-20 Mohan Embar <gnustuff@thisiscool.com> + + * jcf-io.c (find_class): use DIR_SEPARATOR instead of + '/' when computing java source filename + +2003-04-13 Tom Tromey <tromey@redhat.com> + + * gjavah.c (print_c_decl): Indentation fix. + +2003-04-12 Zack Weinberg <zack@codesourcery.com> + + * class.c (make_field_value, make_method_value, get_dispatch_table) + (make_class_data, emit_offset_symbol_table) + * constants.c (build_constants_constructor) + * java-tree.h (START_RECORD_CONSTRUCTOR) + * parse.y (maybe_build_array_element_wfl): + Use build_constructor. + +2003-04-10 Eric Blake <ebb9@email.byu.edu> + + PR java/10253: + * parse.y (string_convert_int_cst): Always use at least one digit + in string conversion. Remove ASCII dependence. + (merge_string_cste): Fix merging of 3-byte UTF-8 characters. + +2003-03-16 Mohan Embar <gnustuff@thisiscool.com> + + * Make-lang.in: added win32-host.c + * jcf.h: defined macro JCF_OPEN_EXACT_CASE which + resolves to open() on non-Win32 platforms and + Win32-specific jcf_open_exact_case() on Win32 + * jcf-io.c (find_class): use JCF_OPEN_EXACT_CASE + when trying .java and .class files + * win32-host.c: added to repository. Defines + Win32-specific jcf_open_exact_case() + +2003-04-10 Andrew Haley <aph@redhat.com> + + * jcf-write.c (struct jcf_partial): num_jsrs: new field. + (maybe_free_localvar): Renamed from localvar_free. + Add new arg, really. + (generate_bytecode_insns): Set new variable, jsrs. + Only free local vars if no jsr insns have been emittted. + Call maybe_free_localvar, not localvar_free. + +2003-03-30 Joseph S. Myers <jsm@polyomino.org.uk> + + * gcj.texi: Remove @ at start of file. + +2003-03-25 Tom Tromey <tromey@redhat.com> + + * parse.y (create_interface): Call CHECK_DEPRECATED. + +2003-03-23 Zack Weinberg <zack@codesourcery.com> + + * Make-lang.in: Link jcf-dump against $(LDEXP_LIB). + +2003-03-21 Zack Weinberg <zack@codesourcery.com> + + * javaop.h (jfloat, jdouble): Make them structures mirroring + the bit fields of IEEE float and double respectively. + (JFLOAT_FINITE, JFLOAT_QNAN_MASK, JFLOAT_EXP_BIAS, + JDOUBLE_FINITE, JDOUBLE_QNAN_MASK, JDOUBLE_EXP_BIAS): New. + (union Word, union DWord): Delete. + (WORD_TO_FLOAT, WORDS_TO_DOUBLE): Update to match. + + * gjavah.c (java_float_finite, java_double_finite, F_NAN_MASK, + D_NAN_MASK): Delete. + (jni_print_float, jni_print_double): New. Generate + hexadecimal floating constants. + (print_field_info): Use jni_print_float/double. + + * jcf-dump.c: Include math.h. Use ldexp/frexp to assemble + finite floating point numbers for output; special case + non-finite floats. + +2003-03-19 Nathanael Nerode <neroden@gcc.gnu.org> + + * lang.c (java_dump_tree): Change return type from 'int' to 'bool'. + Replace 0 and 1 with true and false in return statements. + +2003-03-19 Tom Tromey <tromey@redhat.com> + + * lex.c (do_java_lex): Renamed from java_lex. + (java_lex): New function. + Include timevar.h. + +2003-03-13 Tom Tromey <tromey@redhat.com> + + * parse.y (resolve_inner_class): Error if qualifier is a primitive + type. + +2003-03-04 Andrew Haley <aph@redhat.com> + + * gjavah.c (is_first_data_member): New global variable. + (print_c_decl): If it's the first data member, align it as the + superclass. + (process_file): Set is_first_data_member. + +2003-03-11 Tom Tromey <tromey@redhat.com> + + * parse.y (resolve_field_access): Initialize class if field is + found in another static field. + * expr.c (build_class_init): Don't optimize out initialization of + implemented interface. + +2003-03-11 Andrew Haley <aph@redhat.com> + + * jcf-io.c (caching_stat): Initialize origsep to remove compiler + warning. + +2003-03-10 Ranjit Mathew <rmathew@hotmail.com> + + * jcf-io.c (caching_stat): Account for both DIR_SEPARATOR + and DIR_SEPARATOR_2 for a target. + Correct minor typos. + + * jcf-write.c (make_class_file_name): Take both DIR_SEPARATOR + and DIR_SEPARATOR_2 for a target into account. + +2003-03-08 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_init): Update prototype, move code to java_post_options. + (java_post_options): Similarly. + +2003-03-05 Ranjit Mathew <rmathew@hotmail.com> + + * jcf.h (COMPARE_FILENAMES): New macro similar to "strcmp" to + compare file name components depending on the case-sensitivity + or otherwise of the host file system. + + * jcf-path.c (add_entry): Use COMPARE_FILENAMES instead of + "strcmp" to compare file name components. + Use IS_DIR_SEPARATOR instead of comparing directly against + DIR_SEPARATOR. + (jcf_path_extdirs_arg): Use IS_DIR_SEPARATOR instead of + comparing directly against DIR_SEPARATOR. + +2003-03-04 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java.tags): New target. + +2003-03-01 Roger Sayle <roger@eyesopen.com> + + * java/builtins.c (builtin_type): Handle DEF_FUNCTION_TYPE_VAR_3. + (initialize_builtins): Handle DEF_FUNCTION_TYPE_VAR_3. + +2003-03-01 Tom Tromey <tromey@redhat.com> + + * parse.y (jdep_resolve_class): Only check deprecation if we found + a decl. + +2003-02-28 Tom Tromey <tromey@redhat.com> + + PR java/9695: + * class.c (maybe_layout_super_class): Always pass a WFL to + do_resolve_class. + * parse.y (do_resolve_class): Updated comment to explain + parameters. + +2003-02-26 Tom Tromey <tromey@redhat.com> + + * jcf-write.c (generate_classfile): Check whether class is + deprecated before writing attribute count. + +2003-02-25 Roger Sayle <roger@eyesopen.com> + + * java/decl.c (java_init_decl_processing): Get soft_fmod_node from + built_in_decls[BUILT_IN_FMOD] rather than define it ourselves. + +2003-02-23 Tom Tromey <tromey@redhat.com> + + * lang-options.h: Added -Wdeprecated. + * gcj.texi (Warnings): Document -Wdeprecated. + * java-tree.h (flag_deprecated): Declare. + * lang.c (lang_W_options): Added deprecated. + (flag_deprecated): New global. + * chartables.h: Rebuilt. + * gen-table.pl (process_one): Look at whitespace. + (print_tables): Define LETTER_SPACE, LETTER_MASK. + * parse.h (CLEAR_DEPRECATED): New macro. + (CHECK_DEPRECATED_NO_RESET): New macro. + * jcf-parse.c (handle_deprecated): New function. + (HANDLE_DEPRECATED_ATTRIBUTE): New define. + * jcf-reader.c (get_attribute): Handle Deprecated attribute. + * parse.y (resolve_type_during_patch): Check deprecation. + (jdep_resolve_class): Likewise. + (process_imports): Likewise. + (resolve_expression_name): Likewise. + (check_deprecation): Strip arrays from decl. Check + flag_deprecated. + (patch_method_invocation): Also check the particular constructor + for deprecation. + (register_fields): Use CHECK_DEPRECATED_NO_RESET in loop. + * jcf-write.c (append_deprecated_attribute): New function. + (generate_classfile): Generate deprecated attribute when + appropriate. + * lex.c (java_parse_doc_section): Return type now void. Rewrote. + (java_lex) [case '*']: Simplify logic. + (java_start_char_p): Use LETTER_MASK. + (java_part_char_p): Likewise. + (java_space_char_p): New function. + +2003-02-20 Nathan Sidwell <nathan@codesourcery.com> + + Change base class access representation. + * java/class.c (set_super_info): Don't set TREE_VIA_PUBLIC. + (add_interface_do): Likewise. + +2003-02-12 Ranjit Mathew <rmathew@hotmail.com> + + * decl.c (java_init_decl_processing): Change + soft_lookupjnimethod_node to reflect the change in + signature of _Jv_LookupJNIMethod in libjava/jni.cc + * expr.c (build_jni_stub): Calculate and pass the size + on the stack of the arguments to a JNI function. Use + new target macro MODIFY_JNI_METHOD_CALL to allow a + target to modify the call to a JNI method. + +2003-02-08 Roger Sayle <roger@eyesopen.com> + + * jcf-io.c (java_or_class_file): Use libiberty's lbasename + instead of basename to avoid compiler warnings on Tru64. + +2003-02-04 Joseph S. Myers <jsm@polyomino.org.uk> + + * gcj.texi: Update to GFDL 1.2. + +2003-01-31 Andrew Haley <aph@redhat.com> + + * parse.y (java_expand_classes): Scan the whole class list looking + for access methods that haven't yet been expanded. + +2003-01-31 Adrian Bunk <bunk@fs.tum.de> + + Fix for java/4269: + + * jv-scan.c: Use HAVE_LANGINFO_CODESET instead of HAVE_NL_LANGINFO + to fix bootstrap on sparc-unknown-netbsdelf1.5. + * jcf-parse.c: Likewise. + +2003-01-31 Mark Wielaard <mark@klomp.org> + + * gjavah.c (throwable_p): Allocate 1 more byte for string. + +2003-01-31 Nathan Sidwell <nathan@codesourcery.com> + + * class.c (make_class): Use BINFO_ELTS. + (set_super_info): Likewse. + (add_interface_do): Likewise. + +2003-01-30 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (read_class): Update identifier's class value if it + changed during parsing. + +2003-01-30 Loren James Rittle <ljrittle@acm.org> + + * Make-lang.in (po-generated): Find the targets in $(parsedir). + Propagate change to all other rules as required. + (java/parse-scan.o): Add explicit dependency on + $(parsedir)/java/parse-scan.c . + +2003-01-29 Tom Tromey <tromey@redhat.com> + + * parse.y (patch_assignment): Only transform the rhs of an + assignment when compiling to native. + +2003-01-28 Tom Tromey <tromey@redhat.com> + + * jcf-write.c (generate_bytecode_conditional): Typo fixes. + +2003-01-28 Tom Tromey <tromey@redhat.com> + + * lex.c (java_lex): Don't include UEOF as part of token. + (java_read_unicode): Error if \u sequence prematurely terminated. + +2003-01-27 Tom Tromey <tromey@redhat.com> + + * parse.y (java_check_regular_methods): Check for construct after + checking types in throws clause. + +2003-01-24 Tom Tromey <tromey@redhat.com> + + * class.c (build_static_field_ref): Only a String or numeric field + can fold to a constant. + +2003-01-23 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (parse_zip_file_entries): Overwrite trailing \0 of + file name in resource buffer. + +2003-01-23 Tom Tromey <tromey@redhat.com> + + * expr.c (build_known_method_ref): Use method's context to find + method table index. + +2003-01-23 Tom Tromey <tromey@redhat.com> + + * constants.c (set_constant_entry): Allocated cleared memory. + +2003-01-22 Tom Tromey <tromey@redhat.com> + + * java-tree.h: Don't use PARAMS. + * resource.c: Add prototypes for all functions. + (write_resource_constructor): Use `const char *' to avoid + warning. + +2003-01-22 Nathanael Nerode <neroden@gcc.gnu.org> + + * jcf-parse.c (process_zip_dir): Remove unused variable. + +2003-01-22 Tom Tromey <tromey@redhat.com> + + * expr.c (build_invokeinterface): Abort if method's context is not + an interface. + +2003-01-22 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Input and output files): Mention non-class entries. + * decl.c (java_init_decl_processing): Call + init_resource_processing. + * java-tree.h (compile_resource_data, write_resource_constructor, + compile_resource_file, init_resource_processing): Declare. + * config-lang.in (gtfiles): Added resource.c. + * Make-lang.in (gt-java-resource.h): New target. + (JAVA_OBJS): Added resource.o. + (java/resource.o): New target. + * resource.c: New file. + * class.c (compile_resource_file): Moved to resource.c. + (registerResource_libfunc): Likewise. + (utf8_decl_list): Mark with GTY; now static. + * jcf-parse.c (classify_zip_file): New function. + (parse_zip_file_entries): Use it; compile .properties files. + (process_zip_dir): Use classify_zip_file and compute_class_name. + Don't write class name into zip directory. + (java_parse_file): Call write_resource_constructor. + (compute_class_name): New function. + * jcf-io.c (read_zip_member): Reindented. + +2003-01-21 Tom Tromey <tromey@redhat.com> + + * class.c (supers_all_compiled): New function. + (make_class_data): Use it. + +2003-01-21 Tom Tromey <tromey@redhat.com> + + * parse.y (method_header): Native method can't be strictfp. + No method can be transient or volatile. + +2003-01-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + Make-lang.in (jvspec.o-warn): Add -Wno-error. + +2003-01-18 Kazu Hirata <kazu@cs.umass.edu> + + * check-init.c: Fix comment typos. + * class.c: Likewise. + * constants.c: Likewise. + * decl.c: Likewise. + * except.c: Likewise. + * expr.c: Likewise. + * java-except.h: Likewise. + * java-tree.h: Likewise. + * javaop.h: Likewise. + * jcf-dump.c: Likewise. + * jcf-io.c: Likewise. + * jcf-parse.c: Likewise. + * jcf-write.c: Likewise. + * lang.c: Likewise. + * mangle.c: Likewise. + * typeck.c: Likewise. + * verify.c: Likewise. + +2003-01-18 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (java/jcf-write.o): Depend on $(TM_P_H). + * jcf-write.c: Include "tm_p.h". + +2003-01-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-io.c (caching_stat): Cast the 3rd arg of scandir to void*. + +2003-01-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * builtins.c (java_build_function_call_expr): Renamed from + build_function_call_expr. All callers changed. + + * Make-lang.in (java/jcf-parse.o): Depend on $(TM_P_H). + * jcf-parse.c: Include tm_p.h. + + * jcf-write.c (generate_bytecode_insns): Avoid signed/unsigned + warning. + +2003-01-14 Tom Tromey <tromey@redhat.com> + + * class.c (make_class_data): Check that super is compiled before + building class reference to it. + +2003-01-14 Andrew Haley <aph@redhat.com> + + * decl.c (java_init_decl_processing): _Jv_NewMultiArray is a + varargs function -- correct. + +2003-01-14 Andrew Haley <aph@redhat.com> + + * decl.c (java_init_decl_processing): Temporarily back out previous patch. + +2003-01-14 Andrew Haley <aph@redhat.com> + + * decl.c (java_init_decl_processing): _Jv_NewMultiArray is a + varargs function -- correct. + + * parse.y (patch_assignment): Copy the rhs of an assignment into a + temporary if the RHS is a reference. + +2003-01-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (keyword.h): Pass "-L ANSI-C" to gperf. + * keyword.h: Regenerated. + + * All Files: Convert to ISO C style function definitions. + +2003-01-09 Nathanael Nerode <neroden@gcc.gnu.org> + + * parse.y (check_pkg_class_access): ANSIfy definition. + +2003-01-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * decl.c, parse-scan.y, parse.y: Don't cast return value of + xmalloc et al. + + * class.c, gjavah.c, parse.y, verify.c: Don't use PTR. + +2003-01-09 Geoffrey Keating <geoffk@apple.com> + + Merge from pch-branch: + + 2002-12-02 Geoffrey Keating <geoffk@apple.com> + + * Make-lang.in (java/gjavah.o): Update dependencies. + * gjavah.c: Include ggc.h. + + 2002-08-16 Geoffrey Keating <geoffk@redhat.com> + + * Make-lang.in (GCJH_OBJS): Add ggc-none.o. + (JCFDUMP_OBJS): Add ggc-none.o. + (java/jcf-dump.o): Depend on GGC_H. + * jcf-reader.c (jcf_parse_constant_pool): Use ggc_alloc to allocate + CPool substructures. + * jcf-parse.c (process_zip_dir): Use ggc_alloc to allocate JCFs. + * jcf-dump.c: Include ggc.h. + + 2002-08-08 Geoffrey Keating <geoffk@redhat.com> + + * jcf.h (union cpool_entry): New. + (struct CPool): Use gengtype to mark. Change field 'data' to be + an array of unions. + (struct JCF): Use gengtype to mark. + (CPOOL_UINT): Update for new cpool_entry type. + (CPOOL_USHORT1): Likewise. + (CPOOL_USHORT2): Likewise. + (CPOOL_FINISH): Use GC to free cpool subfields. + * parse.h (struct parser_ctxt): Mark field current_jcf. + * lex.c (java_init_lex): Use GC to allocate struct JCF. + * jcf-parse.c (HANDLE_CONSTANT_Utf8): Update for new cpool_entry type. + (main_jcf): Use gengtype to mark. + (ggc_mark_jcf): Delete. + (get_constant): Update for new cpool_entry type. + (give_name_to_class): Likewise. + (get_class_constant): Likewise. + (init_outgoing_cpool): Use GGC to allocate struct CPool. + (java_parse_file): Use GGC to allocate struct JCF. + (init_jcf_parse): Don't call ggc_add_root. + * jcf-reader.c (jcf_parse_constant_pool): Update for new + cpool_entry type. + * java-tree.h (current_jcf): Use gengtype to mark. + (CPOOL_UTF): Update for new cpool_entry type. + (outgoing_cpool): Use gengtype to mark. + (struct lang_type): GC struct JCF and struct CPool. + * config-lang.in (gtfiles): Add jcf.h. + * constants.c (find_tree_constant): New. + (set_constant_entry): Allocate cpool subfields using GGC. Update + for new cpool_entry type. + (find_constant1): Update for new cpool_entry type. + (find_constant2): Likewise. + (find_utf8_constant): Use find_tree_constant. + (find_class_or_string_constant): Remove unnecessary cast to jword. + Update for new cpool_entry type. + (count_constant_pool_bytes): Update for new cpool_entry type. + (write_constant_pool): Likewise. + (alloc_name_constant): Use find_tree_constant. + (build_constants_constructor): Update for new cpool_entry type. + + 2002-08-08 Geoffrey Keating <geoffk@redhat.com> + + * parse.y (mark_parser_ctxt): Delete. + (goal): Don't use ggc_add_root. + (create_new_parser_context): Use GC to allocate struct parser_ctxt. + (java_pop_parser_context): Let GC free parser_ctxt. + (java_parser_context_resume): Likewise. + * parse.h (struct parser_ctxt): Use gengtype to mark. + (ctxp): Likewise. + (ctxp_for_generation): Likewise. + * lex.h (struct java_lc_s): Mark for gengtype. + (java_lexer): Rearrange for gengtype. + * config-lang.in (gtfiles): Add lex.h, parse.h. + +2003-01-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * All Files: Remove PARAMS macro. + + * expr.c, gjavah.c, javaop.h, jcf-dump.c, jcf-io.c, jcf-reader.c, + jcf-write.c, jcf.h, jv-scan.c: Don't rely on the `DEFUN', `AND' or + `__STDC__' macros. + + * jv-scan.c, parse.y: Remove VPARAMS, VA_OPEN, VA_FIXEDARG and + VA_CLOSE. + +2003-01-09 Christian Cornelssen <ccorn@cs.tu-berlin.de> + + * Make-lang.in (java.install-common, java.uninstall, + java.install-info, java.install-man): Prepend $(DESTDIR) + to destination paths in all (un)installation commands. + (java.install-common): Rewrite $(LN) command to support + DESTDIR with "ln" as well as with "ln -s". + +2003-01-08 Nathanael Nerode <neroden@gcc.gnu.org> + + * java-tree.h: Protect against multiple inclusion. + +2003-01-07 Tom Tromey <tromey@redhat.com> + + * class.c (add_assume_compiled): Don't adjust parent if we're + already at the root of tree. + +2003-01-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lang.c (dump_compound_expr): Prototype. + +2003-01-03 Tom Tromey <tromey@redhat.com> + + Fix for PR java/8712: + * expr.c (build_instanceof): Build an NE_EXPR, not a COND_EXPR, + when simply checking against `null'. + +2003-01-03 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Standard Properties): Document http.proxyHost and + http.proxyPort. + + * gcj.texi (GNU Classpath Properties): Document new properties. + +2003-01-02 Steven Bosscher <s.bosscher@student.tudelft.nl> + + * java/jcf-reader.c, java/jvgenmain.c, java/keyword.gperf, + java/lang-options.h, java/mangle.c, java/mangle_name.c, + java/xref.c, java/zextract.c,java/zipfile.h: Fix copyright years. + +2003-01-01 Steven Bosscher <s.bosscher@student.tudelft.nl> + + * Make-lang.in, boehm.c, buffer.c, + buffer.h, builtins.c, class.c, + config-lang.in, constants.c, + convert.h, decl.c, except.c, + expr.c, java-except.h, + java-tree.h, javaop.def, + jcf-parse.c, jcf-write.c, + jv-scan.c, jvgenmain.c, + jvspec.c, keyword.gperf, + keyword.h, lang-options.h, + lang-specs.h, lang.c, lex.c, + lex.h, mangle.c, mangle_name.c, + parse-scan.y, parse.h, parse.y, + typeck.c, verify.c, xref.c, + xref.h: Replace "GNU CC" with + "GCC" in the copyright header. + + * check-init.c, gjavah.c, javaop.h, + jcf-depend.c, jcf-dump.c, jcf-io.c, + jcf-path.c, jcf-reader.c, jcf.h, + zextract.c, zipfile.h: These files are + "part of GCC". Also say "GCC" not "GNU CC". + +2002-12-30 DJ Delorie <dj@redhat.com> + + * Make-lang.in: Protect against texi2pod/pod2man failing. + +2002-12-28 Joseph S. Myers <jsm@polyomino.org.uk> + + * gcj.texi: Use @copying. + +2002-12-27 Mark Mitchell <mark@codesourcery.com> + + * gjavah.c (print_name_for_stub_or_jni): Adjust call to + print_cxx_classname. + (print_cxx_classname): Add add_scope parameter. + (print_class_decls): Do not emit a semicolon after the extern + "Java" block. + (process_file): Adjust calls to print_cxx_classname. + +2002-12-23 Joseph S. Myers <jsm@polyomino.org.uk> + + * gcj.texi: Include Cover Texts in man page. + +2002-12-23 Jeff Sturm <jsturm@one-point.com> + + * class.c (build_static_field_ref): Check FIELD_FINAL. + + * constants.c (alloc_class_constant): Use TYPE_CPOOL_DATA_REF + instead of current_constant_pool_data_ref. + * java-tree.h (current_constant_pool_data_ref): Undefine. + (JTI_CURRENT_CONSTANT_POOL_DATA_REF): Remove. + * jcf-parse.c (init_outgoing_cpool): Don't initialize + current_constant_pool_data_ref. + + * except.c (prepare_eh_table_type ): Use DECL_NAME of class type, + not build_internal_class_name. + + * parse.y (patch_incomplete_class_ref): Always emit `class$' method. + Use it when class ref isn't certain to be compiled. + +2002-12-23 Joseph S. Myers <jsm@polyomino.org.uk> + + * gcj.texi: Include gcc-common.texi. + * Make-lang.in ($(srcdir)/java/gcj.info, java/gcj.dvi): Depend on + $(srcdir)/doc/include/gcc-common.texi. + +2002-12-22 Anthony Green <green@redhat.com> + + * gcj.texi (Limitations): Add note about org.xml.sax and + org.w3c.dom. + +2002-12-20 Tom Tromey <tromey@redhat.com> + + * jcf-write.c (generate_bytecode_insns) [SWITCH_EXPR]: Handle case + where minimum case value is Integer.MIN_VALUE. + Fixes PR java/8955. + +2002-12-18 Andrew Haley <aph@redhat.com> + + * parse.y (patch_invoke): Force evaluation order when `check' is + set. For PR libgcj/8945. + +2002-12-16 Mark Mitchell <mark@codesourcery.com> + + * gcj.texi: Change version number to 3.4. + +2002-12-05 Ranjit Mathew <rmathew@hotmail.com> + Andrew Haley <aph@redhat.com> + + * parse.y (source_end_java_method): Remove custom encoding of line + numbers for a function decl before passing it to the back end. + +2002-12-03 Andrew Haley <aph@redhat.com> + + * class.c (make_class_data): New field, "chain". + * decl.c (java_init_decl_processing): Likewise. + +2002-12-02 Tom Tromey <tromey@redhat.com> + + For PR java/8740: + * parse.y (do_resolve_class): Handle qualified name via + recursion. + +2002-11-30 Zack Weinberg <zack@codesourcery.com> + + * boehm.c, buffer.c, builtins.c, check-init.c, class.c, + constants.c, decl.c, except.c, expr.c, gjavah.c, jcf-depend.c, + jcf-dump.c, jcf-io.c, jcf-parse.c, jcf-path.c, jcf-write.c, + jv-scan.c, jvgenmain.c, jvspec.c, lang.c, mangle.c, mangle_name.c, + parse-scan.y, parse.y, typeck.c, verify.c, xref.c, zextract.c: + Include coretypes.h and tm.h. + * Make-lang.in: Update dependencies. + +2002-11-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * decl.c (java_init_decl_processing): Use `LL' on 64-bit constant. + +2002-11-25 Diego Novillo <dnovillo@redhat.com> + + * jcf-reader.c: Don't expand JCF_readu4 inside the + expansion of JCF_SKIP. + +2002-11-25 Diego Novillo <dnovillo@redhat.com> + + * jcf-reader.c: Don't expand JCF_readu4 inside the + expansion of JCF_SKIP. + +2002-11-22 Tom Tromey <tromey@redhat.com> + + * parse.y (patch_binop): Cast right hand side of shift expression + to `int'. Fixes PR java/8676. + +2002-11-22 Ranjit Mathew <rmathew@hotmail.com> + Andrew Haley <aph@redhat.com> + + * gcc/java/jcf-write.c (write_classfile): Remove target + class file, if it exists, before renaming the temporary + class file to it. + +2002-11-19 Jason Thorpe <thorpej@wasabisystems.com> + + * jvspec.c (lang_specific_spec_functions): New. + +2002-11-18 Tom Tromey <tromey@redhat.com> + + Fix for PR java/7912: + * expr.c (can_widen_reference_to): Allow cast of array to + Cloneable or Serializable. + * java-tree.h (java_lang_cloneable_identifier_node): Declare. + (java_io_serializable_identifier_node): Likewise. + * parse.y (java_lang_cloneable, java_io_serializable): Removed. + (valid_ref_assignconv_cast_p): Use new identifier nodes. + * lex.c (java_init_lex): Don't initialize java_lang_cloneable and + java_io_serializable. + * decl.c (java_init_decl_processing): Initialize + java_lang_cloneable_identifier_node and + java_io_serializable_identifier_node. + (java_lang_cloneable_identifier_node): New global. + (java_io_serializable_identifier_node): Likewise. + +2002-11-14 Jens-Michael Hoffmann <jensmh@gmx.de> + + * buffer.c: Remove unnecessary casts. + * check-init.c: Likewise. + * class.c: Likewise. + * constants.c: Likewise. + * decl.c: Likewise. + * except.c: Likewise. + * gjavah.c: Likewise. + * jcf-io.c: Likewise. + * jcf-parse.c: Likewise. + * jcf-path.c: Likewise. + * jvspec.c: Likewise. + * lang.c: Likewise. + * lex.c: Likewise. + * verify.c: Likewise. + +2002-11-06 Tom Tromey <tromey@redhat.com> + + * gjavah.c (print_stub_or_jni): Include JNIEXPORT and JNICALL in + a JNI header. + +2002-11-05 Tom Tromey <tromey@redhat.com> + + Fix for PR java/6388. + * lex.h (JAVA_INTEGRAL_RANGE_ERROR): Wrap in do...while. + * java-tree.h (enum java_tree_index): New values + JTI_DECIMAL_INT_MAX_NODE, JTI_DECIMAL_LONG_MAX_NODE. + (decimal_int_max, decimal_long_max): New defines. + * lex.c (yylex): Rewrote range checking. Sign extend literals. + (error_if_numeric_overflow): Rewrote range checking. + * decl.c (java_init_decl_processing): Initialize decimal_int_max, + decimal_long_max. + +2002-11-02 Tom Tromey <tromey@redhat.com> + + * java-tree.h: Move JV_STATE_ERROR before JV_STATE_DONE. + + * class.c (make_method_value): Put class name, not signature, into + `throws' field. For PR java/8415. + +2002-10-24 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Invoking gij): Document --showversion. + (Standard Properties): java.library.path now set. + +2002-10-23 Tom Tromey <tromey@redhat.com> + + * gjavah.c (decode_signature_piece): In JNI mode, print + `jobjectArray' when array depth is nonzero. + Fixes PR java/8296. + +2002-10-15 Andrew Haley <aph@redhat.com> + + * parse.y (patch_invoke): Call force_evaluation_order on a static + arg list. + (resolve_qualified_expression_name): Call force_evaluation_order + on a arg list that is part of a Qualified Expression Name. + + * lang.c (dump_compound_expr): New. + (java_dump_tree): New. + +2002-10-20 Ranjit Mathew <rmathew@hotmail.com> + + * gcj.texi: Added item describing the GCJ runtime property + "gnu.gcj.progname". + +2002-10-15 Richard Henderson <rth@redhat.com> + + * jcf-parse.c (get_constant): Fix type warning. + +2002-10-15 Andrew Haley <aph@redhat.com> + + * java-tree.h (java_inlining_merge_static_initializers): Declare. + (java_inlining_map_static_initializers): Declare. + +2002-10-14 Andrew Haley <aph@redhat.com> + + * tree-inline.c (remap_block): All local class initialization + flags go in the outermost scope. + (expand_call_inline): Call java_inlining_map_static_initializers. + (expand_call_inline): Call java_inlining_merge_static_initializers. + * java/lang.c (merge_init_test_initialization): New. + (java_inlining_merge_static_initializers): New. + (inline_init_test_initialization): New. + (java_inlining_map_static_initializers): New. + +2002-10-11 Mark Wielaard <mark@klomp.org> + + * gcj.texi (Compatibility): Add Limitations and Extensions section. + +2002-10-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (JAVA_TREEHASHHASH_H): Use htab_hash_pointer. + +2002-10-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * parse.y (merge_string_cste): Add parentheses around & within |. + +2002-10-08 Tom Tromey <tromey@redhat.com> + + * parse.y (variable_declarator_id): Simplify error path for + array declarator error. For PR java/8003. + +2002-10-08 Zack Weinberg <zack@codesourcery.com> + + * gjavah.c, jcf-dump.c, jv-scan.c: Globally replace GCCBUGURL with + bug_report_url. + +2002-10-08 Andrew Haley <aph@redhat.com> + + * parse.y (attach_init_test_initialization_flags): Check for + error_mark_node. + +2002-10-07 Anthony Green <green@redhat.com> + + * parse.y (merge_string_cste): Fix bug in string concatenation. + +2002-10-03 Michael Koch <konqueror@gmx.de> + + * gcj.texi (Standard properties): + Change default of java.awt.toolkit to gnu.awt.gtk.GtkToolkit. + +2002-10-02 Roger Sayle <roger@eyesopen.com> + + PR optimization/6627 + * lang.c (java_init): If storing the vbit in function + pointers, ensure that force_align_functions_log is atleast + one to aid compatability with g++ vtables. + +2002-10-01 Nathan Sidwell <nathan@codesourcery.com> + + * jcf-dump.c (print_constant, case CONSTANT_float): Don't fall + foul of type-based aliasing. + +2002-09-30 Anthony Green <green@redhat.com> + + * gcj.texi (Invoking jv-scan): Fix texinfo. + +2002-09-28 Anthony Green <green@redhat.com> + + * gcj.texi (Invoking jv-scan): Add --no-assert documentation. + (Code Generation): Add -fno-assert documentation. + * jv-scan.c (flag_assert): New global. + (options): Add assert option. + (help): Add --no-assert documentation. + * parse-scan.y (flag_assert): New global. + * lang.c (lang_f_options): Add -fassert/-fno-assert support. + (flag_assert): New global. + * java-tree.h (flag_assert): New global. + * lex.c (java_lex): Obey flag_assert. + * jvspec.c (jvgenmain_spec): Strip -fassert/-fno-assert when + calling cc1. + +2002-09-26 Andrew Haley <aph@redhat.com> + + * expr.c (build_java_array_length_access): Check for null pointer. + * expr.c (expand_java_arrayload): Likewise. + +2002-09-21 Richard Henderson <rth@redhat.com> + + * jcf-parse.c (get_constant): Decode from IEEE no matter + what the target format. + +2002-09-20 Kazu Hirata <kazu@cs.umass.edu> + + * ChangeLog: Follow spelling conventions. + * class.c: Likewise. + * decl.c: Likewise. + * expr.c: Likewise. + * gjavah.c: Likewise. + * java-tree.h: Likewise. + * jcf-dump.c: Likewise. + * jcf-parse.c: Likewise. + * jvspec.c: Likewise. + * lang.c: Likewise. + * mangle.c: Likewise. + * parse.y: Likewise. + +2002-09-17 Tom Tromey <tromey@redhat.com> + + * lex.c (java_read_unicode_collapsing_terminators): Handle case + where \r appears at EOF. Fixes PR java/7950. + +2002-09-16 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + + * jvspec.c (lang_specific_driver): Remove unused variable. + +2002-09-16 Geoffrey Keating <geoffk@apple.com> + + * java-tree.h (union lang_tree_node): Add chain_next option. + +2002-09-16 Richard Henderson <rth@redhat.com> + + * jcf-parse.c (get_constant): Runtime check for IEEE format; + use new real.h interface. + * jcf-write.c (find_constant_index): Use new real.h interface. + * lex.c (IS_ZERO): Use REAL_VALUES_EQUAL. + +2002-09-15 Kazu Hirata <kazu@cs.umass.edu> + + * lang.c: Follow spelling conventions. + +2002-09-11 Per Bothner <per@bothner.com> + + * parse.y (fold_constant_for_init): If a VAR_DECL, convert numerical + constant to the type of the field. + (java_complete_tree): Remove now-redundant code. + + * parse.y (fold_constant_for_init): 'null' is not a constant expr. + +2002-09-03 Jesse Rosenstock <jmr@ugcs.caltech.edu> + + For PR java/5794: + * verify.c (verify_jvm_instructions) [OPCODE_jsr]: Only push the + return label if a ret instruction for the jsr has been reached. + +2002-09-09 Ranjit Mathew <rmathew@hotmail.com> + + * parse.y (DIR_SEPARATOR): Don't define. + (check_class_interface_creation): Use IS_DIR_SEPARATOR. + +2002-08-28 Andrew Haley <aph@redhat.com> + + * verify.c (verify_jvm_instructions): Allow exception handler + inside code that is being protected, but generate a warning. + * except.c (link_handler): Initialize `expanded' in new eh_range. + (binding_depth, is_class_level, current_pc): Declare extern. + +2002-09-01 Mark Wielaard <mark@klomp.org> + + * gcj.texi: Add chapter about system properties. + Fixed some typos. + +2002-08-26 Tom Tromey <tromey@redhat.com> + + * parse.y (try_builtin_assignconv): Allow narrowing primitive + conversion if RHS_TYPE is byte, short, or char. + +2002-08-22 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Invoking gij): Document -cp and -classpath. + +2002-08-21 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java/jcf-path.o): Use $(datadir), not + $(prefix)/share. For PR libgcj/7633. + + For PR java/6005 and PR java/7611: + * lang.c (LANG_HOOKS_CAN_USE_BITFIELDS_P): New define. + (java_can_use_bit_fields_p): New function. + +2002-08-16 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Class Initialization): Mention class initialization of + arrays. + +2002-07-30 Andrew Haley <aph@cambridge.redhat.com> + + * Make-lang.in (java-tree-inline.o): New. + (JAVA_OBJS): Add java-tree-inline.o. + * parse.y (source_end_java_method): Call java_optimize_inline. + (java_expand_method_bodies): Save method's tree in + DECL_SAVED_TREE. + (add_stmt_to_compound): Keep track of the number of statments. + * lang.c (java_init): Enable flag_inline_trees. + (java_post_options): If flag_inline_functions is on, enable + flag_inline_trees instread. + (decl_constant_value): New. + (java_tree_inlining_walk_subtrees): New. + * java-tree.h (DECL_NUM_STMTS): New macro. + (java_optimize_inline): Declare. + * expr.c (java_expand_expr): Allow a BLOCK to return a value. + Handle a LABEL_EXPR. + * decl.c (build_result_decl): If we already have a DECL_RESULT + don't make another. + (dump_function): New. + (java_optimize_inline): New. + (dump_function): New. + +2002-08-13 Jesse Rosenstock <jmr@fulcrummicro.com> + + For PR java/7483: + * parse.y (build_assertion): Invert return from + desiredAssertionStatus. + +2002-08-08 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * jcf-write.c (get_access_flags): Return correct access flags for + private and protected inner classes. + +2002-08-08 Nathan Sidwell <nathan@codesourcery.com> + + * java/Make-lang.in (java.mostlyclean): Remove coverage files. + +2002-08-05 Geoffrey Keating <geoffk@redhat.com> + + * mangle_name.c: Don't include obstack.h twice. + * xref.c: Don't include obstack.h. + +2002-08-04 Geoffrey Keating <geoffk@redhat.com> + + * class.c: (permanent_obstack): Delete declaration. + * constants.c: (permanent_obstack): Delete declaration. + * except.c: (permanent_obstack): Delete declaration. + * expr.c: (permanent_obstack): Delete declaration. + * jcf-parse.c: (permanent_obstack): Delete declaration. + (saveable_obstack): Delete declaration. + * parse.h: (permanent_obstack): Delete declaration. + * typeck.c: (permanent_obstack): Delete declaration. + +2002-08-04 Joseph S. Myers <jsm@polyomino.org.uk> + + * gcj.texi (version-gcc): Increase to 3.3. + +2002-07-22 Tom Tromey <tromey@redhat.com> + + * lex.c (java_lex): Check for `e' or `E' after 0. + +2002-07-21 Richard Henderson <rth@redhat.com> + + * lang.c (java_unsafe_for_reeval): New. + (LANG_HOOKS_UNSAFE_FOR_REEVAL): New. + +2002-07-21 Neil Booth <neil@daikokuya.co.uk> + + * jcf-path.c (GET_ENV_PATH_LIST): Remove. + (jcf_path_init): Use GET_ENVIRONMENT. + +2002-07-10 Roger Sayle <roger@eyesopen.com> + Zack Weinberg <zack@codesourcery.com> + + * builtins.c (initialize_builtins): Remove defines that + handled C/C++ specific junk hereby removed from builtins.def. + +2002-07-07 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_post_options): Update prototype. + +2002-07-05 Roger Sayle <roger@eyesopen.com> + + * builtins.c (initialize_builtins): Ignore the additional + parameter to DEF_BUILTIN. Handle more C/C++ specific junk in + the builtins.def file. + +2002-07-01 Tom Tromey <tromey@redhat.com> + + For PR libgcj/7073: + * parse.y (patch_incomplete_class_ref): Handle VOID_TYPE + specially. + +2002-07-01 Roger Sayle <roger@eyesopen.com> + + * java/decl.c (builtin_function): Accept additional parameter. + (java_init_decl_processing): Pass an additional NULL_TREE + argument to builtin_function. + +2002-06-29 T.J. Mather <tjmather@maxmind.com> + + * gcj.texi: Fixed gcj invocation example so that it compiles. + +2002-06-26 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lex.c (java_init_lex): Avoid incorrect hardcoded constant 11. + * parse.y (mark_parser_ctxt): Likewise. + (check_modifiers, declare_local_variables): Avoid incorrect + hardcoded constant 10. + + * lex.c (java_read_char): Avoid "comparison is always true" + warning. + +2002-06-25 Andreas Schwab <schwab@suse.de> + + * expr.c (JSR): Avoid undefined operation on PC. + +2002-06-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * decl.c (clear_binding_level): Const-ify. + +2002-06-13 Akim Demaille <akim@epita.fr> + + * parse.y (class_declaration, interface_declaration): Make sure + all their rules have an action, in order to avoid meaningless `$$ + = $1' and their type clashes. + +2002-06-11 Tom Tromey <tromey@redhat.com> + + * jcf-write.c (generate_classfile): Use FIELD_SYNTHETIC. + * parse-scan.y (statement_without_trailing_substatement): Added + assert_statement. + (assert_statement): New rule. + * java-tree.h (struct lang_type) [assertions]: New field. + (TYPE_USES_ASSERTIONS): New macro. + (CLASS_USES_ASSERTIONS): Likewise. + (FIELD_SYNTHETIC): New define. + * lex.c (java_lval;): Added ASSERT_TK. + * parse.y (ASSERT_TK): Added. + (statement_without_trailing_substatement): Added assert_statement. + (assert_statement): New rule. + (build_assertion): New function. + (maybe_generate_pre_expand_clinit): Create and initialize + $assertionsDisabled. + (lookup_package_type): Removed decl. + * keyword.h: Rebuilt. + * keyword.gperf (assert): New token. + +2002-06-10 Akim Demaille <akim@epita.fr> + + * parse.y (interface_type_list, class_member_declaration) + (unary_expression_not_plus_minus): Remove duplicate %type. + Whitespace changes. + +2002-06-09 Tom Tromey <tromey@redhat.com> + + * Make-lang.in (java/lang.o): Use LANGHOOKS_DEF_H. + + * parse.y (method_header): Give error message in all cases. + Fixes PR java/6865. + +2002-06-10 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + Don't use RTL inlining. Fix for PR java/6820. + * lang.c (LANG_HOOKS_POST_OPTIONS): Define. + (flag_really_inline): New. + (java_decode_option): Set flag_really_inline if -finline-functions + is seen. + (java_post_options): New function. Turn off inlining unless + flag_really_inline is set. + +2002-06-10 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * gjavah.c (throwable_p): Accept argument as either a classname or + signature fragment. Create null-terminated classname string for super + when calling itself recursively. + (decode_signature_piece): Skip first character from class name + signature when calling throwable_p. + +2002-06-08 H.J. Lu (hjl@gnu.org) + + * jcf-path.c (jcf_path_init): Allocate 1 more byte for string. + +2002-06-04 Tom Tromey <tromey@redhat.com> + + * jcf-write.c (perform_relocations): Optmize a goto to a goto. + +2002-06-04 Michael Koch <konqueror@gmx.de> + + * gcj.texi (Input Options): Fixed typo. + +2002-06-04 Zack Weinberg <zack@codesourcery.com> + + * java-tree.h, class.c, expr.c, jcf-parse.c, parse.y, + typeck.c, verify.c: Remove all #if JAVA_USE_HANDLES blocks, + all mention of CLASS_TO_HANDLE_TYPE or HANDLE_TO_CLASS_TYPE, + and all now-pointless local variables. Rename other local + variables to reflect their not being handles. + + * java-tree.h, jcf-dump.c, jcf-io.c: Remove all + #if JCF_USE_STDIO blocks. + + * parse.y: Add missing semicolon at end of rule. + +2002-06-03 Geoffrey Keating <geoffk@redhat.com> + + * check-init.c (attach_initialized_static_class): Delete, unused. + * parse.y: Use htab_t instead of struct hashtable, update + all uses. + * java-tree.h: Include hashtab.h instead of hash.h. + (struct lang_decl_func): Use htab_t, set up for gengtype. + (struct init_test_hash_entry): Delete. + (struct treetreehash_entry): New. + (java_treetreehash_find): New + (java_treetreehash_new): New prototype. + (java_treetreehash_create): New prototype. + (java_mark_tree): Delete prototype. + (java_hash_hash_tree_node): Delete prototype. + (java_hash_compare_tree_node): Delete prototype. + (attach_initialized_static_class): Delete prototype. + * expr.c (build_class_init): Update to use java_treetreehash + functions. + (java_expand_expr): Update to use htab_t. + (emit_init_test_initialization): Likewise. + * decl.c (java_mark_tree): Delete. + * class.c (init_test_hash_newfunc): Delete. + (java_hash_hash_tree_node): Delete. + (java_hash_compare_tree_node): Delete. + (add_method_1): Update to use java_treetreehash functions. + (JAVA_TREEHASHHASH_H): New macro. + (java_treetreehash_hash): New function. + (java_treetreehash_compare): New function. + (java_treetreehash_find): New function. + (java_treetreehash_new): New function. + (java_treetreehash_create): New function. + * Make-lang.in (JAVA_TREE_H): Replace hash.h by HASHTAB_H. + + * Make-lang.in (java/parse.o): Depend on debug.h. + * java-tree.h (struct lang_identifier): Use gengtype. + (union lang_tree_node): New. + (struct lang_decl_func): Use gengtype. + (struct lang_decl_var): Likewise. + (struct lang_decl): Likewise. + * parse.y: Include debug.h. + * lang.c (LANG_HOOKS_MARK_TREE): Delete. + + * lang.c (struct language_function): New dummy structure. + + * java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Set + descriminator for DECL_LANG_SPECIFIC. + (struct lang_decl_func): Rename from struct lang_decl. + (enum lang_decl_desc): New. + (struct lang_decl): Make it a union. Update all the accessor macros. + (struct lang_type): Use gengtype. + * class.c (add_method_1): Set descriminator for DECL_LANG_SPECIFIC. + * decl.c (java_dup_lang_specific_decl): All lang_decl structures + are now the same size. + (lang_mark_tree): Use gengtype to mark TYPE_LANG_SPECIFIC; + use discriminator to mark DECL_LANG_SPECIFIC. + + * Make-lang.in (gt-java-builtins.h): New rule. + (java/builtins.o): Add dependency on gt-<filename>.h. + * builtins.c: Use gengtype for roots. + (union string_or_tree): Use gengtype. + (struct builtin_record): Use gengtype. + * config-lang.in (gtfiles): Add builtins.c. + + * Make-lang.in (gt-java-class.h, gt-java-constants.h, + gt-java-decl.h, gt-java-expr.h, gt-java-jcf-parse.h, + gt-java-jcf-write.h, gt-java-lang.h, gt-java-mangle.h, + gt-java-parse.h, gtype-java.h): Add rules to generate. + (parse.o): Add dependency on gt-java-parse.h, gt-java.h. + (class.o): Add dependency on gt-*.h. + (constants.o): Likewise. + (decl.o): Likewise. + (expr.o): Likewise. + (jcf-parse.o): Likewise. + (jcf-write.o): Likewise. + (lang.o): Likewise. + * config-lang.in (gtfiles): New. + * class.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * constants.c: Replace uses of ggc_add_* with GTY markers. + Include gt-*.h. + * decl.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * expr.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * java-tree.h: Replace uses of ggc_add_* with GTY markers. + * jcf-parse.c: Replace uses of ggc_add_* with GTY markers. + Include gt-*.h. + * jcf-write.c: Replace uses of ggc_add_* with GTY markers. + Include gt-*.h. + * lang.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * mangle.c: Replace uses of ggc_add_* with GTY markers. Include + gt-*.h. + * parse.y: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + Include gtype-java.h. + +2002-06-02 Tom Tromey <tromey@redhat.com> + + Fix for PR java/5913: + * parse.y (patch_binop): Call patch_string on op1. + +2002-06-02 Tom Tromey <tromey@redhat.com> + + Fix for PR java/1343, PR java/6336: + * parse.y (make_nested_class_name): Remove extraneous `else'; fix + formatting. Changed return type. + (anonymous_class_counter): Moved to top of file. + (maybe_make_nested_class_name): Append number to class name for + function-local classes. + +2002-05-28 Zack Weinberg <zack@codesourcery.com> + + * decl.c, jcf-parse.c, parse.y, typeck.c: Include real.h. + * Make-lang.in: Update dependency lists. + +2002-05-18 Mark Mitchell <mark@codesourcery.com> + + * gjavah.c (throwable_p): Do not free the name of the class after + passing it to find_class. + * java-tree.h (CLASS_BEING_LAIDOUT): Remove duplicate definition. + * jcf-io.c (dirent.h): Include it. + (fnmatch.h): Likewise. + (compare_path): New function. + (java_or_class_file): Likewise. + (memoized_dirlist_entry): New type. + (memoized_dirlist_lookup_eq): New function. + (memoized_dirlists): New variable. + (caching_stat): New function. + (memoized_class_lookup_eq): New function. + (memoized_class_lookups): Likewise. + (find_class): Use memoized_class_lookups and caching_stat. + * jcf.h (JCF_USE_SCANDIR): Define. + * parse.y (java_expand_classes): Write the class files in reverse + order. + +2002-05-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + * Make-lang.in: Allow for PWDCMD to override hardcoded pwd. + +2002-05-13 Mark Mitchell <mark@codesourcery.com> + + * jcf-write.c (write_classfile): Unlink the temporary file if it + cannot be renamed. Use concat to build up the name of the + temporary file. + +2002-05-08 Mark Mitchell <mark@codesourcery.com> + + * jcf-write.c (write_classfile): Write the file to a + temporary file and then rename it. + +2002-05-07 Tom Tromey <tromey@redhat.com> + + * gjavah.c (throwable_p): Use xstrdup, not strdup. + + Fix for PR java/1200: + * gjavah.c (throwable_p): New function. + (decode_signature_piece): Use it. A `WeakReference' isn't the + same as a `jweak'. + Include hashtab.h. + (gcjh_streq): New function. + +2002-05-07 Andreas Jaeger <aj@suse.de> + + * parse.y (finish_for_loop): Fix if statement. + +2002-05-06 Tom Tromey <tromey@redhat.com> + + Fix for PR java/5941: + * parse.y (finish_for_loop): Set SUPPRESS_UNREACHABLE_ERROR for + loop update expression. + (java_complete_lhs): Use SUPPRESS_UNREACHABLE_ERROR. + * java-tree.h (SUPPRESS_UNREACHABLE_ERROR): New macro. + +2002-05-04 Mark Wielaard <mark@klomp.org> + + For PR java/6519: + * parse.y (build_string_concatenation): Return just op1 only when op2 + is null and op1 is a STRING_CST, otherwise always construct a + StringBuffer. + +2002-04-27 Tom Tromey <tromey@redhat.com> + + For PR java/6382: + * parse.y (string_convert_int_cst): New function. + (merge_string_cste): Use it. + +2002-04-25 Neil Booth <neil@daikokuya.demon.co.uk> + + * java-tree.h (java_parse_file): Update. + (java_set_yydebug): Remove. + * jcf-parse.c (yydebug): Remove. + (java_set_yydebug): Die. + (java_parse_file): Update. + * lang.c (LANG_HOOKS_SET_YYDEBUG): Remove. + +2002-04-24 Tom Tromey <tromey@redhat.com> + + For PR java/6425: + * parse.y (qualify_ambiguous_name) [case CALL_EXPR]: Always choose + EXPR_WFL_QUALIFICATION of qual_wfl. + +2002-04-23 Per Bothner <per@bothner.com> + + * expr.c (PRE_JSR): Call NOTE_LABEL for return address. + * java-tree.h (BCODE_RETURN_TARGET): Removed - never set. + (BCODE_TARGET): Remove BCODE_RETURN_TARGET. + +2002-04-23 Tom Tromey <tromey@redhat.com> + + For PR java/6314: + * jvspec.c (lang_specific_driver): Use --resource, not -R. Also + recognize `-fcompile-resource='. + * gcj.texi (Invoking gcj): Use --resource, not -R. Expanded text + a bit. + +2002-04-22 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jcf-parse.c: (yyparse): Don't prepend "./" to relative + paths. Fixes PR java/2791. + +2002-04-19 Andrew Haley <aph@redhat.com> + + * jcf-write.c (push_long_const): lo, hi: New variables. + Use rshift_double to extract the high part of a 64-bit long. + Use WORD_TO_INT to extract the low part. + + * jcf-parse.c (get_constant): CONSTANT_Integer: Use an unsigned + HOST_WIDE_INT for num. Use JPOOL_UINT to get it. + CONSTANT_Double: Use JPOOL_UINT to get both halve of a double. + +2002-04-18 Neil Booth <neil@daikokuya.demon.co.uk> + + * typeck.c (incomplete_type_error): Remove. + +2002-04-18 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * class.c (make_class_data): Set DECL_ALIGN on static class data, + for hash synchronization. + * expr.c (java_expand_expr): Set DECL_ALIGN on static array objects. + * decl.c (java_init_decl_processing): Don't set TYPE_ALIGN for + class_type_node. + +2002-04-16 Mark Wielaard <mark@klomp.org> + + * jcf-write.c (generate_bytecode_insns): Only write const_0 if not + negative zero. + +2002-04-16 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + Fix for PR java/6294: + * parse.h (INNER_INTERFACE_MODIFIERS): Allow ACC_PRIVATE for inner + interfaces. + +2002-04-15 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + Fix for PR java/6085: + * parse.y (patch_method_invocation): Always use build_access_to_thisn + to get enclosing "this" argument for inner-class constructor + invocation. Pass correct arguments to build_access_to_thisn. + +2002-04-10 Andreas Jaeger <aj@suse.de> + + * gcj.texi (Input Options): Fix extdirs patch. + +2002-04-10 Anthony Green <green@redhat.com> + + * jcf-path.c (jcf_path_init) : Clean up local extdirs declaration. + +2002-04-09 Anthony Green <green@redhat.com> + + * gcj.texi (Input Options): Add --extdirs documentation. + * jcf-dump.c (OPT_extdirs): New macro. + (options): Add extdirs option. + (help): Describe --extdirs. + (main): Handle OPT_extdirs. + * gjavah.c (OPT_extdirs): New macro. + (options): Add extdirs option. + (help): Describe --extdirs. + (main): Handle OPT_extdirs. + * jcf-path.c (jcf_path_init): Add extdirs support. + (jcf_path_extdirs_arg): New function. + (extensions): New variable to hold extensions path entries. + * jvspec.c: Remove -fextdirs= when compiling main(). + * lang.c (java_decode_option): Handle -fextdirs=. + * jcf.h (jcf_path_extdirs_arg): Declare new function. + * Make-lang.in: Compile jcf-path with version info for use in + identifying the appropriate libgcj.jar. + +2002-04-08 Tom Tromey <tromey@redhat.com> + + For PR libgcj/5303: + * .cvsignore: Added rmic.1 and rmiregistry.1. + * gcj.texi (Top): Link to new nodes. + (Invoking rmic): New node. + (Invoking rmiregistry): Likewise. + * Make-lang.in (java.generated-manpages): Added rmic.1 and + rmiregistry.1. + (java.maintainer-clean): Likewise. + ($(srcdir)/java/rmic.1): New target. + ($(srcdir)/java/rmiregistry.1): Likewise. + (java.install-man): Handle rmic.1 and rmiregistry.1. + +2002-04-08 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * gcj.texi (Invocation): Update JvAttachCurrentThread documentation. + Add note about handling uncaught exceptions. Add an exception handler + to example. + +2002-04-08 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (resolve_qualified_expression_name): Clear "from_super" flag + after using it to patch CALL_EXPR. + +2002-04-08 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * gcj.texi (Invocation): Document CNI invocation API. + +2002-04-04 Neil Booth <neil@daikokuya.demon.co.uk> + + * expr.c (truthvalue_conversion): Rename. Update. + (expand_compare): Update. + * java-tree.h (java_truthvalue_conversion): New. + * lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine. + +2002-04-01 Neil Booth <neil@daikokuya.demon.co.uk> + + * java-tree.h (java_mark_addressable): New. + * lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine. + * typeck.c (mark_addressable): Rename, update. + +2002-04-01 Neil Booth <neil@daikokuya.demon.co.uk> + + * expr.c (build_java_binop): Update. + * java-tree.h (java_signed_type, java_unsigned_type, + java_signed_or_unsigned_type): Update. + * lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE, + LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New. + * parse.y (patch_binop): Update. + * typeck.c (signed_or_unsigned_type, unsigned_type, + signed_type): Update. + +2002-03-31 Neil Booth <neil@daikokuya.demon.co.uk> + + * lang.c (LANG_HOOKS_PRINT_ERROR_FUNCTION): Redefine. + (java_dummy_print): Remove. + (lang_print_error): Rename. Exit early if inhibiting output. + (inhibit_error_printing_function): New. + (java_init): Don't set hook. + (lang_init_source): Use new boolean. + +2002-03-29 Martin Kahlert <martin.kahlert@infineon.com> + + * parse.y (do_resolve_class): Fix infinite recursion. + +2002-03-29 Tom Tromey <tromey@redhat.com> + + * parse.y (check_inner_circular_reference): Ignore incomplete + types. + +2002-03-29 Neil Booth <neil@daikokuya.demon.co.uk> + + * Make-lang.in (builtins.o): Update. + * boehm.c (get_boehm_type_descriptor): Update. + * builtins.c: Include langhooks.h. + * decl.c (java_init_decl_processing): Update. + * java-tree.h (java_type_for_mode, java_type_for_size): New. + * lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE): + Redefine. + * typeck.c (type_for_mode, type_for_size): Update. + +2002-03-29 Martin Kahlert <martin.kahlert@infineon.com> + + * lex.c (java_new_lexer): Alias "646" to DEFAULT_ENCODING. + +2002-03-28 Tom Tromey <tromey@redhat.com> + + * except.c (expand_end_java_handler): If the handler type is NULL, + use java.lang.Throwable. Fixes PR java/5986. + +2002-03-28 Alexandre Petit-Bianco <apbianco@redhat.com> + + Fix for PR java/4715: + * jcf-parse.c (parse_source_file_3): New function. + (read_class): Call it. + (java_parse_file): Likewise. + +2002-03-28 Jan Hubicka <jh@suse.cz> + + * java/lang.c (java_init_options): Set flag_trapping_math to 0. + +2002-03-28 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (resolve_package): Initialize "decl". + (lookup_package_type): Remove unused function. + +2002-03-28 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + Fix for PR java/5993: + * parse.y (resolve_package): Return the decl if resolution was + successful. Don't special case "java.lang" and "java.lang.reflect" + packages. Set type_name to the merged identifier. + (resolved_qualified_expression_name): Print error using "name" if + resolve_package returns NULL_TREE. + +2002-03-27 Tom Tromey <tromey@redhat.com> + + * expr.c (expand_invoke): Don't generate null pointer check if + we're calling <init>. + +2002-03-27 Neil Booth <neil@daikokuya.demon.co.uk> + + * expr.c (java_lang_expand_expr): Rename java_expand_expr, + fix prototype. + * java-tree.h (java_lang_expand_expr): Similarly. + * lang.c (LANG_HOOKS_EXPAND_EXPR): Redefine. + (java_init): Don't set hook. + +2002-03-27 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + Fix for PR java/5850: + * parse.y (lookup_field_wrapper): Call itself recursively for enclosing + context if field was not found in the current scope. + * expr.c (lookup_field): Don't look in enclosing contexts. + +2002-03-26 Tom Tromey <tromey@redhat.com> + + Fix for PR java/5942: + * parse.y (init_src_parse): Added sanity check. + * parse.h (struct parser_ctxt) [modifier_ctx]: Array has 12 + elements, not 11. + +2002-03-26 Neil Booth <neil@daikokuya.demon.co.uk> + + * decl.c (lang_mark_tree): Rename java_mark_tree. + * java-tree.h (java_mark_tree): New. + * java-lang.c (LANG_HOOKS_MARK_TREE): Redefine. + +2002-03-25 Zack Weinberg <zack@codesourcery.com> + + * lex.c: Change java_perform_atof to take normal parameters + instead of a pointer to a parameter block. Call it directly + from java_lex. + +2002-03-22 Mark Wielaard <mark@klomp.org> + + Fix for PR java/5368: + * parse.y (resolve_qualified_expression_name): Use decl not field_decl + when printing error message. + +2002-03-25 Neil Booth <neil@daikokuya.demon.co.uk> + + * decl.c (maybe_build_cleanup): Remove. + +2002-03-22 Tom Tromey <tromey@redhat.com> + + Andrew Haley <aph@cambridge.redhat.com> + + * expr.c (build_field_ref): Don't build a check if the field is a + member of `this'. + +2002-03-21 Eric Blake <ebb9@email.byu.edu> + + Fix for PR java/6026: + * lex.c (java_lex): Fix parsing of consecutive floats. + +2002-03-21 Tom Tromey <tromey@redhat.com> + + * parse.y (build_access_to_thisn): Stop when FROM is not an inner + class. + +2002-03-21 Neil Booth <neil@daikokuya.demon.co.uk> + + * cp-tree.h (pushdecl, pushlevel, poplevel, set_block, + insert_block, getdecls, kept_level_p, global_bindings_p): New. + +2002-03-20 Nic Ferrier <nferrier@tapsellferrier.co.uk> + + * gcj.texi: @code{gcj} becomes @command{gcj}. + @code{gcc} becomes @command{gcc}. + GcjRaw changed to gnu.gcc.RawData. + +2002-03-20 Neil Booth <neil@daikokuya.demon.co.uk> + + * decl.c (start_java_method): Use new hook. + * lang.c (LANG_HOOKS_DECL_PRINTABLE_NAME): Redefine. + (java_init): Remove old hook. + +2002-03-18 Alexandre Petit-Bianco <apbianco@redhat.com> + + * builtins.c (define_builtin): Do nothing if `type' is null. + Fixes PR java/5876. + +2002-03-18 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (parser_check_super_interface): Fix error message + grammar/order. + +2002-03-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-parse.c (get_constant): Delete unused variables. + +2002-03-17 Neil Booth <neil@daikokuya.demon.co.uk> + + * java-tree.h (java_parse_file): New. + * jcf-parse.c (yyparse): Rename java_parse_file. + * lang.c (LANG_HOOKS_PARSE_FILE): Redefine. + +2002-03-16 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (craft_constructor): Return the constructor decl. + (java_expand_classes): Update comments. + (lookup_method_invoke): Call fix_constructors immediately for + anonymous class. Fixes PR java/5935. + +2002-03-15 Anthony Green <green@redhat.com> + + * jcf-parse.c (yyparse): Don't emit class registration + constructor when compiling resource files. + +2002-03-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lang.c (java_tree_code_type, java_tree_code_length, + tree_code_name): Delete. + (tree_code_type, tree_code_length, tree_code_name): Define. + (java_init): Don't try to copy into the various tree_code + arrays. + +2002-03-12 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (get_constant) [CONSTANT_String]: String values are + UTF-8, not UCS-2. Fixes PR java/5923. + + * parse.y (qualify_ambiguous_name): Handle case where QUAL_WFL is + a call_expr wrapped in a convert. Fixes PR java/5848. + +2002-03-12 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * jcf-write.c (write_classfile): Improve error strings. + +2002-03-11 Eric Blake <ebb9@email.byu.edu> + + * lex.c: Adjust comments to GNU standards. + +2002-03-11 Eric Blake <ebb9@email.byu.edu> + + Fix for PR java/5902: + * lex.c (java_lex): Fix parsing of literals. + +2002-03-11 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (patch_assignment): Wrap the right-hand-side with a save_expr + to prevent it getting evaluated twice in the store checking case. + * expr.c (build_java_arraystore_check): Unwrap SAVE_EXPR's when + examining OBJECT. + +2002-03-09 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * decl.c (java_init_decl_processing): Make sure class_type_node + alignment is not less than 64 bits if hash synchronization is enabled. + +2002-03-08 Per Bothner <per@bothner.com> + + * parse.y (java_complete_lhs): Check if patch_assignment + returned an error-mark. + + * parse.y (try_builtin_assignconv): Don't special-case zero. + +2002-03-08 Per Bothner <per@bothner.com> + + Fix for PR java/5812. + * expr.c (build_java_jsr): Take pc arguments, and do lookup_label + here instead of in JSR macro. Likewise with load_type_state call. + Do the latter on if the return_pc has been verified (the jsr returns). + (JSR): Now just call build_java_jsr. + +2002-03-07 Jeff Sturm <jsturm@one-point.com> + + * java/Make-lang.in (JAVA_TARGET_INSTALL_NAME): Define. + (java.install-common): Link native driver to + JAVA_TARGET_INSTALL_NAME. + +2002-03-05 David Billinghurst <David.Billinghurst@riotinto.com> + + * builtins.c(cos_builtin): method_return_type ATTRIBUTE_UNUSED + * builtins.c(sin_builtin): Likewise + * builtins.c(sqrt_builtin): Likewise + +2002-03-03 Zack Weinberg <zack@codesourcery.com> + + * java/expr.c, java/jcf-parse.c, java/lex.c: + Remove all #ifndef REAL_ARITHMETIC blocks, make all #ifdef + REAL_ARITHMETIC blocks unconditional. Delete some further + #ifdef blocks predicated on REAL_ARITHMETIC. + +2002-03-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (init_class_processing): Use ARRAY_SIZE in lieu of + explicit sizeof/sizeof. + * decl.c (java_init_decl_processing): Likewise. + * jcf-parse.c (init_jcf_parse): Likewise. + * parse.y (init_src_parse): Likewise. + +2002-03-02 Per Bothner <per@bothner.com> + + Make --CLASSPATH by a synonym for --classpath and -classpath. + Implement --bootclasspath. + * jcf-path.c (classpath_u): Rename static variable to classpath_user. + (classpath_l): Remove. + (jcf_path_CLASSPATH_arg): Remove. + (jcf_path_bootclasspath_arg): New function. + (jcf_path_seal): Simplify accordingly. + + * jcf.h (jcf_path_bootclasspath_arg): New declarations. + (jcf_path_CLASSPATH): Remove declaration. + * jvspec.c (jvgenmain_spec): Also accept -fbootclasspath*. + (lang_specific_driver): Translate -bootclasspath. + * lang-options.h: Add --bootclasspath. Update --CLASSPATH. + * lang.c (decode_lang_options): Do jcf_path_init first. + Handle -fCLASSPATH same as -fclasspath. Also process -fbootclasspath. + * gjavah.c: Also handle --bootclasspath. + Handle --CLASSPATH as a synonum for --classpath. + * jcf-dump.c: Likewise. + + "." is not part of system path, but is the default for --classpath. + * jcf-path.c (jcf_path_init): Don't add "." to sys_dirs. + (jcf_path_seal): Add "." if no CLASSPATH specified. + + * gcj.texi: Document changes. + +2002-03-01 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * expr.c (build_java_arraystore_check): Fix formatting. + +2002-02-28 Alexandre Petit-Bianco <apbianco@redhat.com> + + Fix for PR java/5758, java/5632: + * jcf-parse.c (load_class): Renamed local variable, consider `.' an + inner-class separator too. + * parse.y (do_resolve_class): New local `decl_result.' + Progressively build a name for what can have been loaded. + +2002-02-28 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * expr.c (java_array_data_offset): Removed function. + (JAVA_ARRAY_LENGTH_OFFSET): Removed macro. + (build_java_array_length_access): Obtain "length" value using a + COMPONENT_REF, instead of INDIRECT_REF and arithmetic. + (build_java_arrayaccess): Correct comment. Access "data" using a + COMPONENT_REF, and return an ARRAY_REF instead of an INDIRECT_REF. + (build_java_arraystore_check): New function. + (expand_java_arraystore): Use build_java_arraystore_check. + * parse.y (patch_assignment): Simplify code to insert a store check + when lvalue is an ARRAY_REF. Use build_java_arraystore_check. + * check-init.c (check_init): Update to reflect that an array length + access is now a COMPONENT_REF. + * gcj.texi (Code Generation): Improve documentation of + -fno-bounds-check. Add documentation for -fno-store-check. + * java-tree.h (flag_store_check): Declare. + (build_java_arraystore_check): Declare. + * lang.c (flag_store_check): Initialize to 1. + (lang_f_options): Add store-check option. + * jvspec.c: Don't pass store-check option to jvgenmain. + * lang-options.h: Add help string for -fno-store-check. + +2002-02-28 Neil Booth <neil@daikokuya.demon.co.uk> + + * decl.c (copy_lang_decl): Rename java_dup_lang_specific_decl. + * java-tree.h (java_dup_lang_specific_decl): New. + * lang.c (LANG_HOOKS_DUP_LANG_SPECIFIC_DECL): Redefine. + +2002-02-27 Zack Weinberg <zack@codesourcery.com> + + * builtins.c, decl.c: Delete traditional-mode-related code + copied from the C front end but not used, or used only to + permit the compiler to link. + +2002-02-22 Tom Tromey <tromey@redhat.com> + + Fix for PR java/2369: + * jvspec.c (verify_class_name): New function. + (lang_specific_driver): Call it. + (JAVA_START_CHAR_P): New macro. + (JAVA_PART_CHAR_P): Likewise. + +2002-02-22 Per Bothner <per@bothner.com> + + * class.c: Change vtable to be more compatible with g++ v3 abi. + (get_dispatch_table): Prepend offset-to-top (always 0) and + type_info pointer (currently unimplemented hence NULL) to vtable. + Specifically, prepend offset-to-top and typeinfo ptr (currently null). + (make_class_data): Variable dtable_start_offset is sizeof 2 pointers. + Adjust vtable pointers by dtable_start_offse - i.e. skip new words. + (build_dtable_decl): Add declarations for new fields. + +2002-02-20 Per Bothner <per@bothner.com> + + * parse.y (patch_method_invocation): Set CAN_COMPLETE_NORMALLY on call + to finit$ (otherwise generate_bytecode_insns drops it). However, we + don't need to set it on the COMPOUND_EXPR - the caller does that. + +2002-02-20 Nic Ferrier <nferrier@tapsellferrier.co.uk> + + * gcj.texi: Option `--classpath' becomes `--CLASSPATH.'Option + `--CLASSPATH' becomes `--classpath.' + * gjavah.c: Likewise. + * jcf-dump.c: Likewise. + * lang-options.h: Likewise. + * lang.c: Likewise. + * jcf-path.c: Updated comment. + (jcf_path_classpath_arg): Renamed `jcf_path_CLASSPATH_arg.' + (jcf_path_CLASSPATH_arg): Renamed `jcf_path_classpath_arg.' + * jcf.h (jcf_path_CLASSPATH_arg): Ditto. + (jcf_path_CLASSPATH_arg): Ditto. + (classpath_u): Updated leading comment. + +2002-02-20 Per Bothner <per@bothner.com> + + * builtins.c (check_for_builtin): New function. + (build_call_or_builtin): Remove. + * java-tree.h: Update accordingly. + * expr.c (expand_invoke): Use build + check_for_builtin instead + of build_call_or_builtin. + * parse.y (patch_invoke): Likewise. This avoids needlessly creating + a new CALL_EXPR node, which means we don't lose the CALL_USING_SUPER + flag (which had caused jcf-write to incorrectly emit invokevirtual). + +2002-02-17 Tom Tromey <tromey@redhat.com> + + * java-tree.h (TYPE_STRICTFP): New macro. + (struct lang_type) [strictfp]: New field. + (CLASS_STRICTFP): New macro. + (METHOD_STRICTFP): New macro. + (struct lang_decl) [strictfp]: New field. + * parse.y (method_header): Disallow strictfp constructor or + abstract method. + (STRICT_TK): Move before MODIFIER_TK. + * parse.h (CLASS_MODIFIERS): Added ACC_STRICT. + (METHOD_MODIFIERS): Likewise. + (INTERFACE_MODIFIERS): Likewise. + * jcf-write.c (get_access_flags): Likewise. + * class.c (set_class_decl_access_flags): Recognize ACC_STRICT. + (add_method_1): Likewise. + (get_access_flags_from_decl): Likewise. + * jcf-dump.c (print_access_flags): Print in standard order. Also, + recognize strictfp flag. + * jcf.h (ACC_STRICT): New define. + +2002-02-12 David Billinghurst <Davod.Billinghurst@riotinto.com> + + * class.c(build_utf8_ref): Move declaration of decl_size + +2002-02-07 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Input Options): --CLASSPATH does not suppress system + path. + +2002-02-04 Anthony Green <green@redhat.com> + + * class.c (build_utf8_ref): Put UTF-8 constants into merged + sections if available. + +2002-02-04 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (java_expand_classes): Fix typo in static field loop. + +2002-02-02 Richard Henderson <rth@redhat.com> + + * class.c (add_field): Mark static fields external. + (build_class_ref): Remove redundant set. + * parse.y (java_expand_classes): Mark static fields of classes + to be compiled as local. + * jcf-parse.c (parse_class_file): Likewise. + +2002-02-02 Nic Ferrier <nferrier@tapsellferrier.co.uk> + + * gcj.texi (About CNI): New node. + +2002-02-01 Craig Rodrigues <rodrigc@gcc.gnu.org> + + PR java/5080 + * jcf-parse.c : Check for HAVE_LOCALE_H before using + setlocale() with LC_CTYPE as a parameter. + * jv-scan.c: Same. + +2002-01-31 Joseph S. Myers <jsm28@cam.ac.uk> + + * gjavah.c (version), jcf-dump.c (version), jv-scan.c (version): + Follow GNU Coding Standards for --version. + +2002-01-28 Tom Tromey <tromey@redhat.com> + + * expr.c (build_jni_stub): Ensure storage for `meth' is + generated. + * parse.y (java_complete_expand_methods): Set + current_function_decl before building JNI stub. + +2002-01-26 Andreas Tobler <a.tobler@schweiz.ch> + + * gcc/java/builtins.c (sqrt_builtin): Use BUILT_IN_SQRT, not + BUILT_IN_SQRTF. + +2002-01-22 Tom Tromey <tromey@redhat.com> + + * decl.c (java_init_decl_processing): Use add_predefined_file. + Predefine RawData.java. + (predef_filenames): Removed. + (java_init_decl_processing): Don't register predef_filenames. + * jcf-parse.c (add_predefined_file): New function. + (predefined_filename_p): Rewrote. + (predefined_filename_p): No longer static. + * decl.c (java_init_decl_processing): Call initialize_builtins. + * Make-lang.in (JAVA_OBJS): Added builtins.o. + (java/builtins.o): New target. + * builtins.c: New file. + * parse.y (patch_invoke): Use build_call_or_builtin. + * java-tree.h (build_call_or_builtin): Declare. + (initialize_builtins): Declare. + (java_set_exception_lang_code): Removed unused declaration. + (PREDEF_FILENAMES_SIZE): Removed. + (java_tree_index): Added JTI_PREDEF_FILENAMES. + (predef_filenames): New define. + (add_predefined_file): Declare. + (predefined_filename_p): Declare. + * expr.c (expand_invoke): Use build_call_or_builtin. + +2002-01-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * parse.y (patch_switch_statement): Fix format specifier. + +2002-01-16 Tom Tromey <tromey@redhat.com> + + More for PR java/5365: + * gjavah.c (print_stub_or_jni): Cause exception to be thrown by + default. + (process_file): Generate include for + java.lang.UnsupportedOperationExceptions. + +2002-01-15 Andreas Jaeger <aj@suse.de> + + * .cvsignore: Add man pages. + +2002-01-15 Tom Tromey <tromey@redhat.com> + + Fix for PR java/5365: + * gjavah.c (process_file): Turn class name into a file name. + +2002-01-14 Matthias Klose <doko@debian.org> + + * gcj.texi: Fix whitespace and formatting errors in the + synopsis of the man pages. Update copyright. + +2002-01-14 Tom Tromey <tromey@redhat.com> + + For PR libgcj/5303: + * Make-lang.in (java.install-man): Handle jv-convert man page. + (java.generated-manpages): Added jv-convert.1. + (java.uninstall): Remove jv-convert.1. + (java.maintainer-clean): Likewise. + ($(srcdir)/java/jv-convert.1): New target. + * gcj.texi (Top): Link to jv-convert node. + (Individual utilities): Likewise. + (Invoking jv-convert): New node. + +2001-01-10 Jeff Sturm <jsturm@one-point.com> + Martin Kahlert <martin.kahlert@infineon.com> + + * jcf-parse.c (get_constant): Don't swap lo/hi for big + endian targets when HOST_BITS_PER_WIDE_INT >= 64. + +2002-01-03 Graham Stott <grahams@redhat.com> + + * class.c (compile_resource_file): Update copyright date. + Constify filename parameter. + (java-tree.h): Update copyright date. + (compile_resource_file): Constify filename parameter. + +2002-01-03 Graham Stott <grahams@redhat.com> + + * gcc/jcf-parse.c: Update copyright date. + (yyparse): Constify resource_filename. + +2002-01-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * parse.y (src_parse_roots): Don't needlessly zero init. + +2001-12-31 Tom Tromey <tromey@redhat.com> + + * parse.y (dump_java_tree): New function. + (source_end_java_method): Call it. + (end_class_declaration): Likewise. + * lang.c (java_decode_option): Call dump_switch_p. + +2001-12-28 Tom Tromey <tromey@redhat.com> + + * gen-table.pl: Don't process characters after \uffff. Added + comment pointing to input file. + +2001-12-28 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gen-table.pl: Const-ify output. Document the location of a + suitable unicode input file. + + * chartables.h: Regenerate. + +2001-12-26 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * chartables.h: Const-ify. + * gjavah.c (options): Likewise. + * jcf-dump.c (options): Likewise. + * jv-scan.c (options): Likewise. + * lex.c (java_start_char_p, java_part_char_p): Likewise. + * parse.y (binop_lookup): Likewise. + +2001-12-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (keyword.h): Pass -C to gperf to const-ify + the static arrays that are output. + * jvspec.c (jvgenmain_spec): Make static. + * keyword.gperf (struct java_keyword, java_keyword): Const-ify. + * keyword.h: Regenerate. + * lang.c (string_option, process_option_with_no, lang_f_options, + lang_W_options): Const-ify. + * lex.c (java_lex): Likewise. + +2001-12-21 Richard Henderson <rth@redhat.com> + + * boehm.c (PROCEDURE_OBJECT_DESCRIPTOR): Merge into .. + (get_boehm_type_descriptor): ... here. Arrange for the + TREE_TYPE to get set properly. + +2001-12-21 Richard Henderson <rth@redhat.com> + + * class.c (compile_resource_file): Set TREE_PUBLIC on the constructor + only if the target requires collect2. + + * class.c (build_class_ref): Mark _Jv_fooClass DECL_EXTERNAL. + +2001-12-20 Tom Tromey <tromey@redhat.com> + + For PR java/4509: + * parse.y (java_complete_lhs) [COMPOUND_EXPR]: Correctly compute + CAN_COMPLETE_NORMALLY for the node. + * jcf-write.c (generate_bytecode_insns) [COMPOUND_EXPR]: Don't + generate code for second branch if first branch can't complete + normally. + (generate_bytecode_insns) [LOOP_EXPR]: Don't generate `goto' to + the loop head if the loop body can't complete normally. + +2001-12-20 Tom Tromey <tromey@redhat.com> + + For PR java/4766: + * jcf-write.c (generate_bytecode_insns) [TRY_FINALLY_EXPR]: Handle + case where `finally' clause can't complete normally. + +2001-12-20 Tom Tromey <tromey@redhat.com> + + Fixes PR java/5057: + * parse.y (analyze_clinit_body): Added this_class parameter. + Check for more cases where we must keep <clinit>. + (maybe_yank_clinit): Cleaned up flow control. + +2001-12-20 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * decl.c (java_init_decl_processing): Don't initialize + finit_leg_identifier_node. + * java-tree.h (java_tree_index): Remove JTI_FINIT_LEG_IDENTIFIER_NODE. + (finit_leg_identifier_node): Remove. + (ID_FINIT_P): Don't check for JTI_FINIT_LEG_IDENTIFIER_NODE. + +2001-12-20 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * mangle.c (mangle_member_name): Don't special-case for + NO_DOLLAR_IN_LABEL. + * mangle_name.c (unicode_mangling_length): Likewise. + (append_unicode_mangled_name): Likewise. + * parse.y (make_nested_class_name): Remove dead NO_DOLLAR_IN_LABEL + code. + +2001-12-20 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * expr.c (build_java_array_length_access): Don't force null pointer + check unless flag_check_references is set. + +2001-12-20 Tom Tromey <tromey@redhat.com> + + Fix for PR java/3417: + * parse.y (patch_assignment): Added special processing for + `return'. + (patch_return): Don't convert booleans to integers, and don't + special-case `null'. + +2001-12-20 Joseph S. Myers <jsm28@cam.ac.uk> + + * config-lang.in (diff_excludes): Remove. + +2001-12-17 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcj.texi: Update link to GCC manual. + +2001-12-17 Tom Tromey <tromey@redhat.com> + + * parse.y (link_nested_class_to_enclosing): Removed useless + statement. + +2001-12-16 Tom Tromey <tromey@redhat.com> + + * mangle.c (mangle_method_decl): Never emit `C2' constructor. + Fixes PR java/5088. + +2001-12-16 Joseph S. Myers <jsm28@cam.ac.uk> + + * ChangeLog, Make-lang.in, class.c, expr.c, gcj.texi, java-tree.h, + jcf-parse.c, jcf-write.c, lex.c, parse.h, parse.y, verify.c: Fix + spelling errors. + +2001-12-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lex.c (java_read_unicode, java_lex): Use hex_p/hex_value. + +2001-12-16 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * decl.c (java_init_decl_processing): Build otable_type correctly. + otable_decl is an otable_type. + +2001-12-15 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * java-tree.h (otable_methods, otable_decl, otable_syms_decl, + otable_type, otable_ptr_type, method_symbol_type, + method_symbols_array_type, method_symbols_array_ptr_type): New + field/global tree definitions. + (flag_indirect_dispatch): New flag. + * decl.c (java_init_decl_processing): Initialize new otable and + otable_syms type nodes and decls. Add new field "index" to + method_type_node. + * class.c (build_method_symbols_entry): New function. + (make_method_value): Set "index" to to method's vtable index for + virtual methods when indirect-dispatch is not used. + (make_class_data): For indirect-dispatch, don't emit the dtable_decl, + and set vtable_method_count to -1. Set otable and otable_syms field + if indirect-dispatch is used and there was something to put in them. + (build_method_symbols_entry): New function. + (emit_offset_symbol_table): New function. + * expr.c (get_offset_table_index): New function. + (build_invokevirtual): Build array reference to otable at the index + returned by get_offset_table_index, and use the result as the vtable + offset. + (build_invokeinterface): Similar. + * jcf-parse.c (yyparse): If indirect-dispatch, call + emit_offset_symbol_table at the end of compilation, after all classes + have been generated. + * jvspec.c: Don't pass findirect-dispatch to jvgenmain. + * lang.c (flag_indirect_dispatch): Define. + (lang_f_options): Add indirect-dispatch flag. + +2001-12-14 Matthias Klose <doko@debian.org> + + * gcj.texi: Markup for man page generation. Document missing + options printed by <tool> --help. + Terminate description of gij's -ms option with a dot. + * Make-lang.in ($(srcdir)/java/*.1): New targets. + (java.generated-manpages java.install-man, java.uninstall, + java-maintainer-clean) Updated. + +2001-12-14 Hans Boehm <Hans_Boehm@hp.com> + + * class.c (get_dispatch_table): Fix java vtable layout + for TARGET_VTABLE_USES_DESCRIPTORS. + * decl.c (java_init_decl_processing): Initialize + alloc_no_finalizer_node, finalize_identifier_node. + * expr.c (class_has_finalize_method): New function. + (expand_java_NEW): Generate calls for finalizer-free allocation. + (build_invokevirtual): Fix java vtable layout for + TARGET_VTABLE_USES_DESCRIPTORS. + * java-tree.h (enum java_tree_index): New entries: + JTI_ALLOC_NO_FINALIZER_NODE, JTI_FINALIZE_IDENTIFIER_NODE. + (alloc_no_finalizer_node, finalize_deintifier_node): New macros. + (class_has_finalize_method): declare. + (HAS_FINALIZER_P): New macro. + * parse.y (patch_invoke): Generate calls for finalizer-free + allocation. + +2001-12-12 Matthias Klose <doko@debian.org> + + * Make-lang.in: JAVA_INSTALL_NAME, JAVA_CROSS_NAME: Remove + whitespace at end of line. + +2001-12-11 Tom Tromey <tromey@redhat.com> + + * lex.c (java_init_lex): Define wfl_to_string as + gnu.gcj.runtime.StringBuffer unless generating bytecode. + +2001-12-11 Jeff Sturm <jsturm@one-point.com> + + * class.c (make_method_value): Use null_pointer_node to + represent empty exception table. + +2001-12-10 Tom Tromey <tromey@redhat.com> + + * check-init.c (check_init) [SWITCH_EXPR]: Use SWITCH_HAS_DEFAULT. + +2001-12-10 Douglas B. Rupp <rupp@gnat.com> + + * Make-lang.in (jvspec.o): Add $(OUTPUT_OPTION). + +2001-12-09 Per Bothner <per@bothner.com> + + * check-init.c (current_switch_has_default): New static field. + (check_init): Case DEFAULT_EXPR: Set current_switch_has_default. + Case SWITCH_EXPR: Save/restore current_switch_has_default. If no + DEFAULT_EXPR seen, simulate a default alternative that copies state. + +2001-12-09 Tom Tromey <tromey@redhat.com> + + * check-init.c (check_init): Don't allow pre- or post- increment + or decrement of final variable. + (final_assign_error): Minor error message rewording. + +2001-12-08 Tom Tromey <tromey@redhat.com> + + * java-tree.h: Fixed typo. + + * gjavah.c (decompile_method): Don't decompile to `return this' + for static methods. + + * gjavah.c (cxx_keywords): Re-sorted. + * lex.c (cxx_keywords): Re-sorted. + + * gjavah.c (HANDLE_METHOD): Set `decompiled' before doing anything + else. + + * gjavah.c (print_namelet): Clear subnamelets. + (HANDLE_METHOD): Set `method_printed' earlier. + +2001-12-07 Tom Tromey <tromey@redhat.com> + + * lang.c (lang_f_options): Added + optimize-static-class-initialization. + (java_decode_option): Removed special case. + +2001-12-07 Per Bothner <per@bothner.com> + + * check-init.c (check_init): Fix typo freeing memory twice. + +2001-12-05 Per Bothner <per@bothner.com> + + Restore support for static class initialization optimization. + * java-tree.h (STATIC_CLASS_INIT_OPT_P): Re-enable. + * check-init.c (check_int): At end of BLOCK handle initialization + blocks, which used to be done in java_complete_expand_method but did + not handle the case where check_for_initialization might allocate + more than a word of bits. + * decl.c (lang_make_tree): The smic field is now a tree. + * expr.c (build_class_init): Set DECL_FUNCTION_INIT_TEST_CLASS field. + * java-tree.h (DECL_FUNCTION_INIT_TEST_TABLE): New macro. + + * parse.y (emit_test_initialization): Combine hash_lookup calls. + + * java-tree.h (DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND): + Change from a hash table to a list. + (struct_lang_decl): Change field 'smic' to match. + * class.c (add_method_1): Initialize + DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND to null list. + * parse.y (adjust_init_test_initialization): Removed - inlined into - + (java_expand_method_bodies): -here, since 'smic' is now a list. + (patch_invoke): Add to 'smic' list, instead of hash_lookup. + + * check-init.c (WORD_SIZE): Use BITS_PER_UNIT. + + * class.c (java_hash_compare_tree_node): Fix casts. + +2001-12-04 Per Bothner <per@bothner.com> + + * check-init.c: Handle definite unassignment to finals in addition + to definite assignment. + (loop_current_locals): New field. + (num_current_locals, int start_current_locals, num_current_words): + Make static. + (SET_P, CLEAR_P, SET_BIT): Add needed but missing parentheses. + (ASSIGNED_P, UNASSIGNED_P, SET_ASSIGNED, SET_UNASSIGNED, + CLEAR_ASSIGNED, CLEAR_UNASSIGNED): New macros. + (get_variable_decl, check_final_reassigned): New functions. + (check_init, check_bool_init): Modify as needed for checking finals. + (check_for_initialization): Take extra parameter and return void. + Do extra start-up logic to check final fields for assignment. + * parse.y (check_static_final_variable_assignment_flag, + reset_static_final_variable_assignment_flag, check_final_assignment, + check_final_variable_local_assignment_flag, + reset_final_variable_indirect_assignment_flag, + reset_final_variable_global_assignment_flag): Remove functions. + (java_complete_expand_methods, outer_field_access_fix, + patch_assignment): Remove no-longer used logic. + * java-tree.h (DECL_FIELD_FINAL_IUD): Change usage and comments. + * parse.y (register_fields, java_complete_tree): Update accordingly. + + * check-init.c (ALLOC_WORDS/FREE_WORDS): Use xmalloc/free, not alloca. + (DECLARE_BUFFERS, RELEASE_BUFFERS, ALLOC_BUFFER, FREE_BUFFER): New. + (check_cond_init, check_bool2_init): Use DECLARE_BUFFERS. + + * java-tree.h (STATIC_CLASS_INIT_OPT_P): Temporarily turn off. + + * java-tree.h (DECL FINAL): New bit-field. + (METHOD_FINAL, FIELD_FINAL, CLASS_FINAL): Define as DECL_FINAL. + (LOCAL_FINAL_P): Use DECL_FINAL rather than old LOCAL_FINAL. + (DECL_INIT_CALLS_THIS): New macro. + (struct lang_decl): New bit-field init_calls_this. + (DECL_FUNCTION_ALL_FINAL_INITIALIZED, DECL_FIELD_FINAL_LIIC, + DECL_FIELD_FINAL_IERR, LOCAL_FINAL, TYPE_HAS_FINAL_VARIABLE + (DECL_BIT_INDEX): Change to use pointer_alias_set since we now + use it for both local variables and final fields. + (struct lang_decl_var): Remove bit-fields final_liic, final_ierr, + and local_final. + (struct lang_type): Remove hfv bit-field. + (check_for_initialization): Change to return void. + + * java-tree.h (IS_ARRAY_LENGTH_ACCESS): New macros. + * expr.c (build_java_array_length_access): Set IS_ARRAY_LENGTH_ACCESS. + * check-init.c (final_assign_error): New helper function. + (check_final_reassigned, check_init): Use it. + (check_init): Also check IS_ARRAY_LENGTH_ACCESS for ARRAY.length. + + * java-tree.h (struct lang_decl, struct lang_decl_var): Change all + bit-fields to unsigned. + +2001-12-03 Per Bothner <per@bothner.com> + + * parse.y (patch_binop): Minor constant folding. + + * parse.y (build_current_thisn): Shorter 'buffer'. + +2001-12-03 Per Bothner <per@bothner.com> + + * decl.c (complete_start_java_method): Now generate TRY_FINALLY_EXPR + instead of CLEANUP_POINT_EXPR and WITH_CLEANUP_EXPR. + * jcf-write.c (generate_bytecode_insns): Remove support for + CLEANUP_POINT_EXPR and WITH_CLEANUP_EXPR as they are no longer used. + * check-init.c (check_init): Likewise. + +2001-12-03 Per Bothner <per@bothner.com> + + * verify.c (subroutine_nesting): New function. + (verify_jvm_instructions): Use it to fix logic for checking that + we're done with the current subroutine. + + * verify.c (verify_jvm_instruction): For OPCODE_checkcast and + OPCODE_instanceof use POP_TYPE macro for better diagnostics. + +2001-12-03 Per Bothner <per@bothner.com> + + * jcf.h: Fix obvious typo in comment. + * typeck.c (build_null_signature): Add comment. + +2001-12-03 Neil Booth <neil@daikokuya.demon.co.uk> + + * expr.c: Remove leading capital from diagnostic messages, as + per GNU coding standards. + * jcf-io.c: Similarly. + * jcf-parse.c: Similarly. + * jv-scan.c: Similarly. + * jvspec.c: Similarly. + * mangle.c: Similarly. + +2001-12-02 Tang Ching-Hui <nicholas@cs.nthu.edu.tw> + Alexandre Petit-Bianco <apbianco@redhat.com> + + * expr.c (build_java_arrayaccess): Call save_expr on array for + correct evaluation order, modified comment, fixed indentation. + * parse.y: (patch_assignment): Correctly extract the array base + from the tree generate by build_java_arrayaccess, added comments. + (patch_array_ref): Remove SAVE_EXPR on ARRAY_REF. + Fixes PR java/3096, PR java/3803, PR java/3965. + +2001-12-01 Neil Booth <neil@daikokuya.demon.co.uk> + + * expr.c (expand_byte_code): Remove trailing periods from messages. + * jcf-parse.c (load_class, jcf_parse): Similarly. + * jcf-write.c (generate_classfile): Similarly. + * lex.c (java_lex): Similarly. + +2001-11-30 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * class.c (add_interface_do): Set BINFO_VPTR_FIELD. + +2001-11-29 Joseph S. Myers <jsm28@cam.ac.uk> + + * Make-lang.in (java.generated-manpages): New dummy target. + +2001-11-27 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + * jvspec.c (jvgenmain_spec): Cannot use %umain, breaks + ASM_FINAL_SPEC. + (lang_specific_pre_link): Use set_input to set input_filename. + Append `main' here. + * jvgenmain.c (usage): Append literal `main' to CLASSNAME. + (main): Fix definition. + Strip `main' from classname. + Fixes PR java/227. + +2001-11-18 Roger Sayle <roger@eyesopen.com> + + * parse.h (java_expand_switch): Remove old prototype. + +2001-11-18 Tom Tromey <tromey@redhat.com> + + Fix for PR java/1401: + * jcf-write.c (generate_bytecode_insns) [binop]: Handle case where + arg0 is null. + (generate_bytecode_insns) [MODIFY_EXPR]: Handle `OP=' case + correctly. + +2001-11-18 Neil Booth <neil@daikokuya.demon.co.uk> + + * lang.c (finish_parse): Rename to java_finish. + (LANG_HOOKS_FINISH, java_finish): New. + +2001-11-15 Neil Booth <neil@daikokuya.demon.co.uk> + + * decl.c (init_decl_processing): Rename java_init_decl_processing. + * java-tree.h: New prototype. + * lang.c (java_init): Update prototype. Combine with old init_parse. + +2001-11-13 Tom Tromey <tromey@redhat.com> + + * gjavah.c (method_signature): New global. + (HANDLE_METHOD): Set it. + (decompile_return_statement): New function. + (decompile_method): Use it. + (print_method_info): Removed `synth' argument. + +2001-11-09 Neil Booth <neil@daikokuya.demon.co.uk> + + * java-tree.h (java_set_yydebug): New. + * jcf-parse.c (set_yydebug): Rename java_set_yydebug. + * lang.c (LANG_HOOKS_SET_YYDEBUG): Override. + (print_lang_decl, print_lang_type, print_lang_identifier, + print_lang_statistics, lang_print_xnode): Remove. + +2001-11-09 Neil Booth <neil@daikokuya.demon.co.uk> + + * jcf-parse.c (init_lex): Remove. + * lang.c (language_string, lang_identify): Remove. + (struct lang_hooks): Constify. + (LANG_HOOKS_NAME): Override. + (init_parse): Update. + +2001-11-08 Andreas Franck <afranck@gmx.de> + + * Make-lang.in (JAVA_INSTALL_NAME, JAVA_CROSS_NAME): Handle + program_transform_name the way suggested by autoconf. + (java.install-common): Also transform auxiliary program names with + program_transform_name. + +2001-11-08 Tom Tromey <tromey@cygnus.com> + + * parse.y (trap_overflow_corner_case): New rule. + (unary_expression): Use it. + * lex.c (java_init_lex): Don't set minus_seen. + (yylex): Don't use minus_seen. Communicate overflow to parser for + it to handle. + (error_if_numeric_overflow): New function. + * parse.h (minus_seen): Removed field. + (JAVA_RADIX10_FLAG): New define. + +2001-11-07 Tom Tromey <tromey@redhat.com> + + Patch for PR java/1414: + * parse.y (case_label_list): New global. + (goal): Register case_label_list with GC. + (java_complete_lhs): Save new case on case_label_list. + (patch_switch_statement): Check for duplicate case labels. + +2001-11-07 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_assignment): Removed unused third argument. + (java_complete_lhs): Removed unused third argument to patch_assignment. + +2001-11-06 Neil Booth <neil@cat.daikokuya.demon.co.uk> + + * lang.c: Include langhooks-def.h. + * Make-lang.in: Update. + +2001-10-31 Zack Weinberg <zack@codesourcery.com> + + * Make-lang.in: Replace $(INTL_TARGETS) with po-generated. + +2001-10-29 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * mangle.c (find_compression_record_match): Don't match compression + records for package name elements unless they occur at the start of + the name. Fix for PR java/4717. + +2001-10-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * expr.c (expand_java_field_op): Don't special-case references to + java.lang.PRIMTYPE.TYPE. + (build_primtype_type_ref): Removed. + * java-tree.h (build_primtype_type_ref): Remove prototype. + * parse.y (maybe_build_primttype_type_ref): Removed. + (complete_function_arguments): Don't special-case references to + java.lang.PRIMTYPE.TYPE. + (patch_assignment): Likewise. + (array_constructor_check_entry): Likewise. + +2001-10-24 Alexandre Petit-Bianco <apbianco@redhat.com> + + * mangle.c (static tree compression_table): Fixed leading comment. + * parse.h (struct parser_ctxt): Fixed field comment. + * parse.y (check_pkg_class_access): New prototype, fixed leading + comment, new parameter used to emit error only if passed as true. + (parse_check_super): Pass extra argument to check_pkg_class_access. + (do_resolve_class): Likewise. + (process_imports): Likewise. + (read_import_dir): Fixed indentation. + (find_in_imports_on_demand): New local class_type_name. Local + node_to_use deleted. while loop changed into for loop. Report + multiple definition only for accessible classes. Improved error + message. + (start_complete_expand_method): Local `ptr' removed. DECL_ARGUMENTS + assigned to parameter list, fixed indentation. while loop changed + into for loop, restore TREE_CHAIN on local `tem' before the next + iteration. + +2001-10-23 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * lang.c (lang_get_alias_set): Deleted. + +2001-10-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (jni_print_char): Fix thinko in last change. + + * gjavah.c (jni_print_char, decode_signature_piece): Use + safe-ctype macros and/or fold extra calls into fewer ones. + * lex.c (java_read_unicode, java_lex): Likewise. + * lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT, + JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise. + * mangle_name.c (append_unicode_mangled_name, + unicode_mangling_length): Likewise. + +2001-10-17 Richard Henderson <rth@redhat.com> + + * Make-lang.in (java/lang.o): Depend on langhooks.h. + +2001-10-15 Alexandre Petit-Bianco <apbianco@redhat.com> + + * lang.c (langhooks.h): Included. + (LANG_HOOKS_INIT): Redefined. + (LANG_HOOKS_INIT_OPTIONS): Likewise. + (LANG_HOOKS_DECODE_OPTION): Likewise. + (struct lang_hooks lang_hooks): New initialization. + +2001-10-11 Per Bothner <per@bothner.com> + + * parse.y (patch_synchronized_statement): Use a TRY_FINALLY_EXPR + rather than a CLEANUP_POINT_EXPR/WITH_CLEANUP_EXPR pair. + The former is simpler, and jcf-write.c handles it better. + (java_complete_lhs): No longer need to handle CLEANUP_POINT_EXPR + or WITH_CLEANUP_EXPR. + * jcf-write.c: Revert Alex's change from 2000-10-18. It is no + longer needed, as we already handle empty TRY_FINALLY_EXPR bodies fine. + + * parse.y (patch_if_else_statement): If the condition is constant, + optimize away the test. + +2001-10-09 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_cast): Call patch_string on the first operand of + the incoming node, update it if necessary. Fixes PR java/4510. + +2001-10-09 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (find_as_inner_class): Don't disregard the enclosing scope + when name qualifier matches a package name. + +2001-10-08 Tom Tromey <tromey@redhat.com> + + Fix for PR java/4489: + * jcf-write.c (generate_bytecode_insns) [SWITCH_EXPR]: Always + force a new label when computing `body_block'. + +2001-10-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-io.c (format_uint): Const-ify. + * lang.c (java_tree_code_type, java_tree_code_length): Likewise. + * lex.c (java_get_line_col): Likewise. + * parse.y (build_incdec): Likewise. + +2001-10-05 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (register_incomplete_type): Set JDEP_SUPER to be given + a NULL enclosing context if appropriate. Fixes PR java/4466. + +2001-10-03 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_assignment): Use lvalue's original TYPE when + building the final COMPOUND_EXPR. + (try_reference_assignconv): Fixed leading comment. + +2001-09-26 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (check_final_variable_indirect_assignment): For + COMPOUND_EXPR, return only if finals were found initialized + properly, if not, keep on checking. + (check_final_variable_global_assignment_flag): New local + error_found, set when appropriate and used to decide whether to + report uninitialized finals. Fixed typo in comment. + +2001-09-22 Alexandre Petit-Bianco <apbianco@redhat.com> + + * decl.c (init_decl_processing): Fixed typo in predef_filenames + last three initializations. Fixes PR java/4360. + +2001-09-21 Richard Henderson <rth@redhat.com> + + * class.c (get_dispatch_table): Handle function descriptors. + (build_dtable_decl): Likewise. + * expr.c (build_invokevirtual): Likewise. + +2001-09-20 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_method_invocation): Build class initialization + when static finals are used to qualify method invocation. + Fixes PR java/4366. + +2001-09-19 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.h: (WFL_STRIP_BRACKET): Re-written using + build_type_name_from_array_name. + (STRING_STRIP_BRACKETS): New macro. + * parse.y (build_type_name_from_array_name): New function. + (array_creation_expression:): Accumulate []s instead of [s. + (cast_expression:): Accumulate []s instead of [s after cast type + name. + (build_array_from_name): Local string deleted, use + build_type_name_from_array_name. + (build_unresolved_array_type): Accumulate []s instead of [s after + type name. + (register_fields): Fixed comment. + (resolve_class): Local name, base deleted, new locals tname and + array_dims. Use build_type_name_from_array_name. Use array_dims to + build array type. + (purify_type_name): Use STRING_STRIP_BRACKETS. + +2001-09-18 Andreas Jaeger <aj@suse.de> + + * parse.y: Use VA_OPEN/VA_CLOSE/VA_FIXEDARG throughout. + * jv-scan.c: Likewise. + +2001-09-17 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_method_invocation): Inner class creation context + check not enforced within constructors. Fixes PR java/1873. + +2001-09-16 Tom Tromey <tromey@redhat.com> + + * jcf-write.c (generate_bytecode_insns) [SWITCH_EXPR]: Call + NOTE_PUSH for single-case push. Fixes PR java/4189. + +2001-09-13 Alexandre Petit-Bianco <apbianco@redhat.com> + + * java-tree.h (TYPE_IMPORT_LIST): New macro. + (TYPE_IMPORT_DEMAND_LIST): Likewise. + (struct lang_type): New fields import_list and import_demand_list. + * parse.y (java_complete_class): Initialize TYPE_IMPORT_LIST and + TYPE_IMPORT_DEMAND_LIST with ctxp counterparts. + (do_resolve_class): New local saved_enclosing_type, initialized, + passed as parameter to find_in_imports and find_in_imports_on_demand. + (find_in_imports): Added paramater enclosing_type, use its + TYPE_IMPORT_LIST when applicable. + (find_in_imports_on_demand): Added parameter enclosing_type, use + its TYPE_IMPORT_DEMAND_LIST when applicable. Reorganized locals + declaration and initialization. + (fold_constant_for_init): Switch/restore current_class to the + appropriate context. + +2001-09-13 Mark Mitchell <mark@codesourcery.com> + + * verify.c (verify_jvm_instructions): Fix typo. + +2001-09-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * expr.c (expand_invoke): Const-ification. + * parse.y (patch_method_invocation): Likewise. + +2001-09-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (cxx_keywords): Const-ification. + * keyword.gperf (java_keyword): Likewise. + * lang.c (java_tree_code_name): Likewise. + * lex.c (cxx_keywords): Likewise. + * parse.y (java_parser_context_suspend, merge_string_cste): Likewise. + +2001-09-11 Richard Henderson <rth@redhat.com> + + * parse.h (ctxp_for_generation): Mark extern. + +2001-09-10 Richard Henderson <rth@redhat.com> + + * class.c (build_class_ref): Set DECL_EXTERNAL before make_decl_rtl. + +2001-09-07 Matt Kraai <kraai@alumni.carnegiemellon.edu> + + * typeck.c (java_array_type_length, build_prim_array_type): + Represent empty arrays by NULL index. + +2001-09-06 Alexandre Petit-Bianco <apbianco@redhat.com> + + * java-tree.h (compile_resource_file): Grouped with other prototypes. + * jvspec.c (lang_specific_driver): Removed unused local `ptr.' + +2001-09-06 Anthony Green <green@redhat.com> + + * class.c (O_BINARY): Define if necessary. + (registerResource_libfunc): Declare. + (init_class_processing): Initilize registerResource_libfunc. + (compile_resource_file): New function. + * java-tree.h (resource_name): Declare. + (compile_resource_file): Declare. + * jcf-parse.c (yyparse): Handle compiling java resource files. + * lang.c (java_decode_option): Handle -fcompile-resource option. + * jvspec.c (lang_specific_driver): Handle -R flag for compiling + resource files. + * gcj.texi (Code Generation): Add documentation for -R flag. + +2001-09-05 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jcf-write.c (generate_classfile): Issue an error in case of + field/initial value mismatch. + * parse.y (analyze_clinit_body): Keep <clinit> if an array is + being initialized and we're generating bytecode. + (java_complete_lhs): In MODIFY_EXPR section: added comments, + set DECL_INITIAL properly when appropriate. + Fixes PR java/4230 + Fixes PR java/4204 + +2001-09-01 Per Bothner <per@bothner.com> + + * parse.y (maybe_yank_clinit): A field without an initializer is not + relevant. All initializers except static final and constant require + <clinit>, regardless of flag_emit_class_files. + +2001-08-31 Per Bothner <per@bothner.com> + + * class.c (set_constant_value): When not emitting class files, then a + String ConstantValue is a utf8const_ptr_type. + +2001-08-30 Per Bothner <per@bothner.com> + + * jcf-write.c (generate_classfile): Check that field is primitive + or string before emitting ConstantValue attribute. + +2001-08-30 Per Bothner <per@bothner.com> + + * parse.y (resolve_qualified_expression_name): If creating a + COMPOUND_EXPR, set it's type correctly. + +2001-08-30 Per Bothner <per@bothner.com> + + * jcf-io.c (open_class): Set filename field. + + * jcf-parse,c (parse_class_file): Set current_function_decl + for better error message when Code attribute is missing. + + * lang.c (put_decl_node, lang_print_error): Re-arrange for + better diagnostics, especially for constructors. + +2001-08-30 Per Bothner <per@bothner.com> + + * jcf-write.c (generate_classfile): Don't write ConstantValue + attribute if field is not final, for compatibility with jdk. + + * jcf-write.c (generate_classfile): Convert ConstantValue values + to correct type. Work-around for front-end bug. + * class.c (set_constant_value): Error if constant has wrong type. + +2001-08-30 Per Bothner <per@bothner.com> + + * jcf-dump.c (print_constant): Fix fencepost error so "Float" and + "Double" are printed at verbosity 1. + + * jcf-dump.c (main): Disable flag_print_attributes if --javap. + + * jcf-dump.c (SPECIAL_IINC): Remove unneeded casts to long. + +2001-08-30 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_assignment): Don't verify final re-assignment here. + (java_complete_lhs): Verify assignments to finals calling + patch_assignment. Verify re-assignments to finals before calling + patch_assignment. + +2001-08-29 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (java_complete_lhs): Allow final locals in CASE_EXPRs. + Fixes PR java/1413 + +2001-08-28 Alexandre Petit-Bianco <apbianco@redhat.com> + + * lex.c (java_lex): new local found_hex_digits. Set and then used + in test to reject invalid hexadecimal numbers. + * parse.y (java_complete_tree): Prevent unwanted cast with + initialized floating point finals. + (patch_binop): Emit a warning when detecting a division by zero, + mark result not constant, don't simplify non integer division. + +2001-08-28 Per Bothner <per@bothner.com> + + * jcf-write.c (generate_bytecode_insns): For increments and + decrements just recurse to push constant. Improvement on Mark's patch. + +2001-08-28 Mark Mitchell <mark@codesourcery.com> + + * jcf-write.c (generate_bytecode_insns): Generate an integer to + real conversion for increments and decrements of reals. + +2001-08-27 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (resolve_qualified_expression_name): Handle unresolved + qualified expressions, prevent numerical qualifiers, fixed typo. + Fixes PR java/4141 + +2001-08-24 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (check_deprecation): Handle TYPE_DECL in a special case, + don't report anything but deprecated class when marked so. Handle + VAR_DECL. + (patch_method_invocation): Check deprecation on methods and types. + (patch_binop): code becomes an enum tree_code, added default: to + switch to handle that. Detect division by zero, try to fold and + return before using a subroutine. + +2001-08-23 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jcf-parse.c (yyparse): Set magic to 0, don't issue error for a + file smaller than 4 bytes. + * parse.y (check_inner_circular_reference): New function. + (check_circular_reference): Likewise. + (array_initializer:): Accept {,}. + (java_check_circular_reference): Rewritten using + check_circular_reference and check_inner_circular_reference. + (java_complete_expand_method): Unconditionally save and restore + the unpurged exception list. + (build_dot_class_method_invocation): Unmangle signature parameter. + +2001-08-21 Tom Tromey <tromey@redhat.com> + + * decl.c (init_decl_processing): Add `throws' field to method + descriptor. + * class.c (make_method_value): Compute `throws' field for method. + +2001-08-22 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (resolve_inner_class): Keep local_enclosing to NULL if + circularity is detected. + (ctors_unchecked_throws_clause_p): Fixed leading comment. + +2001-08-17 Richard Henderson <rth@redhat.com> + + * class.c (emit_register_classes): Add align parameter to + call to assemble_integer. + +2001-08-16 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jcf-parse.c (load_class): New locals saved and class_loaded. If + loading a class_or_name fails, try considering an innerclass name + and load the enclosing context. + * parse.y (resolve_inner_class): New function. + (find_as_inner_class): Added leading comment. + (register_incomplete_type): Keep the current context as enclosing + context for JDEP_FIELD dependencies. + (do_resolve_class): Locals new_class_decl and super initialized to + NULL. Call resolve_inner_class, explore the enclosing context + superclass if necessary. + Fixes PR java/4007 + +2001-08-16 Tom Tromey <tromey@redhat.com> + + * jcf-dump.c (main): Updated for change to jcf_path_seal. + * gjavah.c (main): Updated for change to jcf_path_seal. + * lang.c (version_flag): New global. + (java_decode_option): Recognize `-version'. + (java_init): Update for change to jcf_path_seal. + * jcf.h (jcf_path_seal): Added `print' argument. + * jcf-path.c (jcf_path_seal): Added `print' argument. + +2001-08-13 Zack Weinberg <zackw@panix.com> + + * Make-lang.in (java/decl.o): Update dependencies. + * decl.c: Include libfuncs.h, don't include toplev.h. + +2001-08-12 Alexandre Petit-Bianco <apbianco@redhat.com> + + * decl.c (init_decl_processing): exception_type_node, + class_not_found_type_node, and no_class_def_found_type_node + initialized. predef_filenames augmented accordingly. + instinit_identifier_node initialized. + * java-tree.def (INSTANCE_INITIALIZERS_EXPR): Entry removed. + * java-tree.h (enum java_tree_index): New entries + JTI_EXCEPTION_TYPE_NODE, JTI_CLASS_NOT_FOUND_TYPE_NODE, + JTI_NO_CLASS_DEF_FOUND_TYPE_NODE, JTI_INSTINIT_IDENTIFIER_NODE. + (exception_type_node): New macro. + (class_not_found_type_node): Likewise. + (no_class_def_found_type_node): Likewise. + (instinit_identifier_node): Likewise. + (PREDEF_FILENAMES_SIZE): Adjusted. + (TYPE_HAS_FINAL_VARIABLE): Fixed typo. + (struct lang_type): Fixed typo in bitfield name. + (DECL_INSTINIT_P): New macro. + (ID_INSTINIT_P): Likewise. + * jcf-write.c (generate_classfile): instinit$ bears the Synthetic + attribute. + * parse.y (encapsulate_with_try_catch): New function. + (generate_instinit): Likewise. + (build_instinit_invocation): Likewise. + (ctors_unchecked_throws_clause_p): Likewise. + (add_instance_initializer): Deleted. + (build_instance_initializer): Likewise. + (in_instance_initializer): Likewise. + (check_method_redefinition): instinit$ not to be verified. + (java_complete_expand_methods): Generate instinit$, simplified code. + (build_dot_class_method): Eliminated unnecessary locals. Use + encapsulate_with_try_catch, removed unnecessary code. + (fix_constructors): New local iii. Use build_instinit_invocation. + (patch_method_invocation): Added comment. + (maybe_use_access_method): Don't consider instinit$. + (find_applicable_accessible_methods_list): Shorten the search for + instinit$ too. + (java_complete_lhs): case INSTANCE_INITIALIZERS_EXPR removed. + (patch_return): Use DECL_INSTINIT_P instead of in_instance_initializer. + (patch_throw_statement): Likewise. Fixed typo. + +2001-08-12 David Edelsohn <edelsohn@gnu.org> + + Revert: + 2001-08-02 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + * jvspec.c (jvgenmain_spec): Cannot use %umain, breaks + ASM_FINAL_SPEC. + (lang_specific_pre_link): Use set_input to set input_filename. + Append `main' here. + * jvgenmain.c (usage): Append literal `main' to CLASSNAME. + (main): Fix definition. + Strip `main' from classname. + Fixes PR java/227. + +2001-08-11 Zack Weinberg <zackw@panix.com> + + * lex.h: Don't include setjmp.h. Don't define + SET_FLOAT_HANDLER or prototype set_float_handler. + +2001-08-09 Alexandre Petit-Bianco <apbianco@redhat.com> + + * expr.c (java_lang_expand_expr): Call `expand_end_bindings' and + `poplevel' in the right order. + +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 + (check_init): Don't report uninitialized static class + initialization flags, don't free bit index when doing static class + initialization optimization. + (check_for_initialization): Return type changed to `unsigned int.' + (attach_initialized_static_class): New function. + * class.c (add_method_1): Create the initialized static class + table if necessary. + (finish_class): Always emit deferred inline methods. + * decl.c (emit_init_test_initialization): Moved to expr.c + (complete_start_java_method): Don't traverse + DECL_FUNCTION_INIT_TEST_TABLE. + (lang_mark_tree): Mark hash tables in function decls. + * expr.c (emit_init_test_initialization): Moved from decl.c. + (build_class_init): Create LAG_DECL_SPECIFIC for the static class + initialization flag, set DECL_CONTEXT and + LOCAL_CLASS_INITIALIZATION_FLAG. + (java_lang_expand_expr): Emit initialization code for static class + initialized flags when entering block, if necessary. + * gcj.texi (-fno-optimize-static-class-initialization): Documented. + * java-tree.h (flag_optimize_sci): New global variable declaration. + (DECL_FUNCTION_INITIALIZED_CLASS_TABLE): New macro. + (DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND): Likewise. + (LOCAL_FINAL_P): Fixed typo in comment. + (FINAL_VARIABLE_P): Likewise. + (LOCAL_CLASS_INITIALIZATIO_FLAG): New macro. + (LOCAL_CLASS_INITIALIZATIO_FLAG_P): Likewise. + (struct lang_decl): New fields `ict', `smic' and `cif.' + (check_for_initialization): New returned value for global. + (attach_initialized_static_class): New global function. + (STATIC_CLASS_INIT_OPT_P): New macro. + * lang-options.h (-fno-optimize-static-class-initialization): New flag. + * lang.c (java_decode_option): Handle + `-fno-optimize-static-class-initialization' + * parse.y (start_complete_expand_method): New function. + (java_expand_method_bodies): Likewise. + (attach_init_test_initialization_flags): Likewise. + (adjust_init_test_initialization): Likewise. + (emit_test_initialization): Likewise. + (java_complete_expand_methods): Nullify abstract and native method + bodies. + (java_complete_expand_method): New locals `fbody', `block_body' + and `exception_copy.' Reorganized: directly return on empty method + bodies, call `start_complete_expand_method', remember definitely + initialized static class in function, don't expand method bodies. + (java_expand_classes): Call `java_expand_method_bodies' before + `finish_class' when compiling to native. + (resolve_expression_name): Use `orig' after building outer class + field access. + (patch_invoke): Remember static method invocations. + +2001-08-06 Richard Henderson <rth@redhat.com> + + * class.c (emit_register_classes): Pass a symbol_ref and priority + to assemble_constructor. + +2001-08-02 Alexandre Petit-Bianco <apbianco@redhat.com> + + * java-tree.h (all_class_filename): New macro. + (enum java_tree_index): New enum `JTI_ALL_CLASS_FILENAME.' + (BUILD_FILENAME_IDENTIFIER_NODE): Fixed leading comment. Link + newly created IDENTIFIER_NODE to `all_class_filename.' + +2001-08-01 Jeff Sturm <jsturm@one-point.com> + + * java-tree.h (BUILD_FILENAME_IDENTIFIER_NODE): + Use ggc_add_tree_root to register roots. + +2001-07-31 Alexandre Petit-Bianco <apbianco@redhat.com> + + * check-init.c (check_init): WITH_CLEANUP_EXPR node to use its + second operand calling check_init. + * decl.c (complete_start_java_method): Swaped second and third + arguments while creating WITH_CLEANUP_EXPR node. + * jcf-write.c (generate_bytecode_insns): Use second operand + instead of third when handling WITH_CLEANUP_EXPR. + * parse.y (java_complete_lhs): Expand second operand of + WITH_CLEANUP_EXPR nodes. + (patch_synchronized_statement): Swaped second and third arguments + while creating WITH_CLEANUP_EXPR node. + +2001-07-18 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (create_interface): Avoid cyclic inheritance report when + syntax error encountered during class definition. + Fixes PR java/2956 + +2001-08-02 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + * jvspec.c (jvgenmain_spec): Cannot use %umain, breaks + ASM_FINAL_SPEC. + (lang_specific_pre_link): Use set_input to set input_filename. + Append `main' here. + * jvgenmain.c (usage): Append literal `main' to CLASSNAME. + (main): Fix definition. + Strip `main' from classname. + Fixes PR java/227. + +2001-07-18 Tom Tromey <tromey@redhat.com> + + For PR java/2812: + * lex.h: Use HAVE_ICONV, not HAVE_ICONV_H. + * lex.c (java_new_lexer): Use ICONV_CONST. + (java_read_char): Likewise. + * Make-lang.in (jc1$(exeext)): Link against LIBICONV. + (jv-scan$(exeext)): Likewise. + +2001-07-17 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.h (INTERFACE_INNER_MODIFIERS): Disallow `private.' + * parse.y (check_class_interface_creation): Allow `private' if the + enclosing is not an interface. + (create_interface): Interface tagged public if the enclosing + context is an interface. + (create_class): Class tagged public if the enclosing context + is an interface. + Fixes PR java/2959 + +2001-07-17 Alexandre Petit-Bianco <apbianco@redhat.com> + + * class.c (push_class): Set DECL_SIZE to `integer_zero_node.' + Fixes PR java/2665 + +2001-07-14 Tim Josling <tej@melbpc.org.au> + + * check-init.c (check_init): Remove references to EXPON_EXPR. + +2001-07-13 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (java_complete_lsh): Set CAN_COMPLETE_NORMALLY and unset + TREE_CONSTANT_OVERFLOW of CASE_EXPR value. + Fixes PR java/3602 + +2001-07-13 Tom Tromey <tromey@redhat.com> + + * jvspec.c (jvgenmain_spec): Remove -ffilelist-file from cc1 + invocation. + +2001-07-12 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_method_invocation): Don't override primary if one + is already provided, but let this$<n> be built. Fixed comment. + +2001-07-12 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (empty_statement:): Report empty statement error only + when found at class declaration level. + Fixes PR java/3635 + +2001-07-12 Tom Tromey <tromey@redhat.com> + + * expr.c (expand_load_internal): New function. + (LOAD_INTERNAL): Use it. + +2001-07-11 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (verify_constructor_super): Compare anonymous class ctor + args with `valid_method_invocation_conversion_p.' + Fixes PR java/3285 + +2001-07-10 Alexandre Petit-Bianco <apbianco@redhat.com> + + * lang-specs.h: Forbit the use if `-femit-class-file{s}' without + `-fsyntax-only.' Fixes PR java/3248 + +2001-07-10 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jcf-io.c (find_class): Clarified error message. Fixes PR java/2603 + +2001-07-10 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.h (INNER_ENCLOSING_SCOPE_CHECK): No `this' is fine if the + current function is static. Fixes PR java/1970 + +2001-07-09 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_method_invocation): Add enclosing context to ctor + calls if necessary. Fixes PR java/2953 + +2001-07-09 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (resolve_package): Abort if qualified expression member + isn't right. + (qualify_ambiguous_name): Don't qualify as type if `this' in use. + Fixes PR java/1391 + +2001-07-07 Zack Weinberg <zackw@stanford.edu> + + * verify.c: Don't use // comments. + +2001-07-05 Tom Tromey <tromey@redhat.com> + + * lang.c (flag_assume_compiled): Removed. + * java-tree.h (flag_assume_compiled): Removed. + * lang-options.h: Removed -ffile-list-file, -fuse-boehm-gc, + -fhash-synchronization, -fuse-divide-subroutine, + -fcheck-references, -femit-class-file, -femit-class-files, + -fassume-compiled. Updated --encoding information. Changed + -foutput-class-dir to `-d'. + +2001-07-04 Daniel Berlin <dan@cgsoftware.com> + + * jcf-parse.c (parse_class_file): Add lineno parameter to + debug_start_source_file call. + +2001-07-04 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcj.texi: Use gpl.texi. + * Make-lang.in ($(srcdir)/java/gcj.info, java/gcj.dvi): Update + dependencies and use doc/include in search path. + +2001-07-03 Jeff Sturm <jsturm@one-point.com> + + * parse.y (fix_constructors): Test if a CALL_EXPR invokes + `this'. If so, don't build instance initializers. + +2001-07-03 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (resolve_expression_name): Improved error message for + inner class cases. Fixes PR java/1958 + +2001-06-28 Gabriel Dos Reis <gdr@codesourcery.com> + + * lang.c: #include diagnostic.h + (lang_print_error): Add a `diagnostic_context *' parameter. + (java_dummy_print): Likewise. + * Make-lang.in (JAVA_LEX_C): Depend on diagnostic.h + +2001-06-27 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jcf-parse.c (gcc_mark_jcf): Test for a finished JCF. + * jcf.h (typedef struct JCF): New bitfield `finished.' + (JCF_FINISH): Set `finished.' + (JCF_ZERO): Reset `finished.' + Fixes PR java/2633 + +2001-06-27 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (class_body_declaration:): Don't install empty instance + initializers. + Fixes PR java/1314 + +2001-06-27 Alexandre Petit-Bianco <apbianco@redhat.com> + + * class.c (set_super_info): Call `set_class_decl_access_flags.' + (set_class_decl_access_flags): New function. + * java-tree.h (set_class_decl_access_flags): New prototype. + * jcf-parse.c (handle_innerclass_attribute): Read and set access flags. + (parse_class_file): New local `decl_max_locals.' Take wide types + into account to compute DECL_MAX_LOCALS. + * parse.y (type_import_on_demand_declaration:): Ignore duplicate + imports on demand. + +2001-06-22 Jan van Male <jan.vanmale@fenk.wau.nl> + + * zipfile.h: Use GCC_JCF_H instead of JCF_H. + +2001-06-20 Alexandre Petit-Bianco <apbianco@redhat.com> + + * class.c (java_hash_tree_node): Fixed indentation in leading comment. + * parse.y (do_resolve_class): Moved comments out to leading comment + section. Removed local `start', New local `_ht' and + `circularity_hash.' Record `enclosing' in hash table and search + it to detect circularity. Use `enclosing' as an argument to + `lookup_cl.' Free the hash table when done. + +2001-06-19 Tom Tromey <tromey@redhat.com> + + * lex.c (java_read_char): Disallow invalid and overlong + sequences. Fixes PR java/2319. + +2001-06-05 Jeff Sturm <jsturm@one-point.com> + + * decl.c (create_primitive_vtable): Don't call make_decl_rtl. + +2001-06-04 Alexandre Petit-Bianco <apbianco@redhat.com> + + * expr.c (force_evaluation_order): Match wrapped ctor calls, locate + arguments accordingly. + +2001-06-02 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcj.texi: Move contents to just after title page. + +2001-06-01 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (type_literals:): Use `build_incomplete_class_ref' with + builtin type. + (patch_incomplete_class_ref): Build the class ref, build the class + init if necessary, complete the tree. + Fixes PR java/2605 + +2001-05-31 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (lookup_field_wrapper): Test `name' code. + (resolve_qualified_expression_name): Test `qual_wfl' code. + (qualify_ambiguous_name): Handle `CONVERT_EXPR', fixe indentation, + handle `qual_wfl' by code. + (maybe_build_primttype_type_ref): Test `wfl' code. + +2001-05-23 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + + * Make-lang.in ($(srcdir)/java/gcj.info): Added dependencies on + fdl.texi. + (java/gcj.dvi): Use TEXI2DVI instead of custom tex calls. Create + the dvi file in the java directory. + +2001-05-25 Sam TH <sam@uchicago.edu> + + * gen-table.pl javaop.h jcf.h lex.h, + parse.h: Fix header include guards. + +2001-05-23 Joseph S. Myers <jsm28@cam.ac.uk> + + * jv-scan.c (version): Update copyright year. + +2001-05-21 Per Bothner <per@bothner.com> + + * jcf-parse.c (read_class): If class is from .class or .zip file + and it's already been read, don't push/pop parser context. + +2001-05-18 Per Bothner <per@bothner.com> + + * jvspec.c (lang_specific_pre_link): Re-arrange the linker + command line so the jvgenmain-generated main program comes first. + +2001-05-15 Tom Tromey <tromey@redhat.com> + + * class.c (build_utf8_ref): Don't generate identifier based on + utf8const contents. + +2001-05-12 Richard Henderson <rth@redhat.com> + + * java-tree.def (JAVA_EXC_OBJ_EXPR): New. + * expr.c (java_lang_expand_expr): Expand it. + (process_jvm_instruction): Build JAVA_EXC_OBJ_EXPR instead of + calling build_exception_object_ref. + * parse.y (catch_clause_parameter): Likewise. + (build_dot_class_method): Likewise. + (try_reference_assignconv): Likewise. + * check-init.c (check_init): Check JAVA_EXC_OBJ_EXPR not EXC_PTR_EXPR. + * jcf-write.c (generate_bytecode_insns): Likewise. + +2001-05-07 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (build_unresolved_array_type): Set + EXPR_WFL_QUALIFICATION on the newly created wfl. + Fixes PR java/2538. Fixes PR java/2535. + +2001-05-07 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (fix_constructors): Removed unnecessary assignment to + local. Moved assignment to `this$<n>', fixed comments and + indentation. + (build_wfl_wrap): Fixed indentation. + Fixes PR java/2598, java/2579 and java/2658. + +2001-05-03 Mo DeJong <mdejong@redhat.com> + + * lex.c (java_new_lexer): Call iconv_close on temp handle used to + check for byte swap. + +2000-05-02 Jeff Sturm <jsturm@one-point.com> + + * expr.c (build_class_init): Move MODIFY_EXPR + outside of COND_EXPR. Remove variable `call'. + +2001-05-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * decl.c: NULL_PTR -> NULL. + * jcf-write.c: Likewise. + +2001-05-01 Tom Tromey <tromey@redhat.com> + + * Make-lang.in ($(srcdir)/java/gcj.info): Added `-I..'. + (java/gcj.dvi): Added $(srcdir) to TEXINPUTS. + * gcj.texi: Updated copyright text. Include fdl.texi. + (Top): Link to new node. + +2001-05-01 Per Bothner <per@bothner.com> + + * parse.h (REGISTER_IMPORT): Use tree_cons instead of chainon. + +2001-05-01 Per Bothner <per@bothner.com> + + * parse.y (java_pop_parser_context): The TREE_VALUE of a link in the + import_list contains the name, not the TREE_PURPOSE. + +2001-04-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-io.c (read_zip_member): Cast to long in comparison with + signed value. + + * jvspec.c (lang_specific_driver): Initialize variables. + + * mangle.c (find_compression_record_match): Likewise. + + * typeck.c (build_null_signature): Provide static prototype. Mark + parameter with ATTRIBUTE_UNUSED. + + * verify.c (verify_jvm_instructions): Initialize variable. + +2001-04-27 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * parse.y (do_resolve_class): Check for cyclic inheritance during + inner class resolution. + +2001-04-27 Per Bothner <per@bothner.com> + + * parse.y (java_expand_classes): Don't change ctxp_for_generation + while iterating, since that could cause gc to lose stuff. + +2001-04-26 Per Bothner <per@bothner.com> + + Fix method search wrt scope of inner classes to match JLS2. + * typeck.c (build_null_signature): New static function. + (has_method): New function. Uses build_null_signature and lookup_do. + * java-tree.h (has_method): New declaration. + * parse.y (find_applicable_accessible_methods_list): Do not search + context of inner classes here. + (patch_method_invocation): Search scope, ie. current and outer clases, + for method matching simple name, to find class. + +2001-04-26 Per Bothner <per@bothner.com> + + * jcf-write.c (generate_bytecode_insns case SWITCH_EXPR): + Fix thinko: If a single case, use if_icmpeq, not ifeq. + + * constants.c (find_methodref_with_class_index): New function. + (find_methodref_index): Use find_methodref_with_class_index. + * java-tree.h (find_methodref_with_class_index): New declaration. + * jcf-write.c (generate_bytecode_insns case CALL_EXPR): Don't change + DECL_CONTEXT, instead use new find_methodref_with_class_index function. + If context changed from interface to class, don't use invokeinterface. + +2001-04-25 Per Bothner <per@bothner.com> + + * verify.c (verify_jvm_instructions): For field instructions, + check that field index is valid. For invoke instructions, check that + method index is valid. + +2001-04-25 Alexandre Oliva <aoliva@redhat.com> + + * config-lang.in (target_libs): Copy from $libgcj_saved. + +2001-04-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * decl.c (init_decl_processing): Add new class "protectionDomain" + field. + * class.c (make_class_data): Set initial value for "protectionDomain". + +2001-04-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jvspec.c (lang_specific_driver): Fix memory allocation + deficit, by using concat in lieu of xmalloc/sprintf. + +2001-04-20 Per Bothner <per@bothner.com> + + Fixes to compile multiple .class files at once. + * decl.c (init_decl_processing): Don't set CLASS_LOADED_P. + * java-tree.h (CLASS_PARSED_P): New macro. + (CLASS_LOADED_P): Re-define to use TYPE_SIZE and CLASS_PARSED_P. + * jcf-parse.c (jcf_parse_source): Inline into read_class. + (read_class): Avoid some code duplication. + Don't call JCF_FINISH for a .class file - might be needed later. + (jcf_parse): Don't call layout_class here. Check/set CLASS_PARSED_P + rather than CLASS_LOADED_P, since latter implies class laid out. + (yyparse): Do layout_class and JCF_FINISh here instead, in pass 2. + * parse.y: Don't need to set CLASS_LOADED_P for array types. + +2001-04-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (java/boehm.o): Depend on toplev.h. + + * boehm.c: Include toplev.h. + +2001-04-06 Tom Tromey <tromey@redhat.com> + Alexandre Petit-Bianco <apbianco@redhat.com> + + Fix for PR gcj/1404 and PR gcj/2332: + * parse.y (build_array_from_name): If we use the type_wfl then + accumulate dimensions from the original type as well. + (build_unresolved_array_type): Don't modify TYPE_OR_WFL in place. + +2001-04-06 Tom Tromey <tromey@redhat.com> + + * parse.y (analyze_clinit_body): Return true if the second operand + of a METHOD_EXPR is nonzero. + +2001-04-06 Tom Tromey <tromey@redhat.com> + + * Make-lang.in ($(srcdir)/java/parse-scan.c): Run bison from build + directory. + ($(srcdir)/java/parse.c): Likewise. + +2001-04-05 Alexandre Petit-Bianco <apbianco@redhat.com> + + * gcj.texi: Use `which-gcj' instead of `which-g77.' + (version-gcc): Initialized. + (which-gcj): Likewise. + +2001-04-04 Alexandre Petit-Bianco <apbianco@redhat.com> + + * java-tree.h (struct lang_decl): New macro + `DECL_FIXED_CONSTRUCTOR_P.' New field `fixed_ctor.' + * parse.y (build_instance_initializer): New function. + (add_instance_initializer): Use it. + (java_fix_constructors): Set `current_class' before fix pass. + (fix_constructors): Just return if already fixed. Move `super()' + invocation ahead. Use `build_instance_initializer.' + Fixes PR java/1315. + +2001-04-04 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (resolve_qualified_expression_name): Pass field's + DECL_CONTEXT to `not_accessible_p.' + (not_accessible_p): Changed parameters order in `inherits_from_p' + invocation. + +2001-03-27 Andrew Haley <aph@cambridge.redhat.com> + + * lang-options.h: Add flag_check_references. + +2001-04-04 Per Bothner <per@bothner.com> + + * java-tree.h (CONSTANT_VALUE_P): New macro. + * jcf-write.c (generate_classfile): Use CONSTANT_VALUE_P. + * parse.y (maybe_build_class_init_for_field): New static function. + (resolve_expression_name, resolve_field_access): Use + maybe_build_class_init_for_field instead of build_class_init + This does not do the init if the field is compile-time-constant. + (resolve_field_access): Simplify. + + * parse.y (fold_constant_for_init): Merge test into switch. + +2001-04-03 Zack Weinberg <zackw@stanford.edu> + + * Make-lang.in (buffer.o, check-init.o, class.o): Don't depend + on gansidecl.h. + * buffer.c, jvgenmain.c: Don't include gansidecl.h. + +2001-04-02 Zack Weinberg <zackw@stanford.edu> + + * expr.c (pop_type_0): Save the result of the first + lang_printable_name call in a scratch buffer, so it + won't be clobbered by the second call. + +2001-03-30 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse-scan.y (array_type:): Rewritten. + (type_declaration:): `empty_statement' replaces `SC_TK.' + (class_member_declaration:): `empty statement' added. + (method_body:): Simplified. + (static_initializer:): Likewise. + (primary_no_new_array:): Use `type_literals.' + (type_literals:): New rule. + (dims:): Set and update `bracket_count.' + Fixes PR java/1074. Fixes PR java/2412. + +2001-03-28 Hans Boehm <boehm@acm.org> + + * boehm.c (PROCEDURE_OBJECT_DESCRIPTOR): Set to use `build_int_2.' + (get_boehm_type_descriptor): Set type on returned value to be a + pointer length integer. + +2001-03-28 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * expr.c (pop_type_0): Call `concat' rather than building the + string manually. + (pop_type): Add format specifier in call to `error'. + + * parse.y (patch_method_invocation): Avoid casting away + const-ness. + +2001-03-28 Jeffrey Oldham <oldham@codesourcery.com> + + * jvgenmain.c (do_mangle_classname): End string constant with '\0'. + +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. + * decl.c (throw_node): Don't declare. + (init_decl_processing): Init a scalar throw_node. + Don't register it for gc. + * check-init.c (check_init): Reference scalar throw_node. + * expr.c (build_java_athrow): Likewise. + * jcf-write.c (generate_bytecode_insns): Likewise. + * parse.h (BUILD_THROW): Likewise. + +2001-03-28 Richard Henderson <rth@redhat.com> + + * decl.c (end_java_method): Do not save and restore + flag_non_call_exceptions. + * parse.y (source_end_java_method): Likewise. + * lang.c (flag_exceptions): Don't declare. + (java_init_options): Set flag_non_call_exceptions. Set + flag_exceptions here ... + (java_init): ... not here. + +2001-03-27 Richard Henderson <rth@redhat.com> + + * expr.c, parse.h: Use USING_SJLJ_EXCEPTIONS instead of + exceptions_via_longjmp. + + * lang.c (flag_new_exceptions): Don't declare it. + (java_init_options): Or set it. + +2001-03-27 Richard Henderson <rth@redhat.com> + + * decl.c (end_java_method): Rename asynchronous_exceptions to + flag_non_call_exceptions. + * parse.y (source_end_java_method): Likewise. + +2001-03-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in: Depend on $(SYSTEM_H), not system.h. + +2001-03-26 Mark Mitchell <mark@codesourcery.com> + + * parse.h (DECL_END_SOURCE_LINE): Don't rely on DECL_FRAME_SIZE. + +2001-03-26 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (find_as_inner_class): Follow current package + indications not to mistakingly load an unrelated class. + +2001-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * constants.c (PUTN): Use memcpy, not bcopy. + + * lex.c (java_read_char): Use memmove, not bcopy. + + * parse.y (java_parser_context_resume): Use memcpy, not bcopy. + +2001-03-23 Per Bothner <per@bothner.com> + + * verify.c (verify_jvm_instructions): Replace 3 pop_type by POP_TYPE + macro for better error pin-pointing. + * java-tree.h: Fix typo in comment. + + * jcf-write.c (generate_bytecode_insns): Changes to TRY_FINALLY_EXPR. + Don't include jsr/goto in exception range. + Check if start and end of exception range are the same (also TRY_EXPR). + Don't emit jsr after try_block if CAN_COMPLETE_NORMALLY is false. + However, do emit the following goto even if try_block is empty. + Defer freeing exception_decl until after the finalizer, to make + sure the local isn't reused in the finalizer. Fixes PR java/1208. + + * parse.y (java_complete_lhs): If the try-clause is empty, just + return the finally-clause and vice versa. + +2001-03-23 Alexandre Petit-Bianco <apbianco@redhat.com> + + * gcj.texi (Input Options): documented the check for attribute + `gnu.gcc.gccj-compiled' and the `-fforce-classes-archive-check' flag. + * java-tree.h (flag_force_classes_archive_check): Declared extern. + * jcf-parse.c (HANDLE_GCJCOMPILED_ATTRIBUTE): New macro. + (jcf_parse): Check for the right classes archive if necessary. + * jcf-reader.c (get_attribute): Define `MATCH_ATTRIBUTE' and use it. + (jcf_parse_fields): Fixed indentation. + * jcf-write.c (append_gcj_attribute): New function. + (generate_classfile): Compute the attribute count, invoke + `append_gcj_attribute'. + * jcf.h (typedef struct JCF): `seen_in_zip' and `java_source' + turned into bit-fields. New bit-field `right_zip.' + (JCF_ZERO): Set `right_zip' to zero. + * lang-options.h (-fforce-classes-archive-check): Added flag. + * lang.c (flag_force_classes_archive_check): New flag. + (lang_f_options): New entry `force-classes-archive-check.' + Fixes PR java/1213. + +2001-02-07 Andrew Haley <aph@redhat.com> + + * gcj.texi (Configure-time Options): Add -fcheck-references. + * expr.c (build_java_indirect_ref): New function. + (java_check_reference): New function. + (build_java_array_length_access): Use build_java_indirect_ref to + check for null references. + (build_java_arrayaccess): Likewise. + (build_get_class): Likewise. + (build_field_ref): Likewise. + (invoke_build_dtable): Likewise. + (build_invokeinterface): Likewise. + * lang.c (lang_f_options): Add flag_check_references. + * jvspec.c (jvgenmain_spec): Add flag_check_references. + * java-tree.h (flag_check_references): New variable. + * lang.c (flag_check_references): Likewise. + * parse.y (patch_invoke): Use java_check_reference. + (patch_assignment): Allow for extra nesting in + _Jv_CheckArrayStore. + +2001-03-23 Bryce McKinlay <bryce@albatross.co.nz> + + * gjavah.c (cxx_keywords): Update from the definitive list in cp/lex.c. + * lex.c (cxx_keywords): Likewise. + +2001-03-21 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (qualify_ambiguous_name): Broaden `length' + recognition. Help MODIFY_EXPR be resolved as expression names. + Fixes PR java/2066. Fixes PR java/2400. + +2001-03-21 Bryce McKinlay <bryce@albatross.co.nz> + + * gjavah.c (process_file): Mark interface definitions with + "__attribute__ ((java_interface))". + +2001-03-21 Alexandre Petit-Bianco <apbianco@redhat.com> + + * class.c (layout_class): Fixed push_super_field's second + argument. Fixes PR java/2333. + (jdep_resolve_class): Reset TYPE_SIZE if `error_mark_node', it's + too early to lay innerclasses out. + +2001-03-20 Tom Tromey <tromey@redhat.com> + Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_assignment): Handle the case of a SAVE_EXPR + inside an array reference. Insertion of the array store check + rewritten. Fixes PR java/2299. + +2001-03-20 Tom Tromey <tromey@redhat.com> + + * lex.c (java_read_unicode): Only accept leading `u's. + +2001-03-20 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (read_class): Initialize `class'. + +2001-03-20 Matt Kraai <kraai@alumni.carnegiemellon.edu> + + * jcf_parse.c (jcf_parse): Eliminate unused variable. + +2001-03-19 Mark Mitchell <mark@codesourcery.com> + + * class.c (build_class_ref): Use SET_DECL_ASSEMBLER_NAME. + (layout_class): Likewise. + (layout_class_method): Likewise. + (emit_register_classes): Likewise. + * decl.c (builtin_function): Likewise. + (give_name_to_locals): Likewise. + +2001-03-19 Per Bothner <per@bothner.com> + + * jcf-parse.c (load_inner_classes): Check CLASS_LOADED_P + before trying to load an inner class. + + Fixes to process to command-line .class files in two passes. + * java-tree.h (JAVA_FILE_P, CLASS_FILE_P, ZIP_FILE_P): New flags. + (CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P): Rename to .. + (CLASS_FROM_CURRENTLY_COMPILED_P): ... because it is more general now. + * class.c (is_compiled_class): Fix for renamed flag. + * parse.y (maybe_create_class_interface_decl): Likewise. + * jcf-parse.c (yyparse): Also set if compiling .class files. + * jcf-parse.c (read_class); Read current_class. + (jcf_parse): Make static. + (load_inner_classes): New function, with code moved from jcf_parse, + because we need to inner classes after the command-line files are read. + (yyparse): Set finput to NULL when it doesn't need to be closed. + Reduce use of main_jcf (basically only for archive) and + use finput instead of main_jcf->read_state. + Inline jcf_figure_file_type into yyparse. + Set JAVA_FILE_P, CLASS_FILE_P, or ZIP_FILE_P on filename list name. + Defer load_inner_classes and parse_class_file to a second pass, + after we've correctly mapped command-line .clas fiels to classes. + (jcf_figure_file_type): Removed. + * jcf.h (JCF_ZIP, JCF_CLASS, JCF_SOURCE): Removed flags. + (JCF_ZERO): Also clear zipd field. + * zipfile.h: Conditionalize on JCF_H insread of JCF_ZIP. + +2001-03-18 Matt Kraai <kraai@alumni.carnegiemellon.edu> + + * jcf-parse.c (yyparse): Change ch from char * to char. + +2001-03-19 Per Bothner <per@bothner.com> + + * jvspec.c (lang_specific_driver): Check for .zip and .jar files. + Add constructed filelist-file at end, following -xjava. Thus any .o + and library files are not affected by the -xjava. Also wrap + explicit @FILE with -xjava and -xnone. + +2001-03-19 Andrew Haley <aph@cambridge.redhat.com> + + * class.c (build_static_field_ref): Call make_decl_rtl() after + setting the DECL_EXTERNAL flag. + +2001-03-17 Per Bothner <per@bothner.com> + + * decl.c (clear_binding_level): Fix initializer (broke 03-15). + + * jcf-write.c (generate_bytecode_insns): Handle emitting iinc + when result is is needed (target is STACK_TARGET). + + * parse.h (JDEP_SOLV): Removed. + * parse.y (register_incomplete_type): Use JDEP_TO_RESOLVE instead. + + * parse.y (incomplete_class_list): Removed. + (obtain_incomplete_type): Don't use or set incomplete_class_list. + It doesn't work if resolve_class changes the name of an array type + that is on the list and then someone else looks for the modified name. + Also, seems liable to break when compiling multiple source files at + once. So the simplest is to just remove incomplete_class_list - + it is only a minor space win and it is not even clear it saves time. + + * parse.y (resolve_class): Remove unneeded promote_type. + +2001-03-15 Per Bothner <per@bothner.com> + + * java-tree.h (BLOCK_IS_IMPLICIT): New flag. + * parse.h (BLOCK_EXPR_ORIGIN): Removed macro. + * parse.y (declare_local_variables, maybe_absorb_scoping_blocks): + Use BLOCK_IS_IMPLICIT rather than BLOCK_EXPR_ORIGIN. + + * jcf-parse.c (yyparse): Set/reset input_filename for source file. + * parse.y (java_expand_classes): Likewise. + + * parse.y (expand_start_java_method): Was only called once and had a + misleading name, so inline in caller java_complete_expand_method. + (enter_a_block): Likewise inline in enter_block and remove. + + Remove junk from when gcc/java was created (by copying from C/C++). + * decl.c (keep_next_level_flag, keep_next_if_subblocks): Remove. + (struct binding_level): Remove fields keep, keep_if_subblocks, + more_cleanups_ok, have_cleanups (which have never been used). + (pushlevel, poplevel): Remove related useless code. + + * class.c (make_class_data): The class_dtable_decl (i.e. the + vtable for Class) should be external, except when compiling Class. + + * jvspec.c (lang_specific_driver): Fix -C handling. + Check -save-temps to see if temp @FILE should be deleted. + Follow-up to/fix for February 16 patch. + + * verify.c (verify_jvm_instructions): Better error msgs for dup. + (type_stack_dup): Remove no-longer neded error check. + +2001-03-15 Bryce McKinlay <bryce@albatross.co.nz> + + * mangle.c (mangle_record_type): Rename 'from_pointer' argument + to 'for_pointer'. If this type is for a pointer (argument) mangling, + don't surround the element with 'N..E' if the type name is + unqualified. + +2001-03-14 Mark Mitchell <mark@codesourcery.com> + + * class.c (build_static_field_ref): Use COPY_DECL_RTL, + DECL_RTL_SET_P, etc. + (make_method_value): Likewise. + (get_dispatch_table): Likewise. + + * decl.c (push_jvm_slot): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc. + +2001-03-07 Tom Tromey <tromey@redhat.com> + + * config-lang.in (lang_requires): Define. + +2001-03-07 Brad Lucier <lucier@math.purdue.edu> + + * typeck.c (convert): Check flag_unsafe_math_optimizations, + not flag_fast_math. + +2001-03-05 Per Bothner <per@bothner.com> + + Fix a problem where rest_of_decl_compilation applied to + class_dtable_decl causes problems because it was done too early, + before output file was opened. + * decl.c (init_decl_processing): Remove init of class_dtable_decl. + * class.c (class_dtable_decl): Add macro - element of class_roots. + (make_class_data): Define class_dtable_decl. + * java-tree.h (JTI_CLASS_DTABLE_DECL, class_dtable_decl): Removed. + +2001-03-01 Zack Weinberg <zackw@stanford.edu> + + * java/class.c, java/decl.c, java/java-tree.h: Replace all + uses of 'boolean' with 'bool'. + +2001-03-01 Zack Weinberg <zackw@stanford.edu> + + * lang-specs.h: Add zero initializer for cpp_spec field to all + array elements. + +2001-02-16 Per Bothner <per@bothner.com> + + Handle compiling multiple input files at once, and @FILE syntax. + * gcj.texi: Updated documentation to match. + * java-tree.h (flag_filelist_file, init_src_parse): New declarations. + * jcf-parse.c (parse_source_file): Split into ... + (parse_source_file_1): New function - and: + (parse_source_file_2): New function. + (yyparse): On -ffilelist-file, open and scan named file. + On first pass over files, only do parse_source_file_1. + A new second pass calls parse_source_file_2 for each file to compile. + (init_jcf_parse): Call init_src_parse. + * jvspec.c (INDIRECT_FILE_ARG): New flag. + (lang_specific_driver): Support @FILELIST-FILE syntax, as well + as multiple input file combined in one compilation. + * lang-options.h: Add -ffilelist-file + * lang.c (flag_filelist_file): New flag variable. + (lang_f_options): Handle -ffilelist-file. + * lex.c (java_init_lex): Don't clear ctxp->incomplete_class. + * parse.h (struct parse_ctxt): Remove fields incomplete_class and + gclass_list - use global fields of src_parse_roots instead. + * parse.y (src_parse_roots): New array. + (incomplete_class_list, gclass_list): New macros. + (push_parser_context, java_pop_parser_context, + java_parser_context_resume): Don't fiddle with deleted fields. + (various): Use incomplete_class gclass_list and global macros + instead of parse_ctxt fields - the lists are global. + (init_src_parse): New function. + +2001-02-23 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * decl.c (set_block): Set NAMES and BLOCKS from BLOCK. + +2001-02-20 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (check_inner_class_access): Moved declaration of local + `enclosing_decl_type' to the right location. + +2001-02-19 Bryce McKinlay <bryce@albatross.co.nz> + + * parse.y (parser_check_super_interface): Don't call + check_pkg_class_access for an inner interface. + (parser_check_super): Don't call check_pkg_class_access for inner + class. + (do_resolve_class): Simplify enclosing type loop. Don't call + check_pkg_class_access if CL and DECL are not set. + (find_in_imports_on_demand): Set DECL if class_type needed to be + loaded. Don't call check_pkg_class_access for an inner class. + (check_inner_class_access): Rewritten to implement member access + rules as per spec 6.6.1. + (check_pkg_class_access): Handle the empty package correctly. + (in_same_package): New function. Determine if two classes are in the + same package. + +2001-02-18 Bryce McKinlay <bryce@albatross.co.nz> + + * typeck.c (build_java_array_type): Don't try to poke a public `clone' + method into array types. + * parse.y (patch_method_invocation): Bypass access check on clone call + to array instance. + +2001-02-15 Alexandre Petit-Bianco <apbianco@redhat.com> + + * expr.c (build_instanceof): Check for arrays when trying fold to + false. + +2001-02-15 Jim Meyering <meyering@lucent.com> + + * Make-lang.in (java.install-common): Depend on `installdirs'. + (java.install-info): Likewise. + +2001-02-15 Bryce McKinlay <bryce@albatross.co.nz> + + * Make-lang.in (jvspec.o): Modify rule to match that of cp/g++spec.o. + +2001-02-14 Tom Tromey <tromey@redhat.com> + Alexandre Petit-Bianco <apbianco@cygnus.com> + + Fix for PR java/1261. + * typeck.c (build_java_array_type): Add public `clone' method to + arrays. + * parse.y (resolve_qualified_expression_name): Use current_class + when checking for inaccessibility. + (patch_method_invocation): Fixed error message when accessibility + denied. Added `from_super' argument. + +2001-02-14 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (resolve_class): Don't build a fake decl. Use the one + already built. + * typeck.c (build_java_array_type): Build and assign decl to array + type. + +2001-02-14 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (not_accessible_p): Changed leading comment. Added extra + `where' argument. Use it to enforce protected access rules. + (resolve_qualified_expression_name): Added extra argument to + not_accessible_p. + (patch_method_invocation): Use argument `primary' to provide + not_accessible_p with an extra argument. + (lookup_method_invoke): Added extra argument to not_accessible_p. + (search_applicable_method_list): Likewise. + +2001-02-13 Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (resolve_qualified_expression_name): Try to resolve as + an inner class access only if `decl' is a TYPE_DECL. + +2001-02-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (classdollar_identifier_node): Initialize. + * java-tree.h (enum java_tree_index): New entry + `JTI_CLASSDOLLAR_IDENTIFIER_NODE.' + (classdollar_identifier_node): New macro. + (ID_CLASSDOLLAR_P): Likewise. + * parse.y (build_dot_class_method): Use `classdollar_identifier_node.' + (build_dot_class_method_invocation): Likewise. + (find_applicable_accessible_methods_list): `class$' can't be + inherited. + +2001-02-09 Raja R Harinath <harinath@cs.umn.edu> + + * Make-lang.in (java/mangle_name.o): Add 'make' prereqs. + +2001-02-09 Alexandre Petit-Bianco <apbianco@redhat.com> + + * Manke-lang.in (JVGENMAIN_OBJS): Added `errors.o' + * jvgenmain.c (error): Reversed 2001-02-09 patch. `error' is now + gone. + +2001-02-09 Alexandre Petit-Bianco <apbianco@redhat.com> + + * mangle_name (append_unicode_mangled_name): Emit `_' or `U' + outside of the `__U' sequence too. + (unicode_mangling_length): Count `_' or `U' outside of the `__U' + sequence too. + +2001-02-09 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jvgenmain.c (error): Reversed 2001-02-01 deletion. + +2001-02-08 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Make-lang.in (JAVA_OBJS): Added java/mangle_name.o + (JVGENMAIN_OBJS): Likewise. + * java-tree.h (append_gpp_mangled_name): New prototype. + * jcf-parse.c (ggc_mark_jcf): Argument now `void *.' + Removed cast calling `gcc_add_root.' + * jvgenmain.c (mangle_obstack): New global, initialized. + (main): Use it. + (do_mangle_class): Constify local `ptr.' + Removed macro `MANGLE_NAME.' Removed cast in `for.' Call + append_gpp_mangle_name and update `count' if necessary. + Use `mangle_obstack.' + * mangle.c (append_unicode_mangled_name): Removed. + (append_gpp_mangled_name): Likewise. + (unicode_mangling_length): Likewise. + (mangle_member_name): Return type set to `void.' + (mangle_field_decl): Don't append `U' in escaped names. + (mangle_method_decl): Likewise. + (mangle_member_name): Just use `append_gpp_mangled_name.' + * mangle_name.c: New file. + +2001-02-07 Per Bothner <per@bothner.com> + + * check-init.c (check_init): Fix TRY_FINALLY_EXPR logic. + + * check-init.c (check_init): Don't call done_alternative after + processing loop code, as a LOOP_EXPR never terminates normally. + +2001-02-08 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcj.texi: Change sources.redhat.com reference to gcc.gnu.org. + +2001-02-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (HANDLE_SYNTHETIC_ATTRIBUTE): Don't handle field + DECLs. + +2001-02-06 Tom Tromey <tromey@redhat.com> + + * lex.c (java_new_lexer): Longer error message. + +2001-02-05 Jeff Sturm <jeff.sturm@commerceone.com> + Alexandre Petit-Bianco <apbianco@cygnus.com> + + * typeck.c (build_prim_array_type): Added leading comment. + (build_java_array_type): Moved locals out of + block. Always create the `data' field, fixed alignment to match + C++. + +2001-02-04 Tom Tromey <tromey@redhat.com> + + * expr.c (java_lang_expand_expr): Don't bother recomputing + `length'. Use rest_of_decl_compilation, not make_decl_rtl. + Fixes PR java/1866. + +2001-02-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (process_imports): Save the original name of the import + for better error report. + +2001-02-04 Bryce McKinlay <bryce@albatross.co.nz> + + * Make-lang.in (jvspec.o): Add DRIVER_DEFINES to the list + of macros used when compiling jvspec.c. + * jvspec.c (lang_specific_driver): Link with the shared + libgcc by default. + +2001-02-04 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * check-init.c (check_init): Call internal_error instead of fatal. + * expr.c (java_lang_expand_expr): Likewise. + * jcf-parse.c (get_constant): Likewise. + * mangle.c (java_mangle_decl): Likewise. + * parse.y (make_nested_class_name, java_complete_lhs): Likewise. + (operator_string): Likewise. + * check-init.c (check_init): Call abort instead of fatal. + * class.c (build_class_ref): Likewise. + * constants.c (write_constant_pool): Likewise. + * decl.c (start_java_method): Likewise. + * expr.c (push_type, java_stack_pop, java_stack_swap): Likewise. + (java_stack_dup, encode_newarray_type): Likewise. + (build_java_array_length_access): Likewise. + (build_java_check_indexed_type, expand_java_pushc): Likewise. + (build_java_soft_divmod, build_invokeinterface): Likewise. + * java-tree.h (INNER_CLASS_P): Likewise. + * jcf-parse.c (parse_signature, get_name_constant): Likewise. + (give_name_to_class, get_class_constant): Likewise. + * jcf-write.c (CHECK_PUT, CHECK_OP, get_access_flags): Likewise. + (find_constant_index, generate_bytecode_conditional): Likewise. + (generate_bytecode_insns, perform_relocations): Likewise. + * lex.c (java_unget_unicode, java_lex): Likewise. + * mangle.c (mangle_type, mangle_record_type): Likewise. + (mangle_pointer_type, mangle_array_type, init_mangling): Likewise. + (finish_mangling): Likewise. + * parse.h (MARK_FINAL_PARMS): Likewise. + * parse.y (pop_current_osb, unreachable_stmt_error): Likewise. + (obtain_incomplete_type, java_complete_class): Likewise. + (java_check_regular_methods, java_complete_expand_method): Likewise. + (cut_identifier_in_qualified, check_deprecation): Likewise. + (patch_invoke, find_applicable_accessible_methods_list): Likewise. + (java_complete_lhs, lookup_name_in_blocks): Likewise. + (check_final_variable_indirect_assignment, build_unaryop): Likewise. + * typeck.c (set_local_type, parse_signature_type): Likewise. + (parse_signature_string, build_java_signature): Likewise; + (set_java_signature): Likewise. + * verify.c (type_stack_dup, CHECK_PC_IN_RANGE): Likewise. + * class.c (add_method): Call fatal_error instead of fatal. + (build_static_field_ref): Likewise. + * expr.c (build_known_method_ref, expand_invoke): Likewise. + * jcf-parse.c (get_constant, jcf_parse): Likewise. + * lex.c (java_new_new_lexer): Likewise. + * jv-scan.c (main): Likewise. + (fatal_error): Renamed from fatal. + * jcf-parse.c (yyparse): Call fatal_io_error instead of + pfatal_with_name. + * jcf-parse.c (jcf_parse_source): Call fatal_io_error, not fatal. + (yyparse): Likewise. + * jcf-write.c (make_class_file_name, write_classfile): Likewise. + * lex.c (java_get_line_col): Likewise. + * jcf-parse.c (load_class): Make errors non-fatal. + * lex.c (byteswap_init, need_byteswap): Only #ifdef HAVE_ICONV. + +2001-02-01 Bryce McKinlay <bryce@albatross.co.nz> + + * jvgenmain.c (class_mangling_suffix): Remove unused string. + (error): Remove unused function. + (main): Don't use "__attribute__ alias" on generated class symbol. + +2001-01-30 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (init_jcf_parse): Added cast to ggc_add_root's last + argument. + * parse.y (finish_method_declaration): Code accounting for WFLed + method DECL_NAMEs deleted. + (check_abstract_method_definitions): Likewise. + (resolve_type_during_patch): Layout resolved type. + * typeck.c (lookup_do): Removed unused local. + +2001-01-30 Bryce McKinlay <bryce@albatross.co.nz> + + * java-tree.h: Remove JTI_INTEGER_NEGATIVE_ONE_NODE. + * decl.c (init_decl_processing): Use integer_minus_one_node, not + integer_negative_one_node. + * expr.c (build_java_binop): Likewise. + +2001-01-24 Jeff Sturm <jeff.sturm@commerceone.com> + + * zextract.c (read_zip_archive): Read file_offset before writing + zipd and consequently clobbering the header contents. + +2001-01-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in: Remove all dependencies on defaults.h. + * decl.c: Don't include defaults.h. + * expr.c: Likewise. + * parse.y: Likewise. + +2001-01-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * ChangeLog (2001-01-21): Fixed typo. + * class.c (layout_class_method): Code accounting for WFLed + method DECL_NAMEs deleted. + * constant.c (find_methodref_index): Likewise. + * decl.c (lang_mark_tree): Mark `wfl' field in struct lang_decl. + * java-tree.h (DECL_FUNCTION_WFL): New macro. + (struct lang_decl): New field `wfl'. + (java_get_real_method_name): Prototype deleted. + * mangle.c (mangle_method_decl): Code accounting for WFLed + method DECL_NAMEs deleted. + * parse.h (GET_METHOD_NAME): Macro deleted. + * parse.y (reset_method_name): Deleted. + (method_header): Set DECL_FUNCTION_WFL. + (check_abstract_method_header): Code accounting for WFLed method + DECL_NAMEs deleted. + (java_get_real_method_name): Deleted. + (check_method_redefinition): Code accounting for WFLed method + DECL_NAMEs deleted. Use DECL_FUNCTION_WFL. + (java_check_regular_methods): Likewise. + (java_check_abstract_methods): Likewise. + (java_expand_classes): Don't call `reset_method_name.' + (search_applicable_method_list): Use DECL_NAMEs instead of + GET_METHOD_NAME. + * typeck.c (lookup_do): Code accounting for WFLed method + DECL_NAMEs deleted. + +2001-01-25 Richard Earnshaw <rearnsha@arm.com> + + * lex.c (java_read_char): Check for EOF from getc first. + +2001-01-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class): Don't lay the superclass out if it's + already being laid out. + * jcf-parse.c (handle_innerclass_attribute): New function. + (HANDLE_INNERCLASSES_ATTRIBUTE): Invoke + handle_innerclasses_attribute. + (jcf_parse): Don't load an innerclasses if it's already being + laid out. + * jcf-write.c (append_innerclass_attribute_entry): Static + `anonymous_name' and its initialization deleted. `ocii' and `ini' + to be zero for anonymous classes. + +2001-01-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (set_constant_value): Set DECL_FIELD_FINAL_IUD if + necessary. + * jcf-parse.c (set_source_filename): Use + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC if necessary. + +2001-01-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (build_jni_stub): Set DECL_CONTEXT on `meth_var' so it + gets a unique asm name. + +2001-01-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (HANDLE_END_METHODS): Nullify current_method. + (HANDLE_START_FIELD): Invoke MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC + if necessary. + (HANDLE_SYNTHETIC_ATTRIBUTE): New macro. + * jcf-reader.c (get_attribute): Handle `Synthetic' attribute. + * parse.y (lookup_package_type_and_set_next): Deleted. + (resolve_package): Removed unnecessary code. + (find_applicable_accessible_methods_list): `finit$' can't be + inherited. + * verify.c (pop_argument_types): Added missing prototype. + +2001-01-23 Bryce McKinlay <bryce@albatross.co.nz> + + * config-lang.in: Disable java by default. + +2001-01-23 Tom Tromey <tromey@redhat.com> + + * gcj.texi (Copying): New node. + Added copyright information. + +2001-01-21 Per Bothner <per@bothner.com> + + Various fixes to allow compiling a compressed .jar/.zip archive. + * zipfile.h (struct ZipFileCache): Replace by struct ZipFile. + (struct ZipFile): Add fields name and next (from ZipFileCache). + (struct ZipDirectory): New field zipf points to owning ZipFile. + * jcf.h (struct ZipDirectory): Add forward declaration. + (struct JCF): Declare zipd field to have type struct ZipDirectory. + Remove seen_in_zip and zip_offset fields. + (JCF_SEEN_IN_ZIP): New macro. + * zextract.c (read_zip_archive): Set ZipDirectory's zipf field. + * jcf-io.c: Change all ZipFileCache to ZipFile. + (read_zip_member): New function. + (open_in_zip): Call read_zip_member. + * jcf-parse.c (find_in_current_zip): Remove function. + (read_class): Merge in find_in_current_zip functionality. + Call read_zip_member if needed. + (parse_zip_file_entries): Use read_zip_member. + (process_zip_dir): Update for removed and added JCF fields. + (jcf_figure_file_type): Re-use, don't copy initial ZipFile struct. + +2001-01-21 Per Bothner <per@bothner.com> + + Minor optimization of static ggc roots. + * jcf-parse.c (parse_roots): New static field. + (current_field, current_method, current_file_list): Replace by macros + naming fields of parse_roots. + (init_jcf_parse): Combine 3 ggc_add_tree_root calls to 1. + * class.c (class_roots): New static field. + (registered_class, fields_ident, info_ident, class_list): + New macros naming fields of parse_roots. + (build_static_field_ref): Don't register roots here. + (layout_class): Static field list replaced by macro class_list. + (init_class_processing): Call ggc_add_tree_root for 4 roots. + Initialize fields_ident and info_ident here. + +2001-01-21 Per Bothner <per@bothner.com> + + * jcf-parse.c (ggc_mark_jcf): New function. + (init_jcf_parse): Register current_jcf as ggc root. + +2001-01-21 Per Bothner <per@bothner.com> + + * lang.c (put_decl_node): Print method's name. + +2001-01-21 Per Bothner <per@bothner.com> + + * verify.c (VERIFICATION_ERROR_WITH_INDEX): New macro. + (verify_jvm_instructions): Use it, for better error messages on loads. + +2001-01-21 Per Bothner <per@bothner.com> + + * verify.c (merge_type_state): Still may have to merge even if + LABEL_VERIFIED (label). + +2001-01-21 Per Bothner <per@bothner.com> + + * parse.y (method_header): Don't set the DECL_NAME of a FUNCTION_DECL + to a EXPR_WITH_FILE_LOCATION - that is just too fragile and wrong. + +2001-01-19 Per Bothner <per@bothner.com> + + * expr.c (pop_type_0): Only return object_ptr_type_node on mismatch + if expeting an interface type. Refines Tom's change of 2000-09-12. + +2001-01-18 Per Bothner <per@bothner.com> + + * gcj.texi (Input Options): Mention .java files. + +2001-01-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lang-options.h (-Wunsupported-jdk11): Removed. + * lang.c (flag_not_overriding): Deleted. + (flag_static_local_jdk1_1): Likewise. + (lang_W_options): Removed "unsupported-jdk11" entry. + * parse.y (java_check_methods): Removed dead code. + +2001-01-17 Tom Tromey <tromey@redhat.com> + + Changes suggested by Per Bothner: + * gcj.texi (Input Options): Don't mention input files. + (Code Generation): Updated --main information. + (Invoking jcf-dump): Mention that --javap is incomplete. + From Alexandre Petit-Bianco: + (Warnings): Don't mention -Wunsupported-jdk11. + My stuff: + (Compatibility): Mention JDK 1.2-ness of libraries. + (Resources): Mention resources used when writing gcj. + +2001-01-17 Tom Tromey <tromey@redhat.com> + + * gcj.texi: New file. + * Make-lang.in ($(srcdir)/java/gcj.info): New target. + (java.info): Depend on gcj.info. + (java/gcj.dvi): New target. + (java.dvi): Depend on gcj.dvi. + (java.install-info): Wrote. + +2001-01-16 Jeff Sturm <jeff.sturm@appnet.com> + + * expr.c (java_lang_expand_expr): Use TREE_SYMBOL_REFERENCED after + having called make_decl_rtl. + +2001-01-14 Per Bothner <per@bothner.com> + + Various patches to emit better messages on verification errors. + * expr.c (push_type_0): Return error indication on stack overflow, + instead of callinfg fatal. + (push_type): Now just call push_type_0 (nd fatal on overflow). + (pop_type_0): Return detailed error message (in a char** argument). + (pop_type): If pop_type_0 fails, print error message. + (pop_argument_types): Moved to verify.c. + * verify.c (pop_argument_types): Moved from expr.c. + Return a (possible) error message, rather than void. + (POP_TYPE, POP_TYPE_CONV, PUSH_TYPE, PUSH_PENDING): New macros. + (verify_jvm_instruction): Use new macros, improving error messages. + For case OPCODE_astore use object_ptr_type_node. + * java-tree.h (TYPE_UNDERFLOW, TYPE_UNEXPECTED): New macros. + (pop_type_0, push_type_0, pop_argument_types): Update accordingly. + + * parse.y (java_complete_lhs case EXPR_WITH_FILE_LOCATION): If body is + constant, return body without wrapper. (Improves constant folding.) + * lex.c (build_wfl_node): Clear TREE_TYPE from returned node. + +2001-01-13 Per Bothner <per@bothner.com> + + * expr.c (expand_java_field_op): Assigning to a final field outside + an initializer does not violate JVM spec, so should be warning, not + error. (Sun's verifier does not complain - though MicroSoft's does.) + +2001-01-12 Joseph S. Myers <jsm28@cam.ac.uk> + + * gjavah.c (version), jcf-dump.c (version): Update copyright year + to 2001. + +2001-01-11 Bryce McKinlay <bryce@albatross.co.nz> + + * parse.y (resolve_expression_name): Permit instance variables from + enclosing context in super constructor call. + (resolve_qualified_expression_name): Permit enclosing class's qualified + "this" in super constructor call. + +2001-01-10 Mark Mitchell <mark@codesourcery.com> + + * class.c (build_utf8_ref): Remove last argument in call to + make_decl_rtl; use make_function_rtl instead of make_decl_rtl. + (build_class_ref): Likewise. + (build_static_field_ref): Likewise. + (get_dispatch_table): Likewise. + (layout_class_method): Likewise. + (emit_register_classes): Likewise. + * constants.c (build_constant_data_ref): Likewise. + * decl.c (builtin_function): Likewise. + (create_primitive_vtable): Likewise. + * expr.c (build_known_method_def): Likewise. + (build_jni_stub): Likewise. + (java_lang_expand_expr): Likewise. + +2001-01-10 Tom Tromey <tromey@redhat.com> + + * jvspec.c (jvgenmain_spec): Omit -fencoding from cc1 invocation. + +2001-01-08 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (lang_printable_name_wls): New prototype. + * lang.c (put_decl_name): Removed dead code. Use DECL_CONTEXT + rather than `current_class' to print type name. Don't prepend type + names when printing constructor names. + (lang_printable_name_wls): New function. + * jcf-parse.c (jcf_parse_source): Pass NULL `file' argument to + `build_expr_wfl', alway set EXPR_WFL_FILENAME_NODE. + * parse.y (patch_method_invocation): Message tuned for constructors. + (not_accessible_p): Grant `private' access from within + enclosing contexts. + +2001-01-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + All files with updated copyright when applicable. + * Make-lang.in (JVGENMAIN_OBS): Removed java/mangle.o. + * class.c (mangle_class_field): Function removed. + (append_gpp_mangled_type, mangle_static_field, mangle_field): Likewise. + (utf8_cmp, cxx_keyword_p): Moved to lex.c. + (build_class_ref): Call `java_mangle_class_field' instead of + `mangle_class_field.' + (build_dtable_decl): Rewritten to call `java_mangle_vtable.' + (layout_class): Call `java_mangle_decl' instead of + `mangle_static_field.' + (cxx_keywords): Initialized static array moved to `lex.c.' + (layout_class_method): Changed leading comment. Simplified to + call `java_mangle_decl.' Local `ptr' moved in for loop body. + * decl.c (lang_mark_tree): Mark field `package_list.' + * java-tree.h (TYPE_PACKAGE_LIST): New macro. + (struct lang_type): New field `package_list.' + (unicode_mangling_length): Prototype removed. + (append_gpp_mangled_name, append_gpp_mangled_classtype, + emit_unicode_mangled_name): Likewise. + (cxx_keyword_p): New prototype. + (java_mangle_decl, java_mangle_class_field, + java_mangle_class_field_from_string, java_mangle_vtable): Likewise. + * jcf-parse.c (jcf_parse_source): Constify `file' argument to + `build_expr_wfl.' + * jvgenmain.c (main_method_prefix): Global variable removed. + (main_method_suffix): Likewise. + (do_mangle_classname): New function. + (main): Call it. Format changed to accommodate new mangling scheme. + * lex.c: (utf8_cmp): Conditionally prototyped. + (cxx_keywords): Moved from class.c, conditionally defined. + (utf8_cmp, cxx_keyword_p): Likewise. + * mangle.c (obstack.h, ggc.h): Included. + (mangle_field_decl): New function. + (mangle_method_decl, mangle_type, mangle_pointer_type, + mangle_array_type, mangle_record_type, + find_compression_pointer_match, find_compression_array_match, + find_compression_record_match, + find_compression_array_template_match, set_type_package_list, + entry_match_pointer_p, emit_compression_string, init_mangling, + finish_mangling, compression_table_add, mangle_member_name): Likewise. + (mangle_obstack): New global. + (MANGLE_RAW_STRING): New macro. + (unicode_mangling_length): Turned static. + (append_unicode_mangled_name): Renamed from + `emit_unicode_mangled_name.' Turned static. `mangle_obstack' + replaces `obstack', removed from the parameter list. + (append_gpp_mangled_name): Turned static. `mangle_obstack' + replaces parameter `obstack', removed from the parameter list. Call + `append_unicode_mangled_name' instead of `emit_unicode_mangled_name. + (append_gpp_mangled_classtype): Removed. + (compression_table, compression_next): New static variables. + * parse.y (temporary_obstack): Extern declaration removed. + +2001-01-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_binop): Compute missing type in error situations. + +2001-01-05 Bryce McKinlay <bryce@albatross.co.nz> + + * class.c (make_class_data): Push initial value for "arrayclass". + * decl.c (init_decl_processing): Add new class field "arrayclass". + +2001-01-05 Bryce McKinlay <bryce@albatross.co.nz> + + From patha@softlab.ericsson.se: + * parse.y (switch_label): Use build, not build1, to construct + DEFAULT_EXPR. + +2001-01-04 Neil Booth <neil@daikokuya.demon.co.uk> + + * lang.c (lang_decode_option): Change -MA to -MP. + * jcf-depend.c (jcf_dependency_add_target, jcf_dependency_set_target): + Update to new prototype; do quote targets. + (jcf_dependency_write): Update. + +2000-12-22 Bryce McKinlay <bryce@albatross.co.nz> + + Shorten primitive array allocation path: + * decl.c (init_decl_processing): Use _Jv_NewPrimArray not _Jv_NewArray + to create new primitive arrays. + * expr.c (build_newarray): If generating native code, call + soft_newarray_node with a reference to the primitive TYPE identifier + instead of type_value. + +2000-12-17 Bryce McKinlay <bryce@albatross.co.nz> + + Fix for PRs gcj/312 and gcj/253: + * parse.y (valid_ref_assignconv_cast_p): Load classes for source and + dest if they arn't already. + * class.c (layout_class): Call maybe_layout_super_class on + superinterfaces also, but only if compiling from bytecode. + + Fix for PR gcj/373: + * parse.y (create_class): Set ACC_STATIC if class is declared in an + interface. + +2000-12-15 Tom Tromey <tromey@redhat.com> + + * jcf-parse.c (jcf_parse_source): Set wfl_operator if not already + set. + +2000-12-14 Andrew Haley <aph@redhat.com> + + * boehm.c (mark_reference_fields): Change test to correctly detect + bitmap overflow. + +2000-12-15 Andreas Jaeger <aj@suse.de> + + * config-lang.in (lang_dirs): Added. + +2000-12-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (end_artificial_method_body): Fixed undefined behavior. + Credits go to rth for finding it. + +2000-12-13 Mike Stump <mrs@wrs.com> + + * parse.y (check_static_final_variable_assignment_flag): Fix spelling. + +2000-11-07 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (JAVA_LEX_C): Added chartables.h. + * lex.c (java_ignorable_control_p): Removed. + (java_letter_or_digit_p): Removed. + (java_start_char_p): New function. + (java_read_char): Return `int', not `unicode_t'. Changed + callers. + (java_read_unicode): Likewise. + (java_read_unicode_collapsing_terminators): Likewise. + (java_get_unicode): Likewise. + (java_new_lexer): Initialize hit_eof. + (java_parse_end_comment): Take `int' argument. + (java_parse_doc_section): Likewise. + (java_parse_escape_sequence): Don't allow backlash-newline. + Return `int'. + * lex.h (JAVA_DIGIT_P): Removed. + (_JAVA_LETTER_OR_DIGIT_P): Removed. + (_JAVA_IDENTIFIER_IGNORABLE): Removed. + (JAVA_START_CHAR_P): Renamed from JAVA_ID_CHAR_P. + (JAVA_PART_CHAR_P): New macro. + (UEOF): Now -1. + (JAVA_CHAR_ERROR): Now -2. + (java_lexer): New field `hit_eof'. + * chartables.h: New file. + * gen-table.pl: new file. + +2000-11-20 Tom Tromey <tromey@cygnus.com> + Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_complete_lhs): Only allow compound assignment of + reference type if type is String. + +2000-12-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Make-lang.in (java/jcf-path.o:): libgcj.jar replaces libgcj.zip. + jcf-path.c: Likewise. + +2000-12-09 Anthony Green <green@redhat.com> + + * zipfile.h (ZipDirectory): Declare size, uncompressed_size, + filestart and filename_length as int values. + +2000-12-07 Mo DeJong <mdejong@redhat.com> + + * jcf-io.c (find_class): Correct the logic that tests to see if a + .java file is newer than its .class file. The compiler was + incorrectly printing a warning when file mod times were equal. + +2000-12-07 Zack Weinberg <zack@wolery.stanford.edu> + + * jvgenmain.c: Use ISPRINT not isascii. + +2000-12-06 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (end_artificial_method_body): Fixed typo. + +2000-12-04 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_method_invocation): Pick the correct enclosing + context when creating inner class instances. + Fixes gcj/332. + +2000-11-26 Joseph S. Myers <jsm28@cam.ac.uk> + + * gjavah.c (version), jcf-dump.c (version), jv-scan.c (version): + Update copyright year to 2000. + +2000-11-23 Anthony Green <green@redhat.com> + + * jcf-parse.c (init_jcf_parse): Register current_file_list root. + Move current_file_list out of yyparse and make it static. + + * expr.c: Declare quick_stack and tree_list_free_list as static + (init_expr_processing): Register quick_stack and + tree_list_free_list roots. + +2000-11-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (build_outer_field_access): New local `decl_ctx', use + it. Check for field's context and current class immediate outer + context inheritance. + (outer_field_access_p): Consider fields inherited from the last + enclosing context. + (build_access_to_thisn): Stop at the last enclosing context if + necessary. + Fixes gcj/367. + +2000-11-23 J"orn Rennecke <amylaar@redhat.com> + + * Make-lang.in (jvspec.o): Depend on $(CONFIG_H). + +2000-11-22 Bryce McKinlay <bryce@albatross.co.nz> + + * jcf-parse.c (get_constant): Call UT8_CHAR_LENGTH on `utf8', not the + scratch buffer. + +2000-11-20 Tom Tromey <tromey@cygnus.com> + + * jv-scan.c (help): Document --complexity. + (options): Added --complexity. + (flag_complexity): New global. + (main): Call `report'. + * parse-scan.y (complexity): New global. + (if_then_statement, if_then_else_statement, + if_then_else_statement_nsi, switch_block_statement_group, + while_expression, do_statement, for_begin, continue_statement, + throw_statement, catch_clause, finally, method_invocation, + conditional_and_expression, conditional_or_expression, + conditional_expression): Update complexity. + (reset_report): Reset complexity. + (report): New function. + +2000-11-20 Tom Tromey <tromey@cygnus.com> + + * lex.c (yylex): Added STRICT_TK case. + * parse.y (STRICT_TK): Added. + * parse-scan.y (STRICT_TK): Added. + * Make-lang.in ($(srcdir)/java/keyword.h): Added missing `\' and + `;'. Use 4, not 3, with -k option. Correctly rename resulting + file. + * keyword.h: Rebuilt. + * keyword.gperf (strictfp): Added. + +2000-11-20 Tom Tromey <tromey@cygnus.com> + + * lex.c (yylex): Recognize floating point constants with leading + 0. + +2000-11-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * java-tree.h (cyclic_inheritance_report): Constify. + * parse.y (cyclic_inheritance_report): Likewise. + +2000-11-17 Zack Weinberg <zack@wolery.stanford.edu> + + * parse.y (goal): Remove call to ggc_add_string_root. + +2000-11-16 Zack Weinberg <zack@wolery.stanford.edu> + + * jcf-parse.c (get_constant), parse.y (do_merge_string_cste): + Create string in scratch buffer, then pass to build_string. + +2000-11-13 Joseph S. Myers <jsm28@cam.ac.uk> + + * parse.y (issue_warning_error_from_context): Add + ATTRIBUTE_PRINTF. + +2000-11-11 Anthony Green <green@redhat.com> + + * jcf-parse.c (process_zip_dir): Add finput parameter. + (jcf_figure_file_type): Call process_zip_dir with appropriate + argument. + +2000-11-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * decl.c (copy_lang_decl): Use memcpy, not bcopy. + * jcf-parse.c (jcf_figure_file_type): Likewise. + +2000-11-09 Joseph S. Myers <jsm28@cam.ac.uk> + + * parse.y (create_new_parser_context): Use memset () instead of + bzero (). + +2000-11-08 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (process_file): Only include gcj/cni.h when generating + CNI stubs. + +2000-11-07 Joseph S. Myers <jsm28@cam.ac.uk> + + * expr.c (note_instructions), jcf-io.c (find_class), jcf-parse.c + (init_outgoing_cpool), lex.c (java_init_lex): Use memset () + instead of bzero (). + +2000-11-05 Tom Tromey <tromey@cygnus.com> + + * lex.h (JAVA_FLOAT_RANGE_ERROR): Typo fix. + * lex.c (IS_ZERO): New define. + (java_perform_atof): Error on floating point underflow. + +2000-11-04 Tom Tromey <tromey@cygnus.com> + + * lex.c (java_parse_escape_sequence): Only read two octal + characters if the first one is greater than 3. Don't allow + "octal" numbers to include the digits 8 or 9. + +2000-11-05 Joseph S. Myers <jsm28@cam.ac.uk> + + * Make-lang.in (java.distdir): Remove. + +2000-11-03 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (java.dvi): New target. + Partial fix for PR other/567. + + * lang-options.h: Mention -Wout-of-date. + * jcf-dump.c (flag_newer): New global. + * gjavah.c (flag_newer): New global. + * jcf-io.c (find_class): Only warn when flag_newer set. + * lang.c (flag_newer): New global. + (struct string_option): New declaration. + (lang_W_options): New global. + (process_option_with_no): New function. + (lang_decode_option): Use it. + + * class.c (cxx_keyword_p): Accept keywords with trailing `$'s. + * gjavah.c (cxx_keyword_subst): Handle any number of trailing + `$'. + + * lex.h (_JAVA_IDENTIFIER_IGNORABLE): New macro. + (JAVA_ID_CHAR_P): Also try java_ignorable_control_p. + * lex.c (java_read_unicode): Removed `term_context' argument. + Recognize any number of `u' in `\u'. + (java_read_unicode_collapsing_terminators): New function. + (java_get_unicode): Use it. + (java_lineterminator): Removed. + (yylex): Produce error if character literal is newline or single + quote. Return if eof found in middle of `//' comment. EOF in + `//' comment is only an error if pedantic. + (java_ignorable_control_p): New function. + (java_parse_end_comment): Return if eof found in middle of + comment. + Include flags.h. + * jv-scan.c (pedantic): New global. + +2000-10-31 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (outer_field_access_p): Inherited fields aren't + consider outer fields. + (maybe_build_thisn_access_method): Use + PURE_INNER_CLASS_TYPE_P instead of INNER_CLASS_TYPE_P. + (resolve_expression_name): Trigger an error if a static field + is being accessed as an outer field. + +2000-10-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Make-lang.in (LIBGCJ_ZIP_FILE): Define with `$(prefix)'. + Fixes gcj/365. + +2000-10-27 Zack Weinberg <zack@wolery.stanford.edu> + + * Make-lang.in: Move all build rules here from Makefile.in, + adapt to new context. Wrap all rules that change the current + directory in parentheses. Expunge all references to $(P). + When one command depends on another and they're run all at + once, use && to separate them, not ;. Add OUTPUT_OPTION to + all object-file generation rules. Delete obsolete variables. + + * Makefile.in: Delete. + * config-lang.in: Delete outputs= line. + +2000-10-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_method_invocation): NULLify this_arg when already + inserted. + (maybe_use_access_method): Handle call to methods unrelated to the + current class. Fixed comment. + Fixes gcj/361. + +2000-10-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (INNER_ENCLOSING_SCOPE_CHECK): Check inherited type in + scope. + +2000-10-24 Tom Tromey <tromey@cygnus.com> + + * lex.c (java_new_lexer): Initialize new fields. Work around + broken iconv() implementations. + (java_read_char): Swap bytes if required. Use fallback decoder if + required. + (byteswap_init, need_byteswap): New globals. + (java_destroy_lexer): Only close iconv handle if it is in use. + * lex.h (java_lexer): New fields read_anything, byte_swap, + use_fallback. + Made out_buffer unsigned. + +2000-10-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (register_incomplete_type): Include JDEP_FIELD as a case + where an enclosing context can be set on the jdep. + (do_resolve_class): Fixed identation. + +2000-10-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (NEED_PEEK_ATTRIBUTE, NEED_SKIP_ATTRIBUTE): Define + + * jcf-reader.c (peek_attribute, skip_attribute): Only define + when requested. + + * parse.h (yyerror): If JC1_LITE, mark with ATTRIBUTE_NORETURN. + + * verify.c (CHECK_PC_IN_RANGE): Cast result of stmt-expr to void. + +2000-10-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (OP1): Update `last_bc'. + (struct jcf_block): Fixed indentation and typo in comments. New + field `last_bc'. + (generate_bytecode_insns): Insert `nop' if `jsr' immediately + follows `monitorenter'. + * parse.y (patch_synchronized_statement): New local `tmp'. Call + `patch_string'. + Fixes gcj/232. + +2000-10-16 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (lang_specific_driver): Recognize -MF and -MT. + * lang-specs.h: Added %{MA}, %{MF*}, %{MT*}. + * lang-options.h: Added -MA, -MT, -MF.. + * lang.c (lang_decode_option): Recognize -MA, -MT, -MF. + (DEPEND_TARGET_SET): New macro. + (DEPEND_FILE_ALREADY_SET): Likewise. + (init_parse): Handle new flags. + * jcf.h (jcf_dependency_print_dummies): Declare. + * Make-lang.in (s-java): Added mkdeps.o. + * Makefile.in (BACKEND): Added mkdeps.o. + (../gcjh$(exeext)): Added mkdeps.o. + (../jcf-dump$(exeext)): Added mkdeps.o. + * jcf-depend.c: Include mkdeps.h. + (struct entry, dependencies, targets, MAX_OUTPUT_COLUMNS, + add_entry): Removed. + (jcf_dependency_reset): Rewrote. + (dependencies): New global. + (jcf_dependency_set_target): Rewrote. + (jcf_dependency_add_target): Likewise. + (jcf_dependency_add_file): Likewise. + (munge): Removed. + (print_ents): Removed. + (jcf_dependency_write): Rewrote. + (print_dummies): New global. + (jcf_dependency_print_dummies): New function + (jcf_dependency_write): Call deps_dummy_targets if required. + +2000-10-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * gjavah.c (add_class_decl): Removed unused variables `tname', + `tlen' and `name_index'. + * java-tree.h (BUILD_FILENAME_IDENTIFIER_NODE): New macro. + * jcf-parse.c (jcf_parse_source): Use it and set EXPR_WFL_FILENAME + in `wfl_operator' with value. + (yyparse): Use BUILD_FILENAME_IDENTIFIER_NODE. + (jcf_figure_file_type): Fixed identation. + * lex.c (java_get_line_col): Use EOF. Tuned `^' placement. + * parse.y (analyze_clinit_body): New function. + (static_initializer:): Reset `current_static_block'. + (java_parser_context_restore_global): Set EXPR_WFL_FIILENAME_NODE in + `wfl_operator' with new value. + (lookup_cl): Use EXPR_WFL_FILENAME. + (maybe_yank_clinit): Handle bogus <clinit> bodies, call + analyze_clinit_body. + (build_outer_field_access): Access to this$<n> built from + current_class, not its outer context. + (build_access_to_thisn): Fixed leading comment. Tidied things up. + (resolve_qualified_expression_name): Handle `T.this' and `T.this.f()'. + (patch_method_invocation): Use `is_static_flag' when already + initialized. + (patch_newarray): Removed assignment in ternary operator. + +2000-10-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * except.c (free_eh_ranges): Don't free `whole_range'. + +2000-10-15 Anthony Green <green@redhat.com> + + * decl.c (init_decl_processing): Call init_class_processing before + anything else. + +2000-10-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (check_init): Fixed leading comment. Use + LOCAL_FINAL_P. + * decl.c (push_jvm_slot): Use MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC. + (give_name_to_locals): Likewise. + (lang_mark_tree): Handle FIELD_DECL. Register `am' and `wfl' + fields in lang_decl_var. + * java-tree.h (DECL_FUNCTION_SYNTHETIC_CTOR, + DECL_FUNCTION_ALL_FINAL_INITIALIZED): New macros. + (FIELD_INNER_ACCESS): Removed ugly cast, macro rewritten. + (FIELD_INNER_ACCESS_P, DECL_FIELD_FINAL_IUD, DECL_FIELD_FINAL_LIIC, + DECL_FIELD_FINAL_IERR, DECL_FIELD_FINAL_WFL): New macros. + (LOCAL_FINAL): Rewritten. + (LOCAL_FINAL_P, FINAL_VARIABLE_P, CLASS_FINAL_VARIABLE_P + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): New macros. + (struct lang_decl): Fixed comments. Added `synthetic_ctor' and + `init_final' fields. + (struct lang_decl_var): Fixed leading comment. Added `am', `wfl', + `final_uid', `final_liic', `final_ierr' and `local_final' fields. + (TYPE_HAS_FINAL_VARIABLE): New macro. + (struct lang_type): Added `afv' field. + * parse.y (check_static_final_variable_assignment_flag): New function. + (reset_static_final_variable_assignment_flag): Likewise. + (check_final_variable_local_assignment_flag): Likewise. + (reset_final_variable_local_assignment_flag): Likewise. + (check_final_variable_indirect_assignment): Likewise. + (check_final_variable_global_assignment_flag): Likewise. + (add_inner_class_fields): Use LOCAL_FINAL_P. + (register_fields): Handle local finals and final variables. + (craft_constructor): Set DECL_FUNCTION_SYNTHETIC_CTOR. + (declare_local_variables): Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC. + (source_start_java_method): Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC + on local finals. + (java_complete_expand_methods): Loop to set + TYPE_HAS_FINAL_VARIABLE. Call + `reset_final_variable_local_assignment_flag' and + `check_final_variable_local_assignment_flag' accordingly before + and after constructor expansion. Call + `reset_static_final_variable_assignment_flag' + before expanding <clinit> and after call + `check_static_final_variable_assignment_flag' if the + current_class isn't an interface. After all methods have been + expanded, call `check_final_variable_global_assignment_flag' and + `check_static_final_variable_assignment_flag' if the current class + is an interface. + (maybe_yank_clinit): Fixed typo in comment. + (build_outer_field_access_methods): Removed old sanity check. Use + FIELD_INNER_ACCESS_P. Call MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC. + Don't create access methods for finals. + (resolve_field_access): Use `CLASS_FINAL_VARIABLE_P'. + (java_complete_tree): Likewise. Reset DECL_FIELD_FINAL_IUD if + existing DECL_INIT has been processed. + (java_complete_lhs): Likewise. + (check_final_assignment): Filter input on `lvalue''s TREE_CODE. + Test for COMPONENT_REF to get to the FIELD_DECL. Implemented new + logic. + (patch_assignment): Use LOCAL_FINAL_P. + (fold_constant_for_init): Reset DECL_FIELD_FINAL_IUD if + DECL_INITIAL is nullified. + Fixes gcj/163. + +2000-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (parse.c, parse-scan.c): Create atomically. + + * Makefile.in (parse.c, parse-scan.c): Likewise. + +2000-10-12 Mark Mitchell <mark@codesourcery.com> + + * class.c (temporary_obstack): Remove. + (make_class): Don't mess with obstascks. + (push_class): Likewise. + (set_super_info): Likewise. + (add_method_1): Likewise. + (add_method): Likewise. + (add_field): Likewise. + (build_utf8_ref): Likewise. + (build_class_ref): Likewise. + (build_static_field_ref): Likewise. + (finish_class): Likewise. + (push_super_field): Likewise. + (layout_class): Likewise. + (layout_class_methods): Likewise. + (init_class_processing): Likewise. + * constants.c (get_tag_node): Likewise. + (build_constant_data_ref): Likewise. + * decl.c (ggc_p): Remove. + (copy_lang_decl): Use ggc_alloc. + (complete_start_java_method): Don't mess with obstacks. + (start_java_method): Likewise. + (end_java_method): Likewise. + * except.c (link_handler): Use xmalloc. + (free_eh_ranges): New function. + (method_init_exceptions): Use it. + (add_handler): Use xmalloc. + (expand_start_java_handler): Don't mess with obstacks. + (prepare_eh_table_type): Likewise. + (expand_end_java_handler): Likewise. + * expr.c (push_value): Likewise. + (create_label_decl): Likewise. + (build_jni_stub): Likewise. + (java_lang_expand_expr): Likewise. + (note_instructions): Use xrealloc. + (java_push_constant_from_pool): Don't mess with obstacks. + (process_jvm_instruction): Likewise. + * java-tree.h (cyclic_inheritance_report): Remove duplicate + declaration. + * jcf-parse.c (get_constant): Don't mess with obstacks. + (read_class): Likewise. + (jcf_parse): Likewise. + * lex.c (expression_obstack): Remove. + (java_lex): Don't use obstack_free. + * parse.h (exit_java_complete_class): Don't mess with obstacks. + (MANGLE_OUTER_LOCAL_VARIABLE_NAME): Adjust. + (MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID): Likewise. + (MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STRING): Likewise. + * parse.y (gaol): Add more GC roots. + (add_inner_class_fields): Adjust calls to MANGLE_* macros. + (lookup_field_wrapper): Likewise. + (obtain_incomplete_type): Don't mess with obstacks. + (build_alias_initializer_parameter_list): Adjust calls to MANGLE_* + macros. + (craft_constructor): Don't mess with obstacks. + (safe_layout_class): Likewise. + (java_complete_class): Likewise. + (source_end_java_method): Likewise. + (build_outer_field_access_methods): Likewise. + (build_outer_method_access_method): Likewise. + (maybe_build_thisn_access_method): Likewise. + (build_dot_class_method_invocation): Likewise. + (java_complete_tree): Likewise. + (java_complete_lhs): Likewise. + (do_merge_string_cste): Likewise. + (patch_string_cst): Likewise. + (array_constructor_check_entry): Likewise. + * typeck.c (build_java_array_type): Likewise. + (parse_signature_string): Likewise. + (build_java_signature): Likewise. + +2000-10-12 Tom Tromey <tromey@cygnus.com> + + Fix for PR gcj/356: + * gjavah.c (add_class_decl): Don't special-case inner classes. + (add_namelet): Likewise. + +2000-10-11 Rodney Brown <RodneyBrown@mynd.com> + + * java-tree.h: Constify current_encoding. + * lang.c: Constify current_encoding. + +2000-10-10 Jeff Sturm <jeff.sturm@appnet.com> + + * jvgenmain.c (class_mangling_suffix): Omit `.'. + (main): Use `$' when NO_DOLLAR_IN_LABEL is not set, otherwise `.'. + +2000-10-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (java_lang_expand_expr): Reinstall 1999-08-14 Anthony's + patch. Fixes gcj/340. + +2000-10-10 Tom Tromey <tromey@cygnus.com> + + * lex.c (java_new_lexer): Initialize out_first and out_last + fields. + * lex.h (java_lexer): Added out_buffer, out_first, out_last. + +2000-10-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (pop_current_osb): New function. + (array_type:): Use `dims:', changed actions + accordingly. Suggested by Anthony Green. + (array_creation_expression:): Used pop_current_osb. + (cast_expression:): Likewise. + (search_applicable_method_list): Fixed indentation. + +2000-10-08 Anthony Green <green@redhat.com> + + * parse.y (array_type_literal): Remove production. + (type_literals): Refer to array_type, not array_type_literal. + +2000-10-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + Patch contributed by Corey Minyard. + * decl.c (check_local_named_variable): New function. + (tree check_local_unnamed_variable): Likewise. + (find_local_variable): Splitted. Call check_local_{un}named_variable. + +2000-10-07 Anthony Green <green@redhat.com> + + * class.c (layout_class): Handle case where superclass can't be + layed out yet. + +2000-10-07 Joseph S. Myers <jsm28@cam.ac.uk> + + * Makefile.in (keyword.h): Refer to GNU FTP site for updated + gperf. + +2000-10-05 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (jvgenmain_spec): Added `-fdollars-in-identifiers'. + * jvgenmain.c (class_mangling_prefix): Removed. + (class_mangling_suffix): New global. + (main): Use it. + * gjavah.c (cxx_keyword_subst): Mangle C++ keywords by appending + `$'. + (print_method_info): Handle overrides for static and final + methods. + (process_file): Generate declaration for class object field. + * class.c (cxx_keywords): New array. + (utf8_cmp): New function. + (cxx_keyword_p): New function. + (layout_class_method): Mangle C++ keywords by appending `$'. + (mangle_field): New function. + (mangle_class_field): Use mangle_field. Mangle class name as + `class$'. + (mangle_static_field): Use mangle_field. + +2000-10-03 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (find_local_variable): Removed uncessary type check and + fixed range check typo. From Corey Minyard. + +2000-09-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (give_name_to_locals): New local `code_offset'. Call + `maybe_adjust_start_pc'. + * expr.c (note_instructions): New function. + (expand_byte_code): Don't collect insn starts here. + (peek_opcode_at_pc): New function. + (maybe_adjust_start_pc): Likewise. + * java-tree.h (maybe_adjust_start_pc): Declare. + (note_instructions): Likewise. + * jcf-parse.c (parse_class_file): Call `note_instructions'. + +2000-09-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (field_access:): Fixed indentation. + (qualify_ambiguous_name): Properly qualify `this.a[b].c'. + +2000-09-07 Tom Tromey <tromey@cygnus.com> + + Fix for PR gcj/307: + * parse.y (patch_binop): Use JNUMERIC_TYPE_P, not + JPRIMITIVE_TYPE_P, for arithmetic operators. + (patch_method_invocation): Indentation fix. + (try_builtin_assignconv): Handle boolean specially. Fixed typo. + (valid_builtin_assignconv_identity_widening_p): Handle boolean. + (do_unary_numeric_promotion): Cleaned up code. + (valid_cast_to_p): Handle boolean correctly. + +2000-09-27 Tom Tromey <tromey@cygnus.com> + + * lex.c (java_read_unicode): Reset bs_count when finished with + `\u' sequence. + +2000-10-01 Mark Mitchell <mark@codesourcery.com> + + Convert to GC. + * Make-lang.in (s-java): Don't depend on ggc-callbacks.o. + * Makefile.in (BACKEND): Don't include ggc-callbacks.o. + (typeck.o): Depend on ggc.h. + * class.c (add_method_1): Use GC functions for allocation. + (init_class_processing): Register roots. + * decl.c (ggc_p): Set to 1. + (pending_local_decls): Make it static. + (push_jvm_slot): Use GC functions for allocation. + (init_decl_processing): Register roots. + (give_name_to_locals): Use GC functions for allocation. + (lang_mark_tree): New function. + * java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Use GC + functions for allocation. + * jcf-parse.c (jcf_parse_source): Use ggc_strdup. + * lex.c (java_lex): Use build_string, rather than replicating it + inline. + * parse.y (goal): Add more roots. + (mark_parser_ctxt): New function. + * typeck.c: Include ggc.h. + +2000-09-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (maybe_yank_clinit): Also keep <clinit> if its body + contains something else than MODIFY_EXPR. + +2000-09-23 Mark Mitchell <mark@codesourcery.com> + + * Make-lang.in (JAVA_SRCS): Include java-tree.h. + * Makefile.in (parse.o): Depend on ggc.h. + (class.o): Likewise. + (constants.o): Likewise. + (decl.o): Likewise. + (expr.o): Likewise. + (jcf-parse.o): Likewise. + (jcf-write.o): Likewise. + (mangle.o): Likewise. + * class.c: Include ggc.h. + (build_static_field_ref): Register GC roots. + (layout_class): Likewise. + (init_class_processing): Likewise. + * constants.c: Include ggc.h. + (current_constant_pool_data_ref): Remove. + (tag_nodes): Move it to ... + (get_tag_node): ... here. Register GC roots. + * decl.c: Include ggc.h. Remove many global tree definitions. + (throw_node): Define. + (java_global_trees): Likewise. + (predef_filenames): Make the size a constant. + (init_decl_processing): Adjust accordingly. + (init_decl_processing): Call init_jcf_parse. Register GC roots. + * expr.c: Include ggc.h. + (init_expr_processing): Register GC roots. + (build_invokeinterface): Likewise. + * java-tree.h: Replace extern tree declarations with macros. + (java_global_trees): New variable. + (java_tree_index): New enumeration. + (init_jcf_parse): Declare. + * jcf-parse.c: Include ggc.h. + (current_class): Remove declaration. + (main_class): Likewise. + (all_class_list): Likewise. + (predefined_filename_p): Adjust for constant size of + predef_filenames. + (init_jcf_parse): New function. + * jcf-write.c: Include ggc.h. + (generate_classfile): Register GC roots. + (append_synthetic_attribute): Likewise. + (append_innerclass_attribute_entry): Likewise. + * lang.c: Include ggc.h. + (lang_print_error): Register GC roots. + * parse.h (struct parser_ctxt): Rename fields to avoid conflicts + with macros. + * parse.y: Include ggc.h. + (wfl_operator): Remove. + (goal): Register GC roots. + (java_pop_parser_context): Adjust for new field names. + (java_parser_context_save_global): Likewse. + (java_parser_context_restore_global): Likewise. + (java_parser_context_suspend): Likewise. + (java_parser_context_resume): Likewise. + (verify_constructor_circularity): Register GC roots. + (lookup_cl): Likewise. + (java_reorder_fields): Likewise. + (build_current_this): Likewise. + (class_in_current_package): Likewise. + (argument_types_convertible): Likewise. + (patch_cast): Rename wfl_op parameter to avoid macro conflicts. + +2000-09-14 Tom Tromey <tromey@cygnus.com> + + * lex.h: Use HAVE_ICONV_H, not HAVE_ICONV. + +2000-09-13 Tom Tromey <tromey@cygnus.com> + + * jcf-parse.c: Include <locale.h>. + * jv-scan.c: Include <locale.h>. + +2000-09-12 Tom Tromey <tromey@cygnus.com> + + * expr.c (pop_type_0): Return `Object' if trying to merge two + interface types. + * verify.c (merge_types): Don't return `TYPE_UNKNOWN' for + interface types; `Object' is always a valid supertype. + +2000-09-12 Tom Tromey <tromey@cygnus.com> + + Fix for PR gcj/33: + * jv-scan.c (help): Document --encoding. + (options): Added `encoding' entry. + (OPT_ENCODING): New define. + (main): Handle --encoding. + Include <langinfo.h> if nl_langinfo exists. + * lang-options.h: Document --classpath, --CLASSPATH, --main, and + --encoding. + * jcf-parse.c Include <langinfo.h> if we have nl_langinfo. + (parse_source_file): Correctly call java_init_lex. Added `finput' + argument. Use nl_langinfo to determine default encoding. + * java-tree.h (current_encoding): Declare. + * parse.y (java_parser_context_restore_global): Don't restore + `finput'. + (java_parser_context_save_global): Don't set `finput' field. + (java_pop_parser_context): Don't restore `finput'. Free old lexer + if required. + * lang.c (current_encoding): New global. + (lang_decode_option): Recognize `-fencoding='. + (finish_parse): Don't close finput. + * parse.h (struct parser_ctxt): Removed `finput' and + `unget_utf8_value' fields. Added `lexer' field. + (java_init_lex): Fixed declaration. + * lex.c (java_new_lexer): New function. + (java_destroy_lexer): Likewise. + (java_read_char): Added `lex' argument. Handle iconv case. + (java_read_unicode): Added `lex' argument. Count backslashes in + lexer structure. + (java_init_lex): Added `finput' and `encoding' arguments. Set + `lexer' field in ctxp. + (BAD_UTF8_VALUE): Removed. + (java_lex): Handle seeing UEOF in the middle of a string literal. + * lex.h: Include <iconv.h> if HAVE_ICONV defined. + (java_lexer): New structure. + (UNGETC): Removed. + (GETC): Removed. + (DEFAULT_ENCODING): New define. + (java_destroy_lexer): Declare. + +2000-09-12 Tom Tromey <tromey@cygnus.com> + + Fix for PR gcj/343: + * lex.c (java_init_lex): Initialize java_io_serializable. + * parse.y (java_io_serializable): New global. + (valid_ref_assignconv_cast_p): An array can be cast to + serializable. + +2000-09-10 Zack Weinberg <zack@wolery.cumb.org> + + * decl.c, expr.c: Include defaults.h if not already included. + Don't define the *_TYPE_SIZE macros. + +2000-09-09 Geoffrey Keating <geoffk@cygnus.com> + + * typeck.c (build_java_array_type): Correct first parameter + in ADJUST_FIELD_ALIGN invocation. + +2000-09-06 Tom Tromey <tromey@cygnus.com> + + * lang-specs.h: Also recognize `-femit-class-files'. + +2000-09-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * verify.c (merge_types): Load the types to merge if necessary. + +2000-09-02 Anthony Green <green@redhat.com> + + * jcf-io.c: Include zlib.h. + (open_in_zip): Read compressed class file archives. + * zipfile.h (ZipDirectory): Add uncompressed_size and + compression_method fields. + * zextract.c (read_zip_archive): Collect file compression info. + +2000-08-15 Bryce McKinlay <bryce@albatross.co.nz> + + * parse.y (do_resolve_class): Also explore superclasses of + intermediate enclosing contexts when searching for inner classes. + +2000-08-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (variable_declarator_id:): Better error message. + (expression_statement:): Use YYNOT_TWICE. + (cast_expression:): Likewise. + (assignment:): Likewise. + +2000-08-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (do_merge_string_cste): New locals. Create new + STRING_CSTs each time, use memcpy. Fixes gcj/311. + +2000-08-07 Hans Boehm <boehm@acm.org> + + * boehm.c (mark_reference_fields): Set marking bits for all words in + a multiple-word record. + (get_boehm_type_descriptor): Use the procedure marking descriptor for + java.lang.Class. + +2000-08-31 Mike Stump <mrs@wrs.com> + + * Make-lang.in (jc1$(exeext), gcjh$(exeext), jv-scan$(exeext), + jcf-dump$(exeext)): Make parallel safe. + +2000-08-29 Zack Weinberg <zack@wolery.cumb.org> + + * jcf-parse.c (set_source_filename): Constify a char *. + * jcf-write.c (append_innerclasses_attribute, + make_class_file_name): Constify a char *. Don't recycle a + variable for an unrelated purpose. + * parse.y: (build_alias_initializer_parameter_list): Constify a char *. + (breakdown_qualified): Do not modify IDENTIFIER_POINTER strings. + +2000-08-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (can_widen_reference_to): Fixed indentation. + * java-tree.h (CLASS_METHOD_CHECKED_P): Added leading comment. + * parse.y: `finit$' replaces `$finit$' in comments. + (try_builtin_assignconv): Fixed leading comment. + +2000-08-25 Greg McGary <greg@mcgary.org> + + * gjavah.c (cxx_keyword_subst): Use ARRAY_SIZE. + +2000-08-24 Greg McGary <greg@mcgary.org> + + * lang.c (lang_decode_option): Use ARRAY_SIZE. + * parse.y (BINOP_LOOKUP): Likewise. + +2000-08-22 Andrew Haley <aph@cygnus.com> + + * javaop.h (WORD_TO_INT): Mask lower 32 bits of a jword before + sign extending. Fixes gcj/321. + * jcf-parse.c (get_constant): Mask lower 32 bits of a jint before + combining to make a jlong. Fixes gcj/321. + +2000-08-21 Nix <nix@esperi.demon.co.uk> + + * lang-specs.h: Do not process -o or run the assembler if + -fsyntax-only. + +2000-08-16 Andrew Haley <aph@cygnus.com> + + * typeck.c (build_java_array_type): Rewrite code to do array + alignment. Take into account back-end macros when aligning array + data. Remove setting of TYPE_USER_ALIGN; Java doesn't allow the + user to set alignment. Fixes gcj/252 and 160. + +2000-08-09 Tom Tromey <tromey@cygnus.com> + + * parse.y (check_abstract_method_definitions): Now return `int'. + Check implemented interfaces. Fixes PR gcj/305. + + * parse.y (patch_switch_statement): Disallow `long' in switch + expressions. Fixes PR gcj/310. + +2000-08-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (finit_leg_identifier_node): New global. + (init_decl_processing): Use `finit$' to initialize + finit_identifier_node. Use `$finit$' to initialize + finit_leg_identifier_node. + * expr.c (expand_java_field_op): Use ID_FINIT_P. + * java-tree.h (finit_identifier_node): Changed attached comment. + (finit_leg_identifier_node): New declaration. + (ID_FINIT_P): Take finit_identifier_node and + finit_leg_identifier_node into account. This is a backward + compatibility hack. + +2000-08-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_conditional): Re-installed lost + Jan 6 2000 patch. + (generate_bytecode_insns): Check `nargs' before emitting it. + * verify.c (merge_type_state): Fixed typo. + * ChangeLog: Fixed typo in some jcf-write.c entries mentioning + generate_bytecode_{conditional,insns}. + +2000-08-13 Anthony Green <green@redhat.com> + + * check-init.c (check_init): Add case for BIT_FIELD_REF (required + for -pg builds). + +2000-08-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (maybe_layout_super_class): Fixed indentation. + * java-tree.h (CLASS_METHOD_CHECKED_P): New macro. + (java_check_methods): New function declaration. + * jcf-parse.c (get_constant): Let `char_len' go up to 3. Use `str' + instead of `str_ptr'. + * jcf-write.c (generate_bytecode_insns): Emit number the of args + of a `invokeinterface' at the right time. + * parse.h (WFL_STRIP_BRACKET): New macro. + (SET_TYPE_FOR_RESOLUTION): Use it. + * parse.y (build_unresolved_array_type): Reuse `type_or_wfl'. + (check_class_interface_creation): Don't check for cross package + innerclass name clashes. + (method_header): Behave properly if MDECL is `error_mark_node'. + (method_declarator): Return `error_mark_node' if bogus current + class. + (resolve_class): Apply WFL_STRIP_BRACKET on `cl' if necessary. + (resolve_and_layout): New local `decl_type', set and used. Call + java_check_methods. + (java_check_methods): New method. + (java_layout_classes): Use it. + (resolve_qualified_expression_name): No EH check necessary in + access$<n>. + (java_complete_lhs): Use VAR_DECL's DECL_INITIAL when evaluating + `case' statement. + (patch_assignment): Set DECL_INITIAL on integral final local. + +2000-08-08 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (flag_extraneous_semicolon): New extern. + * lang-options.h: (-Wextraneous-semicolon): New option. + * lang.c (flag_redundant): Fixed typo in leading comment. + (flag_extraneous_semicolon): New global. + (lang_decode_option): Set `flag_extraneous_semicolon' when + -Wall. Decode `-Wextraneous-semicolon'. + * parse.y (type_declaration:): Removed `SC_TK' hack, added + `empty_statement' rule. + (class_body_declaration): Likewise. + (method_body:): Accept `;' as a method body. + (static_initializer:): Removed `SC_TK' hack. + (constructor_block_end:): Likewise. + (empty_statement:): Report deprecated empty declaration. Fixes + gcj/295 + +2000-08-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (build_dot_class_method_invocation): Changed parameter + name to `type'. Build signature from `type' and convert it to a + STRING_CST if it's an array. + (patch_incomplete_class_ref): `build_dot_class_method_invocation' + to use `ref_type' directly. + +2000-08-06 Ovidiu Predescu <ovidiu@cup.hp.com> + + * lang-options.h: Added a comma after the last element to avoid + syntax errors when other languages define additional options. + +2000-08-04 Zack Weinberg <zack@wolery.cumb.org> + + * Make-lang.in (jc1, jv-scan): Depend on $(BACKEND), not stamp-objlist. + * Makefile.in: Add BACKEND; delete OBJS, OBJDEPS. + (jc1): Link with $(BACKEND). + (jv-scan): Depend on version.o, not all of $(OBJS) or $(BACKEND). + +2000-08-02 Zack Weinberg <zack@wolery.cumb.org> + + * jvspec.c: Adjust type of second argument to + lang_specific_driver, and update code as necessary. + + * class.c (build_dtable_decl): Initialize dummy. + +2000-08-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (maybe_yank_clinit): When generating bytecode: non empty + method bodies not to rule out discarding `<clinit>'; don't use + <clinit> to initialize static fields with constant initializers. + +2000-08-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * gjavah.c (print_method_info): Added `synth' parameter. Skip + synthetic methods. + (method_synthetic): New global. + (HANDLE_METHOD): Recognize synthetic method and tell + `print_method_info' about it. + (HANDLE_END_METHOD): Do not issue an additional `;\n' if we're + processing a synthetic method. + * jcf-reader.c (skip_attribute): New function. + ( skip_attribute): Likewise. + +2000-08-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (build_outer_field_access): Fixed comments. + (fix_constructors): Emit the initialization of this$<n> before + calling $finit$. + (resolve_qualified_expression_name): Build an access to `decl' if + necessary. + +2000-07-31 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse-scan.y (curent_class): Non longer const. + (inner_qualifier, inner_qualifier_length): Deleted. + (current_class_length): New global. + (bracket_count): Fixed typo in leading comment. + (anonymous_count): New global. + (class_instance_creation_expression:): Handle anonymous classes. + (anonymous_class_creation:): New rule. + (push_class_context): Rewritten. + (pop_class_context): Likewise. + (INNER_QUALIFIER): Macro deleted. + (report_class_declaration): call `push_class_context' when + entering the function. `fprintf' format modified not to use + INNER_QUALIFIER. + (report_class_declaration): Assign `package_name' and + `current_class' to NULL separately. + +2000-07-31 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (build_invokeinterface): Call layout_class_methods on + target interface. + +2000-07-27 Tom Tromey <tromey@cygnus.com> + Anthony Green <green@cygnus.com> + Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (make_class_data): Create vtable for abstract classes. + (get_dispatch_table): Changed to cope with abstract classes. + +2000-07-27 Tom Tromey <tromey@cygnus.com> + + * parse.y (patch_method_invocation): Don't reverse the argument + list when dealing with anonymous class constructors. Fixed typo in + comment. + +2000-07-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (build_alias_initializer_parameter_list): Reverse + crafted list when building aliases for anonymous class + constructors. + +2000-07-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (jdep_resolve_class): Don't bother checking potential + innerclass access if `decl' is NULL. + (find_in_imports_on_demand): TREE_PURPOSE of `import' contains the + WFL. + +2000-07-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.c: Remove (again.) + +2000-07-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (find_as_inner_class): Removed 2000-07-19 patches. + * jcf-parse.c (HANDLE_INNERCLASSES_ATTRIBUTE): Local `decl' moved + outside the `if' statement, alias to innerclass removed, `decl' + used to mark the class complete. + +2000-07-21 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (simple_name:): Fixed typo in error message. + +2000-07-21 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_complete_lhs): LOOP_EXPR:, SWITCH_EXPR: the node + or its first operand can be error marks. + +2000-07-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (SET_TYPE_FOR_RESOLUTION): Use GET_CPC. + * parse.y (method_header): Likewise. + +2000-07-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (process_imports): Consider that one might be trying to + import an innerclass. Fixes gcj/254 + +2000-07-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (find_as_inner_class): Handle the case where the + enclosing context of an innerclass has been loaded as bytecode. + +2000-07-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (simple_name:): Reject `$' in type names. + (resolve_type_during_patch): Use `type' as a second + argument to resolve_no_layout. Fixes gcj/257. + +2000-07-18 Bryce McKinlay <bryce@albatross.co.nz> + + * parse.y (find_most_specific_methods_list): Select the only + non-abstract method even if max has been set. + Fixes gcj/285, gcj/298. + +2000-07-18 Jeff Sturm <jeff.sturm@appnet.com> + + * lang-specs.h: Added %(jc1) to java compiler options. + +2000-07-14 Zack Weinberg <zack@wolery.cumb.org> + + * .cvsignore: New file. + +2000-07-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (not_accessible_p): Access granted to innerclasses + (indirectly) extending the reference type. Fixes gcj/249. + +2000-07-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_method_invocation): Fixed comment. + (maybe_use_access_method): Build this$<n>s to the context of the + target method, or a type that extends it. Fixes gcj/242. + +2000-07-13 Mark Mitchell <mark@codesourcery.com> + + * parse.c: Remove. + +2000-07-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (fold_constant_for_init): Avoid bullish conversion. + +2000-07-13 Tom Tromey <tromey@cygnus.com> + + * lang-specs.h: Added %{I*}. + +2000-07-13 Zack Weinberg <zack@wolery.cumb.org> + + * lang-specs.h: Use the new named specs. Remove unnecessary braces. + +2000-07-12 Mark Mitchell <mark@codesourcery.com> + + * parse-scan.c: Remove. + +2000-07-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (set_super_info): Handled protected inner classes. + (common_enclosing_context_p): Bail early if arguments aren't both + inner classes. + (get_access_flags_from_decl): Handle private and protected inner + classes. + * java-tree.h (TYPE_PROTECTED_INNER_CLASS): New macro. + (CLASS_PROTECTED): Likewise. + (struct lang_type): New bitfield `poic'. + * parse.y (jdep_resolve_class): Call check_inner_class_access on + inner classes only. + (check_inner_class_access): Renamed arguments, added + comments. Handles protected inner classes (fixes gcj/225) + (not_accessible_p): Fixed comments. Avoid handling inner classes. + +2000-07-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_qualified_expression_name): Verify qualified + access to `this'. Fixes gcj/239. + +2000-07-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_classfile): Don't install ConstantValue + for null pointers. + +2000-07-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_qualified_expression_name): Handle inner class + access. Fixes gcj/256. + +2000-07-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_classfile): Properly install the + ConstantValue attribute and the initial value constant pool index + on string constants. + * parse.y (java_complete_lhs): Keep DECL_INITIAL when emitting + class files. + +2000-07-06 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (BUILD_PTR_FROM_NAME): Surround with a do/while + construct. + * parse.y (find_as_inner_class): Fixed typo. + (do_resolve_class): Explore enclosing contexts when searching for + innerclasses. Removed curly brackets around BUILD_PTR_FROM_NAME. + (check_inner_class_access): Check `decl' which can be null in case + of previous errors. + +2000-07-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (java_debug_context): Declared `extern'. + (safe_layout_class): Likewise. + * parse.y (resolve_field_access): Field must be `static' in order + to be replaced by its initial value. Added comments. + (find_applicable_accessible_methods_list): Fixed typo. + (find_most_specific_methods_list): Methods found in innerclasses + take over methods founds in the enclosing contexts. + (java_complete_tree): Loosen restrictions on the type of DECLs + that can be replaced by their initialization values. + (valid_ref_assignconv_cast_p): Removed call to `enclosing_context_p'. + +2000-07-05 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (PARSE_DIR): New macro. + (PARSE_RELDIR): Likewise. + (PARSE_C): Likewise. + (PARSE_SCAN_C): Likewise. + ($(PARSE_C)): New target. + ($(PARSE_SCAN_C)): Likewise. + (SET_BISON): New macro. + (BISONFLAGS): Likewise. + (JAVABISONFLAGS): Likewise. + +2000-07-02 Bryce McKinlay <bryce@albatross.co.nz> + + * gjavah.c (HANDLE_METHOD): Call print_method_info with a NULL stream + argument on the first pass for CNI as well as JNI. + (print_method_info): Set up method name on the first pass only. + +2000-07-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (parser_qualified_classname): Removed parameter + `is_static'. + (create_interface): Removed first passed parameter to + parser_qualified_classname. + (create_class): Likewise. Don't install alias on static + innerclasses. Fixes gcj/275. + +2000-07-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (maybe_generate_pre_expand_clinit): Don't build a + debugable statement with empty_stmt_node. Fixes gcj/272 + +2000-07-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (build_instanceof): Layout type after it's loaded. Fixes + gcj/271. + +2000-06-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (push_long_const): Appropriately cast short negative + constant to jword. + +2000-06-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (verify_constructor_super): Use loop variable + `m_arg_type' initialized with `mdecl_arg_type'. + +2000-06-29 Tom Tromey <tromey@cygnus.com> + + * parse.y (resolve_field_access): Handle case where `type_found' + is NULL. + +2000-06-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (lookup_field): The same field can be found through two + different interface. Don't declare it ambiguous in that case. + +2000-06-27 Tom Tromey <tromey@cygnus.com> + + * lex.c (java_lineterminator): Don't recognize \r after \n. If \r + follows \r, then unget it at a lower level. + +2000-06-26 Tom Tromey <tromey@cygnus.com> + + * parse.y (resolve_field_access): Pass decl, not DECL_INITIAL, to + java_complete_tree. + +2000-06-25 Tom Tromey <tromey@cygnus.com> + + * parse.y (for_statement): Wrap expression in a WFL if it is a + constant. For PR gcj/268. + +2000-06-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (do_resolve_class): Minor optimiztion in the package + list search. Removed unnecessary test and return statement. + (valid_ref_assignconv_cast_p): Order of arguments to + enclosing_context_p fixed. + +2000-06-24 Tom Tromey <tromey@cygnus.com> + + * expr.c (lookup_field): Print error and return error_mark_node if + field reference is ambiguous. + + * parse.y (check_abstract_method_definitions): Also check if + `other_method' is abstract. + +2000-06-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (set_super_info): Handle ACC_PRIVATE for (inner) + classes. + * java-tree.h (TYPE_PRIVATE_INNER_CLASS): New macro. + (struct lang_type): New field `pic'. + (CLASS_PRIVATE): New macro. + * parse.y (check_inner_class_access): New function. + (jdep_resolve_class): Call it. + +2000-06-23 Tom Tromey <tromey@cygnus.com> + + * parse.y (patch_incomplete_class_ref): Initialize the returned + class. For PR gcj/260. + +2000-06-21 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * except.c (prepare_eh_table_type): Use `CATCH_ALL_TYPE'. + +2000-06-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (ENABLE_JC1_CHECKING): Replaces ENABLE_CHECKING for + Java specific checks. + * expr.c (build_instanceof): CLASS_INTERFACE and CLASS_FINAL usage + screened by DECL_P. + * java-tree.def (CASE_EXPR): Marked 'e'. + (DEFAULT_EXPR): Likewise. + * jcf-parse.c (set_source_filename): CLASS_COMPLETE_P usage + screened by DECL_P. + * jcf-write.c (ENABLE_JC1_CHECKING): Replaces ENABLE_CHECKING for + Java specific checks. + (generate_bytecode_insns): Test try_block for BLOCK before using + BLOCK_EXPR_BODY. + * parse.y (build_wfl_wrap): Added `location' argument. Set + EXPR_WFL_LINECOL accordingly. + (dim_expr:): Wrap constants with WFLs. + (method_declarator): Use TREE_TYPE not TYPE_NAME on GET_CPC. + (resolve_package): Check for `stmt' not being a BLOCK before + building a debuggable statement with it. + (make_qualified_primary): Added extra parameter to build_wfl_wrap + invocation. + (resolve_field_access): Make sure `decl' is a DECL before treating + it as such. + (maybe_build_primttype_type_ref): Make sure `wfl''s node is an + IDENTIFIER_NODE before treating it as such. + (patch_new_array_init): Make sure `elt' is a TREE_LIST before + treating it as such. + (find_applicable_accessible_methods_list): CLASS_INTERFACE macro + to be applied only on non array types. + +2000-06-16 Per Bothner <per@bothner.com> + + * java-tree.h (LABEL_RETURN_LABELS, LABEL_PENDING_CHAIN): Don't + define in terms of DECL_RESULT, as that fails when --enable-checking. + +2000-06-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-write.c (CHECK_PUT): Add static prototype. Make pointer + types the same in comparison. + (CHECK_OP): Add static prototype. + +2000-06-13 Jakub Jelinek <jakub@redhat.com> + + * typeck.c (build_java_array_type): Set TYPE_USER_ALIGN. + * parse.y (java_complete_class): Set DECL_USER_ALIGN. + * parse.c: Rebuilt. + +2000-06-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * decl.c (create_primitive_vtable): Prototype. + + * jcf-write.c (generate_bytecode_insns): Initialize variable + `saved_context'. + + * lang.c (lang_get_alias_set): Mark parameter with ATTRIBUTE_UNUSED. + +2000-06-09 Bryce McKinlay <bryce@albatross.co.nz> + + * parse.y (find_applicable_accessible_methods_list): Use a hashtable + to track searched classes, and do not search the same class more than + once. Call find_applicable_accessible_methods_list on immediate + superclass, instead of search_applicable_method_list on all ancestors. + Fix for PR gcj/238. + +2000-06-09 Bryce McKinlay <bryce@albatross.co.nz> + + * parse.y (register_fields): Permit static fields in inner classes + if they are final. Fix for PR gcj/255. + +2000-06-06 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (REGISTER_IMPORT): Use `chainon' to link new entries. + * parse.y (find_in_imports): Returned type changed to void, + leading comment fixed. + (register_package): New function. + (qualify_and_find): Likewise. + (package_declaration:): Use `register_package'. + (single_type_import_declaration:): Removed local variable + `node'. Added missing `;' for consistency. + (type_import_on_demand_declaration:): Use `chainon' to link new + entries. + (lookup_field_wrapper): Lookup local variables defined in outer + contexts first. + (java_complete_class): Don't reverse the list of imported on demand. + (do_resolve_class): Reorganized. Removed local variable + `original_name'. Call `qualify_and_find' with the current package + name, invoke `find_in_imports_on_demand' right after. Call + `qualify_and_find' with the packages we've seen so far. Fixed + operations numbering in comments. + (java_expand_class): Don't reverse `package_list'. + (find_most_specific_methods_list): New local variables `abstract' + and `candidates'. Use them to pick the right method. + +2000-06-06 Tom Tromey <tromey@ferrule.cygnus.com> + + * parse.y (check_modifiers_consistency): Don't subtract out + `PUBLIC_TK' from argument to THIS_MODIFIER_ONLY. + +2000-06-04 Philipp Thomas <pthomas@suse.de> + + * Makefile.in (INTLLIBS): New. + (LIBS): Add above. + (DEPLIBS): Ditto. + +2000-06-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (get_dispatch_table): Build the vtable dummy entry list + element with a null purpose. Fixed leading comment. + (build_dtable_decl): Build an accurate dtable type when appropriate + and use it. + +2000-06-02 Richard Henderson <rth@cygnus.com> + + * lang.c (lang_get_alias_set): New. + +2000-05-31 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_field_access): Complete the DECL_INITIAL tree + before using it as the accessed field. + +2000-05-31 Tom Tromey <tromey@cygnus.com> + + * java-tree.h (boolean_array_vtable, byte_array_vtable, + char_array_vtable, short_array_vtable, int_array_vtable, + long_array_vtable, float_array_vtable, double_array_vtable): + Declare. + * expr.c (get_primitive_array_vtable): New function. + (create_primitive_vtable): New function. + (java_lang_expand_expr): Enable code to statically generate + arrays. + * decl.c (init_decl_processing): Create primitive vtables. + (boolean_array_vtable, byte_array_vtable, char_array_vtable, + short_array_vtable, int_array_vtable, long_array_vtable, + float_array_vtable, double_array_vtable): Define. + +2000-05-26 Zack Weinberg <zack@wolery.cumb.org> + + * java/parse.y (find_applicable_accessible_methods_list): + Don't add an uninitialized value to the list. + +2000-05-25 Tom Tromey <tromey@cygnus.com> + + * parse.y (resolve_field_access): Don't check DECL_LANG_SPECIFIC + when trying to see if field's class should be initialized. Always + initialize field's declaring class, not qualified class. + For PR gcj/162. + + * parse.y (array_constructor_check_entry): Pass `wfl_value', not + `wfl_operator', to maybe_build_primttype_type_ref. + Fixes PR gcj/235. + +2000-05-23 Bryce McKinlay <bryce@albatross.co.nz> + + * parse.y (patch_method_invocation): Don't try to lookup methods + in primitive types. + +2000-05-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_field_access): Call the appropriate <clinit> + before accessing the length of a static array. Craft a decl for + the field while its time. Fixes PR gcj/129. + +2000-05-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_package): Correctly set `*next' (was off by + one.) + (resolve_qualified_expression_name): Fixed comment. + +2000-04-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (jcf_parse_source): Reset current_class and + current_function_decl to NULL before parsing a new file. + +2000-04-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (block_end:): If the collected block doesn't feature a + statement, insert an empty statement. + +2000-04-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (maybe_yank_clinit): New function. + (maybe_generate_pre_expand_clinit): Always link <clinit> at the + end of the list of methods belonging to a class. + (java_complete_expand_method): Check whether <clinit> is really + necessary and expand it accordingly. + +2000-04-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (fold_constant_for_init): Let VAR_DECL and FIELD_DECL be + processed by the method's switch statement. + +2000-05-19 Tom Tromey <tromey@cygnus.com> + + * java-tree.h: Added init state enum. + * decl.c (emit_init_test_initialization): Initialize class + initialization check variable by looking at class' state. + +2000-05-19 Tom Tromey <tromey@cygnus.com> + + * java-tree.h (build_instanceof): Declare. + (build_get_class): Declare. + * parse.y (patch_binop): Use build_instanceof. + * expr.c (build_instanceof): New function. If class is final, + don't make a function call. + (expand_java_INSTANCEOF): Use it. + (build_get_class): New function. + +2000-05-18 Alexandre Oliva <oliva@lsd.ic.unicamp.br> + + * jcf-write.c (generate_classfile): Scan the source_file for + slashes with the right pointer variable. + +2000-05-17 Andrew Cagney <cagney@b1.cygnus.com> + + * lang.c (lang_decode_option): Update -Wunused flags by calling + set_Wunused. + * decl.c (poplevel): Replace warn_unused with warn_unused_label. + +2000-05-09 Zack Weinberg <zack@wolery.cumb.org> + + * check_init.c (check_init): Constify local char *. + * class.c (push_class): Constify local char *. + * java_tree.h: Update prototypes. + * jcf-io.c (open_class): Constify filename parameter and + return value. + (find_class): Remove redundant string copy. Cast return from + open_class. + * jcf-parse.c (read_class, parse_class_file, yyparse): + Constify local char *. + * jcf-write.c (generate_bytecode_insns, generate_classfile): + Constify local char *. + * jcf.h (JCF): Constify filename and classname. + (JCF_FINISH): Cast args to FREE to char * when appropriate. + * lang.c (init_parse): Constify parameter and return value. + * lex.c (java_get_line_col): Constify filename parameter. + * parse.h: Constify parser_ctxt.filename. Update prototypes. + * parse.y (java_parser_context_suspend, + issue_warning_error_from_context, safe_layout_class): Constify + local char *. + * parse.c: Regenerate. + +2000-05-08 Tom Tromey <tromey@cygnus.com> + + * expr.c (build_jni_stub): Cache the result of + _Jv_LookupJNIMethod. + +2000-05-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (predef_filenames_size): Now 7. + (predef_filenames): New seventh entry. + +2000-05-04 Tom Tromey <tromey@cygnus.com> + + * boehm.c (mark_reference_fields): Don't mark RawData fields. + Keep track of when we've seen a reference field after a + non-reference field. + (get_boehm_type_descriptor): Handle case where we see + non-reference fields but no trailing reference field. + * decl.c (rawdata_ptr_type_node): Define. + (init_decl_processing): Initialize rawdata_ptr_type_node. + * java-tree.h (rawdata_ptr_type_node): Declare. + +2000-05-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-dump.c (SPECIAL_IINC): Ensure arguments match format + specifiers in calls to fprintf. + +2000-05-03 Andrew Haley <aph@cygnus.com> + + * expr.c (build_java_jsr): Use emit_jump, not expand_goto. + + * javaop.h (WORD_TO_INT): New function. + (IMMEDIATE_s4): Use WORD_TO_INT. + * jcf.h (JPOOL_INT): Ditto. + + * gjavah.c (decode_signature_piece): Don't treat `$' as namespace + separator. + +2000-04-19 Tom Tromey <tromey@cygnus.com> + + * class.c (add_method_1): Set both DECL_EXTERNAL and METHOD_NATIVE + on native function. + * jcf-parse.c (parse_class_file): Call build_jni_stub for native + JNI methods. + * expr.c (build_jni_stub): New function. + * lang-specs.h: -fjni and -femit-class-file are incompatible. + * parse.c: Rebuilt. + * parse.y (java_complete_expand_methods): Expand a native method + and call build_jni_stub if -fjni given. + * lang-options.h: Document -fjni. + * lang.c (flag_jni): New global. + (lang_f_options): Added `jni' entry. + * java-tree.h (soft_lookupjnimethod_node, + soft_getjnienvnewframe_node, soft_jnipopsystemframe_node): + Declare. + (flag_jni): Declare. + (build_jni_stub): Declare. + (struct lang_decl): Added `native' flag. + (METHOD_NATIVE): Redefined to use `native' field of lang specific + structure. + * decl.c (soft_lookupjnimethod_node, soft_getjnienvnewframe_node, + soft_jnipopsystemframe_node): New globals. + (init_decl_processing): Set them. _Jv_InitClass only takes one + argument. + + * java-tree.def: Put into `C' mode. + +2000-04-27 Tom Tromey <tromey@cygnus.com> + + Fix for PR gcj/2: + * expr.c (expand_invoke): Generate check to see if object pointer + is null in nonvirtual invocation case. + * java-tree.h (soft_nullpointer_node): Declare. + * decl.c (soft_nullpointer_node): New global. + (init_decl_processing): Initialize soft_nullpointer_node. + * parse.y (invocation_mode): Return INVOKE_NONVIRTUAL for `final' + or `private' methods. + (patch_invoke): Handle INVOKE_NONVIRTUAL case. + +2000-04-26 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (complete_start_java_method): Don't call _Jv_InitClass + from <clinit> + +2000-04-26 Tom Tromey <tromey@cygnus.com> + + * zextract.c (find_zip_file_start): New function. + (read_zip_archive): Use it. + +2000-04-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (register_incomplete_type): Handle JDEP_ANONYMOUS. + +2000-04-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (common_enclosing_context_p): New function. + * java-tree.h (common_enclosing_context_p): Added prototype. + * parse.h (INNER_ENCLOSING_SCOPE_CHECK): Relaxed test to allow + classes sharing an outer context with the current instance. + * parse.y (build_access_to_thisn): Fixed leading comment. + (verify_constructor_super): New local `supper_inner'. Skip + enclosing context argument in the case of inner class constructors. + (patch_method_invocation): Insert proper context as second + parameter to pure inner class constructor super invocations. + +2000-04-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (end_class_declaration): Reset the interface number + counter. + +2000-04-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (source_start_java_method): Deleted unnecessary code. + (patch_method_invocation): Fixed comment. + +2000-04-24 Robert Lipe <robertlipe@usa.net> + + * parse.h (_jdep): Member `kind' now ENUM_BITFIELD. + +2000-04-23 Tom Tromey <tromey@cygnus.com> + + * boehm.c (mark_reference_fields): Use int_byte_position. + +2000-04-22 Tom Tromey <tromey@cygnus.com> + + * boehm.c (mark_reference_fields): Only call byte_position on + non-static fields. + +2000-04-22 Tom Tromey <tromey@cygnus.com> + + * boehm.c (mark_reference_fields): Added `last_view_index' + argument. Use DECL_FIELD_OFFSET to determine field's offset. + +2000-04-20 Mo DeJong <mdejong@cygnus.com> + + * parse.h (INTERFACE_INNER_MODIFIERS): New macro. + * parse.y (check_class_interface_creation): Fixed comments. Select + permitted modifiers for (inner) interfaces. Changed error message + to report rejected modifiers used with local classes. + +2000-04-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (INNER_ENCLOSING_SCOPE_CHECK): Immediate inner classes + of directly inherited type considered in scope. + * parse.y (do_resolve_class): Search inherited classes for inner + classes. + +2000-04-20 Tom Tromey <tromey@cygnus.com> + + * parse.y (not_accessible_p): Use member's class, not current + class, when doing inheritance check for protected reference. + Fixes PR gcj/124. + +2000-04-20 Jason Schroeder <shrode@subnature.com> + + * jcf-dump.c (SPECIAL_IINC): Fixed typo printing iinc instruction. + +2000-04-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (lookup_field_wrapper): Search for final local aliases. + (resolve_expression_name): Let lookup_field_wrapper search for + final local aliases. Force the value of `name' if one is found. + (qualify_ambiguous_name): CONVERT_EXPR is enough to now we have + an expression name. Fixed comments. + +2000-04-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (yyerror): `msg' can be null, don't use it in that case. + +2000-04-19 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (cxx_keyword_subst): Avoid potential infinite loop. + +2000-04-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (maybe_make_nested_class_name): Use `obstack_grow0'. + +2000-04-18 Tom Tromey <tromey@cygnus.com> + + PR gcj/211: + * gjavah.c (utf8_cmp): Changed return value. + (cxx_keyword_subst): Handle all C++ keywords. Allocate new return + result. + (cxx_keywords): New global. + (get_field_name): Handle new result of cxx_keyword_subst. + (print_method_info): Likewise. + +2000-04-17 Bryce McKinlay <bryce@albatross.co.nz> + + * gjavah.c (print_name_for_stub_or_jni): Don't prefix method names + with a newline, for CNI. + (print_stub_or_jni): Print a space or newline before method name for + CNI as well as JNI. + (print_cxx_classname): Don't write leading "::" in CNI stub method. + (process_file): Include gcj/cni.h if generating CNI stubs. + +2000-04-16 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (decompile_method): Use print_field_name. + Fixes PR gcj/205. + +2000-04-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_expand_classes): Reverse the package list once. + (java_complete_lhs): PLUS_EXPR: don't try rhs and lhs at string + reduction. + (patch_binop): New temp `cn'. Call patch_string on LHS/RHS of + the `==' and `!=' operators. + +2000-04-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): At invocation time, + always relate an interface method to the type of its selector. + +2000-04-05 Tom Tromey <tromey@cygnus.com> + + Fix for PR gcj/2: + * expr.c (expand_invoke): Generate check to see if object pointer + is null in nonvirtual invocation case. + * java-tree.h (soft_nullpointer_node): Declare. + * decl.c (soft_nullpointer_node): New global. + (init_decl_processing): Initialize soft_nullpointer_node. + * parse.y (invocation_mode): Return INVOKE_NONVIRTUAL for `final' + or `private' methods. + (patch_invoke): Handle INVOKE_NONVIRTUAL case. + +2000-04-05 Tom Tromey <tromey@cygnus.com> + + Fix for PR gcj/140: + * parse.y (check_final_assignment): Recognize assignments to the + `length' field of an array when generating class files. + +2000-04-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (decl_hash): Prototype removed. + (decl_compare): Likewise. + +2000-04-05 Tom Tromey <tromey@cygnus.com> + + * parse.h (THIS_MODIFIER_ONLY): Changed meaning of `v' parameter. + * parse.y (check_modifiers_consistency): Check for final/volatile + clash. Fixes PR gcj/164. + +2000-04-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c: (java_hash_hash_tree_node): Renamed from `decl_hash', + made global. + (java_hash_compare_tree_node): Renamed from `decl_compare, made + global. + (add_method_1): Use `java_hash_hash_tree_node' and + `java_hash_compare_tree_node'. + * java-tree.h: (java_hash_hash_tree_node): Prototyped. + (java_hash_compare_tree_node): Likewise. + * parse.y (find_applicable_accessible_methods_list): Create, + delete and use a hash table to remember already searched interfaces. + +2000-04-03 Matt Welsh <mdw@cs.berkeley.edu> + + * jcf-depend.c (add_entry): Fixed bug where list was always replaced + with latest entry. + +2000-04-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * boehm.c (mark_reference_fields, set_bit): Prototype. + (set_bit): Un-ANSI-fy definition. + + * class.c (init_test_hash_newfunc, decl_hash, decl_compare): + Prototype. + + * decl.c (emit_init_test_initialization): Likewise. + + * gjavah.c (jni_print_char): Likewise. + + * parse.y (create_new_parser_context): Likewise. + +2000-03-30 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (java_lang_expand_expr): Added Anthony's Thu Jan 6 2000 + patch missing hunk. Fixed indentation. + +2000-03-30 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (D_NAN_MASK): Only define as word-reversed when + HOST_FLOAT_WORDS_BIG_ENDIAN and HOST_WORDS_BIG_ENDIAN disagree. + +2000-03-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse-scan.y (pop_class_context): Reset `inner_qualifier_length' + when negative *before* using it as an array index. + * ChangeLog: Fixed typo. + +2000-03-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse-scan.y (pop_class_context): Reset `inner_qualifier_length' + to 0 when it reaches -1. + +2000-03-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (get_constant): Properly cast `num' during the + invocation of `add_double'. + * jcf-write.c (push_long_const): Properly cast `lo' before + comparing it to short bounds. + * parse-scan.y (interface_declaration:): Rule re-arrange so that + `interface_body:' is reduced after the current interface is + pushed. + +2000-03-26 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (jvgenmain_spec): Add `%{<...}' construct for each + Java-specific `-f' option. + +2000-03-26 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * decl.c (init_decl_processing): Only call initialize_sizetypes once. + Adjust order of making types. + Make bitsize_*_node values. + +2000-03-25 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * class.c (make_field_value): Use byte_position. + * expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. + (java_array_data_offset): Likewise. + * java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to + bzero call. + +2000-03-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (check_abstract_method_definitions): New local + `end_type_reached'. Make sure we also consider `end_type'. + (java_check_abstract_method_definitions): Make sure we eventually + consider `java.lang.Object'. + (maybe_use_access_method): Don't use access method if not in the + context of a pure inner class or if the method's context is right. + (find_applicable_accessible_methods_list): New static flag + `object_done'. Don't search abstract classes as interfaces. Fixed + indentation. Fixed the `java.lang.Object' only search. Search + class interface(s) first, then fully search enclosing contexts. + (find_most_specific_methods_list): Pick the closest candidate when + they're all abstract. + +2000-03-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): TRY_FINALLY_EXPR: + properly initialize `finished_label'. Don't emit gotos for empty + try statements. + +2000-03-19 Martin v. Löwis <loewis@informatik.hu-berlin.de> + + * except.c (emit_handlers): Clear catch_clauses_last. + +2000-03-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (check_method_types_complete): New function. + (create_class): Reset anonymous class counter only when seeing an + non inner classe. + (java_complete_class): JDEP_METHOD: Don't recompute signature + if incomplete. + +2000-03-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (build_static_ref): Fixed indentation in comment. + * java-tree.def (TRY_EXPR): Fixed typo in name. + (CLASS_LITERAL): Likewise. + * java-tree.h: (TYPE_DOT_CLASS): New macro. + (struct lang_type): New field `dot_class'. + * jcf-write.c (generate_bytecode_insns): Fixed error message. + (generate_classfile): Method `class$' is synthetic. + * parse.y (build_do_class_method): New function. + (build_dot_class_method_invocation): Likewise. + (java_complete_expand_methods): Expand TYPE_DOT_CLASS if necessary. + (resolve_qualified_expression_name): Handle CLASS_LITERAL. + (qualify_ambiguous_name): Likewise. + (patch_incomplete_class_ref): Invoke synthetic method if necessary. + (build_try_statement): Fixed leading comment. + +2000-03-17 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * class.c (make_field_value): Properly handle sizes. + (get_dispatch_vector): Use tree_low_cst and host_integerp. + (layout_class_method): Count using trees. + * decl.c (push_promoted_type): Set TYPE_{MIN,MAX}_VALUE with copy_node. + * expr.c (java_array_data_offset): Use int_bit_position. + (build_newarray, build_anewarray): Use host_integerp and tree_low_cst. + (build_invokevirtual): Use tree_low_cst and do computations with trees. + +2000-03-16 Tom Tromey <tromey@cygnus.com> + + * lang.c (flag_hash_synchronization): New global. + (lang_f_options): Added `hash-synchronization'. + * lang-options.h: Mention -fhash-synchronization. + * java-tree.h (flag_hash_synchronization): Declare. + * expr.c (java_lang_expand_expr): Only push `sync_info' value when + hash table synchronization is disabled. + * decl.c (init_decl_processing): Only push `sync_info' value when + hash table synchronization is disabled. + * class.c (make_class_data): Only push `sync_info' field when hash + table synchronization is disabled. Removed dead code. + +2000-03-16 Tom Tromey <tromey@cygnus.com> + + * lang.c (lang_decode_option): Enable -Wunused when -Wall given. + +2000-03-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (INNER_ENCLOSING_SCOPE_CHECK): Disregard anonymous + classes. + * parse.y (patch_method_invocation): Handle anonymous classes + creation in static context. + +2000-03-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (INNER_ENCLOSING_SCOPE_CHECK): New macro. + * parse.y (resolve_qualified_expression_name): Use it. + (patch_method_invocation): Likewise. + +2000-03-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (register_incomplete_type): JDEP_ENCLOSING set + depending on the type of dependency which dictates what the + current class is. + (unresolved_type_p): Resolved types limited to the current class. + +2000-03-15 Tom Tromey <tromey@cygnus.com> + + * decl.c (init_decl_processing): Set type of `sync_info' to be + pointer to Object. + + * boehm.c (get_boehm_type_descriptor): Correctly compute `bits'. + Correctly compute bit number for current slot. Zero `high' and + `low' in DS_LENGTH case. Don't skip inherited fields. Use + mark_reference_fields. + (mark_reference_fields): New function. + +2000-03-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (register_incomplete_type): Fixed initialization of + JDEP_ENCLOSING. + +2000-02-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse-scan.y (inner_qualifier, inner_qualifier_length): New + static globals. + (push_class_context, pop_class_context): New function. + (class_body:): Call pop_class_context. + (interface_body:): Likewise. + (INNER_QUALIFIER): New macro. + (report_class_declaration): Changed output format and use + INNER_QUALIFIER. Call push_class_context. + +2000-02-14 Andrew Haley <aph@cygnus.com> + + * check-init.c (check_init): Add new cases for unary and binary + tree nodes. + +2000-03-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_package): Set `next' once a type name has been + progressively discovered. + (resolve_qualified_expression_name): Propagate resolution only if + there are remaining qualifiers. Take into account `q' might have + been cleared after re-qualification. + * parse.y (patch_method_invocation): New local `resolved'. + Section dealing with qualified expression rewritten to use + resolve_field_access. + +2000-03-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (PUSH_CPC): Fixed indentation. + (DEBUG_CPC): New macro. + (SET_CPC_INITIALIZER_STMT, SET_CPC_STATIC_INITIALIZER_STMT, + SET_CPC_INSTANCE_INITIALIZER_STMT): New macros. + * parse.y (class_body_declaration:): Use + SET_CPC_INSTANCE_INITIALIZER_STMT. + (method_declaration:): Check for null current_function_decl. + (static_initializer:): Use SET_CPC_STATIC_INITIALIZER_STMT. + (java_parser_context_pop_initialized_field): Better handling of + empty lists. + (maybe_make_nested_class_name): Mark nested class name as + qualified when necessary. + (end_class_declaration): Don't call java_parse_context_resume when + one or more error occurred. + (add_inner_class_fields): Use SET_CPC_INITIALIZER_STMT. + (register_fields): Use SET_CPC_STATIC_INITIALIZER_STMT and + SET_CPC_INITIALIZER_STMT. + (method_header): Check for inner classes declaring static methods. + (resolve_qualified_expression_name): Handle situation where `this' + is implied. + +2000-03-13 Hans Boehm <boehm@acm.org> + + * typeck.c (build_prim_array_type): Correctly set the high word too. + +2000-03-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_complete_expand_methods): Leave <clinit> out of + ordinary methods. + (maybe_generate_pre_expand_clinit): Put <clinit> at the end of the + list of methods for interfaces. + +2000-03-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (qualify_ambiguous_name): Properly handle expressions + using `null'. + +2000-03-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (check_final_assignment): Extended to process + COMPOUND_EXPR. + (patch_assignment): Have check_final_assignment called only once. + +2000-03-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (IS_INIT_CHECKED): New flag. + * check-init.c (check_init): Test and set IS_INIT_CHECKED. + * parse.y (patch_string): Call force_evaluation_order on the + completed string concatenation tree. + * expr.c (force_evaluation_order): Call force_evaluation_order on + function's arguments too. + +2000-03-06 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * decl.c (emit_init_test_initialization): Mark KEY as unused. + * expr.c (build_newarray): Cast TREE_INT_CST_LOW to HOST_WIDE_INT. + (build_anewarray): Likewise. + * parse.y (patch_newarray): Likewise. + * parse.c: Regenerated. + +2000-03-06 Bryce McKinlay <bryce@albatross.co.nz> + + * decl.c (init_decl_processing): Added new class fields `depth', + `ancestors', and `idt' to class_type_node. Use + _Jv_LookupInterfaceMethodIdx for soft_lookupinterfacemthod_node. + * class.c (make_class_data): Push initial values for new fields. + * java-tree.h: Updated prototype for `build_invokeinterface'. + * expr.c (build_invokeinterface): Changed parameters to accept + `method' tree. Calculate index of `method' in its declaring + interface. Build call to _Jv_LookupInterfaceMethodIdx. + (expand_invoke): Call `build_invokeinterface' with new parameters. + * parse.y (patch_invoke): Call `build_invokeinterface' with new + parameters. + +2000-03-06 Bryce McKinlay <bryce@albatross.co.nz> + + * typeck.c (lookup_do): Search superinterfaces first + when looking up an interface method. From Godmar Back + <gback@cs.utah.edu> + +2000-03-06 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (JAVA_SRCS): Added boehm.c, lex.c. + +2000-03-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (lookup_argument_method2): Declared. + (safe_layout_class): Prototype moved from parse.h. + * parse.h (safe_layout_class): Prototype moved to java-tree.h. + * parse.y (java_check_regular_methods): Local `super_class' gone. + Call lookup_argument_method2 instead of lookup_argument_method. + Perform modifier match for methods found declared in implemented + interfaces. Fixed indentation problem. Overriding/hiding error + report to take place only for methods found in classes. + * typeck.c (lookup_argument_method): Changed leading + comment. Re-written by calling lookup_do. + (lookup_argument_method2): New function. + (lookup_java_method): Re-written by calling lookup_do. + (lookup_do): New function. + +2000-03-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (check_init): Removed dead code. Handle (blank) + final variables. + * parse.y (declare_local_variables): New local `final_p', set it + and use it to initialize LOCAL_FINAL. + (check_final_assignment): Only check FIELD_DECLs. + +2000-02-17 Tom Tromey <tromey@cygnus.com> + + * Makefile.in (JAVA_OBJS): Added boehm.o. + (boehm.o): New target. + * Make-lang.in (JAVA_SRCS): Added boehm.c. + * java-tree.h (flag_use_boehm_gc): Declare. + (get_boehm_type_descriptor): Declare. + * lang.c (lang_f_options): Added `use-boehm-gc'. + (flag_use_boehm_gc): New global. + * lang-options.h: Added -fuse-boehm-gc. + * boehm.c: New file. + * class.c (get_dispatch_table): If class uses a Boehm type + descriptor, put it in the vtable. + (make_class_data): Removed dead code. + +2000-03-03 Per Bothner <per@bothner.com> + + * decl.c (init_decl_processing): Initialize sizetype properly. + +2000-03-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (LOCAL_CLASS_P): New flag usage and macro. + (PURE_INNER_CLASS_DECL_P, PURE_INNER_CLASS_TYPE_P): New macros. + * jcf-dump.c (HANDLE_INNERCLASSES_ATTRIBUTE): New macro. + * jcf-parse.c (HANDLE_INNERCLASSES_ATTRIBUTE): Likewise. + (jcf_parse): New local `current'. Load innerclasses seen in outer + context being processed. + * jcf-reader.c (HANDLE_INNERCLASSES_ATTRIBUTE): New macro. + * jcf-write.c (append_innerclasses_attribute): New function. + (append_innerclasses_attribute_entry): Likewise. + (get_access_flags): Handle static classes. Set anonymous and local + classes to be private. + (generate_classfile): Attribute count adjusted. Call + append_innerclasses_attribute. + * parse.h (SKIP_THIS_AND_ARTIFICIAL_PARMS): Use + PURE_INNER_CLASS_TYPE_P. + * parse.y (parser_qualified_classname): New parameter `is_static', + produce non qualified name accordingly. + (block_statement:): Set LOCAL_CLASS_P when declaring local class. + (create_interface): Added argument to parser_qualified_classname. + (create_class): Added argument to parser_qualified_classname. Setup + alias for top level classes. Use PURE_INNER_CLASS_DECP_P. + (add_inner_class_fields): Fixed indentation. + (method_declarator): Use PURE_INNER_CLASS_DECP_P. + (method_declarator): Fixed typo in comment. + (craft_constructor): Use PURE_INNER_CLASS_DECP_P. + (build_current_thisn): Likewise. + (patch_method_invocation): Likewise. + +2000-03-01 Martin von Löwis <loewis@informatik.hu-berlin.de> + + * decl.c (current_function_decl): Move to toplev.c. + +2000-02-28 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * java-tree.h (LABEL_PC): Relect name changes in ../tree.h. + (DECL_BIT_INDEX): Use underlying representation. + * parse.h (DECL_INHERITED_SOURCE_LINE): Likewise. + +2000-02-27 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * expr.c (build_java_ret): Pass proper type to size_binop. + +2000-02-25 Anthony Green <green@cygnus.com> + + * expr.c (build_class_init): Mark the decl to be ignored by + check_init. + * java-tree.h (DECL_BIT_INDEX): Move definition from check-init.c + * check-init.c: Move DECL_BIT_INDEX to java-tree.h + * class.c (init_test_hash_newfunc): New function. + (decl_hash): New function. + (decl_compare): New function. + * decl.c (emit_init_test_initialization): New function. + (complete_start_java_method): Traverse the init test hashtable, + calling emit_init_test_initialization. + (always_initialize_class_p): Define. + * expr.c (build_class_init): Use initialization tests when + emitting class initialization code. + (always_initialize_class_p): Declare. + * jcf-parse.c (parse_class_file): Set always_initialize_class_p to + 1. + * java-tree.h: Include hash.h. + (DECL_FUNCTION_INIT_TEST_TABLE): Define. + (struct lang_decl): Add init_test_table field. + (init_test_hash_entry): Define. + +2000-02-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * gjavah.c (main): Avoid using `argi' to report unimplemented + options. + +2000-02-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): TRY_FINALLY_EXPR: + initialize locals to avoid warnings. Local `exception_type' moved + into if statement. + +2000-02-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_expression_name): Use `orig' as a second + argument to resolve_field_access. + (resolve_field_access): Removed unnecessary code when dealing with + static fields. + +2000-02-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (push_super_field): Don't push the field twice. + * jcf-parse.c (parse_source_file): Call java_reorder_fields. + * parse.h (java_reorder_fields): Prototyped. + * parse.y (java_reorder_fields): New function. + (java_layout_class): Simplified not to worry about re-ordering. + +2000-02-23 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_name): In JNI case, correctly quote string. + (print_method_info): Don't handle overrides in JNI mode. + +2000-02-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (init_decl_processing): `_Jv_IsInstanceOf' returned + value type set to `boolean_type_node'. + +2000-01-18 Joerg Brunsmann <joerg.brunsmann@fernuni-hagen.de> + + * jcf-dump.c (main): Test for correct condition after + output file creation. + +2000-02-19 Anthony Green <green@cygnus.com> + + * jcf-depend.c (add_entry): Fix test for first list entry. + +2000-02-19 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * class.c (build_class_ref, push_super_field): Set DECL_SIZE_UNIT. + * constants.c (build_constants_constructor): Likewise. + +2000-02-19 Anthony Green <green@cygnus.com> + + * jcf-depend.c (add_entry): Add entries to the end of the list. + +1999-11-03 Pekka Nikander <pekka.nikander@hut.fi> + + * decl.c (INT_TYPE_SIZE): Define if necessary. + (expand_java_return): Handle the case of a native integer smaller + than a JVM integer. + +2000-02-18 Martin von Löwis <loewis@informatik.hu-berlin.de> + + * gjavah.c (help): Use GCCBUGURL. + * jv-scan.c (help): Likewise. + * jcf-dump.c (help): Likewise. + +2000-02-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): Don't generate empty + `finally' clauses. + +2000-02-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (load_class): Call `fatal' if no file containing + the target class are found. + +2000-02-16 Zack Weinberg <zack@wolery.cumb.org> + + * Makefile.in (PARSE_C, PARSE_SCAN_C): Move dependencies on + lex.c, lex.h, and PARSE_H to... + (parse.o, parse-scan.o): ...here, respectively. + + * lex.c: Split out code that may trigger SIGFPE from yylex() + to its own function. + * lex.h (JAVA_FLOAT_RANGE_ERROR): Don't set value. + +2000-02-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (jvspec.o): Depend on $(GCC_H), not gcc.h. + +2000-02-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (outer_field_access_p): Stop in time when outer contexts + are exhausted. + (resolve_qualified_expression_name): Properly qualify *everything* + after a package.type to be resoled as expression names. + (find_applicable_accessible_methods_list): Save/restore `class' to + isolate it from a possible outer context search. + +2000-02-15 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (jni_print_char): New function. + (print_full_cxx_name): Use it. + (decode_signature_piece): Likewise. + (print_cxx_classname): Likewise. + +2000-02-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (jv-scan, jcf-dump, gcjh): Depend on and link with + version.o. + (jcf-dump.o, gjavah.o, jv-scan.o): Depend on version.h. + + * gjavah.c: Include version.h. + + * jcf-dump.c: Likewise. + + * jv-scan.c: Likewise. + +2000-02-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (outer_field_access_fix): First parameter now a tree + node. Check for assignment to final. First argument to + build_outer_field_access_fix modified to accommodate prototype. + (build_outer_field_access): Don't check for assignment to final + here. + (java_complete_lhs): MODIFY_EXPR case: Check for `error_mark_node' + possibly returned by outer_field_access_fix. Changed + outer_field_access_fix's first argument. + (check_final_assignment): $finit$'s context is OK. + (patch_unaryop): Use node instead of its line/column value when + calling outer_field_access_fix. + +2000-02-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (interface_declaration:): No longer tagged + <node>. Re-installed default action. + (class_member_declaration:): Handle inner interfaces. + (interface_member_declaration): Handle inner interfaces and + classes. + (create_interface): Push error if one seen. Suspend parsing + context when processing an inner interface. + (register_fields): Inner class static field limitations not to + apply to inner interfaces. + +2000-02-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (load_class): Update `java_error_count' when a + class' file can't be found. + (parse.y): Avoid (byte)code generation when errors seen. + +2000-02-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_complete_lhs): Handle TRUNC_DIV_EXPR. Ensure `fatal' + decodes a valid node. + (patch_binop): Handle TRUNC_DIV_EXPR. + +2000-02-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_package): New local `acc'. Try to progressively + build and guess a package and type name. + +2000-02-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (find_applicable_accessible_methods_list): Load and + layout the search class if necessary. + (java_complete_tree): Keep to original type of the folded initial + value. + +2000-02-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class): Set and test CLASS_BEING_LAIDOUT. + Generate error message if circularity is detected. New static + local `list'. + * java-tree.h (CLASS_BEING_LAIDOUT): New flag usage, new macro. * + * jcf-write.c (generate_bytecode_insns): Very simply handle + SAVE_EXPR. + * parse.y (java_check_circular_reference): Use + `cyclic_inheritance_report' during report, if necessary. + (java_complete_lhs): fixed comment with `THROW_EXPR:' case. Avoid + walking NEW_ARRAY_INIT twice. + +2000-02-09 Tom Tromey <tromey@cygnus.com> + + * parse.y (check_class_interface_creation): Allow inner classes to + be `private' or `protected', check modifiers' consistency. Prevent + block local classes from bearing any modifiers. + +2000-02-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * except.c (check_start_handlers): Re-add prototype lost in last + patch. + (maybe_start_try): Remove excess argument to `check_start_handlers'. + +2000-02-09 Andrew Haley <aph@cygnus.com> + + * decl.c (clear_binding_level): Remove excess initializer. + (maybe_poplevels): Remove unused variable. + (force_poplevels): Ditto. + (struct binding_level): Add comment. + +2000-02-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_classfile): Don't consider + pre-initialization with reference value (use <clinit> instead.) + * parse.y (java_fix_constructors): No generated constructor for + interfaces. + (build_outer_field_access): Removed debug message. + (outer_field_expanded_access_p): Adapted to bytecode generation. + (build_outer_field_access_method): Use fix_method_argument_names. + (build_outer_method_access_method): Fixed indentation. Added + comment. Handle access method generation for static and also void + methods. + (build_access_to_thisn): Inserted debug message. + (maybe_build_thisn_access_method): Use fix_method_argument_names. + (resolve_qualified_expression_name): Fixed comment. + (not_accessible_p): Adapted to bytecode generation. Added comment. + (patch_method_invocation): Added comment. + (maybe_use_access_method): Fixed leading comment. Handle static + methods. + (java_complete_lhs): Don't shortcut handling of initialized upon + declaration String type static fields when generating bytecode. + (patch_unaryop): Handle outer field access when generating + bytecode. + +2000-02-03 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (FIELD_THISN): New macro. + * jcf-write.c (append_synthetic_attribute): New function. + (generate_classfile): Set "Synthetic" attribute on this$<n>, + val$<name> fields, access$<n> and $finit$ methods. Fixed indentation. + * parse.y (add_inner_class_fields): Set FIELD_THISN for created + this$<n> fields. + (build_outer_field_access): Turned on access functions usage and + generation when compiling to bytecode. + (maybe_use_access_method): Likewise. + +2000-01-25 Andrew Haley <aph@cygnus.com> + + * java-except.h (struct eh_range): Add `expanded' field. + (maybe_start_try): Add end_pc arg. + (maybe_end_try): Ditto. + * java-tree.h (force_poplevels): new function. + * expr.c (expand_byte_code): Don't call maybe_start_try or + maybe_end_try. + * except.c (add_handler): Reset expanded. + (expand_start_java_handler): Set expanded. + (check_start_handlers): Don't expand a start handler that's + already been expanded. + (maybe_start_try): Add end_pc arg. Only expand a handler which + ends after end_pc. + (expand_end_java_handler): call force_poplevels. + (force_poplevels): new function. + * decl.c (binding_level): Add start_pc of binding level. + (maybe_pushlevels): Call maybe_start_try when pushing binding + levels. + (maybe_poplevels): Call maybe_end_try when popping binding levels. + (LARGEST_PC): Define. + (clear_binding_level): Use LARGEST_PC. + + * java-tree.h (DEBUG_JAVA_BINDING_LEVELS): new define. + * decl.c (DEBUG_JAVA_BINDING_LEVELS): new define. + (binding_depth, is_class_level, current_pc): new variables. + (struct binding_level): ditto. + (indent): new function. + (push_jvm_slot): add debugging info. + (maybe_pushlevels): ditto. + (maybe_poplevels): ditto. + (pushlevel): ditto. + (poplevel): ditto. + (start_java_method): ditto. + (give_name_to_locals): comment only. + * except.c (binding_depth, is_class_level, current_pc): + new variables. + (expand_start_java_handler): add debugging info. + (expand_end_java_handler): ditto. + +2000-02-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (overloaded_jni_method_exists_p): Add prototype. + (print_name_for_stub_or_jni, process_file): Constify a char*. + +2000-02-03 Tom Tromey <tromey@cygnus.com> + + * jcf-io.c (jcf_print_utf8_replace): Handle UTF-8 input. + +2000-01-31 Scott Bambrough <scottb@netwinder.org> + + * gcc/java/javaop.h (WORDS_TO_DOUBLE): Allow WORDS_TO_DOUBLE to + assemble doubles correctly when HOST_FLOAT_WORDS_BIG_ENDIAN is + defined to be 1. + +2000-02-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.def (INSTANCE_INITIALIZERS_EXPR): New tree code. + * java-tree.h (TYPE_II_STMT_LIST): New macro. + (struct lang_type): New field `ii_block'. + * lex.c (java_init_lex): Use CPC_INITIALIZER_LIST, + CPC_STATIC_INITIALIZER_LIST and CPC_INSTANCE_INITIALIZER_LIST. + * parse.h (struct parser_ctxt): New field `instance_initializers'. + (CPC_INITIALIZER_LIST, CPC_STATIC_INITIALIZER_LIST, + CPC_INSTANCE_INITIALIZER_LIST, CPC_INITIALIZER_STMT, + CPC_STATIC_INITIALIZER_STMT, CPC_INSTANCE_INITIALIZER_STMT): New + macros. + * parse.y (add_instance_initializer): New function. + (in_instance_initializer): New static global. + (class_body_declaration:): Link instance initializer block. + (static_initializer:): Use CPC_STATIC_INITIALIZER_STMT. + (array_creation_expression:): Remove unused local. + (java_parser_context_push_initialized_field): Fixed leading + comment. Use CPC_STATIC_INITIALIZER_LIST, CPC_INITIALIZER_LIST and + CPC_INSTANCE_INITIALIZER_LIST. + (java_parser_context_pop_initialized_field): Likewise. + (add_inner_class_fields): Use CPC_INITIALIZER_STMT. + (register_fields): Use CPC_STATIC_INITIALIZER_STMT and + CPC_INITIALIZER_STMT. + (fix_constructors): New local `class_type'. Use it. Call + add_instance_initializer. + (java_complete_lhs): New case INSTANCE_INITIALIZERS_EXPR. + (patch_return): Forbid return in instance initializers. + (patch_throw_statement): Enforce exception handling in the context + of instance initializers. + +2000-02-03 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (java.mostlyclean): Remove executables in + `mostlyclean'. + +2000-01-31 Scott Bambrough <scottb@netwinder.org> + + * gcc/java/gjavah.c (D_NAN_MASK): Alternate definition required when + HOST_FLOAT_WORDS_BIG_ENDIAN is defined to be 1. + (java_float_finite): Convert to use union Word from javaop.h. + (java_double_finite): Convert to use union DWord from javaop.h. + +2000-02-02 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (options): Added `jni' entry. + (help): Document -jni. + (flag_jni): New global. + (process_file): Handle JNI output. Don't print text from + -prepend, -add, etc, when generating stubs. Only remove `.class' + suffix if it actually exists. + (main): Create a `.c' file when run with `--jni --stubs'. Create + correct output file name with `--jni'. + (print_include): Mangle header name differently in JNI case. + (HANDLE_METHOD): In JNI mode, call print_method_info to generate + method list. + (print_method_info): Handle JNI case. Put signature info into + method name. Handle case when STREAM is NULL. + (print_name_for_stub_or_jni): New function. + (print_stub_or_jni): Renamed from `print_stub'. Handle JNI. + (print_cxx_classname): Handle JNI. + (print_full_cxx_name): Likewise. + (decode_signature_piece): Likewise. + (overloaded_jni_method_exists_p): New function. + (struct method_name): Added `signature' and `sig_length' fields. + (HANDLE_END_FIELD): Do nothing in JNI mode. + +2000-02-02 Tom Tromey <tromey@cygnus.com> + + * jv-scan.c: Include version.c, <getopt.h>. + (LONG_OPT, OPT_HELP, OPT_VERSION): New macros. + (options): New array. + (usage): New function. + (version): New function. + (main): Use getopt_long to parse command line. + * jcf-dump.c: Include version.c, <getopt.h>. + (LONG_OPT, OPT_classpath, OPT_CLASSPATH, OPT_HELP, OPT_VERSION, + OPT_JAVAP): New macros. + (options): New array. + (usage): Return `void'. Changed message. + (help): New function. + (version): New function. + (main): Use getopt_long_only to parse command line. + * gjavah.c: Include <getopt.h>. + (LONG_OPT, OPT_classpath, OPT_CLASSPATH, OPT_HELP, OPT_TEMP, + OPT_VERSION, OPT_PREPEND, OPT_FRIEND, OPT_ADD, OPT_APPEND, OPT_M, + OPT_MM, OPT_MG, OPT_MD, OPT_MMD): New macros. + (options): New array. + (java_no_argument): Removed. + (help): Updated with missing options. + (main): Use getopt_long_only to parse command line. + (usage): Changed message. + +2000-02-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.def (NEW_ANONYMOUS_ARRAY_EXPR): New tree code. + * parse.h (ANONYMOUS_ARRAY_BASE_TYPE, ANONYMOUS_ARRAY_DIMS_SIG, + ANONYMOUS_ARRAY_INITIALIZER): New access macros. + * parse.y (array_creation_expression:): Handle anonymous arrays. + (build_array_from_name): Don't set `ret_name' if null. + (resolve_qualified_expression_name): New case NEW_ANONYMOUS_ARRAY_EXPR. + (qualify_ambiguous_name): Likewise. + (java_complete_expand_class): Likewise. + +2000-02-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.def (SYNCHRONIZED_EXPR): Fixed typo. + * parse.h (MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID): New macro. + (MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR): Likewise. + (SKIP_THIS_AND_ARTIFICIAL_PARMS): Use DECL_FINIT_P. + (AIPL_FUNCTION_FINIT_INVOCATION): Replaces + AIPL_FUNCTION_COMPLETED_INVOCATION. + (AIPL_FUNCTION_CTOR_INVOCATION): Replaces + AIPL_FUNCTION_INVOCATION_READY. + (AIPL_FUNCTION_DECLARATION): New enum entry. + * parse.y (reorder_static_initialized): New function. + (java_parser_context_pop_initialized_field): Use it. + (add_inner_class_fields): Use + MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID. Comment + augmented. Install marker after last alias initializer, if any. + (generate_finit): Fixed typo. Don't try to retain only the used + fields. + (method_header): Compute and set DECL_FUNCTION_NAP. + (method_declarator): Fixed comment. Insert alias initializer in + parameter list. + (build_alias_initializer_parameter_list): Fixed leading + comment. New case for AIPL_FUNCTION_DECLARATION. Old enum value + replaced by new ones. Use MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID. + (java_complete_expand_class): Code to retain only used aliases + removed. + (java_complete_expand_methods): New local `first_decl'. Generate + $finit$ first, then expand the constructors, regular methods and + <clinit>. + (java_complete_expand_method): Don't report error on missing + return statement if previously detected bogus. + (fix_constructors): Don't patch constructor parameters list. + (patch_method_invocation): Use new AIPL enum values. Reverse + alias initializer list for anonymous classes. + +2000-01-30 Anthony Green <green@redhat.com> + + * jcf-write.c (generate_bytecode_insns): Use TYPE_IS_WIDE to + determine how many stack slots to pop. + +2000-01-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (formal_parameter:): Set `$$' to NULL_TREE for better + error handling/recovery. + * java-tree.h (SYNCHRONIZED_EXPR): Fixed typo in comment. + +2000-01-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (ARG_FINAL_P, FIELD_LOCAL_ALIAS, + FIELD_LOCAL_ALIAS_USED): New macros. + (DECL_FUNCTION_NAP): New macro. + (struct lang_decl): New field `nap'. + (TYPE_FINIT_STMT_LIST, TYPE_CLINIT_STMT_LIST): New macros. + (struct lang_type): New fields `finit_stmt_list' and + `clinit_stmt_list'. + (CLASS_HAS_FINIT_P): Defined using TYPE_FINIT_STMT_LIST. + * parse.h (MANGLE_OUTER_LOCAL_VARIABLE_NAME): New macro. + (SKIP_THIS_AND_ARTIFICIAL_PARMS, MARK_FINAL_PARMS, + UNMARK_FINAL_PARMS, CRAFTED_PARAM_LIST_FIXUP): New macros. + (AIPL_FUNCTION_CREATION, AIPL_FUNCTION_COMPLETED_INVOCATION, + AIPL_FUNCTION_INVOCATION_READY): New enum fields. + (BUILD_THROW): Macro line separator re-indented. + * parse.y (end_class_declaration): New function. + (maybe_generate_pre_expand_clinit): New name for + java_pre_expand_clinit. Create <clinit> off TYPE_CLINIT_STMT_LIST, + pre-expand static fields. + (maybe_generate_clinit): Function deleted. + (check_for_static_method_reference): Prototype's parameter list + indented. + (generate_finit): New name for maybe_generate_finit. Changed + leading comment. Function rewritten to use + TYPE_FINIT_STMT_LIST. Call build_alias_initializer_parameter_list. + (build_alias_initializer_parameter_list): New function. + (java_parser_context_pop_initialized_field): Likewise. + (add_inner_class_fields): Likewise. + (type_declaration:): Call end_class_declaration. + (class_member_declaration:): Likewise. + (formal_parameter_list:): Fixed typos. + (formal_parameter:): Use ARG_FINAL_P to mark created tree list + element. Improved error handling. + (block_statement:): Call end_class_declaration. + (anonymous_class_creation:): Likewise. + (create_anonymous_class): Fixed comments. + (create_class): Call add_inner_class_fields. + (register_fields): Set FIELD_LOCAL_ALIAS according to ARG_FINAL_P. + (method_header): Use MARK_FINAL_PARMS. + (finish_method_declaration): Use UNMARK_FINAL_PARMS. + (method_declarator): Propagate final argument flag. + (craft_constructor): New local `artificial'. Call + build_alias_initializer_parameter_list. Use + CRAFTED_PARAM_LIST_FIXUP, assign DECL_FUNCTION_NAP. + (source_start_java_method): Mark parm decls with LOCAL_FINAL if + necessary. + (complete_expand_class): Get rid of unused outer context local + alias fields. + (java_complete_expand_methods): Fixed leading + comment. Generate/pre-expand <clinit> first. Changed method + expansion order to regular, $finit$, constructors, <clinit>. + (java_complete_expand_method): Set current_function_decl. + (fix_constructors): Fix constructor parameter list to account for + outer context local alias initializers. + (verify_constructor_super): Use SKIP_THIS_AND_ARTIFICIAL_PARMS. + (resolve_expression_name): Lookup outer context local aliases. New + local `access', use it. + (patch_method_invocation): Patch inner class ctor invocation with + outer context local aliases initialization values. $finit$ + invocation patching now includes things generated with + build_alias_initializer_parameter_list. + (argument_types_convertible): Use SKIP_THIS_AND_ARTIFICIAL_PARMS. + (build_super_invocation): Likewise. + (patch_assignment): Changed comment. + +2000-01-27 Andrew Haley <aph@cygnus.com> + + * jcf-write.c (emit_goto): RESERVE 3 bytes for insn. + (emit_if): Ditto. + (emit_jsr): Ditto. + +2000-01-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * parse.h (OBSOLETE_MODIFIER_WARNING): Don't use ANSI string + concatenation. + (OBSOLETE_MODIFIER_WARNING2): New macro allowing two args. + + * parse.y (register_fields): Don't pass a format specifier to + OBSOLETE_MODIFIER_WARNING. + (check_abstract_method_header): Use OBSOLETE_MODIFIER_WARNING2 + instead of OBSOLETE_MODIFIER_WARNING, and don't pass a format + specifier. + (check_modifiers): Change function into a macro. + (check_class_interface_creation): Pass a literal format string. + +2000-01-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * buffer.h: PROTO -> PARAMS. + * check-init.c: Likewise. + * class.c: Likewise. + * constants.c: Likewise. + * convert.h: Likewise. + * decl.c: Likewise. + * except.c: Likewise. + * expr.c: Likewise. + * gjavah.c: Likewise. + * java-except.h: Likewise. + * java-tree.h: Likewise. + * jcf-depend.c: Likewise. + * jcf-dump.c: Likewise. + * jcf-parse.c: Likewise. + * jcf-path.c: Likewise. + * jcf-reader.c: Likewise. + * jcf-write.c: Likewise. + * jcf.h: Likewise. + * jv-scan.c: Likewise. + * jvgenmain.c: Likewise. + * jvspec.c: Likewise. + * lang.c: Likewise. + * lex.c: Likewise. + * lex.h: Likewise. + * parse-scan.y: Likewise. + * parse.h: Likewise. + * parse.y: Likewise. + * typeck.c: Likewise. + * verify.c: Likewise. + * xref.c: Likewise. + * xref.h: Likewise. + * zextract.c: Likewise. + * zipfile.h: Likewise. + +2000-01-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (make_class): Use MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC. + (is_compiled_class): Remove test on TYPE_LANG_SPECIFIC, use TYPE_JCF. + * constants.c (build_constant_data_ref): Check for cached + current_constant_pool_data_ref. Cache current_constant_pool_data_ref + in TYPE_CPOOL_DATE_REF. + * java-tree.h (TYPE_JCF, TYPE_CPOOL, TYPE_CPOOL_DATA_REF, + MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC:) New macros. + (struct lang_type): New fields `cpool' and `cpool_data_ref'. + (LOCAL_FINAL): New macro. + * jcf-parse.c (init_outgoing_cpool): Always allocate new outgoing + constant pool -- don't try to reuse. + (parse_zip_file_entries): Use TYPE_JCF, don't lazily allocate + TYPE_LANG_SPECIFIC. + (find_in_current_zip): Use TYPE_JCF. + * parse.h (java_check_final): Prototype removed. + * parse.y (create_class): Reversed Jan 12, 2000 extra argument patch. + (maybe_create_class_interface_decl, + check_class_interface_creation): Likewise. + (java_expand_finals): Function removed. + (class_declaration:): Reversed Jan 12, 2000 extra argument patch. + (block_statement:): Fixed comment. + (anonymous_class_creation:): Likewise. + (check_class_interface_creation): Reversed Jan 12, 2000 extra + argument patch. + (check_class_interface_creation): Loosened error report on (inner) + public class declarations. CPC_INNER_P replaces GET_CPC_LIST. + (link_nested_class_to_enclosing): Reversed Jan 12, 2000 patch. + (maybe_create_class_interface_decl): Reversed Jan 12, 2000 extra + argument patch. + (create_interface): Likewise. + (anonymous_class_counter): New static global. + (create_anonymous_class): Reversed Jan 12, 2000 extra argument + patch. Fixed comments. + (create_class): Reversed Jan 12, 2000 extra argument patch. Reset + anonymous_class_counter when declaring a toplevel class. + (craft_constructor): Fixed constructor name when handling + anonymous classes. Anonymous class constructors to feature hidden + this$<n> parameter. + (java_fix_constructors): Added comment. + (java_check_final): Function removed. + (java_complete_expand_methods): Fixed comment. Don't generate + class data, save its outgoing constant pool instead. + (verify_constructor_super): Skip anonymous class constructor + hidden this$<n> parameter. + (java_expand_classes): New local `saved_ctxp'. Removed call to + java_expand_finals and java_check_final. Expand anonymous class + constructors. Generate class data. + (build_super_invocation): Skip anonymous class hidden this$<n> + parameter. + * typeck.c (build_java_signature): Use TYPE_SIGNATURE and + MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC. + (set_java_signature): Likewise. + +2000-01-18 Joerg Brunsmann <joerg.brunsmann@fernuni-hagen.de> + + * gjavah.c: Delete ACC_VISIBILITY define. + * jcf.h: Add ACC_VISIBILITY define. + * parse.y: final: rule tagged <value>. + (java_check_regular_methods): Use ACC_VISIBILITY define for + default package access check. + (local_variable_declaration_statement): Use final: rule. + +2000-01-17 Joerg Brunsmann <joerg.brunsmann@fernuni-hagen.de> + + * parse.y (format_parameter:): Use final: rule instead of modifiers:. + (final:): New rule. + +2000-01-17 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_field_info): Allow non-static final fields. + +2000-01-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (enum jdep_code): New entry `JDEP_ANONYMOUS'. + * parse.y (patch_anonymous_class): New function. + (create_anonymous_class): Register incomplete type when the + class/interface to extends/implement isn't known yet. + (parser_check_super_interface): Simplify argument to CLASS_INTERFACE. + (verify_constructor_super): Tuned error message. + +2000-01-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (FOR_LOOP_P): Replaces IS_FOR_LOOP_P. + (ANONYMOUS_CLASS_P): New macro. + (TYPE_SIGNATURE, TYPE_JCF): New macros. + (INNER_CLASS_TYPE_P): Fixed typo in leading comment. + * parse.y (create_class): Added leading argument. + (maybe_create_class_interface_decl, + check_class_interface_creation): Likewise. + (craft_constructor): New function. + (verify_constructor_super): Added argument in prototype. + (class_declaration:): Inserted leading argument. + (for_begin:): Use FOR_LOOP_P. + (anonymous_class_creation): Create WFL of the anonymous class to + instantiate. Call build_new_invocation. Added comments. + (check_class_interface_creation): Handle parameter `anonymous' in + verbose mode class creation announce. + (link_nested_class_to_enclosing): Exclude anonymous classes. + (maybe_create_class_interface_decl): Don't set DECL_CONTEXT on + anonymous class, even though they appear to have an enclosing + context. + (create_interface): Pass extra argument to + check_class_interface_creation. + (create_anonymous_class): Set ANONYMOUS_CLASS_P to 1. + (create_class): Call check_class_interface_creation and + maybe_create_class_interface_decl with extra new argument. Don't + add private this$<n> to anonymous classes. + (method_declarator): Insert hidden this$<n> to anonymous class + constructors. + (java_fix_constructors): Deleted code creating default + constructor. Call craft_constructor instead. + (java_check_regular_methods): Set `saw_constructor' to 1 for + anonymous classes. + (fix_constructors): Pass extra argument to verify_constructor_super. + (verify_constructor_super): New local `sdecl', use it. Search for + matching constructor (possibly featuring arguments) in super + class. + (lookup_method_invoke): Craft constructor according to arguments + list when dealing with anonymous class constructors. + (build_super_invocation): Pass arguments to anonymous class super + constructors. + (search_loop): Use FOR_LOOP_P. + (labeled_block_contains_loop_p): Likewise. + +2000-01-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (set_super_info): Set CLASS_STATIC when appropriate. + (enclosing_context_p): New function. + (get_access_flags_from_decl): Handle CLASS_STATIC. + (maybe_layout_super_class): Extra first argument passed to + do_resolve_class. + (layout_class_method): Use ID_FINIT_P, DECL_CLINIT_P and + ID_INIT_P. + * decl.c (access0_identifier_node): New global. + (init_decl_processing): access0_identifier_node initialized. + (pushdecl): Set DECL_CONTEXT only on non type decls. + * expr.c (lookup_field): Lookup inner class fields in enclosing + contexts. + (expand_invoke): Use ID_INIT_P. + (expand_java_field_op): Use DECL_CLINIT_P. + * java-tree.def (CLASS_LITERAL): New tree code. + * java-tree.h (DECL_FUNCTION_ACCESS_DECL, + DECL_FUNCTION_INNER_ACCESS, FIELD_INNER_ACCESS): New macros. + (struct lang_decl): New field `inner_access'. + (enclosing_context_p): Prototyped. + (DECL_INIT_P, DECL_FINIT_P, DECL_CLINIT_P, ID_INIT_P, ID_FINIT_P, + ID_CLINIT_P): New macros. + (CLASS_STATIC): New macro. + (CLASS_ACCESS0_GENERATED_P): New macro. + (OUTER_FIELD_ACCESS_IDENTIFIER_P, INNER_CLASS_DECL_P, + TOPLEVEL_CLASS_DECL_P, INNER_CLASS_TYPE_P, TOPLEVEL_CLASS_TYPE_P, + INNER_CLASS_P): New macros. + (DECL_INNER_CLASS_LIST): New macro. + * jcf-parse.c (yyparse): Avoid the use of ANSI string + concatenation. + * jcf-write.c (generate_bytecode_insns): binop: Change the type of + the shift value to int. Fixed typo in comment. + * lex.c (inst_id, wpv_id): Initialize. + * mangle.c (unicode_mangling_length): Take `$' into account. + * parse.h (DRECOVER, RECOVER): Terminate properly. + (IDENTIFIER_INNER_CLASS_OUTER_FIELD_ACCESS): New macro. + (typedef struct _jdep): New field `enclosing'. + (JDEP_ENCLOSING): New macro. + (IS_CLINIT): Deleted (DECL_CLINIT_P replaces it.) + (struct parser_ctxt): New fields `marker_beginning', `marked_end'. + (GET_CPC_LIST, CPC_INNER_P, GET_CPC, GET_CPC_UN, GET_CPC_UN_MODE, + GET_CPC_DECL_NODE, GET_ENCLOSING_CPC, GET_NEXT_ENCLOSING_CPC, + GET_ENCLOSING_CPC_CONTEXT): New macros. + (PUSH_CPC, PUSH_ERROR, POP_CPC): New macros. + (do_resolve_class): Added extra argument in prototype. + * parse.y (resolve_class): Added extra argument in prototype. + (maybe_create_class_interface_decl): Likewise. + (maybe_use_access_method, build_wfl_wrap): New functions. + (java_complete_expand_classes, java_complete_expand_class): + Likewise. + (java_parser_context_push_initialized_field, + java_parser_context_suspend, java_parser_context_resume): + Likewise. + (maybe_make_nested_class_name, make_nested_class_name, + set_nested_class_simple_name_value, + link_nested_class_to_enclosing, find_as_inner_class, + find_as_inner_class_do, check_inner_class_redefinition, + build_thisn_assign, build_current_thisn, build_access_to_thisn, + maybe_build_thisn_access_method, build_outer_field_access, + build_outer_field_access_methods, build_outer_field_access_expr, + build_outer_method_access_method, build_new_access_id, + build_outer_field_access_method, outer_field_access_p, + outer_field_expanded_access_p, outer_field_access_fix, + build_incomplete_class_ref, patch_incomplete_class_ref, + create_anonymous_class): Likewise. + (inst_id, wpv_id): New static global variables. + (synchronized:): New rule, tagged <node>. + (type_declaration:): No longer tagged <node>. Call POP_CPC in sub + rules. + (anonymous_class_creation:): New rule, tagged <node>. + (NEW_TK): Tagged <node>. + (type_literals, array_type_literal): New rules, tagged <node>. + (class_declaration:): Removed action when reducing by class_body: + (class_body:): Set DECL_END_SOURCE_LINE and rule's returned value + using GET_CPC in sub-rules. + (class_member_declaration): Handle inner classes. + (method_declaration): When reducing method_header:, reset + current_function_decl when appropriate. + (method_declarator:): Set the number of formal parameter to 0 for + method declared without arguments. + (constructor_declarator:): Likewise. + (static_initializer:): List of elements kept in a list. + (static:): Rule modifiers: replaces MODIFIER_TK. Enforce correct + use of the keyword `static' for type declarations. + (block_statement:): Handle inner class declarations. + (primary_no_new_array:): Use type_literals:. Fixed comment. Handle + type qualified `this'. + (class_instance_creation_expression): Use anonymous_class_creation: + to handle inner class instances creation. Handle qualified `new'. + (something_dot_new): Added appropriate actions. + (create_new_parser_context): New function. + (java_push_parser_context, java_parser_context_save_global, + java_parser_context_suspend): Use create_new_parser_context. + (check_modifiers): Changed leading comment. + (check_class_interface_creation): Handle interclasses. + (add_superinterfaces): Fixed comment. + (create_interface): Build qualified name from the raw_name instead + of its matching WFL. Push the initialized fields list. raw_name added + as an extra argument to maybe_create_class_interface_decl. + (create_class): Build qualified name from the raw_name instead of + its matching WFL. Removed assignment to current_parsed_class_un. + Call PUSH_ERROR before returning an error. Suspend the current + parser context when processing an inner class. Push the + initialized fields list. raw_name added as an extra argument to + maybe_create_class_interface_decl. Add the private this$<n> + field. + (duplicate_declaration_error_p): Use GET_CPC when calling find_field. + (register_fields): Get the class type from GET_CPC and handle + previous errors. Added code to handle the creation of static + fields in inner classes. Initialized fields initialization + statements kept in a list of lists. + (maybe_generate_finit): Initialized fields initialization + statements kept in a list of lists. Use GET_CPC. + (maybe_generate_clinit): Likewise. + (method_header): Use GET_CPC and GET_CPC_UN. + (parser_qualified_classname): Handle inner classes. + (register_incomplete_type): Set JDEP_ENCLOSING using GET_CPC. + (java_fix_constructors): Hide pointer to enclosing context + instance in constructor list when dealing with inner classes. + (jdep_resolve_class): Call resolve_class with extra first argument + JDEP_ENCLOSING. + (resolve_class): Add enclosing context as a first extra argument + to do_resolve_class. + (do_resolve_class): Call find_as_inner_class. Handle WFLs + properly. + (resolve_no_layout): Extra argument added to resolve_class + invocation. + (reset_method_name): Use DECL_CLINIT_P, DECL_FINIT_P. + (java_get_real_method_name): Use GET_CPC_UN. + (check_abstract_method_definitions): Use DECL_CLINIT_P. + (java_check_abstract_methods): Handle static method declared in + inner classes by an error. + (java_check_regular_methods): Use DECL_CLINIT_P. + (source_start_java_method): Also set DECL_MAX_LOCALS. + (create_artificial_method): Call java_parser_context_save_global + and java_parser_context_restore_global instead of saving/restoring + the context by hand. + (expand_start_java_method): Improved verbose mode message. + (java_complete_expand_methods): Fixed leading comment. Use + DECL_CLINIT_P. + (fix_constructors): Added assignment to this$<n> if necessary. + (java_expand_classes): Call java_complete_expand_classes instead + of java_complete_expand_methods. + (make_qualified_primary): Simplified. + (merge_qualified_name): Optimized for missing left or right parts. + (resolve_expression_name): Handle access to outer class fields from + interclasses. + (resolve_qualified_expression_name): New macro + RESTORE_THIS_AND_CURRENT_CLASS, used. Handle creation of inner + classes. Report error on non appropriate qualification of + `new'. Handle qualified `this'. + (not_accessible_p): Allow access to outer class private fields from + inner classes. + (patch_method_invocation): Handle method invocations through + access methods and inner class constructor invocations. + (find_applicable_accessible_methods_list): Search enclosing + contexts of an inner class. + (search_applicable_methods_list): Fixed typo. + (argument_types_convertible): Handle inner class constructors' + hidden outer context reference argument. + (qualify_ambiguous_name): Handle qualified `this'. + (java_complete_lhs): Handle use of field accessed through + artificial access methods in various cases of assignments. Handle + CLASS_LITERAL node. + (check_final_assignment): Use DECL_CLINIT_P. + (valid_ref_assignconv_cast_p): Handle the destination being an + enclosing context of the source. + (patch_unaryop): Handle use of field accessed through artificial + access methods. + (patch_return): Use DECL_CLINIT_P. + (patch_throw_statement): Use DECL_CLINIT_P. + (check_thrown_exceptions): Use DECL_FINIT_P and DECL_INIT_P. + * verify.c (verify_jvm_instructions): Use ID_CLINIT_P and + ID_INIT_P. + +2000-01-16 Anthony Green <green@cygnus.com> + + * parse.y (build_string_concatenation): Only use + StringBuffer(String) shortcut if String arg is constant. + +2000-01-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): binop: Change the type of + the shift value to int. Fixed typo in comment. + +2000-01-11 Mumit Khan <khan@xraylith.wisc.edu> + + * jcf-path.c: Delete PATH_SEPARATOR and DIR_SEPARATOR macros. + * jcf-write.c: Likewise. + * parse.y: Likewise. + * parse.c: Regenerate. + +2000-01-09 Anthony Green <green@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): Emit invokeinterface + bytecodes in the correct order. + +2000-01-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (jcf-dump, gcjh): Move ../errors.o before $(LIBS). + +2000-01-06 Anthony Green <green@cygnus.com> + + * expr.c (java_lang_expand_expr): Switch to permanent obstack + before building constant array decl. + +2000-01-06 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_conditional): Fixed indentation in + method invocation and typo in conditional expression. + (generate_bytecode_insns): COND_EXPR can be part of a binop. Issue + the appropriate NOTE_POP. + * parse.y (patch_binop): Shift value mask to feature the right + type. + +1999-12-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (assume_compiled, assume_compiled_node): Add static + prototype. + (add_assume_compiled): Use xmalloc/xstrdup, not malloc/strdup. + + * jcf-dump.c (ARRAY_NEW_NUM): Cast long to int in switch. + + * jvgenmain.c (usage): Add static prototype with ATTRIBUTE_NORETURN. + + * parse.h (OBSOLETE_MODIFIER_WARNING): Rename parameter `modifier' + to `__modifier' to avoid stringifying it. + + * parse.y (verify_constructor_circularity): Don't call a variadic + function with a non-literal format string. + (java_check_abstract_methods): Move unreachable code inside + `continue' statement. + (lookup_method_invoke): Call xstrdup, not strdup. + + * expr.c (expand_java_field_op): Avoid the use of ANSI string + concatenation. + + * jcf-parse.c (yyparse): Likewise. + + * jv-scan.c (main): Likewise. + +1999-12-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * parse.h (ABSTRACT_CHECK, JCONSTRUCTOR_CHECK, + ERROR_CANT_CONVERT_TO_BOOLEAN, ERROR_CANT_CONVERT_TO_NUMERIC, + ERROR_CAST_NEEDED_TO_INTEGRAL): Avoid the use of ANSI string + concatenation. + + * parse.y (synchronized, variable_redefinition_error, + check_class_interface_creation, create_interface, create_class, + method_header, finish_method_declaration, + check_modifiers_consistency, method_declarator, + complete_class_report_errors, check_abstract_method_definitions, + java_check_regular_methods, check_throws_clauses, + java_check_abstract_methods, read_import_dir, + check_pkg_class_access, declare_local_variables, fix_constructors, + cut_identifier_in_qualified, resolve_expression_name, + resolve_qualified_expression_name, patch_method_invocation, + java_complete_lhs, patch_assignment, try_builtin_assignconv, + patch_binop, patch_array_ref, patch_newarray, build_labeled_block, + patch_exit_expr, patch_exit_expr, patch_switch_statement, + patch_try_statement, patch_synchronized_statement, + patch_throw_statement, check_thrown_exceptions, + patch_conditional_expr): Likewise. + +1999-12-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Makefile.in (LIBDEPS): Added gcc's errors.o + (../jcf-dump$(exeext):): Link with gcc's errors.o + (../gcjh$(exeext):): Likewise. + * expr.c (expand_java_NEW): Layout the entire target type instead of + laying out its methods only. + (lookup_field): Layout the class after having loaded it. + * java-tree.h (java_debug_context): Declared. + * jcf-io.c (toplev.h): Included. + (find_class): Removed assignment to jcf's outofsynch + field. Force source file to be read if newer than its matching + class file. Tweaked debug messages. + * jcf-parse.c (jcf_out_of_synch): Deleted. + (read_class): Call to jcf_out_of_synch removed. + * jcf.h (typedef struct JCF): Field `outofsynch' deleted. + (jcf_out_of_synch): Prototype deleted. + * parse.h (struct parser_ctxt): `minus_seen', `java_error_flag', + `deprecated' and `class_err': integer turned into bit-fields. + New bit-fields `saved_data_ctx' and `saved_data'. Fixed comments. + * parse.y (package_list): New global. + (package_declaration:): Record newly parsed package name. + (extra_ctxp_pushed_p): Static global deleted. + (java_parser_context_save_global): Create buffer context for the + purpose of saving globals, if necessary. + (java_parser_context_restore_global): Pop context pushed for the + purpose of saving globals, if necessary. + (java_debug_context_do): New prototype and function. + (java_debug_context): Likewise. + (do_resolve_class): Use already parsed package names to qualify + and lookup class candidate. + (java_pre_expand_clinit): Removed unnecessary local variable. + +1999-12-17 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (decode_signature_piece): Print "::" in JArray<>. This + fixes PR gcj/119. + (process_file): Use `\n\' at end of each line in string. + +1999-12-16 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (expand_invoke): Layout the loaded class before + attempting to use it. + (expand_java_field_op): Allow final field assignments to take + place in $finit$. + * typeck.c (convert): Return error_mark_node if expr is null. + +1999-12-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (class_depth): Return -1 if the class doesn't load + properly. + * expr.c (can_widen_reference_to): Check for errors during depth + computation and return 0 accordingly. + * jcf-parse.c (parse_source_file): Call java_fix_constructors to + create default constructors and add an other error check. + * parse.h (java_fix_constructors): Prototyped. + * parse.y (java_pre_expand_clinit): Likewise. + (build_super_invocation): Re-prototyped to feature one argument. + (java_check_circular_reference): Directly use `current'. + (java_fix_constructors): New function. + (java_check_regular_methods): Don't create default constructors + here, but abort if none were found. + (java_complete_expand_methods): Pre-process <clinit> calling + java_pre_expand_clinit. + (java_pre_expand_clinit): New function. + (fix_constructors): build_super_invocation invoked with the + current method declaration as an argument. + (build_super_invocation): Use the context of the processed method + decl argument instead of current_class. + * typeck.c (lookup_java_method): Take WFLs in method names into + account. + +1999-12-14 Per Bothner <per@bothner.com> + + * class.c (make_class_data): flag_keep_inline_functions to keep + private methods in the method array. + +1999-12-15 Anthony Green <green@cygnus.com> + + * check-init.c (check_init): Take into account both types of + `throw's when checking for uninitialized variables. + +1999-12-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_complete_lhs): Force conversion of array + dimensions to int_type_node, that's what runtime's ABI expects. + +1999-12-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (EXPR_WFL_QUALIFICATION): Temporary uses the third + operand of a WFL, until the Java front-end gets fixed with regard + to Mark Mitchell's gcc/tree.h patch (1999-12-04.) + +1999-12-10 Andrew Haley <aph@cygnus.com> + + * parse.h (BUILD_THROW): Add support for sjlj-exceptions. + decl.c (init_decl_processing): Add _Jv_Sjlj_Throw. + expr.c (build_java_athrow): Add support for sjlj-exceptions. + java-tree.h: Ditto. + jcf-write.c: Ditto. + +1999-12-08 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (java_lang_expand_expr): Switch to permanent obstack + before calling expand_eh_region_start and expand_start_all_catch. + * except.c (expand_start_java_handler): Switch to permanent + obstack before calling expand_eh_region_start. + (expand_end_java_handler): Switch to permanent obstack before + calling expand_start_all_catch. + +1999-12-5 Anthony Green <green@cygnus.com> + + * decl.c (init_decl_processing): Mark throw_node as a noreturn + function with side effects. + (init_decl_processing): Mark all memory allocating DECLs with + DECL_IS_MALLOC. + +1999-12-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * except.c (expand_end_java_handler): Call + expand_resume_after_catch and end_catch_handler. + +1999-11-30 Anthony Green <green@cygnus.com> + + * verify.c (verify_jvm_instructions): Create new return label + chain if non existent (don't rely on the verified state of the jsr + target.) + +1999-11-30 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): Fixed indentation for + COMPOUND_EXPR and FIX_TRUNC_EXPR cases. + + * parse.y (patch_assignment): Removed bogus final class test on + lhs when checking on whether to emit an ArrayStoreException runtime + check. + * expr.c (expand_java_arraystore): Likewise. + +1999-11-28 Anthony Green <green@cygnus.com> + + * decl.c (find_local_variable): Reuse single slot decls when + appropriate. + +1999-11-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (saw_java_source): Global variable removed. + (read_class): Don't use `saw_java_source'. Added extra braces. + (yyparse): Code setting `saw_java_source' removed. + +1999-11-24 Mark Mitchell <mark@codesourcery.com> + + * except.c (emit_handlers): Zero catch_clauses after emitting them. + +1999-11-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * verify.c (merge_type_state): Non verified subroutines being + considered more than once to trigger passive type merge. + +1999-11-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (catch_clause_parameter:): Still set `$$' to NULL_TREE + in case of error. Error message tuned. + +1999-11-21 Anthony Green <green@cygnus.com> + + * constants.c (find_methodref_index): Unwrap method names before + inserting them in the constant pool. + + * jcf-parse.c (jcf_parse): Display `interface' when appropriate. + + * class.c (assume_compiled_node): New typedef. + (assume_compiled_tree): New static data. + (find_assume_compiled_node): New function. + (add_assume_compiled): New function. + (assume_compiled): New function. + * class.c (make_class_data): Use assume_compiled. + (is_compiled_class): Use assume_compiled. + + * java-tree.h (add_assume_compiled): Declare. + + * lang.c (lang_decode_option): Parse new options. + +1999-11-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class): Always convert TYPE_SIZE_UNIT to + int_type_node: that's what `_Jv_AllocObject' expects. + +1999-11-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (lookup_method_invoke): Use lang_printable_name to + reliably build the type name during error report. Fixes PR gcj/97. + +1999-11-09 Tom Tromey <tromey@cygnus.com> + + * jcf-path.c: Include <sys/stat.h>. + (jcf_path_init): Search for libjava.zip. Fixes PR gcj/84. + (DIR_UP): New macro. + +1999-11-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (source_end_java_method): Resume permanent allocation, + reversing Apr 27 1998 patch. + (patch_string_cst): Pop obstacks after having pushed the permanent + ones. + +1999-11-05 Tom Tromey <tromey@cygnus.com> + + * class.c (finish_class): Emit inlined methods if any native + methods exist in the class. Fixes PR gcj/85. + +1999-11-04 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_qualified_expression_name): Handle PLUS_EXPR. + (qualify_ambiguous_name): Likewise. + +1999-11-03 Godmar Back <gback@cs.utah.edu> + + * typeck.c: (lookup_java_method): search all inherited + interfaces when looking up interface method. + +1999-11-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (method_header:): Issue error message for rule `type + error'. + (synchronized:): Error report when not using synchronized. + +1999-11-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_qualified_expression_name): Prevent `this' from + being used before the superclass constructor has been called. + (complete_function_arguments): Use CALL_EXPLICIT_CONSTRUCTOR_P + instead of `CALL_THIS_CONSTRUCTOR_P'. + +1999-10-30 Todd T. Fries <todd@lighthouse.fries.net> + + * check-init.c: Fix typo in comment. + +1999-10-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (add_method_1): Set DECL_INLINE to 1 for private, static + and final method. + +1999-10-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (expression_statement:): Call function to report + improper invocation of a constructor. + (parse_ctor_invocation_error): New function. + +1999-10-26 Mark Mitchell <mark@codesourcery.com> + + * decl.c (poplevel): Don't set BLOCK_TYPE_TAGS or call + remember_end_note. + +1999-10-21 Tom Tromey <tromey@cygnus.com> + + * jvgenmain.c (main): _Jv_Compiler_Properties now an extern; set + in generated `main'. + +1999-10-21 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_qualified_expression_name): Handle MODIFY_EXPR. + (qualify_ambiguous_name): Likewise. + +1999-10-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_complete_tree): fold_constant_for_init to work on + permanent_obstack. + (java_complete_lhs): Likewise. + (array_constructor_check_entry): Complete an initializer element + on permanent_obstack. + +1999-10-19 Tom Tromey <tromey@cygnus.com> + + * jcf-parse.c (parse_source_file): Call jcf_dependency_add_file. + From Mike Moreton <mike@pillim.demon.co.uk>. + +1999-10-15 Greg McGary <gkm@gnu.org> + + * java-tree.h (flag_bounds_check): Remove extern decl. + * lang.c (flag_bounds_check): Remove global variable. + (lang_f_options): Remove "bounds-check" entry. + (lang_init_options): Default flag_bounds_check to "on". + +1999-10-14 Tom Tromey <tromey@cygnus.com> + + * jvgenmain.c (usage): New function. + (main): Use it. Also, handle `-D' options. + * jvspec.c (lang_specific_driver): Recognize -D. + (jvgenmain_spec): Added `%{D*}' to jvgenmain invocation. + + * jvspec.c (jvgenmain_spec): Use `%umain', not just `%u'. + +1999-10-14 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jcf-dump.c (print_constant, disassemble_method): Don't call a + variadic function with a non-literal format string. + + * parse-scan.y (report_main_declaration): Likewise. + + * parse.h (ERROR_CAST_NEEDED_TO_INTEGRAL): Likewise. + + * parse.y (read_import_dir, patch_assignment, patch_binop, + patch_array_ref): Likewise. + + * typeck.c (build_java_array_type): Likewise. + + * verify.c (verify_jvm_instructions): Likewise. + +1999-10-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (RELOCATION_VALUE_1): Fixed integer value from 0 to 1. + +1999-10-07 Anthony Green <green@cygnus.com> + + * jcf-write.c (generate_classfile): Use UNSAFE_PUTx in cases + where CHECK_PUT may fail for valid reasons. + + * jcf-write.c (UNSAFE_PUT1, UNSAFE_PUT2, UNSAFE_PUT3, + UNSAFE_PUTN): New macros. + +1999-10-04 Tom Tromey <tromey@cygnus.com> + + * lex.h (BUILD_OPERATOR2): Return ASSIGN_ANY_TK in `lite' case as + well. Fixes Java PR gcj/59. + * parse-scan.y (yyerror): Report errors. + +1999-09-24 Glenn Chambers <GChambers@provsol.com> + + * decl.c (insert_block): Remove unconditional `abort'. + +1999-09-24 Bernd Schmidt <bernds@cygnus.co.uk> + + * decl.c (builtin_function): No longer static. New arg CLASS. Arg + FUNCTION_CODE now of type int. All callers changed. + Set the builtin's DECL_BUILT_IN_CLASS. + +1999-09-23 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (lang_specific_driver): Don't read spec file if + -fsyntax-only given. + +1999-09-22 Tom Tromey <tromey@cygnus.com> + + * lang-specs.h: Added `%(jc1)' to the jc1 spec. + + * javaop.h (WORD_TO_FLOAT): Use `inline' unconditionally. + (WORDS_TO_LONG): Likewise. + (WORDS_TO_DOUBLE): Likewise. + +1999-09-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-write.c (RELOCATION_VALUE_0): New macro. + (RELOCATION_VALUE_1): Likewise. + (emit_iinc, emit_reloc, push_constant1, push_constant2, + push_in_const, push_long_const): Prototyped. + (push_constant1): Argument `index' is of type HOST_WIDE_INT. + (push_constant2): Likewise. + (push_int_const): Cast find_constant1's integer arguments to `jword'. + (find_constant_wide): Cast find_constant2's integer arguments to + `jword'. + (find_constant_index): Cast find_constant2's and find_constant2's + integer arguments to `jword'. + (emit_pop): Argument `value' is of type HOST_WIDE_INT. + (emit_switch_reloc): Use RELOCATION_VALUE_0. + (emit_if): Use RELOCATION_VALUE_1. + (emit_goto): Likewise. + (emit_jsr): Likewise. + (generate_bytecode_insns): Use RELOCATION_VALUE_0. Cast second + argument to push_long_const to HOST_WIDE_INT. + +1999-09-15 Andreas Schwab <schwab@suse.de> + + * Makefile.in (parse.o): Depend on $(JAVA_TREE_H). + +1999-09-20 Nick Clifton <nickc@cygnus.com> + + * lang.c (lang_decode_option): Extend comment. + +1999-09-16 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_method_add_stmt): Test against GET_CURRENT_BLOCK + instead of fndecl. + +1999-09-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (get_field_name, print_method_info, print_include, + add_namelet): Use xmalloc, not malloc. + + * jcf-depend.c (add_entry): Likewise. Use xstrdup, not strdup. + (munge): Use xrealloc, not realloc, trust xrealloc to handle a + NULL pointer. + + * jcf-io.c (open_in_zip, find_class): Use xstrdup, not strdup. + + * jcf-parse.c (jcf_out_of_synch, yyparse): Likewise. + + * jcf-path.c (add_entry): Likewise. + + * jcf.h (ALLOC, REALLOC): Use xmalloc/xrealloc, not malloc/realloc. + + * jv-scan.c (xmalloc): Remove definition. + + * jvgenmain.c (xmalloc): Likewise. + + * jvspec.c (lang_specific_driver): Use xcalloc, not xmalloc/bzero. + + * lex.c (java_store_unicode): Use xrealloc, not realloc. + + * parse-scan.y: Use concat, not of xmalloc/assign/strcpy. Use + concat, not xmalloc/sprintf. + (java_push_parser_context): Use xcalloc, not xmalloc/bzero. + (xstrdup): Remove definition. + + * parse.y (duplicate_declaration_error_p, + constructor_circularity_msg, verify_constructor_circularity, + check_abstract_method_definitions, java_check_regular_methods, + java_check_abstract_methods, patch_method_invocation, + check_for_static_method_reference, patch_assignment, patch_binop, + patch_cast, array_constructor_check_entry, patch_return, + patch_conditional_expr): Use xstrdup, not strdup. + + * zextract.c (ALLOC): Use xmalloc, not malloc. + +1999-09-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (jvspec.o): Depend on system.h and gcc.h. + + * jvspec.c: Include gcc.h. Don't include gansidecl.h. + (do_spec, lang_specific_pre_link, lang_specific_driver, + input_filename, input_filename_length): Don't declare. + (main_class_name, jvgenmain_spec, lang_specific_driver): + Constify a char*. + (lang_specific_driver): All calls to the function pointer + parameter now explicitly call `fatal'. + +1999-09-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (find_applicable_accessible_methods_list): Search + abstract classes as interfaces. + +1999-09-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (finish_class): We're now outside a valid method + declaration. Tell the rest of gcc so. + +1999-09-08 Bruce Korb autogen@linuxbox.com + + * Makefile.in: Give the gperf user a hint about why "gperf -F" fails. + +1999-09-07 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (add_class_decl): Generate include for gcj/array.h, not + java-array.h. + (decode_signature_piece): Don't emit "::" in JArray<>. + (print_namelet): Only print trailing `;' when printing a class. + +1999-09-10 Bernd Schmidt <bernds@cygnus.co.uk> + + * java-tree.h: Delete declarations for all tree nodes now moved to + global_trees. + * decl.c: Delete their definitions. + +1999-09-04 Mark Mitchell <mark@codesourcery.com> + + * Make-lang.in (jc1): Depend on ggc-callbacks.o. + * Makefile.in (OBJS): Add ggc-callbacks.o. + (OBJDEPS): Likewise. + +1999-09-03 Tom Tromey <tromey@cygnus.com> + + * parse.y (strip_out_static_field_access_decl): Return operand if + it satisfies JDECL_P. + +1999-09-02 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (decode_signature_piece): Emit "::" in JArray<>. + Handle nested arrays, like `[[I'. + +1999-09-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (finish_class): Remove unused parameter, all callers + changed. + + * expr.c (build_java_athrow): Change return type to void. + (java_lang_expand_expr): Make sure each case in switch returns a + value. + + * java-tree.h (finish_class): Fix prototype to take void args. + + * jcf-dump.c (usage): Mark with ATTRIBUTE_NORETURN. + (main): Issue return from main, not exit. + + * jcf-parse.c (parse_class_file): Fix call to `finish_class'. + + * jcf.h (jcf_unexpected_eof): Mark with ATTRIBUTE_NORETURN. + + * jv-scan.c (main): Issue return from main, not exit. + + * parse.y (check_abstract_method_definitions, + java_check_abstract_method_definitions): Add static prototypes. + (java_complete_expand_methods): Fix call to `finish_class'. + + * verify.c (verify_jvm_instructions): Initialize variables `oldpc' + and `prevpc'. + +1999-08-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lang.c (language_string): Constify. + +1999-08-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (LIBS): Fix definition so we link with $(CLIB). + Remove hacks for stuff which comes from libiberty. + + * Make-lang.in: Likewise. + +1999-08-30 Hans-Peter Nilsson <hp@axis.se> + + * Makefile.in (xref.o): Depend on xref.c explicitly. + +1999-08-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * java-tree.h (lang_printable_name): Constify a char*. + + * lang.c (lang_printable_name): Likewise. + +1999-08-27 Jeffrey A Law (law@cygnus.com) + + * gjavah.c, jcf-write.c, verify.c: Do not use C++ style + comments in C code. + +1999-08-26 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_cxx_classname): Print "::" before qualified + name. + +1999-08-26 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (lookup_cl): Changed leading comment. Now does its best + to set the column number. + (qualify_ambiguous_name): Take WFL wrappers into account. + +1999-08-25 Gregg Townsend <gmt@cs.arizona.edu> + + * verify.c (verify_jvm_instructions): Don't check instruction + validity beyond end of method. + +1999-08-25 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (lang_specific_driver): Correctly handle --help again. + +1999-08-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (print_name, print_base_classname, utf8_cmp, + cxx_keyword_subst, generate_access, name_is_method_p, + get_field_name, print_field_name, super_class_name, print_include, + decode_signature_piece, print_class_decls, usage, help, + java_no_argument, version, add_namelet, print_namelet): Add static + prototype. + (print_base_classname, utf8_cmp, cxx_keyword_subst, + name_is_method_p): Constify a char*. + (get_field_name): Likewise. Prefer xstrdup over malloc/strcpy. + Provide a final else clause in an if-else-if. + (print_field_info): Add missing final arg in function call to + `print_field_name'. + (print_method_info, decompile_method, decode_signature_piece, + print_c_decl, print_full_cxx_name, print_stub, + print_mangled_classname, super_class_name, print_include, + add_namelet, add_class_decl, print_class_decls, process_file, + help): Constify a char*. + + * jcf-write.c (jcf_handler, push_constant1, push_constant2, + push_int_const, find_constant_wide, find_constant_index, + push_long_const, field_op, maybe_wide, emit_dup, emit_pop, + emit_iinc, emit_load_or_store, emit_load, emit_store, emit_unop, + emit_binop, emit_reloc, emit_switch_reloc, emit_case_reloc, + emit_if, emit_goto, emit_jsr, call_cleanups, + make_class_file_name): Add static prototypes. + (generate_bytecode_return, generate_bytecode_insns): Pass a + NULL_PTR, not a NULL_TREE. + + * jv-scan.c: Include "jcf.h". + (main): Declare using DEFUN macro. + + * jvspec.c (find_spec_file, lang_specific_pre_link, + lang_specific_driver): Add prototypes. + (find_spec_file): Constify a char*. + + * keyword.gperf (hash, java_keyword): Add prototypes. + + * lang.c (lang_print_error): Add static prototype. + (lang_init): Prefer memcpy over bcopy to avoid casts. + + * lex.c (yylex): Add static prototype. + + * parse-scan.y: Include "lex.c" earlier. + + * parse.h: Remove redundant declaration for `yylex'. + + * parse.y (java_decl_equiv, binop_compound_p, search_loop, + labeled_block_contains_loop_p): Add static prototypes. + (not_accessible_p): Make static to match prototype. + + * verify.c (start_pc_cmp): Don't needlessly cast away const. + +1999-08-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (check_method_redefinition): Changed leading comment. + (check_abstract_method_definitions): New function. + (java_check_abstract_method_definitions): New function. + (java_check_regular_methods): Call it. + (verify_constructor_super): Fixed indentation. + (lookup_method_invoke): Likewise. + +1999-08-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (method_header): Return a null pointer if the current + class node is null. + (finish_method_declaration): Return if the current function decl + is null. + (source_start_java_method): Likewise. + (java_method_add_stmt): Likewise. + +1999-08-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (emit_register_class): Removed unnecessary call to + start_sequence. + * parse.y (labeled_block_contains_loop_p): Removed unused local + variable. + +1999-08-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_refold): Added prototype. + +1999-08-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (BINOP_COMPOUND_CANDIDATES): New macro. + (java_stabilize_reference): Removed unnecessary `else'. + (java_complete_lhs): Set flag to remember boolean. Call + java_refold. Added comments. + (java_decl_equiv): New function. + (binop_compound_p): Likewise. + (java_refold): Likewise. + (patch_unaryop): Striped static field access assigned to decl and + op. Changed promotion scheme for ++/-- operators. + (search_loop): New function. + (labeled_block_contains_loop_p): Likewise. + (patch_loop_statement): Call labeled_block_contains_loop_p. Added + comment. + (patch_bc_statement): Call search_loop. Fixed comment. + +1999-08-14 Anthony Green <green@cygnus.com> + + * expr.c (java_lang_expand_expr): Mark static array data as + referenced. + +1999-08-10 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + * jvgenmain.c (main): NUL-terminate name_obstack. + +1999-08-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * check-init.c (check_bool2_init, done_alternative): Add static + prototypes. + + * class.c (add_interface_do, maybe_layout_super_class): Likewise. + (add_method, build_utf8_ref, build_class_ref, + append_gpp_mangled_type, layout_class_method): Constify a char*. + + * decl.c (push_promoted_type, make_binding_level): Add static + prototypes. + (push_promoted_type, pushdecl): Constify a char*. + + * except.c (find_handler_in_range, link_handler, + check_start_handlers): Add static prototypes. + + * expr.c (process_jvm_instruction): Constify a char*. + + * gjavah.c (main): Constify a char*. + + * java-tree.h (verify_jvm_instructions, process_jvm_instruction): + Constify a char*. + + * jcf-depend.c (free_entry, add_entry, munge, print_ents): Add + static prototypes. + (add_entry, jcf_dependency_set_target, jcf_dependency_add_target, + munge, print_ents): Constify a char*. + + * jcf-dump.c (disassemble_method): Constify a char*. + (print_constant_pool, print_exception_table): Add static prototypes. + (print_constant, print_exception_table, main, disassemble_method): + Constify a char*. + + * jcf-io.c (find_classfile, find_class): Likewise. + + * jcf-parse.c (JPOOL_UTF_DATA, find_in_current_zip): Likewise. + (set_source_filename, predefined_filename_p): Add static prototypes. + (set_source_filename, get_constant, get_class_constant, + find_in_current_zip): Constify a char*. + + * jcf-path.c (free_entry, append_entry, add_entry, add_path): Add + static prototypes. + (add_entry, add_path, jcf_path_classpath_arg, + jcf_path_CLASSPATH_arg, jcf_path_include_arg): Constify a char*. + + * jcf-reader.c (get_attribute, jcf_parse_preamble, + jcf_parse_constant_pool, jcf_parse_class, jcf_parse_fields, + jcf_parse_one_method, jcf_parse_methods, + jcf_parse_final_attributes): Add static prototypes. + (get_attribute): Constify a char*. + + * jcf.h (find_class, find_classfile, jcf_dependency_set_target, + jcf_dependency_add_target, jcf_path_classpath_arg, + jcf_path_CLASSPATH_arg, jcf_path_include_arg): Constify a char*. + + * jv-scan.c (main): Constify a char*. + (gcc_obstack_init): Add prototype arguments. + + * jvgenmain.c (gcc_obstack_init): Likewise. + (main): Constify a char*. + + * lang.c (put_decl_string, put_decl_node, java_dummy_print): Add + static prototypes. + (put_decl_string, lang_print_error): Constify a char*. + (lang_init): Remove redundant extern prototype. + + * mangle.c (emit_unicode_mangled_name): Constify a char*. + + * typeck.c (convert_ieee_real_to_integer, parse_signature_type): + Add static prototypes. + (get_type_from_signature): Constify a char*. + + * verify.c (check_pending_block, type_stack_dup, start_pc_cmp ): + Add static prototypes. + (start_pc_cmp): Prefer PTR over GENERIC_PTR. + (verify_jvm_instructions): Constify a char*. + + * xref.c (xref_flag_value): Likewise. + + * xref.h (xref_flag_value): Likewise. + + * zextract.c (makeword, makelong): Add static prototypes. + (makeword, makelong): Constify a uch*. + +1999-08-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * lang.c (java_dummy_print): Constify a char*. + (lang_print_error): Likewise. + (lang_init): Remove redundant prototype for `print_error_function'. + (lang_init_source): Likewise. + (lang_identify): Constify a char*. + +1999-08-09 Tom Tromey <tromey@cygnus.com> + + * javaop.h (WORD_TO_FLOAT): only inline if building with gcc. + (WORDS_TO_LONG): Likewise. + (WORDS_TO_DOUBLE): Likewise. + +1999-08-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (lang.o): Depend on $(RTL_H) $(EXPR_H). + + * expr.c (java_stack_pop, java_array_data_offset, + build_java_throw_out_of_bounds_exception, case_identity, + build_java_check_indexed_type): Add static prototypes. + (linenumber_table, expand_invoke, expand_java_field_op, + build_primtype_type_ref, expand_byte_code): Constify a char*. + + * java-tree.h (build_primtype_type_ref, linenumber_table): + Constify a char*. + (java_lang_expand_expr): Add prototype. + + * lang.c: Include rtl.h and expr.h. Remove extern prototype for + `java_lang_expand_expr'. + + * lex.c (java_lex_error): Constify a char*. + (java_get_unicode, java_read_char, java_allocate_new_line, + java_unget_unicode, java_sneak_unicode): Prototype. + + * parse-scan.y (current_class, package_name, method_declarator, + report_class_declaration, yyerror): Constify a char*. + + * parse.h (java_report_errors): Prototype. + (yyerror): Constify a char*. + + * parse.y (classitf_redefinition_error, check_modifiers, + parse_jdk1_1_error, lookup_package_type, + lookup_package_type_and_set_next, get_printable_method_name, + purify_type_name): Constify a char*. + (build_super_invocation, maybe_generate_finit, + verify_constructor_super, parser_add_interface, + add_superinterfaces, jdep_resolve_class, note_possible_classname, + java_complete_expand_methods, java_expand_finals, + cut_identifier_in_qualified, java_stabilize_reference, + do_unary_numeric_promotion, operator_string, do_merge_string_cste, + merge_string_cste): Prototype. + (single_type_import_declaration, yyerror, + variable_redefinition_error, build_array_from_name, + build_unresolved_array_type, check_class_interface_creation, + resolve_class, complete_class_report_errors, + note_possible_classname, read_import_dir, + find_in_imports_on_demand, resolve_package, fix_constructors, + check_deprecation, lookup_method_invoke, + maybe_build_primttype_type_ref, array_constructor_check_entry): + Constify a char*. + (java_complete_expand_methods, java_expand_finals): Make static. + (convert_narrow): Remove static prototype. + +1999-08-03 J"orn Rennecke <amylaar@cygnus.co.uk> + + * Makefile.in (decl.o): Depends on $(srcdir)/../defaults.h. + +1999-08-02 Richard Henderson <rth@cygnus.com> + + * decl.c: Include defaults.h instead of expr.h. + * parse.y: Likewise. + +1999-08-02 Jakub Jelinek <jj@ultra.linux.cz> + + * java/decl.c (start_java_method): Change all uses of + PROMOTE_PROTOTYPES, so that it tests it as a C expression. + Ensure expr.h is included. + * java/expr.c (pop_arguments): Ditto. + * java/parse.y (expand_start_java_method): Ditto. + +1999-08-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (ALL_CFLAGS): Add '-W -Wall'. + +1999-07-31 Bernd Schmidt <bernds@cygnus.co.uk> + + * decl.c: Include "function.h". + * except.c: Likewise. + * parse.y: Likewise. + * Makefile.in: Update dependencies. + +1999-07-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * expr.c (build_java_soft_divmod): Provide a default case in switch. + (java_lang_expand_expr): Mark parameters `target', `tmode' and + `modifier' with ATTRIBUTE_UNUSED. + + * gjavah.c (process_file): Add braces around ambiguous `else'. + + * jcf-dump.c (print_access_flags, localvar_free): Change return + type to void. + + * parse.y (java_complete_expand_method): Initialize variable + `exception_copy'. + (resolve_qualified_expression_name): Likewise for `field_decl'. + (patch_method_invocation): Likewise for `class_to_search'. + (qualify_ambiguous_name): Likewise for `name' and `ptr_type'. + (patch_assignment): Likewise for `lhs_type'. + + * verify.c (verify_jvm_instructions): Remove unused variable + `caller'. + +1999-07-25 Richard Henderson <rth@cygnus.com> + + * decl.c (va_list_type_node): New. + +1999-07-25 Anthony Green <green@cygnus.com> + + * gjavah.c (print_stub): New function. + (METHOD_IS_NATIVE): New macro. + (print_mangled_classname): Make static. + (HANDLE_END_FIELD): Don't emit fields during stub generation. + (process_file): Perform stub generation. + (HANDLE_METHOD): Don't emit class decls during stub + generation. + (HANDLE_END_METHOD): Take into account stub generation. + (print_method_info): Handle stub generation. + (print_stub): New function. + (print_cxx_classname): Make signature consistant with others. + (help): Describe -stubs option. + (main): Create stub file. + (version): Use version.c. + (print_full_cxx_name): New function. + (print_c_decl): Use print_full_cxx_name. + +1999-07-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (check_init): Handle MAX_EXPR. + +1999-07-15 Andrew Haley <aph@cygnus.com> + + * lang.c (flag_use_divide_subroutine): New variable. + * typeck.c: (convert_ieee_real_to_integer): Bounds check + fp-to-integer conversion. + (convert): Call convert_ieee_real_to_integer when flag_fast_math + is not set. + + * expr.c (build_java_soft_divmod): New function. + (build_java_binop): Call build_java_soft_divmod if + flag_use_divide_subroutine is set. + * decl.c: soft_idiv_node, soft_irem_node, soft_ldiv_node, tree + soft_lrem_node: new builtin functions. + (init_decl_processing) Initialize the new builtins. + * java-tree.h soft_idiv_node, soft_irem_node, soft_ldiv_node, tree + soft_lrem_node: new builtin functions. + (build_java_soft_divmod): New function. + * parse.y: Call build_java_soft_divmod if + flag_use_divide_subroutine is set. + * parse.c: Rebuilt. + + * jvspec.c (lang_specific_driver): Always allow an extra arg (for + a --specs= arg) even if not linking. + * lang-options.h (DEFINE_LANG_NAME ("Java")): Add + -fuse-divide-subroutine + +1999-07-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_and_layout): Check methods only once. + (resolve_qualified_expression_name): Verify thrown exceptions + compatibility. + (check_thrown_exceptions): Reject exceptions thrown in + initializer. Error message tuned. + +1999-07-14 Andrew Haley <aph@cygnus.com> + + * expr.c (expand_expr): Do not return the last statement in a + block as the block's value. + +1999-07-03 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (force_evaluation_order): Save the COMPOUND_EXPR'ed + CALL_EXPR, to avoid order of evaluation changes. + +1999-07-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (qualify_ambiguous_name): Do not use + IDENTIFIER_LOCAL_VALUE when name is a STRING_CST. + +1999-07-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (check_init): Handle MAX_EXPR. + * expr.c (force_evaluation_order): Force method call arguments to + be evaluated in left-to-right order. + * parse.y (qualify_ambiguous_name): Loop again to qualify + NEW_ARRAY_EXPR properly. + +1999-06-30 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_invoke): Resolve unresolved invoked method + returned type. + (qualify_ambiguous_name): STRING_CST to qualify expression for + type name resolution. + +1999-06-24 Andrew Haley <aph@cygnus.com> + + * class.c (finish_class): Whenever a deferred method is + output, rescan the list of methods to see if a new candidate for + output can be found. + +1999-06-28 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (lang_specific_driver): Recognize --help. + +1999-06-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_package): Fixed bogus return statement. + (patch_method_invocation): Resolve method invocation beginning with + a package name qualifier. + +1999-06-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in (java.stage1): Depend on stage1-start. + (java.stage2): Likewise for stage2-start. + (java.stage3): Likewise for stage3-start. + (java.stage4): Likewise for stage4-start. + +1999-06-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_complete_lhs): When doing cross referencing, don't + try to keep file location on a WFL expanded as a CALL_EXPR. + +1999-06-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (finish_method_declaration): Insert a RETURN_EXPR when + compiling to class file a void method with an empty method body. + As a side effect, the bytecode backend will generate the + appropriate `return' instruction. + +1999-06-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (lookup_package_type_and_set_next): New function prototype. + (resolve_package): Search current and imported packages. + (lookup_package_type_and_set_next): New function. + +1999-06-22 Andrew Haley <aph@cygnus.com> + + * verify.c (verify_jvm_instructions): Check for pending blocks + before invalid PC test and opcode switch, not after. + +1999-06-21 Andrew Haley <aph@cygnus.com> + + * except.c (find_handler_in_range): The upper limit for exception + ranges is exclusive, not inclusive: (start <= pc < end). + (link_handler): find child pointer which points to outer by + searching sibling list: previous code incorrectly assumed that + outer->outer->first_child must point to outer. + * verify.c (verify_jvm_instructions): FIXME added to code for + `athrow'. + (verify_jvm_instructions): Do not assume that the last block + processed in a subroutine is a block which ends with a `ret' + instruction. With some control flows it is possible that the last + block ends with an `athrow'. + +1999-06-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (qualify_ambiguous_name): Reorganized the post + evaluation of non WFL leading expression nodes. + +1999-06-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (qualify_ambiguous_name): Handle ARRAY_REF after + CONVERT_EXPR. + +1999-06-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (qualify_ambiguous_name): Handle qualified expression + beginning with a STRING_CST. + +1999-06-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (register_fields): Set DECL_INITIAL on both + pre-initialized static and public fields. + (resolve_field_access): Static field access expressions to always + use pointer types. + (qualify_ambiguous_name): Work out buried CALL_EXPR for proper + qualification. CONVERT_EXPR to be resolved as an expression name. + (java_complete_lhs): Identify and access qualified final + initialized field in switch statement case expression. + (fold_constant_for_init): Pre-initialized field decl constant to + be folded. + +1999-06-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (note_possible_classname): Mark returned node with + QUALIFIED_P only if the original class name contained a '/'. + +1999-06-05 Anthony Green <green@cygnus.com> + + * Make-lang.in (gcjh): More parallel build fixes. + +1999-06-03 Mike Stump <mrs@wrs.com> + + * Make-lang.in (JCF_DUMP_SOURCES, jvgenmain): Fix parallel builds. + +1999-06-02 Anthony Green <green@cygnus.com> + + * except.c (link_handler): Chain exception handlers in order. + +1999-06-02 Anthony Green <green@cygnus.com> + + * expr.c (expand_byte_code): Fill unreachable bytecode regions + with nops and process as usual in order to always set correct EH + ranges. Emit detailed warnings about unreachable bytecodes. + +1999-06-02 Anthony Green <green@cygnus.com> + + * class.c (build_utf8_ref): Mark cinit and utf8 tree nodes as + constant. + +1999-05-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (lookup_field_wrapper): Unified returned value to NULL + or the searched field decl. + +1999-05-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (fold_constant_for_init): Convert numerical constant + values to the type of the assigned field. + +1999-05-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (lookup_field): Relaxed the test on class loading error + detection. + * parse.y (fold_constant_for_init): Enabeled old code. + +1999-05-26 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (valid_ref_assignconv_cast_p): Let `_Jv_CheckCast' + decide the validity of the cast of a java.lang.Cloneable reference + to an array. + (patch_conditional_expr): Fixed first argument passed to + binary_numeric_promotion. + +1999-05-26 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (qualify_ambiguous_name): Take into account that a + CONVERT_EXPR might specify a type as a WFL. + +1999-05-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_assignment): Save the rhs before using it as an + argument to _Jv_CheckArrayStore. + +1999-05-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (java_parse_doc_section): Fixed `tag' buffer size. + +1999-05-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (java_lex): Accepts `+' or `-' after the beginning of a + floating point literal only when the exponent indicator has been + parsed. + +1999-05-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (formal_parameter:): Construct argument tree list + element even if a yet unsupported final parameter was encountered. + +1999-05-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (finish_method_declaration): Issue errors for native or + abstract methods declared with a method body, as well as for non + native or non abstract methods with no method body. + +1999-05-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (build_utf8_ref): Initialize variable `field'. + + * decl.c (init_decl_processing): Initialize variable `field'. + + * expr.c (build_known_method_ref): Mark parameters `method_type', + `method_signature' and `arg_list' with ATTRIBUTE_UNUSED. + (process_jvm_instruction): Likewise for parameter `length'. + + * jvspec.c (lang_specific_driver): Mark variables `saw_math', + `saw_libc', `saw_gc', `saw_threadlib' and `saw_libgcj' with + ATTRIBUTE_UNUSED. + + * parse.y (maybe_generate_clinit): Remove unused variable + `has_non_primitive_fields'. + (find_in_imports_on_demand): Initialize variables `node_to_use' + and `cl'. + (patch_binop): Likewise for variable `prom_type'. + (patch_unaryop): Likewise for variable `prom_type'. + + * verify.c (verify_jvm_instructions): Likewise for variable `last'. + + * xref.c (xref_table): Add missing initializer. + +1999-05-14 Tom Tromey <tromey@cygnus.com> + + * java-except.h (struct eh_range): Removed unused `next' member. + * verify.c (verify_jvm_instructions): Call check_nested_ranges + after adding all exception handlers. Sort exception ranges in + order of start PC. + (struct pc_index): New structure. + (start_pc_cmp): New function. + * except.c (add_handler): Return `void'. Don't call link_handler; + instead construct an ordinary linked list and do range + coalescing. + (check_nested_ranges): New function. + (link_handler): Changed interface to allow merging of eh_ranges. + Split overlapping ranges. Return `void'. + +1999-05-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (constructor_block_end:): New rule, tagged <node>. + (constructor_body:): Use `constructor_block_end' instead of + `block_end'. + +1999-05-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (statement_nsi:): Pop `for' statement block. + (java_complete_lhs): Labeled blocks containing no statement are + marked as completing normally. + +1999-05-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * xref.c (xref_set_current_fp): New function, defined. + * xref.h (xref_set_current_fp): New function, prototyped. + +1999-05-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (check_init): Take into account that + LABELED_BLOCK_STMT can be empty. + +1999-05-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_check_regular_methods): Warning check on not + overriding methods with default access in other packages does not + apply to `<clinit>'. + (java_complete_lhs): If block body is an empty_stmt_node, replace + it by NULL_TREE. This prevents gcc from generating an irrelevant + warning. + +1999-05-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (check_init): Removed code accepting to see things + falling through default:, when doing xrefs. + * java-tree.h (do_not_fold): New global variable, declared. + * parse.y (do_not_fold): New global variable, defined. + (java_complete_expand_method): Set `do_not_fold' to the value of + `flag_emit_xref'. When doing xrefs: copy the thrown exceptions, + and reinstall them after them have been purged; do not check for + initializations; do not issue missing return errors. + (java_complete_lhs): Do not attempt to patch INSTANCEOF_EXPR nodes + when doing xrefs. + (patch_binop): Skip the fold part when doing xrefs. + (build_string_concatenation): Skip the concatenation part when + doing xrefs. + (patch_synchronized_statement): Do not generate a try-finally when + doing xrefs. + (patch_throw_statement): When doing xrefs, do not call BUILD_THROW + and keep the location where the throw was seen. + * typeck.c (convert): When `do_not_fold' is set, do not attempt + any treatment on the converted node an simply return a NOP_EXPR of + the targeted type. + * xref.c (xref_get_data): New function, defined. + * xref.h (xref_get_data): New function, declared. + (XREF_GET_DATA): Use xref_get_data. + +1999-05-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (print_include): Cast the result of `strlen' to int + when comparing against a signed value. + (add_namelet): Likewise. + +1999-05-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * expr.c (expand_invoke): Mark parameter `nargs' with + ATTRIBUTE_UNUSED. + (PRE_LOOKUP_SWITCH): Likewise for variable `match'. + + * jcf-io.c (jcf_unexpected_eof): Mark parameter `count' with + ATTRIBUTE_UNUSED. + + * jcf-reader.c (get_attribute): Cast a value to long + when comparing against a signed expression. Likewise. + + * lex.h: Never define HOST_WIDE_INT, HOST_BITS_PER_WIDE_INT or + HOST_BITS_PER_CHAR. + +1999-05-11 Andrew Haley <aph@cygnus.com> + + * parse.y (source_end_java_method): If the current method contains + any exception handlers, force asynchronous_exceptions: this is + necessary because signal handlers in libjava may throw exceptions. + * decl.c (end_java_method): Ditto. + +1999-05-11 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (jvspec.o): Don't define WITH_THREAD_x or WITH_GC_x + flags. + * jvspec.c (THREAD_NAME): Removed. + (GC_NAME): Likewise. + (MATHLIB): Likewise. + (WITHLIBC): Likewise. + (GCLIB): Likewise. + (THREADLIB): Likewise. + (MATH_LIBRARY): Likewise. + (lang_specific_driver): Don't add `-l' options to command line. + Instead, add a single --specs option. Recognize `-L' options and + use them to search for spec file. + (find_spec_file): New function. + (SPEC_FILE): New define. + +1999-05-11 Dave Brolley <brolley@cygnus.com> + + * lang-options.h: -MD, -MMD, -M and -MM not needed here for + cpplib-enabled build. + +1999-05-05 Per Bothner <bothner@cygnus.com> + + * class.c (make_field_value): DECL_INITIAL may be a string literal; + temporarily zero it while calling rest_of_decl_compilation. + + * java-tree.h (string_ptr_type_node): Add declaration. + * decl.c: Define and initialize string_ptr_type_node. + * parse.y (patch_string_cst): Use string_ptr_type_node. + + * parse.h (LOOP_HAS_LABEL_P, LOOP_HAS_LABEL_SKIP_P): Removed. + * parse.y (for_statement): Now unconditionally exit_block. + (finish_labeled_statement): No longer exit_block if for-loop. + (patch_loop_statement): Check harder if the loop is already labeled. + + * parse.y (patch_initialized_static_field): Removed function. + (maybe_generate_clinit): Removed special handling for interfaces. + (java_complete_expand_methods): Do a preliminary java_complete_tree + on <clinit> to determine if it can be removed. + (java_complete_expand_method): Remove special handling for <clinit>. + (java_complete_lhs): For BLOCK and EXPR_WITH_FILE_LOCATION + optimize if we get back empty_stmt_node. + For MODIFY_EXPR, re-do checking of static initializers. + (fold_constant_for_init): Don't return immediate if VAR_DECL. + For VAR_DECL, pass correct context. + + * verify.c (verify_jvm_instructions): Better error messages. + +1999-05-03 Tom Tromey <tromey@cygnus.com> + + * parse-scan.y (interface_declaration): Call + report_class_declaration for interfaces. + +1999-04-30 20:54 -0400 Zack Weinberg <zack@rabi.columbia.edu> + + * Makefile.in: Remove -v from bison command lines. + +1999-04-30 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * check-init.c (check_init): Exclude a case of error when doing + xrefs. + * class.c (layout_class_method): Don't generate the error message + twice when compiling from source. + * lang-options.h: Added `-Wredundant-modifers' and + `-Wunusupported-jdk11' flags and help text. + * lang.c (lang_decode_option): Added support for + `-Wunsupported-jdk11' and `-Wredundant-modifiers'. + flag_static_local_jdk11 and flag_redundant set accordingly. + * lex.c (java_lex): Call BUILD_OPERATOR on CCB_TK. + * parse.h (EXPR_WFL_ADD_COL): New macro. + (DECL_END_SOURCE_LINE): Likewise. + (DECL_INHERITED_SOURCE_LINE): Likewise. + * parse.y (static_ref_err): New function, prototyped. + (CCB_TK): Now tagged <operator>. + (class_body:): Remember the location of the closing '}' of a class + definition when doing xrefs. + (block:): Likewise. + (block_end:): Likewise. + (create_class): Remember the location of the inherited class + identifier when doing xrefs. + (register_fields): Added test on first operand of `init' before + testing it TREE_CODE. + (method_header): Store the location of the class identifier in the + class decl when doing xrefs. + (finish_method_declaration): Don't combine first/last method line + when doing xref. + (java_check_regular_methods): Warning check on not overriding + methods with default access on other packages move before check on + static methods. Initialization of `aflags' also moved up. + (resolve_expression_name): Call static_ref_err to report the error. + (static_ref_err): New function, implemented. + (resolve_field_access): Returned simplified static field access + when doing xrefs. + (resolve_qualified_expression_name): Check for illegal use of + static fields in a non static context. Call static_ref_err to + report error in various places. + (java_complete_tree): Do not fold initialized static fields when + doing xrefs. + (java_complete_lhs): Likewise. + +1999-04-29 Anthony Green <green@cygnus.com> + + * expr.c (generate_name): Use ASM_GENERATE_INTERNAL_LABEL to + create internal labels. + (lookup_label): Ditto. + +1999-04-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class_method): Generate <clinit>'s rtl for + interfaces. + * decl.c (complete_start_java_method): Don't call _Jv_InitClass + for interfaces' <clinit>. + * expr.c (lookup_field): Search for fields in interfaces. + (expand_invoke): Fixed indentation. + (expand_java_field_op): Likewise. Use IS_CLINIT. + * parse.h (JPRIMITIVE_TYPE_OR_VOID_P): Macro removed. + (IS_CLINIT): New macro. + * parse.y (type_declaration:): Call maybe_generate_clinit after an + interface was parsed. + (maybe_generate_clinit): Don't generate if the current class is an + interface with only fields of primitive types. + (reset_method_name): Use IS_CLINIT. + (java_complete_expand_method): Expand <clinit> when it exists for + interfaces. Use IS_CLINIT. + (resolve_expression_name): Use DECL_CONTEXT instead of + current_class to build static field references. + (java_complete_lhs): Use IS__CLINIT. Don't use SAVE_EXPR on + ARRAY_REF when doing xreferencing. + (check_final_assignment): Fixed typo in leading comment. Use + IS_CLINIT. + (patch_array_ref): Don't fully expand array references when + xreferencing. + (patch_return): Use IS_CLINIT. + (patch_throw_statement): Likewise. + +1999-04-22 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (JAVA_SRCS): Added check-init.c. + +1999-04-21 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (predef_filenames, predef_filenames_size): New globals + (init_decl_processing): predef_filenames and predef_filenames_size + initialized. + * java-tree.h (predef_filenames, predef_filenames_size): Declared + extern. + * jcf-parse.c (predefined_filename_p): New function. + (yyparse): Check that files on the command line are specified only + once and issue a warning otherwise. + * parse.h (JPRIMITIVE_TYPE_OR_VOID_P): New macro. + * parse.y (source_end_java_method): Nullify NOP method bodies, to + avoid a gcc warning with -W -Wall turned on. + (java_expand_classes): Abort if errors were encountered. + (java_complete_lhs): If the cross reference flag is set, wrap + field DECL node around a WFL when resolving expression name. + +1999-04-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lang.c (lang_decode_option): Fixed returned value when parsing + `-fxref=...' and `-Wall'. + * parse.y (source_end_java_method): Do not generate code when + flag_emit_xref is set. + (resolve_expression_name): Do not build static field access when + flag_emit_xref is set. + (resolve_field_access): No special treatment on `length' when + flag_emit_xref is set. Do not build qualified static field access + when flag_emit_xref is set. + (patch_invoke): Keep the method DECL as operand 0 of the CALL_EXPR + when flag_emit_xref is set. + (patch_assignment): Do not generate array store runtime check when + flag_emit_xref is set. + * xref.c (xref_flag_value): Fixed function declaration + indentation. + (xset_set_data): New function. + * xref.h (xref_set_data): Added prototype for new function. + (typedef struct xref_flag_table): New field data. + (XREF_GET_DATA): New macro. + +1999-04-19 Tom Tromey <tromey@cygnus.com> + + * xref.h (enum): Removed trailing comma. + + * parse.y (resolve_qualified_expression_name): Added missing + `break'. + +1999-04-15 Anthony Green <green@cygnus.com> + + * gjavah.c: New prototypes for java_float_finite and + java_double_finite. + +1999-04-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_unaryop): Fixed ++/-- operator check on array + references. + +1999-04-06 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (TREE_H): Add tree-check.h. + (RTL_H): Add genrtl.h. + +1999-04-06 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_assignment): Added ArrayStoreException runtime + check. + +1999-04-06 Per Bothner <bothner@cygnus.com> + + * expr.c (pop_type_0): New function. + (pop_type): Use pop_type_0. + * java-tree.h (pop_type_0): New declaration. + * verify.c (verify_jvm_instructions): Check return instructions. + + * parse.y (patch_binop): Don't fold if non-constant and emiting + class files. + +1999-04-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (gjavah.o): Depend on $(JAVA_TREE_H). + + * gjavah.c: Include math.h earlier. Include tree.h/java-tree.h. + (main_jcf): Don't define. + (process_file): Don't set `main_jcf'. + + * java-tree.h (main_jcf): Don't declare. + + * jcf-parse.c (main_jcf): Add static definition. + + * lang.c (main_jcf): Don't define. + +1999-04-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (add_method_1): Cast the argument of `bzero' to PTR. + + * decl.c (copy_lang_decl): Likewise for `bcopy'. + + * jcf-depend.c: Include "config.h", not <config.h>. + + * jcf-parse.c (jcf_figure_file_type): Cast the arguments of + `bcopy' to PTR. + + * jcf-path.c: Include "config.h", not <config.h>. + + * lex.c: Don't include various system header files. + (java_init_lex): Cast the argument of `bzero' to PTR + + * parse-scan.y (java_push_parser_context): Likewise. + + * parse.y (java_push_parser_context): Likewise. + (patch_bc_statement): Match format specifier to variable argument. + + * xref.c: Don't include <stdio.h>. + +1999-04-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (struct parser_ctxt *ctxp): Now global. + (declare_local_variables): Use WFL compound value for the + declaration source line value, when doing cross-referencing. + +1999-03-31 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_field_info): Allow constants of other types. + (print_include): Generate include when new name is proper prefix + of already printed name. + (add_namelet): Likewise. + (cxx_keyword_subst): New function. + (print_method_info): Use it. + (print_field_name): New function. + (get_field_name): New function. + (print_field_info): Use get_field_name and print_field_name. + +1999-03-31 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (keyword.h): Generate using gperf language 'C', not + 'KR-C', so gperf uses the `const' keyword on strings. + + * keyword.gperf (java_keyword): Const-ify a char*. + +1999-03-30 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_bc_statement): Fixed identation and a bogus + `printf' format. + +1999-03-30 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (patch_assignment): Allow static variables in other + classes to be assigned. + +1999-03-28 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * class.c (maybe_add_interface): Remove unused variable + `interface_binfo'. + (make_class_data): Use = for assignment, not ==. Likewise. + (emit_register_classes): Remove unused variable `decl'. + + * lex.c: Fix comment so as not to contain an embedded `/*'. + + * verify.c (verify_jvm_instructions): Remove unused variable + `self_type'. + +1999-03-27 Per Bothner <bothner@cygnus.com> + + * parse.y (complete_loop_body): Rename to finish_loop_body. + (complete_labeled_statement): Rename to finish_labeled_statement. + (complete_for_loop): Rename to finish_for_loop. + (complete_method_declaration): Rename to finish_method_declaration. + + * java-tree.h (continue_identifier_node): New global node. + * decl.c: Define and initialize continue_identifier_node. + * parse.y (generate_labeled_block): Remove - no longer needed. + (build_loop_body): Use continue_identifier_node for continue block. + (finish_labeled_statement): Also do pop_labeled_block actions. + (java_complete_lhs): POP_LOOP even if error. + (build_labeled_block): Special handling for continue_identifier_node. + (patch_loop_statement): Re-organize. + (patch_bc_statement): Re-write. + +1999-03-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (EXPR_WFL_GET_LINECOL): Set a line and column count + using a WFL compound value. + * parse.y (xref.h): Include. + (maybe_create_class_interface_decl): Set DECL_SOURCE_LINE to the + WFL compound value. + (register_fields): Set WFL compound value to lineno if doing + xrefs. + (java_complete_expand_method): Call expand_xref if flag_emit_xref + is set. + * xref.c (system.h, jcf.h, parse.h, obstack.h): Include. + * xref.h (expand_xref): Prototype renamed from xref_generate. + +1999-03-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h (BLOCK_CHAIN_DECL): New use GET_CURRENT_BLOCK. + (GET_CURRENT_BLOCK): New macro. + * parse.y (current_static_block): New global variable. + (method_body:): Define action. + (complete_method_declaration): Set current_function_decl to NULL + when work on the current method is done. + (declare_local_variables): Use GET_CURRENT_BLOCK. + (java_method_add_stmt): Likewise. + (java_complete_expand_method): Disable the use of `this' when + expanding <clinit>. + (enter_a_block): If no current method exist, use + current_static_block to link static initializer blocks. + (exit_block): Rewritten to use current_static_block when no current + method decl exists. + (lookup_name_in_blocks): Use GET_CURRENT_BLOCK. + (patch_return): Forbid the use of `return' in static initializers. + (patch_throw_statement): Fixed indentation. Issue specific error + for uncaught thrown checked exception in static initializer + blocks. Removed FIXME. + +1999-03-25 Zack Weinberg <zack@rabi.columbia.edu> + + * java/Make-lang.in: Remove all references to gcj.o/gcj.c. + Link gcj from gcc.o. + +1999-03-23 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (find_applicable_accessible_methods_list): When dealing + with interface: ensure that a given interface or java.lang.Object + are searched only once. + +1999-03-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gjavah.c (print_c_decl): Remove unused argument `flags'. + + * jcf-dump.c (print_access_flags): Add braces around if-else. + + * jvspec.c (lang_specific_driver): Wrap variable `len' in macro + COMBINE_INPUTS. + + * lex.c (build_wfl_node): Add static prototype. + + * lex.h (build_wfl_node): Remove static prototype. + + * parse.y: Include lex.c early enough to declare everything needed. + Ensure calls to `build_wfl_node' pass the proper arguments. + (create_class): Remove unused variable `super_decl'. + (get_printable_method_name): Initialize variable `name'. + +1999-03-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Changelog: Fixed 1999-03-22 typos. + * lang.c (lang_decode_option): Fixed typo in error string in the + XARG section. + +1999-03-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Makefile.in (JAVA_OBJS): Added entry xref.o. + (xref.o): New rule. + * java-tree.h (flag_emit_xref): Declared extern. + * lang.c (xref.h): Included. + (flag_emit_xref): New global variable. + (lang_decode_option): Added support for -fxref. + * xref.c: Created. + * xref.h: Likewise. + +1999-03-21 Manfred Hollstein <manfred@s-direktnet.de> + + * Make-lang.in ($(GCJ)$(exeext)): Add intl.o to list of files to be + linked with. + +1999-03-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (jcf-dump.o): Depend on $(CONFIG_H) + $(srcdir)/../system.h and $(JAVA_TREE_H). + (jcf-io.o): Depend on $(JAVA_TREE_H). + (mangle.o): Likewise. + + * check-init.c (check_cond_init): Add static prototype. + + * class.c (build_java_method_type, hashUtf8String, + make_field_value, get_dispatch_vector, get_dispatch_table, + append_gpp_mangled_type, mangle_static_field): Likewise. + (strLengthUtf8): Hide unused definition. + (hashUtf8String): Const-ify. + (make_field_value): Un-ANSI-fy. + + * constants.c: Move inclusion of jcf.h above java-tree.h. + (set_constant_entry, find_class_or_string_constant, + find_name_and_type_constant, get_tag_node, + build_constant_data_ref): Add static prototype. + + * decl.c (push_jvm_slot, builtin_function, + lookup_name_current_level): Likewise. + (builtin_function): Const-ify. + + * except.c (expand_start_java_handler, expand_end_java_handler): + Add static prototype. + + * expr.c (flush_quick_stack, push_value, pop_value, + java_stack_swap, java_stack_dup, build_java_athrow, + build_java_jsr, build_java_ret, expand_java_multianewarray, + expand_java_arraystore, expand_java_arrayload, + expand_java_array_length, build_java_monitor, expand_java_pushc, + expand_java_return, expand_java_NEW, expand_java_INSTANCEOF, + expand_java_CHECKCAST, expand_iinc, expand_java_binop, note_label, + expand_compare, expand_test, expand_cond, expand_java_goto, + expand_java_call, expand_java_ret, pop_arguments, expand_invoke, + expand_java_field_op, java_push_constant_from_pool): Likewise. + + (decode_newarray_type, expand_iinc): Un-ANSI-fy. + (build_java_arraynull_check): Mark parameters `node' and `type' + with ATTRIBUTE_UNUSED. + (note_label): Likewise for parameter `current_pc'. + (expand_java_call, expand_java_ret): Hide unused definition. + + * java-tree.h (make_class, build_constants_constructor, + java_set_exception_lang_code, pop_labeled_block, emit_handlers, + init_outgoing_cpool, register_class, emit_register_classes, + java_layout_seen_class_methods): Prototype. + (unicode_mangling_length): Const-ify. + (append_gpp_mangled_name, append_gpp_mangled_classtype, + emit_unicode_mangled_name, format_int, format_uint, + jcf_trim_old_input, jcf_print_utf8, jcf_print_char, + jcf_print_utf8_replace, open_class): Prototype. + + * jcf-dump.c: Include "config.h", not <config.h>. Don't include + <stdio.h>. Include tree.h/java-tree.h. + (utf8_equal_string usage, process_class): Add static prototype. + (open_class): Don't prototype this here. + (utf8_equal_string): Match arguments to format specifiers. + (HANDLE_CODE_ATTRIBUTE, BRANCH, JSR, RET, LOOKUP_SWITCH, + TABLE_SWITCH, disassemble_method): Likewise. + + * jcf-io.c: Include tree.h/java-tree.h. + (open_class, find_classfile, jcf_print_utf8, + jcf_print_utf8_replace): Const-ify. + + * jcf-parse.c (parse_zip_file_entries, process_zip_dir, + parse_class_file): Add static prototype. + (find_in_current_zip): Match definition to existing static + prototype. + + * jcf-write.c: Include jcf.h before tree.h/java-tree.h. + (alloc_chunk, append_chunk, append_chunk_copy, gen_jcf_label, + finish_jcf_block, define_jcf_label, get_jcf_label_here, + put_linenumber, localvar_alloc, localvar_free, get_access_flags, + write_chunks, adjust_typed_op, generate_bytecode_conditional, + generate_bytecode_return, perform_relocations, init_jcf_state, + init_jcf_method, release_jcf_state, generate_classfile): + Add static prototype. + (emit_unop): Mark parameter `type' with ATTRIBUTE_UNUSED. + (make_class_file_name): Const-ify. + + * jcf.h (find_classfile): Const-ify. + + * jv-scan.c (reset_report): Remove prototype. + + * jvgenmain.c: Include jcf.h/tree.h/java-tree.h. + (error): Rewrite to allow varargs. + + * lang.c (lang_f_options): Const-ify. + + * lex.c (java_parse_escape_sequence): Add static prototype. + (java_allocate_new_line): Match definition to existing static + prototype. + + * mangle.c Include tree.h/java-tree.h. + (unicode_mangling_length, emit_unicode_mangled_name, + append_gpp_mangled_name, append_gpp_mangled_classtype): Const-ify. + + * parse.h (jdep_code): Remove trailing comma in enumeration. + (java_get_line_col): Move prototype outside of !JC1_LITE test. + (reset_report): Add prototype. + + * verify.c (push_pending_label, merge_types): Add static + prototypes. + + * zipfile.h (opendir_in_zip, open_in_zip): Prototype. + +1999-03-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (find_applicable_accessible_methods_list): Extend the + search to superinterfaces when relevant. + (search_applicable_methods_list): New function. + +1999-03-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (unmangle_classname): Implemented stricter testing + before setting the QUALIFIED_P flag on an identifier. + +1999-03-16 Per Bothner <bothner@cygnus.com> + + * parse.y (java_complete_lhs): Call force_evaluation_order + after patch_newarray. + (patch_binop): Don't call fold if there are side effects. + +1999-03-16 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_stabilize_reference): Use save_expr instead of + building a SAVE_EXPR node. + (java_complete_lhs): Patch the resulting string of the `+=' + operator (if necessary) and complete the RHS after having built + the cast. + +1999-03-15 Per Bothner <bothner@cygnus.com> + + * class.c (make_class): Don't set CLASS_P here (because + this function is also called by build_java_array_type). + (push_class): Set CLASS_P here instead. + * parse.h (TYPE_CLASS_P): Check for TYPE_ARRAY_P is redundant. + + * jcf-dump.c (print_access_flags): Take extra parameter to indicate + context. If the context is class, perfer "super" over "synchronized". + * jcf-write.c (generate_classfile): Don't add ACC_SUPER if interface. + + * parse.y (create_class): Don't call parser_check_super here; + it is not robust. Always wait until later. + + * parse.y (method_header): For interfaces, set ACC_ABSTRACT (to + match what JDK 1.2 does), but don't set ACC_PUBLIC. + +1999-03-13 Per Bothner <bothner@cygnus.com> + + * lex.c (java_read_char): UNGET invalid non-initial utf8 character. + * lex.h (UNGETC): Change misleading macro. + +1999-03-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (java_stabilize_reference): Return NODE when patching a + COMPOUND_EXPR. + (java_complete_lhs): Put parenthesis around truth values. + +1999-03-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class_method): Don't make rtl for interface + methods. + * parse.h (GET_TYPE_NAME): New macro. + * parse.y (if_then_statement:): Fixed indentation. + (if_then_else_statement:): Likewise. + (for_statement:): Fixed spacing. + (try_statement:): Fixed indentation. + (create_interface): Don't force interfaces to be abstract. + (method_header): Abstract methods are OK in interfaces. + (declare_local_variables): Fixed typo in comment. + (java_complete_expand_method): Fixed indentation. + (resolve_qualified_expression_name): Use GET_TYPE_NAME to report + non accessible fields. + (java_stabilize_reference): New function. + (java_complete_lhs): Fixed indentation. Use + java_stabilize_reference in compound assignment. Insert the + cast. If not processing `+' fix string constants before processing + binop. + +1999-03-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * constants.c (find_class_or_string_constant): Cast variable `j' + to a `jword' when comparing against one. + + * expr.c (java_lang_expand_expr): Remove unused variables + `has_finally_p' and `op0'. + + * gjavah.c (print_field_info): Cast a value to jint when comparing + against one. Likewise for a jlong. + (add_namelet): Likewise cast a `sizeof' to an int when comparing + against a signed quantity. + + * jcf-dump.c (print_signature_type): Remove unused variable `digit'. + (print_signature): Don't needlessly dereference variable `str' + + * jcf-reader.c (get_attribute): Mark variables `max_stack' and + `max_locals' with ATTRIBUTE_UNUSED. + (jcf_parse_class): Likewise for variable `index'. + + * parse.h (reverse_jdep_list): Remove static prototype. + + * parse.y (build_jump_to_finally): Remove prototype and definition. + (reverse_jdep_list): Add static prototype. + + * typeck.c (convert_ieee_real_to_integer): Remove unused variables + `assignment' and `expr_decl'. + + * verify.c (verify_jvm_instructions): Remove unused label `bad_ldc'. + +1999-03-12 Andrew Haley <aph@cygnus.com> + + * jcf-path.c (add_entry): alloca len+2 rather than len+1 bytes; + we'll need a directory separator and a null character. + +1999-03-10 Per Bothner <bothner@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): Handle __builtin_fmod, for %. + +Tue Mar 9 11:52:08 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (method_header): Don't set ACC_ABSTRACT flags on + interfaces. + +1999-03-05 Per Bothner <bothner@cygnus.com> + + * lex.c (java_parse_end_comment): Take extra parameter (next char). + + * class.c (build_utf8_ref): Fix possible name class/ambiguity. + + * class.c (layout_class_method): A static method in a base class + is never overridden, so treat it like it doesn't exist. + However, do complain about private non-static method overriding + public static method. + + * parse.y: Don't set unused INITIALIZED_P flag. + * java-tree.h (INITIALIZED_P): Removed no-longer needed flag. + + * parse.y (find_expr_with_wfl): Optimize tail-calls. + (build_array_from_name): Re-order &index[string] to &string[index]. + + * parse.y (java_complete_lhs): Don't call patch_assignment if rhs is + error_mark (it might catch more errors, but it is more likely to lose). + +1999-03-06 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (jcf-parse.o): Depend on $(PARSE_H). + (parse-scan.o): Depend on toplev.h. + + * class.c (make_method_value): Add prototype. Make it static. + Remove unused second argument, caller changed. + + * expr.c (java_lang_expand_expr): Remove unused variable + `return_label'. + + * java-tree.h: Don't prototype find_in_current_zip. + Add prototypes for verify_constant_pool, start_java_method, + end_java_method, give_name_to_locals, expand_byte_code, + open_in_zip, set_constant_value, find_constant1, find_constant2, + find_utf8_constant, find_string_constant, find_class_constant, + find_fieldref_index, find_methodref_index, write_constant_pool, + count_constant_pool_bytes and encode_newarray_type. + + * jcf-dump.c: Remove unused variable `LONG_temp'. + + * jcf-parse.c: Include parse.h. + (jcf_parse_source): Remove unused parameter, all callers changed. + (jcf_figure_file_type): Add static prototype. + (find_in_current_zip): Likewise. Also remove unused parameter, + all callers changed. + (read_class): Initialize variable `saved_pos'. + + * jcf-reader.c (jcf_parse_preamble): Mark variables + `minor_version' and `major_version' with ATTRIBUTE_UNUSED. + + * lex.c (java_is_eol): Wrap prototype and definition in !JC1_LITE. + (java_init_lex): Wrap variable `java_lang_imported' in !JC1_LITE. + (java_parse_doc_section): Initialize variable `seen_star'. + (java_lex): Wrap variable `number_beginning' in !JC1_LITE. + (java_lex_error): Mark parameters `msg' and `forward' with + ATTRIBUTE_UNUSED. + (java_get_line_col): Mark parameters `filename' and `line' with + ATTRIBUTE_UNUSED. + + * parse-scan.y: Include toplev.h. + (yyerror): Mark parameter `msg' with ATTRIBUTE_UNUSED. + + * parse.h: use `struct JCF', not plain `JCF'. + (java_parser_context_save_global, java_expand_classes + java_parser_context_restore_global, java_parse): Add prototypes. + + * typeck.c (convert_ieee_real_to_integer): Remove unused variable + `node'. + +1999-02-24 Per Bothner <bothner@deneb.cygnus.com> + + * check-init.c (check_init): COPYN takes word count, not bit count. + +1999-02-26 Per Bothner <bothner@cygnus.com> + + * typeck.c (convert_ieee_real_to_integer): Use save_expr instead of + explicit build_decl. (Avoids crash in reload when optimizing.) + +1999-02-25 Per Bothner <bothner@cygnus.com> + + * decl.c (complete_start_java_method): Handle synchronized method + even when compiling from bytecode. + +1999-02-26 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (add_class_decl): Only generate `#include' if outer + class is not the name of the class we are processing. Correctly + append `.h' in #include. + (process_file): Clean up newlines around generated `#include's. + (decode_signature_piece): Correctly handle inner classes. + (struct include): New structure. + (all_includes): New global. + (print_include): New function. + (add_class_decl): Use it. + (process_file): Likewise. + (add_class_decl): Generate include for java-array.h if array + seen. + (process_file): Don't generate java-array.h include. + + * gjavah.c (add_namelet): Check for standard package names here. + (add_class_decl): Don't check for standard package names here. + +1999-02-25 Tom Tromey <tromey@cygnus.com> + + * parse.y (read_import_dir): Use `|=', not `+=', to set `found'. + When reading a zip file, only use strncmp if both strings are + bigger than the buffer length. Initialize `k' when looping + through zip file. + +1999-02-24 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (struct namelet): New structure. + (add_namelet): New function. + (print_namelet): New function. + (print_class_decls): Use add_namelet and print_namelet to generate + namespaces and not classes. + (method_printed): New global. + (HANDLE_END_METHOD): Examine method_printed. + (print_method_info): Set method_printed when required. Print + error if function to be ignored is marked virtual. Handle $finit$ + method. + (METHOD_IS_FINAL): New macro. + (print_field_info): Use it. + (HANDLE_METHOD): Clear method_printed. + (method_pass): New global. + (HANDLE_END_FIELD): Call add_class_decl on the first pass. + (process_file): Do two passes over both fields and methods. + (HANDLE_METHOD): Examine method_pass. + (root): New global. + (add_class_decl): New function. + (print_class_decls): Don't scan over entire constant pool. + +1999-02-23 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (lang_specific_driver): Recognize -fsyntax-only and + disable linking in that case. + +1999-02-20 Tom Tromey <tromey@cygnus.com> + + * jcf.h (UTF8_GET): Mask first byte of 3-byte encoding with 0x0f, + not 0x1f. + +1999-02-21 Per Bothner <bothner@cygnus.com> + + * decl.c (build_result_decl), java-tree.h: New method. + (complete_start_java_method): Handle synchronized methods. + Don't build DECL_RESULT here. (Ordering dependency problem.) + (start_java_method): Call build_result_decl here instead ... + * parse.y (java_complete_expand_method): ... and here. + (expand_start_java_method): Don't call complete_start_java_method here. + (java_complete_expand_method): Call it here instead. + * parse.h (BUILD_MONITOR_ENTER, BUILD_MONITOR_EXIT): Moved to .. + * java-tree.h: ... here. + + * expr.c (force_evaluation_order): Fix typo, don't handle ARRAY_REF. + * parse.y (java_complete_lhs): Don't call force_evaluation_order + for ARRAY_REF - it doesn't work when array bounds are checked. + (patch_array_ref): Handle it here instead. + + * jcf-write.c (generate_classfile): Emit "Exceptions" attribute. + +1999-02-19 Per Bothner <bothner@cygnus.com> + + Force left-to-right evaluation of binary operations etc. + * expr.c (force_evaluation_order), java-tree.h: New function. + * parse.y (java_complete_lhs): Pass binary operations, procedure + calls, and ARRAY_REFs to force_evaluation_order. + (various): Set TREE_SIDE_EFFECTS more carefully. + + Tolerate random (non-UTF8) encoding in comments without complaining. + * lex.c (java_read_char): Return 0xFFFE if bad UTF8 encoding. + (java_is_eol): Handle '\r' followed by '\n' instead of vice versa. + + * parse.y (resolve_qualified_expression_name): Handle error_mark. + (java_complete_node case EXPR_WITH_FILE_LOCATION): Likewise. + + * parse.y (java_complete_lhs): Ignore an empty statement in a + COMPOUND_EXPR. Don't complain about empty statement after return. + +1999-02-19 Per Bothner <bothner@cygnus.com> + + * parse.y (obtain_incomplete_type): Don't wrap unknown types + in TREE_LIST - just chain the POINTER_TYPEs together. + (resolve_class): If type already resolved, return decl. + After resolving, update TREE_TYPE(class_type), and name (if array). + * parse.h (do_resolve_class), parse.y: Make non-static. + * class.c (maybe_layout_super_class): Take this_class argument. + Do do_resolve_class if necessary. + (layout_class, layout_class_methods): Adjust calls appropriately. + * parse.h (JDEP_TO_RESOLVE, JDEP_RESOLVED_DECL, JDEP_RESOLVED, + JDEP_RESOLVED_P): Redefined for new TREE_LIST-less convention. + * typeck.c (build_java_array_type): Don't call layout_class. + +1999-02-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (check_pkg_class_access): Allow private class access + within the same package. + (strip_out_static_field_access_decl): New function. + (patch_unaryop): Call strip_out_static_field_access_decl on ++/-- + operator argument before testing its nature. + +1999-02-03 Per Bothner <bothner@cygnus.com> + + * java-tree.def (FINALLY_EXPR): Removed. (Now uses TRY_FINALLY_EXPR.) + (TRY_EXPR): Simplify - it no longer has a finally clause. + * check-init.c (check_init): Handle TRY_FINALLY_EXPR. + Simpler handling of TRY_EXPR, which no longer has a finally clause. + * expr.c (java_lang_expand_expr): Likewise. + * java-tree.h (CATCH_EXPR_GET_EXPR): Removed - no longer needed. + * parse.h (java_get_catch_block), parse.y: Removed - no longer needed. + * parse.y (java_complete_lhs): Add support for TRY_FIANLLY_EXPR. + (build_try_statement): Remove finally parameter and handling. + (build_try_finally_statement): New function. + (patch_try_statement): No longer need to support finally clause. + (try_statement): Update grammar action rules. + * jcf-write.c (generate_bytecode_insns): Handle TRY_FINALLY_EXPR. + Simpler handling of TRY_EXPR, which no longer has a finally clause. + +1998-11-26 Andrew Haley <aph@viagra.cygnus.co.uk> + + * jcf-parse.c (get_constant): Add braces around computation of 'd' + when REAL_ARITHMETIC is not defined. [Oct 26 fix got overwritten -PB] + +1999-02-17 Andrew Haley <aph@cygnus.com> + + * class.c (build_utf8_ref): Back out broken patch which was + intended to to output signatures using '.' as a separator. + + * class.c (make_class_data): Output signatures using '.' as a + separator, rather than '/'. + (mangled_classname): Likewise. + (make_field_value): Likewise. + (make_method_value): Likewise. + * constants.c (alloc_class_constant): Likewise. + * expr.c (build_invokeinterface): Likewise. + +1999-02-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (valid_builtin_assignconv_identity_widening_p): Got rid + of an ancient workaround. + +1999-02-10 Jeffrey A Law (law@cygnus.com) + + * jvspec.c (xmalloc): Kill the prototype. It does not belong + here anymore. + +1999-02-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (yylex): Encode \0 as UTF8. + +1999-02-10 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (lang_specific_driver): Use libgcj, not libjava. + * Makefile.in (jcf-path.o): Define LIBGCJ_ZIP_FILE. + (libgcj_zip): Renamed. + * jcf-path.c (add_entry): Use LIBGCJ_ZIP_FILE, not + LIBJAVA_ZIP_FILE. + (jcf_path_init): Use LIBGCJ_ZIP_FILE. + + * jvspec.c (THREAD_NAME): Renamed -lqthreads to -lgcjcoop. + (GC_NAME): Renamed -lgc to -lgcjgc. + +1999-02-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (java_lang_cloneable): Initialize. + * parse.y (java_lang_cloneable): New static variable. + (qualify_ambiguous_name): Take CONVERT_EXPR into account when + doing one more qualification round. + (valid_ref_assignconv_cast_p): Reject null source or + destination. Allow an array to be cast into java.lang.Cloneable. + (patch_cast): Swapped two first arguments to first call to + valid_ref_assignconv_cast_p. + +1999-02-08 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h: DECL_P renamed JDECL_P. + * parse.y: DECL_P replaced by JDECL_P. + (build_array_from_name): Always use pointer's type. + (patch_bc_statement): Extra code to search continue target in a + for loop. Fixed comments. Continue target is current loop when + unlabeled. + +1999-02-05 Andrew Haley <aph@cygnus.com> + + * class.c (make_class_data): The superclass of an interface should + be null, not class Object. + + * lex.c (java_lex): Sign extend hex literals. + +1999-02-04 Andrew Haley <aph@cygnus.com> + + * class.c (build_utf8_ref): Output signatures using '.' as a + separator, rather than '/'. + (make_class_data): Likewise. + +1999-02-03 Marc Espie <Marc.Espie@liafa.jussieu.fr> + + * Make-lang.in ($(GCJ)(exeext)): Remove choose-temp.o, pexecute.o and + mkstemp.o. Get them from libiberty now. + +1999-02-02 Jeffrey A Law (law@cygnus.com) + + * jcf-io.c: Do not include sys/stat.h or sys/wait.h + +1999-02-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * jvspec.c (xmalloc): Fix the prototype to match the one obtained + from libiberty.h + +1999-02-02 Per Bothner <bothner@cygnus.com> + + Optimize: `return (a ? b : c)' as: `if (a) return b; else return c;'. + * jcf-write.c (generate_bytecode_return): New function. + (generate_bytecode_insns): Use it, for RETURN_EXPR. + + * jcf-write.c (generate_bytecode_insns): For REAL_CST that is 0 or 1, + generate special [fd]const_[01] instructions. + + * jcf-parse.c (yyparse): Don't emit_register_classes if -fsyntax-only. + + * verify.c (verify_jvm_instructions): Do INVALIDATE_PC after + handling OPCODE_lookupswitch or OPCODE_tableswitch. + +1999-02-01 Per Bothner <bothner@cygnus.com> + + * parse.y (patch_method_invocation): Handle calling static methods, + even in the form EXPR.METHOD(ARGS), not just TYPE.METHOD(ARGS). + + * parse.y (java_complete_lhs): Don't complain about unreachable + exit condition in a do-while statement. + +1999-01-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (java_read_char): Fixed utf8 decoding. + (java_unicode_2_utf8): Fixed utf8 encoding in the 0x800-0xffff + range. + * parse.y (valid_builtin_assignconv_identity_widening_p): Fixed + comments. Local variable `all_primitive' is gone. Broadened + acceptance of `0' to floating point targets. `long' can now be + widened to `double' or `float'. + (valid_method_invocation_conversion_p): Added leading + comment. Fixed tabulation. + (build_string_concatenation): Optimize out left or right empty + string constants. + +1999-01-28 Per Bothner <bothner@cygnus.com> + + * jcf-write.c (localvar_alloc): Only emit entry for + LocalVariableTable if debug_info_level > DINFO_LEVEL_TERSE. + (generate_bytecode_insns): Only call put_linenumber if + debug_info_level > DINFO_LEVEL_NONE. + * jvspec.c (lang_specific_driver): If no -O* or -g* option + is specified, add -g1 (for compatibility wih javac). + +1999-01-28 Hans-Peter Nilsson <hp@axis.se> + + * java/Makefile.in: Add missing dependencies for jcf-dump.o, + gjavah.o, check-init.o, jv-scan.o + +1999-02-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (gjavah.o): Depend on $(CONFIG_H) and system.h. + + * gjavah.c: Include config.h and system.h. + + * javaop.h (inline): Don't define, its handled by system.h. + (WORD_TO_FLOAT, WORDS_TO_LONG, WORDS_TO_DOUBLE): Change these + from `inline' to `static inline'. + + * jcf.h (inline): Don't define, its handled by system.h. + + * lex.c (inline): Likewise. + +1999-01-31 Zack Weinberg <zack@rabi.columbia.edu> + + * lang-specs.h: Map -Qn to -fno-ident. + +1999-01-29 Richard Henderson <rth@cygnus.com> + + * check-init.c (check_init): Fix CLEANUP_POINT_EXPR typo. + +1999-01-29 Tom Tromey <tromey@cygnus.com> + + * parse.h (BUILD_APPEND): If ARG is a non-String object reference, + then cast it to Object before calling `append' method. + +1999-01-28 Per Bothner <bothner@cygnus.com> + + * check-init.c (check_bool2_init, check_bool_init, check_init): + Handle TRUTH_AND_EXPR, TRUTH_OR_EXPR, and TRUTH_XOR_EXPR. + * jcf-write.c (generate_bytecode_insns): Likewise. + +1999-01-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (jcf_parse): Don't parse the same class file twice. + * parse.y (patch_cast): Allow a boolean to be cast into a + boolean. + +1999-01-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y: (class_declaration:): Fixed indentation. + (class_member_declaration:): Extra `;' after field declaration now + accepted. + (interface_declaration:): Removed debug messages in error reports. + (patch_binop): Nodes created and returned inherit the orignal + node's COMPOUND_ASSIGN_P flag value. + (patch_cast): Fix cast from char to floating point. + +1999-01-25 Andrew Haley <aph@cygnus.com> + + * except.c, java-except.h (expand_resume_after_catch): new + function. + * expr.c (java_lang_expand_expr): call expand_resume_after_catch + to branch back to main flow of control after a catch block. + +1999-01-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (parse.o): Depend on $(CONFIG_H) and + $(srcdir)/../system.h. + (class.o): Depend on $(PARSE_H) and $(srcdir)/../output.h. + (jcf-parse.o): Depend on $(srcdir)/../toplev.h. + (jcf-write.o): Likewise. + (jv-scan.o): Depend on $(CONFIG_H) and $(srcdir)/../system.h. + (mangle.o): Depend on $(srcdir)/../toplev.h. + (parse-scan.o): Depend on $(CONFIG_H) and $(srcdir)/../system.h. + (zextract.o): Depend on $(CONFIG_H) and $(srcdir)/../system.h. + + * class.c: Include output.h and parse.h. + (mangled_classname): Add the `const' keyword to a char*. + (find_named_method): Hide unused function definition. + (build_utf8_ref): Change type of variable `c' to unsigned char. + Use ISALPHA/ISDIGIT instead of isalpha/isdigit. + (build_class_ref): Add the `const' keyword to a char*. + (layout_class_method): Remove unused variable `buf'. + + * decl.c (find_local_variable): Remove unused variable `rtl'. + (pushdecl): Likewise for variables `different_binding_level' and + `oldglobal'. + (pushlevel): Mark parameter `unused' with ATTRIBUTE_UNUSED. + (maybe_build_cleanup): Likewise for parameter `decl'. + + * except.c (expand_start_java_handler): Mark parameter `range' + with ATTRIBUTE_UNUSED. + + * expr.c: Include except.h. + (pop_type): Remove unused variable `i'. + (pop_value): Likewise for variables `n_words' and `i'. + (expand_java_arrayload): Likewise for variable `convert'. + (java_lang_expand_expr): Likewise for variables `op0', `type', + `mode', `unsignedp', `node' and `elements'. + (expand_byte_code): Likewise for variables `prev_eh_ranges' and + `eh_ranges'. + (process_jvm_instruction): Add a `const' qualifier to a char*. + + * gjavah.c (output_directory): Add the `const' keyword to a char*. + (temp_directory): Likewise. + (print_c_decl): Likewise. + (print_method_info): Likewise. + (decode_signature_piece): Likewise. + (print_mangled_classname): Likewise. + + * java-except.h: Provide prototypes for maybe_start_try, + maybe_end_try and add_handler. + + * java-tree.h (mangled_classname): Add the `const' keyword to a char*. + (parse_error_context): Likewise. Also add ATTRIBUTE_PRINTF_2. + (pushdecl_top_level, alloc_class_constant, unicode_mangling_length, + init_expr_processing, push_super_field, init_class_processing, + can_widen_reference_to, class_depth, verify_jvm_instructions, + maybe_pushlevels, maybe_poplevels, process_jvm_instruction, + set_local_type, merge_type_state, push_type, load_type_state, + add_interface, find_in_current_zip, append_gpp_mangled_classtype, + emit_unicode_mangled_name): Add prototypes. + + * jcf-dump.c (print_constant): Add the `const' keyword to a char*. + (print_signature_type): Use ISDIGIT, not isdigit. + (print_signature): Remove unused variable `j'. + + * jcf-io.c (jcf_filbuf_from_stdio): Cast the result of `fread' to + int when comparing against one. + + * jcf-parse.c: Include toplev.h. + + * jcf-write.c: Likewise. Don't include <string.h> or <sys/stat.h>. + (localvar_free): Remove unused variable `i'. + (generate_bytecode_conditional): Likewise for variable `kind'. + + * jv-scan.c: Include config.h and system.h. Remove redundant + OS header and gansidecl.h includes. + (warning): Add the `const' keyword to a char*. Also add + ATTRIBUTE_PRINTF_1 to the prototype. Check ANSI_PROTOTYPES, not + __STDC__, when determining whether to use ANSI-isms. + (fatal): Likewise. Also add ATTRIBUTE_UNUSED. + (xmalloc): Don't redundantly prototype here. + (main): Remove unused parameter `envp'. Also fix the arguments + passed to function `fatal' to match the format specifier. + + * lang.c (java_tree_code_name): Add the `const' keyword to a char*. + + * mangle.c: Include toplev.h. + (emit_unicode_mangled_name): Declare parameter `len'. + + * parse.y (parse_warning_context): Add the `const' keyword to a + char*. Also add ATTRIBUTE_PRINTF_2 to the prototype. Check + `ANSI_PROTOTYPES' not `__STDC__' for whether to use ANSI-isms. + (issue_warning_error_from_context): Add the `const' keyword to + a char*. + (parse_error_context): Likewise. Also check `ANSI_PROTOTYPES' + not `__STDC__' for whether to use ANSI-isms. + + * typeck.c (incomplete_type_error): Mark parameters `value' and + `type' with ATTRIBUTE_UNUSED. + (parse_signature_type): Use ISDIGIT, not isdigit. + + * verify.c (check_pending_block): Add the `const' keyword to a char*. + (verify_jvm_instructions): Likewise. Remove unused variables + `field_name' and `default_val'. + + * zextract.c: Include config.h and system.h. Remove redundant + OS header includes. + + * zipfile.h: Prototype `read_zip_archive'. + +1999-01-21 Andrew Haley <aph@cygnus.com> + + * typeck.c (convert): Allow conversions to void type: some + optimizations in gcc do this. + +1999-01-21 Andrew Haley <aph@cygnus.com> + + * typeck.c (convert_ieee_real_to_integer): New function. + (convert): When not using fast-math and using hardware fp, convert + an IEEE NaN to zero. + +1999-01-18 Andrew Haley <aph@cygnus.com> + + * parse.y (patch_binop): Do a type conversion from signed to + unsigned and then back to signed when a ">>>" is found. + +1999-01-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h: (check_for_initialization): Added prototype. + * lex.c (java_parse_doc_section): `\n' breaks the `*/' string. + * parse.y (do_resolve_class): Removed unused locals. + (read_import_dir): Likewise. + (resolve_qualified_expression_name): Array creation + expressions are valid primary expressions. + (qualify_ambiguous_name): Likewise. + (patch_synchronized_statement): Removed unused local. + +1999-01-17 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (zextract.o): Add dependencies. + + * Makefile.in: Do not put ^Ls at the start of a line. + +1999-01-15 Per Bothner <bothner@cygnus.com> + + * expr.c (process_jvm_instruction): Coerce to correct Throwable + sub-type the result of the call that gets the exception value. + + * parse.y (java_complete_expand_methods): If flags_syntax_only, + don't call finish_class. + + * parse.y (java_check_regular_methods): If METHOD_PRIVATE, + clear found before continuing. + + * verify.c (verify_jvm_instructions): On an array load, allow + and handle top of stack to be TYPE_NULL. + + * gjavah.c (generate_access): Translate Java package private or + protected access to C++ public, but with a comment. + +1999-01-13 Andrew Haley <aph@cygnus.com> + + * expr.c (generate_name): Name prefix changed to avoid clashes + with assembler temp labels. + + * parse.y (patch_synchronized_statement): Set TREE_SIDE_EFFECTS on + MODIFY_EXPR. Without this, code for the assignment may not be + generated at all and the synchronized statement will read an + uninitialized variable. + +1999-01-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (maybe_layout_super_class): Fixed returned value. + * lex.c: Added 1999 to the copyright. + (java_init_lex): Initialize java_lang_imported. + * lex.h: Added 1999 to the copyright. + * parse.h: Added 1999 to the copyright. + (REGISTER_IMPORT): Fixed typo in trailing macro. + (CURRENT_OSB): New macro. + (struct parser_ctxt): New fields osb_depth, osb_limit. + * parse.y (java_lang_id): New global variable. + (type_import_on_demand_declaration): Don't import java.lang.* twice. + (array_creation_expression:): Use CURRENT_OSB. + (dims:): Uses a stack to keep track of array dimensions. + (cast_expression:): Use CURRENT_OSB. + (find_expr_with_wfl): Return NULL if node found doesn't meet the + conditions. + (register_fields): Fixed typos in comment. + (check_method_redefinition): Fixed comment indentation. + (java_check_regular_methods): Set saved found wfl to NULL after + having reinstalled it in the previously found DECL_NAME. + +1999-01-10 Richard Henderson <rth@cygnus.com> + + * gjavah.c (java_float_finite): Use a union to do type punning. + (java_double_finite): Likewise. + +1999-01-09 Per Bothner <bothner@cygnus.com> + + * parse.y (build_new_array_init): Don't set EXPR_WFL_LINECOL + on CONSTRUCTOR (since that trashes TREE_CST_RTL). + (patch_new_array_init): Clear TREE_CONSTANT also if INDIRECT_REF. + (register_fields): Set TREE_STATIC on NEW_ARRAY_INIT, not on + CONSTRUCTOR (which causes expand_expr to call output_constant_def). + * expr.c (java_lang_expand_expr): Check TREE_STATIC of NEW_ARRAY_INIT. + +1999-01-08 Per Bothner <bothner@cygnus.com> + + * check-init.c (check_init): If compiling to native, we don't + see THROW_EXPR. Instead, look for a call to throw_node (_Jv_Throw). + +1999-01-08 Tom Tromey <tromey@cygnus.com> + + * parse-scan.y (variable_declarator_id): Set or increment + bracket_count. + (bracket_count): New global. + (formal_parameter): Handle case where bracket pairs trail variable + declarator id. + +1999-01-07 Andrew Haley <aph@viagra.cygnus.co.uk> + + * jcf-parse.c (yyparse): variable len changed from a char to an + int to prevent overflow. + +1999-01-06 Per Bothner <bothner@cygnus.com> + + * java-tree.h: Declare read_class. + * jcf-parse.c (read_class): New function. + (load_class): Now just call read_class. + + * java-tree.h (java_parse_abort_on_error): Only return if new errors. + * jcf-parse.c (parse_source_file): Declare save_error_count, + which is needed by java_parse_abort_on_error macro, + * parse.y (java_layout_classes, java_expand_classes): Likewise. + + * parse.y (register_fields): Set TREE_STATIC flag of NEW_ARRAY_INIT + constructor, if initializing a static field. + (patch_new_array_init): Set TREE_CONSTANT if it is. + * expr.c (java_lang_expand_expr): For a static array constructor + of primitive elements, allocate the array itself statically. + Disabled until we can set the vtable field statically. + + * check-init.c: New file. Checks for definite assignment. + * Makefile.in (JAVA_OBJS): Add check-init.o. + * parse.y (java_complete_expand_method): Call check_for_initialization. + * parse.h (BLOCK_EXPR_DECLS, BLOCK_EXPR_BODY): Moved to java-tree.h. + +1999-01-06 Graham <grahams@rcp.co.uk> + + * parse.y : include system.h instead of including + standard headers directly with the exception of <dirent.h>. + +1999-01-06 Per Bothner <bothner@cygnus.com> + + * lex.h: Moved static function declarations to lex.c, + to shut up some -Wall warnings. + * lex.c: Static function declarations moved here. + * jcf-dump.c: Small fixes to shut up -Wall warnings. + +1999-01-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Make-lang.in ($(GCJ).o): Depend on prefix.h. + +1998-12-22 Per Bothner <bothner@cygnus.com> + + * expr.c (process_jvm_instruction): Do load_type_state after JSR. + * verify.c (verify_jvm_instructions): Fix off-by-one error. + + * jcf-write.c (CHECK_PUT): Add (void) cast to avoid -Wall warnings. + (localvar_alloc): Change return type to void, + (emit_unop): Remove unused variable size. + + * jcf-write.c (struct jcf_block): Add new union. + (PENDING_CLEANUP_PC, PENDING_EXIT_PC, UNDEFINED_PC): New macros. + (call_cleanups): New functions. + (struct jcf_partial): New fields num_finalizers and return_value_decl. + (generate_bytecode_insns): Support CLEANUP_POINT_EXPR and + WITH_CLEANUP_EXPR. Handle cleanups in RETURN_EXPR and EXIT_BLOCK_EXPR. + * lang.c (lang_init): Call using_eh_for_cleanups. + * parse.y (java_complete_lhs): For SYNCHRONIZED_EXPR, defer + completing operands to patch_synchronized_statement. + Support CLEANUP_POINT_EXPR, WITH_CLEANUP_EXPR. + (patch_synchronized_statement): Re-write suing CLEANUP_POINT_EXPR and + WITH_CLEANUP_EXPR instead of TRY_EXPR. + +1998-12-20 John F. Carr <jfc@mit.edu> + + * Make-lang.in: Comment out control-Ls; they upset some makes. + +1998-12-18 Tom Tromey <tromey@cygnus.com> + + * parse.y (check_class_interface_creation): Use DIR_SEPARATOR + consistently. + +1998-12-17 Tom Tromey <tromey@cygnus.com> + + * parse.y (DIR_SEPARATOR): New define. + (check_class_interface_creation): Use it. + + * parse-scan.y (report_main_declaration): Recognize + `java.lang.String' in argument to main. + +1998-12-16 Per Bothner <bothner@cygnus.com> + + * parse.y (create_interface): Remove bogus test. + +1998-12-16 Per Bothner <bothner@cygnus.com> + + * jcf-parse.c (get_constant): Set TREE_TYPE for string constants. + (HANDLE_CONSTANTVALUE): If flag_emit_class_files, call get_constant. + +1998-12-16 Tom Tromey <tromey@cygnus.com> + + * parse-scan.y (qualified_name): Use correct sprintf format. + +1998-12-15 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_field_info): Changed how most negative number is + printed. + +1998-12-14 Per Bothner <bothner@cygnus.com> + + * parse.y (fold_constant_for_init): New function. + (resolve_expression_name): Don't replace static final + constant-initialized fields by its value. + (java_complete_lhs): New. Same as java_complete_tree, except does + not replace static final constant-initialized fields by their values. + (register_fields): If there is an initializer, set DECL_INITIAL and + MODIFY_EXPR_FROM_INITIALIZATION_P. + (java_complete_tree): For MODIFY_EXPR, use java_complete_lhs for lhs. + Only call patch_initialized_static_field if + MODIFY_EXPR_FROM_INITIALIZATION_P. + (patch_initialized_static_field): If not valid constant, clear + DECL_INITIAL. + + * parse.y (lookup_field_wrapper): Fix thinko. + + * parse.y (java_complete_tree): In EXPR_WITH_FILE_LOCATION, + set and restore global lineno. + +1998-12-14 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_field_info): If value to print is the smallest + value of its size, then print as hex to avoid later warnings from + C++ compiler. + +1998-12-14 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (decompile_method): Decompile `return null'. + (process_file): Generate `#pragma interface'. + (method_declared): New global. + (print_method_info): Set it. + (HANDLE_CODE_ATTRIBUTE): Only print it method_declared set. + (print_method_info): Handle abstract methods. + +1998-12-13 Per Bothner <bothner@cygnus.com> + + * parse.y (patch_method_invocation): If class_decl is null + (e.g. an array type), use original type. + + * parse.y (check_thrown_exceptions): Temporary hack to suppress + errors about uncaught exception from clone (of array, specifically). + +1998-12-13 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (decompile_method): Handle all types of `return' + opcode. Decompile `return this' and `return'. + (method_access): New global. + (print_method_info): Set it. + (decompile_method): Don't decompile a synchronized method. + +1998-12-13 Tom Tromey <tromey@cygnus.com> + + * jcf-reader.c (jcf_parse_one_method): Recognize + HANDLE_END_METHOD. + * gjavah.c (HANDLE_END_METHOD): New macro. + (HANDLE_CODE_ATTRIBUTE): New macro. + (decompile_method): New function. + (print_method_info): Don't print `;\n' at end of function decl. + Include java-opcodes.h. + (decompiled): New global. + +1998-12-12 Per Bothner <bothner@cygnus.com> + + * class.c (build_class_ref): Handle PRIMTYPE.class if + flag_emit_class_files. + * expr.c (expand_java_field_op): Don't optimize java.lang.XXX.TYPE + if flag_emit_class_files. + * parse.y (java_complete_tree): Pre-liminary support for + COMPONENT_REF - only to handle PRIMCLASS.TYPE. + + * parse.y (patch_synchronized_statement): Don't call monitorexit + unless block CAN_COMPLETE_NORMALLY. Propagate that flag properly. + + * java-tree.h (DECL_LOCAL_STATIC_VALUE): Removed - no longer used. + + * zipfile.h (opendir_in_zip): New declaration. + * jcf-io.c (saw_java_source): Moved to jcf-parse.c. + (opendir_in_zip): New function, using code from open_in_zip. + (open_in_zip): Call opendir_in_zip. + (find_class): Remove no-longer-used do_class_file parameter, + but add source_ok parameter. Change logic so if we find a .java file, + we don't look for .class in later classpath emtries. + * jcf-parse.c (load_class): Pass saw_java_source to find_class. + (jcf_figure_file_type): Only call open_in_zip if correct magic number. + * gjavah.c: Update call to find_class. + * jcf-dump.c: Likewise. + + * jcf-write.c (put_linenumber): Handle duplicate line numbers. + (generate_bytecode_insns): For EXPR_WITH_FILE_LOCATION, do + nothing if body is empty_stmt_node. + Various little fixes so SP gets correctly adjusted. + For NEW_ARRAY_INIT, handle IGNORE_TARGET. + For CALL_EXPR, test if static first. + (generate_classfile): Ignore fields that are DECL_ARTIFICIAL, + such as the ones we create for Object and Class. + Set and restore current_function_decl. + * parse.y: Check/set IS_AN_IMPORT_ON_DEMAND_P in read_import_dir. + (note_possible_classname): New function. + (read_import_entry): Removed. Merged with read_import_dir. + (read_import_dir): Don't call find_class - that only gives us + the first classpath entry having the needed package. + Use the struct buffer data structure from buffer.h. + (read_import_dir, find_in_imports_on_demand): The remembered + class names now use '.' (not '/') as package separator. + + * parse.y (java_complete_expand_methods): Call write_classfile + here, and not in java_expand_classes (which only gets first class). + +1998-12-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (<type_declaration>): Do maybe_generate_clinit last. + (register_fields): If a static fields has an initializer, just + chain it on ctxp->static_initialized, and handle later. + (java_complete_expand_methods): Force <clinit> first. + (resolve_expression_name, resolve_field_access): Just get DECL_INITIAL + - it's already been completed. + (patch_initialized_static_field): New function. + (java_complete_field): Call it. + +1998-12-12 Per Bothner <bothner@cygnus.com> + + * expr.c (encode_newarray_type, build_new_array): New functions. + * java-tree.h: Declare build_new_array. + * jcf-write.c (patch_newarray): Use build_new_array. + + * expr.c (java_lang_expand_exp): Support NEW_ARRAY_INIT. + * jcf-write.c (generate_bytecode_insns): Support NEW_ARRAY_INIT. + + * parse.y (patch_new_array_init): Re-organize. + Now is passed the actual array (pointer) type of the value. + Set the type of the CONSTRUCTOR to be an ARRAY_TYPE. + (patch_array_constructor): Removed - merged into patch_new_array_init. + (java_complete_tree): Update patch_new_array_init. + + * jcf-write.c (find_constant_index): New function. + (generate_bytecode_insns): Use find_constant_index. + (generate_classfile): Use find_constant_index for ConstantValue. + +1998-12-11 Tom Tromey <tromey@cygnus.com> + + * expr.c (invoke_build_dtable): Renamed dtable -> vtable. + * decl.c (init_decl_processing): Renamed dtable -> vtable. + * class.c (make_class_data): Renamed dtable -> vtable, and + dtable_method_count -> vtable_method_count. + +1998-12-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (long_zero_node, float_zero_node, double_zero_node): New + global variables, initialized. + * java-tree.h (long_zero_node, float_zero_node, double_zero_node): + Declared new global variables. + * lex.c (java_lex): Return long_zero_node, float_zero_node, + double_zero_node, integer_zero_node upon direct matching. + * parse.y (purify_type_name): Added function prototype. + (duplicate_declaration_error_p): Consider new_type as potentially + being a incomplete type. Use purify_type_name on type string. + (method_header): saved_type: unused variable removed. Don't figure + return type if method name is invalid. + (java_complete_tree): Set CAN_COMPLETE_NORMALLY after `node' was + processed by patch_unaryop. + (patch_unaryop): Fixed typo in comment. Re-convert pre/post + increment/decrement node into its original type after binary + numeric promotion on its operands. + +1998-12-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (array_initializer:): Array init operand is NULL_TREE + instead of a TREE_LIST of NULL_TREEs when parsing `{}'. `{,}' is + now an error. Fixed indentation problems. + (patch_string): Handle error_mark_node as an argument. + (patch_new_array_init): Fixed indentation problems. + (array_constructor_check_entry): Removed check on null wfl_value. + Return an error if wfl_value's walk returns an error. + +1998-12-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.def (NEW_ARRAY_INIT): New Java tree code. + * lex.c (java_lex): Remember column position before advancing one + token. Retain location information on OCB_TK. + * lex.h (typedef struct java_lc): Added new field. + * parse.h (GET_SKIP_TYPE): New macro. + (QUAL_DECL_TYPE): Redefined using GET_SKIP_TYPE. + * parse.y (build_new_array_init, patch_new_array_init, + patch_array_constructor, maybe_build_array_element_wfl, + array_constructor_check_entry): New function prototypes. + (switch_block:): Tagged <node>. + (OCB_TK): Tagged <operator>. + (array_initializer:): Installed actions. + (variable_initializer): Build location information on element if + necessary. + (switch_statement:): Fixed indentation typo. + (switch_block:): Redefined default action. + (java_complete_tree): Handle NEW_ARRAY_INIT in MODIFY_EXPR:. + (patch_assignment): Removed duplicate code. + (maybe_build_array_element_wfl, build_new_array_init, + patch_new_array_init, patch_array_constructor, + array_constructor_check_entry): New functions. + +1998-12-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (array_initializer): Tagged <node>. + (variable_initializer:): Use default rule. + (array_initializer:): Defined actions. + (variable_initializers:): Likewise. + (resolve_qualified_expression_name): Use DECL_CONTEXT to build + non-static field accesses. + (patch_invoke): Fixed indentation typo. + (java_complete_tree): Likewise. + (build_labeled_block): Changed leading comment. Generate an error + in case of duplicate loop labels. + (patch_conditional_expr): Patch results of string concatenation + operations. + +1998-12-06 Per Bothner <bothner@cygnus.com> + + * constants.c (find_methodref_index): When the class is an interface, + generate CONSTANT_InterfaceMethodref instead of a CONSTANT_MethodRef. + + * decl.c (finit_identifier_node): Use "$finit$", rather than + "<finit>" (which Sun's verifier rejects). + * parse.y (maybe_generate_finit): Leave out meaningless final flag. + (generate_field_initialization_code): Removed. + (fix_constructors) Don't add call to $finit$ here (wrong order). + (patch_method_invocation): Add $finit$ call here. + + * java-tree.h (CALL_USING_SUPER): New macro. + * parse.y (patch_invoke): Remove im local variable. + (patch_method_invocation, patch_invoke): Don't pass super parameter. + (patch_invoke): Use CALL_USING_SUPER instead of from_super parameter. + (resolve_qualified_expression_name): Maybe set CALL_USING_SUPER. + + * jcf-write.c (get_access_flags): Fix typo ACC_PUBLIC -> ACC_FINAL. + + * parse.y (java_complete_tree): Don't complain about unreachable + statement if it is empty_stmt_node. + + * jcf-write.c (find_constant_wide): New function. + (push_long_const): Use find_constant_wide. + + * jcf-write.c (generate_bytecode_insn): Fix bug in switch handling. + (generate_bytecode_insn): Use correct dup variant for MODIFY_EXPR. + Add "redundant" NOTE_PUSH/NOTE_POP uses so code_SP_max gets set. + Emit invokeinterface when calling an interface method. + Emit invokespecial also when calling super or private methods. + + * jcf-write.c (generate_classfile): Emit ConstantValue attributes. + +1998-12-06 Per Bothner <bothner@cygnus.com> + + * jcf-dump.c (INVOKE): If invokeinterface, print number of args. + +1998-12-03 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (java_layout_seen_class_methods): New function + prototype. + (LAYOUT_SEEN_CLASS_METHODS): Macro removed. + * jcf-parse.c (parse_class_file): Call java_layout_seen_class_methods. + * parse.h (PROMOTE_RECORD_IF_COMPLETE): New macro. + * parse.y (method_declarator:): Defined action. + (issue_warning_error_from_context): input_filename saved, set to + the appropriate value and restored after java_error is called. + (build_unresolved_array_type): Fixed comment. + (register_fields): Use PROMOTE_RECORD_IF_COMPLETE. + (method_header): Deal with return type the same way type are + handled for fields and method's parameters and local variables + types are handled. + (check_method_redefinition): Removed extra CR. + (declare_local_variables): Use PROMOTE_RECORD_IF_COMPLETE. + (java_layout_seen_class_methods): New function. + (java_layout_classes): Call java_layout_seen_class_methods. + +1998-12-03 Per Bothner <bothner@cygnus.com> + + * parse,y (patch_synchronized_statement): Set CAN_COMPLETE_NORMALLY. + +1998-12-03 Per Bothner <bothner@cygnus.com> + + * jcf-dump.c (main): Fix error message. + * jcf-path.c (add_entry): Style fix. + +1998-12-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class_method): Call build_java_argument_signature + on constructors too. + * parse.y (check_method_redefinition): Use TYPE_ARGUMENT_SIGNATURE. + (patch_method_invocation): Define a primary when resolving an + expression name. Augmented comment on code checking illegal `this' + usage. Loosened it test by accepting NEW_CLASS_EXPR. + +1998-12-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class_method): Don't report error on non-static + overriding static if the method is private. + * java-tree.h (finish_class): Prototype added. + * lex.c (java_get_line_col): Handle col argument -2 value. + * parse.h: All static method declarations moved to parse.y. + * parse.y: Now contains all static method declarations previously + found in parse.h. + (find_expr_with_wfl, missing_return_error, + unreachable_stmt_error): New functions. + (java_get_real_method_name): Identify constructors bearing class + names in source code compiled classes only. + (java_complete_expand_methods): Call missing_return_error. + (invocation_mode): Private methods invoked as static methods. + (java_complete_tree): Call unreachable_stmt_error. + +1998-12-01 Tom Tromey <tromey@cygnus.com> + + * Makefile.in (+target): Removed. + (+xmake_file): Likewise. + (+tmake_file): Likewise. + (.NOEXPORT): Removed duplicate. + +1998-11-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (jc1, jv-scan): Link with $(SUBDIR_OBSTACK). + + * jv-scan.c: Fix xmalloc prototype. Provide an xmalloc definition. + + * jvgenmain.c: Remove the xmalloc prototype, we get it from + libiberty.h. Provide an xmalloc definition. + + * jvspec.c: Remove the xmalloc prototype. + + * parse-scan.y: Include config.h and system.h. Don't include + OS headers or gansidecl.h. Don't prototype xmalloc/xstrdup. + Provide an xstrdup definition. + +1998-11-26 Alexandre Oliva <oliva@dcc.unicamp.br> + + * jcf-path.c (add_entry): Recognize ".jar" too. + * lang-specs.h: Likewise. + +1998-11-26 Per Bothner <bothner@cygnus.com> + + * jcf-write.c (generate_bytecode_insns): In Call_EXPR, handle + soft_monitorenter_node, soft_monitorexit_node, throw_node. + + * jcf-write.c (generate_bytecode_insns): + Handle pre/post-increment/decrement of long. + + * jcf-write.c (generate_bytecode_insns): + Handle missing exception handler (finally for synchronized). + +1998-11-25 Per Bothner <bothner@cygnus.com> + + * java-tree.h (end_params_node): Declare global. + * decl.c (end_params_node): New global. + (init_decl_processing, start_java_method): Use end_params_node for + end of list of parameter types. Follows correct gcc conventions. + * expr.c (pop_argument_types, pop_arguments): Likewise. + * lang.c (put_decl_node): Likewise. + * typeck.c (various places): Likewise. + * class.y (various places): Likewise. + * parse.y (various places): Likewise. + + * parse.y (java_complete_tree): Move CAN_COMPLETE_NORMALLY. + (build_jump_to_finally): Add missing CAN_COMPLETE_NORMALLY. + + * class.c: Add #include flags.h, remove no-longer needed declaration. + + * class.c (layout_class_method): Remove commented-out code, re-format. + Don't add vtable entry (or index) for private methods. + * expr.c (expand_invoke): A private method is implicitly final. + * class.c (make_class_data): If inlining or optimizing, + skip private methods. + + * class.c (finish_class): New function. Calls existing methods, + but alls emits deferred inline functions. + * jcf-parse.c (parse_class_file): Call finish_class. + * parse.y (java_complete_expand_methods): Likewise. + + * expr.c (build_java_binop): Explicit default, to silence -Wall. + + * expr.c (CHECK_PC_IN_RANGE): Add void cast to kill warnings. + +1998-11-25 Marc Espie <espie@quatramaran.ens.fr> + + * jcf-write.c (generate_bytecode_conditional): Fix typo. + +1998-11-24 Per Bothner <bothner@cygnus.com> + + * (generate_classfile): Always write class access flag with + ACC_SUPER set. + +1998-11-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (maybe_layout_super_class): New function. + (layout_class): Reorganized. Loop on class methods dispatched into + a new function. Call maybe_layout_super_class. + (layout_class_methods, layout_class_method): New functions. + * expr.c (expand_java_NEW): Call layout_class_methods on loaded + class. + (expand_invoke): Likewise. + * java-tree.h (all_class_list): New global variable declared. + (layout_class_methods, layout_class_method): New function + prototypes. + (LAYOUT_SEEN_CLASS_METHODS): New macro. + * jcf-parse.c (all_class_list): New global variable. + (load_class): Extended what class_or_name can be. Use parser + context mechanism to save globals before calling jcf_parse. + (jcf_parse_source): Don't parse twice if HAS_BEEN_ALREADY_PARSED_P + is set on the file name. + (jcf_parse): Layout class methods when Object is loaded, otherwise + record class in all_class_list for delayed method layout. + (parse_class_file): Use LAYOUT_SEEN_CLASS_METHODS. + * lang.c (put_decl_node): Decode <init> into the decl context + class name. + * lex.c (java_allocate_new_line): Use xmalloc. + * parse.h (INCOMPLETE_TYPE_P): Redefined to work with incomplete + pointers, not TREE_LIST elements. + (struct parser_ctxt): Fixed comment indentations, added comments + and reordered some fields. + (java_check_methods): Function prototype removed. + * parse.y (java_push_parser_context): Use xmalloc. + (java_parser_context_restore_global): Pop extra pushed ctxp only + when there's nothing next. + (maybe_create_class_interface_decl): Fixed comment, add new + created class decl to all_class_list. + (method_header): Use GET_REAL_TYPE on argument's types. + (method_declarator): Use GET_REAL_TYPE, change type to the real + type in TREE_LIST dependency node. Build argument list with the + real type. + (create_jdep_list): Use xmalloc. Removed allocation error message. + (obtain_incomplete_type): Fixed leading comment. Broadened + incoming argument meaning. + (register_incomplete_type): Use xmalloc. Removed allocation error + message. + (safe_layout_class): Fixed leading comment. + (jdep_resolve_class): Reversed if statement condition and switch + if and else bodies. + (resolve_and_layout): Fixed leading comment. Broadened incoming + argument meaning. + (complete_class_report_errors): New local variable name, for + clarity. purify_type_name used for all error cases. + (java_get_real_method_name): Stricter check on constructors. + (java_check_regular_methods): Reverse methods list only if not + already laid out. Layout artificial constructor. + (java_check_methods): Deleted. + (source_start_java_method): Obtain incomplete type for patchable + method arguments. + (java_layout_classes): Fixed leading comment. Use + LAYOUT_SEEN_CLASS_METHODS, use a loop to check methods. Added else + statement to layout operation, reuse LAYOUT_SEEN_CLASS_METHODS + before returning. Fixed comments. + (java_expand_classes): Check for errors up front. + (patch_method_invocation): Class to search is resolved and laid + out. + +1998-11-24 Per Bothner <bothner@cygnus.com> + + * expr.c (java_lang_expand_expr): Add missing emit_queue. + + * javaop.h (int8): Removed - not used. + (jbyte): Redefine portably with correct signedness. + + * jcf-write.c (generate_bytecode_insns): Don't free sw_state.cases. + + * jcf-write.c (generate_bytecode_insns): Fix typo + OPCODE_getstatic to OPCODE_getfield. + + * java-tree.def (CASE_EXPR, DEFAULT_EXPR): Kind is 'x', not '1'. + * parse.y (java_complete_tree): For CASE_EXPR and DEFAULT_EXPR, + set TREE_SIDE_EFFECTS (otherwise expand_expr may skip them). + +1998-11-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (jcf_parse_source): Function returned type is + void. Added prototype. + (jcf_parse): Function returned type is void. + (yyparse): Remove call to fclose on the last parsed file. + + * java-tree.h (jcf_parse): Changed jcf_parse prototype. + +1998-11-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (unmangle_classname): Set QUALIFIED_P when appropriate. + (layout_class): Cope with methods featuring WFL in decl names. + * decl.c (unqualified_object_id_node): New global variable, + initialized. + (build_decl_no_layout): Removed. + * expr.c (build_primtype_type_ref): Handle Double. + (java_lang_expand_expr): Fixed indentations. + * java-tree.h (CLASS_METHOD_CHECKED_P): Flag deleted. + (flag_wall, flag_redundant, flag_not_overriding, + flag_static_local_jdk1_1, unqualified_object_id_node): Global + variable declarations. + (build_decl_no_layout): Removed prototype. + (java_get_real_method_name): Added prototype. + (IS_UNCHECKED_EXPRESSION_P): Renamed IS_UNCHECKED_EXCEPTION_P. + (java_parse_abort_on_error): Macro now just returns. + * jcf-parse.c (jcf_parse_source): Check fclose returned + value. Call emit_register_classes if java_report_errors returns + zero. + * lanc.c (flag_wall, flag_redundant, flag_not_overriding, + flag_static_local_jdk1_1): New integer flags. + (lang_decode_option): New flags set here. + * parse.h (GET_REAL_TYPE, GET_METHOD_NAME): New macros. + (OBSOLETE_MODIFIER_WARNING): Issue error message conditionally to + the flag_redundant variable. + (SET_TYPE_FOR_RESOLUTION): Consider Object being java.lang.Object + when parsing java.lang.Object class. + (BUILD_MONITOR_ENTER, BUILD_MONITOR_EXIT): Added terminal + NULL_TREE to build. + (resolve_qualified_expression_name): Fixed indentation. + (patch_array_ref): Changed prototype. + (not_initialized_as_it_should_p): Prototype removed. + (java_report_errors): Added function prototype. + * parse.y (formal_parameter:): Changed error message for not yet + supported final parameters. + (class_type_list:): Set both PURPOSE and VALUE of created + TREE_LIST to be class_type. + (primary_no_new_array:): Handle class literals on primitive types. + (parse_warning_context): Reinstalled correct force_error and + do_warning flags setups. + (java_report_errors): Changed prototype. Return java_error_count + value. + (variable_redefinition_error): Consider treating variable type as + a fake pointer. + (create_interface): Warn about redundant abstract modifier if + flag_redundant is set. Changed error message. + (lookup_field_wrapper): Save/restore globals before/after looking + up field. + (duplicate_declaration_error_p): Consider treating declaration + type as a fake pointer. + (register_fields): Extract real type from dependency node. Check + for duplicate field declaration after type adjustment. Use + DECL_INITIAL to store static final initialized values. + (method_header): Extract real function type from dependency node. + (check_abstract_method_header): Use GET_METHOD_NAME. + (obtain_incomplete_type): Layout fake pointer type. + (safe_layout_class): Don't try to check for methods before layout. + (java_complete_class): Don't check for correct throws clause + elements inheritance here. + (resolve_and_layout): Broadened name parameter meaning. + (reset_method_name): Use GET_METHOD_NAME. + (java_get_real_method_name): New function. + (java_check_regular_methods): Don't check methods in + java.lang.Object. Verify lineage of throws clause elements. Use + flag_no_overriding in warning report. + (check_throws_clauses): Don't check if class was from + bytecode. Use IS_UNCHECKED_EXCEPTION_P macro. + (java_check_methods): Don't set CLASS_METHOD_CHECKED_P flag. + (declare_local_variables): Use flag_static_local_jdk1_1 to report + warning on unsupported final local variables. Use build_decl + instead of build_decl_no_layout. Get real local variable type from + dependency node. + (source_start_java_method): Get real parameter type from + dependency node. Call build_decl instead of build_decl_no_layout. + (java_layout_classes): Reverse tree and layout type and class as + required. Mark class as loaded when done. + (resolve_field_access): Fixed indentation. Restricted condition + leading to static field access code generation. Set field_type + decl's TREE_TYPE if QUAL_DECL_TYPE not available. + (resolve_qualified_expression_name): Initialize type_found to + null. Handle static field resolved during qualification. Fixed + layout on non primitive field decl types. + (not_accessible_p): Fixed typo in comment. + (patch_method_invocation): Resolve and layout class to search from + type. + (lookup_method_invoke): Keep integer constant 0 as is. Resolve and + layout non primitive type, if necessary. Make method node only to + report errors. + (find_applicable_accessible_methods_list): Consider WFL'ed method + decl names. Fixed indentation. + (argument_types_convertible): Resolve and layout target type if + necessary. + (java_complete_tree): Fixed indentation problems. Rewrote + CALL_EXPR thrown exceptions check. Re-installed further processing + of the assignment in certain cases. + (patch_assignment): Call maybe_build_primttype_type_ref to perform + inlining on class literals. + (valid_builtin_assignconv_identity_widening_p): Cope with constant + 0 literal. + (valid_method_invocation_conversion_p): Likewise. + (patch_string): Temporary disable forbidden use of `this' in + explicit constructor invocations when doing string concatenation + within their scope. + (patch_unaryop): Added comment. Reinstalled code to disable + further check on assignment operation with cast expression RHS. + (patch_switch_statement): Fixed indentation. + (build_try_statement): Call build_decl instead of + build_decl_no_layout. + (patch_synchronized_statement): Likewise. + (patch_throw_statement): Use IS_UNCHECKED_EXCEPTION_P instead of + IS_UNCHECKED_EXPRESSION_P. + (check_thrown_exceptions_do): Changed leading comment. Resolve and + layout argument exception type. + (purge_unchecked_exceptions): Use IS_UNCHECKED_EXCEPTION_P instead + of IS_UNCHECKED_EXPRESSION_P. + +1998-11-18 Anthony Green <green@cygnus.com> + + * jcf-parse.c (yyparse): Open class file in binary mode. + +1998-11-15 Per Bothner <bothner@cygnus.com> + + * jvgenmain.c: Need to #include "gansidecl.h" (to get PROTO). + + * jcf-write.c (perform_relocations): Move check out one loop. + +1998-11-15 Anthony Green <green@hoser.cygnus.com> + + * Make-lang.in: Fix reference to srcdir. + * jv-scan.c: Add missing xmalloc prototype. + * jvgenmain.c: Ditto. + +1998-11-15 Per Bothner <bothner@cygnus.com> + + * decl.c (error_mark_node), java-tree.h: New global. + * parse.y: Use empty_stmt_node instead of size_zero_node. + (build_if_else_statement): If missing else, use empty_stmt_node. + + * parse.y (not_initialized_as_it_should_p): Removed, with its callers. + (java_complete_expand_method): Complain if return is missing. + (java_check_regular_methods): Comment out incorrect error check. + (not_accessible_p): Fix incorrect handling of protected methods. + (patch_method_invocation): Pass correct context to not_accessible_p. + (find_applicable_accessible_methods_list): Likewise. + (qualify_ambiguous_name): If ARRAY_REF, it's an expression name. + (java_complete_tree): For CASE_EXPR and DEFAULT_EXPR, set + TREE_TYPE (to void_type_node); otherwise expand_expr crashes. + (patch_if_else_statement): Fix setting of CAN_COMPLETE_NORMALLY. + + * jcf-write.c (CHECK_OP, CHECK_PUT): Add some error checking. + (push_int_const): Remove reundant NOTE_PUSH. + (generate_bytecode_insns - case STRING_CST): Do NOTE_PUSH. + (- case SWITCH_EXPR): Fix code generation bug. + (- case PREDECREMENT_EXPR etc): Remove redundant NOTE_PUSH. + (generate_classfile): More robust for abstract methods. + +1998-11-15 Anthony Green <green@cygnus.com> + + * Makefile.in: jv-scan and jvgenmain all require libiberty. + * Make-lang.in: Ditto. + + * jv-scan.c: Remove xmalloc and xstrdup definitions. + * jvgenmain: Ditto. + +1998-11-15 Per Bothner <bothner@cygnus.com> + + * jcf-parse.c (HANDLE_EXCEPTIONS_ATTRIBUTE): New macro. + + * jcf-io.c (find_class): Simpler/cleaner structure fixes a bug. + +1998-11-14 Per Bothner <bothner@cygnus.com> + + Allow uses of interface types to verify. This is not really + type-safe, but it matches what Sun does, and is OK as long as + there are appropriate run-time checks. + * verify.c (merge_types): If merging two interface types, + just set the result to java.lang.Object. + * expr.c (pop_type): Any interface is matches by java.lang.Object. + +1998-11-13 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (main): Handle --output-class-directory argument. + * jvspec.c (lang_specific_driver): Translate `-d' into + -foutput-class-dir. + * jcf.h (jcf_write_base_directory): Declare. + * lang.c (lang_decode_option): Recognize -foutput-class-dir. + * lang-options.h: Mention -foutput-class-dir. + * jcf-write.c (jcf_write_base_directory): New global. + (make_class_file_name): Put generated .class file into `-d' + directory, or into source directory if -d not given. Function now + static. + (write_classfile): Free class file name. Handle case where class + file name is NULL. + (DIR_SEPARATOR): New macro. + Include <sys/stat.h> + + * Makefile.in (prefix): New macro. + +1998-11-12 Per Bothner <bothner@cygnus.com> + + * parse.y (patch_invoke): Do less if flag_emit_class_files. + * expr.c (build_known_method_ref): Don't check flag_emit_class_files + here (done in patch_invoke instead). + (case_identity): Moved here from parse.y. + + * java-tree.h (CAN_COMPLETE_NORMALLY): New macro. + * parse.y (java_complete_tree etc): Maybe set CAN_COMPLETE_NORMALLY. + * parse.y (java_complete_tree): Re-order COMPOUND_EXPR in BLOCK + so they can be efficiently scanned without recursion. + Error it ! CAN_COMPLETE_NORMALLY first part of COMPOUND_EXPR. + * expr.c (java_lang_expand_expr): Expand statements of COMPOUND_EXPR + in BLOCK iteratively, rather than recursively. + + * parse.y (do_unary_numeric_promotion): New function. + (patch_unaryop, patch_binop, patch_array_ref): Use it. + + * parse.y (patch_newarray): Various fixes. + + Re-do handling of switch statements (for proper block scoping). + * parse.y: Add just a single block for the enture switch block, + but don't create any "case blocks". + (group_of_labels): Rmeoved unneeded non-terminal. + CASE_EXPR and DEFAULT_EXPR are added to current block. + * expr.c (java_lang_expand_expr): Inline SWITCH_EXPR here. + Now also need to handle CASE_EXPR and DEFAULT_EXPR. + * java-tree.h (SWITCH_HAS_DEFAULT): New macro. + * parse.y (wfl_operator, print_int_node): Make non-static. + (java_complete_tree): CASE_EXPR and DEFAULT_EXPR are now processed + as part of recursive scan of block. + (java_expand_switch ): Removed - inlined into java_lang_expand_expr. + (patch_switch_statement): Most tests move dinto java_complete_tree. + + * parse.y: Make various production be non-typed (void). + * parse.y (parse_error): Merged into issue_warning_error_from_context. + * parse.y (add_stmt_to_compound): Don't create/change extra node. + (patch_method_invocation_stmt): Renamed to patch_method_invocation. + + * jcf-write.c (struct jcf_handler): New type. + (struct jcf_switch_state): New type. + (SWITCH_ALIGN_RELOC, BLOCK_START_RELOC): New relocation kinds. + (alloc_handler, emit_unop, emit_reloc): New functions. + (adjust_typed_op): Add extra parameter ("max type" offset). + (emit_switch_reloc, emit_case-reloc): New function. + (generate_bytecode_conditional): Handle REAL_TYPE comparisons. + (generate_bytecode_insns): Support REAL_CST, switch statements, + exception handling, method calls, object/array creation, and more. + + * class.c: Remove some unused variables. + * constants.c (find_string_constant): New function. + (count_constant_pool_bytes): Fix to correctly handle wide constants. + * decl.c (complete_start_java_method): Don't _Jv_InitClass + if flag_emit_class_files. + +1998-11-12 Tom Tromey <tromey@cygnus.com> + + * jcf-io.c (find_class): Added explanatory comment. + + * jcf-path.c (add_entry): Look for `.zip' at end of filename. Add + trailing slash to `.zip' entries. + + * jvspec.c (lang_specific_driver): Correctly handle case where + GC_NAME not defined. + +1998-11-11 Tom Tromey <tromey@cygnus.com> + + * jvspec.c (GC_NAME): New define. + (lang_specific_driver): Use GC_NAME. Add GC_NAME to command line + if required. + * Make-lang.in (jvspec.o): Define WITH_GC_<name>. + +1998-11-11 Per Bothner <bothner@cygnus.com> + + * jcf-dump.c (TABLE_SWITCH): Fix typos. + +1998-11-11 Tom Tromey <tromey@cygnus.com> + + * jcf-dump.c (main): Correctly recognize `--'-style long options. + +1998-11-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (is_compiled_class): Call safe_layout_class for class + compiled from source. + * conver.h (convert_to_integer, convert_to_real, + convert_to_pointer): Added prototypes. + * decl.c (init_decl_processing): Non longer push the decls of + `methodtable', `constants', `Class', `Field', `dispatchTable' + `jexception' and `Method'. + * expr.c (build_invokeinterface): New function. + (expand_invoke): static variable CLASS_IDENT now in + build_invokeinterface. Use build_invokeinterface. + (expand_java_field_op): Moved code to inline + java.lang.PRIMTYPE.TYPE into a function. + (build_primtype_type_ref): New function. + * java-tree.def (INSTANCEOF_EXPR): New tree code. + * java-tree.h (CLASS_METHOD_CHECKED_P, METHOD_DEPRECATED, + FIELD_DEPRECATED, CLASS_DEPRECATED): New flag macros. + (DECL_CONSTRUCTOR_P): Fixed typo in comment. + (DECL_LOCAL_STATIC_VALUE): New macro. + (build_invokeinterface, build_primtype_type_ref): New function + prototypes. + (java_parse_abort_on_error): Macro rewritten. + * jcf-parse.c (current_method): Add comment to declaration. + (parse_zip_file_entries, process_zip_dir, void parse_source_file): + Function prototypes fixed. + (jcf_parse_source): push/pop parser context. save/restore global. + (parse_source_file): Fixed leading comment. Now take a + IDENTIFIER_NODE as an argument. Doesn't check methods, layout + classes and pop the parser context anymore. + (yyparse): Push parser context, save globals, parse the source + file, restore globals and pop the parser context when processing a + source file. + * jcf.h (VERBOSE_SKELETON): Replaces SOURCE_FRONTEND_DEBUG define. + * lex.c (java_parse_doc_section): New function. + (java_lex): Call java_parse_doc_section when appropriate. Build an + operator around INSTANCEOF_TK. + * lex.h (java_lineterminator, java_sprint_unicode, + java_unicode_2_utf8, java_lex_error, java_store_unicode): + Prototypes rewritten. + (java_parse_escape_sequence, java_letter_or_digit_p, + java_parse_doc_section, java_parse_end_comment, java_get_unicode, + java_read_unicode, java_store_unicode, java_read_char, + java_allocate_new_line, java_unget_unicode, java_sneak_unicode): + Added function prototypes. + * parse.h (VERBOSE_SKELETON): Replaces SOURCE_FRONTEND_DEBUG + define. + (JNULLP_TYPE_P, CHECK_METHODS, CHECK_DEPRECATED, REGISTER_IMPORT): + New macros + (struct parser_ctxt): New fields: deprecated, + current_parsed_class_un, gclass_list. + (fix_method_argument_names, issue_warning_error_from_context, + resolve_package, lookup_package_type): New function prototypes. + (resolve_expression_name): Fixed function prototype. + (find_applicable_accessible_methods_list): Fixed indentation, added + extra argument in prototype. + (check_final_assignment, build_null_of_type, check_deprecation, + check_method_redefinition, reset_method_name, + java_check_regular_methods, java_check_abstract_methods, + maybe_build_primttype_type_ref): New function prototype. + * parse.y (conver.h): Include. + (INSTANCEOF_TK): Tagged <operator>. + (single_type_import_declaration): Use REGISTER_IMPORT macro. + (relational_expression:): Build binop for instanceof. + (java_push_parser_context): Remember ctxp->gclass_list across + contexts. + (java_pop_parser_context): Simply return if no context + exists. Remember gclass_list across contexts. + (issue_warning_error_from_context): New function. + (parse_error_context): Don't setup ctxp->elc here. Call + issue_warning_error_from_context instead. + (parse_warning_context): Likewise. + (maybe_create_class_interface_decl): Removed DECL_ARTIFICIAL + setup. Link new class/interface to ctxp->gclass_list. + (add_superinterfaces): Register interface as incomplete if not + loaded. + (create_class): Remember class unqualified name in + ctxp->current_parsed_class_un. Check class deprecation. + (register_fields): Check field deprecation. Remember static final + field value in DECL_LOCAL_STATIC_VALUE. Changed comment in part + processing INIT. + (method_header): New local variable ORIG_ARG. Use unqualified + current class name for check on constructor errors. Promote return + type if of record type. Argument list fix moved in + fix_method_argument_names, called here. Check method deprecation. + (fix_method_argument_names): New function. + (method_declarator): Promote record typed arguments. + (safe_layout_class): Check class methods before layout. + (java_complete_class): Compute field layout when patched. + (do_resolve_class): Try to load class after having it renamed + after the package name. + (get_printable_method_name): Use DECL_CONTEXT. + (reset_method_name): New function. + (check_method_redefinition): Use reset_method_name. + (java_check_regular_methods): New local variable + SAVED_FOUND_WFL. Temporarily reinstall overriding/hiding method + names for error report. Check for compile-time error when method + found has default (package) access. + (java_check_abstract_methods): Now takes an interface DECL node as + an argument. Also reinstall real name on unchecked + overriding/hiding methods for error report. + (java_check_methods): Fixed leading comment. Get classes to verify + from ctxp->gclass_list. Use CHECK_METHODS macro and set + CLASS_METHOD_CHECKED_P on class verification. + (lookup_java_method2): Get real method name if necessary. + (find_in_imports): Don't check package class access here. + (resolve_package, lookup_package_type): New functions. + (java_layout_classes): Fixed leading comment. Take classes to be + laid out from ctxp->gclass_list. + (java_complete_expand_methods): Don't expand native and abstract + methods. + (java_expand_classes): New function. + (resolve_expression_name): Use additional argument ORIG. Retrieve + values of static final field of primitive types. + (resolve_field_access): Handles static final field of promotive + type. + (resolve_qualified_expression_name): Handle STRING_CST as + primaries and package name resolution. Check deprecation on found + decls. Set where_found and type_found on non static field resolved + during qualification. Layout non primitive field decl types. + (check_deprecation): New function. + (maybe_access_field): Simplified. + (patch_method_invocation_stmt): Local variable CLASS_TYPE + removed. Reverse method's argument when primary is a type. Don't + use CLASS_TYPE to report problems, use IDENTIFIER_WFL + instead. Include abstract class in the list of class searchable + for constructors. Use DECL_CONTEXT of found method for access + checks. Check method deprecation. + (patch_invoke): Pay extra care to NEW_CLASS_EXPR type call when + converting arguments. Handle INVOKE_INTERFACE. + (lookup_method_invoke): Search constructor using existing + infrastructure (don't rely on lookup_java_constructor anymore). + (find_applicable_accessible_methods_list): Extra argument flag + LC. Now include constructor in the search. + (qualify_ambiguous_name): Conditional expression are primaries. + (not_initialized_as_it_should_p): static final are always + initialized. + (java_complete_tree): Pass extra NULL argument to + resolve_expression_name. Stricter test to carry on patching + assignments. New case for INSTANCEOF_EXPR. + (complete_function_arguments): Inline PRIMTYPE.TYPE read access. + (check_final_assignment, maybe_build_primttype_type_ref): New + functions. + (patch_assignment): Detect resolved static finals and carry normal + assignment error check on them. Inline PRIMTYPE.TYPE read access. + (try_builtin_assignconv): Access constant 0 on all primitive + types. + (valid_builtin_assignconv_identity_widening_p): Accept identical + types. Accept all promoted type on int type. + (valid_ref_assignconv_cast_p): Accept a null pointer to be + assigned to a reference. + (valid_method_invocation_conversion_p): Accept to check null + pointers. + (build_binop): Merge declaration and initialization of local + variable BINOP. + (patch_binop): New case for INSTANCEOF_EXPR. NE_EXPR to accept all + numeric types. Improved validity test for qualify operators on + references. + (patch_unaryop): Broadened rejection test for PREDECREMENT_EXPR + and PREINCREMENT_EXPR. Also detect resolved static finals of a + primitive type and issue the appropriate error message. + (resolve_type_during_patch): Mark class loaded when resolved. + (patch_cast): Allow null to be cased to reference types. + (build_null_of_type): New function. + (patch_array_ref): Handle array on references correctly. + (patch_return): Removed unused local variable MODIFY. Force + boolean to be returned as integers. Allows null to be returned by + a function returning a reference. + * typeck.c (convert_to_integer, convert_to_real, + convert_to_pointer): Prototypes moved to convert.h + (lookup_argument_method): Use method real name, if necessary. + +1998-10-30 Tom Tromey <tromey@cygnus.com> + + * class.c (build_class_ref): Changed name of primitive classes to + start with `_Jv_'. + + * class.c (make_class_data): Renamed fields: nmethods to + method_count, method_count to dtable_method_count. Always set + `state' field to 0. + * decl.c (init_decl_processing): Likewise. + +1998-10-28 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class): Don't mangle <finit>, produce + __finit<class> instead. Don't verify artificial methods. + * decl.c (finit_identifier_node): New declared global. + (init_decl_processing): finit_identifier_node initialized. + * java-tree.def (CONDITIONAL_EXPR): New Java tree code. + * java-tree.h (finit_identifier_node): Declared as extern. + (struct lang_decl): New field called_constructor. + (DECL_CONSTRUCTOR_CALLS): Access macro to called_constructor. + (CLASS_HAS_FINIT_P): New macro. + (CALL_CONSTRUCTOR_P): Leading comment changed. Macro now checks + explicit constructor invocation. + (CALL_EXPLICIT_CONSTRUCTOR_P, CALL_THIS_CONSTRUCTOR_P, + CALL_SUPER_CONSTRUCTOR_P): New macros. + (write_classfile): Added prototype. + * jcf-parse.c (jcf_parse_source): Parse and remember for + generation if the file was seen on the command line. + (parse_source_file): Don't write the class file here. + (yyparse): Loop on files rewritten. Set current_jcf. + (parse_zip_file_entries): Parse class file only if it was found. + * lang.c (init_parse): Don't open command line provided filename + here. + (lang_parse): Don't set main_jcf anymore. + * parse.h (ABSTRAC_CHECK): Capitalized arguments. + (JCONSTRUCTOR_CHECK): New macro. + (JBSC_TYPE_P): New macro. + (IN_TRY_BLOCK_P, EXCEPTIONS_P): Fixed leading comment. + (COMPLETE_CHECK_OP_2): New macro. + (struct parse_ctxt): New field explicit_constructor_p. + (check_class_interface_creation): Fixed prototype indentation. + (patch_method_invocation_stmt): Prototype reflects added argument. + (patch_invoke): Likewise. + (complete_method_declaration, build_super_invocation, + verify_constructor_circularity, + build_this_super_qualified_invocation, get_printable_method_name, + patch_conditional_expr, maybe_generate_finit, fix_constructors, + verify_constructor_super, create_artificial_method, + start_artificial_method_body, end_artificial_method_body, + generate_field_initialization_code): New function prototypes. + * parse.y: Fixed leading comment + (constructor_header:, constructor_body:, block_end:): Rules tagged + <node>. + (type_declaration:): Call maybe_generate_finit. + (method_declaration:): Action for method_body: placed in new + function complete_method_declaration, called here. + (constructor_declaration:): Defined actions. Removed leading + FIXME. + (constructor_header:): New rule with action. + (constructor_body:): Rule rewritten using block_begin: and + block_end:. Defined actions. + (constructor_declarator:, explicit_constructor_invocation:): + Defined actions. + (block:): Use new rules block_begin: block_end:. + (block_begin:, block_end:): New rules and actions. + (block_statements:): Fixed error message for explicit + constructors. + (method_invocation:): Call build_this_super_qualified_invocation + if primary is `this' or `super' was seen. + (conditional_expression:): Action defined. + (extra_ctxp_pushed_p): New static global flag. + (java_parser_context_save_global): Create parser context if + necessary. Use extra_ctxp_pushed_p to remember it. + (java_parser_context_restore_global): Pop extra parser context if + one exists. + (build_array_from_name): Array on primitive types are marked + loaded. + (register_fields): Restore new name in field initializer + expression if type was altered. Non static fields initialized upon + declaration marked initialized. + (maybe_generate_finit): New function. + (maybe_generate_clinit): Use create_artificial_method, + start_artificial_method_body, end_artificial_method_body. Generate + debug info for enclosed initialization statements. + (method_header): Fixed leading comment. Check constructor + flags. Detect constructor declarations and set DECL_CONSTRUCTOR_P + accordingly. + (complete_method_declaration, constructor_circularity_msg, + verify_constructor_circularity): New functions. + (get_printable_method_name): New function. + (check_method_redefinition): Don't rename <finit> methods. Fix + declared constructor names. Error message for + constructors modified. + (java_check_regular_methods): Local variable seen_constructor + renamed saw_constructor. Skip verification on constructors. Create + default constructor with create_artificial_method. + (java_check_methods): Removed unnecessary empty line. + (create_artificial_method, start_artificial_method_body, + end_artificial_method_body): New functions. + (java_layout_classes): Changed leading comment. Reverse fields + list if necessary. Always layout java.lang.Object if being + defined. + (java_complete_expand_methods): Verify constructor circularity. + (java_complete_expand_method): Call fix_constructor on + constructors. Local variable no_ac_found removed. Restore + bindings if method body expansion failed. + (fix_constructors, verify_constructor_super, + generate_field_initialization_code): New function. + (java_expand_classes): Fixed leading comment. Write class file + here. + (resolve_expression_name): Check for illegal instance variable + usage within the argument scope of an explicit constructor + invocation. + (resolve_qualified_expression_name): Pass extra from_super flag + when invoking patch_method_invocation_stmt. New case for + conditional expression when used as a primary. Check for error + when acquiring super. + (patch_method_invocation_stmt): Added extra argument super. New + local variable is_static_flag. Set class_to_search according to + the nature of the constructor invocation. Don't add `this' + argument when expanding NEW_CLASS_EXPR. Check for illegal method + invocation within the argument scope of explicit constructor + invocation. Set is_static according to is_static_flag. Provide + extra `super' argument to patch_invoke invocation. + (patch_invoke): New argument from_super. Loop on arguments + indentation fixed. Pass from_super to invocation_mode. New switch + case INVOKE_SUPER. Fixed error message in switch default case. + Don't use CALL_CONSTRUCTOR_P but rather a test on the tree node + value. + (invocation_mode): Return INVOKE_SUPER mode when appropriate. + (lookup_method_invoke): Fixed prototypes in candidates list. Error + message takes constructors into account. + (find_applicable_accessible_methods_list): Fixed indentation. + (qualify_ambiguous_name): Take explicit constructor invocation + into account. Deal with a conditional expression as a primary to + a method call. + (java_complete_tree): Added local wfl_op3. New CONDITIONAL_EXPR + case. Added extra argument to patch_method_invocation_stmt. + Register calls made to explicit constructor `this'. Don't call + save_expr in ARRAY_REF case when emitting class files. Check for + illegal use of this when expanding explicit constructor invocation + arguments. + (complete_function_arguments): Set and reset parser context + explicit_constructor_p field value when appropriate. + (build_super_invocation, build_this_super_qualified_invocation): + New functions. + (patch_assignment): Fixed typo. + (patch_unaryop): Check on final fields occurs only when a decl + exits. + (patch_return): Take constructors into account. + (patch_conditional_expr): New function. + * typeck.c (build_java_signature): Removed unnecessary empty line. + +1998-10-28 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (jcf-dump, gcjh): Link in $(LIBS) too. + +1998-10-28 Tom Tromey <tromey@cygnus.com> + + * decl.c (init_decl_processing): Renamed fields. + * class.c (make_class_data): Renamed bfsize, nfields, nsfields, + interface_len, msize fields. + + * class.c (make_class_data): Removed subclass_head and + subclass_next fields. + * decl.c (init_decl_processing): Removed subclass_head and + subclass_next fields. + +1998-10-28 Jeffrey A Law (law@cygnus.com) + + * jcf-write.c (emit_load_or_store): Avoid implicit int arguments. + * mangle.c (emit_unicode_mangled_name): Similarly. + +1998-10-26 Nick Clifton <nickc@cygnus.com> + + * jcf-parse.c (get_constant): Place braces around code to compute + 'd' when REAL_ARITHMETIC is not defined. + +1998-10-25 H.J. Lu (hjl@gnu.org) + + * Make-lang.in (jv-scan$(exeext)): Add stamp-objlist to + dependency. + +1998-10-23 Tom Tromey <tromey@cygnus.com> + + * lang-specs.h: `.zip' files are input to jc1. + +1998-10-22 Per Bothner <bothner@cygnus.com> + + * jvspecs.c: Add (but don't enable) support for combining multiple + .class and .java input filenames to a single jc1 invocation. + Add support for -C flag (copile to .class files). + Translate -classpath and -CLASSPATH arguments. + * lang-specs.h: Don't set %2 spec. + +1998-10-22 Tom Tromey <tromey@cygnus.com> + + * jcf-path.c (add_entry): Don't add trailing separator if entry is + a .zip file. + (add_path): Don't add trailing separator to non-empty path + elements. + + * lang.c (lang_decode_option): Check for -fclasspath and + -fCLASSPATH before examining other `-f' options. + + * java-tree.h (finalize_identifier_node): Don't declare. + * class.c (make_class_data): Don't push "final" field. + * decl.c (init_decl_processing): Don't push "final" field. + (finalize_identifier_node): Removed. + (init_decl_processing): Don't set finalize_identifier_node. + + * config-lang.in (stagestuff): Added jcf-dump and jv-scan. + +1998-10-11 Anthony Green <green@cygnus.com> + + * Make-lang.in (java): Depend on jcf-dump and jv-scan. + (JV_SCAN_SOURCES): New macro. + (JCF_DUMP_SOURCES): Likewise. + (jcf-dump$(exeext)): New target. + (jv-scan$(exeext)): New target. + +1998-10-22 Tom Tromey <tromey@cygnus.com> + + * Makefile.in (LEX): Removed. + (LEXFLAGS): Likewise. + (SET_BISON): New macro. + (BISON): Removed. + ($(PARSE_C)): Use SET_BISON. Run bison from srcdir to avoid + spurious diffs in parse.c. + ($(PARSE_SCAN_C)): Likewise. + (PARSE_DIR): New macro. + (PARSE_C): Use it. + (PARSE_SCAN_C): Likewise. + (PARSE_RELDIR): New macro. + + * jcf-io.c (saw_java_source): Define here, not in jcf-parse.c. + + * jcf-io.c (find_class): Use saw_java_source to determine when to + look for `.java' file. + * jcf-parse.c (saw_java_source): New global. + (yyparse): Set it if `.java' file seen. + + * Make-lang.in (JAVA_SRCS): Added jcf-path.c. + (GCJH_SOURCES): Likewise. + * Makefile.in (datadir): New macro. + (libjava_zip): Likewise. + (JAVA_OBJS): Added jcf-path.o. + (../jcf-dump$(exeext)): Depend on and link with jcf-depend.o. + (../gcjh$(exeext)): Likewise. + (jcf-path.o): New target. + * java-tree.h (fix_classpath): Removed decl. + * jcf-parse.c (fix_classpath): Removed. + (load_class): Don't call fix_classpath. + * parse.y (read_import_dir): Don't call fix_classpath. + * lex.h: Don't mention classpath. + * lex.c (java_init_lex): Don't initialize classpath. + * jcf-io.c (classpath): Removed global. + (find_class): Use jcf_path iteration functions. Correctly search + class path for .java file. + (open_in_zip): New argument `is_system'. + * jcf-dump.c (main): Call jcf_path_init. Recognize all new + classpath-related options. + * lang.c (lang_decode_option): Handle -fclasspath, -fCLASSPATH, + and -I. + (lang_init): Call jcf_path_init. + * lang-options.h: Mention -I, -fclasspath, and -fCLASSPATH. + * lang-specs.h: Handle -I. Minor cleanup to -M options. + Correctly put braces around second string in each entry. + * gjavah.c (main): Call jcf_path_init. Recognize all the new + classpath-related options. + (help): Updated for new options. + * jcf.h: Declare functions from jcf-path.c. Don't mention + `classpath' global. + * jcf-path.c: New file. + + * jcf-depend.c: Include jcf.h. + + * jcf-write.c (localvar_alloc): Returns `void'. + (localvar_free): Removed unused variable. + + * lang.c (OBJECT_SUFFIX): Define if not already defined. + (init_parse): Use OBJECT_SUFFIX, not ".o". + +1998-10-21 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (emit_register_classes): Renamed from + emit_register_class. + * java-tree.h (emit_register_classes): Prototype renamed from + emit_register_class. + * jcf-parse.c (yyparse): Call emit_register_classes once before + returning. + * parse.y (java_expand_classes): No longer register classes. + +1998-10-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (is_compiled_class): New local variable + seen_in_zip. Identify classes found in currently compiled source + file(s). + * decl.c (complete_start_java_method): Fixed typo. + * java-tree.h (CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P, + HAS_BEEN_ALREADY_PARSED_P, IS_A_COMMAND_LINE_FILENAME_P): New macros. + (CLASS_P): Moved around. + (java_parse_abort_on_error): Macro moved from jcf-parse.c + * jcf-parse.c (java_parse_abort_on_error): Macro moved to + java-tree.h + (jcf_parse_source): Changed leading comment. Removed unnecessary + fclose and CLASS_FROM_SOURCE_P marking. + (parse_source_file): New local variables remember_for_generation + and filename. Mark parsed file name identifier node. Removed block + executed when parse_only was null. Set remember_for_generation. + Use it as an argument to java_pop_parser_context. + (yyparse): New local variables several_files, list, next node and + current_file_list. Split ampersand separated file names into + current_file_list. Iterate through the list and parse accordingly. + * parse.h (java_pop_parser_context): New function prototype. + * parse.y (ctxp_for_generation): New static global variable. + (java_pop_parser_context): New argument generate. Link popped ctxp + to ctxp_for_generation list accordingly. + (java_complete_expand_methods): Fixed indentation. + (java_expand_classes): New function. + +1998-10-17 Per Bothner <bothner@cygnus.com> + + * Makefile.in: Link with libiberty.a instead of memmove.o. + +1998-10-16 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (setjmp.h): No longer included. + * lex.h (setjmp.h): Included. + * parse.h (SET_TYPE_FOR_RESOLUTION): New macro. + (duplicate_declaration_error_p): Renamed from + duplicate_declaration_error. + (build_array_from_name): New function prototype. + * parse.y (setjmp.h): No longer included. + (variable_declarator_id): Define action. + (build_array_from_name): New function. + (duplicate_declaration_error_p): Renamed from + duplicate_declaration_error. Fixed leading comment. + (register_fields): Main `for' loop reorganized. Uses + SET_TYPE_FOR_RESOLUTION and build_array_from_name. + (method_declarator): Uses SET_TYPE_FOR_RESOLUTION and call + build_array_from_name. + (resolve_class): Set CLASS_LOADED_P on newly build array dimension + types. + (read_import_dir): Don't try to skip `.' and `..'. + (declare_local_variables): Uses SET_TYPE_FOR_RESOLUTION and + build_array_from_name. Main `for' loop reorganized. + (resolve_qualified_expression_name): When building access to a + field, use the type where the field was found, not its own type. + (maybe_access_field): Use field DECL_CONTEXT if the type where the + field was found is null. + (qualify_ambiguous_name): Sweep through all successive array + dimensions. + +1998-10-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (pop_labeled_block, lang_printable_name, + maybe_add_interface, set_super_info, get_access_flags_from_decl, + interface_of_p, inherits_from_p, fix_classpath, + complete_start_java_method, emit_handlers, init_outgoing_cpool, + make_class_data, register_class, alloc_name_constant): New + function prototypes. + * lang.c (lang_decode_option): Set argc argument unused. Fixed + indentation. Added cast to remove warning. + (lang_printable_name): Set v argument unused. + (lang_print_error): Added argument to lang_printable_name call. + (java_dummy_print, print_lang_decl, print_lang_type, + print_lang_identifier, lang_print_xnode): All argument marked + unused. + * lex.c (java_unget_unicode): Removed unnecessary argument. + (java_allocate_new_line): Unused local variable is gone. + (java_read_char): Added parenthesis in expressions to remove + warnings. Added final return statement. + (java_read_unicode): Added parenthesis in expression to remove + warning. + (java_parse_end_comment): Fixed java_unget_unicode invocation. + (java_parse_escape_sequence): Likewise. + (java_lex): Unused local variables are gone. Fixed + java_unget_unicode invocation. + * lex.h (set_float_handler): Prototype added when JC1_LITE not + defined. + * parse.h (ERROR_CANT_CONVERT_TO_BOOLEAN): Fixed + lang_printable_name invocation in macro. + (ERROR_CANT_CONVERT_TO_NUMERIC, ERROR_CAST_NEEDED_TO_INTEGRAL): + Likewise. + (duplicate_declaration_error): Suppressed unused argument in + prototype. + (identical_subpath_p): Function declaration is gone. + (patch_invoke): Suppressed unused argument in prototype. + (patch_cast, build_labeled_block, check_thrown_exceptions): + Likewise. + * parse.y (setjmp.h): Included + (toplev.h): Likewise. + (field_declaration:): Suppressed unused local + (label_decl:): Fixed build_labeled_block invocation. + (java_pop_parser_context): Put extra parenthesis around assignment + in if. + (yyerror): Suppressed unused local variables. + (variable_redefinition_error): Fixed lang_printable_name + invocation. + (create_interface): Suppressed unused local variables. + (create_class): Likewise. + (duplicate_declaration_error): Suppressed unused argument. Fixed + lang_printable_name invocation. + (register_fields): Suppressed unused local variable. Fixed + duplicate_declaration_error invocation. + (method_header): Suppressed unused local variable. + (method_declarator, parser_check_super): Likewise. + (java_complete_class): Suppressed unused local variable. Fixed + fatal error message. + (complete_class_report_errors): Added default: in switch. + (java_check_regular_methods): Fixed lang_printable_name + invocations. + (check_throws_clauses): Likewise. + (java_check_abstract_methods): Suppressed unused local + variable. Fixed lang_printable_name invocation. + (read_import_entry): Added supplemental return statement. + (read_import_dir): Suppressed unused local variables. + (check_pkg_class_access, declare_local_variables): Likewise. + (source_start_java_method): Suppressed unused extern variable + declarations + (expand_start_java_method): Suppressed unused extern and local + variable declarations. + (java_complete_expand_methods): Likewise. + (java_complete_expand_method): Suppressed unused local variables. + (make_qualified_name): Likewise. + (resolve_qualified_expression_name): Added default: in + switch. Fixed lang_printable_name invocation. + (class_instance_creation_expression): Added parenthesis around + expressions. + (patch_method_invocation_stmt): Fixed lang_printable_name and + patch_invoke invocations. + (check_for_static_method_reference): Fixed lang_printable_name + invocation. + (patch_invoke): Suppressed unused arguments and local variables. + (lookup_method_invoke): Suppressed unused local variables. + (qualify_ambiguous_name): Added default: in switch. + (identical_subpath_p): Function removed. + (patch_assignment): Suppressed unused local variables. Suppressed + unnecessary if statement. Fixed lang_printable_name invocations. + (try_builtin_assignconv): Fixed lang_printable_name invocations. + (valid_ref_assignconv_cast_p): Parenthesis around + expression. Suppressed unused local variables. + (build_binop): Suppressed unused local variables. fixed + lang_printable_name invocations. + (string_constant_concatenation): Suppressed unused local + variables. + (patch_unaryop): Fixed lang_printable_name invocation. + (patch_cast): Suppressed unnecessary argument. Fixed + lang_printable_name invocation. + (patch_array_ref): Fixed lang_printable_name invocation. + (patch_newarray, patch_return, patch_if_else_statement): Likewise. + (build_labeled_block): Suppressed unused argument. + (generate_labeled_block): Fixed build_labeled_block invocation. + (build_loop_body): Suppressed unused local variables. + (patch_loop_statement): Likewise. + (patch_exit): Fixed lang_printable_name invocation. + (patch_switch_statement): Likewise. + (case_identity): First argument marked unused. + (patch_try_statement): Fixed lang_printable_name invocations. + (patch_synchronized_statement, patch_throw_statement): Likewise. + (check_thrown_exceptions): Fixed check_thrown_exceptions and + lang_printable_name invocations. + (check_thrown_exceptions_do): Suppressed unused argument. + +1998-10-14 Tom Tromey <tromey@cygnus.com> + + * jcf-write.c (write_classfile): Add output class file as target. + * lang-options.h: Added -MD, -MMD, -M, and -MM. + * jcf.h: Added declarations for dependency-tracking functions. + * lang-specs.h: Handle -M, -MM, MD, and -MMD. + * lang.c (lang_decode_option): Recognize -MD and -MMD. + (finish_parse): Call jcf_dependency_write. + (dependency_tracking): New global. + (DEPEND_SET_FILE): New define. + (DEPEND_ENABLE): New define. + (init_parse): Enable dependency tracking if required. + Include "flags.h". + * Makefile.in (JAVA_OBJS): Added jcf-depend.o. + (../jcf-dump$(exeext)): Depend on and link with jcf-depend.o. + (../gcjh$(exeext)): Likewise. + (jcf-depend.o): New target. + * Make-lang.in (JAVA_SRCS): Added jcf-depend.c. + (GCJH_SOURCES): Likewise. + * jcf-io.c (open_class): Call jcf_dependency_add_file. Added + dep_name argument. + (find_classfile): Added dep_name argument. + (find_class): Compute name of dependency. + (open_in_zip): Call jcf_dependency_add_file. + * gjavah.c (output_file): No longer global. + (usage): Don't mention "gjavah". + (help): Likewise. + (java_no_argument): Likewise. + (version): Likewise. + (main): Recognize and handle -M family of options. + (print_mangled_classname): Return is void. + (process_file): Handle case where output is suppressed. + (HANDLE_END_FIELD): Likewise. + (HANDLE_METHOD): Likewise. + * jcf-depend.c: New file. + +1998-10-13 Jeffrey A Law (law@cygnus.com) + + * java-tree.def: Add missing newline at EOF. + +1998-10-13 Tom Tromey <tromey@cygnus.com> + + * jcf-dump.c (process_class): Use FATAL_EXIT_CODE, not -1. + (main): Likewise. Exit with SUCCESS_EXIT_CODE at end of + function. + Include <config.h> and "system.h". + (disassemble_method): Undefine RET to avoid clash with + config/i386/i386.h. + +1998-10-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (runtime_exception_type_node, error_exception_type_node): + New global variables. + (init_decl_processing): Initialized. + * expr.c (java_lang_expand_expr): Set caught exception type to + null if catch handler argument doesn't exit. + * java-tree.def (SYNCHRONIZED_EXPR, THROW_EXPR): New Java specific + tree codes. + * java-tree.h (runtime_exception_type_node, + error_exception_type_node): Global variables declared. + (DECL_FUNCTION_THROWS): New macro. + (DECL_FUNCTION_BODY): Modified comment. + (DECL_SPECIFIC_COUNT): Likewise. + (struct lang_decl): New field throws_list. + (IS_UNCHECKED_EXPRESSION_P): New macro. + * lex.c (java_lex): Generate location information for THROW_TK. + * parse.h (PUSH_EXCEPTIONS, POP_EXCEPTIONS, IN_TRY_BLOCK_P, + EXCEPTIONS_P): New macros. + (enum jdep_code): New value JDEP_EXCEPTION. + (BUILD_MONITOR_ENTER, BUILD_MONITOR_EXIT, + BUILD_ASSIGN_EXCEPTION_INFO, BUILD_THROW, SET_WFL_OPERATOR, + PATCH_METHOD_RETURN_ERROR): New macros. + (patch_method_invocation_stmt): Added new argument to prototype. + (patch_synchronized_statement, patch_throw_statement, + check_thrown_exceptions, check_thrown_exceptions_do, + purge_unchecked_exceptions, check_throws_clauses): New function + prototypes. + * parse.y Fixed typo in keyword section. + (throw:): Rule tagged <node>. + (THROW_TK): Keyword tagged <operator>. + (method_header:): Last argument to call to method_header passed + from throws: rule. + (throws:, class_type_list:, throw_statement:, + synchronized_statement:, synchronized:): Defined actions. + (method_header): New local variable current. Register exceptions + from throws clause. + (java_complete_tree): Complete and verify exceptions from throws + clause. + (complete_class_report_errors): Error message on exceptions not + found + (java_check_regular_methods): Fixed typo. Shortcut on private + overriding methods. Changed error message on method + redefinition. Check for throws clause compatibility. + (check_throws_clauses): New function. + (java_check_abstract_methods): Use DECL_NAME for wfl or current + method. Changed error message on method redefinition. + (currently_caught_type_list): New static variable. + (java_complete_expand_methods): Purge unchecked exceptions from + throws clause list. Call PUSH_EXCEPTIONS before walk and + POP_EXCEPTIONS after. + (resolve_qualified_expression_name): Pass new argument as NULL to + patch_method_invocation_stmt. + (patch_method_invocation_stmt): New argument ref_decl. Invoke + PATCH_METHOD_RETURN_ERROR when returning with error. Reverse + argument list when appropriate. Use new argument if non null to + store selected method decl. + (patch_invoke): Convert if necessary args of builtin types before + forming CALL_EXPR. Argument list no longer reversed here. + (invocation_mode): Treat final methods as static methods. + (java_complete_tree): New cases for THROW_EXPR: and + SYNCHRONIZED_EXPR:. Check thrown exceptions when completing + function call. + (complete_function_arguments): No more RECORD_TYPE + conversion. Function parameter nodes no longer saved. + (valid_ref_assignconv_cast_p): Avoid handling null type. + (patch_binop): Fixed null constant reference handling. + (build_try_statement): Use BUILD_ASSIGN_EXCEPTION_INFO and + BUILD_THROW macros. + (patch_try_statement): Fixed comments. Record caught types in + list, push the list, expand try block and pop the list. + (patch_synchronized_statement, patch_throw_statement, + check_thrown_exceptions, check_thrown_exceptions_do, + purge_unchecked_exceptions): New functions. + * typeck.c (lookup_argument_method): Allow WFL in place of method + DECL_NAME during method definition check + +1998-10-09 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (decode_signature_piece): New function. + (print_c_decl): Use it. Added `name_override' argument. + (print_method_info): Use name_override argument to print_c_decl. + (seen_fields): Removed. + (print_field_info): Don't update seen_fields. + (struct method_name): New structure. + (method_name_list): New global. + (print_method_info): Add new method to list of methods. + (name_is_method_p): New function. + (print_field_info): If field name has same name as method, then + change field name. + (process_file): Parse methods before fields. + (field_pass): New global. + (HANDLE_END_FIELD): Take field_pass into account. + +1998-10-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * Makefile.in (keyword.h): Add -L KR-C -F ', 0' flags to gperf. + (keyword.h): Regenerate using gperf 2.7.1 (19981006 egcs). + +1998-10-03 Anthony Green <green@cygnus.com> + + * jvspec.c: Fix bug in jvgenmain_spec patch. + +1998-10-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Makefile.in (lang.o:): Install dependency on java-tree.def. + * decl.c (soft_exceptioninfo_call_node): New global variable. + (init_decl_processing): Fixed indentation. soft_badarrayindex_node + takes extra integer argument. soft_exceptioninfo_call_node + initialized. + * except.c (java_set_exception_lang_code): New function + (method_init_exceptions): Called here. + (prepare_eh_table_type): New function. + (expand_end_java_handler): Called here. + * expr.c (build_java_throw_out_of_bounds_exception): Now features + one argument. Modified generation of call to + soft_badarrayindex_node to use new argument. + (build_java_arrayaccess): Pass faulty index value to + build_java_throw_out_of_bounds_exception. + (generate_name): New function. + (java_lang_expand_expr): New local variables node, current, + has_finally_p. Expand TRY_EXPR node. + (process_jvm_instruction): Replace top of the stack with thrown + object reference when entering exception handler. + * java-tree.def (TRY_EXPR, CATCH_EXPR, FINALLY_EXPR): New Java + specific tree codes. + * java-tree.h (soft_exceptioninfo_call_node): Declaration of new + global. + (DECL_SPECIFIC_COUNT): New macro. + (prepare_eh_table_type, java_set_exception_lang_code, + generate_name): New function declarations. + (match_java_method): Declaration deleted. + (FINALLY_EXPR_LABEL, FINALLY_EXPR_BLOCK, CATCH_EXPR_GET_EXPR): New + macros. + * lex.c (TRY_TK, CATCH_TK): Generate location information. + * parse.h (redefinition_error, refine_accessible_methods_list, + can_cast_to_p): Function declaration removed. + (classitf_redefinition_error, variable_redefinition_error, + parse_jdk1_1_error, find_applicable_accessible_methods_list, + find_most_specific_methods_list, argument_types_convertible, + enter_a_block, valid_builtin_assignconv_identity_widening_p, + valid_cast_to_p, valid_method_invocation_conversion_p, + try_reference_assignconv, add_stmt_to_compound, + build_jump_to_finally, build_tree_list, patch_try_statement, + java_get_catch_block): New function declarations. + * parse.y (string_buffer_type): Global variable deleted. + (group_of_labels, catches, catch_clause, catch_clause_parameter, + finally): Rules tagged <node>. + (TRY_TK, CATCH_TK): Token tagged <operator>. + (class_body_declaration:, class_member_declaration:, + formal_parameter:, explicit_constructor_invocation:, + interface_member_declaration:, constant_declaration:, + primary_no_new_array:, class_instance_creation_expression:, + array_creation_expression:): Issue error on unsuported JDK1.1 + features. + (try_statement:, catches:, finally:): Define actions. + (catch_clause_parameter): New rule. + (catch_clause:): Use new rule catch_clause_parameter. + (parse_jdk1_1_error): New function. + (redefinition_error): Renamed classitf_redefinition_error. + (variable_redefinition_error): New function. + (check_class_interface_creation): Call + classitf_redefinition_error. + (java_complete_tree): Added error message on JDEP_TYPE: case. + (complete_class_report_errors): Fixed indentation. + (declare_local_variables): Call variable_redefinition_error. + (source_end_java_method): Call java_set_exception_lang_code and + emit_handlers where appropriate. + (java_method_add_stmt): Call add_stmt_to_block. + (add_stmt_to_block): New function. + (lookup_method_invoke): Fixed outside comment. new local variable + candicates. Call find_applicable_accessible_methods_list and + find_most_specific_methods_list when searching for a + method. Modified error report to list possible candidates when + applicable. + (find_applicable_accessible_methods_list, + find_most_specific_methods_list, argument_types_convertible): New + function. + (refine_accessible_methods_list): Function deleted. + (java_complete_tree): Handle TRY_EXPR. ARRAY_REF handling: save + expr (if applicable) before calling patch_array_ref. + (build_expr_block): Fixed BLOCK_EXPR_BODY assignment. + (enter_block): Fixed comment. + (enter_a_block): New function. + (patch_assignment): Reorganized. Call try_reference_assignconv for + references. Call valid_cast_to_p instead of can_cast_to_p. + (try_reference_assignconv, + valid_builtin_assignconv_identity_widening_p): New functions. + (valid_ref_assignconv_cast_p): Fixed inverted test on CLASS_FINAL. + (valid_cast_to_p, valid_method_invocation_conversion_p): New + functions. + (build_string_concatenation): Don't resolve StringBuffer. + (patch_cast): Fixed inverted arguments. + (patch_array_ref): Code to save array expr deleted. Call + valid_cast_to_p instead of can_cast_to_p. + (generate_labeled_block): Call generate_name. + (build_jump_to_finally, build_try_statement, java_get_catch_block, + patch_try_statement): New functions. + * typeck.c (match_java_method): Function deleted. + +1998-10-02 Anthony Green <green@cygnus.com> + + * jvspec.c: jvgenmain_spec uses different temporary file names. + +1998-10-02 Anthony Green <green@cygnus.com> + + * jvspec.c (lang_specific_driver): Fail if user specifies + --main= when not linking. + +1998-09-28 Tom Tromey <tromey@cygnus.com> + + * class.c (make_class_data): Push value for `thread' field. + * decl.c (init_decl_processing): Added `thread' field to class. + + * class.c (add_field): Always make static fields externally + visible. + +1998-09-26 Anthony Green <green@cygnus.com> + + * expr.c (build_java_athrow, + build_java_throw_out_of_bounds_exception, expand_invoke, + build_newarray, expand_java_multianewarray, build_java_monitor): + Update comments to reflect _Jv_* function names. + +1998-09-25 Per Bothner <bothner@cygnus.com> + + * decl.c (complete_start_java_method): DECL_RESULT is always promoted. + * decl.c (start_java_method): Handle PROMOTE_PROTOTYPES target macro. + * parse.y (expand_start_java_method): Likewise. + +1998-09-24 Per Bothner <bothner@cygnus.com> + + * expr.c (pop_arguments): Handle PROMOTE_PROTOTYPES target macro. + + * class.c (push_class): IDENTIFIER_SIGNATURE_TYPE is now POINTER_TYPE. + (add_field): No longer need to convert from RECORD_TYPE to pointer, + * expr.c: Remove no-longer-needed calls to promote_type. + * decl.c (give_name_to_locals): Liekwise. + * jcf-parse.c (get_class_constant): Compensate for new signatures. + * parse.y: Add/remove promote_type calls as appropriate. + * typeck.c (parse_signature_type): Returns POINTER_TYPE for objects. + (parse_signature_string): Likewise. + (build_java_array_type): Fix for now signature convenions. + + * lex.c (java_lex): Fix (from Alex) for JC1_LITE problem. + +1998-09-23 Tom Tromey <tromey@cygnus.com> + + * class.c (init_class_processing): libjava function renamed to + _Jv_RegisterClass. + +1998-09-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (java_lang_expand_expr): New case for SWITCH_EXPR. + * java-tree.def: Fixed DEFTREECODE third argument. + (UNARY_PLUS_EXPR, NEW_ARRAY_EXPR, NEW_CLASS_EXPR, THIS_EXPR, + CASE_EXPR, DEFAULT_EXPR): New tree codes for Java. + * java-tree.h: (IS_CRAFTED_STRING_BUFFER_P): New macro. + (JAVA_UNARY_PLUS_EXPR, JAVA_NEW_ARRAY_EXPR, JAVA_NEW_CLASS_EXPR, + JAVA_THIS_EXPR): Now replaced by tree code definitions. + (CALL_CONSTRUCTOR_P): Now uses NEW_CLASS_EXPR. + * lang.c (java_tree_code_type, java_tree_code_length, + java_tree_code_name): New arrays. + (lang_init): Append Java tree node definitions to Gcc ones. + * lex.c (expression_obstack): Declared as extern when JC1_LITE + defined. + (java_init_lex): Initialize wfl_append, wfl_string_buffer, + wfl_to_string. + (java_lex): Allow declaration of empty string constants. Retain + location information on CASE_TK and DEFAULT_TK. + * parse.h (JFLOAT_TYPE_P, JINTEGRAL_TYPE_P, JNUMERIC_TYPE_P, + JPRIMITIVE_TYPE_P, JSTRING_TYPE_P, JSTRING_P, JREFERENCE_TYPE_P): + Modified to be more robust. + (BUILD_APPEND, BUILD_STRING_BUFFER): New macros. + (build_new_invocation, try_builtin_assignconv, + patch_switch_statement, string_constant_concatenation, + build_string_concatenation, patch_string_cst, patch_string, + java_expand_switch): New function declarations. + * parse.y: Rules related to switch and EH tagged <node>. + (label_id): Set to NULL_TREE + (wfl_string_buffer, wfl_append, wfl_to_string): New static global + tree nodes. + (this_or_super:): Fixed indentation. + (statement:, statement_nsi:, statement_without_trailing_substatement:, + statement_expression:): Removed call to RULE on all sub-rules. + (switch_expression:, switch_labels:): New rules. + (switch_statement:, switch_block:, switch_block_statement_groups:, + switch_block_statement_group:, switch_labels:, switch_label:): + Defined actions. + (throw_statement:, synchronized_statement:, try_statement:): + Defined temporary actions. + (class_instance_creation_expression:): Call + build_new_invocation. Fixed indentation. + (field_access): Fixed indentation. + (method_invocation): Likewise. + (make_qualified_primary): Use THIS_EXPR. + (resolve_qualified_expression_name): Use NEW_CLASS_EXPR. When + resolving from SUPER, set *type_found. + (qualify_ambiguous_name): Use NEW_CLASS_EXPR. + (java_complete_tree): Removed unused local variable `location'. Case + for SWITCH_EXPR, sharing code with LOOP_EXPR. Use NEW_ARRAY_EXPR, + NEW_CLASS_EXPR, UNARY_PLUS_EXPR and THIS_EXPR. New string handling + on MODIFY_EXPR: and all binary operator tree code cases. Removed + STRING_CST: case. default: checks for patchable strings. + (complete_function_arguments): Transform string constant or + crafted StringBuffer if necessary. + (build_method_invocation): Fixed comments. + (build_new_invocation): New function. + (patch_assignment): Call try_builtin_assignconv to figure a valid + assignment conversion between builtin types. + (try_builtin_assignconv): New function. + (build_binop): Use URSHIFT_EXPR directly to call build. + (operator_string): Use UNARY_PLUS_EXPR. + (patch_binop): Use UNARY_PLUS_EXPR. Handle string concatenation + operator. + (do_merge_string_cste, merge_string_cste, + string_constant_concatenation, build_string_concatenation, + patch_string, patch_string_cst): New function. + (build_unary_op): Use UNARY_PLUS_EXPR and CONVERT_EXPR. + (patch_unaryop): Likewise. New test of valid ++/-- operands. + (build_newarray_node): Use NEW_ARRAY_EXPR. + (build_this): Use THIS_EXPR. + (build_return): Enable debug information on return statement. + (build_if_else_statement): Likewise. + (complete_labeled_statement): Fixed related comment. + (build_loop_body): Fixed comment. + (build_bc_statement): Enable debug information on break/continue + statements. + (patch_bc_statement): Fixed typos. Handle SWITCH statement + context. + (patch_switch_statement, case_identity, java_expand_switch): New + functions. + +1998-09-21 Per Bothner <bothner@cygnus.com> + + * buffer.h (BUFFER_INIT): New macro. + * jcf-write.c (struct jcf_partial): New type. Put global stuff here. + Pass (struct jcf_partial *state) to most functions. + (jcf_block, jcf_relocation): New types. + Support labels, branches, conditionals, loops. + +1998-09-21 Tom Tromey <tromey@cygnus.com> + + * decl.c (INT_TYPE_SIZE): Define as BITS_PER_WORD if not defined. + +1998-09-21 Per Bothner <bothner@cygnus.com> + + * decl.c (integer_type_node): Make it have INT_TYPE_SIZE. + * verify.c (verify_jvm_instructions): Use int_type_not (32 bits), + not integer_type_node (INT_TYPE_SIZ bits). + + * parse.y (patch_if_else_statement): Accept promoted_boolean_type_node. + + * jcf-reader.c (get_attribute): New HANDLE_EXCEPTION_TABLE hook. + * jcf-dump.c (print_exception_table): New function. + (disassemble_method): Better handling of wide instructions. + Make more robust for bad input. + +1998-09-30 Jeffrey A Law (law@cygnus.com) + + * jcf-write.c (OP2, OP4): Use "_i", not "_I" to avoid problems on + FreeBSD. + +1998-09-17 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (jcf-dump, jvgenmain): Link in memmove.o too. + +1998-09-17 Tom Tromey <tromey@cygnus.com> + + * Makefile.in ($(PARSE_H)): Removed target. + +1998-09-17 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (JAVA_OBJS): Add memmove.o + (memmove.o): New target & rules. + +1998-09-15 Tom Tromey <tromey@cygnus.com> + + * expr.c (expand_invoke): Don't generate a call to the class init + code. + +1998-09-14 Jeffrey A Law (law@cygnus.com) + + * Makefile.in: Add many missing dependencies. + * buffer.c, class.c, constants.c, decl.c: Use system.h and toplev.h + as appropriate. + * except.c, expr.c, jcf-io.c jcf-parse.c, jcf-write.c: Likewise. + * jvgenmain.c lang.c mangle.c typeck.c verify.c: Likewise. + +1998-09-11 Per Bothner <bothner@cygnus.com> + + * decl.c (complete_start_java_method): If method is static (and + not private) call _Jv_InitClass. + * expr.c (expand_invoke): Don't call build_class_init. + + * jvspec.c (jvgenmain_spec): Fix spec for generated .o file. + +1998-09-10 Jeffrey A Law (law@cygnus.com) + + * Make-lang.in (GCJ): Define before using. + +1998-09-09 Jeffrey A Law (law@cygnus.com) + + * gjavah.c (java_no_argument): Renamed from no_argument to avoid + losing due to namespace pollution in GNU getopt.h + +1998-09-09 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (java.all.build): Don't mention jvgenmain or gcjh. + (java.all.cross): Likewise. + (java.rest.encap): Likewise. + +1998-09-08 Jeffrey A Law (law@cygnus.com) + + * gjavah.c (print_class_decls): Fix thinko in arglist + * jcv-io.c (find_classfile): Similarly. + +1998-09-07 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (INCLUDES): Update for recent toplevel gcc changes. + +1998-09-05 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (java.maintainer-clean): Don't remove parse.h. + (java.mostlyclean): Remove parse.c and parse-scan.c, not parse.h. + * Makefile.in (PARSE_C): New macro. + (PARSE_H): Likewise. + (PARSE_SCAN_C): Likewise. + ($(PARSE_C)): Target renamed from parse.c. + ($(PARSE_SCAN_C)): Target renamed from parse-scan.c. + (clean): Remove parse-scan.c as well. + (parse.o): Depend on $(PARSE_C). + +1998-09-05 Anthony Green <green@cygnus.com> + + * README, license.terms: Removed. + + * Make-lang.in, Makefile.in, class.c, config-lang.in, constants.c, + decl.c, except.c, expr.c, gjavah.c, java-except.h, java-tree.h, + javaop.def, javaop.h, jcf-dump.c, jcf-io.c, jcf-parse.c, + jcf-reader.c, jcf-write.c, jcf.h, jvgenmain.c, jvspec.c, + keyword.gperf, keyword.h, lang-options.h, lang-specs.h, lang.c, + lex.c, lex.h, mangle.c, parse-scan.y, parse.h, parse.y, typeck.c, + verify.c, zextract.c, zipfile.h: Fixed copyright assignment, + and Java trademark attribution. + +1998-09-04 Tom Tromey <tromey@cygnus.com> + + * Makefile.in: Use gcjh, not gjavah. + * config-lang.in (stagestuff): Use gcjh, not gjavah. + * Make-lang.in: Changed gjavah to gcjh everywhere. + +1998-09-03 Per Bothner <bothner@cygnus.com> + + * gjavah.c: Support new -prepend -add -append flags. + (print_method_info): Method is not virtual if class is final. + +1998-09-03 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jv-scan.c: Fixed copyright assignment. + * keyword.gperf: Likewise. + * keyword.h: Likewise. + * lex.c: Fixed copyright assignment. + (java_lex): Push unicode back when parsing '<'. + * lex.h: Fixed copyright assignment. + * parse-scan.y: Likewise. + * parse.h: Fixed copyright assignment. + (build_debugable_stmt, complete_for_loop): New function prototypes. + * parse.y: Fixed copyright assignment. + (for_statement:): Call complete_for_loop. Set EXIT_EXPR to be + size_zero_node when completing a loop with no exit condition. + (for_statement_nsi:): Define action. + (for_init:, for_update:): Return size_zero_node when empty. + (declare_local_variables): Call build_debugable_stmt. + (build_debugable_stmt): New function. + (build_loop_body): Build debugable statement around loop + condition part. + (complete_loop_body): Take into account the debugable statement + around the EXIT_EXPR. + (complete_loop_body): New function. + (patch_exit_expr): Fixed condition inversion. + +1998-09-02 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (jvspec.o): Use GCC_THREAD_FILE to compute correct + name of thread define. + * jvspec.c (THREAD_NAME): New macro. + (GCLIB): Likewise. + (THREADLIB): Likewise. + (lang_specific_driver): Recognize attempt to link with thread + library or gc library. Recognize -ljava on command line so it + isn't linked against more than once. + +1998-09-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse-scan.y (report_main_declaration): Name of the class + containing `main' can be a qualified name. + +1998-08-31 Tom Tromey <tromey@cygnus.com> + + * config-lang.in: Changed gjavac to gjc everywhere. + * Make-lang.in: Changed gjavac to gjc everywhere. + +1998-08-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Make-lang.in (JAVA_TARGET_INDEPENDENT_BIN_TOOLS): New variable. + (java.install-common:): Loop over JAVA_TARGET_INDEPENDENT_BIN_TOOLS + and install the files. + * Makefile.in (JAVA_OBJS_LITE): New variable. + (compiler:): Now include jv-scan as a dependency. + (../jv-scan$(exeext), parse-scan.c): New targets. + (../jcf-dump$(exeext)): Was jcf-dump$(exeext) before. + * config-lang.in (compilers): Removed gcj, gjavah from the list. + * jcf-parse.c (parse_source_file): Call java_layout_classes and + check for errors even if parse_only. + * lex.c (java_init_lex): Reorganized and skip parts if JC1_LITE is + defined. + (yylex): New function. Uses java_lex body. + (java_lex): Removed commented out statement. Remove local variable + literal. Use SET_LVAL_NODE_TYPE and SET_LVAL_NODE where + appropriate. Use macros FLOAT_TYPE_NODE, DOUBLE_TYPE_NODE, + DCONST0, SET_FLOAT_HANDLER, SET_REAL_VALUE_ATOF, + SET_LVAL_NODE_TYPE and GET_TYPE_PRECISION. Don't create STRING_CST + if JC1_LITE is defined. Use BUILD_ID_WFL to build identifiers. Use + SET_MODIFIER_CTX, SET_LVAL_NODE, BUILD_ID_WFL and GET_IDENTIFIER + where appropriate. + (java_lex_error): Empty if JC1_LITE is defined. + (java_get_line_col): Return 0 if JC1_LITE is defined. + * lex.h (JAVA_FLOAT_RANGE_ERROR, JAVA_INTEGRAL_RANGE_ERROR, + SET_MODIFIER_CTX): Moved into the section containing the macros + conditionally defined by JC1_LITE. + (BUILD_OPERATOR,BUILD_OPERATOR2): Just return the TOKEN + argument if JC1_LITE is defined. + (HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, REAL_VALUE_ATOF, + REAL_VALUE_ISINF, REAL_VALUE_ISNAN): Preset to values if JC1_LITE + is defined. + (DCONST0, SET_FLOAT_HANDLER, GET_IDENTIFIER, SET_REAL_VALUE_ATOF, + FLOAT_TYPE, DOUBLE_TYPE, SET_MODIFIER_CTX, GET_TYPE_PRECISION, + SET_LVAL_NODE, SET_LVAL_NODE_TYPE, BUILD_ID_WFL): New macros, set + to different values according to JC1_LITE. + * parse.h (int_fits_type_p, stabilize_reference): Prototype not + declared if JC1_LITE set. + (jdep_code, typedef struct _jdep, typedef struct _jdeplist): Not + defined if JC1_LITE not set. + (struct parser_ctx): Reorganized and skip the jc1 front end part + if JC1_LITE set. + (java_layout_classes): New function definition. + (java_push_parser_context, java_init_lex, yyparse, yylex, + yyerror): Prototype always declared. All other static function + prototypes declared only if JC1_LITE is not set. + * parse.y (yyparse, yylex, yyerror): No longer declared here. Now + declared in parse.h. + (java_layout_classes): New function. + (java_complete_expand_methods): No longer layout the class here. + * parse-scan.y: New file. + * jv-scan.c: New file. + +1998-08-25 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (main): Handle -friend option. + (friend_specs): New global. + (generate_access): Handle friend_specs. + (process_file): Likewise. + (MAX_FRIENDS): New macro. + (friend_count): New global. + (print_cxx_classname): Added `prefix' argument. Ignore arrays. + Changed all callers. + +1998-08-24 Per Bothner <bothner@cygnus.com> + + * jcf-dump.c (process_class): Move JCF_FINISH use to main, + (main): Handle processing all the entries of a named .zip archive. + * jcf-io.c (jcf_trim_old_input): New function. + * jcf.h (GET_u2_le,GET_u4_le,JCF_readu2_le,JCF_readu4_le): New macros. + +1998-08-24 Per Bothner <bothner@cygnus.com> + + * lang.c (flag_assume_compiled): Make default be on. + +1998-08-21 Per Bothner <bothner@cygnus.com> + + * jcf-dump.c: Add bunches of flags to control output more. + (process_class): New function; support printing more than one class. + (main): Support new --print-main and --javap flags. + * jcf-reader.c (IGNORE_ATTRIBUTE): New hook. + * jcf.h (CPOOL_INDEX_IN_RANGE): New macro. + +1998-08-20 Per Bothner <bothner@cygnus.com> + + Change mangling of dispatch table to match C++ vtable (w/thunks). + * class.c (build_dtable_decl), java-tree.h: New function. + (make_class_data): Call it. + * decl.c (init_decl_processing): Likewise. + +1998-08-19 Warren Levy <warrenl@cygnus.com> + + * decl.c (init_decl_processing): Use _Jv_NewObjectArray, not + soft_anewarray; adjust args passed. + * expr.c (build_anewarray): Adjust args for soft_anewarray_node to + match _Jv_NewObjectArray. + +1998-08-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (push_labeled_block, pop_labeled_block): New functions. + * expr.c (loopup_label): Call create_label_decl. + (create_label_decl): New function. + (java_lang_expand_expr): Call expand_start_bindings with argument + set to zero. + * java-tree.h Added space after PROTO in function declarations + when necessary. + (IS_FOR_LOOP_P, IS_BREAK_STMT_P): New macros. + (create_label_decl, push_labeled_block): New function + declarations. + * lex.c (label_id): Initialize. + (SUPER_TK, THIS_TK, RETURN_TK): Merged common actions in final + switch. + * parse.h Added space after PROTO in function declarations when + necessary. + (LOOP_EXPR_BODY_MAIN_BLOCK, LOOP_EXPR_BODY_UPDATE_BLOCK, + LOOP_EXPR_BODY_CONDITION_EXPR, LOOP_EXPR_BODY_LABELED_BODY, + LOOP_EXPR_BODY_BODY_EXPR, LOOP_HAS_LABEL_P, LOOP_HAS_LABEL_SKIP_P, + PUSH_LABELED_BLOCK, POP_LABELED_BLOCK, PUSH_LOOP, POP_LOOP): New + macros. + (struct parser_ctxt): New fields current_loop, + current_labeled_block. + (build_if_else_statement, patch_if_else_statement, + add_stmt_to_compound, patch_exit_expr, build_labeled_block, + generate_labeled_block, complete_labeled_statement, + build_bc_statement, patch_bc_statement, patch_loop_statement, + build_new_loop, build_loop_body, complete_loop_body): New function + declarations. + * parse.y (java_warning_count): New global variable. + (label_id): New static variable. + (BREAK_TK, CONTINUE_TK): Token tagged <operator>. + (block:): Return size_zero_node when block is empty. + (empty_statement:): Return size_zero_node. + (statement:): Implement supplemental action when for_statement: is + reduced. + (label_decl:): New rule. + (labeled_statement:): Rewritten using label_decl. Actions + implemented. + (labeled_statement_nsi:): Likewise. + (if_then_statement): Actions implemented. + (while_expression): New rule. + (while_statement:): Rewritten using while_expression. Actions + implemented. + (while_statement_nsi:): Likewise. + (do_statement_begin:): New rule. + (do_statement:): Rewritten using do_statement_begin. Actions + implemented. + (for_statement:): Rewritten using for_begin. Actions implemented. + (for_statement_nsi:): Likewise. + (for_header:, for_begin:): New rules. + (for_init:): Actions implemented. + (statement_expression_list:, break_statement:, + continue_statement:): Likewise. + (yyerror): Count number of issued warning(s). + (java_report_errors): Report error(s) and/or warning(s). + (java_complete_class): Use build_java_argument_signature to + recompute completed method signature. + (java_check_regular_methods): New locals method_wfl and aflags. + Use method_wfl instead of lookup_cl during error reports. Fixed + indentation and modified some error messages. Use + lang_printable_name in method instead of the DECL_NAME. New code + to issue warnings on methods not overriding corresponding methods + private to a different package. + (java_method_add_stmt): Call add_stmt_to_compound. + (add_stmt_to_compound): New function. + (java_complete_tree): Handle LABELED_BLOCK_EXPR, EXIT_BLOCK_EXPR, + LOOP_EXPR, EXIT_EXPR and COND_EXPR. + (build_if_else_statement, patch_if_else_statement, + build_labeled_block, generate_labeled_block, + complete_labeled_statement, build_new_loop, build_loop_body, + complete_loop_body, patch_loop_statement, build_bc_statement, + patch_bc_statement, patch_exit_expr): New functions. + * typeck.c (build_java_signature): Build argument signature before + enclosing it in between parenthesis. + +1998-08-17 Warren Levy <warrenl@cygnus.com> + + * Make-lang.in (JAVA_SRCS): Created for dependencies * Makefile.in + (JAVA_OBJS): Added reminder comment + +1998-08-13 Nick Clifton <nickc@cygnus.com> + + * gjavah.c (D_NAN_MASK): Append LL to the constant to force it to + be interpreted as a long long. + +1998-08-13 Warren Levy <warrenl@cygnus.com> + + * decl.c (init_decl_processing): Use _Jv_InitClass, not + soft_initialise_class. Use _Jv_NewMultiArray, not + soft_multianewarray. Use _Jv_ThrowBadArrayIndex, not + soft_badarrayindex. Use _Jv_CheckCast, not soft_checkcast. Use + _Jv_CheckArrayStore, not soft_checkarraystore. Use + _Jv_LookupInterfaceMethod, not soft_lookupinterfacemethod. + +1998-08-12 Per Bothner <bothner@cygnus.com> + + * decl.c, java-tree.h (this_identifier_node, super_identifier_node, + length_identifier_node): New global tree node constants. + * parse.y (kw_super, kw_this, kw_length): Removed globals. + Replace uses by super_identifier_node etc. + * lex.c (kw_super, kw_this, kw_length): Don't initialize. + + * parse.y (resolve_field_access): Don't special-case ".length" if + flag_emit_class_files. + (patch_array_ref): Leave as ARRAY_REF if flag_emit_class_files. + * jcf-write.c (generate_bytecode_insns): Handle ARRAY_REF opcode + and ARRAY.length. + +1998-08-11 Per Bothner <bothner@cygnus.com> + + * decl.c (init_decl_processing): Remove unused method_type_node fields. + * class.c (make_method_value): Remove init for removed fields. + + * class.c (layout_class): Use build_java_argument_signature. + * java-tree.h (TYPE_ARGUMENT_SIGNATURE): New macro. + + * typeck.c (push_java_argument_signature): Removed. Merged into ... + (build_java_argument_signature): Use TYPE_ARGUMENT_SIGNATURE cache. + (build_java_signature): Don't use push_java_argument_signature. + + * typeck.c (lookup_argument_method): New function. + * parse.y (java_check_regular_methods): Use lookup_argument_method + instead of lookup_java_method2 followed by lookup_java_method. + + * parse.y (check_method_redefinition): Minor optimization. + + * jcf-write.c (generate_bytecode_insns): Handle RETURN_EXPR, + MINUS_EXPR, MULT_EXPR, TRUNC_DIV_EXPR, and RDIV_EXPR. + +1998-08-10 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (jc1$(exeext)): Don't depend on c-common.o or + c-pragma.o. + + * gjavah.c (java_float_finite): Use K&R-style definition. + (java_double_finite): Likewise. + (generate_access): Now returns void. Changed all callers. + (last_access_generated): Removed. + (process_file): Only make a single pass over the .class file. + +1998-07-29 Per Bothner <bothner@cygnus.com> + + * class.c (get_dispatch_table): Add extra dummy vtable entry, + for compatibility for G++ (with -fvtable-thunks). + * expr.c (build_invokevirtual): Add one for extra dummy vtable entry. + + * gjavah.c (process_file): Use public inheritance for super-class. + +1998-07-29 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (java_init_lex): Initialize ctxp->package. + * parse.h (struct parser_ctxt): package and package_len replaced + by tree package, an identifier node. Field method_decl_list is + gone. Fixed comments. + (lookup_field_wrapper, merge_qualified_name, not_accessible, + class_in_current_package): New function prototypes. + * parse.y (array_type:): Set class loaded flag on primitive type + arrays. + (package_declaration:): Assign ctxp->package to the + identifier node. + (method_invocation:): Handle invocation of method qualified by + `super'. + (single_type_import_declaration:): Removed ambiguity check. + (java_pop_parser_context): New local variable `next'. Reset and + set IMPORT_CLASSFILE_NAME flags on current and previous import + list. + (java_accstring_lookup): Use new local macro COPY_RETURN. + (lookup_field_wrapper): New function. + (parser_qualified_classname): Use merge_qualified_name. + (parser_check_super_interface): Broaden error message. + (do_resolve_class): Check for qualified class name in the current + compilation unit if appropriate. + (process_imports): Check for already defined classes. + (check_pkg_class_access): Got rid of call to + get_access_flags_from_decl. + (java_complete_expand_methods): Call safe_layout_class based on + the current class size. + (make_qualified_primary): Build a WFL qualification on primary if + none exists. + (merge_qualified_name): New function. + (make_qualified_name): Use merge_qualified_name. + (resolve_expression_name): Use safe_lookup_field. + (resolve_field_access): Got rid of call to get_access_flags_from_decl. + (resolve_qualified_expression_name): Likewise. Check on resolved + element accessibility. + (not_accessible_p, class_in_current_package): New functions. + (maybe_access_field): Got rid of call to get_access_flags_from_decl. + (patch_method_invocation_stmt): Merged common pieces. Check + accessibility of invoked method. + (check_for_static_method_reference): Add returned type in error + message. + (invocation_mode): Get rid of bogus check on PRIVATE methods. + (refine_accessible_methods_list): Merged two conditions in test. + (java_complete_class): Sanity check on stabilize_ref gone. + * zextract.c (read_zip_archive): Cast lseek second argument to long. + +1998-07-28 Per Bothner <bothner@cygnus.com> + + * class.c (hashUtf8String): Fix - use new JavaSoft specification. + +1998-07-24 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (F_NAN): Removed. + (F_NAN_MASK): New macro. + (F_POSITIVE_INFINITY): Removed. + (F_NEGATIVE_INFINITY): Likewise. + (java_float_finite): Rewrote. + (D_NAN_MASK): Renamed. + (java_double_finite): Rewrote. + (D_POSITIVE_INFINITY): Removed. + (D_NEGATIVE_INFINITY): Likewise. + + * jcf-dump.c (print_constant): [CONSTANT_Double, CONSTANT_Float] + If verbose, print underlying representation of value in hex. + +1998-07-24 Per Bothner <bothner@cygnus.com> + + * buffer.h, buffer.c: New files. + * Makefile.in (JAVA_OBJS): Add buffer.o. + + Support locals variables and writing their debug entries to .class. + * jcf-write.c: Simplify some by user new buffer type. + (vode_buffer_grow): Removed. + (struct localvar_info): New type. + (localsvars, localvartable): New buffers. + (localvar_alloc, localvar_free): New functions. + (generate_bytecode_insns): Handle local variables. + (generate_classfile): Write LocalVariableTable attribute. + +1998-07-24 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-io.c (open_in_zip): Check the zipfile magic number. + * zipfile.h (ZIPMAGIC): New macro. + +1998-07-24 Tom Tromey <tromey@cygnus.com> + + * Makefile.in (gjavah.o): Updated dependencies. + (jcf-dump.o): Likewise. + (all.indirect): Use ../gjavah. + (../gjavah$(exeext)): Likewise. + (clean): Don't remove gjavah. + (clean): Remove parse.c, not java/parse.c. + * Make-lang.in (java): Added gjavah. + (gjavah$(exeext)): New target. + (GJAVAH_SOURCES): New macro. + (java.all.build): Added gjavah. + (java.all.cross): Likewise. + (java.rest.encap): Likewise. + * config-lang.in (compilers, stagestuff): Added gjavah. + +1998-07-23 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (java_float_finite): New function. + (java_double_finite): Likewise. + (F_POSITIVE_INFINITY): New macro. + (F_NEGATIVE_INFINITY): Likewise. + (F_NAN): Likewise. + (D_POSITIVE_INFINITY): Likewise. + (D_NEGATIVE_INFINITY): Likewise. + (D_NAN): Likewise. + (print_field_info): Use java_float_finite and java_double_finite. + +1998-07-23 Per Bothner <bothner@cygnus.com> + + * parse.y (method_header): Name "this" implicit argument. + +1998-07-22 Per Bothner <bothner@cygnus.com> + + * jcf-write.c: Write out LineNumberTable attribute in .class file. + (linenumber_buffer, linenumber_ptr, linenumber_limit): New statics. + (put_linenumber): New function. + (generate_bytecode_insns, generate_classfile): Write line numbers. + +1998-07-22 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (CALL_EXPR_FROM_PRIMARY_P): Changed in PRIMARY_P. + (lookup_name, build_known_method_ref, build_class_init, + build_invokevirtual, invoke_build_dtable, match_java_method, + build_field_ref, pushdecl_force_head, build_java_binop, + binary_numeric_promotion, build_decl_no_layout, + build_java_arrayaccess, build_newarray, build_anewarray, + build_java_array_length_access, build_java_arraynull_check): New + extern function prototypes. + (JAVA_UNARY_PLUS_EXPR, JAVA_NEW_ARRAY_EXPR, JAVA_NEW_CLASS_EXPR, + JAVA_THIS_EXPR, CALL_CONSTRUCTOR_P): Macro definition moved in + java-tree.h. + * jcf-parse.c (init_outgoing_cpool): Set current_constant_pool_data_ref + to NULL + * jcf.h (jcf_out_of_synch): New extern function prototype. + * parse.h: Static/global function implemented in parse.y + prototyped and declarations moved at the end of the file. + (DECL_P): Check that the argument isn't null. + (JAVA_UNARY_PLUS_EXPR, JAVA_NEW_ARRAY_EXPR, JAVA_NEW_CLASS_EXPR, + JAVA_THIS_EXPR): No longer defined here. See java-tree.h + (QUAL_DECL_TYPE): New macro. + (PARAMS): Macro definition removed. + * parse.y: (yyparse, yyerror): Use PROTO instead of PARAMS. + (return_statement:): Call build_return. + (field_access:): Call make_qualified_primary in sub rule. + (method_invocation:): Build method invocation and call + make_qualified_primary when processing primaries. + (java_complete_class): Set IDENTIFIER_SIGNATURE_TYPE by calling + get_type_from_signature. + (java_check_regular_method): Extra integer 0 argument when calling + lookup_java_method2. + (lookup_java_interface_method2): Extra method DECL argument when + calling lookup_java_interface_method2. + (java_method_add_stmt): Set TREE_SIDE_EFFECTS on newly created + COMPOUND_EXPR node. + (java_complete_expand_method): Layout current class iff not + already done. Don't process interface's methods. + (java_complete_expand_method): Use super class only if it + exists. Use current class otherwise. + (make_qualified_primary): New function. + (resolve_expression_name): Process qualified expression or + expression from primary the same way. + (resolve_expression_name): Two last arguments to + resolve_field_access are now NULL_TREEs. + (resolve_field_access): New variable is_static. Local field must + be DECLs. is_static computed on field DECLs only. Append code in + where_found to the field access if necessary. Use QUAL_DECL_TYPE + to initialize field_type. + (resolve_qualified_expression_name): New local variable, + previous_call_static and is_static. Handle primaries with function + calls, casts, array references and `this'. `super' now handled as + `(super_class)this'. Use is_static to clarify boolean expressions. + Added code to handle case where a proper handle is required to + access a field. Use QUAL_DECL_TYPE where applicable. + (maybe_access_field): New function. + (patch_method_invocation_stmt): New arguments primary, where, + is_static. Branch of the test on CALL_EXPR_FROM_PRIMARY_P + deleted. Use `where' as a type to search from if specified. Check + for static method reference where forbidden. Append primary or + current_this to the argument list if not calling constructor nor + static methods. + (check_for_static_method_reference): New function. + (patch_invoke): Layout the class on which new is done if + necessary. + (lookup_method_invoke): Changed format to report errors on + methods. + (qualify_ambiguous_name): New local variable this_found. Now + handle things from primaries. Method call are considered + expression names. + (identical_subpath_p): NULL_TREE arguments to breakdown_qualified + changed into NULLs. + (not_initialized_as_it_should_p): Comply with the new DECL_P. + (java_complete_tree): New case fo RETURN_EXPR. Process function + call arguments in separate function. + (complete_function_arguments): New function. + (build_method_invocation): Don't use CALL_EXPR_FROM_PRIMARY_P + anymore. + (patch_assignment): Take the return function slot into account as + a RHS. Distinguish assignment from a return. + (valid_ref_assignconv_cast_p): Use build_java_argument_signature + when checking methods in interfaces. + (resolve_type_during_patch): NULL argument to unresolve_type_p + instead of NULL_TREE. + (patch_newarray): Fixed typo in comment. + (buid_this): Build a WFL with `kw_this' instead of a FIELD_DECL. + (build_return, patch_return): New functions. + * typeck.c (lookup_java_constructor): Fixed typo in comment. + +1998-07-21 Per Bothner <bothner@cygnus.com> + + * constants.c (find_name_and_type_constant, find_fieldref_index, + find_methodref_index): New methods. + * expr.c (build_invoke_non_interface): If flag_emit_class_files, + just return given method. Also, rename to build_known_method_ref. + (expand_invoke): Rename call to build_invoke_non_interface. + * java-tree.h, parse.h: Update prototype. + * parse.y, decl.c, jcf-parse.c: Suppress calls to back-end functions + (such as expand_expr_stmt) if flag_emit_class_files. + * jcf-write.c (RESERVE, OP1, OP2, OP4, NOTE_PUSH, NOTE_POP, + STACK_TARGET, IGNORE_TARGET): New macros. + (code_buffer, code_ptr, code_limit, code_S, code_SP_max): New globals. + (generate_bytecode_insn): New function to generate method's bytecode. + (generate_classfile): Node generate Code attribute for a method. + (code_buffer_grow, push_constant1, push_constant2, push_int_const, + push_long_const, field_op, adjust_typed_op, maybe_wide): + New functions used by generate_bytecode_insn. + + * typeck.c (signature_include_return): Remove variable. + (push_java_argument_signature, build_java_argument_signature): New. + (build_java_signature): Use push_java_argument_signature. + * parse.y: Use build_java_argument_signature instead of fiddling + with signature_include_return. + +1998-07-17 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_c_decl): Always generate JArray<>* for array + types. + + * Makefile.in (all.indirect): Added gjavah$(exeext). + (gjavah$(exeext)): Added $(exeext). + (clean): Likewise. + +1998-07-16 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (layout_class): Call to java_layout_parsed_class replace + by safe_layout_class. + * expr.c (build_java_array_length_access): Removed static storage + class in the function definition. + (build_java_arraynull_check): Likewise. + Also fixed typos in two comments. + * lex.c (java_init_lex): Initialize static global kw_length. + (java_lex): Use BUILD_OPERATOR on RETURN_TK. + * lex.h (JAVA_FLOAT_RANGE_ERROR): Add extra argument to + java_lex_error. + (JAVA_INTEGRAL_RANGE_ERROR): Likewise. + * parse.h (resolve_no_layout): New static function declaration. + (get_identifier_in_static): Declaration removed. + (java_layout_parsed_class): Function name declaration changed to + safe_layout_class. + (build_newarray_node, patch_newarray, resolve_type_during_patch, + not_initialized_as_it_should_p, build_this): New static function + declarations. + (pushdecl_force_head, build_java_binop, int_fits_type_p, + binary_numeric_promotion, stabilize_reference, + build_decl_no_layout, build_java_arrayaccess): Extern function + declarations moved into their own section. + (build_newarray, build_anewarray, build_java_array_length_access, + build_java_arraynull_check): New extern function declarations. + (UNARY_PLUS_EXPR): Macro renamed into JAVA_UNARY_PLUS_EXPR. + (JAVA_NEW_ARRAY_EXPR, JAVA_NEW_CLASS_EXPR, JAVA_THIS_EXPR): New + fake tree codes. + (CALL_CONSTRUCTOR_P): New macro. + * parse.y (kw_length): New static global tree node. + (return_statement): Tagged <node>. + (RETURN_TK): Tagged <operator>. + (variable_declarator_id:): Build variable declaration with an + empty initialization value if a syntax error was found in the + initialization part of the variable declaration. + (statement_without_trailing_substatement:): return_statement: now + uses the default rule. + (return_statement:): Temporarily fixed to return NULL_TREE. + (primary_no_new_array:): Call build_this when THIS_TK was parsed. + (class_instance_creation_expression:): Class creation rules now + call build_method_invocation upon reduction. + (array_creation_expression:): Rules call build_newarray_node upon + reduction. + (dim_exprs:): Build a list of dimension expressions. + (dim_expr:): Store location of the OSB_TK in the dimension + expression node. + (method_invocation:): Added a new error rule. + (build_unresolved_array_type): WFL argument may also be an array + on a primitive type. Name of the argument changed to reflect this. + (method_declarator): Insert argument type at the beginning of the + argument type list and later reverse the list. + (unresolved_type_p): Argument 'returned' may be optionally + NULL_TREE. + (java_layout_class_from_source): Function renamed + safe_layout_class. + (resolve_and_layout): Now call resolve_no_layout and + safe_layout_class. + (resolve_no_layout): New function. + (purify_type_name): New function. + (complete_class_report_errors): Call purify_type_name during error + report on a type not found. + (process_imports): error_found local variable doesn't need to be + initialized to zero. + (declare_local_variables): New local type_wfl. Fixed typo in error + message. type_wfl assigned to unresolved type and used to register + incomplete type. Build a WFL around the variable initialization + statement so that debug info can be generated on it. + (source_start_java_method): Reverse argument list after they've + been processed. + (current_this): New static global variable. + (java_complete_expand_methods): Set current_this when appropriate. + (resolve_expression_name): Build correct static and non static + field access bearing a simple name. + (resolve_field_access): Resolve the length field of arrays. Handle + f.m() cases. + (patch_method_invocation_stmt): Set the type of the method + invocation to error_mark_node. This value is later overridden by a + valid type, if any. Don't handle qualified constructor invocation + as qualified method invocation. Call lookup_method_invoke with its + new flag. It's no longer necessary to access the selected method + as the value of a tree list. Handle constructor invocation. + (patch_invoke): Reverse argument list when invoking non interface + methods. Insert call to new as the first argument of the + constructor. + (invocation_mode): Return a INVOKE_STATIC is the invoked method is + defined within a final class. Return INVOKE_STATIC if the invoked + method is a constructor. + (lookup_method_invoke): New lc argument is a flag to indicate a + constructor lookup. Now handle constructor lookup. Choose the most + specific method in case several were matching the invocation + requirements. Return a method decl instead of a tree list featuring + one single method decl element. + (refine_accessible_methods_list): New lc flag argument to + indicate that a constructor is being looked up. + (not_initialized_as_it_should_p): New function. + (java_complete_tree): Now process fake tree codes + JAVA_NEW_ARRAY_EXPR, JAVA_NEW_CLASS_EXPR and JAVA_THIS_EXPR. Call + save_expr on resolved function call arguments. Case on + UNARY_PLUS_EXPR changed into a case on JAVA_UNARY_PLUS_EXPR. + (patch_assignment): LHS can be a field access expression. When + dealing with reference, lhs_type is the promoted type of the + rhs_type, not the RHS. Use not_initialized_as_it_should_p where + applicable. + (operator_string): JAVA_UNARY_PLUS_EXPR replaces UNARY_PLUS_EXPR. + (patch_binop): Use not_initialized_as_it_should_p where + applicable. + (build_unaryop): JAVA_UNARY_PLUS_EXPR replaces UNARY_PLUS_EXPR. + (patch_unaryop): Likewise. And use not_initialized_as_it_should_p + where applicable. + (resolve_type_during_patch): New function. + (patch_cast): Call resolve_type_during_patch to resolve type and + report error accordingly. + (patch_array_ref): Use not_initialized_as_it_should_p where + applicable. Array base expression is saved before being + used. Promote the type of an array elements if it contains non + builtin types. + (build_newarray_node, patch_newarray, build_this): New functions. + +1998-07-16 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_c_decl): UTF8_GET increments pointer; don't + increment it in `for' statement. + (print_field_info): If number is inf or nan, don't print it. + (print_method_info): If method name is `delete', just ignore it. + (print_c_decl): Special-case jstringArray. + + * gjavah.c (help): New function. + (no_argument): New function. + (usage): Changed text. + (main): Rewrote argument handling. Now handles -v, --help, + --version. + (version): New function. + (found_error): New global. + (main): Return found_error. + (generate_access): Set found_error. + (print_c_decl): Likewise. + +1998-07-15 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_c_decl): Don't print "," when examining field. + Skip type name when looking at "[L" types. + (process_file): Now static. + (generate_access): Now returns int. + (last_access_generated): New global. + (process_file): Clear last_access_generated; make multiple passes + over the class. + (print_field_info): Just return if generate_access returns true. + (print_method_info): Likewise. Also, allow <init> functions to + pass through. + (print_c_decl): Added is_init argument. Print constructors + properly. + (print_cxx_classname): Use UTF8_GET to extract characters from + string. + (print_base_classname): New function. + (print_class_decls): New function. + (process_file): Use it. + (utf8_cmp): New function. + +1998-07-13 Nick Clifton <nickc@cygnus.com> + + * lang-options.h: Format changed to match changes in gcc/toplev.c + to implement a --help option. + +1998-07-10 Brendan Kehoe <brendan@cygnus.com> + + * decl.c (init_decl_processing): Revert change to dtable_type. + +1998-07-09 Per Bothner <bothner@cygnus.com> + + * java-tree.h (CLASS_P): Changed DECL_LANG_FLAG_7 -> TYPE_LANG_FLAG_4. + +1998-07-08 Brendan Kehoe <brendan@cygnus.com> + + * decl.c (init_decl_processing): Set CLASS_LOADED_P on dtable_type. + + * lang.c (lang_init): Default flag_exceptions to 1, without + checking to see if it's 2 first. + +1998-07-08 Jeffrey A Law (law@cygnus.com) + + * constants.c: Include "system.h". + * decl.c: Likewise. + * lang.c (flag_new_exceptions): Get via extern now. + (lang_init_options): New functions. Turn on flag_new_exceptions. + +1998-07-07 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * lex.c (java_lex): Return 0 when we see an invalid character in + the input. + + * lex.c (java_read_char): Specify extra argument when calling + java_lex_error. + (java_read_unicode, java_parse_end_comment, + java_parse_escape_sequence): Likewise, + (java_lex): Specify extra argument when calling + java_lex_error. Test that IDs are beginning with a legal character + for IDs. Handle invalid characters with an error message and a + call to java_lex_error. + (java_lex_error): Adjust column position by new argument + `forward'. Issue an error even if in the middle of reporting an + other error. + +1998-07-07 Brendan Kehoe <brendan@cygnus.com> + + * jcf-io.c (find_class): Zero out BUFFER before we use it, since + we don't explicitly put a null pointer when we're copying it. + +1998-07-07 Tom Tromey <tromey@cygnus.com> + + * gjavah.c (print_cxx_classname): New function. + (super_class_name): Likewise. + (print_super_fields): Removed. + (in_super): Removed. + (print_field_info): Never generate #defines. + (print_c_decl): Changed generated types to match JNI. No longer + print class name before method name. + (print_method_info): Print "static" before static methods. + Print "virtual" before non-final methods. + (usage): Use exit(1), not exit(-1). + (main): Likewise. + (print_field_info): Use %.17g to print a double. + (last_access): New globals. + (process_file): Initialize last_access. + (usage): Now static. + (ACC_VISIBILITY): New define. + (generate_access): New function. + (print_field_info): Call it. + (print_method_info): Likewise. Also, generate information for all + methods, not just native methods. Return void. + (print_c_decl): Return void. + (print_field_info): Return void. + +1998-07-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Makefile.in (JAVABISONFLAGS): Specific flag for bison when + processing the jc1 grammar file. Prefix bison functions and + variables with java_. + (parse.c): Dependencies on parse.h and lex.h + * expr.c (build_java_arrayaccess): Function now global. + * java-tree.h: Comment reorganized to carry on previous + classification effort. + (RESOLVE_EXPRESSION_NAME_P, RESOLVE_PACKAGE_NAME_P, + RESOLVE_TYPE_NAME_P): New flags on WFLs. + * jcf-parse.c (parse_source_file): java_parse_source_file renamed + java_parse (new prefix java_ generated by bison). + (java_layout_parsed_class, java_register_parsed_class): Function + call removed. + (yyparse): Removed unnecessary call to init_outgoing_cpool. + * lex.c (static tree wfl_op): Variable deleted. + (java_init_lex): Initialize kw_super and kw_this. Initialize more + ctxp fields to NULL_TREE. + (java_lex): No longer create WFL for operators. Filename caching + mechanism deleted. Call BUILD_OPERATOR for `.', '(', '['. Strings + created as STRING_CST and later expanded. Removed extra argument + to BUILD_OPERATOR and BUILD_OPERATOR2. Build operators for THIS + and SUPER. + (build_wfl_node): Removed code in comments. + * lex.h (BUILD_OPERATOR, BUILD_OPERATOR2): No longer build a WFL but + store token and location data in the current bison token. + * parse.h: Removed pre-processor based symbol prefixes hack. Moved + static/extern function declaration at the beginning of the file. + (struct qualification): Data structure definition deleted. + (RESOLVE_CHAIN_REMAINDER): Macro definition deleted. + (qualify_ambiguous_name): Function declaration modified. Function + now returns nothing. + (build_array_ref, patch_array_ref, make_qualified_name, + resolve_qualified_expression_name, maybe_generate_clinit, + resolve_field_access): New static function declarations. + (build_java_arrayaccess): New extern function declaration. + (enum { RESOLVE_EXPRESION_NAME...}): Enum deleted. + (CALL_EXPR_PRIMARY): Macro deleted. + (EXPR_WFL_QUALIFICATION, QUAL_WFL, QUAL_RESOLUTION): New macros. + (struct parser_ctxt): Field initialized_final + removed. non_static_initialized, static_initialized: New fields. + * parse.y (static tree kw_super, static tree kw_this): New global + static. + (%union): tree wfl field of operator member replaced by int + location. WFLs are non longer created for operators. + (OSB_TK, DOT_TK, THIS_TK, SUPER_TK): Tagged <operator>. + (qualified_name:): Now calls make_qualified_name to build the + identifier. + (type_declaration:): Consider generating <clinit> when class + parsing completed. + (variable_declarator:): Directly build an assignment node when the + variable is initialized when declared. + (this_or_super:): Build a WFL and set current location when THIS + or SUPER are parsed. + (expression_statement:): Wrap statement around a WFL. + (primary_no_new_array:): Fixed typo. Changed value returned by + THIS_TK because of its new type (temporary). + (dim_exprs:): Temporary fix because of OSB_TK's new type. + (field_access:): Build qualified name with SUPER. + (method_invocation:): Fixed returned value because of SUPER's new + type. + (array_access:): Use OSB_TK location information. + (post_increment_expression:, post_decrement_expression:, + unary_expression:, pre_increment_expression:, + pre_decrement_expression:, unary_expression_not_plus_minus:, + cast_expression:, multiplicative_expression:, + additive_expression:, shift_expression:, relational_expression:, + equality_expression:, and_expression:, exclusive_or_expression:, + inclusive_or_expression:, conditional_and_expression:, + conditional_or_expression:, assignment:): Use new location/token + information available on operators. + (create_class): Set super_decl_type to NULL_TREE when processing + java.lang.Object. + (register_fields): Field initialization is now a MODIFY_EXPR + node. Chain initialization code to the matching lists (according + to the field declaration modifiers). + (maybe_generate_clinit): New function. + (method_header): Don't set method's DECL_NAME to a WFL when adding + methods to java.lang.Object. + (resolve_and_layout): Now can return NULL_TREE if the type + resolution fails. Otherwise, return the class DECL instead of its + TYPE. + (check_method_redefinition): Don't patch method DECL_NAME if it + belongs to java.lang.Object. + (process_imports): Simply assign error_found to the value returned + by check_pkg_class_access. + (declare_local_variables): Don't use their init statements (if + any) when parsing error were previously found. Reuse MODIFY_EXPR + build during parsing as an init statement. + (java_method_add_stmt): Now return the current method body. + (java_layout_parsed_class, java_register_parsed_class): Functions + removed. + (java_complete_expand_methods): Initialize the constant pool on a + per class basis. Layout the classes before expanding their method + bodies. Don't try expand artificial constructor code if error were + found. Make the classes data and register them if no error were + found. + (java_complete_expand_method): Retrieve an artificial constructor + argument list before entering its body. Assign the top block to + the artificial constructor function body and set types of declared + blocks and compound statements to void. Walk method body if not an + artificial constructor. + (make_qualified_name, cut_identifier_in_qualified): New functions. + (resolve_expression_name): Fixed comments. Save/restore the + current class CLASS_LOADED_P flag value. Build non qualified + static field access and handle qualified expression names. + (resolve_field_access, resolve_qualified_expression_name): New + functions. + (patch_method_invocation_stmt): Use the new expression resolution + scheme, calling resolve_field_access when the function call is + resolved as an expression. + (qualify_ambiguous_name): Function rewritten to work on qualified + expression produced by make_qualified_name. + (java_complete_tree): Promote type when function's argument are + RECORD_TYPEs. While processing the MODIFY_EXPR case: don't patch + the assignment to discover further errors if RHS is a expression + name that fails to evaluate. Declare LHS initialized even though + the assignment failed. Don't use the location variable and removed + extra argument in patch function calls. Now handle the ARRAY_REF + case and build internal string representation when STRING_CSTs are + walked. + (build_method_invocation): Don't wrap function call around a WFL. + (build_assignment): Likewise. Use the operator location + information. + (patch_assignment): Handle array access LHSs. Handle error + provenance, resulting in a better error report. + (build_binop): Use op_location from operator as binop location + information. + (build_unaryop, build_incdec, build_cast): Likewise. + (patch_binop): Extract location information from the node. Fixed + typo in error message. + (patch_unary_op): Extract location information from the node. + (build_array_ref, patch_array_ref): New functions. + +1998-07-01 Tom Tromey <tromey@cygnus.com> + + * expr.c (expand_java_INSTANCEOF): Changed calling convention to + match _Jv_IsInstanceOf. + * decl.c (init_decl_processing): Use _Jv_NewArray, not + soft_newarray. Use _Jv_IsInstanceOf, not soft_instanceof. + +1998-06-30 Tom Tromey <tromey@cygnus.com> + + * decl.c (init_decl_processing): Functions are now named + _Jv_MonitorEnter and _Jv_MonitorExit, and return jint. + +1998-06-29 Per Bothner <bothner@cygnus.com> + + * java-tree.h (load_class): Add prototype. + * class.c (is_compiled_class): Add missing arg to load_class. + * expr.c (expand_java_NEW): Call load_class. + * parse.y (process_import): Removed bogus use of void return value. + +1998-06-25 Per Bothner <bothner@cygnus.com> + + * decl.c, java-tree.h (soft_athrow_node): Renamed to soft_node. + Function name is "_Jv_Throw" instead of "soft_athrow". + * decl.c, java-tree.h (soft_new_node): Renamed to alloc_object_node. + Function name is "_Jv_AllocObject" instead of "soft_new". + Takes an extra parameter (object size). + * expr.c: Update calls. + +1998-06-24 Per Bothner <bothner@cygnus.com> + + * lex.c (java_get_line_col): Handle end-of-file. + * except.c (expand_end_java_handler): Handle null type (i.e. finally). + +1998-06-24 Andrew MacLeod <amacleod@cygnus.com> + + * lang.c (lang_init): Make -fexceptions the default. + * except.c (maybe_start_try, maybe_end_try): Don't do anything if + exception handling is not turned on. + +1998-06-23 Andrew MacLeod <amacleod@cygnus.com> + + * lang.c (flag_new_exceptions): Make this this default. + * decl.c (end_java_method): Call emit_handlers. + * except.c (method_init_exceptions): Set language code and version. + (expand_start_java_handler): Enable exception, and call + expand_eh_region_start. + (expand_end_java_handler): Enable exception, and set up catch blocks. + (emit_handlers): New routine to generate the saved handlers. + * java-except.h (emit_handlers): Add prototype. + +1998-06-12 Per Bothner <bothner@cygnus.com> + + We used to have three different representations of the constant pool: + the CPool structure, the tree_constant_pool, and the constructures + used to build the Class object (which may need class and string + constants) in compiled code. None were appropriate for compiling + to .class files, so I did a major overhaul. + + First, the tree_constant_pool array was removed. Things were + modified to the CPool structure in the JCF could be used. + Second, a "capacity" field was added to the CPool, and functions + written to search for a matching constant, adding one if not found. + The code that generated the Class object was changed to use a CPool. + The actual TREE_LISTs used to build the CONSTRUCTORs used for + the static Class object are now only in build_constants_constructor. + Finally, I wrote code which can generate a .class file (including its + constant pool) from the RECORD_TYPE of a class. This is a big step + on the way to compiling Java source into .class files. + + * jcf-write.c: New file. Writes out a RECORD_TYPE as a .class file. + * Makefile.in (JAVA_OBJS): Added jcf-write.o. + + * java-tree.h (CPOOL_UTF, CONSTANT_ResolvedFlag, + CONSTANT_ResolvedString, CONSTANT_ResolvedClass): New macros. + (NAME_AND_TYPE_NAME, NAME_AND_TYPE_SIGNATURE, COMPONENT_REF_NAME, + COMPONENT_REF_NAME_AND_TYPE, COMPONENT_REF_SIGNATURE): Redefined. + (COMPONENT_REF_CLASS): Replaced by COMPONENT_REF_CLASS_INDEX. + (lang_type): Removed constant_pool field. + * jcf.h (CPool): Renamed size to count. Added field capacity. + (CPOO_COUNT, CPOOL_UINT, CPOOL_USHORT1, CPOOL_USHORT2, + CPOOL_FINISH, CPOOL_INIT, CPOOL_REINIT): New macros. + Rewrite some of the old JCF_XXX in terms of CPOOL_XXX macros. + + * constants.c (current_constant_pool_tags, current_constant_pool_data, + current_constant_pool_length), java-tree.h: Replaced by outgoing_cpool. + * constants.c (build_constants_constructor): Use new outgoing_cpool. + (set_constant_entry, find_constant1, find_constant2, + find_class_constant, count_constant_pool_bytes, write_constant_pool, + find_utf8_constant, find_class_or_string_constant): New functions. + + * jcf-parse.c (load_class): Don't save/restore tree-constant_pool. + (get_constant): Use current_jcf.cpool instead of tree_constant_pool. + (give_name_to_class, get_class_constant): Likewise. + * jcf-parse.c, java-tree.h (tree_constant_pool): Removed. + (get_name_and_type_constant, get_ref_constant): Removed. + * parse.h (parser_ctxt): Remove field tree_constant_pool. + * parse.y: Don't save/restore tree_constant_pool. + * verify.c (verify_jvm_instructions): Update for new approach. + * expr.c (expand_invoke, expand_java_field_op): Likewise. + + * lang-options.h: Added -femit-class-file, -femit-class-files. + * lang.c (flag_emit_class_files), java-tree.h: New flag. + (lang_f_options): Added "emit-class-file(s)". + + * expr.c (build_java_arrayaccess): Generate more efficient array + bounds checking, by using unsigned compare. + + * expr.c (expand_invoke): Re-arrange error checks to make more robust. + +1998-06-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.h: New comment on the handling of unresolved type + identifiers. JDEPs are now part of the jdep_code enum. + (typedef struct jdep): Now use enum jdep_code or int, depending on + availability. Both are narrowed down to an 8 bits bitfield. + (CALL_EXPR_PRIMARY): Fixed comment. + +1998-06-10 Tom Tromey <tromey@cygnus.com> + + * Make-lang.in (java): Added gjavac and jvgenmain. + (java.start.encap): Depend on gjavac. + (java.rest.encap): Depend on jvgenmain. + + * Make-lang.in (JAVA_INSTALL_NAME): Name is gjavac, not c++. + (JAVA_CROSS_NAME): Likewise. + (java.all.build): Depend on jvgenmain and gjavac. + (java.all.cross): Depend on jvgenmain and gjavac-cross. + (jvgenmain$(exeext)): New target. + (java.install-common): Wrote. + * config-lang.in (compilers, stagestuff): Added gjavac and + jvgenmain. + +1998-06-10 Dave Brolley <brolley@cygnus.com> + + * lang.c (lang_decode_option): New argc/argv interface. + +1998-06-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * ChangeLog: Fixed entries not compliant with the Gnu Coding Standard. + * decl.c (build_decl_no_layout): New function. + * expr.c (java_lang_expand_expr): Layout declarations found in + blocks before they're pushed. + * jcf-parse.c (load_class): Save current line when parsing class + file. + (parse_source_file): Register class before expanding their + methods. + * lang.c (put_decl_node): Produce `null' when `void *' is + processed. + * lex.c (static tree wfl_op): New static global, for error report + on casts. + (java_init_lex): wfl_operator and wfl_op initialized + here. Filename caching added for wfl_op. Return wfl_op when `(' is + parsed. + * parse.h (build_unaryop, build_incdec, patch_unaryop, build_cast, + patch_cast, valid_ref_assignconv_cast_p, can_cast_to_p, + build_unresolved_array_type): New static function definitions. + (build_decl_no_layout): New extern function declared. + (OBSOLETE_MODIFIER_WARNING): Report error only if the WFL of the + faulty modifier exists. + (TYPE_INTERFACE_P, TYPE_CLASS_P): New macros. + (ERROR_CAST_NEEDED_TO_INTEGRAL): Error message tuned. + (UNARY_PLUS_EXPR): New fake operator. + (struct parser_ctxt): New field osb_number. + * parse.y (static tree wfl_operator): New static WFL for operator + bound error messages. + (DECR_TK, INCR_TK): Moved. + (OP_TK): Tagged <operator>. + (array_type:): Now call build_unresolved_array_type. + (dim_expr:): Count the number of '[' seen. + (post_increment_expression, post_decrement_expression, + pre_increment_expression, pre_decrement_expression, + unary_expression_not_plus_minus, unary_expression:): Actions are + now building the corresponding unary expressions. + (cast_expression:): Actions are now building cast expressions. + (build_unresolved_array_type): New function. + (create_interface): Reset the number of declared interfaces. + (create_class): Likewise. + (method_header): Methods declared within the scope of an interface + are now implicitly set public and abstract. + (java_complete_class): Variable's and parameter's type are patched + with a promoted type. + (declare_local_variables): Resolved non builtin types are promoted + before being used to build a variable decl. Removed type patch + posted on variable initialization statement. + (source_start_java_method): Use build_decl_no_layout to build the + decl of a parameter of incomplete type. + (java_register_parsed_class): Process interfaces too. Call + rest_of_decl_compilation on each processed class declarations. + (java_complete_expand_methods): Don't attempt to expand things in + interfaces. + (java_complete_tree): Process CONVERT_EXPR, even though it always + has a type. Propagate error_mark_node to node's type too. Promote + method's call argument type and return error_mark_node if + argument's completion didn't work. MODIFY_EXPR can have a WFL as a + RHS. Fixed bug in the handling of bogus RHS of a fixed type. Now + handle unary operator nodes. + (build_assignment): Added comment. + (print_int_node): New function. + (patch_assignment): New second argument. New error handling. Use + print_int_node. Handle references. Use can_cast_to_p to issue + different error message according to the context and check upon + the initialization of the RHS. + (can_cast_to_p, valid_ref_assignconv_cast_p): New functions. + (operator_string): Handle more operators. + (patch_binop): No longer use a function static + wfl_operator. Improved error message on shift distance. + (build_unaryop, build_incdec, build_cast, patch_unaryop, + patch_cast): New functions. + +1998-06-05 Per Bothner <bothner@cygnus.com> + + * jvspec.c: New file. + * Make-lang.in: New rules to build gjavac from jvspec.c and ../gcc.c. + + * java-tree.h (identifier_subst): Add declaration. + +1998-06-04 Tom Tromey <tromey@cygnus.com> + + * jvgenmain.c (main): Generate call to JvRunMain. + + * class.c (make_class_data): Push value for "sync_info" field. + * decl.c (init_decl_processing): Push "sync_info" field. + +1998-06-03 Per Bothner <bothner@cygnus.com> + + * typeck.c (build_java_array_type): Set TYPE_NAME to actual + Java (source) name, not signature. + Set TYPE_ALIGN to (at least) that of element_type. + +1998-06-02 Per Bothner <bothner@cygnus.com> + + * class.c: Moved classname-mangling-rekated code to ... + * mangle.c: ... this new file. + * jvgenmain.c: New program (needs mangle.c) to generate main program. + * Makefile.in: Update for above changes. + +1998-06-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (truthvalue_conversion): Convert integer and floating + point value to their truth value. + * lex.c (java_lex): Handle the `null' literal. + * parse.h (JREFERENCE_TYPE_P, DECL_P): New macros. + (ERROR_CANT_CONVERT_TO_BOOLEAN, ERROR_CANT_CONVERT_TO_NUMERIC, + ERROR_CAST_NEEDED_TO_INTEGRAL, ERROR_VARIABLE_NOT_INITIALIZED): + New macros. + + * parse.y: Reorganization/documentation on token declaration. + (binop_lookup[]): New added new tree codes. + (relational_expression): Build corresponding binary operators. + (equality_expression, conditional_and_expression, + conditional_or_expression): Likewise. + (java_complete_class): Fix crash in debug message. + (java_complete_tree): Check initialization of method call + arguments. Further bogus node evaluation to detect more error + during assignments. Handles more binary operators. + (patch_assignment): Use DECL_P. + (build_binop): Fix crash when using URSHIFT_EXPR, a Java only tree + code. + (operator_string): Handle more case. Compacted source. + (patch_binop): Changed function comment. Checking for + uninitialized first operand takes the compound assignment into + account and uses DECL_P. Checking for uninitialized second operand + delayed to routine's end. Use macros to issue type bound error + messages and issue messages on both operands if their types are + different. Force fixed type into node. Handle all binary + operators. + +1998-05-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * java-tree.h (COMPOUND_ASSIGN_P, INITIALIZED_P): New macros. + * lex.c (java_lex): Use BUILD_OPERATOR and BUILD_OPERATOR2 to + build operator node and return tokens. + * lex.h (BUILD_OPERATOR, BUILD_OPERATOR2): New macros. + * parse.h (java_complete_tree): Changed returned type in prototype. + (build_method_invocation, build_assignment, patch_assignment, + patch_binop): New static function declarations. + (JFLOAT_TYPE_P, JNUMERIC_TYPE_P, JPRIMITIVE_TYPE_P, JSTRING_P, + BUILD_EXPR_WFL): New macros. + * parse.y (enum tree_code binop_lookup[]): New static for token to + TREE_CODE lookup. + (%union): Parser union has new sub-structure `operator'. + (ASSIGN_TK, MULT_ASSIGN_TK, DIV_ASSIGN_TK, REM_ASSIGN_TK, + PLUS_ASSIGN_TK, MINUS_ASSIGN_TK, LS_ASSIGN_TK, SRS_ASSIGN_TK, + ZRS_ASSIGN_TK, AND_ASSIGN_TK, XOR_ASSIGN_TK, OR_ASSIGN_TK, + ASSIGN_ANY_TK): Tokens tagged `operator'. + (EQ_TK, GTE_TK, ZRS_TK, SRS_TK, GT_TK, LTE_TK, LS_TK, BOOL_AND_TK, + AND_TK, BOOL_OR_TK, OR_TK, INCR_TK, PLUS_TK, DECR_TK, MINUS_TK, + MULT_TK, DIV_TK, XOR_TK, REM_TK, NEQ_TK, NEG_TK, REL_QM_TK, + REL_CL_TK, NOT_TK, LT_TK): Tokens tagged `operator'. + (assignment_operator:): Rule tagged `operator'. + (expression_statement:): Re-installed default rule. + (method_invocation:): Sub rules call build_method_invocation. + (postfix_expression:): Don't attempt to resolve name here. Just + return an ID. + (multiplicative_expression:): Sub-rules build corresponding binop + expression node. + (additive_expression:, shift_expression:, and_expression:, + exclusive_or_expression:, inclusive_or_expression:): Likewise. + (assignment:): Sub rule invoke build_assignment. + (assignment_operator:): Default rules on sub rules. + (force_error): Added documentation on this variable. + (declare_local_variables): Build initialization calling + build_assignment. + (expand_start_java_method): Removed unused rtx declaration. Mark + arguments as already initialized. + (java_method_add_stmt): Type of built COMPOUND_EXPR set to NULL. + (java_complete_expand_methods): Don't process next method if + completion of the previous one triggered errors. + (java_complete_expand_method): Call source_end_java_method if no + error were found during completion. + (resolve_expression_name): Use IDENTIFIER_LOCAL_VALUE to retrieve + locals declaratilon. Handle names found within a class. Return + error_mark_node when things aren't found. + (patch_method_invocation_stmt): Return error_mark_node on failures. + (patch_invoke): Removed unused local. Return the correct node. + (java_complete_tree): Now returns a value. The BLOCK section binds + local identifiers and the type of a BLOCK is now void. Assign the + result of operand completion on COMPOUND_EXPR. Assign the + encapsulated node of a WFL to the result of its completion, except + when the node is an identifier. Now handle MODIFY_EXPR and several + binary operators. Return error_mark_node on errors. + (build_method_invocation, build_assignment, patch_assignment, + build_binop, operator_string, patch_binop): New functions. + * typeck.c (binary_numeric_promotion): New function. + +1998-05-21 Per Bothner <bothner@cygnus.com> + + * class.c (identifier_subst): New convenience wrapper for ident_subst. + Replace most uses of ident_subst by identifier_subst. + + * class.c (push_class_static_dummy_field): Removed function. + (build_class_ref): Find Class object decl by looking up "CNAME.class", + instead of looking got "class" static field. Create that decl here. + (class_identifier_node): Removed; no longer needed. + (init_class_processing): Don't init class_identifier_node. + * jcf-parse.c (jcf_parse): Don't call push_class_static_dummy_field. + Do nreverse 0 times (instead of twice) for Object and Class. + * parse.y (java_layout_parsed_class): No push_class_static_dummy_field. + +1998-05-20 Per Bothner <bothner@cygnus.com> + + * jcf-parse.c (parse_class-file): Set lino to smallest line number, + while initializing linenumber_count and linenumber_table. + Do it before init_function_start (which calls emit_line_note). + * expr.c (expand_byte_code): Don't need to clear lineno here. + +1998-05-18 Tom Tromey <tromey@cygnus.com> + + * class.c (append_gpp_mangled_type): If `qualifications' is >=9, + then mangle number as _N_. + + * class.c (mangle_class_field): New function. + (build_class_ref): Set assembler name of class reference using + mangle_class_field. + (push_class_static_dummy_field): Likewise. + +1998-05-17 Michael Tiemann <tiemann@cygnus.com> + + * parse.y (source_start_java_method): Use TREE_SET_CODE instead + of assigning to TREE_CODE. The latter method exploits a feature + of GCC that is not ANSI compliant. + +1998-05-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (pushdecl_force_head): New function. + (pushlevel): Removed conditional printf. + (complete_start_java_method): Don't enter local variable scope if + function is compiled from source code. + * expr.c: parse.h now included + (java_lang_expand_expr): New function. + * jcf-io.c (find_class): Use SOURCE_FRONTEND_DEBUG instead of + printf. Terminate buffer when doing directories. + * jcf-parse.c (parse_source_file): Call lang_init_source before + parsing and before code generation. + * jcf.h (SOURCE_FRONTEND_DEBUG): Macro redefined to conditionally + use printf if the macro is defined. + * lang.c (lang_init): Install lang_expand_expr hook on + java_lang_expand_expr. + (java_dummy_print): New function. + (lang_init_source): New function. + * lex.c (java_lex): Remember location of an opening brace at the + second nesting level. + (java_is_eol): Unget character seen after a CR if it is EOF. + * parse.h: Now includes lex.h + (SOURCE_FRONTEND_DEBUG): Macro redefined to conditionally use + printf if the macro is defined. + (expand_start_java_method, build_expr_block, enter_block, + exit_block, lookup_name_in_blocks, maybe_absorb_scoping_blocks): + New static function declarations. + (pushdecl_force_head): New extern function declaration. + (INCOMPLETE_TYPE_P): New macro. + (JDEP_PARM, JDEP_TYPE): New entries in JDEPs enum. + (BLOCK_CHAIN_DECL, BLOCK_EXPR_DECLS, BLOCK_EXPR_BODY, + BLOCK_EXPR_ORIGIN): New macros. + (DECL_SOURCE_LINE_MERGE, DECL_SOURCE_LINE_FIRST, + DECL_SOURCE_LINE_LAST): New macros. + (struct parser_ctxt): Removed field current_method_decl, redundant + with the field current_function_decl. Added fields + first_ccb_indent1 and pending_block. + * parse.y (method_body, literal, INT_LIT_TK, FP_LIT_TK, + BOOL_LIT_TK, CHAR_LIT_TK, STRING_LIT_TK, NULL_TK, VOID_TK): Rules + tagged <node> + (SOURCE_FRONTEND_DEBUG): Used as macro accepting varargs. + (compilation_unit:): Cosmetic on sub rule. + (type_declaration:): Cosmetic on sub rules. Added an error rule. + (variable_initializer:): Installed default rule on expression:. + (method_declaration:): method_header: starts a new + method. method_body: installs the function body, absorbs blocks + emitted for temporary variable scopings, pops function's body block + and merges function's last statement lineno in DECL_SOURCE_LINE. + (method_body:): Installed default rules. + (block:): Call enter_block when an opening brace is seen. Absorb + scoping blocks and call exit_block when a closing brace is seen. + (block_statement:): Cosmetic changes. + (method_invocation:): Create WFL around CALL_EXPR node. + (patch_stage): Added comment around definition. + (method_header): Try to use first_ccb_indent1 as the first line of + the method, so BP debug info are emitted at the first opening + brace of the function. If the function has no body, use the + location of the function's name. Override currently defined method + name with the matching WFL so we can point redefinition errors + using the location where the function's name was declared. + (check_abstract_method_header): Interprets DECL_NAME as an + identifier or as a WFL, accordingly. + (java_complete_class): New cases for JDEP_TYPE and JDEP_PARM. + (check_method_redefinition): Use DECL_NAME as a WFL. Extract + location and name information out of it and reinstall DECL_NAME to + its original identifier node value. + (lookup_cl): Use DECL_SOURCE_LINE_FIRST (first line of the + function's source code). + (read_import_dir): Test the value returned by find_class and issue + a fatal accordingly. + (declare_local_variables): Push a new block for the scope of the + new variable(s) if code has been already generated at that nesting + level. Pinpoint redefinition errors using the variable id + WFLs. Generate initialization code if necessary. If the variable + type is incomplete, register a patch on its decl. + (source_start_java_method): Rewritten. Define a new block for the + function's parameters. Build parameter decl out of function's + arguments and register them for a patch if their types are + incomplete. + (expand_start_java_method): Includes the part of + source_start_java_method that was pushing the parameter decls and + completing the method start code. + (source_end_java_method): Removed call the expand_end_bindings and + poplevel (already taken care of). Reinstall function's arguments + and get function's last line of code before calling + expand_function_end. + (java_method_add_stmt): New comment before the function's + code. Complement the second operand of the current COMPOUND_EXPR + if necessary. + (java_complete_expand_methods): Don't generate debug info on line + zero when expanding a generated constructor. + (java_complete_expand_method): Set start and end line numbers for + a artificially generated constructor to one and manually call + enter_block and exit_block when defining it. For all methods: + expand function's start calling the new expand_start_java_method + and invoke java_complete_tree on the effective method's body, if + any. + (resolve_expression_name): Now use lookup_name_in_blocks to search + local variable decls and print out an error when variables are + undefined. + (patch_method_invocation_stmt): Inserted comment before the + function's code. + (lookup_method_invoke): Chain method's arguments using chainon + with the current arg list as a second argument. Inserted missing + IDENTIFIER_POINTER when reporting an error on methods not found. + (refine_accessible_methods_list): Don't retain constructors. + (patch_arguments): Function removed. + (java_complete_tree): Inserted comment before the function's + code. New case for BLOCKs. Moved the WFL case a bit + further. Complete function's arguments. + (build_expr_block, enter_block, exit_block, lookup_name_in_blocks, + maybe_absorb_scoping_blocks): New functions. + +1998-04-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-io.c (find_class): Reset jcf->java_source after JCF_ZERO, if + previously set. + * jcf-parse.c (parse_source_file, java_error_count): New forward + and extern declarations. + (java_parse_abort_on_error): Macro moved. + (jcf_parse_source): fatal called if fopen fails. Now calls + parse_source_file. + (parse_source_file): New parse_only parameter. Reflects the + elimination of the second pass. + (yyparse): parse_source_file called with argument set to 0. + * jcf.h (JCF_ZERO): Sets java_source to zero. + * lex.c (java_init_lex): pass argument is gone. Function modified + to be called once during the analysis of a file. + (java_unget_unicode): Fixed typo in fatal message. + (java_get_line_col): Likewise. + (java_lval): Likewise. String literals no longer built during + second pass. + * lex.h (JAVA_COLUMN_DELTA): Take the tabulation character into + account. + * parse.h (MODIFIER_WFL): New macro. + (parse_check_super, parser_check_super_interface): Now return int. + (parser_chain_incomplete_item, not_builtin_p, + complete_method_decl): Declarations removed. + (build_method_invocation_stmt, build_invoke): Renamed using the + `patch' instead of `build' + (register-incomplete_type, obtain_incomplete_type, + java_complete_tree, java_complete_expand_method, + unresolved_type_p, create_jdep_list): New function declarations. + (IC_TYPE, IC_DEPEND, DEPEND_DECL, DEPEND_WFL, BEGIN_ONLY_PASS, + END_ONLY_PASS, ELSE_ONLY_PASS): Macro deleted. + (jdep): New typedef on new struct _jdep. + (JDEP_DECL, JDEP_DECL_WFL, JDEP_KIND, JDEP_SOLV, JDEP_WFL, + JDEP_MISC, JDEP_APPLY_PATCH, JDEP_GET_PATCH, JDEP_CHAIN, + JDEP_TO_REVOLVE, JDEP_RESOLVED_DECL, JDEP_RESOLVED, + JDEP_RESOLVED_P): New macros. + (JDEP_NO_PATCH, JDEP_SUPER, JDEP_FIELD, JDEP_METHOD, + JDEP_METHOD_RETURN, JDEP_METHOD_END, JDEP_INTERFACE, + JDEP_VARIABLE): New enum values and jdep kinds. + (jdeplist): New typedef on struct _jdeplist. + (CLASSD_FIRST, CLASSD_LAST, CLASSD_CHAIN, JDEP_INSERT): New + macros. + (CALL_EXPR_PRIMARY): New macro. + (struct parser_ctxt): Fields java_pass, current_method_decl, + method_decl_list deleted. New field jdeplist. + (INCOMPLETE_P): Macro deleted. + * parse.y (single_type_import_declaration:): Removed pass switch. + (type_import_on_demand_declaration): Likewise. + (field_declaration:): Removed pass switch on all sub rules. + (class_declaration:): Call the complete_class_decl removed on + class_body rules. + (method_declaration:): Removed second pass switch. No longer chain + methods decl when method_header reduced. + (method_header:): Sub rules no longer depend on pass switch. + (method_declarator:): Likewise. + (method_body:): Likewise. + (abstract_method_declaration:): Likewise. + (block_statement:): Likewise. + (local_variable_declaration:): Likewise. + (argument_list:): Likewise. + (method_invocation:): Likewise. Call to build_method_invocation_stmt + removed. Partial CLASS_EXPR tree node built instead. + (postfix_expression:): Removed pass switch on all sub rules. + (java_pop_parser_context): Free classd_list content. + (yyerror): Call obstrack_grow0 to finalize error message. + (check_class_interface_creation): Comment modified to reflect new + returned value meaning. Removed second pass switch. Return 1 if an + error was found, 0 otherwise. Adjust pointer on filename if a + leading path separator was found. + (maybe_create_class_interface_decl): Removed first pass switch + when linking the class decl to the class_list. Install a new + jdep_list for the class. + (add_superinterfaces): List of unresolved interfaces is + gone. Unresolved interfaces are directly added to the current + dependencies list. + (create_interface): Second pass shortcut removed. + ctpx->modifier_ctx access through MODIFIER_WFL. + (create_class): Second pass shortcut removed. Call to + register_incomplete_type replaces the call to + parser_chain_incomplete_item. + (complete_class_decl): Function removed. + (duplicate_declaration_error): New way of retrieving redeclared + item type. + (register_fields): Call to lookup_modifier_cl replaced by + MODIFIER_WFL. New way of handling unresolved type, using + unresolved_type_p and obtain_incomplete_type. + register_incomplete_type replaces call to parser_chain_incomplete_item. + (patch_stage): New static global variable. + (method_header): New way of handling unresolved type, using + unresolved_type_p and obtain_incomplete_type. patch_stage used to + indicates that the method decl needs to be patched. + (check_abstract_method_header): Call to lookup_modifier_cl + replaced by MODIFIER_WFL. + (method_declarator): Incomplete argument type are registered + calling register_incomplete_type. Patch on the declared method is + issued in that case. + (unresolved_type_p): New function. + (parser_check_super_interface): New comment to reflect function's + modified returned type (int). Function and has a new argument + this_wfl. Call to parse_error_context uses this_wfl instead of + relying on lookup_cl. + (parser_check_super): Comment reflects function's new returned + type (int). Function returns nonzero value on error. + (create_jdep_list, reverse_jdep_list, obtain_incomplete_type, + register_incomplete_type, jdep_resolve_class): New functions to + handle incomplete types in declarations. + (java_complete_class): Rewritten to work with the new incomplete + type handling scheme. + (complete_class_report_errors): Likewise. + (complete_method_decl): Removed: it jobs is now handled by + java_complete_class. + (do_resolve_class): Class loaded in not already loaded and not + found in Java source code. + (java_check_regular_methods, java_check_abstract_methods): Don't + call complete_method_decl anymore. + (lookup_modifier_cl, not_builtin_p): Functions deleted. + (read_import_dir): Got rid of the pass number dependency. + (declare_local_variables): New handling of unresolved types (patch + issued). + (source_start_java_method): New parameter level. Function called + with level set to 1 when argument types are potentially + unresolved. Called to complete the job with level set to 2 once + types are complete. + (source_end_java_method): Call to permanent_allocation + removed. Waiting to be replaced by a more suitable obstack + management. + (java_complete_expand_methods, java_complete_expand_method, + java_expand_finals): New functions. + (build_method_invocation_stmt): Renamed + patch_method_invocation_stmt. Extracts function call expression + (wfl) and arguments (args) from CALL_EXPR tree operands. + (build_invoke): Renamed patch_invoke. Fixed typo in fatal + call. Patch the function and argument operand of the CALL_EXPR + tree argument. + (patch_argument, java_complete_tree): New functions. + +1998-04-20 Per Bothner <bothner@cygnus.com> + + Recover from missing fields and methods (i.e. error instead of fatal). + * decl.c, java-tree.h (TYPE_identifier_node): New global constant. + * expr.c (expand_invoke): Recover from missing method. + (expand_java_field_op): Recover from missing field. + Inline references to java.lang.{Integer,Char,...}.TYPE. + * typeck.c (get_type_from_signature), java-tree.h: New function. + * class.c (add_method): Use get_type_from_signature. + (build_class_ref): Handle a class that was not found. + * typeck.c (convert): Handle conversion to pointers (for convenience). + * verify.c (verify_jvm_instructions): Use get_type_from_signature + instead of lookup_field to handle missing fields. + + * jcf-parse.c (process_zip_dir): Set java_source. + +1998-04-20 Brendan Kehoe <brendan@cygnus.com> + + * jcf-parse.c (set_source_filename): Use TYPE_NAME, not DECL_NAME. + +1998-04-14 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c (load_class): Don't change input_filename before + calling jcf_parse_source (but still do it before calling + jcf_parse). + (jcf_parse_source): Assign input_filename after having saved the + parser context. + * lex.c (java_init_lex): Chain a WFL node to the import on demand + list. ctxp->modifier_ctx zeroed according to its new + definition. ctxp->filename initialized. Removed + JAVA_MODIFIER_CTX_UNMARK. + (java_unget_unicode): Update the character based column position. + (java_allocate_new_line): ref_count not used anymore. Always free + ctxp->p_line. Initialize c_line->char_col to 0. + (java_get_unicode): Update the character based column position. + (java_lex): Use ctxp->elc to store current position in source + file, at the beginning of the parsed token. Set modifier_ctx entry + corresponding to the parse modifier to a WFL node. Return a WFL + node when an identifier is parsed. + (java_lex_error): Now uses ctxp->elc to store current position in + source. + (build_wfl_node, java_is_eol, java_get_line_col): New functions. + * lex.h (build_wfl_node): New function definitions. + (struct java_line): ref_count and next fields are gone. New field + char_col. + (JAVA_LINE_CHECK, JAVA_LINE_MARK, JAVA_LINE_CHAIN, + JAVA_LINE_UNMARK, ID_NAME, ID_CL): Macro definitions deleted. + (JAVA_COLUMN_DELTA): New macro. + (java_lc): New typedef on new struct _java_lc. + * parse.h (lookup_cl, lookup_modifier_cl): Changed returned types. + (parse_error_context, parse_warning_context): Changed prototypes. + (java_get_line_col): Added as an available global function. + (JAVA_MODIFIER_CTX_UNMARK): Macro removed. + (IC_DECL): Replaced by macro IC_TYPE + (DEPEND_WFL): New macro. + (THIS_MODIFIER_ONLY): Now works with WFL and only remembers the first + wrong modifier. + (exit_java_complete_class): Removed a commented out statement. + (struct parser_ctxt): Added comments on fields. modifier_ctx is + now an array of tree nodes. Deleted fields line_list and + e_line. New field elc, to replace e_line. + * parse.y (array_type:): Build WFL node. + (qualified_name:): Build a single WFL node out of two. Retain + the location information of the first node in the resulting node. + (package_declaration:): Use package name as a WFL node + (single_type_import_declaration:): Use imported name as a WFL node. + (type_import_on_demand_declaration:): Use root of the imported + packages as a WFL node. + (field_declaration:): Removed unused local variable cl. + (method_declaration:): Don't call JAVA_MODIFIER_CTX_UNMARK. + (yyerror): New static elc. Removed static error_line, error_pos. + New local code_from_source. Save ctxp->elc into elc at the first + pass. Call java_get_line_col to get a string of the line where + the error occurred. + (debug_line): Removed static function. + (parse_error_context, parse_warning_context): Parameter cl is now + a WFL node. Use its value to initialize ctxp->elc. + (redefinition_error): Parameter cl is now a WFL node. + (parse_add_interface): New parameter wfl. No longer call + lookup_cl, use wfl instead. + (check_class_interface_creation): Parameter cl is now a WFL node. + (maybe_create_class_interface_decl): Likewise. + (add_superinterfaces): New function. + (create_interface): Removed local cl, node, super_decl, + super_decl_type. Function now uses id as a WFL node. Better + warning/error report on obsolete or forbidden mix of + modifiers. Now calls add_superinterfaces to register interfaces. + (create_class): Removed local cl, node. Local variable id is used + as a WFL node. Better error report on forbidden modifier + mix. Uses add_superinterfaces to register interfaces. + (find_field): Argument cl is now a WFL node. Now store the WFL + node of a fields that needs to be checked for their + initialization. + (method_header): Local variable node non longer used. Local + variable id replaces cl. + (check_modifiers_consistency): Local variable cl is now a WFL + node. + (method_declarator): Local variable cl replaced by parameter id. + (parser_qualified_name): Now uses parameter name as a WFL node. + (parser_check_super_interface): New parameter wfl, for achieve + greater accuracy during error reports. + (parser_chain_incomplete_item): New parameter named location. Used, + along the decl, to construct the incomplete item node. + (java_complete_class): resolve_class now uses WFL node extracted + from the incomplete item node. Macro IC_TYPE replaces TREE_PURPOSE + where appropriate. + (complete_method_decl): Unresolved function's argument types are WFL. + (resolve_class): Parameter cl is now a WFL node. + (resolve_and_layout): Likewise. + (do_resolve_class): Likewise. Try first to use cl and then do the + lookup on the decl when calling check_pkg_class_access. + (complete_class_report_errors): Use IC_TYPE in place of + TREE_PURPOSE where appropriate. Use DEPEND_WFL on dependency + instead of doing a lookup over the decl. + (java_check_final): Use WFL info from field tree list. + (lookup_cl): Rewritten and returns a statically defined WFL node. + (lookup_modifier_cl): Now uses information from WFL nodes. + (process_imports): Likewise. + (read_import_dir): name and cl arguments replaced by a single WFL + node. Function modified accordingly. + (find_in_imports_on_demand): Now uses WFL node. + (check_pkg_class_access): cl argument is now a WFL node. + (declare_local_variables): Fixed to use WFL nodes. + (resolve_expression_name): Likewise. + (build_method_invocation_stmt): name_combo argument renamed + wfl. Function modified to use WFL nodes. + (build_invoke): cl used as a WFL node when calling build_expr_wfl. + (lookup_method_invoke): cl is now a WFL node. Added missing + IDENTIFIER_POINTER to class type decl name. + +1998-04-14 Dave Brolley <brolley@cygnus.com> + + * lang.c (init_parse): Now returns char* containing the filename. + +1998-04-10 Per Bothner <bothner@cygnus.com> + + * class.c (layout_class): Mangle repeated arg types to match cc1plus. + + * decl.c, java-tree.h (integer_four_node): New INTEGER_CST node. + * class.c (make_class_data): If flag_assume_compiled, initial class + state is CSTATE_PREPARED; make superclass and interfaces direct + references, rather than constant pool indexes. + +1998-04-09 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parser.y: Include flags.h. Removed debug variable pl. + (method_declaration:): Uses ctxp->parser_ccb_indent instead of pl. + (block:): Likewise. + (labeled_statement_nsi:): Generate debug info when reducing + expression_statement:. + (check_pkg_class_access): get_access_flags_from_decl invocation + fixed for new CLASS_* flags location. + (source_end_java_method): Save/restore parser context when + entering/leaving this routine. Restore lineno to its right value + before calling expand_end_bindings. + (build_method_invocation_stmt): build_invoke called with the + current line information. + (build_invoke): New argument cl. Wrap the function call around a + wfl node. + (refine_accessible_methods_list): Changed comment, removed + unnecessary code. + * parse.h: Fixed typo in comments. + (CLASS_OR_INTERFACE): Handle the new CLASS_* flags location. + (JAVA_MAYBE_GENERATE_DEBUG_INFO): New macro. + (struct parser_ctxt): New fields ccb_indent, last_ccb_indent1, + parser_ccb_indent. + * lex.c (java_lex): Record the last closing curly bracket of a + function. + * jcf-parse.c (jcf_parse_source): Now calls + java_check_methods. Clarified comment, fixed typo. + +1998-04-09 Dave Brolley <brolley@cygnus.com> + + * lang.c (init_parse): Expose for non USE_CPPLIB builds. + (finish_parse): Expose for non USE_CPPLIB builds. + +1998-04-08 Jeffrey A Law (law@cygnus.com) + + * lang.c (lang_print_xnode): New function. + +1998-04-03 Per Bothner <bothner@cygnus.com> + + * decl.c (class_dtable_decl), java-tree.h: New tree node. + * class.c (get_dispatch_vector, get_dispatch_table): New functions + used to build a class's dispatch table. + (make_class_data): Generate dispatch table if flag_assume_compiled. + Set dtable of class object to address of class_dtable_decl. + + * decl.c (int_decl_processing): Make soft_badarrayindex_node + be volatile and have side effects - generates better code. + + * class.c, expr.c, parse.y: CLASS_INTERFACE, CLASS_FINAL, etc: + These flags were defined for TYPE_DECLs, but used on RECORD_TYPEs. + + * expr.c (expand_invoke): If class is final, method is + effectively final, so can call it directly. + + * java-tree.h (TYPE_NVIRTUALS, TYPE_VTABLE): New macros. + + * Makefile.in, Make-lang.in: Add missing $(exeext)s. + +1998-03-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (build_method_invocation_stmt): Removed extra argument + to build_invoke. + +1998-03-16 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (dtable_indent): Now static global. + (expand_invoke): Now call invoke_build_dtable and + build_invokevirtual. + (invoke_build_dtable, build_invokevirtual): New functions. + * jcf-io.c (find_class): Defer issuing a warning by setting + jcf->outofsynch to 1. + * jcf-parse.c (jcf_out_of_synch): New function. + (load_class): Test this_jcf.outofsynch flag and call + jcf_out_of_synch accordingly. + * jcf.h: (typedef struct JCF): New flag outofsynch. Fixed typo in + comment indentation. + * lex.c (java_get_unicode): Fixed code indentation. + (java_lex): Create string literal. Fixed typo. Removed several + premature obstack_free. + * parse.h: New enums for name resolution and invocation mode. + (struct qualification): New data structure. + (RESOLVE_CHAIN_REMAINDER, BUILD_PTR_FROM_NAME): New macros. + (do_resolve_class, build_method_invocation_stmt, + breakdown_qualified, qualify_ambiguous_name, resolve_and_layout, + debug_line, identical_subpath_p, invocation_mode, + refine_accessible_methods_list, build_invoke, + lookup_method_invoke): New functions declared. + (build_invokevirtual, invoke_build_dtable, match_java_method, + build_field_ref, jcf_out_of_synch): New references to external + functions. + (struct parse_ctxt): Removed artificial_constructor field. + * parse.y: (array_type:): Type defined for this rule. + (class_type:): Installed default rule for interface_type:. + (array_type:): Now build Java array type. + (qualified_name:): Now use obstack_grow0. + (method_declaration:): Skip the artificial constructor added to + the list, if any. + (abstract_method_declaration:): Execute the code only during pass 1. + (block:): Installed default rule in block_statements:. + (block_statement:): Add the statement to the method during pass 2. + (statement_expression): Installed default rule for + method_invocation:. + (argument_list:): Added code to build the argument list. + (method_invocation:): Added call to create the method invocation + node. + (yyerror): Now use obstack_grow0. Removed bogus obstack_free. + (debug_line): New function for debug. + (complete_class_decl): No longer do something during pass 1. + (method_header): Use BUILD_PTR_FROM_NAME. + (parser_qualified_classname): Use obstack_grow0. Removed bogus + obstack_free. + (parser_chain_incomplete_item): Use BUILD_PTR_FROM_NAME. Modified + function's main comment. + (java_complete_class): Set CLASS_LOADED_P on all fixed incomplete + classes. + (complete_method_decl): Use BUILD_PTR_FROM_NAME and promote types. + (resolve_class): Now works with arrays. + (do_resolve_class, resolve_and_layout): New functions. + (java_check_regular_methods): Reverse method list before and after + having processed it. No longer set ctxp->artificial_constructor. + (read_import_dir): Test jcf->outofsynch and call jcf_out_of_synch + accordingly. Fixed typo in issued error message. Now use + obstack_grow0. + (find_in_imports_on_demand): Now use obstack_grow0. + (declare_local_variables): Use BUILD_PTR_FROM_NAME. + (source_end_java_method): Call expand_expr_stmt instead of + expand_expr. Calls it before calling expand_function_end. + (java_method_add_stmt): Do nothing if errors were found during + parsing. + (java_layout_parsed_class): Set CLASS_LOADED_P and fixed typo. + (build_method_invocation_stmt, build_invoke, invocation_mode, + lookup_method_invoke, refine_accessible_methods_list, + qualify_ambiguous_name, breakdown_qualified, identical_subpath_p): + New functions. + * typeck.c (build_java_signature): Properly end method signature + if return type skipped. + (match_java_method): New function. + +1998-03-16 Per Bothner <bothner@cygnus.com> + + * jcf-io.c (find_classfile): If USE_JCF_STDIO, fopen in binary mode. + +1998-02-25 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (build_invoke_non_interface): New function. + (methods_ident, ncode_ident): Now static globals. + (expand_invoke): Use build_invoke_non_interface. + * java-tree.h (struct lang_decl): New field function_decl_body. + (DECL_FUNCTION_BODY): New macro. + * jcf-parse.c (jcf_parse_source): Deeper check before setting + CLASS_FROM_SOURCE_P. + (parse_source_file): Fixed typos. Call java_layout_parsed_class + before starting pass 2. Call to java_generate_parsed_class replaced + by java_register_parsed_class. + * lex.c: Fixed typo in header. Some line width related formating. + * lex.h: Some line width related formating. + * parse.h (source_end_java_method, resolve_expression_name, + complete_class_decl, maybe_create_class_interface_decl, + check_class_interface_creation): New static function declarations. + (java_layout_parsed_class, java_method_add_stmt): New function + declarations. + (struct parser_ctxt): Field mark_class_generate removed. New + fields class_list and artificial_constructor. + * parse.y: Fixed typo in header. + (class_declaration:): Call complete_class_decl when class body + parsed. + (method_declaration:): Call source_end_java_method in pass 2 when + the method body is defined. + (postfix_expression:): Do expression name resolution on sub-rule + name during pass 2. + (create_class, create_interface): Merged common pieces. + (check_class_interface_creation, maybe_create_class_interface_decl): + New functions. + (complete_class_decl): New function. + (register_fields): Fixed line width related typo. + (method_header): Correctly skip first argument when fixing + argument line. Changed the loop. + (java_check_circular_reference): Now use ctxp->class_list. + (java_complete_class): Removed start/stop marking. + (java_check_regular_methods): Now takes a class decl as an + argument. Add default constructor if none were encountered. + (java_check_methods): Now use ctxp->class_list. Changed call to + java_check_regular_methods. + (source_start_java_method): Set DECL_ARG_TYPE for each function + arguments. + (source_end_java_method, java_method_add_stmt): New functions. + (java_generate_parsed_class): No longer exists. + (java_layout_parsed_class, java_register_parsed_class): New functions. + (resolve_expression_name): New function. + +1998-02-12 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-parse.c: (parse_source_file): Check on errors after init lex. + * lex.c: (java_init_lex): Defer ctxp->java_pass initialization + until pass initializations are done. Call read_import_dir with + pass set to 0. + * parse.h: (lookup_modifier_cl): New function declared. + (INTERFACE_FIELD_MODIFIERS): New macro. + (OBSOLETE_MODIFIER_WARNING): New macro. + * parse.y: (register_fields): Class type and current field name in + local variables. Check modifier(s) if adding field(s) to an interface. + (check_abstract_method_header): Now use OBSOLETE_MODIFIER_WARNING + and report errors using the faulty modifier line context. + (lookup_modifier_cl): New function. + (read_import_dir): Detect and report default import processing + failure. + +1998-02-11 Brendan Kehoe <brendan@cygnus.com> + + Add a pair of -fassume-compiled/-fno-assume-compiled options. + * class.c (is_compiled_class): Return 1 after making sure it + qualifies as loaded, if FLAG_ASSUME_COMPILED is set. + * lang-options.h: Add -fassume-compiled/-fno-assume-compiled. + * java-tree.h (flag_assume_compiled): Add decl. + * lang.c (lang_f_options): Add the flag. + (flag_assume_compiled): Add decl, default to 0. + +1998-02-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (class_depth): Call to load_class uses extra VERBOSE arg. + (is_compiled_class): Likewise. + (layout_class): Likewise. + (layout_class): Detect and lay out classes defined in source code. + (interface_of_p, add_interface_do, may_add_interface): New + function. + (add_interface): Now use add_interface_do. + (add_method_1): New function. + (add_method): Now use add_method_1. + (pushlevel): Debug message conditional to SOURCE_FRONTEND_DEBUG. + (complete_start_java_method): New function. + (start_java_mehod): Now call complete_start_java_method. + * expr.c (lookup_field): Call to load_class uses extra VERBOSE arg. + (expand_invoke): Likewise and fixed typo. + *gjava.c: (print_super_field): Use new argument to find_class + DO_CLASS_FILE. + (main): Likewise. + *java-tree.h: (CLASS_FROM_SOURCE_P): New flag on RECORD_TYPE. + (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P, IS_A_CLASSFILE_NAME, + QUALIFIED_P, IS_AN_IMPORT_ON_DEMAND_P): New flags on + IDENTIFIER_NODE. + (CLASS_COMPLETE_P): New flag on TYPE_DECL. + (add_method_1, push_class): New prototypes. + *jcf-dump.c: find_class now uses new DO_CLASS_FILE argument. + *jcf-io.c: (open_in_zip): jcf now stores a pointer to the Zip + directory where the class was found. + (find_class): New argument DO_CLASS_FILE. Function find_class + modified accordingly. + *jcf-parse.c: (fix_class_path): New function. + (load_class): Use new VERBOSE argument. load_class now finds and + loads/parses .class/.java files. Save read_state of current_jcf + if necessary. + (java_parser_abort_on_error): New macro. + (jcf_parse_source, parse_source_file): New function. + (jcf_parse): Fixed typo. + (yyparse): Call parse_source_file () only. + (process_zip_dir): Fixed typo, fix zdir->filename_length when + writing the real class name back in the zip directory entry. + (find_in_current_zip): IDENTIFIER_CLASS_VALUE may be null. + (jcf_figure_file_type): Fixed bogus alloc and bcopy. + *jcf.h: (typedef struct JCF): New fields java_source and zipd. + (find_class): Prototype fixed. + *lex.c: Added 1998 time stamp. + Removed all static global variables, moved into the parser + context data structure.. Now include unistd.h if SEEK_SET not + defined. + (java_init_lex): Rewritten. + (java_sneak_unicode): Modified current unicode access in current line. + (java_unget_unicode): Likewise. + (java_allocate_new_line): New allocation management. + (java_read_char): Modified access and storage of unget_utf8_value. + New way of processing current unicode. + (java_store_unicode, java_read_unicode): Fixed typo in declaration. + (java_get_unicode): Now use the parser context. + (java_lineterminator): Likewise. + (java_lex): Now used java_lval argument (pointer to YYSTYPE), part + of the reentrant parser implementation. Function now use the + parser context data structure and java_lval. Fixed production of + the float and double constant "out of range" error message. Fixed + obstack use. Return integer value when hitting a modifier. Now + return type for TRUE, FALSE and other predefined types. Return + identifier as a TREE_LIST list containing the current line context + as the TREE_VALUE sub-node. + (java_unicode_2_utf8): Fixed typo in declaration. + (java_lex_error): Now use the parser context data structure. + *lex.h: Added 1998 time stamp. + (struct java_line): New fields ref_count and next. + (JAVA_LINE_CHECK, JAVA_LINE_MARK, JAVA_LINE_CHAIN, + JAVA_LINE_UNMARK, ID_NAME, ID_CL): New macros. + (JAVA_FLOAT_RANGE_ERROR, JAVA_INTEGRAL_RANGE_ERROR, UNGETC): Fixed. + *parse.h: Added 1998 time stamp. + (java_parse_source_file): Renamed from parse_source_file. + (YYERROR_NOW, YYNOT_TWICE): Fixed. + (CLASS_MODIFIERS, FIELD_MODIFIERS, METHOD_MODIFIERS, + INTERFACE_MODIFIER, INTERFACE_METHOD_MODIFIERS, + JAVA_MODIFIER_CTX_UNMARK, IC_DECL, IC_DEPEND, DEPEND_DECL, + THIS_MODIFIER_ONLY, ABSTRACT_CHECK, BEGIN_ONLY_PASS, + END_ONLY_PASS, ELSE_ONLY_PASS, exit_java_complete_class, + CLASS_OR_INTERFACE, INCOMPLETE_P): New macros. + (struct parser_ctxt): New data structure to keep the parser context. + *parse.y: Added 1998 time stamp, got rid of static global variables. + (java_error_count, ctxp): New global variables. + (%union): New value field. + (numeric_type, integral_type): Rules removed. + (primitive_type): Rule defined to handle integral, float, double and + boolean types. + (qualified_name, package_declaration, + single_type_import_declaration, type_import_on_demand_declaration, + modifiers, class_declaration, super, interfaces, + interface_type_list, class_body, field_declaration, + field_declaration, variable_declarators, variable_declarator, + variable_declarator_id, method_declaration, method_header, + formal_parameter_list, formal_parameter, method_body, block, + static, interface_declaration, extends_interfaces, + abstract_method_declaration, local_variable_declarators): Rules now + define actions. + (force_error, do_warning): New global statics. + (push_parser_context, parser_context_save_global, + parser_context_restore_global, pop_parser_context): New functions. + (yyerror): Now uses the global parser context. Fixed use of obstack. + (parse_error, parse_error_context, parse_warning_context, + java_accstring_lookup, redefinition_error, check_modifiers, + parser_add_interface, create_interface, create_class, find_field, + duplicate_declaration_error, register_fields, method_header, + check_modifiers_consistency, check_abstract_method_header, + method_declarator, parser_qualified_classname, + parser_check_super_interface, parser_check_super, + parser_chain_incomplete_item, java_check_circular_reference, + layout_class_from_source, java_complete_class, + complete_method_decl, resolve_class, complete_class_report_errors, + java_check_final, check_method_redefinition, + java_check_regular_methods, java_check_abstract_methods, + java_check_methods, lookup_java_interface_method2, + lookup_java_method2, lookup_cl, find_name_in_single_imports, + process_imports, find_in_imports, read_import_entry, + read_import_dir, find_in_imports_on_demand, + check_pkg_class_access, not_builtin_p, declare_local_variables, + source_start_java_method, java_generate_parsed_class): New + functions. + *typeck.c: (signature_include_return): New global variable. + (build_java_signature): Use SIGNATURE_INCLUDE_RETURN figure whether + to add the function returned type in the signature. + +1998-02-09 Brendan Kehoe <brendan@cygnus.com> + + * jcf-io.c (open_in_zip): Use strncmp and LEN. + +1998-01-29 Dave Brolley <brolley@cygnus.com> + + * Make-lang.in (java.info): Added. + (java.install-info): Added + +1998-01-27 Brendan Kehoe <brendan@cygnus.com> + + * Makefile.in (clean): Also remove java/parse.c. + +1998-01-26 Brendan Kehoe <brendan@cygnus.com> + + Add a pair of -fbounds-check/-fno-bounds-check options. + * lang.c (lang_decode_option): Add code to grok arguments. + (flag_bounds_check): Add decl. + (lang_f_options): New array w/ the option in it. + * java-tree.h (flag_bounds_check): Add decl. + * lang-options.h: New file. + * expr.c (build_java_arrayaccess): Use flag_bounds_check instead + of a static macro value. + (JAVA_ARRAY_EXCEPTION): Delete macro. + +1998-01-23 Per Bothner <bothner@cygnus.com> + + * typeck.c (build_java_array_type): Fix two bugs in previous change. + * expr.c (build_anewarray): Add missing promote_type. + +1998-01-22 Per Bothner <bothner@cygnus.com> + + Add array types with known length to optimize bounds checking. + * typeck.c (build_java_array_type): Take length parameter. + (java_array_type_length, build_prim_array_type): New functions. + * java-tree.h: Update for new functions. + * expr.c, typeck.c, verify.c: Update build_java_array_type calls. + * class.c: Use build_prim_array_type. + * expr.c (can_widen_reference_to): Handle known-length array types. + (verify_jvm_instructions): Keep track of integer push instructions + followed by newarray/anewarray, so we can build known-length arrays. + (JAVA_ARRAY_DATA_OFFSET): Replace by ... + (java_array_data_offset): New function. + (build_java_array_length_access): New function. Optimize if constant. + (build_java_arrayaccess): Constant fold bounds check. + (expand_java_newarray, expand_java_anewarray): Replaced by ... + (build_newarray, build_anewarray): New functions. + (ARRAY_NEW_NUM, ARRAY_NEW_PTR): Use build_{a,}newarray. + * verify.c (merge_types): Handle known-lengh array types. + +1998-01-19 Per Bothner <bothner@cygnus.com> + + * expr.c (expand_byte_code): Fix performace bug, which caused + searching linenumber_table to be linear rather than constant. + +1997-12-12 Per Bothner <bothner@cygnus.com> + + * Makefile.in (BISON, BISONFLAGS): Add missing macros. + + * decl.c, java-tree.h (soft_fmod_node): New global. + * decl.c (init_decl_processing): Define __builtin_fmod. + * expr.c (build_java_binop): Implement TRUNC_MOD_EXPR for REAL_TYPE + using __builtin_fmod. + +1997-12-04 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * keyword.h: New file, output of keyword.gperf as processed by + gperf. + * lex.c (java_lex_init): Initialize java_error_flag. + * parse.c (YYERROR_NOW): Uses java_error_flag. + * parse.y: New static java_error_flag. Useless definition of + buffer_error gone. + * parse.y (java_error): Portable error recovery using + java_error_flag (not yet completely tuned). + +1997-12-04 Brendan Kehoe <brendan@lisa.cygnus.com> + + * Makefile.in (parse.c): Use $(srcdir) for parse.y. + +1997-12-03 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Makefile.in: (JAVA_OBJS): New object jcf-parse.o. + (parse.c, lex.c, keyword.h): New rules for Java source code + front-end. + * parse.c: Renamed into jcf-parse.c. + * jcf-parse.c (yyparse): Invoke the parser to process Java source code. + * keyword.gperf: New file, Java keywords. + * parse.y: New file, Java language grammar. + * parse.h: New file, Java language grammar definitions. + * lex.c: New file, Java language lexer. + * lex.h: New file, Java language lexer definitions. + +1997-12-03 Per Bothner <bothner@cygnus.com> + + * decl.c (clinit_identifier_node), java-tree.h: New global. + * java-tree.h (IS_METHOD_INIT_P, IS_METHOD_CLINIT_P): Removed. + * verify.c (verify_jvm_instructions): Inline use of removed macros. + * expr.c (expand_java_field_op): Check for invalid assignment + to final field. + + * jcf-reader.c (get_attribute): Test for wrong attribute length. + +1997-10-27 Per Bothner <bothner@cygnus.com> + + * verify.c (verify_jvm_instructions): When processing a handler, + attempt to set the current_subr to the right value. + (More complicated code combines Sep 17 and Oct 22 versions.) + +1997-10-24 Per Bothner <bothner@cygnus.com> + + * class.c (push_class): Figure out (guess) name of source file. + * parse.c (set_source_filename): Set DECL_SOURCE_FILE of class decl. + (give_name_to_class): Don't guess source name; use DECL_SOURCE_FILE. + (parse_class_file): Change return type from int to void. + Call debug_start_source_file/debug_end_source_file. + + * expr.c (build_java_binop): Fix masking 2nd operand. + * decl.c (init_decl_processing): Set sizetype first. + +1997-10-22 Per Bothner <bothner@cygnus.com> + + * verify.c (verify_jvm_instructions): Don't set current_subr to NULL. + (Revert Sep 17 change.) + +1997-10-21 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.c (process_zip_dir): Skip ZIP entries not bearing the + .class extension in their name and fix thing so we don't process + them parse_zip_file_entries(). + (parse_zip_file_entries): Cleaned unused local variables. + +1997-10-20 Per Bothner <bothner@cygnus.com> + + * expr.c (can_widen_reference_to): Allows equal array element types. + (expand_byte_code): PRE_RET must expand OPERAND_VALUE (to get index). + * jcf-dump.c (RET): Get (and print) index. + + * verify.c (verify_jvm_instructions case OPCODE_anewarray): + Promote element type to POINTER_TYPE. + +1997-10-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * jcf-reader.c, parse.c: (parse_zip_file, process_zip_dir, + find_in_current_zip, jcf_figure_file_type): Moved from + jcf-reader.c to parse.c. + * zextract.c: (read_zip_archive): takes file_comment_length possible + field into account. + +1997-10-20 Per Bothner <bothner@cygnus.com> + + * verify.c (verify_jvm_instructions): Var can also be promoted to int. + + * verify.c (merge_types): Handle array types even better ... + +1997-10-17 Per Bothner <bothner@cygnus.com> + + * expr.c (java_stack_pop): Fix use of NULL_TREE for TYPE_SECOND. + + * java-tree.h (PUSH_FIELD): Set DECL_ARTIFICIAL. + * class.c (make_class_data): Don't build fields_decl if no fields. + When building fields_decl, skip if DECL_ARTIFICIAL. + + * expr.c (java_stack_swap): Update stack_type_map. + * verify.c (merge_types): Handle array types better. + +1997-10-15 Per Bothner <bothner@cygnus.com> + + * class.c (add_field): Don't promote short integral fields to + int any more (unless JAVA_PROMOTE_TO_INT), since Kaffe doesn't. + * expr.c (push_value): Promote and convert short integral values. + + * decl.c, java-tree.h (integer_two_node): New constant node. + * verify.c (merge_types): Check for TYPE_RETURN_ADDR. + +1997-10-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (append_gpp_mangled_type): Use function argument + unpromoted type to generate mangled name. + +1997-10-13 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * constants.c (build_constant_data_ref): Now uses current_class + instead of main_class. + (build_constants_constructor): Now uses current_class instead of + main_class. + * zipfile.h: (struct ZipFileCache): Now defined here. Declaration + of the global variable SeepZipFiles done here. + * zextract.c (read_zip_archive): extra_field optional field taken + into account while computing the position of the class file in the + archive. + * verify.c (verify_jvm_instructions): Use current_jcf to search + the constant pool. + * parse.c (load_class): First search for the class to load in the + current zip file. Saves current_jcf (restored before returning + from that function). Don't call JCF_FINISH in the class was found + in the current ZIP file. + (jcf_parse): If the class was found in the current ZIP file, save + its tree_constant_pool (for later reuse). + (parse_class_file): New function. Process each method defined in + the current class and record the class as to be later registered. + (yyparse): Rewritten. Figure the type of the current file and switch + accordingly. + * lang.c: New global variable current_jcf. + (lang_init): Removed compiling_from_source test (done later, in + yyparse). Removed call the jcf_parse (). + * jcf.h (JCF_ZIP, JCF_CLASS, JCF_SOURCE): New defined values. + (typedef struct JCF): New fields seen_in_zip (to mark a class found + in the current ZIP file) and zip_offset (offset to the class data in + the current zip file). + * jcf-reader.c: zipfile.h included. + localToFile: New ZipFileCache static global variable + (parse_zip_file_entries): New function. Browse the current ZIP + file directory and process each class found. + (process_zip_dir): New function. Register each class found in the + ZIP file directory. The class aren't parsed but a valid JCF is + link to each of them. + (find_in_current_zip): New function. Search for a class in the + current ZIP file directory. If found, prepare the class so that it + can be loaded. + (jcf_figure_file_type): New function. Examine the file structure + to figure a class file, a ZIP file. If none of these categories are + matched, a source file is assumed. + * jcf-io.c: Removed definition of ZipFileCache (moved in zipfile.h). + SeenZipFile: New global variable. + (open_in_zip): Use zipmember's length to accelerate the search for + a member. If zipmember was NULL and zip file successfully read, + return 0. + * java-tree.h: New global variable current_jcf declared. Added + declaration for current_constant_pool_tags, current_constant_pool_data, + current_constant_pool_length, current_constant_pool_data_ref. + (struct lang_type): Augmented with two fields. struct JCF *jcf (to + store the JCF of classes seen in a zip file) and tree *constant_pool + (to save a loaded class constant pool). current_class declared here. + * expr.c (expand_invoke): Use current_jcf instead of main_jcf to + retrieve method_ref_constant. + (PUSHC): java_push_constant_from_pool now uses current_jcf. + (OBJECT): get_class_constant now uses current_jcf. + (ARRAY_NEW_PTR): get_class_constant now uses current_jcf. + (ARRAY_NEW_MULTI): get_class_constant now uses current_jcf. + (expand_invoke): Now uses current_class instead of main_class + (build_class_init): Now uses current_class instead of main_class + * class.c: New static global variable registered_class. + (register_class): New function. + (emit_register_class): Modified to use registered_class instead of + main_class + (is_compiled_class): Now take into account class seen in the archive. + +1997-10-06 Per Bothner <bothner@cygnus.com> + + * except.h: Renamed to: java-except.h. + * parse.c, except.c, expr.c, verify.c: Update #include accordingly. + * except.c: Add semi-working (commented out) implementation. + + * expr.c (expand_iinc): Add needed flush_quick_stack. + * parse.c (set_source_filename): New function. + (give_name_to_class): Set input_filename from package.classname.java. + + * jcf-io.c (find_class): Don't look first in ".". + +1997-10-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * zextract.c (read_zip_archive): Now takes into account the + extra_field field. + * expr.c (can_widen_reference_to): Modified to handle sub-interfaces. + +1997-09-20 Per Bothner <bothner@cygnus.com> + + * constants.c, java-tree.h (build_internal_class_name): New function. + (alloc_class_constant): Re-implement using build_internal_class_name. + * class.c (make_class_data): Likewise. + * class.c (hashUtf8String): Make hash algorithm match String.hashCode. + +1997-09-17 Per Bothner <bothner@cygnus.com> + + * verify.c (verify_jvm_instructions): Temporarily set current_subr + to NULL before pushing an exception handler target. + + * expr.c (flush_quick_stack): Save from low stack indexes to high. + (java_stack_swap, java_stack_dup): Re-write to be safe from + clobbering registers. + (build_class_init): New function. + +1997-09-17 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * typeck.c (build_java_array_type): Temporary use + permanent_obstack to create the array 'length' field. + * expr.c (lookup_label): Temporay use permanent_obstack to create + label if not found. + * class.c (push_super_field): Tempory use permanent_obstack. + +1997-09-15 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * typeck.c (type_for_mode): Now handles double_type_node and + float_type_node. + * verify.c (verify_jvm_instructions): The instruction following + the wide bytecode is checked. OPCODE_ret added to the list of + wide. + +1997-09-11 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (make_class): Temporary use permanent_obstack. Set the + class CLASS_P field to 1. + (push_class): Temporary use permanent_obstack. + (set_super_info): Temporary use permanent_obstack. + (add_method): Temporary use permanent_obstack, set + METHOD_TRANSIENT(). + (add_field): Temporary use permanent_obstack. Sets + FIELD_VOLATILE() and FIELD_TRANSIENT(). + (build_class_ref): Temporary use permanent_obstack if the class + isn't compiled. + (build_static_field_ref): Temporary use permanent_obstack when + creating field's rtl. + (get_access_flags_from_decl): Handle ACC_VOLATILE, ACC_TRANSIENT, + ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT flags for methods + and fields. Function finalized, as far as flag handling. + (push_class_static_dummy_field): Temporary use permanent_obstack. + (emit_register_class): Force generation of class registration at + -O3 or deeper. + * decl.c (end_java_method): Call permanent_allocation() before + returning. + * expr.c (can_widen_reference_to): Added comment to interface + handling, fixed typo. + (lookup_field): Now uses CLASS_P() to correct FIXME + (expand_invoke): Verification on public && !static && + !abstract moved into soft_lookupinterfacemethod (kaffe). + Use Object class dtable if objectref is an array when expanding + invokeinterface. + (java_push_constant_from_pool): Temporary use permanent_obstack + for CONSTANT_string + * parse.c (get_ref_constant): Temporary use permanent_obstack to + create constant references. + (get_constant): Temporary use permanent_obstack to create constant. + (load_class): Temporary use permanent_obstack to load class. + (jcf_parse): Temporary use permanent_obstack to perform class + layout. + * typeck.c: (parse_signature_string): Temporary use permanent_obstack. + (build_java_signature): Temporary use permanent_obstack. + * verify.c: (verify_jvm_instruction): removed unnecessary verification + on ACC_SUPER flag. + * java-tree.h (METHOD_NATIVE, METHOD_TRANSIENT): Defined. + (FIELD_VOLATILE, FIELD_TRANSIENT): Defined. + (CLASS_P): Defined + +1997-09-11 Per Bothner <bothner@cygnus.com> + + * class.c (append_gpp_mangled_type): Fix typo. + (emit_register_class): Use main_class to get class object, rather + than looking for no-longer-existing static decl starting with _CL. + * typeck.c (parse_signature_type): Promote array element type + if it is a RECORD_TYPE. + +1997-09-10 Per Bothner <bothner@cygnus.com> + + * class.c (push_class_static_dummy_field): New function. + (mangle_static_field): New. Do G++-style mangling of static fields. + (layout_class): Mandle static fields here, not in add_field. + (build_class_ref): The class object is now a dummy static field. + * decl.c (find_local_variable): Look for best, instead of first match. + * expr.c (push_type): Always promote_type, not just for RECORD_TYPE. + (build_java_athrow): Don't check here if exception is Throwable. + * java-tree.h (TYPE_UNSET): Renamed to TYPE_UNKNOWN. + (TYPE_USED): Removed. No longer used ... + * parse.c (jcf_parse): Call push_class_static_dummy_field. + * verify.c (push_pending_label): New function. + (push_pending_block): Renamed to check_pending_block. + (merge_types): Remove unneeded suuport for TYPE_UNUSED. + (verify_jvm_instructions): Only reset prev_eh_ranges (to force + re-checking possible handlers) after a store (less wasted work). + Check for null handler (finally) before calling add_handler. + Various changes to (finally?) correctly handle try/finally. + +1997-09-09 Brendan Kehoe <brendan@lisa.cygnus.com> + + * class.c: Include stdio.h. + +1997-09-04 Per Bothner <bothner@cygnus.com> + + * expr.c (expand_invoke): Use COMPOUND_EXPR (and TREE_SIDE_EFFECTS) + to make sure class is initialized before static/special invoke. + + * verify.c (verify_jvm_instructions): On a store instruction, + call find_local_variable to force pre-allocation of decl and rtx. + * decl.c (push_jvm_slot): Set DECL_REGISTER on stack slots. + +1997-09-03 Per Bothner <bothner@cygnus.com> + + * class.c (build_class_ref): Strip off "promoted_" if need be. + (make_field_value): Call build_java_signature when needed. + (layout_class): Don't make_function_rtl if METHOD_ABSTRACT. + * expr.c (build_java_athrow): Don't push_value of exception. + (build_java_binop): Implement COMPARE_L_EXPR and COMPARE_G_EXPR to + match specification of [fd]cmp[lg] for NaNs. + (expand_byte_code): Add support for exception handler ranges. + * except.c: Add skeleton for EH code-generation. + * verify.c (merge_types): Treat all promoted integral types as equal. + * constants.c (build_constants_constructor): To force creation of + current_constant_pool_data_ref, call build_constant_data_ref. + + * javaop.def (lload): Fix typo. + * jcf-dump.c (main): Clear filename to prevent possibly-bad free. + +1997-09-02 Brendan Kehoe <brendan@lisa.cygnus.com> + + * parse.c: Don't include function.h. + +1997-08-27 Per Bothner <bothner@cygnus.com> + + * except.[ch]: New files. + * Makefile.in (JAVA_OBJS): Add except.o + * expr.c: Temporary warning about unimplemented exceptions. + * verify.c: Verify exception handlers. + + * jcf-dump.c (disassemble_method): Print exception table. + +1997-08-27 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * expr.c (verify_jvm_instructions): Started a thorough + verification of invoke* bytecodes. + (expand_byte_code): flush quick stack if PC is the target of a + branch. and undef RET (conflicting with config/i386/i386.h). + (expand_java_arrayload): Fixed bogus cast, when Boolean type is + used. + (expand_invoke): Now handles invokeinterface and do more + verification according to the bytecode. + (lookup_field): Don't try to load the class if processing + dtable_type. + (can_widen_reference_to): Now handles interfaces. + * decl.c (init_decl_processing): New global variable + soft_lookupinterfacemethod_node, declared in java-tree.h. + Call set_super_info on string_type_node. + * java-tree.h (CLASS_INTERFACE, CLASS_ABSTRACT, CLASS_SUPER): Now + defined. + * class.c (set_super_info): Fills the CLASS_* flags according to + access_flags. + (get_access_flags_from_decl): Handles all class flags. + +1997-08-26 Per Bothner <bothner@cygnus.com> + + * class.c (add_method): Zero out newly-allocated DECL_LANG_SPECIFIC. + * parse.c (yyparse): Check for abstract method, and missing code. + * expr.c (expand_byte_code): Change interface. + * lang.c (put_decl_node): Print promoted types prettier. + * verify.c (verify_jvm_instruction): Change interface. + Partial support for scanning exception table. + For load instructions, handle promoted integral types. + +1997-08-21 Per Bothner <bothner@cygnus.com> + + * verify.c: New file, with contents moved from expr.c. + * expr.c: Bunch of stuff (mostly verification) moved to verify.c. + * typeck.c (is_array_type_p): Moved here from expr.c. + * java-tree.h: Add some now-needed function declarations. + * Makefile.in (JAVA_OBJS): Added verify.o. + +1997-08-20 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (add_method): Sets the METHOD_SYNCHRONIZED flag, sets the + METHOD_ABSTRACT flag. + + * java-tree.h (METHOD_SYNCHRONIZED): Set to DECL_LANG_FLAG_4. + (IS_METHOD_CLINIT_P, IS_METHOD_INIT_P): New macros. + (METHOD_ABSTRACT): Set to DECL_LANG_FLAG_5 + + * decl.c (soft_monitorenter_node, soft_monitorexit_node): New global + variables. + (start_java_method): Hook for SYNCHRONIZED methods. + + * expr.c (build_java_jsr, build_java_ret): New functions + (JSR,PRE): New macros + (PRE_TABLE_SWITCH, PRE_LOOKUP_SWITCH): Fixed and secured. + (verify_jvm_instructions): tableswitch, lookupswitch, + monitorenter, monitorexit, goto_w: verified. + (LOOKUP_SWITCH, TABLE_SWITCH): Fixed generation of default: label + (build_java_monitor): New function. + (MONITOR_OPERATION): Modified to call build_java_monitor() + (verify_jvm_instructions): Started a thorough verification of + invoke* bytecodes. + +1997-08-19 Per Bothner <bothner@cygnus.com> + + Support verification of jsr/ret subroutines (used for try/finally). + * decl.c (return_address_type_node): New type node. + * java-tree.h (LABEL_RETURN_LABEL, LABEL_RETURN_TYPE_STATE, + RETURN_MAP_ADJUSTED, LABEL_RETURN_LABELS, LABEL_IN_SUBR, + LABEL_SUBR_START, LABEL_SUBR_CONTEXT, BCODE_VERIFIED): New macros. + (TYPE_UNSET, TYPE_SECOND, TYPE_NULL, TYPE_RETURN_ADDR, TYPE_UNUSED, + TYPE_USED): New macros for special types in type_map. + + * java-tree.h (BCODE_JUMP_TARGET): Renamed to BCODE_TARGET. + (BCODE_BACKWARDS_TARGET, CODE_FORWARDS_TARGET): Replaced by + BCODE_JUMP_TARGET. + * expr.c (expand_byte_code): Fix logic to warn of unused instructions. + + * expr.c (can_widen_reference_to): New function. + (pop_type): Use it. + (merge_type_state): Support handling start of subroutine. + (push_pending_block): Return char* error message, instead of calling + fatal on an error. Also handle subroutines. + (verify_jvm_instructions): Handle errors from push_poending_block. + Support jsr and ret instructions. + +1997-08-19 Per Bothner <bothner@cygnus.com> + + * jcf-io.c (find_classfile): Fix thinko. + * jcf-dump.c: Add CONVERT2 (to match changed javaop.def). + +1997-08-12 Jason Merrill <jason@yorick.cygnus.com> + + * Makefile.in (BISON): Remove. + +1997-08-07 Per Bothner <bothner@cygnus.com> + + * Makefile.in: Convert to autoconf. + * config-lang.in (outputs): Added java/Makefile. + + * Make-lang.in, lang-specs.h, config-lang.in, Makefile.in: + Rename cc1java to jc1. + + * lang.c (init_parse, finihs_parse): New functions #ifdef USE_CPPLIB. + * Makefile.in (INTERNAL_CFLAGS): Add @extra_c_flags. + + * class.c (class_depth): Do load_class if needed. + + Mostly better verification. + * decl.c (pushdecl): Set TYPE_STUB_DECL for a type. + (init_decl_processing): Change return type of soft_checkcast. + * expr.c (expand_java_CHECKCAST): Do push_value of the "casted" value. + * lang.c (put_decl_string, put_decl_node, lang_printable_name, + lang_print_error): New functions. + (lang_init): Set global hook print_error_function to lang_print_error. + * expr.c: In the type_map ptr_type_node is only used for null now. + (pop_type, merge_types): Hence ptr_type_node matches any reference. + (merge_types): Dererence pointer to record types before comparing. + (decode_newarray_type, merge_types): On error just return NULL. + (build_java_binop): Add preliminary implementation (with warning) + for COMPARE_L_EXPR and COMPARE_G_EXPR (i.e. [fd]cmp[lg]). + (lookup_label): Set DECL_IGNORED_P (for dwarf2out). + (expand_compare, expand_java_goto, expand_java_call): Don't + push_pending_block, since that only makes sense when verifying. + (merge_type_state): Different return codes. + (push_pending_block): A block may need to be verified more than once. + (expand_byte_code): Warn about unused code at code generation time. + (verify_jvm_instruction): Changed logic, since code may need to be + re-verified if type-state has changed. Also, better error handling. + Implement acmpeq, acmpne, pop, pop2, swap, checkcast, instanceof. + Improve newarray, anewarray, ?aload, athrow, + * java-tree.h (LABEL_CHANGED): New macro. + +1997-08-05 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * decl.c (soft_athrow_node): New global variable initialized. + * javaop.def (i2b, i2c, i2s): Invoke CONVERT2 + * typeck.c (convert): Added support for REAL_TYPE. + (convert_to_char): New function. + (convert): Handle CHAR_TYPE. + * expr.c (expand_java_arraystore): Modified because CHAR/BYTE/BOOLEAN/ + SHORT now expect INT but store as CHAR/BYTE/BOOLEAN/SHORT. + (expand_java_arrayload): CHAR/BYTE/BOOLEAN/SHORT now convert result to + promoted type. + (verify_jvm_instructions): Added break a the end of bogus unop: label. + (OPCODE_<b|c|s>astore): Pop an int operand from the type stack + (OPCODE_<b|c|s>astore): Push the promoted type onto the stack + (process_jvm_instruction): New macro CONVERT2 for i2c, i2s and i2b. + (JAVA_ARRAY_LENGTH_OFFSET, JAVA_ARRAY_DATA_OFFSET): Modified + to Use The Right Things. + (pop_type): Accept CHAR/BYTE/BOOLEAN/SHORT promoted type as + compatible with INT. BOOLEAN is made equivalent to BYTE. + (OPCODE_athrow, OPCODE_aconst_null, OPCODE_ifnull, + OPCODE_ifnonnull): Now supported. + (build_java_athrow): New function. + +1997-08-04 Per Bothner <bothner@cygnus.com> + + Rename method name <init> to match G++ (and fix mangling). + * class.c (layout_class): Replace method name of <init> by class name. + (make_method_value): Do inverse renaming of constructor from <init>. + * java-tree.h (DECL_CONSTRUCTOR_P): New macro. + * typeck.c (lookup_java_constructor): New function. + * expr.c (expand_invoke): If method_name is <init>, call + lookup_java_constructor to find constructor. + + * parse.c (get_constant): Handle CONSTANT_Float and CONSTANT_Double. + +1997-08-01 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.c (get_class_constant): Modified to handle array "classes" + * typeck.c (set_local_type): Bug fixed when filling type_map[] with + wide type. + (convert): Modified to handle real type. + * java-tree.h (soft_badarrayindex_node, soft_anewarray_node, + soft_multianewarray, soft_newarray_node, soft_throw_node): New global + variables declared. + * decl.c (soft_badarrayindex_node, soft_anewarray_node, + soft_multianewarray, soft_newarray_node, soft_throw_node): New + global variables initialized. + (find_local_variable): Handles the case of a pointer + (end_java_method): Restore the use of one more scope + * expr.c (build_java_arraynull_check, build_java_arrayaccess, + build_java_array_length_access, expand_java_arrayload, + expand_java_arraystore, expand_java_array_length, + expand_java_multianewarray, expand_java_anewarray, + build_java_check_indexed_type, is_array_type_p, + build_java_throw_out_of_bound_exception): New functions. + (STORE_INTERNAL): Now forces type of the decl to be type of the value. + (OPCODE_arraylength, OPCODE_newarray, OPCODE_<t>astore, + OPCODE_<t>aload): Implemented code for verification. + (ARRAY_STORE, ARRAY_LOAD, ARRAY_LENGTH, ARRAY_NEW_PTR, ARRAY_NEW_NUM + ARRAY_NEW_MULTI): Macro defined. + (CONVERT): Modified to invoke convert(). + (case OPCODE_aload2): Fixed index typo from 2 to 1. + +1997-07-31 Per Bothner <bothner@cygnus.com> + + * class.c (push_class): Set DECL_ARTIFICIAL (for dbxout.c). + (build_class_ref, is_compiled_class): Handle pointer-to-record types. + (make_class_data): Field name needs '/' as package prefix. + * expr.c (type_stack_dup, java_stack_dup): Fix fencepost errors. + +1997-07-25 Per Bothner <bothner@cygnus.com> + + Implement debug information for local variables. + * java-tree.h (DECL_CODE_LENGTH, DECL_ARG_SLOT_COUNT, + DECL_LOCAL_SLOT_NUMBER, DECL_LOCAL_START_PC, DECL_LOCAL_END_PC, + DECL_LOCAL_SLOT_CHAIN): New macros. + (struct lang_decl_var): New type. + * parse.c (give_name_to_locals): Move to decl.c. + * decl.c (give_name_to_locals): Re-written to Do The Right Thing. + (start_java_method): Re-write parameter handling. + (pending_local_decls): New global variable. + (push_jvm_slot, maybe_pushlevels, maybe_poplevels): New functions. + (find_local_variable): Accept pc so we can skips decls not in range. + (struct binding_level): Add end_pc field. + * expr.c (expand_byte_code): Call maybe_pushlevels and maybe_poplevels. + (various): Change so current pc gets passed to find_local_variable. + + * decl.c (init_decl_processing): Re-arrange fields in + class_type_node and and method_type_node to match kaffe 0.9.1. + * class.c (make_method_value, make_class_data): Update + initializations to match. + +1997-07-16 Per Bothner <bothner@cygnus.com> + + * class.c (unicode_mangling_length, emit_unicode_mangled_name, + append_gpp_mangled_name, append_gpp_mangled_type): New functions. + (push_super_field): New function. + (make_class_data): Handle inheritance of class static initializer. + (layout_class): New name mangling. + * constants.c (build_constant_data_ref): Init type of data array + to a one-element array. + (build_constants_constructor): Set DECL_SIZE from complete array type. + * decl.c: Rename class_type, object_type etc to class_type_node, + object_type_node etc. Make former inherit from latter. + * expr.c (expand_invoke): Add cast of function address. + * java-tree.h (TYPE_ARRAY_ELEMENT, PUSH_SUPER_VALUE): New. + * parse.c (yyparse): Don't call layout_class here. + * typeck.c (build_java_array_type): Set TYPE_ARRAY_ELEMENT. + +1997-06-14 Per Bothner <bothner@cygnus.com> + + * decl.c, class.c: Update method type to match latest Kaffe snapshot. + * constants.c (lookup_name_constant): Renamed to alloc_name_constant. + (alloc_class_constant): New. + * expr.c (expand_invoke): Make sure method's class is initialized. + * class.c (interits_from_p, emit_register_class): New functions. + * parse.c (yyparse): Call emit_register_class. + +1997-06-09 Per Bothner <bothner@cygnus.com> + + * constants.c: New file, to handle constant pool. + * Makefile.in (JAVA_OBJS): Add constants.o. + * decl.c (init_decl_processing): Update, fix, finish various structs. + (pushdecl_top_level): New. + * parse.c (layout_class): Moved to class.c. + * expr.c (java_push_constant_from_pool): New function. + * class.c (build_class_ref): Make work fully + (make_class_data): Emit super-class, constant pool, interface vector. + +1997-06-03 Per Bothner <bothner@cygnus.com> + + java-tree.h (DECL_SIGNATURE, BCODE_EMITTED): Remove. + (LABEL_VERIFIED, BCODE_EXCEPTION_TARGET, TYPE_ARRAY_P): New. + * class.c (class_depth): New function. + (lookup_named_class): Replaced by new function lookup_class. + * decl.c (object_type_node, string_type_node): New. + Remove various types that we no longer need. + * expr.c (verify_jvm_instructions): New separate verifier pass. + (push_type, pop_type): New functions for verifier. + (type_stack_dup, pop_argument_types, merge_types): Likewise. + (expand_byte_code): Simplify, since we assume already verified. + (expand_invoke): Now mostly works. + * javaop.def: Rename ldc1->ldc, ldc2->ldc_w, ldc2w->ldc2_w. + * lang.c (main_class): Move to parse.c. Don't make_class yet. + * parse.c: Wait to allocate class object until we know its name. + (layout_class): Calculate DECL_VINDEX for each virtual method. + * typeck.c (get_array_type): Rename to ... + (build_java_array_type): ... and provide working implementation. + (build_java_signature): New function - build Java signature of type. + (set_java_signature): New function - cache signature with type. + (lookup_java_method): New function. + +1997-05-06 Per Bothner <bothner@deneb.cygnus.com> + + * class.c (ident_subst): Take extra SUFFIX parameter. + (add_field): Set DECL_ASSEMBLER_NAME of static fields; more. + (set_constant_value, build_static_field_ref, is_compiled_class): New. + (build_class_ref): Actually implement. + * decl.c, java-tree.h: Renamed some xx_type to xx_type_node. + * decl.c (builtin_function): New. + (init_decl_processing): Update for current Kaffe. Declare some + builtin Kaffe functions. + * expr.c (build_address_of): New. + (expand_java_NEW, expand_java_INSTANCEOF, expand_java_CHECKCAST): + Renamed (from expand_java_new etc), and added working implementations. + (build_field_ref): Now also handle static fields. + (expand_invoke): Implement invokestatic, and start implement rest. + * java-opcodes.h: Use javaop.def to avoid duplicated list. + * javaop.def: Rename invokevirt -> invokevirtual. + * lang.c (use_handles): Removed. + * parse.c: Add support for ConstantValue attribute. + Handle nested loading of a class. (JPOOL_UTF): New. + +1997-03-11 Per Bothner <bothner@deneb.cygnus.com> + + * expr.c (expand_java_pushc): Support #ifndef REAL_ARITHMETIC case. + +1997-02-27 Per Bothner <bothner@deneb.cygnus.com> + + * Make-lang.in (java.install-man): New empty rule. + * typeck.c (set_local_type): New function. + * expr.c (STORE_INTERNAL): Call find_local_variable, + not find_stack_slot. Call set_local_type. + +1997-02-12 Per Bothner <bothner@kalessin.cygnus.com> + + * java-tree.h: Various new macros for constructing RECORD_TYPEs, + and building RECORD_TYPE CONSTRUCTORs. + Also support for creating Utf8Const objects from an INDETIFIER_NODE. + + * lang.c (use_handles): Change the default to 0. + * decl.c: Define and build class_type, field_type, utf8const_type. + * class.c (make_class_data, make_field_value, + get_access_flags_from_decl, build_class_ref, build_utf8_ref, + hashUtf8String, strLengthUtf8, mangled_classname: + Functions to build reflective data structures. + * parse.c (yyparse): Call make_class_data. + + * jcf-io.c (open_class, find_classfile): New functions. + * jcf-dump.c: Support reading classfile from explicitly-named + class file (without CLASSPATH searching). + +1996-10-24 Per Bothner <bothner@deneb.cygnus.com> + + * jcf-reader.c: Add parameter list to HANDLE_CONSTANT_Utf8. + * parse.c (JPOOL_UTF_LENGTH, JPOOL_UTF_DATA, HANDLE_CONSTANT_Utf8): + Override jcf-reader macros so CONSTANT_Utf8 becomes tree node here. + (get_constant): Now trivial for CONSTANT_Utf8. + + * jcf.h: Make NEW_CPOOL the default. + * jcf.h, jcf-reader.c, parse.c: Remove support for !NEW_CPOOL. + +1996-10-24 Per Bothner <bothner@deneb.cygnus.com> + + New directory. + + +Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/java/ChangeLog.ptr b/gcc/java/ChangeLog.ptr new file mode 100644 index 000000000..3243223f5 --- /dev/null +++ b/gcc/java/ChangeLog.ptr @@ -0,0 +1,25 @@ +2007-06-14 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * except.c (build_exception_object_ref): + Use fold_build1 instead of build1 for NEGATE_EXPR. + +2007-05-12 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * class.c (make_class_data): Build the index in sizetype. + Use POINTER_PLUS_EXPR instead of PLUS_EXPR when + adding to a pointer type. + (build_symbol_entry): Likewise. + * expr.c (build_java_arrayaccess): Likewise. + (build_field_ref): Likewise. + (build_known_method_ref): Likewise. + (build_invokevirtual): Likewise. + * except.c (build_exception_object_ref): Do a + NEGATIVE and then a POINTER_PLUS_EXPR instead + of a MINUS_EXPR. + + +Copyright (C) 2007 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/java/ChangeLog.tree-ssa b/gcc/java/ChangeLog.tree-ssa new file mode 100644 index 000000000..09a263a76 --- /dev/null +++ b/gcc/java/ChangeLog.tree-ssa @@ -0,0 +1,367 @@ +2004-05-10 Andrew Haley <aph@redhat.com> + + * java-gimplify.c (java_gimplify_expr): Copy the LHS of a binary + expression into a temporary variable. + + (java_gimplify_new_array_init): Set the DECL_CONTEXT of array and + tmp to current_function_decl. + +2004-04-13 Diego Novillo <dnovillo@redhat.com> + + * expr.c (build_expr_wfl): Don't check type nodes for + side effects. + +2004-04-12 Diego Novillo <dnovillo@redhat.com> + + * decl.c (java_expand_stmt): Remove. + * lang.c (LANG_HOOKS_RTL_EXPAND_STMT): Remove. + +2004-02-24 Richard Henderson <rth@redhat.com> + + * java-gimplify.c (java_gimplify_new_array_init): Remove extra + argument building BLOCK. + +2004-02-19 Steven Bosscher <stevenb@suse.de> + + * decl.c (poplevel): Don't output nested inline functions. + +2004-02-16 Richard Henderson <rth@redhat.com> + + * builtins.c (java_build_function_call_expr): Add static chain + operand to call_expr. + +2004-01-29 Richard Henderson <rth@redhat.com> + + PR java/12906 + * decl.c (maybe_pushlevels): Careful with TREE_CHAIN when + registering decls with push_jvm_slot. + +2003-12-10 Diego Novillo <dnovillo@redhat.com> + + * parse.y (resolve_field_access): Remove superfluous + initialization of decl. + +2003-12-10 Richard Henderson <rth@redhat.com> + + * lang.c (java_post_options): Don't ever use rtl inlining. + +2003-12-06 Jan Hubicka <jh@suse.cz> + + * parse.y (resolve_field_access): Initialize decl. + +2003-11-31 Richard Henderson <rth@redhat.com> + + * lang.c (java_start_inlining): Remove. + (LANG_HOOKS_TREE_INLINING_START_INLINING): Remove. + +2003-11-31 Richard Henderson <rth@redhat.com> + + * jcf-parse.c (java_parse_file): Finalize cgraph after emitting + class tables. + +2003-11-24 Richard Henderson <rth@redhat.com> + + * Make-lang.in (parse.o): Remove -Wno-error. + +2003-11-20 Richard Henderson <rth@redhat.com> + + * constants.c (build_constant_data_ref): Lay out the array type. + +2003-11-20 Richard Henderson <rth@redhat.com> + + * class.c (build_indirect_class_ref): Use convert. + * constants.c (build_constant_data_ref): Fix type on the decl + and return that directly. + (build_constants_constructor): Remove kruft to match. + (build_ref_from_constant_pool): Use ARRAY_REF. + * expr.c (build_java_indirect_ref): Use convert. + (build_known_method_ref): Likewise. + * parse.y (patch_string_cst): Likewise. + + * class.c (finish_class): Kill code to output_inline_function. + +2003-11-12 Jason Merrill <jason@redhat.com> + + PR optimization/12547 + * lang.c (java_tree_inlining_walk_subtrees): Restore. + (LANG_HOOKS_TREE_INLINING_WALK_SUBTREES): Restore. + +2003-11-12 Richard Henderson <rth@redhat.com> + + * java-gimplify.c (java_gimplify_expr): Use annotate_with_locus + instead of annotate_all_with_locus. + +2003-11-10 Richard Henderson <rth@redhat.com> + + * expr.c: Use append_to_statement_list instead of add_tree. + +2003-10-30 Richard Henderson <rth@redhat.com> + + * java-gimplify.c (cleanup_compound_expr): Remove. + (cleanup_try_finally_expr): Remove. + (java_gimplify_expr): Don't call them. + (java_gimplify_case_expr): Use create_artificial_label. + (java_gimplify_default_expr): Likewise. + +2003-10-30 Richard Henderson <rth@redhat.com> + + * expr.c (expand_java_switch, expand_java_add_case): New. + (LOOKUP_SWITCH, TABLE_SWITCH): Use them. + +2003-10-23 Richard Henderson <rth@redhat.com> + + * java-gimplify.c (java_gimplify_expr): Return gimplify_status. + +2003-10-14 Richard Henderson <rth@redhat.com> + + * decl.c (finish_method): Set cfun->function_end_locus. + * java-gimplify.c (java_gimplify_expr): Set input_location + for EXPR_WITH_FILE_LOCATION. Use annotate_all_with_locus. + * parse.h (DECL_SOURCE_LINE_MERGE): Remove. + (DECL_SOURCE_LINE_FIRST, DECL_SOURCE_LINE_LAST): Remove. + * parse.y (missing_return_error): Use DECL_FUNCTION_LAST_LINE. + (finish_method_declaration): Likewise. + (start_artificial_method_body): Likewise. + (lookup_cl): Use DECL_SOURCE_LINE. + (start_complete_expand_method): Likewise. + (java_complete_lhs): Fix IS_EXPR_CODE_CLASS check. + +2003-10-13 Richard Henderson <rth@redhat.com> + + * decl.c (java_add_stmt): Use annotate_with_locus. + +2003-10-13 Richard Henderson <rth@redhat.com> + + * expr.c (build_java_jsr): Don't emit LABEL_EXPR or + load_type_state here. + +2003-10-12 Richard Henderson <rth@redhat.com> + + * class.c (build_utf8_ref, get_dispatch_table): Set TREE_INVARIANT. + (make_class_data, build_symbol_entry, emit_symbol_table): Likewise. + * decl.c (java_init_decl_processing): Likewise. + * except.c (prepare_eh_table_type): Likewise. + * parse.y (patch_assignment, patch_binop): Likewise. + (patch_string_cst, patch_new_array_init): Likewise. + * resource.c (compile_resource_data): Likewise. + +2003-10-08 Jeff Sturm <jsturm@one-point.com> + + * decl.c (cgraph.h): Include. + (tree-inline.h, tree-dump.h, tree-flow.h): Remove includes. + (complete_start_java_method): Remove. + (start_java_method): Combine with complete_start_java_method. + Remove dead code. + (end_java_method): Don't patch or expand tree. + Use finish_method. + (finish_method): New function. + (java_expand_body): Use tree_rest_of_compilation. + (java_expand_stmt): New function. + + * java-gimplify.c (tree-dump.h): Include. + (java_genericize): New function. + (dump_java_tree): Declare. New function. + + * java-tree.h (start_complete_expand_method): Remove declaration. + (complete_start_java_method): Remove declaration. + (finish_method, java_expand_stmt, java_genericize): Declare. + + * lang.c (LANG_HOOKS_RTL_EXPAND_STMT): Define. + + * parse.y (tree-inline.h, tree-dump.h, tree-flow.h, + cgraph.h): Remove includes. + (start_complete_expand_method): Declare. + (source_end_java_method): Don't expand tree. Use finish_method. + Reset current_function_decl. + (java_expand_method_bodies): Don't patch tree for class + initialization or method synchronization. + +2003-10-01 Richard Henderson <rth@redhat.com> + + * decl.c (end_java_method): Invoke remove_useless_stmts_and_vars + and lower_eh_constructs. + * parse.y (source_end_java_method): Likewise. + +2003-09-24 Jason Merrill <jason@redhat.com> + + * decl.c, jcf-parse.c, jcf-write.c, parse.h, parse.y, resource.c: + Revert from TREE_LOCUS to DECL_SOURCE_LOCATION. + +2003-09-18 Richard Henderson <rth@redhat.com> + + * lang.c (java_estimate_num_insns): Take an expr, not a decl. + +2003-08-12 Diego Novillo <dnovillo@redhat.com> + + * java-gimplify.c (java_gimplify_block): If the body is a + NULL_TREE, return an empty statement. + +2003-08-08 Jason Merrill <jason@redhat.com> + + * parse.y (source_end_java_method): Support + !keep_function_tree_in_gimple_form. + Do TDI_generic dump. + +2003-07-31 Andrew Haley <aph@redhat.com> + + * java-tree.h: (add_stmt_to_compound): New function. + (java_add_stmt): New function. + (java_add_local_var): New function. + (get_stmts): New function. + * java-gimplify.c (java_gimplify_block): Allow for null body. + * except.c (link_handler): Set h->stmt. + (expand_start_java_handler): Build a TRY_CATCH_EXPR for this + range; don't expand_eh_region_start. + (expand_end_java_handler): Rewrite. + * java-except.h (stmt): New field. + * expr.c (flush_quick_stack): Replace expand_assignment with + java_add_stmt. + (java_stack_dup): Replace emit_move_insn with java_add_stmt. + (build_java_athrow): Replace expand_expr_stmt with java_add_stmt. + (build_java_jsr): Replace emit_jump with java_add_stmt (build (GOTO_EXPR)) + (build_java_ret): Replace expand_computed_goto with + java_add_stmt (build (GOTO_EXPR)) + (expand_java_arraystore): Replace expand_assignment with + java_add_stmt. + (expand_java_return): Replace expand_return with + java_add_stmt (build (RETURN_EXPR)) + (expand_load_internal): Remove layout_decl, DECL_REGISTER, + expand_decl, and expand_decl_init. Instead, add the local + variable and a MODIFY_EXPR to the current tree. + (expand_iinc): Replace expand_assignment with + java_add_stmt. + (expand_compare): Replace expand_cond with + java_add_stmt(build (COND_EXPR)) + (expand_java_goto): Replace expand_goto with + java_add_stmt (build (GOTO_EXPR)) + (expand_invoke): Replace expand_expr_stmt with java_add_stmt. + (build_jni_stub): Generate a BIND_EXPR to hold the block we've + created. Don't distinguish between source and byte compiler. + (expand_java_field_op): Replace expand_assignment with + java_add_stmt. + (java_expand_expr): Abort. No-one should call this function any + more. + (expand_byte_code): Replace expand_label with + java_add_stmt (build (LABEL_EXPR)) + (process_jvm_instruction): Replace build (JAVA_EXC_OBJ_EXPR) with + build_exception_object_ref. Replace expand_assignment with + java_add_stmt. + * except.c (link_handler): Null stmt field. + (expand_start_java_handler): Don't expand_eh_region_start. + Instead, generate a TRY_CATCH_EXPR and insert it into the tree + we're building. + (expand_end_java_handler): Don't expand_start_all_catch. Instead, + build a TRY_FINALLY_EXPR and wrap the catch block with it. + Don't expand_end_all_catch. + * decl.c (push_jvm_slot): Call pushdecl(). + (find_local_variable): Give symbolic names to unnamed local + variables. + (struct binding_level: stmts): New field. + (poplevel): If any statements have been generated at this level, + create a BIND_EXPR to hold them and copy the variables to it. If + we are at the outermost level, save this BIND_EXPR in the + DECL_SAVED_TREE of this function. + (maybe_pushlevels): Don't expand_start_bindings. + (maybe_poplevels): Don't expand_end_bindings. + (complete_start_java_method): Reorganize static initialization and + synchronization logic for source compiler. Remove pushlevel and + expand_start_bindings for byte compiler. + (end_java_method): Don't expand_end_bindings. Add static + initialization and synchronization logic for byte compiler. + Set cfun->x_whole_function_mode_p. + Call gimplify_function_tree and optimize_function_tree and + expand_expr_stmt. + (add_stmt_to_compound): New. + (java_add_stmt): New. + (java_add_local_var): New. + (get_stmts): New. + * parse.y (add_stmt_to_compound): Remove. + * jcf-parse.c (parse_class_file): Don't call expand_expr_stmt for + a native method -- we'll do that later. + +2003-07-27 Andreas Jaeger <aj@suse.de> + + * expr.c (build_expr_wfl): Convert remaining K&R prototypes + to ISO C90. + +2003-06-28 Jeff Sturm <jsturm@one-point.com> + + * java-gimplify.c (java_gimplify_block): Rebuild BLOCK_SUBBLOCKS. + * lang.c (flag_disable_gimple): Remove initialization. + +2003-06-23 Jeff Law <law@redhat.com> + + * Make-lang.in (java-gimplify.o): Add dependencies. + +2003-06-22 Jeff Sturm <jsturm@one-point.com> + + * parse.y (source_end_java_method): Don't attempt to inline + or optimize trees if flag_disable_gimple. + + * Make-lang.in (JAVA_OBJS): Remove java-tree-inline.o. + +2003-06-21 Jeff Sturm <jsturm@one-point.com> + + * Make-lang.in (JAVA_OBJS): Add java-gimplify.o. + + * decl.c (java_init_decl_processing): Initialize size_type_node. + (complete_start_java_method): Update DECL_SAVED_TREE. + (dump_function): Remove. + (java_optimize_inline): Remove. + + * expr.c (always_initialize_class_p): Initialize to 1. + (build_instanceof): Build proper boolean condition. + (build_class_init): Set DECL_INITIAL for init_test_decl. + (force_evaluation_order): Don't save_expr a void expr node. + + * java-gimplify.c: New file. + + * java-tree.h (java_gimplify_expr): Declare. + + * lang.c (java_tree_inlining_walk_subtrees): Remove declaration. + (flag_optimize_sci): Initialize to 0. + (LANG_HOOKS_TREE_INLINING_WALK_SUBTREES): Remove define. + (LANG_HOOKS_SIMPLIFY_EXPR): Add define. + (java_tree_inlining_walk_subtrees): Remove function. + (java_init): Set flag_disable_gimple to 1. + + * parse.y (source_end_java_method): Set cfun->x_whole_function_mode_p. + Gimplify. Optimize tree before expanding. Update comments. + (java_expand_method_bodies): Always save DECL_SAVED_TREE. + (patch_invoke): Don't save_expr force_evaluation_order result. + (patch_assignment): Use simpler compound expression. + (patch_if_else_statement): Don't optimize constant condition nodes. + +2003-03-02 Diego Novillo <dnovillo@redhat.com> + + * class.c: Replace DECL_SOURCE_FILE with TREE_FILENAME and + DECL_SOURCE_LINE with TREE_LINENO everywhere. + +2003-02-03 Diego Novillo <dnovillo@redhat.com> + + * parse.y (qualify_ambiguous_name): Initialize variable 'decl'. + +2003-01-15 Jeff Law <law@redhat.com> + + * class.c: Use TREE_FILENAME and TREE_LINENO to extract file/line + information from tree nodes. Use annotate_with_file_line to + annotate tree nodes with file/line information. + * decl.c, jcf-parse.c, jcf-write.c, parse.h: Likewise. + * parse.y: Likewise. + * expr.c (java_expand_expr): Handle EXPR_WITH_FILE_LOCATION nodes. + (build_expr_wfl): New function. + * java-tree.def (EXPR_WITH_FILE_LOCATION): New node. + * java-tree.h (EXPR_WFL_*): New macros. + (build_expr_wfl): Declare. + +Local Variables: +mode: change-log +change-log-default-name: "ChangeLog.tree-ssa" +End: + + +Copyright (C) 2003, 2004 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in new file mode 100644 index 000000000..f5852b405 --- /dev/null +++ b/gcc/java/Make-lang.in @@ -0,0 +1,412 @@ +# Top level -*- makefile -*- fragment for the GNU compiler for the Java(TM) +# language. +# Copyright (C) 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +#This file is part of GCC. + +#GCC is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 3, or (at your option) +#any later version. + +#GCC is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. + +#You should have received a copy of the GNU General Public License +#along with GCC; see the file COPYING3. If not see +#<http://www.gnu.org/licenses/>. + +#Java and all Java-based marks are trademarks or registered trademarks +#of Sun Microsystems, Inc. in the United States and other countries. +#The Free Software Foundation is independent of Sun Microsystems, Inc. + +# This file provides the language dependent support in the main Makefile. +# Each language makefile fragment must provide the following targets: +# +# foo.all.cross, foo.start.encap, foo.rest.encap, +# foo.install-common, foo.install-man, foo.install-info, foo.install-pdf, +# foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall, +# foo.mostlyclean, foo.clean, foo.distclean, +# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4 +# +# where `foo' is the name of the language. +# +# It should also provide rules for: +# +# - making any compiler driver (eg: g++) +# - the compiler proper (eg: jc1) +# - define the names for selecting the language in LANGUAGES. + +# Actual names to use when installing a native compiler. +JAVA_INSTALL_NAME := $(shell echo gcj|sed '$(program_transform_name)') +JAVA_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcj|sed '$(program_transform_name)') + +XGCJ = gcj + +# Define the names for selecting java in LANGUAGES. +java: jc1$(exeext) $(XGCJ)$(exeext) jvgenmain$(exeext) jcf-dump$(exeext) + +# Define the name of target independent tools to be installed in $(bindir) +# Names are subject to changes +JAVA_TARGET_INDEPENDENT_BIN_TOOLS = jcf-dump + +# Tell GNU make to ignore these if they exist. +.PHONY: java + +jvspec.o: $(srcdir)/java/jvspec.c $(SYSTEM_H) coretypes.h $(TM_H) \ + $(GCC_H) $(CONFIG_H) java/jcf.h java/javaop.h $(OPTS_H) + (SHLIB_LINK='$(SHLIB_LINK)'; \ + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \ + $(INCLUDES) $(srcdir)/java/jvspec.c $(OUTPUT_OPTION)) + +# Create the compiler driver for $(XGCJ). +$(XGCJ)$(exeext): $(GCC_OBJS) jvspec.o java/jcf-path.o version.o \ + prefix.o intl.o $(LIBDEPS) $(EXTRA_GCC_OBJS) + +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \ + jvspec.o java/jcf-path.o prefix.o intl.o \ + version.o $(EXTRA_GCC_OBJS) $(LIBS) + +# Create a version of the $(XGCJ) driver which calls the cross-compiler. +$(XGCJ)-cross$(exeext): $(XGCJ)$(exeext) + -rm -f $(XGCJ)-cross$(exeext) + cp $(XGCJ)$(exeext) $(XGCJ)-cross$(exeext) + +java.srcextra: + +# Executables built by this Makefile: +JAVA_OBJS = java/class.o java/decl.o java/expr.o \ + java/constants.o java/lang.o java/typeck.o java/except.o \ + java/verify-glue.o java/verify-impl.o \ + java/zextract.o java/jcf-io.o java/win32-host.o java/jcf-parse.o java/mangle.o \ + java/mangle_name.o java/builtins.o java/resource.o \ + java/jcf-depend.o \ + java/jcf-path.o java/boehm.o java/java-gimplify.o + +JCFDUMP_OBJS = java/jcf-dump.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \ + java/win32-host.o java/zextract.o errors.o version.o ggc-none.o intl.o + +JVGENMAIN_OBJS = java/jvgenmain.o java/mangle_name.o errors.o intl.o + +java_OBJS = $(sort $(JAVA_OBJS) $(JCFDUMP_OBJS) $(JVGENMAIN_OBJS)) jvspec.o + +# Use strict warnings for this front end. +java-warn = $(STRICT_WARN) + +# String length warnings +jvspec.o-warn = -Wno-error + +jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS) attribs.o + rm -f $@ + +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ + $(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS) attribs.o $(BACKENDLIBS) + +jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIBDEPS) + rm -f $@ + +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \ + $(CPPLIBS) $(ZLIB) $(LDEXP_LIB) $(LIBS) + +jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS) + rm -f $@ + +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) \ + $(LIBS) + +# +# Build hooks: + +java.all.cross: $(XGCJ)-cross$(exeext) +java.start.encap: $(XGCJ)$(exeext) +java.rest.encap: + + +java.tags: force + cd $(srcdir)/java; etags -o TAGS.sub *.c *.h --language=none \ + --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' java-tree.def; \ + etags --include TAGS.sub --include ../TAGS.sub + + +java.info: doc/gcj.info + +java.srcinfo: doc/gcj.info + -cp -p $^ $(srcdir)/doc + +java.dvi: doc/gcj.dvi + +JAVA_PDFFILES = doc/gcj.pdf + +java.pdf: $(JAVA_PDFFILES) + +JAVA_HTMLFILES = $(build_htmldir)/java + +java.html: $(JAVA_HTMLFILES)/index.html + +JAVA_MANFILES = doc/gcj.1 doc/jcf-dump.1 doc/gij.1 \ + doc/jv-convert.1 doc/grmic.1 \ + doc/gcj-dbtool.1 doc/gc-analyze.1 doc/aot-compile.1 \ + doc/rebuild-gcj-db.1 + +java.man: $(JAVA_MANFILES) + +java.srcman: $(JAVA_MANFILES) + -cp -p $^ $(srcdir)/doc + +check-java : +check-java-subtargets : + +# Install hooks: +# jc1, gcj, and jvgenmain are installed elsewhere as part +# of $(COMPILERS). + +# Install gcj as well as the target-independent tools. +java.install-common: installdirs + -if [ -f $(XGCJ)$(exeext) ]; then \ + rm -f $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \ + $(INSTALL_PROGRAM) $(XGCJ)$(exeext) $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \ + chmod a+x $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \ + if [ -f $(XGCJ)-cross$(exeext) ]; then \ + true; \ + else \ + rm -f $(DESTDIR)$(bindir)/$(JAVA_TARGET_INSTALL_NAME)$(exeext); \ + ( cd $(DESTDIR)$(bindir) && \ + $(LN) $(JAVA_INSTALL_NAME)$(exeext) $(JAVA_TARGET_INSTALL_NAME)$(exeext) ); \ + fi ; \ + fi ; \ + for tool in $(JAVA_TARGET_INDEPENDENT_BIN_TOOLS); do \ + tool_transformed_name=`echo $$tool|sed '$(program_transform_name)'`; \ + if [ -f $$tool$(exeext) ]; then \ + rm -f $(DESTDIR)$(bindir)/$$tool_transformed_name$(exeext); \ + $(INSTALL_PROGRAM) $$tool$(exeext) $(DESTDIR)$(bindir)/$$tool_transformed_name$(exeext); \ + chmod a+x $(DESTDIR)$(bindir)/$$tool_transformed_name$(exeext); \ + fi ; \ + done + +java.install-plugin: +java.install-man: + +java.uninstall: + -rm -rf $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext) + -rm -rf $(DESTDIR)$(man1dir)/$(JAVA_INSTALL_NAME)$(man1ext) + -rm -rf $(DESTDIR)$(man1dir)/jcf-dump$(man1ext) + -rm -rf $(DESTDIR)$(man1dir)/gij$(man1ext) + -rm -rf $(DESTDIR)$(man1dir)/jv-convert$(man1ext) + -rm -rf $(DESTDIR)$(man1dir)/gcj-dbtool$(man1ext) + -rm -rf $(DESTDIR)$(man1dir)/aot-compile$(man1ext) + -rm -rf $(DESTDIR)$(man1dir)/rebuild-gcj-db$(man1ext) + +java.install-info: $(DESTDIR)$(infodir)/gcj.info + +java.install-pdf: $(JAVA_PDFFILES) + @$(NORMAL_INSTALL) + test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc" + @list='$(JAVA_PDFFILES)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(pdf__strip_dir) \ + echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \ + $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \ + done + +java.install-html: $(JAVA_HTMLFILES) + @$(NORMAL_INSTALL) + test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)" + @list='$(JAVA_HTMLFILES)'; for p in $$list; do \ + if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \ + f=$(html__strip_dir) \ + if test -d "$$d$$p"; then \ + echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \ + $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ + echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \ + else \ + echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \ + fi; \ + done +# +# Clean hooks: +# A lot of the ancillary files are deleted by the main makefile. +# We just have to delete files specific to us. + +java.mostlyclean: + -rm -f java/*$(objext) $(DEMANGLER_PROG) + -rm -f java/*$(coverageexts) + -rm -f jc1$(exeext) $(XGCJ)$(exeext) jvgenmain$(exeext) \ + jcf-dump$(exeext) s-java +java.clean: +java.distclean: + -rm -f java/config.status java/Makefile +java.maintainer-clean: + -rm -f $(docobjdir)/gcj.1 + -rm -f $(docobjdir)/jcf-dump.1 + -rm -f $(docobjdir)/gij.1 + -rm -f $(docobjdir)/jv-convert.1 + -rm -f $(docobjdir)/grmic.1 + -rm -f $(docobjdir)/gcj-dbtool.1 + -rm -f $(docobjdir)/gc-analyze.1 + -rm -f $(docobjdir)/aot-compile.1 + -rm -f $(docobjdir)/rebuild-gcj-db.1 +# +# Stage hooks: +# The main makefile has already created stage?/java. + +java.stage1: stage1-start + -mv java/*$(objext) stage1/java +java.stage2: stage2-start + -mv java/*$(objext) stage2/java +java.stage3: stage3-start + -mv java/*$(objext) stage3/java +java.stage4: stage4-start + -mv java/*$(objext) stage4/java +java.stageprofile: stageprofile-start + -mv java/*$(objext) stageprofile/java +java.stagefeedback: stageprofile-start + -mv java/*$(objext) stagefeedback/java + +# +# .o:.h dependencies. +JAVA_TREE_H = $(TREE_H) $(HASHTAB_H) java/java-tree.h + +java/jcf-dump.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h $(JAVA_TREE_H) \ + java/jcf-dump.c java/jcf-reader.c java/jcf.h java/javaop.h java/javaop.def \ + version.h $(GGC_H) intl.h java/zipfile.h +java/boehm.o: java/boehm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + $(TREE_H) $(JAVA_TREE_H) java/parse.h +java/builtins.o: java/builtins.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + $(JAVA_TREE_H) $(GGC_H) $(FLAGS_H) $(OPTABS_H) $(EXPR_H) langhooks.h \ + gt-java-builtins.h +java/class.o: java/class.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + $(JAVA_TREE_H) java/jcf.h java/parse.h toplev.h output.h $(GGC_H) \ + $(FUNCTION_H) gt-java-class.h +java/constants.o: java/constants.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \ + toplev.h $(SYSTEM_H) coretypes.h $(TM_H) $(GGC_H) gt-java-constants.h +java/decl.o: java/decl.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \ + toplev.h $(FLAGS_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + libfuncs.h java/java-except.h $(GGC_H) $(REAL_H) gt-java-decl.h \ + $(TARGET_H) $(CGRAPH_H) langhooks.h +java/except.o: java/except.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h $(REAL_H) \ + java/javaop.h java/java-opcodes.h java/java-except.h \ + toplev.h $(SYSTEM_H) coretypes.h +java/expr.o: java/expr.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h $(REAL_H) \ + java/javaop.h java/java-opcodes.h \ + java/java-except.h java/java-except.h java/parse.h \ + $(SYSTEM_H) coretypes.h $(TM_H) $(GGC_H) gt-java-expr.h $(TARGET_H) \ + tree-iterator.h +java/jcf-depend.o: java/jcf-depend.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + java/jcf.h +java/jcf-parse.o: java/jcf-parse.c $(CONFIG_H) $(JAVA_TREE_H) $(FLAGS_H) \ + input.h java/java-except.h $(SYSTEM_H) coretypes.h \ + java/parse.h $(GGC_H) debug.h $(REAL_H) gt-java-jcf-parse.h \ + java/jcf-reader.c java/zipfile.h java/jcf.h $(BITMAP_H) +java/jvgenmain.o: java/jvgenmain.c $(CONFIG_H) $(JAVA_TREE_H) $(SYSTEM_H) \ + coretypes.h $(TM_H) intl.h +java/lang.o: java/lang.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h input.h \ + $(SYSTEM_H) coretypes.h $(TM_H) $(DIAGNOSTIC_H) \ + langhooks.h $(LANGHOOKS_DEF_H) gt-java-lang.h $(OPTS_H) $(OPTIONS_H) \ + $(TARGET_H) +java/mangle.o: java/mangle.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) $(SYSTEM_H) \ + coretypes.h $(TM_H) $(GGC_H) gt-java-mangle.h $(LANGHOOKS_DEF_H) +java/mangle_name.o: java/mangle_name.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) \ + $(SYSTEM_H) coretypes.h $(GGC_H) +java/resource.o: java/resource.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(JAVA_TREE_H) java/jcf.h java/parse.h toplev.h output.h $(GGC_H) \ + $(TARGET_H) $(FUNCTION_H) gt-java-resource.h +java/typeck.o: java/typeck.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \ + $(SYSTEM_H) coretypes.h $(GGC_H) $(REAL_H) +java/win32-host.o: java/win32-host.c $(CONFIG_H) $(SYSTEM_H) coretypes.h java/jcf.h +java/verify-glue.o: java/verify-glue.c $(CONFIG_H) $(SYSTEM_H) $(JAVA_TREE_H) \ + coretypes.h java/verify.h +java/verify-impl.o: java/verify-impl.c $(CONFIG_H) java/verify.h $(SYSTEM_H) \ + coretypes.h java/jcf.h $(JAVA_TREE_H) +java/zextract.o: java/zextract.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + java/zipfile.h +java/java-gimplify.o: java/java-gimplify.c $(CONFIG_H) $(SYSTEM_H) \ + coretypes.h $(JAVA_TREE_H) $(GIMPLE_H) + +# jcf-io.o needs $(ZLIBINC) added to cflags. +java/jcf-io.o: java/jcf-io.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(JAVA_TREE_H) java/zipfile.h + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(ZLIBINC) $(srcdir)/java/jcf-io.c $(OUTPUT_OPTION) + +# jcf-path.o needs a -D. +java/jcf-path.o: java/jcf-path.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + java/jcf.h + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + -DLIBGCJ_ZIP_FILE='"$(datadir)/java/libgcj-$(version).jar"' \ + -DDEFAULT_TARGET_VERSION=\"$(version)\" \ + $(srcdir)/java/jcf-path.c $(OUTPUT_OPTION) + +TEXI_JAVA_FILES = java/gcj.texi $(gcc_docdir)/include/fdl.texi \ + $(gcc_docdir)/include/gpl_v3.texi $(gcc_docdir)/include/gcc-common.texi \ + gcc-vers.texi + +# Documentation +doc/gcj.info: $(TEXI_JAVA_FILES) + if test "x$(BUILD_INFO)" = xinfo; then \ + rm -f doc/gcj.info*; \ + $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \ + -I $(gcc_docdir)/include -o $@ $<; \ + else true; fi + +doc/gcj.dvi: $(TEXI_JAVA_FILES) + $(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $< + +doc/gcj.pdf: $(TEXI_JAVA_FILES) + $(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $< + +$(build_htmldir)/java/index.html: $(TEXI_JAVA_FILES) + $(mkinstalldirs) $(@D) + rm -f $(@D)/* + $(TEXI2HTML) -I $(gcc_docdir) -I $(gcc_docdir)/include \ + -I $(srcdir)/java -o $(@D) $< + +.INTERMEDIATE: gcj.pod jcf-dump.pod gij.pod \ + jv-convert.pod grmic.pod gcj-dbtool.pod gc-analyze.pod + +gcj.pod: java/gcj.texi + -$(TEXI2POD) -D gcj < $< > $@ +jcf-dump.pod: java/gcj.texi + -$(TEXI2POD) -D jcf-dump < $< > $@ +gij.pod: java/gcj.texi + -$(TEXI2POD) -D gij < $< > $@ +jv-convert.pod: java/gcj.texi + -$(TEXI2POD) -D jv-convert < $< > $@ +grmic.pod: java/gcj.texi + -$(TEXI2POD) -D grmic < $< > $@ +gcj-dbtool.pod: java/gcj.texi + -$(TEXI2POD) -D gcj-dbtool < $< > $@ +gc-analyze.pod: java/gcj.texi + -$(TEXI2POD) -D gc-analyze < $< > $@ +aot-compile.pod: java/gcj.texi + -$(TEXI2POD) -D aot-compile < $< > $@ +rebuild-gcj-db.pod: java/gcj.texi + -$(TEXI2POD) -D rebuild-gcj-db < $< > $@ + +# Install the man pages. +java.install-man: installdirs \ + $(DESTDIR)$(man1dir)/$(JAVA_INSTALL_NAME)$(man1ext) \ + $(JAVA_TARGET_INDEPENDENT_BIN_TOOLS:%=doc/%.1) \ + doc/gij.1 doc/jv-convert.1 doc/grmic.1 \ + doc/gcj-dbtool.1 doc/gc-analyze.1 \ + doc/aot-compile.1 doc/rebuild-gcj-db.1 + for tool in $(JAVA_TARGET_INDEPENDENT_BIN_TOOLS) \ + gij jv-convert grmic gcj-dbtool gc-analyze aot-compile \ + rebuild-gcj-db; do \ + tool_transformed_name=`echo $$tool|sed '$(program_transform_name)'`; \ + man_name=$(DESTDIR)$(man1dir)/$${tool_transformed_name}$(man1ext); \ + rm -f $$man_name ; \ + for source_name in doc/$${tool}.1 $(srcdir)/doc/$${tool}.1 ; do \ + if test -f $$source_name; then \ + $(INSTALL_DATA) $$source_name $$man_name; \ + break; \ + else : ; \ + fi; \ + done ; \ + chmod a-x $$man_name ; \ + done + +$(DESTDIR)$(man1dir)/$(JAVA_INSTALL_NAME)$(man1ext): doc/gcj.1 installdirs + -rm -f $@ + -$(INSTALL_DATA) $< $@ + -chmod a-x $@ diff --git a/gcc/java/boehm.c b/gcc/java/boehm.c new file mode 100644 index 000000000..f4a9af619 --- /dev/null +++ b/gcc/java/boehm.c @@ -0,0 +1,238 @@ +/* Functions related to the Boehm garbage collector. + Copyright (C) 2000, 2003, 2004, 2006, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Tom Tromey <tromey@cygnus.com>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "double-int.h" +#include "tm.h" +#include "tree.h" +#include "java-tree.h" +#include "parse.h" +#include "diagnostic-core.h" + +static void mark_reference_fields (tree, double_int *, unsigned int, + int *, int *, int *, HOST_WIDE_INT *); + +/* A procedure-based object descriptor. We know that our + `kind' is 0, and `env' is likewise 0, so we have a simple + computation. From the GC sources: + (((((env) << LOG_MAX_MARK_PROCS) | (proc_index)) << DS_TAG_BITS) \ + | DS_PROC) + Here DS_PROC == 2. */ +#define PROCEDURE_OBJECT_DESCRIPTOR 2 + +/* Recursively mark reference fields. */ +static void +mark_reference_fields (tree field, + double_int *mask, + unsigned int ubit, + int *pointer_after_end, + int *all_bits_set, + int *last_set_index, + HOST_WIDE_INT *last_view_index) +{ + /* See if we have fields from our superclass. */ + if (DECL_NAME (field) == NULL_TREE) + { + mark_reference_fields (TYPE_FIELDS (TREE_TYPE (field)), + mask, ubit, + pointer_after_end, all_bits_set, + last_set_index, last_view_index); + field = DECL_CHAIN (field); + } + + for (; field != NULL_TREE; field = DECL_CHAIN (field)) + { + HOST_WIDE_INT offset; + HOST_WIDE_INT size_bytes; + + if (FIELD_STATIC (field)) + continue; + + offset = int_byte_position (field); + size_bytes = int_size_in_bytes (TREE_TYPE (field)); + + if (JREFERENCE_TYPE_P (TREE_TYPE (field)) + /* An `object' of type gnu.gcj.RawData is actually non-Java + data. */ + && TREE_TYPE (field) != rawdata_ptr_type_node) + { + unsigned int count; + unsigned int size_words; + unsigned int i; + + /* If this reference slot appears to overlay a slot we think + we already covered, then we are doomed. */ + gcc_assert (offset > *last_view_index); + + if (offset % (HOST_WIDE_INT) (POINTER_SIZE / BITS_PER_UNIT)) + { + *all_bits_set = -1; + *pointer_after_end = 1; + break; + } + + count = offset * BITS_PER_UNIT / POINTER_SIZE; + size_words = size_bytes * BITS_PER_UNIT / POINTER_SIZE; + + *last_set_index = count; + + /* First word in object corresponds to most significant byte of + bitmap. + + In the case of a multiple-word record, we set pointer + bits for all words in the record. This is conservative, but the + size_words != 1 case is impossible in regular java code. */ + for (i = 0; i < size_words; ++i) + *mask = double_int_setbit (*mask, ubit - count - i - 1); + + if (count >= ubit - 2) + *pointer_after_end = 1; + + /* If we saw a non-reference field earlier, then we can't + use the count representation. We keep track of that in + *ALL_BITS_SET. */ + if (! *all_bits_set) + *all_bits_set = -1; + } + else if (*all_bits_set > 0) + *all_bits_set = 0; + + *last_view_index = offset; + } +} + +/* Return the marking bitmap for the class TYPE. For now this is a + single word describing the type. */ +tree +get_boehm_type_descriptor (tree type) +{ + unsigned int count, log2_size, ubit; + int bit; + int all_bits_set = 1; + int last_set_index = 0; + HOST_WIDE_INT last_view_index = -1; + int pointer_after_end = 0; + double_int mask; + tree field, value, value_type; + + mask = double_int_zero; + + /* If the GC wasn't requested, just use a null pointer. */ + if (! flag_use_boehm_gc) + return null_pointer_node; + + value_type = java_type_for_mode (ptr_mode, 1); + /* If we have a type of unknown size, use a proc. */ + if (int_size_in_bytes (type) == -1) + goto procedure_object_descriptor; + + bit = POINTER_SIZE / BITS_PER_UNIT; + /* The size of this node has to be known. And, we only support 32 + and 64 bit targets, so we need to know that the log2 is one of + our values. */ + log2_size = exact_log2 (bit); + if (bit == -1 || (log2_size != 2 && log2_size != 3)) + { + /* This means the GC isn't supported. We should probably + abort or give an error. Instead, for now, we just silently + revert. FIXME. */ + return null_pointer_node; + } + bit *= BITS_PER_UNIT; + + /* Warning avoidance. */ + ubit = (unsigned int) bit; + + if (type == class_type_node) + goto procedure_object_descriptor; + + field = TYPE_FIELDS (type); + mark_reference_fields (field, &mask, ubit, + &pointer_after_end, &all_bits_set, + &last_set_index, &last_view_index); + + /* If the object is all pointers, or if the part with pointers fits + in our bitmap, then we are ok. Otherwise we have to allocate it + a different way. */ + if (all_bits_set != -1 || (pointer_after_end && flag_reduced_reflection)) + { + /* In this case the initial part of the object is all reference + fields, and the end of the object is all non-reference + fields. We represent the mark as a count of the fields, + shifted. In the GC the computation looks something like + this: + value = DS_LENGTH | WORDS_TO_BYTES (last_set_index + 1); + DS_LENGTH is 0. + WORDS_TO_BYTES shifts by log2(bytes-per-pointer). + + In the case of flag_reduced_reflection and the bitmap would + overflow, we tell the gc that the object is all pointers so + that we don't have to emit reflection data for run time + marking. */ + count = 0; + mask = double_int_zero; + ++last_set_index; + while (last_set_index) + { + if ((last_set_index & 1)) + mask = double_int_setbit (mask, log2_size + count); + last_set_index >>= 1; + ++count; + } + value = double_int_to_tree (value_type, mask); + } + else if (! pointer_after_end) + { + /* Bottom two bits for bitmap mark type are 01. */ + mask = double_int_setbit (mask, 0); + value = double_int_to_tree (value_type, mask); + } + else + { + procedure_object_descriptor: + value = build_int_cst (value_type, PROCEDURE_OBJECT_DESCRIPTOR); + } + + return value; +} + +/* The fourth (index of 3) element in the vtable is the GC descriptor. + A value of 2 indicates that the class uses _Jv_MarkObj. */ +bool +uses_jv_markobj_p (tree dtable) +{ + tree v; + /* FIXME: what do we return if !flag_use_boehm_gc ? */ + gcc_assert (flag_use_boehm_gc); + /* FIXME: this is wrong if TARGET_VTABLE_USES_DESCRIPTORS. However, + this function is only used with flag_reduced_reflection. No + point in asserting unless we hit the bad case. */ + gcc_assert (!flag_reduced_reflection || TARGET_VTABLE_USES_DESCRIPTORS == 0); + v = VEC_index (constructor_elt, CONSTRUCTOR_ELTS (dtable), 3)->value; + return (PROCEDURE_OBJECT_DESCRIPTOR == TREE_INT_CST_LOW (v)); +} diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c new file mode 100644 index 000000000..2100f093a --- /dev/null +++ b/gcc/java/builtins.c @@ -0,0 +1,641 @@ +/* Built-in and inline functions for gcj + Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +. + +. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Tom Tromey <tromey@redhat.com>. */ + +/* FIXME: Still need to include rtl.h here (see below). */ +#undef IN_GCC_FRONTEND + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "ggc.h" +#include "flags.h" +#include "langhooks.h" +#include "java-tree.h" + +/* FIXME: All these headers are necessary for sync_compare_and_swap. + Front ends should never have to look at that. */ +#include "rtl.h" +#include "insn-codes.h" +#include "expr.h" +#include "optabs.h" + +static tree max_builtin (tree, tree); +static tree min_builtin (tree, tree); +static tree abs_builtin (tree, tree); +static tree convert_real (tree, tree); + +static tree java_build_function_call_expr (tree, tree); + +static tree putObject_builtin (tree, tree); +static tree compareAndSwapInt_builtin (tree, tree); +static tree compareAndSwapLong_builtin (tree, tree); +static tree compareAndSwapObject_builtin (tree, tree); +static tree putVolatile_builtin (tree, tree); +static tree getVolatile_builtin (tree, tree); +static tree VMSupportsCS8_builtin (tree, tree); + + +/* Functions of this type are used to inline a given call. Such a + function should either return an expression, if the call is to be + inlined, or NULL_TREE if a real call should be emitted. Arguments + are method return type and the original CALL_EXPR containing the + arguments to the call. */ +typedef tree builtin_creator_function (tree, tree); + +/* Hold a char*, before initialization, or a tree, after + initialization. */ +union GTY(()) string_or_tree { + const char * GTY ((tag ("0"))) s; + tree GTY ((tag ("1"))) t; +}; + +/* Used to hold a single builtin record. */ +struct GTY(()) builtin_record { + union string_or_tree GTY ((desc ("1"))) class_name; + union string_or_tree GTY ((desc ("1"))) method_name; + builtin_creator_function * GTY((skip)) creator; + enum built_in_function builtin_code; +}; + +static GTY(()) struct builtin_record java_builtins[] = +{ + { { "java.lang.Math" }, { "min" }, min_builtin, (enum built_in_function) 0 }, + { { "java.lang.Math" }, { "max" }, max_builtin, (enum built_in_function) 0 }, + { { "java.lang.Math" }, { "abs" }, abs_builtin, (enum built_in_function) 0 }, + { { "java.lang.Math" }, { "acos" }, NULL, BUILT_IN_ACOS }, + { { "java.lang.Math" }, { "asin" }, NULL, BUILT_IN_ASIN }, + { { "java.lang.Math" }, { "atan" }, NULL, BUILT_IN_ATAN }, + { { "java.lang.Math" }, { "atan2" }, NULL, BUILT_IN_ATAN2 }, + { { "java.lang.Math" }, { "ceil" }, NULL, BUILT_IN_CEIL }, + { { "java.lang.Math" }, { "cos" }, NULL, BUILT_IN_COS }, + { { "java.lang.Math" }, { "exp" }, NULL, BUILT_IN_EXP }, + { { "java.lang.Math" }, { "floor" }, NULL, BUILT_IN_FLOOR }, + { { "java.lang.Math" }, { "log" }, NULL, BUILT_IN_LOG }, + { { "java.lang.Math" }, { "pow" }, NULL, BUILT_IN_POW }, + { { "java.lang.Math" }, { "sin" }, NULL, BUILT_IN_SIN }, + { { "java.lang.Math" }, { "sqrt" }, NULL, BUILT_IN_SQRT }, + { { "java.lang.Math" }, { "tan" }, NULL, BUILT_IN_TAN }, + { { "java.lang.Float" }, { "intBitsToFloat" }, convert_real, + (enum built_in_function) 0 }, + { { "java.lang.Double" }, { "longBitsToDouble" }, convert_real, + (enum built_in_function) 0 }, + { { "java.lang.Float" }, { "floatToRawIntBits" }, convert_real, + (enum built_in_function) 0 }, + { { "java.lang.Double" }, { "doubleToRawLongBits" }, convert_real, + (enum built_in_function) 0 }, + { { "sun.misc.Unsafe" }, { "putInt" }, putObject_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putLong" }, putObject_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putObject" }, putObject_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "compareAndSwapInt" }, + compareAndSwapInt_builtin, (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "compareAndSwapLong" }, + compareAndSwapLong_builtin, (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "compareAndSwapObject" }, + compareAndSwapObject_builtin, (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putOrderedInt" }, putVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putOrderedLong" }, putVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putOrderedObject" }, putVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putIntVolatile" }, putVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putLongVolatile" }, putVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "putObjectVolatile" }, putVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "getObjectVolatile" }, getVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "getIntVolatile" }, getVolatile_builtin, + (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "getLongVolatile" }, getVolatile_builtin, (enum built_in_function) 0}, + { { "sun.misc.Unsafe" }, { "getLong" }, getVolatile_builtin, + (enum built_in_function) 0}, + { { "java.util.concurrent.atomic.AtomicLong" }, { "VMSupportsCS8" }, + VMSupportsCS8_builtin, (enum built_in_function) 0}, + { { NULL }, { NULL }, NULL, END_BUILTINS } +}; + + +/* Internal functions which implement various builtin conversions. */ + +static tree +max_builtin (tree method_return_type, tree orig_call) +{ + /* MAX_EXPR does not handle -0.0 in the Java style. */ + if (TREE_CODE (method_return_type) == REAL_TYPE) + return NULL_TREE; + return fold_build2 (MAX_EXPR, method_return_type, + CALL_EXPR_ARG (orig_call, 0), + CALL_EXPR_ARG (orig_call, 1)); +} + +static tree +min_builtin (tree method_return_type, tree orig_call) +{ + /* MIN_EXPR does not handle -0.0 in the Java style. */ + if (TREE_CODE (method_return_type) == REAL_TYPE) + return NULL_TREE; + return fold_build2 (MIN_EXPR, method_return_type, + CALL_EXPR_ARG (orig_call, 0), + CALL_EXPR_ARG (orig_call, 1)); +} + +static tree +abs_builtin (tree method_return_type, tree orig_call) +{ + return fold_build1 (ABS_EXPR, method_return_type, + CALL_EXPR_ARG (orig_call, 0)); +} + +/* Construct a new call to FN using the arguments from ORIG_CALL. */ + +static tree +java_build_function_call_expr (tree fn, tree orig_call) +{ + int nargs = call_expr_nargs (orig_call); + switch (nargs) + { + /* Although we could handle the 0-3 argument cases using the general + logic in the default case, splitting them out permits folding to + be performed without constructing a temporary CALL_EXPR. */ + case 0: + return build_call_expr (fn, 0); + case 1: + return build_call_expr (fn, 1, CALL_EXPR_ARG (orig_call, 0)); + case 2: + return build_call_expr (fn, 2, + CALL_EXPR_ARG (orig_call, 0), + CALL_EXPR_ARG (orig_call, 1)); + case 3: + return build_call_expr (fn, 3, + CALL_EXPR_ARG (orig_call, 0), + CALL_EXPR_ARG (orig_call, 1), + CALL_EXPR_ARG (orig_call, 2)); + default: + { + tree fntype = TREE_TYPE (fn); + fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fn); + return fold (build_call_array (TREE_TYPE (fntype), + fn, nargs, CALL_EXPR_ARGP (orig_call))); + } + } +} + +static tree +convert_real (tree method_return_type, tree orig_call) +{ + return build1 (VIEW_CONVERT_EXPR, method_return_type, + CALL_EXPR_ARG (orig_call, 0)); +} + + + +/* Provide builtin support for atomic operations. These are + documented at length in libjava/sun/misc/Unsafe.java. */ + +/* FIXME. There are still a few things wrong with this logic. In + particular, atomic writes of multi-word integers are not truly + atomic: this requires more work. + + In general, double-word compare-and-swap cannot portably be + implemented, so we need some kind of fallback for 32-bit machines. + +*/ + + +/* Macros to unmarshal arguments from a CALL_EXPR into a few + variables. We also convert the offset arg from a long to an + integer that is the same size as a pointer. */ + +#define UNMARSHAL3(METHOD_CALL) \ +tree this_arg, obj_arg, offset_arg; \ +do \ +{ \ + tree orig_method_call = METHOD_CALL; \ + this_arg = CALL_EXPR_ARG (orig_method_call, 0); \ + obj_arg = CALL_EXPR_ARG (orig_method_call, 1); \ + offset_arg = fold_convert (java_type_for_size (POINTER_SIZE, 0), \ + CALL_EXPR_ARG (orig_method_call, 2)); \ +} \ +while (0) + +#define UNMARSHAL4(METHOD_CALL) \ +tree value_type, this_arg, obj_arg, offset_arg, value_arg; \ +do \ +{ \ + tree orig_method_call = METHOD_CALL; \ + this_arg = CALL_EXPR_ARG (orig_method_call, 0); \ + obj_arg = CALL_EXPR_ARG (orig_method_call, 1); \ + offset_arg = fold_convert (java_type_for_size (POINTER_SIZE, 0), \ + CALL_EXPR_ARG (orig_method_call, 2)); \ + value_arg = CALL_EXPR_ARG (orig_method_call, 3); \ + value_type = TREE_TYPE (value_arg); \ +} \ +while (0) + +#define UNMARSHAL5(METHOD_CALL) \ +tree value_type, this_arg, obj_arg, offset_arg, expected_arg, value_arg; \ +do \ +{ \ + tree orig_method_call = METHOD_CALL; \ + this_arg = CALL_EXPR_ARG (orig_method_call, 0); \ + obj_arg = CALL_EXPR_ARG (orig_method_call, 1); \ + offset_arg = fold_convert (java_type_for_size (POINTER_SIZE, 0), \ + CALL_EXPR_ARG (orig_method_call, 2)); \ + expected_arg = CALL_EXPR_ARG (orig_method_call, 3); \ + value_arg = CALL_EXPR_ARG (orig_method_call, 4); \ + value_type = TREE_TYPE (value_arg); \ +} \ +while (0) + +/* Add an address to an offset, forming a sum. */ + +static tree +build_addr_sum (tree type, tree addr, tree offset) +{ + tree ptr_type = build_pointer_type (type); + return fold_build2 (POINTER_PLUS_EXPR, + ptr_type, + fold_convert (ptr_type, addr), + fold_convert (sizetype, offset)); +} + +/* Make sure that this-arg is non-NULL. This is a security check. */ + +static tree +build_check_this (tree stmt, tree this_arg) +{ + return build2 (COMPOUND_EXPR, TREE_TYPE (stmt), + java_check_reference (this_arg, 1), stmt); +} + +/* Now the builtins. These correspond to the primitive functions in + libjava/sun/misc/natUnsafe.cc. */ + +static tree +putObject_builtin (tree method_return_type ATTRIBUTE_UNUSED, + tree orig_call) +{ + tree addr, stmt; + UNMARSHAL4 (orig_call); + + addr = build_addr_sum (value_type, obj_arg, offset_arg); + stmt = fold_build2 (MODIFY_EXPR, value_type, + build_java_indirect_ref (value_type, addr, + flag_check_references), + value_arg); + + return build_check_this (stmt, this_arg); +} + +static tree +compareAndSwapInt_builtin (tree method_return_type ATTRIBUTE_UNUSED, + tree orig_call) +{ + enum machine_mode mode = TYPE_MODE (int_type_node); + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing + || flag_use_atomic_builtins) + { + tree addr, stmt; + UNMARSHAL5 (orig_call); + (void) value_type; /* Avoid set but not used warning. */ + + addr = build_addr_sum (int_type_node, obj_arg, offset_arg); + stmt = build_call_expr (built_in_decls[BUILT_IN_BOOL_COMPARE_AND_SWAP_4], + 3, addr, expected_arg, value_arg); + + return build_check_this (stmt, this_arg); + } + return NULL_TREE; +} + +static tree +compareAndSwapLong_builtin (tree method_return_type ATTRIBUTE_UNUSED, + tree orig_call) +{ + enum machine_mode mode = TYPE_MODE (long_type_node); + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing + || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (word_mode) + && flag_use_atomic_builtins)) + /* We don't trust flag_use_atomic_builtins for multi-word + compareAndSwap. Some machines such as ARM have atomic libfuncs + but not the multi-word versions. */ + { + tree addr, stmt; + UNMARSHAL5 (orig_call); + (void) value_type; /* Avoid set but not used warning. */ + + addr = build_addr_sum (long_type_node, obj_arg, offset_arg); + stmt = build_call_expr (built_in_decls[BUILT_IN_BOOL_COMPARE_AND_SWAP_8], + 3, addr, expected_arg, value_arg); + + return build_check_this (stmt, this_arg); + } + return NULL_TREE; +} +static tree +compareAndSwapObject_builtin (tree method_return_type ATTRIBUTE_UNUSED, + tree orig_call) +{ + enum machine_mode mode = TYPE_MODE (ptr_type_node); + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing + || flag_use_atomic_builtins) + { + tree addr, stmt; + int builtin; + + UNMARSHAL5 (orig_call); + builtin = (POINTER_SIZE == 32 + ? BUILT_IN_BOOL_COMPARE_AND_SWAP_4 + : BUILT_IN_BOOL_COMPARE_AND_SWAP_8); + + addr = build_addr_sum (value_type, obj_arg, offset_arg); + stmt = build_call_expr (built_in_decls[builtin], + 3, addr, expected_arg, value_arg); + + return build_check_this (stmt, this_arg); + } + return NULL_TREE; +} + +static tree +putVolatile_builtin (tree method_return_type ATTRIBUTE_UNUSED, + tree orig_call) +{ + tree addr, stmt, modify_stmt; + UNMARSHAL4 (orig_call); + + addr = build_addr_sum (value_type, obj_arg, offset_arg); + addr + = fold_convert (build_pointer_type (build_type_variant (value_type, 0, 1)), + addr); + + stmt = build_call_expr (built_in_decls[BUILT_IN_SYNCHRONIZE], 0); + modify_stmt = fold_build2 (MODIFY_EXPR, value_type, + build_java_indirect_ref (value_type, addr, + flag_check_references), + value_arg); + stmt = build2 (COMPOUND_EXPR, TREE_TYPE (modify_stmt), + stmt, modify_stmt); + + return build_check_this (stmt, this_arg); +} + +static tree +getVolatile_builtin (tree method_return_type ATTRIBUTE_UNUSED, + tree orig_call) +{ + tree addr, stmt, modify_stmt, tmp; + UNMARSHAL3 (orig_call); + (void) this_arg; /* Avoid set but not used warning. */ + + addr = build_addr_sum (method_return_type, obj_arg, offset_arg); + addr + = fold_convert (build_pointer_type (build_type_variant + (method_return_type, 0, 1)), addr); + + stmt = build_call_expr (built_in_decls[BUILT_IN_SYNCHRONIZE], 0); + + tmp = build_decl (BUILTINS_LOCATION, VAR_DECL, NULL, method_return_type); + DECL_IGNORED_P (tmp) = 1; + DECL_ARTIFICIAL (tmp) = 1; + pushdecl (tmp); + + modify_stmt = fold_build2 (MODIFY_EXPR, method_return_type, + tmp, + build_java_indirect_ref (method_return_type, addr, + flag_check_references)); + + stmt = build2 (COMPOUND_EXPR, void_type_node, modify_stmt, stmt); + stmt = build2 (COMPOUND_EXPR, method_return_type, stmt, tmp); + + return stmt; +} + +static tree +VMSupportsCS8_builtin (tree method_return_type, + tree orig_call ATTRIBUTE_UNUSED) +{ + enum machine_mode mode = TYPE_MODE (long_type_node); + gcc_assert (method_return_type == boolean_type_node); + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing) + return boolean_true_node; + else + return boolean_false_node; +} + + + +#define BUILTIN_NOTHROW 1 +#define BUILTIN_CONST 2 +/* Define a single builtin. */ +static void +define_builtin (enum built_in_function val, + const char *name, + tree type, + const char *libname, + int flags) +{ + tree decl; + + decl = build_decl (BUILTINS_LOCATION, + FUNCTION_DECL, get_identifier (name), type); + DECL_EXTERNAL (decl) = 1; + TREE_PUBLIC (decl) = 1; + SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname)); + pushdecl (decl); + DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL; + DECL_FUNCTION_CODE (decl) = val; + if (flags & BUILTIN_NOTHROW) + TREE_NOTHROW (decl) = 1; + if (flags & BUILTIN_CONST) + TREE_READONLY (decl) = 1; + + implicit_built_in_decls[val] = decl; + built_in_decls[val] = decl; +} + + + +/* Initialize the builtins. */ +void +initialize_builtins (void) +{ + tree double_ftype_double, double_ftype_double_double; + tree float_ftype_float_float; + tree boolean_ftype_boolean_boolean; + int i; + + for (i = 0; java_builtins[i].builtin_code != END_BUILTINS; ++i) + { + tree klass_id = get_identifier (java_builtins[i].class_name.s); + tree m = get_identifier (java_builtins[i].method_name.s); + + java_builtins[i].class_name.t = klass_id; + java_builtins[i].method_name.t = m; + } + + void_list_node = end_params_node; + + float_ftype_float_float + = build_function_type_list (float_type_node, + float_type_node, float_type_node, NULL_TREE); + + double_ftype_double + = build_function_type_list (double_type_node, double_type_node, NULL_TREE); + double_ftype_double_double + = build_function_type_list (double_type_node, + double_type_node, double_type_node, NULL_TREE); + + define_builtin (BUILT_IN_FMOD, "__builtin_fmod", + double_ftype_double_double, "fmod", BUILTIN_CONST); + define_builtin (BUILT_IN_FMODF, "__builtin_fmodf", + float_ftype_float_float, "fmodf", BUILTIN_CONST); + + define_builtin (BUILT_IN_ACOS, "__builtin_acos", + double_ftype_double, "_ZN4java4lang4Math4acosEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_ASIN, "__builtin_asin", + double_ftype_double, "_ZN4java4lang4Math4asinEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_ATAN, "__builtin_atan", + double_ftype_double, "_ZN4java4lang4Math4atanEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_ATAN2, "__builtin_atan2", + double_ftype_double_double, "_ZN4java4lang4Math5atan2EJddd", + BUILTIN_CONST); + define_builtin (BUILT_IN_CEIL, "__builtin_ceil", + double_ftype_double, "_ZN4java4lang4Math4ceilEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_COS, "__builtin_cos", + double_ftype_double, "_ZN4java4lang4Math3cosEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_EXP, "__builtin_exp", + double_ftype_double, "_ZN4java4lang4Math3expEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_FLOOR, "__builtin_floor", + double_ftype_double, "_ZN4java4lang4Math5floorEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_LOG, "__builtin_log", + double_ftype_double, "_ZN4java4lang4Math3logEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_POW, "__builtin_pow", + double_ftype_double_double, "_ZN4java4lang4Math3powEJddd", + BUILTIN_CONST); + define_builtin (BUILT_IN_SIN, "__builtin_sin", + double_ftype_double, "_ZN4java4lang4Math3sinEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_SQRT, "__builtin_sqrt", + double_ftype_double, "_ZN4java4lang4Math4sqrtEJdd", + BUILTIN_CONST); + define_builtin (BUILT_IN_TAN, "__builtin_tan", + double_ftype_double, "_ZN4java4lang4Math3tanEJdd", + BUILTIN_CONST); + + boolean_ftype_boolean_boolean + = build_function_type_list (boolean_type_node, + boolean_type_node, boolean_type_node, + NULL_TREE); + define_builtin (BUILT_IN_EXPECT, "__builtin_expect", + boolean_ftype_boolean_boolean, + "__builtin_expect", + BUILTIN_CONST | BUILTIN_NOTHROW); + define_builtin (BUILT_IN_BOOL_COMPARE_AND_SWAP_4, + "__sync_bool_compare_and_swap_4", + build_function_type_list (boolean_type_node, + int_type_node, + build_pointer_type (int_type_node), + int_type_node, NULL_TREE), + "__sync_bool_compare_and_swap_4", 0); + define_builtin (BUILT_IN_BOOL_COMPARE_AND_SWAP_8, + "__sync_bool_compare_and_swap_8", + build_function_type_list (boolean_type_node, + long_type_node, + build_pointer_type (long_type_node), + int_type_node, NULL_TREE), + "__sync_bool_compare_and_swap_8", 0); + define_builtin (BUILT_IN_SYNCHRONIZE, "__sync_synchronize", + build_function_type_list (void_type_node, NULL_TREE), + "__sync_synchronize", BUILTIN_NOTHROW); + + define_builtin (BUILT_IN_RETURN_ADDRESS, "__builtin_return_address", + build_function_type_list (ptr_type_node, int_type_node, NULL_TREE), + "__builtin_return_address", BUILTIN_NOTHROW); + + build_common_builtin_nodes (); +} + +/* If the call matches a builtin, return the + appropriate builtin expression instead. */ +tree +check_for_builtin (tree method, tree call) +{ + if (optimize && TREE_CODE (call) == CALL_EXPR) + { + int i; + tree method_class = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method))); + tree method_name = DECL_NAME (method); + tree method_return_type = TREE_TYPE (TREE_TYPE (method)); + + for (i = 0; java_builtins[i].builtin_code != END_BUILTINS; ++i) + { + if (method_class == java_builtins[i].class_name.t + && method_name == java_builtins[i].method_name.t) + { + tree fn; + + if (java_builtins[i].creator != NULL) + { + tree result + = (*java_builtins[i].creator) (method_return_type, call); + return result == NULL_TREE ? call : result; + } + + /* Builtin functions emit a direct call which is incompatible + with the BC-ABI. */ + if (flag_indirect_dispatch) + return call; + fn = built_in_decls[java_builtins[i].builtin_code]; + if (fn == NULL_TREE) + return call; + return java_build_function_call_expr (fn, call); + } + } + } + return call; +} + +#include "gt-java-builtins.h" diff --git a/gcc/java/class.c b/gcc/java/class.c new file mode 100644 index 000000000..92091f9e9 --- /dev/null +++ b/gcc/java/class.c @@ -0,0 +1,3247 @@ +/* Functions related to building classes and their related objects. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com> */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "flags.h" +#include "java-tree.h" +#include "jcf.h" +#include "obstack.h" +#include "diagnostic-core.h" +#include "toplev.h" +#include "output.h" +#include "parse.h" +#include "function.h" +#include "ggc.h" +#include "cgraph.h" +#include "tree-iterator.h" +#include "vecprim.h" +#include "tm.h" /* FIXME: For gcc_obstack_init from defaults.h. */ +#include "target.h" + +static tree make_method_value (tree); +static tree build_java_method_type (tree, tree, int); +static int32 hashUtf8String (const char *, int); +static tree make_field_value (tree); +static tree get_dispatch_vector (tree); +static tree get_dispatch_table (tree, tree); +static int supers_all_compiled (tree type); +static tree maybe_layout_super_class (tree, tree); +static void add_miranda_methods (tree, tree); +static int assume_compiled (const char *); +static tree build_symbol_entry (tree, tree); +static tree emit_assertion_table (tree); +static void register_class (void); + +struct obstack temporary_obstack; + +static const char *cyclic_inheritance_report; + +/* The compiler generates different code depending on whether or not + it can assume certain classes have been compiled down to native + code or not. The compiler options -fassume-compiled= and + -fno-assume-compiled= are used to create a tree of + class_flag_node objects. This tree is queried to determine if + a class is assume to be compiled or not. Each node in the tree + represents either a package or a specific class. */ + +typedef struct class_flag_node_struct +{ + /* The class or package name. */ + const char *ident; + + /* Nonzero if this represents an exclusion. */ + int value; + + /* Pointers to other nodes in the tree. */ + struct class_flag_node_struct *parent; + struct class_flag_node_struct *sibling; + struct class_flag_node_struct *child; +} class_flag_node; + +static class_flag_node *find_class_flag_node (class_flag_node *, const char *); +static void add_class_flag (class_flag_node **, const char *, int); + +/* This is the root of the include/exclude tree. */ + +static class_flag_node *assume_compiled_tree; + +static class_flag_node *enable_assert_tree; + +static GTY(()) tree class_roots[4]; +#define fields_ident class_roots[0] /* get_identifier ("fields") */ +#define info_ident class_roots[1] /* get_identifier ("info") */ +#define class_list class_roots[2] +#define class_dtable_decl class_roots[3] + +static GTY(()) VEC(tree,gc) *registered_class; + +/* A tree that returns the address of the class$ of the class + currently being compiled. */ +static GTY(()) tree this_classdollar; + +/* A list of static class fields. This is to emit proper debug + info for them. */ +VEC(tree,gc) *pending_static_fields; + +/* Return the node that most closely represents the class whose name + is IDENT. Start the search from NODE (followed by its siblings). + Return NULL if an appropriate node does not exist. */ + +static class_flag_node * +find_class_flag_node (class_flag_node *node, const char *ident) +{ + while (node) + { + size_t node_ident_length = strlen (node->ident); + + /* node_ident_length is zero at the root of the tree. If the + identifiers are the same length, then we have matching + classes. Otherwise check if we've matched an enclosing + package name. */ + + if (node_ident_length == 0 + || (strncmp (ident, node->ident, node_ident_length) == 0 + && (ident[node_ident_length] == '\0' + || ident[node_ident_length] == '.'))) + { + /* We've found a match, however, there might be a more + specific match. */ + + class_flag_node *found = find_class_flag_node (node->child, ident); + if (found) + return found; + else + return node; + } + + /* No match yet. Continue through the sibling list. */ + node = node->sibling; + } + + /* No match at all in this tree. */ + return NULL; +} + +void +add_class_flag (class_flag_node **rootp, const char *ident, int value) +{ + class_flag_node *root = *rootp; + class_flag_node *parent, *node; + + /* Create the root of the tree if it doesn't exist yet. */ + + if (NULL == root) + { + root = XNEW (class_flag_node); + root->ident = ""; + root->value = 0; + root->sibling = NULL; + root->child = NULL; + root->parent = NULL; + *rootp = root; + } + + /* Calling the function with the empty string means we're setting + value for the root of the hierarchy. */ + + if (0 == ident[0]) + { + root->value = value; + return; + } + + /* Find the parent node for this new node. PARENT will either be a + class or a package name. Adjust PARENT accordingly. */ + + parent = find_class_flag_node (root, ident); + if (strcmp (ident, parent->ident) == 0) + parent->value = value; + else + { + /* Insert new node into the tree. */ + node = XNEW (class_flag_node); + + node->ident = xstrdup (ident); + node->value = value; + node->child = NULL; + + node->parent = parent; + node->sibling = parent->child; + parent->child = node; + } +} + +/* Add a new IDENT to the include/exclude tree. It's an exclusion + if EXCLUDEP is nonzero. */ + +void +add_assume_compiled (const char *ident, int excludep) +{ + add_class_flag (&assume_compiled_tree, ident, excludep); +} + +/* The default value returned by enable_assertions. */ + +#define DEFAULT_ENABLE_ASSERT (optimize == 0) + +/* Enter IDENT (a class or package name) into the enable-assertions table. + VALUE is true to enable and false to disable. */ + +void +add_enable_assert (const char *ident, int value) +{ + if (enable_assert_tree == NULL) + add_class_flag (&enable_assert_tree, "", DEFAULT_ENABLE_ASSERT); + add_class_flag (&enable_assert_tree, ident, value); +} + +/* Returns nonzero if IDENT is the name of a class that the compiler + should assume has been compiled to object code. */ + +static int +assume_compiled (const char *ident) +{ + class_flag_node *i; + int result; + + if (NULL == assume_compiled_tree) + return 1; + + i = find_class_flag_node (assume_compiled_tree, ident); + + result = ! i->value; + + return (result); +} + +/* Return true if we should generate code to check assertions within KLASS. */ + +bool +enable_assertions (tree klass) +{ + /* Check if command-line specifies whether we should check assertions. */ + + if (klass != NULL_TREE && DECL_NAME (klass) && enable_assert_tree != NULL) + { + const char *ident = IDENTIFIER_POINTER (DECL_NAME (klass)); + class_flag_node *node + = find_class_flag_node (enable_assert_tree, ident); + return node->value; + } + + /* The default is to enable assertions if generating class files, + or not optimizing. */ + return DEFAULT_ENABLE_ASSERT; +} + +/* Return an IDENTIFIER_NODE the same as (OLD_NAME, OLD_LENGTH). + except that characters matching OLD_CHAR are substituted by NEW_CHAR. + Also, PREFIX is prepended, and SUFFIX is appended. */ + +tree +ident_subst (const char* old_name, + int old_length, + const char *prefix, + int old_char, + int new_char, + const char *suffix) +{ + int prefix_len = strlen (prefix); + int suffix_len = strlen (suffix); + int i = prefix_len + old_length + suffix_len + 1; + char *buffer = (char *) alloca (i); + + strcpy (buffer, prefix); + for (i = 0; i < old_length; i++) + { + char ch = old_name[i]; + if (ch == old_char) + ch = new_char; + buffer[prefix_len + i] = ch; + } + strcpy (buffer + prefix_len + old_length, suffix); + return get_identifier (buffer); +} + +/* Return an IDENTIFIER_NODE the same as OLD_ID, + except that characters matching OLD_CHAR are substituted by NEW_CHAR. + Also, PREFIX is prepended, and SUFFIX is appended. */ + +tree +identifier_subst (const tree old_id, + const char *prefix, + int old_char, + int new_char, + const char *suffix) +{ + return ident_subst (IDENTIFIER_POINTER (old_id), IDENTIFIER_LENGTH (old_id), + prefix, old_char, new_char, suffix); +} + +/* Generate a valid C identifier from the name of the class TYPE, + prefixed by PREFIX. */ + +tree +mangled_classname (const char *prefix, tree type) +{ + tree result; + tree ident = TYPE_NAME (type); + if (TREE_CODE (ident) != IDENTIFIER_NODE) + ident = DECL_NAME (ident); + result = identifier_subst (ident, prefix, '.', '_', ""); + + /* Replace any characters that aren't in the set [0-9a-zA-Z_$] with + "_0xXX". Class names containing such chracters are uncommon, but + they do sometimes occur in class files. Without this check, + these names cause assembly errors. + + There is a possibility that a real class name could conflict with + the identifier we generate, but it is unlikely and will + immediately be detected as an assembler error. At some point we + should do something more elaborate (perhaps using the full + unicode mangling scheme) in order to prevent such a conflict. */ + { + int i; + const int len = IDENTIFIER_LENGTH (result); + const char *p = IDENTIFIER_POINTER (result); + int illegal_chars = 0; + + /* Make two passes over the identifier. The first pass is merely + to count illegal characters; we need to do this in order to + allocate a buffer. */ + for (i = 0; i < len; i++) + { + char c = p[i]; + illegal_chars += (! ISALNUM (c) && c != '_' && c != '$'); + } + + /* And the second pass, which is rarely executed, does the + rewriting. */ + if (illegal_chars != 0) + { + char *buffer = (char *) alloca (illegal_chars * 4 + len + 1); + int j; + + for (i = 0, j = 0; i < len; i++) + { + char c = p[i]; + if (! ISALNUM (c) && c != '_' && c != '$') + { + buffer[j++] = '_'; + sprintf (&buffer[j], "0x%02x", c); + j += 4; + } + else + buffer[j++] = c; + } + + buffer[j] = 0; + result = get_identifier (buffer); + } + } + + return result; +} + +tree +make_class (void) +{ + tree type; + type = make_node (RECORD_TYPE); + /* Unfortunately we must create the binfo here, so that class + loading works. */ + TYPE_BINFO (type) = make_tree_binfo (0); + MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type); + TYPE_CATCH_CLASSES (type) = NULL; + /* Push a dummy entry; we can't call make_catch_class_record here + because other infrastructure may not be set up yet. We'll come + back and fill it in later once said infrastructure is + initialized. */ + CONSTRUCTOR_APPEND_ELT (TYPE_CATCH_CLASSES (type), NULL_TREE, NULL_TREE); + + return type; +} + +/* Given a fully-qualified classname in NAME (whose length is NAME_LENGTH), + and where each of the constituents is separated by '/', + return a corresponding IDENTIFIER_NODE, except using '.' as separator. */ + +tree +unmangle_classname (const char *name, int name_length) +{ + tree to_return = ident_subst (name, name_length, "", '/', '.', ""); + /* It's not sufficient to compare to_return and get_identifier + (name) to determine whether to_return is qualified. There are + cases in signature analysis where name will be stripped of a + trailing ';'. */ + name = IDENTIFIER_POINTER (to_return); + while (*name) + if (*name++ == '.') + { + QUALIFIED_P (to_return) = 1; + break; + } + + return to_return; +} + +#define GEN_TABLE(TABLE, NAME, TABLE_TYPE, TYPE) \ +do \ +{ \ + const char *type_name = IDENTIFIER_POINTER (mangled_classname ("", TYPE)); \ + char *buf = (char *) alloca (strlen (type_name) \ + + strlen (#NAME "_syms_") + 1); \ + tree decl; \ + \ + sprintf (buf, #NAME "_%s", type_name); \ + TYPE_## TABLE ##_DECL (type) = decl = \ + build_decl (input_location, VAR_DECL, get_identifier (buf), TABLE_TYPE); \ + DECL_EXTERNAL (decl) = 1; \ + TREE_STATIC (decl) = 1; \ + TREE_READONLY (decl) = 1; \ + TREE_CONSTANT (decl) = 1; \ + DECL_IGNORED_P (decl) = 1; \ + /* Mark the table as belonging to this class. */ \ + pushdecl (decl); \ + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); \ + DECL_OWNER (decl) = TYPE; \ + sprintf (buf, #NAME "_syms_%s", type_name); \ + TYPE_## TABLE ##_SYMS_DECL (TYPE) = \ + build_decl (input_location, VAR_DECL, get_identifier (buf), symbols_array_type); \ + TREE_STATIC (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \ + TREE_CONSTANT (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \ + DECL_IGNORED_P (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \ +} \ +while (0) + +/* Given a class, create the DECLs for all its associated indirect + dispatch tables. */ +void +gen_indirect_dispatch_tables (tree type) +{ + const char *type_name = IDENTIFIER_POINTER (mangled_classname ("", type)); + { + tree field = NULL; + char *buf = (char *) alloca (strlen (type_name) + + strlen ("_catch_classes_") + 1); + tree catch_class_type = make_node (RECORD_TYPE); + + sprintf (buf, "_catch_classes_%s", type_name); + PUSH_FIELD (input_location, + catch_class_type, field, "address", utf8const_ptr_type); + PUSH_FIELD (input_location, + catch_class_type, field, "classname", ptr_type_node); + FINISH_RECORD (catch_class_type); + + TYPE_CTABLE_DECL (type) + = build_decl (input_location, VAR_DECL, get_identifier (buf), + build_array_type (catch_class_type, 0)); + DECL_EXTERNAL (TYPE_CTABLE_DECL (type)) = 1; + TREE_STATIC (TYPE_CTABLE_DECL (type)) = 1; + TREE_READONLY (TYPE_CTABLE_DECL (type)) = 1; + TREE_CONSTANT (TYPE_CTABLE_DECL (type)) = 1; + DECL_IGNORED_P (TYPE_CTABLE_DECL (type)) = 1; + pushdecl (TYPE_CTABLE_DECL (type)); + } + + if (flag_indirect_dispatch) + { + GEN_TABLE (ATABLE, _atable, atable_type, type); + GEN_TABLE (OTABLE, _otable, otable_type, type); + GEN_TABLE (ITABLE, _itable, itable_type, type); + } +} + +#undef GEN_TABLE + +tree +push_class (tree class_type, tree class_name) +{ + tree decl, signature; + location_t saved_loc = input_location; + CLASS_P (class_type) = 1; + decl = build_decl (input_location, TYPE_DECL, class_name, class_type); + TYPE_DECL_SUPPRESS_DEBUG (decl) = 1; + + /* dbxout needs a DECL_SIZE if in gstabs mode */ + DECL_SIZE (decl) = integer_zero_node; + + input_location = saved_loc; + signature = identifier_subst (class_name, "L", '.', '/', ";"); + IDENTIFIER_SIGNATURE_TYPE (signature) = build_pointer_type (class_type); + + /* Setting DECL_ARTIFICIAL forces dbxout.c to specific the type is + both a typedef and in the struct name-space. We may want to re-visit + this later, but for now it reduces the changes needed for gdb. */ + DECL_ARTIFICIAL (decl) = 1; + + pushdecl_top_level (decl); + + return decl; +} + +/* Finds the (global) class named NAME. Creates the class if not found. + Also creates associated TYPE_DECL. + Does not check if the class actually exists, load the class, + fill in field or methods, or do layout_type. */ + +tree +lookup_class (tree name) +{ + tree decl = IDENTIFIER_CLASS_VALUE (name); + if (decl == NULL_TREE) + decl = push_class (make_class (), name); + return TREE_TYPE (decl); +} + +void +set_super_info (int access_flags, tree this_class, + tree super_class, int interfaces_count) +{ + int total_supers = interfaces_count; + tree class_decl = TYPE_NAME (this_class); + + if (super_class) + total_supers++; + + if (total_supers) + TYPE_BINFO (this_class) = make_tree_binfo (total_supers); + TYPE_VFIELD (this_class) = TYPE_VFIELD (object_type_node); + if (super_class) + { + tree super_binfo = make_tree_binfo (0); + BINFO_TYPE (super_binfo) = super_class; + BINFO_OFFSET (super_binfo) = integer_zero_node; + BINFO_BASE_APPEND (TYPE_BINFO (this_class), super_binfo); + CLASS_HAS_SUPER_FLAG (TYPE_BINFO (this_class)) = 1; + } + + set_class_decl_access_flags (access_flags, class_decl); +} + +void +set_class_decl_access_flags (int access_flags, tree class_decl) +{ + if (access_flags & ACC_PUBLIC) CLASS_PUBLIC (class_decl) = 1; + if (access_flags & ACC_FINAL) CLASS_FINAL (class_decl) = 1; + if (access_flags & ACC_SUPER) CLASS_SUPER (class_decl) = 1; + if (access_flags & ACC_INTERFACE) CLASS_INTERFACE (class_decl) = 1; + if (access_flags & ACC_ABSTRACT) CLASS_ABSTRACT (class_decl) = 1; + if (access_flags & ACC_STATIC) CLASS_STATIC (class_decl) = 1; + if (access_flags & ACC_PRIVATE) CLASS_PRIVATE (class_decl) = 1; + if (access_flags & ACC_PROTECTED) CLASS_PROTECTED (class_decl) = 1; + if (access_flags & ACC_STRICT) CLASS_STRICTFP (class_decl) = 1; + if (access_flags & ACC_ENUM) CLASS_ENUM (class_decl) = 1; + if (access_flags & ACC_SYNTHETIC) CLASS_SYNTHETIC (class_decl) = 1; + if (access_flags & ACC_ANNOTATION) CLASS_ANNOTATION (class_decl) = 1; +} + +/* Return length of inheritance chain of CLAS, where java.lang.Object is 0, + direct sub-classes of Object are 1, and so on. */ + +int +class_depth (tree clas) +{ + int depth = 0; + if (! CLASS_LOADED_P (clas)) + load_class (clas, 1); + if (TYPE_SIZE (clas) == error_mark_node) + return -1; + while (clas != object_type_node) + { + depth++; + clas = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (clas), 0)); + } + return depth; +} + +/* Return true iff TYPE2 is an interface that extends interface TYPE1 */ + +int +interface_of_p (tree type1, tree type2) +{ + int i; + tree binfo, base_binfo; + + if (! TYPE_BINFO (type2)) + return 0; + + for (binfo = TYPE_BINFO (type2), i = 0; + BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + if (BINFO_TYPE (base_binfo) == type1) + return 1; + + for (binfo = TYPE_BINFO (type2), i = 0; + BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) /* */ + if (BINFO_TYPE (base_binfo) + && interface_of_p (type1, BINFO_TYPE (base_binfo))) + return 1; + + return 0; +} + +/* Return true iff TYPE1 inherits from TYPE2. */ + +int +inherits_from_p (tree type1, tree type2) +{ + while (type1 != NULL_TREE && TREE_CODE (type1) == RECORD_TYPE) + { + if (type1 == type2) + return 1; + + if (! CLASS_LOADED_P (type1)) + load_class (type1, 1); + + type1 = maybe_layout_super_class (CLASSTYPE_SUPER (type1), type1); + } + return 0; +} + +/* Return a 1 iff TYPE1 is an enclosing context for TYPE2 */ + +int +enclosing_context_p (tree type1, tree type2) +{ + if (!INNER_CLASS_TYPE_P (type2)) + return 0; + + for (type2 = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type2))); + type2; + type2 = (INNER_CLASS_TYPE_P (type2) ? + TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type2))) : NULL_TREE)) + { + if (type2 == type1) + return 1; + } + + return 0; +} + + +/* Return 1 iff TYPE1 and TYPE2 share a common enclosing class, regardless of + nesting level. */ + +int +common_enclosing_context_p (tree type1, tree type2) +{ + while (type1) + { + tree current; + for (current = type2; current; + current = (INNER_CLASS_TYPE_P (current) ? + TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current))) : + NULL_TREE)) + if (type1 == current) + return 1; + + if (INNER_CLASS_TYPE_P (type1)) + type1 = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type1))); + else + break; + } + return 0; +} + +/* Return 1 iff there exists a common enclosing "this" between TYPE1 + and TYPE2, without crossing any static context. */ + +int +common_enclosing_instance_p (tree type1, tree type2) +{ + if (!PURE_INNER_CLASS_TYPE_P (type1) || !PURE_INNER_CLASS_TYPE_P (type2)) + return 0; + + for (type1 = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type1))); type1; + type1 = (PURE_INNER_CLASS_TYPE_P (type1) ? + TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type1))) : NULL_TREE)) + { + tree current; + for (current = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type2))); current; + current = (PURE_INNER_CLASS_TYPE_P (current) ? + TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current))) : + NULL_TREE)) + if (type1 == current) + return 1; + } + return 0; +} + +/* Add INTERFACE_CLASS to THIS_CLASS iff INTERFACE_CLASS can't be + found in THIS_CLASS. Returns NULL_TREE upon success, INTERFACE_CLASS + if attempt is made to add it twice. */ + +tree +maybe_add_interface (tree this_class, tree interface_class) +{ + tree binfo, base_binfo; + int i; + + for (binfo = TYPE_BINFO (this_class), i = 0; + BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + if (BINFO_TYPE (base_binfo) == interface_class) + return interface_class; + add_interface (this_class, interface_class); + return NULL_TREE; +} + +/* Add the INTERFACE_CLASS as one of the interfaces of THIS_CLASS. */ + +void +add_interface (tree this_class, tree interface_class) +{ + tree interface_binfo = make_tree_binfo (0); + + BINFO_TYPE (interface_binfo) = interface_class; + BINFO_OFFSET (interface_binfo) = integer_zero_node; + BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node; + BINFO_VIRTUAL_P (interface_binfo) = 1; + + BINFO_BASE_APPEND (TYPE_BINFO (this_class), interface_binfo); +} + +static tree +build_java_method_type (tree fntype, tree this_class, int access_flags) +{ + if (access_flags & ACC_STATIC) + return fntype; + fntype = build_method_type (this_class, fntype); + + /* We know that arg 1 of every nonstatic method is non-null; tell + the back-end so. */ + TYPE_ATTRIBUTES (fntype) = (tree_cons + (get_identifier ("nonnull"), + tree_cons (NULL_TREE, + build_int_cst (NULL_TREE, 1), + NULL_TREE), + TYPE_ATTRIBUTES (fntype))); + return fntype; +} + +void +java_hide_decl (tree decl ATTRIBUTE_UNUSED) +{ +#ifdef HAVE_GAS_HIDDEN + DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; + DECL_VISIBILITY_SPECIFIED (decl) = 1; +#endif +} + +tree +add_method_1 (tree this_class, int access_flags, tree name, tree function_type) +{ + tree method_type, fndecl; + + method_type = build_java_method_type (function_type, + this_class, access_flags); + + fndecl = build_decl (input_location, FUNCTION_DECL, name, method_type); + DECL_CONTEXT (fndecl) = this_class; + + DECL_LANG_SPECIFIC (fndecl) + = ggc_alloc_cleared_lang_decl(sizeof (struct lang_decl)); + DECL_LANG_SPECIFIC (fndecl)->desc = LANG_DECL_FUNC; + + /* Initialize the static initializer test table. */ + + DECL_FUNCTION_INIT_TEST_TABLE (fndecl) = java_treetreehash_create (10); + + /* Initialize the initialized (static) class table. */ + if (access_flags & ACC_STATIC) + DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl) = + htab_create_ggc (50, htab_hash_pointer, htab_eq_pointer, NULL); + + DECL_CHAIN (fndecl) = TYPE_METHODS (this_class); + TYPE_METHODS (this_class) = fndecl; + + /* If pointers to member functions use the least significant bit to + indicate whether a function is virtual, ensure a pointer + to this function will have that bit clear. */ + if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn + && !(access_flags & ACC_STATIC) + && DECL_ALIGN (fndecl) < 2 * BITS_PER_UNIT) + DECL_ALIGN (fndecl) = 2 * BITS_PER_UNIT; + + /* Notice that this is a finalizer and update the class type + accordingly. This is used to optimize instance allocation. */ + if (name == finalize_identifier_node + && TREE_TYPE (function_type) == void_type_node + && TREE_VALUE (TYPE_ARG_TYPES (function_type)) == void_type_node) + HAS_FINALIZER_P (this_class) = 1; + + if (access_flags & ACC_PUBLIC) METHOD_PUBLIC (fndecl) = 1; + if (access_flags & ACC_PROTECTED) METHOD_PROTECTED (fndecl) = 1; + if (access_flags & ACC_PRIVATE) + METHOD_PRIVATE (fndecl) = 1; + if (access_flags & ACC_NATIVE) + { + METHOD_NATIVE (fndecl) = 1; + DECL_EXTERNAL (fndecl) = 1; + } + else + /* FNDECL is external unless we are compiling it into this object + file. */ + DECL_EXTERNAL (fndecl) = CLASS_FROM_CURRENTLY_COMPILED_P (this_class) == 0; + if (access_flags & ACC_STATIC) + METHOD_STATIC (fndecl) = 1; + if (access_flags & ACC_FINAL) + METHOD_FINAL (fndecl) = 1; + if (access_flags & ACC_SYNCHRONIZED) METHOD_SYNCHRONIZED (fndecl) = 1; + if (access_flags & ACC_ABSTRACT) METHOD_ABSTRACT (fndecl) = 1; + if (access_flags & ACC_STRICT) METHOD_STRICTFP (fndecl) = 1; + if (access_flags & ACC_SYNTHETIC) DECL_ARTIFICIAL (fndecl) = 1; + if (access_flags & ACC_BRIDGE) METHOD_BRIDGE (fndecl) = 1; + if (access_flags & ACC_VARARGS) METHOD_VARARGS (fndecl) = 1; + return fndecl; +} + +/* Add a method to THIS_CLASS. + The method's name is NAME. + Its signature (mangled type) is METHOD_SIG (an IDENTIFIER_NODE). */ + +tree +add_method (tree this_class, int access_flags, tree name, tree method_sig) +{ + tree function_type, fndecl; + const unsigned char *sig + = (const unsigned char *) IDENTIFIER_POINTER (method_sig); + + if (sig[0] != '(') + fatal_error ("bad method signature"); + + function_type = get_type_from_signature (method_sig); + fndecl = add_method_1 (this_class, access_flags, name, function_type); + set_java_signature (TREE_TYPE (fndecl), method_sig); + return fndecl; +} + +tree +add_field (tree klass, tree name, tree field_type, int flags) +{ + int is_static = (flags & ACC_STATIC) != 0; + tree field; + field = build_decl (input_location, + is_static ? VAR_DECL : FIELD_DECL, name, field_type); + DECL_CHAIN (field) = TYPE_FIELDS (klass); + TYPE_FIELDS (klass) = field; + DECL_CONTEXT (field) = klass; + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (field); + + if (flags & ACC_PUBLIC) FIELD_PUBLIC (field) = 1; + if (flags & ACC_PROTECTED) FIELD_PROTECTED (field) = 1; + if (flags & ACC_PRIVATE) FIELD_PRIVATE (field) = 1; + if (flags & ACC_FINAL) FIELD_FINAL (field) = 1; + if (flags & ACC_VOLATILE) + { + FIELD_VOLATILE (field) = 1; + TREE_THIS_VOLATILE (field) = 1; + } + if (flags & ACC_TRANSIENT) FIELD_TRANSIENT (field) = 1; + if (flags & ACC_ENUM) FIELD_ENUM (field) = 1; + if (flags & ACC_SYNTHETIC) FIELD_SYNTHETIC (field) = 1; + if (is_static) + { + FIELD_STATIC (field) = 1; + /* Always make field externally visible. This is required so + that native methods can always access the field. */ + TREE_PUBLIC (field) = 1; + /* Hide everything that shouldn't be visible outside a DSO. */ + if (flag_indirect_classes + || (FIELD_PRIVATE (field))) + java_hide_decl (field); + /* Considered external unless we are compiling it into this + object file. */ + DECL_EXTERNAL (field) = (is_compiled_class (klass) != 2); + if (!DECL_EXTERNAL (field)) + VEC_safe_push (tree, gc, pending_static_fields, field); + } + + return field; +} + +/* Associate a constant value CONSTANT with VAR_DECL FIELD. */ + +void +set_constant_value (tree field, tree constant) +{ + if (field == NULL_TREE) + warning (OPT_Wattributes, + "misplaced ConstantValue attribute (not in any field)"); + else if (DECL_INITIAL (field) != NULL_TREE) + warning (OPT_Wattributes, + "duplicate ConstantValue attribute for field '%s'", + IDENTIFIER_POINTER (DECL_NAME (field))); + else + { + DECL_INITIAL (field) = constant; + if (TREE_TYPE (constant) != TREE_TYPE (field) + && ! (TREE_TYPE (constant) == int_type_node + && INTEGRAL_TYPE_P (TREE_TYPE (field)) + && TYPE_PRECISION (TREE_TYPE (field)) <= 32) + && ! (TREE_TYPE (constant) == utf8const_ptr_type + && TREE_TYPE (field) == string_ptr_type_node)) + error ("ConstantValue attribute of field '%s' has wrong type", + IDENTIFIER_POINTER (DECL_NAME (field))); + } +} + +/* Calculate a hash value for a string encoded in Utf8 format. + * This returns the same hash value as specified for java.lang.String.hashCode. + */ + +static int32 +hashUtf8String (const char *str, int len) +{ + const unsigned char* ptr = (const unsigned char*) str; + const unsigned char *limit = ptr + len; + int32 hash = 0; + for (; ptr < limit;) + { + int ch = UTF8_GET (ptr, limit); + /* Updated specification from + http://www.javasoft.com/docs/books/jls/clarify.html. */ + hash = (31 * hash) + ch; + } + return hash; +} + +tree +build_utf8_ref (tree name) +{ + const char * name_ptr = IDENTIFIER_POINTER (name); + int name_len = IDENTIFIER_LENGTH (name), name_pad; + char buf[60]; + tree ctype, field = NULL_TREE, str_type, cinit, string; + static int utf8_count = 0; + int name_hash; + tree ref = IDENTIFIER_UTF8_REF (name); + tree decl; + VEC(constructor_elt,gc) *v = NULL; + if (ref != NULL_TREE) + return ref; + + ctype = make_node (RECORD_TYPE); + /* '\0' byte plus padding to utf8const_type's alignment. */ + name_pad = TYPE_ALIGN_UNIT (utf8const_type) + - (name_len & (TYPE_ALIGN_UNIT (utf8const_type) - 1)); + str_type = build_prim_array_type (unsigned_byte_type_node, + name_len + name_pad); + PUSH_FIELD (input_location, ctype, field, "hash", unsigned_short_type_node); + PUSH_FIELD (input_location, + ctype, field, "length", unsigned_short_type_node); + PUSH_FIELD (input_location, ctype, field, "data", str_type); + FINISH_RECORD (ctype); + START_RECORD_CONSTRUCTOR (v, ctype); + name_hash = hashUtf8String (name_ptr, name_len) & 0xFFFF; + PUSH_FIELD_VALUE (v, "hash", build_int_cst (NULL_TREE, name_hash)); + PUSH_FIELD_VALUE (v, "length", build_int_cst (NULL_TREE, name_len)); + string = build_string (name_len, name_ptr); + TREE_TYPE (string) = str_type; + PUSH_FIELD_VALUE (v, "data", string); + FINISH_RECORD_CONSTRUCTOR (cinit, v, ctype); + TREE_CONSTANT (cinit) = 1; + + /* Generate a unique-enough identifier. */ + sprintf(buf, "_Utf%d", ++utf8_count); + + decl = build_decl (input_location, + VAR_DECL, get_identifier (buf), utf8const_type); + TREE_STATIC (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + DECL_IGNORED_P (decl) = 1; + TREE_READONLY (decl) = 1; + TREE_THIS_VOLATILE (decl) = 0; + DECL_INITIAL (decl) = cinit; + DECL_USER_ALIGN (decl) = 1; + + if (HAVE_GAS_SHF_MERGE) + { + int decl_size; + /* Ensure decl_size is a multiple of utf8const_type's alignment. */ + decl_size = name_len + 4 + name_pad; + if (flag_merge_constants && decl_size < 256) + { + char buf[32]; + int flags = (SECTION_OVERRIDE + | SECTION_MERGE | (SECTION_ENTSIZE & decl_size)); + sprintf (buf, ".rodata.jutf8.%d", decl_size); + switch_to_section (get_section (buf, flags, NULL)); + DECL_SECTION_NAME (decl) = build_string (strlen (buf), buf); + } + } + + layout_decl (decl, 0); + DECL_SIZE (decl) = TYPE_SIZE (ctype); + DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (ctype); + pushdecl (decl); + rest_of_decl_compilation (decl, global_bindings_p (), 0); + varpool_mark_needed_node (varpool_node (decl)); + ref = build1 (ADDR_EXPR, utf8const_ptr_type, decl); + IDENTIFIER_UTF8_REF (name) = ref; + return ref; +} + +/* Like build_class_ref, but instead of a direct reference generate a + pointer into the constant pool. */ + +static tree +build_indirect_class_ref (tree type) +{ + int index; + tree cl; + index = alloc_class_constant (type); + cl = build_ref_from_constant_pool (index); + return convert (promote_type (class_ptr_type), cl); +} + +static tree +build_static_class_ref (tree type) +{ + tree decl_name, decl, ref; + + if (TYPE_SIZE (type) == error_mark_node) + return null_pointer_node; + decl_name = identifier_subst (DECL_NAME (TYPE_NAME (type)), + "", '/', '/', ".class$$"); + decl = IDENTIFIER_GLOBAL_VALUE (decl_name); + if (decl == NULL_TREE) + { + decl = build_decl (input_location, VAR_DECL, decl_name, class_type_node); + TREE_STATIC (decl) = 1; + if (! flag_indirect_classes) + { + TREE_PUBLIC (decl) = 1; + if (CLASS_PRIVATE (TYPE_NAME (type))) + java_hide_decl (decl); + } + DECL_IGNORED_P (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + if (is_compiled_class (type) == 1) + DECL_EXTERNAL (decl) = 1; + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + DECL_CLASS_FIELD_P (decl) = 1; + DECL_CONTEXT (decl) = type; + + /* ??? We want to preserve the DECL_CONTEXT we set just above, + that that means not calling pushdecl_top_level. */ + IDENTIFIER_GLOBAL_VALUE (decl_name) = decl; + } + + ref = build1 (ADDR_EXPR, class_ptr_type, decl); + return ref; +} + +static tree +build_classdollar_field (tree type) +{ + tree decl_name = identifier_subst (DECL_NAME (TYPE_NAME (type)), + "", '/', '/', ".class$"); + tree decl = IDENTIFIER_GLOBAL_VALUE (decl_name); + + if (decl == NULL_TREE) + { + decl + = build_decl (input_location, + VAR_DECL, decl_name, + (build_type_variant + (build_pointer_type + (build_type_variant (class_type_node, + /* const */ 1, 0)), + /* const */ 1, 0))); + TREE_STATIC (decl) = 1; + TREE_CONSTANT (decl) = 1; + TREE_READONLY (decl) = 1; + TREE_PUBLIC (decl) = 1; + java_hide_decl (decl); + DECL_IGNORED_P (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + IDENTIFIER_GLOBAL_VALUE (decl_name) = decl; + DECL_CLASS_FIELD_P (decl) = 1; + DECL_CONTEXT (decl) = type; + } + + return decl; +} + +/* Create a local variable that holds the current class$. */ + +void +cache_this_class_ref (tree fndecl) +{ + if (optimize) + { + tree classdollar_field; + if (flag_indirect_classes) + classdollar_field = build_classdollar_field (output_class); + else + classdollar_field = build_static_class_ref (output_class); + + this_classdollar = build_decl (input_location, + VAR_DECL, NULL_TREE, + TREE_TYPE (classdollar_field)); + + java_add_local_var (this_classdollar); + java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (this_classdollar), + this_classdollar, classdollar_field)); + } + else + this_classdollar = build_classdollar_field (output_class); + + /* Prepend class initialization for static methods reachable from + other classes. */ + if (METHOD_STATIC (fndecl) + && (! METHOD_PRIVATE (fndecl) + || INNER_CLASS_P (DECL_CONTEXT (fndecl))) + && ! DECL_CLINIT_P (fndecl) + && ! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (fndecl)))) + { + tree init = build_call_expr (soft_initclass_node, 1, + this_classdollar); + java_add_stmt (init); + } +} + +/* Remove the reference to the local variable that holds the current + class$. */ + +void +uncache_this_class_ref (tree fndecl ATTRIBUTE_UNUSED) +{ + this_classdollar = build_classdollar_field (output_class); +} + +/* Build a reference to the class TYPE. + Also handles primitive types and array types. */ + +tree +build_class_ref (tree type) +{ + int is_compiled = is_compiled_class (type); + if (is_compiled) + { + tree ref, decl; + if (TREE_CODE (type) == POINTER_TYPE) + type = TREE_TYPE (type); + + if (flag_indirect_dispatch + && type != output_class + && TREE_CODE (type) == RECORD_TYPE) + return build_indirect_class_ref (type); + + if (type == output_class && flag_indirect_classes) + { + /* This can be NULL if we see a JNI stub before we see any + other method. */ + if (! this_classdollar) + this_classdollar = build_classdollar_field (output_class); + return this_classdollar; + } + + if (TREE_CODE (type) == RECORD_TYPE) + return build_static_class_ref (type); + else + { + const char *name; + tree decl_name; + char buffer[25]; + decl_name = TYPE_NAME (type); + if (TREE_CODE (decl_name) == TYPE_DECL) + decl_name = DECL_NAME (decl_name); + name = IDENTIFIER_POINTER (decl_name); + if (strncmp (name, "promoted_", 9) == 0) + name += 9; + sprintf (buffer, "_Jv_%sClass", name); + decl_name = get_identifier (buffer); + decl = IDENTIFIER_GLOBAL_VALUE (decl_name); + if (decl == NULL_TREE) + { + decl = build_decl (input_location, + VAR_DECL, decl_name, class_type_node); + TREE_STATIC (decl) = 1; + TREE_PUBLIC (decl) = 1; + DECL_EXTERNAL (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + pushdecl_top_level (decl); + } + } + + ref = build1 (ADDR_EXPR, class_ptr_type, decl); + return ref; + } + else + return build_indirect_class_ref (type); +} + +/* Create a local statically allocated variable that will hold a + pointer to a static field. */ + +static tree +build_fieldref_cache_entry (int index, tree fdecl ATTRIBUTE_UNUSED) +{ + tree decl, decl_name; + const char *name = IDENTIFIER_POINTER (mangled_classname ("_cpool_", output_class)); + char *buf = (char *) alloca (strlen (name) + 20); + sprintf (buf, "%s_%d_ref", name, index); + decl_name = get_identifier (buf); + decl = IDENTIFIER_GLOBAL_VALUE (decl_name); + if (decl == NULL_TREE) + { + decl = build_decl (input_location, + VAR_DECL, decl_name, ptr_type_node); + TREE_STATIC (decl) = 1; + TREE_PUBLIC (decl) = 0; + DECL_EXTERNAL (decl) = 0; + DECL_ARTIFICIAL (decl) = 1; + DECL_IGNORED_P (decl) = 1; + pushdecl_top_level (decl); + } + return decl; +} + +tree +build_static_field_ref (tree fdecl) +{ + tree fclass = DECL_CONTEXT (fdecl); + int is_compiled = is_compiled_class (fclass); + + /* Allow static final fields to fold to a constant. When using + -findirect-dispatch, we simply never do this folding if compiling + from .class; in the .class file constants will be referred to via + the constant pool. */ + if (!flag_indirect_dispatch + && (is_compiled + || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE + && (JSTRING_TYPE_P (TREE_TYPE (fdecl)) + || JNUMERIC_TYPE_P (TREE_TYPE (fdecl))) + && TREE_CONSTANT (DECL_INITIAL (fdecl))))) + { + if (is_compiled == 1) + DECL_EXTERNAL (fdecl) = 1; + } + else + { + /* Generate a CONSTANT_FieldRef for FDECL in the constant pool + and a class local static variable CACHE_ENTRY, then + + *(fdecl **)((__builtin_expect (cache_entry == null, false)) + ? cache_entry = _Jv_ResolvePoolEntry (output_class, cpool_index) + : cache_entry) + + This can mostly be optimized away, so that the usual path is a + load followed by a test and branch. _Jv_ResolvePoolEntry is + only called once for each constant pool entry. + + There is an optimization that we don't do: at the start of a + method, create a local copy of CACHE_ENTRY and use that instead. + + */ + + int cpool_index = alloc_constant_fieldref (output_class, fdecl); + tree cache_entry = build_fieldref_cache_entry (cpool_index, fdecl); + tree test + = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, + build2 (EQ_EXPR, boolean_type_node, + cache_entry, null_pointer_node), + boolean_false_node); + tree cpool_index_cst = build_int_cst (NULL_TREE, cpool_index); + tree init + = build_call_expr (soft_resolvepoolentry_node, 2, + build_class_ref (output_class), + cpool_index_cst); + init = build2 (MODIFY_EXPR, ptr_type_node, cache_entry, init); + init = build3 (COND_EXPR, ptr_type_node, test, init, cache_entry); + init = fold_convert (build_pointer_type (TREE_TYPE (fdecl)), init); + fdecl = build1 (INDIRECT_REF, TREE_TYPE (fdecl), init); + } + return fdecl; +} + +int +get_access_flags_from_decl (tree decl) +{ + int access_flags = 0; + if (TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == VAR_DECL) + { + if (FIELD_STATIC (decl)) + access_flags |= ACC_STATIC; + if (FIELD_PUBLIC (decl)) + access_flags |= ACC_PUBLIC; + if (FIELD_PROTECTED (decl)) + access_flags |= ACC_PROTECTED; + if (FIELD_PRIVATE (decl)) + access_flags |= ACC_PRIVATE; + if (FIELD_FINAL (decl)) + access_flags |= ACC_FINAL; + if (FIELD_VOLATILE (decl)) + access_flags |= ACC_VOLATILE; + if (FIELD_TRANSIENT (decl)) + access_flags |= ACC_TRANSIENT; + if (FIELD_ENUM (decl)) + access_flags |= ACC_ENUM; + if (FIELD_SYNTHETIC (decl)) + access_flags |= ACC_SYNTHETIC; + return access_flags; + } + if (TREE_CODE (decl) == TYPE_DECL) + { + if (CLASS_PUBLIC (decl)) + access_flags |= ACC_PUBLIC; + if (CLASS_FINAL (decl)) + access_flags |= ACC_FINAL; + if (CLASS_SUPER (decl)) + access_flags |= ACC_SUPER; + if (CLASS_INTERFACE (decl)) + access_flags |= ACC_INTERFACE; + if (CLASS_ABSTRACT (decl)) + access_flags |= ACC_ABSTRACT; + if (CLASS_STATIC (decl)) + access_flags |= ACC_STATIC; + if (CLASS_PRIVATE (decl)) + access_flags |= ACC_PRIVATE; + if (CLASS_PROTECTED (decl)) + access_flags |= ACC_PROTECTED; + if (CLASS_STRICTFP (decl)) + access_flags |= ACC_STRICT; + if (CLASS_ENUM (decl)) + access_flags |= ACC_ENUM; + if (CLASS_SYNTHETIC (decl)) + access_flags |= ACC_SYNTHETIC; + if (CLASS_ANNOTATION (decl)) + access_flags |= ACC_ANNOTATION; + return access_flags; + } + if (TREE_CODE (decl) == FUNCTION_DECL) + { + if (METHOD_PUBLIC (decl)) + access_flags |= ACC_PUBLIC; + if (METHOD_PRIVATE (decl)) + access_flags |= ACC_PRIVATE; + if (METHOD_PROTECTED (decl)) + access_flags |= ACC_PROTECTED; + if (METHOD_STATIC (decl)) + access_flags |= ACC_STATIC; + if (METHOD_FINAL (decl)) + access_flags |= ACC_FINAL; + if (METHOD_SYNCHRONIZED (decl)) + access_flags |= ACC_SYNCHRONIZED; + if (METHOD_NATIVE (decl)) + access_flags |= ACC_NATIVE; + if (METHOD_ABSTRACT (decl)) + access_flags |= ACC_ABSTRACT; + if (METHOD_STRICTFP (decl)) + access_flags |= ACC_STRICT; + if (METHOD_INVISIBLE (decl)) + access_flags |= ACC_INVISIBLE; + if (DECL_ARTIFICIAL (decl)) + access_flags |= ACC_SYNTHETIC; + if (METHOD_BRIDGE (decl)) + access_flags |= ACC_BRIDGE; + if (METHOD_VARARGS (decl)) + access_flags |= ACC_VARARGS; + return access_flags; + } + gcc_unreachable (); +} + +static GTY (()) int alias_labelno = 0; + +/* Create a private alias for METHOD. Using this alias instead of the method + decl ensures that ncode entries in the method table point to the real function + at runtime, not a PLT entry. */ + +static tree +make_local_function_alias (tree method) +{ +#ifdef ASM_OUTPUT_DEF + tree alias; + + const char *method_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (method)); + char *name = (char *) alloca (strlen (method_name) + 2); + char *buf = (char *) alloca (strlen (method_name) + 128); + + /* Only create aliases for local functions. */ + if (DECL_EXTERNAL (method)) + return method; + + /* Prefix method_name with 'L' for the alias label. */ + *name = 'L'; + strcpy (name + 1, method_name); + + targetm.asm_out.generate_internal_label (buf, name, alias_labelno++); + alias = build_decl (input_location, + FUNCTION_DECL, get_identifier (buf), + TREE_TYPE (method)); + DECL_CONTEXT (alias) = NULL; + TREE_READONLY (alias) = TREE_READONLY (method); + TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (method); + TREE_PUBLIC (alias) = 0; + DECL_EXTERNAL (alias) = 0; + DECL_ARTIFICIAL (alias) = 1; + DECL_INITIAL (alias) = error_mark_node; + TREE_ADDRESSABLE (alias) = 1; + TREE_USED (alias) = 1; + TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (alias)) = 1; + if (!flag_syntax_only) + assemble_alias (alias, DECL_ASSEMBLER_NAME (method)); + return alias; +#else + return method; +#endif +} + +/** Make reflection data (_Jv_Field) for field FDECL. */ + +static tree +make_field_value (tree fdecl) +{ + tree finit; + int flags; + tree type = TREE_TYPE (fdecl); + int resolved = is_compiled_class (type) && ! flag_indirect_dispatch; + VEC(constructor_elt,gc) *v = NULL; + + START_RECORD_CONSTRUCTOR (v, field_type_node); + PUSH_FIELD_VALUE (v, "name", build_utf8_ref (DECL_NAME (fdecl))); + if (resolved) + type = build_class_ref (type); + else + { + tree signature = build_java_signature (type); + + type = build_utf8_ref (unmangle_classname + (IDENTIFIER_POINTER (signature), + IDENTIFIER_LENGTH (signature))); + } + PUSH_FIELD_VALUE (v, "type", type); + + flags = get_access_flags_from_decl (fdecl); + if (! resolved) + flags |= 0x8000 /* FIELD_UNRESOLVED_FLAG */; + + PUSH_FIELD_VALUE (v, "accflags", build_int_cst (NULL_TREE, flags)); + PUSH_FIELD_VALUE (v, "bsize", TYPE_SIZE_UNIT (TREE_TYPE (fdecl))); + + { + tree field_address = integer_zero_node; + tree index, value; + if ((DECL_INITIAL (fdecl) || ! flag_indirect_classes) + && FIELD_STATIC (fdecl)) + field_address = build_address_of (fdecl); + + index = (FIELD_STATIC (fdecl) + ? DECL_CHAIN (TYPE_FIELDS (field_info_union_node)) + : TYPE_FIELDS (field_info_union_node)); + value = (FIELD_STATIC (fdecl) + ? field_address + : byte_position (fdecl)); + + PUSH_FIELD_VALUE + (v, "info", + build_constructor_single (field_info_union_node, index, value)); + } + + FINISH_RECORD_CONSTRUCTOR (finit, v, field_type_node); + return finit; +} + +/** Make reflection data (_Jv_Method) for method MDECL. */ + +static tree +make_method_value (tree mdecl) +{ + static int method_name_count = 0; + tree minit; + tree index; + tree code; + tree class_decl; +#define ACC_TRANSLATED 0x4000 + int accflags = get_access_flags_from_decl (mdecl) | ACC_TRANSLATED; + VEC(constructor_elt,gc) *v = NULL; + + class_decl = DECL_CONTEXT (mdecl); + /* For interfaces, the index field contains the dispatch index. */ + if (CLASS_INTERFACE (TYPE_NAME (class_decl))) + index = build_int_cst (NULL_TREE, + get_interface_method_index (mdecl, class_decl)); + else if (!flag_indirect_dispatch && get_method_index (mdecl) != NULL_TREE) + index = get_method_index (mdecl); + else + index = integer_minus_one_node; + + code = null_pointer_node; + if (METHOD_ABSTRACT (mdecl)) + code = build1 (ADDR_EXPR, nativecode_ptr_type_node, + soft_abstractmethod_node); + else + code = build1 (ADDR_EXPR, nativecode_ptr_type_node, + make_local_function_alias (mdecl)); + START_RECORD_CONSTRUCTOR (v, method_type_node); + PUSH_FIELD_VALUE (v, "name", + build_utf8_ref (DECL_CONSTRUCTOR_P (mdecl) ? + init_identifier_node + : DECL_NAME (mdecl))); + { + tree signature = build_java_signature (TREE_TYPE (mdecl)); + PUSH_FIELD_VALUE (v, "signature", + (build_utf8_ref + (unmangle_classname + (IDENTIFIER_POINTER(signature), + IDENTIFIER_LENGTH(signature))))); + } + PUSH_FIELD_VALUE (v, "accflags", build_int_cst (NULL_TREE, accflags)); + PUSH_FIELD_VALUE (v, "index", index); + PUSH_FIELD_VALUE (v, "ncode", code); + + { + /* Compute the `throws' information for the method. */ + tree table = null_pointer_node; + + if (!VEC_empty (tree, DECL_FUNCTION_THROWS (mdecl))) + { + int length = 1 + VEC_length (tree, DECL_FUNCTION_THROWS (mdecl)); + tree t, type, array; + char buf[60]; + VEC(constructor_elt,gc) *v = NULL; + int idx = length - 1; + unsigned ix; + constructor_elt *e; + + v = VEC_alloc (constructor_elt, gc, length); + VEC_safe_grow_cleared (constructor_elt, gc, v, length); + + e = VEC_index (constructor_elt, v, idx--); + e->value = null_pointer_node; + + FOR_EACH_VEC_ELT (tree, DECL_FUNCTION_THROWS (mdecl), ix, t) + { + tree sig = DECL_NAME (TYPE_NAME (t)); + tree utf8 + = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (sig), + IDENTIFIER_LENGTH (sig))); + e = VEC_index (constructor_elt, v, idx--); + e->value = utf8; + } + gcc_assert (idx == -1); + type = build_prim_array_type (ptr_type_node, length); + table = build_constructor (type, v); + /* Compute something unique enough. */ + sprintf (buf, "_methods%d", method_name_count++); + array = build_decl (input_location, + VAR_DECL, get_identifier (buf), type); + DECL_INITIAL (array) = table; + TREE_STATIC (array) = 1; + DECL_ARTIFICIAL (array) = 1; + DECL_IGNORED_P (array) = 1; + rest_of_decl_compilation (array, 1, 0); + + table = build1 (ADDR_EXPR, ptr_type_node, array); + } + + PUSH_FIELD_VALUE (v, "throws", table); + } + + FINISH_RECORD_CONSTRUCTOR (minit, v, method_type_node); + return minit; +} + +static tree +get_dispatch_vector (tree type) +{ + tree vtable = TYPE_VTABLE (type); + + if (vtable == NULL_TREE) + { + HOST_WIDE_INT i; + tree method; + tree super = CLASSTYPE_SUPER (type); + HOST_WIDE_INT nvirtuals = tree_low_cst (TYPE_NVIRTUALS (type), 0); + vtable = make_tree_vec (nvirtuals); + TYPE_VTABLE (type) = vtable; + if (super != NULL_TREE) + { + tree super_vtable = get_dispatch_vector (super); + + for (i = tree_low_cst (TYPE_NVIRTUALS (super), 0); --i >= 0; ) + TREE_VEC_ELT (vtable, i) = TREE_VEC_ELT (super_vtable, i); + } + + for (method = TYPE_METHODS (type); method != NULL_TREE; + method = DECL_CHAIN (method)) + { + tree method_index = get_method_index (method); + if (method_index != NULL_TREE + && host_integerp (method_index, 0)) + TREE_VEC_ELT (vtable, tree_low_cst (method_index, 0)) = method; + } + } + + return vtable; +} + +static tree +get_dispatch_table (tree type, tree this_class_addr) +{ + int abstract_p = CLASS_ABSTRACT (TYPE_NAME (type)); + tree vtable = get_dispatch_vector (type); + int i, j; + int nvirtuals = TREE_VEC_LENGTH (vtable); + int arraysize; + tree gc_descr; + VEC(constructor_elt,gc) *v = NULL; + constructor_elt *e; + tree arraytype; + + arraysize = (TARGET_VTABLE_USES_DESCRIPTORS? nvirtuals + 1 : nvirtuals + 2); + if (TARGET_VTABLE_USES_DESCRIPTORS) + arraysize *= TARGET_VTABLE_USES_DESCRIPTORS; + arraysize += 2; + + VEC_safe_grow_cleared (constructor_elt, gc, v, arraysize); + e = VEC_index (constructor_elt, v, arraysize - 1); + +#define CONSTRUCTOR_PREPEND_VALUE(E, V) E->value = V, E-- + for (i = nvirtuals; --i >= 0; ) + { + tree method = TREE_VEC_ELT (vtable, i); + if (METHOD_ABSTRACT (method)) + { + if (! abstract_p) + warning_at (DECL_SOURCE_LOCATION (method), 0, + "abstract method in non-abstract class"); + + if (TARGET_VTABLE_USES_DESCRIPTORS) + for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j) + CONSTRUCTOR_PREPEND_VALUE (e, null_pointer_node); + else + CONSTRUCTOR_PREPEND_VALUE (e, null_pointer_node); + } + else + { + if (TARGET_VTABLE_USES_DESCRIPTORS) + for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j) + { + tree fdesc = build2 (FDESC_EXPR, nativecode_ptr_type_node, + method, build_int_cst (NULL_TREE, j)); + TREE_CONSTANT (fdesc) = 1; + CONSTRUCTOR_PREPEND_VALUE (e, fdesc); + } + else + CONSTRUCTOR_PREPEND_VALUE (e, + build1 (ADDR_EXPR, + nativecode_ptr_type_node, + method)); + } + } + + /* Dummy entry for compatibility with G++ -fvtable-thunks. When + using the Boehm GC we sometimes stash a GC type descriptor + there. We set the PURPOSE to NULL_TREE not to interfere (reset) + the emitted byte count during the output to the assembly file. */ + /* With TARGET_VTABLE_USES_DESCRIPTORS, we only add one extra + fake "function descriptor". It's first word is the is the class + pointer, and subsequent words (usually one) contain the GC descriptor. + In all other cases, we reserve two extra vtable slots. */ + gc_descr = get_boehm_type_descriptor (type); + CONSTRUCTOR_PREPEND_VALUE (e, gc_descr); + for (j = 1; j < TARGET_VTABLE_USES_DESCRIPTORS-1; ++j) + CONSTRUCTOR_PREPEND_VALUE (e, gc_descr); + CONSTRUCTOR_PREPEND_VALUE (e, this_class_addr); + + /** Pointer to type_info object (to be implemented), according to g++ ABI. */ + CONSTRUCTOR_PREPEND_VALUE (e, null_pointer_node); + /** Offset to start of whole object. Always (ptrdiff_t)0 for Java. */ + gcc_assert (e == VEC_address (constructor_elt, v)); + e->index = integer_zero_node; + e->value = null_pointer_node; +#undef CONSTRUCTOR_PREPEND_VALUE + + arraytype = build_prim_array_type (nativecode_ptr_type_node, arraysize); + return build_constructor (arraytype, v); +} + + +/* Set the method_index for a method decl. */ +void +set_method_index (tree decl, tree method_index) +{ + if (method_index != NULL_TREE) + { + /* method_index is null if we're using indirect dispatch. */ + method_index = fold (convert (sizetype, method_index)); + + if (TARGET_VTABLE_USES_DESCRIPTORS) + /* Add one to skip bogus descriptor for class and GC descriptor. */ + method_index = size_binop (PLUS_EXPR, method_index, size_int (1)); + else + /* Add 1 to skip "class" field of dtable, and 1 to skip GC + descriptor. */ + method_index = size_binop (PLUS_EXPR, method_index, size_int (2)); + } + + DECL_VINDEX (decl) = method_index; +} + +/* Get the method_index for a method decl. */ +tree +get_method_index (tree decl) +{ + tree method_index = DECL_VINDEX (decl); + + if (! method_index) + return NULL; + + if (TARGET_VTABLE_USES_DESCRIPTORS) + /* Sub one to skip bogus descriptor for class and GC descriptor. */ + method_index = size_binop (MINUS_EXPR, method_index, size_int (1)); + else + /* Sub 1 to skip "class" field of dtable, and 1 to skip GC descriptor. */ + method_index = size_binop (MINUS_EXPR, method_index, size_int (2)); + + return method_index; +} + +static int +supers_all_compiled (tree type) +{ + while (type != NULL_TREE) + { + if (!assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))))) + return 0; + type = CLASSTYPE_SUPER (type); + } + return 1; +} + +static void +add_table_and_syms (VEC(constructor_elt,gc) **v, + VEC(method_entry,gc) *methods, + const char *table_name, tree table_slot, tree table_type, + const char *syms_name, tree syms_slot) +{ + if (methods == NULL) + { + PUSH_FIELD_VALUE (*v, table_name, null_pointer_node); + PUSH_FIELD_VALUE (*v, syms_name, null_pointer_node); + } + else + { + pushdecl_top_level (syms_slot); + PUSH_FIELD_VALUE (*v, table_name, + build1 (ADDR_EXPR, table_type, table_slot)); + PUSH_FIELD_VALUE (*v, syms_name, + build1 (ADDR_EXPR, symbols_array_ptr_type, + syms_slot)); + TREE_CONSTANT (table_slot) = 1; + } +} + +void +make_class_data (tree type) +{ + tree decl, cons, temp; + tree field, fields_decl; + HOST_WIDE_INT static_field_count = 0; + HOST_WIDE_INT instance_field_count = 0; + HOST_WIDE_INT field_count; + tree field_array_type; + tree method; + tree dtable_decl = NULL_TREE; + HOST_WIDE_INT method_count = 0; + tree method_array_type; + tree methods_decl; + tree super; + tree this_class_addr; + tree constant_pool_constructor; + tree interfaces = null_pointer_node; + int interface_len = 0; + int uses_jv_markobj = 0; + tree type_decl = TYPE_NAME (type); + tree id_main = get_identifier("main"); + tree id_class = get_identifier("java.lang.Class"); + /** Offset from start of virtual function table declaration + to where objects actually point at, following new g++ ABI. */ + tree dtable_start_offset = size_int (2 * POINTER_SIZE / BITS_PER_UNIT); + VEC(int, heap) *field_indexes; + tree first_real_field; + VEC(constructor_elt,gc) *v1 = NULL, *v2 = NULL; + tree reflection_data; + VEC(constructor_elt,gc) *static_fields = NULL; + VEC(constructor_elt,gc) *instance_fields = NULL; + VEC(constructor_elt,gc) *methods = NULL; + + this_class_addr = build_static_class_ref (type); + decl = TREE_OPERAND (this_class_addr, 0); + + if (supers_all_compiled (type) && ! CLASS_INTERFACE (type_decl) + && !flag_indirect_dispatch) + { + tree dtable = get_dispatch_table (type, this_class_addr); + uses_jv_markobj = uses_jv_markobj_p (dtable); + if (type == class_type_node && class_dtable_decl != NULL_TREE) + { + /* We've already created some other class, and consequently + we made class_dtable_decl. Now we just want to fill it + in. */ + dtable_decl = class_dtable_decl; + } + else + { + dtable_decl = build_dtable_decl (type); + TREE_STATIC (dtable_decl) = 1; + DECL_ARTIFICIAL (dtable_decl) = 1; + DECL_IGNORED_P (dtable_decl) = 1; + } + + TREE_PUBLIC (dtable_decl) = 1; + DECL_INITIAL (dtable_decl) = dtable; + /* The only dispatch table exported from a DSO is the dispatch + table for java.lang.Class. */ + if (DECL_NAME (type_decl) != id_class) + java_hide_decl (dtable_decl); + if (! flag_indirect_classes) + rest_of_decl_compilation (dtable_decl, 1, 0); + /* Maybe we're compiling Class as the first class. If so, set + class_dtable_decl to the decl we just made. */ + if (type == class_type_node && class_dtable_decl == NULL_TREE) + class_dtable_decl = dtable_decl; + } + + /* Build Field array. */ + field = TYPE_FIELDS (type); + while (field && DECL_ARTIFICIAL (field)) + field = DECL_CHAIN (field); /* Skip dummy fields. */ + if (field && DECL_NAME (field) == NULL_TREE) + field = DECL_CHAIN (field); /* Skip dummy field for inherited data. */ + first_real_field = field; + + /* First count static and instance fields. */ + for ( ; field != NULL_TREE; field = DECL_CHAIN (field)) + { + if (! DECL_ARTIFICIAL (field)) + { + if (FIELD_STATIC (field)) + static_field_count++; + else if (uses_jv_markobj || !flag_reduced_reflection) + instance_field_count++; + } + } + field_count = static_field_count + instance_field_count; + field_indexes = VEC_alloc (int, heap, field_count); + + /* gcj sorts fields so that static fields come first, followed by + instance fields. Unfortunately, by the time this takes place we + have already generated the reflection_data for this class, and + that data contains indexes into the fields. So, we generate a + permutation that maps each original field index to its final + position. Then we pass this permutation to + rewrite_reflection_indexes(), which fixes up the reflection + data. */ + { + int i; + int static_count = 0; + int instance_count = static_field_count; + int field_index; + + for (i = 0, field = first_real_field; + field != NULL_TREE; + field = DECL_CHAIN (field), i++) + { + if (! DECL_ARTIFICIAL (field)) + { + field_index = 0; + if (FIELD_STATIC (field)) + field_index = static_count++; + else if (uses_jv_markobj || !flag_reduced_reflection) + field_index = instance_count++; + else + continue; + VEC_quick_push (int, field_indexes, field_index); + } + } + } + + for (field = first_real_field; field != NULL_TREE; + field = DECL_CHAIN (field)) + { + if (! DECL_ARTIFICIAL (field)) + { + if (FIELD_STATIC (field)) + { + /* We must always create reflection data for static fields + as it is used in the creation of the field itself. */ + tree init = make_field_value (field); + tree initial = DECL_INITIAL (field); + CONSTRUCTOR_APPEND_ELT (static_fields, NULL_TREE, init); + /* If the initial value is a string constant, + prevent output_constant from trying to assemble the value. */ + if (initial != NULL_TREE + && TREE_TYPE (initial) == string_ptr_type_node) + DECL_INITIAL (field) = NULL_TREE; + rest_of_decl_compilation (field, 1, 1); + DECL_INITIAL (field) = initial; + } + else if (uses_jv_markobj || !flag_reduced_reflection) + { + tree init = make_field_value (field); + CONSTRUCTOR_APPEND_ELT (instance_fields, NULL_TREE, init); + } + } + } + + gcc_assert (static_field_count + == (int) VEC_length (constructor_elt, static_fields)); + gcc_assert (instance_field_count + == (int) VEC_length (constructor_elt, instance_fields)); + + if (field_count > 0) + { + VEC_safe_splice (constructor_elt, gc, static_fields, instance_fields); + field_array_type = build_prim_array_type (field_type_node, field_count); + fields_decl = build_decl (input_location, + VAR_DECL, mangled_classname ("_FL_", type), + field_array_type); + DECL_INITIAL (fields_decl) + = build_constructor (field_array_type, static_fields); + TREE_STATIC (fields_decl) = 1; + DECL_ARTIFICIAL (fields_decl) = 1; + DECL_IGNORED_P (fields_decl) = 1; + rest_of_decl_compilation (fields_decl, 1, 0); + } + else + fields_decl = NULL_TREE; + + /* Build Method array. */ + for (method = TYPE_METHODS (type); + method != NULL_TREE; method = DECL_CHAIN (method)) + { + tree init; + if (METHOD_PRIVATE (method) + && ! flag_keep_inline_functions + && optimize) + continue; + /* Even if we have a decl, we don't necessarily have the code. + This can happen if we inherit a method from a superclass for + which we don't have a .class file. */ + if (METHOD_DUMMY (method)) + continue; + + /* Generate method reflection data if: + + - !flag_reduced_reflection. + + - <clinit> -- The runtime uses reflection to initialize the + class. + + - Any method in class java.lang.Class -- Class.forName() and + perhaps other things require it. + + - class$ -- It does not work if reflection data missing. + + - main -- Reflection is used to find main(String[]) methods. + + - public not static -- It is potentially part of an + interface. The runtime uses reflection data to build + interface dispatch tables. */ + if (!flag_reduced_reflection + || DECL_CLINIT_P (method) + || DECL_NAME (type_decl) == id_class + || DECL_NAME (method) == id_main + || (METHOD_PUBLIC (method) && !METHOD_STATIC (method))) + { + init = make_method_value (method); + method_count++; + CONSTRUCTOR_APPEND_ELT (methods, NULL_TREE, init); + } + } + method_array_type = build_prim_array_type (method_type_node, method_count); + methods_decl = build_decl (input_location, + VAR_DECL, mangled_classname ("_MT_", type), + method_array_type); + DECL_INITIAL (methods_decl) = build_constructor (method_array_type, methods); + TREE_STATIC (methods_decl) = 1; + DECL_ARTIFICIAL (methods_decl) = 1; + DECL_IGNORED_P (methods_decl) = 1; + rest_of_decl_compilation (methods_decl, 1, 0); + + if (class_dtable_decl == NULL_TREE) + { + class_dtable_decl = build_dtable_decl (class_type_node); + TREE_STATIC (class_dtable_decl) = 1; + DECL_ARTIFICIAL (class_dtable_decl) = 1; + DECL_IGNORED_P (class_dtable_decl) = 1; + if (is_compiled_class (class_type_node) != 2) + { + DECL_EXTERNAL (class_dtable_decl) = 1; + rest_of_decl_compilation (class_dtable_decl, 1, 0); + } + } + + super = CLASSTYPE_SUPER (type); + if (super == NULL_TREE) + super = null_pointer_node; + else if (! flag_indirect_dispatch + && assume_compiled (IDENTIFIER_POINTER (DECL_NAME (type_decl))) + && assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (super))))) + super = build_class_ref (super); + else + { + int super_index = alloc_class_constant (super); + super = build_int_cst (ptr_type_node, super_index); + } + + /* Build and emit the array of implemented interfaces. */ + if (type != object_type_node) + interface_len = BINFO_N_BASE_BINFOS (TYPE_BINFO (type)) - 1; + + if (interface_len > 0) + { + int i; + tree interface_array_type, idecl; + VEC(constructor_elt,gc) *init = VEC_alloc (constructor_elt, gc, + interface_len); + interface_array_type + = build_prim_array_type (class_ptr_type, interface_len); + idecl = build_decl (input_location, + VAR_DECL, mangled_classname ("_IF_", type), + interface_array_type); + + for (i = 1; i <= interface_len; i++) + { + tree child = BINFO_BASE_BINFO (TYPE_BINFO (type), i); + tree iclass = BINFO_TYPE (child); + tree index; + if (! flag_indirect_dispatch + && (assume_compiled + (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (iclass)))))) + index = build_class_ref (iclass); + else + { + int int_index = alloc_class_constant (iclass); + index = build_int_cst (ptr_type_node, int_index); + } + CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, index); + } + DECL_INITIAL (idecl) = build_constructor (interface_array_type, init); + TREE_STATIC (idecl) = 1; + DECL_ARTIFICIAL (idecl) = 1; + DECL_IGNORED_P (idecl) = 1; + interfaces = build1 (ADDR_EXPR, ptr_type_node, idecl); + rest_of_decl_compilation (idecl, 1, 0); + } + + constant_pool_constructor = build_constants_constructor (); + + if (flag_indirect_dispatch) + { + TYPE_OTABLE_DECL (type) + = emit_symbol_table + (DECL_NAME (TYPE_OTABLE_DECL (type)), + TYPE_OTABLE_DECL (type), TYPE_OTABLE_METHODS (type), + TYPE_OTABLE_SYMS_DECL (type), integer_type_node, 1); + + TYPE_ATABLE_DECL (type) + = emit_symbol_table + (DECL_NAME (TYPE_ATABLE_DECL (type)), + TYPE_ATABLE_DECL (type), TYPE_ATABLE_METHODS (type), + TYPE_ATABLE_SYMS_DECL (type), ptr_type_node, 1); + + TYPE_ITABLE_DECL (type) + = emit_symbol_table + (DECL_NAME (TYPE_ITABLE_DECL (type)), + TYPE_ITABLE_DECL (type), TYPE_ITABLE_METHODS (type), + TYPE_ITABLE_SYMS_DECL (type), ptr_type_node, 2); + } + + TYPE_CTABLE_DECL (type) = emit_catch_table (type); + + START_RECORD_CONSTRUCTOR (v1, object_type_node); + PUSH_FIELD_VALUE (v1, "vtable", + (flag_indirect_classes + ? null_pointer_node + : build2 (POINTER_PLUS_EXPR, dtable_ptr_type, + build1 (ADDR_EXPR, dtable_ptr_type, + class_dtable_decl), + dtable_start_offset))); + if (! flag_hash_synchronization) + PUSH_FIELD_VALUE (v1, "sync_info", null_pointer_node); + FINISH_RECORD_CONSTRUCTOR (temp, v1, object_type_node); + START_RECORD_CONSTRUCTOR (v2, class_type_node); + PUSH_SUPER_VALUE (v2, temp); + PUSH_FIELD_VALUE (v2, "next_or_version", gcj_abi_version); + PUSH_FIELD_VALUE (v2, "name", build_utf8_ref (DECL_NAME (type_decl))); + PUSH_FIELD_VALUE (v2, "accflags", + build_int_cst (NULL_TREE, + get_access_flags_from_decl (type_decl))); + + PUSH_FIELD_VALUE (v2, "superclass", + CLASS_INTERFACE (type_decl) ? null_pointer_node : super); + PUSH_FIELD_VALUE (v2, "constants", constant_pool_constructor); + PUSH_FIELD_VALUE (v2, "methods", + methods_decl == NULL_TREE ? null_pointer_node + : build1 (ADDR_EXPR, method_ptr_type_node, methods_decl)); + PUSH_FIELD_VALUE (v2, "method_count", + build_int_cst (NULL_TREE, method_count)); + + PUSH_FIELD_VALUE (v2, "vtable_method_count", + (flag_indirect_dispatch + ? integer_minus_one_node + : TYPE_NVIRTUALS (type))); + + PUSH_FIELD_VALUE (v2, "fields", + fields_decl == NULL_TREE ? null_pointer_node + : build1 (ADDR_EXPR, field_ptr_type_node, fields_decl)); + /* If we're using the binary compatibility ABI we don't know the + size until load time. */ + PUSH_FIELD_VALUE (v2, "size_in_bytes", + (flag_indirect_dispatch + ? integer_minus_one_node + : size_in_bytes (type))); + PUSH_FIELD_VALUE (v2, "field_count", + build_int_cst (NULL_TREE, field_count)); + PUSH_FIELD_VALUE (v2, "static_field_count", + build_int_cst (NULL_TREE, static_field_count)); + + PUSH_FIELD_VALUE (v2, "vtable", + (flag_indirect_dispatch || dtable_decl == NULL_TREE + ? null_pointer_node + : build2 (POINTER_PLUS_EXPR, dtable_ptr_type, + build1 (ADDR_EXPR, dtable_ptr_type, + dtable_decl), + dtable_start_offset))); + add_table_and_syms (&v2, TYPE_OTABLE_METHODS (type), + "otable", TYPE_OTABLE_DECL (type), otable_ptr_type, + "otable_syms", TYPE_OTABLE_SYMS_DECL (type)); + add_table_and_syms (&v2, TYPE_ATABLE_METHODS (type), + "atable", TYPE_ATABLE_DECL (type), atable_ptr_type, + "atable_syms", TYPE_ATABLE_SYMS_DECL (type)); + add_table_and_syms (&v2, TYPE_ITABLE_METHODS (type), + "itable", TYPE_ITABLE_DECL (type), itable_ptr_type, + "itable_syms", TYPE_ITABLE_SYMS_DECL (type)); + + PUSH_FIELD_VALUE (v2, "catch_classes", + build1 (ADDR_EXPR, ptr_type_node, TYPE_CTABLE_DECL (type))); + PUSH_FIELD_VALUE (v2, "interfaces", interfaces); + PUSH_FIELD_VALUE (v2, "loader", null_pointer_node); + PUSH_FIELD_VALUE (v2, "interface_count", + build_int_cst (NULL_TREE, interface_len)); + PUSH_FIELD_VALUE (v2, "state", + convert (byte_type_node, + build_int_cst (NULL_TREE, JV_STATE_PRELOADING))); + + PUSH_FIELD_VALUE (v2, "thread", null_pointer_node); + PUSH_FIELD_VALUE (v2, "depth", integer_zero_node); + PUSH_FIELD_VALUE (v2, "ancestors", null_pointer_node); + PUSH_FIELD_VALUE (v2, "idt", null_pointer_node); + PUSH_FIELD_VALUE (v2, "arrayclass", null_pointer_node); + PUSH_FIELD_VALUE (v2, "protectionDomain", null_pointer_node); + + { + tree assertion_table_ref; + if (TYPE_ASSERTIONS (type) == NULL) + assertion_table_ref = null_pointer_node; + else + assertion_table_ref = build1 (ADDR_EXPR, + build_pointer_type (assertion_table_type), + emit_assertion_table (type)); + + PUSH_FIELD_VALUE (v2, "assertion_table", assertion_table_ref); + } + + PUSH_FIELD_VALUE (v2, "hack_signers", null_pointer_node); + PUSH_FIELD_VALUE (v2, "chain", null_pointer_node); + PUSH_FIELD_VALUE (v2, "aux_info", null_pointer_node); + PUSH_FIELD_VALUE (v2, "engine", null_pointer_node); + + if (TYPE_REFLECTION_DATA (current_class)) + { + int i; + int count = TYPE_REFLECTION_DATASIZE (current_class); + VEC (constructor_elt, gc) *v + = VEC_alloc (constructor_elt, gc, count); + unsigned char *data = TYPE_REFLECTION_DATA (current_class); + tree max_index = build_int_cst (sizetype, count); + tree index = build_index_type (max_index); + tree type = build_array_type (unsigned_byte_type_node, index); + char buf[64]; + tree array; + static int reflection_data_count; + + sprintf (buf, "_reflection_data_%d", reflection_data_count++); + array = build_decl (input_location, + VAR_DECL, get_identifier (buf), type); + + rewrite_reflection_indexes (field_indexes); + + for (i = 0; i < count; i++) + { + constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL); + elt->index = build_int_cst (sizetype, i); + elt->value = build_int_cstu (byte_type_node, data[i]); + } + + DECL_INITIAL (array) = build_constructor (type, v); + TREE_STATIC (array) = 1; + DECL_ARTIFICIAL (array) = 1; + DECL_IGNORED_P (array) = 1; + TREE_READONLY (array) = 1; + TREE_CONSTANT (DECL_INITIAL (array)) = 1; + rest_of_decl_compilation (array, 1, 0); + + reflection_data = build_address_of (array); + + free (data); + TYPE_REFLECTION_DATA (current_class) = NULL; + } + else + reflection_data = null_pointer_node; + + PUSH_FIELD_VALUE (v2, "reflection_data", reflection_data); + FINISH_RECORD_CONSTRUCTOR (cons, v2, class_type_node); + + DECL_INITIAL (decl) = cons; + + /* Hash synchronization requires at least 64-bit alignment. */ + if (flag_hash_synchronization && POINTER_SIZE < 64) + DECL_ALIGN (decl) = 64; + + if (flag_indirect_classes) + { + TREE_READONLY (decl) = 1; + TREE_CONSTANT (DECL_INITIAL (decl)) = 1; + } + + rest_of_decl_compilation (decl, 1, 0); + + { + tree classdollar_field = build_classdollar_field (type); + if (!flag_indirect_classes) + DECL_INITIAL (classdollar_field) = build_static_class_ref (type); + rest_of_decl_compilation (classdollar_field, 1, 0); + } + + TYPE_OTABLE_DECL (type) = NULL_TREE; + TYPE_ATABLE_DECL (type) = NULL_TREE; + TYPE_CTABLE_DECL (type) = NULL_TREE; +} + +void +finish_class (void) +{ + java_expand_catch_classes (current_class); + + current_function_decl = NULL_TREE; + TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (current_class)) = 0; + make_class_data (current_class); + register_class (); + rest_of_decl_compilation (TYPE_NAME (current_class), 1, 0); +} + +/* Return 2 if KLASS is compiled by this compilation job; + return 1 if KLASS can otherwise be assumed to be compiled; + return 0 if we cannot assume that KLASS is compiled. + Returns 1 for primitive and 0 for array types. */ +int +is_compiled_class (tree klass) +{ + int seen_in_zip; + if (TREE_CODE (klass) == POINTER_TYPE) + klass = TREE_TYPE (klass); + if (TREE_CODE (klass) != RECORD_TYPE) /* Primitive types are static. */ + return 1; + if (TYPE_ARRAY_P (klass)) + return 0; + + seen_in_zip = (TYPE_JCF (klass) && JCF_SEEN_IN_ZIP (TYPE_JCF (klass))); + if (CLASS_FROM_CURRENTLY_COMPILED_P (klass)) + { + /* The class was seen in the current ZIP file and will be + available as a compiled class in the future but may not have + been loaded already. Load it if necessary. This prevent + build_class_ref () from crashing. */ + + if (seen_in_zip && !CLASS_LOADED_P (klass) && (klass != current_class)) + load_class (klass, 1); + + /* We return 2 for class seen in ZIP and class from files + belonging to the same compilation unit */ + return 2; + } + + if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (klass))))) + { + if (!CLASS_LOADED_P (klass)) + { + if (klass != current_class) + load_class (klass, 1); + } + return 1; + } + + return 0; +} + +/* Build a VAR_DECL for the dispatch table (vtable) for class TYPE. */ + +tree +build_dtable_decl (tree type) +{ + tree dtype, decl; + + /* We need to build a new dtable type so that its size is uniquely + computed when we're dealing with the class for real and not just + faking it (like java.lang.Class during the initialization of the + compiler.) We know we're not faking a class when CURRENT_CLASS is + TYPE. */ + if (current_class == type) + { + tree dummy = NULL_TREE; + int n; + + dtype = make_node (RECORD_TYPE); + + PUSH_FIELD (input_location, dtype, dummy, "top_offset", ptr_type_node); + PUSH_FIELD (input_location, dtype, dummy, "type_info", ptr_type_node); + + PUSH_FIELD (input_location, dtype, dummy, "class", class_ptr_type); + for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n) + { + tree tmp_field = build_decl (input_location, + FIELD_DECL, NULL_TREE, ptr_type_node); + TREE_CHAIN (dummy) = tmp_field; + DECL_CONTEXT (tmp_field) = dtype; + DECL_ARTIFICIAL (tmp_field) = 1; + dummy = tmp_field; + } + + PUSH_FIELD (input_location, dtype, dummy, "gc_descr", ptr_type_node); + for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n) + { + tree tmp_field = build_decl (input_location, + FIELD_DECL, NULL_TREE, ptr_type_node); + TREE_CHAIN (dummy) = tmp_field; + DECL_CONTEXT (tmp_field) = dtype; + DECL_ARTIFICIAL (tmp_field) = 1; + dummy = tmp_field; + } + + n = TREE_VEC_LENGTH (get_dispatch_vector (type)); + if (TARGET_VTABLE_USES_DESCRIPTORS) + n *= TARGET_VTABLE_USES_DESCRIPTORS; + + PUSH_FIELD (input_location, dtype, dummy, "methods", + build_prim_array_type (nativecode_ptr_type_node, n)); + layout_type (dtype); + } + else + dtype = dtable_type; + + decl = build_decl (input_location, + VAR_DECL, get_identifier ("vt$"), dtype); + DECL_CONTEXT (decl) = type; + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + DECL_VTABLE_P (decl) = 1; + + return decl; +} + +/* Pre-pend the TYPE_FIELDS of THIS_CLASS with a dummy FIELD_DECL for the + fields inherited from SUPER_CLASS. */ + +void +push_super_field (tree this_class, tree super_class) +{ + tree base_decl; + /* Don't insert the field if we're just re-laying the class out. */ + if (TYPE_FIELDS (this_class) && !DECL_NAME (TYPE_FIELDS (this_class))) + return; + base_decl = build_decl (input_location, + FIELD_DECL, NULL_TREE, super_class); + DECL_IGNORED_P (base_decl) = 1; + DECL_CHAIN (base_decl) = TYPE_FIELDS (this_class); + TYPE_FIELDS (this_class) = base_decl; + DECL_SIZE (base_decl) = TYPE_SIZE (super_class); + DECL_SIZE_UNIT (base_decl) = TYPE_SIZE_UNIT (super_class); +} + +/* Handle the different manners we may have to lay out a super class. */ + +static tree +maybe_layout_super_class (tree super_class, tree this_class ATTRIBUTE_UNUSED) +{ + if (!super_class) + return NULL_TREE; + else if (TREE_CODE (super_class) == RECORD_TYPE) + { + if (!CLASS_LOADED_P (super_class)) + load_class (super_class, 1); + } + /* We might have to layout the class before its dependency on + the super class gets resolved by java_complete_class */ + else if (TREE_CODE (super_class) == POINTER_TYPE) + { + if (TREE_TYPE (super_class) != NULL_TREE) + super_class = TREE_TYPE (super_class); + else + gcc_unreachable (); + } + if (!TYPE_SIZE (super_class)) + safe_layout_class (super_class); + + return super_class; +} + +/* safe_layout_class just makes sure that we can load a class without + disrupting the current_class, input_file, input_line, etc, information + about the class processed currently. */ + +void +safe_layout_class (tree klass) +{ + tree save_current_class = current_class; + location_t save_location = input_location; + + layout_class (klass); + + current_class = save_current_class; + input_location = save_location; +} + +void +layout_class (tree this_class) +{ + int i; + tree super_class = CLASSTYPE_SUPER (this_class); + + class_list = tree_cons (this_class, NULL_TREE, class_list); + if (CLASS_BEING_LAIDOUT (this_class)) + { + char buffer [1024]; + char *report; + tree current; + + sprintf (buffer, " with '%s'", + IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (this_class)))); + obstack_grow (&temporary_obstack, buffer, strlen (buffer)); + + for (current = TREE_CHAIN (class_list); current; + current = TREE_CHAIN (current)) + { + tree decl = TYPE_NAME (TREE_PURPOSE (current)); + sprintf (buffer, "\n which inherits from '%s' (%s:%d)", + IDENTIFIER_POINTER (DECL_NAME (decl)), + DECL_SOURCE_FILE (decl), + DECL_SOURCE_LINE (decl)); + obstack_grow (&temporary_obstack, buffer, strlen (buffer)); + } + obstack_1grow (&temporary_obstack, '\0'); + report = XOBFINISH (&temporary_obstack, char *); + cyclic_inheritance_report = ggc_strdup (report); + obstack_free (&temporary_obstack, report); + TYPE_SIZE (this_class) = error_mark_node; + return; + } + CLASS_BEING_LAIDOUT (this_class) = 1; + + if (super_class && !CLASS_BEING_LAIDOUT (super_class)) + { + tree maybe_super_class + = maybe_layout_super_class (super_class, this_class); + if (maybe_super_class == NULL + || TREE_CODE (TYPE_SIZE (maybe_super_class)) == ERROR_MARK) + { + TYPE_SIZE (this_class) = error_mark_node; + CLASS_BEING_LAIDOUT (this_class) = 0; + class_list = TREE_CHAIN (class_list); + return; + } + if (TYPE_SIZE (this_class) == NULL_TREE) + push_super_field (this_class, maybe_super_class); + } + + layout_type (this_class); + + /* Also recursively load/layout any superinterfaces. */ + if (TYPE_BINFO (this_class)) + { + for (i = BINFO_N_BASE_BINFOS (TYPE_BINFO (this_class)) - 1; i > 0; i--) + { + tree binfo = BINFO_BASE_BINFO (TYPE_BINFO (this_class), i); + tree super_interface = BINFO_TYPE (binfo); + tree maybe_super_interface + = maybe_layout_super_class (super_interface, NULL_TREE); + if (maybe_super_interface == NULL + || TREE_CODE (TYPE_SIZE (maybe_super_interface)) == ERROR_MARK) + { + TYPE_SIZE (this_class) = error_mark_node; + CLASS_BEING_LAIDOUT (this_class) = 0; + class_list = TREE_CHAIN (class_list); + return; + } + } + } + + /* Convert the size back to an SI integer value. */ + TYPE_SIZE_UNIT (this_class) = + fold (convert (int_type_node, TYPE_SIZE_UNIT (this_class))); + + CLASS_BEING_LAIDOUT (this_class) = 0; + class_list = TREE_CHAIN (class_list); +} + +static void +add_miranda_methods (tree base_class, tree search_class) +{ + int i; + tree binfo, base_binfo; + + if (!CLASS_PARSED_P (search_class)) + load_class (search_class, 1); + + for (binfo = TYPE_BINFO (search_class), i = 1; + BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + { + tree method_decl; + tree elt = BINFO_TYPE (base_binfo); + + /* FIXME: This is totally bogus. We should not be handling + Miranda methods at all if we're using the BC ABI. */ + if (TYPE_DUMMY (elt)) + continue; + + /* Ensure that interface methods are seen in declared order. */ + if (!CLASS_LOADED_P (elt)) + load_class (elt, 1); + layout_class_methods (elt); + + /* All base classes will have been laid out at this point, so the order + will be correct. This code must match similar layout code in the + runtime. */ + for (method_decl = TYPE_METHODS (elt); + method_decl; method_decl = DECL_CHAIN (method_decl)) + { + tree sig, override; + + /* An interface can have <clinit>. */ + if (ID_CLINIT_P (DECL_NAME (method_decl))) + continue; + + sig = build_java_argument_signature (TREE_TYPE (method_decl)); + override = lookup_argument_method (base_class, + DECL_NAME (method_decl), sig); + if (override == NULL_TREE) + { + /* Found a Miranda method. Add it. */ + tree new_method; + sig = build_java_signature (TREE_TYPE (method_decl)); + new_method + = add_method (base_class, + get_access_flags_from_decl (method_decl), + DECL_NAME (method_decl), sig); + METHOD_INVISIBLE (new_method) = 1; + } + } + + /* Try superinterfaces. */ + add_miranda_methods (base_class, elt); + } +} + +void +layout_class_methods (tree this_class) +{ + tree method_decl, dtable_count; + tree super_class, type_name; + + if (TYPE_NVIRTUALS (this_class)) + return; + + super_class = CLASSTYPE_SUPER (this_class); + + if (super_class) + { + super_class = maybe_layout_super_class (super_class, this_class); + if (!TYPE_NVIRTUALS (super_class)) + layout_class_methods (super_class); + dtable_count = TYPE_NVIRTUALS (super_class); + } + else + dtable_count = integer_zero_node; + + type_name = TYPE_NAME (this_class); + if (!flag_indirect_dispatch + && (CLASS_ABSTRACT (type_name) || CLASS_INTERFACE (type_name))) + { + /* An abstract class can have methods which are declared only in + an implemented interface. These are called "Miranda + methods". We make a dummy method entry for such methods + here. */ + add_miranda_methods (this_class, this_class); + } + + TYPE_METHODS (this_class) = nreverse (TYPE_METHODS (this_class)); + + for (method_decl = TYPE_METHODS (this_class); + method_decl; method_decl = DECL_CHAIN (method_decl)) + dtable_count = layout_class_method (this_class, super_class, + method_decl, dtable_count); + + TYPE_NVIRTUALS (this_class) = dtable_count; +} + +/* Return the index of METHOD in INTERFACE. This index begins at 1 + and is used as an argument for _Jv_LookupInterfaceMethodIdx(). */ +int +get_interface_method_index (tree method, tree interface) +{ + tree meth; + int i = 1; + + for (meth = TYPE_METHODS (interface); ; meth = DECL_CHAIN (meth)) + { + if (meth == method) + return i; + /* We don't want to put <clinit> into the interface table. */ + if (! ID_CLINIT_P (DECL_NAME (meth))) + ++i; + gcc_assert (meth != NULL_TREE); + } +} + +/* Lay METHOD_DECL out, returning a possibly new value of + DTABLE_COUNT. Also mangle the method's name. */ + +tree +layout_class_method (tree this_class, tree super_class, + tree method_decl, tree dtable_count) +{ + tree method_name = DECL_NAME (method_decl); + + TREE_PUBLIC (method_decl) = 1; + + if (flag_indirect_classes + || (METHOD_PRIVATE (method_decl) && METHOD_STATIC (method_decl) + && ! METHOD_NATIVE (method_decl) + && ! special_method_p (method_decl))) + java_hide_decl (method_decl); + + /* Considered external unless it is being compiled into this object + file, or it was already flagged as external. */ + if (!DECL_EXTERNAL (method_decl)) + DECL_EXTERNAL (method_decl) = ((is_compiled_class (this_class) != 2) + || METHOD_NATIVE (method_decl)); + + if (ID_INIT_P (method_name)) + { + const char *p = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (this_class))); + const char *ptr; + for (ptr = p; *ptr; ) + { + if (*ptr++ == '.') + p = ptr; + } + DECL_CONSTRUCTOR_P (method_decl) = 1; + build_java_signature (TREE_TYPE (method_decl)); + } + else if (! METHOD_STATIC (method_decl)) + { + tree method_sig = + build_java_signature (TREE_TYPE (method_decl)); + bool method_override = false; + tree super_method = lookup_java_method (super_class, method_name, + method_sig); + if (super_method != NULL_TREE + && ! METHOD_DUMMY (super_method)) + { + method_override = true; + if (! METHOD_PUBLIC (super_method) && + ! METHOD_PROTECTED (super_method)) + { + /* Don't override private method, or default-access method in + another package. */ + if (METHOD_PRIVATE (super_method) || + ! in_same_package (TYPE_NAME (this_class), + TYPE_NAME (super_class))) + method_override = false; + } + } + if (method_override) + { + tree method_index = get_method_index (super_method); + set_method_index (method_decl, method_index); + if (method_index == NULL_TREE + && ! flag_indirect_dispatch + && ! DECL_ARTIFICIAL (super_method)) + error ("non-static method %q+D overrides static method", + method_decl); + } + else if (this_class == object_type_node + && (METHOD_FINAL (method_decl) + || METHOD_PRIVATE (method_decl))) + { + /* We don't generate vtable entries for final Object + methods. This is simply to save space, since every + object would otherwise have to define them. */ + } + else if (! METHOD_PRIVATE (method_decl) + && dtable_count) + { + /* We generate vtable entries for final methods because they + may one day be changed to non-final. */ + set_method_index (method_decl, dtable_count); + dtable_count = fold_build2 (PLUS_EXPR, integer_type_node, + dtable_count, integer_one_node); + } + } + + return dtable_count; +} + +static void +register_class (void) +{ + tree node; + + if (!registered_class) + registered_class = VEC_alloc (tree, gc, 8); + + if (flag_indirect_classes) + node = current_class; + else + node = TREE_OPERAND (build_class_ref (current_class), 0); + VEC_safe_push (tree, gc, registered_class, node); +} + +/* Emit a function that calls _Jv_RegisterNewClasses with a list of + all the classes we have emitted. */ + +static void +emit_indirect_register_classes (tree *list_p) +{ + tree klass, t, register_class_fn; + int i; + + int size = VEC_length (tree, registered_class) * 2 + 1; + VEC(constructor_elt,gc) *init = VEC_alloc (constructor_elt, gc, size); + tree class_array_type + = build_prim_array_type (ptr_type_node, size); + tree cdecl = build_decl (input_location, + VAR_DECL, get_identifier ("_Jv_CLS"), + class_array_type); + tree reg_class_list; + FOR_EACH_VEC_ELT (tree, registered_class, i, klass) + { + t = fold_convert (ptr_type_node, build_static_class_ref (klass)); + CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, t); + t = fold_convert (ptr_type_node, + build_address_of (build_classdollar_field (klass))); + CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, t); + } + CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, integer_zero_node); + DECL_INITIAL (cdecl) = build_constructor (class_array_type, init); + TREE_CONSTANT (DECL_INITIAL (cdecl)) = 1; + TREE_STATIC (cdecl) = 1; + DECL_ARTIFICIAL (cdecl) = 1; + DECL_IGNORED_P (cdecl) = 1; + TREE_READONLY (cdecl) = 1; + TREE_CONSTANT (cdecl) = 1; + rest_of_decl_compilation (cdecl, 1, 0); + reg_class_list = fold_convert (ptr_type_node, build_address_of (cdecl)); + + t = build_function_type_list (void_type_node, + build_pointer_type (ptr_type_node), NULL); + t = build_decl (input_location, + FUNCTION_DECL, + get_identifier ("_Jv_RegisterNewClasses"), t); + TREE_PUBLIC (t) = 1; + DECL_EXTERNAL (t) = 1; + register_class_fn = t; + t = build_call_expr (register_class_fn, 1, reg_class_list); + append_to_statement_list (t, list_p); +} + + +/* Emit something to register classes at start-up time. + + The preferred mechanism is through the .jcr section, which contain + a list of pointers to classes which get registered during constructor + invocation time. + + The fallback mechanism is to add statements to *LIST_P to call + _Jv_RegisterClass for each class in this file. These statements will + be added to a static constructor function for this translation unit. */ + +void +emit_register_classes (tree *list_p) +{ + if (registered_class == NULL) + return; + + if (flag_indirect_classes) + { + emit_indirect_register_classes (list_p); + return; + } + + /* TARGET_USE_JCR_SECTION defaults to 1 if SUPPORTS_WEAK and + TARGET_ASM_NAMED_SECTION, else 0. Some targets meet those conditions + but lack suitable crtbegin/end objects or linker support. These + targets can override the default in tm.h to use the fallback mechanism. */ + if (TARGET_USE_JCR_SECTION) + { + tree klass, t; + int i; + +#ifdef JCR_SECTION_NAME + switch_to_section (get_section (JCR_SECTION_NAME, SECTION_WRITE, NULL)); +#else + /* A target has defined TARGET_USE_JCR_SECTION, + but doesn't have a JCR_SECTION_NAME. */ + gcc_unreachable (); +#endif + assemble_align (POINTER_SIZE); + + FOR_EACH_VEC_ELT (tree, registered_class, i, klass) + { + t = build_fold_addr_expr (klass); + output_constant (t, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE); + } + } + else + { + tree klass, t, register_class_fn; + int i; + + t = build_function_type_list (void_type_node, class_ptr_type, NULL); + t = build_decl (input_location, + FUNCTION_DECL, get_identifier ("_Jv_RegisterClass"), t); + TREE_PUBLIC (t) = 1; + DECL_EXTERNAL (t) = 1; + register_class_fn = t; + + FOR_EACH_VEC_ELT (tree, registered_class, i, klass) + { + t = build_fold_addr_expr (klass); + t = build_call_expr (register_class_fn, 1, t); + append_to_statement_list (t, list_p); + } + } +} + +/* Build a constructor for an entry in the symbol table. */ + +static tree +build_symbol_table_entry (tree clname, tree name, tree signature) +{ + tree symbol; + VEC(constructor_elt,gc) *v = NULL; + + START_RECORD_CONSTRUCTOR (v, symbol_type); + PUSH_FIELD_VALUE (v, "clname", clname); + PUSH_FIELD_VALUE (v, "name", name); + PUSH_FIELD_VALUE (v, "signature", signature); + FINISH_RECORD_CONSTRUCTOR (symbol, v, symbol_type); + TREE_CONSTANT (symbol) = 1; + + return symbol; +} + +/* Make a symbol_type (_Jv_MethodSymbol) node for DECL. */ + +static tree +build_symbol_entry (tree decl, tree special) +{ + tree clname, name, signature; + clname = build_utf8_ref (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))); + /* ??? Constructors are given the name foo.foo all the way through + the compiler, but in the method table they're all renamed + foo.<init>. So, we have to do the same here unless we want an + unresolved reference at runtime. */ + name = build_utf8_ref ((TREE_CODE (decl) == FUNCTION_DECL + && DECL_CONSTRUCTOR_P (decl)) + ? init_identifier_node + : DECL_NAME (decl)); + signature = build_java_signature (TREE_TYPE (decl)); + signature = build_utf8_ref (unmangle_classname + (IDENTIFIER_POINTER (signature), + IDENTIFIER_LENGTH (signature))); + /* SPECIAL is either NULL_TREE or integer_one_node. We emit + signature addr+1 if SPECIAL, and this indicates to the runtime + system that this is a "special" symbol, i.e. one that should + bypass access controls. */ + if (special != NULL_TREE) + signature = build2 (POINTER_PLUS_EXPR, TREE_TYPE (signature), signature, + fold_convert (sizetype, special)); + + return build_symbol_table_entry (clname, name, signature); +} + +/* Emit a symbol table: used by -findirect-dispatch. */ + +tree +emit_symbol_table (tree name, tree the_table, + VEC(method_entry,gc) *decl_table, + tree the_syms_decl, tree the_array_element_type, + int element_size) +{ + tree table, null_symbol, table_size, the_array_type; + unsigned index; + method_entry *e; + VEC(constructor_elt,gc) *v = NULL; + + /* Only emit a table if this translation unit actually made any + references via it. */ + if (decl_table == NULL) + return the_table; + + /* Build a list of _Jv_MethodSymbols for each entry in otable_methods. */ + FOR_EACH_VEC_ELT (method_entry, decl_table, index, e) + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, + build_symbol_entry (e->method, e->special)); + + /* Terminate the list with a "null" entry. */ + null_symbol = build_symbol_table_entry (null_pointer_node, + null_pointer_node, + null_pointer_node); + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, null_symbol); + + table = build_constructor (symbols_array_type, v); + + /* Make it the initial value for otable_syms and emit the decl. */ + DECL_INITIAL (the_syms_decl) = table; + DECL_ARTIFICIAL (the_syms_decl) = 1; + DECL_IGNORED_P (the_syms_decl) = 1; + rest_of_decl_compilation (the_syms_decl, 1, 0); + + /* Now that its size is known, redefine the table as an + uninitialized static array of INDEX + 1 elements. The extra entry + is used by the runtime to track whether the table has been + initialized. */ + table_size + = build_index_type (build_int_cst (NULL_TREE, index * element_size + 1)); + the_array_type = build_array_type (the_array_element_type, table_size); + the_table = build_decl (input_location, + VAR_DECL, name, the_array_type); + TREE_STATIC (the_table) = 1; + TREE_READONLY (the_table) = 1; + rest_of_decl_compilation (the_table, 1, 0); + + return the_table; +} + +/* Make an entry for the catch_classes list. */ +tree +make_catch_class_record (tree catch_class, tree classname) +{ + tree entry; + tree type = TREE_TYPE (TREE_TYPE (TYPE_CTABLE_DECL (output_class))); + VEC(constructor_elt,gc) *v = NULL; + START_RECORD_CONSTRUCTOR (v, type); + PUSH_FIELD_VALUE (v, "address", catch_class); + PUSH_FIELD_VALUE (v, "classname", classname); + FINISH_RECORD_CONSTRUCTOR (entry, v, type); + return entry; +} + + +/* Generate the list of Throwable classes that are caught by exception + handlers in this class. */ +tree +emit_catch_table (tree this_class) +{ + tree table, table_size, array_type; + int n_catch_classes; + constructor_elt *e; + /* Fill in the dummy entry that make_class created. */ + e = VEC_index (constructor_elt, TYPE_CATCH_CLASSES (this_class), 0); + e->value = make_catch_class_record (null_pointer_node, null_pointer_node); + CONSTRUCTOR_APPEND_ELT (TYPE_CATCH_CLASSES (this_class), NULL_TREE, + make_catch_class_record (null_pointer_node, + null_pointer_node)); + n_catch_classes = VEC_length (constructor_elt, + TYPE_CATCH_CLASSES (this_class)); + table_size = build_index_type (build_int_cst (NULL_TREE, n_catch_classes)); + array_type + = build_array_type (TREE_TYPE (TREE_TYPE (TYPE_CTABLE_DECL (this_class))), + table_size); + table = + build_decl (input_location, + VAR_DECL, DECL_NAME (TYPE_CTABLE_DECL (this_class)), array_type); + DECL_INITIAL (table) = + build_constructor (array_type, TYPE_CATCH_CLASSES (this_class)); + TREE_STATIC (table) = 1; + TREE_READONLY (table) = 1; + DECL_IGNORED_P (table) = 1; + rest_of_decl_compilation (table, 1, 0); + return table; +} + +/* Given a type, return the signature used by + _Jv_FindClassFromSignature() in libgcj. This isn't exactly the + same as build_java_signature() because we want the canonical array + type. */ + +static tree +build_signature_for_libgcj (tree type) +{ + tree sig, ref; + + sig = build_java_signature (type); + ref = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (sig), + IDENTIFIER_LENGTH (sig))); + return ref; +} + +/* Build an entry in the type assertion table. */ + +static tree +build_assertion_table_entry (tree code, tree op1, tree op2) +{ + VEC(constructor_elt,gc) *v = NULL; + tree entry; + + START_RECORD_CONSTRUCTOR (v, assertion_entry_type); + PUSH_FIELD_VALUE (v, "assertion_code", code); + PUSH_FIELD_VALUE (v, "op1", op1); + PUSH_FIELD_VALUE (v, "op2", op2); + FINISH_RECORD_CONSTRUCTOR (entry, v, assertion_entry_type); + + return entry; +} + +/* Add an entry to the type assertion table. Callback used during hashtable + traversal. */ + +static int +add_assertion_table_entry (void **htab_entry, void *ptr) +{ + tree entry; + tree code_val, op1_utf8, op2_utf8; + VEC(constructor_elt,gc) **v = (VEC(constructor_elt,gc) **) ptr; + type_assertion *as = (type_assertion *) *htab_entry; + + code_val = build_int_cst (NULL_TREE, as->assertion_code); + + if (as->op1 == NULL_TREE) + op1_utf8 = null_pointer_node; + else + op1_utf8 = build_signature_for_libgcj (as->op1); + + if (as->op2 == NULL_TREE) + op2_utf8 = null_pointer_node; + else + op2_utf8 = build_signature_for_libgcj (as->op2); + + entry = build_assertion_table_entry (code_val, op1_utf8, op2_utf8); + + CONSTRUCTOR_APPEND_ELT (*v, NULL_TREE, entry); + return true; +} + +/* Generate the type assertion table for KLASS, and return its DECL. */ + +static tree +emit_assertion_table (tree klass) +{ + tree null_entry, ctor, table_decl; + htab_t assertions_htab = TYPE_ASSERTIONS (klass); + VEC(constructor_elt,gc) *v = NULL; + + /* Iterate through the hash table. */ + htab_traverse (assertions_htab, add_assertion_table_entry, &v); + + /* Finish with a null entry. */ + null_entry = build_assertion_table_entry (integer_zero_node, + null_pointer_node, + null_pointer_node); + + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, null_entry); + + ctor = build_constructor (assertion_table_type, v); + + table_decl = build_decl (input_location, + VAR_DECL, mangled_classname ("_type_assert_", klass), + assertion_table_type); + + TREE_STATIC (table_decl) = 1; + TREE_READONLY (table_decl) = 1; + TREE_CONSTANT (table_decl) = 1; + DECL_IGNORED_P (table_decl) = 1; + + DECL_INITIAL (table_decl) = ctor; + DECL_ARTIFICIAL (table_decl) = 1; + rest_of_decl_compilation (table_decl, 1, 0); + + return table_decl; +} + +void +init_class_processing (void) +{ + fields_ident = get_identifier ("fields"); + info_ident = get_identifier ("info"); + + gcc_obstack_init (&temporary_obstack); +} + +static hashval_t java_treetreehash_hash (const void *); +static int java_treetreehash_compare (const void *, const void *); + +/* A hash table mapping trees to trees. Used generally. */ + +#define JAVA_TREEHASHHASH_H(t) ((hashval_t)TYPE_UID (t)) + +static hashval_t +java_treetreehash_hash (const void *k_p) +{ + const struct treetreehash_entry *const k + = (const struct treetreehash_entry *) k_p; + return JAVA_TREEHASHHASH_H (k->key); +} + +static int +java_treetreehash_compare (const void * k1_p, const void * k2_p) +{ + const struct treetreehash_entry *const k1 + = (const struct treetreehash_entry *) k1_p; + const_tree const k2 = (const_tree) k2_p; + return (k1->key == k2); +} + +tree +java_treetreehash_find (htab_t ht, tree t) +{ + struct treetreehash_entry *e; + hashval_t hv = JAVA_TREEHASHHASH_H (t); + e = (struct treetreehash_entry *) htab_find_with_hash (ht, t, hv); + if (e == NULL) + return NULL; + else + return e->value; +} + +tree * +java_treetreehash_new (htab_t ht, tree t) +{ + void **e; + struct treetreehash_entry *tthe; + hashval_t hv = JAVA_TREEHASHHASH_H (t); + + e = htab_find_slot_with_hash (ht, t, hv, INSERT); + if (*e == NULL) + { + tthe = ggc_alloc_cleared_treetreehash_entry (); + tthe->key = t; + *e = tthe; + } + else + tthe = (struct treetreehash_entry *) *e; + return &tthe->value; +} + +htab_t +java_treetreehash_create (size_t size) +{ + return htab_create_ggc (size, java_treetreehash_hash, + java_treetreehash_compare, NULL); +} + +/* Break down qualified IDENTIFIER into package and class-name components. + For example, given SOURCE "pkg.foo.Bar", LEFT will be set to + "pkg.foo", and RIGHT to "Bar". */ + +int +split_qualified_name (tree *left, tree *right, tree source) +{ + char *p, *base; + int l = IDENTIFIER_LENGTH (source); + + base = (char *) alloca (l + 1); + memcpy (base, IDENTIFIER_POINTER (source), l + 1); + + /* Breakdown NAME into REMAINDER . IDENTIFIER. */ + p = base + l - 1; + while (*p != '.' && p != base) + p--; + + /* We didn't find a '.'. Return an error. */ + if (p == base) + return 1; + + *p = '\0'; + if (right) + *right = get_identifier (p+1); + *left = get_identifier (base); + + return 0; +} + +/* Given two classes (TYPE_DECL) or class names (IDENTIFIER), return TRUE + if the classes are from the same package. */ + +int +in_same_package (tree name1, tree name2) +{ + tree tmp; + tree pkg1; + tree pkg2; + + if (TREE_CODE (name1) == TYPE_DECL) + name1 = DECL_NAME (name1); + if (TREE_CODE (name2) == TYPE_DECL) + name2 = DECL_NAME (name2); + + if (QUALIFIED_P (name1) != QUALIFIED_P (name2)) + /* One in empty package. */ + return 0; + + if (QUALIFIED_P (name1) == 0 && QUALIFIED_P (name2) == 0) + /* Both in empty package. */ + return 1; + + split_qualified_name (&pkg1, &tmp, name1); + split_qualified_name (&pkg2, &tmp, name2); + + return (pkg1 == pkg2); +} + +/* lang_hooks.decls.final_write_globals: perform final processing on + global variables. */ + +void +java_write_globals (void) +{ + tree *vec = VEC_address (tree, pending_static_fields); + int len = VEC_length (tree, pending_static_fields); + write_global_declarations (); + emit_debug_global_declarations (vec, len); + VEC_free (tree, gc, pending_static_fields); +} + +#include "gt-java-class.h" diff --git a/gcc/java/config-lang.in b/gcc/java/config-lang.in new file mode 100644 index 000000000..29ee3fd85 --- /dev/null +++ b/gcc/java/config-lang.in @@ -0,0 +1,40 @@ +# Top level configure fragment for the GNU compiler for the Java(TM) +# language. +# Copyright (C) 1994, 1995, 2000, 2001, 2003, 2007 Free Software Foundation, Inc. + +#This file is part of GCC. + +#GCC is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 3, or (at your option) +#any later version. + +#GCC is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. + +#You should have received a copy of the GNU General Public License +#along with GCC; see the file COPYING3. If not see +#<http://www.gnu.org/licenses/>. + +#Java and all Java-based marks are trademarks or registered trademarks +#of Sun Microsystems, Inc. in the United States and other countries. +#The Free Software Foundation is independent of Sun Microsystems, Inc. + +# Configure looks for the existence of this file to auto-config each language. +# We define several parameters used by configure: +# +# language - name of language as it would appear in $(LANGUAGES) +# compilers - value to add to $(COMPILERS) + +language="java" + +compilers="jc1\$(exeext) jvgenmain\$(exeext)" + +gtfiles="\$(srcdir)/java/java-tree.h \$(srcdir)/java/jcf.h \$(srcdir)/java/parse.h \$(srcdir)/java/builtins.c \$(srcdir)/java/class.c \$(srcdir)/java/constants.c \$(srcdir)/java/decl.c \$(srcdir)/java/expr.c \$(srcdir)/java/jcf-parse.c \$(srcdir)/java/lang.c \$(srcdir)/java/mangle.c \$(srcdir)/java/resource.c" + +target_libs=${libgcj_saved} +lang_dirs="fastjar" +#build_by_default=no +lang_requires=c++ diff --git a/gcc/java/constants.c b/gcc/java/constants.c new file mode 100644 index 000000000..4425338f6 --- /dev/null +++ b/gcc/java/constants.c @@ -0,0 +1,620 @@ +/* Handle the constant pool of the Java(TM) Virtual Machine. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, + 2007, 2008, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "jcf.h" +#include "tree.h" +#include "java-tree.h" +#include "diagnostic-core.h" +#include "toplev.h" +#include "ggc.h" + +static void set_constant_entry (CPool *, int, int, jword); +static int find_tree_constant (CPool *, int, tree); +static int find_name_and_type_constant (CPool *, tree, tree); +static tree get_tag_node (int); + +/* Set the INDEX'th constant in CPOOL to have the given TAG and VALUE. */ + +static void +set_constant_entry (CPool *cpool, int index, int tag, jword value) +{ + if (cpool->data == NULL) + { + cpool->capacity = 100; + cpool->tags = (uint8 *) ggc_alloc_cleared_atomic (sizeof (uint8) + * cpool->capacity); + cpool->data = ggc_alloc_cleared_vec_cpool_entry (sizeof + (union cpool_entry), + cpool->capacity); + cpool->count = 1; + } + if (index >= cpool->capacity) + { + int old_cap = cpool->capacity; + cpool->capacity *= 2; + if (index >= cpool->capacity) + cpool->capacity = index + 10; + cpool->tags = GGC_RESIZEVEC (uint8, cpool->tags, cpool->capacity); + cpool->data = GGC_RESIZEVEC (union cpool_entry, cpool->data, + cpool->capacity); + + /* Make sure GC never sees uninitialized tag values. */ + memset (cpool->tags + old_cap, 0, cpool->capacity - old_cap); + memset (cpool->data + old_cap, 0, + (cpool->capacity - old_cap) * sizeof (union cpool_entry)); + } + if (index >= cpool->count) + cpool->count = index + 1; + cpool->tags[index] = tag; + cpool->data[index].w = value; +} + +/* Find (or create) a constant pool entry matching TAG and VALUE. */ + +int +find_constant1 (CPool *cpool, int tag, jword value) +{ + int i; + for (i = cpool->count; --i > 0; ) + { + if (cpool->tags[i] == tag && cpool->data[i].w == value) + return i; + } + i = cpool->count == 0 ? 1 : cpool->count; + set_constant_entry (cpool, i, tag, value); + return i; +} + +/* Find a double-word constant pool entry matching TAG and WORD1/WORD2. */ + +int +find_constant2 (CPool *cpool, int tag, jword word1, jword word2) +{ + int i; + for (i = cpool->count - 1; --i > 0; ) + { + if (cpool->tags[i] == tag + && cpool->data[i].w == word1 + && cpool->data[i+1].w == word2) + return i; + } + i = cpool->count == 0 ? 1 : cpool->count; + set_constant_entry (cpool, i, tag, word1); + set_constant_entry (cpool, i+1, 0, word2); + return i; +} + +static int +find_tree_constant (CPool *cpool, int tag, tree value) +{ + int i; + for (i = cpool->count; --i > 0; ) + { + if (cpool->tags[i] == tag && cpool->data[i].t == value) + return i; + } + i = cpool->count == 0 ? 1 : cpool->count; + set_constant_entry (cpool, i, tag, 0); + cpool->data[i].t = value; + return i; +} + + +int +find_utf8_constant (CPool *cpool, tree name) +{ + if (name == NULL_TREE) + return 0; + return find_tree_constant (cpool, CONSTANT_Utf8, name); +} + +int +find_class_or_string_constant (CPool *cpool, int tag, tree name) +{ + jword j = find_utf8_constant (cpool, name); + int i; + for (i = cpool->count; --i > 0; ) + { + if (cpool->tags[i] == tag && cpool->data[i].w == j) + return i; + } + i = cpool->count; + set_constant_entry (cpool, i, tag, j); + return i; +} + +int +find_class_constant (CPool *cpool, tree type) +{ + return find_class_or_string_constant (cpool, CONSTANT_Class, + build_internal_class_name (type)); +} + +/* Allocate a CONSTANT_string entry given a STRING_CST. */ + +int +find_string_constant (CPool *cpool, tree string) +{ + string = get_identifier (TREE_STRING_POINTER (string)); + return find_class_or_string_constant (cpool, CONSTANT_String, string); + +} + +/* Find (or create) a CONSTANT_NameAndType matching NAME and TYPE. + Return its index in the constant pool CPOOL. */ + +static int +find_name_and_type_constant (CPool *cpool, tree name, tree type) +{ + int name_index = find_utf8_constant (cpool, name); + int type_index = find_utf8_constant (cpool, build_java_signature (type)); + return find_constant1 (cpool, CONSTANT_NameAndType, + (name_index << 16) | type_index); +} + +/* Find (or create) a CONSTANT_Fieldref for DECL (a FIELD_DECL or VAR_DECL). + Return its index in the constant pool CPOOL. */ + +int +find_fieldref_index (CPool *cpool, tree decl) +{ + int class_index = find_class_constant (cpool, DECL_CONTEXT (decl)); + int name_type_index + = find_name_and_type_constant (cpool, DECL_NAME (decl), TREE_TYPE (decl)); + return find_constant1 (cpool, CONSTANT_Fieldref, + (class_index << 16) | name_type_index); +} + +/* Find (or create) a CONSTANT_Methodref for DECL (a FUNCTION_DECL). + Return its index in the constant pool CPOOL. */ + +int +find_methodref_index (CPool *cpool, tree decl) +{ + return find_methodref_with_class_index (cpool, decl, DECL_CONTEXT (decl)); +} + +int +find_methodref_with_class_index (CPool *cpool, tree decl, tree mclass) +{ + int class_index = find_class_constant (cpool, mclass); + tree name = DECL_CONSTRUCTOR_P (decl) ? init_identifier_node + : DECL_NAME (decl); + int name_type_index; + name_type_index = + find_name_and_type_constant (cpool, name, TREE_TYPE (decl)); + return find_constant1 (cpool, + CLASS_INTERFACE (TYPE_NAME (mclass)) + ? CONSTANT_InterfaceMethodref + : CONSTANT_Methodref, + (class_index << 16) | name_type_index); +} + +#define PUT1(X) (*ptr++ = (X)) +#define PUT2(X) (PUT1((X) >> 8), PUT1(X)) +#define PUT4(X) (PUT2((X) >> 16), PUT2(X)) +#define PUTN(P, N) (memcpy(ptr, (P), (N)), ptr += (N)) + +/* Give the number of bytes needed in a .class file for the CPOOL + constant pool. Includes the 2-byte constant_pool_count. */ + +int +count_constant_pool_bytes (CPool *cpool) +{ + int size = 2; + int i = 1; + for ( ; i < cpool->count; i++) + { + size++; + switch (cpool->tags[i]) + { + case CONSTANT_NameAndType: + case CONSTANT_Fieldref: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + case CONSTANT_Float: + case CONSTANT_Integer: + size += 4; + break; + case CONSTANT_Class: + case CONSTANT_String: + size += 2; + break; + case CONSTANT_Long: + case CONSTANT_Double: + size += 8; + i++; + break; + case CONSTANT_Utf8: + { + tree t = cpool->data[i].t; + int len = IDENTIFIER_LENGTH (t); + size += len + 2; + } + break; + default: + /* Second word of CONSTANT_Long and CONSTANT_Double. */ + size--; + } + } + return size; +} + +/* Write the constant pool CPOOL into BUFFER. + The length of BUFFER is LENGTH, which must match the needed length. */ + +void +write_constant_pool (CPool *cpool, unsigned char *buffer, int length) +{ + unsigned char *ptr = buffer; + int i = 1; + union cpool_entry *datap = &cpool->data[1]; + PUT2 (cpool->count); + for ( ; i < cpool->count; i++, datap++) + { + int tag = cpool->tags[i]; + PUT1 (tag); + switch (tag) + { + case CONSTANT_NameAndType: + case CONSTANT_Fieldref: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + case CONSTANT_Float: + case CONSTANT_Integer: + PUT4 (datap->w); + break; + case CONSTANT_Class: + case CONSTANT_String: + PUT2 (datap->w); + break; + break; + case CONSTANT_Long: + case CONSTANT_Double: + PUT4(datap->w); + i++; + datap++; + PUT4 (datap->w); + break; + case CONSTANT_Utf8: + { + tree t = datap->t; + int len = IDENTIFIER_LENGTH (t); + PUT2 (len); + PUTN (IDENTIFIER_POINTER (t), len); + } + break; + } + } + + gcc_assert (ptr == buffer + length); +} + +static GTY(()) tree tag_nodes[13]; +static tree +get_tag_node (int tag) +{ + /* A Cache for build_int_cst (CONSTANT_XXX, 0). */ + + if (tag >= 13) + return build_int_cst (NULL_TREE, tag); + + if (tag_nodes[tag] == NULL_TREE) + tag_nodes[tag] = build_int_cst (NULL_TREE, tag); + return tag_nodes[tag]; +} + +/* Given a class, return its constant pool, creating one if necessary. */ + +CPool * +cpool_for_class (tree klass) +{ + CPool *cpool = TYPE_CPOOL (klass); + + if (cpool == NULL) + { + cpool = ggc_alloc_cleared_CPool (); + TYPE_CPOOL (klass) = cpool; + } + return cpool; +} + +/* Look for a constant pool entry that matches TAG and NAME. + Creates a new entry if not found. + TAG is one of CONSTANT_Utf8, CONSTANT_String or CONSTANT_Class. + NAME is an IDENTIFIER_NODE naming the Utf8 constant, string, or class. + Returns the index of the entry. */ + +int +alloc_name_constant (int tag, tree name) +{ + CPool *outgoing_cpool = cpool_for_class (output_class); + return find_tree_constant (outgoing_cpool, tag, name); +} + +/* Create a constant pool entry for a name_and_type. This one has '.' + rather than '/' because it isn't going into a class file, it's + going into a compiled object. We don't use the '/' separator in + compiled objects. */ + +static int +find_name_and_type_constant_tree (CPool *cpool, tree name, tree type) +{ + int name_index = find_utf8_constant (cpool, name); + int type_index + = find_utf8_constant (cpool, + identifier_subst (build_java_signature (type), + "", '/', '.', "")); + return find_constant1 (cpool, CONSTANT_NameAndType, + (name_index << 16) | type_index); +} + +/* Look for a field ref that matches DECL in the constant pool of + KLASS. + Return the index of the entry. */ + +int +alloc_constant_fieldref (tree klass, tree decl) +{ + CPool *outgoing_cpool = cpool_for_class (klass); + int class_index + = find_tree_constant (outgoing_cpool, CONSTANT_Class, + DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))); + int name_type_index + = find_name_and_type_constant_tree (outgoing_cpool, DECL_NAME (decl), + TREE_TYPE (decl)); + return find_constant1 (outgoing_cpool, CONSTANT_Fieldref, + (class_index << 16) | name_type_index); +} + +/* Build an identifier for the internal name of reference type TYPE. */ + +tree +build_internal_class_name (tree type) +{ + tree name; + if (TYPE_ARRAY_P (type)) + name = build_java_signature (type); + else + { + name = TYPE_NAME (type); + if (TREE_CODE (name) != IDENTIFIER_NODE) + name = DECL_NAME (name); + name = identifier_subst (name, "", '.', '/', ""); + } + return name; +} + +/* Look for a CONSTANT_Class entry for CLAS, creating a new one if needed. */ + +int +alloc_class_constant (tree clas) +{ + tree class_name = build_internal_class_name (clas); + + return alloc_name_constant (CONSTANT_Class, + (unmangle_classname + (IDENTIFIER_POINTER(class_name), + IDENTIFIER_LENGTH(class_name)))); +} + +/* Return the decl of the data array of the current constant pool. */ + +tree +build_constant_data_ref (bool indirect) +{ + if (indirect) + { + tree d; + tree cpool_type = build_array_type (ptr_type_node, NULL_TREE); + tree decl = build_class_ref (output_class); + tree klass = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (decl)), + decl); + tree constants = build3 (COMPONENT_REF, + TREE_TYPE (constants_field_decl_node), klass, + constants_field_decl_node, + NULL_TREE); + tree data = build3 (COMPONENT_REF, + TREE_TYPE (constants_data_field_decl_node), + constants, + constants_data_field_decl_node, + NULL_TREE); + + TREE_THIS_NOTRAP (klass) = 1; + data = fold_convert (build_pointer_type (cpool_type), data); + d = build1 (INDIRECT_REF, cpool_type, data); + + return d; + } + else + { + tree decl_name = mangled_classname ("_CD_", output_class); + tree decl = IDENTIFIER_GLOBAL_VALUE (decl_name); + + if (! decl) + { + /* Build a type with unspecified bounds. The will make sure + that targets do the right thing with whatever size we end + up with at the end. Using bounds that are too small risks + assuming the data is in the small data section. */ + tree type = build_array_type (ptr_type_node, NULL_TREE); + + /* We need to lay out the type ourselves, since build_array_type + thinks the type is incomplete. */ + layout_type (type); + + decl = build_decl (input_location, VAR_DECL, decl_name, type); + TREE_STATIC (decl) = 1; + IDENTIFIER_GLOBAL_VALUE (decl_name) = decl; + } + + return decl; + } +} + +/* Get the pointer value at the INDEX'th element of the constant pool. */ + +tree +build_ref_from_constant_pool (int index) +{ + tree i; + tree d = TYPE_CPOOL_DATA_REF (output_class); + + if (d == NULL_TREE) + d = build_constant_data_ref (flag_indirect_classes); + + i = build_int_cst (NULL_TREE, index); + d = build4 (ARRAY_REF, TREE_TYPE (TREE_TYPE (d)), d, i, + NULL_TREE, NULL_TREE); + return d; +} + +/* Build an initializer for the constants field of the current constant pool. + Should only be called at top-level, since it may emit declarations. */ + +tree +build_constants_constructor (void) +{ + CPool *outgoing_cpool = cpool_for_class (current_class); + tree tags_value, data_value; + tree cons; + VEC(constructor_elt,gc) *v = NULL; + int i; + VEC(constructor_elt,gc) *tags = NULL; + VEC(constructor_elt,gc) *data = NULL; + constructor_elt *t = NULL; + constructor_elt *d = NULL; + + if (outgoing_cpool->count > 0) + { + int c = outgoing_cpool->count; + VEC_safe_grow_cleared (constructor_elt, gc, tags, c); + VEC_safe_grow_cleared (constructor_elt, gc, data, c); + t = VEC_index (constructor_elt, tags, c-1); + d = VEC_index (constructor_elt, data, c-1); + } + +#define CONSTRUCTOR_PREPEND_VALUE(E, V) E->value = V, E-- + for (i = outgoing_cpool->count; --i > 0; ) + switch (outgoing_cpool->tags[i] & ~CONSTANT_LazyFlag) + { + case CONSTANT_None: /* The second half of a Double or Long on a + 32-bit target. */ + case CONSTANT_Fieldref: + case CONSTANT_NameAndType: + case CONSTANT_Float: + case CONSTANT_Integer: + case CONSTANT_Double: + case CONSTANT_Long: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + { + unsigned HOST_WIDE_INT temp = outgoing_cpool->data[i].w; + + /* Make sure that on a big-endian machine with 64-bit + pointers this 32-bit jint appears in the first word. + FIXME: This is a kludge. The field we're initializing is + not a scalar but a union, and that's how we should + represent it in the compiler. We should fix this. */ + if (BYTES_BIG_ENDIAN) + temp <<= ((POINTER_SIZE > 32) ? POINTER_SIZE - 32 : 0); + + CONSTRUCTOR_PREPEND_VALUE (t, get_tag_node (outgoing_cpool->tags[i])); + CONSTRUCTOR_PREPEND_VALUE (d, + fold_convert (ptr_type_node, + (build_int_cst (NULL_TREE, + temp)))); + } + break; + + case CONSTANT_Class: + case CONSTANT_String: + case CONSTANT_Unicode: + case CONSTANT_Utf8: + CONSTRUCTOR_PREPEND_VALUE (t, get_tag_node (outgoing_cpool->tags[i])); + CONSTRUCTOR_PREPEND_VALUE (d, build_utf8_ref (outgoing_cpool->data[i].t)); + break; + + default: + gcc_assert (false); + } +#undef CONSTRUCTOR_PREPEND_VALUE + + if (outgoing_cpool->count > 0) + { + tree data_decl, tags_decl, tags_type; + tree max_index = build_int_cst (sizetype, outgoing_cpool->count - 1); + tree index_type = build_index_type (max_index); + tree tem; + + /* Add dummy 0'th element of constant pool. */ + gcc_assert (t == VEC_address (constructor_elt, tags)); + gcc_assert (d == VEC_address (constructor_elt, data)); + t->value = get_tag_node (0); + d->value = null_pointer_node; + + /* Change the type of the decl to have the proper array size. + ??? Make sure to transition the old type-pointer-to list to this + new type to not invalidate all build address expressions. */ + data_decl = build_constant_data_ref (false); + tem = TYPE_POINTER_TO (TREE_TYPE (data_decl)); + if (!tem) + tem = build_pointer_type (TREE_TYPE (data_decl)); + TYPE_POINTER_TO (TREE_TYPE (data_decl)) = NULL_TREE; + TREE_TYPE (data_decl) = build_array_type (ptr_type_node, index_type); + TYPE_POINTER_TO (TREE_TYPE (data_decl)) = tem; + DECL_INITIAL (data_decl) = build_constructor (TREE_TYPE (data_decl), data); + DECL_SIZE (data_decl) = TYPE_SIZE (TREE_TYPE (data_decl)); + DECL_SIZE_UNIT (data_decl) = TYPE_SIZE_UNIT (TREE_TYPE (data_decl)); + rest_of_decl_compilation (data_decl, 1, 0); + data_value = build_address_of (data_decl); + + tags_type = build_array_type (unsigned_byte_type_node, index_type); + tags_decl = build_decl (input_location, + VAR_DECL, mangled_classname ("_CT_", + current_class), + tags_type); + TREE_STATIC (tags_decl) = 1; + DECL_INITIAL (tags_decl) = build_constructor (tags_type, tags); + rest_of_decl_compilation (tags_decl, 1, 0); + tags_value = build_address_of (tags_decl); + } + else + { + data_value = null_pointer_node; + tags_value = null_pointer_node; + } + START_RECORD_CONSTRUCTOR (v, constants_type_node); + PUSH_FIELD_VALUE (v, "size", + build_int_cst (NULL_TREE, outgoing_cpool->count)); + PUSH_FIELD_VALUE (v, "tags", tags_value); + PUSH_FIELD_VALUE (v, "data", data_value); + FINISH_RECORD_CONSTRUCTOR (cons, v, constants_type_node); + return cons; +} + +#include "gt-java-constants.h" diff --git a/gcc/java/decl.c b/gcc/java/decl.c new file mode 100644 index 000000000..a17b82669 --- /dev/null +++ b/gcc/java/decl.c @@ -0,0 +1,2100 @@ +/* Process declarations and variables for the GNU compiler for the + Java(TM) language. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, + 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "diagnostic-core.h" +#include "toplev.h" +#include "flags.h" +#include "java-tree.h" +#include "jcf.h" +#include "libfuncs.h" +#include "java-except.h" +#include "ggc.h" +#include "cgraph.h" +#include "tree-inline.h" +#include "target.h" +#include "version.h" +#include "tree-iterator.h" +#include "langhooks.h" +#include "cgraph.h" + +#if defined (DEBUG_JAVA_BINDING_LEVELS) +extern void indent (void); +#endif + +static tree push_jvm_slot (int, tree); +static tree lookup_name_current_level (tree); +static tree push_promoted_type (const char *, tree); +static struct binding_level *make_binding_level (void); +static tree create_primitive_vtable (const char *); +static tree check_local_unnamed_variable (tree, tree, tree); +static void parse_version (void); + + +/* The following ABI flags are used in the high-order bits of the version + ID field. The version ID number itself should never be larger than + 0xfffff, so it should be safe to use top 12 bits for these flags. */ + +#define FLAG_BINARYCOMPAT_ABI (1<<31) /* Class is built with the BC-ABI. */ + +#define FLAG_BOOTSTRAP_LOADER (1<<30) /* Used when defining a class that + should be loaded by the bootstrap + loader. */ + +/* If an ABI change is made within a GCC release series, rendering current + binaries incompatible with the old runtimes, this number must be set to + enforce the compatibility rules. */ +#define MINOR_BINARYCOMPAT_ABI_VERSION 1 + +/* The runtime may recognize a variety of BC ABIs (objects generated by + different version of gcj), but will probably always require strict + matching for the ordinary (C++) ABI. */ + +/* The version ID of the BC ABI that we generate. This must be kept in + sync with parse_version(), libgcj, and reality (if the BC format changes, + this must change). */ +#define GCJ_CURRENT_BC_ABI_VERSION \ + (4 * 100000 + 0 * 1000 + MINOR_BINARYCOMPAT_ABI_VERSION) + +/* The ABI version number. */ +tree gcj_abi_version; + +/* Name of the Cloneable class. */ +tree java_lang_cloneable_identifier_node; + +/* Name of the Serializable class. */ +tree java_io_serializable_identifier_node; + +/* The DECL_MAP is a mapping from (index, type) to a decl node. + If index < max_locals, it is the index of a local variable. + if index >= max_locals, then index-max_locals is a stack slot. + The DECL_MAP mapping is represented as a TREE_VEC whose elements + are a list of decls (VAR_DECL or PARM_DECL) chained by + DECL_LOCAL_SLOT_CHAIN; the index finds the TREE_VEC element, and then + we search the chain for a decl with a matching TREE_TYPE. */ + +static GTY(()) tree decl_map; + +/* The base_decl_map is contains one variable of ptr_type: this is + used to contain every variable of reference type that is ever + stored in a local variable slot. */ + +static GTY(()) tree base_decl_map; + +/* An index used to make temporary identifiers unique. */ +static int uniq; + +/* A list of local variables VAR_DECLs for this method that we have seen + debug information, but we have not reached their starting (byte) PC yet. */ + +static GTY(()) tree pending_local_decls; + +/* The decl for "_Jv_ResolvePoolEntry". */ +tree soft_resolvepoolentry_node; + +/* The decl for the .constants field of an instance of Class. */ +tree constants_field_decl_node; + +/* The decl for the .data field of an instance of Class. */ +tree constants_data_field_decl_node; + +#if defined(DEBUG_JAVA_BINDING_LEVELS) +int binding_depth = 0; +int is_class_level = 0; +int current_pc; + +void +indent (void) +{ + int i; + + for (i = 0; i < binding_depth*2; i++) + putc (' ', stderr); +} +#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ + +/* True if decl is a named local variable, i.e. if it is an alias + that's used only for debugging purposes. */ + +static bool +debug_variable_p (tree decl) +{ + if (TREE_CODE (decl) == PARM_DECL) + return false; + + if (LOCAL_SLOT_P (decl)) + return false; + + return true; +} + +static tree +push_jvm_slot (int index, tree decl) +{ + DECL_CONTEXT (decl) = current_function_decl; + layout_decl (decl, 0); + + /* Now link the decl into the decl_map. */ + if (DECL_LANG_SPECIFIC (decl) == NULL) + { + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + DECL_LOCAL_START_PC (decl) = 0; + DECL_LOCAL_END_PC (decl) = DECL_CODE_LENGTH (current_function_decl); + DECL_LOCAL_SLOT_NUMBER (decl) = index; + } + DECL_LOCAL_SLOT_CHAIN (decl) = TREE_VEC_ELT (decl_map, index); + TREE_VEC_ELT (decl_map, index) = decl; + + return decl; +} + +/* Find the best declaration based upon type. If 'decl' fits 'type' better + than 'best', return 'decl'. Otherwise return 'best'. */ + +static tree +check_local_unnamed_variable (tree best, tree decl, tree type) +{ + tree decl_type = TREE_TYPE (decl); + + gcc_assert (! LOCAL_VAR_OUT_OF_SCOPE_P (decl)); + + /* Use the same decl for all integer types <= 32 bits. This is + necessary because sometimes a value is stored as (for example) + boolean but loaded as int. */ + if (decl_type == type + || (INTEGRAL_TYPE_P (decl_type) + && INTEGRAL_TYPE_P (type) + && TYPE_PRECISION (decl_type) <= 32 + && TYPE_PRECISION (type) <= 32 + && TYPE_PRECISION (decl_type) >= TYPE_PRECISION (type)) + /* ptr_type_node is used for null pointers, which are + assignment compatible with everything. */ + || (TREE_CODE (decl_type) == POINTER_TYPE + && type == ptr_type_node) + /* Whenever anyone wants to use a slot that is initially + occupied by a PARM_DECL of pointer type they must get that + decl, even if they asked for a pointer to a different type. + However, if someone wants a scalar variable in a slot that + initially held a pointer arg -- or vice versa -- we create a + new VAR_DECL. + + ???: As long as verification is correct, this will be a + compatible type. But maybe we should create a dummy variable + and replace all references to it with the DECL and a + NOP_EXPR. + */ + || (TREE_CODE (decl_type) == POINTER_TYPE + && TREE_CODE (decl) == PARM_DECL + && TREE_CODE (type) == POINTER_TYPE)) + { + if (best == NULL_TREE + || (decl_type == type && TREE_TYPE (best) != type)) + return decl; + } + + return best; +} + + +/* Find a VAR_DECL (or PARM_DECL) at local index INDEX that has type TYPE, + that is valid at PC (or -1 if any pc). + If there is no existing matching decl, allocate one. */ + +tree +find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED) +{ + tree tmp = TREE_VEC_ELT (decl_map, index); + tree decl = NULL_TREE; + + /* Scan through every declaration that has been created in this + slot. We're only looking for variables that correspond to local + index declarations and PARM_DECLs, not named variables: such + local variables are used only for debugging information. */ + while (tmp != NULL_TREE) + { + if (! debug_variable_p (tmp)) + decl = check_local_unnamed_variable (decl, tmp, type); + tmp = DECL_LOCAL_SLOT_CHAIN (tmp); + } + + /* gcj has a function called promote_type(), which is used by both + the bytecode compiler and the source compiler. Unfortunately, + the type systems for the Java VM and the Java language are not + the same: a boolean in the VM promotes to an int, not to a wide + boolean. If our caller wants something to hold a boolean, that + had better be an int, because that slot might be re-used + later in integer context. */ + if (TREE_CODE (type) == BOOLEAN_TYPE) + type = integer_type_node; + + /* If we don't find a match, create one with the type passed in. + The name of the variable is #n#m, which n is the variable index + in the local variable area and m is a dummy identifier for + uniqueness -- multiple variables may share the same local + variable index. We don't call pushdecl() to push pointer types + into a binding expr because they'll all be replaced by a single + variable that is used for every reference in that local variable + slot. */ + if (! decl) + { + char buf[64]; + tree name; + sprintf (buf, "#slot#%d#%d", index, uniq++); + name = get_identifier (buf); + decl = build_decl (input_location, VAR_DECL, name, type); + DECL_IGNORED_P (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + decl = push_jvm_slot (index, decl); + LOCAL_SLOT_P (decl) = 1; + + if (TREE_CODE (type) != POINTER_TYPE) + pushdecl_function_level (decl); + } + + /* As well as creating a local variable that matches the type, we + also create a base variable (of ptr_type) that will hold all its + aliases. */ + if (TREE_CODE (type) == POINTER_TYPE + && ! TREE_VEC_ELT (base_decl_map, index)) + { + char buf[64]; + tree name; + tree base_decl; + sprintf (buf, "#ref#%d#%d", index, uniq++); + name = get_identifier (buf); + base_decl + = TREE_VEC_ELT (base_decl_map, index) + = build_decl (input_location, VAR_DECL, name, ptr_type_node); + pushdecl_function_level (base_decl); + DECL_IGNORED_P (base_decl) = 1; + DECL_ARTIFICIAL (base_decl) = 1; + } + + return decl; +} + +/* Called during genericization for every variable. If the variable + is a temporary of pointer type, replace it with a common variable + thath is used to hold all pointer types that are ever stored in + that slot. Set WANT_LVALUE if you want a variable that is to be + written to. */ + +static tree +java_replace_reference (tree var_decl, bool want_lvalue) +{ + tree decl_type; + + if (! base_decl_map) + return var_decl; + + decl_type = TREE_TYPE (var_decl); + + if (TREE_CODE (decl_type) == POINTER_TYPE) + { + if (DECL_LANG_SPECIFIC (var_decl) + && LOCAL_SLOT_P (var_decl)) + { + int index = DECL_LOCAL_SLOT_NUMBER (var_decl); + tree base_decl = TREE_VEC_ELT (base_decl_map, index); + + gcc_assert (base_decl); + if (! want_lvalue) + base_decl = build1 (NOP_EXPR, decl_type, base_decl); + + return base_decl; + } + } + + return var_decl; +} + +/* Helper for java_genericize. */ + +tree +java_replace_references (tree *tp, int *walk_subtrees, + void *data ATTRIBUTE_UNUSED) +{ + if (TREE_CODE (*tp) == MODIFY_EXPR) + { + source_location loc = EXPR_LOCATION (*tp); + tree lhs = TREE_OPERAND (*tp, 0); + /* This is specific to the bytecode compiler. If a variable has + LOCAL_SLOT_P set, replace an assignment to it with an assignment + to the corresponding variable that holds all its aliases. */ + if (TREE_CODE (lhs) == VAR_DECL + && DECL_LANG_SPECIFIC (lhs) + && LOCAL_SLOT_P (lhs) + && TREE_CODE (TREE_TYPE (lhs)) == POINTER_TYPE) + { + tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true); + tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs), + TREE_OPERAND (*tp, 1)); + tree tem = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs), + new_lhs, new_rhs); + *tp = build1 (NOP_EXPR, TREE_TYPE (lhs), tem); + SET_EXPR_LOCATION (tem, loc); + SET_EXPR_LOCATION (new_rhs, loc); + SET_EXPR_LOCATION (*tp, loc); + } + } + if (TREE_CODE (*tp) == VAR_DECL) + { + *tp = java_replace_reference (*tp, /* want_lvalue */ false); + *walk_subtrees = 0; + } + + return NULL_TREE; +} + +/* Same as find_local_index, except that INDEX is a stack index. */ + +tree +find_stack_slot (int index, tree type) +{ + return find_local_variable (index + DECL_MAX_LOCALS (current_function_decl), + type, -1); +} + +struct GTY(()) + binding_level { + /* A chain of _DECL nodes for all variables, constants, functions, + * and typedef types. These are in the reverse of the order supplied. + */ + tree names; + + /* For each level, a list of shadowed outer-level local definitions + to be restored when this level is popped. + Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and + whose TREE_VALUE is its old definition (a kind of ..._DECL node). */ + tree shadowed; + + /* For each level (except not the global one), + a chain of BLOCK nodes for all the levels + that were entered and exited one level down. */ + tree blocks; + + /* The binding level which this one is contained in (inherits from). */ + struct binding_level *level_chain; + + /* The bytecode PC that marks the end of this level. */ + int end_pc; + /* The bytecode PC that marks the start of this level. */ + int start_pc; + + /* The statements in this binding level. */ + tree stmts; + + /* An exception range associated with this binding level. */ + struct eh_range * GTY((skip (""))) exception_range; + + /* Binding depth at which this level began. Used only for debugging. */ + unsigned binding_depth; + + /* The location at which this level began. */ + source_location loc; + }; + +#define NULL_BINDING_LEVEL (struct binding_level *) NULL + +/* The binding level currently in effect. */ + +static GTY(()) struct binding_level *current_binding_level; + +/* A chain of binding_level structures awaiting reuse. */ + +static GTY(()) struct binding_level *free_binding_level; + +/* The outermost binding level, for names of file scope. + This is created when the compiler is started and exists + through the entire run. */ + +static GTY(()) struct binding_level *global_binding_level; + +/* The binding level that holds variables declared at the outermost + level within a function body. */ + +static struct binding_level *function_binding_level; + +/* A PC value bigger than any PC value we may ever may encounter. */ + +#define LARGEST_PC (( (unsigned int)1 << (HOST_BITS_PER_INT - 1)) - 1) + +/* Binding level structures are initialized by copying this one. */ + +static const struct binding_level clear_binding_level += { + NULL_TREE, /* names */ + NULL_TREE, /* shadowed */ + NULL_TREE, /* blocks */ + NULL_BINDING_LEVEL, /* level_chain */ + LARGEST_PC, /* end_pc */ + 0, /* start_pc */ + NULL, /* stmts */ + NULL, /* exception_range */ + 0, /* binding_depth */ + 0, /* loc */ + }; + +tree java_global_trees[JTI_MAX]; + +/* Build (and pushdecl) a "promoted type" for all standard + types shorter than int. */ + +static tree +push_promoted_type (const char *name, tree actual_type) +{ + tree type = make_node (TREE_CODE (actual_type)); +#if 1 + tree in_min = TYPE_MIN_VALUE (int_type_node); + tree in_max = TYPE_MAX_VALUE (int_type_node); +#else + tree in_min = TYPE_MIN_VALUE (actual_type); + tree in_max = TYPE_MAX_VALUE (actual_type); +#endif + TYPE_MIN_VALUE (type) = copy_node (in_min); + TREE_TYPE (TYPE_MIN_VALUE (type)) = type; + TYPE_MAX_VALUE (type) = copy_node (in_max); + TREE_TYPE (TYPE_MAX_VALUE (type)) = type; + TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node); + TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type); + layout_type (type); + pushdecl (build_decl (input_location, + TYPE_DECL, get_identifier (name), type)); + return type; +} + +/* Return tree that represents a vtable for a primitive array. */ +static tree +create_primitive_vtable (const char *name) +{ + tree r; + char buf[50]; + + sprintf (buf, "_Jv_%sVTable", name); + r = build_decl (input_location, + VAR_DECL, get_identifier (buf), ptr_type_node); + DECL_EXTERNAL (r) = 1; + return r; +} + +/* Parse the version string and compute the ABI version number. */ +static void +parse_version (void) +{ + const char *p = version_string; + unsigned int major = 0, minor = 0; + unsigned int abi_version; + + /* Skip leading junk. */ + while (*p && !ISDIGIT (*p)) + ++p; + gcc_assert (*p); + + /* Extract major version. */ + while (ISDIGIT (*p)) + { + major = major * 10 + *p - '0'; + ++p; + } + + gcc_assert (*p == '.' && ISDIGIT (p[1])); + ++p; + + /* Extract minor version. */ + while (ISDIGIT (*p)) + { + minor = minor * 10 + *p - '0'; + ++p; + } + + if (flag_indirect_dispatch) + { + abi_version = GCJ_CURRENT_BC_ABI_VERSION; + abi_version |= FLAG_BINARYCOMPAT_ABI; + } + else /* C++ ABI */ + { + /* Implicit in this computation is the idea that we won't break the + old-style binary ABI in a sub-minor release (e.g., from 4.0.0 to + 4.0.1). */ + abi_version = 100000 * major + 1000 * minor; + } + if (flag_bootstrap_classes) + abi_version |= FLAG_BOOTSTRAP_LOADER; + + gcj_abi_version = build_int_cstu (ptr_type_node, abi_version); +} + +void +java_init_decl_processing (void) +{ + tree field = NULL_TREE; + tree t; + + init_class_processing (); + + current_function_decl = NULL; + current_binding_level = NULL_BINDING_LEVEL; + free_binding_level = NULL_BINDING_LEVEL; + pushlevel (0); /* make the binding_level structure for global names */ + global_binding_level = current_binding_level; + + /* The code here must be similar to build_common_tree_nodes{,_2} in + tree.c, especially as to the order of initializing common nodes. */ + error_mark_node = make_node (ERROR_MARK); + TREE_TYPE (error_mark_node) = error_mark_node; + + /* Create sizetype first - needed for other types. */ + initialize_sizetypes (); + + byte_type_node = make_signed_type (8); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("byte"), byte_type_node)); + short_type_node = make_signed_type (16); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("short"), short_type_node)); + int_type_node = make_signed_type (32); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("int"), int_type_node)); + long_type_node = make_signed_type (64); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("long"), long_type_node)); + + unsigned_byte_type_node = make_unsigned_type (8); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("unsigned byte"), + unsigned_byte_type_node)); + unsigned_short_type_node = make_unsigned_type (16); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("unsigned short"), + unsigned_short_type_node)); + unsigned_int_type_node = make_unsigned_type (32); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("unsigned int"), + unsigned_int_type_node)); + unsigned_long_type_node = make_unsigned_type (64); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("unsigned long"), + unsigned_long_type_node)); + + /* This is not a java type, however tree-dfa requires a definition for + size_type_node. */ + size_type_node = make_unsigned_type (POINTER_SIZE); + set_sizetype (size_type_node); + + /* Define these next since types below may used them. */ + integer_type_node = java_type_for_size (INT_TYPE_SIZE, 0); + integer_zero_node = build_int_cst (NULL_TREE, 0); + integer_one_node = build_int_cst (NULL_TREE, 1); + integer_two_node = build_int_cst (NULL_TREE, 2); + integer_three_node = build_int_cst (NULL_TREE, 3); + integer_four_node = build_int_cst (NULL_TREE, 4); + integer_minus_one_node = build_int_cst (NULL_TREE, -1); + + /* A few values used for range checking in the lexer. */ + decimal_int_max = build_int_cstu (unsigned_int_type_node, 0x80000000); + decimal_long_max + = double_int_to_tree (unsigned_long_type_node, + double_int_setbit (double_int_zero, 64)); + + size_zero_node = size_int (0); + size_one_node = size_int (1); + bitsize_zero_node = bitsize_int (0); + bitsize_one_node = bitsize_int (1); + bitsize_unit_node = bitsize_int (BITS_PER_UNIT); + + long_zero_node = build_int_cst (long_type_node, 0); + + void_type_node = make_node (VOID_TYPE); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("void"), void_type_node)); + layout_type (void_type_node); /* Uses size_zero_node */ + + ptr_type_node = build_pointer_type (void_type_node); + const_ptr_type_node + = build_pointer_type (build_type_variant (void_type_node, 1, 0)); + + t = make_node (VOID_TYPE); + layout_type (t); /* Uses size_zero_node */ + return_address_type_node = build_pointer_type (t); + + null_pointer_node = build_int_cst (ptr_type_node, 0); + + char_type_node = make_node (INTEGER_TYPE); + TYPE_STRING_FLAG (char_type_node) = 1; + TYPE_PRECISION (char_type_node) = 16; + fixup_unsigned_type (char_type_node); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("char"), char_type_node)); + + boolean_type_node = make_node (BOOLEAN_TYPE); + TYPE_PRECISION (boolean_type_node) = 1; + fixup_unsigned_type (boolean_type_node); + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("boolean"), + boolean_type_node)); + boolean_false_node = TYPE_MIN_VALUE (boolean_type_node); + boolean_true_node = TYPE_MAX_VALUE (boolean_type_node); + + promoted_byte_type_node + = push_promoted_type ("promoted_byte", byte_type_node); + promoted_short_type_node + = push_promoted_type ("promoted_short", short_type_node); + promoted_char_type_node + = push_promoted_type ("promoted_char", char_type_node); + promoted_boolean_type_node + = push_promoted_type ("promoted_boolean", boolean_type_node); + + float_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (float_type_node) = 32; + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("float"), + float_type_node)); + layout_type (float_type_node); + + double_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (double_type_node) = 64; + pushdecl (build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("double"), + double_type_node)); + layout_type (double_type_node); + + float_zero_node = build_real (float_type_node, dconst0); + double_zero_node = build_real (double_type_node, dconst0); + + /* These are the vtables for arrays of primitives. */ + boolean_array_vtable = create_primitive_vtable ("boolean"); + byte_array_vtable = create_primitive_vtable ("byte"); + char_array_vtable = create_primitive_vtable ("char"); + short_array_vtable = create_primitive_vtable ("short"); + int_array_vtable = create_primitive_vtable ("int"); + long_array_vtable = create_primitive_vtable ("long"); + float_array_vtable = create_primitive_vtable ("float"); + double_array_vtable = create_primitive_vtable ("double"); + + one_elt_array_domain_type = build_index_type (integer_one_node); + utf8const_type = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + utf8const_type, field, "hash", unsigned_short_type_node); + PUSH_FIELD (input_location, + utf8const_type, field, "length", unsigned_short_type_node); + FINISH_RECORD (utf8const_type); + utf8const_ptr_type = build_pointer_type (utf8const_type); + + atable_type = build_array_type (ptr_type_node, + one_elt_array_domain_type); + TYPE_NONALIASED_COMPONENT (atable_type) = 1; + atable_ptr_type = build_pointer_type (atable_type); + + itable_type = build_array_type (ptr_type_node, + one_elt_array_domain_type); + TYPE_NONALIASED_COMPONENT (itable_type) = 1; + itable_ptr_type = build_pointer_type (itable_type); + + symbol_type = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + symbol_type, field, "clname", utf8const_ptr_type); + PUSH_FIELD (input_location, symbol_type, field, "name", utf8const_ptr_type); + PUSH_FIELD (input_location, + symbol_type, field, "signature", utf8const_ptr_type); + FINISH_RECORD (symbol_type); + + symbols_array_type = build_array_type (symbol_type, + one_elt_array_domain_type); + symbols_array_ptr_type = build_pointer_type (symbols_array_type); + + assertion_entry_type = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + assertion_entry_type, field, "assertion_code", integer_type_node); + PUSH_FIELD (input_location, + assertion_entry_type, field, "op1", utf8const_ptr_type); + PUSH_FIELD (input_location, + assertion_entry_type, field, "op2", utf8const_ptr_type); + FINISH_RECORD (assertion_entry_type); + + assertion_table_type = build_array_type (assertion_entry_type, + one_elt_array_domain_type); + + /* As you're adding items here, please update the code right after + this section, so that the filename containing the source code of + the pre-defined class gets registered correctly. */ + unqualified_object_id_node = get_identifier ("Object"); + object_type_node = lookup_class (get_identifier ("java.lang.Object")); + object_ptr_type_node = promote_type (object_type_node); + string_type_node = lookup_class (get_identifier ("java.lang.String")); + string_ptr_type_node = promote_type (string_type_node); + class_type_node = lookup_class (get_identifier ("java.lang.Class")); + throwable_type_node = lookup_class (get_identifier ("java.lang.Throwable")); + exception_type_node = lookup_class (get_identifier ("java.lang.Exception")); + runtime_exception_type_node = + lookup_class (get_identifier ("java.lang.RuntimeException")); + error_exception_type_node = + lookup_class (get_identifier ("java.lang.Error")); + + rawdata_ptr_type_node + = promote_type (lookup_class (get_identifier ("gnu.gcj.RawData"))); + + add_predefined_file (get_identifier ("java/lang/Class.java")); + add_predefined_file (get_identifier ("java/lang/Error.java")); + add_predefined_file (get_identifier ("java/lang/Object.java")); + add_predefined_file (get_identifier ("java/lang/RuntimeException.java")); + add_predefined_file (get_identifier ("java/lang/String.java")); + add_predefined_file (get_identifier ("java/lang/Throwable.java")); + add_predefined_file (get_identifier ("gnu/gcj/RawData.java")); + add_predefined_file (get_identifier ("java/lang/Exception.java")); + add_predefined_file (get_identifier ("java/lang/ClassNotFoundException.java")); + add_predefined_file (get_identifier ("java/lang/NoClassDefFoundError.java")); + + methodtable_type = make_node (RECORD_TYPE); + layout_type (methodtable_type); + build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("methodtable"), methodtable_type); + methodtable_ptr_type = build_pointer_type (methodtable_type); + + TYPE_identifier_node = get_identifier ("TYPE"); + init_identifier_node = get_identifier ("<init>"); + clinit_identifier_node = get_identifier ("<clinit>"); + void_signature_node = get_identifier ("()V"); + finalize_identifier_node = get_identifier ("finalize"); + this_identifier_node = get_identifier ("this"); + + java_lang_cloneable_identifier_node = get_identifier ("java.lang.Cloneable"); + java_io_serializable_identifier_node = + get_identifier ("java.io.Serializable"); + + /* for lack of a better place to put this stub call */ + init_expr_processing(); + + constants_type_node = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + constants_type_node, field, "size", unsigned_int_type_node); + PUSH_FIELD (input_location, + constants_type_node, field, "tags", ptr_type_node); + PUSH_FIELD (input_location, + constants_type_node, field, "data", ptr_type_node); + constants_data_field_decl_node = field; + FINISH_RECORD (constants_type_node); + build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("constants"), constants_type_node); + + access_flags_type_node = unsigned_short_type_node; + + dtable_type = make_node (RECORD_TYPE); + dtable_ptr_type = build_pointer_type (dtable_type); + + otable_type = build_array_type (integer_type_node, + one_elt_array_domain_type); + TYPE_NONALIASED_COMPONENT (otable_type) = 1; + otable_ptr_type = build_pointer_type (otable_type); + + PUSH_FIELD (input_location, + object_type_node, field, "vtable", dtable_ptr_type); + DECL_FCONTEXT (field) = object_type_node; + TYPE_VFIELD (object_type_node) = field; + + /* This isn't exactly true, but it is what we have in the source. + There is an unresolved issue here, which is whether the vtable + should be marked by the GC. */ + if (! flag_hash_synchronization) + PUSH_FIELD (input_location, object_type_node, field, "sync_info", + build_pointer_type (object_type_node)); + for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = DECL_CHAIN (t)) + FIELD_PRIVATE (t) = 1; + FINISH_RECORD (object_type_node); + + field_type_node = make_node (RECORD_TYPE); + field_ptr_type_node = build_pointer_type (field_type_node); + method_type_node = make_node (RECORD_TYPE); + method_ptr_type_node = build_pointer_type (method_type_node); + + set_super_info (0, class_type_node, object_type_node, 0); + set_super_info (0, string_type_node, object_type_node, 0); + class_ptr_type = build_pointer_type (class_type_node); + + PUSH_FIELD (input_location, + class_type_node, field, "next_or_version", class_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "name", utf8const_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "accflags", access_flags_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "superclass", class_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "constants", constants_type_node); + constants_field_decl_node = field; + PUSH_FIELD (input_location, + class_type_node, field, "methods", method_ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "method_count", short_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "vtable_method_count", short_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "fields", field_ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "size_in_bytes", int_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "field_count", short_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "static_field_count", short_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "vtable", dtable_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "otable", otable_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "otable_syms", + symbols_array_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "atable", atable_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "atable_syms", + symbols_array_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "itable", itable_ptr_type); + PUSH_FIELD (input_location, class_type_node, field, "itable_syms", + symbols_array_ptr_type); + PUSH_FIELD (input_location, + class_type_node, field, "catch_classes", ptr_type_node); + PUSH_FIELD (input_location, class_type_node, field, "interfaces", + build_pointer_type (class_ptr_type)); + PUSH_FIELD (input_location, class_type_node, field, "loader", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "interface_count", short_type_node); + PUSH_FIELD (input_location, class_type_node, field, "state", byte_type_node); + PUSH_FIELD (input_location, class_type_node, field, "thread", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "depth", short_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "ancestors", ptr_type_node); + PUSH_FIELD (input_location, class_type_node, field, "idt", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "arrayclass", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "protectionDomain", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "assertion_table", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "hack_signers", ptr_type_node); + PUSH_FIELD (input_location, class_type_node, field, "chain", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "aux_info", ptr_type_node); + PUSH_FIELD (input_location, class_type_node, field, "engine", ptr_type_node); + PUSH_FIELD (input_location, + class_type_node, field, "reflection_data", ptr_type_node); + for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = DECL_CHAIN (t)) + FIELD_PRIVATE (t) = 1; + push_super_field (class_type_node, object_type_node); + + FINISH_RECORD (class_type_node); + build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("Class"), class_type_node); + + field_info_union_node = make_node (UNION_TYPE); + PUSH_FIELD (input_location, + field_info_union_node, field, "boffset", int_type_node); + PUSH_FIELD (input_location, + field_info_union_node, field, "addr", ptr_type_node); + layout_type (field_info_union_node); + + PUSH_FIELD (input_location, + field_type_node, field, "name", utf8const_ptr_type); + PUSH_FIELD (input_location, field_type_node, field, "type", class_ptr_type); + PUSH_FIELD (input_location, + field_type_node, field, "accflags", access_flags_type_node); + PUSH_FIELD (input_location, + field_type_node, field, "bsize", unsigned_short_type_node); + PUSH_FIELD (input_location, + field_type_node, field, "info", field_info_union_node); + FINISH_RECORD (field_type_node); + build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("Field"), field_type_node); + + nativecode_ptr_array_type_node + = build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type); + + PUSH_FIELD (input_location, + dtable_type, field, "class", class_ptr_type); + PUSH_FIELD (input_location, + dtable_type, field, "methods", nativecode_ptr_array_type_node); + FINISH_RECORD (dtable_type); + build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("dispatchTable"), dtable_type); + + jexception_type = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + jexception_type, field, "start_pc", ptr_type_node); + PUSH_FIELD (input_location, jexception_type, field, "end_pc", ptr_type_node); + PUSH_FIELD (input_location, + jexception_type, field, "handler_pc", ptr_type_node); + PUSH_FIELD (input_location, + jexception_type, field, "catch_type", class_ptr_type); + FINISH_RECORD (jexception_type); + build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("jexception"), field_type_node); + jexception_ptr_type = build_pointer_type (jexception_type); + + lineNumberEntry_type = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + lineNumberEntry_type, field, "line_nr", unsigned_short_type_node); + PUSH_FIELD (input_location, + lineNumberEntry_type, field, "start_pc", ptr_type_node); + FINISH_RECORD (lineNumberEntry_type); + + lineNumbers_type = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + lineNumbers_type, field, "length", unsigned_int_type_node); + FINISH_RECORD (lineNumbers_type); + + PUSH_FIELD (input_location, + method_type_node, field, "name", utf8const_ptr_type); + PUSH_FIELD (input_location, + method_type_node, field, "signature", utf8const_ptr_type); + PUSH_FIELD (input_location, + method_type_node, field, "accflags", access_flags_type_node); + PUSH_FIELD (input_location, + method_type_node, field, "index", unsigned_short_type_node); + PUSH_FIELD (input_location, + method_type_node, field, "ncode", nativecode_ptr_type_node); + PUSH_FIELD (input_location, + method_type_node, field, "throws", ptr_type_node); + FINISH_RECORD (method_type_node); + build_decl (BUILTINS_LOCATION, + TYPE_DECL, get_identifier ("Method"), method_type_node); + + end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE); + + t = build_function_type_list (ptr_type_node, class_ptr_type, NULL_TREE); + alloc_object_node = add_builtin_function ("_Jv_AllocObject", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + DECL_IS_MALLOC (alloc_object_node) = 1; + alloc_no_finalizer_node = + add_builtin_function ("_Jv_AllocObjectNoFinalizer", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + DECL_IS_MALLOC (alloc_no_finalizer_node) = 1; + + t = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); + soft_initclass_node = add_builtin_function ("_Jv_InitClass", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + t = build_function_type_list (ptr_type_node, + class_ptr_type, int_type_node, NULL_TREE); + soft_resolvepoolentry_node + = add_builtin_function ("_Jv_ResolvePoolEntry", t, + 0,NOT_BUILT_IN, NULL, NULL_TREE); + DECL_PURE_P (soft_resolvepoolentry_node) = 1; + t = build_function_type_list (void_type_node, + class_ptr_type, int_type_node, NULL_TREE); + throw_node = add_builtin_function ("_Jv_Throw", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + /* 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_list (void_type_node, ptr_type_node, NULL_TREE); + soft_monitorenter_node + = add_builtin_function ("_Jv_MonitorEnter", t, 0, NOT_BUILT_IN, + NULL, NULL_TREE); + soft_monitorexit_node + = add_builtin_function ("_Jv_MonitorExit", t, 0, NOT_BUILT_IN, + NULL, NULL_TREE); + + t = build_function_type_list (ptr_type_node, + ptr_type_node, int_type_node, NULL_TREE); + soft_newarray_node + = add_builtin_function ("_Jv_NewPrimArray", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + DECL_IS_MALLOC (soft_newarray_node) = 1; + + t = build_function_type_list (ptr_type_node, + int_type_node, class_ptr_type, + object_ptr_type_node, NULL_TREE); + soft_anewarray_node + = add_builtin_function ("_Jv_NewObjectArray", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + DECL_IS_MALLOC (soft_anewarray_node) = 1; + + t = build_varargs_function_type_list (ptr_type_node, + ptr_type_node, int_type_node, + NULL_TREE); + soft_multianewarray_node + = add_builtin_function ("_Jv_NewMultiArray", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + DECL_IS_MALLOC (soft_multianewarray_node) = 1; + + t = build_function_type_list (void_type_node, int_type_node, NULL_TREE); + soft_badarrayindex_node + = add_builtin_function ("_Jv_ThrowBadArrayIndex", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + /* Mark soft_badarrayindex_node as a `noreturn' function with side + effects. */ + TREE_THIS_VOLATILE (soft_badarrayindex_node) = 1; + TREE_SIDE_EFFECTS (soft_badarrayindex_node) = 1; + + t = build_function_type_list (void_type_node, NULL_TREE); + soft_nullpointer_node + = add_builtin_function ("_Jv_ThrowNullPointerException", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + /* Mark soft_nullpointer_node as a `noreturn' function with side + effects. */ + TREE_THIS_VOLATILE (soft_nullpointer_node) = 1; + TREE_SIDE_EFFECTS (soft_nullpointer_node) = 1; + + soft_abstractmethod_node + = add_builtin_function ("_Jv_ThrowAbstractMethodError", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + /* Mark soft_abstractmethod_node as a `noreturn' function with side + effects. */ + TREE_THIS_VOLATILE (soft_abstractmethod_node) = 1; + TREE_SIDE_EFFECTS (soft_abstractmethod_node) = 1; + + soft_nosuchfield_node + = add_builtin_function ("_Jv_ThrowNoSuchFieldError", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + /* Mark soft_nosuchfield_node as a `noreturn' function with side + effects. */ + TREE_THIS_VOLATILE (soft_nosuchfield_node) = 1; + TREE_SIDE_EFFECTS (soft_nosuchfield_node) = 1; + + t = build_function_type_list (ptr_type_node, + class_ptr_type, object_ptr_type_node, + NULL_TREE); + soft_checkcast_node + = add_builtin_function ("_Jv_CheckCast", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + t = build_function_type_list (boolean_type_node, + object_ptr_type_node, class_ptr_type, + NULL_TREE); + soft_instanceof_node + = add_builtin_function ("_Jv_IsInstanceOf", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + DECL_PURE_P (soft_instanceof_node) = 1; + t = build_function_type_list (void_type_node, + object_ptr_type_node, object_ptr_type_node, + NULL_TREE); + soft_checkarraystore_node + = add_builtin_function ("_Jv_CheckArrayStore", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + t = build_function_type_list (ptr_type_node, + ptr_type_node, ptr_type_node, int_type_node, + NULL_TREE); + soft_lookupinterfacemethod_node + = add_builtin_function ("_Jv_LookupInterfaceMethodIdx", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + DECL_PURE_P (soft_lookupinterfacemethod_node) = 1; + + t = build_function_type_list (ptr_type_node, + ptr_type_node, ptr_type_node, ptr_type_node, + NULL_TREE); + soft_lookupinterfacemethodbyname_node + = add_builtin_function ("_Jv_LookupInterfaceMethod", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + t = build_function_type_list (ptr_type_node, + object_ptr_type_node, ptr_type_node, + ptr_type_node, int_type_node, NULL_TREE); + soft_lookupjnimethod_node + = add_builtin_function ("_Jv_LookupJNIMethod", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + t = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE); + soft_getjnienvnewframe_node + = add_builtin_function ("_Jv_GetJNIEnvNewFrame", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + t = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); + soft_jnipopsystemframe_node + = add_builtin_function ("_Jv_JNI_PopSystemFrame", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + + t = build_function_type_list (object_ptr_type_node, + object_ptr_type_node, NULL_TREE); + soft_unwrapjni_node + = add_builtin_function ("_Jv_UnwrapJNIweakReference", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + + t = build_function_type_list (int_type_node, + int_type_node, int_type_node, NULL_TREE); + soft_idiv_node + = add_builtin_function ("_Jv_divI", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + + soft_irem_node + = add_builtin_function ("_Jv_remI", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + + t = build_function_type_list (long_type_node, + long_type_node, long_type_node, NULL_TREE); + soft_ldiv_node + = add_builtin_function ("_Jv_divJ", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + + soft_lrem_node + = add_builtin_function ("_Jv_remJ", t, + 0, NOT_BUILT_IN, NULL, NULL_TREE); + + initialize_builtins (); + + soft_fmod_node = built_in_decls[BUILT_IN_FMOD]; + + parse_version (); +} + + +/* Look up NAME in the current binding level and its superiors + in the namespace of variables, functions and typedefs. + Return a ..._DECL node of some kind representing its definition, + or return 0 if it is undefined. */ + +tree +lookup_name (tree name) +{ + tree val; + if (current_binding_level != global_binding_level + && IDENTIFIER_LOCAL_VALUE (name)) + val = IDENTIFIER_LOCAL_VALUE (name); + else + val = IDENTIFIER_GLOBAL_VALUE (name); + return val; +} + +/* Similar to `lookup_name' but look only at current binding level and + the previous one if it's the parameter level. */ + +static tree +lookup_name_current_level (tree name) +{ + tree t; + + if (current_binding_level == global_binding_level) + return IDENTIFIER_GLOBAL_VALUE (name); + + if (IDENTIFIER_LOCAL_VALUE (name) == 0) + return 0; + + for (t = current_binding_level->names; t; t = DECL_CHAIN (t)) + if (DECL_NAME (t) == name) + break; + + return t; +} + +/* Record a decl-node X as belonging to the current lexical scope. + Check for errors (such as an incompatible declaration for the same + name already seen in the same scope). + + Returns either X or an old decl for the same name. + If an old decl is returned, it may have been smashed + to agree with what X says. */ + +tree +pushdecl (tree x) +{ + tree t; + tree name = DECL_NAME (x); + struct binding_level *b = current_binding_level; + + if (TREE_CODE (x) != TYPE_DECL) + DECL_CONTEXT (x) = current_function_decl; + if (name) + { + t = lookup_name_current_level (name); + if (t != 0 && t == error_mark_node) + /* error_mark_node is 0 for a while during initialization! */ + { + t = 0; + error ("%q+D used prior to declaration", x); + } + + /* If we're naming a hitherto-unnamed type, set its TYPE_NAME + to point to the TYPE_DECL. + Since Java does not have typedefs, a type can only have + one (true) name, given by a class, interface, or builtin. */ + if (TREE_CODE (x) == TYPE_DECL + && TYPE_NAME (TREE_TYPE (x)) == 0 + && TREE_TYPE (x) != error_mark_node) + { + TYPE_NAME (TREE_TYPE (x)) = x; + TYPE_STUB_DECL (TREE_TYPE (x)) = x; + } + + /* This name is new in its binding level. + Install the new declaration and return it. */ + if (b == global_binding_level) + { + /* Install a global value. */ + + IDENTIFIER_GLOBAL_VALUE (name) = x; + } + else + { + /* Here to install a non-global value. */ + tree oldlocal = IDENTIFIER_LOCAL_VALUE (name); + IDENTIFIER_LOCAL_VALUE (name) = x; + + /* If storing a local value, there may already be one (inherited). + If so, record it for restoration when this binding level ends. */ + if (oldlocal != 0) + b->shadowed = tree_cons (name, oldlocal, b->shadowed); + } + } + + /* Put decls on list in reverse order. + We will reverse them later if necessary. */ + DECL_CHAIN (x) = b->names; + b->names = x; + + return x; +} + +void +pushdecl_force_head (tree x) +{ + current_binding_level->names = x; +} + +/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */ + +tree +pushdecl_top_level (tree x) +{ + tree t; + struct binding_level *b = current_binding_level; + + current_binding_level = global_binding_level; + t = pushdecl (x); + current_binding_level = b; + return t; +} + +/* Like pushdecl, only it places X in FUNCTION_BINDING_LEVEL, if appropriate. */ + +tree +pushdecl_function_level (tree x) +{ + tree t; + struct binding_level *b = current_binding_level; + + current_binding_level = function_binding_level; + t = pushdecl (x); + current_binding_level = b; + return t; +} + +/* Nonzero if we are currently in the global binding level. */ + +int +global_bindings_p (void) +{ + return current_binding_level == global_binding_level; +} + +/* Return the list of declarations of the current level. + Note that this list is in reverse order unless/until + you nreverse it; and when you do nreverse it, you must + store the result back using `storedecls' or you will lose. */ + +tree +getdecls (void) +{ + return current_binding_level->names; +} + +/* Create a new `struct binding_level'. */ + +static struct binding_level * +make_binding_level (void) +{ + /* NOSTRICT */ + return ggc_alloc_cleared_binding_level (); +} + +void +pushlevel (int unused ATTRIBUTE_UNUSED) +{ + struct binding_level *newlevel = NULL_BINDING_LEVEL; + + /* Reuse or create a struct for this binding level. */ + + if (free_binding_level) + { + newlevel = free_binding_level; + free_binding_level = free_binding_level->level_chain; + } + else + { + newlevel = make_binding_level (); + } + + /* Add this level to the front of the chain (stack) of levels that + are active. */ + + *newlevel = clear_binding_level; + newlevel->level_chain = current_binding_level; + newlevel->loc = input_location; + current_binding_level = newlevel; +#if defined(DEBUG_JAVA_BINDING_LEVELS) + newlevel->binding_depth = binding_depth; + indent (); + fprintf (stderr, "push %s level %p pc %d\n", + (is_class_level) ? "class" : "block", newlevel, current_pc); + is_class_level = 0; + binding_depth++; +#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ +} + +/* Exit a binding level. + Pop the level off, and restore the state of the identifier-decl mappings + that were in effect when this level was entered. + + If KEEP is nonzero, this level had explicit declarations, so + and create a "block" (a BLOCK node) for the level + to record its declarations and subblocks for symbol table output. + + If FUNCTIONBODY is nonzero, this level is the body of a function, + so create a block as if KEEP were set and also clear out all + label names. + + If REVERSE is nonzero, reverse the order of decls before putting + them into the BLOCK. */ + +tree +poplevel (int keep, int reverse, int functionbody) +{ + tree link; + /* The chain of decls was accumulated in reverse order. + Put it into forward order, just for cleanliness. */ + tree decls; + tree subblocks = current_binding_level->blocks; + tree block = 0; + tree decl; + tree bind = 0; + +#if defined(DEBUG_JAVA_BINDING_LEVELS) + binding_depth--; + indent (); + if (current_binding_level->end_pc != LARGEST_PC) + fprintf (stderr, "pop %s level %p pc %d (end pc %d)\n", + (is_class_level) ? "class" : "block", current_binding_level, current_pc, + current_binding_level->end_pc); + else + fprintf (stderr, "pop %s level %p pc %d\n", + (is_class_level) ? "class" : "block", current_binding_level, current_pc); +#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ + + /* Get the decls in the order they were written. + Usually current_binding_level->names is in reverse order. + But parameter decls were previously put in forward order. */ + + if (reverse) + current_binding_level->names + = decls = nreverse (current_binding_level->names); + else + decls = current_binding_level->names; + + for (decl = decls; decl; decl = DECL_CHAIN (decl)) + if (TREE_CODE (decl) == VAR_DECL + && DECL_LANG_SPECIFIC (decl) != NULL + && DECL_LOCAL_SLOT_NUMBER (decl)) + LOCAL_VAR_OUT_OF_SCOPE_P (decl) = 1; + + /* If there were any declarations in that level, + or if this level is a function body, + create a BLOCK to record them for the life of this function. */ + + block = 0; + if (keep || functionbody) + { + block = make_node (BLOCK); + TREE_TYPE (block) = void_type_node; + } + + if (current_binding_level->exception_range) + expand_end_java_handler (current_binding_level->exception_range); + + if (block != 0) + { + /* If any statements have been generated at this level, create a + BIND_EXPR to hold them and copy the variables to it. This + only applies to the bytecode compiler. */ + if (current_binding_level->stmts) + { + tree decl = decls; + tree *var = &BLOCK_VARS (block); + + /* Copy decls from names list, ignoring labels. */ + while (decl) + { + tree next = DECL_CHAIN (decl); + if (TREE_CODE (decl) != LABEL_DECL) + { + *var = decl; + var = &DECL_CHAIN (decl); + } + decl = next; + } + *var = NULL; + + bind = build3 (BIND_EXPR, TREE_TYPE (block), BLOCK_VARS (block), + BLOCK_EXPR_BODY (block), block); + BIND_EXPR_BODY (bind) = current_binding_level->stmts; + + if (BIND_EXPR_BODY (bind) + && TREE_SIDE_EFFECTS (BIND_EXPR_BODY (bind))) + TREE_SIDE_EFFECTS (bind) = 1; + + /* FIXME: gimplifier brain damage. */ + if (BIND_EXPR_BODY (bind) == NULL) + BIND_EXPR_BODY (bind) = build_java_empty_stmt (); + + SET_EXPR_LOCATION (bind, current_binding_level->loc); + + current_binding_level->stmts = NULL; + } + else + { + BLOCK_VARS (block) = decls; + } + BLOCK_SUBBLOCKS (block) = subblocks; + } + + /* In each subblock, record that this is its superior. */ + + for (link = subblocks; link; link = TREE_CHAIN (link)) + BLOCK_SUPERCONTEXT (link) = block; + + /* Clear out the meanings of the local variables of this level. */ + + for (link = decls; link; link = DECL_CHAIN (link)) + { + tree name = DECL_NAME (link); + if (name != 0 && IDENTIFIER_LOCAL_VALUE (name) == link) + { + /* If the ident. was used or addressed via a local extern decl, + don't forget that fact. */ + if (DECL_EXTERNAL (link)) + { + if (TREE_USED (link)) + TREE_USED (name) = 1; + if (TREE_ADDRESSABLE (link)) + TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1; + } + IDENTIFIER_LOCAL_VALUE (name) = 0; + } + } + + /* Restore all name-meanings of the outer levels + that were shadowed by this level. */ + + for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link)) + IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); + + /* If the level being exited is the top level of a function, + check over all the labels, and clear out the current + (function local) meanings of their names. */ + + if (functionbody) + { + /* If this is the top level block of a function, + the vars are the function's parameters. + Don't leave them in the BLOCK because they are + found in the FUNCTION_DECL instead. */ + + BLOCK_VARS (block) = 0; + } + + /* Pop the current level, and free the structure for reuse. */ + + { + struct binding_level *level = current_binding_level; + current_binding_level = current_binding_level->level_chain; + + level->level_chain = free_binding_level; + free_binding_level = level; + } + + /* Dispose of the block that we just made inside some higher level. */ + if (functionbody) + { + DECL_INITIAL (current_function_decl) = block; + DECL_SAVED_TREE (current_function_decl) = bind; + } + else + { + if (block) + { + current_binding_level->blocks + = chainon (current_binding_level->blocks, block); + } + /* If we did not make a block for the level just exited, + any blocks made for inner levels + (since they cannot be recorded as subblocks in that level) + must be carried forward so they will later become subblocks + of something else. */ + else if (subblocks) + current_binding_level->blocks + = chainon (current_binding_level->blocks, subblocks); + + if (bind) + java_add_stmt (bind); + } + + if (block) + TREE_USED (block) = 1; + return block; +} + +void +maybe_pushlevels (int pc) +{ +#if defined(DEBUG_JAVA_BINDING_LEVELS) + current_pc = pc; +#endif + + while (pending_local_decls != NULL_TREE && + DECL_LOCAL_START_PC (pending_local_decls) <= pc) + { + tree *ptr = &pending_local_decls; + tree decl = *ptr, next; + int end_pc = DECL_LOCAL_END_PC (decl); + + while (*ptr != NULL_TREE + && DECL_LOCAL_START_PC (*ptr) <= pc + && DECL_LOCAL_END_PC (*ptr) == end_pc) + ptr = &DECL_CHAIN (*ptr); + pending_local_decls = *ptr; + *ptr = NULL_TREE; + + /* Force non-nested range to be nested in current range by + truncating variable lifetimes. */ + if (end_pc > current_binding_level->end_pc) + { + tree t; + end_pc = current_binding_level->end_pc; + for (t = decl; t != NULL_TREE; t = DECL_CHAIN (t)) + DECL_LOCAL_END_PC (t) = end_pc; + } + + maybe_start_try (pc, end_pc); + + pushlevel (1); + + current_binding_level->end_pc = end_pc; + current_binding_level->start_pc = pc; + current_binding_level->names = NULL; + for ( ; decl != NULL_TREE; decl = next) + { + int index = DECL_LOCAL_SLOT_NUMBER (decl); + tree base_decl; + next = DECL_CHAIN (decl); + push_jvm_slot (index, decl); + pushdecl (decl); + base_decl + = find_local_variable (index, TREE_TYPE (decl), pc); + if (TREE_CODE (TREE_TYPE (base_decl)) == POINTER_TYPE) + base_decl = TREE_VEC_ELT (base_decl_map, index); + SET_DECL_VALUE_EXPR (decl, base_decl); + DECL_HAS_VALUE_EXPR_P (decl) = 1; + } + } + + maybe_start_try (pc, 0); +} + +void +maybe_poplevels (int pc) +{ +#if defined(DEBUG_JAVA_BINDING_LEVELS) + current_pc = pc; +#endif + + /* FIXME: I'm pretty sure that this is wrong. Variable scopes are + inclusive, so a variable is live if pc == end_pc. Here, we + terminate a range if the current pc is equal to the end of the + range, and this is *before* we have generated code for the + instruction at end_pc. We're closing a binding level one + instruction too early.*/ + while (current_binding_level->end_pc <= pc) + poplevel (1, 0, 0); +} + +/* Terminate any binding which began during the range beginning at + start_pc. This tidies up improperly nested local variable ranges + and exception handlers; a variable declared within an exception + range is forcibly terminated when that exception ends. */ + +void +force_poplevels (int start_pc) +{ + while (current_binding_level->start_pc > start_pc) + { + if (pedantic && current_binding_level->start_pc > start_pc) + warning (0, "In %+D: overlapped variable and exception ranges at %d", + current_function_decl, + current_binding_level->start_pc); + poplevel (1, 0, 0); + } +} + +/* integrate_decl_tree calls this function. */ + +void +java_dup_lang_specific_decl (tree node) +{ + int lang_decl_size; + struct lang_decl *x; + + if (!DECL_LANG_SPECIFIC (node)) + return; + + lang_decl_size = sizeof (struct lang_decl); + x = ggc_alloc_lang_decl (lang_decl_size); + memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size); + DECL_LANG_SPECIFIC (node) = x; +} + +void +give_name_to_locals (JCF *jcf) +{ + int i, n = DECL_LOCALVARIABLES_OFFSET (current_function_decl); + int code_offset = DECL_CODE_OFFSET (current_function_decl); + tree parm; + pending_local_decls = NULL_TREE; + if (n == 0) + return; + JCF_SEEK (jcf, n); + n = JCF_readu2 (jcf); + for (i = 0; i < n; i++) + { + int start_pc = JCF_readu2 (jcf); + int length = JCF_readu2 (jcf); + int name_index = JCF_readu2 (jcf); + int signature_index = JCF_readu2 (jcf); + int slot = JCF_readu2 (jcf); + tree name = get_name_constant (jcf, name_index); + tree type = parse_signature (jcf, signature_index); + if (slot < DECL_ARG_SLOT_COUNT (current_function_decl) + && start_pc == 0 + && length == DECL_CODE_LENGTH (current_function_decl)) + { + tree decl = TREE_VEC_ELT (decl_map, slot); + DECL_NAME (decl) = name; + if (TREE_CODE (decl) != PARM_DECL || TREE_TYPE (decl) != type) + warning (0, "bad type in parameter debug info"); + } + else + { + tree *ptr; + int end_pc = start_pc + length; + tree decl = build_decl (input_location, VAR_DECL, name, type); + if (end_pc > DECL_CODE_LENGTH (current_function_decl)) + { + warning (0, "bad PC range for debug info for local %q+D", + decl); + end_pc = DECL_CODE_LENGTH (current_function_decl); + } + + /* Adjust start_pc if necessary so that the local's first + store operation will use the relevant DECL as a + destination. Fore more information, read the leading + comments for expr.c:maybe_adjust_start_pc. */ + start_pc = maybe_adjust_start_pc (jcf, code_offset, start_pc, slot); + + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + DECL_LOCAL_SLOT_NUMBER (decl) = slot; + DECL_LOCAL_START_PC (decl) = start_pc; + DECL_LOCAL_END_PC (decl) = end_pc; + + /* Now insert the new decl in the proper place in + pending_local_decls. We are essentially doing an insertion sort, + which works fine, since the list input will normally already + be sorted. */ + ptr = &pending_local_decls; + while (*ptr != NULL_TREE + && (DECL_LOCAL_START_PC (*ptr) > start_pc + || (DECL_LOCAL_START_PC (*ptr) == start_pc + && DECL_LOCAL_END_PC (*ptr) < end_pc))) + ptr = &DECL_CHAIN (*ptr); + DECL_CHAIN (decl) = *ptr; + *ptr = decl; + } + } + + pending_local_decls = nreverse (pending_local_decls); + + /* Fill in default names for the parameters. */ + for (parm = DECL_ARGUMENTS (current_function_decl), i = 0; + parm != NULL_TREE; parm = DECL_CHAIN (parm), i++) + { + if (DECL_NAME (parm) == NULL_TREE) + { + int arg_i = METHOD_STATIC (current_function_decl) ? i+1 : i; + if (arg_i == 0) + DECL_NAME (parm) = get_identifier ("this"); + else + { + char buffer[12]; + sprintf (buffer, "ARG_%d", arg_i); + DECL_NAME (parm) = get_identifier (buffer); + } + } + } +} + +tree +build_result_decl (tree fndecl) +{ + tree restype = TREE_TYPE (TREE_TYPE (fndecl)); + tree result = DECL_RESULT (fndecl); + if (! result) + { + result = build_decl (DECL_SOURCE_LOCATION (fndecl), + RESULT_DECL, NULL_TREE, restype); + DECL_ARTIFICIAL (result) = 1; + DECL_IGNORED_P (result) = 1; + DECL_CONTEXT (result) = fndecl; + DECL_RESULT (fndecl) = result; + } + return result; +} + +void +start_java_method (tree fndecl) +{ + tree tem, *ptr; + int i; + + uniq = 0; + + current_function_decl = fndecl; + announce_function (fndecl); + + i = DECL_MAX_LOCALS(fndecl) + DECL_MAX_STACK(fndecl); + decl_map = make_tree_vec (i); + base_decl_map = make_tree_vec (i); + type_map = XRESIZEVEC (tree, type_map, i); + +#if defined(DEBUG_JAVA_BINDING_LEVELS) + fprintf (stderr, "%s:\n", lang_printable_name (fndecl, 2)); + current_pc = 0; +#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ + pushlevel (1); /* Push parameters. */ + + ptr = &DECL_ARGUMENTS (fndecl); + for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0; + tem != end_params_node; tem = TREE_CHAIN (tem), i++) + { + tree parm_name = NULL_TREE, parm_decl; + tree parm_type = TREE_VALUE (tem); + gcc_assert (i < DECL_MAX_LOCALS (fndecl)); + + parm_decl = build_decl (input_location, PARM_DECL, parm_name, parm_type); + DECL_CONTEXT (parm_decl) = fndecl; + if (targetm.calls.promote_prototypes (parm_type) + && TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node) + && INTEGRAL_TYPE_P (parm_type)) + parm_type = integer_type_node; + DECL_ARG_TYPE (parm_decl) = parm_type; + + *ptr = parm_decl; + ptr = &DECL_CHAIN (parm_decl); + + /* Add parm_decl to the decl_map. */ + push_jvm_slot (i, parm_decl); + + /* The this parameter of methods is artificial. */ + if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE && i == 0) + DECL_ARTIFICIAL (parm_decl) = 1; + + type_map[i] = TREE_TYPE (parm_decl); + if (TYPE_IS_WIDE (TREE_TYPE (parm_decl))) + { + i++; + type_map[i] = void_type_node; + } + } + *ptr = NULL_TREE; + DECL_ARG_SLOT_COUNT (current_function_decl) = i; + + while (i < DECL_MAX_LOCALS(fndecl)) + type_map[i++] = NULL_TREE; + + build_result_decl (fndecl); + DECL_SOURCE_LOCATION (fndecl) = input_location; + + /* Push local variables. */ + pushlevel (2); + + function_binding_level = current_binding_level; +} + +void +end_java_method (void) +{ + tree fndecl = current_function_decl; + + /* pop out of function */ + poplevel (1, 1, 0); + + /* pop out of its parameters */ + poplevel (1, 0, 1); + + BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl; + + if (DECL_SAVED_TREE (fndecl)) + { + tree fbody, block_body; + /* Before we check initialization, attached all class initialization + variable to the block_body */ + fbody = DECL_SAVED_TREE (fndecl); + block_body = BIND_EXPR_BODY (fbody); + htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (fndecl), + attach_init_test_initialization_flags, block_body); + } + + finish_method (fndecl); + + current_function_decl = NULL_TREE; + base_decl_map = NULL_TREE; +} + +/* Prepare a method for expansion. */ + +void +finish_method (tree fndecl) +{ + tree *tp = &DECL_SAVED_TREE (fndecl); + + /* Wrap body of synchronized methods in a monitorenter, + plus monitorexit cleanup. */ + if (METHOD_SYNCHRONIZED (fndecl)) + { + tree enter, exit, lock; + if (METHOD_STATIC (fndecl)) + lock = build_class_ref (DECL_CONTEXT (fndecl)); + else + lock = DECL_ARGUMENTS (fndecl); + BUILD_MONITOR_ENTER (enter, lock); + BUILD_MONITOR_EXIT (exit, lock); + *tp = build2 (COMPOUND_EXPR, void_type_node, enter, + build2 (TRY_FINALLY_EXPR, void_type_node, *tp, exit)); + } + + /* Convert function tree to GENERIC prior to inlining. */ + java_genericize (fndecl); + + /* Store the end of the function, so that we get good line number + info for the epilogue. */ + if (DECL_STRUCT_FUNCTION (fndecl)) + set_cfun (DECL_STRUCT_FUNCTION (fndecl)); + else + allocate_struct_function (fndecl, false); + cfun->function_end_locus = DECL_FUNCTION_LAST_LINE (fndecl); + + /* Defer inlining and expansion to the cgraph optimizers. */ + cgraph_finalize_function (fndecl, false); +} + +/* We pessimistically marked all methods and fields external until we + knew what set of classes we were planning to compile. Now mark those + associated with CLASS to be generated locally as not external. */ + +static void +java_mark_decl_local (tree decl) +{ + DECL_EXTERNAL (decl) = 0; + +#ifdef ENABLE_CHECKING + /* Double check that we didn't pass the function to the callgraph early. */ + if (TREE_CODE (decl) == FUNCTION_DECL) + gcc_assert (!cgraph_node (decl)->local.finalized); +#endif + gcc_assert (!DECL_RTL_SET_P (decl)); +} + +/* Given appropriate target support, G++ will emit hidden aliases for native + methods. Using this hidden name is required for proper operation of + _Jv_Method::ncode, but it doesn't hurt to use it everywhere. Look for + proper target support, then mark the method for aliasing. */ + +static void +java_mark_cni_decl_local (tree decl) +{ +#if !defined(HAVE_GAS_HIDDEN) || !defined(ASM_OUTPUT_DEF) + return; +#endif + + DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; + DECL_LOCAL_CNI_METHOD_P (decl) = 1; + + /* Setting DECL_LOCAL_CNI_METHOD_P changes the behavior of the + mangler. We might have already referenced this native method and + therefore created its name, but even if we have it won't hurt. + We'll just go via its externally visible name, rather than its + hidden alias. However, we must force things so that the correct + mangling is done. */ + + if (DECL_ASSEMBLER_NAME_SET_P (decl)) + java_mangle_decl (decl); + if (DECL_RTL_SET_P (decl)) + { + SET_DECL_RTL (decl, 0); + make_decl_rtl (decl); + } +} + +/* Use the preceding two functions and mark all members of the class. */ + +void +java_mark_class_local (tree klass) +{ + tree t; + + for (t = TYPE_FIELDS (klass); t ; t = DECL_CHAIN (t)) + if (FIELD_STATIC (t)) + { + if (DECL_EXTERNAL (t)) + VEC_safe_push (tree, gc, pending_static_fields, t); + java_mark_decl_local (t); + } + + for (t = TYPE_METHODS (klass); t ; t = DECL_CHAIN (t)) + if (!METHOD_ABSTRACT (t)) + { + if (METHOD_NATIVE (t) && !flag_jni) + java_mark_cni_decl_local (t); + else + java_mark_decl_local (t); + } +} + +/* Add a statement to a compound_expr. */ + +tree +add_stmt_to_compound (tree existing, tree type, tree stmt) +{ + if (!stmt) + return existing; + else if (existing) + { + tree expr = build2 (COMPOUND_EXPR, type, existing, stmt); + TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (existing) + | TREE_SIDE_EFFECTS (stmt); + return expr; + } + else + return stmt; +} + +/* If this node is an expr, mark its input location. Called from + walk_tree(). */ + +static tree +set_input_location (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) +{ + tree t = *tp; + + if (CAN_HAVE_LOCATION_P (t)) + { + if (EXPR_HAS_LOCATION(t)) + return t; /* Don't walk any further into this expr. */ + else + SET_EXPR_LOCATION (t, input_location); + } + + return NULL_TREE; /* Continue walking this expr. */ +} + +/* Add a statement to the statement_list currently being constructed. + If the statement_list is null, we don't create a singleton list. + This is necessary because poplevel() assumes that adding a + statement to a null statement_list returns the statement. */ + +tree +java_add_stmt (tree new_stmt) +{ + tree stmts = current_binding_level->stmts; + tree_stmt_iterator i; + + if (input_filename) + walk_tree (&new_stmt, set_input_location, NULL, NULL); + + if (stmts == NULL) + return current_binding_level->stmts = new_stmt; + + /* Force STMTS to be a statement_list. */ + if (TREE_CODE (stmts) != STATEMENT_LIST) + { + tree t = make_node (STATEMENT_LIST); + i = tsi_last (t); + tsi_link_after (&i, stmts, TSI_CONTINUE_LINKING); + stmts = t; + } + + i = tsi_last (stmts); + tsi_link_after (&i, new_stmt, TSI_CONTINUE_LINKING); + TREE_TYPE (stmts) = void_type_node; + + return current_binding_level->stmts = stmts; +} + +/* Add a variable to the current scope. */ + +tree +java_add_local_var (tree decl) +{ + tree *vars = ¤t_binding_level->names; + tree next = *vars; + DECL_CHAIN (decl) = next; + *vars = decl; + DECL_CONTEXT (decl) = current_function_decl; + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + return decl; +} + +/* Return a pointer to the compound_expr currently being + constructed. */ + +tree * +get_stmts (void) +{ + return ¤t_binding_level->stmts; +} + +/* Register an exception range as belonging to the current binding + level. There may only be one: if there are more, we'll create more + binding levels. However, each range can have multiple handlers, + and these are expanded when we call expand_end_java_handler(). */ + +void +register_exception_range (struct eh_range *range, int pc, int end_pc) +{ + gcc_assert (! current_binding_level->exception_range); + current_binding_level->exception_range = range; + current_binding_level->end_pc = end_pc; + current_binding_level->start_pc = pc; +} + +#include "gt-java-decl.h" diff --git a/gcc/java/except.c b/gcc/java/except.c new file mode 100644 index 000000000..1705106c4 --- /dev/null +++ b/gcc/java/except.c @@ -0,0 +1,611 @@ +/* Handle exceptions for GNU compiler for the Java(TM) language. + Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "java-tree.h" +#include "javaop.h" +#include "java-opcodes.h" +#include "jcf.h" +#include "java-except.h" +#include "diagnostic-core.h" +#include "toplev.h" +#include "tree-iterator.h" + + +static void expand_start_java_handler (struct eh_range *); +static struct eh_range *find_handler_in_range (int, struct eh_range *, + struct eh_range *); +static void check_start_handlers (struct eh_range *, int); +static void free_eh_ranges (struct eh_range *range); + +struct eh_range *current_method_handlers; + +struct eh_range *current_try_block = NULL; + +/* These variables are used to speed up find_handler. */ + +static int cache_range_start, cache_range_end; +static struct eh_range *cache_range; +static struct eh_range *cache_next_child; + +/* A dummy range that represents the entire method. */ + +struct eh_range whole_range; + +/* Check the invariants of the structure we're using to contain + exception regions. Either returns true or fails an assertion + check. */ + +bool +sanity_check_exception_range (struct eh_range *range) +{ + struct eh_range *ptr = range->first_child; + for (; ptr; ptr = ptr->next_sibling) + { + gcc_assert (ptr->outer == range + && ptr->end_pc > ptr->start_pc); + if (ptr->next_sibling) + gcc_assert (ptr->next_sibling->start_pc >= ptr->end_pc); + gcc_assert (ptr->start_pc >= ptr->outer->start_pc + && ptr->end_pc <= ptr->outer->end_pc); + (void) sanity_check_exception_range (ptr); + } + return true; +} + +#if defined(DEBUG_JAVA_BINDING_LEVELS) +extern int is_class_level; +extern int current_pc; +extern int binding_depth; +extern void indent (void); +static void +print_ranges (struct eh_range *range) +{ + if (! range) + return; + + struct eh_range *child = range->first_child; + + indent (); + fprintf (stderr, "handler pc %d --> %d ", range->start_pc, range->end_pc); + + tree handler = range->handlers; + for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler)) + { + tree type = TREE_PURPOSE (handler); + if (type == NULL) + type = throwable_type_node; + fprintf (stderr, " type=%s ", IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)))); + } + fprintf (stderr, "\n"); + + int saved = binding_depth; + binding_depth++; + print_ranges (child); + binding_depth = saved; + + print_ranges (range->next_sibling); +} +#endif + +/* Search for the most specific eh_range containing PC. + Assume PC is within RANGE. + CHILD is a list of children of RANGE such that any + previous children have end_pc values that are too low. */ + +static struct eh_range * +find_handler_in_range (int pc, struct eh_range *range, struct eh_range *child) +{ + for (; child != NULL; child = child->next_sibling) + { + if (pc < child->start_pc) + break; + if (pc < child->end_pc) + return find_handler_in_range (pc, child, child->first_child); + } + cache_range = range; + cache_range_start = pc; + cache_next_child = child; + cache_range_end = child == NULL ? range->end_pc : child->start_pc; + return range; +} + +/* Find the inner-most handler that contains PC. */ + +struct eh_range * +find_handler (int pc) +{ + struct eh_range *h; + if (pc >= cache_range_start) + { + h = cache_range; + if (pc < cache_range_end) + return h; + while (pc >= h->end_pc) + { + cache_next_child = h->next_sibling; + h = h->outer; + } + } + else + { + h = &whole_range; + cache_next_child = h->first_child; + } + return find_handler_in_range (pc, h, cache_next_child); +} + +static void +free_eh_ranges (struct eh_range *range) +{ + while (range) + { + struct eh_range *next = range->next_sibling; + free_eh_ranges (range->first_child); + if (range != &whole_range) + free (range); + range = next; + } +} + +/* Called to re-initialize the exception machinery for a new method. */ + +void +method_init_exceptions (void) +{ + free_eh_ranges (&whole_range); + whole_range.start_pc = 0; + whole_range.end_pc = DECL_CODE_LENGTH (current_function_decl) + 1; + whole_range.outer = NULL; + whole_range.first_child = NULL; + whole_range.next_sibling = NULL; + cache_range_start = 0xFFFFFF; +} + +/* Split an exception range into two at PC. The sub-ranges that + belong to the range are split and distributed between the two new + ranges. */ + +static void +split_range (struct eh_range *range, int pc) +{ + struct eh_range *ptr; + struct eh_range **first_child, **second_child; + struct eh_range *h; + + /* First, split all the sub-ranges. */ + for (ptr = range->first_child; ptr; ptr = ptr->next_sibling) + { + if (pc > ptr->start_pc + && pc < ptr->end_pc) + { + split_range (ptr, pc); + } + } + + /* Create a new range. */ + h = XNEW (struct eh_range); + + h->start_pc = pc; + h->end_pc = range->end_pc; + h->next_sibling = range->next_sibling; + range->next_sibling = h; + range->end_pc = pc; + h->handlers = build_tree_list (TREE_PURPOSE (range->handlers), + TREE_VALUE (range->handlers)); + h->next_sibling = NULL; + h->expanded = 0; + h->stmt = NULL; + h->outer = range->outer; + h->first_child = NULL; + + ptr = range->first_child; + first_child = &range->first_child; + second_child = &h->first_child; + + /* Distribute the sub-ranges between the two new ranges. */ + for (ptr = range->first_child; ptr; ptr = ptr->next_sibling) + { + if (ptr->start_pc < pc) + { + *first_child = ptr; + ptr->outer = range; + first_child = &ptr->next_sibling; + } + else + { + *second_child = ptr; + ptr->outer = h; + second_child = &ptr->next_sibling; + } + } + *first_child = NULL; + *second_child = NULL; +} + + +/* Add an exception range. + + There are some missed optimization opportunities here. For + example, some bytecode obfuscators generate seemingly + nonoverlapping exception ranges which, when coalesced, do in fact + nest correctly. We could merge these, but we'd have to fix up all + the enclosed regions first and perhaps create a new range anyway if + it overlapped existing ranges. + + Also, we don't attempt to detect the case where two previously + added disjoint ranges could be coalesced by a new range. */ + +void +add_handler (int start_pc, int end_pc, tree handler, tree type) +{ + struct eh_range *ptr, *h; + struct eh_range **first_child, **prev; + + /* First, split all the existing ranges that we need to enclose. */ + for (ptr = whole_range.first_child; ptr; ptr = ptr->next_sibling) + { + if (start_pc > ptr->start_pc + && start_pc < ptr->end_pc) + { + split_range (ptr, start_pc); + } + + if (end_pc > ptr->start_pc + && end_pc < ptr->end_pc) + { + split_range (ptr, end_pc); + } + + if (ptr->start_pc >= end_pc) + break; + } + + /* Create the new range. */ + h = XNEW (struct eh_range); + first_child = &h->first_child; + + h->start_pc = start_pc; + h->end_pc = end_pc; + h->first_child = NULL; + h->outer = NULL_EH_RANGE; + h->handlers = build_tree_list (type, handler); + h->next_sibling = NULL; + h->expanded = 0; + h->stmt = NULL; + + /* Find every range at the top level that will be a sub-range of the + range we're inserting and make it so. */ + { + struct eh_range **prev = &whole_range.first_child; + for (ptr = *prev; ptr;) + { + struct eh_range *next = ptr->next_sibling; + + if (ptr->start_pc >= end_pc) + break; + + if (ptr->start_pc < start_pc) + { + prev = &ptr->next_sibling; + } + else if (ptr->start_pc >= start_pc + && ptr->start_pc < end_pc) + { + *prev = next; + *first_child = ptr; + first_child = &ptr->next_sibling; + ptr->outer = h; + ptr->next_sibling = NULL; + } + + ptr = next; + } + } + + /* Find the right place to insert the new range. */ + prev = &whole_range.first_child; + for (ptr = *prev; ptr; prev = &ptr->next_sibling, ptr = ptr->next_sibling) + { + gcc_assert (ptr->outer == NULL_EH_RANGE); + if (ptr->start_pc >= start_pc) + break; + } + + /* And insert it there. */ + *prev = h; + if (ptr) + { + h->next_sibling = ptr; + h->outer = ptr->outer; + } +} + + +/* if there are any handlers for this range, issue start of region */ +static void +expand_start_java_handler (struct eh_range *range) +{ +#if defined(DEBUG_JAVA_BINDING_LEVELS) + indent (); + fprintf (stderr, "expand start handler pc %d --> %d\n", + current_pc, range->end_pc); +#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ + pushlevel (0); + register_exception_range (range, range->start_pc, range->end_pc); + range->expanded = 1; +} + +tree +prepare_eh_table_type (tree type) +{ + tree exp; + tree *slot; + const char *name; + char *buf; + tree decl; + tree utf8_ref; + + /* The "type" (match_info) in a (Java) exception table is a pointer to: + * a) NULL - meaning match any type in a try-finally. + * b) a pointer to a pointer to a class. + * c) a pointer to a pointer to a utf8_ref. The pointer is + * rewritten to point to the appropriate class. */ + + if (type == NULL_TREE) + return NULL_TREE; + + if (TYPE_TO_RUNTIME_MAP (output_class) == NULL) + TYPE_TO_RUNTIME_MAP (output_class) = java_treetreehash_create (10); + + slot = java_treetreehash_new (TYPE_TO_RUNTIME_MAP (output_class), type); + if (*slot != NULL) + return TREE_VALUE (*slot); + + if (is_compiled_class (type) && !flag_indirect_dispatch) + { + name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); + buf = (char *) alloca (strlen (name) + 5); + sprintf (buf, "%s_ref", name); + decl = build_decl (input_location, + VAR_DECL, get_identifier (buf), ptr_type_node); + TREE_STATIC (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + DECL_IGNORED_P (decl) = 1; + TREE_READONLY (decl) = 1; + TREE_THIS_VOLATILE (decl) = 0; + DECL_INITIAL (decl) = build_class_ref (type); + layout_decl (decl, 0); + pushdecl (decl); + exp = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (decl)), decl); + } + else + { + utf8_ref = build_utf8_ref (DECL_NAME (TYPE_NAME (type))); + name = IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (utf8_ref, 0))); + buf = (char *) alloca (strlen (name) + 5); + sprintf (buf, "%s_ref", name); + decl = build_decl (input_location, + VAR_DECL, get_identifier (buf), utf8const_ptr_type); + TREE_STATIC (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + DECL_IGNORED_P (decl) = 1; + TREE_READONLY (decl) = 1; + TREE_THIS_VOLATILE (decl) = 0; + layout_decl (decl, 0); + pushdecl (decl); + exp = build1 (ADDR_EXPR, build_pointer_type (utf8const_ptr_type), decl); + CONSTRUCTOR_APPEND_ELT (TYPE_CATCH_CLASSES (output_class), + NULL_TREE, + make_catch_class_record (exp, utf8_ref)); + } + + exp = convert (ptr_type_node, exp); + + *slot = tree_cons (type, exp, NULL_TREE); + + return exp; +} + +static int +expand_catch_class (void **entry, void *x ATTRIBUTE_UNUSED) +{ + struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + tree addr = TREE_VALUE ((tree)ite->value); + tree decl; + STRIP_NOPS (addr); + decl = TREE_OPERAND (addr, 0); + rest_of_decl_compilation (decl, global_bindings_p (), 0); + return true; +} + +/* For every class in the TYPE_TO_RUNTIME_MAP, expand the + corresponding object that is used by the runtime type matcher. */ + +void +java_expand_catch_classes (tree this_class) +{ + if (TYPE_TO_RUNTIME_MAP (this_class)) + htab_traverse + (TYPE_TO_RUNTIME_MAP (this_class), + expand_catch_class, NULL); +} + +/* Build and push the variable that will hold the exception object + within this function. */ + +static tree +build_exception_object_var (void) +{ + tree decl = DECL_FUNCTION_EXC_OBJ (current_function_decl); + if (decl == NULL) + { + decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl), + VAR_DECL, get_identifier ("#exc_obj"), ptr_type_node); + DECL_IGNORED_P (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + + DECL_FUNCTION_EXC_OBJ (current_function_decl) = decl; + pushdecl_function_level (decl); + } + return decl; +} + +/* Build a reference to the jthrowable object being carried in the + exception header. */ + +tree +build_exception_object_ref (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_exception_object_var (); + obj = fold_convert (build_pointer_type (type), obj); + obj = build2 (POINTER_PLUS_EXPR, TREE_TYPE (obj), obj, + fold_build1 (NEGATE_EXPR, sizetype, + TYPE_SIZE_UNIT (TREE_TYPE (obj)))); + obj = build1 (INDIRECT_REF, type, obj); + + return obj; +} + +/* If there are any handlers for this range, issue end of range, + and then all handler blocks */ +void +expand_end_java_handler (struct eh_range *range) +{ + tree handler = range->handlers; + if (handler) + { + tree exc_obj = build_exception_object_var (); + tree catches = make_node (STATEMENT_LIST); + tree_stmt_iterator catches_i = tsi_last (catches); + tree *body; + + for (; handler; handler = TREE_CHAIN (handler)) + { + tree type, eh_type, x; + tree stmts = make_node (STATEMENT_LIST); + tree_stmt_iterator stmts_i = tsi_last (stmts); + + type = TREE_PURPOSE (handler); + if (type == NULL) + type = throwable_type_node; + eh_type = prepare_eh_table_type (type); + + x = build_call_expr (built_in_decls[BUILT_IN_EH_POINTER], + 1, integer_zero_node); + x = build2 (MODIFY_EXPR, void_type_node, exc_obj, x); + tsi_link_after (&stmts_i, x, TSI_CONTINUE_LINKING); + + x = build1 (GOTO_EXPR, void_type_node, TREE_VALUE (handler)); + tsi_link_after (&stmts_i, x, TSI_CONTINUE_LINKING); + + x = build2 (CATCH_EXPR, void_type_node, eh_type, stmts); + tsi_link_after (&catches_i, x, TSI_CONTINUE_LINKING); + + /* Throwable can match anything in Java, and therefore + any subsequent handlers are unreachable. */ + /* ??? If we're assured of no foreign language exceptions, + we'd be better off using NULL as the exception type + for the catch. */ + if (type == throwable_type_node) + break; + } + + body = get_stmts (); + *body = build2 (TRY_CATCH_EXPR, void_type_node, *body, catches); + } + +#if defined(DEBUG_JAVA_BINDING_LEVELS) + indent (); + fprintf (stderr, "expand end handler pc %d <-- %d\n", + current_pc, range->start_pc); +#endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ +} + +/* Recursive helper routine for maybe_start_handlers. */ + +static void +check_start_handlers (struct eh_range *range, int pc) +{ + if (range != NULL_EH_RANGE && range->start_pc == pc) + { + check_start_handlers (range->outer, pc); + if (!range->expanded) + expand_start_java_handler (range); + } +} + + +/* Routine to see if exception handling is turned on. + DO_WARN is nonzero if we want to inform the user that exception + handling is turned off. + + This is used to ensure that -fexceptions has been specified if the + compiler tries to use any exception-specific functions. */ + +static inline int +doing_eh (void) +{ + if (! flag_exceptions) + { + static int warned = 0; + if (! warned) + { + error ("exception handling disabled, use -fexceptions to enable"); + warned = 1; + } + return 0; + } + return 1; +} + +static struct eh_range *current_range; + +/* Emit any start-of-try-range starting at start_pc and ending after + end_pc. */ + +void +maybe_start_try (int start_pc, int end_pc) +{ + struct eh_range *range; + if (! doing_eh ()) + return; + + range = find_handler (start_pc); + while (range != NULL_EH_RANGE && range->start_pc == start_pc + && range->end_pc < end_pc) + range = range->outer; + + current_range = range; + check_start_handlers (range, start_pc); +} + diff --git a/gcc/java/expr.c b/gcc/java/expr.c new file mode 100644 index 000000000..53feab5ce --- /dev/null +++ b/gcc/java/expr.c @@ -0,0 +1,3820 @@ +/* Process expressions for the GNU compiler for the Java(TM) language. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "flags.h" +#include "java-tree.h" +#include "javaop.h" +#include "java-opcodes.h" +#include "jcf.h" +#include "java-except.h" +#include "parse.h" +#include "diagnostic-core.h" +#include "ggc.h" +#include "tree-iterator.h" +#include "target.h" + +static void flush_quick_stack (void); +static void push_value (tree); +static tree pop_value (tree); +static void java_stack_swap (void); +static void java_stack_dup (int, int); +static void build_java_athrow (tree); +static void build_java_jsr (int, int); +static void build_java_ret (tree); +static void expand_java_multianewarray (tree, int); +static void expand_java_arraystore (tree); +static void expand_java_arrayload (tree); +static void expand_java_array_length (void); +static tree build_java_monitor (tree, tree); +static void expand_java_pushc (int, tree); +static void expand_java_return (tree); +static void expand_load_internal (int, tree, int); +static void expand_java_NEW (tree); +static void expand_java_INSTANCEOF (tree); +static void expand_java_CHECKCAST (tree); +static void expand_iinc (unsigned int, int, int); +static void expand_java_binop (tree, enum tree_code); +static void note_label (int, int); +static void expand_compare (enum tree_code, tree, tree, int); +static void expand_test (enum tree_code, tree, int); +static void expand_cond (enum tree_code, tree, int); +static void expand_java_goto (int); +static tree expand_java_switch (tree, int); +static void expand_java_add_case (tree, int, int); +static VEC(tree,gc) *pop_arguments (tree); +static void expand_invoke (int, int, int); +static void expand_java_field_op (int, int, int); +static void java_push_constant_from_pool (struct JCF *, int); +static void java_stack_pop (int); +static tree build_java_throw_out_of_bounds_exception (tree); +static tree build_java_check_indexed_type (tree, tree); +static unsigned char peek_opcode_at_pc (struct JCF *, int, int); +static void promote_arguments (void); +static void cache_cpool_data_ref (void); + +static GTY(()) tree operand_type[59]; + +static GTY(()) tree methods_ident; +static GTY(()) tree ncode_ident; +tree dtable_ident = NULL_TREE; + +/* Set to nonzero value in order to emit class initialization code + before static field references. */ +int always_initialize_class_p = 0; + +/* We store the stack state in two places: + Within a basic block, we use the quick_stack, which is a VEC of expression + nodes. + This is the top part of the stack; below that we use find_stack_slot. + At the end of a basic block, the quick_stack must be flushed + to the stack slot array (as handled by find_stack_slot). + Using quick_stack generates better code (especially when + compiled without optimization), because we do not have to + explicitly store and load trees to temporary variables. + + If a variable is on the quick stack, it means the value of variable + when the quick stack was last flushed. Conceptually, flush_quick_stack + saves all the quick_stack elements in parallel. However, that is + complicated, so it actually saves them (i.e. copies each stack value + to is home virtual register) from low indexes. This allows a quick_stack + element at index i (counting from the bottom of stack the) to references + slot virtuals for register that are >= i, but not those that are deeper. + This convention makes most operations easier. For example iadd works + even when the stack contains (reg[0], reg[1]): It results in the + stack containing (reg[0]+reg[1]), which is OK. However, some stack + operations are more complicated. For example dup given a stack + containing (reg[0]) would yield (reg[0], reg[0]), which would violate + the convention, since stack value 1 would refer to a register with + lower index (reg[0]), which flush_quick_stack does not safely handle. + So dup cannot just add an extra element to the quick_stack, but iadd can. +*/ + +static GTY(()) VEC(tree,gc) *quick_stack; + +/* The physical memory page size used in this computer. See + build_field_ref(). */ +static GTY(()) tree page_size; + +/* The stack pointer of the Java virtual machine. + This does include the size of the quick_stack. */ + +int stack_pointer; + +const unsigned char *linenumber_table; +int linenumber_count; + +/* Largest pc so far in this method that has been passed to lookup_label. */ +int highest_label_pc_this_method = -1; + +/* Base value for this method to add to pc to get generated label. */ +int start_label_pc_this_method = 0; + +void +init_expr_processing (void) +{ + operand_type[21] = operand_type[54] = int_type_node; + operand_type[22] = operand_type[55] = long_type_node; + operand_type[23] = operand_type[56] = float_type_node; + operand_type[24] = operand_type[57] = double_type_node; + operand_type[25] = operand_type[58] = ptr_type_node; +} + +tree +java_truthvalue_conversion (tree expr) +{ + /* It is simpler and generates better code to have only TRUTH_*_EXPR + or comparison expressions as truth values at this level. + + This function should normally be identity for Java. */ + + switch (TREE_CODE (expr)) + { + case EQ_EXPR: case NE_EXPR: case UNEQ_EXPR: case LTGT_EXPR: + case LE_EXPR: case GE_EXPR: case LT_EXPR: case GT_EXPR: + case UNLE_EXPR: case UNGE_EXPR: case UNLT_EXPR: case UNGT_EXPR: + case ORDERED_EXPR: case UNORDERED_EXPR: + case TRUTH_ANDIF_EXPR: + case TRUTH_ORIF_EXPR: + case TRUTH_AND_EXPR: + case TRUTH_OR_EXPR: + case TRUTH_XOR_EXPR: + case TRUTH_NOT_EXPR: + case ERROR_MARK: + return expr; + + case INTEGER_CST: + return integer_zerop (expr) ? boolean_false_node : boolean_true_node; + + case REAL_CST: + return real_zerop (expr) ? boolean_false_node : boolean_true_node; + + /* are these legal? XXX JH */ + case NEGATE_EXPR: + case ABS_EXPR: + case FLOAT_EXPR: + /* These don't change whether an object is nonzero or zero. */ + return java_truthvalue_conversion (TREE_OPERAND (expr, 0)); + + case COND_EXPR: + /* Distribute the conversion into the arms of a COND_EXPR. */ + return fold_build3 (COND_EXPR, boolean_type_node, TREE_OPERAND (expr, 0), + java_truthvalue_conversion (TREE_OPERAND (expr, 1)), + java_truthvalue_conversion (TREE_OPERAND (expr, 2))); + + case NOP_EXPR: + /* If this is widening the argument, we can ignore it. */ + if (TYPE_PRECISION (TREE_TYPE (expr)) + >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0)))) + return java_truthvalue_conversion (TREE_OPERAND (expr, 0)); + /* fall through to default */ + + default: + return fold_build2 (NE_EXPR, boolean_type_node, + expr, boolean_false_node); + } +} + +/* Save any stack slots that happen to be in the quick_stack into their + home virtual register slots. + + The copy order is from low stack index to high, to support the invariant + that the expression for a slot may contain decls for stack slots with + higher (or the same) index, but not lower. */ + +static void +flush_quick_stack (void) +{ + int stack_index = stack_pointer; + unsigned ix; + tree t; + + /* Count the number of slots the quick stack is holding. */ + for (ix = 0; VEC_iterate(tree, quick_stack, ix, t); ix++) + stack_index -= 1 + TYPE_IS_WIDE (TREE_TYPE (t)); + + for (ix = 0; VEC_iterate(tree, quick_stack, ix, t); ix++) + { + tree decl, type = TREE_TYPE (t); + + decl = find_stack_slot (stack_index, type); + if (decl != t) + java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (t), decl, t)); + stack_index += 1 + TYPE_IS_WIDE (type); + } + + VEC_truncate (tree, quick_stack, 0); +} + +/* Push TYPE on the type stack. + Return true on success, 0 on overflow. */ + +int +push_type_0 (tree type) +{ + int n_words; + type = promote_type (type); + n_words = 1 + TYPE_IS_WIDE (type); + if (stack_pointer + n_words > DECL_MAX_STACK (current_function_decl)) + return 0; + /* Allocate decl for this variable now, so we get a temporary that + survives the whole method. */ + find_stack_slot (stack_pointer, type); + stack_type_map[stack_pointer++] = type; + n_words--; + while (--n_words >= 0) + stack_type_map[stack_pointer++] = TYPE_SECOND; + return 1; +} + +void +push_type (tree type) +{ + int r = push_type_0 (type); + gcc_assert (r); +} + +static void +push_value (tree value) +{ + tree type = TREE_TYPE (value); + if (TYPE_PRECISION (type) < 32 && INTEGRAL_TYPE_P (type)) + { + type = promote_type (type); + value = convert (type, value); + } + push_type (type); + VEC_safe_push (tree, gc, quick_stack, value); + + /* If the value has a side effect, then we need to evaluate it + whether or not the result is used. If the value ends up on the + quick stack and is then popped, this won't happen -- so we flush + the quick stack. It is safest to simply always flush, though, + since TREE_SIDE_EFFECTS doesn't capture COMPONENT_REF, and for + the latter we may need to strip conversions. */ + flush_quick_stack (); +} + +/* Pop a type from the type stack. + TYPE is the expected type. Return the actual type, which must be + convertible to TYPE. + On an error, *MESSAGEP is set to a freshly malloc'd error message. */ + +tree +pop_type_0 (tree type, char **messagep) +{ + int n_words; + tree t; + *messagep = NULL; + if (TREE_CODE (type) == RECORD_TYPE) + type = promote_type (type); + n_words = 1 + TYPE_IS_WIDE (type); + if (stack_pointer < n_words) + { + *messagep = xstrdup ("stack underflow"); + return type; + } + while (--n_words > 0) + { + if (stack_type_map[--stack_pointer] != void_type_node) + { + *messagep = xstrdup ("Invalid multi-word value on type stack"); + return type; + } + } + t = stack_type_map[--stack_pointer]; + if (type == NULL_TREE || t == type) + return t; + if (TREE_CODE (t) == TREE_LIST) + { + do + { + tree tt = TREE_PURPOSE (t); + if (! can_widen_reference_to (tt, type)) + { + t = tt; + goto fail; + } + t = TREE_CHAIN (t); + } + while (t); + return t; + } + if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (t) + && TYPE_PRECISION (type) <= 32 && TYPE_PRECISION (t) <= 32) + return t; + if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (t) == POINTER_TYPE) + { + /* If the expected type we've been passed is object or ptr + (i.e. void*), the caller needs to know the real type. */ + if (type == ptr_type_node || type == object_ptr_type_node) + return t; + + /* Since the verifier has already run, we know that any + types we see will be compatible. In BC mode, this fact + may be checked at runtime, but if that is so then we can + assume its truth here as well. So, we always succeed + here, with the expected type. */ + return type; + } + + if (! flag_verify_invocations && flag_indirect_dispatch + && t == object_ptr_type_node) + { + if (type != ptr_type_node) + warning (0, "need to insert runtime check for %s", + xstrdup (lang_printable_name (type, 0))); + return type; + } + + /* lang_printable_name uses a static buffer, so we must save the result + from calling it the first time. */ + fail: + { + char *temp = xstrdup (lang_printable_name (type, 0)); + /* If the stack contains a multi-word type, keep popping the stack until + the real type is found. */ + while (t == void_type_node) + t = stack_type_map[--stack_pointer]; + *messagep = concat ("expected type '", temp, + "' but stack contains '", lang_printable_name (t, 0), + "'", NULL); + free (temp); + } + return type; +} + +/* Pop a type from the type stack. + TYPE is the expected type. Return the actual type, which must be + convertible to TYPE, otherwise call error. */ + +tree +pop_type (tree type) +{ + char *message = NULL; + type = pop_type_0 (type, &message); + if (message != NULL) + { + error ("%s", message); + free (message); + } + return type; +} + + +/* Return true if two type assertions are equal. */ + +static int +type_assertion_eq (const void * k1_p, const void * k2_p) +{ + const type_assertion k1 = *(const type_assertion *)k1_p; + const type_assertion k2 = *(const type_assertion *)k2_p; + return (k1.assertion_code == k2.assertion_code + && k1.op1 == k2.op1 + && k1.op2 == k2.op2); +} + +/* Hash a type assertion. */ + +static hashval_t +type_assertion_hash (const void *p) +{ + const type_assertion *k_p = (const type_assertion *) p; + hashval_t hash = iterative_hash (&k_p->assertion_code, sizeof + k_p->assertion_code, 0); + + switch (k_p->assertion_code) + { + case JV_ASSERT_TYPES_COMPATIBLE: + hash = iterative_hash (&TYPE_UID (k_p->op2), sizeof TYPE_UID (k_p->op2), + hash); + /* Fall through. */ + + case JV_ASSERT_IS_INSTANTIABLE: + hash = iterative_hash (&TYPE_UID (k_p->op1), sizeof TYPE_UID (k_p->op1), + hash); + /* Fall through. */ + + case JV_ASSERT_END_OF_TABLE: + break; + + default: + gcc_unreachable (); + } + + return hash; +} + +/* Add an entry to the type assertion table for the given class. + KLASS is the class for which this assertion will be evaluated by the + runtime during loading/initialization. + ASSERTION_CODE is the 'opcode' or type of this assertion: see java-tree.h. + OP1 and OP2 are the operands. The tree type of these arguments may be + specific to each assertion_code. */ + +void +add_type_assertion (tree klass, int assertion_code, tree op1, tree op2) +{ + htab_t assertions_htab; + type_assertion as; + void **as_pp; + + assertions_htab = TYPE_ASSERTIONS (klass); + if (assertions_htab == NULL) + { + assertions_htab = htab_create_ggc (7, type_assertion_hash, + type_assertion_eq, NULL); + TYPE_ASSERTIONS (current_class) = assertions_htab; + } + + as.assertion_code = assertion_code; + as.op1 = op1; + as.op2 = op2; + + as_pp = htab_find_slot (assertions_htab, &as, INSERT); + + /* Don't add the same assertion twice. */ + if (*as_pp) + return; + + *as_pp = ggc_alloc_type_assertion (); + **(type_assertion **)as_pp = as; +} + + +/* Return 1 if SOURCE_TYPE can be safely widened to TARGET_TYPE. + Handles array types and interfaces. */ + +int +can_widen_reference_to (tree source_type, tree target_type) +{ + if (source_type == ptr_type_node || target_type == object_ptr_type_node) + return 1; + + /* Get rid of pointers */ + if (TREE_CODE (source_type) == POINTER_TYPE) + source_type = TREE_TYPE (source_type); + if (TREE_CODE (target_type) == POINTER_TYPE) + target_type = TREE_TYPE (target_type); + + if (source_type == target_type) + return 1; + + /* FIXME: This is very pessimistic, in that it checks everything, + even if we already know that the types are compatible. If we're + to support full Java class loader semantics, we need this. + However, we could do something more optimal. */ + if (! flag_verify_invocations) + { + add_type_assertion (current_class, JV_ASSERT_TYPES_COMPATIBLE, + source_type, target_type); + + if (!quiet_flag) + warning (0, "assert: %s is assign compatible with %s", + xstrdup (lang_printable_name (target_type, 0)), + xstrdup (lang_printable_name (source_type, 0))); + /* Punt everything to runtime. */ + return 1; + } + + if (TYPE_DUMMY (source_type) || TYPE_DUMMY (target_type)) + { + return 1; + } + else + { + if (TYPE_ARRAY_P (source_type) || TYPE_ARRAY_P (target_type)) + { + HOST_WIDE_INT source_length, target_length; + if (TYPE_ARRAY_P (source_type) != TYPE_ARRAY_P (target_type)) + { + /* An array implements Cloneable and Serializable. */ + tree name = DECL_NAME (TYPE_NAME (target_type)); + return (name == java_lang_cloneable_identifier_node + || name == java_io_serializable_identifier_node); + } + target_length = java_array_type_length (target_type); + if (target_length >= 0) + { + source_length = java_array_type_length (source_type); + if (source_length != target_length) + return 0; + } + source_type = TYPE_ARRAY_ELEMENT (source_type); + target_type = TYPE_ARRAY_ELEMENT (target_type); + if (source_type == target_type) + return 1; + if (TREE_CODE (source_type) != POINTER_TYPE + || TREE_CODE (target_type) != POINTER_TYPE) + return 0; + return can_widen_reference_to (source_type, target_type); + } + else + { + int source_depth = class_depth (source_type); + int target_depth = class_depth (target_type); + + if (TYPE_DUMMY (source_type) || TYPE_DUMMY (target_type)) + { + if (! quiet_flag) + warning (0, "assert: %s is assign compatible with %s", + xstrdup (lang_printable_name (target_type, 0)), + xstrdup (lang_printable_name (source_type, 0))); + return 1; + } + + /* class_depth can return a negative depth if an error occurred */ + if (source_depth < 0 || target_depth < 0) + return 0; + + if (CLASS_INTERFACE (TYPE_NAME (target_type))) + { + /* target_type is OK if source_type or source_type ancestors + implement target_type. We handle multiple sub-interfaces */ + tree binfo, base_binfo; + int i; + + for (binfo = TYPE_BINFO (source_type), i = 0; + BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + if (can_widen_reference_to + (BINFO_TYPE (base_binfo), target_type)) + return 1; + + if (!i) + return 0; + } + + for ( ; source_depth > target_depth; source_depth--) + { + source_type + = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (source_type), 0)); + } + return source_type == target_type; + } + } +} + +static tree +pop_value (tree type) +{ + type = pop_type (type); + if (VEC_length (tree, quick_stack) != 0) + return VEC_pop (tree, quick_stack); + else + return find_stack_slot (stack_pointer, promote_type (type)); +} + + +/* Pop and discard the top COUNT stack slots. */ + +static void +java_stack_pop (int count) +{ + while (count > 0) + { + tree type; + + gcc_assert (stack_pointer != 0); + + type = stack_type_map[stack_pointer - 1]; + if (type == TYPE_SECOND) + { + count--; + gcc_assert (stack_pointer != 1 && count > 0); + + type = stack_type_map[stack_pointer - 2]; + } + pop_value (type); + count--; + } +} + +/* Implement the 'swap' operator (to swap two top stack slots). */ + +static void +java_stack_swap (void) +{ + tree type1, type2; + tree temp; + tree decl1, decl2; + + if (stack_pointer < 2 + || (type1 = stack_type_map[stack_pointer - 1]) == TYPE_SECOND + || (type2 = stack_type_map[stack_pointer - 2]) == TYPE_SECOND + || TYPE_IS_WIDE (type1) || TYPE_IS_WIDE (type2)) + /* Bad stack swap. */ + abort (); + /* Bad stack swap. */ + + flush_quick_stack (); + decl1 = find_stack_slot (stack_pointer - 1, type1); + decl2 = find_stack_slot (stack_pointer - 2, type2); + temp = build_decl (input_location, VAR_DECL, NULL_TREE, type1); + java_add_local_var (temp); + java_add_stmt (build2 (MODIFY_EXPR, type1, temp, decl1)); + java_add_stmt (build2 (MODIFY_EXPR, type2, + find_stack_slot (stack_pointer - 1, type2), + decl2)); + java_add_stmt (build2 (MODIFY_EXPR, type1, + find_stack_slot (stack_pointer - 2, type1), + temp)); + stack_type_map[stack_pointer - 1] = type2; + stack_type_map[stack_pointer - 2] = type1; +} + +static void +java_stack_dup (int size, int offset) +{ + int low_index = stack_pointer - size - offset; + int dst_index; + if (low_index < 0) + error ("stack underflow - dup* operation"); + + flush_quick_stack (); + + stack_pointer += size; + dst_index = stack_pointer; + + for (dst_index = stack_pointer; --dst_index >= low_index; ) + { + tree type; + int src_index = dst_index - size; + if (src_index < low_index) + src_index = dst_index + size + offset; + type = stack_type_map [src_index]; + if (type == TYPE_SECOND) + { + /* Dup operation splits 64-bit number. */ + gcc_assert (src_index > low_index); + + stack_type_map[dst_index] = type; + src_index--; dst_index--; + type = stack_type_map[src_index]; + gcc_assert (TYPE_IS_WIDE (type)); + } + else + gcc_assert (! TYPE_IS_WIDE (type)); + + if (src_index != dst_index) + { + tree src_decl = find_stack_slot (src_index, type); + tree dst_decl = find_stack_slot (dst_index, type); + + java_add_stmt + (build2 (MODIFY_EXPR, TREE_TYPE (dst_decl), dst_decl, src_decl)); + stack_type_map[dst_index] = type; + } + } +} + +/* Calls _Jv_Throw or _Jv_Sjlj_Throw. Discard the contents of the + value stack. */ + +static void +build_java_athrow (tree node) +{ + tree call; + + call = build_call_nary (void_type_node, + build_address_of (throw_node), + 1, node); + TREE_SIDE_EFFECTS (call) = 1; + java_add_stmt (call); + java_stack_pop (stack_pointer); +} + +/* Implementation for jsr/ret */ + +static void +build_java_jsr (int target_pc, int return_pc) +{ + tree where = lookup_label (target_pc); + tree ret = lookup_label (return_pc); + tree ret_label = fold_build1 (ADDR_EXPR, return_address_type_node, ret); + push_value (ret_label); + flush_quick_stack (); + java_add_stmt (build1 (GOTO_EXPR, void_type_node, where)); + + /* Do not need to emit the label here. We noted the existence of the + label as a jump target in note_instructions; we'll emit the label + for real at the beginning of the expand_byte_code loop. */ +} + +static void +build_java_ret (tree location) +{ + java_add_stmt (build1 (GOTO_EXPR, void_type_node, location)); +} + +/* Implementation of operations on array: new, load, store, length */ + +tree +decode_newarray_type (int atype) +{ + switch (atype) + { + case 4: return boolean_type_node; + case 5: return char_type_node; + case 6: return float_type_node; + case 7: return double_type_node; + case 8: return byte_type_node; + case 9: return short_type_node; + case 10: return int_type_node; + case 11: return long_type_node; + default: return NULL_TREE; + } +} + +/* Map primitive type to the code used by OPCODE_newarray. */ + +int +encode_newarray_type (tree type) +{ + if (type == boolean_type_node) + return 4; + else if (type == char_type_node) + return 5; + else if (type == float_type_node) + return 6; + else if (type == double_type_node) + return 7; + else if (type == byte_type_node) + return 8; + else if (type == short_type_node) + return 9; + else if (type == int_type_node) + return 10; + else if (type == long_type_node) + return 11; + else + gcc_unreachable (); +} + +/* Build a call to _Jv_ThrowBadArrayIndex(), the + ArrayIndexOfBoundsException exception handler. */ + +static tree +build_java_throw_out_of_bounds_exception (tree index) +{ + tree node; + + /* We need to build a COMPOUND_EXPR because _Jv_ThrowBadArrayIndex() + has void return type. We cannot just set the type of the CALL_EXPR below + to int_type_node because we would lose it during gimplification. */ + gcc_assert (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (soft_badarrayindex_node)))); + node = build_call_nary (void_type_node, + build_address_of (soft_badarrayindex_node), + 1, index); + TREE_SIDE_EFFECTS (node) = 1; + + node = build2 (COMPOUND_EXPR, int_type_node, node, integer_zero_node); + TREE_SIDE_EFFECTS (node) = 1; /* Allows expansion within ANDIF */ + + return (node); +} + +/* Return the length of an array. Doesn't perform any checking on the nature + or value of the array NODE. May be used to implement some bytecodes. */ + +tree +build_java_array_length_access (tree node) +{ + tree type = TREE_TYPE (node); + tree array_type = TREE_TYPE (type); + HOST_WIDE_INT length; + + if (!is_array_type_p (type)) + { + /* With the new verifier, we will see an ordinary pointer type + here. In this case, we just use an arbitrary array type. */ + array_type = build_java_array_type (object_ptr_type_node, -1); + type = promote_type (array_type); + } + + length = java_array_type_length (type); + if (length >= 0) + return build_int_cst (NULL_TREE, length); + + node = build3 (COMPONENT_REF, int_type_node, + build_java_indirect_ref (array_type, node, + flag_check_references), + lookup_field (&array_type, get_identifier ("length")), + NULL_TREE); + IS_ARRAY_LENGTH_ACCESS (node) = 1; + return node; +} + +/* Optionally checks a reference against the NULL pointer. ARG1: the + expr, ARG2: we should check the reference. Don't generate extra + checks if we're not generating code. */ + +tree +java_check_reference (tree expr, int check) +{ + if (!flag_syntax_only && check) + { + expr = save_expr (expr); + expr = build3 (COND_EXPR, TREE_TYPE (expr), + build2 (EQ_EXPR, boolean_type_node, + expr, null_pointer_node), + build_call_nary (void_type_node, + build_address_of (soft_nullpointer_node), + 0), + expr); + } + + return expr; +} + +/* Reference an object: just like an INDIRECT_REF, but with checking. */ + +tree +build_java_indirect_ref (tree type, tree expr, int check) +{ + tree t; + t = java_check_reference (expr, check); + t = convert (build_pointer_type (type), t); + return build1 (INDIRECT_REF, type, t); +} + +/* Implement array indexing (either as l-value or r-value). + Returns a tree for ARRAY[INDEX], assume TYPE is the element type. + Optionally performs bounds checking and/or test to NULL. + At this point, ARRAY should have been verified as an array. */ + +tree +build_java_arrayaccess (tree array, tree type, tree index) +{ + tree node, throw_expr = NULL_TREE; + tree data_field; + tree ref; + tree array_type = TREE_TYPE (TREE_TYPE (array)); + tree size_exp = fold_convert (sizetype, size_in_bytes (type)); + + if (!is_array_type_p (TREE_TYPE (array))) + { + /* With the new verifier, we will see an ordinary pointer type + here. In this case, we just use the correct array type. */ + array_type = build_java_array_type (type, -1); + } + + if (flag_bounds_check) + { + /* Generate: + * (unsigned jint) INDEX >= (unsigned jint) LEN + * && throw ArrayIndexOutOfBoundsException. + * Note this is equivalent to and more efficient than: + * INDEX < 0 || INDEX >= LEN && throw ... */ + tree test; + tree len = convert (unsigned_int_type_node, + build_java_array_length_access (array)); + test = fold_build2 (GE_EXPR, boolean_type_node, + convert (unsigned_int_type_node, index), + len); + if (! integer_zerop (test)) + { + throw_expr + = build2 (TRUTH_ANDIF_EXPR, int_type_node, test, + build_java_throw_out_of_bounds_exception (index)); + /* allows expansion within COMPOUND */ + TREE_SIDE_EFFECTS( throw_expr ) = 1; + } + } + + /* If checking bounds, wrap the index expr with a COMPOUND_EXPR in order + to have the bounds check evaluated first. */ + if (throw_expr != NULL_TREE) + index = build2 (COMPOUND_EXPR, int_type_node, throw_expr, index); + + data_field = lookup_field (&array_type, get_identifier ("data")); + + ref = build3 (COMPONENT_REF, TREE_TYPE (data_field), + build_java_indirect_ref (array_type, array, + flag_check_references), + data_field, NULL_TREE); + + /* Take the address of the data field and convert it to a pointer to + the element type. */ + node = build1 (NOP_EXPR, build_pointer_type (type), build_address_of (ref)); + + /* Multiply the index by the size of an element to obtain a byte + offset. Convert the result to a pointer to the element type. */ + index = build2 (MULT_EXPR, sizetype, + fold_convert (sizetype, index), + size_exp); + + /* Sum the byte offset and the address of the data field. */ + node = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (node), node, index); + + /* Finally, return + + *((&array->data) + index*size_exp) + + */ + return build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (node)), node); +} + +/* Generate code to throw an ArrayStoreException if OBJECT is not assignable + (at runtime) to an element of ARRAY. A NOP_EXPR is returned if it can + determine that no check is required. */ + +tree +build_java_arraystore_check (tree array, tree object) +{ + tree check, element_type, source; + tree array_type_p = TREE_TYPE (array); + tree object_type = TYPE_NAME (TREE_TYPE (TREE_TYPE (object))); + + if (! flag_verify_invocations) + { + /* With the new verifier, we don't track precise types. FIXME: + performance regression here. */ + element_type = TYPE_NAME (object_type_node); + } + else + { + gcc_assert (is_array_type_p (array_type_p)); + + /* Get the TYPE_DECL for ARRAY's element type. */ + element_type + = TYPE_NAME (TREE_TYPE (TREE_TYPE (TREE_TYPE (array_type_p)))); + } + + gcc_assert (TREE_CODE (element_type) == TYPE_DECL + && TREE_CODE (object_type) == TYPE_DECL); + + if (!flag_store_check) + return build1 (NOP_EXPR, array_type_p, array); + + /* No check is needed if the element type is final. Also check that + element_type matches object_type, since in the bytecode + compilation case element_type may be the actual element type of + the array rather than its declared type. However, if we're doing + indirect dispatch, we can't do the `final' optimization. */ + if (element_type == object_type + && ! flag_indirect_dispatch + && CLASS_FINAL (element_type)) + return build1 (NOP_EXPR, array_type_p, array); + + /* OBJECT might be wrapped by a SAVE_EXPR. */ + if (TREE_CODE (object) == SAVE_EXPR) + source = TREE_OPERAND (object, 0); + else + source = object; + + /* Avoid the check if OBJECT was just loaded from the same array. */ + if (TREE_CODE (source) == ARRAY_REF) + { + tree target; + source = TREE_OPERAND (source, 0); /* COMPONENT_REF. */ + source = TREE_OPERAND (source, 0); /* INDIRECT_REF. */ + source = TREE_OPERAND (source, 0); /* Source array's DECL or SAVE_EXPR. */ + if (TREE_CODE (source) == SAVE_EXPR) + source = TREE_OPERAND (source, 0); + + target = array; + if (TREE_CODE (target) == SAVE_EXPR) + target = TREE_OPERAND (target, 0); + + if (source == target) + return build1 (NOP_EXPR, array_type_p, array); + } + + /* Build an invocation of _Jv_CheckArrayStore */ + check = build_call_nary (void_type_node, + build_address_of (soft_checkarraystore_node), + 2, array, object); + TREE_SIDE_EFFECTS (check) = 1; + + return check; +} + +/* Makes sure that INDEXED_TYPE is appropriate. If not, make it from + ARRAY_NODE. This function is used to retrieve something less vague than + a pointer type when indexing the first dimension of something like [[<t>. + May return a corrected type, if necessary, otherwise INDEXED_TYPE is + return unchanged. */ + +static tree +build_java_check_indexed_type (tree array_node ATTRIBUTE_UNUSED, + tree indexed_type) +{ + /* We used to check to see if ARRAY_NODE really had array type. + However, with the new verifier, this is not necessary, as we know + that the object will be an array of the appropriate type. */ + + return indexed_type; +} + +/* newarray triggers a call to _Jv_NewPrimArray. This function should be + called with an integer code (the type of array to create), and the length + of the array to create. */ + +tree +build_newarray (int atype_value, tree length) +{ + tree type_arg; + + tree prim_type = decode_newarray_type (atype_value); + tree type + = build_java_array_type (prim_type, + host_integerp (length, 0) == INTEGER_CST + ? tree_low_cst (length, 0) : -1); + + /* Pass a reference to the primitive type class and save the runtime + some work. */ + type_arg = build_class_ref (prim_type); + + return build_call_nary (promote_type (type), + build_address_of (soft_newarray_node), + 2, type_arg, length); +} + +/* Generates anewarray from a given CLASS_TYPE. Gets from the stack the size + of the dimension. */ + +tree +build_anewarray (tree class_type, tree length) +{ + tree type + = build_java_array_type (class_type, + host_integerp (length, 0) + ? tree_low_cst (length, 0) : -1); + + return build_call_nary (promote_type (type), + build_address_of (soft_anewarray_node), + 3, + length, + build_class_ref (class_type), + null_pointer_node); +} + +/* Return a node the evaluates 'new TYPE[LENGTH]'. */ + +tree +build_new_array (tree type, tree length) +{ + if (JPRIMITIVE_TYPE_P (type)) + return build_newarray (encode_newarray_type (type), length); + else + return build_anewarray (TREE_TYPE (type), length); +} + +/* Generates a call to _Jv_NewMultiArray. multianewarray expects a + class pointer, a number of dimensions and the matching number of + dimensions. The argument list is NULL terminated. */ + +static void +expand_java_multianewarray (tree class_type, int ndim) +{ + int i; + VEC(tree,gc) *args = NULL; + + VEC_safe_grow (tree, gc, args, 3 + ndim); + + VEC_replace (tree, args, 0, build_class_ref (class_type)); + VEC_replace (tree, args, 1, build_int_cst (NULL_TREE, ndim)); + + for(i = ndim - 1; i >= 0; i-- ) + VEC_replace (tree, args, (unsigned)(2 + i), pop_value (int_type_node)); + + VEC_replace (tree, args, 2 + ndim, null_pointer_node); + + push_value (build_call_vec (promote_type (class_type), + build_address_of (soft_multianewarray_node), + args)); +} + +/* ARRAY[INDEX] <- RHS. build_java_check_indexed_type makes sure that + ARRAY is an array type. May expand some bound checking and NULL + pointer checking. RHS_TYPE_NODE we are going to store. In the case + of the CHAR/BYTE/BOOLEAN SHORT, the type popped of the stack is an + INT. In those cases, we make the conversion. + + if ARRAy is a reference type, the assignment is checked at run-time + to make sure that the RHS can be assigned to the array element + type. It is not necessary to generate this code if ARRAY is final. */ + +static void +expand_java_arraystore (tree rhs_type_node) +{ + tree rhs_node = pop_value ((INTEGRAL_TYPE_P (rhs_type_node) + && TYPE_PRECISION (rhs_type_node) <= 32) ? + int_type_node : rhs_type_node); + tree index = pop_value (int_type_node); + tree array_type, array, temp, access; + + /* If we're processing an `aaload' we might as well just pick + `Object'. */ + if (TREE_CODE (rhs_type_node) == POINTER_TYPE) + { + array_type = build_java_array_type (object_ptr_type_node, -1); + rhs_type_node = object_ptr_type_node; + } + else + array_type = build_java_array_type (rhs_type_node, -1); + + array = pop_value (array_type); + array = build1 (NOP_EXPR, promote_type (array_type), array); + + rhs_type_node = build_java_check_indexed_type (array, rhs_type_node); + + flush_quick_stack (); + + index = save_expr (index); + array = save_expr (array); + + /* We want to perform the bounds check (done by + build_java_arrayaccess) before the type check (done by + build_java_arraystore_check). So, we call build_java_arrayaccess + -- which returns an ARRAY_REF lvalue -- and we then generate code + to stash the address of that lvalue in a temp. Then we call + build_java_arraystore_check, and finally we generate a + MODIFY_EXPR to set the array element. */ + + access = build_java_arrayaccess (array, rhs_type_node, index); + temp = build_decl (input_location, VAR_DECL, NULL_TREE, + build_pointer_type (TREE_TYPE (access))); + java_add_local_var (temp); + java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (temp), + temp, + build_fold_addr_expr (access))); + + if (TREE_CODE (rhs_type_node) == POINTER_TYPE) + { + tree check = build_java_arraystore_check (array, rhs_node); + java_add_stmt (check); + } + + java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (access), + build1 (INDIRECT_REF, TREE_TYPE (access), temp), + rhs_node)); +} + +/* Expand the evaluation of ARRAY[INDEX]. build_java_check_indexed_type makes + sure that LHS is an array type. May expand some bound checking and NULL + pointer checking. + LHS_TYPE_NODE is the type of ARRAY[INDEX]. But in the case of CHAR/BYTE/ + BOOLEAN/SHORT, we push a promoted type back to the stack. +*/ + +static void +expand_java_arrayload (tree lhs_type_node) +{ + tree load_node; + tree index_node = pop_value (int_type_node); + tree array_type; + tree array_node; + + /* If we're processing an `aaload' we might as well just pick + `Object'. */ + if (TREE_CODE (lhs_type_node) == POINTER_TYPE) + { + array_type = build_java_array_type (object_ptr_type_node, -1); + lhs_type_node = object_ptr_type_node; + } + else + array_type = build_java_array_type (lhs_type_node, -1); + array_node = pop_value (array_type); + array_node = build1 (NOP_EXPR, promote_type (array_type), array_node); + + index_node = save_expr (index_node); + array_node = save_expr (array_node); + + lhs_type_node = build_java_check_indexed_type (array_node, + lhs_type_node); + load_node = build_java_arrayaccess (array_node, + lhs_type_node, + index_node); + if (INTEGRAL_TYPE_P (lhs_type_node) && TYPE_PRECISION (lhs_type_node) <= 32) + load_node = fold_build1 (NOP_EXPR, int_type_node, load_node); + push_value (load_node); +} + +/* Expands .length. Makes sure that we deal with and array and may expand + a NULL check on the array object. */ + +static void +expand_java_array_length (void) +{ + tree array = pop_value (ptr_type_node); + tree length = build_java_array_length_access (array); + + push_value (length); +} + +/* Emit code for the call to _Jv_Monitor{Enter,Exit}. CALL can be + either soft_monitorenter_node or soft_monitorexit_node. */ + +static tree +build_java_monitor (tree call, tree object) +{ + return build_call_nary (void_type_node, + build_address_of (call), + 1, object); +} + +/* Emit code for one of the PUSHC instructions. */ + +static void +expand_java_pushc (int ival, tree type) +{ + tree value; + if (type == ptr_type_node && ival == 0) + value = null_pointer_node; + else if (type == int_type_node || type == long_type_node) + value = build_int_cst (type, ival); + else if (type == float_type_node || type == double_type_node) + { + REAL_VALUE_TYPE x; + REAL_VALUE_FROM_INT (x, ival, 0, TYPE_MODE (type)); + value = build_real (type, x); + } + else + gcc_unreachable (); + + push_value (value); +} + +static void +expand_java_return (tree type) +{ + if (type == void_type_node) + java_add_stmt (build1 (RETURN_EXPR, void_type_node, NULL)); + else + { + tree retval = pop_value (type); + tree res = DECL_RESULT (current_function_decl); + retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, retval); + + /* Handle the situation where the native integer type is smaller + than the JVM integer. It can happen for many cross compilers. + The whole if expression just goes away if INT_TYPE_SIZE < 32 + is false. */ + if (INT_TYPE_SIZE < 32 + && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res))) + < GET_MODE_SIZE (TYPE_MODE (type)))) + retval = build1(NOP_EXPR, TREE_TYPE(res), retval); + + TREE_SIDE_EFFECTS (retval) = 1; + java_add_stmt (build1 (RETURN_EXPR, void_type_node, retval)); + } +} + +static void +expand_load_internal (int index, tree type, int pc) +{ + tree copy; + tree var = find_local_variable (index, type, pc); + + /* Now VAR is the VAR_DECL (or PARM_DECL) that we are going to push + on the stack. If there is an assignment to this VAR_DECL between + the stack push and the use, then the wrong code could be + generated. To avoid this we create a new local and copy our + value into it. Then we push this new local on the stack. + Hopefully this all gets optimized out. */ + copy = build_decl (input_location, VAR_DECL, NULL_TREE, type); + if ((INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)) + && TREE_TYPE (copy) != TREE_TYPE (var)) + var = convert (type, var); + java_add_local_var (copy); + java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (var), copy, var)); + + push_value (copy); +} + +tree +build_address_of (tree value) +{ + return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (value)), value); +} + +bool +class_has_finalize_method (tree type) +{ + tree super = CLASSTYPE_SUPER (type); + + if (super == NULL_TREE) + return false; /* Every class with a real finalizer inherits */ + /* from java.lang.Object. */ + else + return HAS_FINALIZER_P (type) || class_has_finalize_method (super); +} + +tree +java_create_object (tree type) +{ + tree alloc_node = (class_has_finalize_method (type) + ? alloc_object_node + : alloc_no_finalizer_node); + + return build_call_nary (promote_type (type), + build_address_of (alloc_node), + 1, build_class_ref (type)); +} + +static void +expand_java_NEW (tree type) +{ + tree alloc_node; + + alloc_node = (class_has_finalize_method (type) ? alloc_object_node + : alloc_no_finalizer_node); + if (! CLASS_LOADED_P (type)) + load_class (type, 1); + safe_layout_class (type); + push_value (build_call_nary (promote_type (type), + build_address_of (alloc_node), + 1, build_class_ref (type))); +} + +/* This returns an expression which will extract the class of an + object. */ + +tree +build_get_class (tree value) +{ + tree class_field = lookup_field (&dtable_type, get_identifier ("class")); + tree vtable_field = lookup_field (&object_type_node, + get_identifier ("vtable")); + tree tmp = build3 (COMPONENT_REF, dtable_ptr_type, + build_java_indirect_ref (object_type_node, value, + flag_check_references), + vtable_field, NULL_TREE); + return build3 (COMPONENT_REF, class_ptr_type, + build1 (INDIRECT_REF, dtable_type, tmp), + class_field, NULL_TREE); +} + +/* This builds the tree representation of the `instanceof' operator. + It tries various tricks to optimize this in cases where types are + known. */ + +tree +build_instanceof (tree value, tree type) +{ + tree expr; + tree itype = TREE_TYPE (TREE_TYPE (soft_instanceof_node)); + tree valtype = TREE_TYPE (TREE_TYPE (value)); + tree valclass = TYPE_NAME (valtype); + tree klass; + + /* When compiling from bytecode, we need to ensure that TYPE has + been loaded. */ + if (CLASS_P (type) && ! CLASS_LOADED_P (type)) + { + load_class (type, 1); + safe_layout_class (type); + if (! TYPE_SIZE (type) || TREE_CODE (TYPE_SIZE (type)) == ERROR_MARK) + return error_mark_node; + } + klass = TYPE_NAME (type); + + if (type == object_type_node || inherits_from_p (valtype, type)) + { + /* Anything except `null' is an instance of Object. Likewise, + if the object is known to be an instance of the class, then + we only need to check for `null'. */ + expr = build2 (NE_EXPR, itype, value, null_pointer_node); + } + else if (flag_verify_invocations + && ! TYPE_ARRAY_P (type) + && ! TYPE_ARRAY_P (valtype) + && DECL_P (klass) && DECL_P (valclass) + && ! CLASS_INTERFACE (valclass) + && ! CLASS_INTERFACE (klass) + && ! inherits_from_p (type, valtype) + && (CLASS_FINAL (klass) + || ! inherits_from_p (valtype, type))) + { + /* The classes are from different branches of the derivation + tree, so we immediately know the answer. */ + expr = boolean_false_node; + } + else if (DECL_P (klass) && CLASS_FINAL (klass)) + { + tree save = save_expr (value); + expr = build3 (COND_EXPR, itype, + build2 (NE_EXPR, boolean_type_node, + save, null_pointer_node), + build2 (EQ_EXPR, itype, + build_get_class (save), + build_class_ref (type)), + boolean_false_node); + } + else + { + expr = build_call_nary (itype, + build_address_of (soft_instanceof_node), + 2, value, build_class_ref (type)); + } + TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (value); + return expr; +} + +static void +expand_java_INSTANCEOF (tree type) +{ + tree value = pop_value (object_ptr_type_node); + value = build_instanceof (value, type); + push_value (value); +} + +static void +expand_java_CHECKCAST (tree type) +{ + tree value = pop_value (ptr_type_node); + value = build_call_nary (promote_type (type), + build_address_of (soft_checkcast_node), + 2, build_class_ref (type), value); + push_value (value); +} + +static void +expand_iinc (unsigned int local_var_index, int ival, int pc) +{ + tree local_var, res; + tree constant_value; + + flush_quick_stack (); + local_var = find_local_variable (local_var_index, int_type_node, pc); + constant_value = build_int_cst (NULL_TREE, ival); + res = fold_build2 (PLUS_EXPR, int_type_node, local_var, constant_value); + java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (local_var), local_var, res)); +} + + +tree +build_java_soft_divmod (enum tree_code op, tree type, tree op1, tree op2) +{ + tree call = NULL; + tree arg1 = convert (type, op1); + tree arg2 = convert (type, op2); + + if (type == int_type_node) + { + switch (op) + { + case TRUNC_DIV_EXPR: + call = soft_idiv_node; + break; + case TRUNC_MOD_EXPR: + call = soft_irem_node; + break; + default: + break; + } + } + else if (type == long_type_node) + { + switch (op) + { + case TRUNC_DIV_EXPR: + call = soft_ldiv_node; + break; + case TRUNC_MOD_EXPR: + call = soft_lrem_node; + break; + default: + break; + } + } + + gcc_assert (call); + call = build_call_nary (type, build_address_of (call), 2, arg1, arg2); + return call; +} + +tree +build_java_binop (enum tree_code op, tree type, tree arg1, tree arg2) +{ + tree mask; + switch (op) + { + case URSHIFT_EXPR: + { + tree u_type = unsigned_type_for (type); + arg1 = convert (u_type, arg1); + arg1 = build_java_binop (RSHIFT_EXPR, u_type, arg1, arg2); + return convert (type, arg1); + } + case LSHIFT_EXPR: + case RSHIFT_EXPR: + mask = build_int_cst (NULL_TREE, + TYPE_PRECISION (TREE_TYPE (arg1)) - 1); + arg2 = fold_build2 (BIT_AND_EXPR, int_type_node, arg2, mask); + break; + + case COMPARE_L_EXPR: /* arg1 > arg2 ? 1 : arg1 == arg2 ? 0 : -1 */ + case COMPARE_G_EXPR: /* arg1 < arg2 ? -1 : arg1 == arg2 ? 0 : 1 */ + arg1 = save_expr (arg1); arg2 = save_expr (arg2); + { + tree ifexp1 = fold_build2 (op == COMPARE_L_EXPR ? GT_EXPR : LT_EXPR, + boolean_type_node, arg1, arg2); + tree ifexp2 = fold_build2 (EQ_EXPR, boolean_type_node, arg1, arg2); + tree second_compare = fold_build3 (COND_EXPR, int_type_node, + ifexp2, integer_zero_node, + op == COMPARE_L_EXPR + ? integer_minus_one_node + : integer_one_node); + return fold_build3 (COND_EXPR, int_type_node, ifexp1, + op == COMPARE_L_EXPR ? integer_one_node + : integer_minus_one_node, + second_compare); + } + case COMPARE_EXPR: + arg1 = save_expr (arg1); arg2 = save_expr (arg2); + { + tree ifexp1 = fold_build2 (LT_EXPR, boolean_type_node, arg1, arg2); + tree ifexp2 = fold_build2 (GT_EXPR, boolean_type_node, arg1, arg2); + tree second_compare = fold_build3 (COND_EXPR, int_type_node, + ifexp2, integer_one_node, + integer_zero_node); + return fold_build3 (COND_EXPR, int_type_node, + ifexp1, integer_minus_one_node, second_compare); + } + case TRUNC_DIV_EXPR: + case TRUNC_MOD_EXPR: + if (TREE_CODE (type) == REAL_TYPE + && op == TRUNC_MOD_EXPR) + { + tree call; + if (type != double_type_node) + { + arg1 = convert (double_type_node, arg1); + arg2 = convert (double_type_node, arg2); + } + call = build_call_nary (double_type_node, + build_address_of (soft_fmod_node), + 2, arg1, arg2); + if (type != double_type_node) + call = convert (type, call); + return call; + } + + if (TREE_CODE (type) == INTEGER_TYPE + && flag_use_divide_subroutine + && ! flag_syntax_only) + return build_java_soft_divmod (op, type, arg1, arg2); + + break; + default: ; + } + return fold_build2 (op, type, arg1, arg2); +} + +static void +expand_java_binop (tree type, enum tree_code op) +{ + tree larg, rarg; + tree ltype = type; + tree rtype = type; + switch (op) + { + case LSHIFT_EXPR: + case RSHIFT_EXPR: + case URSHIFT_EXPR: + rtype = int_type_node; + rarg = pop_value (rtype); + break; + default: + rarg = pop_value (rtype); + } + larg = pop_value (ltype); + push_value (build_java_binop (op, type, larg, rarg)); +} + +/* Lookup the field named NAME in *TYPEP or its super classes. + If not found, return NULL_TREE. + (If the *TYPEP is not found, or if the field reference is + ambiguous, return error_mark_node.) + If found, return the FIELD_DECL, and set *TYPEP to the + class containing the field. */ + +tree +lookup_field (tree *typep, tree name) +{ + if (CLASS_P (*typep) && !CLASS_LOADED_P (*typep)) + { + load_class (*typep, 1); + safe_layout_class (*typep); + if (!TYPE_SIZE (*typep) || TREE_CODE (TYPE_SIZE (*typep)) == ERROR_MARK) + return error_mark_node; + } + do + { + tree field, binfo, base_binfo; + tree save_field; + int i; + + for (field = TYPE_FIELDS (*typep); field; field = DECL_CHAIN (field)) + if (DECL_NAME (field) == name) + return field; + + /* Process implemented interfaces. */ + save_field = NULL_TREE; + for (binfo = TYPE_BINFO (*typep), i = 0; + BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + { + tree t = BINFO_TYPE (base_binfo); + if ((field = lookup_field (&t, name))) + { + if (save_field == field) + continue; + if (save_field == NULL_TREE) + save_field = field; + else + { + tree i1 = DECL_CONTEXT (save_field); + tree i2 = DECL_CONTEXT (field); + error ("reference %qs is ambiguous: appears in interface %qs and interface %qs", + IDENTIFIER_POINTER (name), + IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (i1))), + IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (i2)))); + return error_mark_node; + } + } + } + + if (save_field != NULL_TREE) + return save_field; + + *typep = CLASSTYPE_SUPER (*typep); + } while (*typep); + return NULL_TREE; +} + +/* Look up the field named NAME in object SELF_VALUE, + which has class SELF_CLASS (a non-handle RECORD_TYPE). + SELF_VALUE is NULL_TREE if looking for a static field. */ + +tree +build_field_ref (tree self_value, tree self_class, tree name) +{ + tree base_class = self_class; + tree field_decl = lookup_field (&base_class, name); + if (field_decl == NULL_TREE) + { + error ("field %qs not found", IDENTIFIER_POINTER (name)); + return error_mark_node; + } + if (self_value == NULL_TREE) + { + return build_static_field_ref (field_decl); + } + else + { + tree base_type = promote_type (base_class); + + /* CHECK is true if self_value is not the this pointer. */ + int check = (! (DECL_P (self_value) + && DECL_NAME (self_value) == this_identifier_node)); + + /* Determine whether a field offset from NULL will lie within + Page 0: this is necessary on those GNU/Linux/BSD systems that + trap SEGV to generate NullPointerExceptions. + + We assume that Page 0 will be mapped with NOPERM, and that + memory may be allocated from any other page, so only field + offsets < pagesize are guaranteed to trap. We also assume + the smallest page size we'll encounter is 4k bytes. */ + if (! flag_syntax_only && check && ! flag_check_references + && ! flag_indirect_dispatch) + { + tree field_offset = byte_position (field_decl); + if (! page_size) + page_size = size_int (4096); + check = ! INT_CST_LT_UNSIGNED (field_offset, page_size); + } + + if (base_type != TREE_TYPE (self_value)) + self_value = fold_build1 (NOP_EXPR, base_type, self_value); + if (! flag_syntax_only && flag_indirect_dispatch) + { + tree otable_index + = build_int_cst (NULL_TREE, get_symbol_table_index + (field_decl, NULL_TREE, + &TYPE_OTABLE_METHODS (output_class))); + tree field_offset + = build4 (ARRAY_REF, integer_type_node, + TYPE_OTABLE_DECL (output_class), otable_index, + NULL_TREE, NULL_TREE); + tree address; + + if (DECL_CONTEXT (field_decl) != output_class) + field_offset + = build3 (COND_EXPR, TREE_TYPE (field_offset), + build2 (EQ_EXPR, boolean_type_node, + field_offset, integer_zero_node), + build_call_nary (void_type_node, + build_address_of (soft_nosuchfield_node), + 1, otable_index), + field_offset); + + field_offset = fold (convert (sizetype, field_offset)); + self_value = java_check_reference (self_value, check); + address + = fold_build2 (POINTER_PLUS_EXPR, + TREE_TYPE (self_value), + self_value, field_offset); + address = fold_convert (build_pointer_type (TREE_TYPE (field_decl)), + address); + return fold_build1 (INDIRECT_REF, TREE_TYPE (field_decl), address); + } + + self_value = build_java_indirect_ref (TREE_TYPE (TREE_TYPE (self_value)), + self_value, check); + return fold_build3 (COMPONENT_REF, TREE_TYPE (field_decl), + self_value, field_decl, NULL_TREE); + } +} + +tree +lookup_label (int pc) +{ + tree name; + char buf[32]; + if (pc > highest_label_pc_this_method) + highest_label_pc_this_method = pc; + targetm.asm_out.generate_internal_label (buf, "LJpc=", + start_label_pc_this_method + pc); + name = get_identifier (buf); + if (IDENTIFIER_LOCAL_VALUE (name)) + return IDENTIFIER_LOCAL_VALUE (name); + else + { + /* The type of the address of a label is return_address_type_node. */ + tree decl = create_label_decl (name); + return pushdecl (decl); + } +} + +/* Generate a unique name for the purpose of loops and switches + labels, and try-catch-finally blocks label or temporary variables. */ + +tree +generate_name (void) +{ + static int l_number = 0; + char buff [32]; + targetm.asm_out.generate_internal_label (buff, "LJv", l_number); + l_number++; + return get_identifier (buff); +} + +tree +create_label_decl (tree name) +{ + tree decl; + decl = build_decl (input_location, LABEL_DECL, name, + TREE_TYPE (return_address_type_node)); + DECL_CONTEXT (decl) = current_function_decl; + DECL_IGNORED_P (decl) = 1; + return decl; +} + +/* This maps a bytecode offset (PC) to various flags. */ +char *instruction_bits; + +/* This is a vector of type states for the current method. It is + indexed by PC. Each element is a tree vector holding the type + state at that PC. We only note type states at basic block + boundaries. */ +VEC(tree, gc) *type_states; + +static void +note_label (int current_pc ATTRIBUTE_UNUSED, int target_pc) +{ + lookup_label (target_pc); + instruction_bits [target_pc] |= BCODE_JUMP_TARGET; +} + +/* Emit code to jump to TARGET_PC if VALUE1 CONDITION VALUE2, + where CONDITION is one of one the compare operators. */ + +static void +expand_compare (enum tree_code condition, tree value1, tree value2, + int target_pc) +{ + tree target = lookup_label (target_pc); + tree cond = fold_build2 (condition, boolean_type_node, value1, value2); + java_add_stmt + (build3 (COND_EXPR, void_type_node, java_truthvalue_conversion (cond), + build1 (GOTO_EXPR, void_type_node, target), + build_java_empty_stmt ())); +} + +/* Emit code for a TEST-type opcode. */ + +static void +expand_test (enum tree_code condition, tree type, int target_pc) +{ + tree value1, value2; + flush_quick_stack (); + value1 = pop_value (type); + value2 = (type == ptr_type_node) ? null_pointer_node : integer_zero_node; + expand_compare (condition, value1, value2, target_pc); +} + +/* Emit code for a COND-type opcode. */ + +static void +expand_cond (enum tree_code condition, tree type, int target_pc) +{ + tree value1, value2; + flush_quick_stack (); + /* note: pop values in opposite order */ + value2 = pop_value (type); + value1 = pop_value (type); + /* Maybe should check value1 and value2 for type compatibility ??? */ + expand_compare (condition, value1, value2, target_pc); +} + +static void +expand_java_goto (int target_pc) +{ + tree target_label = lookup_label (target_pc); + flush_quick_stack (); + java_add_stmt (build1 (GOTO_EXPR, void_type_node, target_label)); +} + +static tree +expand_java_switch (tree selector, int default_pc) +{ + tree switch_expr, x; + + flush_quick_stack (); + switch_expr = build3 (SWITCH_EXPR, TREE_TYPE (selector), selector, + NULL_TREE, NULL_TREE); + java_add_stmt (switch_expr); + + x = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE, + create_artificial_label (input_location)); + append_to_statement_list (x, &SWITCH_BODY (switch_expr)); + + x = build1 (GOTO_EXPR, void_type_node, lookup_label (default_pc)); + append_to_statement_list (x, &SWITCH_BODY (switch_expr)); + + return switch_expr; +} + +static void +expand_java_add_case (tree switch_expr, int match, int target_pc) +{ + tree value, x; + + value = build_int_cst (TREE_TYPE (switch_expr), match); + + x = build3 (CASE_LABEL_EXPR, void_type_node, value, NULL_TREE, + create_artificial_label (input_location)); + append_to_statement_list (x, &SWITCH_BODY (switch_expr)); + + x = build1 (GOTO_EXPR, void_type_node, lookup_label (target_pc)); + append_to_statement_list (x, &SWITCH_BODY (switch_expr)); +} + +static VEC(tree,gc) * +pop_arguments (tree method_type) +{ + function_args_iterator fnai; + tree type; + VEC(tree,gc) *args = NULL; + int arity; + + FOREACH_FUNCTION_ARGS (method_type, type, fnai) + { + /* XXX: leaky abstraction. */ + if (type == void_type_node) + break; + + VEC_safe_push (tree, gc, args, type); + } + + arity = VEC_length (tree, args); + + while (arity--) + { + tree arg = pop_value (VEC_index (tree, args, arity)); + + /* We simply cast each argument to its proper type. This is + needed since we lose type information coming out of the + verifier. We also have to do this when we pop an integer + type that must be promoted for the function call. */ + if (TREE_CODE (type) == POINTER_TYPE) + arg = build1 (NOP_EXPR, type, arg); + else if (targetm.calls.promote_prototypes (type) + && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node) + && INTEGRAL_TYPE_P (type)) + arg = convert (integer_type_node, arg); + + VEC_replace (tree, args, arity, arg); + } + + return args; +} + +/* Attach to PTR (a block) the declaration found in ENTRY. */ + +int +attach_init_test_initialization_flags (void **entry, void *ptr) +{ + tree block = (tree)ptr; + struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + + if (block != error_mark_node) + { + if (TREE_CODE (block) == BIND_EXPR) + { + tree body = BIND_EXPR_BODY (block); + DECL_CHAIN (ite->value) = BIND_EXPR_VARS (block); + BIND_EXPR_VARS (block) = ite->value; + body = build2 (COMPOUND_EXPR, void_type_node, + build1 (DECL_EXPR, void_type_node, ite->value), body); + BIND_EXPR_BODY (block) = body; + } + else + { + tree body = BLOCK_SUBBLOCKS (block); + TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block); + BLOCK_EXPR_DECLS (block) = ite->value; + body = build2 (COMPOUND_EXPR, void_type_node, + build1 (DECL_EXPR, void_type_node, ite->value), body); + BLOCK_SUBBLOCKS (block) = body; + } + + } + return true; +} + +/* Build an expression to initialize the class CLAS. + if EXPR is non-NULL, returns an expression to first call the initializer + (if it is needed) and then calls EXPR. */ + +tree +build_class_init (tree clas, tree expr) +{ + tree init; + + /* An optimization: if CLAS is a superclass of the class we're + compiling, we don't need to initialize it. However, if CLAS is + an interface, it won't necessarily be initialized, even if we + implement it. */ + if ((! CLASS_INTERFACE (TYPE_NAME (clas)) + && inherits_from_p (current_class, clas)) + || current_class == clas) + return expr; + + if (always_initialize_class_p) + { + init = build_call_nary (void_type_node, + build_address_of (soft_initclass_node), + 1, build_class_ref (clas)); + TREE_SIDE_EFFECTS (init) = 1; + } + else + { + tree *init_test_decl; + tree decl; + init_test_decl = java_treetreehash_new + (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), clas); + + if (*init_test_decl == NULL) + { + /* Build a declaration and mark it as a flag used to track + static class initializations. */ + decl = build_decl (input_location, VAR_DECL, NULL_TREE, + boolean_type_node); + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + DECL_CONTEXT (decl) = current_function_decl; + DECL_INITIAL (decl) = boolean_false_node; + /* Don't emit any symbolic debugging info for this decl. */ + DECL_IGNORED_P (decl) = 1; + *init_test_decl = decl; + } + + init = build_call_nary (void_type_node, + build_address_of (soft_initclass_node), + 1, build_class_ref (clas)); + TREE_SIDE_EFFECTS (init) = 1; + init = build3 (COND_EXPR, void_type_node, + build2 (EQ_EXPR, boolean_type_node, + *init_test_decl, boolean_false_node), + init, integer_zero_node); + TREE_SIDE_EFFECTS (init) = 1; + init = build2 (COMPOUND_EXPR, TREE_TYPE (expr), init, + build2 (MODIFY_EXPR, boolean_type_node, + *init_test_decl, boolean_true_node)); + TREE_SIDE_EFFECTS (init) = 1; + } + + if (expr != NULL_TREE) + { + expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), init, expr); + TREE_SIDE_EFFECTS (expr) = 1; + return expr; + } + return init; +} + + + +/* Rewrite expensive calls that require stack unwinding at runtime to + cheaper alternatives. The logic here performs these + transformations: + + java.lang.Class.forName("foo") -> java.lang.Class.forName("foo", class$) + java.lang.Class.getClassLoader() -> java.lang.Class.getClassLoader(class$) + +*/ + +typedef struct +{ + const char *classname; + const char *method; + const char *signature; + const char *new_classname; + const char *new_signature; + int flags; + void (*rewrite_arglist) (VEC(tree,gc) **); +} rewrite_rule; + +/* Add __builtin_return_address(0) to the end of an arglist. */ + + +static void +rewrite_arglist_getcaller (VEC(tree,gc) **arglist) +{ + tree retaddr + = build_call_expr (built_in_decls[BUILT_IN_RETURN_ADDRESS], + 1, integer_zero_node); + + DECL_UNINLINABLE (current_function_decl) = 1; + + VEC_safe_push (tree, gc, *arglist, retaddr); +} + +/* Add this.class to the end of an arglist. */ + +static void +rewrite_arglist_getclass (VEC(tree,gc) **arglist) +{ + VEC_safe_push (tree, gc, *arglist, build_class_ref (output_class)); +} + +static rewrite_rule rules[] = + {{"java.lang.Class", "getClassLoader", "()Ljava/lang/ClassLoader;", + "java.lang.Class", "(Ljava/lang/Class;)Ljava/lang/ClassLoader;", + ACC_FINAL|ACC_PRIVATE, rewrite_arglist_getclass}, + + {"java.lang.Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;", + "java.lang.Class", "(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class;", + ACC_FINAL|ACC_PRIVATE|ACC_STATIC, rewrite_arglist_getclass}, + + {"gnu.classpath.VMStackWalker", "getCallingClass", "()Ljava/lang/Class;", + "gnu.classpath.VMStackWalker", "(Lgnu/gcj/RawData;)Ljava/lang/Class;", + ACC_FINAL|ACC_PRIVATE|ACC_STATIC, rewrite_arglist_getcaller}, + + {"gnu.classpath.VMStackWalker", "getCallingClassLoader", + "()Ljava/lang/ClassLoader;", + "gnu.classpath.VMStackWalker", "(Lgnu/gcj/RawData;)Ljava/lang/ClassLoader;", + ACC_FINAL|ACC_PRIVATE|ACC_STATIC, rewrite_arglist_getcaller}, + + {"gnu.java.lang.VMCPStringBuilder", "toString", "([CII)Ljava/lang/String;", + "java.lang.String", "([CII)Ljava/lang/String;", + ACC_FINAL|ACC_PRIVATE|ACC_STATIC, NULL}, + + {NULL, NULL, NULL, NULL, NULL, 0, NULL}}; + +/* True if this method is special, i.e. it's a private method that + should be exported from a DSO. */ + +bool +special_method_p (tree candidate_method) +{ + tree context = DECL_NAME (TYPE_NAME (DECL_CONTEXT (candidate_method))); + tree method = DECL_NAME (candidate_method); + rewrite_rule *p; + + for (p = rules; p->classname; p++) + { + if (get_identifier (p->classname) == context + && get_identifier (p->method) == method) + return true; + } + return false; +} + +/* Scan the rules list for replacements for *METHOD_P and replace the + args accordingly. If the rewrite results in an access to a private + method, update SPECIAL.*/ + +void +maybe_rewrite_invocation (tree *method_p, VEC(tree,gc) **arg_list_p, + tree *method_signature_p, tree *special) +{ + tree context = DECL_NAME (TYPE_NAME (DECL_CONTEXT (*method_p))); + rewrite_rule *p; + *special = NULL_TREE; + + for (p = rules; p->classname; p++) + { + if (get_identifier (p->classname) == context) + { + tree method = DECL_NAME (*method_p); + if (get_identifier (p->method) == method + && get_identifier (p->signature) == *method_signature_p) + { + tree maybe_method; + tree destination_class + = lookup_class (get_identifier (p->new_classname)); + gcc_assert (destination_class); + maybe_method + = lookup_java_method (destination_class, + method, + get_identifier (p->new_signature)); + if (! maybe_method && ! flag_verify_invocations) + { + maybe_method + = add_method (destination_class, p->flags, + method, get_identifier (p->new_signature)); + DECL_EXTERNAL (maybe_method) = 1; + } + *method_p = maybe_method; + gcc_assert (*method_p); + if (p->rewrite_arglist) + p->rewrite_arglist (arg_list_p); + *method_signature_p = get_identifier (p->new_signature); + *special = integer_one_node; + + break; + } + } + } +} + + + +tree +build_known_method_ref (tree method, tree method_type ATTRIBUTE_UNUSED, + tree self_type, tree method_signature ATTRIBUTE_UNUSED, + VEC(tree,gc) *arg_list ATTRIBUTE_UNUSED, tree special) +{ + tree func; + if (is_compiled_class (self_type)) + { + /* With indirect dispatch we have to use indirect calls for all + publicly visible methods or gcc will use PLT indirections + to reach them. We also have to use indirect dispatch for all + external methods. */ + if (! flag_indirect_dispatch + || (! DECL_EXTERNAL (method) && ! TREE_PUBLIC (method))) + { + func = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (method)), + method); + } + else + { + tree table_index + = build_int_cst (NULL_TREE, + (get_symbol_table_index + (method, special, + &TYPE_ATABLE_METHODS (output_class)))); + func + = build4 (ARRAY_REF, + TREE_TYPE (TREE_TYPE (TYPE_ATABLE_DECL (output_class))), + TYPE_ATABLE_DECL (output_class), table_index, + NULL_TREE, NULL_TREE); + } + func = convert (method_ptr_type_node, func); + } + else + { + /* We don't know whether the method has been (statically) compiled. + Compile this code to get a reference to the method's code: + + SELF_TYPE->methods[METHOD_INDEX].ncode + + */ + + int method_index = 0; + tree meth, ref; + + /* The method might actually be declared in some superclass, so + we have to use its class context, not the caller's notion of + where the method is. */ + self_type = DECL_CONTEXT (method); + ref = build_class_ref (self_type); + ref = build1 (INDIRECT_REF, class_type_node, ref); + if (ncode_ident == NULL_TREE) + ncode_ident = get_identifier ("ncode"); + if (methods_ident == NULL_TREE) + methods_ident = get_identifier ("methods"); + ref = build3 (COMPONENT_REF, method_ptr_type_node, ref, + lookup_field (&class_type_node, methods_ident), + NULL_TREE); + for (meth = TYPE_METHODS (self_type); + ; meth = DECL_CHAIN (meth)) + { + if (method == meth) + break; + if (meth == NULL_TREE) + fatal_error ("method '%s' not found in class", + IDENTIFIER_POINTER (DECL_NAME (method))); + method_index++; + } + method_index *= int_size_in_bytes (method_type_node); + ref = fold_build2 (POINTER_PLUS_EXPR, method_ptr_type_node, + ref, size_int (method_index)); + ref = build1 (INDIRECT_REF, method_type_node, ref); + func = build3 (COMPONENT_REF, nativecode_ptr_type_node, + ref, lookup_field (&method_type_node, ncode_ident), + NULL_TREE); + } + return func; +} + +tree +invoke_build_dtable (int is_invoke_interface, VEC(tree,gc) *arg_list) +{ + tree dtable, objectref; + tree saved = save_expr (VEC_index (tree, arg_list, 0)); + + VEC_replace (tree, arg_list, 0, saved); + + /* If we're dealing with interfaces and if the objectref + argument is an array then get the dispatch table of the class + Object rather than the one from the objectref. */ + objectref = (is_invoke_interface + && is_array_type_p (TREE_TYPE (saved)) + ? build_class_ref (object_type_node) : saved); + + if (dtable_ident == NULL_TREE) + dtable_ident = get_identifier ("vtable"); + dtable = build_java_indirect_ref (object_type_node, objectref, + flag_check_references); + dtable = build3 (COMPONENT_REF, dtable_ptr_type, dtable, + lookup_field (&object_type_node, dtable_ident), NULL_TREE); + + return dtable; +} + +/* Determine the index in SYMBOL_TABLE for a reference to the decl + T. If this decl has not been seen before, it will be added to the + [oa]table_methods. If it has, the existing table slot will be + reused. */ + +int +get_symbol_table_index (tree t, tree special, + VEC(method_entry,gc) **symbol_table) +{ + method_entry *e; + unsigned i; + + FOR_EACH_VEC_ELT (method_entry, *symbol_table, i, e) + if (t == e->method && special == e->special) + goto done; + + e = VEC_safe_push (method_entry, gc, *symbol_table, NULL); + e->method = t; + e->special = special; + + done: + return i + 1; +} + +tree +build_invokevirtual (tree dtable, tree method, tree special) +{ + tree func; + tree nativecode_ptr_ptr_type_node + = build_pointer_type (nativecode_ptr_type_node); + tree method_index; + tree otable_index; + + if (flag_indirect_dispatch) + { + gcc_assert (! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method)))); + + otable_index + = build_int_cst (NULL_TREE, get_symbol_table_index + (method, special, + &TYPE_OTABLE_METHODS (output_class))); + method_index = build4 (ARRAY_REF, integer_type_node, + TYPE_OTABLE_DECL (output_class), + otable_index, NULL_TREE, NULL_TREE); + } + else + { + /* We fetch the DECL_VINDEX field directly here, rather than + using get_method_index(). DECL_VINDEX is the true offset + from the vtable base to a method, regrdless of any extra + words inserted at the start of the vtable. */ + method_index = DECL_VINDEX (method); + method_index = size_binop (MULT_EXPR, method_index, + TYPE_SIZE_UNIT (nativecode_ptr_ptr_type_node)); + if (TARGET_VTABLE_USES_DESCRIPTORS) + method_index = size_binop (MULT_EXPR, method_index, + size_int (TARGET_VTABLE_USES_DESCRIPTORS)); + } + + func = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dtable), dtable, + convert (sizetype, method_index)); + + if (TARGET_VTABLE_USES_DESCRIPTORS) + func = build1 (NOP_EXPR, nativecode_ptr_type_node, func); + else + { + func = fold_convert (nativecode_ptr_ptr_type_node, func); + func = build1 (INDIRECT_REF, nativecode_ptr_type_node, func); + } + + return func; +} + +static GTY(()) tree class_ident; +tree +build_invokeinterface (tree dtable, tree method) +{ + tree interface; + tree idx; + + /* We expand invokeinterface here. */ + + if (class_ident == NULL_TREE) + class_ident = get_identifier ("class"); + + dtable = build_java_indirect_ref (dtable_type, dtable, + flag_check_references); + dtable = build3 (COMPONENT_REF, class_ptr_type, dtable, + lookup_field (&dtable_type, class_ident), NULL_TREE); + + interface = DECL_CONTEXT (method); + gcc_assert (CLASS_INTERFACE (TYPE_NAME (interface))); + layout_class_methods (interface); + + if (flag_indirect_dispatch) + { + int itable_index + = 2 * (get_symbol_table_index + (method, NULL_TREE, &TYPE_ITABLE_METHODS (output_class))); + interface + = build4 (ARRAY_REF, + TREE_TYPE (TREE_TYPE (TYPE_ITABLE_DECL (output_class))), + TYPE_ITABLE_DECL (output_class), + build_int_cst (NULL_TREE, itable_index-1), + NULL_TREE, NULL_TREE); + idx + = build4 (ARRAY_REF, + TREE_TYPE (TREE_TYPE (TYPE_ITABLE_DECL (output_class))), + TYPE_ITABLE_DECL (output_class), + build_int_cst (NULL_TREE, itable_index), + NULL_TREE, NULL_TREE); + interface = convert (class_ptr_type, interface); + idx = convert (integer_type_node, idx); + } + else + { + idx = build_int_cst (NULL_TREE, + get_interface_method_index (method, interface)); + interface = build_class_ref (interface); + } + + return build_call_nary (ptr_type_node, + build_address_of (soft_lookupinterfacemethod_node), + 3, dtable, interface, idx); +} + +/* Expand one of the invoke_* opcodes. + OPCODE is the specific opcode. + METHOD_REF_INDEX is an index into the constant pool. + NARGS is the number of arguments, or -1 if not specified. */ + +static void +expand_invoke (int opcode, int method_ref_index, int nargs ATTRIBUTE_UNUSED) +{ + tree method_signature + = COMPONENT_REF_SIGNATURE(¤t_jcf->cpool, method_ref_index); + tree method_name = COMPONENT_REF_NAME (¤t_jcf->cpool, + method_ref_index); + tree self_type + = get_class_constant (current_jcf, + COMPONENT_REF_CLASS_INDEX(¤t_jcf->cpool, + method_ref_index)); + const char *const self_name + = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type))); + tree call, func, method, method_type; + VEC(tree,gc) *arg_list; + tree check = NULL_TREE; + + tree special = NULL_TREE; + + if (! CLASS_LOADED_P (self_type)) + { + load_class (self_type, 1); + safe_layout_class (self_type); + if (TREE_CODE (TYPE_SIZE (self_type)) == ERROR_MARK) + fatal_error ("failed to find class '%s'", self_name); + } + layout_class_methods (self_type); + + if (ID_INIT_P (method_name)) + method = lookup_java_constructor (self_type, method_signature); + else + method = lookup_java_method (self_type, method_name, method_signature); + + /* We've found a method in a class other than the one in which it + was wanted. This can happen if, for instance, we're trying to + compile invokespecial super.equals(). + FIXME: This is a kludge. Rather than nullifying the result, we + should change lookup_java_method() so that it doesn't search the + superclass chain when we're BC-compiling. */ + if (! flag_verify_invocations + && method + && ! TYPE_ARRAY_P (self_type) + && self_type != DECL_CONTEXT (method)) + method = NULL_TREE; + + /* We've found a method in an interface, but this isn't an interface + call. */ + if (opcode != OPCODE_invokeinterface + && method + && (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))) + method = NULL_TREE; + + /* We've found a non-interface method but we are making an + interface call. This can happen if the interface overrides a + method in Object. */ + if (! flag_verify_invocations + && opcode == OPCODE_invokeinterface + && method + && ! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method)))) + method = NULL_TREE; + + if (method == NULL_TREE) + { + if (flag_verify_invocations || ! flag_indirect_dispatch) + { + error ("class '%s' has no method named '%s' matching signature '%s'", + self_name, + IDENTIFIER_POINTER (method_name), + IDENTIFIER_POINTER (method_signature)); + } + else + { + int flags = ACC_PUBLIC; + if (opcode == OPCODE_invokestatic) + flags |= ACC_STATIC; + if (opcode == OPCODE_invokeinterface) + { + flags |= ACC_INTERFACE | ACC_ABSTRACT; + CLASS_INTERFACE (TYPE_NAME (self_type)) = 1; + } + method = add_method (self_type, flags, method_name, + method_signature); + DECL_ARTIFICIAL (method) = 1; + METHOD_DUMMY (method) = 1; + layout_class_method (self_type, NULL, + method, NULL); + } + } + + /* Invoke static can't invoke static/abstract method */ + if (method != NULL_TREE) + { + if (opcode == OPCODE_invokestatic) + { + if (!METHOD_STATIC (method)) + { + error ("invokestatic on non static method"); + method = NULL_TREE; + } + else if (METHOD_ABSTRACT (method)) + { + error ("invokestatic on abstract method"); + method = NULL_TREE; + } + } + else + { + if (METHOD_STATIC (method)) + { + error ("invoke[non-static] on static method"); + method = NULL_TREE; + } + } + } + + if (method == NULL_TREE) + { + /* If we got here, we emitted an error message above. So we + just pop the arguments, push a properly-typed zero, and + continue. */ + method_type = get_type_from_signature (method_signature); + pop_arguments (method_type); + if (opcode != OPCODE_invokestatic) + pop_type (self_type); + method_type = promote_type (TREE_TYPE (method_type)); + push_value (convert (method_type, integer_zero_node)); + return; + } + + method_type = TREE_TYPE (method); + arg_list = pop_arguments (method_type); + flush_quick_stack (); + + maybe_rewrite_invocation (&method, &arg_list, &method_signature, + &special); + + func = NULL_TREE; + if (opcode == OPCODE_invokestatic) + func = build_known_method_ref (method, method_type, self_type, + method_signature, arg_list, special); + else if (opcode == OPCODE_invokespecial + || (opcode == OPCODE_invokevirtual + && (METHOD_PRIVATE (method) + || METHOD_FINAL (method) + || CLASS_FINAL (TYPE_NAME (self_type))))) + { + /* If the object for the method call is null, we throw an + exception. We don't do this if the object is the current + method's `this'. In other cases we just rely on an + optimization pass to eliminate redundant checks. FIXME: + Unfortunately there doesn't seem to be a way to determine + what the current method is right now. + We do omit the check if we're calling <init>. */ + /* We use a SAVE_EXPR here to make sure we only evaluate + the new `self' expression once. */ + tree save_arg = save_expr (VEC_index (tree, arg_list, 0)); + VEC_replace (tree, arg_list, 0, save_arg); + check = java_check_reference (save_arg, ! DECL_INIT_P (method)); + func = build_known_method_ref (method, method_type, self_type, + method_signature, arg_list, special); + } + else + { + tree dtable = invoke_build_dtable (opcode == OPCODE_invokeinterface, + arg_list); + if (opcode == OPCODE_invokevirtual) + func = build_invokevirtual (dtable, method, special); + else + func = build_invokeinterface (dtable, method); + } + + if (TREE_CODE (func) == ADDR_EXPR) + TREE_TYPE (func) = build_pointer_type (method_type); + else + func = build1 (NOP_EXPR, build_pointer_type (method_type), func); + + call = build_call_vec (TREE_TYPE (method_type), func, arg_list); + TREE_SIDE_EFFECTS (call) = 1; + call = check_for_builtin (method, call); + + if (check != NULL_TREE) + { + call = build2 (COMPOUND_EXPR, TREE_TYPE (call), check, call); + TREE_SIDE_EFFECTS (call) = 1; + } + + if (TREE_CODE (TREE_TYPE (method_type)) == VOID_TYPE) + java_add_stmt (call); + else + { + push_value (call); + flush_quick_stack (); + } +} + +/* Create a stub which will be put into the vtable but which will call + a JNI function. */ + +tree +build_jni_stub (tree method) +{ + tree jnifunc, call, body, method_sig, arg_types; + tree jniarg0, jniarg1, jniarg2, jniarg3; + tree jni_func_type, tem; + tree env_var, res_var = NULL_TREE, block; + tree method_args; + tree meth_var; + tree bind; + VEC(tree,gc) *args = NULL; + int args_size = 0; + + tree klass = DECL_CONTEXT (method); + klass = build_class_ref (klass); + + gcc_assert (METHOD_NATIVE (method) && flag_jni); + + DECL_ARTIFICIAL (method) = 1; + DECL_EXTERNAL (method) = 0; + + env_var = build_decl (input_location, + VAR_DECL, get_identifier ("env"), ptr_type_node); + DECL_CONTEXT (env_var) = method; + + if (TREE_TYPE (TREE_TYPE (method)) != void_type_node) + { + res_var = build_decl (input_location, VAR_DECL, get_identifier ("res"), + TREE_TYPE (TREE_TYPE (method))); + DECL_CONTEXT (res_var) = method; + DECL_CHAIN (env_var) = res_var; + } + + method_args = DECL_ARGUMENTS (method); + block = build_block (env_var, NULL_TREE, method_args, NULL_TREE); + TREE_SIDE_EFFECTS (block) = 1; + TREE_TYPE (block) = TREE_TYPE (TREE_TYPE (method)); + + /* Compute the local `env' by calling _Jv_GetJNIEnvNewFrame. */ + body = build2 (MODIFY_EXPR, ptr_type_node, env_var, + build_call_nary (ptr_type_node, + build_address_of (soft_getjnienvnewframe_node), + 1, klass)); + + /* The JNIEnv structure is the first argument to the JNI function. */ + args_size += int_size_in_bytes (TREE_TYPE (env_var)); + VEC_safe_push (tree, gc, args, env_var); + + /* For a static method the second argument is the class. For a + non-static method the second argument is `this'; that is already + available in the argument list. */ + if (METHOD_STATIC (method)) + { + args_size += int_size_in_bytes (TREE_TYPE (klass)); + VEC_safe_push (tree, gc, args, klass); + } + + /* All the arguments to this method become arguments to the + underlying JNI function. If we had to wrap object arguments in a + special way, we would do that here. */ + for (tem = method_args; tem != NULL_TREE; tem = DECL_CHAIN (tem)) + { + int arg_bits = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem))); +#ifdef PARM_BOUNDARY + arg_bits = (((arg_bits + PARM_BOUNDARY - 1) / PARM_BOUNDARY) + * PARM_BOUNDARY); +#endif + args_size += (arg_bits / BITS_PER_UNIT); + + VEC_safe_push (tree, gc, args, tem); + } + arg_types = TYPE_ARG_TYPES (TREE_TYPE (method)); + + /* Argument types for static methods and the JNIEnv structure. + FIXME: Write and use build_function_type_vec to avoid this. */ + if (METHOD_STATIC (method)) + arg_types = tree_cons (NULL_TREE, object_ptr_type_node, arg_types); + arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types); + + /* We call _Jv_LookupJNIMethod to find the actual underlying + function pointer. _Jv_LookupJNIMethod will throw the appropriate + exception if this function is not found at runtime. */ + method_sig = build_java_signature (TREE_TYPE (method)); + jniarg0 = klass; + jniarg1 = build_utf8_ref (DECL_NAME (method)); + jniarg2 = build_utf8_ref (unmangle_classname + (IDENTIFIER_POINTER (method_sig), + IDENTIFIER_LENGTH (method_sig))); + jniarg3 = build_int_cst (NULL_TREE, args_size); + + tem = build_function_type (TREE_TYPE (TREE_TYPE (method)), arg_types); + +#ifdef MODIFY_JNI_METHOD_CALL + tem = MODIFY_JNI_METHOD_CALL (tem); +#endif + + jni_func_type = build_pointer_type (tem); + + /* Use the actual function type, rather than a generic pointer type, + such that this decl keeps the actual pointer type from being + garbage-collected. If it is, we end up using canonical types + with different uids for equivalent function types, and this in + turn causes utf8 identifiers and output order to vary. */ + meth_var = build_decl (input_location, + VAR_DECL, get_identifier ("meth"), jni_func_type); + TREE_STATIC (meth_var) = 1; + TREE_PUBLIC (meth_var) = 0; + DECL_EXTERNAL (meth_var) = 0; + DECL_CONTEXT (meth_var) = method; + DECL_ARTIFICIAL (meth_var) = 1; + DECL_INITIAL (meth_var) = null_pointer_node; + TREE_USED (meth_var) = 1; + chainon (env_var, meth_var); + build_result_decl (method); + + jnifunc = build3 (COND_EXPR, jni_func_type, + build2 (NE_EXPR, boolean_type_node, + meth_var, build_int_cst (TREE_TYPE (meth_var), 0)), + meth_var, + build2 (MODIFY_EXPR, jni_func_type, meth_var, + build1 + (NOP_EXPR, jni_func_type, + build_call_nary (ptr_type_node, + build_address_of + (soft_lookupjnimethod_node), + 4, + jniarg0, jniarg1, + jniarg2, jniarg3)))); + + /* Now we make the actual JNI call via the resulting function + pointer. */ + call = build_call_vec (TREE_TYPE (TREE_TYPE (method)), jnifunc, args); + + /* If the JNI call returned a result, capture it here. If we had to + unwrap JNI object results, we would do that here. */ + if (res_var != NULL_TREE) + { + /* If the call returns an object, it may return a JNI weak + reference, in which case we must unwrap it. */ + if (! JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_TYPE (method)))) + call = build_call_nary (TREE_TYPE (TREE_TYPE (method)), + build_address_of (soft_unwrapjni_node), + 1, call); + call = build2 (MODIFY_EXPR, TREE_TYPE (TREE_TYPE (method)), + res_var, call); + } + + TREE_SIDE_EFFECTS (call) = 1; + + body = build2 (COMPOUND_EXPR, void_type_node, body, call); + TREE_SIDE_EFFECTS (body) = 1; + + /* Now free the environment we allocated. */ + call = build_call_nary (ptr_type_node, + build_address_of (soft_jnipopsystemframe_node), + 1, env_var); + TREE_SIDE_EFFECTS (call) = 1; + body = build2 (COMPOUND_EXPR, void_type_node, body, call); + TREE_SIDE_EFFECTS (body) = 1; + + /* Finally, do the return. */ + if (res_var != NULL_TREE) + { + tree drt; + gcc_assert (DECL_RESULT (method)); + /* Make sure we copy the result variable to the actual + result. We use the type of the DECL_RESULT because it + might be different from the return type of the function: + it might be promoted. */ + drt = TREE_TYPE (DECL_RESULT (method)); + if (drt != TREE_TYPE (res_var)) + res_var = build1 (CONVERT_EXPR, drt, res_var); + res_var = build2 (MODIFY_EXPR, drt, DECL_RESULT (method), res_var); + TREE_SIDE_EFFECTS (res_var) = 1; + } + + body = build2 (COMPOUND_EXPR, void_type_node, body, + build1 (RETURN_EXPR, void_type_node, res_var)); + TREE_SIDE_EFFECTS (body) = 1; + + /* Prepend class initialization for static methods reachable from + other classes. */ + if (METHOD_STATIC (method) + && (! METHOD_PRIVATE (method) + || INNER_CLASS_P (DECL_CONTEXT (method)))) + { + tree init = build_call_expr (soft_initclass_node, 1, + klass); + body = build2 (COMPOUND_EXPR, void_type_node, init, body); + TREE_SIDE_EFFECTS (body) = 1; + } + + bind = build3 (BIND_EXPR, void_type_node, BLOCK_VARS (block), + body, block); + return bind; +} + + +/* Given lvalue EXP, return a volatile expression that references the + same object. */ + +tree +java_modify_addr_for_volatile (tree exp) +{ + tree exp_type = TREE_TYPE (exp); + tree v_type + = build_qualified_type (exp_type, + TYPE_QUALS (exp_type) | TYPE_QUAL_VOLATILE); + tree addr = build_fold_addr_expr (exp); + v_type = build_pointer_type (v_type); + addr = fold_convert (v_type, addr); + exp = build_fold_indirect_ref (addr); + return exp; +} + + +/* Expand an operation to extract from or store into a field. + IS_STATIC is 1 iff the field is static. + IS_PUTTING is 1 for putting into a field; 0 for getting from the field. + FIELD_REF_INDEX is an index into the constant pool. */ + +static void +expand_java_field_op (int is_static, int is_putting, int field_ref_index) +{ + tree self_type + = get_class_constant (current_jcf, + COMPONENT_REF_CLASS_INDEX (¤t_jcf->cpool, + field_ref_index)); + const char *self_name + = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type))); + tree field_name = COMPONENT_REF_NAME (¤t_jcf->cpool, field_ref_index); + tree field_signature = COMPONENT_REF_SIGNATURE (¤t_jcf->cpool, + field_ref_index); + tree field_type = get_type_from_signature (field_signature); + tree new_value = is_putting ? pop_value (field_type) : NULL_TREE; + tree field_ref; + int is_error = 0; + tree original_self_type = self_type; + tree field_decl; + tree modify_expr; + + if (! CLASS_LOADED_P (self_type)) + load_class (self_type, 1); + field_decl = lookup_field (&self_type, field_name); + if (field_decl == error_mark_node) + { + is_error = 1; + } + else if (field_decl == NULL_TREE) + { + if (! flag_verify_invocations) + { + int flags = ACC_PUBLIC; + if (is_static) + flags |= ACC_STATIC; + self_type = original_self_type; + field_decl = add_field (original_self_type, field_name, + field_type, flags); + DECL_ARTIFICIAL (field_decl) = 1; + DECL_IGNORED_P (field_decl) = 1; +#if 0 + /* FIXME: We should be pessimistic about volatility. We + don't know one way or another, but this is safe. + However, doing this has bad effects on code quality. We + need to look at better ways to do this. */ + TREE_THIS_VOLATILE (field_decl) = 1; +#endif + } + else + { + error ("missing field '%s' in '%s'", + IDENTIFIER_POINTER (field_name), self_name); + is_error = 1; + } + } + else if (build_java_signature (TREE_TYPE (field_decl)) != field_signature) + { + error ("mismatching signature for field '%s' in '%s'", + IDENTIFIER_POINTER (field_name), self_name); + is_error = 1; + } + field_ref = is_static ? NULL_TREE : pop_value (self_type); + if (is_error) + { + if (! is_putting) + push_value (convert (field_type, integer_zero_node)); + flush_quick_stack (); + return; + } + + field_ref = build_field_ref (field_ref, self_type, field_name); + if (is_static + && ! flag_indirect_dispatch) + { + tree context = DECL_CONTEXT (field_ref); + if (context != self_type && CLASS_INTERFACE (TYPE_NAME (context))) + field_ref = build_class_init (context, field_ref); + else + field_ref = build_class_init (self_type, field_ref); + } + if (is_putting) + { + flush_quick_stack (); + if (FIELD_FINAL (field_decl)) + { + if (DECL_CONTEXT (field_decl) != current_class) + error ("assignment to final field %q+D not in field%'s class", + field_decl); + /* We used to check for assignments to final fields not + occurring in the class initializer or in a constructor + here. However, this constraint doesn't seem to be + enforced by the JVM. */ + } + + if (TREE_THIS_VOLATILE (field_decl)) + field_ref = java_modify_addr_for_volatile (field_ref); + + modify_expr = build2 (MODIFY_EXPR, TREE_TYPE (field_ref), + field_ref, new_value); + + if (TREE_THIS_VOLATILE (field_decl)) + java_add_stmt + (build_call_expr (built_in_decls[BUILT_IN_SYNCHRONIZE], 0)); + + java_add_stmt (modify_expr); + } + else + { + tree temp = build_decl (input_location, + VAR_DECL, NULL_TREE, TREE_TYPE (field_ref)); + java_add_local_var (temp); + + if (TREE_THIS_VOLATILE (field_decl)) + field_ref = java_modify_addr_for_volatile (field_ref); + + modify_expr + = build2 (MODIFY_EXPR, TREE_TYPE (field_ref), temp, field_ref); + java_add_stmt (modify_expr); + + if (TREE_THIS_VOLATILE (field_decl)) + java_add_stmt + (build_call_expr (built_in_decls[BUILT_IN_SYNCHRONIZE], 0)); + + push_value (temp); + } + TREE_THIS_VOLATILE (field_ref) = TREE_THIS_VOLATILE (field_decl); +} + +static void +load_type_state (int pc) +{ + int i; + tree vec = VEC_index (tree, type_states, pc); + int cur_length = TREE_VEC_LENGTH (vec); + stack_pointer = cur_length - DECL_MAX_LOCALS(current_function_decl); + for (i = 0; i < cur_length; i++) + type_map [i] = TREE_VEC_ELT (vec, i); +} + +/* Go over METHOD's bytecode and note instruction starts in + instruction_bits[]. */ + +void +note_instructions (JCF *jcf, tree method) +{ + int PC; + unsigned char* byte_ops; + long length = DECL_CODE_LENGTH (method); + + int saw_index; + jint INT_temp; + +#undef RET /* Defined by config/i386/i386.h */ +#undef PTR +#define BCODE byte_ops +#define BYTE_type_node byte_type_node +#define SHORT_type_node short_type_node +#define INT_type_node int_type_node +#define LONG_type_node long_type_node +#define CHAR_type_node char_type_node +#define PTR_type_node ptr_type_node +#define FLOAT_type_node float_type_node +#define DOUBLE_type_node double_type_node +#define VOID_type_node void_type_node +#define CONST_INDEX_1 (saw_index = 1, IMMEDIATE_u1) +#define CONST_INDEX_2 (saw_index = 1, IMMEDIATE_u2) +#define VAR_INDEX_1 (saw_index = 1, IMMEDIATE_u1) +#define VAR_INDEX_2 (saw_index = 1, IMMEDIATE_u2) + +#define CHECK_PC_IN_RANGE(PC) ((void)1) /* Already handled by verifier. */ + + JCF_SEEK (jcf, DECL_CODE_OFFSET (method)); + byte_ops = jcf->read_ptr; + instruction_bits = XRESIZEVAR (char, instruction_bits, length + 1); + memset (instruction_bits, 0, length + 1); + type_states = VEC_alloc (tree, gc, length + 1); + VEC_safe_grow_cleared (tree, gc, type_states, length + 1); + + /* This pass figures out which PC can be the targets of jumps. */ + for (PC = 0; PC < length;) + { + int oldpc = PC; /* PC at instruction start. */ + instruction_bits [PC] |= BCODE_INSTRUCTION_START; + switch (byte_ops[PC++]) + { +#define JAVAOP(OPNAME, OPCODE, OPKIND, OPERAND_TYPE, OPERAND_VALUE) \ + case OPCODE: \ + PRE_##OPKIND(OPERAND_TYPE, OPERAND_VALUE); \ + break; + +#define NOTE_LABEL(PC) note_label(oldpc, PC) + +#define PRE_PUSHC(OPERAND_TYPE, OPERAND_VALUE) (void)(OPERAND_VALUE); +#define PRE_LOAD(OPERAND_TYPE, OPERAND_VALUE) (void)(OPERAND_VALUE); +#define PRE_STORE(OPERAND_TYPE, OPERAND_VALUE) (void)(OPERAND_VALUE); +#define PRE_STACK(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define PRE_UNOP(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define PRE_BINOP(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define PRE_CONVERT(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define PRE_CONVERT2(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ + +#define PRE_SPECIAL(OPERAND_TYPE, INSTRUCTION) \ + PRE_SPECIAL_##INSTRUCTION(OPERAND_TYPE) +#define PRE_SPECIAL_IINC(OPERAND_TYPE) \ + ((void) IMMEDIATE_u1, (void) IMMEDIATE_s1) +#define PRE_SPECIAL_ENTER(IGNORE) /* nothing */ +#define PRE_SPECIAL_EXIT(IGNORE) /* nothing */ +#define PRE_SPECIAL_THROW(IGNORE) /* nothing */ +#define PRE_SPECIAL_BREAK(IGNORE) /* nothing */ + +/* two forms of wide instructions */ +#define PRE_SPECIAL_WIDE(IGNORE) \ + { \ + int modified_opcode = IMMEDIATE_u1; \ + if (modified_opcode == OPCODE_iinc) \ + { \ + (void) IMMEDIATE_u2; /* indexbyte1 and indexbyte2 */ \ + (void) IMMEDIATE_s2; /* constbyte1 and constbyte2 */ \ + } \ + else \ + { \ + (void) IMMEDIATE_u2; /* indexbyte1 and indexbyte2 */ \ + } \ + } + +#define PRE_IMPL(IGNORE1, IGNORE2) /* nothing */ + +#define PRE_MONITOR(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ + +#define PRE_RETURN(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define PRE_ARRAY(OPERAND_TYPE, SUBOP) \ + PRE_ARRAY_##SUBOP(OPERAND_TYPE) +#define PRE_ARRAY_LOAD(TYPE) /* nothing */ +#define PRE_ARRAY_STORE(TYPE) /* nothing */ +#define PRE_ARRAY_LENGTH(TYPE) /* nothing */ +#define PRE_ARRAY_NEW(TYPE) PRE_ARRAY_NEW_##TYPE +#define PRE_ARRAY_NEW_NUM ((void) IMMEDIATE_u1) +#define PRE_ARRAY_NEW_PTR ((void) IMMEDIATE_u2) +#define PRE_ARRAY_NEW_MULTI ((void) IMMEDIATE_u2, (void) IMMEDIATE_u1) + +#define PRE_TEST(OPERAND_TYPE, OPERAND_VALUE) NOTE_LABEL (oldpc+IMMEDIATE_s2) +#define PRE_COND(OPERAND_TYPE, OPERAND_VALUE) NOTE_LABEL (oldpc+IMMEDIATE_s2) +#define PRE_BRANCH(OPERAND_TYPE, OPERAND_VALUE) \ + saw_index = 0; INT_temp = (OPERAND_VALUE); \ + if (!saw_index) NOTE_LABEL(oldpc + INT_temp); +#define PRE_JSR(OPERAND_TYPE, OPERAND_VALUE) \ + saw_index = 0; INT_temp = (OPERAND_VALUE); \ + NOTE_LABEL (PC); \ + if (!saw_index) NOTE_LABEL(oldpc + INT_temp); + +#define PRE_RET(OPERAND_TYPE, OPERAND_VALUE) (void)(OPERAND_VALUE) + +#define PRE_SWITCH(OPERAND_TYPE, TABLE_OR_LOOKUP) \ + PC = (PC + 3) / 4 * 4; PRE_##TABLE_OR_LOOKUP##_SWITCH + +#define PRE_LOOKUP_SWITCH \ + { jint default_offset = IMMEDIATE_s4; jint npairs = IMMEDIATE_s4; \ + NOTE_LABEL (default_offset+oldpc); \ + if (npairs >= 0) \ + while (--npairs >= 0) { \ + jint match ATTRIBUTE_UNUSED = IMMEDIATE_s4; \ + jint offset = IMMEDIATE_s4; \ + NOTE_LABEL (offset+oldpc); } \ + } + +#define PRE_TABLE_SWITCH \ + { jint default_offset = IMMEDIATE_s4; \ + jint low = IMMEDIATE_s4; jint high = IMMEDIATE_s4; \ + NOTE_LABEL (default_offset+oldpc); \ + if (low <= high) \ + while (low++ <= high) { \ + jint offset = IMMEDIATE_s4; \ + NOTE_LABEL (offset+oldpc); } \ + } + +#define PRE_FIELD(MAYBE_STATIC, PUT_OR_GET) (void)(IMMEDIATE_u2); +#define PRE_OBJECT(MAYBE_STATIC, PUT_OR_GET) (void)(IMMEDIATE_u2); +#define PRE_INVOKE(MAYBE_STATIC, IS_INTERFACE) \ + (void)(IMMEDIATE_u2); \ + PC += 2 * IS_INTERFACE /* for invokeinterface */; + +#include "javaop.def" +#undef JAVAOP + } + } /* for */ +} + +void +expand_byte_code (JCF *jcf, tree method) +{ + int PC; + int i; + const unsigned char *linenumber_pointer; + int dead_code_index = -1; + unsigned char* byte_ops; + long length = DECL_CODE_LENGTH (method); + location_t max_location = input_location; + + stack_pointer = 0; + JCF_SEEK (jcf, DECL_CODE_OFFSET (method)); + byte_ops = jcf->read_ptr; + + /* We make an initial pass of the line number table, to note + which instructions have associated line number entries. */ + linenumber_pointer = linenumber_table; + for (i = 0; i < linenumber_count; i++) + { + int pc = GET_u2 (linenumber_pointer); + linenumber_pointer += 4; + if (pc >= length) + warning (0, "invalid PC in line number table"); + else + { + if ((instruction_bits[pc] & BCODE_HAS_LINENUMBER) != 0) + instruction_bits[pc] |= BCODE_HAS_MULTI_LINENUMBERS; + instruction_bits[pc] |= BCODE_HAS_LINENUMBER; + } + } + + if (! verify_jvm_instructions_new (jcf, byte_ops, length)) + return; + + promote_arguments (); + cache_this_class_ref (method); + cache_cpool_data_ref (); + + /* Translate bytecodes. */ + linenumber_pointer = linenumber_table; + for (PC = 0; PC < length;) + { + if ((instruction_bits [PC] & BCODE_TARGET) != 0 || PC == 0) + { + tree label = lookup_label (PC); + flush_quick_stack (); + if ((instruction_bits [PC] & BCODE_TARGET) != 0) + java_add_stmt (build1 (LABEL_EXPR, void_type_node, label)); + if ((instruction_bits[PC] & BCODE_VERIFIED) != 0) + load_type_state (PC); + } + + if (! (instruction_bits [PC] & BCODE_VERIFIED)) + { + if (dead_code_index == -1) + { + /* This is the start of a region of unreachable bytecodes. + They still need to be processed in order for EH ranges + to get handled correctly. However, we can simply + replace these bytecodes with nops. */ + dead_code_index = PC; + } + + /* Turn this bytecode into a nop. */ + byte_ops[PC] = 0x0; + } + else + { + if (dead_code_index != -1) + { + /* We've just reached the end of a region of dead code. */ + if (extra_warnings) + warning (0, "unreachable bytecode from %d to before %d", + dead_code_index, PC); + dead_code_index = -1; + } + } + + /* Handle possible line number entry for this PC. + + This code handles out-of-order and multiple linenumbers per PC, + but is optimized for the case of line numbers increasing + monotonically with PC. */ + if ((instruction_bits[PC] & BCODE_HAS_LINENUMBER) != 0) + { + if ((instruction_bits[PC] & BCODE_HAS_MULTI_LINENUMBERS) != 0 + || GET_u2 (linenumber_pointer) != PC) + linenumber_pointer = linenumber_table; + while (linenumber_pointer < linenumber_table + linenumber_count * 4) + { + int pc = GET_u2 (linenumber_pointer); + linenumber_pointer += 4; + if (pc == PC) + { + int line = GET_u2 (linenumber_pointer - 2); + input_location = linemap_line_start (line_table, line, 1); + if (input_location > max_location) + max_location = input_location; + if (!(instruction_bits[PC] & BCODE_HAS_MULTI_LINENUMBERS)) + break; + } + } + } + maybe_pushlevels (PC); + PC = process_jvm_instruction (PC, byte_ops, length); + maybe_poplevels (PC); + } /* for */ + + uncache_this_class_ref (method); + + if (dead_code_index != -1) + { + /* We've just reached the end of a region of dead code. */ + if (extra_warnings) + warning (0, "unreachable bytecode from %d to the end of the method", + dead_code_index); + } + + DECL_FUNCTION_LAST_LINE (method) = max_location; +} + +static void +java_push_constant_from_pool (JCF *jcf, int index) +{ + tree c; + if (JPOOL_TAG (jcf, index) == CONSTANT_String) + { + tree name; + name = get_name_constant (jcf, JPOOL_USHORT1 (jcf, index)); + index = alloc_name_constant (CONSTANT_String, name); + c = build_ref_from_constant_pool (index); + c = convert (promote_type (string_type_node), c); + } + else if (JPOOL_TAG (jcf, index) == CONSTANT_Class + || JPOOL_TAG (jcf, index) == CONSTANT_ResolvedClass) + { + tree record = get_class_constant (jcf, index); + c = build_class_ref (record); + } + else + c = get_constant (jcf, index); + push_value (c); +} + +int +process_jvm_instruction (int PC, const unsigned char* byte_ops, + long length ATTRIBUTE_UNUSED) +{ + const char *opname; /* Temporary ??? */ + int oldpc = PC; /* PC at instruction start. */ + + /* If the instruction is at the beginning of an exception handler, + replace the top of the stack with the thrown object reference. */ + if (instruction_bits [PC] & BCODE_EXCEPTION_TARGET) + { + /* Note that the verifier will not emit a type map at all for + dead exception handlers. In this case we just ignore the + situation. */ + if ((instruction_bits[PC] & BCODE_VERIFIED) != 0) + { + tree type = pop_type (promote_type (throwable_type_node)); + push_value (build_exception_object_ref (type)); + } + } + + switch (byte_ops[PC++]) + { +#define JAVAOP(OPNAME, OPCODE, OPKIND, OPERAND_TYPE, OPERAND_VALUE) \ + case OPCODE: \ + opname = #OPNAME; \ + OPKIND(OPERAND_TYPE, OPERAND_VALUE); \ + break; + +#define RET(OPERAND_TYPE, OPERAND_VALUE) \ + { \ + int saw_index = 0; \ + int index = OPERAND_VALUE; \ + (void) saw_index; /* Avoid set but not used warning. */ \ + build_java_ret \ + (find_local_variable (index, return_address_type_node, oldpc)); \ + } + +#define JSR(OPERAND_TYPE, OPERAND_VALUE) \ + { \ + /* OPERAND_VALUE may have side-effects on PC */ \ + int opvalue = OPERAND_VALUE; \ + build_java_jsr (oldpc + opvalue, PC); \ + } + +/* Push a constant onto the stack. */ +#define PUSHC(OPERAND_TYPE, OPERAND_VALUE) \ + { int saw_index = 0; int ival = (OPERAND_VALUE); \ + if (saw_index) java_push_constant_from_pool (current_jcf, ival); \ + else expand_java_pushc (ival, OPERAND_TYPE##_type_node); } + +/* internal macro added for use by the WIDE case */ +#define LOAD_INTERNAL(OPTYPE, OPVALUE) \ + expand_load_internal (OPVALUE, type_map[OPVALUE], oldpc); + +/* Push local variable onto the opcode stack. */ +#define LOAD(OPERAND_TYPE, OPERAND_VALUE) \ + { \ + /* have to do this since OPERAND_VALUE may have side-effects */ \ + int opvalue = OPERAND_VALUE; \ + LOAD_INTERNAL(OPERAND_TYPE##_type_node, opvalue); \ + } + +#define RETURN(OPERAND_TYPE, OPERAND_VALUE) \ + expand_java_return (OPERAND_TYPE##_type_node) + +#define REM_EXPR TRUNC_MOD_EXPR +#define BINOP(OPERAND_TYPE, OPERAND_VALUE) \ + expand_java_binop (OPERAND_TYPE##_type_node, OPERAND_VALUE##_EXPR) + +#define FIELD(IS_STATIC, IS_PUT) \ + expand_java_field_op (IS_STATIC, IS_PUT, IMMEDIATE_u2) + +#define TEST(OPERAND_TYPE, CONDITION) \ + expand_test (CONDITION##_EXPR, OPERAND_TYPE##_type_node, oldpc+IMMEDIATE_s2) + +#define COND(OPERAND_TYPE, CONDITION) \ + expand_cond (CONDITION##_EXPR, OPERAND_TYPE##_type_node, oldpc+IMMEDIATE_s2) + +#define BRANCH(OPERAND_TYPE, OPERAND_VALUE) \ + BRANCH_##OPERAND_TYPE (OPERAND_VALUE) + +#define BRANCH_GOTO(OPERAND_VALUE) \ + expand_java_goto (oldpc + OPERAND_VALUE) + +#define BRANCH_CALL(OPERAND_VALUE) \ + expand_java_call (oldpc + OPERAND_VALUE, oldpc) + +#if 0 +#define BRANCH_RETURN(OPERAND_VALUE) \ + { \ + tree type = OPERAND_TYPE##_type_node; \ + tree value = find_local_variable (OPERAND_VALUE, type, oldpc); \ + expand_java_ret (value); \ + } +#endif + +#define NOT_IMPL(OPERAND_TYPE, OPERAND_VALUE) \ + fprintf (stderr, "%3d: %s ", oldpc, opname); \ + fprintf (stderr, "(not implemented)\n") +#define NOT_IMPL1(OPERAND_VALUE) \ + fprintf (stderr, "%3d: %s ", oldpc, opname); \ + fprintf (stderr, "(not implemented)\n") + +#define BRANCH_RETURN(OPERAND_VALUE) NOT_IMPL1(OPERAND_VALUE) + +#define STACK(SUBOP, COUNT) STACK_##SUBOP (COUNT) + +#define STACK_POP(COUNT) java_stack_pop (COUNT) + +#define STACK_SWAP(COUNT) java_stack_swap() + +#define STACK_DUP(COUNT) java_stack_dup (COUNT, 0) +#define STACK_DUPx1(COUNT) java_stack_dup (COUNT, 1) +#define STACK_DUPx2(COUNT) java_stack_dup (COUNT, 2) + +#define SWITCH(OPERAND_TYPE, TABLE_OR_LOOKUP) \ + PC = (PC + 3) / 4 * 4; TABLE_OR_LOOKUP##_SWITCH + +#define LOOKUP_SWITCH \ + { jint default_offset = IMMEDIATE_s4; jint npairs = IMMEDIATE_s4; \ + tree selector = pop_value (INT_type_node); \ + tree switch_expr = expand_java_switch (selector, oldpc + default_offset); \ + while (--npairs >= 0) \ + { \ + jint match = IMMEDIATE_s4; jint offset = IMMEDIATE_s4; \ + expand_java_add_case (switch_expr, match, oldpc + offset); \ + } \ + } + +#define TABLE_SWITCH \ + { jint default_offset = IMMEDIATE_s4; \ + jint low = IMMEDIATE_s4; jint high = IMMEDIATE_s4; \ + tree selector = pop_value (INT_type_node); \ + tree switch_expr = expand_java_switch (selector, oldpc + default_offset); \ + for (; low <= high; low++) \ + { \ + jint offset = IMMEDIATE_s4; \ + expand_java_add_case (switch_expr, low, oldpc + offset); \ + } \ + } + +#define INVOKE(MAYBE_STATIC, IS_INTERFACE) \ + { int opcode = byte_ops[PC-1]; \ + int method_ref_index = IMMEDIATE_u2; \ + int nargs; \ + if (IS_INTERFACE) { nargs = IMMEDIATE_u1; (void) IMMEDIATE_u1; } \ + else nargs = -1; \ + expand_invoke (opcode, method_ref_index, nargs); \ + } + +/* Handle new, checkcast, instanceof */ +#define OBJECT(TYPE, OP) \ + expand_java_##OP (get_class_constant (current_jcf, IMMEDIATE_u2)) + +#define ARRAY(OPERAND_TYPE, SUBOP) ARRAY_##SUBOP(OPERAND_TYPE) + +#define ARRAY_LOAD(OPERAND_TYPE) \ + { \ + expand_java_arrayload( OPERAND_TYPE##_type_node ); \ + } + +#define ARRAY_STORE(OPERAND_TYPE) \ + { \ + expand_java_arraystore( OPERAND_TYPE##_type_node ); \ + } + +#define ARRAY_LENGTH(OPERAND_TYPE) expand_java_array_length(); +#define ARRAY_NEW(OPERAND_TYPE) ARRAY_NEW_##OPERAND_TYPE() +#define ARRAY_NEW_PTR() \ + push_value (build_anewarray (get_class_constant (current_jcf, \ + IMMEDIATE_u2), \ + pop_value (int_type_node))); +#define ARRAY_NEW_NUM() \ + { \ + int atype = IMMEDIATE_u1; \ + push_value (build_newarray (atype, pop_value (int_type_node)));\ + } +#define ARRAY_NEW_MULTI() \ + { \ + tree klass = get_class_constant (current_jcf, IMMEDIATE_u2 ); \ + int ndims = IMMEDIATE_u1; \ + expand_java_multianewarray( klass, ndims ); \ + } + +#define UNOP(OPERAND_TYPE, OPERAND_VALUE) \ + push_value (fold_build1 (NEGATE_EXPR, OPERAND_TYPE##_type_node, \ + pop_value (OPERAND_TYPE##_type_node))); + +#define CONVERT2(FROM_TYPE, TO_TYPE) \ + { \ + push_value (build1 (NOP_EXPR, int_type_node, \ + (convert (TO_TYPE##_type_node, \ + pop_value (FROM_TYPE##_type_node))))); \ + } + +#define CONVERT(FROM_TYPE, TO_TYPE) \ + { \ + push_value (convert (TO_TYPE##_type_node, \ + pop_value (FROM_TYPE##_type_node))); \ + } + +/* internal macro added for use by the WIDE case + Added TREE_TYPE (decl) assignment, apbianco */ +#define STORE_INTERNAL(OPTYPE, OPVALUE) \ + { \ + tree decl, value; \ + int index = OPVALUE; \ + tree type = OPTYPE; \ + value = pop_value (type); \ + type = TREE_TYPE (value); \ + decl = find_local_variable (index, type, oldpc); \ + set_local_type (index, type); \ + java_add_stmt (build2 (MODIFY_EXPR, type, decl, value)); \ + } + +#define STORE(OPERAND_TYPE, OPERAND_VALUE) \ + { \ + /* have to do this since OPERAND_VALUE may have side-effects */ \ + int opvalue = OPERAND_VALUE; \ + STORE_INTERNAL(OPERAND_TYPE##_type_node, opvalue); \ + } + +#define SPECIAL(OPERAND_TYPE, INSTRUCTION) \ + SPECIAL_##INSTRUCTION(OPERAND_TYPE) + +#define SPECIAL_ENTER(IGNORED) MONITOR_OPERATION (soft_monitorenter_node) +#define SPECIAL_EXIT(IGNORED) MONITOR_OPERATION (soft_monitorexit_node) + +#define MONITOR_OPERATION(call) \ + { \ + tree o = pop_value (ptr_type_node); \ + tree c; \ + flush_quick_stack (); \ + c = build_java_monitor (call, o); \ + TREE_SIDE_EFFECTS (c) = 1; \ + java_add_stmt (c); \ + } + +#define SPECIAL_IINC(IGNORED) \ + { \ + unsigned int local_var_index = IMMEDIATE_u1; \ + int ival = IMMEDIATE_s1; \ + expand_iinc(local_var_index, ival, oldpc); \ + } + +#define SPECIAL_WIDE(IGNORED) \ + { \ + int modified_opcode = IMMEDIATE_u1; \ + unsigned int local_var_index = IMMEDIATE_u2; \ + switch (modified_opcode) \ + { \ + case OPCODE_iinc: \ + { \ + int ival = IMMEDIATE_s2; \ + expand_iinc (local_var_index, ival, oldpc); \ + break; \ + } \ + case OPCODE_iload: \ + case OPCODE_lload: \ + case OPCODE_fload: \ + case OPCODE_dload: \ + case OPCODE_aload: \ + { \ + /* duplicate code from LOAD macro */ \ + LOAD_INTERNAL(operand_type[modified_opcode], local_var_index); \ + break; \ + } \ + case OPCODE_istore: \ + case OPCODE_lstore: \ + case OPCODE_fstore: \ + case OPCODE_dstore: \ + case OPCODE_astore: \ + { \ + STORE_INTERNAL(operand_type[modified_opcode], local_var_index); \ + break; \ + } \ + default: \ + error ("unrecogized wide sub-instruction"); \ + } \ + } + +#define SPECIAL_THROW(IGNORED) \ + build_java_athrow (pop_value (throwable_type_node)) + +#define SPECIAL_BREAK NOT_IMPL1 +#define IMPL NOT_IMPL + +#include "javaop.def" +#undef JAVAOP + default: + fprintf (stderr, "%3d: unknown(%3d)\n", oldpc, byte_ops[PC]); + } + return PC; +} + +/* Return the opcode at PC in the code section pointed to by + CODE_OFFSET. */ + +static unsigned char +peek_opcode_at_pc (JCF *jcf, int code_offset, int pc) +{ + unsigned char opcode; + long absolute_offset = (long)JCF_TELL (jcf); + + JCF_SEEK (jcf, code_offset); + opcode = jcf->read_ptr [pc]; + JCF_SEEK (jcf, absolute_offset); + return opcode; +} + +/* Some bytecode compilers are emitting accurate LocalVariableTable + attributes. Here's an example: + + PC <t>store_<n> + PC+1 ... + + Attribute "LocalVariableTable" + slot #<n>: ... (PC: PC+1 length: L) + + This is accurate because the local in slot <n> really exists after + the opcode at PC is executed, hence from PC+1 to PC+1+L. + + This procedure recognizes this situation and extends the live range + of the local in SLOT to START_PC-1 or START_PC-2 (depending on the + length of the store instruction.) + + This function is used by `give_name_to_locals' so that a local's + DECL features a DECL_LOCAL_START_PC such that the first related + store operation will use DECL as a destination, not an unrelated + temporary created for the occasion. + + This function uses a global (instruction_bits) `note_instructions' should + have allocated and filled properly. */ + +int +maybe_adjust_start_pc (struct JCF *jcf, int code_offset, + int start_pc, int slot) +{ + int first, index, opcode; + int pc, insn_pc; + int wide_found = 0; + + if (!start_pc) + return start_pc; + + first = index = -1; + + /* Find last previous instruction and remember it */ + for (pc = start_pc-1; pc; pc--) + if (instruction_bits [pc] & BCODE_INSTRUCTION_START) + break; + insn_pc = pc; + + /* Retrieve the instruction, handle `wide'. */ + opcode = (int) peek_opcode_at_pc (jcf, code_offset, pc++); + if (opcode == OPCODE_wide) + { + wide_found = 1; + opcode = (int) peek_opcode_at_pc (jcf, code_offset, pc++); + } + + switch (opcode) + { + case OPCODE_astore_0: + case OPCODE_astore_1: + case OPCODE_astore_2: + case OPCODE_astore_3: + first = OPCODE_astore_0; + break; + + case OPCODE_istore_0: + case OPCODE_istore_1: + case OPCODE_istore_2: + case OPCODE_istore_3: + first = OPCODE_istore_0; + break; + + case OPCODE_lstore_0: + case OPCODE_lstore_1: + case OPCODE_lstore_2: + case OPCODE_lstore_3: + first = OPCODE_lstore_0; + break; + + case OPCODE_fstore_0: + case OPCODE_fstore_1: + case OPCODE_fstore_2: + case OPCODE_fstore_3: + first = OPCODE_fstore_0; + break; + + case OPCODE_dstore_0: + case OPCODE_dstore_1: + case OPCODE_dstore_2: + case OPCODE_dstore_3: + first = OPCODE_dstore_0; + break; + + case OPCODE_astore: + case OPCODE_istore: + case OPCODE_lstore: + case OPCODE_fstore: + case OPCODE_dstore: + index = peek_opcode_at_pc (jcf, code_offset, pc); + if (wide_found) + { + int other = peek_opcode_at_pc (jcf, code_offset, ++pc); + index = (other << 8) + index; + } + break; + } + + /* Now we decide: first >0 means we have a <t>store_<n>, index >0 + means we have a <t>store. */ + if ((first > 0 && opcode - first == slot) || (index > 0 && index == slot)) + start_pc = insn_pc; + + return start_pc; +} + +/* Force the (direct) sub-operands of NODE to be evaluated in left-to-right + order, as specified by Java Language Specification. + + The problem is that while expand_expr will evaluate its sub-operands in + left-to-right order, for variables it will just return an rtx (i.e. + an lvalue) for the variable (rather than an rvalue). So it is possible + that a later sub-operand will change the register, and when the + actual operation is done, it will use the new value, when it should + have used the original value. + + We fix this by using save_expr. This forces the sub-operand to be + copied into a fresh virtual register, + + For method invocation, we modify the arguments so that a + left-to-right order evaluation is performed. Saved expressions + will, in CALL_EXPR order, be reused when the call will be expanded. + + We also promote outgoing args if needed. */ + +tree +force_evaluation_order (tree node) +{ + if (flag_syntax_only) + return node; + if (TREE_CODE (node) == CALL_EXPR + || (TREE_CODE (node) == COMPOUND_EXPR + && TREE_CODE (TREE_OPERAND (node, 0)) == CALL_EXPR + && TREE_CODE (TREE_OPERAND (node, 1)) == SAVE_EXPR)) + { + tree call, cmp; + int i, nargs; + + /* Account for wrapped around ctors. */ + if (TREE_CODE (node) == COMPOUND_EXPR) + call = TREE_OPERAND (node, 0); + else + call = node; + + nargs = call_expr_nargs (call); + + /* This reverses the evaluation order. This is a desired effect. */ + for (i = 0, cmp = NULL_TREE; i < nargs; i++) + { + tree arg = CALL_EXPR_ARG (call, i); + /* Promote types smaller than integer. This is required by + some ABIs. */ + tree type = TREE_TYPE (arg); + tree saved; + if (targetm.calls.promote_prototypes (type) + && INTEGRAL_TYPE_P (type) + && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), + TYPE_SIZE (integer_type_node))) + arg = fold_convert (integer_type_node, arg); + + saved = save_expr (force_evaluation_order (arg)); + cmp = (cmp == NULL_TREE ? saved : + build2 (COMPOUND_EXPR, void_type_node, cmp, saved)); + + CALL_EXPR_ARG (call, i) = saved; + } + + if (cmp && TREE_CODE (cmp) == COMPOUND_EXPR) + TREE_SIDE_EFFECTS (cmp) = 1; + + if (cmp) + { + cmp = build2 (COMPOUND_EXPR, TREE_TYPE (node), cmp, node); + if (TREE_TYPE (cmp) != void_type_node) + cmp = save_expr (cmp); + TREE_SIDE_EFFECTS (cmp) = 1; + node = cmp; + } + } + return node; +} + +/* Build a node to represent empty statements and blocks. */ + +tree +build_java_empty_stmt (void) +{ + tree t = build_empty_stmt (input_location); + return t; +} + +/* Promote all args of integral type before generating any code. */ + +static void +promote_arguments (void) +{ + int i; + tree arg; + for (arg = DECL_ARGUMENTS (current_function_decl), i = 0; + arg != NULL_TREE; arg = DECL_CHAIN (arg), i++) + { + tree arg_type = TREE_TYPE (arg); + if (INTEGRAL_TYPE_P (arg_type) + && TYPE_PRECISION (arg_type) < 32) + { + tree copy = find_local_variable (i, integer_type_node, -1); + java_add_stmt (build2 (MODIFY_EXPR, integer_type_node, + copy, + fold_convert (integer_type_node, arg))); + } + if (TYPE_IS_WIDE (arg_type)) + i++; + } +} + +/* Create a local variable that points to the constant pool. */ + +static void +cache_cpool_data_ref (void) +{ + if (optimize) + { + tree cpool; + tree d = build_constant_data_ref (flag_indirect_classes); + tree cpool_ptr = build_decl (input_location, VAR_DECL, NULL_TREE, + build_pointer_type (TREE_TYPE (d))); + java_add_local_var (cpool_ptr); + TREE_CONSTANT (cpool_ptr) = 1; + + java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (cpool_ptr), + cpool_ptr, build_address_of (d))); + cpool = build1 (INDIRECT_REF, TREE_TYPE (d), cpool_ptr); + TREE_THIS_NOTRAP (cpool) = 1; + TYPE_CPOOL_DATA_REF (output_class) = cpool; + } +} + +#include "gt-java-expr.h" diff --git a/gcc/java/gcj.texi b/gcc/java/gcj.texi new file mode 100644 index 000000000..01acf4344 --- /dev/null +++ b/gcc/java/gcj.texi @@ -0,0 +1,2734 @@ +\input texinfo @c -*-texinfo-*- +@setfilename gcj.info +@settitle Guide to GNU gcj + +@c Merge the standard indexes into a single one. +@syncodeindex fn cp +@syncodeindex vr cp +@syncodeindex ky cp +@syncodeindex pg cp +@syncodeindex tp cp + +@include gcc-common.texi + +@c Note: When reading this manual you'll find lots of strange +@c circumlocutions like ``compiler for the Java language''. +@c This is necessary due to Sun's restrictions on the use of +@c the word ``Java'. + +@c When this manual is copyrighted. +@set copyrights-gcj 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 + +@copying +@c man begin COPYRIGHT +Copyright @copyright{} @value{copyrights-gcj} Free Software Foundation, Inc. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, the Front-Cover Texts being (a) (see below), and +with the Back-Cover Texts being (b) (see below). +A copy of the license is included in the +@c man end +section entitled ``GNU Free Documentation License''. +@ignore +@c man begin COPYRIGHT +man page gfdl(7). +@c man end +@end ignore + +@c man begin COPYRIGHT + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. +@c man end +@end copying + +@ifinfo +@format +@dircategory Software development +@direntry +* Gcj: (gcj). Ahead-of-time compiler for the Java language +@end direntry + +@dircategory Individual utilities +@direntry +* jcf-dump: (gcj)Invoking jcf-dump. + Print information about Java class files +* gij: (gcj)Invoking gij. GNU interpreter for Java bytecode +* gcj-dbtool: (gcj)Invoking gcj-dbtool. + Tool for manipulating class file databases. +* jv-convert: (gcj)Invoking jv-convert. + Convert file from one encoding to another +* grmic: (gcj)Invoking grmic. + Generate stubs for Remote Method Invocation. +* gc-analyze: (gcj)Invoking gc-analyze. + Analyze Garbage Collector (GC) memory dumps. +* aot-compile: (gcj)Invoking aot-compile. + Compile bytecode to native and generate databases. +* rebuild-gcj-db: (gcj)Invoking rebuild-gcj-db. + Merge the per-solib databases made by aot-compile + into one system-wide database. +@end direntry +@end format + +@insertcopying +@end ifinfo + +@titlepage +@title GNU gcj +@versionsubtitle +@author Tom Tromey + +@page +@vskip 0pt plus 1filll +Published by the Free Software Foundation @* +51 Franklin Street, Fifth Floor@* +Boston, MA 02110-1301, USA@* +@sp 1 +@insertcopying +@end titlepage +@contents +@page + + +@node Top +@top Introduction + +This manual describes how to use @command{gcj}, the GNU compiler for the +Java programming language. @command{gcj} can generate both @file{.class} +files and object files, and it can read both Java source code and +@file{.class} files. + +@menu +* Copying:: The GNU General Public License +* GNU Free Documentation License:: + How you can share and copy this manual +* Invoking gcj:: Compiler options supported by @command{gcj} +* Compatibility:: Compatibility between gcj and other tools for Java +* Invoking jcf-dump:: Print information about class files +* Invoking gij:: Interpreting Java bytecodes +* Invoking gcj-dbtool:: Tool for manipulating class file databases. +* Invoking jv-convert:: Converting from one encoding to another +* Invoking grmic:: Generate stubs for Remote Method Invocation. +* Invoking gc-analyze:: Analyze Garbage Collector (GC) memory dumps. +* Invoking aot-compile:: Compile bytecode to native and generate databases. +* Invoking rebuild-gcj-db:: Merge the per-solib databases made by aot-compile + into one system-wide database. +* About CNI:: Description of the Compiled Native Interface +* System properties:: Modifying runtime behavior of the libgcj library +* Resources:: Where to look for more information +* Index:: Index. +@end menu + + +@include gpl_v3.texi + +@include fdl.texi + + +@node Invoking gcj +@chapter Invoking gcj + +@c man title gcj Ahead-of-time compiler for the Java language + +@ignore +@c man begin SYNOPSIS gcj +gcj [@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}] + [@option{--CLASSPATH}=@var{path}] [@option{--classpath}=@var{path}] + [@option{-f}@var{option}@dots{}] [@option{--encoding}=@var{name}] + [@option{--main}=@var{classname}] [@option{-D}@var{name}[=@var{value}]@dots{}] + [@option{-C}] [@option{--resource} @var{resource-name}] [@option{-d} @var{directory}] + [@option{-W}@var{warn}@dots{}] + @var{sourcefile}@dots{} +@c man end +@c man begin SEEALSO gcj +gcc(1), gcjh(1), gjnih(1), gij(1), jcf-dump(1), gfdl(7), +and the Info entries for @file{gcj} and @file{gcc}. +@c man end +@end ignore + +@c man begin DESCRIPTION gcj + +As @command{gcj} is just another front end to @command{gcc}, it supports many +of the same options as gcc. @xref{Option Summary, , Option Summary, +gcc, Using the GNU Compiler Collection (GCC)}. This manual only documents the +options specific to @command{gcj}. + +@c man end + +@menu +* Input and output files:: +* Input Options:: How gcj finds files +* Encodings:: Options controlling source file encoding +* Warnings:: Options controlling warnings specific to gcj +* Linking:: Options for making an executable +* Code Generation:: Options controlling the output of gcj +* Configure-time Options:: Options you won't use +@end menu + +@c man begin OPTIONS gcj + +@node Input and output files +@section Input and output files + +A @command{gcj} command is like a @command{gcc} command, in that it +consists of a number of options and file names. The following kinds +of input file names are supported: + +@table @gcctabopt +@item @var{file}.java +Java source files. +@item @var{file}.class +Java bytecode files. +@item @var{file}.zip +@itemx @var{file}.jar +An archive containing one or more @code{.class} files, all of +which are compiled. The archive may be compressed. Files in +an archive which don't end with @samp{.class} are treated as +resource files; they are compiled into the resulting object file +as @samp{core:} URLs. +@item @@@var{file} +A file containing a whitespace-separated list of input file names. +(Currently, these must all be @code{.java} source files, but that +may change.) +Each named file is compiled, just as if it had been on the command line. +@item @var{library}.a +@itemx @var{library}.so +@itemx -l@var{libname} +Libraries to use when linking. See the @command{gcc} manual. +@end table + +You can specify more than one input file on the @command{gcj} command line, +in which case they will all be compiled. If you specify a +@code{-o @var{FILENAME}} +option, all the input files will be compiled together, producing a +single output file, named @var{FILENAME}. +This is allowed even when using @code{-S} or @code{-c}, +but not when using @code{-C} or @code{--resource}. +(This is an extension beyond the what plain @command{gcc} allows.) +(If more than one input file is specified, all must currently +be @code{.java} files, though we hope to fix this.) + +@node Input Options +@section Input Options + +@cindex class path + +@command{gcj} has options to control where it looks to find files it needs. +For instance, @command{gcj} might need to load a class that is referenced +by the file it has been asked to compile. Like other compilers for the +Java language, @command{gcj} has a notion of a @dfn{class path}. There are +several options and environment variables which can be used to +manipulate the class path. When @command{gcj} looks for a given class, it +searches the class path looking for matching @file{.class} or +@file{.java} file. @command{gcj} comes with a built-in class path which +points at the installed @file{libgcj.jar}, a file which contains all the +standard classes. + +In the text below, a directory or path component can refer either to an +actual directory on the filesystem, or to a @file{.zip} or @file{.jar} +file, which @command{gcj} will search as if it is a directory. + +@table @gcctabopt +@item -I@var{dir} +All directories specified by @code{-I} are kept in order and prepended +to the class path constructed from all the other options. Unless +compatibility with tools like @code{javac} is important, we recommend +always using @code{-I} instead of the other options for manipulating the +class path. + +@item --classpath=@var{path} +This sets the class path to @var{path}, a colon-separated list of paths +(on Windows-based systems, a semicolon-separate list of paths). +This does not override the builtin (``boot'') search path. + +@item --CLASSPATH=@var{path} +Deprecated synonym for @code{--classpath}. + +@item --bootclasspath=@var{path} +Where to find the standard builtin classes, such as @code{java.lang.String}. + +@item --extdirs=@var{path} +For each directory in the @var{path}, place the contents of that +directory at the end of the class path. + +@item CLASSPATH +This is an environment variable which holds a list of paths. +@end table + +The final class path is constructed like so: + +@itemize @bullet +@item +First come all directories specified via @code{-I}. + +@item +If @option{--classpath} is specified, its value is appended. +Otherwise, if the @code{CLASSPATH} environment variable is specified, +then its value is appended. +Otherwise, the current directory (@code{"."}) is appended. + +@item +If @code{--bootclasspath} was specified, append its value. +Otherwise, append the built-in system directory, @file{libgcj.jar}. + +@item +Finally, if @code{--extdirs} was specified, append the contents of the +specified directories at the end of the class path. Otherwise, append +the contents of the built-in extdirs at @code{$(prefix)/share/java/ext}. +@end itemize + +The classfile built by @command{gcj} for the class @code{java.lang.Object} +(and placed in @code{libgcj.jar}) contains a special zero length +attribute @code{gnu.gcj.gcj-compiled}. The compiler looks for this +attribute when loading @code{java.lang.Object} and will report an error +if it isn't found, unless it compiles to bytecode (the option +@code{-fforce-classes-archive-check} can be used to override this +behavior in this particular case.) + +@table @gcctabopt +@item -fforce-classes-archive-check +This forces the compiler to always check for the special zero length +attribute @code{gnu.gcj.gcj-compiled} in @code{java.lang.Object} and +issue an error if it isn't found. + +@item -fsource=@var{VERSION} +This option is used to choose the source version accepted by +@command{gcj}. The default is @samp{1.5}. +@end table + +@node Encodings +@section Encodings + +The Java programming language uses Unicode throughout. In an effort to +integrate well with other locales, @command{gcj} allows @file{.java} files +to be written using almost any encoding. @command{gcj} knows how to +convert these encodings into its internal encoding at compile time. + +You can use the @code{--encoding=@var{NAME}} option to specify an +encoding (of a particular character set) to use for source files. If +this is not specified, the default encoding comes from your current +locale. If your host system has insufficient locale support, then +@command{gcj} assumes the default encoding to be the @samp{UTF-8} encoding +of Unicode. + +To implement @code{--encoding}, @command{gcj} simply uses the host +platform's @code{iconv} conversion routine. This means that in practice +@command{gcj} is limited by the capabilities of the host platform. + +The names allowed for the argument @code{--encoding} vary from platform +to platform (since they are not standardized anywhere). However, +@command{gcj} implements the encoding named @samp{UTF-8} internally, so if +you choose to use this for your source files you can be assured that it +will work on every host. + + +@node Warnings +@section Warnings + +@command{gcj} implements several warnings. As with other generic +@command{gcc} warnings, if an option of the form @code{-Wfoo} enables a +warning, then @code{-Wno-foo} will disable it. Here we've chosen to +document the form of the warning which will have an effect -- the +default being the opposite of what is listed. + +@table @gcctabopt +@item -Wredundant-modifiers +With this flag, @command{gcj} will warn about redundant modifiers. For +instance, it will warn if an interface method is declared @code{public}. + +@item -Wextraneous-semicolon +This causes @command{gcj} to warn about empty statements. Empty statements +have been deprecated. + +@item -Wno-out-of-date +This option will cause @command{gcj} not to warn when a source file is +newer than its matching class file. By default @command{gcj} will warn +about this. + +@item -Wno-deprecated +Warn if a deprecated class, method, or field is referred to. + +@item -Wunused +This is the same as @command{gcc}'s @code{-Wunused}. + +@item -Wall +This is the same as @code{-Wredundant-modifiers -Wextraneous-semicolon +-Wunused}. +@end table + + +@node Linking +@section Linking + +To turn a Java application into an executable program, +you need to link it with the needed libraries, just as for C or C++. +The linker by default looks for a global function named @code{main}. +Since Java does not have global functions, and a +collection of Java classes may have more than one class with a +@code{main} method, you need to let the linker know which of those +@code{main} methods it should invoke when starting the application. +You can do that in any of these ways: + +@itemize @bullet +@item +Specify the class containing the desired @code{main} method +when you link the application, using the @code{--main} flag, +described below. +@item +Link the Java package(s) into a shared library (dll) rather than an +executable. Then invoke the application using the @code{gij} program, +making sure that @code{gij} can find the libraries it needs. +@item +Link the Java packages(s) with the flag @code{-lgij}, which links +in the @code{main} routine from the @code{gij} command. +This allows you to select the class whose @code{main} method you +want to run when you run the application. You can also use +other @code{gij} flags, such as @code{-D} flags to set properties. +Using the @code{-lgij} library (rather than the @code{gij} program +of the previous mechanism) has some advantages: it is compatible with +static linking, and does not require configuring or installing libraries. +@end itemize + +These @code{gij} options relate to linking an executable: + +@table @gcctabopt +@item --main=@var{CLASSNAME} +This option is used when linking to specify the name of the class whose +@code{main} method should be invoked when the resulting executable is +run. + +@item -D@var{name}[=@var{value}] +This option can only be used with @code{--main}. It defines a system +property named @var{name} with value @var{value}. If @var{value} is not +specified then it defaults to the empty string. These system properties +are initialized at the program's startup and can be retrieved at runtime +using the @code{java.lang.System.getProperty} method. + +@item -lgij +Create an application whose command-line processing is that +of the @code{gij} command. + +This option is an alternative to using @code{--main}; you cannot use both. + +@item -static-libgcj +This option causes linking to be done against a static version of the +libgcj runtime library. This option is only available if +corresponding linker support exists. + +@strong{Caution:} Static linking of libgcj may cause essential parts +of libgcj to be omitted. Some parts of libgcj use reflection to load +classes at runtime. Since the linker does not see these references at +link time, it can omit the referred to classes. The result is usually +(but not always) a @code{ClassNotFoundException} being thrown at +runtime. Caution must be used when using this option. For more +details see: +@w{@uref{http://gcc.gnu.org/wiki/Statically%20linking%20libgcj}} +@end table + +@node Code Generation +@section Code Generation + +In addition to the many @command{gcc} options controlling code generation, +@command{gcj} has several options specific to itself. + +@table @gcctabopt + +@item -C +This option is used to tell @command{gcj} to generate bytecode +(@file{.class} files) rather than object code. + +@item --resource @var{resource-name} +This option is used to tell @command{gcj} to compile the contents of a +given file to object code so it may be accessed at runtime with the core +protocol handler as @samp{core:/@var{resource-name}}. Note that +@var{resource-name} is the name of the resource as found at runtime; for +instance, it could be used in a call to @code{ResourceBundle.getBundle}. +The actual file name to be compiled this way must be specified +separately. + +@item -ftarget=@var{VERSION} +This can be used with @option{-C} to choose the version of bytecode +emitted by @command{gcj}. The default is @samp{1.5}. When not +generating bytecode, this option has no effect. + +@item -d @var{directory} +When used with @code{-C}, this causes all generated @file{.class} files +to be put in the appropriate subdirectory of @var{directory}. By +default they will be put in subdirectories of the current working +directory. + +@item -fno-bounds-check +By default, @command{gcj} generates code which checks the bounds of all +array indexing operations. With this option, these checks are omitted, which +can improve performance for code that uses arrays extensively. Note that this +can result in unpredictable behavior if the code in question actually does +violate array bounds constraints. It is safe to use this option if you are +sure that your code will never throw an @code{ArrayIndexOutOfBoundsException}. + +@item -fno-store-check +Don't generate array store checks. When storing objects into arrays, a runtime +check is normally generated in order to ensure that the object is assignment +compatible with the component type of the array (which may not be known +at compile-time). With this option, these checks are omitted. This can +improve performance for code which stores objects into arrays frequently. +It is safe to use this option if you are sure your code will never throw an +@code{ArrayStoreException}. + +@item -fjni +With @command{gcj} there are two options for writing native methods: CNI +and JNI@. By default @command{gcj} assumes you are using CNI@. If you are +compiling a class with native methods, and these methods are implemented +using JNI, then you must use @code{-fjni}. This option causes +@command{gcj} to generate stubs which will invoke the underlying JNI +methods. + +@item -fno-assert +Don't recognize the @code{assert} keyword. This is for compatibility +with older versions of the language specification. + +@item -fno-optimize-static-class-initialization +When the optimization level is greater or equal to @code{-O2}, +@command{gcj} will try to optimize the way calls into the runtime are made +to initialize static classes upon their first use (this optimization +isn't carried out if @code{-C} was specified.) When compiling to native +code, @code{-fno-optimize-static-class-initialization} will turn this +optimization off, regardless of the optimization level in use. + +@item --disable-assertions[=@var{class-or-package}] +Don't include code for checking assertions in the compiled code. +If @code{=@var{class-or-package}} is missing disables assertion code +generation for all classes, unless overridden by a more +specific @code{--enable-assertions} flag. +If @var{class-or-package} is a class name, only disables generating +assertion checks within the named class or its inner classes. +If @var{class-or-package} is a package name, disables generating +assertion checks within the named package or a subpackage. + +By default, assertions are enabled when generating class files +or when not optimizing, and disabled when generating optimized binaries. + +@item --enable-assertions[=@var{class-or-package}] +Generates code to check assertions. The option is perhaps misnamed, +as you still need to turn on assertion checking at run-time, +and we don't support any easy way to do that. +So this flag isn't very useful yet, except to partially override +@code{--disable-assertions}. + +@item -findirect-dispatch +@command{gcj} has a special binary compatibility ABI, which is enabled +by the @code{-findirect-dispatch} option. In this mode, the code +generated by @command{gcj} honors the binary compatibility guarantees +in the Java Language Specification, and the resulting object files do +not need to be directly linked against their dependencies. Instead, +all dependencies are looked up at runtime. This allows free mixing of +interpreted and compiled code. + +Note that, at present, @code{-findirect-dispatch} can only be used +when compiling @file{.class} files. It will not work when compiling +from source. CNI also does not yet work with the binary compatibility +ABI. These restrictions will be lifted in some future release. + +However, if you compile CNI code with the standard ABI, you can call +it from code built with the binary compatibility ABI. + +@item -fbootstrap-classes +This option can be use to tell @code{libgcj} that the compiled classes +should be loaded by the bootstrap loader, not the system class loader. +By default, if you compile a class and link it into an executable, it +will be treated as if it was loaded using the system class loader. +This is convenient, as it means that things like +@code{Class.forName()} will search @samp{CLASSPATH} to find the +desired class. + +@item -freduced-reflection +This option causes the code generated by @command{gcj} to contain a +reduced amount of the class meta-data used to support runtime +reflection. The cost of this savings is the loss of +the ability to use certain reflection capabilities of the standard +Java runtime environment. When set all meta-data except for that +which is needed to obtain correct runtime semantics is eliminated. + +For code that does not use reflection (i.e. serialization, RMI, CORBA +or call methods in the @code{java.lang.reflect} package), +@code{-freduced-reflection} will result in proper operation with a +savings in executable code size. + +JNI (@code{-fjni}) and the binary compatibility ABI +(@code{-findirect-dispatch}) do not work properly without full +reflection meta-data. Because of this, it is an error to use these options +with @code{-freduced-reflection}. + +@strong{Caution:} If there is no reflection meta-data, code that uses +a @code{SecurityManager} may not work properly. Also calling +@code{Class.forName()} may fail if the calling method has no +reflection meta-data. + +@end table + + +@node Configure-time Options +@section Configure-time Options + +Some @command{gcj} code generations options affect the resulting ABI, and +so can only be meaningfully given when @code{libgcj}, the runtime +package, is configured. @code{libgcj} puts the appropriate options from +this group into a @samp{spec} file which is read by @command{gcj}. These +options are listed here for completeness; if you are using @code{libgcj} +then you won't want to touch these options. + +@table @gcctabopt +@item -fuse-boehm-gc +This enables the use of the Boehm GC bitmap marking code. In particular +this causes @command{gcj} to put an object marking descriptor into each +vtable. + +@item -fhash-synchronization +By default, synchronization data (the data used for @code{synchronize}, +@code{wait}, and @code{notify}) is pointed to by a word in each object. +With this option @command{gcj} assumes that this information is stored in a +hash table and not in the object itself. + +@item -fuse-divide-subroutine +On some systems, a library routine is called to perform integer +division. This is required to get exception handling correct when +dividing by zero. + +@item -fcheck-references +On some systems it's necessary to insert inline checks whenever +accessing an object via a reference. On other systems you won't need +this because null pointer accesses are caught automatically by the +processor. + +@item -fuse-atomic-builtins +On some systems, gcc can generate code for built-in atomic operations. +Use this option to force gcj to use these builtins when compiling Java +code. Where this capability is present it should be automatically +detected, so you won't usually need to use this option. + +@end table + +@c man end + +@node Compatibility +@chapter Compatibility with the Java Platform + +As we believe it is important that the Java platform not be fragmented, +@command{gcj} and @code{libgcj} try to conform to the relevant Java +specifications. However, limited manpower and incomplete and unclear +documentation work against us. So, there are caveats to using +@command{gcj}. + +@menu +* Limitations:: +* Extensions:: +@end menu + +@node Limitations +@section Standard features not yet supported + +This list of compatibility issues is by no means complete. + +@itemize @bullet +@item +@command{gcj} implements the JDK 1.2 language. It supports inner classes +and the new 1.4 @code{assert} keyword. It does not yet support the Java 2 +@code{strictfp} keyword (it recognizes the keyword but ignores it). + +@item +@code{libgcj} is largely compatible with the JDK 1.2 libraries. +However, @code{libgcj} is missing many packages, most notably +@code{java.awt}. There are also individual missing classes and methods. +We currently do not have a list showing differences between +@code{libgcj} and the Java 2 platform. + +@item +Sometimes the @code{libgcj} implementation of a method or class differs +from the JDK implementation. This is not always a bug. Still, if it +affects you, it probably makes sense to report it so that we can discuss +the appropriate response. + +@item +@command{gcj} does not currently allow for piecemeal replacement of +components within @code{libgcj}. Unfortunately, programmers often want +to use newer versions of certain packages, such as those provided by +the Apache Software Foundation's Jakarta project. This has forced us +to place the @code{org.w3c.dom} and @code{org.xml.sax} packages into +their own libraries, separate from @code{libgcj}. If you intend to +use these classes, you must link them explicitly with +@code{-l-org-w3c-dom} and @code{-l-org-xml-sax}. Future versions of +@command{gcj} may not have this restriction. +@end itemize + +@node Extensions +@section Extra features unique to gcj + +The main feature of @command{gcj} is that it can compile programs written in +the Java programming language to native code. Most extensions that have been +added are to facilitate this functionality. + +@itemize @bullet +@item +@command{gcj} makes it easy and efficient to mix code written in Java and C++. +@xref{About CNI}, for more info on how to use this in your programs. + +@item +When you compile your classes into a shared library using +@code{-findirect-dispatch} then add them to the system-wide +classmap.db file using @code{gcj-dbtool}, they will be automatically +loaded by the @code{libgcj} system classloader. This is the new, +preferred classname-to-library resolution mechanism. @xref{Invoking +gcj-dbtool}, for more information on using the classmap database. + +@item +The old classname-to-library lookup mechanism is still supported +through the @code{gnu.gcj.runtime.VMClassLoader.library_control} +property, but it is deprecated and will likely be removed in some +future release. When trying to load a class @code{gnu.pkg.SomeClass} +the system classloader will first try to load the shared library +@file{lib-gnu-pkg-SomeClass.so}, if that fails to load the class then +it will try to load @file{lib-gnu-pkg.so} and finally when the class +is still not loaded it will try to load @file{lib-gnu.so}. Note that +all @samp{.}s will be transformed into @samp{-}s and that searching +for inner classes starts with their outermost outer class. If the +class cannot be found this way the system classloader tries to use the +@code{libgcj} bytecode interpreter to load the class from the standard +classpath. This process can be controlled to some degree via the +@code{gnu.gcj.runtime.VMClassLoader.library_control} property; +@xref{libgcj Runtime Properties}. + +@item +@code{libgcj} includes a special @samp{gcjlib} URL type. A URL of +this form is like a @code{jar} URL, and looks like +@samp{gcjlib:/path/to/shared/library.so!/path/to/resource}. An access +to one of these URLs causes the shared library to be @code{dlopen()}d, +and then the resource is looked for in that library. These URLs are +most useful when used in conjunction with @code{java.net.URLClassLoader}. +Note that, due to implementation limitations, currently any such URL +can be accessed by only one class loader, and libraries are never +unloaded. This means some care must be exercised to make sure that +a @code{gcjlib} URL is not accessed by more than one class loader at once. +In a future release this limitation will be lifted, and such +libraries will be mapped privately. + +@item +A program compiled by @command{gcj} will examine the +@env{GCJ_PROPERTIES} environment variable and change its behavior in +some ways. In particular @env{GCJ_PROPERTIES} holds a list of +assignments to global properties, such as would be set with the +@option{-D} option to @command{java}. For instance, +@samp{java.compiler=gcj} is a valid (but currently meaningless) +setting. +@cindex GCJ_PROPERTIES +@vindex GCJ_PROPERTIES + +@end itemize + + +@node Invoking jcf-dump +@chapter Invoking jcf-dump + +@c man title jcf-dump print information about Java class files + +@ignore +@c man begin SYNOPSIS jcf-dump +jcf-dump [@option{-c}] [@option{--javap}] + [@option{--classpath}=@var{path}] [@option{--CLASSPATH}=@var{path}] + [@option{-I}@var{dir}@dots{}] [@option{-o} @var{file}] + [@option{--version}] [@option{--help}] [@option{-v}] [@option{--verbose}] + @var{classname}@dots{} +@c man end +@c man begin SEEALSO jcf-dump +gcc(1), gcj(1), gcjh(1), gij(1), jcf-dump(1), gfdl(7), +and the Info entries for @file{gcj} and @file{gcc}. +@c man end +@end ignore + +@c man begin DESCRIPTION jcf-dump + +This is a class file examiner, similar to @code{javap}. It will print +information about a number of classes, which are specified by class name +or file name. + +@c man end + +@c man begin OPTIONS jcf-dump + +@table @gcctabopt +@item -c +Disassemble method bodies. By default method bodies are not printed. + +@item --print-constants +Print the constant pool. When printing a reference to a constant +also print its index in the constant pool. + +@item --javap +Generate output in @code{javap} format. The implementation of this +feature is very incomplete. + +@item --classpath=@var{path} +@itemx --CLASSPATH=@var{path} +@itemx -I@var{directory} +@itemx -o @var{file} +These options as the same as the corresponding @command{gcj} options. + +@item --help +Print help, then exit. + +@item --version +Print version number, then exit. + +@item -v, --verbose +Print extra information while running. +Implies @code{--print-constants}. +@end table + +@c man end + +@node Invoking gij +@chapter Invoking gij + +@c man title gij GNU interpreter for Java bytecode + +@ignore +@c man begin SYNOPSIS gij +gij [@option{OPTION}] @dots{} @var{JARFILE} [@var{ARGS}@dots{}] + +gij [@option{-jar}] [@option{OPTION}] @dots{} @var{CLASS} [@var{ARGS}@dots{}] + [@option{-cp} @var{path}] [@option{-classpath} @var{path}] + [@option{-D}@var{name}[=@var{value}]@dots{}] + [@option{-ms=}@var{number}] [@option{-mx=}@var{number}] + [@option{-X@var{argument}}] [@option{-verbose}] [@option{-verbose:class}] + [@option{--showversion}] [@option{--version}] [@option{--help}][@option{-?}] +@c man end +@c man begin SEEALSO gij +gcc(1), gcj(1), gcjh(1), jcf-dump(1), gfdl(7), +and the Info entries for @file{gcj} and @file{gcc}. +@c man end +@end ignore + +@c man begin DESCRIPTION gij + +@code{gij} is a Java bytecode interpreter included with @code{libgcj}. +@code{gij} is not available on every platform; porting it requires a +small amount of assembly programming which has not been done for all the +targets supported by @command{gcj}. + +The primary argument to @code{gij} is the name of a class or, with +@code{-jar}, a jar file. Options before this argument are interpreted +by @code{gij}; remaining options are passed to the interpreted program. + +If a class name is specified and this class does not have a @code{main} +method with the appropriate signature (a @code{static void} method with +a @code{String[]} as its sole argument), then @code{gij} will print an +error and exit. + +If a jar file is specified then @code{gij} will use information in it to +determine which class' @code{main} method will be invoked. + +@code{gij} will invoke the @code{main} method with all the remaining +command-line options. + +Note that @code{gij} is not limited to interpreting code. Because +@code{libgcj} includes a class loader which can dynamically load shared +objects, it is possible to give @code{gij} the name of a class which has +been compiled and put into a shared library on the class path. + +@c man end + +@c man begin OPTIONS gij + +@table @gcctabopt +@item -cp @var{path} +@itemx -classpath @var{path} +Set the initial class path. The class path is used for finding +class and resource files. If specified, this option overrides the +@code{CLASSPATH} environment variable. Note that this option is +ignored if @code{-jar} is used. + +@item -D@var{name}[=@var{value}] +This defines a system property named @var{name} with value @var{value}. +If @var{value} is not specified then it defaults to the empty string. +These system properties are initialized at the program's startup and can +be retrieved at runtime using the @code{java.lang.System.getProperty} +method. + +@item -ms=@var{number} +Equivalent to @code{-Xms}. + +@item -mx=@var{number} +Equivalent to @code{-Xmx}. + +@item -noverify +Do not verify compliance of bytecode with the VM specification. In addition, +this option disables type verification which is otherwise performed on BC-ABI +compiled code. + +@item -X +@itemx -X@var{argument} +Supplying @code{-X} by itself will cause @code{gij} to list all the +supported @code{-X} options. Currently these options are supported: + +@table @gcctabopt +@item -Xms@var{size} +Set the initial heap size. + +@item -Xmx@var{size} +Set the maximum heap size. + +@item -Xss@var{size} +Set the thread stack size. +@end table + +Unrecognized @code{-X} options are ignored, for compatibility with +other runtimes. + +@item -jar +This indicates that the name passed to @code{gij} should be interpreted +as the name of a jar file, not a class. + +@item --help +@itemx -? +Print help, then exit. + +@item --showversion +Print version number and continue. + +@item --fullversion +Print detailed version information, then exit. + +@item --version +Print version number, then exit. + +@item -verbose +@itemx -verbose:class +Each time a class is initialized, print a short message on standard error. +@end table + +@code{gij} also recognizes and ignores the following options, for +compatibility with existing application launch scripts: +@code{-client}, @code{-server}, @code{-hotspot}, @code{-jrockit}, +@code{-agentlib}, @code{-agentpath}, @code{-debug}, @code{-d32}, +@code{-d64}, @code{-javaagent}, @code{-noclassgc}, @code{-verify}, +and @code{-verifyremote}. + +@c man end + +@node Invoking gcj-dbtool +@chapter Invoking gcj-dbtool. + +@c man title gcj-dbtool Manipulate class file mapping databases for libgcj + +@ignore +@c man begin SYNOPSIS gcj-dbtool +gcj-dbtool @option{OPTION} @var{DBFILE} [@option{MORE}] @dots{} + +gcj-dbtool [@option{-0}] [@option{-}] [@option{-n}] [@option{-a}] [@option{-f}] + [@option{-t}] [@option{-l}] [@option{-p} [@var{LIBDIR}]] + [@option{-v}] [@option{-m}] [@option{--version}] [@option{--help}] + +@c man end +@c man begin SEEALSO gcj-dbtool +gcc(1), gcj(1), gcjh(1), jcf-dump(1), gfdl(7), +and the Info entries for @file{gcj} and @file{gcc}. +@c man end +@end ignore + +@c man begin DESCRIPTION gcj-dbtool + +@code{gcj-dbtool} is a tool for creating and manipulating class file +mapping databases. @code{libgcj} can use these databases to find a +shared library corresponding to the bytecode representation of a +class. This functionality is useful for ahead-of-time compilation of +a program that has no knowledge of @code{gcj}. + +@code{gcj-dbtool} works best if all the jar files added to it are +compiled using @code{-findirect-dispatch}. + +Note that @code{gcj-dbtool} is currently available as ``preview +technology''. We believe it is a reasonable way to allow +application-transparent ahead-of-time compilation, but this is an +unexplored area. We welcome your comments. + +@c man end + +@c man begin OPTIONS gcj-dbtool + +@table @gcctabopt +@item -n @var{DBFILE} [@var{SIZE}] +This creates a new database. Currently, databases cannot be resized; +you can choose a larger initial size if desired. The default size is +32,749. + +@item -a @var{DBFILE} @var{JARFILE} @var{LIB} +@itemx -f @var{DBFILE} @var{JARFILE} @var{LIB} +This adds a jar file to the database. For each class file in the jar, +a cryptographic signature of the bytecode representation of the class +is recorded in the database. At runtime, a class is looked up by its +signature and the compiled form of the class is looked for in the +corresponding shared library. The @option{-a} option will verify +that @var{LIB} exists before adding it to the database; @option{-f} +skips this check. + +@item [@option{-}][@option{-0}] -m @var{DBFILE} @var{DBFILE},[@var{DBFILE}] +Merge a number of databases. The output database overwrites any +existing database. To add databases into an existing database, +include the destination in the list of sources. + +If @option{-} or @option{-0} are used, the list of files to read is +taken from standard input instead of the command line. For +@option{-0}, Input filenames are terminated by a null character +instead of by whitespace. Useful when arguments might contain white +space. The GNU find -print0 option produces input suitable for this +mode. + +@item -t @var{DBFILE} +Test a database. + +@item -l @var{DBFILE} +List the contents of a database. + +@item -p +Print the name of the default database. If there is no default +database, this prints a blank line. If @var{LIBDIR} is specified, use +it instead of the default library directory component of the database +name. + +@item --help +Print a help message, then exit. + +@item --version +@itemx -v +Print version information, then exit. + +@end table + +@c man end + +@node Invoking jv-convert +@chapter Invoking jv-convert + +@c man title jv-convert Convert file from one encoding to another + +@c man begin SYNOPSIS jv-convert +@command{jv-convert} [@option{OPTION}] @dots{} [@var{INPUTFILE} [@var{OUTPUTFILE}]] +@ignore + + [@option{--encoding} @var{name}] + [@option{--from} @var{name}] + [@option{--to} @var{name}] + [@option{-i} @var{file}] [@option{-o} @var{file}] + [@option{--reverse}] [@option{--help}] [@option{--version}] +@end ignore +@c man end + +@c man begin DESCRIPTION jv-convert + +@command{jv-convert} is a utility included with @code{libgcj} which +converts a file from one encoding to another. It is similar to the Unix +@command{iconv} utility. + +The encodings supported by @command{jv-convert} are platform-dependent. +Currently there is no way to get a list of all supported encodings. + +@c man end + +@c man begin OPTIONS jv-convert + +@table @gcctabopt +@item --encoding @var{name} +@itemx --from @var{name} +Use @var{name} as the input encoding. The default is the current +locale's encoding. + +@item --to @var{name} +Use @var{name} as the output encoding. The default is the +@code{JavaSrc} encoding; this is ASCII with @samp{\u} escapes for +non-ASCII characters. + +@item -i @var{file} +Read from @var{file}. The default is to read from standard input. + +@item -o @var{file} +Write to @var{file}. The default is to write to standard output. + +@item --reverse +Swap the input and output encodings. + +@item --help +Print a help message, then exit. + +@item --version +Print version information, then exit. +@end table + +@c man end + +@node Invoking grmic +@chapter Invoking grmic + +@c man title grmic Generate stubs for Remote Method Invocation + +@c man begin SYNOPSIS grmic +@command{grmic} [@option{OPTION}] @dots{} @var{class} @dots{} +@ignore + [@option{-keep}] + [@option{-keepgenerated}] + [@option{-v1.1}] + [@option{-vcompat}] + [@option{-v1.2}] + [@option{-nocompile}] + [@option{-verbose}] + [@option{-d} @var{directory}] + [@option{-help}] + [@option{-version}] +@end ignore +@c man end + +@c man begin DESCRIPTION grmic + +@command{grmic} is a utility included with @code{libgcj} which generates +stubs for remote objects. + +@c FIXME: Add real information here. +@c This really isn't much more than the --help output. + +Note that this program isn't yet fully compatible with the JDK +@command{grmic}. Some options, such as @option{-classpath}, are +recognized but currently ignored. We have left these options +undocumented for now. + +Long options can also be given with a GNU-style leading @samp{--}. For +instance, @option{--help} is accepted. + +@c man end + +@c man begin OPTIONS grmic + +@table @gcctabopt +@item -keep +@itemx -keepgenerated +By default, @command{grmic} deletes intermediate files. Either of these +options causes it not to delete such files. + +@item -v1.1 +Cause @command{grmic} to create stubs and skeletons for the 1.1 +protocol version. + +@item -vcompat +Cause @command{grmic} to create stubs and skeletons compatible with both +the 1.1 and 1.2 protocol versions. This is the default. + +@item -v1.2 +Cause @command{grmic} to create stubs and skeletons for the 1.2 +protocol version. + +@item -nocompile +Don't compile the generated files. + +@item -verbose +Print information about what @command{grmic} is doing. + +@item -d @var{directory} +Put output files in @var{directory}. By default the files are put in +the current working directory. + +@item -help +Print a help message, then exit. + +@item -version +Print version information, then exit. +@end table + +@c man end + + +@node Invoking gc-analyze +@chapter Invoking gc-analyze + +@c man title gc-analyze Analyze Garbage Collector (GC) memory dumps + +@c man begin SYNOPSIS gc-analyze +@command{gc-analyze} [@option{OPTION}] @dots{} [@var{file}] +@ignore + [@option{-v}] + [@option{--verbose}] + [@option{-p} @var{tool-prefix}] + [@option{-d} @var{directory}] + [@option{--version}] + [@option{--help}] +@end ignore +@c man end + +@c man begin DESCRIPTION gc-analyze + +@command{gc-analyze} prints an analysis of a GC memory dump to +standard out. + +The memory dumps may be created by calling +@code{gnu.gcj.util.GCInfo.enumerate(String namePrefix)} from java +code. A memory dump will be created on an out of memory condition if +@code{gnu.gcj.util.GCInfo.setOOMDump(String namePrefix)} is called +before the out of memory occurs. + +Running this program will create two files: @file{TestDump001} and +@file{TestDump001.bytes}. + +@example +import gnu.gcj.util.*; +import java.util.*; + +public class GCDumpTest +@{ + static public void main(String args[]) + @{ + ArrayList<String> l = new ArrayList<String>(1000); + + for (int i = 1; i < 1500; i++) @{ + l.add("This is string #" + i); + @} + GCInfo.enumerate("TestDump"); + @} +@} +@end example + +The memory dump may then be displayed by running: + +@example +gc-analyze -v TestDump001 +@end example + +@c FIXME: Add real information here. +@c This really isn't much more than the --help output. + +@c man end + +@c man begin OPTIONS gc-analyze + +@table @gcctabopt +@item --verbose +@itemx -v +Verbose output. + +@item -p @var{tool-prefix} +Prefix added to the names of the @command{nm} and @command{readelf} commands. + +@item -d @var{directory} +Directory that contains the executable and shared libraries used when +the dump was generated. + +@item --help +Print a help message, then exit. + +@item --version +Print version information, then exit. +@end table + +@c man end + +@node Invoking aot-compile +@chapter Invoking aot-compile + +@c man title aot-compile Compile bytecode to native and generate databases + +@ignore + +@c man begin SYNOPSIS aot-compile +aot-compile [@option{OPTION}] @dots{} @var{SRCDIR} @var{DSTDIR} + +aot-compile [@option{-M, --make}=@var{PATH}] [@option{-C, --gcj}=@var{PATH}] + [@option{-D, --dbtool}=@var{PATH}] [@option{-m, --makeflags}=@var{FLAGS}] + [@option{-c, --gcjflags}=@var{FLAGS}] [@option{-l, --ldflags}=@var{FLAGS}] + [@option{-e, --exclude}=@var{PATH}] +@c man end + +@c man begin SEEALSO aot-compile +gcc(1), gcj(1), gcjh(1), jcf-dump(1), gfdl(7), +and the Info entries for @file{gcj} and @file{gcc}. +@c man end + +@end ignore + +@c man begin DESCRIPTION aot-compile +@code{aot-compile} is a script that searches a directory for Java bytecode +(as class files, or in jars) and uses @code{gcj} to compile it to native +code and generate the databases from it. +@c man end + +@c man begin OPTIONS aot-compile +@table @gcctabopt +@item -M, --make=@var{PATH} +Specify the path to the @code{make} executable to use. + +@item -C, --gcj=@var{PATH} +Specify the path to the @code{gcj} executable to use. + +@item -D, --dbtool=@var{PATH} +Specify the path to the @code{gcj-dbtool} executable to use. + +@item -m, --makeflags=@var{FLAGS} +Specify flags to pass to @code{make} during the build. + +@item -c, --gcjflags=@var{FLAGS} +Specify flags to pass to @code{gcj} during compilation, in addition to +'-fPIC -findirect-dispatch -fjni'. + +@item -l, --ldflags=@var{FLAGS} +Specify flags to pass to @code{gcj} during linking, in addition to +'-Wl,-Bsymbolic'. + +@item -e, --exclude=@var{PATH} +Do not compile @var{PATH}. + +@end table + +@c man end + +@node Invoking rebuild-gcj-db +@chapter Invoking rebuild-gcj-db + +@c man title rebuild-gcj-db Merge the per-solib databases made by aot-compile into one system-wide database. +@ignore + +@c man begin SYNOPSIS rebuild-gcj-db +rebuild-gcj-db +@c man end + +@c man begin SEEALSO rebuild-gcj-db +gcc(1), gcj(1), gcjh(1), jcf-dump(1), gfdl(7), +and the Info entries for @file{gcj} and @file{gcc}. +@c man end + +@end ignore + +@c man begin DESCRIPTION rebuild-gcj-db +@code{rebuild-gcj-db} is a script that merges the per-solib databases made by +@code{aot-compile} into one system-wide database so @code{gij} can find the +solibs. +@c man end + +@node About CNI +@chapter About CNI + +This documents CNI, the Compiled Native Interface, +which is is a convenient way to write Java native methods using C++. +This is a more efficient, more convenient, but less portable +alternative to the standard JNI (Java Native Interface). + +@menu +* Basic concepts:: Introduction to using CNI@. +* Packages:: How packages are mapped to C++. +* Primitive types:: Handling primitive Java types in C++. +* Reference types:: Handling Java reference types in C++. +* Interfaces:: How Java interfaces map to C++. +* Objects and Classes:: C++ and Java classes. +* Class Initialization:: How objects are initialized. +* Object allocation:: How to create Java objects in C++. +* Memory allocation:: How to allocate and free memory. +* Arrays:: Dealing with Java arrays in C++. +* Methods:: Java methods in C++. +* Strings:: Information about Java Strings. +* Mixing with C++:: How CNI can interoperate with C++. +* Exception Handling:: How exceptions are handled. +* Synchronization:: Synchronizing between Java and C++. +* Invocation:: Starting the Java runtime from C++. +* Reflection:: Using reflection from C++. +@end menu + + +@node Basic concepts +@section Basic concepts + +In terms of languages features, Java is mostly a subset +of C++. Java has a few important extensions, plus a powerful standard +class library, but on the whole that does not change the basic similarity. +Java is a hybrid object-oriented language, with a few native types, +in addition to class types. It is class-based, where a class may have +static as well as per-object fields, and static as well as instance methods. +Non-static methods may be virtual, and may be overloaded. Overloading is +resolved at compile time by matching the actual argument types against +the parameter types. Virtual methods are implemented using indirect calls +through a dispatch table (virtual function table). Objects are +allocated on the heap, and initialized using a constructor method. +Classes are organized in a package hierarchy. + +All of the listed attributes are also true of C++, though C++ has +extra features (for example in C++ objects may be allocated not just +on the heap, but also statically or in a local stack frame). Because +@command{gcj} uses the same compiler technology as G++ (the GNU +C++ compiler), it is possible to make the intersection of the two +languages use the same ABI (object representation and calling +conventions). The key idea in CNI is that Java objects are C++ +objects, and all Java classes are C++ classes (but not the other way +around). So the most important task in integrating Java and C++ is to +remove gratuitous incompatibilities. + +You write CNI code as a regular C++ source file. (You do have to use +a Java/CNI-aware C++ compiler, specifically a recent version of G++.) + +@noindent A CNI C++ source file must have: + +@example +#include <gcj/cni.h> +@end example + +@noindent and then must include one header file for each Java class it uses, e.g.: + +@example +#include <java/lang/Character.h> +#include <java/util/Date.h> +#include <java/lang/IndexOutOfBoundsException.h> +@end example + +@noindent These header files are automatically generated by @code{gcjh}. + + +CNI provides some functions and macros to make using Java objects and +primitive types from C++ easier. In general, these CNI functions and +macros start with the @code{Jv} prefix, for example the function +@code{JvNewObjectArray}. This convention is used to avoid conflicts +with other libraries. Internal functions in CNI start with the prefix +@code{_Jv_}. You should not call these; if you find a need to, let us +know and we will try to come up with an alternate solution. + + +@subsection Limitations + +Whilst a Java class is just a C++ class that doesn't mean that you are +freed from the shackles of Java, a @acronym{CNI} C++ class must adhere to the +rules of the Java programming language. + +For example: it is not possible to declare a method in a CNI class +that will take a C string (@code{char*}) as an argument, or to declare a +member variable of some non-Java datatype. + + +@node Packages +@section Packages + +The only global names in Java are class names, and packages. A +@dfn{package} can contain zero or more classes, and also zero or more +sub-packages. Every class belongs to either an unnamed package or a +package that has a hierarchical and globally unique name. + +A Java package is mapped to a C++ @dfn{namespace}. The Java class +@code{java.lang.String} is in the package @code{java.lang}, which is a +sub-package of @code{java}. The C++ equivalent is the class +@code{java::lang::String}, which is in the namespace @code{java::lang} +which is in the namespace @code{java}. + +@noindent Here is how you could express this: + +@example +(// @r{Declare the class(es), possibly in a header file:} +namespace java @{ + namespace lang @{ + class Object; + class String; + ... + @} +@} + +class java::lang::String : public java::lang::Object +@{ + ... +@}; +@end example + +@noindent The @code{gcjh} tool automatically generates the necessary namespace +declarations. + + +@subsection Leaving out package names + +Always using the fully-qualified name of a java class can be +tiresomely verbose. Using the full qualified name also ties the code +to a single package making code changes necessary should the class +move from one package to another. The Java @code{package} declaration +specifies that the following class declarations are in the named +package, without having to explicitly name the full package +qualifiers. The @code{package} declaration can be +followed by zero or more @code{import} declarations, which +allows either a single class or all the classes in a package to be +named by a simple identifier. C++ provides something similar with the +@code{using} declaration and directive. + +@noindent In Java: + +@example +import @var{package-name}.@var{class-name}; +@end example + +@noindent allows the program text to refer to @var{class-name} as a shorthand for +the fully qualified name: @code{@var{package-name}.@var{class-name}}. + + +@noindent To achieve the same effect C++, you have to do this: + +@example +using @var{package-name}::@var{class-name}; +@end example + + +@noindent Java can also cause imports on demand, like this: + +@example +import @var{package-name}.*; +@end example + +@noindent Doing this allows any class from the package @var{package-name} to be +referred to only by its class-name within the program text. + + +@noindent The same effect can be achieved in C++ like this: + +@example +using namespace @var{package-name}; +@end example + + +@node Primitive types +@section Primitive types + +Java provides 8 @dfn{primitives} types which represent integers, floats, +characters and booleans (and also the void type). C++ has its own +very similar concrete types. Such types in C++ however are not always +implemented in the same way (an int might be 16, 32 or 64 bits for example) +so CNI provides a special C++ type for each primitive Java type: + +@multitable @columnfractions .20 .25 .60 +@item @strong{Java type} @tab @strong{C/C++ typename} @tab @strong{Description} +@item @code{char} @tab @code{jchar} @tab 16 bit Unicode character +@item @code{boolean} @tab @code{jboolean} @tab logical (true or false) values +@item @code{byte} @tab @code{jbyte} @tab 8-bit signed integer +@item @code{short} @tab @code{jshort} @tab 16 bit signed integer +@item @code{int} @tab @code{jint} @tab 32 bit signed integer +@item @code{long} @tab @code{jlong} @tab 64 bit signed integer +@item @code{float} @tab @code{jfloat} @tab 32 bit IEEE floating point number +@item @code{double} @tab @code{jdouble} @tab 64 bit IEEE floating point number +@item @code{void} @tab @code{void} @tab no value +@end multitable + +When referring to a Java type You should always use these C++ typenames (e.g.: @code{jint}) +to avoid disappointment. + + +@subsection Reference types associated with primitive types + +In Java each primitive type has an associated reference type, +e.g.: @code{boolean} has an associated @code{java.lang.Boolean.TYPE} class. +In order to make working with such classes easier GCJ provides the macro +@code{JvPrimClass}: + +@deffn macro JvPrimClass type +Return a pointer to the @code{Class} object corresponding to the type supplied. + +@example +JvPrimClass(void) @result{} java.lang.Void.TYPE +@end example + +@end deffn + + +@node Reference types +@section Reference types + +A Java reference type is treated as a class in C++. Classes and +interfaces are handled this way. A Java reference is translated to a +C++ pointer, so for instance a Java @code{java.lang.String} becomes, +in C++, @code{java::lang::String *}. + +CNI provides a few built-in typedefs for the most common classes: +@multitable @columnfractions .30 .25 .60 +@item @strong{Java type} @tab @strong{C++ typename} @tab @strong{Description} +@item @code{java.lang.Object} @tab @code{jobject} @tab Object type +@item @code{java.lang.String} @tab @code{jstring} @tab String type +@item @code{java.lang.Class} @tab @code{jclass} @tab Class type +@end multitable +@cindex jobject +@cindex jstring +@cindex jclass + +Every Java class or interface has a corresponding @code{Class} +instance. These can be accessed in CNI via the static @code{class$} +field of a class. The @code{class$} field is of type @code{Class} +(and not @code{Class *}), so you will typically take the address of +it. +@cindex class$ + +Here is how you can refer to the class of @code{String}, which in +Java would be written @code{String.class}: + +@example +using namespace java::lang; +doSomething (&String::class$); +@end example + + +@node Interfaces +@section Interfaces + +A Java class can @dfn{implement} zero or more +@dfn{interfaces}, in addition to inheriting from +a single base class. + +@acronym{CNI} allows CNI code to implement methods of interfaces. +You can also call methods through interface references, with some +limitations. + +@acronym{CNI} doesn't understand interface inheritance at all yet. So, +you can only call an interface method when the declared type of the +field being called matches the interface which declares that +method. The workaround is to cast the interface reference to the right +superinterface. + +For example if you have: + +@example +interface A +@{ + void a(); +@} + +interface B extends A +@{ + void b(); +@} +@end example + +and declare a variable of type @code{B} in C++, you can't call +@code{a()} unless you cast it to an @code{A} first. + +@node Objects and Classes +@section Objects and Classes + +@subsection Classes + +All Java classes are derived from @code{java.lang.Object}. C++ does +not have a unique root class, but we use the C++ class +@code{java::lang::Object} as the C++ version of the +@code{java.lang.Object} Java class. All other Java classes are mapped +into corresponding C++ classes derived from @code{java::lang::Object}. + +Interface inheritance (the @code{implements} keyword) is currently not +reflected in the C++ mapping. + + +@subsection Object fields + +Each object contains an object header, followed by the instance fields +of the class, in order. The object header consists of a single +pointer to a dispatch or virtual function table. (There may be extra +fields @emph{in front of} the object, for example for memory +management, but this is invisible to the application, and the +reference to the object points to the dispatch table pointer.) + +The fields are laid out in the same order, alignment, and size as in +C++. Specifically, 8-bit and 16-bit native types (@code{byte}, +@code{short}, @code{char}, and @code{boolean}) are @emph{not} widened +to 32 bits. Note that the Java VM does extend 8-bit and 16-bit types +to 32 bits when on the VM stack or temporary registers. + +If you include the @code{gcjh}-generated header for a +class, you can access fields of Java classes in the @emph{natural} +way. For example, given the following Java class: + +@example +public class Int +@{ + public int i; + public Int (int i) @{ this.i = i; @} + public static Int zero = new Int(0); +@} +@end example + +you can write: + +@example +#include <gcj/cni.h>; +#include <Int>; + +Int* +mult (Int *p, jint k) +@{ + if (k == 0) + return Int::zero; // @r{Static member access.} + return new Int(p->i * k); +@} +@end example + + +@subsection Access specifiers + +CNI does not strictly enforce the Java access +specifiers, because Java permissions cannot be directly mapped +into C++ permission. Private Java fields and methods are mapped +to private C++ fields and methods, but other fields and methods +are mapped to public fields and methods. + + + +@node Class Initialization +@section Class Initialization + +Java requires that each class be automatically initialized at the time +of the first active use. Initializing a class involves +initializing the static fields, running code in class initializer +methods, and initializing base classes. There may also be +some implementation specific actions, such as allocating +@code{String} objects corresponding to string literals in +the code. + +The GCJ compiler inserts calls to @code{JvInitClass} at appropriate +places to ensure that a class is initialized when required. The C++ +compiler does not insert these calls automatically---it is the +programmer's responsibility to make sure classes are initialized. +However, this is fairly painless because of the conventions assumed by +the Java system. + +First, @code{libgcj} will make sure a class is initialized before an +instance of that object is created. This is one of the +responsibilities of the @code{new} operation. This is taken care of +both in Java code, and in C++ code. When G++ sees a @code{new} of a +Java class, it will call a routine in @code{libgcj} to allocate the +object, and that routine will take care of initializing the class. +Note however that this does not happen for Java arrays; you must +allocate those using the appropriate CNI function. It follows that +you can access an instance field, or call an instance (non-static) +method and be safe in the knowledge that the class and all of its base +classes have been initialized. + +Invoking a static method is also safe. This is because the +Java compiler adds code to the start of a static method to make sure +the class is initialized. However, the C++ compiler does not +add this extra code. Hence, if you write a native static method +using CNI, you are responsible for calling @code{JvInitClass} +before doing anything else in the method (unless you are sure +it is safe to leave it out). + +Accessing a static field also requires the class of the +field to be initialized. The Java compiler will generate code +to call @code{JvInitClass} before getting or setting the field. +However, the C++ compiler will not generate this extra code, +so it is your responsibility to make sure the class is +initialized before you access a static field from C++. + + +@node Object allocation +@section Object allocation + +New Java objects are allocated using a +@dfn{class instance creation expression}, e.g.: + +@example +new @var{Type} ( ... ) +@end example + +The same syntax is used in C++. The main difference is that +C++ objects have to be explicitly deleted; in Java they are +automatically deleted by the garbage collector. +Using @acronym{CNI}, you can allocate a new Java object +using standard C++ syntax and the C++ compiler will allocate +memory from the garbage collector. If you have overloaded +constructors, the compiler will choose the correct one +using standard C++ overload resolution rules. + +@noindent For example: + +@example +java::util::Hashtable *ht = new java::util::Hashtable(120); +@end example + + +@node Memory allocation +@section Memory allocation + +When allocating memory in @acronym{CNI} methods it is best to handle +out-of-memory conditions by throwing a Java exception. These +functions are provided for that purpose: + +@deftypefun void* JvMalloc (jsize @var{size}) +Calls malloc. Throws @code{java.lang.OutOfMemoryError} if allocation +fails. +@end deftypefun + +@deftypefun void* JvRealloc (void* @var{ptr}, jsize @var{size}) +Calls realloc. Throws @code{java.lang.OutOfMemoryError} if +reallocation fails. +@end deftypefun + +@deftypefun void JvFree (void* @var{ptr}) +Calls free. +@end deftypefun + +@node Arrays +@section Arrays + +While in many ways Java is similar to C and C++, it is quite different +in its treatment of arrays. C arrays are based on the idea of pointer +arithmetic, which would be incompatible with Java's security +requirements. Java arrays are true objects (array types inherit from +@code{java.lang.Object}). An array-valued variable is one that +contains a reference (pointer) to an array object. + +Referencing a Java array in C++ code is done using the +@code{JArray} template, which as defined as follows: + +@example +class __JArray : public java::lang::Object +@{ +public: + int length; +@}; + +template<class T> +class JArray : public __JArray +@{ + T data[0]; +public: + T& operator[](jint i) @{ return data[i]; @} +@}; +@end example + + +There are a number of @code{typedef}s which correspond to @code{typedef}s +from the @acronym{JNI}. Each is the type of an array holding objects +of the relevant type: + +@example +typedef __JArray *jarray; +typedef JArray<jobject> *jobjectArray; +typedef JArray<jboolean> *jbooleanArray; +typedef JArray<jbyte> *jbyteArray; +typedef JArray<jchar> *jcharArray; +typedef JArray<jshort> *jshortArray; +typedef JArray<jint> *jintArray; +typedef JArray<jlong> *jlongArray; +typedef JArray<jfloat> *jfloatArray; +typedef JArray<jdouble> *jdoubleArray; +@end example + + +@deftypemethod {template<class T>} T* elements (JArray<T> @var{array}) +This template function can be used to get a pointer to the elements of +the @code{array}. For instance, you can fetch a pointer to the +integers that make up an @code{int[]} like so: + +@example +extern jintArray foo; +jint *intp = elements (foo); +@end example + +The name of this function may change in the future. +@end deftypemethod + + +@deftypefun jobjectArray JvNewObjectArray (jsize @var{length}, jclass @var{klass}, jobject @var{init}) +This creates a new array whose elements have reference type. +@code{klass} is the type of elements of the array and +@code{init} is the initial value put into every slot in the array. +@end deftypefun + +@example +using namespace java::lang; +JArray<String *> *array + = (JArray<String *> *) JvNewObjectArray(length, &String::class$, NULL); +@end example + + +@subsection Creating arrays + +For each primitive type there is a function which can be used to +create a new array of that type. The name of the function is of the +form: + +@example +JvNew@var{Type}Array +@end example + +@noindent For example: + +@example +JvNewBooleanArray +@end example + +@noindent can be used to create an array of Java primitive boolean types. + +@noindent The following function definition is the template for all such functions: + +@deftypefun jbooleanArray JvNewBooleanArray (jint @var{length}) +Creates an array @var{length} indices long. +@end deftypefun + +@deftypefun jsize JvGetArrayLength (jarray @var{array}) +Returns the length of the @var{array}. +@end deftypefun + + +@node Methods +@section Methods + +Java methods are mapped directly into C++ methods. +The header files generated by @code{gcjh} +include the appropriate method definitions. +Basically, the generated methods have the same names and +@emph{corresponding} types as the Java methods, +and are called in the natural manner. + +@subsection Overloading + +Both Java and C++ provide method overloading, where multiple +methods in a class have the same name, and the correct one is chosen +(at compile time) depending on the argument types. +The rules for choosing the correct method are (as expected) more complicated +in C++ than in Java, but given a set of overloaded methods +generated by @code{gcjh} the C++ compiler will choose +the expected one. + +Common assemblers and linkers are not aware of C++ overloading, +so the standard implementation strategy is to encode the +parameter types of a method into its assembly-level name. +This encoding is called @dfn{mangling}, +and the encoded name is the @dfn{mangled name}. +The same mechanism is used to implement Java overloading. +For C++/Java interoperability, it is important that both the Java +and C++ compilers use the @emph{same} encoding scheme. + +@subsection Static methods + +Static Java methods are invoked in @acronym{CNI} using the standard +C++ syntax, using the @code{::} operator rather +than the @code{.} operator. + +@noindent For example: + +@example +jint i = java::lang::Math::round((jfloat) 2.3); +@end example + +@noindent C++ method definition syntax is used to define a static native method. +For example: + +@example +#include <java/lang/Integer> +java::lang::Integer* +java::lang::Integer::getInteger(jstring str) +@{ + ... +@} +@end example + + +@subsection Object Constructors + +Constructors are called implicitly as part of object allocation +using the @code{new} operator. + +@noindent For example: + +@example +java::lang::Integer *x = new java::lang::Integer(234); +@end example + +Java does not allow a constructor to be a native method. +This limitation can be coded round however because a constructor +can @emph{call} a native method. + + +@subsection Instance methods + +Calling a Java instance method from a C++ @acronym{CNI} method is done +using the standard C++ syntax, e.g.: + +@example +// @r{First create the Java object.} +java::lang::Integer *x = new java::lang::Integer(234); +// @r{Now call a method.} +jint prim_value = x->intValue(); +if (x->longValue == 0) + ... +@end example + +@noindent Defining a Java native instance method is also done the natural way: + +@example +#include <java/lang/Integer.h> + +jdouble +java::lang:Integer::doubleValue() +@{ + return (jdouble) value; +@} +@end example + + +@subsection Interface methods + +In Java you can call a method using an interface reference. This is +supported, but not completely. @xref{Interfaces}. + + + + +@node Strings +@section Strings + +@acronym{CNI} provides a number of utility functions for +working with Java Java @code{String} objects. +The names and interfaces are analogous to those of @acronym{JNI}. + + +@deftypefun jstring JvNewString (const jchar* @var{chars}, jsize @var{len}) +Returns a Java @code{String} object with characters from the array of +Unicode characters @var{chars} up to the index @var{len} in that array. +@end deftypefun + +@deftypefun jstring JvNewStringLatin1 (const char* @var{bytes}, jsize @var{len}) +Returns a Java @code{String} made up of @var{len} bytes from @var{bytes}. +@end deftypefun + + +@deftypefun jstring JvNewStringLatin1 (const char* @var{bytes}) +As above but the length of the @code{String} is @code{strlen(@var{bytes})}. +@end deftypefun + +@deftypefun jstring JvNewStringUTF (const char* @var{bytes}) +Returns a @code{String} which is made up of the UTF encoded characters +present in the C string @var{bytes}. +@end deftypefun + +@deftypefun jchar* JvGetStringChars (jstring @var{str}) +Returns a pointer to an array of characters making up the @code{String} @var{str}. +@end deftypefun + +@deftypefun int JvGetStringUTFLength (jstring @var{str}) +Returns the number of bytes required to encode the contents of the +@code{String} @var{str} in UTF-8. +@end deftypefun + +@deftypefun jsize JvGetStringUTFRegion (jstring @var{str}, jsize @var{start}, jsize @var{len}, char* @var{buf}) +Puts the UTF-8 encoding of a region of the @code{String} @var{str} into +the buffer @code{buf}. The region to fetch is marked by @var{start} and @var{len}. + +Note that @var{buf} is a buffer, not a C string. It is @emph{not} +null terminated. +@end deftypefun + + +@node Mixing with C++ +@section Interoperating with C/C++ + +Because @acronym{CNI} is designed to represent Java classes and methods it +cannot be mixed readily with C/C++ types. + +One important restriction is that Java classes cannot have non-Java +type instance or static variables and cannot have methods which take +non-Java types as arguments or return non-Java types. + +@noindent None of the following is possible with CNI: + +@example + +class ::MyClass : public java::lang::Object +@{ + char* variable; // @r{char* is not a valid Java type.} +@} + + +uint +::SomeClass::someMethod (char *arg) +@{ + . + . + . +@} // @r{@code{uint} is not a valid Java type, neither is @code{char*}} +@end example + +@noindent Of course, it is ok to use C/C++ types within the scope of a method: + + +@example +jint +::SomeClass::otherMethod (jstring str) +@{ + char *arg = ... + . + . + . +@} +@end example + +@subsection RawData + +The above restriction can be problematic, so @acronym{CNI} includes the +@code{gnu.gcj.RawData} class. The @code{RawData} class is a +@dfn{non-scanned reference} type. In other words variables declared +of type @code{RawData} can contain any data and are not checked by the +compiler or memory manager in any way. + +This means that you can put C/C++ data structures (including classes) +in your @acronym{CNI} classes, as long as you use the appropriate cast. + +@noindent Here are some examples: + +@example + +class ::MyClass : public java::lang::Object +@{ + gnu.gcj.RawData string; + + MyClass (); + gnu.gcj.RawData getText (); + void printText (); +@} + +::MyClass::MyClass () +@{ + char* text = ... + string = text; +@} + +gnu.gcj.RawData +::MyClass::getText () +@{ + return string; +@} + +void +::MyClass::printText () +@{ + printf("%s\n", (char*) string); +@} +@end example + + +@subsection RawDataManaged + +@code{gnu.gcj.RawDataManaged} is another type used to indicate special data used +by native code. Unlike the @code{RawData} type, fields declared as +@code{RawDataManaged} will be "marked" by the memory manager and +considered for garbage collection. + +Native data which is allocated using CNI's @code{JvAllocBytes()} +function and stored in a @code{RawDataManaged} will be automatically +freed when the Java object it is associated with becomes unreachable. + +@subsection Native memory allocation + +@deftypefun void* JvAllocBytes (jsize @var{size}) +Allocates @var{size} bytes from the heap. The memory returned is zeroed. +This memory is not scanned for pointers by the garbage collector, but will +be freed if no references to it are discovered. + +This function can be useful if you need to associate some native data with a +Java object. Using a CNI's special @code{RawDataManaged} type, native data +allocated with @code{JvAllocBytes} will be automatically freed when the Java +object itself becomes unreachable. +@end deftypefun + +@subsection Posix signals + +On Posix based systems the @code{libgcj} library uses several signals +internally. @acronym{CNI} code should not attempt to use the same +signals as doing so may cause @code{libgcj} and/or the @acronym{CNI} +code to fail. + +SIGSEGV is used on many systems to generate +@code{NullPointerExceptions}. SIGCHLD is used internally by +@code{Runtime.exec()}. Several other signals (that vary from platform to +platform) can be used by the memory manager and by +@code{Thread.interrupt()}. + +@node Exception Handling +@section Exception Handling + +While C++ and Java share a common exception handling framework, +things are not yet perfectly integrated. The main issue is that the +run-time type information facilities of the two +languages are not integrated. + +Still, things work fairly well. You can throw a Java exception from +C++ using the ordinary @code{throw} construct, and this +exception can be caught by Java code. Similarly, you can catch an +exception thrown from Java using the C++ @code{catch} +construct. + +@noindent Here is an example: + +@example +if (i >= count) + throw new java::lang::IndexOutOfBoundsException(); +@end example + +Normally, G++ will automatically detect when you are writing C++ +code that uses Java exceptions, and handle them appropriately. +However, if C++ code only needs to execute destructors when Java +exceptions are thrown through it, GCC will guess incorrectly. Sample +problematic code: + +@example +struct S @{ ~S(); @}; + +extern void bar(); // @r{Is implemented in Java and may throw exceptions.} + +void foo() +@{ + S s; + bar(); +@} +@end example + +The usual effect of an incorrect guess is a link failure, complaining of +a missing routine called @code{__gxx_personality_v0}. + +You can inform the compiler that Java exceptions are to be used in a +translation unit, irrespective of what it might think, by writing +@code{#pragma GCC java_exceptions} at the head of the +file. This @code{#pragma} must appear before any +functions that throw or catch exceptions, or run destructors when +exceptions are thrown through them. + +@node Synchronization +@section Synchronization + +Each Java object has an implicit monitor. +The Java VM uses the instruction @code{monitorenter} to acquire +and lock a monitor, and @code{monitorexit} to release it. + +The corresponding CNI macros are @code{JvMonitorEnter} and +@code{JvMonitorExit} (JNI has similar methods @code{MonitorEnter} +and @code{MonitorExit}). + + +The Java source language does not provide direct access to these primitives. +Instead, there is a @code{synchronized} statement that does an +implicit @code{monitorenter} before entry to the block, +and does a @code{monitorexit} on exit from the block. +Note that the lock has to be released even when the block is abnormally +terminated by an exception, which means there is an implicit +@code{try finally} surrounding synchronization locks. + +From C++, it makes sense to use a destructor to release a lock. +@acronym{CNI} defines the following utility class: + +@example +class JvSynchronize() @{ + jobject obj; + JvSynchronize(jobject o) @{ obj = o; JvMonitorEnter(o); @} + ~JvSynchronize() @{ JvMonitorExit(obj); @} +@}; +@end example + +So this Java code: + +@example +synchronized (OBJ) +@{ + CODE +@} +@end example + +@noindent might become this C++ code: + +@example +@{ + JvSynchronize dummy (OBJ); + CODE; +@} +@end example + +Java also has methods with the @code{synchronized} attribute. +This is equivalent to wrapping the entire method body in a +@code{synchronized} statement. +(Alternatively, an implementation could require the caller to do +the synchronization. This is not practical for a compiler, because +each virtual method call would have to test at run-time if +synchronization is needed.) Since in @command{gcj} +the @code{synchronized} attribute is handled by the +method implementation, it is up to the programmer +of a synchronized native method to handle the synchronization +(in the C++ implementation of the method). +In other words, you need to manually add @code{JvSynchronize} +in a @code{native synchronized} method. + +@node Invocation +@section Invocation + +CNI permits C++ applications to make calls into Java classes, in addition to +allowing Java code to call into C++. Several functions, known as the +@dfn{invocation API}, are provided to support this. + +@deftypefun jint JvCreateJavaVM (JvVMInitArgs* @var{vm_args}) + +Initializes the Java runtime. This function performs essential initialization +of the threads interface, garbage collector, exception handling and other key +aspects of the runtime. It must be called once by an application with +a non-Java @code{main()} function, before any other Java or CNI calls are made. +It is safe, but not recommended, to call @code{JvCreateJavaVM()} more than +once provided it is only called from a single thread. +The @var{vmargs} parameter can be used to specify initialization parameters +for the Java runtime. It may be @code{NULL}. + +JvVMInitArgs represents a list of virtual machine initialization +arguments. @code{JvCreateJavaVM()} ignores the version field. + +@example +typedef struct JvVMOption +@{ + // a VM initialization option + char* optionString; + // extra information associated with this option + void* extraInfo; +@} JvVMOption; + +typedef struct JvVMInitArgs +@{ + // for compatibility with JavaVMInitArgs + jint version; + + // number of VM initialization options + jint nOptions; + + // an array of VM initialization options + JvVMOption* options; + + // true if the option parser should ignore unrecognized options + jboolean ignoreUnrecognized; +@} JvVMInitArgs; +@end example + +@code{JvCreateJavaVM()} returns @code{0} upon success, or @code{-1} if +the runtime is already initialized. + +@emph{Note:} In GCJ 3.1, the @code{vm_args} parameter is ignored. It +is recognized and used as of release 4.0. +@end deftypefun + +@deftypefun java::lang::Thread* JvAttachCurrentThread (jstring @var{name}, java::lang::ThreadGroup* @var{group}) +Registers an existing thread with the Java runtime. This must be called once +from each thread, before that thread makes any other Java or CNI calls. It +must be called after @code{JvCreateJavaVM}. +@var{name} specifies a name for the thread. It may be @code{NULL}, in which +case a name will be generated. +@var{group} is the ThreadGroup in which this thread will be a member. If it +is @code{NULL}, the thread will be a member of the main thread group. +The return value is the Java @code{Thread} object that represents the thread. +It is safe to call @code{JvAttachCurrentThread()} more than once from the same +thread. If the thread is already attached, the call is ignored and the current +thread object is returned. +@end deftypefun + +@deftypefun jint JvDetachCurrentThread () +Unregisters a thread from the Java runtime. This should be called by threads +that were attached using @code{JvAttachCurrentThread()}, after they have +finished making calls to Java code. This ensures that any resources associated +with the thread become eligible for garbage collection. +This function returns @code{0} upon success, or @code{-1} if the current thread +is not attached. +@end deftypefun + +@subsection Handling uncaught exceptions + +If an exception is thrown from Java code called using the invocation API, and +no handler for the exception can be found, the runtime will abort the +application. In order to make the application more robust, it is recommended +that code which uses the invocation API be wrapped by a top-level try/catch +block that catches all Java exceptions. + +@subsection Example + +The following code demonstrates the use of the invocation API. In this +example, the C++ application initializes the Java runtime and attaches +itself. The @code{java.lang.System} class is initialized in order to +access its @code{out} field, and a Java string is printed. Finally, the thread +is detached from the runtime once it has finished making Java calls. Everything +is wrapped with a try/catch block to provide a default handler for any uncaught +exceptions. + +The example can be compiled with @command{c++ -c test.cc; gcj test.o}. + +@example +// test.cc +#include <gcj/cni.h> +#include <java/lang/System.h> +#include <java/io/PrintStream.h> +#include <java/lang/Throwable.h> + +int main(int argc, char *argv[]) +@{ + using namespace java::lang; + + try + @{ + JvCreateJavaVM(NULL); + JvAttachCurrentThread(NULL, NULL); + + String *message = JvNewStringLatin1("Hello from C++"); + JvInitClass(&System::class$); + System::out->println(message); + + JvDetachCurrentThread(); + @} + catch (Throwable *t) + @{ + System::err->println(JvNewStringLatin1("Unhandled Java exception:")); + t->printStackTrace(); + @} +@} +@end example + +@node Reflection +@section Reflection + +Reflection is possible with CNI code, it functions similarly to how it +functions with JNI@. + +@c clean this up... I mean, what are the types jfieldID and jmethodID in JNI? +The types @code{jfieldID} and @code{jmethodID} +are as in JNI@. + +@noindent The functions: + +@itemize +@item @code{JvFromReflectedField}, +@item @code{JvFromReflectedMethod}, +@item @code{JvToReflectedField} +@item @code{JvToFromReflectedMethod} +@end itemize + +@noindent will be added shortly, as will other functions corresponding to JNI@. + + +@node System properties +@chapter System properties + +The runtime behavior of the @code{libgcj} library can be modified by setting +certain system properties. These properties can be compiled into the program +using the @code{-D@var{name}[=@var{value}]} option to @command{gcj} or by +setting them explicitly in the program by calling the +@code{java.lang.System.setProperty()} method. Some system properties are only +used for informational purposes (like giving a version number or a user name). +A program can inspect the current value of a property by calling the +@code{java.lang.System.getProperty()} method. + +@menu +* Standard Properties:: Standard properties supported by @code{libgcj} +* GNU Classpath Properties:: Properties found in Classpath based libraries +* libgcj Runtime Properties:: Properties specific to @code{libgcj} +@end menu + +@node Standard Properties +@section Standard Properties + +The following properties are normally found in all implementations of the core +libraries for the Java language. + +@table @gcctabopt + +@item java.version +The @code{libgcj} version number. + +@item java.vendor +Set to @samp{The Free Software Foundation, Inc.} + +@item java.vendor.url +Set to @uref{http://gcc.gnu.org/java/}. + +@item java.home +The directory where @code{gcj} was installed. Taken from the @code{--prefix} +option given to @command{configure}. + +@item java.class.version +The class format version number supported by the libgcj byte code interpreter. +(Currently @samp{46.0}) + +@item java.vm.specification.version +The Virtual Machine Specification version implemented by @code{libgcj}. +(Currently @samp{1.0}) + +@item java.vm.specification.vendor +The name of the Virtual Machine specification designer. + +@item java.vm.specification.name +The name of the Virtual Machine specification +(Set to @samp{Java Virtual Machine Specification}). + +@item java.vm.version +The @command{gcj} version number. + +@item java.vm.vendor +Set to @samp{The Free Software Foundation, Inc.} + +@item java.vm.name +Set to @samp{GNU libgcj}. + +@item java.specification.version +The Runtime Environment specification version implemented by @code{libgcj}. +(Currently set to @samp{1.3}) + +@item java.specification.vendor +The Runtime Environment specification designer. + +@item java.specification.name +The name of the Runtime Environment specification +(Set to @samp{Java Platform API Specification}). + +@item java.class.path +The paths (jar files, zip files and directories) used for finding class files. + +@item java.library.path +Directory path used for finding native libraries. + +@item java.io.tmpdir +The directory used to put temporary files in. + +@item java.compiler +Name of the Just In Time compiler to use by the byte code interpreter. +Currently not used in @code{libgcj}. + +@item java.ext.dirs +Directories containing jar files with extra libraries. Will be used when +resolving classes. + +@item java.protocol.handler.pkgs +A @samp{|} separated list of package names that is used to find classes that +implement handlers for @code{java.net.URL}. + +@item java.rmi.server.codebase +A list of URLs that is used by the @code{java.rmi.server.RMIClassLoader} +to load classes from. + +@item jdbc.drivers +A list of class names that will be loaded by the @code{java.sql.DriverManager} +when it starts up. + +@item file.separator +The separator used in when directories are included in a filename +(normally @samp{/} or @samp{\} ). + +@item file.encoding +The default character encoding used when converting platform native files to +Unicode (usually set to @samp{8859_1}). + +@item path.separator +The standard separator used when a string contains multiple paths +(normally @samp{:} or @samp{;}), the string is usually not a valid character +to use in normal directory names.) + +@item line.separator +The default line separator used on the platform (normally @samp{\n}, @samp{\r} +or a combination of those two characters). + +@item policy.provider +The class name used for the default policy provider returned by +@code{java.security.Policy.getPolicy}. + +@item user.name +The name of the user running the program. Can be the full name, the login name +or empty if unknown. + +@item user.home +The default directory to put user specific files in. + +@item user.dir +The current working directory from which the program was started. + +@item user.language +The default language as used by the @code{java.util.Locale} class. + +@item user.region +The default region as used by the @code{java.util.Local} class. + +@item user.variant +The default variant of the language and region local used. + +@item user.timezone +The default timezone as used by the @code{java.util.TimeZone} class. + +@item os.name +The operating system/kernel name that the program runs on. + +@item os.arch +The hardware that we are running on. + +@item os.version +The version number of the operating system/kernel. + +@item awt.appletWarning +The string to display when an untrusted applet is displayed. +Returned by @code{java.awt.Window.getWarningString()} when the window is +``insecure''. + +@item awt.toolkit +The class name used for initializing the default @code{java.awt.Toolkit}. +Defaults to @code{gnu.awt.gtk.GtkToolkit}. + +@item http.proxyHost +Name of proxy host for http connections. + +@item http.proxyPort +Port number to use when a proxy host is in use. + +@end table + +@node GNU Classpath Properties +@section GNU Classpath Properties + +@code{libgcj} is based on the GNU Classpath (Essential Libraries for Java) a +GNU project to create free core class libraries for use with virtual machines +and compilers for the Java language. The following properties are common to +libraries based on GNU Classpath. + +@table @gcctabopt + +@item gcj.dumpobject +Enables printing serialization debugging by the @code{java.io.ObjectInput} and +@code{java.io.ObjectOutput} classes when set to something else then the empty +string. Only used when running a debug build of the library. + +@item gnu.classpath.vm.shortname +This is a succinct name of the virtual machine. For @code{libgcj}, +this will always be @samp{libgcj}. + +@item gnu.classpath.home.url +A base URL used for finding system property files (e.g., +@file{classpath.security}). By default this is a @samp{file:} URL +pointing to the @file{lib} directory under @samp{java.home}. + +@end table + +@node libgcj Runtime Properties +@section libgcj Runtime Properties + +The following properties are specific to the @code{libgcj} runtime and will +normally not be found in other core libraries for the java language. + +@table @gcctabopt + +@item java.fullversion +The combination of @code{java.vm.name} and @code{java.vm.version}. + +@item java.vm.info +Same as @code{java.fullversion}. + +@item impl.prefix +Used by the @code{java.net.DatagramSocket} class when set to something else +then the empty string. When set all newly created @code{DatagramSocket}s will +try to load a class @code{java.net.[impl.prefix]DatagramSocketImpl} instead of +the normal @code{java.net.PlainDatagramSocketImpl}. + +@item gnu.gcj.progname +The class or binary name that was used to invoke the program. This will be +the name of the "main" class in the case where the @code{gij} front end is +used, or the program binary name in the case where an application is compiled +to a native binary. + +@item gnu.gcj.user.realname +The real name of the user, as taken from the password file. This may +not always hold only the user's name (as some sites put extra +information in this field). Also, this property is not available on +all platforms. + +@item gnu.gcj.runtime.NameFinder.use_addr2line +Whether an external process, @command{addr2line}, should be used to determine +line number information when tracing the stack. Setting this to @code{false} +may suppress line numbers when printing stack traces and when using +the java.util.logging infrastructure. However, performance may improve +significantly for applications that print stack traces or make logging calls +frequently. + +@item gnu.gcj.runtime.NameFinder.show_raw +Whether the address of a stack frame should be printed when the line +number is unavailable. Setting this to @code{true} will cause the name +of the object and the offset within that object to be printed when no +line number is available. This allows for off-line decoding of +stack traces if necessary debug information is available. The default +is @code{false}, no raw addresses are printed. + +@item gnu.gcj.runtime.NameFinder.remove_unknown +Whether stack frames for non-java code should be included in a stack +trace. The default value is @code{true}, stack frames for non-java +code are suppressed. Setting this to @code{false} will cause any +non-java stack frames to be printed in addition to frames for the java +code. + +@item gnu.gcj.runtime.VMClassLoader.library_control +This controls how shared libraries are automatically loaded by the +built-in class loader. If this property is set to @samp{full}, a full +search is done for each requested class. If this property is set to +@samp{cache}, then any failed lookups are cached and not tried again. +If this property is set to @samp{never} (the default), then lookups +are never done. For more information, @xref{Extensions}. + +@item gnu.gcj.runtime.endorsed.dirs +This is like the standard @code{java.endorsed.dirs}, property, but +specifies some extra directories which are searched after the standard +endorsed directories. This is primarily useful for telling +@code{libgcj} about additional libraries which are ordinarily +incorporated into the JDK, and which should be loaded by the bootstrap +class loader, but which are not yet part of @code{libgcj} itself for +some reason. + +@item gnu.gcj.jit.compiler +@c FIXME we should probably have a whole node on this... +This is the full path to @command{gcj} executable which should be +used to compile classes just-in-time when +@code{ClassLoader.defineClass} is called. If not set, @command{gcj} +will not be invoked by the runtime; this can also be controlled via +@code{Compiler.disable}. + +@item gnu.gcj.jit.options +This is a space-separated string of options which should be passed to +@command{gcj} when in JIT mode. If not set, a sensible default is +chosen. + +@item gnu.gcj.jit.cachedir +This is the directory where cached shared library files are +stored. If not set, JIT compilation is disabled. This should never +be set to a directory that is writable by any other user. + +@item gnu.gcj.precompiled.db.path +This is a sequence of file names, each referring to a file created by +@command{gcj-dbtool}. These files will be used by @code{libgcj} to +find shared libraries corresponding to classes that are loaded from +bytecode. @code{libgcj} often has a built-in default database; it +can be queried using @code{gcj-dbtool -p}. + +@end table + + +@node Resources +@chapter Resources + +While writing @command{gcj} and @code{libgcj} we have, of course, relied +heavily on documentation from Sun Microsystems. In particular we have +used The Java Language Specification (both first and second editions), +the Java Class Libraries (volumes one and two), and the Java Virtual +Machine Specification. In addition we've used the online documentation +at @uref{http://java.sun.com/}. + +The current @command{gcj} home page is +@uref{http://gcc.gnu.org/java/}. + +For more information on gcc, see @uref{http://gcc.gnu.org/}. + +Some @code{libgcj} testing is done using the Mauve test suite. This is +a free software Java class library test suite which is being written +because the JCK is not free. See +@uref{http://sources.redhat.com/mauve/} for more information. + + +@node Index +@unnumbered Index + +@printindex cp + +@bye diff --git a/gcc/java/java-except.h b/gcc/java/java-except.h new file mode 100644 index 000000000..c940e6c10 --- /dev/null +++ b/gcc/java/java-except.h @@ -0,0 +1,68 @@ +/* Definitions for exception handling for use by the GNU compiler + for the Java(TM) language compiler. + Copyright (C) 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2007 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +struct eh_range + { + /* The (byte-code PC) range of the handled block. */ + int start_pc; + int end_pc; + + /* A list of handlers. For each element in the list, + the TREE_PURPOSE is the handled class (NULL_EXPR for a finally block), + and the TREE_VALUE is the LABEL_DECL of the handler. */ + tree handlers; + + /* Surrounding handler, if any. */ + struct eh_range *outer; + + /* The first child range. It is is nested inside this range + (i.e. this.start_pc <= first_child.end_pc + && this.end_pc >= first_child.end_pc). + The children are linked together using next_sibling, and are sorted + by increasing start_pc and end_pc (we do not support non-nested + overlapping ranges). */ + struct eh_range *first_child; + + /* The next child of outer, in address order. */ + struct eh_range *next_sibling; + + /* True if this range has already been expanded. */ + int expanded; + + /* The TRY_CATCH_EXPR for this EH range. */ + tree stmt; + }; + +/* A dummy range that represents the entire method. */ +extern struct eh_range whole_range; + +#define NULL_EH_RANGE (&whole_range) + +extern struct eh_range * find_handler (int); +extern void method_init_exceptions (void); +extern void maybe_start_try (int, int); +extern void add_handler (int, int, tree, tree); +extern void expand_end_java_handler (struct eh_range *); +extern bool sanity_check_exception_range (struct eh_range *); diff --git a/gcc/java/java-gimplify.c b/gcc/java/java-gimplify.c new file mode 100644 index 000000000..3def7223e --- /dev/null +++ b/gcc/java/java-gimplify.c @@ -0,0 +1,170 @@ +/* Java(TM) language-specific gimplification routines. + Copyright (C) 2003, 2004, 2006, 2007, 2007, 2008, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "java-tree.h" +#include "tree-dump.h" +#include "gimple.h" + +static tree java_gimplify_block (tree); +static enum gimplify_status java_gimplify_modify_expr (tree *); +static enum gimplify_status java_gimplify_self_mod_expr (tree *, gimple_seq *, + gimple_seq *); + +static void dump_java_tree (enum tree_dump_index, tree); + +/* Convert a Java tree to GENERIC. */ + +void +java_genericize (tree fndecl) +{ + walk_tree (&DECL_SAVED_TREE (fndecl), java_replace_references, NULL, NULL); + dump_java_tree (TDI_original, fndecl); +} + +/* Gimplify a Java tree. */ + +int +java_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) +{ + enum tree_code code = TREE_CODE (*expr_p); + + switch (code) + { + case BLOCK: + *expr_p = java_gimplify_block (*expr_p); + break; + + case MODIFY_EXPR: + return java_gimplify_modify_expr (expr_p); + + case POSTINCREMENT_EXPR: + case POSTDECREMENT_EXPR: + case PREINCREMENT_EXPR: + case PREDECREMENT_EXPR: + return java_gimplify_self_mod_expr (expr_p, pre_p, post_p); + + /* These should already be lowered before we get here. */ + case URSHIFT_EXPR: + case COMPARE_EXPR: + case COMPARE_L_EXPR: + case COMPARE_G_EXPR: + gcc_unreachable (); + + default: + return GS_UNHANDLED; + } + + return GS_OK; +} + +static enum gimplify_status +java_gimplify_modify_expr (tree *modify_expr_p) +{ + tree modify_expr = *modify_expr_p; + tree lhs = TREE_OPERAND (modify_expr, 0); + tree rhs = TREE_OPERAND (modify_expr, 1); + tree lhs_type = TREE_TYPE (lhs); + + if (lhs_type != TREE_TYPE (rhs)) + /* Fix up type mismatches to make legal GIMPLE. These are + generated in several places, in particular null pointer + assignment and subclass assignment. */ + TREE_OPERAND (modify_expr, 1) = convert (lhs_type, rhs); + + return GS_UNHANDLED; +} + +/* Special case handling for volatiles: we need to generate a barrier + between the reading and the writing. */ + +static enum gimplify_status +java_gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, + gimple_seq *post_p ATTRIBUTE_UNUSED) +{ + tree lhs = TREE_OPERAND (*expr_p, 0); + + if (TREE_CODE (lhs) == COMPONENT_REF + && TREE_THIS_VOLATILE (TREE_OPERAND (lhs, 1))) + TREE_THIS_VOLATILE (lhs) = 1; + + return GS_UNHANDLED; +} + + +/* Gimplify BLOCK into a BIND_EXPR. */ + +static tree +java_gimplify_block (tree java_block) +{ + tree decls = BLOCK_VARS (java_block); + tree body = BLOCK_EXPR_BODY (java_block); + gimple outer = gimple_current_bind_expr (); + tree block; + + /* Don't bother with empty blocks. */ + if (! body) + return build_empty_stmt (input_location); + + if (IS_EMPTY_STMT (body)) + return body; + + /* Make a proper block. Java blocks are unsuitable for BIND_EXPR + because they use BLOCK_SUBBLOCKS for another purpose. */ + block = make_node (BLOCK); + BLOCK_VARS (block) = decls; + + /* The TREE_USED flag on a block determines whether the debug output + routines generate info for the variables in that block. */ + TREE_USED (block) = 1; + + if (outer != NULL) + { + tree b = gimple_bind_block (outer); + BLOCK_SUBBLOCKS (b) = chainon (BLOCK_SUBBLOCKS (b), block); + } + BLOCK_EXPR_BODY (java_block) = NULL_TREE; + + return build3 (BIND_EXPR, TREE_TYPE (java_block), decls, body, block); +} + +/* Dump a tree of some kind. This is a convenience wrapper for the + dump_* functions in tree-dump.c. */ +static void +dump_java_tree (enum tree_dump_index phase, tree t) +{ + FILE *stream; + int flags; + + stream = dump_begin (phase, &flags); + flags |= TDF_SLIM; + if (stream) + { + dump_node (t, flags, stream); + dump_end (phase, stream); + } +} diff --git a/gcc/java/java-opcodes.h b/gcc/java/java-opcodes.h new file mode 100644 index 000000000..12b3a72f7 --- /dev/null +++ b/gcc/java/java-opcodes.h @@ -0,0 +1,6 @@ +enum java_opcode { +#define JAVAOP(NAME, CODE, KIND, TYPE, VALUE) OPCODE_##NAME = CODE, +#include "javaop.def" +#undef JAVAOP +LAST_AND_UNUSED_JAVA_OPCODE +}; diff --git a/gcc/java/java-tree.def b/gcc/java/java-tree.def new file mode 100644 index 000000000..e565499b1 --- /dev/null +++ b/gcc/java/java-tree.def @@ -0,0 +1,38 @@ +/* This file contains the definitions and documentation for the + extra tree codes used by gcj. + Copyright (C) 1996, 2007 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + + +/* Shift right, logical. */ +DEFTREECODE (URSHIFT_EXPR, "urshift_expr", tcc_binary, 2) + +/* Return -1, 0, 1 depending on whether the first argument is + less, equal, or greater to the second argument. */ +DEFTREECODE (COMPARE_EXPR, "compare_expr", tcc_binary, 2) + +/* Same as COMPARE_EXPR, but if either value is NaN, the result is -1. */ +DEFTREECODE (COMPARE_L_EXPR, "compare_l_expr", tcc_binary, 2) +/* Same as COMPARE_EXPR, but if either value is NaN, the result is 1. */ +DEFTREECODE (COMPARE_G_EXPR, "compare_g_expr", tcc_binary, 2) + +/* +Local variables: +mode:c +End: +*/ diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h new file mode 100644 index 000000000..3addcca09 --- /dev/null +++ b/gcc/java/java-tree.h @@ -0,0 +1,1519 @@ +/* Definitions for parsing and type checking for the GNU compiler for + the Java(TM) language. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */ + +#ifndef GCC_JAVA_TREE_H +#define GCC_JAVA_TREE_H + +#include "hashtab.h" + +struct JCF; + +/* Usage of TREE_LANG_FLAG_?: + 2: QUALIFIED_P (in IDENTIFIER_NODE) + CLASS_FILE_P (in a TRANSLATION_UNIT_DECL in current_file_list) + 3: HAS_FINALIZER (in RECORD_TYPE) + 4: IS_A_COMMAND_LINE_FILENAME_P (in IDENTIFIER_NODE) + IS_ARRAY_LENGTH_ACCESS (in INDIRECT_REF) + 5: HAS_BEEN_ALREADY_PARSED_P (in IDENTIFIER_NODE) + + Usage of TYPE_LANG_FLAG_?: + 1: TYPE_ARRAY_P (in RECORD_TYPE). + 2: CLASS_PARSED_P (in RECORD_TYPE). + 4: CLASS_P (in RECORD_TYPE). + 5: CLASS_FROM_CURRENTLY_COMPILED_P (in RECORD_TYPE) + 6: CLASS_BEING_LAIDOUT (in RECORD_TYPE) + + Usage of DECL_LANG_FLAG_?: + 0: METHOD_DEPRECATED (in FUNCTION_DECL). + FIELD_DEPRECATED (in FIELD_DECL). + CLASS_DEPRECATED (in TYPE_DECL). + 1: METHOD_PUBLIC (in FUNCTION_DECL). + FIELD_PUBLIC (in FIELD_DECL). + CLASS_PUBLIC (in TYPE_DECL). + 2: METHOD_STATIC (in FUNCTION_DECL). + (But note that FIELD_STATIC uses TREE_STATIC!) + FIELD_SYNTHETIC (in FIELD_DECL) + CLASS_COMPLETE_P (in TYPE_DECL) + 3: METHOD_FINAL (in FUNCTION_DECL) + FIELD_FINAL (in FIELD_DECL) + CLASS_FINAL (in TYPE_DECL) + DECL_FINAL (in any decl) + 4: METHOD_SYNCHRONIZED (in FUNCTION_DECL). + CLASS_INTERFACE (in TYPE_DECL) + FIELD_VOLATILE (int FIELD_DECL) + 5: METHOD_ABSTRACT (in FUNCTION_DECL). + CLASS_ABSTRACT (in TYPE_DECL) + FIELD_TRANSIENT (in FIELD_DECL) + 6: CLASS_SUPER (in TYPE_DECL, ACC_SUPER flag) + 7: DECL_CONSTRUCTOR_P (in FUNCTION_DECL). + CLASS_STATIC (in TYPE_DECL) +*/ + +#define VAR_OR_FIELD_CHECK(DECL) \ + TREE_CHECK3 (DECL, FIELD_DECL, VAR_DECL, PARM_DECL) + +/* True if the class whose TYPE_BINFO this is has a superclass. + (True of all classes except Object.) */ +#define CLASS_HAS_SUPER_FLAG(BINFO) BINFO_FLAG_1 (BINFO) +#define CLASS_HAS_SUPER(TYPE) \ + (TYPE_BINFO (TYPE) && CLASS_HAS_SUPER_FLAG (TYPE_BINFO (TYPE))) + +/* Return the supertype of class TYPE, or NULL_TREE is it has none. */ +#define CLASSTYPE_SUPER(TYPE) (CLASS_HAS_SUPER (TYPE) \ + ? BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (TYPE), 0)) \ + : NULL_TREE) + +/* The class defined by the actual (main) file we are compiling. */ +#define main_class \ + java_global_trees[JTI_MAIN_CLASS] + +/* The class we use as the base for name resolution. It's usually the + class we're generating code for but sometimes it points to an inner + class. If you really want to know the class we're currently + generating code for, use output_class instead. */ +#define current_class \ + java_global_trees[JTI_CURRENT_CLASS] + +/* The class we are currently generating. Really. */ +#define output_class \ + java_global_trees[JTI_OUTPUT_CLASS] + +/* List of virtual decls referred to by this translation unit, used to + generate virtual method offset symbol table. */ + +/* The virtual offset table. This is emitted as uninitialized data of + the required length, and filled out at run time during class + linking. */ + +/* The virtual offset symbol table. Used by the runtime to fill out + the otable. */ + +/* Resource name. */ +extern const char *resource_name; + +/* Turned to 1 if -Wall was encountered. See lang.c for their meanings. */ +extern int flag_wall; + +/* The Java .class file that provides main_class; the main input file. */ +extern GTY(()) struct JCF * current_jcf; + +/* Set to nonzero value in order to emit class initialization code + before static field references. */ +extern int always_initialize_class_p; + +extern int flag_verify_invocations; + +/* Largest pc so far in this method that has been passed to lookup_label. */ +extern int highest_label_pc_this_method; + +/* Base value for this method to add to pc to get generated label. */ +extern int start_label_pc_this_method; + +typedef struct CPool constant_pool; + +#define CONSTANT_ResolvedFlag 16 + +/* Don't eagerly resolve this entry. When this flag is set, constant + pool entries are resolved only at runtime when the entry is first + referred to. */ +#define CONSTANT_LazyFlag 32 + +/* The cpool->data[i] for a ResolvedString points to a STRING_CST. */ +#define CONSTANT_ResolvedString (CONSTANT_String+CONSTANT_ResolvedFlag) + +/* The cpool->data[i] for a ResolvedClass points to a RECORD_TYPE. */ +#define CONSTANT_ResolvedClass (CONSTANT_Class+CONSTANT_ResolvedFlag) + +#define CPOOL_UTF(CPOOL, INDEX) ((CPOOL)->data[INDEX].t) + +/* A NameAndType constant is represented as a TREE_LIST. + The type is the signature string (as an IDENTIFIER_NODE). */ + +#define NAME_AND_TYPE_NAME(CPOOL, IDX) \ + CPOOL_UTF(CPOOL, CPOOL_USHORT1(CPOOL, IDX)) +#define NAME_AND_TYPE_SIGNATURE(CPOOL, IDX) \ + CPOOL_UTF(CPOOL, CPOOL_USHORT2(CPOOL, IDX)) + +/* A FieldRef, MethodRef or InterfaceMethodRef constant + is represented as a TREE_LIST. */ + +#define COMPONENT_REF_CLASS_INDEX(CPOOL, IDX) CPOOL_USHORT1(CPOOL, IDX) +#define COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX) CPOOL_USHORT2(CPOOL, IDX) +#define COMPONENT_REF_NAME(CPOOL, IDX) \ + NAME_AND_TYPE_NAME (CPOOL, COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX)) +#define COMPONENT_REF_SIGNATURE(CPOOL, IDX) \ + NAME_AND_TYPE_SIGNATURE (CPOOL, COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX)) + +extern GTY(()) tree java_lang_cloneable_identifier_node; +extern GTY(()) tree java_io_serializable_identifier_node; +extern GTY(()) tree gcj_abi_version; + +/* The decl for the .constants field of an instance of Class. */ +extern GTY(()) tree constants_field_decl_node; + +/* The decl for the .data field of an instance of Class. */ +extern GTY(()) tree constants_data_field_decl_node; + +enum java_tree_index +{ + JTI_PROMOTED_BYTE_TYPE_NODE, + JTI_PROMOTED_SHORT_TYPE_NODE, + JTI_PROMOTED_CHAR_TYPE_NODE, + JTI_PROMOTED_BOOLEAN_TYPE_NODE, + + JTI_BYTE_TYPE_NODE, + JTI_SHORT_TYPE_NODE, + JTI_INT_TYPE_NODE, + JTI_LONG_TYPE_NODE, + + JTI_UNSIGNED_BYTE_TYPE_NODE, + JTI_UNSIGNED_SHORT_TYPE_NODE, + JTI_UNSIGNED_INT_TYPE_NODE, + JTI_UNSIGNED_LONG_TYPE_NODE, + + JTI_DECIMAL_INT_MAX_NODE, + JTI_DECIMAL_LONG_MAX_NODE, + + JTI_OBJECT_TYPE_NODE, + JTI_UNQUALIFIED_OBJECT_ID_NODE, + JTI_OBJECT_PTR_TYPE_NODE, + JTI_STRING_TYPE_NODE, + JTI_STRING_PTR_TYPE_NODE, + JTI_THROWABLE_TYPE_NODE, + JTI_EXCEPTION_TYPE_NODE, + JTI_RUNTIME_EXCEPTION_TYPE_NODE, + JTI_ERROR_EXCEPTION_TYPE_NODE, + JTI_RAWDATA_PTR_TYPE_NODE, + + JTI_BYTE_ARRAY_TYPE_NODE, + JTI_SHORT_ARRAY_TYPE_NODE, + JTI_INT_ARRAY_TYPE_NODE, + JTI_LONG_ARRAY_TYPE_NODE, + JTI_BOOLEAN_ARRAY_TYPE_NODE, + JTI_CHAR_ARRAY_TYPE_NODE, + JTI_DOUBLE_ARRAY_TYPE_NODE, + JTI_FLOAT_ARRAY_TYPE_NODE, + JTI_ARRAY_ARRAY_TYPE_NODE, + JTI_OBJECT_ARRAY_TYPE_NODE, + JTI_STRING_ARRAY_TYPE_NODE, + JTI_BOOLEAN_ARRAY_VTABLE, + JTI_BYTE_ARRAY_VTABLE, + JTI_CHAR_ARRAY_VTABLE, + JTI_SHORT_ARRAY_VTABLE, + JTI_INT_ARRAY_VTABLE, + JTI_LONG_ARRAY_VTABLE, + JTI_FLOAT_ARRAY_VTABLE, + JTI_DOUBLE_ARRAY_VTABLE, + JTI_TYPE_IDENTIFIER_NODE, + JTI_INIT_IDENTIFIER_NODE, + JTI_CLINIT_IDENTIFIER_NODE, + JTI_VOID_SIGNATURE_NODE, + JTI_FINALIZE_IDENTIFIER_NODE, + JTI_THIS_IDENTIFIER_NODE, + JTI_ONE_ELT_ARRAY_DOMAIN_TYPE, + + JTI_RETURN_ADDRESS_TYPE_NODE, + + JTI_LONG_ZERO_NODE, + JTI_FLOAT_ZERO_NODE, + JTI_DOUBLE_ZERO_NODE, + JTI_INTEGER_TWO_NODE, + JTI_INTEGER_FOUR_NODE, + + JTI_METHODTABLE_TYPE, + JTI_METHODTABLE_PTR_TYPE, + + JTI_UTF8CONST_TYPE, + JTI_UTF8CONST_PTR_TYPE, + + JTI_CLASS_TYPE_NODE, + JTI_CLASS_PTR_TYPE, + JTI_FIELD_TYPE_NODE, + JTI_CONSTANTS_TYPE_NODE, + JTI_DTABLE_TYPE, + JTI_DTABLE_PTR_TYPE, + JTI_FIELD_PTR_TYPE_NODE, + JTI_FIELD_INFO_UNION_NODE, + JTI_EXCEPTION_TYPE, + JTI_EXCEPTION_PTR_TYPE, + JTI_LINENUMBERENTRY_TYPE, + JTI_LINENUMBERS_TYPE, + JTI_METHOD_TYPE_NODE, + JTI_METHOD_PTR_TYPE_NODE, + JTI_OTABLE_TYPE, + JTI_OTABLE_PTR_TYPE, + JTI_ATABLE_TYPE, + JTI_ATABLE_PTR_TYPE, + JTI_ITABLE_TYPE, + JTI_ITABLE_PTR_TYPE, + JTI_SYMBOL_TYPE, + JTI_SYMBOLS_ARRAY_TYPE, + JTI_SYMBOLS_ARRAY_PTR_TYPE, + JTI_ASSERTION_ENTRY_TYPE, + JTI_ASSERTION_TABLE_TYPE, + + JTI_END_PARAMS_NODE, + + JTI_THROW_NODE, + JTI_ALLOC_OBJECT_NODE, + JTI_ALLOC_NO_FINALIZER_NODE, + JTI_SOFT_INSTANCEOF_NODE, + JTI_SOFT_CHECKCAST_NODE, + JTI_SOFT_INITCLASS_NODE, + JTI_SOFT_NEWARRAY_NODE, + JTI_SOFT_ANEWARRAY_NODE, + JTI_SOFT_MULTIANEWARRAY_NODE, + JTI_SOFT_BADARRAYINDEX_NODE, + JTI_SOFT_NULLPOINTER_NODE, + JTI_SOFT_ABSTRACTMETHOD_NODE, + JTI_SOFT_NOSUCHFIELD_NODE, + JTI_SOFT_CHECKARRAYSTORE_NODE, + JTI_SOFT_MONITORENTER_NODE, + JTI_SOFT_MONITOREXIT_NODE, + JTI_SOFT_LOOKUPINTERFACEMETHOD_NODE, + JTI_SOFT_LOOKUPINTERFACEMETHODBYNAME_NODE, + JTI_SOFT_LOOKUPJNIMETHOD_NODE, + JTI_SOFT_GETJNIENVNEWFRAME_NODE, + JTI_SOFT_JNIPOPSYSTEMFRAME_NODE, + JTI_SOFT_UNWRAPJNI_NODE, + JTI_SOFT_FMOD_NODE, + JTI_SOFT_IDIV_NODE, + JTI_SOFT_IREM_NODE, + JTI_SOFT_LDIV_NODE, + JTI_SOFT_LREM_NODE, + + JTI_ACCESS_FLAGS_TYPE_NODE, + + JTI_NATIVECODE_PTR_ARRAY_TYPE_NODE, + + JTI_MAIN_CLASS, + JTI_CURRENT_CLASS, + JTI_OUTPUT_CLASS, + + JTI_MAX +}; + +extern GTY(()) tree java_global_trees[JTI_MAX]; + +/* "Promoted types" that are used for primitive types smaller + than int. We could use int_type_node, but then we would lose + type information (such as needed for debugging). */ +#define promoted_byte_type_node \ + java_global_trees[JTI_PROMOTED_BYTE_TYPE_NODE] +#define promoted_short_type_node \ + java_global_trees[JTI_PROMOTED_SHORT_TYPE_NODE] +#define promoted_char_type_node \ + java_global_trees[JTI_PROMOTED_CHAR_TYPE_NODE] +#define promoted_boolean_type_node \ + java_global_trees[JTI_PROMOTED_BOOLEAN_TYPE_NODE] + +#define byte_type_node \ + java_global_trees[JTI_BYTE_TYPE_NODE] +#define short_type_node \ + java_global_trees[JTI_SHORT_TYPE_NODE] +#define int_type_node \ + java_global_trees[JTI_INT_TYPE_NODE] +#define long_type_node \ + java_global_trees[JTI_LONG_TYPE_NODE] + +#define unsigned_byte_type_node \ + java_global_trees[JTI_UNSIGNED_BYTE_TYPE_NODE] +#define unsigned_short_type_node \ + java_global_trees[JTI_UNSIGNED_SHORT_TYPE_NODE] +#define unsigned_int_type_node \ + java_global_trees[JTI_UNSIGNED_INT_TYPE_NODE] +#define unsigned_long_type_node \ + java_global_trees[JTI_UNSIGNED_LONG_TYPE_NODE] + +#define decimal_int_max \ + java_global_trees[JTI_DECIMAL_INT_MAX_NODE] +#define decimal_long_max \ + java_global_trees[JTI_DECIMAL_LONG_MAX_NODE] + +#define object_type_node \ + java_global_trees[JTI_OBJECT_TYPE_NODE] +#define unqualified_object_id_node \ + java_global_trees[JTI_UNQUALIFIED_OBJECT_ID_NODE] +#define object_ptr_type_node \ + java_global_trees[JTI_OBJECT_PTR_TYPE_NODE] +#define string_type_node \ + java_global_trees[JTI_STRING_TYPE_NODE] +#define string_ptr_type_node \ + java_global_trees[JTI_STRING_PTR_TYPE_NODE] +#define throwable_type_node \ + java_global_trees[JTI_THROWABLE_TYPE_NODE] +#define exception_type_node \ + java_global_trees[JTI_EXCEPTION_TYPE_NODE] +#define runtime_exception_type_node \ + java_global_trees[JTI_RUNTIME_EXCEPTION_TYPE_NODE] +#define error_exception_type_node \ + java_global_trees[JTI_ERROR_EXCEPTION_TYPE_NODE] +#define rawdata_ptr_type_node \ + java_global_trees[JTI_RAWDATA_PTR_TYPE_NODE] + +#define byte_array_type_node \ + java_global_trees[JTI_BYTE_ARRAY_TYPE_NODE] +#define short_array_type_node \ + java_global_trees[JTI_SHORT_ARRAY_TYPE_NODE] +#define int_array_type_node \ + java_global_trees[JTI_INT_ARRAY_TYPE_NODE] +#define long_array_type_node \ + java_global_trees[JTI_LONG_ARRAY_TYPE_NODE] +#define boolean_array_type_node \ + java_global_trees[JTI_BOOLEAN_ARRAY_TYPE_NODE] +#define char_array_type_node \ + java_global_trees[JTI_CHAR_ARRAY_TYPE_NODE] +#define double_array_type_node \ + java_global_trees[JTI_DOUBLE_ARRAY_TYPE_NODE] +#define float_array_type_node \ + java_global_trees[JTI_FLOAT_ARRAY_TYPE_NODE] +#define array_array_type_node \ + java_global_trees[JTI_ARRAY_ARRAY_TYPE_NODE] +#define object_array_type_node \ + java_global_trees[JTI_OBJECT_ARRAY_TYPE_NODE] +#define string_array_type_node \ + java_global_trees[JTI_STRING_ARRAY_TYPE_NODE] +#define boolean_array_vtable \ + java_global_trees[JTI_BOOLEAN_ARRAY_VTABLE] +#define byte_array_vtable \ + java_global_trees[JTI_BYTE_ARRAY_VTABLE] +#define char_array_vtable \ + java_global_trees[JTI_CHAR_ARRAY_VTABLE] +#define short_array_vtable \ + java_global_trees[JTI_SHORT_ARRAY_VTABLE] +#define int_array_vtable \ + java_global_trees[JTI_INT_ARRAY_VTABLE] +#define long_array_vtable \ + java_global_trees[JTI_LONG_ARRAY_VTABLE] +#define float_array_vtable \ + java_global_trees[JTI_FLOAT_ARRAY_VTABLE] +#define double_array_vtable \ + java_global_trees[JTI_DOUBLE_ARRAY_VTABLE] +#define TYPE_identifier_node \ + java_global_trees[JTI_TYPE_IDENTIFIER_NODE] /* "TYPE" */ +#define init_identifier_node \ + java_global_trees[JTI_INIT_IDENTIFIER_NODE] /* "<init>" */ +#define clinit_identifier_node \ + java_global_trees[JTI_CLINIT_IDENTIFIER_NODE] /* "<clinit>" */ +#define void_signature_node \ + java_global_trees[JTI_VOID_SIGNATURE_NODE] /* "()V" */ +#define finalize_identifier_node \ + java_global_trees[JTI_FINALIZE_IDENTIFIER_NODE] /* "finalize" */ +#define this_identifier_node \ + java_global_trees[JTI_THIS_IDENTIFIER_NODE] /* "this" */ +#define one_elt_array_domain_type \ + java_global_trees[JTI_ONE_ELT_ARRAY_DOMAIN_TYPE] +/* The type of the return address of a subroutine. */ +#define return_address_type_node \ + java_global_trees[JTI_RETURN_ADDRESS_TYPE_NODE] + +/* Integer constants not declared in tree.h. */ +#define long_zero_node \ + java_global_trees[JTI_LONG_ZERO_NODE] +#define float_zero_node \ + java_global_trees[JTI_FLOAT_ZERO_NODE] +#define double_zero_node \ + java_global_trees[JTI_DOUBLE_ZERO_NODE] +#define integer_two_node \ + java_global_trees[JTI_INTEGER_TWO_NODE] +#define integer_four_node \ + java_global_trees[JTI_INTEGER_FOUR_NODE] + +/* The type for struct methodtable. */ +#define methodtable_type \ + java_global_trees[JTI_METHODTABLE_TYPE] +#define methodtable_ptr_type \ + java_global_trees[JTI_METHODTABLE_PTR_TYPE] + +#define utf8const_type \ + java_global_trees[JTI_UTF8CONST_TYPE] +#define utf8const_ptr_type \ + java_global_trees[JTI_UTF8CONST_PTR_TYPE] + +#define class_type_node \ + java_global_trees[JTI_CLASS_TYPE_NODE] +#define class_ptr_type \ + java_global_trees[JTI_CLASS_PTR_TYPE] +#define field_type_node \ + java_global_trees[JTI_FIELD_TYPE_NODE] +#define constants_type_node \ + java_global_trees[JTI_CONSTANTS_TYPE_NODE] +#define dtable_type \ + java_global_trees[JTI_DTABLE_TYPE] +#define dtable_ptr_type \ + java_global_trees[JTI_DTABLE_PTR_TYPE] +#define field_ptr_type_node \ + java_global_trees[JTI_FIELD_PTR_TYPE_NODE] +#define field_info_union_node \ + java_global_trees[JTI_FIELD_INFO_UNION_NODE] +#define jexception_type \ + java_global_trees[JTI_EXCEPTION_TYPE] +#define jexception_ptr_type \ + java_global_trees[JTI_EXCEPTION_PTR_TYPE] +#define lineNumberEntry_type \ + java_global_trees[JTI_LINENUMBERENTRY_TYPE] +#define lineNumbers_type \ + java_global_trees[JTI_LINENUMBERS_TYPE] +#define method_type_node \ + java_global_trees[JTI_METHOD_TYPE_NODE] +#define method_ptr_type_node \ + java_global_trees[JTI_METHOD_PTR_TYPE_NODE] +#define otable_type \ + java_global_trees[JTI_OTABLE_TYPE] +#define atable_type \ + java_global_trees[JTI_ATABLE_TYPE] +#define itable_type \ + java_global_trees[JTI_ITABLE_TYPE] +#define otable_ptr_type \ + java_global_trees[JTI_OTABLE_PTR_TYPE] +#define atable_ptr_type \ + java_global_trees[JTI_ATABLE_PTR_TYPE] +#define itable_ptr_type \ + java_global_trees[JTI_ITABLE_PTR_TYPE] +#define symbol_type \ + java_global_trees[JTI_SYMBOL_TYPE] +#define symbols_array_type \ + java_global_trees[JTI_SYMBOLS_ARRAY_TYPE] +#define symbols_array_ptr_type \ + java_global_trees[JTI_SYMBOLS_ARRAY_PTR_TYPE] +#define assertion_entry_type \ + java_global_trees[JTI_ASSERTION_ENTRY_TYPE] +#define assertion_table_type \ + java_global_trees[JTI_ASSERTION_TABLE_TYPE] + +#define end_params_node \ + java_global_trees[JTI_END_PARAMS_NODE] + +/* References to internal libjava functions we use. */ +#define throw_node \ + java_global_trees[JTI_THROW_NODE] +#define alloc_object_node \ + java_global_trees[JTI_ALLOC_OBJECT_NODE] +#define alloc_no_finalizer_node \ + java_global_trees[JTI_ALLOC_NO_FINALIZER_NODE] +#define soft_instanceof_node \ + java_global_trees[JTI_SOFT_INSTANCEOF_NODE] +#define soft_checkcast_node \ + java_global_trees[JTI_SOFT_CHECKCAST_NODE] +#define soft_initclass_node \ + java_global_trees[JTI_SOFT_INITCLASS_NODE] +#define soft_newarray_node \ + java_global_trees[JTI_SOFT_NEWARRAY_NODE] +#define soft_anewarray_node \ + java_global_trees[JTI_SOFT_ANEWARRAY_NODE] +#define soft_multianewarray_node \ + java_global_trees[JTI_SOFT_MULTIANEWARRAY_NODE] +#define soft_badarrayindex_node \ + java_global_trees[JTI_SOFT_BADARRAYINDEX_NODE] +#define soft_nullpointer_node \ + java_global_trees[JTI_SOFT_NULLPOINTER_NODE] +#define soft_abstractmethod_node \ + java_global_trees[JTI_SOFT_ABSTRACTMETHOD_NODE] +#define soft_nosuchfield_node \ + java_global_trees[JTI_SOFT_NOSUCHFIELD_NODE] +#define soft_checkarraystore_node \ + java_global_trees[JTI_SOFT_CHECKARRAYSTORE_NODE] +#define soft_monitorenter_node \ + java_global_trees[JTI_SOFT_MONITORENTER_NODE] +#define soft_monitorexit_node \ + java_global_trees[JTI_SOFT_MONITOREXIT_NODE] +#define soft_lookupinterfacemethod_node \ + java_global_trees[JTI_SOFT_LOOKUPINTERFACEMETHOD_NODE] +#define soft_lookupinterfacemethodbyname_node \ + java_global_trees[JTI_SOFT_LOOKUPINTERFACEMETHODBYNAME_NODE] +#define soft_lookupjnimethod_node \ + java_global_trees[JTI_SOFT_LOOKUPJNIMETHOD_NODE] +#define soft_getjnienvnewframe_node \ + java_global_trees[JTI_SOFT_GETJNIENVNEWFRAME_NODE] +#define soft_jnipopsystemframe_node \ + java_global_trees[JTI_SOFT_JNIPOPSYSTEMFRAME_NODE] +#define soft_unwrapjni_node \ + java_global_trees[JTI_SOFT_UNWRAPJNI_NODE] +#define soft_fmod_node \ + java_global_trees[JTI_SOFT_FMOD_NODE] +#define soft_idiv_node \ + java_global_trees[JTI_SOFT_IDIV_NODE] +#define soft_irem_node \ + java_global_trees[JTI_SOFT_IREM_NODE] +#define soft_ldiv_node \ + java_global_trees[JTI_SOFT_LDIV_NODE] +#define soft_lrem_node \ + java_global_trees[JTI_SOFT_LREM_NODE] + +#define access_flags_type_node \ + java_global_trees[JTI_ACCESS_FLAGS_TYPE_NODE] + +#define nativecode_ptr_array_type_node \ + java_global_trees[JTI_NATIVECODE_PTR_ARRAY_TYPE_NODE] + +#define nativecode_ptr_type_node ptr_type_node + +/* The decl for "_Jv_ResolvePoolEntry". */ +extern GTY(()) tree soft_resolvepoolentry_node; + +struct GTY(()) lang_identifier { + struct tree_identifier ignore; + tree global_value; + tree local_value; + + /* If non-NULL: An ADDR_REF to a VAR_DECL that contains + * the Utf8Const representation of the identifier. */ + tree utf8_ref; +}; + +/* The resulting tree type. */ +union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"), + chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)"))) + + lang_tree_node { + union tree_node GTY ((tag ("0"), + desc ("tree_node_structure (&%h)"))) + generic; + struct lang_identifier GTY ((tag ("1"))) identifier; +}; + +/* Macros for access to language-specific slots in an identifier. */ +/* Unless specified, each of these slots contains a DECL node or null. */ + +/* This represents the value which the identifier has in the + file-scope namespace. */ +#define IDENTIFIER_GLOBAL_VALUE(NODE) \ + (((struct lang_identifier *)(NODE))->global_value) +/* This represents the value which the identifier has in the current + scope. */ +#define IDENTIFIER_LOCAL_VALUE(NODE) \ + (((struct lang_identifier *)(NODE))->local_value) + +/* Given an identifier NODE, get the corresponding class. + E.g. IDENTIFIER_CLASS_VALUE(get_identifier ("java.lang.Number")) + is the corresponding RECORD_TYPE. */ +#define IDENTIFIER_CLASS_VALUE(NODE) IDENTIFIER_GLOBAL_VALUE(NODE) + +/* Given a signature of a reference (or array) type, or a method, return the + corresponding type (if one has been allocated). + Do not use for primitive types, since they may be ambiguous. + (E.g. is "I" a signature or a class name?) */ +#define IDENTIFIER_SIGNATURE_TYPE(NODE) IDENTIFIER_GLOBAL_VALUE(NODE) + +/* If non-NULL: An ADDR_REF to a VAR_DECL that contains + the Utf8Const representation of the identifier. */ +#define IDENTIFIER_UTF8_REF(NODE) \ + (((struct lang_identifier *)(NODE))->utf8_ref) + +#define IDENTIFIER_UTF8_DECL(NODE) \ + TREE_OPERAND((((struct lang_identifier *)(NODE))->utf8_ref), 0) + +/* For a FUNCTION_DECL, if we are compiling a .class file, then this is + the position in the .class file of the method code. + Specifically, this is the code itself, not the code attribute. */ +#define DECL_CODE_OFFSET(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.code_offset) +/* Similarly, the length of the bytecode. */ +#define DECL_CODE_LENGTH(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.code_length) +/* Similarly, the position of the LineNumberTable attribute. */ +#define DECL_LINENUMBERS_OFFSET(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.linenumbers_offset) +/* Similarly, the position of the LocalVariableTable attribute + (following the standard attribute header). */ +#define DECL_LOCALVARIABLES_OFFSET(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.localvariables_offset) + +#define DECL_MAX_LOCALS(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.max_locals) +#define DECL_MAX_STACK(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.max_stack) +/* Number of local variable slots needed for the arguments of this function. */ +#define DECL_ARG_SLOT_COUNT(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.arg_slot_count) +/* Source location of end of function. */ +#define DECL_FUNCTION_LAST_LINE(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.last_line) +/* List of checked thrown exceptions, as specified with the `throws' + keyword */ +#define DECL_FUNCTION_THROWS(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.throws_list) +/* VAR_DECL containing the caught exception object. */ +#define DECL_FUNCTION_EXC_OBJ(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.exc_obj) +/* For each function decl, init_test_table contains a hash table whose + entries are keyed on class names, and whose values are local + boolean decls. The variables are intended to be TRUE when the + class has been initialized in this function, and FALSE otherwise. */ +#define DECL_FUNCTION_INIT_TEST_TABLE(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.init_test_table) +/* For each static function decl, itc contains a hash table whose + entries are keyed on class named that are definitively initialized + in DECL. */ +#define DECL_FUNCTION_INITIALIZED_CLASS_TABLE(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.ict) + +#define DECL_LOCAL_CNI_METHOD_P(NODE) \ + (DECL_LANG_SPECIFIC (NODE)->u.f.local_cni) + +/* True when DECL (a field) is Synthetic. */ +#define FIELD_SYNTHETIC(DECL) DECL_LANG_FLAG_2 (VAR_OR_FIELD_CHECK (DECL)) + +/* The slot number for this local variable. */ +#define DECL_LOCAL_SLOT_NUMBER(NODE) \ + (DECL_LANG_SPECIFIC (NODE)->u.v.slot_number) +/* The start (bytecode) pc for the valid range of this local variable. */ +#define DECL_LOCAL_START_PC(NODE) (DECL_LANG_SPECIFIC (NODE)->u.v.start_pc) +/* The end (bytecode) pc for the valid range of this local variable. */ +#define DECL_LOCAL_END_PC(NODE) (DECL_LANG_SPECIFIC (NODE)->u.v.end_pc) +/* For a VAR_DECL or PARM_DECL, used to chain decls with the same + slot_number in decl_map. */ +#define DECL_LOCAL_SLOT_CHAIN(NODE) (DECL_LANG_SPECIFIC(NODE)->u.v.slot_chain) +/* The class that's the owner of a dynamic binding table. */ +#define DECL_OWNER(NODE) (DECL_LANG_SPECIFIC(NODE)->u.v.owner) +/* True if NODE is a class final field. */ +#define FIELD_ENUM(DECL) (DECL_LANG_SPECIFIC (DECL)->u.v.field_enum) +/* True if NODE is a variable that is out of scope. */ +#define LOCAL_VAR_OUT_OF_SCOPE_P(NODE) \ + (DECL_LANG_SPECIFIC (NODE)->u.v.freed) +#define LOCAL_SLOT_P(NODE) \ + (DECL_LANG_SPECIFIC (NODE)->u.v.local_slot) + +#define DECL_CLASS_FIELD_P(NODE) \ + (DECL_LANG_SPECIFIC (NODE)->u.v.class_field) +#define DECL_VTABLE_P(NODE) \ + (DECL_LANG_SPECIFIC (NODE)->u.v.vtable) + +/* Create a DECL_LANG_SPECIFIC if necessary. */ +#define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T) \ + if (DECL_LANG_SPECIFIC (T) == NULL) \ + { \ + DECL_LANG_SPECIFIC ((T)) \ + = ggc_alloc_cleared_lang_decl (sizeof (struct lang_decl)); \ + DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR; \ + } + +/* A ConstantExpression, after folding and name resolution. */ +#define CONSTANT_VALUE_P(NODE) \ + (TREE_CODE (NODE) == STRING_CST \ + || (TREE_CODE (NODE) == INTEGER_CST \ + && TREE_CODE (TREE_TYPE (NODE)) != POINTER_TYPE) \ + || TREE_CODE (NODE) == REAL_CST) + +/* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */ +struct GTY(()) lang_decl_func { + /* tree chain; not yet used. */ + long code_offset; + int code_length; + long linenumbers_offset; + long localvariables_offset; + int arg_slots; + int max_locals; + int max_stack; + int arg_slot_count; + source_location last_line; /* End line number for a function decl */ + VEC(tree,gc) *throws_list; /* Exception specified by `throws' */ + tree exc_obj; /* Decl holding the exception object. */ + + /* Class initialization test variables */ + htab_t GTY ((param_is (struct treetreehash_entry))) init_test_table; + + /* Initialized (static) Class Table */ + htab_t GTY ((param_is (union tree_node))) ict; + + unsigned int native : 1; /* Nonzero if this is a native method */ + unsigned int strictfp : 1; + unsigned int invisible : 1; /* Set for methods we generate + internally but which shouldn't be + written to the .class file. */ + unsigned int dummy : 1; + unsigned int local_cni : 1; /* Decl needs mangle_local_cni_method. */ + unsigned int bridge : 1; /* Bridge method. */ + unsigned int varargs : 1; /* Varargs method. */ +}; + +struct GTY(()) treetreehash_entry { + tree key; + tree value; +}; + +/* These represent the possible assertion_codes that can be emitted in the + type assertion table. */ +enum +{ + JV_ASSERT_END_OF_TABLE = 0, /* Last entry in table. */ + JV_ASSERT_TYPES_COMPATIBLE = 1, /* Operand A is assignable to Operand B. */ + JV_ASSERT_IS_INSTANTIABLE = 2 /* Operand A is an instantiable class. */ +}; + +/* Annotation types used in the reflection_data. See + java.lang.Class.getDeclaredAnnotations() in the runtime library for + an example of how these are used. */ + +typedef enum +{ + JV_CLASS_ATTR, + JV_METHOD_ATTR, + JV_FIELD_ATTR, + JV_DONE_ATTR +} jv_attr_type; + +typedef enum +{ + JV_INNER_CLASSES_KIND, + JV_ENCLOSING_METHOD_KIND, + JV_SIGNATURE_KIND, + JV_ANNOTATIONS_KIND, + JV_PARAMETER_ANNOTATIONS_KIND, + JV_ANNOTATION_DEFAULT_KIND +} jv_attr_kind; + +typedef struct GTY(()) type_assertion { + int assertion_code; /* 'opcode' for the type of this assertion. */ + tree op1; /* First operand. */ + tree op2; /* Second operand. */ +} type_assertion; + +extern tree java_treetreehash_find (htab_t, tree); +extern tree * java_treetreehash_new (htab_t, tree); +extern htab_t java_treetreehash_create (size_t size); + +/* DECL_LANG_SPECIFIC for VAR_DECL, PARM_DECL and sometimes FIELD_DECL + (access methods on outer class fields) and final fields. */ +struct GTY(()) lang_decl_var { + int slot_number; + int start_pc; + int end_pc; + tree slot_chain; + tree owner; + unsigned int freed : 1; /* Decl is no longer in scope. */ + unsigned int local_slot : 1; /* Decl is a temporary in the stack frame. */ + unsigned int class_field : 1; /* Decl needs mangle_class_field. */ + unsigned int vtable : 1; /* Decl needs mangle_vtable. */ + unsigned int field_enum:1; /* Field is an enum. */ +}; + +/* This is what 'lang_decl' really points to. */ + +enum lang_decl_desc {LANG_DECL_FUNC, LANG_DECL_VAR}; + +struct GTY((variable_size)) lang_decl { + enum lang_decl_desc desc; + union lang_decl_u + { + struct lang_decl_func GTY ((tag ("LANG_DECL_FUNC"))) f; + struct lang_decl_var GTY ((tag ("LANG_DECL_VAR"))) v; + } GTY ((desc ("%0.desc"))) u; +}; + +/* Macro to access fields in `struct lang_type'. */ + +#define TYPE_SIGNATURE(T) (TYPE_LANG_SPECIFIC (T)->signature) +#define TYPE_JCF(T) (TYPE_LANG_SPECIFIC (T)->jcf) +#define TYPE_CPOOL(T) (TYPE_LANG_SPECIFIC (T)->cpool) +#define TYPE_CPOOL_DATA_REF(T) (TYPE_LANG_SPECIFIC (T)->cpool_data_ref) +#define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \ + if (TYPE_LANG_SPECIFIC ((T)) == NULL) \ + TYPE_LANG_SPECIFIC ((T)) \ + = ggc_alloc_cleared_lang_type (sizeof (struct lang_type)); + +#define TYPE_DUMMY(T) (TYPE_LANG_SPECIFIC(T)->dummy_class) + +#define TYPE_PACKAGE_LIST(T) (TYPE_LANG_SPECIFIC (T)->package_list) +#define TYPE_PRIVATE_INNER_CLASS(T) (TYPE_LANG_SPECIFIC (T)->pic) +#define TYPE_PROTECTED_INNER_CLASS(T) (TYPE_LANG_SPECIFIC (T)->poic) +#define TYPE_STRICTFP(T) (TYPE_LANG_SPECIFIC (T)->strictfp) +#define TYPE_ENUM(T) (TYPE_LANG_SPECIFIC (T)->enum_class) +#define TYPE_SYNTHETIC(T) (TYPE_LANG_SPECIFIC (T)->synthetic) +#define TYPE_ANNOTATION(T) (TYPE_LANG_SPECIFIC (T)->annotation) + +#define TYPE_USES_ASSERTIONS(T) (TYPE_LANG_SPECIFIC (T)->assertions) + +#define TYPE_ATABLE_METHODS(T) (TYPE_LANG_SPECIFIC (T)->atable_methods) +#define TYPE_ATABLE_SYMS_DECL(T) (TYPE_LANG_SPECIFIC (T)->atable_syms_decl) +#define TYPE_ATABLE_DECL(T) (TYPE_LANG_SPECIFIC (T)->atable_decl) + +#define TYPE_OTABLE_METHODS(T) (TYPE_LANG_SPECIFIC (T)->otable_methods) +#define TYPE_OTABLE_SYMS_DECL(T) (TYPE_LANG_SPECIFIC (T)->otable_syms_decl) +#define TYPE_OTABLE_DECL(T) (TYPE_LANG_SPECIFIC (T)->otable_decl) + +#define TYPE_ITABLE_METHODS(T) (TYPE_LANG_SPECIFIC (T)->itable_methods) +#define TYPE_ITABLE_SYMS_DECL(T) (TYPE_LANG_SPECIFIC (T)->itable_syms_decl) +#define TYPE_ITABLE_DECL(T) (TYPE_LANG_SPECIFIC (T)->itable_decl) + +#define TYPE_CTABLE_DECL(T) (TYPE_LANG_SPECIFIC (T)->ctable_decl) +#define TYPE_CATCH_CLASSES(T) (TYPE_LANG_SPECIFIC (T)->catch_classes) + +#define TYPE_TO_RUNTIME_MAP(T) (TYPE_LANG_SPECIFIC (T)->type_to_runtime_map) +#define TYPE_ASSERTIONS(T) (TYPE_LANG_SPECIFIC (T)->type_assertions) +#define TYPE_PACKAGE(T) (TYPE_LANG_SPECIFIC (T)->package) + +#define TYPE_REFLECTION_DATA(T) (TYPE_LANG_SPECIFIC (T)->reflection_data) +#define TYPE_REFLECTION_DATASIZE(T) \ + (TYPE_LANG_SPECIFIC (T)->reflection_datasize) + +typedef struct GTY(()) method_entry_d { + tree method; + tree special; +} method_entry; + +DEF_VEC_O(method_entry); +DEF_VEC_ALLOC_O(method_entry,gc); + +/* FIXME: the variable_size annotation here is needed because these types are + variable-sized in some other frontends. Due to gengtype deficiency the GTY + options of such types have to agree across all frontends. */ +struct GTY((variable_size)) lang_type { + tree signature; + struct JCF *jcf; + struct CPool *cpool; + tree cpool_data_ref; /* Cached */ + tree package_list; /* List of package names, progressive */ + + VEC(method_entry,gc) *otable_methods; /* List of static decls referred + to by this class. */ + tree otable_decl; /* The static address table. */ + tree otable_syms_decl; + + VEC(method_entry,gc) *atable_methods; /* List of abstract methods + referred to by this class. */ + tree atable_decl; /* The static address table. */ + tree atable_syms_decl; + + VEC(method_entry,gc) *itable_methods; /* List of interface methods + referred to by this class. */ + tree itable_decl; /* The interfaces table. */ + tree itable_syms_decl; + + tree ctable_decl; /* The table of classes for the runtime + type matcher. */ + VEC(constructor_elt,gc) *catch_classes; + + htab_t GTY ((param_is (struct treetreehash_entry))) type_to_runtime_map; + /* The mapping of classes to exception region + markers. */ + + htab_t GTY ((param_is (struct type_assertion))) type_assertions; + /* Table of type assertions to be evaluated + by the runtime when this class is loaded. */ + + tree package; /* IDENTIFIER_NODE for package this class is + a member of. */ + + unsigned char* GTY((skip)) reflection_data; /* The raw reflection + data for this + class. */ + long reflection_datasize; /* The size of the raw reflection data + for this class, in bytes. */ + + unsigned pic:1; /* Private Inner Class. */ + unsigned poic:1; /* Protected Inner Class. */ + unsigned strictfp:1; /* `strictfp' class. */ + unsigned assertions:1; /* Any method uses `assert'. */ + unsigned dummy_class:1; /* Not a real class, just a placeholder. */ + unsigned enum_class:1; /* Class is an enum type. */ + unsigned synthetic:1; /* Class is synthetic. */ + unsigned annotation:1; /* Class is an annotation type. */ +}; + +#define JCF_u4 unsigned long +#define JCF_u2 unsigned short + +/* Possible values to pass to lookup_argument_method_generic. */ +#define SEARCH_INTERFACE 1 +#define SEARCH_SUPER 2 +#define SEARCH_VISIBLE 4 + +/* Defined in java-except.h */ +struct eh_range; + +extern void java_parse_file (void); +extern tree java_type_for_mode (enum machine_mode, int); +extern tree java_type_for_size (unsigned int, int); +extern tree java_truthvalue_conversion (tree); +extern void add_assume_compiled (const char *, int); +extern void add_enable_assert (const char *, int); +extern bool enable_assertions (tree); +extern tree lookup_class (tree); +extern tree lookup_java_constructor (tree, tree); +extern tree lookup_java_method (tree, tree, tree); +extern tree lookup_argument_method (tree, tree, tree); +extern tree lookup_argument_method_generic (tree, tree, tree, int); +extern int has_method (tree, tree); +extern tree promote_type (tree); +extern tree get_constant (struct JCF*, int); +extern tree get_name_constant (struct JCF*, int); +extern tree get_class_constant (struct JCF*, int); +extern tree parse_signature (struct JCF *jcf, int sig_index); +extern tree add_field (tree, tree, tree, int); +extern tree add_method (tree, int, tree, tree); +extern tree add_method_1 (tree, int, tree, tree); +extern void java_hide_decl (tree); +extern tree make_class (void); +extern tree push_class (tree, tree); +extern tree unmangle_classname (const char *name, int name_length); +extern tree parse_signature_string (const unsigned char *, int); +extern tree get_type_from_signature (tree); +extern void layout_class (tree); +extern int get_interface_method_index (tree, tree); +extern tree layout_class_method (tree, tree, tree, tree); +extern void layout_class_methods (tree); +extern void cache_this_class_ref (tree); +extern void uncache_this_class_ref (tree); +extern tree build_class_ref (tree); +extern tree build_dtable_decl (tree); +extern tree build_internal_class_name (tree); +extern tree build_constants_constructor (void); +extern tree build_constant_data_ref (bool); +extern tree build_ref_from_constant_pool (int); +extern tree build_utf8_ref (tree); +extern tree ident_subst (const char *, int, const char *, int, int, + const char *); +extern tree identifier_subst (const tree, const char *, int, int, + const char *); +extern int global_bindings_p (void); +extern tree getdecls (void); +extern void pushlevel (int); +extern tree poplevel (int,int, int); +extern tree pushdecl (tree); +extern void java_init_decl_processing (void); +extern void java_dup_lang_specific_decl (tree); +extern tree build_java_signature (tree); +extern tree build_java_argument_signature (tree); +extern void set_java_signature (tree, tree); +extern tree build_static_field_ref (tree); +extern tree build_address_of (tree); +extern tree find_local_variable (int index, tree type, int pc); +extern tree find_stack_slot (int index, tree type); +extern tree build_prim_array_type (tree, HOST_WIDE_INT); +extern tree build_java_array_type (tree, HOST_WIDE_INT); +extern int is_compiled_class (tree); +extern tree mangled_classname (const char *, tree); +extern tree lookup_label (int); +extern tree pop_type_0 (tree, char **); +extern tree pop_type (tree); +extern tree decode_newarray_type (int); +extern tree lookup_field (tree *, tree); +extern int is_array_type_p (tree); +extern HOST_WIDE_INT java_array_type_length (tree); +extern int read_class (tree); +extern void load_class (tree, int); + +extern tree check_for_builtin (tree, tree); +extern void initialize_builtins (void); + +extern tree lookup_name (tree); +extern bool special_method_p (tree); +extern void maybe_rewrite_invocation (tree *, VEC(tree,gc) **, tree *, tree *); +extern tree build_known_method_ref (tree, tree, tree, tree, VEC(tree,gc) *, tree); +extern tree build_class_init (tree, tree); +extern int attach_init_test_initialization_flags (void **, void *); +extern tree build_invokevirtual (tree, tree, tree); +extern tree build_invokeinterface (tree, tree); +extern tree build_jni_stub (tree); +extern tree invoke_build_dtable (int, VEC(tree,gc) *); +extern tree build_field_ref (tree, tree, tree); +extern tree java_modify_addr_for_volatile (tree); +extern void pushdecl_force_head (tree); +extern tree build_java_binop (enum tree_code, tree, tree, tree); +extern tree build_java_soft_divmod (enum tree_code, tree, tree, tree); +extern tree binary_numeric_promotion (tree, tree, tree *, tree *); +extern tree build_java_arrayaccess (tree, tree, tree); +extern tree build_java_arraystore_check (tree, tree); +extern tree build_newarray (int, tree); +extern tree build_anewarray (tree, tree); +extern tree build_new_array (tree, tree); +extern tree build_java_array_length_access (tree); +extern tree build_java_indirect_ref (tree, tree, int); +extern tree java_check_reference (tree, int); +extern tree build_get_class (tree); +extern tree build_instanceof (tree, tree); +extern tree create_label_decl (tree); +extern tree prepare_eh_table_type (tree); +extern void java_expand_catch_classes (tree); +extern tree build_exception_object_ref (tree); +extern tree generate_name (void); +extern const char *lang_printable_name (tree, int); +extern tree maybe_add_interface (tree, tree); +extern void set_super_info (int, tree, tree, int); +extern void set_class_decl_access_flags (int, tree); +extern int get_access_flags_from_decl (tree); +extern int interface_of_p (tree, tree); +extern int inherits_from_p (tree, tree); +extern int common_enclosing_context_p (tree, tree); +extern int common_enclosing_instance_p (tree, tree); +extern int enclosing_context_p (tree, tree); +extern tree build_result_decl (tree); +extern void set_method_index (tree decl, tree method_index); +extern tree get_method_index (tree decl); +extern void make_class_data (tree); +extern int alloc_name_constant (int, tree); +extern int alloc_constant_fieldref (tree, tree); +extern void emit_register_classes (tree *); +extern tree emit_symbol_table (tree, tree, VEC(method_entry,gc) *, + tree, tree, int); +extern void lang_init_source (int); +extern void write_classfile (tree); +extern char *print_int_node (tree); +extern void finish_class (void); +extern void check_for_initialization (tree, tree); +extern struct CPool *cpool_for_class (tree); +extern int find_class_or_string_constant (struct CPool *, int, tree); + +extern tree pushdecl_top_level (tree); +extern tree pushdecl_function_level (tree); +extern tree java_replace_references (tree *, int *, void *); +extern int alloc_class_constant (tree); +extern void init_expr_processing (void); +extern void push_super_field (tree, tree); +extern void init_class_processing (void); +extern void add_type_assertion (tree, int, tree, tree); +extern int can_widen_reference_to (tree, tree); +extern int class_depth (tree); +extern int verify_jvm_instructions_new (struct JCF *, const unsigned char *, + long); +extern void maybe_pushlevels (int); +extern void maybe_poplevels (int); +extern void force_poplevels (int); +extern int process_jvm_instruction (int, const unsigned char *, long); +extern int maybe_adjust_start_pc (struct JCF *, int, int, int); +extern void set_local_type (int, tree); +extern int merge_type_state (tree); +extern int push_type_0 (tree); +extern void push_type (tree); +extern void add_interface (tree, tree); +extern tree force_evaluation_order (tree); +extern tree java_create_object (tree); +extern int verify_constant_pool (struct JCF *); +extern void start_java_method (tree); +extern void end_java_method (void); +extern void give_name_to_locals (struct JCF *); +extern void note_instructions (struct JCF *, tree); +extern void expand_byte_code (struct JCF *, tree); +extern int open_in_zip (struct JCF *, const char *, const char *, int); +extern void set_constant_value (tree, tree); +#ifdef jword +extern int find_constant1 (struct CPool *, int, jword); +extern int find_constant2 (struct CPool *, int, jword, jword); +#endif +extern int find_utf8_constant (struct CPool *, tree); +extern int find_string_constant (struct CPool *, tree); +extern int find_class_constant (struct CPool *, tree); +extern int find_fieldref_index (struct CPool *, tree); +extern int find_methodref_index (struct CPool *, tree); +extern int find_methodref_with_class_index (struct CPool *, tree, tree); +extern void write_constant_pool (struct CPool *, unsigned char *, int); +extern int count_constant_pool_bytes (struct CPool *); +extern int encode_newarray_type (tree); +#ifdef uint64 +extern void format_int (char *, jlong, int); +extern void format_uint (char *, uint64, int); +#endif +extern void jcf_trim_old_input (struct JCF *); +#ifdef BUFSIZ +extern void jcf_print_utf8 (FILE *, const unsigned char *, int); +extern void jcf_print_char (FILE *, int); +extern void jcf_print_utf8_replace (FILE *, const unsigned char *, int, + int, int); +extern const char* open_class (const char *, struct JCF *, int, const char *); +#endif +extern void java_debug_context (void); +extern void safe_layout_class (tree); + +extern tree get_boehm_type_descriptor (tree); +extern bool uses_jv_markobj_p (tree); +extern bool class_has_finalize_method (tree); +extern void java_check_methods (tree); + +extern void java_mangle_decl (tree); +extern tree java_mangle_class_field (struct obstack *, tree); +extern tree java_mangle_vtable (struct obstack *, tree); +extern tree java_mangle_resource_name (const char *); +extern void append_gpp_mangled_name (const char *, int); + +extern void add_predefined_file (tree); +extern int predefined_filename_p (tree); + +extern tree decl_constant_value (tree); + +extern void java_mark_class_local (tree); + +extern void java_inlining_merge_static_initializers (tree, void *); +extern void java_inlining_map_static_initializers (tree, void *); + +extern void compile_resource_data (const char *name, const char *buffer, int); +extern void compile_resource_file (const char *, const char *); +extern void write_resource_constructor (tree *); +extern tree build_java_empty_stmt (void); +extern tree add_stmt_to_compound (tree, tree, tree); +extern tree java_add_stmt (tree); +extern tree java_add_local_var (tree decl); +extern tree *get_stmts (void); +extern void register_exception_range(struct eh_range *, int, int); + +extern void finish_method (tree); +extern void java_expand_body (tree); + +extern int get_symbol_table_index (tree, tree, VEC(method_entry,gc) **); + +extern tree make_catch_class_record (tree, tree); +extern tree emit_catch_table (tree); + +extern void gen_indirect_dispatch_tables (tree type); +extern int split_qualified_name (tree *left, tree *right, tree source); +extern int in_same_package (tree, tree); + +extern void java_read_sourcefilenames (const char *fsource_filename); + +extern void rewrite_reflection_indexes (void *); + +int cxx_keyword_p (const char *name, int length); + +extern GTY(()) VEC(tree,gc) *pending_static_fields; + +extern void java_write_globals (void); + +#define DECL_FINAL(DECL) DECL_LANG_FLAG_3 (DECL) + +/* Access flags etc for a method (a FUNCTION_DECL): */ + +#define METHOD_DUMMY(DECL) (DECL_LANG_SPECIFIC (DECL)->u.f.dummy) + +#define METHOD_PUBLIC(DECL) DECL_LANG_FLAG_1 (FUNCTION_DECL_CHECK (DECL)) +#define METHOD_PRIVATE(DECL) TREE_PRIVATE (FUNCTION_DECL_CHECK (DECL)) +#define METHOD_PROTECTED(DECL) TREE_PROTECTED (FUNCTION_DECL_CHECK (DECL)) +#define METHOD_STATIC(DECL) DECL_LANG_FLAG_2 (FUNCTION_DECL_CHECK (DECL)) +#define METHOD_FINAL(DECL) DECL_FINAL (FUNCTION_DECL_CHECK (DECL)) +#define METHOD_SYNCHRONIZED(DECL) DECL_LANG_FLAG_4 (FUNCTION_DECL_CHECK (DECL)) +#define METHOD_NATIVE(DECL) \ + (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.native) +#define METHOD_ABSTRACT(DECL) DECL_LANG_FLAG_5 (FUNCTION_DECL_CHECK (DECL)) +#define METHOD_STRICTFP(DECL) \ + (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.strictfp) +#define METHOD_INVISIBLE(DECL) \ + (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.invisible) +#define METHOD_BRIDGE(DECL) \ + (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.bridge) +#define METHOD_VARARGS(DECL) \ + (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.varargs) + +#define CLASS_FILE_P(NODE) TREE_LANG_FLAG_3 (NODE) + +/* Other predicates on method decls */ + +#define DECL_CONSTRUCTOR_P(DECL) DECL_LANG_FLAG_7 (FUNCTION_DECL_CHECK (DECL)) + +#define DECL_INIT_P(DECL) (ID_INIT_P (DECL_NAME (DECL))) +#define DECL_CLINIT_P(DECL) (ID_CLINIT_P (DECL_NAME (DECL))) + +/* Predicates on method identifiers. Kept close to other macros using + them */ +#define ID_INIT_P(ID) ((ID) == init_identifier_node) +#define ID_CLINIT_P(ID) ((ID) == clinit_identifier_node) + +/* Access flags etc for variable/field (FIELD_DECL, VAR_DECL, or PARM_DECL): */ + +#define FIELD_PRIVATE(DECL) TREE_PRIVATE (VAR_OR_FIELD_CHECK (DECL)) +#define FIELD_PROTECTED(DECL) TREE_PROTECTED (VAR_OR_FIELD_CHECK (DECL)) +#define FIELD_PUBLIC(DECL) DECL_LANG_FLAG_1 (VAR_OR_FIELD_CHECK (DECL)) +#define FIELD_STATIC(DECL) TREE_STATIC (VAR_OR_FIELD_CHECK (DECL)) +#define FIELD_FINAL(DECL) DECL_FINAL (VAR_OR_FIELD_CHECK (DECL)) +#define FIELD_VOLATILE(DECL) DECL_LANG_FLAG_4 (VAR_OR_FIELD_CHECK (DECL)) +#define FIELD_TRANSIENT(DECL) DECL_LANG_FLAG_5 (VAR_OR_FIELD_CHECK (DECL)) + +/* Access flags etc for a class (a TYPE_DECL): */ + +#define CLASS_PUBLIC(DECL) DECL_LANG_FLAG_1 (TYPE_DECL_CHECK (DECL)) +#define CLASS_FINAL(DECL) DECL_FINAL (TYPE_DECL_CHECK (DECL)) +#define CLASS_INTERFACE(DECL) DECL_LANG_FLAG_4 (TYPE_DECL_CHECK (DECL)) +#define CLASS_ABSTRACT(DECL) DECL_LANG_FLAG_5 (TYPE_DECL_CHECK (DECL)) +#define CLASS_SUPER(DECL) DECL_LANG_FLAG_6 (TYPE_DECL_CHECK (DECL)) +#define CLASS_STATIC(DECL) DECL_LANG_FLAG_7 (TYPE_DECL_CHECK (DECL)) +#define CLASS_PRIVATE(DECL) (TYPE_PRIVATE_INNER_CLASS (TREE_TYPE (DECL))) +#define CLASS_PROTECTED(DECL) (TYPE_PROTECTED_INNER_CLASS (TREE_TYPE (DECL))) +#define CLASS_STRICTFP(DECL) (TYPE_STRICTFP (TREE_TYPE (DECL))) +#define CLASS_ENUM(DECL) (TYPE_ENUM (TREE_TYPE (DECL))) +#define CLASS_USES_ASSERTIONS(DECL) (TYPE_USES_ASSERTIONS (TREE_TYPE (DECL))) +#define CLASS_SYNTHETIC(DECL) (TYPE_SYNTHETIC (TREE_TYPE (DECL))) +#define CLASS_ANNOTATION(DECL) (TYPE_ANNOTATION (TREE_TYPE (DECL))) + +/* @deprecated marker flag on methods, fields and classes */ + +#define METHOD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL) +#define FIELD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL) +#define CLASS_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL) +#define DECL_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL) + +/* The number of virtual methods in this class's dispatch table. + Does not include initial two dummy entries (one points to the + Class object, and the other is for G++ -fvtable-thunks compatibility). */ +#define TYPE_NVIRTUALS(TYPE) BINFO_VIRTUALS (TYPE_BINFO (TYPE)) + +/* A TREE_VEC (indexed by DECL_VINDEX) containing this class's + virtual methods. */ +#define TYPE_VTABLE(TYPE) BINFO_VTABLE(TYPE_BINFO (TYPE)) + +/* Use CLASS_LOADED_P? FIXME */ +#define CLASS_COMPLETE_P(DECL) DECL_LANG_FLAG_2 (DECL) + +/* A vector used to track type states for the current method. */ +extern VEC(tree, gc) *type_states; + +/* This maps a bytecode offset (PC) to various flags, + listed below (starting with BCODE_). */ +extern char *instruction_bits; + +/* True iff the byte is the start of an instruction. */ +#define BCODE_INSTRUCTION_START 1 + +/* True iff there is a jump or a return to this location. */ +#define BCODE_JUMP_TARGET 2 + +/* True iff this is the start of an exception handler. */ +#define BCODE_EXCEPTION_TARGET 16 + +/* True iff there is a jump to this location (and it needs a label). */ +#define BCODE_TARGET (BCODE_JUMP_TARGET| BCODE_EXCEPTION_TARGET) + +/* True iff there is an entry in the linenumber table for this location. */ +#define BCODE_HAS_LINENUMBER 32 + +/* True iff there is more than one entry in the linenumber table for + this location. (This probably does not make much sense.) */ +#define BCODE_HAS_MULTI_LINENUMBERS 64 + +/* True if this instruction has been verified. */ +#define BCODE_VERIFIED 8 + +/* A pointer to the line number table of the current method. */ +extern const unsigned char *linenumber_table; +/* The length (in items) of the line number table. */ +extern int linenumber_count; + +/* In type_map, means the second half of a 64-bit double or long. */ +#define TYPE_SECOND void_type_node + +/* In type_map, means the null type (i.e. type of a null reference). */ +#define TYPE_NULL ptr_type_node + +/* In a type map means the type the address subroutine return address. */ +#define TYPE_RETURN_ADDR return_address_type_node + +/* A array mapping variable/stack slot index to the type current + in that variable/stack slot. + TYPE_SECOND and TYPE_NULL are special cases. */ +extern tree *type_map; + +/* Map a stack index to the type currently in that slot. */ +#define stack_type_map (type_map + DECL_MAX_LOCALS (current_function_decl)) + +/* True iff TYPE takes two variable/stack slots. */ +#define TYPE_IS_WIDE(TYPE) \ + ((TYPE) == double_type_node || (TYPE) == long_type_node) + +/* True iff TYPE is a Java array type. */ +#define TYPE_ARRAY_P(TYPE) TYPE_LANG_FLAG_1 (TYPE) + +/* True for an INDIRECT_REF created from a 'ARRAY.length' operation. */ +#define IS_ARRAY_LENGTH_ACCESS(NODE) TREE_LANG_FLAG_4 (NODE) + +/* If FUNCTION_TYPE or METHOD_TYPE: cache for build_java_argument_signature. */ +#define TYPE_ARGUMENT_SIGNATURE(TYPE) \ + (TREE_CHECK2 (TYPE, FUNCTION_TYPE, METHOD_TYPE)->type.minval) + +/* Given an array type, give the type of the elements. */ +/* FIXME this use of TREE_TYPE conflicts with something or other. */ +#define TYPE_ARRAY_ELEMENT(ATYPE) TREE_TYPE (ATYPE) + +/* True if class TYPE has been loaded (i.e. parsed plus laid out). + (The check for CLASS_PARSED_P is needed because of Object and Class.) */ +#define CLASS_LOADED_P(TYPE) (TYPE_SIZE (TYPE) != NULL_TREE \ + && (CLASS_PARSED_P(TYPE) || TYPE_ARRAY_P(TYPE))) + +/* True if class TYPE has been parsed (first pass). */ +#define CLASS_PARSED_P(TYPE) TYPE_LANG_FLAG_2 (TYPE) + +/* True of a RECORD_TYPE of a class/interface type (not array type) */ +#define CLASS_P(TYPE) TYPE_LANG_FLAG_4 (TYPE) + +/* True if class TYPE was requested (on command line) to be compiled.*/ +#define CLASS_FROM_CURRENTLY_COMPILED_P(TYPE) TYPE_LANG_FLAG_5 (TYPE) + +/* True if class TYPE is currently being laid out. Helps in detection + of inheritance cycle occurring as a side effect of performing the + layout of a class. */ +#define CLASS_BEING_LAIDOUT(TYPE) TYPE_LANG_FLAG_6 (TYPE) + +/* True if ID is a qualified named (contains . or /) */ +#define QUALIFIED_P(ID) TREE_LANG_FLAG_2 (ID) + +/* True if ID is a command-line specified filename */ +#define IS_A_COMMAND_LINE_FILENAME_P(ID) TREE_LANG_FLAG_4 (ID) + +/* True if filename ID has already been parsed */ +#define HAS_BEEN_ALREADY_PARSED_P(ID) TREE_LANG_FLAG_5 (ID) + +/* True if TYPE (a TREE_TYPE denoting a class type) was found to + feature a finalizer method. */ +#define HAS_FINALIZER_P(EXPR) TREE_LANG_FLAG_3 (EXPR) + +/* True if NODE belongs to an inner class TYPE_DECL node. + Verifies that NODE as the attributes of a decl. */ +#define INNER_CLASS_DECL_P(NODE) (TYPE_NAME (TREE_TYPE (NODE)) == NODE \ + && DECL_CONTEXT (NODE)) + +/* True if NODE belongs to an inner class RECORD_TYPE node. Checks + that TYPE_NAME bears a decl. An array type wouldn't. */ +#define INNER_CLASS_TYPE_P(NODE) (TREE_CODE (TYPE_NAME (NODE)) == TYPE_DECL \ + && DECL_CONTEXT (TYPE_NAME (NODE))) + +/* True if the class type NODE was declared in an inner scope and is + not a toplevel class */ +#define PURE_INNER_CLASS_TYPE_P(NODE) \ + (INNER_CLASS_TYPE_P (NODE) && !CLASS_STATIC (TYPE_NAME (NODE))) + +/* True if NODE (a TYPE_DECL or a RECORD_TYPE) is an inner class. */ +#define INNER_CLASS_P(NODE) (TREE_CODE (NODE) == TYPE_DECL ? \ + INNER_CLASS_DECL_P (NODE) : \ + (TREE_CODE (NODE) == RECORD_TYPE ? \ + INNER_CLASS_TYPE_P (NODE) : \ + (abort (), 0))) + +/* On a TYPE_DECL, hold the list of inner classes defined within the + scope of TYPE_DECL. */ +#define DECL_INNER_CLASS_LIST(NODE) DECL_INITIAL (TYPE_DECL_CHECK (NODE)) + +/* Add a FIELD_DECL to RECORD_TYPE RTYPE. + The field has name NAME (a char*), a type FTYPE, and a location of LOC. + Unless this is the first field, FIELD most hold the previous field. + FIELD is set to the newly created FIELD_DECL. + + We set DECL_ARTIFICIAL so these fields get skipped by make_class_data + if compiling java.lang.Object or java.lang.Class. */ + +#define PUSH_FIELD(LOC, RTYPE, FIELD, NAME, FTYPE) \ +{ tree _field = build_decl (LOC, FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \ + if (TYPE_FIELDS (RTYPE) == NULL_TREE) \ + TYPE_FIELDS (RTYPE) = _field; \ + else \ + DECL_CHAIN(FIELD) = _field; \ + DECL_CONTEXT (_field) = (RTYPE); \ + DECL_ARTIFICIAL (_field) = 1; \ + FIELD = _field; } + +#define FINISH_RECORD(RTYPE) layout_type (RTYPE) + +/* Start building a RECORD_TYPE constructor's elements in V. The + constructor will have type CTYPE. */ +#define START_RECORD_CONSTRUCTOR(V, CTYPE) \ + do \ + { \ + V = VEC_alloc (constructor_elt, gc, 0); \ + CONSTRUCTOR_APPEND_ELT (V, TYPE_FIELDS (CTYPE), NULL); \ + } \ + while (0) + +/* Append a field initializer to V for the dummy field for the inherited + fields. The dummy field has the given VALUE, and the same type as the + super-class. Must be specified before calls to PUSH_FIELD_VALUE. */ +#define PUSH_SUPER_VALUE(V, VALUE) \ + do \ + { \ + constructor_elt *_elt___ = VEC_last (constructor_elt, V); \ + tree _next___ = DECL_CHAIN (_elt___->index); \ + gcc_assert (!DECL_NAME (_elt___->index)); \ + _elt___->value = VALUE; \ + CONSTRUCTOR_APPEND_ELT (V, _next___, NULL); \ + } \ + while (0) + +/* Append a field initializer to V for a field with the given VALUE. + NAME is a char* string used for error checking; + the initializer must be specified in order. */ +#define PUSH_FIELD_VALUE(V, NAME, VALUE) \ + do \ + { \ + constructor_elt *_elt___ = VEC_last (constructor_elt, V); \ + tree _next___ = DECL_CHAIN (_elt___->index); \ + gcc_assert (strcmp (IDENTIFIER_POINTER (DECL_NAME (_elt___->index)), \ + NAME) == 0); \ + _elt___->value = VALUE; \ + CONSTRUCTOR_APPEND_ELT (V, _next___, NULL); \ + } \ + while (0) + +/* Finish creating a record CONSTRUCTOR CONS with type CTYPE and elements V. */ +#define FINISH_RECORD_CONSTRUCTOR(CONS, V, CTYPE) \ + do \ + { \ + VEC_pop (constructor_elt, V); \ + CONS = build_constructor (CTYPE, V); \ + TREE_CONSTANT (CONS) = 0; \ + } \ + while (0) + +#define BLOCK_EXPR_DECLS(NODE) BLOCK_VARS(NODE) +#define BLOCK_EXPR_BODY(NODE) BLOCK_SUBBLOCKS(NODE) + +#define BUILD_MONITOR_ENTER(WHERE, ARG) \ + { \ + (WHERE) = build_call_nary (int_type_node, \ + build_address_of (soft_monitorenter_node), \ + 1, (ARG)); \ + TREE_SIDE_EFFECTS (WHERE) = 1; \ + } + +#define BUILD_MONITOR_EXIT(WHERE, ARG) \ + { \ + (WHERE) = build_call_nary (int_type_node, \ + build_address_of (soft_monitorexit_node), \ + 1, (ARG)); \ + TREE_SIDE_EFFECTS (WHERE) = 1; \ + } + +/* True when we can perform static class initialization optimization */ +#define STATIC_CLASS_INIT_OPT_P() \ + (flag_optimize_sci && (optimize >= 2)) + +/* These are the possible values for the `state' field of the class + structure. This must be kept in sync with libgcj. */ +enum +{ + JV_STATE_NOTHING = 0, /* Set by compiler. */ + + JV_STATE_PRELOADING = 1, /* Can do _Jv_FindClass. */ + JV_STATE_LOADING = 3, /* Has super installed. */ + JV_STATE_READ = 4, /* Has been completely defined. */ + JV_STATE_LOADED = 5, /* Has Miranda methods defined. */ + + JV_STATE_COMPILED = 6, /* This was a compiled class. */ + + JV_STATE_PREPARED = 7, /* Layout & static init done. */ + JV_STATE_LINKED = 9, /* Strings interned. */ + + JV_STATE_IN_PROGRESS = 10, /* <Clinit> running. */ + JV_STATE_ERROR = 12, + + JV_STATE_DONE = 14 /* Must be last. */ +}; + +#undef DEBUG_JAVA_BINDING_LEVELS + +extern void java_genericize (tree); +extern int java_gimplify_expr (tree *, gimple_seq *, gimple_seq *); + +extern FILE *finput; + +#endif /* ! GCC_JAVA_TREE_H */ diff --git a/gcc/java/javaop.def b/gcc/java/javaop.def new file mode 100644 index 000000000..653c77f72 --- /dev/null +++ b/gcc/java/javaop.def @@ -0,0 +1,313 @@ +/* Table of opcodes for byte codes defined by the Java(TM) virtual + machine specification. + Copyright (C) 1998, 2003, 2007 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. + +Written by Per Bothner <bothner@cygnus.com>, February 1996. +*/ + +/* JAVAOP (OPNAME, OPCODE, OPKIND, OPERAND_TYPE, OPERAND_VALUE), where: + OPNAME is the name of the opcode. + OPCODE is the 1-byte opcode value. + OPKIND is the kind of operation. + OPERAND_TYPE is the type operands affected. + OPERAND_VALUE tells where to get the value. (Its meaning + depends on OPKIND.) */ + +/* Various macro used in OPERAND_VALUE: +IMMEDIATE_s1: An immediate signed 1-byte value in the byte-code stream. +IMMEDIATE_s2: An immediate signed 2-byte value in the byte-code stream. +IMMEDIATE_u1: An immediate unsigned 1-byte value in the byte-code stream. +IMMEDIATE_u2: An immediate unsigned 2-byte value in the byte-code stream. + +CONST_INDEX_1: An immediate unsigned 1-byte index into the constant pool. +CONST_INDEX_2: An immediate unsigned 2-byte index into the constant pool. +*/ + +/* More specifically, this is the meaning of the various OPKINDs: + +BINOP: binary operation + OPERAND_TYPE is the argument type. + OPERAND_VALUE is PLUS, MINUS, MULT, TRUNC_DIV, RDIV, REM, + LSHIFT, RSHIFT, URSHIFT, BIT_AND, BIT_IOR, BIT_XOR, + COMPARE, COMPARE_L, or COMPARE_G. + +UNOP: unary operation + OPERAND_TYPE is the argument type. + OPERAND_VALUE is NEG. + +INVOKE: invoke operations + OPERAND_TYPE is VIRTUAL, SPECIAL, STATIC, or INTERFACE. + OPERAND_VALUE is 1 if interface, 0 otherwise. + +OBJECT: new, checkcast, instanceof + OPERAND_TYPE is PTR. + OPERAND_VALUE is NEW, CHECKCAST, or INSTANCEOF. + +BRANCH: branch operations + OPERAND_TYPE is GOTO, CALL, or RETURN. + OPERAND_VALUE is IMMEDIATE_s2, VAR_INDEX_1, IMMEDIATE_s4, + or VAR_INDEX_2. + +STACK: Various stack operations. + +PUSHC: Push a constant onto the operand stack. + OPERAND_VALUE maybe be the value to push, + or IMMEDIATE_s1 or IMMEDIATE_s2 if the constant is immediate, + or CONST_INDEX_1 or CONST_INDEX_2 for a constant pool index. + +LOAD: Push a value from a local variable onto the operand stack. + OPERAND_VALUE is the index of the local variable in the current + Java frame. It can be a literal, or IMMEDIATE_i2. + +CONVERT: Convert top of stack value from one type to another. + OPERAND_TYPE is the argument type. + OPERAND_VALUE is the result type. + +TEST: Compares an integer (popped from the stack) against zero. + If the test (in OPERAND_VALUE) is true, goto a relative + offset given by the next two bytes. + +COND: Compares two values (popped from the stack) against each other. + If the test (in OPERAND_VALUE) is true, goto a relative + offset given by the next two bytes. + +SWITCH: + OPERAND_VALUE is either TABLE or LOOKUP. + +ARRAY: + OPERAND_VALUE is LOAD, STORE, LENGTH, or NEW. + +FIELD: Extracts from or stores into a field. + OPERAND_TYPE is 1 for a static field, 0 for a regular field. + OPERAND_VALUE is 1 for a put operation, 0 for a get operation. + +SPECIAL: + Random bunch of opcodes. + +*/ + +JAVAOP (nop, 0, STACK, POP, 0) +JAVAOP (aconst_null, 1, PUSHC, PTR, 0) +JAVAOP (iconst_m1, 2, PUSHC, INT, -1) +JAVAOP (iconst_0, 3, PUSHC, INT, 0) +JAVAOP (iconst_1, 4, PUSHC, INT, 1) +JAVAOP (iconst_2, 5, PUSHC, INT, 2) +JAVAOP (iconst_3, 6, PUSHC, INT, 3) +JAVAOP (iconst_4, 7, PUSHC, INT, 4) +JAVAOP (iconst_5, 8, PUSHC, INT, 5) +JAVAOP (lconst_0, 9, PUSHC, LONG, 0) +JAVAOP (lconst_1, 10, PUSHC, LONG, 1) +JAVAOP (fconst_0, 11, PUSHC, FLOAT, 0) +JAVAOP (fconst_1, 12, PUSHC, FLOAT, 1) +JAVAOP (fconst_2, 13, PUSHC, FLOAT, 2) +JAVAOP (dconst_0, 14, PUSHC, DOUBLE, 0) +JAVAOP (dconst_1, 15, PUSHC, DOUBLE, 1) +JAVAOP (bipush, 16, PUSHC, INT, IMMEDIATE_s1) +JAVAOP (sipush, 17, PUSHC, INT, IMMEDIATE_s2) +JAVAOP (ldc, 18, PUSHC, INT, CONST_INDEX_1) +JAVAOP (ldc_w, 19, PUSHC, INT, CONST_INDEX_2) +JAVAOP (ldc2_w, 20, PUSHC, LONG, CONST_INDEX_2) +JAVAOP (iload, 21, LOAD, INT, IMMEDIATE_u1) +JAVAOP (lload, 22, LOAD, LONG, IMMEDIATE_u1) +JAVAOP (fload, 23, LOAD, FLOAT, IMMEDIATE_u1) +JAVAOP (dload, 24, LOAD, DOUBLE, IMMEDIATE_u1) +JAVAOP (aload, 25, LOAD, PTR, IMMEDIATE_u1) +JAVAOP (iload_0, 26, LOAD, INT, 0) +JAVAOP (iload_1, 27, LOAD, INT, 1) +JAVAOP (iload_2, 28, LOAD, INT, 2) +JAVAOP (iload_3, 29, LOAD, INT, 3) +JAVAOP (lload_0, 30, LOAD, LONG, 0) +JAVAOP (lload_1, 31, LOAD, LONG, 1) +JAVAOP (lload_2, 32, LOAD, LONG, 2) +JAVAOP (lload_3, 33, LOAD, LONG, 3) +JAVAOP (fload_0, 34, LOAD, FLOAT, 0) +JAVAOP (fload_1, 35, LOAD, FLOAT, 1) +JAVAOP (fload_2, 36, LOAD, FLOAT, 2) +JAVAOP (fload_3, 37, LOAD, FLOAT, 3) +JAVAOP (dload_0, 38, LOAD, DOUBLE, 0) +JAVAOP (dload_1, 39, LOAD, DOUBLE, 1) +JAVAOP (dload_2, 40, LOAD, DOUBLE, 2) +JAVAOP (dload_3, 41, LOAD, DOUBLE, 3) +JAVAOP (aload_0, 42, LOAD, PTR, 0) +JAVAOP (aload_1, 43, LOAD, PTR, 1) +JAVAOP (aload_2, 44, LOAD, PTR, 2) +JAVAOP (aload_3, 45, LOAD, PTR, 3) +JAVAOP (iaload, 46, ARRAY, INT, LOAD) +JAVAOP (laload, 47, ARRAY, LONG, LOAD) +JAVAOP (faload, 48, ARRAY, FLOAT, LOAD) +JAVAOP (daload, 49, ARRAY, DOUBLE, LOAD) +JAVAOP (aaload, 50, ARRAY, PTR, LOAD) +JAVAOP (baload, 51, ARRAY, BYTE, LOAD) +JAVAOP (caload, 52, ARRAY, CHAR, LOAD) +JAVAOP (saload, 53, ARRAY, SHORT, LOAD) +JAVAOP (istore, 54, STORE, INT, IMMEDIATE_u1) +JAVAOP (lstore, 55, STORE, LONG, IMMEDIATE_u1) +JAVAOP (fstore, 56, STORE, FLOAT, IMMEDIATE_u1) +JAVAOP (dstore, 57, STORE, DOUBLE, IMMEDIATE_u1) +JAVAOP (astore, 58, STORE, PTR, IMMEDIATE_u1) +JAVAOP (istore_0, 59, STORE, INT, 0) +JAVAOP (istore_1, 60, STORE, INT, 1) +JAVAOP (istore_2, 61, STORE, INT, 2) +JAVAOP (istore_3, 62, STORE, INT, 3) +JAVAOP (lstore_0, 63, STORE, LONG, 0) +JAVAOP (lstore_1, 64, STORE, LONG, 1) +JAVAOP (lstore_2, 65, STORE, LONG, 2) +JAVAOP (lstore_3, 66, STORE, LONG, 3) +JAVAOP (fstore_0, 67, STORE, FLOAT, 0) +JAVAOP (fstore_1, 68, STORE, FLOAT, 1) +JAVAOP (fstore_2, 69, STORE, FLOAT, 2) +JAVAOP (fstore_3, 70, STORE, FLOAT, 3) +JAVAOP (dstore_0, 71, STORE, DOUBLE, 0) +JAVAOP (dstore_1, 72, STORE, DOUBLE, 1) +JAVAOP (dstore_2, 73, STORE, DOUBLE, 2) +JAVAOP (dstore_3, 74, STORE, DOUBLE, 3) +JAVAOP (astore_0, 75, STORE, PTR, 0) +JAVAOP (astore_1, 76, STORE, PTR, 1) +JAVAOP (astore_2, 77, STORE, PTR, 2) +JAVAOP (astore_3, 78, STORE, PTR, 3) +JAVAOP (iastore, 79, ARRAY, INT, STORE) +JAVAOP (lastore, 80, ARRAY, LONG, STORE) +JAVAOP (fastore, 81, ARRAY, FLOAT, STORE) +JAVAOP (dastore, 82, ARRAY, DOUBLE, STORE) +JAVAOP (aastore, 83, ARRAY, PTR, STORE) +JAVAOP (bastore, 84, ARRAY, BYTE, STORE) +JAVAOP (castore, 85, ARRAY, CHAR, STORE) +JAVAOP (sastore, 86, ARRAY, SHORT, STORE) +JAVAOP (pop, 87, STACK, POP, 1) +JAVAOP (pop2, 88, STACK, POP, 2) +JAVAOP (dup, 89, STACK, DUP, 1) +JAVAOP (dup_x1, 90, STACK, DUPx1, 1) +JAVAOP (dup_x2, 91, STACK, DUPx2, 1) +JAVAOP (dup2, 92, STACK, DUP, 2) +JAVAOP (dup2_x1, 93, STACK, DUPx1, 2) +JAVAOP (dup2_x2, 94, STACK, DUPx2, 2) +JAVAOP (swap, 95, STACK, SWAP, 0) +JAVAOP (iadd, 96, BINOP, INT, PLUS) +JAVAOP (ladd, 97, BINOP, LONG, PLUS) +JAVAOP (fadd, 98, BINOP, FLOAT, PLUS) +JAVAOP (dadd, 99, BINOP, DOUBLE, PLUS) +JAVAOP (isub, 100, BINOP, INT, MINUS) +JAVAOP (lsub, 101, BINOP, LONG, MINUS) +JAVAOP (fsub, 102, BINOP, FLOAT, MINUS) +JAVAOP (dsub, 103, BINOP, DOUBLE, MINUS) +JAVAOP (imul, 104, BINOP, INT, MULT) +JAVAOP (lmul, 105, BINOP, LONG, MULT) +JAVAOP (fmul, 106, BINOP, FLOAT, MULT) +JAVAOP (dmul, 107, BINOP, DOUBLE, MULT) +JAVAOP (idiv, 108, BINOP, INT, TRUNC_DIV) +JAVAOP (ldiv, 109, BINOP, LONG, TRUNC_DIV) +JAVAOP (fdiv, 110, BINOP, FLOAT, RDIV) +JAVAOP (ddiv, 111, BINOP, DOUBLE, RDIV) +JAVAOP (irem, 112, BINOP, INT, REM) +JAVAOP (lrem, 113, BINOP, LONG, REM) +JAVAOP (frem, 114, BINOP, FLOAT, REM) +JAVAOP (drem, 115, BINOP, DOUBLE, REM) +JAVAOP (ineg, 116, UNOP, INT, NEG) +JAVAOP (lneg, 117, UNOP, LONG, NEG) +JAVAOP (fneg, 118, UNOP, FLOAT, NEG) +JAVAOP (dneg, 119, UNOP, DOUBLE, NEG) +JAVAOP (ishl, 120, BINOP, INT, LSHIFT) +JAVAOP (lshl, 121, BINOP, LONG, LSHIFT) +JAVAOP (ishr, 122, BINOP, INT, RSHIFT) +JAVAOP (lshr, 123, BINOP, LONG, RSHIFT) +JAVAOP (iushr, 124, BINOP, INT, URSHIFT) +JAVAOP (lushr, 125, BINOP, LONG, URSHIFT) +JAVAOP (iand, 126, BINOP, INT, BIT_AND) +JAVAOP (land, 127, BINOP, LONG, BIT_AND) +JAVAOP (ior, 128, BINOP, INT, BIT_IOR) +JAVAOP (lor, 129, BINOP, LONG, BIT_IOR) +JAVAOP (ixor, 130, BINOP, INT, BIT_XOR) +JAVAOP (lxor, 131, BINOP, LONG, BIT_XOR) +JAVAOP (iinc, 132, SPECIAL, INT, IINC) +JAVAOP (i2l, 133, CONVERT, INT, LONG) +JAVAOP (i2f, 134, CONVERT, INT, FLOAT) +JAVAOP (i2d, 135, CONVERT, INT, DOUBLE) +JAVAOP (l2i, 136, CONVERT, LONG, INT) +JAVAOP (l2f, 137, CONVERT, LONG, FLOAT) +JAVAOP (l2d, 138, CONVERT, LONG, DOUBLE) +JAVAOP (f2i, 139, CONVERT, FLOAT, INT) +JAVAOP (f2l, 140, CONVERT, FLOAT, LONG) +JAVAOP (f2d, 141, CONVERT, FLOAT, DOUBLE) +JAVAOP (d2i, 142, CONVERT, DOUBLE, INT) +JAVAOP (d2l, 143, CONVERT, DOUBLE, LONG) +JAVAOP (d2f, 144, CONVERT, DOUBLE, FLOAT) +JAVAOP (i2b, 145, CONVERT2, INT, BYTE) +JAVAOP (i2c, 146, CONVERT2, INT, CHAR) +JAVAOP (i2s, 147, CONVERT2, INT, SHORT) +JAVAOP (lcmp, 148, BINOP, LONG, COMPARE) +JAVAOP (fcmpl, 149, BINOP, FLOAT, COMPARE_L) +JAVAOP (fcmpg, 150, BINOP, FLOAT, COMPARE_G) +JAVAOP (dcmpl, 151, BINOP, DOUBLE, COMPARE_L) +JAVAOP (dcmpg, 152, BINOP, DOUBLE, COMPARE_G) +JAVAOP (ifeq, 153, TEST, INT, EQ) +JAVAOP (ifne, 154, TEST, INT, NE) +JAVAOP (iflt, 155, TEST, INT, LT) +JAVAOP (ifge, 156, TEST, INT, GE) +JAVAOP (ifgt, 157, TEST, INT, GT) +JAVAOP (ifle, 158, TEST, INT, LE) +JAVAOP (if_icmpeq, 159, COND, INT, EQ) +JAVAOP (if_icmpne, 160, COND, INT, NE) +JAVAOP (if_icmplt, 161, COND, INT, LT) +JAVAOP (if_icmpge, 162, COND, INT, GE) +JAVAOP (if_icmpgt, 163, COND, INT, GT) +JAVAOP (if_icmple, 164, COND, INT, LE) +JAVAOP (if_acmpeq, 165, COND, PTR, EQ) +JAVAOP (if_acmpne, 166, COND, PTR, NE) +JAVAOP (goto, 167, BRANCH, GOTO, IMMEDIATE_s2) +JAVAOP (jsr, 168, JSR, CALL, IMMEDIATE_s2) +JAVAOP (ret, 169, RET, RETURN, VAR_INDEX_1) +JAVAOP (tableswitch, 170, SWITCH, INT, TABLE) +JAVAOP (lookupswitch, 171, SWITCH, INT, LOOKUP) +JAVAOP (ireturn, 172, RETURN, INT, 0) +JAVAOP (lreturn, 173, RETURN, LONG, 0) +JAVAOP (freturn, 174, RETURN, FLOAT, 0) +JAVAOP (dreturn, 175, RETURN, DOUBLE, 0) +JAVAOP (areturn, 176, RETURN, PTR, 0) +JAVAOP (return, 177, RETURN, VOID, 0) +JAVAOP (getstatic, 178, FIELD, 1, 0) +JAVAOP (putstatic, 179, FIELD, 1, 1) +JAVAOP (getfield, 180, FIELD, 0, 0) +JAVAOP (putfield, 181, FIELD, 0, 1) +JAVAOP (invokevirtual, 182, INVOKE, VIRTUAL,0) +JAVAOP (invokespecial, 183, INVOKE, SPECIAL, 0) +JAVAOP (invokestatic, 184, INVOKE, STATIC, 0) +JAVAOP (invokeinterface,185, INVOKE, INTERFACE, 1) +JAVAOP (new, 187, OBJECT, PTR, NEW) +JAVAOP (newarray, 188, ARRAY, NUM, NEW) +JAVAOP (anewarray, 189, ARRAY, PTR, NEW) +JAVAOP (arraylength, 190, ARRAY, INT, LENGTH) +JAVAOP (athrow, 191, SPECIAL, ANY, THROW) +JAVAOP (checkcast, 192, OBJECT, PTR, CHECKCAST) +JAVAOP (instanceof, 193, OBJECT, PTR, INSTANCEOF) +JAVAOP (monitorenter, 194, SPECIAL, MONITOR, ENTER) +JAVAOP (monitorexit, 195, SPECIAL, MONITOR, EXIT) +JAVAOP (wide, 196, SPECIAL, ANY, WIDE) +JAVAOP (multianewarray,197, ARRAY, MULTI, NEW) +JAVAOP (ifnull, 198, TEST, PTR, EQ) +JAVAOP (ifnonnull, 199, TEST, PTR, NE) +JAVAOP (goto_w, 200, BRANCH, GOTO, IMMEDIATE_s4) +JAVAOP (jsr_w, 201, JSR, CALL, IMMEDIATE_s4) +JAVAOP (breakpoint, 202, SPECIAL, ANY, BREAK) +JAVAOP (ret_w, 209, RET, RETURN, VAR_INDEX_2) +JAVAOP (impdep1, 254, IMPL, ANY, 1) +JAVAOP (impdep2, 255, IMPL, ANY, 2) diff --git a/gcc/java/javaop.h b/gcc/java/javaop.h new file mode 100644 index 000000000..176fe046f --- /dev/null +++ b/gcc/java/javaop.h @@ -0,0 +1,190 @@ +/* Utility macros to handle Java(TM) byte codes. + + Copyright (C) 1996, 1998, 1999, 2003, 2007 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */ + +#ifndef GCC_JAVAOP_H +#define GCC_JAVAOP_H + +typedef unsigned char uint8; +#ifndef int16 +#if __SHRT_MAX__ == 32767 +#define int16 short +#elif __INT_MAX__ == 32767 +#define int16 int +#elif __LONG_MAX__ == 32767 +#define int16 long +#else +#define int16 short +#endif +#endif +typedef unsigned int16 uint16; + +#ifndef int32 +#if __INT_MAX__ == 2147483647 +#define int32 int +#elif __LONG_MAX__ == 2147483647 +#define int32 long +#elif __SHRT_MAX__ == 2147483647 +#define int32 short +#else +#define int32 int +#endif +#endif +typedef unsigned int32 uint32; + +/* A signed 64-bit (or more) integral type, suitable for Java's 'long'. */ +#ifndef int64 +#if __LONG_MAX__ == 9223372036854775807LL +#define int64 long +#elif __LONG_LONG_MAX__ == 9223372036854775807LL +#define int64 long long +#else +#define int64 long long +#endif +#endif +/* An unsigned 64-bit (or more) integral type, same length as int64. */ +#ifndef uint64 +#define uint64 unsigned int64 +#endif + +typedef uint16 jchar; +typedef signed char jbyte; +typedef int16 jshort; +typedef int32 jint; +typedef int64 jlong; +typedef void* jref; + +/* A 32-bit big-endian IEEE single-precision float. */ +typedef struct _jfloat { + unsigned int negative : 1; + unsigned int exponent : 8; + unsigned int mantissa : 23; +} jfloat; +#define JFLOAT_FINITE(f) ((f).exponent != 0xFF) +#define JFLOAT_QNAN_MASK 0x400000 +#define JFLOAT_EXP_BIAS 0x7f + +/* A 32-bit big-endian IEEE double-precision float. */ +typedef struct _jdouble { + unsigned int negative : 1; + unsigned int exponent : 11; + unsigned int mantissa0: 20; + unsigned int mantissa1: 32; +} jdouble; +#define JDOUBLE_FINITE(f) ((f).exponent != 0x7FF) +#define JDOUBLE_QNAN_MASK 0x80000 /* apply to mantissa0 */ +#define JDOUBLE_EXP_BIAS 0x3ff + +/* A jword is an unsigned integral type big enough for a 32-bit jint + or jfloat *or* a pointer. It is the type appropriate for stack + locations and local variables in a Java interpreter. */ + + +#ifndef jword +#if defined (__LP64__) || defined (__alpha__) || defined (__MMIX__) \ + || (defined (_ARCH_PPC) && defined (__64BIT__)) \ + || defined (__powerpc64__) || defined (__s390x__) || defined (__x86_64__) \ + || defined (__sparcv9) || (defined (__sparc__) && defined (__arch64__)) +#define jword uint64 +#else +#define jword uint32 +#endif +#endif + +#ifndef IMMEDIATE_u1 +#define IMMEDIATE_u1 (PC++, CHECK_PC_IN_RANGE(PC), BCODE[PC-1]) +#endif +#ifndef IMMEDIATE_s1 +#define IMMEDIATE_s1 (PC++, CHECK_PC_IN_RANGE(PC), (signed char)BCODE[PC-1]) +#endif +#ifndef IMMEDIATE_s2 +#define IMMEDIATE_s2 (PC+=2, CHECK_PC_IN_RANGE(PC), \ + (signed char) BCODE[PC-2] * 256 + BCODE[PC-1]) +#endif +#ifndef IMMEDIATE_u2 +#define IMMEDIATE_u2 (PC+=2, CHECK_PC_IN_RANGE(PC),\ + (BCODE[PC-2] * 256 + BCODE[PC-1])) +#endif +#ifndef IMMEDIATE_s4 +#define IMMEDIATE_s4 (PC+=4, CHECK_PC_IN_RANGE(PC), \ + (WORD_TO_INT((BCODE[PC-4] << 24) | (BCODE[PC-3] << 16) \ + | (BCODE[PC-2] << 8) | (BCODE[PC-1])))) +#endif + +static inline jfloat +WORD_TO_FLOAT(jword w) +{ + jfloat f; + + f.negative = (w & 0x80000000) >> 31; + f.exponent = (w & 0x7f800000) >> 23; + f.mantissa = (w & 0x007fffff); + + return f; +} + +/* Sign extend w. If the host on which this cross-compiler runs uses + a 64-bit type for jword the appropriate sign extension is + performed; if it's a 32-bit type the arithmetic does nothing but is + harmless. */ +static inline jint +WORD_TO_INT(jword w) +{ + jint n = w & 0xffffffff; /* Mask lower 32 bits. */ + n ^= (jint)1 << 31; + n -= (jint)1 << 31; /* Sign extend lower 32 bits to upper. */ + return n; +} + +static inline jlong +WORDS_TO_LONG(jword hi, jword lo) +{ + return ((jlong) hi << 32) | ((jlong)lo & (((jlong)1 << 32) -1)); +} + +static inline jdouble +WORDS_TO_DOUBLE(jword hi, jword lo) +{ + jdouble d; + + d.negative = (hi & 0x80000000) >> 31; + d.exponent = (hi & 0x7ff00000) >> 20; + d.mantissa0 = (hi & 0x000fffff); + d.mantissa1 = lo; + + return d; +} + +/* If PREFIX_CHAR is the first character of the Utf8 encoding of a character, + return the number of bytes taken by the encoding. + Return -1 for a continuation character. */ +#define UT8_CHAR_LENGTH(PREFIX_CHAR) \ + ((unsigned char)(PREFIX_CHAR) < 128 ? 1 \ + : ((PREFIX_CHAR) & 0x40) == 0 ? -1 \ + : ((PREFIX_CHAR) & 0x20) == 0 ? 2 \ + : ((PREFIX_CHAR) & 0x10) == 0 ? 3 \ + : ((PREFIX_CHAR) & 0x08) == 0 ? 4 : 5) + +#endif /* ! GCC_JAVAOP_H */ diff --git a/gcc/java/jcf-depend.c b/gcc/java/jcf-depend.c new file mode 100644 index 000000000..cde2a8dc7 --- /dev/null +++ b/gcc/java/jcf-depend.c @@ -0,0 +1,141 @@ +/* Functions for handling dependency tracking when reading .class files. + + Copyright (C) 1998, 1999, 2000, 2001, 2003, 2006, 2007, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Tom Tromey <tromey@cygnus.com>, October 1998. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "mkdeps.h" + +#include "jcf.h" + + + +/* The dependency structure used for this invocation. */ +struct deps *dependencies; + +/* The output file, or NULL if we aren't doing dependency tracking. */ +static FILE *dep_out = NULL; + +/* Nonzero if system files should be added. */ +static int system_files; + +/* Nonzero if we are dumping out dummy dependencies. */ +static int print_dummies; + + + +/* Call this to reset the dependency module. This is required if + multiple dependency files are being generated from a single tool + invocation. FIXME: we should change our API or just completely use + the one in mkdeps.h. */ +void +jcf_dependency_reset (void) +{ + if (dep_out != NULL) + { + if (dep_out != stdout) + fclose (dep_out); + dep_out = NULL; + } + + if (dependencies != NULL) + { + deps_free (dependencies); + dependencies = NULL; + } +} + +void +jcf_dependency_set_target (const char *name) +{ + /* We just handle this the same as an `add_target'. */ + if (dependencies != NULL && name != NULL) + deps_add_target (dependencies, name, 1); +} + +void +jcf_dependency_add_target (const char *name) +{ + if (dependencies != NULL) + deps_add_target (dependencies, name, 1); +} + +void +jcf_dependency_set_dep_file (const char *name) +{ + gcc_assert (dep_out != stdout); + if (dep_out) + fclose (dep_out); + if (! strcmp (name, "-")) + dep_out = stdout; + else + dep_out = fopen (name, "w"); +} + +void +jcf_dependency_add_file (const char *filename ATTRIBUTE_UNUSED, int system_p) +{ + if (! dependencies) + return; + + /* Just omit system files. */ + if (system_p && ! system_files) + return; + + + /* FIXME: Don't emit any dependencies. In many cases we'll just see + temporary files emitted by ecj... */ + /* deps_add_dep (dependencies, filename); */ +} + +void +jcf_dependency_init (int system_p) +{ + gcc_assert (! dependencies); + system_files = system_p; + dependencies = deps_init (); +} + +void +jcf_dependency_print_dummies (void) +{ + print_dummies = 1; +} + +void +jcf_dependency_write (void) +{ + if (! dep_out) + return; + + gcc_assert (dependencies); + + deps_write (dependencies, dep_out, 72); + if (print_dummies) + deps_phony_targets (dependencies, dep_out); + fflush (dep_out); +} diff --git a/gcc/java/jcf-dump.c b/gcc/java/jcf-dump.c new file mode 100644 index 000000000..719105fe2 --- /dev/null +++ b/gcc/java/jcf-dump.c @@ -0,0 +1,1582 @@ +/* Program to dump out a Java(TM) .class file. + Functionally similar to Sun's javap. + + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */ + +/* + jcf-dump is a program to print out the contents of class files. + Usage: jcf-dump [FLAGS] CLASS + Each CLASS is either: + + the name of a class in the CLASSPATH (e.g "java.lang.String"), or + + the name of a class *file* (e.g. "/home/me/work/package/Foo.class"). + + The name of a .zip or .jar file (which prints all the classes in the + archive). + + OPTIONS: + -c + Dis-assemble each method. + -classpath PATH + Overrides $CLASSPATH. + --print-main + Print nothing if there is no valid "main" method; + otherwise, print only the class name. + --javap + Print output in the style of Sun's javap program. VERY UNFINISHED. + */ + + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "intl.h" + +#include "jcf.h" +#include "tree.h" +#include "java-tree.h" + +#include "version.h" + +#include <getopt.h> +#include <math.h> + +/* Output file. */ +FILE *out; +/* Name of output file, if NULL if stdout. */ +char *output_file = NULL; + +int verbose = 0; + +int flag_disassemble_methods = 0; +int flag_print_class_info = 1; +int flag_print_constant_pool = 0; +int flag_print_fields = 1; +int flag_print_methods = 1; +int flag_print_attributes = 1; + +/* Print names of classes that have a "main" method. */ +int flag_print_main = 0; + +/* Index in constant pool of this class. */ +int this_class_index = 0; + +int class_access_flags = 0; + +/* Print in format similar to javap. VERY INCOMPLETE. */ +int flag_javap_compatible = 0; + +static void print_access_flags (FILE *, uint16, char); +static void print_constant_terse (FILE*, JCF*, int, int); +static void print_constant_terse_with_index (FILE *, JCF *, int, int); +static void print_constant (FILE *, JCF *, int, int); +static void print_constant_ref (FILE *, JCF *, int); +static void disassemble_method (JCF*, const unsigned char *, int); +static void print_name (FILE*, JCF*, int); +static void print_signature (FILE*, JCF*, int, int); +static int utf8_equal_string (struct JCF*, int, const char *); +static void usage (void) ATTRIBUTE_NORETURN; +static void help (void) ATTRIBUTE_NORETURN; +static void version (void) ATTRIBUTE_NORETURN; +static void process_class (struct JCF *); +static void print_constant_pool (struct JCF *); +static void print_exception_table (struct JCF *, const unsigned char *entries, + int); +static void indent (FILE *, int); +static void print_element_value (FILE *, JCF *, int); +static void print_annotation (FILE *, JCF *, int); +static void print_annotations (FILE *, JCF *, int); +static void print_parameter_annotations (FILE *, JCF *, int); + +#define PRINT_SIGNATURE_RESULT_ONLY 1 +#define PRINT_SIGNATURE_ARGS_ONLY 2 + +static int +utf8_equal_string (JCF *jcf, int index, const char * value) +{ + if (CPOOL_INDEX_IN_RANGE (&jcf->cpool, index) + && JPOOL_TAG (jcf, index) == CONSTANT_Utf8) + { + int len = strlen (value); + if (JPOOL_UTF_LENGTH (jcf, index) == len + && memcmp (JPOOL_UTF_DATA (jcf, index), value, len) == 0) + return 1; + } + return 0; +} + +#define HANDLE_MAGIC(MAGIC, MINOR, MAJOR) \ + this_class_index = 0; \ + if (flag_print_class_info) \ + fprintf (out, \ + "Magic number: 0x%0lx, minor_version: %ld, major_version: %ld.\n",\ + (unsigned long) MAGIC, (long) MINOR, (long) MAJOR) + +#define HANDLE_START_CONSTANT_POOL(COUNT) \ + if (flag_print_constant_pool) \ + fprintf (out, "\nConstant pool (count: %d):\n", COUNT) + +#define HANDLE_SOURCEFILE(INDEX) \ +{ fprintf (out, "Attribute "); \ + print_constant_terse (out, jcf, attribute_name, CONSTANT_Utf8); \ + fprintf (out, ", length:%ld, #%d=", (long) attribute_length, INDEX); \ + print_constant_terse (out, jcf, INDEX, CONSTANT_Utf8); fputc ('\n', out); } + +#define HANDLE_CLASS_INFO(ACCESS_FLAGS, THIS, SUPER, INTERFACES_COUNT) \ + this_class_index = THIS; \ + class_access_flags = ACCESS_FLAGS; \ + if (flag_print_class_info) \ + { fprintf (out, "\nAccess flags: 0x%x", ACCESS_FLAGS); \ + print_access_flags (out, ACCESS_FLAGS, 'c'); \ + fputc ('\n', out); \ + fprintf (out, "This class: "); \ + print_constant_terse_with_index (out, jcf, THIS, CONSTANT_Class); \ + if (flag_print_constant_pool || SUPER != 0) \ + fprintf (out, ", super: "); \ + if (flag_print_constant_pool) \ + { \ + fprintf (out, "%d", SUPER); \ + if (SUPER != 0) \ + fputc ('=', out); \ + } \ + if (SUPER != 0) \ + print_constant_terse (out, jcf, SUPER, CONSTANT_Class); \ + fprintf (out, "\nInterfaces (count: %d):\n", INTERFACES_COUNT); \ + } + +#define IGNORE_ATTRIBUTE(JCF, NAME, NAME_LENGTH) \ + (flag_print_attributes <= 0) + +#define HANDLE_CLASS_INTERFACE(INDEX) \ + if (flag_print_class_info) \ + { fprintf (out, "- Implements: "); \ + print_constant_terse_with_index (out, jcf, INDEX, CONSTANT_Class); \ + fputc ('\n', out); } + +#define HANDLE_START_FIELDS(FIELDS_COUNT) \ + if (flag_print_fields) \ + fprintf (out, "\nFields (count: %d):\n", FIELDS_COUNT) + +#define HANDLE_START_FIELD(ACCESS_FLAGS, NAME, SIGNATURE, ATTRIBUTE_COUNT) \ + if (flag_print_fields) \ + { fprintf (out, "Field name:"); \ + print_constant_terse (out, jcf, NAME, CONSTANT_Utf8); \ + print_access_flags (out, ACCESS_FLAGS, 'f'); \ + fprintf (out, " Descriptor: "); \ + if (flag_print_constant_pool) \ + fprintf (out, "%d=", SIGNATURE); \ + print_signature (out, jcf, SIGNATURE, 0); \ + fputc ('\n', out); } \ + else \ + flag_print_attributes--; + +#define HANDLE_END_FIELD() \ + if (! flag_print_fields) \ + flag_print_attributes++; + +#define HANDLE_START_METHODS(METHODS_COUNT) \ + if (flag_print_methods) \ + fprintf (out, "\nMethods (count: %d):\n", METHODS_COUNT); \ + else \ + flag_print_attributes--; + + +#define HANDLE_END_METHODS() \ + if (! flag_print_methods) \ + flag_print_attributes++; + +#define HANDLE_METHOD(ACCESS_FLAGS, NAME, SIGNATURE, ATTRIBUTE_COUNT) \ +{ \ + if (flag_print_methods) \ + { \ + if (flag_javap_compatible) \ + { \ + fprintf (out, " "); \ + print_access_flags (out, ACCESS_FLAGS, 'm'); \ + fputc (' ', out); \ + print_signature (out, jcf, SIGNATURE, PRINT_SIGNATURE_RESULT_ONLY); \ + fputc (' ', out); \ + print_constant_terse (out, jcf, NAME, CONSTANT_Utf8); \ + print_signature (out, jcf, SIGNATURE, PRINT_SIGNATURE_ARGS_ONLY); \ + fputc ('\n', out); \ + } \ + else \ + { \ + fprintf (out, "\nMethod name:"); \ + print_constant_terse (out, jcf, NAME, CONSTANT_Utf8); \ + print_access_flags (out, ACCESS_FLAGS, 'm'); \ + fprintf (out, " Descriptor: "); \ + if (flag_print_constant_pool) \ + fprintf (out, "%d=", SIGNATURE); \ + print_signature (out, jcf, SIGNATURE, 0); \ + fputc ('\n', out); \ + } \ + } \ + if (flag_print_main && ACCESS_FLAGS == (ACC_STATIC|ACC_PUBLIC) \ + && utf8_equal_string (jcf, NAME, "main") \ + && utf8_equal_string (jcf, SIGNATURE, "([Ljava/lang/String;)V") \ + && this_class_index > 0 \ + && (class_access_flags & ACC_PUBLIC)) \ + { \ + print_constant_terse(out, jcf, this_class_index, CONSTANT_Class); \ + fputc ('\n', out); \ + } \ +} + +#define COMMON_HANDLE_ATTRIBUTE(JCF, INDEX, LENGTH) \ +( fprintf (out, "Attribute "), \ + print_constant_terse (out, jcf, INDEX, CONSTANT_Utf8), \ + fprintf (out, ", length:%ld", (long) LENGTH) ) + +#define HANDLE_CONSTANTVALUE(VALUE_INDEX) \ +( COMMON_HANDLE_ATTRIBUTE(JCF, attribute_name, attribute_length), \ + fprintf (out, ", value: "), \ + print_constant_ref (out, jcf, VALUE_INDEX), \ + fprintf (out, "\n") ) + +#define HANDLE_CODE_ATTRIBUTE(MAX_STACK, MAX_LOCALS, CODE_LENGTH) \ +{ COMMON_HANDLE_ATTRIBUTE(JCF, attribute_name, attribute_length); \ + fprintf (out, ", max_stack:%ld, max_locals:%ld, code_length:%ld\n", \ + (long) MAX_STACK, (long) MAX_LOCALS, (long) CODE_LENGTH); \ + disassemble_method (jcf, jcf->read_ptr, CODE_LENGTH); } + +#define HANDLE_EXCEPTION_TABLE(ENTRIES, COUNT) \ + print_exception_table (jcf, ENTRIES, COUNT) + +#define HANDLE_EXCEPTIONS_ATTRIBUTE(COUNT) \ +{ int n = (COUNT); int i; \ + COMMON_HANDLE_ATTRIBUTE(JCF, attribute_name, attribute_length); \ + fprintf (out, ", count: %d\n", n); \ + for (i = 0; i < n; i++) {\ + int ex_index = JCF_readu2 (jcf); \ + fprintf (out, "%3d: ", i); \ + print_constant_ref (out, jcf, ex_index); \ + fputc ('\n', out); } } + +#define HANDLE_LOCALVARIABLETABLE_ATTRIBUTE(COUNT) \ +{ int n = (COUNT); int i; \ + COMMON_HANDLE_ATTRIBUTE(JCF, attribute_name, attribute_length); \ + fprintf (out, ", count: %d\n", n); \ + for (i = 0; i < n; i++) {\ + int start_pc = JCF_readu2 (jcf); \ + int length = JCF_readu2 (jcf); \ + int name_index = JCF_readu2 (jcf); \ + int signature_index = JCF_readu2 (jcf); \ + int slot = JCF_readu2 (jcf); \ + fprintf (out, " slot#%d: name: ", slot); \ + if (flag_print_constant_pool) \ + fprintf (out, "%d=", name_index); \ + print_name (out, jcf, name_index); \ + fprintf (out, ", type: "); \ + if (flag_print_constant_pool) \ + fprintf (out, "%d=", signature_index); \ + print_signature (out, jcf, signature_index, 0); \ + fprintf (out, " (pc: %d length: %d)\n", start_pc, length); }} + +#define HANDLE_LOCALVARIABLETYPETABLE_ATTRIBUTE(COUNT) \ +{ int n = (COUNT); int i; \ + COMMON_HANDLE_ATTRIBUTE(JCF, attribute_name, attribute_length); \ + fprintf (out, ", count: %d\n", n); \ + for (i = 0; i < n; i++) { \ + int start_pc = JCF_readu2 (jcf); \ + int length = JCF_readu2 (jcf); \ + int name_index = JCF_readu2 (jcf); \ + int signature_index = JCF_readu2 (jcf); \ + int slot = JCF_readu2 (jcf); \ + fprintf (out, " slot#%d: name: ", slot); \ + if (flag_print_constant_pool) \ + fprintf (out, "%d=", name_index); \ + print_name (out, jcf, name_index); \ + fprintf (out, ", type: "); \ + if (flag_print_constant_pool) \ + fprintf (out, "%d=", signature_index); \ + print_signature (out, jcf, signature_index, 0); \ + fprintf (out, " (pc: %d length: %d)\n", start_pc, length); }} + +#define HANDLE_LINENUMBERTABLE_ATTRIBUTE(COUNT) \ +{ int n = (COUNT); int i; \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + fprintf (out, ", count: %d\n", n); \ + if (flag_disassemble_methods) \ + for (i = 0; i < n; i++) {\ + int start_pc = JCF_readu2 (jcf); \ + int line_number = JCF_readu2 (jcf); \ + fprintf (out, " line: %d at pc: %d\n", line_number, start_pc); }\ + else \ + JCF_SKIP (jcf, 4 * n); } + +#define HANDLE_INNERCLASSES_ATTRIBUTE(COUNT) \ +{ int n = (COUNT); \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + while (n--) \ + { \ + uint16 inner_class_info_index = JCF_readu2 (jcf); \ + uint16 outer_class_info_index = JCF_readu2 (jcf); \ + uint16 inner_name_index = JCF_readu2 (jcf); \ + uint16 inner_class_access_flags = JCF_readu2 (jcf); \ + \ + if (flag_print_class_info) \ + { \ + fprintf (out, "\n inner: "); \ + if (inner_class_info_index == 0) \ + fprintf (out, " (no inner info index)"); \ + else \ + print_constant_terse_with_index (out, jcf, \ + inner_class_info_index, \ + CONSTANT_Class); \ + if (inner_name_index == 0) \ + fprintf (out, " (anonymous)"); \ + else if (verbose || flag_print_constant_pool) \ + { \ + fprintf (out, " ("); \ + print_constant_terse_with_index (out, jcf, inner_name_index, \ + CONSTANT_Utf8); \ + fputc (')', out); \ + } \ + fprintf (out, ", access flags: 0x%x", inner_class_access_flags); \ + print_access_flags (out, inner_class_access_flags, 'c'); \ + fprintf (out, ", outer class: "); \ + if (outer_class_info_index == 0) \ + fprintf (out, "(not a member)"); \ + else \ + print_constant_terse_with_index (out, jcf, \ + outer_class_info_index, \ + CONSTANT_Class); \ + } \ + } \ + if (flag_print_class_info) \ + fputc ('\n', out); \ +} + +#define HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE(LENGTH) \ +{ int i, n = (LENGTH), c = 0; \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + fputc ('\n', out); \ + for (i = 0; i < n; i++) { c = JCF_readu(jcf); fputc(c, out); } \ + if (c != '\r' && c != '\n') fputc('\n', out); } + +#define HANDLE_ENCLOSINGMETHOD_ATTRIBUTE() \ + { uint16 class_index, method_index; \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + class_index = JCF_readu2 (jcf); \ + method_index = JCF_readu2 (jcf); \ + fprintf (out, "\n Class: "); \ + print_constant_terse_with_index (out, jcf, class_index, CONSTANT_Class); \ + fprintf (out, "\n Method: "); \ + print_constant_terse_with_index (out, jcf, method_index, \ + CONSTANT_NameAndType); \ + fputc ('\n', out); \ +} + +#define HANDLE_SIGNATURE_ATTRIBUTE() \ +{ \ + uint16 signature; \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + signature = JCF_readu2 (jcf); \ + fprintf (out, "\n Value: "); \ + print_constant_terse_with_index (out, jcf, signature, CONSTANT_Utf8); \ + fputc ('\n', out); \ +} + +#define HANDLE_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE() \ +{ \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + print_annotations (out, jcf, 1); \ +} + +#define HANDLE_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE() \ +{ \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + print_annotations (out, jcf, 1); \ +} + +#define HANDLE_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE() \ +{ \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + print_parameter_annotations (out, jcf, 1); \ +} + +#define HANDLE_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE() \ +{ \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + print_parameter_annotations (out, jcf, 1); \ +} + +#define HANDLE_ANNOTATIONDEFAULT_ATTRIBUTE() \ +{ \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + print_element_value (out, jcf, 1); \ +} + + +#define PROCESS_OTHER_ATTRIBUTE(JCF, INDEX, LENGTH) \ +{ COMMON_HANDLE_ATTRIBUTE(JCF, INDEX, LENGTH); \ + fputc ('\n', out); JCF_SKIP (JCF, LENGTH); } + +#define START_FINAL_ATTRIBUTES(ATTRIBUTES_COUNT) \ + if (flag_print_attributes > 0) \ + fprintf (out, "\nAttributes (count: %d):\n", attributes_count); + +#include "javaop.h" + + + +static void +indent (FILE *stream, int level) +{ + int i; + for (i = 0; i < level; ++i) + fprintf (stream, " "); +} + +static void +print_element_value (FILE *stream, JCF *jcf, int level) +{ + uint8 tag = JCF_readu (jcf); + indent (stream, level); + switch (tag) + { + case 'B': + case 'C': + case 'S': + case 'Z': + case 'I': + { + uint16 cindex = JCF_readu2 (jcf); + print_constant_terse_with_index (stream, jcf, cindex, + CONSTANT_Integer); + } + break; + case 'D': + { + uint16 cindex = JCF_readu2 (jcf); + print_constant_terse_with_index (stream, jcf, cindex, + CONSTANT_Double); + } + break; + case 'F': + { + uint16 cindex = JCF_readu2 (jcf); + print_constant_terse_with_index (stream, jcf, cindex, + CONSTANT_Float); + } + break; + case 'J': + { + uint16 cindex = JCF_readu2 (jcf); + print_constant_terse_with_index (stream, jcf, cindex, + CONSTANT_Long); + } + break; + case 's': + { + uint16 cindex = JCF_readu2 (jcf); + /* Despite what the JVM spec says, compilers generate a Utf8 + constant here, not a String. */ + print_constant_terse_with_index (stream, jcf, cindex, + CONSTANT_Utf8); + } + break; + + case 'e': + { + uint16 type_name_index = JCF_readu2 (jcf); + uint16 const_name_index = JCF_readu2 (jcf); + fprintf (stream, "enum class: "); + print_constant_terse_with_index (stream, jcf, type_name_index, + CONSTANT_Utf8); + fprintf (stream, "\n"); + indent (stream, level); + fprintf (stream, "Field: "); + print_constant_terse_with_index (stream, jcf, const_name_index, + CONSTANT_Utf8); + } + break; + case 'c': + { + uint16 class_info_index = JCF_readu2 (jcf); + print_constant_terse_with_index (stream, jcf, class_info_index, + CONSTANT_Utf8); + } + break; + case '@': + { + fprintf (stream, "Annotation:\n"); + print_annotation (stream, jcf, level + 1); + } + break; + case '[': + { + uint16 n_array_elts = JCF_readu2 (jcf); + fprintf (stream, "array[%d]: [\n", (int) n_array_elts); + while (n_array_elts--) + print_element_value (stream, jcf, level + 1); + indent (stream, level); + fprintf (stream, "]"); + } + break; + default: + fprintf (stream, "Unexpected tag value: %d", (int) tag); + break; + } + fputc ('\n', stream); +} + +static void +print_annotation (FILE *stream, JCF *jcf, int level) +{ + uint16 type_index = JCF_readu2 (jcf); + uint16 npairs = JCF_readu2 (jcf); + fprintf (stream, "\n"); + indent (stream, level); + fprintf (stream, "Annotation name: "); + print_constant_terse_with_index (stream, jcf, type_index, + CONSTANT_Utf8); + if (npairs) + { + fprintf (stream, "\n"); + while (npairs--) + { + uint16 name_index = JCF_readu2 (jcf); + indent (stream, level + 1); + fprintf (stream, "Name: "); + print_constant_terse_with_index (stream, jcf, name_index, + CONSTANT_Utf8); + fprintf (stream, "\n"); + print_element_value (stream, jcf, level + 2); + } + } +} + +static void +print_annotations (FILE *stream, JCF *jcf, int level) +{ + uint16 num = JCF_readu2 (jcf); + while (num--) + print_annotation (stream, jcf, level); +} + +static void +print_parameter_annotations (FILE *stream, JCF *jcf, int level) +{ + uint8 nparams = JCF_readu (jcf); + uint8 i; + for (i = 0; i < nparams; ++i) + { + indent (stream, level); + fprintf (stream, "Parameter annotations (%d):\n", (int) i); + print_annotations (stream, jcf, level + 1); + } +} + + + +static void +print_constant_ref (FILE *stream, JCF *jcf, int index) +{ + if (index <= 0 || index >= JPOOL_SIZE(jcf)) + fprintf (stream, "<out of range>"); + else + { + if (flag_print_constant_pool) + fprintf (stream, "#%d=", index); + fputc ('<', stream); + print_constant (stream, jcf, index, 1); + fputc ('>', stream); + } +} + +/* Print the access flags given by FLAGS. + The CONTEXT is one of 'c' (class flags), 'f' (field flags), + or 'm' (method flags). */ + +static void +print_access_flags (FILE *stream, uint16 flags, char context) +{ + if (flags & ACC_PUBLIC) fprintf (stream, " public"); + if (flags & ACC_PRIVATE) fprintf (stream, " private"); + if (flags & ACC_PROTECTED) fprintf (stream, " protected"); + if (flags & ACC_ABSTRACT) fprintf (stream, " abstract"); + if (flags & ACC_STATIC) fprintf (stream, " static"); + if (flags & ACC_FINAL) fprintf (stream, " final"); + if (flags & ACC_TRANSIENT) + fprintf (stream, context == 'm' ? " varargs" : " transient"); + if (flags & ACC_VOLATILE) + fprintf (stream, context == 'm' ? " bridge" : " volatile"); + if (flags & ACC_NATIVE) fprintf (stream, " native"); + if (flags & ACC_SYNCHRONIZED) + { + if (context == 'c') + fprintf (stream, " super"); + else + fprintf (stream, " synchronized"); + } + if (flags & ACC_INTERFACE) + fprintf (stream, (flags & ACC_ANNOTATION) ? " @interface" : " interface"); + if (flags & ACC_ENUM) fprintf (stream, " enum"); + if (flags & ACC_STRICT) fprintf (stream, " strictfp"); + if (flags & ACC_SYNTHETIC) fprintf (stream, " synthetic"); +} + + +static void +print_name (FILE* stream, JCF* jcf, int name_index) +{ + if (JPOOL_TAG (jcf, name_index) != CONSTANT_Utf8) + fprintf (stream, "<not a UTF8 constant>"); + else + jcf_print_utf8 (stream, JPOOL_UTF_DATA (jcf,name_index), + JPOOL_UTF_LENGTH (jcf, name_index)); +} + +/* If the type of the constant at INDEX matches EXPECTED, + print it tersely, otherwise more verbosely. */ + +static void +print_constant_terse (FILE *out, JCF *jcf, int index, int expected) +{ + if (! CPOOL_INDEX_IN_RANGE (&jcf->cpool, index)) + fprintf (out, "<constant pool index %d not in range>", index); + else if (JPOOL_TAG (jcf, index) != expected) + { + fprintf (out, "<Unexpected constant type "); + print_constant (out, jcf, index, 1); + fprintf (out, ">"); + } + else + print_constant (out, jcf, index, 0); +} + +static void +print_constant_terse_with_index (FILE *out, JCF *jcf, int index, int expected) +{ + if (flag_print_constant_pool) + fprintf (out, "%d=", index); + print_constant_terse (out, jcf, index, expected); +} + +/* Print the constant at INDEX in JCF's constant pool. + If verbosity==0, print very tersely (no extraneous text). + If verbosity==1, prefix the type of the constant. + If verbosity==2, add more descriptive text. */ + +static void +print_constant (FILE *out, JCF *jcf, int index, int verbosity) +{ + int j, n; + jlong num; + const char *str; + int kind = JPOOL_TAG (jcf, index); + switch (kind) + { + case CONSTANT_Class: + n = JPOOL_USHORT1 (jcf, index); + if (verbosity > 0) + { + if (verbosity > 1) + fprintf (out, "Class name: %d=", n); + else + fprintf (out, "Class "); + } + if (! CPOOL_INDEX_IN_RANGE (&jcf->cpool, n)) + fprintf (out, "<out of range>"); + else if (verbosity < 2 && JPOOL_TAG (jcf, n) == CONSTANT_Utf8) + { + int len = JPOOL_UTF_LENGTH (jcf, n); + jcf_print_utf8_replace (out, JPOOL_UTF_DATA(jcf,n), len, '/', '.'); + } + else + print_constant_terse (out, jcf, n, CONSTANT_Utf8); + break; + case CONSTANT_Fieldref: + str = "Field"; goto field_or_method; + case CONSTANT_Methodref: + str = "Method"; goto field_or_method; + case CONSTANT_InterfaceMethodref: + str = "InterfaceMethod"; goto field_or_method; + field_or_method: + { + uint16 tclass = JPOOL_USHORT1 (jcf, index); + uint16 name_and_type = JPOOL_USHORT2 (jcf, index); + if (verbosity == 2) + fprintf (out, "%sref class: %d=", str, tclass); + else if (verbosity > 0) + fprintf (out, "%s ", str); + print_constant_terse (out, jcf, tclass, CONSTANT_Class); + if (verbosity < 2) + fprintf (out, "."); + else + fprintf (out, " name_and_type: %d=<", name_and_type); + print_constant_terse (out, jcf, name_and_type, CONSTANT_NameAndType); + if (verbosity == 2) + fputc ('>', out); + } + break; + case CONSTANT_String: + j = JPOOL_USHORT1 (jcf, index); + if (verbosity > 0) + { + if (verbosity > 1) + fprintf (out, "String %d=", j); + else + fprintf (out, "String "); + } + print_constant_terse (out, jcf, j, CONSTANT_Utf8); + break; + case CONSTANT_Integer: + if (verbosity > 0) + fprintf (out, "Integer "); + num = JPOOL_INT (jcf, index); + goto integer; + case CONSTANT_Long: + if (verbosity > 0) + fprintf (out, "Long "); + num = JPOOL_LONG (jcf, index); + goto integer; + integer: + { + char buffer[25]; + format_int (buffer, num, 10); + fprintf (out, "%s", buffer); + if (verbosity > 1) + { + format_uint (buffer, (uint64)num, 16); + fprintf (out, "=0x%s", buffer); + } + } + break; + case CONSTANT_Float: + { + jfloat fnum = JPOOL_FLOAT (jcf, index); + + if (verbosity > 0) + fputs ("Float ", out); + + if (fnum.negative) + putc ('-', out); + + if (JFLOAT_FINITE (fnum)) + { + int dummy; + int exponent = fnum.exponent - JFLOAT_EXP_BIAS; + double f; + uint32 mantissa = fnum.mantissa; + if (fnum.exponent == 0) + /* Denormal. */ + exponent++; + else + /* Normal; add the implicit bit. */ + mantissa |= ((uint32)1 << 23); + + f = frexp (mantissa, &dummy); + f = ldexp (f, exponent + 1); + fprintf (out, "%.10g", f); + } + else + { + if (fnum.mantissa == 0) + fputs ("Inf", out); + else if (fnum.mantissa & JFLOAT_QNAN_MASK) + fprintf (out, "QNaN(%u)", (fnum.mantissa & ~JFLOAT_QNAN_MASK)); + else + fprintf (out, "SNaN(%u)", (fnum.mantissa & ~JFLOAT_QNAN_MASK)); + } + + if (verbosity > 1) + fprintf (out, ", bits = 0x%08lx", (unsigned long) JPOOL_UINT (jcf, index)); + + break; + } + case CONSTANT_Double: + { + jdouble dnum = JPOOL_DOUBLE (jcf, index); + + if (verbosity > 0) + fputs ("Double ", out); + + if (dnum.negative) + putc ('-', out); + + if (JDOUBLE_FINITE (dnum)) + { + int dummy; + int exponent = dnum.exponent - JDOUBLE_EXP_BIAS; + double d; + uint64 mantissa = ((((uint64) dnum.mantissa0) << 32) + + dnum.mantissa1); + if (dnum.exponent == 0) + /* Denormal. */ + exponent++; + else + /* Normal; add the implicit bit. */ + mantissa |= ((uint64)1 << 52); + + d = frexp (mantissa, &dummy); + d = ldexp (d, exponent + 1); + fprintf (out, "%.20g", d); + } + else + { + uint64 mantissa = dnum.mantissa0 & ~JDOUBLE_QNAN_MASK; + mantissa = (mantissa << 32) + dnum.mantissa1; + + if (dnum.mantissa0 == 0 && dnum.mantissa1 == 0) + fputs ("Inf", out); + else if (dnum.mantissa0 & JDOUBLE_QNAN_MASK) + fprintf (out, "QNaN(%" HOST_LONG_LONG_FORMAT "u)", + (unsigned long long)mantissa); + else + fprintf (out, "SNaN(%" HOST_LONG_LONG_FORMAT "u)", + (unsigned long long)mantissa); + } + if (verbosity > 1) + { + int32 hi, lo; + hi = JPOOL_UINT (jcf, index); + lo = JPOOL_UINT (jcf, index + 1); + fprintf (out, ", bits = 0x%08lx%08lx", (unsigned long) hi, + (unsigned long) lo); + } + break; + } + case CONSTANT_NameAndType: + { + uint16 name = JPOOL_USHORT1 (jcf, index); + uint16 sig = JPOOL_USHORT2 (jcf, index); + if (verbosity > 0) + { + if (verbosity > 1) + fprintf (out, "NameAndType name: %d=", name); + else + fprintf (out, "NameAndType "); + } + print_name (out, jcf, name); + if (verbosity <= 1) + fputc (' ', out); + else + fprintf (out, ", signature: %d=", sig); + print_signature (out, jcf, sig, 0); + } + break; + case CONSTANT_Utf8: + { + const unsigned char *str = JPOOL_UTF_DATA (jcf, index); + int length = JPOOL_UTF_LENGTH (jcf, index); + if (verbosity > 0) + { /* Print as 8-bit bytes. */ + fputs ("Utf8: \"", out); + while (--length >= 0) + jcf_print_char (out, *str++); + } + else + { /* Print as Unicode. */ + fputc ('\"', out); + jcf_print_utf8 (out, str, length); + } + fputc ('\"', out); + } + break; + default: + fprintf (out, "(Unknown constant type %d)", kind); + } +} + +static void +print_constant_pool (JCF *jcf) +{ + int i; + for (i = 1; i < JPOOL_SIZE(jcf); i++) + { + int kind = JPOOL_TAG (jcf, i); + fprintf (out, "#%d: ", i); + print_constant (out, jcf, i, 2); + fprintf (out, "\n"); + if (kind == CONSTANT_Double || kind == CONSTANT_Long) + i++; /* These take up two slots in the constant table */ + } +} + +static void +print_signature_type (FILE* stream, const unsigned char **ptr, + const unsigned char *limit) +{ + int array_size; + if ((*ptr) >= limit) + return; + switch (*(*ptr)) + { + case '[': + array_size = -1; + for ((*ptr)++; (*ptr) < limit && ISDIGIT (**ptr); (*ptr)++) + { + array_size = (array_size < 0 ? 0 : 10 * array_size) + *(*ptr) - '0'; + } + print_signature_type (stream, ptr, limit); + if (array_size == -1) + fprintf (stream, "[]"); + else + fprintf (stream, "[%d]", array_size); + break; + case '(': + { + int nargs = 0; + fputc (*(*ptr)++, stream); + for (; **ptr != ')' && *ptr < limit; nargs++) + { + if (nargs > 0) + fputc (',', stream); + print_signature_type (stream, ptr, limit); + } + if (*ptr < limit) + { + fputc (*(*ptr)++, stream); + print_signature_type (stream, ptr, limit); + } + else + fprintf (stream, "???"); + } + break; + + case 'B': fprintf (stream, "byte"); (*ptr)++; break; + case 'C': fprintf (stream, "char"); (*ptr)++; break; + case 'D': fprintf (stream, "double"); (*ptr)++; break; + case 'F': fprintf (stream, "float"); (*ptr)++; break; + case 'S': fprintf (stream, "short"); (*ptr)++; break; + case 'I': fprintf (stream, "int"); (*ptr)++; break; + case 'J': fprintf (stream, "long"); (*ptr)++; break; + case 'Z': fprintf (stream, "boolean"); (*ptr)++; break; + case 'V': fprintf (stream, "void"); (*ptr)++; break; + + case 'L': + for ((*ptr)++; (*ptr)<limit && *(*ptr) != ';'; (*ptr)++) + jcf_print_char (stream, *(*ptr) == '/' ? '.' : *(*ptr)); + if (*(*ptr) == ';') + (*ptr)++; + break; + default: + jcf_print_char (stream, *(*ptr)++); + } +} + +static void +print_signature (FILE* stream, JCF *jcf, int signature_index, int options) +{ + if (JPOOL_TAG (jcf, signature_index) != CONSTANT_Utf8) + print_constant_terse (out, jcf, signature_index, CONSTANT_Utf8); + else + { + const unsigned char *str = JPOOL_UTF_DATA (jcf, signature_index); + int length = JPOOL_UTF_LENGTH (jcf, signature_index); + const unsigned char *limit; + limit = str + length; + if (str >= limit) + fprintf (stream, "<empty signature string>"); + else + { + if (options & PRINT_SIGNATURE_RESULT_ONLY) + { + while (str < limit && *str++ != ')') ; + } + if (options & PRINT_SIGNATURE_ARGS_ONLY) + { + str++; + fputc ('(', stream); + while (str < limit && *str != ')') + { + print_signature_type (stream, &str, limit); + if (*str != ')') + fputs (", ", stream); + } + fputc (')', stream); + } + else + { + print_signature_type (stream, &str, limit); + if (str < limit) + { + fprintf (stream, "<junk:"); + jcf_print_utf8 (stream, str, limit - str); + fputc ('>', stream); + } + } + } + } +} + + +static void +print_exception_table (JCF *jcf, const unsigned char *entries, int count) +{ + /* Print exception table. */ + int i = count; + if (i > 0) + { + const unsigned char *ptr = entries; + fprintf (out, "Exceptions (count: %d):\n", i); + for (; --i >= 0; ptr+= 8) + { + int start_pc = GET_u2 (ptr); + int end_pc = GET_u2 (ptr+2); + int handler_pc = GET_u2 (ptr+4); + int catch_type = GET_u2 (ptr+6); + fprintf (out, " start: %d, end: %d, handler: %d, type: ", + start_pc, end_pc, handler_pc); + if (catch_type == 0) + fputs ("0 /* finally */", out); + else + print_constant_terse_with_index (out, jcf, + catch_type, CONSTANT_Class); + fputc ('\n', out); + } + } +} + +#include "jcf-reader.c" + +static void +process_class (JCF *jcf) +{ + int code; + if (jcf_parse_preamble (jcf) != 0) + fprintf (stderr, _("Not a valid Java .class file.\n")); + + /* Parse and possibly print constant pool */ + code = jcf_parse_constant_pool (jcf); + if (code != 0) + { + fprintf (stderr, _("error while parsing constant pool\n")); + exit (FATAL_EXIT_CODE); + } + code = verify_constant_pool (jcf); + if (code > 0) + { + fprintf (stderr, _("error in constant pool entry #%d\n"), code); + exit (FATAL_EXIT_CODE); + } + if (flag_print_constant_pool) + print_constant_pool (jcf); + + jcf_parse_class (jcf); + code = jcf_parse_fields (jcf); + if (code != 0) + { + fprintf (stderr, _("error while parsing fields\n")); + exit (FATAL_EXIT_CODE); + } + code = jcf_parse_methods (jcf); + if (code != 0) + { + fprintf (stderr, _("error while parsing methods\n")); + exit (FATAL_EXIT_CODE); + } + code = jcf_parse_final_attributes (jcf); + if (code != 0) + { + fprintf (stderr, _("error while parsing final attributes\n")); + exit (FATAL_EXIT_CODE); + } + jcf->filename = NULL; +} + + + +/* This is used to mark options with no short value. */ +#define LONG_OPT(Num) ((Num) + 128) + +#define OPT_classpath LONG_OPT (0) +#define OPT_CLASSPATH OPT_classpath +#define OPT_bootclasspath LONG_OPT (1) +#define OPT_extdirs LONG_OPT (2) +#define OPT_HELP LONG_OPT (3) +#define OPT_VERSION LONG_OPT (4) +#define OPT_JAVAP LONG_OPT (5) + +static const struct option options[] = +{ + { "classpath", required_argument, NULL, OPT_classpath }, + { "bootclasspath", required_argument, NULL, OPT_bootclasspath }, + { "extdirs", required_argument, NULL, OPT_extdirs }, + { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, + { "help", no_argument, NULL, OPT_HELP }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, OPT_VERSION }, + { "javap", no_argument, NULL, OPT_JAVAP }, + { "print-main", no_argument, &flag_print_main, 1 }, + { "print-constants", no_argument, &flag_print_constant_pool, 1 }, + { NULL, no_argument, NULL, 0 } +}; + +static void +usage (void) +{ + fprintf (stderr, _("Try 'jcf-dump --help' for more information.\n")); + exit (1); +} + +static void +help (void) +{ + printf (_("Usage: jcf-dump [OPTION]... CLASS...\n\n")); + printf (_("Display contents of a class file in readable form.\n\n")); + printf (_(" -c Disassemble method bodies\n")); + printf (_(" --javap Generate output in 'javap' format\n")); + printf ("\n"); + printf (_(" --classpath PATH Set path to find .class files\n")); + printf (_(" -IDIR Append directory to class path\n")); + printf (_(" --bootclasspath PATH Override built-in class path\n")); + printf (_(" --extdirs PATH Set extensions directory path\n")); + printf (_(" -o FILE Set output file name\n")); + printf ("\n"); + printf (_(" --help Print this help, then exit\n")); + printf (_(" --version Print version number, then exit\n")); + printf (_(" -v, --verbose Print extra information while running\n")); + printf ("\n"); + printf (_("For bug reporting instructions, please see:\n" + "%s.\n"), bug_report_url); + exit (0); +} + +static void +version (void) +{ + printf ("jcf-dump %s%s\n\n", pkgversion_string, version_string); + printf ("Copyright %s 2011 Free Software Foundation, Inc.\n", _("(C)")); + printf (_("This is free software; see the source for copying conditions. There is NO\n" + "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n")); + exit (0); +} + +int +main (int argc, char** argv) +{ + JCF jcf[1]; + int argi, opt; + + /* Unlock the stdio streams. */ + unlock_std_streams (); + + gcc_init_libintl (); + + if (argc <= 1) + { + fprintf (stderr, _("jcf-dump: no classes specified\n")); + usage (); + } + + jcf_path_init (); + + /* We use getopt_long_only to allow single `-' long options. For + some of our options this is more natural. */ + while ((opt = getopt_long_only (argc, argv, "o:I:vc", options, NULL)) != -1) + { + switch (opt) + { + case 0: + /* Already handled. */ + break; + + case 'o': + output_file = optarg; + break; + + case 'I': + jcf_path_include_arg (optarg); + break; + + case 'v': + verbose++; + break; + + case 'c': + flag_disassemble_methods = 1; + break; + + case OPT_classpath: + jcf_path_classpath_arg (optarg); + break; + + case OPT_bootclasspath: + jcf_path_bootclasspath_arg (optarg); + break; + + case OPT_extdirs: + jcf_path_extdirs_arg (optarg); + break; + + case OPT_HELP: + help (); + break; + + case OPT_VERSION: + version (); + break; + + case OPT_JAVAP: + flag_javap_compatible++; + flag_print_constant_pool = 0; + flag_print_attributes = 0; + break; + + default: + usage (); + } + } + + if (verbose && ! flag_javap_compatible) + flag_print_constant_pool = 1; + + if (optind == argc) + { + fprintf (stderr, _("jcf-dump: no classes specified\n")); + usage (); + } + + jcf_path_seal (verbose); + + if (flag_print_main) + { + flag_print_fields = 0; + flag_print_methods = 0; + flag_print_constant_pool = 0; + flag_print_attributes = 0; + flag_print_class_info = 0; + } + + if (output_file) + { + out = fopen (output_file, "w"); + if (! out) + { + fprintf (stderr, _("Cannot open '%s' for output.\n"), output_file); + return FATAL_EXIT_CODE; + } + } + else + out = stdout; + + if (optind >= argc) + { + fprintf (out, "Reading .class from <standard input>.\n"); + open_class ("<stdio>", jcf, 0, NULL); + process_class (jcf); + } + else + { + for (argi = optind; argi < argc; argi++) + { + char *arg = argv[argi]; + const char *class_filename = find_class (arg, strlen (arg), jcf); + if (class_filename == NULL) + class_filename = find_classfile (arg, jcf, NULL); + if (class_filename == NULL) + { + perror ("Could not find class"); + return FATAL_EXIT_CODE; + } + JCF_FILL (jcf, 4); + if (GET_u4 (jcf->read_ptr) == ZIPMAGIC) + { + long compressed_size, member_size; + int compression_method, filename_length, extra_length; + const char *filename; + int total_length; + if (flag_print_class_info) + fprintf (out, "Reading classes from archive %s.\n", + class_filename); + for (;;) + { + int skip = 0; + jcf_filbuf_t save_filbuf = jcf->filbuf; + long magic = JCF_readu4_le (jcf); + if (magic == 0x02014b50 || magic == 0x06054b50) + break; /* got to central directory */ + if (magic != 0x04034b50) /* ZIPMAGIC (little-endian) */ + { + fprintf (stderr, _("bad format of .zip/.jar archive\n")); + return FATAL_EXIT_CODE; + } + JCF_FILL (jcf, 26); + JCF_SKIP (jcf, 2); + (void) /* general_purpose_bits = */ JCF_readu2_le (jcf); + compression_method = JCF_readu2_le (jcf); + JCF_SKIP (jcf, 8); + compressed_size = JCF_readu4_le (jcf); + member_size = JCF_readu4_le (jcf); + filename_length = JCF_readu2_le (jcf); + extra_length = JCF_readu2_le (jcf); + total_length = filename_length + extra_length + + compressed_size; + if (jcf->read_end - jcf->read_ptr < total_length) + jcf_trim_old_input (jcf); + JCF_FILL (jcf, total_length); + filename = (const char *) jcf->read_ptr; + JCF_SKIP (jcf, filename_length); + JCF_SKIP (jcf, extra_length); + if (filename_length > 0 + && filename[filename_length-1] == '/') + { + if (flag_print_class_info) + fprintf (out, "[Skipping directory %.*s]\n", + filename_length, filename); + skip = 1; + } + else if (compression_method != 0) + { + if (flag_print_class_info) + fprintf (out, "[Skipping compressed file %.*s]\n", + filename_length, filename); + skip = 1; + } + else if (member_size < 4 + || GET_u4 (jcf->read_ptr) != 0xcafebabe) + { + if (flag_print_class_info) + fprintf (out, "[Skipping non-.class member %.*s]\n", + filename_length, filename); + skip = 1; + } + else + { + if (flag_print_class_info) + fprintf (out, "Reading class member: %.*s.\n", + filename_length, filename); + } + if (skip) + { + JCF_SKIP (jcf, compressed_size); + } + else + { + unsigned char *save_end; + jcf->filbuf = jcf_unexpected_eof; + save_end = jcf->read_end; + jcf->read_end = jcf->read_ptr + compressed_size; + process_class (jcf); + jcf->filbuf = save_filbuf; + jcf->read_end = save_end; + } + } + } + else + { + if (flag_print_class_info) + fprintf (out, "Reading .class from %s.\n", class_filename); + process_class (jcf); + } + JCF_FINISH(jcf); + } + } + + return SUCCESS_EXIT_CODE; +} + + + +static void +disassemble_method (JCF* jcf, const unsigned char *byte_ops, int len) +{ +#undef PTR + int PC; + int i; + int saw_wide = 0; + if (flag_disassemble_methods == 0) + return; +#define BCODE byte_ops + for (PC = 0; PC < len;) + { + int oldpc = PC; + int saw_index; + jint INT_temp; + switch (byte_ops[PC++]) + { + +/* This is the actual code emitted for each of opcodes in javaops.def. + The actual opcode-specific stuff is handled by the OPKIND macro. + I.e. for an opcode whose OPKIND is BINOP, the BINOP will be called. + Those macros are defined below. The OPKINDs that do not have any + inline parameters (such as BINOP) and therefore do mot need anything + else to me printed out just use an empty body. */ + +#define JAVAOP(OPNAME, OPCODE, OPKIND, OPERAND_TYPE, OPERAND_VALUE) \ + case OPCODE: \ + fprintf (out, "%3d: %s", oldpc, #OPNAME); \ + OPKIND(OPERAND_TYPE, OPERAND_VALUE); \ + fputc ('\n', out); \ + break; + +#define CONST_INDEX_1 (saw_index = 1, IMMEDIATE_u1) +#define CONST_INDEX_2 (saw_index = 1, IMMEDIATE_u2) +#define VAR_INDEX_1 (saw_index = 1, IMMEDIATE_u1) +#define VAR_INDEX_2 (saw_index = 1, IMMEDIATE_u2) + +#define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > len ? \ + (fprintf(stderr, _("Bad byte codes.\n")), exit(-1), 0) : 1) + +/* Print out operand (if not implied by the opcode) for PUSCH opcodes. + These all push a constant onto the opcode stack. */ +#define PUSHC(OPERAND_TYPE, OPERAND_VALUE) \ + saw_index = 0, i = (OPERAND_VALUE); \ + if (oldpc+1 == PC) /* nothing */; \ + else if (saw_index) fprintf (out, " "), print_constant_ref (out, jcf, i); \ + else fprintf (out, " %d", i); + +/* Print out operand (a local variable index) for LOAD opcodes. + These all push local variable onto the opcode stack. */ +#define LOAD(OPERAND_TYPE, OPERAND_VALUE) \ + INT_temp = saw_wide ? IMMEDIATE_u2 : (OPERAND_VALUE); goto load_store; + +/* Handle STORE opcodes same as LOAD opcodes. + These all store a value from the opcode stack in a local variable. */ +#define STORE LOAD + +/* Handle more kind of opcodes. */ +#define STACK(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define UNOP(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define BINOP(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define CONVERT(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define CONVERT2(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define RETURN(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ +#define UNKNOWN(OPERAND_TYPE, OPERAND_VALUE) /* nothing */ + +/* Handle putfield and getfield opcodes, with static versions. */ +#define FIELD(MAYBE_STATIC, PUT_OR_GET) \ + fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2) + +/* Print operand for invoke opcodes. */ +#define INVOKE(OPERAND_TYPE, OPERAND_VALUE) \ + fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2);\ + if (OPERAND_VALUE) /* for invokeinterface */ \ + { int nargs = IMMEDIATE_u1; PC++; \ + fprintf (out, " nargs:%d", nargs); } + +#define OBJECT(OPERAND_TYPE, OPERAND_VALUE) \ + fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2); + +#define ARRAY(OPERAND_TYPE, SUBOP) \ + ARRAY_##SUBOP(OPERAND_TYPE) +/* Handle sub-categories of ARRAY opcodes. */ +#define ARRAY_LOAD(TYPE) /* nothing */ +#define ARRAY_STORE(TYPE) /* nothing */ +#define ARRAY_LENGTH(TYPE) /* nothing */ +#define ARRAY_NEW(TYPE) ARRAY_NEW_##TYPE +#define ARRAY_NEW_NUM \ + INT_temp = IMMEDIATE_u1; \ + { switch ((int) INT_temp) { \ + case 4: fputs (" boolean", out); break; \ + case 5: fputs (" char", out); break; \ + case 6: fputs (" float", out); break; \ + case 7: fputs (" double", out); break; \ + case 8: fputs (" byte", out); break; \ + case 9: fputs (" short", out); break; \ + case 10: fputs (" int", out); break; \ + case 11: fputs (" long", out); break; \ + default: fprintf (out, " <unknown type code %ld>", (long)INT_temp); break;\ + } } + +#define ARRAY_NEW_PTR \ + fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2); + +#define ARRAY_NEW_MULTI \ + fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2); \ + fprintf (out, " %d", IMMEDIATE_u1); /* number of dimensions */ + +#define TEST(OPERAND_TYPE, OPERAND_VALUE) \ + fprintf (out, " %d", oldpc + IMMEDIATE_s2) + +#define BRANCH(OPERAND_TYPE, OPERAND_VALUE) \ + saw_index = 0, INT_temp = (OPERAND_VALUE); \ + fprintf (out, " %ld", (long) (saw_index ? INT_temp : oldpc + INT_temp)) + +#define JSR(OPERAND_TYPE, OPERAND_VALUE) \ + saw_index = 0, INT_temp = (OPERAND_VALUE); \ + fprintf (out, " %ld", (long) (saw_index ? INT_temp : oldpc + INT_temp)) + +#undef RET /* Defined by config/i386/i386.h */ +#define RET(OPERAND_TYPE, OPERAND_VALUE) \ + INT_temp = saw_wide ? IMMEDIATE_u2 : (OPERAND_VALUE); \ + saw_wide = 0; \ + fprintf (out, " %ld", (long) INT_temp); + +#define SWITCH(OPERAND_TYPE, TABLE_OR_LOOKUP) \ + PC = (PC + 3) / 4 * 4; TABLE_OR_LOOKUP##_SWITCH + +#define LOOKUP_SWITCH \ + { jint default_offset = IMMEDIATE_s4; jint npairs = IMMEDIATE_s4; \ + fprintf (out, " npairs=%ld, default=%ld", (long) npairs, (long) default_offset+oldpc); \ + while (--npairs >= 0) { \ + jint match = IMMEDIATE_s4; jint offset = IMMEDIATE_s4; \ + fprintf (out, "\n%10ld: %ld", (long)match, (long)(offset+oldpc)); } \ + } + +#define TABLE_SWITCH \ + { jint default_offset = IMMEDIATE_s4; \ + jint low = IMMEDIATE_s4; jint high = IMMEDIATE_s4; \ + fprintf (out, " low=%ld, high=%ld, default=%ld", \ + (long) low, (long) high, (long) default_offset+oldpc); \ + for (; low <= high; low++) { \ + jint offset = IMMEDIATE_s4; \ + fprintf (out, "\n%10ld: %ld", (long)low, (long)(offset+oldpc)); } \ + } + +#define SPECIAL(OPERAND_TYPE, OPERAND_VALUE) \ + SPECIAL_##OPERAND_VALUE(OPERAND_TYPE) + +#define SPECIAL_IINC(OPERAND_TYPE) \ + i = saw_wide ? IMMEDIATE_u2 : IMMEDIATE_u1; \ + fprintf (out, " %d", i); \ + i = saw_wide ? IMMEDIATE_s2 : IMMEDIATE_s1; \ + saw_wide = 0; \ + fprintf (out, " %d", i) + +#define SPECIAL_WIDE(OPERAND_TYPE) \ + saw_wide = 1; + +#define SPECIAL_EXIT(OPERAND_TYPE) /* nothing */ +#define SPECIAL_ENTER(OPERAND_TYPE) /* nothing */ +#define SPECIAL_BREAK(OPERAND_TYPE) /* nothing */ +#define SPECIAL_THROW(OPERAND_TYPE) /* nothing */ + +#define IMPL(OPERAND_TYPE, OPERAND_VALUE) \ + fprintf (out, " %d", IMMEDIATE_u##OPERAND_VALUE) + +#define COND(OPERAND_TYPE, OPERAND_VALUE) \ + TEST(OPERAND_TYPE, OPERAND_VALUE) + +#include "javaop.def" + + load_store: + if (oldpc+1 == PC) /* nothing - local index implied by opcode */; + else + { + saw_wide = 0; + fprintf (out, " %ld", (long) INT_temp); + } + fputc ('\n', out); + break; + + default: + fprintf (out, "%3d: unknown(%3d)\n", oldpc, byte_ops[PC]); + } + } +} diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c new file mode 100644 index 000000000..0dc761534 --- /dev/null +++ b/gcc/java/jcf-io.c @@ -0,0 +1,564 @@ +/* Utility routines for finding and reading Java(TM) .class files. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" + +#include "jcf.h" +#include "tree.h" +#include "java-tree.h" +#include "hashtab.h" +#include <dirent.h> + +#include "zlib.h" + +int +jcf_unexpected_eof (JCF *jcf, int count ATTRIBUTE_UNUSED) +{ + if (jcf->filename) + fprintf (stderr, "Premature end of .class file %s.\n", jcf->filename); + else + fprintf (stderr, "Premature end of .class file <stdin>.\n"); + exit (-1); +} + +void +jcf_trim_old_input (JCF *jcf) +{ + int count = jcf->read_ptr - jcf->buffer; + if (count > 0) + { + memmove (jcf->buffer, jcf->read_ptr, jcf->read_end - jcf->read_ptr); + jcf->read_ptr -= count; + jcf->read_end -= count; + } +} + +int +jcf_filbuf_from_stdio (JCF *jcf, int count) +{ + FILE *file = (FILE*) (jcf->read_state); + if (count > jcf->buffer_end - jcf->read_ptr) + { + JCF_u4 old_read_ptr = jcf->read_ptr - jcf->buffer; + JCF_u4 old_read_end = jcf->read_end - jcf->buffer; + JCF_u4 old_size = jcf->buffer_end - jcf->buffer; + JCF_u4 new_size = (old_size == 0 ? 2000 : 2 * old_size) + count; + unsigned char *new_buffer + = jcf->buffer == NULL ? XNEWVAR (unsigned char, new_size) + : XRESIZEVAR (unsigned char, jcf->buffer, new_size); + jcf->buffer = new_buffer; + jcf->buffer_end = new_buffer + new_size; + jcf->read_ptr = new_buffer + old_read_ptr; + jcf->read_end = new_buffer + old_read_end; + } + count -= jcf->read_end - jcf->read_ptr; + if (count <= 0) + return 0; + if ((int) fread (jcf->read_end, 1, count, file) != count) + jcf_unexpected_eof (jcf, count); + jcf->read_end += count; + return 0; +} + +#include "zipfile.h" + +struct ZipFile *SeenZipFiles = NULL; + +/* Open a zip file with the given name, and cache directory and file + descriptor. If the file is missing, treat it as an empty archive. + Return NULL if the .zip file is malformed. +*/ + +ZipFile * +opendir_in_zip (const char *zipfile, int is_system) +{ + struct ZipFile* zipf; + char magic [4]; + int fd; + for (zipf = SeenZipFiles; zipf != NULL; zipf = zipf->next) + { + if (strcmp (zipf->name, zipfile) == 0) + return zipf; + } + + zipf = XNEWVAR (struct ZipFile, sizeof (struct ZipFile) + strlen (zipfile) + 1); + zipf->next = SeenZipFiles; + zipf->name = (char*)(zipf+1); + strcpy (zipf->name, zipfile); + fd = open (zipfile, O_RDONLY | O_BINARY); + zipf->fd = fd; + if (fd < 0) + { + /* A missing zip file is not considered an error. + We may want to re-consider that. FIXME. */ + zipf->count = 0; + zipf->dir_size = 0; + zipf->central_directory = NULL; + } + else + { + jcf_dependency_add_file (zipfile, is_system); + if (read (fd, magic, 4) != 4 || GET_u4 (magic) != (JCF_u4)ZIPMAGIC) + { + free (zipf); + close (fd); + return NULL; + } + lseek (fd, 0L, SEEK_SET); + if (read_zip_archive (zipf) != 0) + { + free (zipf); + close (fd); + return NULL; + } + } + + SeenZipFiles = zipf; + return zipf; +} + +/* Returns: + 0: OK - zipmember found. + -1: Not found. + -2: Malformed archive. +*/ + +int +open_in_zip (JCF *jcf, const char *zipfile, const char *zipmember, + int is_system) +{ + ZipDirectory *zipd; + int i, len; + ZipFile *zipf = opendir_in_zip (zipfile, is_system); + + if (zipf == NULL) + return -2; + + if (!zipmember) + return 0; + + len = strlen (zipmember); + + zipd = (struct ZipDirectory*) zipf->central_directory; + for (i = 0; i < zipf->count; i++, zipd = ZIPDIR_NEXT (zipd)) + { + if (len == zipd->filename_length && + strncmp (ZIPDIR_FILENAME (zipd), zipmember, len) == 0) + { + JCF_ZERO (jcf); + + jcf->filename = xstrdup (zipfile); + jcf->classname = xstrdup (zipmember); + return read_zip_member(jcf, zipd, zipf); + } + } + return -1; +} + +/* Read data from zip archive member. */ + +int +read_zip_member (JCF *jcf, ZipDirectory *zipd, ZipFile *zipf) +{ + jcf->filbuf = jcf_unexpected_eof; + jcf->zipd = zipd; + + if (zipd->compression_method == Z_NO_COMPRESSION) + { + jcf->buffer = XNEWVEC (unsigned char, zipd->size); + jcf->buffer_end = jcf->buffer + zipd->size; + jcf->read_ptr = jcf->buffer; + jcf->read_end = jcf->buffer_end; + if (lseek (zipf->fd, zipd->filestart, 0) < 0 + || read (zipf->fd, jcf->buffer, zipd->size) != (long) zipd->size) + return -2; + } + else + { + char *buffer; + z_stream d_stream; /* decompression stream */ + d_stream.zalloc = (alloc_func) 0; + d_stream.zfree = (free_func) 0; + d_stream.opaque = (voidpf) 0; + + jcf->buffer = XNEWVEC (unsigned char, zipd->uncompressed_size); + d_stream.next_out = jcf->buffer; + d_stream.avail_out = zipd->uncompressed_size; + jcf->buffer_end = jcf->buffer + zipd->uncompressed_size; + jcf->read_ptr = jcf->buffer; + jcf->read_end = jcf->buffer_end; + buffer = XNEWVEC (char, zipd->size); + d_stream.next_in = (unsigned char *) buffer; + d_stream.avail_in = zipd->size; + if (lseek (zipf->fd, zipd->filestart, 0) < 0 + || read (zipf->fd, buffer, zipd->size) != (long) zipd->size) + return -2; + /* Handle NO_HEADER using undocumented zlib feature. + This is a very common hack. */ + inflateInit2 (&d_stream, -MAX_WBITS); + inflate (&d_stream, Z_NO_FLUSH); + inflateEnd (&d_stream); + free (buffer); + } + + return 0; +} + +const char * +open_class (const char *filename, JCF *jcf, int fd, const char *dep_name) +{ + if (jcf) + { + struct stat stat_buf; + if (fstat (fd, &stat_buf) != 0 + || ! S_ISREG (stat_buf.st_mode)) + { + perror ("Could not figure length of .class file"); + return NULL; + } + if (dep_name != NULL) + jcf_dependency_add_file (dep_name, 0); + JCF_ZERO (jcf); + jcf->buffer = XNEWVEC (unsigned char, stat_buf.st_size); + jcf->buffer_end = jcf->buffer + stat_buf.st_size; + jcf->read_ptr = jcf->buffer; + jcf->read_end = jcf->buffer_end; + jcf->read_state = NULL; + jcf->filename = xstrdup (filename); + if (read (fd, jcf->buffer, stat_buf.st_size) != stat_buf.st_size) + { + perror ("Failed to read .class file"); + return NULL; + } + close (fd); + jcf->filbuf = jcf_unexpected_eof; + } + else + close (fd); + return filename; +} + + +const char * +find_classfile (char *filename, JCF *jcf, const char *dep_name) +{ + int fd = open (filename, O_RDONLY | O_BINARY); + if (fd < 0) + return NULL; + return open_class (filename, jcf, fd, dep_name); +} + +/* Returns 1 if the CLASSNAME (really a char *) matches the name + stored in TABLE_ENTRY (also a char *). */ + +static int +memoized_class_lookup_eq (const void *table_entry, const void *classname) +{ + return strcmp ((const char *)classname, (const char *)table_entry) == 0; +} + +/* A hash table keeping track of class names that were not found + during class lookup. (There is no need to cache the values + associated with names that were found; they are saved in + IDENTIFIER_CLASS_VALUE.) */ +static htab_t memoized_class_lookups; + +/* Returns a freshly malloc'd string with the fully qualified pathname + of the .class file for the class CLASSNAME. CLASSNAME must be + allocated in permanent storage; this function may retain a pointer + to it. Returns NULL on failure. If JCF != NULL, it is suitably + initialized. SOURCE_OK is true if we should also look for .java + file. */ + +const char * +find_class (const char *classname, int classname_length, JCF *jcf) +{ + int fd; + int i, k, klass = -1; + struct stat class_buf; + char *dep_file; + void *entry; + int buflen; + char *buffer; + hashval_t hash; + + /* Create the hash table, if it does not already exist. */ + if (!memoized_class_lookups) + memoized_class_lookups = htab_create (37, + htab_hash_string, + memoized_class_lookup_eq, + NULL); + + /* Loop for this class in the hashtable. If it is present, we've + already looked for this class and failed to find it. */ + hash = htab_hash_string (classname); + if (htab_find_with_hash (memoized_class_lookups, classname, hash)) + return NULL; + + /* Allocate and zero out the buffer, since we don't explicitly put a + null pointer when we're copying it below. */ + buflen = jcf_path_max_len () + classname_length + 10; + buffer = XNEWVAR (char, buflen); + memset (buffer, 0, buflen); + + for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry)) + { + const char *path_name = jcf_path_name (entry); + if (klass != 0) + { + int dir_len; + + strcpy (buffer, path_name); + i = strlen (buffer); + + /* This is right because we know that `.zip' entries will have a + trailing slash. See jcf-path.c. */ + dir_len = i - 1; + + for (k = 0; k < classname_length; k++, i++) + { + char ch = classname[k]; + buffer[i] = ch == '.' ? '/' : ch; + } + strcpy (buffer+i, ".class"); + + if (jcf_path_is_zipfile (entry)) + { + int err_code; + JCF _jcf; + buffer[dir_len] = '\0'; + SOURCE_FRONTEND_DEBUG + (("Trying [...%s]:%s", + &buffer[dir_len-(dir_len > 15 ? 15 : dir_len)], + buffer+dir_len+1)); + if (jcf == NULL) + jcf = &_jcf; + err_code = open_in_zip (jcf, buffer, buffer+dir_len+1, + jcf_path_is_system (entry)); + if (err_code == 0) + { + /* Should we check if .zip is out-of-date wrt .java? */ + buffer[dir_len] = '('; + strcpy (buffer+i, ".class)"); + if (jcf == &_jcf) + JCF_FINISH (jcf); + return buffer; + } + else + continue; + } + klass = stat (buffer, &class_buf); + } + } + + dep_file = buffer; + if (!klass) + { + SOURCE_FRONTEND_DEBUG ((stderr, "[Class selected: %s]\n", + classname+classname_length- + (classname_length <= 30 ? + classname_length : 30))); + fd = JCF_OPEN_EXACT_CASE (buffer, O_RDONLY | O_BINARY); + if (fd >= 0) + goto found; + } + + free (buffer); + + /* Remember that this class could not be found so that we do not + have to look again. */ + *htab_find_slot_with_hash (memoized_class_lookups, classname, hash, INSERT) + = (void *) CONST_CAST (char *, classname); + + return NULL; + found: + { + const char *const tmp = open_class (buffer, jcf, fd, dep_file); + jcf->classname = xstrdup (classname); + return tmp; + } +} + +void +jcf_print_char (FILE *stream, int ch) +{ + switch (ch) + { + case '\'': + case '\\': + case '\"': + fprintf (stream, "\\%c", ch); + break; + case '\n': + fprintf (stream, "\\n"); + break; + case '\t': + fprintf (stream, "\\t"); + break; + case '\r': + fprintf (stream, "\\r"); + break; + default: + if (ch >= ' ' && ch < 127) + putc (ch, stream); + else if (ch < 256) + fprintf (stream, "\\%03x", ch); + else + fprintf (stream, "\\u%04x", ch); + } +} + +/* Print UTF8 string at STR of length LENGTH bytes to STREAM. */ + +void +jcf_print_utf8 (FILE *stream, const unsigned char *str, int length) +{ + const unsigned char * limit = str + length; + while (str < limit) + { + int ch = UTF8_GET (str, limit); + if (ch < 0) + { + fprintf (stream, "\\<invalid>"); + return; + } + jcf_print_char (stream, ch); + } +} + +/* Same as jcf_print_utf8, but print IN_CHAR as OUT_CHAR. */ + +void +jcf_print_utf8_replace (FILE *stream, const unsigned char *str, int length, + int in_char, int out_char) +{ + const unsigned char *limit = str + length; + while (str < limit) + { + int ch = UTF8_GET (str, limit); + if (ch < 0) + { + fprintf (stream, "\\<invalid>"); + return; + } + jcf_print_char (stream, ch == in_char ? out_char : ch); + } +} + +/* Check that all the cross-references in the constant pool are + valid. Returns 0 on success. + Otherwise, returns the index of the (first) invalid entry. + Only checks internal consistency, but does not check that + any classes, fields, or methods are valid.*/ + +int +verify_constant_pool (JCF *jcf) +{ + int i, n; + for (i = 1; i < JPOOL_SIZE (jcf); i++) + { + switch (JPOOL_TAG (jcf, i)) + { + case CONSTANT_NameAndType: + n = JPOOL_USHORT2 (jcf, i); + if (n <= 0 || n >= JPOOL_SIZE(jcf) + || JPOOL_TAG (jcf, n) != CONSTANT_Utf8) + return i; + /* ... fall through ... */ + case CONSTANT_Class: + case CONSTANT_String: + n = JPOOL_USHORT1 (jcf, i); + if (n <= 0 || n >= JPOOL_SIZE(jcf) + || JPOOL_TAG (jcf, n) != CONSTANT_Utf8) + return i; + break; + case CONSTANT_Fieldref: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + n = JPOOL_USHORT1 (jcf, i); + if (n <= 0 || n >= JPOOL_SIZE(jcf) + || JPOOL_TAG (jcf, n) != CONSTANT_Class) + return i; + n = JPOOL_USHORT2 (jcf, i); + if (n <= 0 || n >= JPOOL_SIZE(jcf) + || JPOOL_TAG (jcf, n) != CONSTANT_NameAndType) + return i; + break; + case CONSTANT_Long: + case CONSTANT_Double: + i++; + break; + case CONSTANT_Float: + case CONSTANT_Integer: + case CONSTANT_Utf8: + case CONSTANT_Unicode: + break; + default: + return i; + } + } + return 0; +} + +void +format_uint (char *buffer, uint64 value, int base) +{ +#define WRITE_BUF_SIZE (4 + sizeof(uint64) * 8) + char buf[WRITE_BUF_SIZE]; + char *buf_ptr = buf+WRITE_BUF_SIZE; /* End of buf. */ + int chars_written; + int i; + + /* Now do the actual conversion, placing the result at the *end* of buf. */ + /* Note this code does not pretend to be optimized. */ + do { + int digit = value % base; + static const char digit_chars[] = "0123456789abcdefghijklmnopqrstuvwxyz"; + *--buf_ptr = digit_chars[digit]; + value /= base; + } while (value != 0); + + chars_written = buf+WRITE_BUF_SIZE - buf_ptr; + for (i = 0; i < chars_written; i++) + buffer[i] = *buf_ptr++; + buffer[i] = 0; +} + +void +format_int (char *buffer, jlong value, int base) +{ + uint64 abs_value; + if (value < 0) + { + abs_value = -(uint64)value; + *buffer++ = '-'; + } + else + abs_value = (uint64) value; + format_uint (buffer, abs_value, base); +} diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c new file mode 100644 index 000000000..d10791fe6 --- /dev/null +++ b/gcc/java/jcf-parse.c @@ -0,0 +1,2207 @@ +/* Parser for Java(TM) .class files. + Copyright (C) 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com> */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "obstack.h" +#include "flags.h" +#include "java-except.h" +#include "input.h" +#include "javaop.h" +#include "java-tree.h" +#include "diagnostic-core.h" +#include "parse.h" +#include "ggc.h" +#include "debug.h" +#include "cgraph.h" +#include "vecprim.h" +#include "bitmap.h" +#include "target.h" + +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif + +#ifdef HAVE_LANGINFO_CODESET +#include <langinfo.h> +#endif + +/* A CONSTANT_Utf8 element is converted to an IDENTIFIER_NODE at parse time. */ +#define JPOOL_UTF(JCF, INDEX) CPOOL_UTF(&(JCF)->cpool, INDEX) +#define JPOOL_UTF_LENGTH(JCF, INDEX) IDENTIFIER_LENGTH (JPOOL_UTF (JCF, INDEX)) +#define JPOOL_UTF_DATA(JCF, INDEX) \ + ((const unsigned char *) IDENTIFIER_POINTER (JPOOL_UTF (JCF, INDEX))) +#define HANDLE_CONSTANT_Utf8(JCF, INDEX, LENGTH) \ + do { \ + unsigned char save; unsigned char *text; \ + JCF_FILL (JCF, (LENGTH)+1); /* Make sure we read 1 byte beyond string. */ \ + text = (JCF)->read_ptr; \ + save = text[LENGTH]; \ + text[LENGTH] = 0; \ + (JCF)->cpool.data[INDEX].t = get_identifier ((const char *) text); \ + text[LENGTH] = save; \ + JCF_SKIP (JCF, LENGTH); } while (0) + +#include "jcf.h" + +extern struct obstack temporary_obstack; + +static GTY(()) tree parse_roots[2]; + +/* The FIELD_DECL for the current field. */ +#define current_field parse_roots[0] + +/* The METHOD_DECL for the current method. */ +#define current_method parse_roots[1] + +/* Line 0 in current file, if compiling from bytecode. */ +static location_t file_start_location; + +/* The Java archive that provides main_class; the main input file. */ +static GTY(()) struct JCF * main_jcf; + +/* A list of all the class DECLs seen so far. */ +static GTY(()) VEC(tree,gc) *all_class_list; + +/* The number of source files passed to us by -fsource-filename and an + array of pointers to each name. Used by find_sourcefile(). */ +static int num_files = 0; +static char **filenames; + +static struct ZipFile *localToFile; + +/* A map of byte offsets in the reflection data that are fields which + need renumbering. */ +bitmap field_offsets; +bitmap_obstack bit_obstack; + +/* Declarations of some functions used here. */ +static void handle_innerclass_attribute (int count, JCF *, int len); +static tree give_name_to_class (JCF *jcf, int index); +static char *compute_class_name (struct ZipDirectory *zdir); +static int classify_zip_file (struct ZipDirectory *zdir); +static void parse_zip_file_entries (void); +static void process_zip_dir (FILE *); +static void parse_class_file (void); +static void handle_deprecated (void); +static void set_source_filename (JCF *, int); +static void jcf_parse (struct JCF*); +static void load_inner_classes (tree); +static void handle_annotation (JCF *jcf, int level); +static void java_layout_seen_class_methods (void); + +/* Handle "Deprecated" attribute. */ +static void +handle_deprecated (void) +{ + if (current_field != NULL_TREE) + FIELD_DEPRECATED (current_field) = 1; + else if (current_method != NULL_TREE) + METHOD_DEPRECATED (current_method) = 1; + else if (current_class != NULL_TREE) + CLASS_DEPRECATED (TYPE_NAME (current_class)) = 1; + else + { + /* Shouldn't happen. */ + gcc_unreachable (); + } +} + + + +/* Reverse a string. */ +static char * +reverse (const char *s) +{ + if (s == NULL) + return NULL; + else + { + int len = strlen (s); + char *d = XNEWVAR (char, len + 1); + const char *sp; + char *dp; + + d[len] = 0; + for (dp = &d[0], sp = &s[len-1]; sp >= s; dp++, sp--) + *dp = *sp; + + return d; + } +} + +/* Compare two strings for qsort(). */ +static int +cmpstringp (const void *p1, const void *p2) +{ + /* The arguments to this function are "pointers to + pointers to char", but strcmp() arguments are "pointers + to char", hence the following cast plus dereference */ + + return strcmp(*(const char *const*) p1, *(const char *const*) p2); +} + +/* Create an array of strings, one for each source file that we've + seen. fsource_filename can either be the name of a single .java + file or a file that contains a list of filenames separated by + newlines. */ +void +java_read_sourcefilenames (const char *fsource_filename) +{ + if (fsource_filename + && filenames == 0 + && strlen (fsource_filename) > strlen (".java") + && strcmp ((fsource_filename + + strlen (fsource_filename) + - strlen (".java")), + ".java") != 0) + { +/* fsource_filename isn't a .java file but a list of filenames + separated by newlines */ + FILE *finput = fopen (fsource_filename, "r"); + int len = 0; + int longest_line = 0; + + gcc_assert (finput); + + /* Find out how many files there are, and how long the filenames are. */ + while (! feof (finput)) + { + int ch = getc (finput); + if (ch == '\n') + { + num_files++; + if (len > longest_line) + longest_line = len; + len = 0; + continue; + } + if (ch == EOF) + break; + len++; + } + + rewind (finput); + + /* Read the filenames. Put a pointer to each filename into the + array FILENAMES. */ + { + char *linebuf = (char *) alloca (longest_line + 1); + int i = 0; + int charpos; + + filenames = XNEWVEC (char *, num_files); + + charpos = 0; + for (;;) + { + int ch = getc (finput); + if (ch == EOF) + break; + if (ch == '\n') + { + linebuf[charpos] = 0; + gcc_assert (i < num_files); + /* ??? Perhaps we should use lrealpath() here. Doing + so would tidy up things like /../ but the rest of + gcc seems to assume relative pathnames, not + absolute pathnames. */ +/* realname = lrealpath (linebuf); */ + filenames[i++] = reverse (linebuf); + charpos = 0; + continue; + } + gcc_assert (charpos < longest_line); + linebuf[charpos++] = ch; + } + + if (num_files > 1) + qsort (filenames, num_files, sizeof (char *), cmpstringp); + } + fclose (finput); + } + else + { + filenames = XNEWVEC (char *, 1); + filenames[0] = reverse (fsource_filename); + num_files = 1; + } +} + +/* Given a relative pathname such as foo/bar.java, attempt to find a + longer pathname with the same suffix. + + This is a best guess heuristic; with some weird class hierarchies we + may fail to pick the correct source file. For example, if we have + the filenames foo/bar.java and also foo/foo/bar.java, we do not + have enough information to know which one is the right match for + foo/bar.java. */ + +static const char * +find_sourcefile (const char *name) +{ + int i = 0, j = num_files-1; + char *found = NULL; + + if (filenames) + { + char *revname = reverse (name); + + do + { + int k = (i+j) / 2; + int cmp = strncmp (revname, filenames[k], strlen (revname)); + if (cmp == 0) + { + /* OK, so we found one. But is it a unique match? */ + if ((k > i + && strncmp (revname, filenames[k-1], strlen (revname)) == 0) + || (k < j + && (strncmp (revname, filenames[k+1], strlen (revname)) + == 0))) + ; + else + found = filenames[k]; + break; + } + if (cmp > 0) + i = k+1; + else + j = k-1; + } + while (i <= j); + + free (revname); + } + + if (found && strlen (found) > strlen (name)) + return reverse (found); + else + return name; +} + + + +/* Handle "SourceFile" attribute. */ + +static void +set_source_filename (JCF *jcf, int index) +{ + tree sfname_id = get_name_constant (jcf, index); + const char *sfname = IDENTIFIER_POINTER (sfname_id); + const char *old_filename = input_filename; + int new_len = IDENTIFIER_LENGTH (sfname_id); + if (old_filename != NULL) + { + int old_len = strlen (old_filename); + /* Use the current input_filename (derived from the class name) + if it has a directory prefix, but otherwise matches sfname. */ + if (old_len > new_len + && strcmp (sfname, old_filename + old_len - new_len) == 0 + && (old_filename[old_len - new_len - 1] == '/' + || old_filename[old_len - new_len - 1] == '\\')) + return; + } + if (strchr (sfname, '/') == NULL && strchr (sfname, '\\') == NULL) + { + const char *class_name + = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))); + const char *dot = strrchr (class_name, '.'); + if (dot != NULL) + { + /* Length of prefix, not counting final dot. */ + int i = dot - class_name; + /* Concatenate current package prefix with new sfname. */ + char *buf = XNEWVEC (char, i + new_len + 2); /* Space for '.' and '\0'. */ + strcpy (buf + i + 1, sfname); + /* Copy package from class_name, replacing '.' by DIR_SEPARATOR. + Note we start at the end with the final package dot. */ + for (; i >= 0; i--) + { + char c = class_name[i]; + if (c == '.') + c = DIR_SEPARATOR; + buf[i] = c; + } + sfname_id = get_identifier (buf); + free (buf); + sfname = IDENTIFIER_POINTER (sfname_id); + } + } + + sfname = find_sourcefile (sfname); + line_table->maps[line_table->used-1].to_file = sfname; + if (current_class == main_class) main_input_filename = sfname; +} + + + + +/* Annotation handling. + + The technique we use here is to copy the annotation data directly + from the input class file into the output file. We don't decode the + data at all, merely rewriting constant indexes whenever we come + across them: this is necessary because the constant pool in the + output file isn't the same as the constant pool in in the input. + + The main advantage of this technique is that the resulting + annotation data is pointer-free, so it doesn't have to be relocated + at startup time. As a consequence of this, annotations have no + performance impact unless they are used. Also, this representation + is very dense. */ + + +/* Expand TYPE_REFLECTION_DATA by DELTA bytes. Return the address of + the start of the newly allocated region. */ + +static unsigned char* +annotation_grow (int delta) +{ + unsigned char **data = &TYPE_REFLECTION_DATA (current_class); + long *datasize = &TYPE_REFLECTION_DATASIZE (current_class); + long len = *datasize; + + if (*data == NULL) + { + *data = XNEWVAR (unsigned char, delta); + } + else + { + int newlen = *datasize + delta; + if (floor_log2 (newlen) != floor_log2 (*datasize)) + *data = XRESIZEVAR (unsigned char, *data, 2 << (floor_log2 (newlen))); + } + *datasize += delta; + return *data + len; +} + +/* annotation_rewrite_TYPE. Rewrite various int types at p. Use Java + byte order (i.e. big endian.) */ + +static void +annotation_rewrite_byte (unsigned int n, unsigned char *p) +{ + p[0] = n; +} + +static void +annotation_rewrite_short (unsigned int n, unsigned char *p) +{ + p[0] = n>>8; + p[1] = n; +} + +static void +annotation_rewrite_int (unsigned int n, unsigned char *p) +{ + p[0] = n>>24; + p[1] = n>>16; + p[2] = n>>8; + p[3] = n; +} + +/* Read a 16-bit unsigned int in Java byte order (i.e. big + endian.) */ + +static uint16 +annotation_read_short (unsigned char *p) +{ + uint16 tmp = p[0]; + tmp = (tmp << 8) | p[1]; + return tmp; +} + +/* annotation_write_TYPE. Rewrite various int types, appending them + to TYPE_REFLECTION_DATA. Use Java byte order (i.e. big + endian.) */ + +static void +annotation_write_byte (unsigned int n) +{ + annotation_rewrite_byte (n, annotation_grow (1)); +} + +static void +annotation_write_short (unsigned int n) +{ + annotation_rewrite_short (n, annotation_grow (2)); +} + +static void +annotation_write_int (unsigned int n) +{ + annotation_rewrite_int (n, annotation_grow (4)); +} + +/* Create a 64-bit constant in the constant pool. + + This is used for both integer and floating-point types. As a + consequence, it will not work if the target floating-point format + is anything other than IEEE-754. While this is arguably a bug, the + runtime library makes exactly the same assumption and it's unlikely + that Java will ever run on a non-IEEE machine. */ + +static int +handle_long_constant (JCF *jcf, CPool *cpool, enum cpool_tag kind, + int index, bool big_endian) +{ + /* If we're on a 64-bit platform we can fit a long or double + into the same space as a jword. */ + if (POINTER_SIZE >= 64) + index = find_constant1 (cpool, kind, JPOOL_LONG (jcf, index)); + + /* In a compiled program the constant pool is in native word + order. How weird is that??? */ + else if (big_endian) + index = find_constant2 (cpool, kind, + JPOOL_INT (jcf, index), + JPOOL_INT (jcf, index+1)); + else + index = find_constant2 (cpool, kind, + JPOOL_INT (jcf, index+1), + JPOOL_INT (jcf, index)); + + return index; +} + +/* Given a class file and an index into its constant pool, create an + entry in the outgoing constant pool for the same item. */ + +static uint16 +handle_constant (JCF *jcf, int index, enum cpool_tag purpose) +{ + unsigned int kind; + CPool *cpool = cpool_for_class (output_class); + + if (index == 0) + return 0; + + if (! CPOOL_INDEX_IN_RANGE (&jcf->cpool, index)) + error ("<constant pool index %d not in range>", index); + + kind = JPOOL_TAG (jcf, index); + + if ((kind & ~CONSTANT_ResolvedFlag) != purpose) + { + if (purpose == CONSTANT_Class + && kind == CONSTANT_Utf8) + ; + else + error ("<constant pool index %d unexpected type", index); + } + + switch (kind) + { + case CONSTANT_Class: + case CONSTANT_ResolvedClass: + { + /* For some reason I know not the what of, class names in + annotations are UTF-8 strings in the constant pool but + class names in EnclosingMethod attributes are real class + references. Set CONSTANT_LazyFlag here so that the VM + doesn't attempt to resolve them at class initialization + time. */ + tree resolved_class, class_name; + resolved_class = get_class_constant (jcf, index); + class_name = build_internal_class_name (resolved_class); + index = alloc_name_constant (CONSTANT_Class | CONSTANT_LazyFlag, + (unmangle_classname + (IDENTIFIER_POINTER(class_name), + IDENTIFIER_LENGTH(class_name)))); + break; + } + case CONSTANT_Utf8: + { + tree utf8 = get_constant (jcf, index); + if (purpose == CONSTANT_Class) + /* Create a constant pool entry for a type signature. This + one has '.' rather than '/' because it isn't going into a + class file, it's going into a compiled object. + + This has to match the logic in + _Jv_ClassReader::prepare_pool_entry(). */ + utf8 = unmangle_classname (IDENTIFIER_POINTER(utf8), + IDENTIFIER_LENGTH(utf8)); + index = alloc_name_constant (kind, utf8); + } + break; + + case CONSTANT_Long: + index = handle_long_constant (jcf, cpool, CONSTANT_Long, index, + targetm.words_big_endian ()); + break; + + case CONSTANT_Double: + index = handle_long_constant (jcf, cpool, CONSTANT_Double, index, + targetm.float_words_big_endian ()); + break; + + case CONSTANT_Float: + case CONSTANT_Integer: + index = find_constant1 (cpool, kind, JPOOL_INT (jcf, index)); + break; + + case CONSTANT_NameAndType: + { + uint16 name = JPOOL_USHORT1 (jcf, index); + uint16 sig = JPOOL_USHORT2 (jcf, index); + uint32 name_index = handle_constant (jcf, name, CONSTANT_Utf8); + uint32 sig_index = handle_constant (jcf, sig, CONSTANT_Class); + jword new_index = (name_index << 16) | sig_index; + index = find_constant1 (cpool, kind, new_index); + } + break; + + default: + abort (); + } + + return index; +} + +/* Read an element_value structure from an annotation in JCF. Return + the constant pool index for the resulting constant pool entry. */ + +static int +handle_element_value (JCF *jcf, int level) +{ + uint8 tag = JCF_readu (jcf); + int index = 0; + + annotation_write_byte (tag); + switch (tag) + { + case 'B': + case 'C': + case 'S': + case 'Z': + case 'I': + { + uint16 cindex = JCF_readu2 (jcf); + index = handle_constant (jcf, cindex, + CONSTANT_Integer); + annotation_write_short (index); + } + break; + case 'D': + { + uint16 cindex = JCF_readu2 (jcf); + index = handle_constant (jcf, cindex, + CONSTANT_Double); + annotation_write_short (index); + } + break; + case 'F': + { + uint16 cindex = JCF_readu2 (jcf); + index = handle_constant (jcf, cindex, + CONSTANT_Float); + annotation_write_short (index); + } + break; + case 'J': + { + uint16 cindex = JCF_readu2 (jcf); + index = handle_constant (jcf, cindex, + CONSTANT_Long); + annotation_write_short (index); + } + break; + case 's': + { + uint16 cindex = JCF_readu2 (jcf); + /* Despite what the JVM spec says, compilers generate a Utf8 + constant here, not a String. */ + index = handle_constant (jcf, cindex, + CONSTANT_Utf8); + annotation_write_short (index); + } + break; + + case 'e': + { + uint16 type_name_index = JCF_readu2 (jcf); + uint16 const_name_index = JCF_readu2 (jcf); + index = handle_constant (jcf, type_name_index, + CONSTANT_Class); + annotation_write_short (index); + index = handle_constant (jcf, const_name_index, + CONSTANT_Utf8); + annotation_write_short (index); + } + break; + case 'c': + { + uint16 class_info_index = JCF_readu2 (jcf); + index = handle_constant (jcf, class_info_index, + CONSTANT_Class); + annotation_write_short (index); + } + break; + case '@': + { + handle_annotation (jcf, level + 1); + } + break; + case '[': + { + uint16 n_array_elts = JCF_readu2 (jcf); + annotation_write_short (n_array_elts); + while (n_array_elts--) + handle_element_value (jcf, level + 1); + } + break; + default: + abort(); + break; + } + return index; +} + +/* Read an annotation structure from JCF. Write it to the + reflection_data field of the outgoing class. */ + +static void +handle_annotation (JCF *jcf, int level) +{ + uint16 type_index = JCF_readu2 (jcf); + uint16 npairs = JCF_readu2 (jcf); + int index = handle_constant (jcf, type_index, + CONSTANT_Class); + annotation_write_short (index); + annotation_write_short (npairs); + while (npairs--) + { + uint16 name_index = JCF_readu2 (jcf); + index = handle_constant (jcf, name_index, + CONSTANT_Utf8); + annotation_write_short (index); + handle_element_value (jcf, level + 2); + } +} + +/* Read an annotation count from JCF, and write the following + annotations to the reflection_data field of the outgoing class. */ + +static void +handle_annotations (JCF *jcf, int level) +{ + uint16 num = JCF_readu2 (jcf); + annotation_write_short (num); + while (num--) + handle_annotation (jcf, level); +} + +/* As handle_annotations(), but perform a sanity check that we write + the same number of bytes that we were expecting. */ + +static void +handle_annotation_attribute (int ATTRIBUTE_UNUSED index, JCF *jcf, + long length) +{ + long old_datasize = TYPE_REFLECTION_DATASIZE (current_class); + + handle_annotations (jcf, 0); + + gcc_assert (old_datasize + length + == TYPE_REFLECTION_DATASIZE (current_class)); +} + +/* gcj permutes its fields array after generating annotation_data, so + we have to fixup field indexes for fields that have moved. Given + ARG, a VEC_int, fixup the field indexes in the reflection_data of + the outgoing class. We use field_offsets to tell us where the + fixups must go. */ + +void +rewrite_reflection_indexes (void *arg) +{ + bitmap_iterator bi; + unsigned int offset; + VEC(int, heap) *map = (VEC(int, heap) *) arg; + unsigned char *data = TYPE_REFLECTION_DATA (current_class); + + if (map) + { + EXECUTE_IF_SET_IN_BITMAP (field_offsets, 0, offset, bi) + { + uint16 index = annotation_read_short (data + offset); + annotation_rewrite_short + (VEC_index (int, map, index), data + offset); + } + } +} + +/* Read the RuntimeVisibleAnnotations from JCF and write them to the + reflection_data of the outgoing class. */ + +static void +handle_member_annotations (int member_index, JCF *jcf, + const unsigned char *name ATTRIBUTE_UNUSED, + long len, jv_attr_type member_type) +{ + int new_len = len + 1; + annotation_write_byte (member_type); + if (member_type != JV_CLASS_ATTR) + new_len += 2; + annotation_write_int (new_len); + annotation_write_byte (JV_ANNOTATIONS_KIND); + if (member_type == JV_FIELD_ATTR) + bitmap_set_bit (field_offsets, TYPE_REFLECTION_DATASIZE (current_class)); + if (member_type != JV_CLASS_ATTR) + annotation_write_short (member_index); + handle_annotation_attribute (member_index, jcf, len); +} + +/* Read the RuntimeVisibleParameterAnnotations from JCF and write them + to the reflection_data of the outgoing class. */ + +static void +handle_parameter_annotations (int member_index, JCF *jcf, + const unsigned char *name ATTRIBUTE_UNUSED, + long len, jv_attr_type member_type) +{ + int new_len = len + 1; + uint8 num; + annotation_write_byte (member_type); + if (member_type != JV_CLASS_ATTR) + new_len += 2; + annotation_write_int (new_len); + annotation_write_byte (JV_PARAMETER_ANNOTATIONS_KIND); + if (member_type != JV_CLASS_ATTR) + annotation_write_short (member_index); + num = JCF_readu (jcf); + annotation_write_byte (num); + while (num--) + handle_annotations (jcf, 0); +} + + +/* Read the AnnotationDefault data from JCF and write them to the + reflection_data of the outgoing class. */ + +static void +handle_default_annotation (int member_index, JCF *jcf, + const unsigned char *name ATTRIBUTE_UNUSED, + long len, jv_attr_type member_type) +{ + int new_len = len + 1; + annotation_write_byte (member_type); + if (member_type != JV_CLASS_ATTR) + new_len += 2; + annotation_write_int (new_len); + annotation_write_byte (JV_ANNOTATION_DEFAULT_KIND); + if (member_type != JV_CLASS_ATTR) + annotation_write_short (member_index); + handle_element_value (jcf, 0); +} + +/* As above, for the EnclosingMethod attribute. */ + +static void +handle_enclosingmethod_attribute (int member_index, JCF *jcf, + const unsigned char *name ATTRIBUTE_UNUSED, + long len, jv_attr_type member_type) +{ + int new_len = len + 1; + uint16 index; + annotation_write_byte (member_type); + if (member_type != JV_CLASS_ATTR) + new_len += 2; + annotation_write_int (new_len); + annotation_write_byte (JV_ENCLOSING_METHOD_KIND); + if (member_type != JV_CLASS_ATTR) + annotation_write_short (member_index); + + index = JCF_readu2 (jcf); + index = handle_constant (jcf, index, CONSTANT_Class); + annotation_write_short (index); + + index = JCF_readu2 (jcf); + index = handle_constant (jcf, index, CONSTANT_NameAndType); + annotation_write_short (index); +} + +/* As above, for the Signature attribute. */ + +static void +handle_signature_attribute (int member_index, JCF *jcf, + const unsigned char *name ATTRIBUTE_UNUSED, + long len, jv_attr_type member_type) +{ + int new_len = len + 1; + uint16 index; + annotation_write_byte (member_type); + if (member_type != JV_CLASS_ATTR) + new_len += 2; + annotation_write_int (new_len); + annotation_write_byte (JV_SIGNATURE_KIND); + if (member_type != JV_CLASS_ATTR) + annotation_write_short (member_index); + + index = JCF_readu2 (jcf); + index = handle_constant (jcf, index, CONSTANT_Utf8); + annotation_write_short (index); +} + + + +#define HANDLE_SOURCEFILE(INDEX) set_source_filename (jcf, INDEX) + +#define HANDLE_CLASS_INFO(ACCESS_FLAGS, THIS, SUPER, INTERFACES_COUNT) \ +{ tree super_class = SUPER==0 ? NULL_TREE : get_class_constant (jcf, SUPER); \ + output_class = current_class = give_name_to_class (jcf, THIS); \ + set_super_info (ACCESS_FLAGS, current_class, super_class, INTERFACES_COUNT);} + +#define HANDLE_CLASS_INTERFACE(INDEX) \ + add_interface (current_class, get_class_constant (jcf, INDEX)) + +#define HANDLE_START_FIELD(ACCESS_FLAGS, NAME, SIGNATURE, ATTRIBUTE_COUNT) \ +{ int sig_index = SIGNATURE; \ + current_field = add_field (current_class, get_name_constant (jcf, NAME), \ + parse_signature (jcf, sig_index), ACCESS_FLAGS); \ + set_java_signature (TREE_TYPE (current_field), JPOOL_UTF (jcf, sig_index)); \ + if ((ACCESS_FLAGS) & ACC_FINAL) \ + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (current_field); \ +} + +#define HANDLE_END_FIELDS() \ + (current_field = NULL_TREE) + +#define HANDLE_CONSTANTVALUE(INDEX) \ +{ tree constant; int index = INDEX; \ + if (JPOOL_TAG (jcf, index) == CONSTANT_String) { \ + tree name = get_name_constant (jcf, JPOOL_USHORT1 (jcf, index)); \ + constant = build_utf8_ref (name); \ + } \ + else \ + constant = get_constant (jcf, index); \ + set_constant_value (current_field, constant); } + +#define HANDLE_METHOD(ACCESS_FLAGS, NAME, SIGNATURE, ATTRIBUTE_COUNT) \ + (current_method = add_method (current_class, ACCESS_FLAGS, \ + get_name_constant (jcf, NAME), \ + get_name_constant (jcf, SIGNATURE)), \ + DECL_LOCALVARIABLES_OFFSET (current_method) = 0, \ + DECL_LINENUMBERS_OFFSET (current_method) = 0) + +#define HANDLE_END_METHODS() \ +{ current_method = NULL_TREE; } + +#define HANDLE_CODE_ATTRIBUTE(MAX_STACK, MAX_LOCALS, CODE_LENGTH) \ +{ DECL_MAX_STACK (current_method) = (MAX_STACK); \ + DECL_MAX_LOCALS (current_method) = (MAX_LOCALS); \ + DECL_CODE_LENGTH (current_method) = (CODE_LENGTH); \ + DECL_CODE_OFFSET (current_method) = JCF_TELL (jcf); } + +#define HANDLE_LOCALVARIABLETABLE_ATTRIBUTE(COUNT) \ +{ int n = (COUNT); \ + DECL_LOCALVARIABLES_OFFSET (current_method) = JCF_TELL (jcf) - 2; \ + JCF_SKIP (jcf, n * 10); } + +#define HANDLE_LINENUMBERTABLE_ATTRIBUTE(COUNT) \ +{ int n = (COUNT); \ + DECL_LINENUMBERS_OFFSET (current_method) = JCF_TELL (jcf) - 2; \ + JCF_SKIP (jcf, n * 4); } + +#define HANDLE_EXCEPTIONS_ATTRIBUTE(COUNT) \ +{ \ + int n = COUNT; \ + VEC (tree,gc) *v = VEC_alloc (tree, gc, n); \ + gcc_assert (DECL_FUNCTION_THROWS (current_method) == NULL); \ + while (--n >= 0) \ + { \ + tree thrown_class = get_class_constant (jcf, JCF_readu2 (jcf)); \ + VEC_quick_push (tree, v, thrown_class); \ + } \ + DECL_FUNCTION_THROWS (current_method) = v; \ +} + +#define HANDLE_DEPRECATED_ATTRIBUTE() handle_deprecated () + +/* Link seen inner classes to their outer context and register the + inner class to its outer context. They will be later loaded. */ +#define HANDLE_INNERCLASSES_ATTRIBUTE(COUNT) \ + handle_innerclass_attribute (COUNT, jcf, attribute_length) + +#define HANDLE_SYNTHETIC_ATTRIBUTE() \ +{ \ + /* Irrelevant decls should have been nullified by the END macros. \ + DECL_ARTIFICIAL on fields is used for something else (See \ + PUSH_FIELD in java-tree.h) */ \ + if (current_method) \ + DECL_ARTIFICIAL (current_method) = 1; \ + else if (current_field) \ + FIELD_SYNTHETIC (current_field) = 1; \ + else \ + TYPE_SYNTHETIC (current_class) = 1; \ +} + +#define HANDLE_GCJCOMPILED_ATTRIBUTE() \ +{ \ + if (current_class == object_type_node) \ + jcf->right_zip = 1; \ +} + +#define HANDLE_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE() \ +{ \ + handle_member_annotations (index, jcf, name_data, attribute_length, attr_type); \ +} + +#define HANDLE_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE() \ +{ \ + JCF_SKIP(jcf, attribute_length); \ +} + +#define HANDLE_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE() \ +{ \ + handle_parameter_annotations (index, jcf, name_data, attribute_length, attr_type); \ +} + +#define HANDLE_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE() \ +{ \ + JCF_SKIP(jcf, attribute_length); \ +} + +#define HANDLE_ANNOTATIONDEFAULT_ATTRIBUTE() \ +{ \ + handle_default_annotation (index, jcf, name_data, attribute_length, attr_type); \ +} + +#define HANDLE_ENCLOSINGMETHOD_ATTRIBUTE() \ +{ \ + handle_enclosingmethod_attribute (index, jcf, name_data, \ + attribute_length, attr_type); \ +} + +#define HANDLE_SIGNATURE_ATTRIBUTE() \ +{ \ + handle_signature_attribute (index, jcf, name_data, \ + attribute_length, attr_type); \ +} + +#include "jcf-reader.c" + +tree +parse_signature (JCF *jcf, int sig_index) +{ + gcc_assert (sig_index > 0 + && sig_index < JPOOL_SIZE (jcf) + && JPOOL_TAG (jcf, sig_index) == CONSTANT_Utf8); + + return parse_signature_string (JPOOL_UTF_DATA (jcf, sig_index), + JPOOL_UTF_LENGTH (jcf, sig_index)); +} + +tree +get_constant (JCF *jcf, int index) +{ + tree value; + int tag; + if (index <= 0 || index >= JPOOL_SIZE(jcf)) + goto bad; + tag = JPOOL_TAG (jcf, index); + if ((tag & CONSTANT_ResolvedFlag) || tag == CONSTANT_Utf8) + return jcf->cpool.data[index].t; + switch (tag) + { + case CONSTANT_Integer: + { + jint num = JPOOL_INT(jcf, index); + value = build_int_cst (int_type_node, num); + break; + } + case CONSTANT_Long: + { + unsigned HOST_WIDE_INT num; + double_int val; + + num = JPOOL_UINT (jcf, index); + val = double_int_lshift (uhwi_to_double_int (num), 32, 64, false); + num = JPOOL_UINT (jcf, index + 1); + val = double_int_ior (val, uhwi_to_double_int (num)); + + value = double_int_to_tree (long_type_node, val); + break; + } + + case CONSTANT_Float: + { + jint num = JPOOL_INT(jcf, index); + long buf = num; + REAL_VALUE_TYPE d; + + real_from_target_fmt (&d, &buf, &ieee_single_format); + value = build_real (float_type_node, d); + break; + } + + case CONSTANT_Double: + { + long buf[2], lo, hi; + REAL_VALUE_TYPE d; + + hi = JPOOL_UINT (jcf, index); + lo = JPOOL_UINT (jcf, index+1); + + if (targetm.float_words_big_endian ()) + buf[0] = hi, buf[1] = lo; + else + buf[0] = lo, buf[1] = hi; + + real_from_target_fmt (&d, buf, &ieee_double_format); + value = build_real (double_type_node, d); + break; + } + + case CONSTANT_String: + { + tree name = get_name_constant (jcf, JPOOL_USHORT1 (jcf, index)); + const char *utf8_ptr = IDENTIFIER_POINTER (name); + int utf8_len = IDENTIFIER_LENGTH (name); + const unsigned char *utf8; + int i; + + /* Check for a malformed Utf8 string. */ + utf8 = (const unsigned char *) utf8_ptr; + i = utf8_len; + while (i > 0) + { + int char_len = UT8_CHAR_LENGTH (*utf8); + if (char_len < 0 || char_len > 3 || char_len > i) + fatal_error ("bad string constant"); + + utf8 += char_len; + i -= char_len; + } + + /* Allocate a new string value. */ + value = build_string (utf8_len, utf8_ptr); + TREE_TYPE (value) = build_pointer_type (string_type_node); + } + break; + default: + goto bad; + } + JPOOL_TAG (jcf, index) = tag | CONSTANT_ResolvedFlag; + jcf->cpool.data[index].t = value; + return value; + bad: + internal_error ("bad value constant type %d, index %d", + JPOOL_TAG (jcf, index), index); +} + +tree +get_name_constant (JCF *jcf, int index) +{ + tree name = get_constant (jcf, index); + gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE); + return name; +} + +/* Handle reading innerclass attributes. If a nonzero entry (denoting + a non anonymous entry) is found, We augment the inner class list of + the outer context with the newly resolved innerclass. */ + +static void +handle_innerclass_attribute (int count, JCF *jcf, int attribute_length) +{ + int c = count; + + annotation_write_byte (JV_CLASS_ATTR); + annotation_write_int (attribute_length+1); + annotation_write_byte (JV_INNER_CLASSES_KIND); + annotation_write_short (count); + + while (c--) + { + /* Read inner_class_info_index. This may be 0 */ + int icii = JCF_readu2 (jcf); + /* Read outer_class_info_index. If the innerclasses attribute + entry isn't a member (like an inner class) the value is 0. */ + int ocii = JCF_readu2 (jcf); + /* Read inner_name_index. If the class we're dealing with is + an anonymous class, it must be 0. */ + int ini = JCF_readu2 (jcf); + /* Read the access flag. */ + int acc = JCF_readu2 (jcf); + + annotation_write_short (handle_constant (jcf, icii, CONSTANT_Class)); + annotation_write_short (handle_constant (jcf, ocii, CONSTANT_Class)); + annotation_write_short (handle_constant (jcf, ini, CONSTANT_Utf8)); + annotation_write_short (acc); + + /* If icii is 0, don't try to read the class. */ + if (icii >= 0) + { + tree klass = get_class_constant (jcf, icii); + tree decl = TYPE_NAME (klass); + /* Skip reading further if ocii is null */ + if (DECL_P (decl) && !CLASS_COMPLETE_P (decl) && ocii) + { + tree outer = TYPE_NAME (get_class_constant (jcf, ocii)); + tree alias = (ini ? get_name_constant (jcf, ini) : NULL_TREE); + set_class_decl_access_flags (acc, decl); + DECL_CONTEXT (decl) = outer; + DECL_INNER_CLASS_LIST (outer) = + tree_cons (decl, alias, DECL_INNER_CLASS_LIST (outer)); + CLASS_COMPLETE_P (decl) = 1; + } + } + } +} + +static tree +give_name_to_class (JCF *jcf, int i) +{ + gcc_assert (i > 0 + && i < JPOOL_SIZE (jcf) + && JPOOL_TAG (jcf, i) == CONSTANT_Class); + + { + tree package_name = NULL_TREE, tmp; + tree this_class; + int j = JPOOL_USHORT1 (jcf, i); + /* verify_constant_pool confirmed that j is a CONSTANT_Utf8. */ + tree class_name = unmangle_classname ((const char *) JPOOL_UTF_DATA (jcf, j), + JPOOL_UTF_LENGTH (jcf, j)); + this_class = lookup_class (class_name); + { + tree source_name = identifier_subst (class_name, "", '.', '/', ".java"); + const char *sfname = find_sourcefile (IDENTIFIER_POINTER (source_name)); + linemap_add (line_table, LC_ENTER, false, sfname, 0); + input_location = linemap_line_start (line_table, 0, 1); + file_start_location = input_location; + DECL_SOURCE_LOCATION (TYPE_NAME (this_class)) = input_location; + if (main_input_filename == NULL && jcf == main_jcf) + main_input_filename = sfname; + } + + jcf->cpool.data[i].t = this_class; + JPOOL_TAG (jcf, i) = CONSTANT_ResolvedClass; + split_qualified_name (&package_name, &tmp, + DECL_NAME (TYPE_NAME (this_class))); + TYPE_PACKAGE (this_class) = package_name; + return this_class; + } +} + +/* Get the class of the CONSTANT_Class whose constant pool index is I. */ + +tree +get_class_constant (JCF *jcf, int i) +{ + tree type; + gcc_assert (i > 0 + && i < JPOOL_SIZE (jcf) + && (JPOOL_TAG (jcf, i) & ~CONSTANT_ResolvedFlag) == CONSTANT_Class); + + if (JPOOL_TAG (jcf, i) != CONSTANT_ResolvedClass) + { + int name_index = JPOOL_USHORT1 (jcf, i); + /* verify_constant_pool confirmed that name_index is a CONSTANT_Utf8. */ + const char *name = (const char *) JPOOL_UTF_DATA (jcf, name_index); + int nlength = JPOOL_UTF_LENGTH (jcf, name_index); + + if (name[0] == '[') /* Handle array "classes". */ + type = TREE_TYPE (parse_signature_string ((const unsigned char *) name, nlength)); + else + { + tree cname = unmangle_classname (name, nlength); + type = lookup_class (cname); + } + jcf->cpool.data[i].t = type; + JPOOL_TAG (jcf, i) = CONSTANT_ResolvedClass; + } + else + type = jcf->cpool.data[i].t; + return type; +} + +/* Read a class with the fully qualified-name NAME. + Return 1 iff we read the requested file. + (It is still possible we failed if the file did not + define the class it is supposed to.) */ + +int +read_class (tree name) +{ + JCF this_jcf, *jcf; + tree icv, klass = NULL_TREE; + tree save_current_class = current_class; + tree save_output_class = output_class; + location_t save_location = input_location; + JCF *save_current_jcf = current_jcf; + + if ((icv = IDENTIFIER_CLASS_VALUE (name)) != NULL_TREE) + { + klass = TREE_TYPE (icv); + jcf = TYPE_JCF (klass); + } + else + jcf = NULL; + + if (jcf == NULL) + { + const char* path_name; + this_jcf.zipd = NULL; + jcf = &this_jcf; + + path_name = find_class (IDENTIFIER_POINTER (name), + IDENTIFIER_LENGTH (name), + &this_jcf); + if (path_name == 0) + return 0; + else + free(CONST_CAST (char *, path_name)); + } + + current_jcf = jcf; + + if (klass == NULL_TREE || ! CLASS_PARSED_P (klass)) + { + output_class = current_class = klass; + if (JCF_SEEN_IN_ZIP (current_jcf)) + read_zip_member(current_jcf, + current_jcf->zipd, current_jcf->zipd->zipf); + jcf_parse (current_jcf); + /* Parsing might change the class, in which case we have to + put it back where we found it. */ + if (current_class != klass && icv != NULL_TREE) + TREE_TYPE (icv) = current_class; + klass = current_class; + } + layout_class (klass); + load_inner_classes (klass); + + output_class = save_output_class; + current_class = save_current_class; + input_location = save_location; + current_jcf = save_current_jcf; + return 1; +} + +/* Load CLASS_OR_NAME. CLASS_OR_NAME can be a mere identifier if + called from the parser, otherwise it's a RECORD_TYPE node. If + VERBOSE is 1, print error message on failure to load a class. */ +void +load_class (tree class_or_name, int verbose) +{ + tree name, saved; + int class_loaded = 0; + tree class_decl = NULL_TREE; + bool is_compiled_class = false; + + /* We've already failed, don't try again. */ + if (TREE_CODE (class_or_name) == RECORD_TYPE + && TYPE_DUMMY (class_or_name)) + return; + + /* class_or_name can be the name of the class we want to load */ + if (TREE_CODE (class_or_name) == IDENTIFIER_NODE) + name = class_or_name; + /* In some cases, it's a dependency that we process earlier that + we though */ + else if (TREE_CODE (class_or_name) == TREE_LIST) + name = TYPE_NAME (TREE_PURPOSE (class_or_name)); + /* Or it's a type in the making */ + else + name = DECL_NAME (TYPE_NAME (class_or_name)); + + class_decl = IDENTIFIER_CLASS_VALUE (name); + if (class_decl != NULL_TREE) + { + tree type = TREE_TYPE (class_decl); + is_compiled_class + = ((TYPE_JCF (type) && JCF_SEEN_IN_ZIP (TYPE_JCF (type))) + || CLASS_FROM_CURRENTLY_COMPILED_P (type)); + } + + saved = name; + + /* If flag_verify_invocations is unset, we don't try to load a class + unless we're looking for Object (which is fixed by the ABI) or + it's a class that we're going to compile. */ + if (flag_verify_invocations + || class_or_name == object_type_node + || is_compiled_class + || TREE_CODE (class_or_name) == IDENTIFIER_NODE) + { + while (1) + { + const char *separator; + + /* We've already loaded it. */ + if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE) + { + tree tmp_decl = IDENTIFIER_CLASS_VALUE (name); + if (CLASS_PARSED_P (TREE_TYPE (tmp_decl))) + break; + } + + if (read_class (name)) + break; + + /* We failed loading name. Now consider that we might be looking + for an inner class. */ + if ((separator = strrchr (IDENTIFIER_POINTER (name), '$')) + || (separator = strrchr (IDENTIFIER_POINTER (name), '.'))) + name = get_identifier_with_length (IDENTIFIER_POINTER (name), + (separator + - IDENTIFIER_POINTER (name))); + /* Otherwise, we failed, we bail. */ + else + break; + } + + { + /* have we found the class we're looking for? */ + tree type_decl = IDENTIFIER_CLASS_VALUE (saved); + tree type = type_decl ? TREE_TYPE (type_decl) : NULL; + class_loaded = type && CLASS_PARSED_P (type); + } + } + + if (!class_loaded) + { + if (flag_verify_invocations || ! flag_indirect_dispatch) + { + if (verbose) + error ("cannot find file for class %s", IDENTIFIER_POINTER (saved)); + } + else if (verbose) + { + /* This is just a diagnostic during testing, not a real problem. */ + if (!quiet_flag) + warning (0, "cannot find file for class %s", + IDENTIFIER_POINTER (saved)); + + /* Fake it. */ + if (TREE_CODE (class_or_name) == RECORD_TYPE) + { + set_super_info (0, class_or_name, object_type_node, 0); + TYPE_DUMMY (class_or_name) = 1; + /* We won't be able to output any debug info for this class. */ + DECL_IGNORED_P (TYPE_NAME (class_or_name)) = 1; + } + } + } +} + +/* Parse the .class file JCF. */ + +static void +jcf_parse (JCF* jcf) +{ + int i, code; + + bitmap_clear (field_offsets); + + if (jcf_parse_preamble (jcf) != 0) + fatal_error ("not a valid Java .class file"); + code = jcf_parse_constant_pool (jcf); + if (code != 0) + fatal_error ("error while parsing constant pool"); + code = verify_constant_pool (jcf); + if (code > 0) + fatal_error ("error in constant pool entry #%d\n", code); + + jcf_parse_class (jcf); + if (main_class == NULL_TREE) + main_class = current_class; + if (! quiet_flag && TYPE_NAME (current_class)) + fprintf (stderr, " %s %s", + (jcf->access_flags & ACC_INTERFACE) ? "interface" : "class", + IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)))); + if (CLASS_PARSED_P (current_class)) + { + /* FIXME - where was first time */ + fatal_error ("reading class %s for the second time from %s", + IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))), + jcf->filename); + } + CLASS_PARSED_P (current_class) = 1; + + for (i = 1; i < JPOOL_SIZE(jcf); i++) + { + switch (JPOOL_TAG (jcf, i)) + { + case CONSTANT_Class: + get_class_constant (jcf, i); + break; + } + } + + code = jcf_parse_fields (jcf); + if (code != 0) + fatal_error ("error while parsing fields"); + code = jcf_parse_methods (jcf); + if (code != 0) + fatal_error ("error while parsing methods"); + code = jcf_parse_final_attributes (jcf); + if (code != 0) + fatal_error ("error while parsing final attributes"); + + if (TYPE_REFLECTION_DATA (current_class)) + annotation_write_byte (JV_DONE_ATTR); + + linemap_add (line_table, LC_LEAVE, false, NULL, 0); + + /* The fields of class_type_node are already in correct order. */ + if (current_class != class_type_node && current_class != object_type_node) + TYPE_FIELDS (current_class) = nreverse (TYPE_FIELDS (current_class)); + + if (current_class == object_type_node) + layout_class_methods (object_type_node); + else + VEC_safe_push (tree, gc, all_class_list, TYPE_NAME (current_class)); +} + +/* If we came across inner classes, load them now. */ +static void +load_inner_classes (tree cur_class) +{ + tree current; + for (current = DECL_INNER_CLASS_LIST (TYPE_NAME (cur_class)); current; + current = TREE_CHAIN (current)) + { + tree name = DECL_NAME (TREE_PURPOSE (current)); + tree decl = IDENTIFIER_GLOBAL_VALUE (name); + if (decl && ! CLASS_LOADED_P (TREE_TYPE (decl)) + && !CLASS_BEING_LAIDOUT (TREE_TYPE (decl))) + load_class (name, 1); + } +} + +static void +duplicate_class_warning (const char *filename) +{ + location_t warn_loc; + linemap_add (line_table, LC_RENAME, 0, filename, 0); + warn_loc = linemap_line_start (line_table, 0, 1); + warning_at (warn_loc, 0, "duplicate class will only be compiled once"); +} + +static void +java_layout_seen_class_methods (void) +{ + unsigned start = 0; + unsigned end = VEC_length (tree, all_class_list); + + while (1) + { + unsigned ix; + unsigned new_length; + + for (ix = start; ix != end; ix++) + { + tree decl = VEC_index (tree, all_class_list, ix); + tree cls = TREE_TYPE (decl); + + input_location = DECL_SOURCE_LOCATION (decl); + + if (! CLASS_LOADED_P (cls)) + load_class (cls, 0); + + layout_class_methods (cls); + } + + /* Note that new classes might have been added while laying out + methods, changing the value of all_class_list. */ + new_length = VEC_length (tree, all_class_list); + if (end != new_length) + { + start = end; + end = new_length; + } + else + break; + } +} + +static void +parse_class_file (void) +{ + tree method; + location_t save_location = input_location; + + java_layout_seen_class_methods (); + + input_location = DECL_SOURCE_LOCATION (TYPE_NAME (current_class)); + { + /* Re-enter the current file. */ + expanded_location loc = expand_location (input_location); + linemap_add (line_table, LC_ENTER, 0, loc.file, loc.line); + } + file_start_location = input_location; + (*debug_hooks->start_source_file) (input_line, input_filename); + + java_mark_class_local (current_class); + + gen_indirect_dispatch_tables (current_class); + + for (method = TYPE_METHODS (current_class); + method != NULL_TREE; method = DECL_CHAIN (method)) + { + JCF *jcf = current_jcf; + + if (METHOD_ABSTRACT (method) || METHOD_DUMMY (method)) + continue; + + if (METHOD_NATIVE (method)) + { + tree arg; + int decl_max_locals; + + if (! flag_jni) + continue; + /* We need to compute the DECL_MAX_LOCALS. We need to take + the wide types into account too. */ + for (arg = TYPE_ARG_TYPES (TREE_TYPE (method)), decl_max_locals = 0; + arg != end_params_node; + arg = TREE_CHAIN (arg), decl_max_locals += 1) + { + if (TREE_VALUE (arg) && TYPE_IS_WIDE (TREE_VALUE (arg))) + decl_max_locals += 1; + } + DECL_MAX_LOCALS (method) = decl_max_locals; + start_java_method (method); + give_name_to_locals (jcf); + *get_stmts () = build_jni_stub (method); + end_java_method (); + continue; + } + + if (DECL_CODE_OFFSET (method) == 0) + { + current_function_decl = method; + error ("missing Code attribute"); + continue; + } + + input_location = DECL_SOURCE_LOCATION (TYPE_NAME (current_class)); + if (DECL_LINENUMBERS_OFFSET (method)) + { + int i; + int min_line = 0; + unsigned char *ptr; + JCF_SEEK (jcf, DECL_LINENUMBERS_OFFSET (method)); + linenumber_count = i = JCF_readu2 (jcf); + linenumber_table = ptr = jcf->read_ptr; + + for (ptr += 2; --i >= 0; ptr += 4) + { + int line = GET_u2 (ptr); + /* Set initial input_line to smallest linenumber. + * Needs to be set before init_function_start. */ + if (min_line == 0 || line < min_line) + min_line = line; + } + if (min_line != 0) + input_location = linemap_line_start (line_table, min_line, 1); + } + else + { + linenumber_table = NULL; + linenumber_count = 0; + } + + start_java_method (method); + + note_instructions (jcf, method); + + give_name_to_locals (jcf); + + /* Bump up start_label_pc_this_method so we get a unique label number + and reset highest_label_pc_this_method. */ + if (highest_label_pc_this_method >= 0) + { + /* We adjust to the next multiple of 1000. This is just a frill + so the last 3 digits of the label number match the bytecode + offset, which might make debugging marginally more convenient. */ + start_label_pc_this_method + = ((((start_label_pc_this_method + highest_label_pc_this_method) + / 1000) + + 1) + * 1000); + highest_label_pc_this_method = -1; + } + + /* Convert bytecode to trees. */ + expand_byte_code (jcf, method); + + end_java_method (); + } + + finish_class (); + + (*debug_hooks->end_source_file) (LOCATION_LINE (save_location)); + input_location = save_location; +} + +static VEC(tree,gc) *predefined_filenames; + +void +add_predefined_file (tree name) +{ + VEC_safe_push (tree, gc, predefined_filenames, name); +} + +int +predefined_filename_p (tree node) +{ + unsigned ix; + tree f; + + FOR_EACH_VEC_ELT (tree, predefined_filenames, ix, f) + if (f == node) + return 1; + + return 0; +} + +/* Generate a function that does all static initialization for this + translation unit. */ + +static void +java_emit_static_constructor (void) +{ + tree body = NULL; + + emit_register_classes (&body); + write_resource_constructor (&body); + + if (body) + { + tree name = get_identifier ("_Jv_global_static_constructor"); + + tree decl + = build_decl (input_location, FUNCTION_DECL, name, + build_function_type_list (void_type_node, NULL_TREE)); + + tree resdecl = build_decl (input_location, + RESULT_DECL, NULL_TREE, void_type_node); + DECL_ARTIFICIAL (resdecl) = 1; + DECL_RESULT (decl) = resdecl; + current_function_decl = decl; + allocate_struct_function (decl, false); + + TREE_STATIC (decl) = 1; + TREE_USED (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1; + DECL_SAVED_TREE (decl) = body; + DECL_UNINLINABLE (decl) = 1; + + DECL_INITIAL (decl) = make_node (BLOCK); + TREE_USED (DECL_INITIAL (decl)) = 1; + + DECL_STATIC_CONSTRUCTOR (decl) = 1; + java_genericize (decl); + cgraph_finalize_function (decl, false); + } +} + + +void +java_parse_file (void) +{ + int filename_count = 0; + location_t save_location = input_location; + char *file_list = NULL, *list, *next; + tree node; + FILE *finput = NULL; + int in_quotes = 0; + unsigned ix; + + bitmap_obstack_initialize (&bit_obstack); + field_offsets = BITMAP_ALLOC (&bit_obstack); + + if (flag_filelist_file) + { + int avail = 2000; + finput = fopen (main_input_filename, "r"); + if (finput == NULL) + fatal_error ("can%'t open %s: %m", input_filename); + list = XNEWVEC (char, avail); + next = list; + for (;;) + { + int count; + if (avail < 500) + { + count = next - list; + avail = 2 * (count + avail); + list = XRESIZEVEC (char, list, avail); + next = list + count; + avail = avail - count; + } + /* Subtract to to guarantee space for final '\0'. */ + count = fread (next, 1, avail - 1, finput); + if (count == 0) + { + if (! feof (finput)) + fatal_error ("error closing %s: %m", input_filename); + *next = '\0'; + break; + } + avail -= count; + next += count; + } + fclose (finput); + finput = NULL; + file_list = list; + } + else + list = CONST_CAST (char *, main_input_filename); + + while (list) + { + for (next = list; ; ) + { + char ch = *next; + if (flag_filelist_file && ! in_quotes + && (ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ' + || ch == '&') /* FIXME */) + { + if (next == list) + { + next++; + list = next; + continue; + } + else + { + *next++ = '\0'; + break; + } + } + if (flag_filelist_file && ch == '"') + { + in_quotes = ! in_quotes; + *next++ = '\0'; + if (in_quotes) + list = next; + else + break; + } + if (ch == '\0') + { + next = NULL; + break; + } + next++; + } + + /* Exclude .java files. */ + if (strlen (list) > 5 && ! strcmp (list + strlen (list) - 5, ".java")) + { + /* Nothing. */ + } + else if (list[0]) + { + node = get_identifier (list); + + filename_count++; + + /* Exclude file that we see twice on the command line. */ + + if (IS_A_COMMAND_LINE_FILENAME_P (node)) + duplicate_class_warning (IDENTIFIER_POINTER (node)); + else + { + build_translation_unit_decl (node); + IS_A_COMMAND_LINE_FILENAME_P (node) = 1; + } + } + list = next; + } + + if (file_list != NULL) + free (file_list); + + if (filename_count == 0) + warning (0, "no input file specified"); + + if (resource_name) + { + const char *resource_filename; + + /* Only one resource file may be compiled at a time. */ + gcc_assert (VEC_length (tree, all_translation_units) == 1); + + resource_filename + = IDENTIFIER_POINTER + (DECL_NAME (VEC_index (tree, all_translation_units, 0))); + compile_resource_file (resource_name, resource_filename); + + goto finish; + } + + current_jcf = main_jcf; + FOR_EACH_VEC_ELT (tree, all_translation_units, ix, node) + { + unsigned char magic_string[4]; + char *real_path; + uint32 magic = 0; + tree name = DECL_NAME (node); + tree real_file; + const char *filename = IDENTIFIER_POINTER (name); + + /* Skip already parsed files */ + real_path = lrealpath (filename); + real_file = get_identifier (real_path); + free (real_path); + if (HAS_BEEN_ALREADY_PARSED_P (real_file)) + continue; + + /* Close previous descriptor, if any */ + if (finput && fclose (finput)) + fatal_error ("can%'t close input file %s: %m", main_input_filename); + + finput = fopen (filename, "rb"); + if (finput == NULL) + fatal_error ("can%'t open %s: %m", filename); + +#ifdef IO_BUFFER_SIZE + setvbuf (finput, xmalloc (IO_BUFFER_SIZE), + _IOFBF, IO_BUFFER_SIZE); +#endif + + /* Figure what kind of file we're dealing with */ + if (fread (magic_string, 1, 4, finput) == 4) + { + fseek (finput, 0L, SEEK_SET); + magic = GET_u4 (magic_string); + } + if (magic == 0xcafebabe) + { + CLASS_FILE_P (node) = 1; + current_jcf = ggc_alloc_cleared_JCF (); + current_jcf->read_state = finput; + current_jcf->filbuf = jcf_filbuf_from_stdio; + jcf_parse (current_jcf); + DECL_SOURCE_LOCATION (node) = file_start_location; + TYPE_JCF (current_class) = current_jcf; + if (CLASS_FROM_CURRENTLY_COMPILED_P (current_class)) + { + /* We've already compiled this class. */ + duplicate_class_warning (filename); + continue; + } + CLASS_FROM_CURRENTLY_COMPILED_P (current_class) = 1; + TREE_TYPE (node) = current_class; + } + else if (magic == (JCF_u4)ZIPMAGIC) + { + main_jcf = ggc_alloc_cleared_JCF (); + main_jcf->read_state = finput; + main_jcf->filbuf = jcf_filbuf_from_stdio; + linemap_add (line_table, LC_ENTER, false, filename, 0); + input_location = linemap_line_start (line_table, 0, 1); + if (open_in_zip (main_jcf, filename, NULL, 0) < 0) + fatal_error ("bad zip/jar file %s", filename); + localToFile = SeenZipFiles; + /* Register all the classes defined there. */ + process_zip_dir ((FILE *) main_jcf->read_state); + linemap_add (line_table, LC_LEAVE, false, NULL, 0); + parse_zip_file_entries (); + } + else if (magic == (JCF_u4) ZIPEMPTYMAGIC) + { + /* Ignore an empty input jar. */ + } + else + { + gcc_unreachable (); +#if 0 + java_push_parser_context (); + java_parser_context_save_global (); + + parse_source_file_1 (real_file, filename, finput); + java_parser_context_restore_global (); + java_pop_parser_context (1); + linemap_add (line_table, LC_LEAVE, false, NULL, 0); +#endif + } + } + + FOR_EACH_VEC_ELT (tree, all_translation_units, ix, node) + { + input_location = DECL_SOURCE_LOCATION (node); + if (CLASS_FILE_P (node)) + { + /* FIXME: These two flags really should be independent. We + should be able to compile fully binary compatible, but + with flag_verify_invocations on. */ + flag_verify_invocations = ! flag_indirect_dispatch; + output_class = current_class = TREE_TYPE (node); + + current_jcf = TYPE_JCF (current_class); + layout_class (current_class); + load_inner_classes (current_class); + parse_class_file (); + JCF_FINISH (current_jcf); + } + } + input_location = save_location; + + bitmap_obstack_release (&bit_obstack); + + finish: + /* Arrange for any necessary initialization to happen. */ + java_emit_static_constructor (); + gcc_assert (global_bindings_p ()); +} + + +/* Return the name of the class corresponding to the name of the file + in this zip entry. The result is newly allocated using ALLOC. */ +static char * +compute_class_name (struct ZipDirectory *zdir) +{ + char *class_name_in_zip_dir = ZIPDIR_FILENAME (zdir); + char *class_name; + int i; + int filename_length = zdir->filename_length; + + while (filename_length > 2 && strncmp (class_name_in_zip_dir, "./", 2) == 0) + { + class_name_in_zip_dir += 2; + filename_length -= 2; + } + + filename_length -= strlen (".class"); + class_name = XNEWVEC (char, filename_length + 1); + memcpy (class_name, class_name_in_zip_dir, filename_length); + class_name [filename_length] = '\0'; + + for (i = 0; i < filename_length; i++) + if (class_name[i] == '/') + class_name[i] = '.'; + + return class_name; +} + +/* Return 0 if we should skip this entry, 1 if it is a .class file, 2 + if it is a property file of some sort. */ +static int +classify_zip_file (struct ZipDirectory *zdir) +{ + char *class_name_in_zip_dir = ZIPDIR_FILENAME (zdir); + + if (zdir->filename_length > 6 + && !strncmp (&class_name_in_zip_dir[zdir->filename_length - 6], + ".class", 6)) + return 1; + + /* For now we drop the manifest, but not other information. */ + if (zdir->filename_length == 20 + && !strncmp (class_name_in_zip_dir, "META-INF/MANIFEST.MF", 20)) + return 0; + + /* Drop directory entries. */ + if (zdir->filename_length > 0 + && class_name_in_zip_dir[zdir->filename_length - 1] == '/') + return 0; + + return 2; +} + +/* Process all class entries found in the zip file. */ +static void +parse_zip_file_entries (void) +{ + struct ZipDirectory *zdir; + int i; + + for (i = 0, zdir = (ZipDirectory *)localToFile->central_directory; + i < localToFile->count; i++, zdir = ZIPDIR_NEXT (zdir)) + { + tree klass; + + switch (classify_zip_file (zdir)) + { + case 0: + continue; + + case 1: + { + char *class_name = compute_class_name (zdir); + int previous_alias_set = -1; + klass = lookup_class (get_identifier (class_name)); + FREE (class_name); + current_jcf = TYPE_JCF (klass); + output_class = current_class = klass; + + /* This is a dummy class, and now we're compiling it for + real. */ + gcc_assert (! TYPE_DUMMY (klass)); + + /* This is for a corner case where we have a superclass + but no superclass fields. + + This can happen if we earlier failed to lay out this + class because its superclass was still in the process + of being laid out; this occurs when we have recursive + class dependencies via inner classes. We must record + the previous alias set and restore it after laying out + the class. + + FIXME: this really is a kludge. We should figure out a + way to lay out the class properly before this + happens. */ + if (TYPE_SIZE (klass) && CLASSTYPE_SUPER (klass) + && integer_zerop (TYPE_SIZE (klass))) + { + TYPE_SIZE (klass) = NULL_TREE; + previous_alias_set = TYPE_ALIAS_SET (klass); + TYPE_ALIAS_SET (klass) = -1; + } + + if (! CLASS_LOADED_P (klass)) + { + if (! CLASS_PARSED_P (klass)) + { + read_zip_member (current_jcf, zdir, localToFile); + jcf_parse (current_jcf); + } + layout_class (current_class); + load_inner_classes (current_class); + } + + if (previous_alias_set != -1) + TYPE_ALIAS_SET (klass) = previous_alias_set; + + if (TYPE_SIZE (current_class) != error_mark_node) + { + parse_class_file (); + free (current_jcf->buffer); /* No longer necessary */ + /* Note: there is a way to free this buffer right after a + class seen in a zip file has been parsed. The idea is the + set its jcf in such a way that buffer will be reallocated + the time the code for the class will be generated. FIXME. */ + } + } + break; + + case 2: + { + char *file_name, *class_name_in_zip_dir, *buffer; + JCF *jcf; + file_name = XNEWVEC (char, zdir->filename_length + 1); + class_name_in_zip_dir = ZIPDIR_FILENAME (zdir); + strncpy (file_name, class_name_in_zip_dir, zdir->filename_length); + file_name[zdir->filename_length] = '\0'; + jcf = XNEW (JCF); + JCF_ZERO (jcf); + jcf->read_state = finput; + jcf->filbuf = jcf_filbuf_from_stdio; + jcf->classname = NULL; + jcf->filename = file_name; + jcf->zipd = zdir; + + if (read_zip_member (jcf, zdir, localToFile) < 0) + fatal_error ("error while reading %s from zip file", file_name); + + buffer = XNEWVEC (char, zdir->filename_length + 1 + + (jcf->buffer_end - jcf->buffer)); + strcpy (buffer, file_name); + /* This is not a typo: we overwrite the trailing \0 of the + file name; this is just how the data is laid out. */ + memcpy (buffer + zdir->filename_length, + jcf->buffer, jcf->buffer_end - jcf->buffer); + + compile_resource_data (file_name, buffer, + jcf->buffer_end - jcf->buffer); + JCF_FINISH (jcf); + free (jcf); + free (buffer); + } + break; + + default: + gcc_unreachable (); + } + } +} + +/* Read all the entries of the zip file, creates a class and a JCF. Sets the + jcf up for further processing and link it to the created class. */ + +static void +process_zip_dir (FILE *finput) +{ + int i; + ZipDirectory *zdir; + + for (i = 0, zdir = (ZipDirectory *)localToFile->central_directory; + i < localToFile->count; i++, zdir = ZIPDIR_NEXT (zdir)) + { + char *class_name, *file_name, *class_name_in_zip_dir; + tree klass; + JCF *jcf; + + class_name_in_zip_dir = ZIPDIR_FILENAME (zdir); + + /* Here we skip non-class files; we handle them later. */ + if (classify_zip_file (zdir) != 1) + continue; + + class_name = compute_class_name (zdir); + file_name = XNEWVEC (char, zdir->filename_length+1); + jcf = ggc_alloc_cleared_JCF (); + + strncpy (file_name, class_name_in_zip_dir, zdir->filename_length); + file_name [zdir->filename_length] = '\0'; + + klass = lookup_class (get_identifier (class_name)); + + if (CLASS_FROM_CURRENTLY_COMPILED_P (klass)) + { + /* We've already compiled this class. */ + duplicate_class_warning (file_name); + continue; + } + /* This function is only called when processing a zip file seen + on the command line. */ + CLASS_FROM_CURRENTLY_COMPILED_P (klass) = 1; + + jcf->read_state = finput; + jcf->filbuf = jcf_filbuf_from_stdio; + jcf->classname = class_name; + jcf->filename = file_name; + jcf->zipd = zdir; + + TYPE_JCF (klass) = jcf; + } +} + +#include "gt-java-jcf-parse.h" +#include "gtype-java.h" diff --git a/gcc/java/jcf-path.c b/gcc/java/jcf-path.c new file mode 100644 index 000000000..16ec65538 --- /dev/null +++ b/gcc/java/jcf-path.c @@ -0,0 +1,517 @@ +/* Handle CLASSPATH, -classpath, and path searching. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, + 2007, 2008, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Tom Tromey <tromey@cygnus.com>, October 1998. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" + +#include <dirent.h> + +#include "jcf.h" + +#ifndef DIR_UP +#define DIR_UP ".." +#endif + + + +/* Possible flag values. */ +#define FLAG_SYSTEM 1 +#define FLAG_ZIP 2 + +/* We keep linked lists of directory names. A ``directory'' can be + either an ordinary directory or a .zip file. */ +struct entry +{ + char *name; + int flags; + struct entry *next; +}; + +static void free_entry (struct entry **); +static void append_entry (struct entry **, struct entry *); +static void add_entry (struct entry **, const char *, int); +static void add_path (struct entry **, const char *, int); + +/* We support several different ways to set the class path. + + built-in system directory (only libgcj.jar) + CLASSPATH environment variable + -classpath option overrides $CLASSPATH + -CLASSPATH option is a synonym for -classpath (for compatibility) + -bootclasspath overrides built-in + -extdirs sets the extensions directory path (overrides built-in) + -I prepends path to list + + We implement this by keeping several path lists, and then simply + ignoring the ones which are not relevant. */ + +/* This holds all the -I directories. */ +static struct entry *include_dirs; + +/* This holds the CLASSPATH environment variable. */ +static struct entry *classpath_env; + +/* This holds the -classpath command-line option. */ +static struct entry *classpath_user; + +/* This holds the default directories. Some of these will have the + "system" flag set. */ +static struct entry *sys_dirs; + +/* This holds the extensions path entries. */ +static struct entry *extensions; + +/* This is the sealed list. It is just a combination of other lists. */ +static struct entry *sealed; + +/* We keep track of the longest path we've seen. */ +static int longest_path = 0; + + + +static void +free_entry (struct entry **entp) +{ + struct entry *e, *n; + + for (e = *entp; e; e = n) + { + n = e->next; + free (e->name); + free (e); + } + *entp = NULL; +} + +static void +append_entry (struct entry **entp, struct entry *ent) +{ + /* It doesn't matter if this is slow, since it is run only at + startup, and then infrequently. */ + struct entry *e; + + /* Find end of list. */ + for (e = *entp; e && e->next; e = e->next) + ; + + if (e) + e->next = ent; + else + *entp = ent; +} + +static void +add_entry (struct entry **entp, const char *filename, int is_system) +{ + int len; + struct entry *n; + + n = XNEW (struct entry); + n->flags = is_system ? FLAG_SYSTEM : 0; + n->next = NULL; + + len = strlen (filename); + + if (len > 4 && (FILENAME_CMP (filename + len - 4, ".zip") == 0 + || FILENAME_CMP (filename + len - 4, ".jar") == 0)) + { + n->flags |= FLAG_ZIP; + /* If the user uses -classpath then he'll have to include + libgcj.jar in the value. We check for this in a simplistic + way. Symlinks will fool this test. This is only used for + -MM and -MMD, so it probably isn't terribly important. */ + if (! FILENAME_CMP (filename, LIBGCJ_ZIP_FILE)) + n->flags |= FLAG_SYSTEM; + } + + /* Note that we add a trailing separator to `.zip' names as well. + This is a little hack that lets the searching code in jcf-io.c + work more easily. Eww. */ + if (! IS_DIR_SEPARATOR (filename[len - 1])) + { + char *f2 = (char *) alloca (len + 2); + strcpy (f2, filename); + f2[len] = DIR_SEPARATOR; + f2[len + 1] = '\0'; + n->name = xstrdup (f2); + ++len; + } + else + n->name = xstrdup (filename); + + if (len > longest_path) + longest_path = len; + + append_entry (entp, n); +} + +static void +add_path (struct entry **entp, const char *cp, int is_system) +{ + const char *startp, *endp; + + if (cp) + { + char *buf = (char *) alloca (strlen (cp) + 3); + startp = endp = cp; + while (1) + { + if (! *endp || *endp == PATH_SEPARATOR) + { + if (endp == startp) + { + buf[0] = '.'; + buf[1] = DIR_SEPARATOR; + buf[2] = '\0'; + } + else + { + strncpy (buf, startp, endp - startp); + buf[endp - startp] = '\0'; + } + add_entry (entp, buf, is_system); + if (! *endp) + break; + ++endp; + startp = endp; + } + else + ++endp; + } + } +} + +static int init_done = 0; + +/* Initialize the path module. */ +void +jcf_path_init (void) +{ + char *cp; + char *attempt, sep[2]; + struct stat stat_b; + int found = 0, len; + + if (init_done) + return; + init_done = 1; + + sep[0] = DIR_SEPARATOR; + sep[1] = '\0'; + + cp = getenv ("GCC_EXEC_PREFIX"); + if (cp) + { + attempt = (char *) alloca (strlen (cp) + 50); + /* The exec prefix can be something like + /usr/local/bin/../lib/gcc-lib/. We want to change this + into a pointer to the share/java directory. We support two + configurations: one where prefix and exec-prefix are the + same, and one where exec-prefix is `prefix/SOMETHING'. */ + strcpy (attempt, cp); + strcat (attempt, DIR_UP); + strcat (attempt, sep); + strcat (attempt, DIR_UP); + strcat (attempt, sep); + len = strlen (attempt); + + strcpy (attempt + len, "share"); + strcat (attempt, sep); + strcat (attempt, "java"); + strcat (attempt, sep); + strcat (attempt, "libgcj-" DEFAULT_TARGET_VERSION ".jar"); + if (! stat (attempt, &stat_b)) + { + add_entry (&sys_dirs, attempt, 1); + found = 1; + strcpy (&attempt[strlen (attempt) + - strlen ("libgcj-" DEFAULT_TARGET_VERSION ".jar")], + sep); + strcat (attempt, "ext"); + strcat (attempt, sep); + if (! stat (attempt, &stat_b)) + jcf_path_extdirs_arg (attempt); + } + else + { + strcpy (attempt + len, DIR_UP); + strcat (attempt, sep); + strcat (attempt, "share"); + strcat (attempt, sep); + strcat (attempt, "java"); + strcat (attempt, sep); + strcat (attempt, "libgcj-" DEFAULT_TARGET_VERSION ".jar"); + if (! stat (attempt, &stat_b)) + { + add_entry (&sys_dirs, attempt, 1); + found = 1; + strcpy (&attempt[strlen (attempt) + - strlen ("libgcj-" DEFAULT_TARGET_VERSION ".jar")], + sep); + strcat (attempt, "ext"); + strcat (attempt, sep); + if (! stat (attempt, &stat_b)) + jcf_path_extdirs_arg (attempt); + } + } + } + if (! found) + { + /* Desperation: use the installed one. */ + char *extdirs; + add_entry (&sys_dirs, LIBGCJ_ZIP_FILE, 1); + extdirs = (char *) alloca (strlen (LIBGCJ_ZIP_FILE) + 1); + strcpy (extdirs, LIBGCJ_ZIP_FILE); + strcpy (&extdirs[strlen (LIBGCJ_ZIP_FILE) + - strlen ("libgcj-" DEFAULT_TARGET_VERSION ".jar")], + "ext"); + strcat (extdirs, sep); + if (! stat (extdirs, &stat_b)) + jcf_path_extdirs_arg (extdirs); + } + + cp = getenv ("CLASSPATH"); + add_path (&classpath_env, cp, 0); +} + +/* Call this when -classpath is seen on the command line. + This overrides only the $CLASSPATH environment variable. + */ +void +jcf_path_classpath_arg (const char *path) +{ + free_entry (&classpath_user); + add_path (&classpath_user, path, 0); +} + +/* Call this when -bootclasspath is seen on the command line. + */ +void +jcf_path_bootclasspath_arg (const char *path) +{ + free_entry (&sys_dirs); + add_path (&sys_dirs, path, 1); +} + +/* Call this when -extdirs is seen on the command line. + */ +void +jcf_path_extdirs_arg (const char *cp) +{ + const char *startp, *endp; + + free_entry (&extensions); + + if (cp) + { + char *buf = (char *) alloca (strlen (cp) + 3); + startp = endp = cp; + while (1) + { + if (! *endp || *endp == PATH_SEPARATOR) + { + if (endp == startp) + return; + + strncpy (buf, startp, endp - startp); + buf[endp - startp] = '\0'; + + { + DIR *dirp = NULL; + int dirname_length = strlen (buf); + + dirp = opendir (buf); + if (dirp == NULL) + return; + + for (;;) + { + struct dirent *direntp = readdir (dirp); + + if (!direntp) + break; + + if (direntp->d_name[0] != '.') + { + char *name = (char *) alloca (dirname_length + + strlen (direntp->d_name) + 2); + strcpy (name, buf); + if (! IS_DIR_SEPARATOR (name[dirname_length-1])) + { + name[dirname_length] = DIR_SEPARATOR; + name[dirname_length+1] = 0; + } + strcat (name, direntp->d_name); + add_entry (&extensions, name, 0); + } + } + if (dirp) + closedir (dirp); + } + + if (! *endp) + break; + ++endp; + startp = endp; + } + else + ++endp; + } + } +} + +/* Call this when -I is seen on the command line. */ +void +jcf_path_include_arg (const char *path) +{ + add_entry (&include_dirs, path, 0); +} + +/* We `seal' the path by linking everything into one big list. Then + we provide a way to iterate through the sealed list. If PRINT is + true then we print the final class path to stderr. */ +void +jcf_path_seal (int print) +{ + struct entry *secondary; + + sealed = include_dirs; + include_dirs = NULL; + + if (classpath_user) + { + secondary = classpath_user; + classpath_user = NULL; + } + else + { + if (! classpath_env) + add_entry (&classpath_env, ".", 0); + + secondary = classpath_env; + classpath_env = NULL; + } + + + free_entry (&classpath_user); + free_entry (&classpath_env); + + append_entry (&sealed, secondary); + append_entry (&sealed, sys_dirs); + append_entry (&sealed, extensions); + sys_dirs = NULL; + extensions = NULL; + + if (print) + { + struct entry *ent; + fprintf (stderr, "Class path starts here:\n"); + for (ent = sealed; ent; ent = ent->next) + { + fprintf (stderr, " %s", ent->name); + if ((ent->flags & FLAG_SYSTEM)) + fprintf (stderr, " (system)"); + if ((ent->flags & FLAG_ZIP)) + fprintf (stderr, " (zip)"); + fprintf (stderr, "\n"); + } + } +} + +void * +jcf_path_start (void) +{ + return (void *) sealed; +} + +void * +jcf_path_next (void *x) +{ + struct entry *ent = (struct entry *) x; + return (void *) ent->next; +} + +static const char +PATH_SEPARATOR_STR[] = {PATH_SEPARATOR, '\0'}; + +char * +jcf_path_compute (const char *prefix) +{ + struct entry *iter; + char *result; + int length = strlen (prefix) + 1; + int first; + + for (iter = sealed; iter != NULL; iter = iter->next) + length += strlen (iter->name) + 1; + + result = (char *) xmalloc (length); + strcpy (result, prefix); + first = 1; + for (iter = sealed; iter != NULL; iter = iter->next) + { + if (! first) + strcat (result, PATH_SEPARATOR_STR); + first = 0; + strcat (result, iter->name); + /* Ugly: we want to strip the '/' from zip entries when + computing a string classpath. */ + if ((iter->flags & FLAG_ZIP) != 0) + result[strlen (result) - 1] = '\0'; + } + + return result; +} + +/* We guarantee that the return path will either be a zip file, or it + will end with a directory separator. */ +char * +jcf_path_name (void *x) +{ + struct entry *ent = (struct entry *) x; + return ent->name; +} + +int +jcf_path_is_zipfile (void *x) +{ + struct entry *ent = (struct entry *) x; + return (ent->flags & FLAG_ZIP); +} + +int +jcf_path_is_system (void *x) +{ + struct entry *ent = (struct entry *) x; + return (ent->flags & FLAG_SYSTEM); +} + +int +jcf_path_max_len (void) +{ + return longest_path; +} diff --git a/gcc/java/jcf-reader.c b/gcc/java/jcf-reader.c new file mode 100644 index 000000000..315bd411a --- /dev/null +++ b/gcc/java/jcf-reader.c @@ -0,0 +1,523 @@ +/* This file read a Java(TM) .class file. + It is not stand-alone: It depends on tons of macros, and the + intent is you #include this file after you've defined the macros. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, + 2007, 2008, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +#include "ggc.h" +#include "jcf.h" +#include "zipfile.h" + +static int get_attribute (JCF *, int, jv_attr_type); +static int jcf_parse_preamble (JCF *); +static int jcf_parse_constant_pool (JCF *); +static void jcf_parse_class (JCF *); +static int jcf_parse_fields (JCF *); +static int jcf_parse_one_method (JCF *, int); +static int jcf_parse_methods (JCF *); +static int jcf_parse_final_attributes (JCF *); +#ifdef NEED_PEEK_ATTRIBUTE +static int peek_attribute (JCF *, int, const char *, int); +#endif +#ifdef NEED_SKIP_ATTRIBUTE +static void skip_attribute (JCF *, int); +#endif + +/* Go through all available attribute (ATTRIBUTE_NUMER) and try to + identify PEEKED_NAME. Return 1 if PEEKED_NAME was found, 0 + otherwise. JCF is restored to its initial position before + returning. */ + +#ifdef NEED_PEEK_ATTRIBUTE /* Not everyone uses this function */ +static int +peek_attribute (JCF *jcf, int attribute_number, const char *peeked_name, + int peeked_name_length) +{ + int to_return = 0; + long absolute_offset = (long)JCF_TELL (jcf); + int i; + + for (i = 0; !to_return && i < attribute_number; i++) + { + uint16 attribute_name = (JCF_FILL (jcf, 6), JCF_readu2 (jcf)); + uint32 attribute_length = JCF_readu4 (jcf); + int name_length; + const unsigned char *name_data; + + JCF_FILL (jcf, (long) attribute_length); + if (attribute_name <= 0 || attribute_name >= JPOOL_SIZE(jcf) + || JPOOL_TAG (jcf, attribute_name) != CONSTANT_Utf8) + continue; + + name_length = JPOOL_UTF_LENGTH (jcf, attribute_name); + name_data = JPOOL_UTF_DATA (jcf, attribute_name); + + if (name_length == peeked_name_length + && ! memcmp (name_data, peeked_name, peeked_name_length)) + { + to_return = 1; + break; + } + + JCF_SKIP (jcf, attribute_length); + } + + JCF_SEEK (jcf, absolute_offset); + return to_return; +} +#endif + +#ifdef NEED_SKIP_ATTRIBUTE /* Not everyone uses this function */ +static void +skip_attribute (JCF *jcf, int number_of_attribute) +{ + while (number_of_attribute--) + { + JCF_u4 N; + JCF_FILL (jcf, 6); + (void) JCF_readu2 (jcf); + N = JCF_readu4 (jcf); + JCF_SKIP (jcf, N); + } +} +#endif + +static int +get_attribute (JCF *jcf, int index, + jv_attr_type attr_type ATTRIBUTE_UNUSED) +{ + uint16 attribute_name = (JCF_FILL (jcf, 6), JCF_readu2 (jcf)); + uint32 attribute_length = JCF_readu4 (jcf); + uint32 start_pos = JCF_TELL(jcf); + int name_length; + const unsigned char *name_data; + JCF_FILL (jcf, (long) attribute_length); + if (attribute_name <= 0 || attribute_name >= JPOOL_SIZE(jcf)) + return -2; + if (JPOOL_TAG (jcf, attribute_name) != CONSTANT_Utf8) + return -2; + name_length = JPOOL_UTF_LENGTH (jcf, attribute_name); + name_data = JPOOL_UTF_DATA (jcf, attribute_name); + +#define MATCH_ATTRIBUTE(S) \ + (name_length == sizeof (S)-1 && memcmp (name_data, S, sizeof (S)-1) == 0) + +#ifdef IGNORE_ATTRIBUTE + if (IGNORE_ATTRIBUTE (jcf, attribute_name, attribute_length)) + { + JCF_SKIP (jcf, attribute_length); + } + else +#endif +#ifdef HANDLE_SOURCEFILE + if (MATCH_ATTRIBUTE ("SourceFile")) + { + uint16 sourcefile_index = JCF_readu2 (jcf); + HANDLE_SOURCEFILE(sourcefile_index); + } + else +#endif +#ifdef HANDLE_CONSTANTVALUE + if (MATCH_ATTRIBUTE ("ConstantValue")) + { + uint16 constantvalue_index = JCF_readu2 (jcf); + if (constantvalue_index <= 0 || constantvalue_index >= JPOOL_SIZE(jcf)) + return -2; + HANDLE_CONSTANTVALUE(constantvalue_index); + } + else +#endif +#ifdef HANDLE_CODE_ATTRIBUTE + if (MATCH_ATTRIBUTE ("Code")) + { + uint16 j; + uint16 max_stack ATTRIBUTE_UNUSED = JCF_readu2 (jcf); + uint16 max_locals ATTRIBUTE_UNUSED = JCF_readu2 (jcf); + uint32 code_length = JCF_readu4 (jcf); + uint16 exception_table_length, attributes_count; + if (code_length + 12 > attribute_length) + return -1; + HANDLE_CODE_ATTRIBUTE(max_stack, max_locals, code_length); + JCF_SKIP (jcf, code_length); + exception_table_length = JCF_readu2 (jcf); + if (code_length + 8 * exception_table_length + 12 > attribute_length) + return -1; +#ifdef HANDLE_EXCEPTION_TABLE + HANDLE_EXCEPTION_TABLE (jcf->read_ptr, exception_table_length); +#endif + JCF_SKIP (jcf, 2 * 4 * exception_table_length); + attributes_count = JCF_readu2 (jcf); + for (j = 0; j < attributes_count; j++) + { + int code = get_attribute (jcf, index, JV_METHOD_ATTR); + if (code != 0) + return code; + } + } + else +#endif /* HANDLE_CODE_ATTRIBUTE */ +#ifdef HANDLE_EXCEPTIONS_ATTRIBUTE + if (MATCH_ATTRIBUTE ("Exceptions")) + { + uint16 count = JCF_readu2 (jcf); + HANDLE_EXCEPTIONS_ATTRIBUTE (count); + } + else +#endif +#ifdef HANDLE_LINENUMBERTABLE_ATTRIBUTE + if (MATCH_ATTRIBUTE ("LineNumberTable")) + { + uint16 count = JCF_readu2 (jcf); + HANDLE_LINENUMBERTABLE_ATTRIBUTE (count); + } + else +#endif +#ifdef HANDLE_LOCALVARIABLETABLE_ATTRIBUTE + if (MATCH_ATTRIBUTE ("LocalVariableTable")) + { + uint16 count = JCF_readu2 (jcf); + HANDLE_LOCALVARIABLETABLE_ATTRIBUTE (count); + } + else +#endif +#ifdef HANDLE_LOCALVARIABLETYPETABLE_ATTRIBUTE + if (MATCH_ATTRIBUTE ("LocalVariableTypeTable")) + { + uint16 count = JCF_readu2 (jcf); + HANDLE_LOCALVARIABLETYPETABLE_ATTRIBUTE (count); + } + else +#endif +#ifdef HANDLE_INNERCLASSES_ATTRIBUTE + if (MATCH_ATTRIBUTE ("InnerClasses")) + { + uint16 count = JCF_readu2 (jcf); + HANDLE_INNERCLASSES_ATTRIBUTE (count); + } + else +#endif +#ifdef HANDLE_SYNTHETIC_ATTRIBUTE + if (MATCH_ATTRIBUTE ("Synthetic")) + { + HANDLE_SYNTHETIC_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_GCJCOMPILED_ATTRIBUTE + if (MATCH_ATTRIBUTE ("gnu.gcj.gcj-compiled")) + { + HANDLE_GCJCOMPILED_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_DEPRECATED_ATTRIBUTE + if (MATCH_ATTRIBUTE ("Deprecated")) + { + HANDLE_DEPRECATED_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE + if (MATCH_ATTRIBUTE ("SourceDebugExtension")) /* JSR 45 */ + { + HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE (attribute_length); + } + else +#endif +#ifdef HANDLE_ENCLOSINGMETHOD_ATTRIBUTE + if (MATCH_ATTRIBUTE ("EnclosingMethod")) + { + HANDLE_ENCLOSINGMETHOD_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_SIGNATURE_ATTRIBUTE + if (MATCH_ATTRIBUTE ("Signature")) + { + HANDLE_SIGNATURE_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE + if (MATCH_ATTRIBUTE ("RuntimeVisibleAnnotations")) + { + HANDLE_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE + if (MATCH_ATTRIBUTE ("RuntimeInvisibleAnnotations")) + { + HANDLE_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE + if (MATCH_ATTRIBUTE ("RuntimeVisibleParameterAnnotations")) + { + HANDLE_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE + if (MATCH_ATTRIBUTE ("RuntimeInvisibleParameterAnnotations")) + { + HANDLE_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE (); + } + else +#endif +#ifdef HANDLE_ANNOTATIONDEFAULT_ATTRIBUTE + if (MATCH_ATTRIBUTE ("AnnotationDefault")) + { + HANDLE_ANNOTATIONDEFAULT_ATTRIBUTE (); + } + else +#endif + { +#ifdef PROCESS_OTHER_ATTRIBUTE + PROCESS_OTHER_ATTRIBUTE(jcf, attribute_name, attribute_length); +#else + JCF_SKIP (jcf, attribute_length); +#endif + } + if ((long) (start_pos + attribute_length) != JCF_TELL(jcf)) + return -1; + return 0; +} + +/* Read and handle the pre-amble. */ +static int +jcf_parse_preamble (JCF* jcf) +{ + uint32 magic = (JCF_FILL (jcf, 8), JCF_readu4 (jcf)); + uint16 minor_version ATTRIBUTE_UNUSED = JCF_readu2 (jcf); + uint16 major_version ATTRIBUTE_UNUSED = JCF_readu2 (jcf); +#ifdef HANDLE_MAGIC + HANDLE_MAGIC (magic, minor_version, major_version); +#endif + if (magic != 0xcafebabe) + return -1; + else + return 0; +} + +/* Read and handle the constant pool. + + Return 0 if OK. + Return -2 if a bad cross-reference (index of other constant) was seen. +*/ +static int +jcf_parse_constant_pool (JCF* jcf) +{ + int i, n; + JPOOL_SIZE (jcf) = (JCF_FILL (jcf, 2), JCF_readu2 (jcf)); + jcf->cpool.tags = (uint8 *) ggc_alloc_atomic (JPOOL_SIZE (jcf)); + jcf->cpool.data = ggc_alloc_cpool_entry (sizeof (jword) * JPOOL_SIZE (jcf)); + jcf->cpool.tags[0] = 0; +#ifdef HANDLE_START_CONSTANT_POOL + HANDLE_START_CONSTANT_POOL (JPOOL_SIZE (jcf)); +#endif + for (i = 1; i < (int) JPOOL_SIZE (jcf); i++) + { + int constant_kind; + + /* Make sure at least 9 bytes are available. This is enough + for all fixed-sized constant pool entries (so we don't need many + more JCF_FILL calls below), but is is small enough that + we are guaranteed to not hit EOF (in a valid .class file). */ + JCF_FILL (jcf, 9); + constant_kind = JCF_readu (jcf); + jcf->cpool.tags[i] = constant_kind; + switch (constant_kind) + { + case CONSTANT_String: + case CONSTANT_Class: + jcf->cpool.data[i].w = JCF_readu2 (jcf); + break; + case CONSTANT_Fieldref: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + case CONSTANT_NameAndType: + jcf->cpool.data[i].w = JCF_readu2 (jcf); + jcf->cpool.data[i].w |= JCF_readu2 (jcf) << 16; + break; + case CONSTANT_Integer: + case CONSTANT_Float: + jcf->cpool.data[i].w = JCF_readu4 (jcf); + break; + case CONSTANT_Long: + case CONSTANT_Double: + jcf->cpool.data[i].w = JCF_readu4 (jcf); + i++; /* These take up two spots in the constant pool */ + jcf->cpool.tags[i] = 0; + jcf->cpool.data[i].w = JCF_readu4 (jcf); + break; + case CONSTANT_Utf8: + n = JCF_readu2 (jcf); + JCF_FILL (jcf, n); +#ifdef HANDLE_CONSTANT_Utf8 + HANDLE_CONSTANT_Utf8(jcf, i, n); +#else + jcf->cpool.data[i].w = JCF_TELL(jcf) - 2; + JCF_SKIP (jcf, n); +#endif + break; + default: + return i; + } + } + return 0; +} + +/* Read various class flags and numbers. */ + +static void +jcf_parse_class (JCF* jcf) +{ + int i; + uint16 interfaces_count; + JCF_FILL (jcf, 8); + jcf->access_flags = JCF_readu2 (jcf); + jcf->this_class = JCF_readu2 (jcf); + jcf->super_class = JCF_readu2 (jcf); + interfaces_count = JCF_readu2 (jcf); + +#ifdef HANDLE_CLASS_INFO + HANDLE_CLASS_INFO(jcf->access_flags, jcf->this_class, jcf->super_class, interfaces_count); +#endif + + JCF_FILL (jcf, 2 * interfaces_count); + + /* Read interfaces. */ + for (i = 0; i < interfaces_count; i++) + { + uint16 index ATTRIBUTE_UNUSED = JCF_readu2 (jcf); +#ifdef HANDLE_CLASS_INTERFACE + HANDLE_CLASS_INTERFACE (index); +#endif + } +} + +/* Read fields. */ +static int +jcf_parse_fields (JCF* jcf) +{ + int i, j; + uint16 fields_count; + JCF_FILL (jcf, 2); + fields_count = JCF_readu2 (jcf); + +#ifdef HANDLE_START_FIELDS + HANDLE_START_FIELDS (fields_count); +#endif + for (i = 0; i < fields_count; i++) + { + uint16 access_flags = (JCF_FILL (jcf, 8), JCF_readu2 (jcf)); + uint16 name_index = JCF_readu2 (jcf); + uint16 signature_index = JCF_readu2 (jcf); + uint16 attribute_count = JCF_readu2 (jcf); +#ifdef HANDLE_START_FIELD + HANDLE_START_FIELD (access_flags, name_index, signature_index, + attribute_count); +#endif + for (j = 0; j < attribute_count; j++) + { + int code = get_attribute (jcf, i, JV_FIELD_ATTR); + if (code != 0) + return code; + } +#ifdef HANDLE_END_FIELD + HANDLE_END_FIELD (); +#endif + } +#ifdef HANDLE_END_FIELDS + HANDLE_END_FIELDS (); +#endif + return 0; +} + +/* Read methods. */ + +static int +jcf_parse_one_method (JCF* jcf, int index) +{ + int i; + uint16 access_flags = (JCF_FILL (jcf, 8), JCF_readu2 (jcf)); + uint16 name_index = JCF_readu2 (jcf); + uint16 signature_index = JCF_readu2 (jcf); + uint16 attribute_count = JCF_readu2 (jcf); +#ifdef HANDLE_METHOD + HANDLE_METHOD(access_flags, name_index, signature_index, attribute_count); +#endif + for (i = 0; i < attribute_count; i++) + { + int code = get_attribute (jcf, index, JV_METHOD_ATTR); + if (code != 0) + return code; + } +#ifdef HANDLE_END_METHOD + HANDLE_END_METHOD (); +#endif + return 0; +} + +static int +jcf_parse_methods (JCF* jcf) +{ + int i; + uint16 methods_count; + JCF_FILL (jcf, 2); + methods_count = JCF_readu2 (jcf); +#ifdef HANDLE_START_METHODS + HANDLE_START_METHODS (methods_count); +#endif + for (i = 0; i < methods_count; i++) + { + int code = jcf_parse_one_method (jcf, i); + if (code != 0) + return code; + } +#ifdef HANDLE_END_METHODS + HANDLE_END_METHODS (); +#endif + return 0; +} + +/* Read attributes. */ +static int +jcf_parse_final_attributes (JCF *jcf) +{ + int i; + uint16 attributes_count = (JCF_FILL (jcf, 2), JCF_readu2 (jcf)); +#ifdef START_FINAL_ATTRIBUTES + START_FINAL_ATTRIBUTES (attributes_count) +#endif + for (i = 0; i < attributes_count; i++) + { + int code = get_attribute (jcf, i, JV_CLASS_ATTR); + if (code != 0) + return code; + } + return 0; +} + diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h new file mode 100644 index 000000000..b066b2967 --- /dev/null +++ b/gcc/java/jcf.h @@ -0,0 +1,310 @@ +/* Utility macros to read Java(TM) .class files and byte codes. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */ + +#ifndef GCC_JCF_H +#define GCC_JCF_H +#include "javaop.h" + +#ifndef JCF_u4 +#define JCF_u4 unsigned long +#endif +#ifndef JCF_u2 +#define JCF_u2 unsigned short +#endif + +#define ALLOC xmalloc +#define REALLOC xrealloc +#ifndef FREE +#define FREE(PTR) free(PTR) +#endif + +#ifdef JCF_word +#define JCF_word JCF_u4 +#endif + +/* On case-insensitive file systems, we need to ensure that a request + to open a .java or .class file is honored only if the file to be + opened is of the exact case we are asking for. In other words, we + want to override the inherent case insensitivity of the underlying + file system. On other platforms, this macro becomes the vanilla + open() call. + + If you want to add another host, add your define to the list below + (i.e. defined(WIN32) || defined(YOUR_HOST)) and add a host-specific + .c file to Make-lang.in similar to win32-host.c. */ +#if defined(WIN32) +extern int +jcf_open_exact_case (const char* filename, int oflag); +#define JCF_OPEN_EXACT_CASE(X, Y) jcf_open_exact_case (X, Y) +#else +#define JCF_OPEN_EXACT_CASE open +#endif /* WIN32 */ + +struct JCF; +typedef int (*jcf_filbuf_t) (struct JCF*, int needed); + +union GTY((variable_size)) cpool_entry { + jword GTY ((tag ("0"))) w; + tree GTY ((tag ("1"))) t; +}; + +#define cpool_entry_is_tree(tag) \ + (tag & CONSTANT_ResolvedFlag) || tag == CONSTANT_Utf8 + +typedef struct GTY(()) CPool { + /* Available number of elements in the constants array, before it + must be re-allocated. */ + int capacity; + + /* The constant_pool_count. */ + int count; + + uint8* GTY((length ("%h.count"))) tags; + + union cpool_entry * GTY((length ("%h.count"), + desc ("cpool_entry_is_tree (%1.tags%a)"))) data; +} CPool; + +struct ZipDirectory; + +/* JCF encapsulates the state of reading a Java Class File. */ + +typedef struct GTY(()) JCF { + unsigned char * GTY ((skip)) buffer; + unsigned char * GTY ((skip)) buffer_end; + unsigned char * GTY ((skip)) read_ptr; + unsigned char * GTY ((skip)) read_end; + unsigned int right_zip : 1; + unsigned int finished : 1; + jcf_filbuf_t filbuf; + PTR GTY ((skip)) read_state; + const char *filename; + const char *classname; + /* Directory entry where it was found. */ + struct ZipDirectory * GTY ((skip)) zipd; + JCF_u2 access_flags; + JCF_u2 this_class; + JCF_u2 super_class; + CPool cpool; +} JCF; +/*typedef JCF* JCF_FILE;*/ + +#define JCF_SEEN_IN_ZIP(JCF) ((JCF)->zipd != NULL) + +/* The CPOOL macros take a (pointer to a) CPool. + The JPOOL macros take a (pointer to a) JCF. + Some of the latter should perhaps be deprecated or removed. */ + +#define CPOOL_COUNT(CPOOL) ((CPOOL)->count) +#define JPOOL_SIZE(JCF) CPOOL_COUNT(&(JCF)->cpool) +#define JPOOL_TAG(JCF, INDEX) ((JCF)->cpool.tags[INDEX]) +/* The INDEX'th constant pool entry as a JCF_u4. */ +#define CPOOL_UINT(CPOOL, INDEX) ((CPOOL)->data[INDEX].w) +#define JPOOL_UINT(JCF, INDEX) CPOOL_UINT(&(JCF)->cpool, INDEX) /*deprecated*/ +/* The first uint16 of the INDEX'th constant pool entry. */ +#define CPOOL_USHORT1(CPOOL, INDEX) ((CPOOL)->data[INDEX].w & 0xFFFF) +#define JPOOL_USHORT1(JCF, INDEX) CPOOL_USHORT1(&(JCF)->cpool, INDEX) +/* The second uint16 of the INDEX'th constant pool entry. */ +#define CPOOL_USHORT2(CPOOL, INDEX) ((CPOOL)->data[INDEX].w >> 16) +#define JPOOL_USHORT2(JCF, INDEX) CPOOL_USHORT2(&(JCF)->cpool, INDEX) +#define JPOOL_LONG(JCF, INDEX) \ + WORDS_TO_LONG (JPOOL_UINT(JCF, INDEX), JPOOL_UINT(JCF, (INDEX)+1)) +#define JPOOL_DOUBLE(JCF, INDEX) \ + WORDS_TO_DOUBLE (JPOOL_UINT(JCF, INDEX), JPOOL_UINT(JCF, (INDEX)+1)) +#ifndef JPOOL_UTF_LENGTH +#define JPOOL_UTF_LENGTH(JCF, INDEX) \ + GET_u2 ((JCF)->buffer+JPOOL_UINT(JCF, INDEX)) +#endif +#ifndef JPOOL_UTF_DATA +#define JPOOL_UTF_DATA(JCF, INDEX) \ + ((JCF)->buffer+JPOOL_UINT(JCF, INDEX)+2) +#endif +#define JPOOL_INT(JCF, INDEX) (WORD_TO_INT(JPOOL_UINT (JCF, INDEX))) +#define JPOOL_FLOAT(JCF, INDEX) WORD_TO_FLOAT (JPOOL_UINT (JCF, INDEX)) + +#define CPOOL_INDEX_IN_RANGE(CPOOL, INDEX) \ + ((INDEX) > 0 && (INDEX) < CPOOL_COUNT(CPOOL)) + +#define CPOOL_FINISH(CPOOL) { \ + (CPOOL)->tags = 0; \ + (CPOOL)->data = 0; \ + } + +#define JCF_FINISH(JCF) { \ + CPOOL_FINISH(&(JCF)->cpool); \ + if ((JCF)->buffer) free ((JCF)->buffer); \ + if ((JCF)->filename) free (CONST_CAST (char *, (JCF)->filename)); \ + if ((JCF)->classname) free (CONST_CAST (char *, (JCF)->classname)); \ + (JCF)->finished = 1; } + +#define CPOOL_INIT(CPOOL) \ + ((CPOOL)->capacity = 0, (CPOOL)->count = 0, (CPOOL)->tags = 0, (CPOOL)->data = 0) + +#define CPOOL_REINIT(CPOOL) ((CPOOL)->count = 0) + +#define JCF_ZERO(JCF) \ + ((JCF)->buffer = (JCF)->buffer_end = (JCF)->read_ptr = (JCF)->read_end = 0,\ + (JCF)->read_state = 0, (JCF)->filename = (JCF)->classname = 0, \ + CPOOL_INIT(&(JCF)->cpool), (JCF)->zipd = 0, \ + (JCF)->finished = 0) + +/* Given that PTR points to a 2-byte unsigned integer in network + (big-endian) byte-order, return that integer. */ +#define GET_u2(PTR) (((PTR)[0] << 8) | ((PTR)[1])) +/* Like GET_u2, but for little-endian format. */ +#define GET_u2_le(PTR) (((PTR)[1] << 8) | ((PTR)[0])) + +/* Given that PTR points to a 4-byte unsigned integer in network + (big-endian) byte-order, return that integer. */ +#define GET_u4(PTR) (((JCF_u4)(PTR)[0] << 24) | ((JCF_u4)(PTR)[1] << 16) \ + | ((JCF_u4)(PTR)[2] << 8) | ((JCF_u4)(PTR)[3])) +/* Like GET_u4, but for little-endian order. */ +#define GET_u4_le(PTR) (((JCF_u4)(PTR)[3] << 24) | ((JCF_u4)(PTR)[2] << 16) \ + | ((JCF_u4)(PTR)[1] << 8) | ((JCF_u4)(PTR)[0])) + +/* Make sure there are COUNT bytes readable. */ +#define JCF_FILL(JCF, COUNT) \ + ((JCF)->read_end-(JCF)->read_ptr >= (COUNT) ? 0 : (*(JCF)->filbuf)(JCF, COUNT)) +#define JCF_GETC(JCF) (JCF_FILL(JCF, 1) ? -1 : *(JCF)->read_ptr++) +#define JCF_READ(JCF, BUFFER, N) \ + (memcpy (BUFFER, (JCF)->read_ptr, N), (JCF)->read_ptr += (N)) +#define JCF_SKIP(JCF,N) ((JCF)->read_ptr += (N)) +#define JCF_readu(JCF) (*(JCF)->read_ptr++) + +/* Reads an unsigned 2-byte integer in network (big-endian) byte-order + from JCF. Returns that integer. + Does not check for EOF (make sure to call JCF_FILL before-hand). */ +#define JCF_readu2(JCF) ((JCF)->read_ptr += 2, GET_u2 ((JCF)->read_ptr-2)) +#define JCF_readu2_le(JCF) ((JCF)->read_ptr += 2, GET_u2_le((JCF)->read_ptr-2)) + +/* Like JCF_readu2, but read a 4-byte unsigned integer. */ +#define JCF_readu4(JCF) ((JCF)->read_ptr += 4, GET_u4 ((JCF)->read_ptr-4)) +#define JCF_readu4_le(JCF) ((JCF)->read_ptr += 4, GET_u4_le((JCF)->read_ptr-4)) + +#define JCF_TELL(JCF) ((JCF)->read_ptr - (JCF)->buffer) +#define JCF_SEEK(JCF, POS) ((JCF)->read_ptr = (JCF)->buffer + (POS)) + +#define ACC_PUBLIC 0x0001 +#define ACC_PRIVATE 0x0002 +#define ACC_PROTECTED 0x0004 +#define ACC_STATIC 0x0008 +#define ACC_FINAL 0x0010 +#define ACC_SYNCHRONIZED 0x0020 +#define ACC_SUPER 0x0020 +#define ACC_BRIDGE 0x0040 +#define ACC_VOLATILE 0x0040 +#define ACC_TRANSIENT 0x0080 +#define ACC_VARARGS 0x0080 +#define ACC_NATIVE 0x0100 +#define ACC_INTERFACE 0x0200 +#define ACC_ABSTRACT 0x0400 +#define ACC_STRICT 0x0800 +#define ACC_SYNTHETIC 0x01000 +#define ACC_ANNOTATION 0x02000 +#define ACC_ENUM 0x04000 +/* "Invisible" refers to Miranda methods inserted into an abstract + class. It is also used in the runtime. */ +#define ACC_INVISIBLE 0x8000 + +#define ACC_VISIBILITY (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED) + +enum cpool_tag +{ + CONSTANT_Class = 7, + CONSTANT_Fieldref = 9, + CONSTANT_Methodref = 10, + CONSTANT_InterfaceMethodref = 11, + CONSTANT_String = 8, + CONSTANT_Integer = 3, + CONSTANT_Float = 4, + CONSTANT_Long = 5, + CONSTANT_Double = 6, + CONSTANT_NameAndType = 12, + CONSTANT_Utf8 = 1, + CONSTANT_Unicode = 2, + CONSTANT_None = 0 +}; + +#define DEFAULT_CLASS_PATH "." + +extern const char *find_class (const char *, int, JCF *); +extern const char *find_classfile (char *, JCF*, const char *); +extern int jcf_filbuf_from_stdio (JCF *jcf, int count); +extern int jcf_unexpected_eof (JCF*, int) ATTRIBUTE_NORETURN; + +/* Extract a character from a Java-style Utf8 string. + * PTR points to the current character. + * LIMIT points to the end of the Utf8 string. + * PTR is incremented to point after the character that gets returned. + * On an error, -1 is returned. */ +#define UTF8_GET(PTR, LIMIT) \ + ((PTR) >= (LIMIT) ? -1 \ + : *(PTR) < 128 ? *(PTR)++ \ + : (*(PTR)&0xE0) == 0xC0 && ((PTR)+=2)<=(LIMIT) && ((PTR)[-1]&0xC0) == 0x80 \ + ? (((PTR)[-2] & 0x1F) << 6) + ((PTR)[-1] & 0x3F) \ + : (*(PTR) & 0xF0) == 0xE0 && ((PTR) += 3) <= (LIMIT) \ + && ((PTR)[-2] & 0xC0) == 0x80 && ((PTR)[-1] & 0xC0) == 0x80 \ + ? (((PTR)[-3]&0x0F) << 12) + (((PTR)[-2]&0x3F) << 6) + ((PTR)[-1]&0x3F) \ + : ((PTR)++, -1)) + +extern const char *jcf_write_base_directory; + +/* Debug macros, for the front end */ + +#ifdef VERBOSE_SKELETON +#undef SOURCE_FRONTEND_DEBUG +#define SOURCE_FRONTEND_DEBUG(X) \ + {if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} } +#else +#define SOURCE_FRONTEND_DEBUG(X) +#endif + +/* Declarations for dependency code. */ +extern void jcf_dependency_reset (void); +extern void jcf_dependency_set_target (const char *); +extern void jcf_dependency_add_target (const char *); +extern void jcf_dependency_set_dep_file (const char *); +extern void jcf_dependency_add_file (const char *, int); +extern void jcf_dependency_write (void); +extern void jcf_dependency_init (int); +extern void jcf_dependency_print_dummies (void); + +/* Declarations for path handling code. */ +extern void jcf_path_init (void); +extern void jcf_path_classpath_arg (const char *); +extern void jcf_path_bootclasspath_arg (const char *); +extern void jcf_path_extdirs_arg (const char *); +extern void jcf_path_include_arg (const char *); +extern void jcf_path_seal (int); +extern void *jcf_path_start (void); +extern void *jcf_path_next (void *); +extern char *jcf_path_name (void *); +extern char *jcf_path_compute (const char *); +extern int jcf_path_is_zipfile (void *); +extern int jcf_path_is_system (void *); +extern int jcf_path_max_len (void); + +#endif /* ! GCC_JCF_H */ diff --git a/gcc/java/jvgenmain.c b/gcc/java/jvgenmain.c new file mode 100644 index 000000000..128c8ec59 --- /dev/null +++ b/gcc/java/jvgenmain.c @@ -0,0 +1,187 @@ +/* Program to generate "main" a Java(TM) class containing a main method. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com> */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "obstack.h" +#include "jcf.h" +#include "tree.h" +#include "java-tree.h" +#include "intl.h" +#include "tm.h" /* FIXME: For gcc_obstack_init from defaults.h. */ + +static char * do_mangle_classname (const char *string); + +struct obstack name_obstack; +struct obstack *mangle_obstack = &name_obstack; + +static void usage (const char *) ATTRIBUTE_NORETURN; + +static void +usage (const char *name) +{ + fprintf (stderr, _("Usage: %s [OPTIONS]... CLASSNAMEmain [OUTFILE]\n"), + name); + exit (1); +} + +int +main (int argc, char **argv) +{ + char *classname, *p; + FILE *stream; + const char *mangled_classname; + int i, last_arg; + int indirect = 0; + char *prog_name = argv[0]; + + /* Unlock the stdio streams. */ + unlock_std_streams (); + + gcc_init_libintl (); + + if (argc > 1 && ! strcmp (argv[1], "-findirect-dispatch")) + { + indirect = 1; + ++argv; + --argc; + } + + if (argc < 2) + usage (prog_name); + + for (i = 1; i < argc; ++i) + { + if (! strncmp (argv[i], "-D", 2)) + { + /* Handled later. Check "-D XXX=YYY". */ + if (argv[i][2] == '\0') + i++; + } + else + break; + } + + if (i < argc - 2 || i == argc) + usage (prog_name); + last_arg = i; + + classname = argv[i]; + + /* gcj always appends `main' to classname. We need to strip this here. */ + p = strrchr (classname, 'm'); + if (p == NULL || p == classname || strcmp (p, "main") != 0) + usage (prog_name); + else + *p = '\0'; + + gcc_obstack_init (mangle_obstack); + mangled_classname = do_mangle_classname (classname); + + if (i < argc - 1 && strcmp (argv[i + 1], "-") != 0) + { + const char *outfile = argv[i + 1]; + stream = fopen (outfile, "w"); + if (stream == NULL) + { + fprintf (stderr, _("%s: Cannot open output file: %s\n"), + prog_name, outfile); + exit (1); + } + } + else + stream = stdout; + + /* At this point every element of ARGV from 1 to LAST_ARG is a `-D' + option. Process them appropriately. */ + fprintf (stream, "extern const char **_Jv_Compiler_Properties;\n"); + fprintf (stream, "static const char *props[] =\n{\n"); + for (i = 1; i < last_arg; ++i) + { + const char *p; + + if (strcmp (argv[i], "-D") == 0) + continue; + + fprintf (stream, " \""); + for (p = argv[i]; *p; ++p) + { + if (! ISPRINT (*p)) + fprintf (stream, "\\%o", *p); + else if (*p == '\\' || *p == '"') + fprintf (stream, "\\%c", *p); + else + putc (*p, stream); + } + fprintf (stream, "\",\n"); + } + fprintf (stream, " 0\n};\n\n"); + + fprintf (stream, "int main (int argc, const char **argv)\n"); + fprintf (stream, "{\n"); + fprintf (stream, " _Jv_Compiler_Properties = props;\n"); + if (indirect) + fprintf (stream, " JvRunMainName (\"%s\", argc, argv);\n", classname); + else + { + fprintf (stream, " extern char %s;\n", mangled_classname); + fprintf (stream, " JvRunMain (&%s, argc, argv);\n", mangled_classname); + } + fprintf (stream, "}\n"); + if (stream != stdout && fclose (stream) != 0) + { + fprintf (stderr, _("%s: Failed to close output file %s\n"), + prog_name, argv[2]); + exit (1); + } + return 0; +} + + +static char * +do_mangle_classname (const char *string) +{ + const char *ptr; + int count = 0; + + obstack_grow (&name_obstack, "_ZN", 3); + + for (ptr = string; *ptr; ptr++ ) + { + if (*ptr == '.') + { + append_gpp_mangled_name (ptr - count, count); + count = 0; + } + else + count++; + } + append_gpp_mangled_name (&ptr [-count], count); + obstack_grow (mangle_obstack, "6class$E", strlen ("6class$E")); + obstack_1grow (mangle_obstack, '\0'); + return XOBFINISH (mangle_obstack, char *); +} diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c new file mode 100644 index 000000000..c7762422f --- /dev/null +++ b/gcc/java/jvspec.c @@ -0,0 +1,644 @@ +/* Specific flags and argument handling of the front-end of the + GNU compiler for the Java(TM) language. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "gcc.h" +#include "jcf.h" +#include "opts.h" + +/* Name of spec file. */ +#define SPEC_FILE "libgcj.spec" + +/* This bit is set if we saw a `-xfoo' language specification. */ +#define LANGSPEC (1<<1) +/* True if this arg is a .java input file name. */ +#define JAVA_FILE_ARG (1<<3) +/* True if this arg is a .class input file name. */ +#define CLASS_FILE_ARG (1<<4) +/* True if this arg is a .zip or .jar input file name. */ +#define ZIP_FILE_ARG (1<<5) +/* True if this arg is @FILE - where FILE contains a list of filenames. */ +#define INDIRECT_FILE_ARG (1<<6) +/* True if this arg is a resource file. */ +#define RESOURCE_FILE_ARG (1<<7) + +static char *find_spec_file (const char *); +static int verify_class_name (const char *); + +static const char *main_class_name = NULL; +int lang_specific_extra_outfiles = 0; + +/* True if we should add -shared-libgcc to the command-line. */ +int shared_libgcc = 1; + +static const char jvgenmain_spec[] = + "jvgenmain %{findirect-dispatch} %{D*} %b %m.i |\n\ + cc1 %m.i %1 \ + %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*}\ + %{g*} %{O*} \ + %{v:-version} %{pg:-p} %{p}\ + %<fbounds-check %<fno-bounds-check\ + %<fassume-compiled* %<fno-assume-compiled*\ + %<fcompile-resource* %<fassert %<fno-assert \ + %<femit-class-file %<femit-class-files %<fencoding*\ + %<fuse-boehm-gc %<fhash-synchronization %<fjni\ + %<findirect-dispatch\ + %<fno-store-check %<foutput-class-dir\ + %<fclasspath* %<fbootclasspath*\ + %<fextdirs*\ + %<fuse-divide-subroutine %<fno-use-divide-subroutine\ + %<fuse-atomic-builtins %<fno-use-atomic-builtins\ + %<fcheck-references %<fno-check-references\ + %<ffilelist-file %<fsaw-java-file %<fsource* %<ftarget*\ + %{f*} -fdollars-in-identifiers\ + %{aux-info*}\ + %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ + %{S:%W{o*}%{!o*:-o %b.s}}\ + %(invoke_as)"; + +/* Return full path name of spec file if it is in DIR, or NULL if + not. */ +static char * +find_spec_file (const char *dir) +{ + char *spec; + struct stat sb; + + spec = XNEWVEC (char, strlen (dir) + sizeof (SPEC_FILE) + 4); + strcpy (spec, dir); + strcat (spec, "/"); + strcat (spec, SPEC_FILE); + if (! stat (spec, &sb)) + return spec; + free (spec); + return NULL; +} + +#define JAVA_START_CHAR_P(c) (c < 128 && (ISIDST (c) || c == '$')) +#define JAVA_PART_CHAR_P(c) (c < 128 \ + && (ISIDNUM (c) \ + || c == '$' \ + || (c >= 0x00 && c <= 0x08) \ + || (c >= 0x0e && c <= 0x1b) \ + || c == 0x7f)) + +/* Verify that NAME is a valid Java class name that might contain + `main'. Return 0 on failure. */ +static int +verify_class_name (const char *name) +{ + /* FIXME: what encoding do we use for command-line arguments? For + now we assume plain ASCII, which of course is wrong. */ + while (*name) + { + int ch = *name++; + if (ch < 0 || ! JAVA_START_CHAR_P (ch)) + return 0; + while (*name) + { + ch = *name++; + if (ch < 0) + return 0; + /* We found a break between class names. Next character + must be an identifier start again. */ + if (ch == '.') + break; + if (! JAVA_PART_CHAR_P (ch)) + return 0; + } + } + + return 1; +} + +void +lang_specific_driver (struct cl_decoded_option **in_decoded_options, + unsigned int *in_decoded_options_count, + int *in_added_libraries) +{ + unsigned int i, j; + + int saw_save_temps = 0; + + /* This will be 0 if we encounter a situation where we should not + link in libgcj. */ + int library = 1; + + /* This will be 1 if multiple input files (.class and/or .java) + should be passed to a single jc1 invocation. */ + int combine_inputs = 0; + + /* Number of .java and .class source file arguments seen. */ + int java_files_count = 0; + int class_files_count = 0; + /* Number of .zip or .jar file arguments seen. */ + int zip_files_count = 0; + /* Number of '@FILES' arguments seen. */ + int indirect_files_count = 0; + + /* Name of file containing list of files to compile. */ + char *filelist_filename = 0; + + FILE *filelist_file = 0; + + /* The number of arguments being added to what's in argv, other than + libraries. */ + int added = 2; + + /* The new argument list will be contained in this. */ + struct cl_decoded_option *new_decoded_options; + + /* Nonzero if we saw a `-xfoo' language specification on the + command line. Used to avoid adding our own -xc++ if the user + already gave a language for the file. */ + int saw_speclang = 0; + + /* Saw --resource, -C or -o options, respectively. */ + int saw_resource = 0; + int saw_C = 0; + int saw_o = 0; + + /* Saw some -O* or -g* option, respectively. */ + int saw_O = 0; + int saw_g = 0; + + /* Saw a `-D' option. */ + int saw_D = 0; + + /* An array used to flag each argument that needs a bit set for + LANGSPEC, MATHLIB, WITHLIBC, or GCLIB. */ + int *args; + + /* The total number of arguments with the new stuff. */ + unsigned int argc; + + /* The argument list. */ + struct cl_decoded_option *decoded_options; + + /* The number of libraries added in. */ + int added_libraries; + + /* The total number of arguments with the new stuff. */ + unsigned int num_args = 1; + + /* Nonzero if linking is supposed to happen. */ + int will_link = 1; + + /* Nonzero if we want to find the spec file. */ + int want_spec_file = 1; + + /* The argument we use to specify the spec file. */ + char *spec_file = NULL; + + /* If linking, nonzero if the BC-ABI is in use. */ + int link_for_bc_abi = 0; + + argc = *in_decoded_options_count; + decoded_options = *in_decoded_options; + added_libraries = *in_added_libraries; + + args = XCNEWVEC (int, argc); + + for (i = 1; i < argc; i++) + { + switch (decoded_options[i].opt_index) + { + case OPT_nostdlib: + case OPT_nodefaultlibs: + library = 0; + break; + + case OPT_fmain_: + main_class_name = decoded_options[i].arg; + added--; + break; + + case OPT__help: + want_spec_file = 0; + break; + + case OPT_v: + if (argc == 2) + { + /* If they only gave us `-v', don't try to link + in libgcj. */ + library = 0; + } + break; + + case OPT_x: + saw_speclang = 1; + break; + + case OPT_C: + saw_C = 1; + want_spec_file = 0; + if (library != 0) + added -= 2; + library = 0; + will_link = 0; + break; + + case OPT_fcompile_resource_: + saw_resource = 1; + want_spec_file = 0; + if (library != 0) + --added; + library = 0; + will_link = 0; + break; + + case OPT_D: + saw_D = 1; + break; + + case OPT_g: + case OPT_gcoff: + case OPT_gdwarf_: + case OPT_ggdb: + case OPT_gstabs: + case OPT_gstabs_: + case OPT_gvms: + case OPT_gxcoff: + case OPT_gxcoff_: + saw_g = 1; + break; + + case OPT_O: + case OPT_Os: + case OPT_Ofast: + saw_O = 1; + break; + + case OPT_o: + saw_o = 1; + break; + + case OPT_fclasspath_: + case OPT_fbootclasspath_: + case OPT_extdirs: + added -= 1; + break; + + case OPT_c: + case OPT_S: + case OPT_E: + case OPT_M: + case OPT_MM: + /* Don't specify libraries if we won't link, since that would + cause a warning. */ + library = 0; + added -= 2; + + /* Remember this so we can confirm -fmain option. */ + will_link = 0; + break; + + case OPT_fsyntax_only: + library = 0; + will_link = 0; + continue; + + case OPT_save_temps: + saw_save_temps = 1; + break; + + case OPT_static_libgcc: + case OPT_static: + shared_libgcc = 0; + break; + + case OPT_findirect_dispatch: + link_for_bc_abi = 1; + break; + + case OPT_SPECIAL_input_file: + { + const char *arg = decoded_options[i].arg; + int len; + + /* We don't do this anymore, since we don't get them with minus + signs on them. */ + if (arg[0] == '\0' || arg[1] == '\0') + continue; + + if (saw_speclang) + { + saw_speclang = 0; + continue; + } + + if (saw_resource) + { + args[i] |= RESOURCE_FILE_ARG; + added += 2; /* for -xjava and -xnone */ + } + + if (arg[0] == '@') + { + args[i] |= INDIRECT_FILE_ARG; + indirect_files_count++; + added += 2; /* for -xjava and -xnone */ + } + + len = strlen (arg); + if (len > 5 && strcmp (arg + len - 5, ".java") == 0) + { + args[i] |= JAVA_FILE_ARG; + java_files_count++; + } + if (len > 6 && strcmp (arg + len - 6, ".class") == 0) + { + args[i] |= CLASS_FILE_ARG; + class_files_count++; + } + if (len > 4 + && (strcmp (arg + len - 4, ".zip") == 0 + || strcmp (arg + len - 4, ".jar") == 0)) + { + args[i] |= ZIP_FILE_ARG; + zip_files_count++; + } + } + + default: + /* Pass other options through. */ + continue; + } + } + + if (saw_D && ! main_class_name) + fatal_error ("can%'t specify %<-D%> without %<--main%>"); + + if (main_class_name && ! verify_class_name (main_class_name)) + fatal_error ("%qs is not a valid class name", main_class_name); + + num_args = argc + added; + if (saw_resource) + { + if (! saw_o) + fatal_error ("--resource requires -o"); + } + if (saw_C) + { + num_args += 3; + if (class_files_count + zip_files_count > 0) + { + warning (0, "already-compiled .class files ignored with -C"); + num_args -= class_files_count + zip_files_count; + class_files_count = 0; + zip_files_count = 0; + } + num_args += 2; /* For -o NONE. */ + if (saw_o) + fatal_error ("cannot specify both -C and -o"); + } + if ((saw_o && java_files_count + class_files_count + zip_files_count > 1) + || (saw_C && java_files_count > 1) + || (indirect_files_count > 0 + && java_files_count + class_files_count + zip_files_count > 0)) + combine_inputs = 1; + + if (combine_inputs) + { + filelist_filename = make_temp_file ("jx"); + if (filelist_filename == NULL) + fatal_error ("cannot create temporary file"); + record_temp_file (filelist_filename, ! saw_save_temps, 0); + filelist_file = fopen (filelist_filename, "w"); + if (filelist_file == NULL) + pfatal_with_name (filelist_filename); + num_args -= java_files_count + class_files_count + zip_files_count; + num_args += 3; /* for the combined arg "-xjava", and "-xnone" */ + } + + if (main_class_name) + { + lang_specific_extra_outfiles++; + } + if (saw_g + saw_O == 0) + num_args++; + num_args++; + /* An additional entry for the classpath. */ + num_args++; + + if (combine_inputs || indirect_files_count > 0) + num_args += 1; /* for "-ffilelist-file" */ + if (combine_inputs && indirect_files_count > 0) + fatal_error ("using both @FILE with multiple files not implemented"); + + /* There's no point adding -shared-libgcc if we don't have a shared + libgcc. */ +#ifndef ENABLE_SHARED_LIBGCC + shared_libgcc = 0; +#endif + + if (java_files_count > 0) + ++num_args; + + num_args += shared_libgcc; + + num_args += link_for_bc_abi; + + new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args); + j = 0; + + new_decoded_options[j++] = decoded_options[0]; + + if (combine_inputs || indirect_files_count > 0) + generate_option (OPT_ffilelist_file, NULL, 1, CL_DRIVER, + &new_decoded_options[j++]); + + if (combine_inputs) + { + generate_option (OPT_x, "java", 1, CL_DRIVER, + &new_decoded_options[j++]); + generate_option_input_file (filelist_filename, + &new_decoded_options[j++]); + generate_option (OPT_x, "none", 1, CL_DRIVER, + &new_decoded_options[j++]); + } + + if (java_files_count > 0) + generate_option (OPT_fsaw_java_file, NULL, 1, CL_DRIVER, + &new_decoded_options[j++]); + + jcf_path_init (); + for (i = 1; i < argc; i++, j++) + { + new_decoded_options[j] = decoded_options[i]; + + if (decoded_options[i].errors & CL_ERR_MISSING_ARG) + continue; + + if ((args[i] & RESOURCE_FILE_ARG) != 0) + { + generate_option (OPT_x, "java", 1, CL_DRIVER, + &new_decoded_options[j++]); + new_decoded_options[j++] = decoded_options[i]; + generate_option (OPT_x, "none", 1, CL_DRIVER, + &new_decoded_options[j]); + } + + switch (decoded_options[i].opt_index) + { + case OPT_I: + jcf_path_include_arg (decoded_options[i].arg); + --j; + continue; + + case OPT_fclasspath_: + jcf_path_classpath_arg (decoded_options[i].arg); + --j; + continue; + + case OPT_fbootclasspath_: + jcf_path_bootclasspath_arg (decoded_options[i].arg); + --j; + continue; + + case OPT_extdirs: + jcf_path_extdirs_arg (decoded_options[i].arg); + --j; + continue; + + case OPT_L: + if (spec_file == NULL) + spec_file = find_spec_file (decoded_options[i].arg); + break; + + case OPT_fmain_: + if (! will_link) + fatal_error ("cannot specify %<main%> class when not linking"); + --j; + continue; + } + + if ((args[i] & INDIRECT_FILE_ARG) != 0) + { + generate_option (OPT_x, "java", 1, CL_DRIVER, + &new_decoded_options[j++]); + /* Drop '@'. */ + generate_option_input_file (decoded_options[i].arg + 1, + &new_decoded_options[j++]); + generate_option (OPT_x, "none", 1, CL_DRIVER, + &new_decoded_options[j]); + } + + if ((args[i] & (CLASS_FILE_ARG|ZIP_FILE_ARG)) && saw_C) + { + --j; + continue; + } + + if (combine_inputs + && (args[i] & (CLASS_FILE_ARG|JAVA_FILE_ARG|ZIP_FILE_ARG)) != 0) + { + fputs (decoded_options[i].arg, filelist_file); + fputc ('\n', filelist_file); + --j; + continue; + } + } + + /* Handle classpath setting. We specify the bootclasspath since + that requires the fewest changes to our existing code... */ + jcf_path_seal (0); + generate_option (OPT_fbootclasspath_, jcf_path_compute (""), 1, + CL_DRIVER, &new_decoded_options[j++]); + + if (combine_inputs) + { + if (fclose (filelist_file)) + pfatal_with_name (filelist_filename); + } + + /* If we saw no -O or -g option, default to -g1, for javac compatibility. */ + if (saw_g + saw_O == 0) + generate_option (OPT_g, "1", 1, CL_DRIVER, &new_decoded_options[j++]); + + /* Read the specs file corresponding to libgcj. + If we didn't find the spec file on the -L path, then we hope it + is somewhere in the standard install areas. */ + if (want_spec_file) + generate_option (OPT_specs_, spec_file == NULL ? "libgcj.spec" : spec_file, + 1, CL_DRIVER, &new_decoded_options[j++]); + + if (saw_C) + { + generate_option (OPT_fsyntax_only, NULL, 1, CL_DRIVER, + &new_decoded_options[j++]); + generate_option (OPT_femit_class_files, NULL, 1, CL_DRIVER, + &new_decoded_options[j++]); + generate_option (OPT_S, NULL, 1, CL_DRIVER, &new_decoded_options[j++]); + generate_option (OPT_o, "NONE", 1, CL_DRIVER, + &new_decoded_options[j++]); + } + + if (shared_libgcc) + generate_option (OPT_shared_libgcc, NULL, 1, CL_DRIVER, + &new_decoded_options[j++]); + + if (link_for_bc_abi) + generate_option (OPT_s_bc_abi, NULL, 1, CL_DRIVER, + &new_decoded_options[j++]); + + *in_decoded_options_count = j; + *in_decoded_options = new_decoded_options; + *in_added_libraries = added_libraries; +} + +int +lang_specific_pre_link (void) +{ + int err; + if (main_class_name == NULL) + return 0; + /* Append `main' to make the filename unique and allow + + gcj --main=hello -save-temps hello.java + + to work. jvgenmain needs to strip this `main' to arrive at the correct + class name. Append dummy `.c' that can be stripped by set_input so %b + is correct. */ + set_input (concat (main_class_name, "main.c", NULL)); + err = do_spec (jvgenmain_spec); + if (err == 0) + { + /* Shift the outfiles array so the generated main comes first. + This is important when linking against (non-shared) libraries, + since otherwise we risk (a) nothing getting linked or + (b) 'main' getting picked up from a library. */ + int i = n_infiles; + const char *generated = outfiles[i]; + while (--i >= 0) + outfiles[i + 1] = outfiles[i]; + outfiles[0] = generated; + } + return err; +} diff --git a/gcc/java/lang-specs.h b/gcc/java/lang-specs.h new file mode 100644 index 000000000..87653bf52 --- /dev/null +++ b/gcc/java/lang-specs.h @@ -0,0 +1,63 @@ +/* Definitions for specs for the GNU compiler for the Java(TM) language. + Copyright (C) 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* This is the contribution to the `default_compilers' array in gcc.c for + Java. */ + + {".java", "@java" , 0, 0, 0}, + {".class", "@java" , 0, 0, 0}, + {".zip", "@java" , 0, 0, 0}, + {".jar", "@java" , 0, 0, 0}, + {"@java", + "%{fjni:%{femit-class-files:%e-fjni and -femit-class-files are incompatible}}\ + %{fjni:%{femit-class-file:%e-fjni and -femit-class-file are incompatible}}\ + %{femit-class-file:%{!fsyntax-only:%e-femit-class-file should used along with -fsyntax-only}}\ + %{femit-class-files:%{!fsyntax-only:%e-femit-class-file should used along with -fsyntax-only}}\ + %{E:%{e-E is not valid for gcj}}\ + %{.java|fsaw-java-file:ecj1 %i %{W*} %{w} %{g*} \ + %{fbootclasspath*} \ + %{fenable-assertions*} \ + %{fdisable-assertions*} \ + %{fencoding*} %{ffilelist-file} \ + %{foutput-class-dir*} %{g*} \ + %{fsource*} %{!fsource*:-fsource=1.5} \ + %{ftarget*} %{!femit-class-files|!ftarget*:-ftarget=1.5} \ + %{!findirect-dispatch:-fzip-dependency %U.zip} \ + %{!fsyntax-only:-fzip-target %U.jar}}\n \ + %{.class|.zip|.jar|!fsyntax-only:jc1 \ + %{.java|fsaw-java-file:%U.jar -fsource-filename=%i %<ffilelist-file} \ + %{.class|.zip|.jar|ffilelist-file|fcompile-resource*:%i} \ + %(jc1) %(cc1_options) %{I*} %{!findirect-dispatch:-faux-classpath %U.zip} \ + %{MD:-MD_} %{MMD:-MMD_} %{M} %{MM} %{MA} %{MT*} %{MF*}\ + %(invoke_as)}", + 0, 0, 0}, + + /* + FIXME: we don't use %|, even though we could, because we need the + dependency zip to be ready early enough. We could work around + this by not having a dependency zip and instead teaching jc1 to + read a special manifest file included in the sole zip, this + manifest would say which files are to be compiled and which are + not. + */ diff --git a/gcc/java/lang.c b/gcc/java/lang.c new file mode 100644 index 000000000..982474cc8 --- /dev/null +++ b/gcc/java/lang.c @@ -0,0 +1,920 @@ +/* Java(TM) language-specific utility routines. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2008, 2010, 2012 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "input.h" +#include "java-tree.h" +#include "jcf.h" +#include "langhooks.h" +#include "langhooks-def.h" +#include "flags.h" +#include "ggc.h" +#include "diagnostic.h" +#include "tree-inline.h" +#include "splay-tree.h" +#include "tree-dump.h" +#include "opts.h" +#include "options.h" +#include "target.h" + +static bool java_init (void); +static void java_finish (void); +static unsigned int java_option_lang_mask (void); +static void java_init_options_struct (struct gcc_options *); +static void java_init_options (unsigned int, struct cl_decoded_option *); +static bool java_post_options (const char **); + +static bool java_handle_option (size_t, const char *, int, int, location_t, + const struct cl_option_handlers *); +static void put_decl_string (const char *, int); +static void put_decl_node (tree, int); +static void java_print_error_function (diagnostic_context *, const char *, + diagnostic_info *); +static int merge_init_test_initialization (void * *, void *); +static int inline_init_test_initialization (void * *, void *); +static bool java_dump_tree (void *, tree); +static void dump_compound_expr (dump_info_p, tree); +static bool java_decl_ok_for_sibcall (const_tree); + +static enum classify_record java_classify_record (tree type); + +static tree java_eh_personality (void); + +#ifndef TARGET_OBJECT_SUFFIX +# define TARGET_OBJECT_SUFFIX ".o" +#endif + +/* Table of machine-independent attributes. */ +const struct attribute_spec java_attribute_table[] = +{ + { "nonnull", 0, -1, false, true, true, + NULL }, + { NULL, 0, 0, false, false, false, NULL } +}; + +/* Used to avoid printing error messages with bogus function + prototypes. Starts out false. */ +static bool inhibit_error_function_printing; + +const char *resource_name; + +/* When nonzero, -Wall was turned on. */ +int flag_wall = 0; + +/* When nonzero, report use of deprecated classes, methods, or fields. */ +int flag_deprecated = 1; + +/* When zero, don't optimize static class initialization. This flag shouldn't + be tested alone, use STATIC_CLASS_INITIALIZATION_OPTIMIZATION_P instead. */ +/* FIXME: Make this work with gimplify. */ +/* int flag_optimize_sci = 0; */ + +/* Don't attempt to verify invocations. */ +int flag_verify_invocations = 0; + +/* When nonzero, print extra version information. */ +static int v_flag = 0; + +JCF *current_jcf; + +/* Variable controlling how dependency tracking is enabled in + java_init. */ +static int dependency_tracking = 0; + +/* Flag values for DEPENDENCY_TRACKING. */ +#define DEPEND_SET_FILE 1 +#define DEPEND_ENABLE 2 +#define DEPEND_TARGET_SET 4 +#define DEPEND_FILE_ALREADY_SET 8 + +struct GTY(()) language_function { + int unused; +}; + +#undef LANG_HOOKS_NAME +#define LANG_HOOKS_NAME "GNU Java" +#undef LANG_HOOKS_INIT +#define LANG_HOOKS_INIT java_init +#undef LANG_HOOKS_FINISH +#define LANG_HOOKS_FINISH java_finish +#undef LANG_HOOKS_OPTION_LANG_MASK +#define LANG_HOOKS_OPTION_LANG_MASK java_option_lang_mask +#undef LANG_HOOKS_INIT_OPTIONS_STRUCT +#define LANG_HOOKS_INIT_OPTIONS_STRUCT java_init_options_struct +#undef LANG_HOOKS_INIT_OPTIONS +#define LANG_HOOKS_INIT_OPTIONS java_init_options +#undef LANG_HOOKS_HANDLE_OPTION +#define LANG_HOOKS_HANDLE_OPTION java_handle_option +#undef LANG_HOOKS_POST_OPTIONS +#define LANG_HOOKS_POST_OPTIONS java_post_options +#undef LANG_HOOKS_PARSE_FILE +#define LANG_HOOKS_PARSE_FILE java_parse_file +#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL +#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl +#undef LANG_HOOKS_DECL_PRINTABLE_NAME +#define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name +#undef LANG_HOOKS_PRINT_ERROR_FUNCTION +#define LANG_HOOKS_PRINT_ERROR_FUNCTION java_print_error_function +#undef LANG_HOOKS_WRITE_GLOBALS +#define LANG_HOOKS_WRITE_GLOBALS java_write_globals + +#undef LANG_HOOKS_TYPE_FOR_MODE +#define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode +#undef LANG_HOOKS_TYPE_FOR_SIZE +#define LANG_HOOKS_TYPE_FOR_SIZE java_type_for_size +#undef LANG_HOOKS_CLASSIFY_RECORD +#define LANG_HOOKS_CLASSIFY_RECORD java_classify_record + +#undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN +#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree + +#undef LANG_HOOKS_GIMPLIFY_EXPR +#define LANG_HOOKS_GIMPLIFY_EXPR java_gimplify_expr + +#undef LANG_HOOKS_DECL_OK_FOR_SIBCALL +#define LANG_HOOKS_DECL_OK_FOR_SIBCALL java_decl_ok_for_sibcall + +#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME +#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME java_mangle_decl + +#undef LANG_HOOKS_ATTRIBUTE_TABLE +#define LANG_HOOKS_ATTRIBUTE_TABLE java_attribute_table + +#undef LANG_HOOKS_EH_PERSONALITY +#define LANG_HOOKS_EH_PERSONALITY java_eh_personality + +#undef LANG_HOOKS_EH_USE_CXA_END_CLEANUP +#define LANG_HOOKS_EH_USE_CXA_END_CLEANUP true + +/* Each front end provides its own. */ +struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; + +/* + * process java-specific compiler command-line options + * return false, but do not complain if the option is not recognized. + */ +static bool +java_handle_option (size_t scode, const char *arg, int value, + int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED, + const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED) +{ + enum opt_code code = (enum opt_code) scode; + + switch (code) + { + case OPT_I: + jcf_path_include_arg (arg); + break; + + case OPT_M: + jcf_dependency_init (1); + dependency_tracking |= DEPEND_ENABLE; + break; + + case OPT_MD_: + jcf_dependency_init (1); + dependency_tracking |= DEPEND_SET_FILE | DEPEND_ENABLE; + break; + + case OPT_MF: + jcf_dependency_set_dep_file (arg); + dependency_tracking |= DEPEND_FILE_ALREADY_SET; + break; + + case OPT_MM: + jcf_dependency_init (0); + dependency_tracking |= DEPEND_ENABLE; + break; + + case OPT_MMD_: + jcf_dependency_init (0); + dependency_tracking |= DEPEND_SET_FILE | DEPEND_ENABLE; + break; + + case OPT_MP: + jcf_dependency_print_dummies (); + break; + + case OPT_MT: + jcf_dependency_set_target (arg); + dependency_tracking |= DEPEND_TARGET_SET; + break; + + case OPT_Wall: + flag_wall = value; + /* When -Wall given, enable -Wunused. We do this because the C + compiler does it, and people expect it. */ + warn_unused = value; + break; + + case OPT_fenable_assertions_: + add_enable_assert (arg, value); + break; + + case OPT_fenable_assertions: + add_enable_assert ("", value); + break; + + case OPT_fdisable_assertions_: + add_enable_assert (arg, !value); + break; + + case OPT_fdisable_assertions: + add_enable_assert ("", !value); + break; + + case OPT_fassume_compiled_: + add_assume_compiled (arg, !value); + break; + + case OPT_fassume_compiled: + add_assume_compiled ("", !value); + break; + + case OPT_fbootclasspath_: + jcf_path_bootclasspath_arg (arg); + break; + + case OPT_faux_classpath: + case OPT_fclasspath_: + jcf_path_classpath_arg (arg); + break; + + case OPT_fcompile_resource_: + resource_name = arg; + break; + + case OPT_fdump_: + if (!dump_switch_p (arg)) + return false; + break; + + case OPT_fencoding_: + /* Nothing. */ + break; + + case OPT_fextdirs_: + jcf_path_extdirs_arg (arg); + break; + + case OPT_foutput_class_dir_: + /* FIXME: remove; this is handled by ecj1 now. */ + break; + + case OPT_version: + v_flag = 1; + break; + + case OPT_fsource_filename_: + java_read_sourcefilenames (arg); + break; + + default: + if (cl_options[code].flags & CL_Java) + break; + gcc_unreachable (); + } + + return true; +} + +/* Global open file. */ +FILE *finput; + +static bool +java_init (void) +{ + /* FIXME: Indirect dispatch isn't yet compatible with static class + init optimization. */ + if (flag_indirect_dispatch) + always_initialize_class_p = true; + + if (!flag_indirect_dispatch) + flag_indirect_classes = false; + + jcf_path_seal (v_flag); + + java_init_decl_processing (); + + using_eh_for_cleanups (); + + return true; +} + +static void +java_finish (void) +{ + jcf_dependency_write (); +} + +/* Buffer used by lang_printable_name. */ +static char *decl_buf = NULL; + +/* Allocated size of decl_buf. */ +static int decl_buflen = 0; + +/* Length of used part of decl_buf; position for next character. */ +static int decl_bufpos = 0; + +/* Append the string STR to decl_buf. + It length is given by LEN; -1 means the string is nul-terminated. */ + +static void +put_decl_string (const char *str, int len) +{ + if (len < 0) + len = strlen (str); + if (decl_bufpos + len >= decl_buflen) + { + if (decl_buf == NULL) + { + decl_buflen = len + 100; + decl_buf = XNEWVEC (char, decl_buflen); + } + else + { + decl_buflen *= 2; + decl_buf = XRESIZEVAR (char, decl_buf, decl_buflen); + } + } + strcpy (decl_buf + decl_bufpos, str); + decl_bufpos += len; +} + +/* Append to decl_buf a printable name for NODE. + Depending on VERBOSITY, more information about NODE + is printed. Read the comments of decl_printable_name in + langhooks.h for more. */ + +static void +put_decl_node (tree node, int verbosity) +{ + int was_pointer = 0; + if (TREE_CODE (node) == POINTER_TYPE) + { + node = TREE_TYPE (node); + was_pointer = 1; + } + if (DECL_P (node) && DECL_NAME (node) != NULL_TREE) + { + if (TREE_CODE (node) == FUNCTION_DECL) + { + if (verbosity == 0 && DECL_NAME (node)) + /* We have been instructed to just print the bare name + of the function. */ + { + put_decl_node (DECL_NAME (node), 0); + return; + } + + /* We want to print the type the DECL belongs to. We don't do + that when we handle constructors. */ + if (! DECL_CONSTRUCTOR_P (node) + && ! DECL_ARTIFICIAL (node) && DECL_CONTEXT (node) + /* We want to print qualified DECL names only + if verbosity is higher than 1. */ + && verbosity >= 1) + { + put_decl_node (TREE_CODE (DECL_CONTEXT (node)) == FUNCTION_DECL + ? DECL_CONTEXT (node) + : TYPE_NAME (DECL_CONTEXT (node)), + verbosity); + put_decl_string (".", 1); + } + if (! DECL_CONSTRUCTOR_P (node)) + put_decl_node (DECL_NAME (node), verbosity); + if (TREE_TYPE (node) != NULL_TREE + /* We want to print function parameters only if verbosity + is higher than 2. */ + && verbosity >= 2) + { + int i = 0; + tree args = TYPE_ARG_TYPES (TREE_TYPE (node)); + if (TREE_CODE (TREE_TYPE (node)) == METHOD_TYPE) + args = TREE_CHAIN (args); + put_decl_string ("(", 1); + for ( ; args != end_params_node; args = TREE_CHAIN (args), i++) + { + if (i > 0) + put_decl_string (",", 1); + put_decl_node (TREE_VALUE (args), verbosity); + } + put_decl_string (")", 1); + } + } + else + put_decl_node (DECL_NAME (node), verbosity); + } + else if (TYPE_P (node) && TYPE_NAME (node) != NULL_TREE) + { + if (TREE_CODE (node) == RECORD_TYPE && TYPE_ARRAY_P (node) + /* Print detailed array information only if verbosity is higher + than 2. */ + && verbosity >= 2) + { + put_decl_node (TYPE_ARRAY_ELEMENT (node), verbosity); + put_decl_string("[]", 2); + } + else if (node == promoted_byte_type_node) + put_decl_string ("byte", 4); + else if (node == promoted_short_type_node) + put_decl_string ("short", 5); + else if (node == promoted_char_type_node) + put_decl_string ("char", 4); + else if (node == promoted_boolean_type_node) + put_decl_string ("boolean", 7); + else if (node == void_type_node && was_pointer) + put_decl_string ("null", 4); + else + put_decl_node (TYPE_NAME (node), verbosity); + } + else if (TREE_CODE (node) == IDENTIFIER_NODE) + put_decl_string (IDENTIFIER_POINTER (node), IDENTIFIER_LENGTH (node)); + else + put_decl_string ("<unknown>", -1); +} + +/* Return a user-friendly name for DECL. + The resulting string is only valid until the next call. + The value of the hook decl_printable_name is this function, + which is also called directly by java_print_error_function. */ + +const char * +lang_printable_name (tree decl, int v) +{ + decl_bufpos = 0; + put_decl_node (decl, v); + put_decl_string ("", 1); + return decl_buf; +} + +/* Print on stderr the current class and method context. This function + is the value of the hook print_error_function. */ + +static GTY(()) tree last_error_function_context; +static GTY(()) tree last_error_function; +static void +java_print_error_function (diagnostic_context *context ATTRIBUTE_UNUSED, + const char *file, + diagnostic_info *diagnostic ATTRIBUTE_UNUSED) +{ + /* Don't print error messages with bogus function prototypes. */ + if (inhibit_error_function_printing) + return; + + if (current_function_decl != NULL + && DECL_CONTEXT (current_function_decl) != last_error_function_context) + { + if (file) + fprintf (stderr, "%s: ", file); + + last_error_function_context = DECL_CONTEXT (current_function_decl); + fprintf (stderr, "In class '%s':\n", + lang_printable_name (last_error_function_context, 0)); + } + if (last_error_function != current_function_decl) + { + if (file) + fprintf (stderr, "%s: ", file); + + if (current_function_decl == NULL) + fprintf (stderr, "At top level:\n"); + else + { + const char *name = lang_printable_name (current_function_decl, 2); + fprintf (stderr, "In %s '%s':\n", + (DECL_CONSTRUCTOR_P (current_function_decl) ? "constructor" + : "method"), + name); + } + + last_error_function = current_function_decl; + } + +} + +/* Called to install the PRINT_ERROR_FUNCTION hook differently + according to LEVEL. LEVEL is 1 during early parsing, when function + prototypes aren't fully resolved. java_print_error_function is set + so it doesn't print incomplete function prototypes. When LEVEL is + 2, function prototypes are fully resolved and can be printed when + reporting errors. */ + +void +lang_init_source (int level) +{ + inhibit_error_function_printing = (level == 1); +} + +static unsigned int +java_option_lang_mask (void) +{ + return CL_Java; +} + +/* Initialize options structure OPTS. */ + +static void +java_init_options_struct (struct gcc_options *opts) +{ + opts->x_flag_bounds_check = 1; + opts->x_flag_exceptions = 1; + opts->x_flag_non_call_exceptions = 1; + + /* In Java floating point operations never trap. */ + opts->x_flag_trapping_math = 0; + opts->frontend_set_flag_trapping_math = true; + + /* In Java arithmetic overflow always wraps around. */ + opts->x_flag_wrapv = 1; + + /* Java requires left-to-right evaluation of subexpressions. */ + opts->x_flag_evaluation_order = 1; +} + +static void +java_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED, + struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED) +{ + jcf_path_init (); +} + +/* Post-switch processing. */ +static bool +java_post_options (const char **pfilename) +{ + const char *filename = *pfilename; + + /* Excess precision other than "fast" requires front-end + support. */ + if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD + && TARGET_FLT_EVAL_METHOD_NON_DEFAULT) + sorry ("-fexcess-precision=standard for Java"); + flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; + + /* An absolute requirement: if we're not using indirect dispatch, we + must always verify everything. */ + if (! flag_indirect_dispatch) + flag_verify_invocations = true; + + if (flag_reduced_reflection) + { + if (flag_indirect_dispatch) + error ("-findirect-dispatch is incompatible " + "with -freduced-reflection"); + if (flag_jni) + error ("-fjni is incompatible with -freduced-reflection"); + } + + /* Open input file. */ + + if (filename == 0 || !strcmp (filename, "-")) + { + finput = stdin; + filename = "stdin"; + + if (dependency_tracking) + error ("can%'t do dependency tracking with input from stdin"); + } + else + { + if (dependency_tracking) + { + const char *dot; + + /* If the target is set and the output filename is set, then + there's no processing to do here. Otherwise we must + compute one or the other. */ + if (! ((dependency_tracking & DEPEND_TARGET_SET) + && (dependency_tracking & DEPEND_FILE_ALREADY_SET))) + { + dot = strrchr (filename, '.'); + if (dot == NULL) + error ("couldn%'t determine target name for dependency tracking"); + else + { + char *buf = XNEWVEC (char, dot - filename + + 3 + sizeof (TARGET_OBJECT_SUFFIX)); + strncpy (buf, filename, dot - filename); + + /* If emitting class files, we might have multiple + targets. The class generation code takes care of + registering them. Otherwise we compute the + target name here. */ + if ((dependency_tracking & DEPEND_TARGET_SET)) + ; /* Nothing. */ + else + { + strcpy (buf + (dot - filename), TARGET_OBJECT_SUFFIX); + jcf_dependency_set_target (buf); + } + + if ((dependency_tracking & DEPEND_FILE_ALREADY_SET)) + ; /* Nothing. */ + else if ((dependency_tracking & DEPEND_SET_FILE)) + { + strcpy (buf + (dot - filename), ".d"); + jcf_dependency_set_dep_file (buf); + } + else + jcf_dependency_set_dep_file ("-"); + + free (buf); + } + } + } + } + linemap_add (line_table, LC_ENTER, false, filename, 0); + linemap_add (line_table, LC_RENAME, false, "<built-in>", 0); + + /* Initialize the compiler back end. */ + return false; +} + +/* Return either DECL or its known constant value (if it has one). */ + +tree +decl_constant_value (tree decl) +{ + if (/* Don't change a variable array bound or initial value to a constant + in a place where a variable is invalid. */ + current_function_decl != 0 + && ! TREE_THIS_VOLATILE (decl) + && TREE_READONLY (decl) + && DECL_INITIAL (decl) != 0 + && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK + /* This is invalid if initial value is not constant. + If it has either a function call, a memory reference, + or a variable, then re-evaluating it could give different results. */ + && TREE_CONSTANT (DECL_INITIAL (decl)) + /* Check for cases where this is sub-optimal, even though valid. */ + && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR) + return DECL_INITIAL (decl); + return decl; +} + +/* Every call to a static constructor has an associated boolean + variable which is in the outermost scope of the calling method. + This variable is used to avoid multiple calls to the static + constructor for each class. + + It looks something like this: + + foo () + { + boolean dummy = OtherClass.is_initialized; + + ... + + if (! dummy) + OtherClass.initialize(); + + ... use OtherClass.data ... + } + + Each of these boolean variables has an entry in the + DECL_FUNCTION_INIT_TEST_TABLE of a method. When inlining a method + we must merge the DECL_FUNCTION_INIT_TEST_TABLE from the function + being inlined and create the boolean variables in the outermost + scope of the method being inlined into. */ + +/* Create a mapping from a boolean variable in a method being inlined + to one in the scope of the method being inlined into. */ + +static int +merge_init_test_initialization (void **entry, void *x) +{ + struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + splay_tree decl_map = (splay_tree)x; + splay_tree_node n; + tree *init_test_decl; + + /* See if we have remapped this declaration. If we haven't there's + a bug in the inliner. */ + n = splay_tree_lookup (decl_map, (splay_tree_key) ite->value); + gcc_assert (n); + + /* Create a new entry for the class and its remapped boolean + variable. If we already have a mapping for this class we've + already initialized it, so don't overwrite the value. */ + init_test_decl = java_treetreehash_new + (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), ite->key); + if (!*init_test_decl) + *init_test_decl = (tree)n->value; + + /* This fixes a weird case. + + The front end assumes that once we have called a method that + initializes some class, we can assume the class is initialized. It + does this by setting the DECL_INITIAL of the init_test_decl for that + class, and no initializations are emitted for that class. + + However, what if the method that is supposed to do the initialization + is itself inlined in the caller? When expanding the called method + we'll assume that the class initialization has already been done, + because the DECL_INITIAL of the init_test_decl is set. + + To fix this we remove the DECL_INITIAL (in the caller scope) of all + the init_test_decls corresponding to classes initialized by the + inlined method. This makes the caller no longer assume that the + method being inlined does any class initializations. */ + DECL_INITIAL (*init_test_decl) = NULL; + + return true; +} + +/* Merge the DECL_FUNCTION_INIT_TEST_TABLE from the function we're + inlining. */ + +void +java_inlining_merge_static_initializers (tree fn, void *decl_map) +{ + htab_traverse + (DECL_FUNCTION_INIT_TEST_TABLE (fn), + merge_init_test_initialization, decl_map); +} + +/* Lookup a DECL_FUNCTION_INIT_TEST_TABLE entry in the method we're + inlining into. If we already have a corresponding entry in that + class we don't need to create another one, so we create a mapping + from the variable in the inlined class to the corresponding + pre-existing one. */ + +static int +inline_init_test_initialization (void **entry, void *x) +{ + struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + splay_tree decl_map = (splay_tree)x; + + tree h = java_treetreehash_find + (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), ite->key); + if (! h) + return true; + splay_tree_insert (decl_map, + (splay_tree_key) ite->value, + (splay_tree_value) h); + return true; +} + +/* Look up the boolean variables in the DECL_FUNCTION_INIT_TEST_TABLE + of a method being inlined. For each hone, if we already have a + variable associated with the same class in the method being inlined + into, create a new mapping for it. */ + +void +java_inlining_map_static_initializers (tree fn, void *decl_map) +{ + htab_traverse + (DECL_FUNCTION_INIT_TEST_TABLE (fn), + inline_init_test_initialization, decl_map); +} + +/* Avoid voluminous output for deep recursion of compound exprs. */ + +static void +dump_compound_expr (dump_info_p di, tree t) +{ + int i; + + for (i=0; i<2; i++) + { + switch (TREE_CODE (TREE_OPERAND (t, i))) + { + case COMPOUND_EXPR: + dump_compound_expr (di, TREE_OPERAND (t, i)); + break; + + default: + dump_child ("expr", TREE_OPERAND (t, i)); + } + } +} + +static bool +java_dump_tree (void *dump_info, tree t) +{ + enum tree_code code; + dump_info_p di = (dump_info_p) dump_info; + + /* Figure out what kind of node this is. */ + code = TREE_CODE (t); + + switch (code) + { + case FUNCTION_DECL: + dump_child ("args", DECL_ARGUMENTS (t)); + if (DECL_EXTERNAL (t)) + dump_string (di, "undefined"); + if (TREE_PUBLIC (t)) + dump_string (di, "extern"); + else + dump_string (di, "static"); + if (DECL_LANG_SPECIFIC (t) && !dump_flag (di, TDF_SLIM, t)) + dump_child ("inline body", DECL_SAVED_TREE (t)); + return true; + + case RETURN_EXPR: + dump_child ("expr", TREE_OPERAND (t, 0)); + return true; + + case GOTO_EXPR: + dump_child ("goto", TREE_OPERAND (t, 0)); + return true; + + case LABEL_EXPR: + dump_child ("label", TREE_OPERAND (t, 0)); + return true; + + case BLOCK: + if (BLOCK_EXPR_BODY (t)) + { + tree local = BLOCK_VARS (t); + while (local) + { + tree next = TREE_CHAIN (local); + dump_child ("var", local); + local = next; + } + + { + tree block = BLOCK_EXPR_BODY (t); + dump_child ("body", block); + block = TREE_CHAIN (block); + } + } + return true; + + case COMPOUND_EXPR: + if (!dump_flag (di, TDF_SLIM, t)) + return false; + dump_compound_expr (di, t); + return true; + + default: + break; + } + return false; +} + +/* Java calls can't, in general, be sibcalls because we need an + accurate stack trace in order to guarantee correct operation of + methods such as Class.forName(String) and + SecurityManager.getClassContext(). */ + +static bool +java_decl_ok_for_sibcall (const_tree decl) +{ + return (decl != NULL && DECL_CONTEXT (decl) == output_class + && !DECL_UNINLINABLE (decl)); +} + +static enum classify_record +java_classify_record (tree type) +{ + if (! CLASS_P (type)) + return RECORD_IS_STRUCT; + + if (CLASS_INTERFACE (TYPE_NAME (type))) + return RECORD_IS_INTERFACE; + + return RECORD_IS_CLASS; +} + +static GTY(()) tree java_eh_personality_decl; + +static tree +java_eh_personality (void) +{ + if (!java_eh_personality_decl) + java_eh_personality_decl = build_personality_function ("gcj"); + return java_eh_personality_decl; +} + +#include "gt-java-lang.h" diff --git a/gcc/java/lang.opt b/gcc/java/lang.opt new file mode 100644 index 000000000..b0383be90 --- /dev/null +++ b/gcc/java/lang.opt @@ -0,0 +1,452 @@ +; Options for the Java front end. +; Copyright (C) 2003, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. +; +; This file is part of GCC. +; +; GCC is free software; you can redistribute it and/or modify it under +; the terms of the GNU General Public License as published by the Free +; Software Foundation; either version 3, or (at your option) any later +; version. +; +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY +; WARRANTY; without even the implied warranty of MERCHANTABILITY or +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +; for more details. +; +; You should have received a copy of the GNU General Public License +; along with GCC; see the file COPYING3. If not see +; <http://www.gnu.org/licenses/>. + +; See the GCC internals manual for a description of this file's format. + +; Please try to keep this file in ASCII collating order. + +Language +Java + +-CLASSPATH +Java Separate Alias(fclasspath=) + +-all-warnings +Java Alias(Wall) + +-bootclasspath +Java Separate Alias(fbootclasspath=) + +-classpath +Java Separate Alias(fclasspath=) + +-dependencies +Java Alias(M) + +-encoding +Java Separate Alias(fencoding=) + +-extdirs +Java Separate Alias(fextdirs=) + +-include-directory +Java Separate Alias(I) + +-include-directory= +Java Joined Alias(I) + +-output-class-directory +Java Separate Alias(foutput-class-dir=) + +-output-class-directory= +Java Joined Alias(foutput-class-dir=) + +-resource +Java Separate Alias(fcompile-resource=) + +-resource= +Java Joined Alias(fcompile-resource=) + +-user-dependencies +Java Alias(MM) + +C +Driver +; Java driver option in fact distinct from C-family option with the same name. + +CLASSPATH +Java Separate Alias(fclasspath=) + +D +Driver Joined Separate +; Java driver option similar to C-family option. + +I +Java Joined Separate +; Documented for C + +M +Java +; Documented for C + +MD_ +Java Undocumented RejectDriver +; Documented for C + +MF +Java Separate +; Documented for C + +MM +Java +; Documented for C + +MMD_ +Java Undocumented RejectDriver +; Documented for C + +MP +Java +; Documented for C + +MT +Java Separate +; Documented for C + +Wall +Java +; Documented for C + +Wdeprecated +Java Var(warn_deprecated) +; Documented for C + +Wextraneous-semicolon +Java Var(flag_extraneous_semicolon) +Warn if deprecated empty statements are found + +Wout-of-date +Java Var(flag_newer) Init(1) +Warn if .class files are out of date + +Wredundant-modifiers +Java Var(flag_redundant) +Warn if modifiers are specified when not necessary + +bootclasspath +Java Separate Alias(fbootclasspath=) + +classpath +Java Separate Alias(fclasspath=) + +d +Java Separate SeparateAlias Alias(foutput-class-dir=) +; Different from language-independent -d with joined argument. + +encoding +Java Separate Alias(fencoding=) + +extdirs +Driver Separate + +fCLASSPATH= +Java JoinedOrMissing RejectNegative Alias(fclasspath=) +--CLASSPATH Deprecated; use --classpath instead + +faux-classpath +Java Separate RejectNegative Undocumented + +fassert +Java Var(flag_assert) Init(1) +Permit the use of the assert keyword + +fassume-compiled +Java + +fassume-compiled= +Java JoinedOrMissing + +fenable-assertions +Java + +fenable-assertions= +Java JoinedOrMissing + +fdisable-assertions +Java + +fdisable-assertions= +Java JoinedOrMissing + +fbootclasspath= +Java JoinedOrMissing RejectNegative +--bootclasspath=<path> Replace system path + +fcheck-references +Java Var(flag_check_references) +Generate checks for references to NULL + +fclasspath= +Java JoinedOrMissing RejectNegative +--classpath=<path> Set class path + +fcompile-resource= +Java Joined RejectNegative + +femit-class-file +Java Var(flag_emit_class_files) +Output a class file + +femit-class-files +Java Var(flag_emit_class_files) +Alias for -femit-class-file + +fencoding= +Java Joined RejectNegative +--encoding=<encoding> Choose input encoding (defaults from your locale) + +fextdirs= +Java Joined RejectNegative +--extdirs=<path> Set the extension directory path + +fmain= +Driver JoinedOrMissing RejectNegative + +fsource-filename= +Java Joined Undocumented + +ffilelist-file +Java Var(flag_filelist_file) +Input file is a file with a list of filenames to compile + +fsaw-java-file +Java Undocumented RejectNegative + +fforce-classes-archive-check +Java Var(flag_force_classes_archive_check) +Always check for non gcj generated classes archives + +fhash-synchronization +Java Var(flag_hash_synchronization) +Assume the runtime uses a hash table to map an object to its synchronization structure + +findirect-classes +Java Var(flag_indirect_classes) Init(1) +Generate instances of Class at runtime + +findirect-dispatch +Java Var(flag_indirect_dispatch) +Use offset tables for virtual method calls + +finline-functions +Java + +fjni +Java Var(flag_jni) +Assume native functions are implemented using JNI + +foptimize-static-class-initialization +Java Var(flag_optimize_sci) +Enable optimization of static class initialization code + +foutput-class-dir= +Java Joined RejectNegative + +freduced-reflection +Java Var(flag_reduced_reflection) +Reduce the amount of reflection meta-data generated + +fstore-check +Java Var(flag_store_check) Init(1) +Enable assignability checks for stores into object arrays + +fuse-boehm-gc +Java Var(flag_use_boehm_gc) +Generate code for the Boehm GC + +fuse-divide-subroutine +Java Var(flag_use_divide_subroutine) Init(1) +Call a library routine to do integer divisions + +fuse-atomic-builtins +Java Var(flag_use_atomic_builtins) Init(0) +Generate code for built-in atomic operations + +fbootstrap-classes +Java Var(flag_bootstrap_classes) +Generated should be loaded by bootstrap loader + +fsource= +Java Joined +Set the source language version + +ftarget= +Java Joined +Set the target VM version + +s-bc-abi +Driver + +static-libgcj +Driver + +version +Java RejectDriver + +; +; Warnings handled by ecj. +; FIXME: document them +; + +Wconstructor-name +Java + +Wpkg-default-method +Java + +Wmasked-catch-block +Java + +Wall-deprecation +Java + +Wunused-local +Java + +Wunused-argument +Java + +Wunused-import +Java + +Wunused-private +Java + +Wunused-label +Java + +Wlocal-hiding +Java + +Wfield-hiding +Java + +Wspecial-param-hiding +Java + +Wcondition-assign +Java + +Wsynthetic-access +Java + +Wnls +Java + +Wstatic-receiver +Java + +Windirect-static +Java + +Wno-effect-assign +Java + +Wintf-non-inherited +Java + +Wchar-concat +Java + +Wserial +Java + +Wempty-block +Java + +Wuseless-type-check +Java + +Wuncheck +Java + +Wraw +Java + +Wfinal-bound +Java + +Wsuppress +Java + +Wwarning-token +Java + +Wunnecessary-else +Java + +Wjavadoc +Java + +Wall-javadoc +Java + +Wtasks +Java + +Wassert-identifier +Java + +Wenum-identifier +Java + +Wfinally +Java + +Wunused-thrown +Java + +Wunqualified-field +Java + +Wtype-hiding +Java + +Wvarargs-cast +Java + +Wnull +Java + +Wboxing +Java + +Wover-ann +Java + +Wdep-ann +Java + +Wintf-annotation +Java + +Wenum-switch +Java + +Whiding +Java + +Wstatic-access +Java + +Wunused +Java + +Wparam-assign +Java + +Wdiscouraged +Java + +Wforbidden +Java + +Wfallthrough +Java + diff --git a/gcc/java/mangle.c b/gcc/java/mangle.c new file mode 100644 index 000000000..48caf113e --- /dev/null +++ b/gcc/java/mangle.c @@ -0,0 +1,721 @@ +/* Functions related to mangling class names for the GNU compiler + for the Java(TM) language. + Copyright (C) 1998, 1999, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com> */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "jcf.h" +#include "tree.h" +#include "java-tree.h" +#include "obstack.h" +#include "diagnostic-core.h" +#include "ggc.h" +#include "langhooks-def.h" +#include "tm.h" /* FIXME: For gcc_obstack_init from defaults.h. */ + +static void mangle_class_field (tree); +static void mangle_vtable (tree); +static void mangle_field_decl (tree); +static void mangle_method_decl (tree); +static void mangle_local_cni_method_decl (tree); + +static void mangle_type (tree); +static void mangle_pointer_type (tree); +static void mangle_array_type (tree); +static int mangle_record_type (tree, int); + +static int find_compression_pointer_match (tree); +static int find_compression_array_match (tree); +static int find_compression_record_match (tree, tree *); +static int find_compression_array_template_match (tree); + +static void set_type_package_list (tree); +static int entry_match_pointer_p (tree, int); +static void emit_compression_string (int); + +static void init_mangling (void); +static tree finish_mangling (void); +static void compression_table_add (tree); + +static void mangle_member_name (tree); + +static struct obstack mangle_obstack_1; +struct obstack *mangle_obstack; + +#define MANGLE_RAW_STRING(S) \ + obstack_grow (mangle_obstack, (S), sizeof (S)-1) + +/* atms: array template mangled string. */ +static GTY(()) tree atms; + +/* This is the mangling interface: a decl, a class field (.class) and + the vtable. */ + +void +java_mangle_decl (tree decl) +{ + /* A copy of the check from the beginning of lhd_set_decl_assembler_name. + Only FUNCTION_DECLs and VAR_DECLs for variables with static storage + duration need a real DECL_ASSEMBLER_NAME. */ + gcc_assert (TREE_CODE (decl) == FUNCTION_DECL + || (TREE_CODE (decl) == VAR_DECL + && (TREE_STATIC (decl) + || DECL_EXTERNAL (decl) + || TREE_PUBLIC (decl)))); + + /* Mangling only applies to class members. */ + if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl))) + { + init_mangling (); + switch (TREE_CODE (decl)) + { + case VAR_DECL: + if (DECL_LANG_SPECIFIC (decl)) + { + if (DECL_CLASS_FIELD_P (decl)) + { + mangle_class_field (decl); + break; + } + else if (DECL_VTABLE_P (decl)) + { + mangle_vtable (DECL_CONTEXT (decl)); + break; + } + } + mangle_field_decl (decl); + break; + + case FUNCTION_DECL: + if (DECL_LANG_SPECIFIC (decl) && DECL_LOCAL_CNI_METHOD_P (decl)) + mangle_local_cni_method_decl (decl); + else + mangle_method_decl (decl); + break; + + default: + gcc_unreachable (); + } + SET_DECL_ASSEMBLER_NAME (decl, finish_mangling ()); + } + else + lhd_set_decl_assembler_name (decl); +} + +/* Beginning of the helper functions */ + +static void +mangle_class_field (tree decl) +{ + tree type = DECL_CONTEXT (decl); + mangle_record_type (type, /* for_pointer = */ 0); + if (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE) + MANGLE_RAW_STRING ("6class$"); + else + MANGLE_RAW_STRING ("7class$$"); + obstack_1grow (mangle_obstack, 'E'); +} + +static void +mangle_vtable (tree type) +{ + MANGLE_RAW_STRING ("TV"); + mangle_record_type (type, /* for_pointer = */ 0); + obstack_1grow (mangle_obstack, 'E'); +} + +/* This mangles a field decl */ + +static void +mangle_field_decl (tree decl) +{ + /* Mangle the name of the this the field belongs to */ + mangle_record_type (DECL_CONTEXT (decl), /* for_pointer = */ 0); + + /* Mangle the name of the field */ + mangle_member_name (DECL_NAME (decl)); + + /* Terminate the mangled name */ + obstack_1grow (mangle_obstack, 'E'); +} + +/* This mangles a method decl, first mangling its name and then all + its arguments. */ + +static void +mangle_method_decl (tree mdecl) +{ + tree method_name = DECL_NAME (mdecl); + tree arglist; + + /* Mangle the name of the type that contains mdecl */ + mangle_record_type (DECL_CONTEXT (mdecl), /* for_pointer = */ 0); + + /* Mangle the function name. There are two cases: + - mdecl is a constructor, use `C1' for its name, (denotes a + complete object constructor.) + - mdecl is not a constructor, standard mangling is performed. + We terminate the mangled function name with a `E'. */ + if (ID_INIT_P (method_name)) + obstack_grow (mangle_obstack, "C1", 2); + else + mangle_member_name (method_name); + obstack_1grow (mangle_obstack, 'E'); + + /* We mangled type.methodName. Now onto the arguments. */ + arglist = TYPE_ARG_TYPES (TREE_TYPE (mdecl)); + if (TREE_CODE (TREE_TYPE (mdecl)) == METHOD_TYPE) + arglist = TREE_CHAIN (arglist); + + /* Output literal 'J' and mangle the return type IF not a + constructor. */ + if (!ID_INIT_P (method_name)) + { + obstack_1grow (mangle_obstack, 'J'); + mangle_type(TREE_TYPE(TREE_TYPE(mdecl))); + } + + /* No arguments is easy. We shortcut it. */ + if (arglist == end_params_node) + obstack_1grow (mangle_obstack, 'v'); + else + { + tree arg; + for (arg = arglist; arg != end_params_node; arg = TREE_CHAIN (arg)) + mangle_type (TREE_VALUE (arg)); + } +} + +/* This mangles a CNI method for a local class. If the target supports + hidden aliases, then G++ will have generated one for us. It is the + responsibility of java_mark_class_local to check target support, since + we need to set DECL_VISIBILITY (or not) much earlier. */ + +static void +mangle_local_cni_method_decl (tree decl) +{ + MANGLE_RAW_STRING ("GA"); + mangle_method_decl (decl); +} + +/* This mangles a member name, like a function name or a field + name. Handle cases were `name' is a C++ keyword. Return a nonzero + value if unicode encoding was required. */ + +static void +mangle_member_name (tree name) +{ + append_gpp_mangled_name (IDENTIFIER_POINTER (name), + IDENTIFIER_LENGTH (name)); +} + +/* Append the mangled name of TYPE onto OBSTACK. */ + +static void +mangle_type (tree type) +{ + switch (TREE_CODE (type)) + { + char code; + case BOOLEAN_TYPE: code = 'b'; goto primitive; + case VOID_TYPE: code = 'v'; goto primitive; + case INTEGER_TYPE: + if (type == char_type_node || type == promoted_char_type_node) + { + code = 'w'; + goto primitive; + } + /* Get the original type instead of the arguments promoted type. + Avoid symbol name clashes. Should call a function to do that. + FIXME. */ + if (type == promoted_short_type_node) + type = short_type_node; + if (type == promoted_byte_type_node) + type = byte_type_node; + switch (TYPE_PRECISION (type)) + { + case 8: code = 'c'; goto primitive; + case 16: code = 's'; goto primitive; + case 32: code = 'i'; goto primitive; + case 64: code = 'x'; goto primitive; + default: goto bad_type; + } + primitive: + obstack_1grow (mangle_obstack, code); + break; + + case REAL_TYPE: + switch (TYPE_PRECISION (type)) + { + case 32: code = 'f'; goto primitive; + case 64: code = 'd'; goto primitive; + default: goto bad_type; + } + case POINTER_TYPE: + if (TYPE_ARRAY_P (TREE_TYPE (type))) + mangle_array_type (type); + else + mangle_pointer_type (type); + break; + bad_type: + default: + gcc_unreachable (); + } +} + +/* The compression table is a vector that keeps track of things we've + already seen, so they can be reused. For example, java.lang.Object + would generate three entries: two package names and a type. If + java.lang.String is presented next, the java.lang will be matched + against the first two entries (and kept for compression as S0_), and + type String would be added to the table. See mangle_record_type. + COMPRESSION_NEXT is the index to the location of the next insertion + of an element. */ + +static GTY(()) tree compression_table; +static int compression_next; + +/* Find a POINTER_TYPE in the compression table. Use a special + function to match pointer entries and start from the end */ + +static int +find_compression_pointer_match (tree type) +{ + int i; + + for (i = compression_next-1; i >= 0; i--) + if (entry_match_pointer_p (type, i)) + return i; + return -1; +} + +/* Already recorder arrays are handled like pointer as they're always + associated with it. */ + +static int +find_compression_array_match (tree type) +{ + return find_compression_pointer_match (type); +} + +/* Match the table of type against STRING. */ + +static int +find_compression_array_template_match (tree string) +{ + int i; + for (i = 0; i < compression_next; i++) + if (TREE_VEC_ELT (compression_table, i) == string) + return i; + return -1; +} + +/* We go through the compression table and try to find a complete or + partial match. The function returns the compression table entry + that (eventually partially) matches TYPE. *NEXT_CURRENT can be set + to the rest of TYPE to be mangled. */ + +static int +find_compression_record_match (tree type, tree *next_current) +{ + int i, match = -1; + tree current, saved_current = NULL_TREE; + + current = TYPE_PACKAGE_LIST (type); + + for (i = 0; i < compression_next; i++) + { + tree compression_entry = TREE_VEC_ELT (compression_table, i); + if (current && compression_entry == TREE_PURPOSE (current)) + { + match = i; + saved_current = current; + current = TREE_CHAIN (current); + } + else + /* We don't want to match an element that appears in the middle + of a package name, so skip forward to the next complete type name. + IDENTIFIER_NODEs (except for a "6JArray") are partial package + names while RECORD_TYPEs represent complete type names. */ + while (i < compression_next + && TREE_CODE (compression_entry) == IDENTIFIER_NODE + && compression_entry != atms) + compression_entry = TREE_VEC_ELT (compression_table, ++i); + } + + if (!next_current) + return match; + + /* If we have a match, set next_current to the item next to the last + matched value. */ + if (match >= 0) + *next_current = TREE_CHAIN (saved_current); + /* We had no match: we'll have to start from the beginning. */ + if (match < 0) + *next_current = TYPE_PACKAGE_LIST (type); + + return match; +} + +/* Mangle a record type. If a nonzero value is returned, it means + that a 'N' was emitted (so that a matching 'E' can be emitted if + necessary.) FOR_POINTER indicates that this element is for a pointer + symbol, meaning it was preceded by a 'P'. */ + +static int +mangle_record_type (tree type, int for_pointer) +{ + tree current; + int match; + int nadded_p = 0; + int qualified; + + /* Does this name have a package qualifier? */ + qualified = QUALIFIED_P (DECL_NAME (TYPE_NAME (type))); + +#define ADD_N() \ + do { obstack_1grow (mangle_obstack, 'N'); nadded_p = 1; } while (0) + + gcc_assert (TREE_CODE (type) == RECORD_TYPE); + + if (!TYPE_PACKAGE_LIST (type)) + set_type_package_list (type); + + match = find_compression_record_match (type, ¤t); + if (match >= 0) + { + /* If we had a pointer, and there's more, we need to emit + 'N' after 'P' (for_pointer tells us we already emitted it.) */ + if (for_pointer && current) + ADD_N(); + emit_compression_string (match); + } + while (current) + { + /* Add the new type to the table */ + compression_table_add (TREE_PURPOSE (current)); + /* Add 'N' if we never got a chance to, but only if we have a qualified + name. For non-pointer elements, the name is always qualified. */ + if ((qualified || !for_pointer) && !nadded_p) + ADD_N(); + /* Use the bare type name for the mangle. */ + append_gpp_mangled_name (IDENTIFIER_POINTER (TREE_VALUE (current)), + IDENTIFIER_LENGTH (TREE_VALUE (current))); + current = TREE_CHAIN (current); + } + return nadded_p; +#undef ADD_N +} + +/* Mangle a pointer type. There are two cases: the pointer is already + in the compression table: the compression is emitted sans 'P' + indicator. Otherwise, a 'P' is emitted and, depending on the type, + a partial compression or/plus the rest of the mangling. */ + +static void +mangle_pointer_type (tree type) +{ + int match; + tree pointer_type; + + /* Search for the type already in the compression table */ + if ((match = find_compression_pointer_match (type)) >= 0) + { + emit_compression_string (match); + return; + } + + /* This didn't work. We start by mangling the pointed-to type */ + pointer_type = type; + type = TREE_TYPE (type); + gcc_assert (TREE_CODE (type) == RECORD_TYPE); + + obstack_1grow (mangle_obstack, 'P'); + if (mangle_record_type (type, /* for_pointer = */ 1)) + obstack_1grow (mangle_obstack, 'E'); + + /* Don't forget to insert the pointer type in the table */ + compression_table_add (pointer_type); +} + +/* Mangle an array type. Search for an easy solution first, then go + through the process of finding out whether the bare array type or even + the template indicator were already used and compressed appropriately. + It handles pointers. */ + +static void +mangle_array_type (tree p_type) +{ + tree type, elt_type; + int match; + + type = TREE_TYPE (p_type); + gcc_assert (type); + + elt_type = TYPE_ARRAY_ELEMENT (type); + + /* We cache a bit of the Jarray <> mangle. */ + if (!atms) + { + atms = get_identifier ("6JArray"); + } + + /* Maybe we have what we're looking for in the compression table. */ + if ((match = find_compression_array_match (p_type)) >= 0) + { + emit_compression_string (match); + return; + } + + /* We know for a fact that all arrays are pointers */ + obstack_1grow (mangle_obstack, 'P'); + /* Maybe we already have a Jarray<t> somewhere. PSx_ will be enough. */ + if ((match = find_compression_record_match (type, NULL)) > 0) + { + emit_compression_string (match); + return; + } + + /* Maybe we already have just JArray somewhere */ + if ((match = find_compression_array_template_match (atms)) > 0) + emit_compression_string (match); + else + { + /* Start the template mangled name */ + obstack_grow (mangle_obstack, + IDENTIFIER_POINTER (atms), IDENTIFIER_LENGTH (atms)); + /* Insert in the compression table */ + compression_table_add (atms); + } + + /* Mangle Jarray <elt_type> */ + obstack_1grow (mangle_obstack, 'I'); + mangle_type (elt_type); + obstack_1grow (mangle_obstack, 'E'); + + /* Add `Jarray <elt_type>' and `Jarray <elt_type> *' to the table */ + compression_table_add (type); + compression_table_add (p_type); +} + +/* Write a substitution string for entry I. Substitution string starts a + -1 (encoded S_.) The base is 36, and the code shamelessly taken from + cp/mangle.c. */ + +static void +emit_compression_string (int i) +{ + i -= 1; /* Adjust */ + obstack_1grow (mangle_obstack, 'S'); + if (i >= 0) + { + static const char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + unsigned HOST_WIDE_INT n; + unsigned HOST_WIDE_INT m=1; + /* How many digits for I in base 36? */ + for (n = i; n >= 36; n /= 36, m *=36); + /* Write the digits out */ + while (m > 0) + { + int digit = i / m; + obstack_1grow (mangle_obstack, digits [digit]); + i -= digit * m; + m /= 36; + } + } + obstack_1grow (mangle_obstack, '_'); +} + +/* If search the compression table at index I for a pointer type + equivalent to TYPE (meaning that after all the indirection, which + might all be unique, we find the same RECORD_TYPE.) */ + +static int +entry_match_pointer_p (tree type, int i) +{ + tree t = TREE_VEC_ELT (compression_table, i); + + while (TREE_CODE (type) == POINTER_TYPE + && TREE_CODE (t) == POINTER_TYPE) + { + t = TREE_TYPE (t); + type = TREE_TYPE (type); + } + return (TREE_CODE (type) == RECORD_TYPE + && TREE_CODE (t) == RECORD_TYPE + && t == type); +} + +/* Go through all qualification of type and build a list of list node + elements containings as a purpose what should be used for a match and + inserted in the compression table; and as it value the raw name of the + part. The result is stored in TYPE_PACKAGE_LIST to be reused. */ + +static void +set_type_package_list (tree type) +{ + int i; + const char *type_string = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); + const char *ptr; + int qualifications; + tree list = NULL_TREE, elt; + + for (ptr = type_string, qualifications = 0; *ptr; ptr++) + if (*ptr == '.') + qualifications += 1; + + for (ptr = type_string, i = 0; i < qualifications; ptr++) + { + if (ptr [0] == '.') + { + tree const identifier + = get_identifier_with_length (type_string, ptr - type_string); + + elt = build_tree_list (identifier, identifier); + TREE_CHAIN (elt) = list; + list = elt; + type_string = ptr+1; + i += 1; + } + } + + elt = build_tree_list (type, get_identifier (type_string)); + TREE_CHAIN (elt) = list; + list = elt; + TYPE_PACKAGE_LIST (type) = nreverse (list); +} + +/* Add TYPE as the last element of the compression table. Resize the + compression table if necessary. */ + +static void +compression_table_add (tree type) +{ + if (compression_next == TREE_VEC_LENGTH (compression_table)) + { + tree new_table = make_tree_vec (2*compression_next); + int i; + + for (i = 0; i < compression_next; i++) + TREE_VEC_ELT (new_table, i) = TREE_VEC_ELT (compression_table, i); + + compression_table = new_table; + } + TREE_VEC_ELT (compression_table, compression_next++) = type; +} + +/* Mangle an embedded resource file name. "_ZGr" is the prefix. A + '_' is prepended to the name so that names starting with a digit + can be demangled. The length and then the resulting name itself + are appended while escaping '$', '.', and '/' to: "$$", "$_", and + "$S". */ + +tree +java_mangle_resource_name (const char *name) +{ + int len = strlen (name); + char *buf = (char *) alloca (2 * len + 1); + char *pos; + const unsigned char *w1 = (const unsigned char *) name; + const unsigned char *w2; + const unsigned char *limit = w1 + len; + + pos = buf; + + init_mangling (); + MANGLE_RAW_STRING ("Gr"); + + *pos++ = '_'; + while (w1 < limit) + { + int ch; + w2 = w1; + ch = UTF8_GET (w1, limit); + gcc_assert (ch > 0); + switch (ch) + { + case '$': + *pos++ = '$'; + *pos++ = '$'; + break; + case '.': + *pos++ = '$'; + *pos++ = '_'; + break; + case '/': + *pos++ = '$'; + *pos++ = 'S'; + break; + default: + memcpy (pos, w2, w1 - w2); + pos += w1 - w2; + break; + } + } + append_gpp_mangled_name (buf, pos - buf); + + return finish_mangling (); +} + +/* Mangling initialization routine. */ + +static void +init_mangling (void) +{ + if (!mangle_obstack) + { + mangle_obstack = &mangle_obstack_1; + gcc_obstack_init (mangle_obstack); + } + + gcc_assert (compression_table == NULL); + compression_table = make_tree_vec (10); + + /* Mangled name are to be suffixed */ + MANGLE_RAW_STRING ("_Z"); +} + +/* Mangling finalization routine. The mangled name is returned as a + IDENTIFIER_NODE. */ + +static tree +finish_mangling (void) +{ + tree result; + + gcc_assert (compression_table); + + compression_table = NULL_TREE; + compression_next = 0; + obstack_1grow (mangle_obstack, '\0'); + result = get_identifier (obstack_base (mangle_obstack)); + obstack_free (mangle_obstack, obstack_base (mangle_obstack)); + + return result; +} + +#include "gt-java-mangle.h" diff --git a/gcc/java/mangle_name.c b/gcc/java/mangle_name.c new file mode 100644 index 000000000..658bb2bc4 --- /dev/null +++ b/gcc/java/mangle_name.c @@ -0,0 +1,410 @@ +/* Shared functions related to mangling names for the GNU compiler + for the Java(TM) language. + Copyright (C) 2001, 2002, 2003, 2007, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Alexandre Petit-Bianco <apbianco@cygnus.com> */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "jcf.h" +#include "tree.h" +#include "java-tree.h" +#include "obstack.h" +#include "diagnostic-core.h" + +static void append_unicode_mangled_name (const char *, int); +#ifndef HAVE_AS_UTF8 +static int unicode_mangling_length (const char *, int); +#endif + +extern struct obstack *mangle_obstack; + +static int +utf8_cmp (const unsigned char *str, int length, const char *name) +{ + const unsigned char *limit = str + length; + int i; + + for (i = 0; name[i]; ++i) + { + int ch = UTF8_GET (str, limit); + if (ch != name[i]) + return ch - name[i]; + } + + return str == limit ? 0 : 1; +} + +/* A sorted list of all C++ keywords. If you change this, be sure + also to change the list in + libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java. */ +static const char *const cxx_keywords[] = +{ + "_Complex", + "__alignof", + "__alignof__", + "__asm", + "__asm__", + "__attribute", + "__attribute__", + "__builtin_va_arg", + "__complex", + "__complex__", + "__const", + "__const__", + "__extension__", + "__imag", + "__imag__", + "__inline", + "__inline__", + "__label__", + "__null", + "__real", + "__real__", + "__restrict", + "__restrict__", + "__signed", + "__signed__", + "__typeof", + "__typeof__", + "__volatile", + "__volatile__", + "and", + "and_eq", + "asm", + "auto", + "bitand", + "bitor", + "bool", + "break", + "case", + "catch", + "char", + "class", + "compl", + "const", + "const_cast", + "continue", + "default", + "delete", + "do", + "double", + "dynamic_cast", + "else", + "enum", + "explicit", + "export", + "extern", + "false", + "float", + "for", + "friend", + "goto", + "if", + "inline", + "int", + "long", + "mutable", + "namespace", + "new", + "not", + "not_eq", + "operator", + "or", + "or_eq", + "private", + "protected", + "public", + "register", + "reinterpret_cast", + "return", + "short", + "signed", + "sizeof", + "static", + "static_cast", + "struct", + "switch", + "template", + "this", + "throw", + "true", + "try", + "typedef", + "typeid", + "typename", + "typeof", + "union", + "unsigned", + "using", + "virtual", + "void", + "volatile", + "wchar_t", + "while", + "xor", + "xor_eq" +}; + +/* Return true if NAME is a C++ keyword. */ +int +cxx_keyword_p (const char *name, int length) +{ + int last = ARRAY_SIZE (cxx_keywords); + int first = 0; + int mid = (last + first) / 2; + int old = -1; + + for (mid = (last + first) / 2; + mid != old; + old = mid, mid = (last + first) / 2) + { + int kwl = strlen (cxx_keywords[mid]); + int min_length = kwl > length ? length : kwl; + int r = utf8_cmp ((const unsigned char *) name, min_length, cxx_keywords[mid]); + + if (r == 0) + { + int i; + /* We've found a match if all the remaining characters are `$'. */ + for (i = min_length; i < length && name[i] == '$'; ++i) + ; + if (i == length) + return 1; + r = 1; + } + + if (r < 0) + last = mid; + else + first = mid; + } + return 0; +} + +/* If NAME happens to be a C++ keyword, add `$'. */ +#define MANGLE_CXX_KEYWORDS(NAME, LEN) \ +do \ + { \ + if (cxx_keyword_p ((NAME), (LEN))) \ + { \ + char *tmp_buf = (char *)alloca ((LEN)+1); \ + memcpy (tmp_buf, (NAME), (LEN)); \ + tmp_buf[LEN]= '$'; \ + (NAME) = tmp_buf; \ + (LEN)++; \ + } \ + } \ +while (0) + + +/* If the assembler doesn't support UTF8 in symbol names, some + characters might need to be escaped. */ + +#ifndef HAVE_AS_UTF8 + +/* Assuming (NAME, LEN) is a Utf8-encoding string, emit the string + appropriately mangled (with Unicode escapes if needed) to + MANGLE_OBSTACK. Note that `java', `lang' and `Object' are used so + frequently that they could be cached. */ + +void +append_gpp_mangled_name (const char *name, int len) +{ + int encoded_len, needs_escapes; + char buf[6]; + + MANGLE_CXX_KEYWORDS (name, len); + + encoded_len = unicode_mangling_length (name, len); + needs_escapes = encoded_len > 0; + + sprintf (buf, "%d", (needs_escapes ? encoded_len : len)); + obstack_grow (mangle_obstack, buf, strlen (buf)); + + if (needs_escapes) + append_unicode_mangled_name (name, len); + else + obstack_grow (mangle_obstack, name, len); +} + +/* Assuming (NAME, LEN) is a Utf8-encoded string, emit the string + appropriately mangled (with Unicode escapes) to MANGLE_OBSTACK. + Characters needing an escape are encoded `__UNN_' to `__UNNNN_', in + which case `__U' will be mangled `__U_'. */ + +static void +append_unicode_mangled_name (const char *name, int len) +{ + const unsigned char *ptr; + const unsigned char *limit = (const unsigned char *)name + len; + int uuU = 0; + for (ptr = (const unsigned char *) name; ptr < limit; ) + { + int ch = UTF8_GET(ptr, limit); + + if ((ISALNUM (ch) && ch != 'U') || ch == '$') + { + obstack_1grow (mangle_obstack, ch); + uuU = 0; + } + /* Everything else needs encoding */ + else + { + char buf [9]; + if (ch == '_' || ch == 'U') + { + /* Prepare to recognize __U */ + if (ch == '_' && (uuU < 3)) + { + uuU++; + obstack_1grow (mangle_obstack, ch); + } + /* We recognize __U that we wish to encode + __U_. Finish the encoding. */ + else if (ch == 'U' && (uuU == 2)) + { + uuU = 0; + obstack_grow (mangle_obstack, "U_", 2); + } + /* Otherwise, just reset uuU and emit the character we + have. */ + else + { + uuU = 0; + obstack_1grow (mangle_obstack, ch); + } + continue; + } + sprintf (buf, "__U%x_", ch); + obstack_grow (mangle_obstack, buf, strlen (buf)); + uuU = 0; + } + } +} + +/* Assuming (NAME, LEN) is a Utf8-encoding string, calculate the + length of the string as mangled (a la g++) including Unicode + escapes. If no escapes are needed, return 0. */ + +static int +unicode_mangling_length (const char *name, int len) +{ + const unsigned char *ptr; + const unsigned char *limit = (const unsigned char *)name + len; + int need_escapes = 0; /* Whether we need an escape or not */ + int num_chars = 0; /* Number of characters in the mangled name */ + int uuU = 0; /* Help us to find __U. 0: '_', 1: '__' */ + for (ptr = (const unsigned char *) name; ptr < limit; ) + { + int ch = UTF8_GET(ptr, limit); + + if (ch < 0) + error ("internal error - invalid Utf8 name"); + if ((ISALNUM (ch) && ch != 'U') || ch == '$') + { + num_chars++; + uuU = 0; + } + /* Everything else needs encoding */ + else + { + int encoding_length = 2; + + if (ch == '_' || ch == 'U') + { + /* It's always at least one character. */ + num_chars++; + + /* Prepare to recognize __U */ + if (ch == '_' && (uuU < 3)) + uuU++; + + /* We recognize __U that we wish to encode __U_, we + count one more character. */ + else if (ch == 'U' && (uuU == 2)) + { + num_chars++; + need_escapes = 1; + uuU = 0; + } + /* Otherwise, just reset uuU */ + else + uuU = 0; + + continue; + } + + if (ch > 0xff) + encoding_length++; + if (ch > 0xfff) + encoding_length++; + + num_chars += (4 + encoding_length); + need_escapes = 1; + uuU = 0; + } + } + if (need_escapes) + return num_chars; + else + return 0; +} + +#else + +/* The assembler supports UTF8, we don't use escapes. Mangling is + simply <N>NAME. <N> is the number of UTF8 encoded characters that + are found in NAME. Note that `java', `lang' and `Object' are used + so frequently that they could be cached. */ + +void +append_gpp_mangled_name (const char *name, int len) +{ + const unsigned char *ptr; + const unsigned char *limit; + int encoded_len; + char buf [6]; + + MANGLE_CXX_KEYWORDS (name, len); + + limit = (const unsigned char *)name + len; + + /* Compute the length of the string we wish to mangle. */ + for (encoded_len = 0, ptr = (const unsigned char *) name; + ptr < limit; encoded_len++) + { + int ch = UTF8_GET(ptr, limit); + + if (ch < 0) + error ("internal error - invalid Utf8 name"); + } + + sprintf (buf, "%d", encoded_len); + obstack_grow (mangle_obstack, buf, strlen (buf)); + obstack_grow (mangle_obstack, name, len); +} + +#endif /* HAVE_AS_UTF8 */ diff --git a/gcc/java/parse.h b/gcc/java/parse.h new file mode 100644 index 000000000..28f431c40 --- /dev/null +++ b/gcc/java/parse.h @@ -0,0 +1,71 @@ +/* Language parser definitions for the GNU compiler for the Java(TM) language. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2010 Free Software Foundation, Inc. + Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com) + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +#ifndef GCC_JAVA_PARSE_H +#define GCC_JAVA_PARSE_H + +/* Extern global variable declarations */ +extern struct obstack temporary_obstack; + +#ifdef VERBOSE_SKELETON +#undef SOURCE_FRONTEND_DEBUG +#define SOURCE_FRONTEND_DEBUG(X) \ + {if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} } +#else +#define SOURCE_FRONTEND_DEBUG(X) +#endif + +/* Types classification, according to the JLS, section 4.2 */ +#define JFLOAT_TYPE_P(TYPE) (TYPE && TREE_CODE ((TYPE)) == REAL_TYPE) +#define JINTEGRAL_TYPE_P(TYPE) ((TYPE) \ + && (TREE_CODE ((TYPE)) == INTEGER_TYPE)) +#define JNUMERIC_TYPE_P(TYPE) ((TYPE) \ + && (JFLOAT_TYPE_P ((TYPE)) \ + || JINTEGRAL_TYPE_P ((TYPE)))) +#define JPRIMITIVE_TYPE_P(TYPE) ((TYPE) \ + && (JNUMERIC_TYPE_P ((TYPE)) \ + || TREE_CODE ((TYPE)) == BOOLEAN_TYPE)) + +/* Not defined in the LRM */ +#define JSTRING_TYPE_P(TYPE) ((TYPE) \ + && ((TYPE) == string_type_node || \ + (TREE_CODE (TYPE) == POINTER_TYPE && \ + TREE_TYPE (TYPE) == string_type_node))) +#define JREFERENCE_TYPE_P(TYPE) ((TYPE) \ + && (TREE_CODE (TYPE) == RECORD_TYPE \ + || (TREE_CODE (TYPE) == POINTER_TYPE \ + && TREE_CODE (TREE_TYPE (TYPE)) == \ + RECORD_TYPE))) + +int java_report_errors (void); +extern tree do_resolve_class (tree, tree, tree, tree, tree); + +/* Always in use, no matter what you compile */ +void java_push_parser_context (void); +void java_pop_parser_context (int); +extern void java_parser_context_save_global (void); +extern void java_parser_context_restore_global (void); + +#endif /* ! GCC_JAVA_PARSE_H */ diff --git a/gcc/java/resource.c b/gcc/java/resource.c new file mode 100644 index 000000000..25a9bdd22 --- /dev/null +++ b/gcc/java/resource.c @@ -0,0 +1,143 @@ +/* Functions related to building resource files. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "java-tree.h" +#include "jcf.h" +#include "diagnostic-core.h" +#include "toplev.h" +#include "output.h" +#include "parse.h" +#include "function.h" +#include "ggc.h" +#include "tree-iterator.h" +#include "cgraph.h" + +/* A list of all the resources files. */ +static GTY(()) VEC(tree,gc) *resources; + +void +compile_resource_data (const char *name, const char *buffer, int length) +{ + tree rtype, field = NULL_TREE, data_type, rinit, data, decl; + VEC(constructor_elt,gc) *v = NULL; + + data_type = build_prim_array_type (unsigned_byte_type_node, + strlen (name) + length); + rtype = make_node (RECORD_TYPE); + PUSH_FIELD (input_location, + rtype, field, "name_length", unsigned_int_type_node); + PUSH_FIELD (input_location, + rtype, field, "resource_length", unsigned_int_type_node); + PUSH_FIELD (input_location, rtype, field, "data", data_type); + FINISH_RECORD (rtype); + START_RECORD_CONSTRUCTOR (v, rtype); + PUSH_FIELD_VALUE (v, "name_length", + build_int_cst (NULL_TREE, strlen (name))); + PUSH_FIELD_VALUE (v, "resource_length", + build_int_cst (NULL_TREE, length)); + data = build_string (strlen(name) + length, buffer); + TREE_TYPE (data) = data_type; + PUSH_FIELD_VALUE (v, "data", data); + FINISH_RECORD_CONSTRUCTOR (rinit, v, rtype); + TREE_CONSTANT (rinit) = 1; + + decl = build_decl (input_location, + VAR_DECL, java_mangle_resource_name (name), rtype); + TREE_STATIC (decl) = 1; + TREE_PUBLIC (decl) = 1; + java_hide_decl (decl); + DECL_ARTIFICIAL (decl) = 1; + DECL_IGNORED_P (decl) = 1; + TREE_READONLY (decl) = 1; + TREE_THIS_VOLATILE (decl) = 0; + DECL_INITIAL (decl) = rinit; + layout_decl (decl, 0); + pushdecl (decl); + rest_of_decl_compilation (decl, global_bindings_p (), 0); + varpool_finalize_decl (decl); + + VEC_safe_push (tree, gc, resources, decl); +} + +void +write_resource_constructor (tree *list_p) +{ + tree decl, t, register_resource_fn; + unsigned ix; + + if (resources == NULL) + return; + + t = build_function_type_list (void_type_node, ptr_type_node, NULL); + t = build_decl (input_location, + FUNCTION_DECL, get_identifier ("_Jv_RegisterResource"), t); + TREE_PUBLIC (t) = 1; + DECL_EXTERNAL (t) = 1; + register_resource_fn = t; + + /* Write out entries in the same order in which they were defined. */ + FOR_EACH_VEC_ELT (tree, resources, ix, decl) + { + t = build_fold_addr_expr (decl); + t = build_call_expr (register_resource_fn, 1, t); + append_to_statement_list (t, list_p); + } +} + +/* Generate a byte array representing the contents of FILENAME. The + array is assigned a unique local symbol. The array represents a + compiled Java resource, which is accessed by the runtime using + NAME. */ +void +compile_resource_file (const char *name, const char *filename) +{ + struct stat stat_buf; + int fd; + char *buffer; + + fd = open (filename, O_RDONLY | O_BINARY); + if (fd < 0) + { + perror ("Failed to read resource file"); + return; + } + if (fstat (fd, &stat_buf) != 0 + || ! S_ISREG (stat_buf.st_mode)) + { + perror ("Could not figure length of resource file"); + return; + } + buffer = XNEWVEC (char, strlen (name) + stat_buf.st_size); + strcpy (buffer, name); + read (fd, buffer + strlen (name), stat_buf.st_size); + close (fd); + + compile_resource_data (name, buffer, stat_buf.st_size); +} + +#include "gt-java-resource.h" diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c new file mode 100644 index 000000000..67552176b --- /dev/null +++ b/gcc/java/typeck.c @@ -0,0 +1,828 @@ +/* Handle types for the GNU compiler for the Java(TM) language. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2007, + 2008, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com> */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "obstack.h" +#include "flags.h" +#include "java-tree.h" +#include "jcf.h" +#include "convert.h" +#include "diagnostic-core.h" +#include "ggc.h" + +static tree convert_ieee_real_to_integer (tree, tree); +static tree parse_signature_type (const unsigned char **, + const unsigned char *); +static tree lookup_do (tree, int, tree, tree, tree (*)(tree)); +static tree build_null_signature (tree); + +tree * type_map; + +/* Set the type of the local variable with index SLOT to TYPE. */ + +void +set_local_type (int slot, tree type) +{ + int max_locals = DECL_MAX_LOCALS(current_function_decl); + int nslots = TYPE_IS_WIDE (type) ? 2 : 1; + + gcc_assert (slot >= 0 && (slot + nslots - 1 < max_locals)); + + type_map[slot] = type; + while (--nslots > 0) + type_map[++slot] = void_type_node; +} + +/* Convert an IEEE real to an integer type. The result of such a + conversion when the source operand is a NaN isn't defined by + IEEE754, but by the Java language standard: it must be zero. Also, + overflows must be clipped to within range. This conversion + produces something like: + + ((expr >= (float)MAX_INT) + ? MAX_INT + : ((expr <= (float)MIN_INT) + ? MIN_INT + : ((expr != expr) + ? 0 + : (int)expr))) */ + +static tree +convert_ieee_real_to_integer (tree type, tree expr) +{ + tree result; + expr = save_expr (expr); + + result = fold_build3 (COND_EXPR, type, + fold_build2 (NE_EXPR, boolean_type_node, expr, expr), + convert (type, integer_zero_node), + convert_to_integer (type, expr)); + + result = fold_build3 (COND_EXPR, type, + fold_build2 (LE_EXPR, boolean_type_node, expr, + convert (TREE_TYPE (expr), + TYPE_MIN_VALUE (type))), + TYPE_MIN_VALUE (type), + result); + + result = fold_build3 (COND_EXPR, type, + fold_build2 (GE_EXPR, boolean_type_node, expr, + convert (TREE_TYPE (expr), + TYPE_MAX_VALUE (type))), + TYPE_MAX_VALUE (type), + result); + + return result; +} + +/* Create an expression whose value is that of EXPR, + converted to type TYPE. The TREE_TYPE of the value + is always TYPE. This function implements all reasonable + conversions; callers should filter out those that are + not permitted by the language being compiled. */ + +tree +convert (tree type, tree expr) +{ + enum tree_code code = TREE_CODE (type); + + if (!expr) + return error_mark_node; + + if (type == TREE_TYPE (expr) + || TREE_CODE (expr) == ERROR_MARK) + return expr; + if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) + return error_mark_node; + if (code == VOID_TYPE) + return build1 (CONVERT_EXPR, type, expr); + if (code == BOOLEAN_TYPE) + return fold_convert (type, expr); + if (code == INTEGER_TYPE) + { + if (type == char_type_node || type == promoted_char_type_node) + return fold_convert (type, expr); + if ((really_constant_p (expr) || ! flag_unsafe_math_optimizations) + && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE) + return convert_ieee_real_to_integer (type, expr); + else + { + /* fold very helpfully sets the overflow status if a type + overflows in a narrowing integer conversion, but Java + doesn't care. */ + tree tmp = fold (convert_to_integer (type, expr)); + if (TREE_CODE (tmp) == INTEGER_CST) + TREE_OVERFLOW (tmp) = 0; + return tmp; + } + } + if (code == REAL_TYPE) + return fold (convert_to_real (type, expr)); + if (code == POINTER_TYPE) + return fold (convert_to_pointer (type, expr)); + error ("conversion to non-scalar type requested"); + return error_mark_node; +} + + +/* Return a data type that has machine mode MODE. + If the mode is an integer, + then UNSIGNEDP selects between signed and unsigned types. */ + +tree +java_type_for_mode (enum machine_mode mode, int unsignedp) +{ + if (mode == TYPE_MODE (int_type_node)) + return unsignedp ? unsigned_int_type_node : int_type_node; + if (mode == TYPE_MODE (long_type_node)) + return unsignedp ? unsigned_long_type_node : long_type_node; + if (mode == TYPE_MODE (short_type_node)) + return unsignedp ? unsigned_short_type_node : short_type_node; + if (mode == TYPE_MODE (byte_type_node)) + return unsignedp ? unsigned_byte_type_node : byte_type_node; + if (mode == TYPE_MODE (float_type_node)) + return float_type_node; + if (mode == TYPE_MODE (double_type_node)) + return double_type_node; + + return 0; +} + +/* Return an integer type with BITS bits of precision, + that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */ + +tree +java_type_for_size (unsigned bits, int unsignedp) +{ + if (bits <= TYPE_PRECISION (byte_type_node)) + return unsignedp ? unsigned_byte_type_node : byte_type_node; + if (bits <= TYPE_PRECISION (short_type_node)) + return unsignedp ? unsigned_short_type_node : short_type_node; + if (bits <= TYPE_PRECISION (int_type_node)) + return unsignedp ? unsigned_int_type_node : int_type_node; + if (bits <= TYPE_PRECISION (long_type_node)) + return unsignedp ? unsigned_long_type_node : long_type_node; + return 0; +} + +/* Thorough checking of the arrayness of TYPE. */ + +int +is_array_type_p (tree type) +{ + return TREE_CODE (type) == POINTER_TYPE + && TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE + && TYPE_ARRAY_P (TREE_TYPE (type)); +} + +/* Return the length of a Java array type. + Return -1 if the length is unknown or non-constant. */ + +HOST_WIDE_INT +java_array_type_length (tree array_type) +{ + tree arfld; + if (TREE_CODE (array_type) == POINTER_TYPE) + array_type = TREE_TYPE (array_type); + arfld = DECL_CHAIN (DECL_CHAIN (TYPE_FIELDS (array_type))); + if (arfld != NULL_TREE) + { + tree index_type = TYPE_DOMAIN (TREE_TYPE (arfld)); + if (index_type != NULL_TREE) + { + tree high = TYPE_MAX_VALUE (index_type); + if (TREE_CODE (high) == INTEGER_CST) + return TREE_INT_CST_LOW (high) + 1; + } + } + return -1; +} + +/* An array of unknown length will be ultimately given a length of + -2, so that we can still have `length' producing a negative value + even if found. This was part of an optimization aiming at removing + `length' from static arrays. We could restore it, FIXME. */ + +tree +build_prim_array_type (tree element_type, HOST_WIDE_INT length) +{ + tree index = NULL; + + if (length != -1) + { + tree max_index = build_int_cst (sizetype, length - 1); + index = build_index_type (max_index); + } + return build_array_type (element_type, index); +} + +/* Return a Java array type with a given ELEMENT_TYPE and LENGTH. + These are hashed (shared) using IDENTIFIER_SIGNATURE_TYPE. + The LENGTH is -1 if the length is unknown. */ + +tree +build_java_array_type (tree element_type, HOST_WIDE_INT length) +{ + tree sig, t, fld, atype, arfld; + char buf[23]; + tree elsig = build_java_signature (element_type); + tree el_name = element_type; + buf[0] = '['; + if (length >= 0) + sprintf (buf+1, HOST_WIDE_INT_PRINT_DEC, length); + else + buf[1] = '\0'; + sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig), + buf, 0, 0, ""); + t = IDENTIFIER_SIGNATURE_TYPE (sig); + if (t != NULL_TREE) + return TREE_TYPE (t); + t = make_class (); + IDENTIFIER_SIGNATURE_TYPE (sig) = build_pointer_type (t); + TYPE_ARRAY_P (t) = 1; + + if (TREE_CODE (el_name) == POINTER_TYPE) + el_name = TREE_TYPE (el_name); + el_name = TYPE_NAME (el_name); + if (TREE_CODE (el_name) == TYPE_DECL) + el_name = DECL_NAME (el_name); + { + char suffix[23]; + if (length >= 0) + sprintf (suffix, "[%d]", (int)length); + else + strcpy (suffix, "[]"); + TYPE_NAME (t) + = TYPE_STUB_DECL (t) + = build_decl (input_location, TYPE_DECL, + identifier_subst (el_name, "", '.', '.', suffix), + t); + TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (t)) = true; + } + + set_java_signature (t, sig); + set_super_info (0, t, object_type_node, 0); + if (TREE_CODE (element_type) == RECORD_TYPE) + element_type = promote_type (element_type); + TYPE_ARRAY_ELEMENT (t) = element_type; + + /* Add length pseudo-field. */ + fld = build_decl (input_location, + FIELD_DECL, get_identifier ("length"), int_type_node); + TYPE_FIELDS (t) = fld; + DECL_CONTEXT (fld) = t; + FIELD_PUBLIC (fld) = 1; + FIELD_FINAL (fld) = 1; + TREE_READONLY (fld) = 1; + + atype = build_prim_array_type (element_type, length); + arfld = build_decl (input_location, + FIELD_DECL, get_identifier ("data"), atype); + DECL_CONTEXT (arfld) = t; + DECL_CHAIN (fld) = arfld; + DECL_ALIGN (arfld) = TYPE_ALIGN (element_type); + + /* We could layout_class, but that loads java.lang.Object prematurely. + * This is called by the parser, and it is a bad idea to do load_class + * in the middle of parsing, because of possible circularity problems. */ + push_super_field (t, object_type_node); + layout_type (t); + + return t; +} + +/* Promote TYPE to the type actually used for fields and parameters. */ + +tree +promote_type (tree type) +{ + switch (TREE_CODE (type)) + { + case RECORD_TYPE: + return build_pointer_type (type); + case BOOLEAN_TYPE: + if (type == boolean_type_node) + return promoted_boolean_type_node; + goto handle_int; + case INTEGER_TYPE: + if (type == char_type_node) + return promoted_char_type_node; + handle_int: + if (TYPE_PRECISION (type) < TYPE_PRECISION (int_type_node)) + { + if (type == short_type_node) + return promoted_short_type_node; + if (type == byte_type_node) + return promoted_byte_type_node; + return int_type_node; + } + /* ... else fall through ... */ + default: + return type; + } +} + +/* Parse a signature string, starting at *PTR and ending at LIMIT. + Return the seen TREE_TYPE, updating *PTR. */ + +static tree +parse_signature_type (const unsigned char **ptr, const unsigned char *limit) +{ + tree type; + gcc_assert (*ptr < limit); + + switch (**ptr) + { + case 'B': (*ptr)++; return byte_type_node; + case 'C': (*ptr)++; return char_type_node; + case 'D': (*ptr)++; return double_type_node; + case 'F': (*ptr)++; return float_type_node; + case 'S': (*ptr)++; return short_type_node; + case 'I': (*ptr)++; return int_type_node; + case 'J': (*ptr)++; return long_type_node; + case 'Z': (*ptr)++; return boolean_type_node; + case 'V': (*ptr)++; return void_type_node; + case '[': + for ((*ptr)++; (*ptr) < limit && ISDIGIT (**ptr); ) (*ptr)++; + type = parse_signature_type (ptr, limit); + type = build_java_array_type (type, -1); + break; + case 'L': + { + const unsigned char *start = ++(*ptr); + const unsigned char *str = start; + for ( ; ; str++) + { + gcc_assert (str < limit); + if (*str == ';') + break; + } + *ptr = str+1; + type = lookup_class (unmangle_classname ((const char *) start, str - start)); + break; + } + default: + gcc_unreachable (); + } + return promote_type (type); +} + +/* Parse a Java "mangled" signature string, starting at SIG_STRING, + and SIG_LENGTH bytes long. + Return a gcc type node. */ + +tree +parse_signature_string (const unsigned char *sig_string, int sig_length) +{ + tree result_type; + const unsigned char *str = sig_string; + const unsigned char *limit = str + sig_length; + + if (str < limit && str[0] == '(') + { + tree argtype_list = NULL_TREE; + str++; + while (str < limit && str[0] != ')') + { + tree argtype = parse_signature_type (&str, limit); + argtype_list = tree_cons (NULL_TREE, argtype, argtype_list); + } + if (str++, str >= limit) + abort (); + result_type = parse_signature_type (&str, limit); + argtype_list = chainon (nreverse (argtype_list), end_params_node); + result_type = build_function_type (result_type, argtype_list); + } + else + result_type = parse_signature_type (&str, limit); + if (str != limit) + error ("junk at end of signature string"); + return result_type; +} + +/* Convert a signature to its type. + * Uses IDENTIFIER_SIGNATURE_TYPE as a cache (except for primitive types). + */ + +tree +get_type_from_signature (tree signature) +{ + const unsigned char *sig = (const unsigned char *) IDENTIFIER_POINTER (signature); + int len = IDENTIFIER_LENGTH (signature); + tree type; + /* Primitive types aren't cached. */ + if (len <= 1) + return parse_signature_string (sig, len); + type = IDENTIFIER_SIGNATURE_TYPE (signature); + if (type == NULL_TREE) + { + type = parse_signature_string (sig, len); + IDENTIFIER_SIGNATURE_TYPE (signature) = type; + } + return type; +} + +/* Ignore signature and always return null. Used by has_method. */ + +static tree +build_null_signature (tree type ATTRIBUTE_UNUSED) +{ + return NULL_TREE; +} + +/* Return the signature string for the arguments of method type TYPE. */ + +tree +build_java_argument_signature (tree type) +{ + extern struct obstack temporary_obstack; + tree sig = TYPE_ARGUMENT_SIGNATURE (type); + if (sig == NULL_TREE) + { + tree args = TYPE_ARG_TYPES (type); + if (TREE_CODE (type) == METHOD_TYPE) + args = TREE_CHAIN (args); /* Skip "this" argument. */ + for (; args != end_params_node; args = TREE_CHAIN (args)) + { + tree t = build_java_signature (TREE_VALUE (args)); + obstack_grow (&temporary_obstack, + IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t)); + } + obstack_1grow (&temporary_obstack, '\0'); + + sig = get_identifier (obstack_base (&temporary_obstack)); + TYPE_ARGUMENT_SIGNATURE (type) = sig; + obstack_free (&temporary_obstack, obstack_base (&temporary_obstack)); + } + return sig; +} + +/* Return the signature of the given TYPE. */ + +tree +build_java_signature (tree type) +{ + tree sig, t; + while (TREE_CODE (type) == POINTER_TYPE) + type = TREE_TYPE (type); + MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type); + sig = TYPE_SIGNATURE (type); + if (sig == NULL_TREE) + { + char sg[2]; + switch (TREE_CODE (type)) + { + case BOOLEAN_TYPE: sg[0] = 'Z'; goto native; + case VOID_TYPE: sg[0] = 'V'; goto native; + case INTEGER_TYPE: + if (type == char_type_node || type == promoted_char_type_node) + { + sg[0] = 'C'; + goto native; + } + switch (TYPE_PRECISION (type)) + { + case 8: sg[0] = 'B'; goto native; + case 16: sg[0] = 'S'; goto native; + case 32: sg[0] = 'I'; goto native; + case 64: sg[0] = 'J'; goto native; + default: goto bad_type; + } + case REAL_TYPE: + switch (TYPE_PRECISION (type)) + { + case 32: sg[0] = 'F'; goto native; + case 64: sg[0] = 'D'; goto native; + default: goto bad_type; + } + native: + sg[1] = 0; + sig = get_identifier (sg); + break; + case RECORD_TYPE: + if (TYPE_ARRAY_P (type)) + { + t = build_java_signature (TYPE_ARRAY_ELEMENT (type)); + sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t), + "[", 0, 0, ""); + } + else + { + t = DECL_NAME (TYPE_NAME (type)); + sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t), + "L", '.', '/', ";"); + } + break; + case METHOD_TYPE: + case FUNCTION_TYPE: + { + extern struct obstack temporary_obstack; + sig = build_java_argument_signature (type); + obstack_1grow (&temporary_obstack, '('); + obstack_grow (&temporary_obstack, + IDENTIFIER_POINTER (sig), IDENTIFIER_LENGTH (sig)); + obstack_1grow (&temporary_obstack, ')'); + + t = build_java_signature (TREE_TYPE (type)); + obstack_grow0 (&temporary_obstack, + IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t)); + + sig = get_identifier (obstack_base (&temporary_obstack)); + obstack_free (&temporary_obstack, + obstack_base (&temporary_obstack)); + } + break; + bad_type: + default: + gcc_unreachable (); + } + TYPE_SIGNATURE (type) = sig; + } + return sig; +} + +/* Save signature string SIG (an IDENTIFIER_NODE) in TYPE for future use. */ + +void +set_java_signature (tree type, tree sig) +{ + tree old_sig; + while (TREE_CODE (type) == POINTER_TYPE) + type = TREE_TYPE (type); + MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type); + old_sig = TYPE_SIGNATURE (type); + if (old_sig != NULL_TREE && old_sig != sig) + abort (); + TYPE_SIGNATURE (type) = sig; +#if 0 /* careful about METHOD_TYPE */ + if (IDENTIFIER_SIGNATURE_TYPE (sig) == NULL_TREE && TREE_PERMANENT (type)) + IDENTIFIER_SIGNATURE_TYPE (sig) = type; +#endif +} + +/* Search in SEARCHED_CLASS and its superclasses for a method matching + METHOD_NAME and signature METHOD_SIGNATURE. This function will + only search for methods declared in the class hierarchy; interfaces + will not be considered. Returns NULL_TREE if the method is not + found. */ +tree +lookup_argument_method (tree searched_class, tree method_name, + tree method_signature) +{ + return lookup_do (searched_class, 0, + method_name, method_signature, + build_java_argument_signature); +} + +/* Like lookup_argument_method, but lets the caller set any flags + desired. */ +tree +lookup_argument_method_generic (tree searched_class, tree method_name, + tree method_signature, int flags) +{ + return lookup_do (searched_class, flags, + method_name, method_signature, + build_java_argument_signature); +} + + +/* Search in class SEARCHED_CLASS (and its superclasses) for a method + matching METHOD_NAME and signature METHOD_SIGNATURE. Return a + FUNCTION_DECL on success, or NULL_TREE if none found. (Contrast + lookup_argument_method, which ignores return type.) If + SEARCHED_CLASS is an interface, search it too. */ +tree +lookup_java_method (tree searched_class, tree method_name, + tree method_signature) +{ + return lookup_do (searched_class, SEARCH_INTERFACE, method_name, + method_signature, build_java_signature); +} + +/* Return true iff KLASS (or its ancestors) has a method METHOD_NAME. �*/ +int +has_method (tree klass, tree method_name) +{ + return lookup_do (klass, SEARCH_INTERFACE, + method_name, NULL_TREE, + build_null_signature) != NULL_TREE; +} + +/* Search in class SEARCHED_CLASS, but not its superclasses, for a + method matching METHOD_NAME and signature SIGNATURE. A private + helper for lookup_do. */ +static tree +shallow_find_method (tree searched_class, int flags, tree method_name, + tree signature, tree (*signature_builder) (tree)) +{ + tree method; + for (method = TYPE_METHODS (searched_class); + method != NULL_TREE; method = DECL_CHAIN (method)) + { + tree method_sig = (*signature_builder) (TREE_TYPE (method)); + if (DECL_NAME (method) == method_name && method_sig == signature) + { + /* If the caller requires a visible method, then we + skip invisible methods here. */ + if (! (flags & SEARCH_VISIBLE) + || ! METHOD_INVISIBLE (method)) + return method; + } + } + return NULL_TREE; +} + +/* Search in the superclasses of SEARCHED_CLASS for a method matching + METHOD_NAME and signature SIGNATURE. A private helper for + lookup_do. */ +static tree +find_method_in_superclasses (tree searched_class, int flags, + tree method_name, tree signature, + tree (*signature_builder) (tree)) +{ + tree klass; + for (klass = CLASSTYPE_SUPER (searched_class); klass != NULL_TREE; + klass = CLASSTYPE_SUPER (klass)) + { + tree method; + method = shallow_find_method (klass, flags, method_name, + signature, signature_builder); + if (method != NULL_TREE) + return method; + } + + return NULL_TREE; +} + +/* Search in the interfaces of SEARCHED_CLASS and its superinterfaces + for a method matching METHOD_NAME and signature SIGNATURE. A + private helper for lookup_do. */ +static tree +find_method_in_interfaces (tree searched_class, int flags, tree method_name, + tree signature, tree (*signature_builder) (tree)) +{ + int i; + tree binfo, base_binfo; + + for (binfo = TYPE_BINFO (searched_class), i = 1; + BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + { + tree iclass = BINFO_TYPE (base_binfo); + tree method; + + /* If the superinterface hasn't been loaded yet, do so now. */ + if (!CLASS_LOADED_P (iclass)) + load_class (iclass, 1); + + /* First, we look in ICLASS. If that doesn't work we'll + recursively look through all its superinterfaces. */ + method = shallow_find_method (iclass, flags, method_name, + signature, signature_builder); + if (method != NULL_TREE) + return method; + + method = find_method_in_interfaces + (iclass, flags, method_name, signature, signature_builder); + if (method != NULL_TREE) + return method; + } + + return NULL_TREE; +} + + +/* Search in class SEARCHED_CLASS (and its superclasses) for a method + matching METHOD_NAME and signature SIGNATURE. FLAGS control some + parameters of the search. + + SEARCH_INTERFACE means also search interfaces and superinterfaces + of SEARCHED_CLASS. + + SEARCH_SUPER means skip SEARCHED_CLASS and start with its + superclass. + + SEARCH_VISIBLE means skip methods for which METHOD_INVISIBLE is + set. + + Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is + used on method candidates to build their (sometimes partial) + signature. */ +static tree +lookup_do (tree searched_class, int flags, tree method_name, + tree signature, tree (*signature_builder) (tree)) +{ + tree method; + tree orig_class = searched_class; + + if (searched_class == NULL_TREE) + return NULL_TREE; + + if (flags & SEARCH_SUPER) + { + searched_class = CLASSTYPE_SUPER (searched_class); + if (searched_class == NULL_TREE) + return NULL_TREE; + } + + /* First look in our own methods. */ + method = shallow_find_method (searched_class, flags, method_name, + signature, signature_builder); + if (method) + return method; + + /* Then look in our superclasses. */ + if (! CLASS_INTERFACE (TYPE_NAME (searched_class))) + method = find_method_in_superclasses (searched_class, flags, method_name, + signature, signature_builder); + if (method) + return method; + + /* If that doesn't work, look in our interfaces. */ + if (flags & SEARCH_INTERFACE) + method = find_method_in_interfaces (orig_class, flags, method_name, + signature, signature_builder); + + return method; +} + +/* Search in class CLAS for a constructor matching METHOD_SIGNATURE. + Return a FUNCTION_DECL on success, or NULL_TREE if none found. */ + +tree +lookup_java_constructor (tree clas, tree method_signature) +{ + tree method = TYPE_METHODS (clas); + for ( ; method != NULL_TREE; method = DECL_CHAIN (method)) + { + tree method_sig = build_java_signature (TREE_TYPE (method)); + if (DECL_CONSTRUCTOR_P (method) && method_sig == method_signature) + return method; + } + return NULL_TREE; +} + +/* Return a type which is the Binary Numeric Promotion of the pair T1, + T2 and convert EXP1 and/or EXP2. See 5.6.2 Binary Numeric + Promotion. It assumes that both T1 and T2 are eligible to BNP. */ + +tree +binary_numeric_promotion (tree t1, tree t2, tree *exp1, tree *exp2) +{ + if (t1 == double_type_node || t2 == double_type_node) + { + if (t1 != double_type_node) + *exp1 = convert (double_type_node, *exp1); + if (t2 != double_type_node) + *exp2 = convert (double_type_node, *exp2); + return double_type_node; + } + if (t1 == float_type_node || t2 == float_type_node) + { + if (t1 != float_type_node) + *exp1 = convert (float_type_node, *exp1); + if (t2 != float_type_node) + *exp2 = convert (float_type_node, *exp2); + return float_type_node; + } + if (t1 == long_type_node || t2 == long_type_node) + { + if (t1 != long_type_node) + *exp1 = convert (long_type_node, *exp1); + if (t2 != long_type_node) + *exp2 = convert (long_type_node, *exp2); + return long_type_node; + } + + if (t1 != int_type_node) + *exp1 = convert (int_type_node, *exp1); + if (t2 != int_type_node) + *exp2 = convert (int_type_node, *exp2); + return int_type_node; +} diff --git a/gcc/java/verify-glue.c b/gcc/java/verify-glue.c new file mode 100644 index 000000000..c9eee07ff --- /dev/null +++ b/gcc/java/verify-glue.c @@ -0,0 +1,503 @@ +/* Glue to interface gcj with bytecode verifier. + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Tom Tromey <tromey@redhat.com>. */ + +#include "config.h" + +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "parse.h" + +#include "verify.h" +#include "java-tree.h" +#include "java-except.h" +#include "diagnostic-core.h" + +void * +vfy_alloc (size_t bytes) +{ + return xmalloc (bytes); +} + +void +vfy_free (void *mem) +{ + free (mem); +} + +bool +vfy_strings_equal (vfy_string one, vfy_string two) +{ + return one == two; +} + +const char * +vfy_string_bytes (vfy_string str) +{ + return IDENTIFIER_POINTER (str); +} + +int +vfy_string_length (vfy_string str) +{ + return IDENTIFIER_LENGTH (str); +} + +vfy_string +vfy_init_name (void) +{ + return init_identifier_node; +} + +vfy_string +vfy_clinit_name (void) +{ + return clinit_identifier_node; +} + +static const char* +skip_one_type (const char* ptr) +{ + int ch = *ptr++; + + while (ch == '[') + { + ch = *ptr++; + } + + if (ch == 'L') + { + do { ch = *ptr++; } while (ch != ';'); + } + + return ptr; +} + +int +vfy_count_arguments (vfy_string signature) +{ + const char *ptr = IDENTIFIER_POINTER (signature); + int arg_count = 0; + + /* Skip '('. */ + ptr++; + + /* Count args. */ + while (*ptr != ')') + { + ptr = skip_one_type (ptr); + arg_count += 1; + } + + return arg_count; +} + +vfy_string +vfy_get_string (const char *s, int len) +{ + return get_identifier_with_length (s, len); +} + +vfy_string +vfy_get_signature (vfy_method *method) +{ + return method->signature; +} + +vfy_string +vfy_get_method_name (vfy_method *method) +{ + return method->name; +} + +bool +vfy_is_static (vfy_method *method) +{ + return METHOD_STATIC (method->method); +} + +const unsigned char * +vfy_get_bytecode (vfy_method *method) +{ + return method->bytes; +} + +vfy_exception * +vfy_get_exceptions (vfy_method *method) +{ + return method->exceptions; +} + +void +vfy_get_exception (vfy_exception *exceptions, int index, int *handler, + int *start, int *end, int *handler_type) +{ + *handler = exceptions[index].handler; + *start = exceptions[index].start; + *end = exceptions[index].end; + *handler_type = exceptions[index].type; +} + +int +vfy_tag (vfy_constants *pool, int index) +{ + int result = JPOOL_TAG (pool, index); + /* gcj will resolve constant pool entries other than string and + class references. The verifier doesn't care about the values, so + we just strip off the resolved flag. */ + if ((result & CONSTANT_ResolvedFlag) != 0 + && result != CONSTANT_ResolvedString + && result != CONSTANT_ResolvedClass) + result &= ~ CONSTANT_ResolvedFlag; + return result; +} + +void +vfy_load_indexes (vfy_constants *pool, int index, + vfy_uint_16 *index0, vfy_uint_16 *index1) +{ + *index0 = JPOOL_USHORT1 (pool, index); + *index1 = JPOOL_USHORT2 (pool, index); +} + +vfy_constants * +vfy_get_constants (vfy_jclass klass) +{ + return TYPE_JCF (klass); +} + +int +vfy_get_constants_size (vfy_jclass klass) +{ + return JPOOL_SIZE (TYPE_JCF (klass)); +} + +vfy_string +vfy_get_pool_string (vfy_constants *pool, int index) +{ + return get_name_constant (pool, index); +} + +vfy_jclass +vfy_get_pool_class (vfy_constants *pool, int index) +{ + vfy_jclass k; + k = get_class_constant (pool, index); + return k; +} + +vfy_string +vfy_get_class_name (vfy_jclass klass) +{ + return DECL_NAME (TYPE_NAME (klass)); +} + +bool +vfy_is_assignable_from (vfy_jclass target, vfy_jclass source) +{ + /* Any class is always assignable to itself, or java.lang.Object. */ + if (source == target || target == object_type_node) + return true; + + /* For the C++ ABI, perform this test statically. */ + if (! flag_indirect_dispatch) + return can_widen_reference_to (source, target); + + /* For the BC-ABI, we assume at compile time that reference types are always + compatible. However, a type assertion table entry is emitted so that the + runtime can detect binary-incompatible changes. */ + + add_type_assertion (current_class, JV_ASSERT_TYPES_COMPATIBLE, source, + target); + return true; +} + +char +vfy_get_primitive_char (vfy_jclass klass) +{ + tree sig; + gcc_assert (vfy_is_primitive (klass)); + sig = build_java_signature (klass); + return (IDENTIFIER_POINTER (sig))[0]; +} + +bool +vfy_is_array (vfy_jclass klass) +{ + return TYPE_ARRAY_P (klass); +} + +bool +vfy_is_interface (vfy_jclass klass) +{ + return CLASS_INTERFACE (TYPE_NAME (klass)); +} + +bool +vfy_is_primitive (vfy_jclass klass) +{ + return JPRIMITIVE_TYPE_P (klass); +} + +vfy_jclass +vfy_get_superclass (vfy_jclass klass) +{ + vfy_jclass k; + k = CLASSTYPE_SUPER (klass); + return k; +} + +vfy_jclass +vfy_get_array_class (vfy_jclass klass) +{ + vfy_jclass k; + k = build_java_array_type (klass, -1); + return k; +} + +vfy_jclass +vfy_get_component_type (vfy_jclass klass) +{ + vfy_jclass k; + gcc_assert (vfy_is_array (klass)); + k = TYPE_ARRAY_ELEMENT (klass); + if (TREE_CODE (k) == POINTER_TYPE) + k = TREE_TYPE (k); + return k; +} + +bool +vfy_is_abstract (vfy_jclass klass) +{ + return CLASS_ABSTRACT (TYPE_NAME (klass)); +} + +vfy_jclass +vfy_find_class (vfy_jclass ignore ATTRIBUTE_UNUSED, vfy_string name) +{ + vfy_jclass k; + + k = get_type_from_signature (name); + if (TREE_CODE (k) == POINTER_TYPE) + k = TREE_TYPE (k); + + return k; +} + +vfy_jclass +vfy_object_type (void) +{ + vfy_jclass k; + k = object_type_node; + return k; +} + +vfy_jclass +vfy_class_type (void) +{ + return class_type_node; +} + +vfy_jclass +vfy_string_type (void) +{ + vfy_jclass k; + k = string_type_node; + return k; +} + +vfy_jclass +vfy_throwable_type (void) +{ + vfy_jclass k; + k = throwable_type_node; + return k; +} + +vfy_jclass +vfy_unsuitable_type (void) +{ + return TYPE_SECOND; +} + +vfy_jclass +vfy_return_address_type (void) +{ + return TYPE_RETURN_ADDR; +} + +vfy_jclass +vfy_null_type (void) +{ + return TYPE_NULL; +} + +bool +vfy_class_has_field (vfy_jclass klass, vfy_string name, + vfy_string signature) +{ + tree field = TYPE_FIELDS (klass); + while (field != NULL_TREE) + { + if (DECL_NAME (field) == name + && build_java_signature (TREE_TYPE (field)) == signature) + return true; + field = DECL_CHAIN (field); + } + return false; +} + +int +vfy_fail (const char *message, int pc, vfy_jclass ignore1 ATTRIBUTE_UNUSED, + vfy_method *ignore2 ATTRIBUTE_UNUSED) +{ + if (pc == -1) + error ("verification failed: %s", message); + else + error ("verification failed at PC=%d: %s", pc, message); + /* We have to return a value for the verifier to throw. */ + return 1; +} + +vfy_jclass +vfy_get_primitive_type (int type) +{ + vfy_jclass k; + k = decode_newarray_type (type); + return k; +} + +void +vfy_note_stack_depth (vfy_method *method, int pc, int depth) +{ + tree val = make_tree_vec (method->max_locals + depth); + VEC_replace (tree, type_states, pc, val); + /* Called for side effects. */ + lookup_label (pc); +} + +void +vfy_note_stack_type (vfy_method *method, int pc, int slot, vfy_jclass type) +{ + tree vec; + + slot += method->max_locals; + + if (type == object_type_node) + type = object_ptr_type_node; + + vec = VEC_index (tree, type_states, pc); + TREE_VEC_ELT (vec, slot) = type; + /* Called for side effects. */ + lookup_label (pc); +} + +void +vfy_note_local_type (vfy_method *method ATTRIBUTE_UNUSED, int pc, int slot, + vfy_jclass type) +{ + tree vec; + + if (type == object_type_node) + type = object_ptr_type_node; + + vec = VEC_index (tree, type_states, pc); + TREE_VEC_ELT (vec, slot) = type; + /* Called for side effects. */ + lookup_label (pc); +} + +void +vfy_note_instruction_seen (int pc) +{ + instruction_bits[pc] |= BCODE_VERIFIED; +} + +/* Verify the bytecodes of the current method. + Return 1 on success, 0 on failure. */ +int +verify_jvm_instructions_new (JCF *jcf, const unsigned char *byte_ops, + long length) +{ + vfy_method method; + int i, result, eh_count; + vfy_exception *exceptions; + + method_init_exceptions (); + + JCF_SEEK (jcf, DECL_CODE_OFFSET (current_function_decl) + length); + eh_count = JCF_readu2 (jcf); + + exceptions = (vfy_exception *) xmalloc (eh_count * sizeof (vfy_exception)); + for (i = 0; i < eh_count; ++i) + { + int start_pc, end_pc, handler_pc, catch_type; + unsigned char *p = jcf->read_ptr + 8 * i; + start_pc = GET_u2 (p); + end_pc = GET_u2 (p+2); + handler_pc = GET_u2 (p+4); + catch_type = GET_u2 (p+6); + + if (start_pc < 0 || start_pc >= length + || end_pc < 0 || end_pc > length || start_pc >= end_pc + || handler_pc < 0 || handler_pc >= length) + { + error ("bad pc in exception_table"); + free (exceptions); + return 0; + } + + exceptions[i].handler = handler_pc; + exceptions[i].start = start_pc; + exceptions[i].end = end_pc; + exceptions[i].type = catch_type; + + add_handler (start_pc, end_pc, + lookup_label (handler_pc), + catch_type == 0 ? NULL_TREE + : get_class_constant (jcf, catch_type)); + instruction_bits[handler_pc] |= BCODE_EXCEPTION_TARGET; + } + + gcc_assert (sanity_check_exception_range (&whole_range)); + + method.method = current_function_decl; + method.signature = build_java_signature (TREE_TYPE (current_function_decl)); + method.name = DECL_NAME (current_function_decl); + method.bytes = byte_ops; + method.exceptions = exceptions; + method.defining_class = DECL_CONTEXT (current_function_decl); + method.max_stack = DECL_MAX_STACK (current_function_decl); + method.max_locals = DECL_MAX_LOCALS (current_function_decl); + method.code_length = length; + method.exc_count = eh_count; + + result = verify_method (&method); + + free (exceptions); + + return result; +} diff --git a/gcc/java/verify-impl.c b/gcc/java/verify-impl.c new file mode 100644 index 000000000..1ca2d9fd6 --- /dev/null +++ b/gcc/java/verify-impl.c @@ -0,0 +1,3307 @@ +/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 + Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +/* Written by Tom Tromey <tromey@redhat.com> */ + +/* Uncomment this to enable debugging output. */ +/* #define VERIFY_DEBUG */ + +#include "config.h" + +#include "verify.h" + +/* Hack to work around namespace pollution from java-tree.h. */ +#undef current_class + +/* This is used to mark states which are not scheduled for + verification. */ +#define INVALID_STATE ((state *) -1) + +static void ATTRIBUTE_PRINTF_1 +debug_print (const char *fmt ATTRIBUTE_UNUSED, ...) +{ +#ifdef VERIFY_DEBUG + va_list ap; + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); +#endif /* VERIFY_DEBUG */ +} + +/* This started as a fairly ordinary verifier, and for the most part + it remains so. It works in the obvious way, by modeling the effect + of each opcode as it is encountered. For most opcodes, this is a + straightforward operation. + + This verifier does not do type merging. It used to, but this + results in difficulty verifying some relatively simple code + involving interfaces, and it pushed some verification work into the + interpreter. + + Instead of merging reference types, when we reach a point where two + flows of control merge, we simply keep the union of reference types + from each branch. Then, when we need to verify a fact about a + reference on the stack (e.g., that it is compatible with the + argument type of a method), we check to ensure that all possible + types satisfy the requirement. + + Another area this verifier differs from the norm is in its handling + of subroutines. The JVM specification has some confusing things to + say about subroutines. For instance, it makes claims about not + allowing subroutines to merge and it rejects recursive subroutines. + For the most part these are red herrings; we used to try to follow + these things but they lead to problems. For example, the notion of + "being in a subroutine" is not well-defined: is an exception + handler in a subroutine? If you never execute the `ret' but + instead `goto 1' do you remain in the subroutine? + + For clarity on what is really required for type safety, read + "Simple Verification Technique for Complex Java Bytecode + Subroutines" by Alessandro Coglio. Among other things this paper + shows that recursive subroutines are not harmful to type safety. + We implement something similar to what he proposes. Note that this + means that this verifier will accept code that is rejected by some + other verifiers. + + For those not wanting to read the paper, the basic observation is + that we can maintain split states in subroutines. We maintain one + state for each calling `jsr'. In other words, we re-verify a + subroutine once for each caller, using the exact types held by the + callers (as opposed to the old approach of merging types and + keeping a bitmap registering what did or did not change). This + approach lets us continue to verify correctly even when a + subroutine is exited via `goto' or `athrow' and not `ret'. + + In some other areas the JVM specification is (mildly) incorrect, + so we diverge. For instance, you cannot + violate type safety by allocating an object with `new' and then + failing to initialize it, no matter how one branches or where one + stores the uninitialized reference. See "Improving the official + specification of Java bytecode verification" by Alessandro Coglio. + + Note that there's no real point in enforcing that padding bytes or + the mystery byte of invokeinterface must be 0, but we do that + regardless. + + The verifier is currently neither completely lazy nor eager when it + comes to loading classes. It tries to represent types by name when + possible, and then loads them when it needs to verify a fact about + the type. Checking types by name is valid because we only use + names which come from the current class' constant pool. Since all + such names are looked up using the same class loader, there is no + danger that we might be fooled into comparing different types with + the same name. + + In the future we plan to allow for a completely lazy mode of + operation, where the verifier will construct a list of type + assertions to be checked later. + + Some test cases for the verifier live in the "verify" module of the + Mauve test suite. However, some of these are presently + (2004-01-20) believed to be incorrect. (More precisely the notion + of "correct" is not well-defined, and this verifier differs from + others while remaining type-safe.) Some other tests live in the + libgcj test suite. + + This verifier is also written to be pluggable. This means that it + is intended for use in a variety of environments, not just libgcj. + As a result the verifier expects a number of type and method + declarations to be declared in "verify.h". The intent is that you + recompile the verifier for your particular environment. This + approach was chosen so that operations could be inlined in verify.h + as much as possible. + + See the verify.h that accompanies this copy of the verifier to see + what types, preprocessor defines, and functions must be declared. + The interface is ad hoc, but was defined so that it could be + implemented to connect to a pure C program. +*/ + +#define FLAG_INSN_START 1 +#define FLAG_BRANCH_TARGET 2 +#define FLAG_INSN_SEEN 4 + +struct state; +struct type; +struct ref_intersection; + +typedef struct state state; +typedef struct type type; +typedef struct ref_intersection ref_intersection; + +/*typedef struct state_list state_list;*/ + +typedef struct state_list +{ + state *val; + struct state_list *next; +} state_list; + +typedef struct vfy_string_list +{ + vfy_string val; + struct vfy_string_list *next; +} vfy_string_list; + +typedef struct verifier_context +{ + /* The current PC. */ + int PC; + /* The PC corresponding to the start of the current instruction. */ + int start_PC; + + /* The current state of the stack, locals, etc. */ + state *current_state; + + /* At each branch target we keep a linked list of all the states we + can process at that point. We'll only have multiple states at a + given PC if they both have different return-address types in the + same stack or local slot. This array is indexed by PC and holds + the list of all such states. */ + state_list **states; + + /* We keep a linked list of all the states which we must reverify. + This is the head of the list. */ + state *next_verify_state; + + /* We keep some flags for each instruction. The values are the + FLAG_* constants defined above. This is an array indexed by PC. */ + char *flags; + + /* The bytecode itself. */ + const unsigned char *bytecode; + /* The exceptions. */ + vfy_exception *exception; + + /* Defining class. */ + vfy_jclass current_class; + /* This method. */ + vfy_method *current_method; + + /* A linked list of utf8 objects we allocate. */ + vfy_string_list *utf8_list; + + /* A linked list of all ref_intersection objects we allocate. */ + ref_intersection *isect_list; +} verifier_context; + +/* The current verifier's state data. This is maintained by + {push/pop}_verifier_context to provide a shorthand form to access + the verification state. */ +static GTY(()) verifier_context *vfr; + +/* Local function declarations. */ +bool type_initialized (type *t); +int ref_count_dimensions (ref_intersection *ref); + +static void +verify_fail_pc (const char *s, int pc) +{ + vfy_fail (s, pc, vfr->current_class, vfr->current_method); +} + +static void +verify_fail (const char *s) +{ + verify_fail_pc (s, vfr->PC); +} + +/* This enum holds a list of tags for all the different types we + need to handle. Reference types are treated specially by the + type class. */ +typedef enum type_val +{ + void_type, + + /* The values for primitive types are chosen to correspond to values + specified to newarray. */ + boolean_type = 4, + char_type = 5, + float_type = 6, + double_type = 7, + byte_type = 8, + short_type = 9, + int_type = 10, + long_type = 11, + + /* Used when overwriting second word of a double or long in the + local variables. Also used after merging local variable states + to indicate an unusable value. */ + unsuitable_type, + return_address_type, + /* This is the second word of a two-word value, i.e., a double or + a long. */ + continuation_type, + + /* Everything after `reference_type' must be a reference type. */ + reference_type, + null_type, + uninitialized_reference_type +} type_val; + +/* This represents a merged class type. Some verifiers (including + earlier versions of this one) will compute the intersection of + two class types when merging states. However, this loses + critical information about interfaces implemented by the various + classes. So instead we keep track of all the actual classes that + have been merged. */ +struct ref_intersection +{ + /* Whether or not this type has been resolved. */ + bool is_resolved; + + /* Actual type data. */ + union + { + /* For a resolved reference type, this is a pointer to the class. */ + vfy_jclass klass; + /* For other reference types, this it the name of the class. */ + vfy_string name; + } data; + + /* Link to the next reference in the intersection. */ + ref_intersection *ref_next; + + /* This is used to keep track of all the allocated + ref_intersection objects, so we can free them. + FIXME: we should allocate these in chunks. */ + ref_intersection *alloc_next; +}; + +static ref_intersection * +make_ref (void) +{ + ref_intersection *new_ref = + (ref_intersection *) vfy_alloc (sizeof (ref_intersection)); + + new_ref->alloc_next = vfr->isect_list; + vfr->isect_list = new_ref; + return new_ref; +} + +static ref_intersection * +clone_ref (ref_intersection *dup) +{ + ref_intersection *new_ref = make_ref (); + + new_ref->is_resolved = dup->is_resolved; + new_ref->data = dup->data; + return new_ref; +} + +static void +resolve_ref (ref_intersection *ref) +{ + if (ref->is_resolved) + return; + ref->data.klass = vfy_find_class (vfr->current_class, ref->data.name); + ref->is_resolved = true; +} + +static bool +refs_equal (ref_intersection *ref1, ref_intersection *ref2) +{ + if (! ref1->is_resolved && ! ref2->is_resolved + && vfy_strings_equal (ref1->data.name, ref2->data.name)) + return true; + if (! ref1->is_resolved) + resolve_ref (ref1); + if (! ref2->is_resolved) + resolve_ref (ref2); + return ref1->data.klass == ref2->data.klass; +} + +/* Merge REF1 type into REF2, returning the result. This will + return REF2 if all the classes in THIS already appear in + REF2. */ +static ref_intersection * +merge_refs (ref_intersection *ref1, ref_intersection *ref2) +{ + ref_intersection *tail = ref2; + for (; ref1 != NULL; ref1 = ref1->ref_next) + { + bool add = true; + ref_intersection *iter; + for (iter = ref2; iter != NULL; iter = iter->ref_next) + { + if (refs_equal (ref1, iter)) + { + add = false; + break; + } + } + + if (add) + { + ref_intersection *new_tail = clone_ref (ref1); + new_tail->ref_next = tail; + tail = new_tail; + } + } + return tail; +} + +/* See if an object of type SOURCE can be assigned to an object of + type TARGET. This might resolve classes in one chain or the other. */ +static bool +ref_compatible (ref_intersection *target, ref_intersection *source) +{ + for (; target != NULL; target = target->ref_next) + { + ref_intersection *source_iter = source; + + for (; source_iter != NULL; source_iter = source_iter->ref_next) + { + /* Avoid resolving if possible. */ + if (! target->is_resolved + && ! source_iter->is_resolved + && vfy_strings_equal (target->data.name, + source_iter->data.name)) + continue; + + if (! target->is_resolved) + resolve_ref (target); + if (! source_iter->is_resolved) + resolve_ref (source_iter); + + if (! vfy_is_assignable_from (target->data.klass, + source_iter->data.klass)) + return false; + } + } + + return true; +} + +static bool +ref_isarray (ref_intersection *ref) +{ + /* assert (ref_next == NULL); */ + if (ref->is_resolved) + return vfy_is_array (ref->data.klass); + else + return vfy_string_bytes (ref->data.name)[0] == '['; +} + +static bool +ref_isinterface (ref_intersection *ref) +{ + /* assert (ref_next == NULL); */ + if (! ref->is_resolved) + resolve_ref (ref); + return vfy_is_interface (ref->data.klass); +} + +static bool +ref_isabstract (ref_intersection *ref) +{ + /* assert (ref_next == NULL); */ + if (! ref->is_resolved) + resolve_ref (ref); + return vfy_is_abstract (ref->data.klass); +} + +static vfy_jclass +ref_getclass (ref_intersection *ref) +{ + if (! ref->is_resolved) + resolve_ref (ref); + return ref->data.klass; +} + +int +ref_count_dimensions (ref_intersection *ref) +{ + int ndims = 0; + if (ref->is_resolved) + { + vfy_jclass k = ref->data.klass; + while (vfy_is_array (k)) + { + k = vfy_get_component_type (k); + ++ndims; + } + } + else + { + const char *p = vfy_string_bytes (ref->data.name); + while (*p++ == '[') + ++ndims; + } + return ndims; +} + +/* Return the type_val corresponding to a primitive signature + character. For instance `I' returns `int.class'. */ +static type_val +get_type_val_for_signature (char sig) +{ + type_val rt; + switch (sig) + { + case 'Z': + rt = boolean_type; + break; + case 'B': + rt = byte_type; + break; + case 'C': + rt = char_type; + break; + case 'S': + rt = short_type; + break; + case 'I': + rt = int_type; + break; + case 'J': + rt = long_type; + break; + case 'F': + rt = float_type; + break; + case 'D': + rt = double_type; + break; + case 'V': + rt = void_type; + break; + default: + verify_fail ("invalid signature"); + return null_type; + } + return rt; +} + +/* Return the type_val corresponding to a primitive class. */ +static type_val +get_type_val_for_primtype (vfy_jclass k) +{ + return get_type_val_for_signature (vfy_get_primitive_char (k)); +} + +/* The `type' class is used to represent a single type in the verifier. */ +struct type +{ + /* The type key. */ + type_val key; + + /* For reference types, the representation of the type. */ + ref_intersection *klass; + + /* This is used in two situations. + + First, when constructing a new object, it is the PC of the + `new' instruction which created the object. We use the special + value UNINIT to mean that this is uninitialized. The special + value SELF is used for the case where the current method is + itself the <init> method. the special value EITHER is used + when we may optionally allow either an uninitialized or + initialized reference to match. + + Second, when the key is return_address_type, this holds the PC + of the instruction following the `jsr'. */ + int pc; + +#define UNINIT -2 +#define SELF -1 +#define EITHER -3 +}; + +/* Make a new instance given the type tag. We assume a generic + `reference_type' means Object. */ +static void +init_type_from_tag (type *t, type_val k) +{ + t->key = k; + /* For reference_type, if KLASS==NULL then that means we are + looking for a generic object of any kind, including an + uninitialized reference. */ + t->klass = NULL; + t->pc = UNINIT; +} + +/* Make a type for the given type_val tag K. */ +static type +make_type (type_val k) +{ + type t; + init_type_from_tag (&t, k); + return t; +} + +/* Make a new instance given a class. */ +static void +init_type_from_class (type *t, vfy_jclass k) +{ + t->key = reference_type; + t->klass = make_ref (); + t->klass->is_resolved = true; + t->klass->data.klass = k; + t->klass->ref_next = NULL; + t->pc = UNINIT; +} + +static type +make_type_from_class (vfy_jclass k) +{ + type t; + init_type_from_class (&t, k); + return t; +} + +static void +init_type_from_string (type *t, vfy_string n) +{ + t->key = reference_type; + t->klass = make_ref (); + t->klass->is_resolved = false; + t->klass->data.name = n; + t->klass->ref_next = NULL; + t->pc = UNINIT; +} + +static type +make_type_from_string (vfy_string n) +{ + type t; + init_type_from_string (&t, n); + return t; +} + +/* Promote a numeric type. */ +static void +vfy_promote_type (type *t) +{ + if (t->key == boolean_type || t->key == char_type + || t->key == byte_type || t->key == short_type) + t->key = int_type; +} +#define promote_type vfy_promote_type + +/* Mark this type as the uninitialized result of `new'. */ +static void +type_set_uninitialized (type *t, int npc) +{ + if (t->key == reference_type) + t->key = uninitialized_reference_type; + else + verify_fail ("internal error in type::uninitialized"); + t->pc = npc; +} + +/* Mark this type as now initialized. */ +static void +type_set_initialized (type *t, int npc) +{ + if (npc != UNINIT && t->pc == npc && t->key == uninitialized_reference_type) + { + t->key = reference_type; + t->pc = UNINIT; + } +} + +/* Mark this type as a particular return address. */ +static void type_set_return_address (type *t, int npc) +{ + t->pc = npc; +} + +/* Return true if this type and type OTHER are considered + mergeable for the purposes of state merging. This is related + to subroutine handling. For this purpose two types are + considered unmergeable if they are both return-addresses but + have different PCs. */ +static bool +type_state_mergeable_p (type *t1, type *t2) +{ + return (t1->key != return_address_type + || t2->key != return_address_type + || t1->pc == t2->pc); +} + +/* Return true if an object of type K can be assigned to a variable + of type T. Handle various special cases too. Might modify + T or K. Note however that this does not perform numeric + promotion. */ +static bool +types_compatible (type *t, type *k) +{ + /* Any type is compatible with the unsuitable type. */ + if (k->key == unsuitable_type) + return true; + + if (t->key < reference_type || k->key < reference_type) + return t->key == k->key; + + /* The `null' type is convertible to any initialized reference + type. */ + if (t->key == null_type) + return k->key != uninitialized_reference_type; + if (k->key == null_type) + return t->key != uninitialized_reference_type; + + /* A special case for a generic reference. */ + if (t->klass == NULL) + return true; + if (k->klass == NULL) + verify_fail ("programmer error in type::compatible"); + + /* Handle the special 'EITHER' case, which is only used in a + special case of 'putfield'. Note that we only need to handle + this on the LHS of a check. */ + if (! type_initialized (t) && t->pc == EITHER) + { + /* If the RHS is uninitialized, it must be an uninitialized + 'this'. */ + if (! type_initialized (k) && k->pc != SELF) + return false; + } + else if (type_initialized (t) != type_initialized (k)) + { + /* An initialized type and an uninitialized type are not + otherwise compatible. */ + return false; + } + else + { + /* Two uninitialized objects are compatible if either: + * The PCs are identical, or + * One PC is UNINIT. */ + if (type_initialized (t)) + { + if (t->pc != k->pc && t->pc != UNINIT && k->pc != UNINIT) + return false; + } + } + + return ref_compatible (t->klass, k->klass); +} + +/* Return true if two types are equal. Only valid for reference + types. */ +static bool +types_equal (type *t1, type *t2) +{ + if ((t1->key != reference_type && t1->key != uninitialized_reference_type) + || (t2->key != reference_type + && t2->key != uninitialized_reference_type)) + return false; + /* Only single-ref types are allowed. */ + if (t1->klass->ref_next || t2->klass->ref_next) + return false; + return refs_equal (t1->klass, t2->klass); +} + +static bool +type_isvoid (type *t) +{ + return t->key == void_type; +} + +static bool +type_iswide (type *t) +{ + return t->key == long_type || t->key == double_type; +} + +/* Return number of stack or local variable slots taken by this type. */ +static int +type_depth (type *t) +{ + return type_iswide (t) ? 2 : 1; +} + +static bool +type_isarray (type *t) +{ + /* We treat null_type as not an array. This is ok based on the + current uses of this method. */ + if (t->key == reference_type) + return ref_isarray (t->klass); + return false; +} + +static bool +type_isnull (type *t) +{ + return t->key == null_type; +} + +static bool +type_isinterface (type *t) +{ + if (t->key != reference_type) + return false; + return ref_isinterface (t->klass); +} + +static bool +type_isabstract (type *t) +{ + if (t->key != reference_type) + return false; + return ref_isabstract (t->klass); +} + +/* Return the element type of an array. */ +static type +type_array_element (type *t) +{ + type et; + vfy_jclass k; + + if (t->key != reference_type) + verify_fail ("programmer error in type::element_type()"); + + k = vfy_get_component_type (ref_getclass (t->klass)); + if (vfy_is_primitive (k)) + init_type_from_tag (&et, get_type_val_for_primtype (k)); + else + init_type_from_class (&et, k); + return et; +} + +/* Return the array type corresponding to an initialized + reference. We could expand this to work for other kinds of + types, but currently we don't need to. */ +static type +type_to_array (type *t) +{ + type at; + vfy_jclass k; + + if (t->key != reference_type) + verify_fail ("internal error in type::to_array()"); + + k = ref_getclass (t->klass); + init_type_from_class (&at, vfy_get_array_class (k)); + return at; +} + +static bool +type_isreference (type *t) +{ + return t->key >= reference_type; +} + +static int +type_get_pc (type *t) +{ + return t->pc; +} + +bool +type_initialized (type *t) +{ + return t->key == reference_type || t->key == null_type; +} + +static void +type_verify_dimensions (type *t, int ndims) +{ + /* The way this is written, we don't need to check isarray(). */ + if (t->key != reference_type) + verify_fail ("internal error in verify_dimensions:" + " not a reference type"); + + if (ref_count_dimensions (t->klass) < ndims) + verify_fail ("array type has fewer dimensions" + " than required"); +} + +/* Merge OLD_TYPE into this. On error throw exception. Return + true if the merge caused a type change. */ +static bool +merge_types (type *t, type *old_type, bool local_semantics) +{ + bool changed = false; + bool refo = type_isreference (old_type); + bool refn = type_isreference (t); + if (refo && refn) + { + if (old_type->key == null_type) + ; + else if (t->key == null_type) + { + *t = *old_type; + changed = true; + } + else if (type_initialized (t) != type_initialized (old_type)) + verify_fail ("merging initialized and uninitialized types"); + else + { + ref_intersection *merged; + if (! type_initialized (t)) + { + if (t->pc == UNINIT) + t->pc = old_type->pc; + else if (old_type->pc == UNINIT) + ; + else if (t->pc != old_type->pc) + verify_fail ("merging different uninitialized types"); + } + + merged = merge_refs (old_type->klass, t->klass); + if (merged != t->klass) + { + t->klass = merged; + changed = true; + } + } + } + else if (refo || refn || t->key != old_type->key) + { + if (local_semantics) + { + /* If we already have an `unsuitable' type, then we + don't need to change again. */ + if (t->key != unsuitable_type) + { + t->key = unsuitable_type; + changed = true; + } + } + else + verify_fail ("unmergeable type"); + } + return changed; +} + +#ifdef VERIFY_DEBUG +static void +type_print (type *t) +{ + char c = '?'; + switch (t->key) + { + case boolean_type: c = 'Z'; break; + case byte_type: c = 'B'; break; + case char_type: c = 'C'; break; + case short_type: c = 'S'; break; + case int_type: c = 'I'; break; + case long_type: c = 'J'; break; + case float_type: c = 'F'; break; + case double_type: c = 'D'; break; + case void_type: c = 'V'; break; + case unsuitable_type: c = '-'; break; + case return_address_type: c = 'r'; break; + case continuation_type: c = '+'; break; + case reference_type: c = 'L'; break; + case null_type: c = '@'; break; + case uninitialized_reference_type: c = 'U'; break; + } + debug_print ("%c", c); +} +#endif /* VERIFY_DEBUG */ + +/* This class holds all the state information we need for a given + location. */ +struct state +{ + /* The current top of the stack, in terms of slots. */ + int stacktop; + /* The current depth of the stack. This will be larger than + STACKTOP when wide types are on the stack. */ + int stackdepth; + /* The stack. */ + type *stack; + /* The local variables. */ + type *locals; + /* We keep track of the type of `this' specially. This is used to + ensure that an instance initializer invokes another initializer + on `this' before returning. We must keep track of this + specially because otherwise we might be confused by code which + assigns to locals[0] (overwriting `this') and then returns + without really initializing. */ + type this_type; + + /* The PC for this state. This is only valid on states which are + permanently attached to a given PC. For an object like + `current_state', which is used transiently, this has no + meaning. */ + int pc; + /* We keep a linked list of all states requiring reverification. + If this is the special value INVALID_STATE then this state is + not on the list. NULL marks the end of the linked list. */ + state *next; +}; + +/* NO_NEXT is the PC value meaning that a new state must be + acquired from the verification list. */ +#define NO_NEXT -1 + +static void +init_state_with_stack (state *s, int max_stack, int max_locals) +{ + int i; + s->stacktop = 0; + s->stackdepth = 0; + s->stack = (type *) vfy_alloc (max_stack * sizeof (type)); + for (i = 0; i < max_stack; ++i) + init_type_from_tag (&s->stack[i], unsuitable_type); + s->locals = (type *) vfy_alloc (max_locals * sizeof (type)); + for (i = 0; i < max_locals; ++i) + init_type_from_tag (&s->locals[i], unsuitable_type); + init_type_from_tag (&s->this_type, unsuitable_type); + s->pc = NO_NEXT; + s->next = INVALID_STATE; +} + +static void +copy_state (state *s, state *copy, int max_stack, int max_locals) +{ + int i; + s->stacktop = copy->stacktop; + s->stackdepth = copy->stackdepth; + for (i = 0; i < max_stack; ++i) + s->stack[i] = copy->stack[i]; + for (i = 0; i < max_locals; ++i) + s->locals[i] = copy->locals[i]; + + s->this_type = copy->this_type; + /* Don't modify `next' or `pc'. */ +} + +static void +copy_state_with_stack (state *s, state *orig, int max_stack, int max_locals) +{ + init_state_with_stack (s, max_stack, max_locals); + copy_state (s, orig, max_stack, max_locals); +} + +/* Allocate a new state, copying ORIG. */ +static state * +make_state_copy (state *orig, int max_stack, int max_locals) +{ + state *s = (state *) vfy_alloc (sizeof (state)); + copy_state_with_stack (s, orig, max_stack, max_locals); + return s; +} + +static state * +make_state (int max_stack, int max_locals) +{ + state *s = (state *) vfy_alloc (sizeof (state)); + init_state_with_stack (s, max_stack, max_locals); + return s; +} + +static void +free_state (state *s) +{ + if (s->stack != NULL) + vfy_free (s->stack); + if (s->locals != NULL) + vfy_free (s->locals); +} + +/* Modify this state to reflect entry to an exception handler. */ +static void +state_set_exception (state *s, type *t, int max_stack) +{ + int i; + s->stackdepth = 1; + s->stacktop = 1; + s->stack[0] = *t; + for (i = s->stacktop; i < max_stack; ++i) + init_type_from_tag (&s->stack[i], unsuitable_type); +} + +/* Merge STATE_OLD into this state. Destructively modifies this + state. Returns true if the new state was in fact changed. + Will throw an exception if the states are not mergeable. */ +static bool +merge_states (state *s, state *state_old, int max_locals) +{ + int i; + bool changed = false; + + /* Special handling for `this'. If one or the other is + uninitialized, then the merge is uninitialized. */ + if (type_initialized (&s->this_type)) + s->this_type = state_old->this_type; + + /* Merge stacks. */ + if (state_old->stacktop != s->stacktop) /* FIXME stackdepth instead? */ + verify_fail ("stack sizes differ"); + for (i = 0; i < state_old->stacktop; ++i) + { + if (merge_types (&s->stack[i], &state_old->stack[i], false)) + changed = true; + } + + /* Merge local variables. */ + for (i = 0; i < max_locals; ++i) + { + if (merge_types (&s->locals[i], &state_old->locals[i], true)) + changed = true; + } + + return changed; +} + +/* Ensure that `this' has been initialized. */ +static void +state_check_this_initialized (state *s) +{ + if (type_isreference (&s->this_type) && ! type_initialized (&s->this_type)) + verify_fail ("`this' is uninitialized"); +} + +/* Set type of `this'. */ +static void +state_set_this_type (state *s, type *k) +{ + s->this_type = *k; +} + +/* Mark each `new'd object we know of that was allocated at PC as + initialized. */ +static void +state_set_initialized (state *s, int pc, int max_locals) +{ + int i; + for (i = 0; i < s->stacktop; ++i) + type_set_initialized (&s->stack[i], pc); + for (i = 0; i < max_locals; ++i) + type_set_initialized (&s->locals[i], pc); + type_set_initialized (&s->this_type, pc); +} + +/* This tests to see whether two states can be considered "merge + compatible". If both states have a return-address in the same + slot, and the return addresses are different, then they are not + compatible and we must not try to merge them. */ +static bool +state_mergeable_p (state *s, state *other, int max_locals) + +{ + int i; + + /* This is tricky: if the stack sizes differ, then not only are + these not mergeable, but in fact we should give an error, as + we've found two execution paths that reach a branch target + with different stack depths. FIXME stackdepth instead? */ + if (s->stacktop != other->stacktop) + verify_fail ("stack sizes differ"); + + for (i = 0; i < s->stacktop; ++i) + if (! type_state_mergeable_p (&s->stack[i], &other->stack[i])) + return false; + for (i = 0; i < max_locals; ++i) + if (! type_state_mergeable_p (&s->locals[i], &other->locals[i])) + return false; + return true; +} + +static void +state_reverify (state *s) +{ + if (s->next == INVALID_STATE) + { + s->next = vfr->next_verify_state; + vfr->next_verify_state = s; + } +} + +#ifdef VERIFY_DEBUG +static void +debug_print_state (state *s, const char *leader, int pc, int max_stack, + int max_locals) +{ + int i; + debug_print ("%s [%4d]: [stack] ", leader, pc); + for (i = 0; i < s->stacktop; ++i) + type_print (&s->stack[i]); + for (; i < max_stack; ++i) + debug_print ("."); + debug_print (" [local] "); + for (i = 0; i < max_locals; ++i) + type_print (&s->locals[i]); + debug_print (" | %p\n", s); +} +#else +static void +debug_print_state (state *s ATTRIBUTE_UNUSED, + const char *leader ATTRIBUTE_UNUSED, + int pc ATTRIBUTE_UNUSED, int max_stack ATTRIBUTE_UNUSED, + int max_locals ATTRIBUTE_UNUSED) +{ +} +#endif /* VERIFY_DEBUG */ + +static type +pop_raw (void) +{ + type r; + state *s = vfr->current_state; + if (s->stacktop <= 0) + verify_fail ("stack empty"); + r = s->stack[--s->stacktop]; + s->stackdepth -= type_depth (&r); + if (s->stackdepth < 0) + verify_fail_pc ("stack empty", vfr->start_PC); + return r; +} + +static type +pop32 (void) +{ + type r = pop_raw (); + if (type_iswide (&r)) + verify_fail ("narrow pop of wide type"); + return r; +} + +static type +vfy_pop_type_t (type match) +{ + type t; + vfy_promote_type (&match); + t = pop_raw (); + if (! types_compatible (&match, &t)) + verify_fail ("incompatible type on stack"); + return t; +} + +static type +vfy_pop_type (type_val match) +{ + type t = make_type (match); + return vfy_pop_type_t (t); +} + +#define pop_type vfy_pop_type +#define pop_type_t vfy_pop_type_t + +/* Pop a reference which is guaranteed to be initialized. MATCH + doesn't have to be a reference type; in this case this acts like + pop_type. */ +static type +pop_init_ref_t (type match) +{ + type t = pop_raw (); + if (type_isreference (&t) && ! type_initialized (&t)) + verify_fail ("initialized reference required"); + else if (! types_compatible (&match, &t)) + verify_fail ("incompatible type on stack"); + return t; +} + +static type +pop_init_ref (type_val match) +{ + type t = make_type (match); + return pop_init_ref_t (t); +} + +/* Pop a reference type or a return address. */ +static type +pop_ref_or_return (void) +{ + type t = pop_raw (); + if (! type_isreference (&t) && t.key != return_address_type) + verify_fail ("expected reference or return address on stack"); + return t; +} + +static void +vfy_push_type_t (type t) +{ + int depth; + state *s = vfr->current_state; + /* If T is a numeric type like short, promote it to int. */ + promote_type (&t); + + depth = type_depth (&t); + + if (s->stackdepth + depth > vfr->current_method->max_stack) + verify_fail ("stack overflow"); + s->stack[s->stacktop++] = t; + s->stackdepth += depth; +} + +static void +vfy_push_type (type_val tval) +{ + type t = make_type (tval); + vfy_push_type_t (t); +} + +#define push_type vfy_push_type +#define push_type_t vfy_push_type_t + +static void +set_variable (int index, type t) +{ + int depth; + state *s = vfr->current_state; + /* If T is a numeric type like short, promote it to int. */ + promote_type (&t); + + depth = type_depth (&t); + if (index > vfr->current_method->max_locals - depth) + verify_fail ("invalid local variable"); + s->locals[index] = t; + + if (depth == 2) + init_type_from_tag (&s->locals[index + 1], continuation_type); + if (index > 0 && type_iswide (&s->locals[index - 1])) + init_type_from_tag (&s->locals[index - 1], unsuitable_type); +} + +static type +get_variable_t (int index, type *t) +{ + state *s = vfr->current_state; + int depth = type_depth (t); + if (index > vfr->current_method->max_locals - depth) + verify_fail ("invalid local variable"); + if (! types_compatible (t, &s->locals[index])) + verify_fail ("incompatible type in local variable"); + if (depth == 2) + { + type cont = make_type (continuation_type); + if (! types_compatible (&s->locals[index + 1], &cont)) + verify_fail ("invalid local variable"); + } + return s->locals[index]; +} + +static type +get_variable (int index, type_val v) +{ + type t = make_type (v); + return get_variable_t (index, &t); +} + +/* Make sure ARRAY is an array type and that its elements are + compatible with type ELEMENT. Returns the actual element type. */ +static type +require_array_type_t (type array, type element) +{ + type t; + /* An odd case. Here we just pretend that everything went ok. If + the requested element type is some kind of reference, return + the null type instead. */ + if (type_isnull (&array)) + return type_isreference (&element) ? make_type (null_type) : element; + + if (! type_isarray (&array)) + verify_fail ("array required"); + + t = type_array_element (&array); + if (! types_compatible (&element, &t)) + { + /* Special case for byte arrays, which must also be boolean + arrays. */ + bool ok = true; + if (element.key == byte_type) + { + type e2 = make_type (boolean_type); + ok = types_compatible (&e2, &t); + } + if (! ok) + verify_fail ("incompatible array element type"); + } + + /* Return T and not ELEMENT, because T might be specialized. */ + return t; +} + +static type +require_array_type (type array, type_val element) +{ + type t = make_type (element); + return require_array_type_t (array, t); +} + +static jint +get_byte (void) +{ + if (vfr->PC >= vfr->current_method->code_length) + verify_fail ("premature end of bytecode"); + return (jint) vfr->bytecode[vfr->PC++] & 0xff; +} + +static jint +get_ushort (void) +{ + jint b1 = get_byte (); + jint b2 = get_byte (); + return (jint) ((b1 << 8) | b2) & 0xffff; +} + +static jint +get_short (void) +{ + signed char b1 = (signed char) get_byte (); + jint b2 = get_byte (); + jshort s = (b1 << 8) | b2; + return (jint) s; +} + +static jint +get_int (void) +{ + jint b1 = get_byte (); + jint b2 = get_byte (); + jint b3 = get_byte (); + jint b4 = get_byte (); + jword result = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; + /* In the compiler, 'jint' might have more than 32 bits, so we must + sign extend. */ + return WORD_TO_INT (result); +} + +static int +compute_jump (int offset) +{ + int npc = vfr->start_PC + offset; + if (npc < 0 || npc >= vfr->current_method->code_length) + verify_fail_pc ("branch out of range", vfr->start_PC); + return npc; +} + +/* Add a new state to the state list at NPC. */ +static state * +add_new_state (int npc, state *old_state) +{ + state_list *nlink; + vfy_method *current_method = vfr->current_method; + state *new_state = make_state_copy (old_state, current_method->max_stack, + current_method->max_locals); + debug_print ("== New state in add_new_state\n"); + debug_print_state (new_state, "New", npc, current_method->max_stack, + current_method->max_locals); + + nlink = (state_list *) vfy_alloc (sizeof (state_list)); + nlink->val = new_state; + nlink->next = vfr->states[npc]; + vfr->states[npc] = nlink; + new_state->pc = npc; + return new_state; +} + +/* Merge the indicated state into the state at the branch target and + schedule a new PC if there is a change. NPC is the PC of the + branch target, and FROM_STATE is the state at the source of the + branch. This method returns true if the destination state + changed and requires reverification, false otherwise. */ +static void +merge_into (int npc, state *from_state) +{ + /* Iterate over all target states and merge our state into each, + if applicable. FIXME one improvement we could make here is + "state destruction". Merging a new state into an existing one + might cause a return_address_type to be merged to + unsuitable_type. In this case the resulting state may now be + mergeable with other states currently held in parallel at this + location. So in this situation we could pairwise compare and + reduce the number of parallel states. */ + state_list *iter; + bool applicable = false; + for (iter = vfr->states[npc]; iter != NULL; iter = iter->next) + { + state *new_state = iter->val; + vfy_method *current_method = vfr->current_method; + + if (state_mergeable_p (new_state, from_state, + current_method->max_locals)) + { + bool changed; + applicable = true; + + debug_print ("== Merge states in merge_into\n"); + debug_print_state (from_state, "Frm", vfr->start_PC, current_method->max_stack, + current_method->max_locals); + debug_print_state (new_state, " To", npc, current_method->max_stack, + current_method->max_locals); + changed = merge_states (new_state, from_state, + current_method->max_locals); + debug_print_state (new_state, "New", npc, current_method->max_stack, + current_method->max_locals); + + if (changed) + state_reverify (new_state); + } + } + + if (! applicable) + { + /* Either we don't yet have a state at NPC, or we have a + return-address type that is in conflict with all existing + state. So, we need to create a new entry. */ + state *new_state = add_new_state (npc, from_state); + /* A new state added in this way must always be reverified. */ + state_reverify (new_state); + } +} + +static void +push_jump (int offset) +{ + int npc = compute_jump (offset); + /* According to the JVM Spec, we need to check for uninitialized + objects here. However, this does not actually affect type + safety, and the Eclipse java compiler generates code that + violates this constraint. */ + merge_into (npc, vfr->current_state); +} + +static void +push_exception_jump (type t, int pc) +{ + state s; + /* According to the JVM Spec, we need to check for uninitialized + objects here. However, this does not actually affect type + safety, and the Eclipse java compiler generates code that + violates this constraint. */ + copy_state_with_stack (&s, vfr->current_state, + vfr->current_method->max_stack, + vfr->current_method->max_locals); + if (vfr->current_method->max_stack < 1) + verify_fail ("stack overflow at exception handler"); + state_set_exception (&s, &t, vfr->current_method->max_stack); + merge_into (pc, &s); + /* FIXME: leak.. need free_state or GC */ +} + +static state * +pop_jump (void) +{ + state *new_state = vfr->next_verify_state; + if (new_state == INVALID_STATE) + verify_fail ("programmer error in pop_jump"); + if (new_state != NULL) + { + vfr->next_verify_state = new_state->next; + new_state->next = INVALID_STATE; + } + return new_state; +} + +static void +invalidate_pc (void) +{ + vfr->PC = NO_NEXT; +} + +static void +note_branch_target (int pc) +{ + /* Don't check `pc <= PC', because we've advanced PC after + fetching the target and we haven't yet checked the next + instruction. */ + if (pc < vfr->PC && ! (vfr->flags[pc] & FLAG_INSN_START)) + verify_fail_pc ("branch not to instruction start", vfr->start_PC); + vfr->flags[pc] |= FLAG_BRANCH_TARGET; +} + +static void +skip_padding (void) +{ + while ((vfr->PC % 4) > 0) + if (get_byte () != 0) + verify_fail ("found nonzero padding byte"); +} + +/* Do the work for a `ret' instruction. INDEX is the index into the + local variables. */ +static void +handle_ret_insn (int index) +{ + type ret = make_type (return_address_type); + type ret_addr = get_variable_t (index, &ret); + /* It would be nice if we could do this. However, the JVM Spec + doesn't say that this is what happens. It is implied that + reusing a return address is invalid, but there's no actual + prohibition against it. */ + /* set_variable (index, unsuitable_type); */ + + int npc = type_get_pc (&ret_addr); + /* We might be returning to a `jsr' that is at the end of the + bytecode. This is ok if we never return from the called + subroutine, but if we see this here it is an error. */ + if (npc >= vfr->current_method->code_length) + verify_fail ("fell off end"); + + /* According to the JVM Spec, we need to check for uninitialized + objects here. However, this does not actually affect type + safety, and the Eclipse java compiler generates code that + violates this constraint. */ + merge_into (npc, vfr->current_state); + invalidate_pc (); +} + +static void handle_jsr_insn (int offset) +{ + type ret_addr; + int npc = compute_jump (offset); + + /* According to the JVM Spec, we need to check for uninitialized + objects here. However, this does not actually affect type + safety, and the Eclipse java compiler generates code that + violates this constraint. */ + + /* Modify our state as appropriate for entry into a subroutine. */ + ret_addr = make_type (return_address_type); + type_set_return_address (&ret_addr, vfr->PC); + vfy_push_type_t (ret_addr); + merge_into (npc, vfr->current_state); + invalidate_pc (); +} + +static vfy_jclass +construct_primitive_array_type (type_val prim) +{ + vfy_jclass k = NULL; + switch (prim) + { + case boolean_type: + case char_type: + case float_type: + case double_type: + case byte_type: + case short_type: + case int_type: + case long_type: + k = vfy_get_primitive_type ((int) prim); + break; + + /* These aren't used here but we call them out to avoid + warnings. */ + case void_type: + case unsuitable_type: + case return_address_type: + case continuation_type: + case reference_type: + case null_type: + case uninitialized_reference_type: + default: + verify_fail ("unknown type in construct_primitive_array_type"); + } + k = vfy_get_array_class (k); + return k; +} + +/* This pass computes the location of branch targets and also + instruction starts. */ +static void +branch_prepass (void) +{ + int i, pc; + vfr->flags = (char *) vfy_alloc (vfr->current_method->code_length); + + for (i = 0; i < vfr->current_method->code_length; ++i) + vfr->flags[i] = 0; + + vfr->PC = 0; + while (vfr->PC < vfr->current_method->code_length) + { + java_opcode opcode; + /* Set `start_PC' early so that error checking can have the + correct value. */ + vfr->start_PC = vfr->PC; + vfr->flags[vfr->PC] |= FLAG_INSN_START; + + opcode = (java_opcode) vfr->bytecode[vfr->PC++]; + switch (opcode) + { + case op_nop: + case op_aconst_null: + case op_iconst_m1: + case op_iconst_0: + case op_iconst_1: + case op_iconst_2: + case op_iconst_3: + case op_iconst_4: + case op_iconst_5: + case op_lconst_0: + case op_lconst_1: + case op_fconst_0: + case op_fconst_1: + case op_fconst_2: + case op_dconst_0: + case op_dconst_1: + case op_iload_0: + case op_iload_1: + case op_iload_2: + case op_iload_3: + case op_lload_0: + case op_lload_1: + case op_lload_2: + case op_lload_3: + case op_fload_0: + case op_fload_1: + case op_fload_2: + case op_fload_3: + case op_dload_0: + case op_dload_1: + case op_dload_2: + case op_dload_3: + case op_aload_0: + case op_aload_1: + case op_aload_2: + case op_aload_3: + case op_iaload: + case op_laload: + case op_faload: + case op_daload: + case op_aaload: + case op_baload: + case op_caload: + case op_saload: + case op_istore_0: + case op_istore_1: + case op_istore_2: + case op_istore_3: + case op_lstore_0: + case op_lstore_1: + case op_lstore_2: + case op_lstore_3: + case op_fstore_0: + case op_fstore_1: + case op_fstore_2: + case op_fstore_3: + case op_dstore_0: + case op_dstore_1: + case op_dstore_2: + case op_dstore_3: + case op_astore_0: + case op_astore_1: + case op_astore_2: + case op_astore_3: + case op_iastore: + case op_lastore: + case op_fastore: + case op_dastore: + case op_aastore: + case op_bastore: + case op_castore: + case op_sastore: + case op_pop: + case op_pop2: + case op_dup: + case op_dup_x1: + case op_dup_x2: + case op_dup2: + case op_dup2_x1: + case op_dup2_x2: + case op_swap: + case op_iadd: + case op_isub: + case op_imul: + case op_idiv: + case op_irem: + case op_ishl: + case op_ishr: + case op_iushr: + case op_iand: + case op_ior: + case op_ixor: + case op_ladd: + case op_lsub: + case op_lmul: + case op_ldiv: + case op_lrem: + case op_lshl: + case op_lshr: + case op_lushr: + case op_land: + case op_lor: + case op_lxor: + case op_fadd: + case op_fsub: + case op_fmul: + case op_fdiv: + case op_frem: + case op_dadd: + case op_dsub: + case op_dmul: + case op_ddiv: + case op_drem: + case op_ineg: + case op_i2b: + case op_i2c: + case op_i2s: + case op_lneg: + case op_fneg: + case op_dneg: + case op_i2l: + case op_i2f: + case op_i2d: + case op_l2i: + case op_l2f: + case op_l2d: + case op_f2i: + case op_f2l: + case op_f2d: + case op_d2i: + case op_d2l: + case op_d2f: + case op_lcmp: + case op_fcmpl: + case op_fcmpg: + case op_dcmpl: + case op_dcmpg: + case op_monitorenter: + case op_monitorexit: + case op_ireturn: + case op_lreturn: + case op_freturn: + case op_dreturn: + case op_areturn: + case op_return: + case op_athrow: + case op_arraylength: + break; + + case op_bipush: + case op_ldc: + case op_iload: + case op_lload: + case op_fload: + case op_dload: + case op_aload: + case op_istore: + case op_lstore: + case op_fstore: + case op_dstore: + case op_astore: + case op_ret: + case op_newarray: + get_byte (); + break; + + case op_iinc: + case op_sipush: + case op_ldc_w: + case op_ldc2_w: + case op_getstatic: + case op_getfield: + case op_putfield: + case op_putstatic: + case op_new: + case op_anewarray: + case op_instanceof: + case op_checkcast: + case op_invokespecial: + case op_invokestatic: + case op_invokevirtual: + get_short (); + break; + + case op_multianewarray: + get_short (); + get_byte (); + break; + + case op_jsr: + case op_ifeq: + case op_ifne: + case op_iflt: + case op_ifge: + case op_ifgt: + case op_ifle: + case op_if_icmpeq: + case op_if_icmpne: + case op_if_icmplt: + case op_if_icmpge: + case op_if_icmpgt: + case op_if_icmple: + case op_if_acmpeq: + case op_if_acmpne: + case op_ifnull: + case op_ifnonnull: + case op_goto: + note_branch_target (compute_jump (get_short ())); + break; + + case op_tableswitch: + { + jint low, hi; + skip_padding (); + note_branch_target (compute_jump (get_int ())); + low = get_int (); + hi = get_int (); + if (low > hi) + verify_fail_pc ("invalid tableswitch", vfr->start_PC); + for (i = low; i <= hi; ++i) + note_branch_target (compute_jump (get_int ())); + } + break; + + case op_lookupswitch: + { + int npairs; + skip_padding (); + note_branch_target (compute_jump (get_int ())); + npairs = get_int (); + if (npairs < 0) + verify_fail_pc ("too few pairs in lookupswitch", vfr->start_PC); + while (npairs-- > 0) + { + get_int (); + note_branch_target (compute_jump (get_int ())); + } + } + break; + + case op_invokeinterface: + get_short (); + get_byte (); + get_byte (); + break; + + case op_wide: + { + opcode = (java_opcode) get_byte (); + get_short (); + if (opcode == op_iinc) + get_short (); + } + break; + + case op_jsr_w: + case op_goto_w: + note_branch_target (compute_jump (get_int ())); + break; + +#if 0 + /* These are unused here, but we call them out explicitly + so that -Wswitch-enum doesn't complain. */ + case op_putfield_1: + case op_putfield_2: + case op_putfield_4: + case op_putfield_8: + case op_putfield_a: + case op_putstatic_1: + case op_putstatic_2: + case op_putstatic_4: + case op_putstatic_8: + case op_putstatic_a: + case op_getfield_1: + case op_getfield_2s: + case op_getfield_2u: + case op_getfield_4: + case op_getfield_8: + case op_getfield_a: + case op_getstatic_1: + case op_getstatic_2s: + case op_getstatic_2u: + case op_getstatic_4: + case op_getstatic_8: + case op_getstatic_a: +#endif /* VFY_FAST_OPCODES */ + default: + verify_fail_pc ("unrecognized instruction in branch_prepass", + vfr->start_PC); + } + + /* See if any previous branch tried to branch to the middle of + this instruction. */ + for (pc = vfr->start_PC + 1; pc < vfr->PC; ++pc) + { + if ((vfr->flags[pc] & FLAG_BRANCH_TARGET)) + verify_fail_pc ("branch to middle of instruction", pc); + } + } + + /* Verify exception handlers. */ + for (i = 0; i < vfr->current_method->exc_count; ++i) + { + int handler, start, end, htype; + vfy_get_exception (vfr->exception, i, &handler, &start, &end, &htype); + if (! (vfr->flags[handler] & FLAG_INSN_START)) + verify_fail_pc ("exception handler not at instruction start", + handler); + if (! (vfr->flags[start] & FLAG_INSN_START)) + verify_fail_pc ("exception start not at instruction start", start); + if (end != vfr->current_method->code_length + && ! (vfr->flags[end] & FLAG_INSN_START)) + verify_fail_pc ("exception end not at instruction start", end); + + vfr->flags[handler] |= FLAG_BRANCH_TARGET; + } +} + +static void +check_pool_index (int index) +{ + if (index < 0 || index >= vfy_get_constants_size (vfr->current_class)) + verify_fail_pc ("constant pool index out of range", vfr->start_PC); +} + +static type +check_class_constant (int index) +{ + type t = { (type_val) 0, 0, 0 }; + vfy_constants *pool; + + check_pool_index (index); + pool = vfy_get_constants (vfr->current_class); + if (vfy_tag (pool, index) == JV_CONSTANT_ResolvedClass) + init_type_from_class (&t, vfy_get_pool_class (pool, index)); + else if (vfy_tag (pool, index) == JV_CONSTANT_Class) + init_type_from_string (&t, vfy_get_pool_string (pool, index)); + else + verify_fail_pc ("expected class constant", vfr->start_PC); + return t; +} + +static type +check_constant (int index) +{ + type t = { (type_val) 0, 0, 0 }; + vfy_constants *pool; + + check_pool_index (index); + pool = vfy_get_constants (vfr->current_class); + if (vfy_tag (pool, index) == JV_CONSTANT_ResolvedString + || vfy_tag (pool, index) == JV_CONSTANT_String) + init_type_from_class (&t, vfy_string_type ()); + else if (vfy_tag (pool, index) == JV_CONSTANT_Integer) + init_type_from_tag (&t, int_type); + else if (vfy_tag (pool, index) == JV_CONSTANT_Float) + init_type_from_tag (&t, float_type); + else if (vfy_tag (pool, index) == JV_CONSTANT_Class + || vfy_tag (pool, index) == JV_CONSTANT_ResolvedClass) + /* FIXME: should only allow this for 1.5 bytecode. */ + init_type_from_class (&t, vfy_class_type ()); + else + verify_fail_pc ("String, int, or float constant expected", vfr->start_PC); + return t; +} + +static type +check_wide_constant (int index) +{ + type t = { (type_val) 0, 0, 0 }; + vfy_constants *pool; + + check_pool_index (index); + pool = vfy_get_constants (vfr->current_class); + if (vfy_tag (pool, index) == JV_CONSTANT_Long) + init_type_from_tag (&t, long_type); + else if (vfy_tag (pool, index) == JV_CONSTANT_Double) + init_type_from_tag (&t, double_type); + else + verify_fail_pc ("long or double constant expected", vfr->start_PC); + return t; +} + +/* Helper for both field and method. These are laid out the same in + the constant pool. */ +static type +handle_field_or_method (int index, int expected, + vfy_string *name, vfy_string *fmtype) +{ + vfy_uint_16 class_index, name_and_type_index; + vfy_uint_16 name_index, desc_index; + vfy_constants *pool; + + check_pool_index (index); + pool = vfy_get_constants (vfr->current_class); + if (vfy_tag (pool, index) != expected) + verify_fail_pc ("didn't see expected constant", vfr->start_PC); + /* Once we know we have a Fieldref or Methodref we assume that it + is correctly laid out in the constant pool. I think the code + in defineclass.cc guarantees this. */ + vfy_load_indexes (pool, index, &class_index, &name_and_type_index); + vfy_load_indexes (pool, name_and_type_index, &name_index, &desc_index); + + *name = vfy_get_pool_string (pool, name_index); + *fmtype = vfy_get_pool_string (pool, desc_index); + + return check_class_constant (class_index); +} + +/* Return field's type, compute class' type if requested. If + PUTFIELD is true, use the special 'putfield' semantics. */ +static type +check_field_constant (int index, type *class_type, bool putfield) +{ + vfy_string name, field_type; + const char *typec; + type t; + + type ct = handle_field_or_method (index, + JV_CONSTANT_Fieldref, + &name, &field_type); + if (class_type) + *class_type = ct; + typec = vfy_string_bytes (field_type); + if (typec[0] == '[' || typec[0] == 'L') + init_type_from_string (&t, field_type); + else + init_type_from_tag (&t, get_type_val_for_signature (typec[0])); + + /* We have an obscure special case here: we can use `putfield' on a + field declared in this class, even if `this' has not yet been + initialized. */ + if (putfield + && ! type_initialized (&vfr->current_state->this_type) + && vfr->current_state->this_type.pc == SELF + && types_equal (&vfr->current_state->this_type, &ct) + && vfy_class_has_field (vfr->current_class, name, field_type)) + /* Note that we don't actually know whether we're going to match + against 'this' or some other object of the same type. So, + here we set things up so that it doesn't matter. This relies + on knowing what our caller is up to. */ + type_set_uninitialized (class_type, EITHER); + + return t; +} + +static type +check_method_constant (int index, bool is_interface, + vfy_string *method_name, + vfy_string *method_signature) +{ + return handle_field_or_method (index, + (is_interface + ? JV_CONSTANT_InterfaceMethodref + : JV_CONSTANT_Methodref), + method_name, method_signature); +} + +static const char * +get_one_type (const char *p, type *t) +{ + const char *start = p; + vfy_jclass k; + type_val rt; + char v; + + int arraycount = 0; + while (*p == '[') + { + ++arraycount; + ++p; + } + + v = *p++; + + if (v == 'L') + { + vfy_string name; + while (*p != ';') + ++p; + ++p; + name = vfy_get_string (start, p - start); + *t = make_type_from_string (name); + return p; + } + + /* Casting to jchar here is ok since we are looking at an ASCII + character. */ + rt = get_type_val_for_signature (v); + + if (arraycount == 0) + { + /* Callers of this function eventually push their arguments on + the stack. So, promote them here. */ + type new_t = make_type (rt); + vfy_promote_type (&new_t); + *t = new_t; + return p; + } + + k = construct_primitive_array_type (rt); + while (--arraycount > 0) + k = vfy_get_array_class (k); + *t = make_type_from_class (k); + return p; +} + +static void +compute_argument_types (vfy_string signature, type *types) +{ + int i; + const char *p = vfy_string_bytes (signature); + + /* Skip `('. */ + ++p; + + i = 0; + while (*p != ')') + p = get_one_type (p, &types[i++]); +} + +static type +compute_return_type (vfy_string signature) +{ + const char *p = vfy_string_bytes (signature); + type t; + while (*p != ')') + ++p; + ++p; + get_one_type (p, &t); + return t; +} + +static void +check_return_type (type onstack) +{ + type rt = compute_return_type (vfy_get_signature (vfr->current_method)); + if (! types_compatible (&rt, &onstack)) + verify_fail ("incompatible return type"); +} + +/* Initialize the stack for the new method. Returns true if this + method is an instance initializer. */ +static bool +initialize_stack (void) +{ + int arg_count, i; + int var = 0; + bool is_init = vfy_strings_equal (vfy_get_method_name (vfr->current_method), + vfy_init_name()); + bool is_clinit = vfy_strings_equal (vfy_get_method_name (vfr->current_method), + vfy_clinit_name()); + + if (! vfy_is_static (vfr->current_method)) + { + type kurr = make_type_from_class (vfr->current_class); + if (is_init) + { + type_set_uninitialized (&kurr, SELF); + is_init = true; + } + else if (is_clinit) + verify_fail ("<clinit> method must be static"); + set_variable (0, kurr); + state_set_this_type (vfr->current_state, &kurr); + ++var; + } + else + { + if (is_init) + verify_fail ("<init> method must be non-static"); + } + + /* We have to handle wide arguments specially here. */ + arg_count = vfy_count_arguments (vfy_get_signature (vfr->current_method)); + { + type *arg_types = (type *) vfy_alloc (arg_count * sizeof (type)); + compute_argument_types (vfy_get_signature (vfr->current_method), arg_types); + for (i = 0; i < arg_count; ++i) + { + set_variable (var, arg_types[i]); + ++var; + if (type_iswide (&arg_types[i])) + ++var; + } + vfy_free (arg_types); + } + + return is_init; +} + +static void +verify_instructions_0 (void) +{ + int i; + bool this_is_init; + + vfr->current_state = make_state (vfr->current_method->max_stack, + vfr->current_method->max_locals); + + vfr->PC = 0; + vfr->start_PC = 0; + + /* True if we are verifying an instance initializer. */ + this_is_init = initialize_stack (); + + vfr->states = (state_list **) vfy_alloc (sizeof (state_list *) + * vfr->current_method->code_length); + + for (i = 0; i < vfr->current_method->code_length; ++i) + vfr->states[i] = NULL; + + vfr->next_verify_state = NULL; + + while (true) + { + java_opcode opcode; + + /* If the PC was invalidated, get a new one from the work list. */ + if (vfr->PC == NO_NEXT) + { + state *new_state = pop_jump (); + /* If it is null, we're done. */ + if (new_state == NULL) + break; + + vfr->PC = new_state->pc; + debug_print ("== State pop from pending list\n"); + /* Set up the current state. */ + copy_state (vfr->current_state, new_state, + vfr->current_method->max_stack, vfr->current_method->max_locals); + } + else + { + /* We only have to do this checking in the situation where + control flow falls through from the previous instruction. + Otherwise merging is done at the time we push the branch. + Note that we'll catch the off-the-end problem just + below. */ + if (vfr->PC < vfr->current_method->code_length + && vfr->states[vfr->PC] != NULL) + { + /* We've already visited this instruction. So merge + the states together. It is simplest, but not most + efficient, to just always invalidate the PC here. */ + merge_into (vfr->PC, vfr->current_state); + invalidate_pc (); + continue; + } + } + + /* Control can't fall off the end of the bytecode. We need to + check this in both cases, not just the fall-through case, + because we don't check to see whether a `jsr' appears at + the end of the bytecode until we process a `ret'. */ + if (vfr->PC >= vfr->current_method->code_length) + verify_fail ("fell off end"); + vfr->flags[vfr->PC] |= FLAG_INSN_SEEN; + + /* We only have to keep saved state at branch targets. If + we're at a branch target and the state here hasn't been set + yet, we set it now. You might notice that `ret' targets + won't necessarily have FLAG_BRANCH_TARGET set. This + doesn't matter, since those states will be filled in by + merge_into. */ + /* Note that other parts of the compiler assume that there is a + label with a type map at PC=0. */ + if (vfr->states[vfr->PC] == NULL + && (vfr->PC == 0 || (vfr->flags[vfr->PC] & FLAG_BRANCH_TARGET) != 0)) + add_new_state (vfr->PC, vfr->current_state); + + /* Set this before handling exceptions so that debug output is + sane. */ + vfr->start_PC = vfr->PC; + + /* Update states for all active exception handlers. Ordinarily + there are not many exception handlers. So we simply run + through them all. */ + for (i = 0; i < vfr->current_method->exc_count; ++i) + { + int hpc, start, end, htype; + vfy_get_exception (vfr->exception, i, &hpc, &start, &end, &htype); + if (vfr->PC >= start && vfr->PC < end) + { + type handler = make_type_from_class (vfy_throwable_type ()); + if (htype != 0) + handler = check_class_constant (htype); + push_exception_jump (handler, hpc); + } + } + + + debug_print_state (vfr->current_state, " ", vfr->PC, + vfr->current_method->max_stack, + vfr->current_method->max_locals); + opcode = (java_opcode) vfr->bytecode[vfr->PC++]; + switch (opcode) + { + case op_nop: + break; + + case op_aconst_null: + push_type (null_type); + break; + + case op_iconst_m1: + case op_iconst_0: + case op_iconst_1: + case op_iconst_2: + case op_iconst_3: + case op_iconst_4: + case op_iconst_5: + push_type (int_type); + break; + + case op_lconst_0: + case op_lconst_1: + push_type (long_type); + break; + + case op_fconst_0: + case op_fconst_1: + case op_fconst_2: + push_type (float_type); + break; + + case op_dconst_0: + case op_dconst_1: + push_type (double_type); + break; + + case op_bipush: + get_byte (); + push_type (int_type); + break; + + case op_sipush: + get_short (); + push_type (int_type); + break; + + case op_ldc: + push_type_t (check_constant (get_byte ())); + break; + case op_ldc_w: + push_type_t (check_constant (get_ushort ())); + break; + case op_ldc2_w: + push_type_t (check_wide_constant (get_ushort ())); + break; + + case op_iload: + push_type_t (get_variable (get_byte (), int_type)); + break; + case op_lload: + push_type_t (get_variable (get_byte (), long_type)); + break; + case op_fload: + push_type_t (get_variable (get_byte (), float_type)); + break; + case op_dload: + push_type_t (get_variable (get_byte (), double_type)); + break; + case op_aload: + push_type_t (get_variable (get_byte (), reference_type)); + break; + + case op_iload_0: + case op_iload_1: + case op_iload_2: + case op_iload_3: + push_type_t (get_variable (opcode - op_iload_0, int_type)); + break; + case op_lload_0: + case op_lload_1: + case op_lload_2: + case op_lload_3: + push_type_t (get_variable (opcode - op_lload_0, long_type)); + break; + case op_fload_0: + case op_fload_1: + case op_fload_2: + case op_fload_3: + push_type_t (get_variable (opcode - op_fload_0, float_type)); + break; + case op_dload_0: + case op_dload_1: + case op_dload_2: + case op_dload_3: + push_type_t (get_variable (opcode - op_dload_0, double_type)); + break; + case op_aload_0: + case op_aload_1: + case op_aload_2: + case op_aload_3: + push_type_t (get_variable (opcode - op_aload_0, reference_type)); + break; + case op_iaload: + pop_type (int_type); + push_type_t (require_array_type (pop_init_ref (reference_type), + int_type)); + break; + case op_laload: + pop_type (int_type); + push_type_t (require_array_type (pop_init_ref (reference_type), + long_type)); + break; + case op_faload: + pop_type (int_type); + push_type_t (require_array_type (pop_init_ref (reference_type), + float_type)); + break; + case op_daload: + pop_type (int_type); + push_type_t (require_array_type (pop_init_ref (reference_type), + double_type)); + break; + case op_aaload: + pop_type (int_type); + push_type_t (require_array_type (pop_init_ref (reference_type), + reference_type)); + break; + case op_baload: + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), byte_type); + push_type (int_type); + break; + case op_caload: + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), char_type); + push_type (int_type); + break; + case op_saload: + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), short_type); + push_type (int_type); + break; + case op_istore: + set_variable (get_byte (), pop_type (int_type)); + break; + case op_lstore: + set_variable (get_byte (), pop_type (long_type)); + break; + case op_fstore: + set_variable (get_byte (), pop_type (float_type)); + break; + case op_dstore: + set_variable (get_byte (), pop_type (double_type)); + break; + case op_astore: + set_variable (get_byte (), pop_ref_or_return ()); + break; + case op_istore_0: + case op_istore_1: + case op_istore_2: + case op_istore_3: + set_variable (opcode - op_istore_0, pop_type (int_type)); + break; + case op_lstore_0: + case op_lstore_1: + case op_lstore_2: + case op_lstore_3: + set_variable (opcode - op_lstore_0, pop_type (long_type)); + break; + case op_fstore_0: + case op_fstore_1: + case op_fstore_2: + case op_fstore_3: + set_variable (opcode - op_fstore_0, pop_type (float_type)); + break; + case op_dstore_0: + case op_dstore_1: + case op_dstore_2: + case op_dstore_3: + set_variable (opcode - op_dstore_0, pop_type (double_type)); + break; + case op_astore_0: + case op_astore_1: + case op_astore_2: + case op_astore_3: + set_variable (opcode - op_astore_0, pop_ref_or_return ()); + break; + case op_iastore: + pop_type (int_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), int_type); + break; + case op_lastore: + pop_type (long_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), long_type); + break; + case op_fastore: + pop_type (float_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), float_type); + break; + case op_dastore: + pop_type (double_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), double_type); + break; + case op_aastore: + pop_type (reference_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), reference_type); + break; + case op_bastore: + pop_type (int_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), byte_type); + break; + case op_castore: + pop_type (int_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), char_type); + break; + case op_sastore: + pop_type (int_type); + pop_type (int_type); + require_array_type (pop_init_ref (reference_type), short_type); + break; + case op_pop: + pop32 (); + break; + case op_pop2: + { + type t = pop_raw (); + if (! type_iswide (&t)) + pop32 (); + } + break; + case op_dup: + { + type t = pop32 (); + push_type_t (t); + push_type_t (t); + } + break; + case op_dup_x1: + { + type t1 = pop32 (); + type t2 = pop32 (); + push_type_t (t1); + push_type_t (t2); + push_type_t (t1); + } + break; + case op_dup_x2: + { + type t1 = pop32 (); + type t2 = pop_raw (); + if (! type_iswide (&t2)) + { + type t3 = pop32 (); + push_type_t (t1); + push_type_t (t3); + } + else + push_type_t (t1); + push_type_t (t2); + push_type_t (t1); + } + break; + case op_dup2: + { + type t = pop_raw (); + if (! type_iswide (&t)) + { + type t2 = pop32 (); + push_type_t (t2); + push_type_t (t); + push_type_t (t2); + } + else + push_type_t (t); + push_type_t (t); + } + break; + case op_dup2_x1: + { + type t1 = pop_raw (); + type t2 = pop32 (); + if (! type_iswide (&t1)) + { + type t3 = pop32 (); + push_type_t (t2); + push_type_t (t1); + push_type_t (t3); + } + else + push_type_t (t1); + push_type_t (t2); + push_type_t (t1); + } + break; + case op_dup2_x2: + { + type t1 = pop_raw (); + if (type_iswide (&t1)) + { + type t2 = pop_raw (); + if (type_iswide (&t2)) + { + push_type_t (t1); + push_type_t (t2); + } + else + { + type t3 = pop32 (); + push_type_t (t1); + push_type_t (t3); + push_type_t (t2); + } + push_type_t (t1); + } + else + { + type t2 = pop32 (); + type t3 = pop_raw (); + if (type_iswide (&t3)) + { + push_type_t (t2); + push_type_t (t1); + } + else + { + type t4 = pop32 (); + push_type_t (t2); + push_type_t (t1); + push_type_t (t4); + } + push_type_t (t3); + push_type_t (t2); + push_type_t (t1); + } + } + break; + case op_swap: + { + type t1 = pop32 (); + type t2 = pop32 (); + push_type_t (t1); + push_type_t (t2); + } + break; + case op_iadd: + case op_isub: + case op_imul: + case op_idiv: + case op_irem: + case op_ishl: + case op_ishr: + case op_iushr: + case op_iand: + case op_ior: + case op_ixor: + pop_type (int_type); + push_type_t (pop_type (int_type)); + break; + case op_ladd: + case op_lsub: + case op_lmul: + case op_ldiv: + case op_lrem: + case op_land: + case op_lor: + case op_lxor: + pop_type (long_type); + push_type_t (pop_type (long_type)); + break; + case op_lshl: + case op_lshr: + case op_lushr: + pop_type (int_type); + push_type_t (pop_type (long_type)); + break; + case op_fadd: + case op_fsub: + case op_fmul: + case op_fdiv: + case op_frem: + pop_type (float_type); + push_type_t (pop_type (float_type)); + break; + case op_dadd: + case op_dsub: + case op_dmul: + case op_ddiv: + case op_drem: + pop_type (double_type); + push_type_t (pop_type (double_type)); + break; + case op_ineg: + case op_i2b: + case op_i2c: + case op_i2s: + push_type_t (pop_type (int_type)); + break; + case op_lneg: + push_type_t (pop_type (long_type)); + break; + case op_fneg: + push_type_t (pop_type (float_type)); + break; + case op_dneg: + push_type_t (pop_type (double_type)); + break; + case op_iinc: + get_variable (get_byte (), int_type); + get_byte (); + break; + case op_i2l: + pop_type (int_type); + push_type (long_type); + break; + case op_i2f: + pop_type (int_type); + push_type (float_type); + break; + case op_i2d: + pop_type (int_type); + push_type (double_type); + break; + case op_l2i: + pop_type (long_type); + push_type (int_type); + break; + case op_l2f: + pop_type (long_type); + push_type (float_type); + break; + case op_l2d: + pop_type (long_type); + push_type (double_type); + break; + case op_f2i: + pop_type (float_type); + push_type (int_type); + break; + case op_f2l: + pop_type (float_type); + push_type (long_type); + break; + case op_f2d: + pop_type (float_type); + push_type (double_type); + break; + case op_d2i: + pop_type (double_type); + push_type (int_type); + break; + case op_d2l: + pop_type (double_type); + push_type (long_type); + break; + case op_d2f: + pop_type (double_type); + push_type (float_type); + break; + case op_lcmp: + pop_type (long_type); + pop_type (long_type); + push_type (int_type); + break; + case op_fcmpl: + case op_fcmpg: + pop_type (float_type); + pop_type (float_type); + push_type (int_type); + break; + case op_dcmpl: + case op_dcmpg: + pop_type (double_type); + pop_type (double_type); + push_type (int_type); + break; + case op_ifeq: + case op_ifne: + case op_iflt: + case op_ifge: + case op_ifgt: + case op_ifle: + pop_type (int_type); + push_jump (get_short ()); + break; + case op_if_icmpeq: + case op_if_icmpne: + case op_if_icmplt: + case op_if_icmpge: + case op_if_icmpgt: + case op_if_icmple: + pop_type (int_type); + pop_type (int_type); + push_jump (get_short ()); + break; + case op_if_acmpeq: + case op_if_acmpne: + pop_type (reference_type); + pop_type (reference_type); + push_jump (get_short ()); + break; + case op_goto: + push_jump (get_short ()); + invalidate_pc (); + break; + case op_jsr: + handle_jsr_insn (get_short ()); + break; + case op_ret: + handle_ret_insn (get_byte ()); + break; + case op_tableswitch: + { + int i; + jint low, high; + pop_type (int_type); + skip_padding (); + push_jump (get_int ()); + low = get_int (); + high = get_int (); + /* Already checked LOW -vs- HIGH. */ + for (i = low; i <= high; ++i) + push_jump (get_int ()); + invalidate_pc (); + } + break; + + case op_lookupswitch: + { + int i; + jint npairs, lastkey; + + pop_type (int_type); + skip_padding (); + push_jump (get_int ()); + npairs = get_int (); + /* Already checked NPAIRS >= 0. */ + lastkey = 0; + for (i = 0; i < npairs; ++i) + { + jint key = get_int (); + if (i > 0 && key <= lastkey) + verify_fail_pc ("lookupswitch pairs unsorted", vfr->start_PC); + lastkey = key; + push_jump (get_int ()); + } + invalidate_pc (); + } + break; + case op_ireturn: + check_return_type (pop_type (int_type)); + invalidate_pc (); + break; + case op_lreturn: + check_return_type (pop_type (long_type)); + invalidate_pc (); + break; + case op_freturn: + check_return_type (pop_type (float_type)); + invalidate_pc (); + break; + case op_dreturn: + check_return_type (pop_type (double_type)); + invalidate_pc (); + break; + case op_areturn: + check_return_type (pop_init_ref (reference_type)); + invalidate_pc (); + break; + case op_return: + /* We only need to check this when the return type is void, + because all instance initializers return void. We also + need to special-case Object constructors, as they can't + call a superclass <init>. */ + if (this_is_init && vfr->current_class != vfy_object_type ()) + state_check_this_initialized (vfr->current_state); + check_return_type (make_type (void_type)); + invalidate_pc (); + break; + case op_getstatic: + push_type_t (check_field_constant (get_ushort (), NULL, false)); + break; + case op_putstatic: + pop_type_t (check_field_constant (get_ushort (), NULL, false)); + break; + case op_getfield: + { + type klass; + type field = check_field_constant (get_ushort (), &klass, false); + pop_type_t (klass); + push_type_t (field); + } + break; + case op_putfield: + { + type klass; + type field = check_field_constant (get_ushort (), &klass, true); + pop_type_t (field); + pop_type_t (klass); + } + break; + + case op_invokevirtual: + case op_invokespecial: + case op_invokestatic: + case op_invokeinterface: + { + vfy_string method_name, method_signature; + const char *namec; + int i, arg_count; + type rt; + bool is_init = false; + + type class_type + = check_method_constant (get_ushort (), + opcode == op_invokeinterface, + &method_name, + &method_signature); + /* NARGS is only used when we're processing + invokeinterface. It is simplest for us to compute it + here and then verify it later. */ + int nargs = 0; + if (opcode == op_invokeinterface) + { + nargs = get_byte (); + if (get_byte () != 0) + verify_fail ("invokeinterface dummy byte is wrong"); + } + + namec = vfy_string_bytes (method_name); + + if (vfy_strings_equal (method_name, vfy_init_name())) + { + is_init = true; + if (opcode != op_invokespecial) + verify_fail ("can't invoke <init>"); + } + else if (namec[0] == '<') + verify_fail ("can't invoke method starting with `<'"); + + arg_count = vfy_count_arguments (method_signature); + { + /* Pop arguments and check types. */ + type *arg_types = (type *) vfy_alloc (arg_count * sizeof (type)); + + compute_argument_types (method_signature, arg_types); + for (i = arg_count - 1; i >= 0; --i) + { + /* This is only used for verifying the byte for + invokeinterface. */ + nargs -= type_depth (&arg_types[i]); + pop_init_ref_t (arg_types[i]); + } + + vfy_free (arg_types); + } + + if (opcode == op_invokeinterface + && nargs != 1) + verify_fail ("wrong argument count for invokeinterface"); + + if (opcode != op_invokestatic) + { + type raw; + type t = class_type; + if (is_init) + { + /* In this case the PC doesn't matter. */ + type_set_uninitialized (&t, UNINIT); + /* FIXME: check to make sure that the <init> + call is to the right class. + It must either be super or an exact class + match. */ + } + raw = pop_raw (); + if (! types_compatible (&t, &raw)) + verify_fail ("incompatible type on stack"); + + if (is_init) + state_set_initialized (vfr->current_state, + type_get_pc (&raw), vfr->current_method->max_locals); + } + + rt = compute_return_type (method_signature); + if (! type_isvoid (&rt)) + push_type_t (rt); + } + break; + + case op_new: + { + type t = check_class_constant (get_ushort ()); + if (type_isarray (&t) || type_isinterface (&t) + || type_isabstract (&t)) + verify_fail ("type is array, interface, or abstract"); + type_set_uninitialized (&t, vfr->start_PC); + push_type_t (t); + } + break; + + case op_newarray: + { + int atype = get_byte (); + vfy_jclass k; + type t; + /* We intentionally have chosen constants to make this + valid. */ + if (atype < boolean_type || atype > long_type) + verify_fail_pc ("type not primitive", vfr->start_PC); + pop_type (int_type); + k = construct_primitive_array_type ((type_val) atype); + init_type_from_class (&t, k); + push_type_t (t); + } + break; + case op_anewarray: + { + type t; + pop_type (int_type); + t = check_class_constant (get_ushort ()); + push_type_t (type_to_array (&t)); + } + break; + case op_arraylength: + { + type t = pop_init_ref (reference_type); + if (! type_isarray (&t) && ! type_isnull (&t)) + verify_fail ("array type expected"); + push_type (int_type); + } + break; + case op_athrow: + pop_type_t (make_type_from_class (vfy_throwable_type ())); + invalidate_pc (); + break; + case op_checkcast: + pop_init_ref (reference_type); + push_type_t (check_class_constant (get_ushort ())); + break; + case op_instanceof: + pop_init_ref (reference_type); + check_class_constant (get_ushort ()); + push_type (int_type); + break; + case op_monitorenter: + pop_init_ref (reference_type); + break; + case op_monitorexit: + pop_init_ref (reference_type); + break; + case op_wide: + { + switch (get_byte ()) + { + case op_iload: + push_type_t (get_variable (get_ushort (), int_type)); + break; + case op_lload: + push_type_t (get_variable (get_ushort (), long_type)); + break; + case op_fload: + push_type_t (get_variable (get_ushort (), float_type)); + break; + case op_dload: + push_type_t (get_variable (get_ushort (), double_type)); + break; + case op_aload: + push_type_t (get_variable (get_ushort (), reference_type)); + break; + case op_istore: + set_variable (get_ushort (), pop_type (int_type)); + break; + case op_lstore: + set_variable (get_ushort (), pop_type (long_type)); + break; + case op_fstore: + set_variable (get_ushort (), pop_type (float_type)); + break; + case op_dstore: + set_variable (get_ushort (), pop_type (double_type)); + break; + case op_astore: + set_variable (get_ushort (), pop_init_ref (reference_type)); + break; + case op_ret: + handle_ret_insn (get_short ()); + break; + case op_iinc: + get_variable (get_ushort (), int_type); + get_short (); + break; + default: + verify_fail_pc ("unrecognized wide instruction", vfr->start_PC); + } + } + break; + case op_multianewarray: + { + int i; + type atype = check_class_constant (get_ushort ()); + int dim = get_byte (); + if (dim < 1) + verify_fail_pc ("too few dimensions to multianewarray", vfr->start_PC); + type_verify_dimensions (&atype, dim); + for (i = 0; i < dim; ++i) + pop_type (int_type); + push_type_t (atype); + } + break; + case op_ifnull: + case op_ifnonnull: + pop_type (reference_type); + push_jump (get_short ()); + break; + case op_goto_w: + push_jump (get_int ()); + invalidate_pc (); + break; + case op_jsr_w: + handle_jsr_insn (get_int ()); + break; + + default: + /* Unrecognized opcode. */ + verify_fail_pc ("unrecognized instruction in verify_instructions_0", + vfr->start_PC); + } + } +} + +/* This turns a `type' into something suitable for use by the type map + in the other parts of the compiler. In particular, reference types + are mapped to Object, primitive types are unchanged, and other + types are mapped using special functions declared in verify.h. */ +static vfy_jclass +collapse_type (type *t) +{ + switch (t->key) + { + case void_type: + case boolean_type: + case char_type: + case float_type: + case double_type: + case byte_type: + case short_type: + case int_type: + case long_type: + return vfy_get_primitive_type (t->key); + + case unsuitable_type: + case continuation_type: + return vfy_unsuitable_type (); + + case return_address_type: + return vfy_return_address_type (); + + case null_type: + return vfy_null_type (); + + case reference_type: + case uninitialized_reference_type: + return vfy_object_type (); + } + + gcc_unreachable (); +} + +static void +verify_instructions (void) +{ + int i; + + branch_prepass (); + verify_instructions_0 (); + + /* Now tell the rest of the compiler about the types we've found. */ + for (i = 0; i < vfr->current_method->code_length; ++i) + { + int j, slot; + struct state *curr; + + if ((vfr->flags[i] & FLAG_INSN_SEEN) != 0) + vfy_note_instruction_seen (i); + + if (! vfr->states[i]) + continue; + + curr = vfr->states[i]->val; + vfy_note_stack_depth (vfr->current_method, i, curr->stackdepth); + + /* Tell the compiler about each local variable. */ + for (j = 0; j < vfr->current_method->max_locals; ++j) + vfy_note_local_type (vfr->current_method, i, j, + collapse_type (&curr->locals[j])); + /* Tell the compiler about each stack slot. */ + for (slot = j = 0; j < curr->stacktop; ++j, ++slot) + { + vfy_note_stack_type (vfr->current_method, i, slot, + collapse_type (&curr->stack[j])); + if (type_iswide (&curr->stack[j])) + { + ++slot; + vfy_note_stack_type (vfr->current_method, i, slot, + vfy_unsuitable_type ()); + } + } + gcc_assert (slot == curr->stackdepth); + } +} + +static void +make_verifier_context (vfy_method *m) +{ + vfr = (verifier_context *) vfy_alloc (sizeof (struct verifier_context)); + + vfr->current_method = m; + vfr->bytecode = vfy_get_bytecode (m); + vfr->exception = vfy_get_exceptions (m); + vfr->current_class = m->defining_class; + + vfr->states = NULL; + vfr->flags = NULL; + vfr->utf8_list = NULL; + vfr->isect_list = NULL; +} + +static void +free_verifier_context (void) +{ + vfy_string_list *utf8_list; + ref_intersection *isect_list; + + if (vfr->flags) + vfy_free (vfr->flags); + + utf8_list = vfr->utf8_list; + while (utf8_list != NULL) + { + vfy_string_list *n = utf8_list->next; + vfy_free (utf8_list); + utf8_list = n; + } + + isect_list = vfr->isect_list; + while (isect_list != NULL) + { + ref_intersection *next = isect_list->alloc_next; + vfy_free (isect_list); + isect_list = next; + } + + if (vfr->states != NULL) + { + int i; + for (i = 0; i < vfr->current_method->code_length; ++i) + { + state_list *iter = vfr->states[i]; + while (iter != NULL) + { + state_list *next = iter->next; + free_state (iter->val); + vfy_free (iter->val); + vfy_free (iter); + iter = next; + } + } + vfy_free (vfr->states); + } + + vfy_free (vfr); +} + +int +verify_method (vfy_method *meth) +{ + debug_print ("verify_method (%s) %i\n", vfy_string_bytes (meth->name), + meth->code_length); + + if (vfr != NULL) + verify_fail ("verifier re-entered"); + + make_verifier_context (meth); + verify_instructions (); + free_verifier_context (); + vfr = NULL; + + return 1; +} diff --git a/gcc/java/verify.h b/gcc/java/verify.h new file mode 100644 index 000000000..8c3184447 --- /dev/null +++ b/gcc/java/verify.h @@ -0,0 +1,154 @@ +/* Declarations to interface gcj with bytecode verifier. + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Tom Tromey <tromey@redhat.com>. */ + +#ifndef GCC_VERIFY_H +#define GCC_VERIFY_H + +#include "system.h" +#include "coretypes.h" +#include "jcf.h" +#include "tree.h" +#include "java-tree.h" + +typedef JCF vfy_constants; + +/* For our purposes a string is the same as an identifier. */ +typedef tree vfy_string; + +/* The TYPE_DECL for a class or primitive type. */ +typedef tree vfy_jclass; + +/* An unsigned jshort. */ +typedef uint16 vfy_uint_16; + +typedef struct +{ + int handler, start, end, type; +} vfy_exception; + +typedef struct +{ + tree method; + vfy_string signature; + vfy_string name; + const unsigned char *bytes; + vfy_exception *exceptions; + + /* These fields are referred to directly by the verifier. */ + vfy_jclass defining_class; + int max_stack; + int max_locals; + int code_length; + int exc_count; +} vfy_method; + +/* Entry point to the verifier. */ +int verify_jvm_instructions_new (JCF *jcf, const unsigned char *byte_ops, + long length); + +void *vfy_alloc (size_t bytes); +void vfy_free (void *mem); +bool vfy_strings_equal (vfy_string one, vfy_string two); +const char *vfy_string_bytes (vfy_string str); +int vfy_string_length (vfy_string str); +vfy_string vfy_get_string (const char *chars, int length); +vfy_string vfy_init_name (void); +vfy_string vfy_clinit_name (void); +int vfy_count_arguments (vfy_string signature); +vfy_string vfy_get_signature (vfy_method *method); +vfy_string vfy_get_method_name (vfy_method *method); +bool vfy_is_static (vfy_method *method); +const unsigned char *vfy_get_bytecode (vfy_method *method); +vfy_exception *vfy_get_exceptions (vfy_method *method); +void vfy_get_exception (vfy_exception *, int index, int *handler, + int *start, int *end, int *handler_type); +int vfy_tag (vfy_constants *pool, int index); +void vfy_load_indexes (vfy_constants *pool, int index, + vfy_uint_16 *index0, vfy_uint_16 *index1); +vfy_constants *vfy_get_constants (vfy_jclass klass); +int vfy_get_constants_size (vfy_jclass klass); +vfy_string vfy_get_pool_string (vfy_constants *pool, int index); +vfy_jclass vfy_get_pool_class (vfy_constants *pool, int index); +vfy_string vfy_get_class_name (vfy_jclass klass); +bool vfy_is_assignable_from (vfy_jclass target, vfy_jclass source); +char vfy_get_primitive_char (vfy_jclass klass); +int vfy_get_interface_count (vfy_jclass klass); +vfy_jclass vfy_get_interface (vfy_jclass klass, int index); +bool vfy_is_array (vfy_jclass klass); +bool vfy_is_interface (vfy_jclass klass); +bool vfy_is_primitive (vfy_jclass klass); +vfy_jclass vfy_get_superclass (vfy_jclass klass); +vfy_jclass vfy_get_array_class (vfy_jclass klass); +vfy_jclass vfy_get_component_type (vfy_jclass klass); +bool vfy_is_abstract (vfy_jclass klass); +vfy_jclass vfy_find_class (vfy_jclass klass, vfy_string name); +vfy_jclass vfy_object_type (void); +vfy_jclass vfy_class_type (void); +vfy_jclass vfy_string_type (void); +vfy_jclass vfy_throwable_type (void); +vfy_jclass vfy_unsuitable_type (void); +vfy_jclass vfy_return_address_type (void); +vfy_jclass vfy_null_type (void); +int vfy_fail (const char *message, int pc, vfy_jclass ignore1, + vfy_method *method); +vfy_jclass vfy_get_primitive_type (int type); +void vfy_note_stack_depth (vfy_method *method, int pc, int depth); +void vfy_note_stack_type (vfy_method *method, int pc, int slot, + vfy_jclass type); +void vfy_note_local_type (vfy_method *method, int pc, int slot, + vfy_jclass type); +void vfy_note_instruction_seen (int pc); +bool vfy_class_has_field (vfy_jclass klass, vfy_string name, + vfy_string signature); + +#define GLOM(name, stuff) name ## stuff +#define VFY_PRIMITIVE_CLASS(name) \ + vfy_get_primitive_type ((int) (GLOM (name, _type))) + +typedef enum +{ +#define JAVAOP(name, num, ignore1, ignore2, ignore3) \ + GLOM (op_, name) = num, +#include "javaop.def" + java_opcode_end +} java_opcode; + + +#define JV_CONSTANT_Class CONSTANT_Class +#define JV_CONSTANT_ResolvedClass CONSTANT_ResolvedClass +#define JV_CONSTANT_String CONSTANT_String +#define JV_CONSTANT_ResolvedString CONSTANT_ResolvedString +#define JV_CONSTANT_Integer CONSTANT_Integer +#define JV_CONSTANT_Float CONSTANT_Float +#define JV_CONSTANT_Long CONSTANT_Long +#define JV_CONSTANT_Double CONSTANT_Double +#define JV_CONSTANT_Fieldref CONSTANT_Fieldref +#define JV_CONSTANT_InterfaceMethodref CONSTANT_InterfaceMethodref +#define JV_CONSTANT_Methodref CONSTANT_Methodref + +int verify_method (vfy_method *meth); + +#endif /* ! GCC_VERIFY_H */ diff --git a/gcc/java/win32-host.c b/gcc/java/win32-host.c new file mode 100644 index 000000000..0e9613b42 --- /dev/null +++ b/gcc/java/win32-host.c @@ -0,0 +1,87 @@ +/* Platform-Specific Win32 Functions + Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Mohan Embar <gnustuff@thisiscool.com>, March 2003. */ + + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "jcf.h" + +#ifdef WIN32 + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#undef WIN32_LEAN_AND_MEAN + +/* Simulate an open() failure with ENOENT */ +static int +file_not_found (void); + +static int +file_not_found (void) +{ + errno = ENOENT; + return -1; +} + +int +jcf_open_exact_case (const char *filename, int oflag) +{ + int filename_len = strlen (filename); + int found_file_len; + HANDLE found_file_handle; + WIN32_FIND_DATA fd; + + /* See if we can find this file. */ + found_file_handle = FindFirstFile (filename, &fd); + if (found_file_handle == INVALID_HANDLE_VALUE) + return file_not_found (); + FindClose (found_file_handle); + + found_file_len = strlen (fd.cFileName); + + /* This should never happen. */ + if (found_file_len > filename_len) + return file_not_found (); + + /* Here, we're only actually comparing the filename and not + checking the case of any containing directory components. + Although we're not fully obeying our contract, checking + all directory components would be tedious and time-consuming + and it's a pretty safe assumption that mixed-case package + names are a fringe case.... */ + if (strcmp (filename + filename_len - found_file_len, fd.cFileName)) + { + /* Reject this because it is not a perfect-case match. */ + /* printf("************\nRejected:\n%s\n%s\n************\n\n", filename, fd.cFileName); */ + return file_not_found (); + } + else + { + return open (filename, oflag); + } +} + +#endif /* WIN32 */ diff --git a/gcc/java/zextract.c b/gcc/java/zextract.c new file mode 100644 index 000000000..b11319720 --- /dev/null +++ b/gcc/java/zextract.c @@ -0,0 +1,396 @@ +/* Handle a .class file embedded in a .zip archive. + This extracts a member from a .zip file, but does not handle + uncompression (since that is not needed for classes.zip). + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, + 2007 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "zipfile.h" + +/* This stuff is partly based on the 28 August 1994 public release of the +Info-ZIP group's portable UnZip zipfile-extraction program (and related +utilities). */ + +/*************/ +/* Defines */ +/*************/ + +#define UNZIP +#define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */ +#define VMS_UNZIP_VERSION 42 /* if OS-needed-to-extract is VMS: can do */ + + +#define ZSUFX ".zip" +#define CENTRAL_HDR_SIG "\113\001\002" /* the infamous "PK" signature */ +#define LOCAL_HDR_SIG "\113\003\004" /* bytes, sans "P" (so unzip */ +#define END_CENTRAL_SIG "\113\005\006" /* executable not mistaken for */ +#define EXTD_LOCAL_SIG "\113\007\010" /* zipfile itself) */ + +#define STORED 0 /* compression methods */ +#define SHRUNK 1 +#define REDUCED1 2 +#define REDUCED2 3 +#define REDUCED3 4 +#define REDUCED4 5 +#define IMPLODED 6 +#define TOKENIZED 7 +#define DEFLATED 8 +#define NUM_METHODS 9 /* index of last method + 1 */ +/* don't forget to update list_files() appropriately if NUM_METHODS changes */ + +#define PK_OK 0 /* no error */ +#define PK_COOL 0 /* no error */ +#define PK_GNARLY 0 /* no error */ +#define PK_WARN 1 /* warning error */ +#define PK_ERR 2 /* error in zipfile */ +#define PK_BADERR 3 /* severe error in zipfile */ +#define PK_MEM 4 /* insufficient memory */ +#define PK_MEM2 5 /* insufficient memory */ +#define PK_MEM3 6 /* insufficient memory */ +#define PK_MEM4 7 /* insufficient memory */ +#define PK_MEM5 8 /* insufficient memory */ +#define PK_NOZIP 9 /* zipfile not found */ +#define PK_PARAM 10 /* bad or illegal parameters specified */ +#define PK_FIND 11 /* no files found */ +#define PK_DISK 50 /* disk full */ +#define PK_EOF 51 /* unexpected EOF */ + +/*--------------------------------------------------------------------------- + True sizes of the various headers, as defined by PKWARE--so it is not + likely that these will ever change. But if they do, make sure both these + defines AND the typedefs below get updated accordingly. + ---------------------------------------------------------------------------*/ +#define LREC_SIZE 26 /* lengths of local file headers, central */ +#define CREC_SIZE 42 /* directory headers, and the end-of- */ +#define ECREC_SIZE 18 /* central-dir record, respectively */ + + +#ifndef SEEK_SET +# define SEEK_SET 0 +# define SEEK_CUR 1 +# define SEEK_END 2 +#endif + +/**************/ +/* Typedefs */ +/**************/ + +typedef char boolean; +typedef unsigned char uch; /* code assumes unsigned bytes; these type- */ +typedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */ +typedef unsigned long ulg; /* predefined on some systems) & match zip */ + +/*--------------------------------------------------------------------------- + Zipfile layout declarations. If these headers ever change, make sure the + xxREC_SIZE defines (above) change with them! + ---------------------------------------------------------------------------*/ + + typedef uch local_byte_hdr[ LREC_SIZE ]; +# define L_VERSION_NEEDED_TO_EXTRACT_0 0 +# define L_VERSION_NEEDED_TO_EXTRACT_1 1 +# define L_GENERAL_PURPOSE_BIT_FLAG 2 +# define L_COMPRESSION_METHOD 4 +# define L_LAST_MOD_FILE_TIME 6 +# define L_LAST_MOD_FILE_DATE 8 +# define L_CRC32 10 +# define L_COMPRESSED_SIZE 14 +# define L_UNCOMPRESSED_SIZE 18 +# define L_FILENAME_LENGTH 22 +# define L_EXTRA_FIELD_LENGTH 24 + + typedef uch cdir_byte_hdr[ CREC_SIZE ]; +# define C_VERSION_MADE_BY_0 0 +# define C_VERSION_MADE_BY_1 1 +# define C_VERSION_NEEDED_TO_EXTRACT_0 2 +# define C_VERSION_NEEDED_TO_EXTRACT_1 3 +# define C_GENERAL_PURPOSE_BIT_FLAG 4 +# define C_COMPRESSION_METHOD 6 +# define C_LAST_MOD_FILE_TIME 8 +# define C_LAST_MOD_FILE_DATE 10 +# define C_CRC32 12 +# define C_COMPRESSED_SIZE 16 +# define C_UNCOMPRESSED_SIZE 20 +# define C_FILENAME_LENGTH 24 +# define C_EXTRA_FIELD_LENGTH 26 +# define C_FILE_COMMENT_LENGTH 28 +# define C_DISK_NUMBER_START 30 +# define C_INTERNAL_FILE_ATTRIBUTES 32 +# define C_EXTERNAL_FILE_ATTRIBUTES 34 +# define C_RELATIVE_OFFSET_LOCAL_HEADER 38 + + typedef uch ec_byte_rec[ ECREC_SIZE+4 ]; +/* define SIGNATURE 0 space-holder only */ +# define NUMBER_THIS_DISK 4 +# define NUM_DISK_WITH_START_CENTRAL_DIR 6 +# define NUM_ENTRIES_CENTRL_DIR_THS_DISK 8 +# define TOTAL_ENTRIES_CENTRAL_DIR 10 +# define SIZE_CENTRAL_DIRECTORY 12 +# define OFFSET_START_CENTRAL_DIRECTORY 16 +# define ZIPFILE_COMMENT_LENGTH 20 + + + typedef struct local_file_header { /* LOCAL */ + uch version_needed_to_extract[2]; + ush general_purpose_bit_flag; + ush compression_method; + ush last_mod_file_time; + ush last_mod_file_date; + ulg crc32; + ulg csize; + ulg ucsize; + ush filename_length; + ush extra_field_length; + } local_file_hdr; + + typedef struct central_directory_file_header { /* CENTRAL */ + uch version_made_by[2]; + uch version_needed_to_extract[2]; + ush general_purpose_bit_flag; + ush compression_method; + ush last_mod_file_time; + ush last_mod_file_date; + ulg crc32; + ulg csize; + ulg ucsize; + ush filename_length; + ush extra_field_length; + ush file_comment_length; + ush disk_number_start; + ush internal_file_attributes; + ulg external_file_attributes; + ulg relative_offset_local_header; + } cdir_file_hdr; + + typedef struct end_central_dir_record { /* END CENTRAL */ + ush number_this_disk; + ush num_disk_with_start_central_dir; + ush num_entries_centrl_dir_ths_disk; + ush total_entries_central_dir; + ulg size_central_directory; + ulg offset_start_central_directory; + ush zipfile_comment_length; + } ecdir_rec; + + +/************/ +/* Macros */ +/************/ + +#ifndef MAX +# define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + + +/***********************/ +/* Prototypes */ +/***********************/ + +static ush makeword (const uch *); +static ulg makelong (const uch *); +static long find_zip_file_start (int fd, long offset); + +/***********************/ +/* Function makeword() */ +/***********************/ + +static ush makeword(const uch *b) +{ + /* + * Convert Intel style 'short' integer to non-Intel non-16-bit + * host format. This routine also takes care of byte-ordering. + */ + return (ush)((b[1] << 8) | b[0]); +} + + +/***********************/ +/* Function makelong() */ +/***********************/ + +static ulg +makelong (const uch *sig) +{ + /* + * Convert intel style 'long' variable to non-Intel non-16-bit + * host format. This routine also takes care of byte-ordering. + */ + return (((ulg)sig[3]) << 24) + + (((ulg)sig[2]) << 16) + + (((ulg)sig[1]) << 8) + + ((ulg)sig[0]); +} + +/* Examine file's header in zip file and return the offset of the + start of the actual data. Return -1 on error. OFFSET is the + offset from the beginning of the zip file of the file's header. */ +static long +find_zip_file_start (int fd, long offset) +{ + int filename_length, extra_field_length; + unsigned char buffer[LREC_SIZE + 4]; + + if (lseek (fd, offset, SEEK_SET) < 0) + return -1; + + if (read (fd, buffer, LREC_SIZE + 4) != LREC_SIZE + 4) + return -1; + + if (buffer[0] != 'P' || strncmp ((const char *) &buffer[1], LOCAL_HDR_SIG, 3)) + return -1; + + filename_length = makeword (&buffer[4 + L_FILENAME_LENGTH]); + extra_field_length = makeword (&buffer[4 + L_EXTRA_FIELD_LENGTH]); + + return offset + (4 + LREC_SIZE) + filename_length + extra_field_length; +} + +int +read_zip_archive (ZipFile *zipf) +{ + int i; + int dir_last_pad; + char *dir_ptr; + char buffer[100]; + + zipf->size = lseek (zipf->fd, 0L, SEEK_END); + + if (zipf->size < (ECREC_SIZE+4) || lseek (zipf->fd, (long)(-(ECREC_SIZE+4)), SEEK_CUR) <= 0) + return -1; + if (read (zipf->fd, buffer, ECREC_SIZE+4) != ECREC_SIZE+4) + return -2; + if (buffer[0] != 'P' + || strncmp ((const char *) &buffer[1], END_CENTRAL_SIG, 3)) + { + /* We could not find the end-central-header signature, probably + because a zipfile comment is present. Scan backwards until we + find the signature. */ + if (lseek (zipf->fd, (long)(-ECREC_SIZE), SEEK_END) <= 0) + return -2; + while (buffer[0] != 'P' + || strncmp ((const char *) &buffer[1], END_CENTRAL_SIG, 3)) + { + if (lseek (zipf->fd, -5, SEEK_CUR) < 0) + return -2; + if (read (zipf->fd, buffer, 4) != 4) + return -2; + } + if (read (zipf->fd, buffer + 4, ECREC_SIZE) != ECREC_SIZE) + return -2; + } + zipf->count = makeword((const uch *) &buffer[TOTAL_ENTRIES_CENTRAL_DIR]); + zipf->dir_size = makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY]); + /* Allocate 1 more to allow appending '\0' to last filename. */ + zipf->central_directory = XNEWVEC (char, zipf->dir_size + 1); + if (lseek (zipf->fd, -(zipf->dir_size+ECREC_SIZE+4), SEEK_CUR) < 0) + return -2; + if (read (zipf->fd, zipf->central_directory, zipf->dir_size) < 0) + return -2; + +#ifdef TEST + printf ("number_this_disk = %d\n", makeword(&buffer[NUMBER_THIS_DISK])); + printf ("num_disk_with_start_central_dir = %d\n", makeword(&buffer[NUM_DISK_WITH_START_CENTRAL_DIR])); + + printf ("num_entries_centrl_dir_ths_disk = %d\n", + makeword(&buffer[NUM_ENTRIES_CENTRL_DIR_THS_DISK])); + printf ("total_entries_central_dir = %d\n", + makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR])); + printf ("size_central_directory = %d\n", + makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY])); + printf ("offset_start_central_directory = %d\n", + makelong((const uch *) &buffer[OFFSET_START_CENTRAL_DIRECTORY])); + printf ("zipfile_comment_length = %d\n", + makeword(&buffer[ZIPFILE_COMMENT_LENGTH])); +#endif + + dir_last_pad = 0; + dir_ptr = zipf->central_directory; + for (i = 0; i < zipf->count; i++) + { + ZipDirectory *zipd = (ZipDirectory*)(dir_ptr + dir_last_pad); + int compression_method = (int) dir_ptr[4+C_COMPRESSION_METHOD]; + long size = makelong ((const uch *) &dir_ptr[4+C_COMPRESSED_SIZE]); + long uncompressed_size = makelong ((const uch *) &dir_ptr[4+C_UNCOMPRESSED_SIZE]); + long filename_length = makeword ((const uch *) &dir_ptr[4+C_FILENAME_LENGTH]); + long extra_field_length = makeword ((const uch *) &dir_ptr[4+C_EXTRA_FIELD_LENGTH]); + long file_offset = makelong ((const uch *) &dir_ptr[4+C_RELATIVE_OFFSET_LOCAL_HEADER]); + int unpadded_direntry_length; + if ((dir_ptr-zipf->central_directory)+filename_length+CREC_SIZE+4>zipf->dir_size) + return -1; + + zipd->filename_length = filename_length; + zipd->compression_method = compression_method; + zipd->size = size; + zipd->uncompressed_size = uncompressed_size; + zipd->zipf = zipf; +#ifdef __GNUC__ +#define DIR_ALIGN __alignof__(ZipDirectory) +#else +#define DIR_ALIGN sizeof(long) +#endif + zipd->filestart = find_zip_file_start (zipf->fd, file_offset); + zipd->filename_offset = CREC_SIZE+4 - dir_last_pad; + unpadded_direntry_length + = zipd->filename_offset + zipd->filename_length + extra_field_length; + zipd->direntry_size = + ((unpadded_direntry_length + DIR_ALIGN) / DIR_ALIGN) * DIR_ALIGN; + dir_last_pad = zipd->direntry_size - unpadded_direntry_length; + dir_ptr = (char*)zipd + unpadded_direntry_length; + *dir_ptr = '\0'; + } + return 0; +} + +#ifdef TEST +main (void) +{ + ZipFile zipf[1]; + ZipDirectory *zipd; + int i; + + zipf->fd = 0; + + i = read_zip_archive (zipf); + if (i) + { + fprintf (stderr, "Bad zip file.\n"); + exit (i); + } + + zipd = (ZipDirectory*) zipf->central_directory; + for (i = 0; i < zipf->count; i++, zipd = ZIPDIR_NEXT (zipd)) + { + printf ("%d: size:%d, name(#%d)%s, offset:%d\n", + i, zipd->size, zipd->filename_length, + ZIPDIR_FILENAME (zipd), + zipd->filestart); + } +} +#endif diff --git a/gcc/java/zipfile.h b/gcc/java/zipfile.h new file mode 100644 index 000000000..d78226a49 --- /dev/null +++ b/gcc/java/zipfile.h @@ -0,0 +1,68 @@ +/* Definitions for using a zipped' archive. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2007 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. + +Java and all Java-based marks are trademarks or registered trademarks +of Sun Microsystems, Inc. in the United States and other countries. +The Free Software Foundation is independent of Sun Microsystems, Inc. */ + +struct ZipFile { + char *name; + int fd; + long size; + long count; + long dir_size; + char *central_directory; + + /* Chain together in SeenZipFiles. */ + struct ZipFile *next; +}; + +typedef struct ZipFile ZipFile; + +struct ZipDirectory { + int direntry_size; + int filename_offset; + int compression_method; + unsigned size; /* length of file */ + unsigned uncompressed_size; /* length of uncompressed data */ + unsigned filestart; /* start of file in archive */ + ZipFile *zipf; + int filename_length; + /* char mid_padding[...]; */ + /* char filename[filename_length]; */ + /* char end_padding[...]; */ +}; + +typedef struct ZipDirectory ZipDirectory; + +extern struct ZipFile *SeenZipFiles; + +#define ZIPDIR_FILENAME(ZIPD) ((char*)(ZIPD)+(ZIPD)->filename_offset) +#define ZIPDIR_NEXT(ZIPD) \ + ((ZipDirectory*)((char*)(ZIPD)+(ZIPD)->direntry_size)) +#define ZIPMAGIC 0x504b0304 +#define ZIPEMPTYMAGIC 0x504b0506 + +extern ZipFile * opendir_in_zip (const char *, int); +extern int read_zip_archive (ZipFile *); +#ifdef GCC_JCF_H +extern int read_zip_member (JCF*, ZipDirectory*, ZipFile *); +extern int open_in_zip (struct JCF *, const char *, const char *, int); +#endif |