This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
gcj patch: -fassume-compiled= feature
- To: gcc-patches at gcc dot gnu dot org
- Subject: gcj patch: -fassume-compiled= feature
- From: Anthony Green <green at cygnus dot com>
- Date: Sat, 6 Nov 1999 10:26:10 -0800 (PST)
This patch changes -fassume-compiled and -fno-assume-compiled
slightly. They continue to work as is, but now you can also use them
like... -fassume-compiled=CLASSNAME or -fassume-compiled=PACKAGENAME.
You can also combine them, so "-fassume-compiled
-fno-assume-compiled=java.net -fassume-compiled=java.net.URL" means
assume everything is compiled natively, except for java.net, except
that java.net.URL _is_ compiled natively.
This isn't really useful right now, but will be some day.
1999-11-06 Anthony Green <green@cygnus.com>
* 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.
Index: gcc/java/class.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/class.c,v
retrieving revision 1.47
diff -u -r1.47 class.c
--- class.c 1999/11/05 18:27:28 1.47
+++ class.c 1999/11/06 18:04:09
@@ -53,6 +53,147 @@
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 @@
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 @@
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 @@
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 @@
return 2;
}
- if (flag_assume_compiled)
+ if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class)))))
{
if (!CLASS_LOADED_P (class))
{
Index: gcc/java/java-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/java-tree.h,v
retrieving revision 1.47
diff -u -r1.47 java-tree.h
--- java-tree.h 1999/10/16 01:21:18 1.47
+++ java-tree.h 1999/11/06 18:04:10
@@ -479,6 +479,7 @@
#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));
Index: gcc/java/lang.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lang.c,v
retrieving revision 1.33
diff -u -r1.33 lang.c
--- lang.c 1999/10/16 01:21:18 1.33
+++ lang.c 1999/11/06 18:21:36
@@ -124,7 +128,6 @@
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 +154,34 @@
{
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 +190,7 @@
}
#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;
--
Anthony Green Cygnus Solutions
Sunnyvale, California