6977924: Changes for 6975078 produce build error with certain gcc versions

Wed, 18 Aug 2010 10:59:06 -0700

author
johnc
date
Wed, 18 Aug 2010 10:59:06 -0700
changeset 2076
413ad0331a0c
parent 2074
b63010841f78
child 2077
effb55808a18

6977924: Changes for 6975078 produce build error with certain gcc versions
Summary: The changes introduced for 6975078 assign badHeapOopVal to the _allocation field in the ResourceObj class. In 32 bit linux builds with certain versions of gcc this assignment will be flagged as an error while compiling allocation.cpp. In 32 bit builds the constant value badHeapOopVal (which is cast to an intptr_t) is negative. The _allocation field is typed as an unsigned intptr_t and gcc catches this as an error.
Reviewed-by: jcoomes, ysr, phh

src/share/vm/memory/allocation.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/memory/allocation.cpp	Tue Aug 17 14:40:00 2010 -0400
     1.2 +++ b/src/share/vm/memory/allocation.cpp	Wed Aug 18 10:59:06 2010 -0700
     1.3 @@ -58,7 +58,7 @@
     1.4  void ResourceObj::operator delete(void* p) {
     1.5    assert(((ResourceObj *)p)->allocated_on_C_heap(),
     1.6           "delete only allowed for C_HEAP objects");
     1.7 -  DEBUG_ONLY(((ResourceObj *)p)->_allocation = badHeapOopVal;)
     1.8 +  DEBUG_ONLY(((ResourceObj *)p)->_allocation = (uintptr_t) badHeapOopVal;)
     1.9    FreeHeap(p);
    1.10  }
    1.11  
    1.12 @@ -104,7 +104,7 @@
    1.13  ResourceObj::~ResourceObj() {
    1.14      // allocated_on_C_heap() also checks that encoded (in _allocation) address == this.
    1.15      if (!allocated_on_C_heap()) {  // ResourceObj::delete() zaps _allocation for C_heap.
    1.16 -      _allocation = badHeapOopVal; // zap type
    1.17 +      _allocation = (uintptr_t) badHeapOopVal; // zap type
    1.18      }
    1.19  }
    1.20  #endif // ASSERT

mercurial