diff options
author | green <green@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-11-21 23:37:58 +0000 |
---|---|---|
committer | green <green@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-11-21 23:37:58 +0000 |
commit | c0c735e9be2426bb3bbf6ae6f31f4c0f580d6ca8 (patch) | |
tree | 6339330b1e1b16ec9eff2000914b559bac7134bd /gcc/java | |
parent | 0fcdecb459ac25884886dfa09191da916dcb2e96 (diff) | |
download | gcc-c0c735e9be2426bb3bbf6ae6f31f4c0f580d6ca8.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30608 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 19 | ||||
-rw-r--r-- | gcc/java/class.c | 149 | ||||
-rw-r--r-- | gcc/java/constants.c | 7 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 1 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 3 | ||||
-rw-r--r-- | gcc/java/lang.c | 31 |
6 files changed, 201 insertions, 9 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 36b3a2bcf34..38a7d7d6396 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,22 @@ +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. + Wed Nov 17 21:09:28 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * class.c (layout_class): Always convert TYPE_SIZE_UNIT to diff --git a/gcc/java/class.c b/gcc/java/class.c index a270b2acc6a..77e7fce0833 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -53,6 +53,147 @@ static rtx registerClass_libfunc; extern struct obstack permanent_obstack; extern struct obstack temporary_obstack; +/* 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 + assume_compiled_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 assume_compiled_node_struct +{ + /* The class or package name. */ + const char *ident; + + /* Non-zero if this represents an exclusion. */ + int excludep; + + /* Pointers to other nodes in the tree. */ + struct assume_compiled_node_struct *parent; + struct assume_compiled_node_struct *sibling; + struct assume_compiled_node_struct *child; +} assume_compiled_node; + +/* This is the root of the include/exclude tree. */ + +static assume_compiled_node *assume_compiled_tree; + +/* Return the node that most closely represents the class whose name + is IDENT. Start the search from NODE. Return NULL if an + appropriate node does not exist. */ + +assume_compiled_node * +find_assume_compiled_node (node, ident) + assume_compiled_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 + && (strlen (ident) == node_ident_length + || ident[node_ident_length] == '.'))) + { + /* We've found a match, however, there might be a more + specific match. */ + + assume_compiled_node *found = find_assume_compiled_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; +} + +/* Add a new IDENT to the include/exclude tree. It's an exclusion + if EXCLUDEP is non-zero. */ + +void +add_assume_compiled (ident, excludep) + const char *ident; + int excludep; +{ + assume_compiled_node *parent; + assume_compiled_node *node = + (assume_compiled_node *) malloc (sizeof (assume_compiled_node)); + + node->ident = strdup (ident); + node->excludep = excludep; + node->child = NULL; + + /* Create the root of the tree if it doesn't exist yet. */ + + if (NULL == assume_compiled_tree) + { + assume_compiled_tree = + (assume_compiled_node *) malloc (sizeof (assume_compiled_node)); + assume_compiled_tree->ident = ""; + assume_compiled_tree->excludep = 0; + assume_compiled_tree->sibling = NULL; + assume_compiled_tree->child = NULL; + assume_compiled_tree->parent = NULL; + } + + /* Calling the function with the empty string means we're setting + excludep for the root of the hierarchy. */ + + if (0 == ident[0]) + { + assume_compiled_tree->excludep = excludep; + return; + } + + /* Find the parent node for this new node. PARENT will either be a + class or a package name. Adjust PARENT accordingly. */ + + parent = find_assume_compiled_node (assume_compiled_tree, ident); + if (ident[strlen (parent->ident)] != '.') + parent = parent->parent; + + /* Insert NODE into the tree. */ + + node->parent = parent; + node->sibling = parent->child; + parent->child = node; +} + +/* Returns non-zero if IDENT is the name of a class that the compiler + should assume has been compiled to FIXME */ + +int +assume_compiled (ident) + const char *ident; +{ + assume_compiled_node *i; + int result; + + if (NULL == assume_compiled_tree) + return 1; + + i = find_assume_compiled_node (assume_compiled_tree, + ident); + + result = ! i->excludep; + + return (result); +} + /* 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. */ @@ -1091,7 +1232,7 @@ make_class_data (type) DECL_IGNORED_P (methods_decl) = 1; rest_of_decl_compilation (methods_decl, (char*) 0, 1, 0); - if (flag_assume_compiled + if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (type_decl))) && ! CLASS_ABSTRACT (type_decl) && ! CLASS_INTERFACE (type_decl)) { tree dtable = get_dispatch_table (type, this_class_addr); @@ -1107,7 +1248,7 @@ make_class_data (type) super = CLASSTYPE_SUPER (type); if (super == NULL_TREE) super = null_pointer_node; - else if (flag_assume_compiled) + else if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (type_decl)))) super = build_class_ref (super); else { @@ -1133,7 +1274,7 @@ make_class_data (type) tree child = TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), i); tree iclass = BINFO_TYPE (child); tree index; - if (flag_assume_compiled) + if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (iclass))))) index = build_class_ref (iclass); else { @@ -1284,7 +1425,7 @@ is_compiled_class (class) return 2; } - if (flag_assume_compiled) + if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class))))) { if (!CLASS_LOADED_P (class)) { diff --git a/gcc/java/constants.c b/gcc/java/constants.c index a1f820e0dd2..46203836943 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -200,8 +200,11 @@ find_methodref_index (cpool, decl) int class_index = find_class_constant (cpool, mclass); tree name = DECL_CONSTRUCTOR_P (decl) ? init_identifier_node : DECL_NAME (decl); - int name_type_index - = find_name_and_type_constant (cpool, name, TREE_TYPE (decl)); + int name_type_index; + if (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION) + name = EXPR_WFL_NODE (name); + name_type_index = + find_name_and_type_constant (cpool, name, TREE_TYPE (decl)); return find_constant1 (cpool, CLASS_INTERFACE (TYPE_NAME (mclass)) ? CONSTANT_InterfaceMethodref diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 781721f0b19..7c646e6ff88 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -479,6 +479,7 @@ struct lang_type #define JCF_u4 unsigned long #define JCF_u2 unsigned short +extern void add_assume_compiled PROTO ((const char *, int)); extern tree lookup_class PROTO ((tree)); extern tree lookup_java_constructor PROTO ((tree, tree)); extern tree lookup_java_method PROTO ((tree, tree, tree)); diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index ef47563abcf..ff4ec818bf1 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -612,7 +612,8 @@ jcf_parse (jcf) if (main_class == NULL_TREE) main_class = current_class; if (! quiet_flag && TYPE_NAME (current_class)) - fprintf (stderr, " class %s", + fprintf (stderr, " %s %s", + (jcf->access_flags & ACC_INTERFACE) ? "interface" : "class", IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)))); if (CLASS_LOADED_P (current_class)) return; diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 018f93d693a..11be76d6495 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -124,7 +124,6 @@ extern int flag_exceptions; static struct { const char *string; int *variable; int on_value;} lang_f_options[] = { - {"assume-compiled", &flag_assume_compiled, 1}, {"emit-class-file", &flag_emit_class_files, 1}, {"emit-class-files", &flag_emit_class_files, 1}, {"use-divide-subroutine", &flag_use_divide_subroutine, 1}, @@ -151,6 +150,34 @@ lang_decode_option (argc, argv) { char *p = argv[0]; +#define CLARG "-fassume-compiled=" + if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) + { + add_assume_compiled (p + sizeof (CLARG) - 1, 0); + return 1; + } +#undef CLARG +#define CLARG "-fno-assume-compiled=" + if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) + { + add_assume_compiled (p + sizeof (CLARG) - 1, 1); + return 1; + } +#undef CLARG +#define CLARG "-fassume-compiled" + if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) + { + add_assume_compiled ("", 0); + return 1; + } +#undef CLARG +#define CLARG "-fno-assume-compiled" + if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) + { + add_assume_compiled ("", 1); + return 1; + } +#undef CLARG #define CLARG "-fclasspath=" if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) { @@ -159,7 +186,7 @@ lang_decode_option (argc, argv) } #undef CLARG #define CLARG "-fCLASSPATH=" - else if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) + if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0) { jcf_path_CLASSPATH_arg (p + sizeof (CLARG) - 1); return 1; |