diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-24 00:43:40 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-24 00:43:40 +0000 |
commit | 958a6031309a5885ffefbf8e69c398f6a1927e60 (patch) | |
tree | 933ecd6a4250e4eba29b9292dde0fe6fcd8d2d65 /gcc/java/expr.c | |
parent | bef0b7d1542400811eb5eac2fcdf3de2f9de0920 (diff) | |
download | gcc-958a6031309a5885ffefbf8e69c398f6a1927e60.tar.gz |
Shorten primitive array allocation path:
* decl.c (init_decl_processing): Use _Jv_NewPrimArray not _Jv_NewArray
to create new primitive arrays.
* expr.c (build_newarray): If generating native code, call
soft_newarray_node with a reference to the primitive TYPE identifier
instead of type_value.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38482 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r-- | gcc/java/expr.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 5b9048856ee..95a27fd4ccd 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -784,24 +784,35 @@ build_java_check_indexed_type (array_node, indexed_type) return indexed_type; } -/* newarray triggers a call to _Jv_NewArray. This function should be called - with an integer code (the type of array to create) and get from the stack - the size of the dimmension. */ +/* newarray triggers a call to _Jv_NewPrimArray. This function should be + called with an integer code (the type of array to create), and the length + of the array to create. */ tree build_newarray (atype_value, length) int atype_value; tree length; { + tree type_arg; + + tree prim_type = decode_newarray_type (atype_value); tree type - = build_java_array_type (decode_newarray_type (atype_value), + = build_java_array_type (prim_type, host_integerp (length, 0) == INTEGER_CST ? tree_low_cst (length, 0) : -1); + /* If compiling to native, pass a reference to the primitive type class + and save the runtime some work. However, the bytecode generator + expects to find the type_code int here. */ + if (flag_emit_class_files) + type_arg = build_int_2 (atype_value, 0); + else + type_arg = build_class_ref (prim_type); + return build (CALL_EXPR, promote_type (type), build_address_of (soft_newarray_node), tree_cons (NULL_TREE, - build_int_2 (atype_value, 0), + type_arg, build_tree_list (NULL_TREE, length)), NULL_TREE); } |