JDK-6676841 : ClearArrayNode::Identity is incorrect for 64-bit
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2008-03-18
  • Updated: 2011-04-20
  • Resolved: 2011-04-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 Other
6u14Fixed hs12Fixed
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
19-03-2008

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;
18-03-2008

EVALUATION do as suggested.
18-03-2008