From fec763fcfdaad01e5ebb8ca1d3ccee34ef65f099 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 22 Jan 2002 20:23:46 +0000 Subject: [PATCH] decl.c (java_init_decl_processing): Use add_predefined_file. * 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. From-SVN: r49091 --- gcc/java/ChangeLog | 24 ++++ gcc/java/Make-lang.in | 4 +- gcc/java/builtins.c | 365 ++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/java/decl.c | 31 ++--- gcc/java/expr.c | 13 +- gcc/java/java-tree.h | 13 +- gcc/java/jcf-parse.c | 21 ++- gcc/java/parse.y | 21 ++- 8 files changed, 451 insertions(+), 41 deletions(-) create mode 100644 gcc/java/builtins.c diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 5d5625b..b2fde76 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,27 @@ +2002-01-22 Tom Tromey + + * 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 * parse.y (patch_switch_statement): Fix format specifier. diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in index 99724b3..c7fe5a9 100644 --- a/gcc/java/Make-lang.in +++ b/gcc/java/Make-lang.in @@ -101,7 +101,7 @@ $(srcdir)/java/keyword.h: $(srcdir)/java/keyword.gperf JAVA_OBJS = java/parse.o java/class.o java/decl.o java/expr.o \ java/constants.o java/lang.o java/typeck.o java/except.o java/verify.o \ java/zextract.o java/jcf-io.o java/jcf-parse.o java/mangle.o \ - java/mangle_name.o \ + java/mangle_name.o java/builtins.o \ java/jcf-write.o java/buffer.o java/check-init.o java/jcf-depend.o \ java/jcf-path.o java/xref.o java/boehm.o mkdeps.o @@ -257,6 +257,8 @@ java/gjavah.o: $(CONFIG_H) $(SYSTEM_H) $(JAVA_TREE_H) java/gjavah.c \ java/boehm.o: java/boehm.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(JAVA_TREE_H) \ java/parse.h toplev.h java/buffer.o: java/buffer.c $(CONFIG_H) java/buffer.h $(SYSTEM_H) toplev.h +java/builtins.o: java/builtins.c $(CONFIG_H) $(SYSTEM_H) $(JAVA_TREE_H) \ + $(GGC_H) flags.h java/check-init.o: java/check-init.c $(CONFIG_H) \ $(JAVA_TREE_H) $(SYSTEM_H) toplev.h java/class.o: java/class.c $(CONFIG_H) $(JAVA_TREE_H) $(RTL_H) java/jcf.h \ diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c new file mode 100644 index 0000000..2449859 --- /dev/null +++ b/gcc/java/builtins.c @@ -0,0 +1,365 @@ +/* Built-in and inline functions for gcj + Copyright (C) 2001 + Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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 2, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + +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 . */ + +#include "config.h" +#include "system.h" +#include "tree.h" +#include "ggc.h" +#include "flags.h" + +#include "java-tree.h" + +enum builtin_type +{ +#define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME, +#define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME, +#define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME, +#define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME, +#define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME, +#define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME, +#define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME, +#define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME, +#define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME, +#define DEF_POINTER_TYPE(NAME, TYPE) NAME, +#include "builtin-types.def" +#undef DEF_PRIMITIVE_TYPE +#undef DEF_FUNCTION_TYPE_0 +#undef DEF_FUNCTION_TYPE_1 +#undef DEF_FUNCTION_TYPE_2 +#undef DEF_FUNCTION_TYPE_3 +#undef DEF_FUNCTION_TYPE_4 +#undef DEF_FUNCTION_TYPE_VAR_0 +#undef DEF_FUNCTION_TYPE_VAR_1 +#undef DEF_FUNCTION_TYPE_VAR_2 +#undef DEF_POINTER_TYPE + BT_LAST +}; + +static tree max_builtin PARAMS ((tree, tree)); +static tree min_builtin PARAMS ((tree, tree)); +static tree abs_builtin PARAMS ((tree, tree)); +static tree cos_builtin PARAMS ((tree, tree)); +static tree sin_builtin PARAMS ((tree, tree)); +static tree sqrt_builtin PARAMS ((tree, tree)); + +static tree build_function_call_expr PARAMS ((tree, tree)); +static void define_builtin PARAMS ((enum built_in_function, + const char *, + enum built_in_class, + tree, int)); +static tree define_builtin_type PARAMS ((int, int, int, int, int)); + + + +/* 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 arguments to call. */ +typedef tree builtin_creator_function PARAMS ((tree, tree)); + +/* Hold a char*, before initialization, or a tree, after + initialization. */ +union string_or_tree +{ + const char *s; + tree t; +}; + +/* Used to hold a single builtin record. */ +struct builtin_record +{ + union string_or_tree class_name; + union string_or_tree method_name; + builtin_creator_function *creator; +}; + +static struct builtin_record java_builtins[] = +{ + { { "java.lang.Math" }, { "min" }, min_builtin }, + { { "java.lang.Math" }, { "max" }, max_builtin }, + { { "java.lang.Math" }, { "abs" }, abs_builtin }, + { { "java.lang.Math" }, { "cos" }, cos_builtin }, + { { "java.lang.Math" }, { "sin" }, sin_builtin }, + { { "java.lang.Math" }, { "sqrt" }, sqrt_builtin }, + { { NULL }, { NULL }, NULL } +}; + +/* This is only used transiently, so we don't mark it as roots for the + GC. */ +static tree builtin_types[(int) BT_LAST]; + + +/* Internal functions which implement various builtin conversions. */ + +static tree +max_builtin (method_return_type, method_arguments) + tree method_return_type, method_arguments; +{ + return build (MAX_EXPR, method_return_type, + TREE_VALUE (method_arguments), + TREE_VALUE (TREE_CHAIN (method_arguments))); +} + +static tree +min_builtin (method_return_type, method_arguments) + tree method_return_type, method_arguments; +{ + return build (MIN_EXPR, method_return_type, + TREE_VALUE (method_arguments), + TREE_VALUE (TREE_CHAIN (method_arguments))); +} + +static tree +abs_builtin (method_return_type, method_arguments) + tree method_return_type, method_arguments; +{ + return build1 (ABS_EXPR, method_return_type, + TREE_VALUE (method_arguments)); +} + +/* Mostly copied from ../builtins.c. */ +static tree +build_function_call_expr (tree fn, tree arglist) +{ + tree call_expr; + + call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn); + call_expr = build (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)), + call_expr, arglist); + TREE_SIDE_EFFECTS (call_expr) = 1; + return call_expr; +} + +static tree +cos_builtin (method_return_type, method_arguments) + tree method_return_type, method_arguments; +{ + /* FIXME: this assumes that jdouble and double are the same. */ + tree fn = built_in_decls[BUILT_IN_COS]; + if (fn == NULL_TREE) + return NULL_TREE; + return build_function_call_expr (fn, method_arguments); +} + +static tree +sin_builtin (method_return_type, method_arguments) + tree method_return_type, method_arguments; +{ + /* FIXME: this assumes that jdouble and double are the same. */ + tree fn = built_in_decls[BUILT_IN_SIN]; + if (fn == NULL_TREE) + return NULL_TREE; + return build_function_call_expr (fn, method_arguments); +} + +static tree +sqrt_builtin (method_return_type, method_arguments) + tree method_return_type, method_arguments; +{ + /* FIXME: this assumes that jdouble and double are the same. */ + tree fn = built_in_decls[BUILT_IN_SQRTF]; + if (fn == NULL_TREE) + return NULL_TREE; + return build_function_call_expr (fn, method_arguments); +} + + + +/* Define a single builtin. */ +static void +define_builtin (val, name, class, type, fallback_p) + enum built_in_function val; + const char *name; + enum built_in_class class; + tree type; + int fallback_p; +{ + tree decl; + + if (! name) + return; + + if (strncmp (name, "__builtin_", strlen ("__builtin_")) != 0) + abort (); + decl = build_decl (FUNCTION_DECL, get_identifier (name), type); + DECL_EXTERNAL (decl) = 1; + TREE_PUBLIC (decl) = 1; + if (fallback_p) + SET_DECL_ASSEMBLER_NAME (decl, + get_identifier (name + strlen ("__builtin_"))); + make_decl_rtl (decl, NULL); + pushdecl (decl); + DECL_BUILT_IN_CLASS (decl) = class; + DECL_FUNCTION_CODE (decl) = val; + built_in_decls[val] = decl; +} + +/* Compute the type for a builtin. */ +static tree +define_builtin_type (ret, arg1, arg2, arg3, arg4) + int ret, arg1, arg2, arg3, arg4; +{ + tree args; + + if (builtin_types[ret] == NULL_TREE) + return NULL_TREE; + + args = void_list_node; + + if (arg4 != -1) + { + if (builtin_types[arg4] == NULL_TREE) + return NULL_TREE; + args = tree_cons (NULL_TREE, builtin_types[arg4], args); + } + if (arg3 != -1) + { + if (builtin_types[arg3] == NULL_TREE) + return NULL_TREE; + args = tree_cons (NULL_TREE, builtin_types[arg3], args); + } + if (arg2 != -1) + { + if (builtin_types[arg2] == NULL_TREE) + return NULL_TREE; + args = tree_cons (NULL_TREE, builtin_types[arg2], args); + } + if (arg1 != -1) + { + if (builtin_types[arg1] == NULL_TREE) + return NULL_TREE; + args = tree_cons (NULL_TREE, builtin_types[arg1], args); + } + + return build_function_type (builtin_types[ret], args); +} + + + +/* Initialize the builtins. */ +void +initialize_builtins () +{ + int i; + + for (i = 0; java_builtins[i].creator != NULL; ++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; + ggc_add_tree_root (&java_builtins[i].class_name.t, 1); + ggc_add_tree_root (&java_builtins[i].method_name.t, 1); + } + + void_list_node = end_params_node; + + /* Work around C-specific junk in builtin-types.def. */ +#define intmax_type_node NULL_TREE +#define traditional_ptr_type_node NULL_TREE +#define traditional_cptr_type_node NULL_TREE +#define c_size_type_node NULL_TREE +#define const_string_type_node NULL_TREE +#define traditional_len_type_node NULL_TREE +#define va_list_ref_type_node NULL_TREE +#define va_list_arg_type_node NULL_TREE +#define flag_isoc99 0 + +#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \ + builtin_types[(int) ENUM] = VALUE; +#define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \ + builtin_types[(int) ENUM] \ + = define_builtin_type (RETURN, -1, -1, -1, -1); +#define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \ + builtin_types[(int) ENUM] \ + = define_builtin_type (RETURN, ARG1, -1, -1, -1); +#define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \ + builtin_types[(int) ENUM] \ + = define_builtin_type (RETURN, ARG1, ARG2, -1, -1); +#define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ + builtin_types[(int) ENUM] \ + = define_builtin_type (RETURN, ARG1, ARG2, ARG3, -1); +#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ + builtin_types[(int) ENUM] \ + = define_builtin_type (RETURN, ARG1, ARG2, ARG3, ARG4); +#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \ + builtin_types[(int) ENUM] = NULL_TREE; +#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \ + builtin_types[(int) ENUM] = NULL_TREE; +#define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \ + builtin_types[(int) ENUM] = NULL_TREE; +#define DEF_POINTER_TYPE(ENUM, TYPE) \ + builtin_types[(int) ENUM] = NULL_TREE; + +#include "builtin-types.def" + +#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, \ + FALLBACK_P, NONANSI_P) \ + define_builtin (ENUM, NAME, CLASS, builtin_types[TYPE], FALLBACK_P); +#include "builtins.def" +} + +/* Generate a method call. If the call matches a builtin, return the + appropriate builtin expression instead. */ +tree +build_call_or_builtin (method, func, method_arguments) + tree method, func, method_arguments; +{ + 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)); + tree call = NULL_TREE; + + /* Only look if we're generating object code and optimizing. */ + if (! flag_emit_class_files && optimize) + { + int i; + + for (i = 0; java_builtins[i].creator != NULL; ++i) + { + if (method_class == java_builtins[i].class_name.t + && method_name == java_builtins[i].method_name.t) + { + call = (*java_builtins[i].creator) (method_return_type, + method_arguments); + break; + } + } + } + + if (call == NULL_TREE) + { + /* Either nothing matched, or the creator function decided not + to inline. In either case, emit a call. */ + call = build (CALL_EXPR, method_return_type, func, method_arguments, + NULL_TREE); + TREE_SIDE_EFFECTS (call) = 1; + } + + return call; +} diff --git a/gcc/java/decl.c b/gcc/java/decl.c index f7464a8..b76f46f 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -327,8 +327,6 @@ int flag_traditional; tree java_global_trees[JTI_MAX]; -tree predef_filenames[PREDEF_FILENAMES_SIZE]; - /* Build (and pushdecl) a "promoted type" for all standard types shorter than int. */ @@ -554,20 +552,17 @@ java_init_decl_processing () rawdata_ptr_type_node = promote_type (lookup_class (get_identifier ("gnu.gcj.RawData"))); - /* If you add to this section, don't forget to increase - PREDEF_FILENAMES_SIZE. */ - predef_filenames [0] = get_identifier ("java/lang/Class.java"); - predef_filenames [1] = get_identifier ("java/lang/Error.java"); - predef_filenames [2] = get_identifier ("java/lang/Object.java"); - predef_filenames [3] = get_identifier ("java/lang/RuntimeException.java"); - predef_filenames [4] = get_identifier ("java/lang/String.java"); - predef_filenames [5] = get_identifier ("java/lang/Throwable.java"); - predef_filenames [6] = get_identifier ("gnu/gcj/RawData.java"); - predef_filenames [7] = get_identifier ("java/lang/Exception.java"); - predef_filenames [8] = - get_identifier ("java/lang/ClassNotFoundException.java"); - predef_filenames [9] = - get_identifier ("java/lang/NoClassDefFoundError.java"); + 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")); + add_predefined_file (get_identifier ("gnu/gcj/RawData.java")); methodtable_type = make_node (RECORD_TYPE); layout_type (methodtable_type); @@ -916,10 +911,10 @@ java_init_decl_processing () /* Register nodes with the garbage collector. */ ggc_add_tree_root (java_global_trees, sizeof (java_global_trees) / sizeof (tree)); - ggc_add_tree_root (predef_filenames, - sizeof (predef_filenames) / sizeof (tree)); ggc_add_tree_root (&decl_map, 1); ggc_add_tree_root (&pending_local_decls, 1); + + initialize_builtins (); } diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 39ba935..e3eaf35 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -1780,7 +1780,8 @@ build_class_init (clas, expr) } tree -build_known_method_ref (method, method_type, self_type, method_signature, arg_list) +build_known_method_ref (method, method_type, self_type, + method_signature, arg_list) tree method, method_type ATTRIBUTE_UNUSED, self_type, method_signature ATTRIBUTE_UNUSED, arg_list ATTRIBUTE_UNUSED; { @@ -1794,13 +1795,13 @@ build_known_method_ref (method, method_type, self_type, method_signature, arg_li { /* 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 - + This is guaranteed to work (assuming SELF_TYPE has been initialized), since if the method is not compiled yet, its ncode points to a trampoline that forces compilation. */ - + int method_index = 0; tree meth; tree ref = build_class_ref (self_type); @@ -2110,8 +2111,8 @@ expand_invoke (opcode, method_ref_index, nargs) func = build_invokeinterface (dtable, method); } func = build1 (NOP_EXPR, build_pointer_type (method_type), func); - call = build (CALL_EXPR, TREE_TYPE (method_type), func, arg_list, NULL_TREE); - TREE_SIDE_EFFECTS (call) = 1; + + call = build_call_or_builtin (method, func, arg_list); if (check != NULL_TREE) { diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 0c9fcd7..0c2e566 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -395,6 +395,8 @@ enum java_tree_index JTI_OTABLE_DECL, JTI_OTABLE_SYMS_DECL, + JTI_PREDEF_FILENAMES, + JTI_MAX }; @@ -656,8 +658,8 @@ extern tree java_global_trees[JTI_MAX]; #define nativecode_ptr_array_type_node \ java_global_trees[JTI_NATIVECODE_PTR_ARRAY_TYPE_NODE] -#define PREDEF_FILENAMES_SIZE 10 -extern tree predef_filenames[PREDEF_FILENAMES_SIZE]; +#define predef_filenames \ + java_global_trees[JTI_PREDEF_FILENAMES] #define nativecode_ptr_type_node ptr_type_node @@ -1085,6 +1087,9 @@ extern HOST_WIDE_INT java_array_type_length PARAMS ((tree)); extern int read_class PARAMS ((tree)); extern void load_class PARAMS ((tree, int)); +extern tree build_call_or_builtin PARAMS ((tree, tree, tree)); +extern void initialize_builtins PARAMS ((void)); + extern tree lookup_name PARAMS ((tree)); extern tree build_known_method_ref PARAMS ((tree, tree, tree, tree, tree)); extern tree build_class_init PARAMS ((tree, tree)); @@ -1111,7 +1116,6 @@ extern tree create_label_decl PARAMS ((tree)); extern void push_labeled_block PARAMS ((tree)); extern tree prepare_eh_table_type PARAMS ((tree)); extern tree build_exception_object_ref PARAMS ((tree)); -extern void java_set_exception_lang_code PARAMS ((void)); extern tree generate_name PARAMS ((void)); extern void pop_labeled_block PARAMS ((void)); extern const char *lang_printable_name PARAMS ((tree, int)); @@ -1222,6 +1226,9 @@ extern tree java_mangle_vtable PARAMS ((struct obstack *, tree)); extern const char *lang_printable_name_wls PARAMS ((tree, int)); extern void append_gpp_mangled_name PARAMS ((const char *, int)); +extern void add_predefined_file PARAMS ((tree)); +extern int predefined_filename_p PARAMS ((tree)); + /* We use ARGS_SIZE_RTX to indicate that gcc/expr.h has been included to declare `enum expand_modifier'. */ #if defined (TREE_CODE) && defined(RTX_CODE) && defined (HAVE_MACHINE_MODES) && defined (ARGS_SIZE_RTX) diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 4e83b2a..ff5bf05 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -98,7 +98,6 @@ static void parse_source_file_1 PARAMS ((tree, FILE *)); static void parse_source_file_2 PARAMS ((void)); static void parse_class_file PARAMS ((void)); static void set_source_filename PARAMS ((JCF *, int)); -static int predefined_filename_p PARAMS ((tree)); static void ggc_mark_jcf PARAMS ((void**)); static void jcf_parse PARAMS ((struct JCF*)); static void load_inner_classes PARAMS ((tree)); @@ -945,14 +944,24 @@ parse_source_file_2 () java_reorder_fields (); /* Reorder the fields */ } -static int +void +add_predefined_file (name) + tree name; +{ + predef_filenames = tree_cons (NULL_TREE, name, predef_filenames); +} + +int predefined_filename_p (node) tree node; { - int i; - for (i = 0; i < PREDEF_FILENAMES_SIZE; i++) - if (predef_filenames [i] == node) - return 1; + tree iter; + + for (iter = predef_filenames; iter != NULL_TREE; iter = TREE_CHAIN (iter)) + { + if (TREE_VALUE (iter) == node) + return 1; + } return 0; } diff --git a/gcc/java/parse.y b/gcc/java/parse.y index c00a303..a75e3f9 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -10625,7 +10625,6 @@ patch_invoke (patch, method, args) func = method; else { - tree signature = build_java_signature (TREE_TYPE (method)); switch (invocation_mode (method, CALL_USING_SUPER (patch))) { case INVOKE_VIRTUAL: @@ -10650,9 +10649,12 @@ patch_invoke (patch, method, args) case INVOKE_SUPER: case INVOKE_STATIC: - func = build_known_method_ref (method, TREE_TYPE (method), - DECL_CONTEXT (method), - signature, args); + { + tree signature = build_java_signature (TREE_TYPE (method)); + func = build_known_method_ref (method, TREE_TYPE (method), + DECL_CONTEXT (method), + signature, args); + } break; case INVOKE_INTERFACE: @@ -10668,9 +10670,14 @@ patch_invoke (patch, method, args) func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func); } - TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method)); - TREE_OPERAND (patch, 0) = func; - TREE_OPERAND (patch, 1) = args; + if (TREE_CODE (patch) == CALL_EXPR) + patch = build_call_or_builtin (method, func, args); + else + { + TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method)); + TREE_OPERAND (patch, 0) = func; + TREE_OPERAND (patch, 1) = args; + } original_call = patch; /* We're processing a `new TYPE ()' form. New is called and its -- 2.7.4