Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314276

Improve PtrQueue API around size/capacity



    • gc
    • b12


      There are a number of places where we need to check for empty queues or queue size, or empty buffers or buffer size.

      Currently the capacity for PtrQueue is accessible via the _capacity_in_bytes member and also via the associated qset's buffer_capacity(). It's not clear which should be used in some places, and there are asserts sprinkled about to ensure they remain consistent. All the while, the actual buffers whose size is determined by that value have no direct knowledge of it, and code manipulating them must obtain it from one of the other sources and assume that's correct.

      So things in this area are less than ideal.

      It would be better if BufferNode carried around it's capacity information directly. But we don't want to increase the size of BufferNode for that extra information. We can accomplish that by restricting the maximum capacity and combining the index and capacity in a single pointer-sized section of the object. That is, instead of using size_t members for both, use uint32_t for both on 64bit platforms and uint16_t for both on 32bit platforms.

      Then we can get rid of PtrQueue::_capacity_in_bytes and obtain the capacity information from the BN directly rather than from the qset (via its allocator configuration).

      This also permits adding is_empty and size member functions to BufferNode, simplifying various uses and reducing some logical coupling between some uses and the implementation.


        Issue Links



              kbarrett Kim Barrett
              kbarrett Kim Barrett
              0 Vote for this issue
              3 Start watching this issue