Shorten primitive array allocation path:
authorBryce McKinlay <bryce@albatross.co.nz>
Sun, 24 Dec 2000 00:43:40 +0000 (00:43 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Sun, 24 Dec 2000 00:43:40 +0000 (00:43 +0000)
        * 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.

From-SVN: r38482

gcc/java/ChangeLog
gcc/java/decl.c
gcc/java/expr.c

index 42a82bf9333b85cea55607abd76dcb06799b539d..c52b5291a0e8756e7b53939e58eaa02682aa9d79 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-22  Bryce McKinlay  <bryce@albatross.co.nz>
+
+       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.
+       
 2000-12-17  Bryce McKinlay  <bryce@albatross.co.nz>
 
        Fix for PRs gcj/312 and gcj/253:
index 0ed71700bde8ee5ffe4e2871ec10e96de8306526..df6b236e45ed6b9286caac84386f69300e17cdae 100644 (file)
@@ -775,7 +775,7 @@ init_decl_processing ()
   t = tree_cons (NULL_TREE, int_type_node, 
                 tree_cons (NULL_TREE, int_type_node, endlink));
   soft_newarray_node
-      = builtin_function ("_Jv_NewArray",
+      = builtin_function ("_Jv_NewPrimArray",
                          build_function_type(ptr_type_node, t),
                          0, NOT_BUILT_IN, NULL_PTR);
   DECL_IS_MALLOC (soft_newarray_node) = 1;
index 5b9048856ee4dbabcef4af5861302114e2dae9c0..95a27fd4ccd4ca0c3344a70be7842b0ebfaa0632 100644 (file)
@@ -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);
 }