RFR: 8141501: Problems with BitMap buffer management

Stefan Karlsson stefan.karlsson at oracle.com
Wed Apr 27 11:57:14 UTC 2016


Hi all,

Please review this patch to change how the backing storage of BitMaps 
are managed.

http://cr.openjdk.java.net/~stefank/8141501/webrev.01
https://bugs.openjdk.java.net/browse/JDK-8141501

The patch changes BitMap into an abstract base class, with concrete 
sub-classes that manages the underlying bitmap backing storage.

The proposed BitMap classes are:

- BitMap - the abstract base class
- ResourceBitMap - bitmap with resource area allocated backing storage
- ArenaBitMap - bitmap with arena allocated backing storage
- CHeapBitMap - bitmap with CHeap allocated backing storage
- BitMapView - bitmap without the ownership of the backing storage

  This will hopefully make it less likely to use the BitMaps 
incorrectly. Previously, it was possible to write the following broken code:

// CHeap allocate.
BitMap map(BITMAP_SIZE / 2, false);

// Resource allocate.
// The CHeap memory is leaked.
map.resize(BITMAP_SIZE);

and:

// Resource allocate.
BitMap map(BITMAP_SIZE / 2);

// CHeap allocate.
// CHeap freeing Resource allocated memory => memory stomping
map.resize(BITMAP_SIZE, false);

The stricter typing of the new BitMap sub-classes prevents these classes 
of bugs.

Further motivation for this patch can be found in:
https://bugs.openjdk.java.net/browse/JDK-8141501

Tested with JPRT and ExecuteInternalVMTests.

Thanks Kim for providing offline feedback on different revisions of this 
patch.

This changes code in mostly the GC and Compiler parts of the JVM, so it 
would be good to get reviews from those groups.

Thanks,
StefanK


More information about the hotspot-dev mailing list