PATCH: Improve Java build times
Zack Weinberg
zack@codesourcery.com
Fri May 31 19:30:00 GMT 2002
On Fri, May 31, 2002 at 04:34:37PM -0600, Tom Tromey wrote:
> >>>>> "Zack" == Zack Weinberg <zack@codesourcery.com> writes:
>
> Zack> Also, JCF_USE_STDIO is defined nowhere -- suggest ripping out
> Zack> that option entirely. Code that uses stat does not gain any
> Zack> portability from using stdio.
>
> There's other weird, dead code in gcj. For instance look for
> JAVA_USE_HANDLES. I'm not really sure what either of these options
> was intended for. I'm definitely in favor of removing any code that
> has sat unused for years...
Well, since I'm in a mood for deleting code tonight, here's a patch to
take out both of them. I've compiled this but not tested it. There
might be other stuff to hit - the #if 0 blocks in decl.c and class.c
come to mind - but I am not familiar enough with the code to know
whether any of that should be dusted off and finished instead of
deleted.
> Zack> A broader question: Why is this code using the obsolete DEFUN()
> Zack> notation? These programs are only compiled with GCC - why do
> Zack> they have K+R compat notation at all?
>
> I suppose when the code was written, that was the standard for all of
> gcc. Things changed since then, but nobody updated this code.
I'm not volunteering to do it :-)
zw
java:
* 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.
===================================================================
Index: java/class.c
--- java/class.c 17 Apr 2002 23:13:11 -0000 1.131
+++ java/class.c 1 Jun 2002 02:20:42 -0000
@@ -286,21 +286,7 @@ make_class ()
{
tree type;
type = make_node (RECORD_TYPE);
-#ifdef JAVA_USE_HANDLES
- tree field1 = build_decl (FIELD_DECL, get_identifier ("obj"),
- build_pointer_type (type));
- tree field2 = build_decl (FIELD_DECL, get_identifier ("methods"),
- methodtable_ptr_type);
- tree handle_type = make_node (RECORD_TYPE);
- TREE_CHAIN (field1) = field2;
- TYPE_FIELDS (handle_type) = field1;
- TYPE_BINFO (type) = make_tree_vec (7);
- TYPE_BINFO (handle_type) = make_tree_vec (7);
- BINFO_HANDLE (TYPE_BINFO (handle_type)) = type;
- BINFO_HANDLE (TYPE_BINFO (type)) = handle_type;
-#else
TYPE_BINFO (type) = make_tree_vec (6);
-#endif
MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
return type;
@@ -357,15 +343,6 @@ push_class (class_type, class_name)
DECL_ARTIFICIAL (decl) = 1;
pushdecl_top_level (decl);
-#ifdef JAVA_USE_HANDLES
- {
- tree handle_name = identifier_subst (class_name,
- "Handle$", '.', '.', "");
- tree handle_decl = build_decl (TYPE_DECL, handle_name,
- CLASS_TO_HANDLE_TYPE (class_type));
- pushdecl (handle_decl);
- }
-#endif
return decl;
}
@@ -622,7 +599,7 @@ build_java_method_type (fntype, this_cla
{
if (access_flags & ACC_STATIC)
return fntype;
- return build_method_type (CLASS_TO_HANDLE_TYPE (this_class), fntype);
+ return build_method_type (this_class, fntype);
}
static struct hash_entry *
@@ -663,8 +640,8 @@ java_hash_compare_tree_node (k1, k2)
}
tree
-add_method_1 (handle_class, access_flags, name, function_type)
- tree handle_class;
+add_method_1 (this_class, access_flags, name, function_type)
+ tree this_class;
int access_flags;
tree name;
tree function_type;
@@ -672,10 +649,10 @@ add_method_1 (handle_class, access_flags
tree method_type, fndecl;
method_type = build_java_method_type (function_type,
- handle_class, access_flags);
+ this_class, access_flags);
fndecl = build_decl (FUNCTION_DECL, name, method_type);
- DECL_CONTEXT (fndecl) = handle_class;
+ DECL_CONTEXT (fndecl) = this_class;
DECL_LANG_SPECIFIC (fndecl)
= (struct lang_decl *) ggc_alloc_cleared (sizeof (struct lang_decl));
@@ -694,15 +671,15 @@ add_method_1 (handle_class, access_flags
/* Initialize the static method invocation compound list */
DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl) = NULL_TREE;
- TREE_CHAIN (fndecl) = TYPE_METHODS (handle_class);
- TYPE_METHODS (handle_class) = fndecl;
+ TREE_CHAIN (fndecl) = TYPE_METHODS (this_class);
+ TYPE_METHODS (this_class) = fndecl;
/* 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 (handle_class) = 1;
+ HAS_FINALIZER_P (this_class) = 1;
if (access_flags & ACC_PUBLIC) METHOD_PUBLIC (fndecl) = 1;
if (access_flags & ACC_PROTECTED) METHOD_PROTECTED (fndecl) = 1;
@@ -735,7 +712,6 @@ add_method (this_class, access_flags, na
tree name;
tree method_sig;
{
- tree handle_class = CLASS_TO_HANDLE_TYPE (this_class);
tree function_type, fndecl;
const unsigned char *sig
= (const unsigned char *) IDENTIFIER_POINTER (method_sig);
@@ -744,7 +720,7 @@ add_method (this_class, access_flags, na
fatal_error ("bad method signature");
function_type = get_type_from_signature (method_sig);
- fndecl = add_method_1 (handle_class, access_flags, name, function_type);
+ fndecl = add_method_1 (this_class, access_flags, name, function_type);
set_java_signature (TREE_TYPE (fndecl), method_sig);
return fndecl;
}
@@ -1566,7 +1542,7 @@ make_class_data (type)
fields_decl = NULL_TREE;
/* Build Method array. */
- for (method = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (type));
+ for (method = TYPE_METHODS (type);
method != NULL_TREE; method = TREE_CHAIN (method))
{
tree init;
@@ -1748,7 +1724,7 @@ void
finish_class ()
{
tree method;
- tree type_methods = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (current_class));
+ tree type_methods = TYPE_METHODS (current_class);
int saw_native_method = 0;
/* Find out if we have any native methods. We use this information
@@ -2054,13 +2030,12 @@ layout_class_methods (this_class)
tree this_class;
{
tree method_decl, dtable_count;
- tree super_class, handle_type;
+ tree super_class;
if (TYPE_NVIRTUALS (this_class))
return;
super_class = CLASSTYPE_SUPER (this_class);
- handle_type = CLASS_TO_HANDLE_TYPE (this_class);
if (super_class)
{
@@ -2072,18 +2047,14 @@ layout_class_methods (this_class)
else
dtable_count = integer_zero_node;
- TYPE_METHODS (handle_type) = nreverse (TYPE_METHODS (handle_type));
+ TYPE_METHODS (this_class) = nreverse (TYPE_METHODS (this_class));
- for (method_decl = TYPE_METHODS (handle_type);
+ for (method_decl = TYPE_METHODS (this_class);
method_decl; method_decl = TREE_CHAIN (method_decl))
dtable_count = layout_class_method (this_class, super_class,
method_decl, dtable_count);
TYPE_NVIRTUALS (this_class) = dtable_count;
-
-#ifdef JAVA_USE_HANDLES
- layout_type (handle_type);
-#endif
}
/* Return 0 if NAME is equal to STR, -1 if STR is "less" than NAME,
===================================================================
Index: java/expr.c
--- java/expr.c 24 Apr 2002 22:14:59 -0000 1.145
+++ java/expr.c 1 Jun 2002 02:20:43 -0000
@@ -203,22 +203,6 @@ java_truthvalue_conversion (expr)
}
}
-#ifdef JAVA_USE_HANDLES
-/* Given a pointer to a handle, get a pointer to an object. */
-
-tree
-unhand_expr (expr)
- tree expr;
-{
- tree field, handle_type;
- expr = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (expr)), expr);
- handle_type = TREE_TYPE (expr);
- field = TYPE_FIELDS (handle_type);
- expr = build (COMPONENT_REF, TREE_TYPE (field), expr, field);
- return expr;
-}
-#endif
-
/* Save any stack slots that happen to be in the quick_stack into their
home virtual register slots.
@@ -409,8 +393,6 @@ can_widen_reference_to (source_type, tar
return 1;
else
{
- source_type = HANDLE_TO_CLASS_TYPE (source_type);
- target_type = HANDLE_TO_CLASS_TYPE (target_type);
if (TYPE_ARRAY_P (source_type) || TYPE_ARRAY_P (target_type))
{
HOST_WIDE_INT source_length, target_length;
@@ -1576,12 +1558,9 @@ build_field_ref (self_value, self_class,
&& ! (DECL_P (self_value)
&& DECL_NAME (self_value) == this_identifier_node));
- tree base_handle_type = promote_type (base_class);
- if (base_handle_type != TREE_TYPE (self_value))
- self_value = fold (build1 (NOP_EXPR, base_handle_type, self_value));
-#ifdef JAVA_USE_HANDLES
- self_value = unhand_expr (self_value);
-#endif
+ tree base_type = promote_type (base_class);
+ if (base_type != TREE_TYPE (self_value))
+ self_value = fold (build1 (NOP_EXPR, base_type, self_value));
self_value = build_java_indirect_ref (TREE_TYPE (TREE_TYPE (self_value)),
self_value, check);
return fold (build (COMPONENT_REF, TREE_TYPE (field_decl),
@@ -1849,7 +1828,7 @@ build_known_method_ref (method, method_t
methods_ident = get_identifier ("methods");
ref = build (COMPONENT_REF, method_ptr_type_node, ref,
lookup_field (&class_type_node, methods_ident));
- for (meth = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (self_type));
+ for (meth = TYPE_METHODS (self_type);
; meth = TREE_CHAIN (meth))
{
if (method == meth)
@@ -2064,11 +2043,9 @@ expand_invoke (opcode, method_ref_index,
layout_class_methods (self_type);
if (ID_INIT_P (method_name))
- method = lookup_java_constructor (CLASS_TO_HANDLE_TYPE (self_type),
- method_signature);
+ method = lookup_java_constructor (self_type, method_signature);
else
- method = lookup_java_method (CLASS_TO_HANDLE_TYPE (self_type),
- method_name, method_signature);
+ method = lookup_java_method (self_type, method_name, method_signature);
if (method == NULL_TREE)
{
error ("class '%s' has no method named '%s' matching signature '%s'",
===================================================================
Index: java/java-tree.h
--- java/java-tree.h 19 May 2002 16:25:51 -0000 1.150
+++ java/java-tree.h 1 Jun 2002 02:20:43 -0000
@@ -1018,22 +1018,6 @@ struct lang_type
unsigned strictfp:1; /* `strictfp' class. */
};
-#ifdef JAVA_USE_HANDLES
-/* TYPE_BINFO_HANDLE points from a handle-class to its corresponding
- non-handle-class, and vice verse. */
-
-#define BINFO_HANDLE(NODE) TREE_VEC_ELT ((NODE), 6)
-
-/* Given a RECORD_TYPE for a handle type, return the corresponding class. */
-#define HANDLE_TO_CLASS_TYPE(HTYPE) BINFO_HANDLE (TYPE_BINFO (HTYPE))
-
-/* Given a RECORD_TYPE for a class, return the corresponding handle type. */
-#define CLASS_TO_HANDLE_TYPE(TYPE) BINFO_HANDLE (TYPE_BINFO (TYPE))
-#else
-#define HANDLE_TO_CLASS_TYPE(HTYPE) (HTYPE)
-#define CLASS_TO_HANDLE_TYPE(TYPE) (TYPE)
-#endif
-
#define JCF_u4 unsigned long
#define JCF_u2 unsigned short
@@ -1221,13 +1205,8 @@ extern void jcf_print_utf8 PARAMS ((FILE
extern void jcf_print_char PARAMS ((FILE *, int));
extern void jcf_print_utf8_replace PARAMS ((FILE *, const unsigned char *,
int, int, int));
-# if JCF_USE_STDIO
-extern const char* open_class PARAMS ((const char *, struct JCF *,
- FILE *, const char *));
-# else
extern const char* open_class PARAMS ((const char *, struct JCF *,
int, const char *));
-# endif /* JCF_USE_STDIO */
#endif
extern void java_debug_context PARAMS ((void));
extern void safe_layout_class PARAMS ((tree));
===================================================================
Index: java/jcf-dump.c
--- java/jcf-dump.c 12 Apr 2002 14:28:49 -0000 1.44
+++ java/jcf-dump.c 1 Jun 2002 02:20:43 -0000
@@ -939,11 +939,7 @@ DEFUN(main, (argc, argv),
if (optind >= argc)
{
fprintf (out, "Reading .class from <standard input>.\n");
-#if JCF_USE_STDIO
- open_class ("<stdio>", jcf, stdin, NULL);
-#else
open_class ("<stdio>", jcf, 0, NULL);
-#endif
process_class (jcf);
}
else
===================================================================
Index: java/jcf-io.c
--- java/jcf-io.c 19 May 2002 16:25:51 -0000 1.34
+++ java/jcf-io.c 1 Jun 2002 02:20:44 -0000
@@ -231,30 +231,6 @@ DEFUN(read_zip_member, (jcf, zipd, zipf)
return 0;
}
-#if JCF_USE_STDIO
-const char *
-DEFUN(open_class, (filename, jcf, stream, dep_name),
- const char *filename AND JCF *jcf AND FILE* stream
- AND const char *dep_name)
-{
- if (jcf)
- {
- if (dep_name != NULL)
- jcf_dependency_add_file (dep_name, 0);
- JCF_ZERO (jcf);
- jcf->buffer = NULL;
- jcf->buffer_end = NULL;
- jcf->read_ptr = NULL;
- jcf->read_end = NULL;
- jcf->read_state = stream;
- jcf->filename = filename;
- jcf->filbuf = jcf_filbuf_from_stdio;
- }
- else
- fclose (stream);
- return filename;
-}
-#else
const char *
DEFUN(open_class, (filename, jcf, fd, dep_name),
const char *filename AND JCF *jcf AND int fd AND const char *dep_name)
@@ -289,24 +265,16 @@ DEFUN(open_class, (filename, jcf, fd, de
close (fd);
return filename;
}
-#endif
const char *
DEFUN(find_classfile, (filename, jcf, dep_name),
char *filename AND JCF *jcf AND const char *dep_name)
{
-#if JCF_USE_STDIO
- FILE *stream = fopen (filename, "rb");
- if (stream == NULL)
- return NULL;
- return open_class (arg, jcf, stream, dep_name);
-#else
int fd = open (filename, O_RDONLY | O_BINARY);
if (fd < 0)
return NULL;
return open_class (filename, jcf, fd, dep_name);
-#endif
}
#if JCF_USE_SCANDIR
@@ -461,11 +429,7 @@ DEFUN(find_class, (classname, classname_
const char *classname AND int classname_length AND JCF *jcf AND int source_ok)
{
-#if JCF_USE_STDIO
- FILE *stream;
-#else
int fd;
-#endif
int i, k, java = -1, class = -1;
struct stat java_buf, class_buf;
char *dep_file;
@@ -578,27 +542,6 @@ DEFUN(find_class, (classname, classname_
dep_file = java_buffer;
else
dep_file = buffer;
-#if JCF_USE_STDIO
- if (!class)
- {
- SOURCE_FRONTEND_DEBUG (("Trying %s", buffer));
- stream = fopen (buffer, "rb");
- if (stream)
- goto found;
- }
- /* Give .java a try, if necessary */
- if (!java)
- {
- strcpy (buffer, java_buffer);
- SOURCE_FRONTEND_DEBUG (("Trying %s", buffer));
- stream = fopen (buffer, "r");
- if (stream)
- {
- jcf->java_source = 1;
- goto found;
- }
- }
-#else
if (!class)
{
SOURCE_FRONTEND_DEBUG ((stderr, "[Class selected: %s]\n",
@@ -624,7 +567,6 @@ DEFUN(find_class, (classname, classname_
goto found;
}
}
-#endif
free (buffer);
@@ -635,12 +577,6 @@ DEFUN(find_class, (classname, classname_
return NULL;
found:
-#if JCF_USE_STDIO
- if (jcf->java_source)
- return NULL; /* FIXME */
- else
- return open_class (buffer, jcf, stream, dep_file);
-#else
if (jcf->java_source)
{
JCF_ZERO (jcf); /* JCF_FINISH relies on this */
@@ -652,7 +588,6 @@ DEFUN(find_class, (classname, classname_
buffer = (char *) open_class (buffer, jcf, fd, dep_file);
jcf->classname = xstrdup (classname);
return buffer;
-#endif
}
void
===================================================================
Index: java/jcf-parse.c
--- java/jcf-parse.c 28 May 2002 17:33:09 -0000 1.116
+++ java/jcf-parse.c 1 Jun 2002 02:20:44 -0000
@@ -193,9 +193,7 @@ set_source_filename (jcf, index)
DECL_LINENUMBERS_OFFSET (current_method) = 0)
#define HANDLE_END_METHODS() \
-{ tree handle_type = CLASS_TO_HANDLE_TYPE (current_class); \
- if (handle_type != current_class) layout_type (handle_type); \
- current_method = NULL_TREE; }
+{ current_method = NULL_TREE; }
#define HANDLE_CODE_ATTRIBUTE(MAX_STACK, MAX_LOCALS, CODE_LENGTH) \
{ DECL_MAX_STACK (current_method) = (MAX_STACK); \
@@ -745,12 +743,12 @@ parse_class_file ()
compiling from class files. */
always_initialize_class_p = 1;
- for (field = TYPE_FIELDS (CLASS_TO_HANDLE_TYPE (current_class));
+ for (field = TYPE_FIELDS (current_class);
field != NULL_TREE; field = TREE_CHAIN (field))
if (FIELD_STATIC (field))
DECL_EXTERNAL (field) = 0;
- for (method = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (current_class));
+ for (method = TYPE_METHODS (current_class);
method != NULL_TREE; method = TREE_CHAIN (method))
{
JCF *jcf = current_jcf;
===================================================================
Index: java/parse.y
--- java/parse.y 28 May 2002 17:33:10 -0000 1.379
+++ java/parse.y 1 Jun 2002 02:20:48 -0000
@@ -1907,6 +1907,7 @@ catch_clause:
exit_block ();
$$ = $1;
}
+;
catch_clause_parameter:
CATCH_TK OP_TK formal_parameter CP_TK
@@ -6311,7 +6312,7 @@ java_check_regular_methods (class_decl)
{
int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
tree method;
- tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
+ tree class = TREE_TYPE (class_decl);
tree found = NULL_TREE;
tree mthrows;
===================================================================
Index: java/typeck.c
--- java/typeck.c 28 May 2002 17:33:14 -0000 1.49
+++ java/typeck.c 1 Jun 2002 02:20:48 -0000
@@ -446,7 +446,7 @@ promote_type (type)
switch (TREE_CODE (type))
{
case RECORD_TYPE:
- return build_pointer_type (CLASS_TO_HANDLE_TYPE (type));
+ return build_pointer_type (type);
case BOOLEAN_TYPE:
if (type == boolean_type_node)
return promoted_boolean_type_node;
===================================================================
Index: java/verify.c
--- java/verify.c 16 Dec 2001 16:23:50 -0000 1.47
+++ java/verify.c 1 Jun 2002 02:20:49 -0000
@@ -145,8 +145,8 @@ merge_types (type1, type2)
if (type2 == ptr_type_node || type1 == object_ptr_type_node)
return type1;
- tt1 = HANDLE_TO_CLASS_TYPE (TREE_TYPE (type1));
- tt2 = HANDLE_TO_CLASS_TYPE (TREE_TYPE (type2));
+ tt1 = TREE_TYPE (type1);
+ tt2 = TREE_TYPE (type2);
/* If tt{1,2} haven't been properly loaded, now is a good time
to do it. */
More information about the Java
mailing list