aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2003-07-09 02:31:20 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2003-07-09 00:31:20 +0000
commit084c1779088967df7cde7aef1ac91587d68ab3bb (patch)
tree5029eb04a9f787f6958b11882444a0e5bc409cfb /gcc/java
parent1b1838b64cf2ee0cc35ddf75020894de2a84ee38 (diff)
downloadgcc-084c1779088967df7cde7aef1ac91587d68ab3bb.zip
gcc-084c1779088967df7cde7aef1ac91587d68ab3bb.tar.gz
gcc-084c1779088967df7cde7aef1ac91587d68ab3bb.tar.bz2
java-tree.h (DECL_NUM_STMTS): Rename to...
* java-tree.h (DECL_NUM_STMTS): Rename to... (DECL_ESTIMATED_INSNS): ... this. * lang.c (java_estimate_num_insns, java_estimate_num_insns_1): New static functions. (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Define. * parser.y (add_stmt_to_compound): Do not account statements. * cp-lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): New. * decl.c (duplicate_decls): Use DECL_ESTIMATED_INSNS. (start_function): Use DECL_ESTIMATED_INSNS. * optimize.c (maybe_clone_body): Use DECL_ESTIMATED_INSNS. * decl2.c (maybe_emit_vtables): Fix marking vtables as needed in unit-at-a-time * c-common.c (c_estimate_num_insns_1): New static function. (c_estimate_num_insns): New global function. * c-common.h (DECL_NUM_STMTS): Rename to... (DECL_ESTIMATED_INSNS): ... this. (c_estimate_num_insns): Declare. * c-decl.c (duplicate_decls): Use DECL_ESTIMATED_INSNS. * c-lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): New. * c-semantics.c (add_stmt): Do not account statements. * langhooks-def.h (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): New. * langhooks.h (lang_hooks_for_tree_inlining): Add estimate_num_insns * params.def (max-inline-insns-auto, max-inline-insns-auto): set to 100. (max-inline-insns): set to 300. (min-inline-insns): set to 10. * tree-inline.c (struct inline_data): Rename inlined_stmts to inlined-insns. (INSNS_PER_STMT): Kill. (inlinable_function_p): Compute and store body size. (expand_call_inline): Likewise. (optimize_inline_calls): Likewise. From-SVN: r69113
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog9
-rw-r--r--gcc/java/java-tree.h4
-rw-r--r--gcc/java/lang.c107
-rw-r--r--gcc/java/parse.y4
4 files changed, 118 insertions, 6 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index e00ec4b..fba4f04 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,12 @@
+Wed Jul 9 02:29:15 CEST 2003 Jan Hubicka <jh@suse.cz>
+
+ * java-tree.h (DECL_NUM_STMTS): Rename to...
+ (DECL_ESTIMATED_INSNS): ... this.
+ * lang.c (java_estimate_num_insns, java_estimate_num_insns_1):
+ New static functions.
+ (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Define.
+ * parser.y (add_stmt_to_compound): Do not account statements.
+
2003-07-08 Mark Wielaard <mark@klomp.org>
* gcj.texi: CNI now expands to Compiled Native Interface.
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index f4764e7..357f349 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -922,10 +922,10 @@ union lang_tree_node
#define DECL_FIELD_FINAL_WFL(NODE) \
(DECL_LANG_SPECIFIC(NODE)->u.v.wfl)
/* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this is
- the approximate number of statements in this function. There is
+ the approximate number of instructions in this function. There is
no need for this number to be exact; it is only used in various
heuristics regarding optimization. */
-#define DECL_NUM_STMTS(NODE) \
+#define DECL_ESTIMATED_INSNS(NODE) \
(FUNCTION_DECL_CHECK (NODE)->decl.u1.i)
/* True if NODE is a local variable final. */
#define LOCAL_FINAL_P(NODE) (DECL_LANG_SPECIFIC (NODE) && DECL_FINAL (NODE))
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index 7402ab7..1f94706 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -66,6 +66,7 @@ static bool java_can_use_bit_fields_p (void);
static bool java_dump_tree (void *, tree);
static void dump_compound_expr (dump_info_p, tree);
static bool java_decl_ok_for_sibcall (tree);
+static int java_estimate_num_insns (tree);
#ifndef TARGET_OBJECT_SUFFIX
# define TARGET_OBJECT_SUFFIX ".o"
@@ -249,6 +250,9 @@ struct language_function GTY(())
#undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
#define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES java_tree_inlining_walk_subtrees
+#undef LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS
+#define LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS java_estimate_num_insns
+
#undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
@@ -1076,4 +1080,107 @@ java_decl_ok_for_sibcall (tree decl)
return decl != NULL && DECL_CONTEXT (decl) == current_class;
}
+/* Used by estimate_num_insns. Estimate number of instructions seen
+ by given statement. */
+static tree
+java_estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
+{
+ int *count = data;
+ tree x = *tp;
+
+ if (TYPE_P (x) || DECL_P (x))
+ {
+ *walk_subtrees = 0;
+ return NULL;
+ }
+ /* Assume that constants and references counts nothing. These should
+ be majorized by amount of operations amoung them we count later
+ and are common target of CSE and similar optimizations. */
+ if (TREE_CODE_CLASS (TREE_CODE (x)) == 'c'
+ || TREE_CODE_CLASS (TREE_CODE (x)) == 'r')
+ return NULL;
+ switch (TREE_CODE (x))
+ {
+ /* Reconginze assignments of large structures and constructors of
+ big arrays. */
+ case MODIFY_EXPR:
+ case CONSTRUCTOR:
+ {
+ int size = int_size_in_bytes (TREE_TYPE (x));
+
+ if (!size || size > MOVE_MAX_PIECES)
+ *count += 10;
+ else
+ *count += 2 * (size + MOVE_MAX - 1) / MOVE_MAX;
+ return NULL;
+ }
+ break;
+ /* Few special cases of expensive operations. This is usefull
+ to avoid inlining on functions having too many of these. */
+ case TRUNC_DIV_EXPR:
+ case CEIL_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case TRUNC_MOD_EXPR:
+ case CEIL_MOD_EXPR:
+ case FLOOR_MOD_EXPR:
+ case ROUND_MOD_EXPR:
+ case RDIV_EXPR:
+ case CALL_EXPR:
+ case METHOD_CALL_EXPR:
+
+ case NEW_ARRAY_EXPR:
+ case NEW_ANONYMOUS_ARRAY_EXPR:
+ case NEW_CLASS_EXPR:
+ *count += 10;
+ break;
+ /* Various containers that will produce no code themselves. */
+ case INIT_EXPR:
+ case TARGET_EXPR:
+ case BIND_EXPR:
+ case BLOCK:
+ case TREE_LIST:
+ case TREE_VEC:
+ case IDENTIFIER_NODE:
+ case PLACEHOLDER_EXPR:
+ case WITH_CLEANUP_EXPR:
+ case CLEANUP_POINT_EXPR:
+ case NOP_EXPR:
+ case VIEW_CONVERT_EXPR:
+ case SAVE_EXPR:
+ case UNSAVE_EXPR:
+ case COMPLEX_EXPR:
+ case REALPART_EXPR:
+ case IMAGPART_EXPR:
+ case TRY_CATCH_EXPR:
+ case TRY_FINALLY_EXPR:
+ case LABEL_EXPR:
+ case EXIT_EXPR:
+ case LABELED_BLOCK_EXPR:
+ case EXIT_BLOCK_EXPR:
+ case EXPR_WITH_FILE_LOCATION:
+ case UNARY_PLUS_EXPR:
+ case THIS_EXPR:
+ case DEFAULT_EXPR:
+ case TRY_EXPR:
+
+ break;
+ case CLASS_LITERAL:
+ *walk_subtrees = 0;
+ break;
+ default:
+ (*count)++;
+ }
+ return NULL;
+}
+
+/* Estimate number of instructions that will be created by expanding the body. */
+static int
+java_estimate_num_insns (tree decl)
+{
+ int num = 0;
+ walk_tree (&DECL_SAVED_TREE (decl), java_estimate_num_insns_1, &num, NULL);
+ return num;
+}
+
#include "gt-java-lang.h"
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index a156be1..cbb4297 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -7429,10 +7429,6 @@ add_stmt_to_block (tree b, tree type, tree stmt)
static tree
add_stmt_to_compound (tree existing, tree type, tree stmt)
{
- /* Keep track of this for inlining. */
- if (current_function_decl)
- ++DECL_NUM_STMTS (current_function_decl);
-
if (existing)
return build (COMPOUND_EXPR, type, existing, stmt);
else