JDK-8164632 : Node indices should be treated as unsigned integers
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10,11
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2016-08-23
  • Updated: 2022-03-28
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Node::_idx is declared as node_idx_t (unsigned int) but at several places we cast it to int. For example, in escape.cpp:

uint ni = n->_idx;
[...]
const TypeOopPtr* tinst = t->cast_to_instance_id(ni);

with TypeOopPtr::cast_to_instance_id(int instance_id). This should be fixed to use unsigned int consistently.
Comments
Email thread: https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2020-August/039466.html
28-03-2022

The argument to cast_to_instance_id() is int because TypeOopPtr::_instance_id field is int. That in turn is because _instance_id's value can be InstanceTop, which latter is defined by enum { InstanceTop = -1, // undefined instance InstanceBot = 0 // any possible instance }; I.e., the value of _instance_id can be negative. So, a TypeOopPtr::_instance_id cannot represent node ids greater than INT_MAX. The only place where a node id is passed to cast_to_instance_id() is the single instance in split_unique_types() in escape.cpp referenced in the Description. That could be handled by a cast to make Type's _instance_id range limitation explicit, vis assert(ni <= INT_MAX, "node index cannot be negative"); const TypeOopPtr* tinst = t->cast_to_instance_id((int)ni); The call to cast_to_instance_id() is the only use of ni in split_unique_types().
13-08-2020

Converting to an enhancement because it's not a problem with current code.
27-02-2018

ILW = Cast from unsigned to signed, currently not causing problems because node index is always in signed int range, no workaround = MLH = P4
23-08-2016