Request for review (M): 6778669: Patch from Red Hat -- fixes compilation errors

Christian Thalinger Christian.Thalinger at Sun.COM
Mon Feb 23 08:47:21 PST 2009


On Sun, 2009-02-22 at 20:35 +0000, Andrew John Hughes wrote:
> /tmp/hotspot-comp/hotspot/src/share/vm/adlc/output_c.cpp:1251: error: format '%d' expects type 'int', but argument 3 has type 'intptr_t'
> /tmp/hotspot-comp/hotspot/src/share/vm/adlc/output_c.cpp:1256: error: format '%d' expects type 'int', but argument 3 has type 'intptr_t'
> /tmp/hotspot-comp/hotspot/src/share/vm/adlc/output_c.cpp:1256: error: format '%d' expects type 'int', but argument 5 has type 'intptr_t'
<snip>

I was looking more closely at these and it seems it's not really
necessary that the type is an intptr_t.  There is even an assert in
output_c.cpp (left_index is one of the warnings):

  assert( (left_index <= 9999) && (left_op_index <= 9999), "exceed string size");

Digging further into the code and changing the intptr_t's to int's
revealed that in some classes a NameList is used to store these
integers, e.g.:

  class PeepMatch : public Form {
  private:
    char *_rule;
    // NameList  _depth;                // Depth of this instruction
    NameList  _parent;
    NameList  _position;

The integers are stored like:

void  PeepMatch::add_instruction(intptr_t parent, intptr_t position, const char *name,
                                 intptr_t input) {
  if( position > _max_position ) _max_position = position;

  _parent.addName((char *)parent);
  _position.addName((char *)position);

(Note: _max_position is an int)

And retrieved with:

void  PeepMatch::next_instruction(intptr_t &parent, intptr_t &position, const char* &name, intptr_t &input) {
  parent   = (intptr_t) _parent.iter();
  position = (intptr_t) _position.iter();

Would it be possible to use std::vector<int> or std::list<int> instead
of a NameList for these integers?

-- Christian




More information about the hotspot-dev mailing list