United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6676841 ClearArrayNode::Identity is incorrect for 64-bit
6676841 : ClearArrayNode::Identity is incorrect for 64-bit

Details
Type:
Bug
Submit Date:
2008-03-18
Status:
Closed
Updated Date:
2011-04-20
Project Name:
JDK
Resolved Date:
2011-04-20
Component:
hotspot
OS:
solaris_9
Sub-Component:
compiler
CPU:
sparc
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs12

Related Reports
Backport:
Backport:

Sub Tasks

Description
ClearArray::identity assumes that the count of words to clear is an int when in fact it is an intptr_t so it's a long in 64-bit.  This inhibits elimination of useless ClearArrays.  The fix is to use TypeX instead of TypeInt.  Additionally in many cases it's possible to know at creation time there is nothing to do so we shouldn't bother to create them in those cases.

                                    

Comments
SUGGESTED FIX

repo:       /net/jano2.sfbay/export2/hotspot/hg/hotspot-comp.clean
changeset:  51:daf38130e60d
user:       never
date:       Tue Mar 18 23:44:46 2008 -0700
description:
6676841: ClearArrayNode::Identity is incorrect for 64-bit
Summary: ClearArrayNode::Identity should use TypeX instead of TypeInt
Reviewed-by: jrose, kvn, sgoldman

files:
src/share/vm/opto/memnode.cpp
                                     
2008-03-19
SUGGESTED FIX

diff -r 6dbf1a175d6b src/share/vm/opto/memnode.cpp
--- a/src/share/vm/opto/memnode.cpp     Fri Mar 14 16:40:42 2008 -0700
+++ b/src/share/vm/opto/memnode.cpp     Tue Mar 18 11:01:12 2008 -0700
@@ -1881,7 +1881,7 @@ uint ClearArrayNode::match_edge(uint idx
 //------------------------------Identity---------------------------------------
 // Clearing a zero length array does nothing
 Node *ClearArrayNode::Identity( PhaseTransform *phase ) {
-  return phase->type(in(2))->higher_equal(TypeInt::ZERO)  ? in(1) : this;
+  return phase->type(in(2))->higher_equal(TypeX::ZERO)  ? in(1) : this;
 }

 //------------------------------Idealize---------------------------------------
@@ -1954,6 +1954,11 @@ Node* ClearArrayNode::clear_memory(Node*
                                    Node* start_offset,
                                    Node* end_offset,
                                    PhaseGVN* phase) {
+  if (start_offset == end_offset) {
+    // nothing to do
+    return mem;
+  }
+
   Compile* C = phase->C;
   int unit = BytesPerLong;
   Node* zbase = start_offset;
@@ -1979,6 +1984,11 @@ Node* ClearArrayNode::clear_memory(Node*
                                    intptr_t start_offset,
                                    intptr_t end_offset,
                                    PhaseGVN* phase) {
+  if (start_offset == end_offset) {
+    // nothing to do
+    return mem;
+  }
+
   Compile* C = phase->C;
   assert((end_offset % BytesPerInt) == 0, "odd end offset");
   intptr_t done_offset = end_offset;
                                     
2008-03-18
EVALUATION

do as suggested.
                                     
2008-03-18



Hardware and Software, Engineered to Work Together