constants.c (find_methodref_index): Unwrap method names before inserting them in the constant pool.
* 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. From-SVN: r30608
This commit is contained in:
parent
250ba2372c
commit
48aedbca8b
@ -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
|
||||
|
149
gcc/java/class.c
149
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))
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user