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

G1: SATB and Update buffer allocation code allocates too much space

    XMLWordPrintable

Details

    • gc
    • b06
    • generic, x86, sparc
    • generic, solaris_10

    Backports

      Description

        While investigating 6889740 it was discovered that the code that allocates the buffers that are used for the SATB and Update processing allocates too much space.

        For the SATB buffers we set the size of the SATB Queue set (the _sz field) to be G1SATBLogBufferSize * oopSize during VM initialization. With the default value of G1SATBLogBufferSize (1K) this gives _sz = 8*1K or 4*1K (for 32 bit). The actual buffers are allocated using NEW_C_HEAP_ARRAY and given void* as the type. This means that size requested of the allocation routine is 8K*8 = 64K (or 4K*4 = 16K for 32 bit).

        This seenms to be incorrect. The buffers are indexed using a helper routine byte_index_to_index which takes an index (usually the value of the _index field) and divides it by oopSize to give an index into the buffer array. The _index field is initialized to the value of _sz (8*1K). Suppose we have _index == 8184 (_sz - oopSize), the value of byte_index_to_index for 8184 gives 1023. So we assign into _buf[1023].

        So we assign values into _buf[0..(_sz/oopSize)-1] but we have allocated a buffer with enough space to hold 8K entries (64K bytes).

        The fix is relatively simple: the code in allocate_buffer and deallocate_buffer should be changed to use:

           (void**)NEW_C_HEAP_ARRAY(char, _sz);

        This will give 8K byte buffers - which looks like what was intended from the generated barrier code and the indexing code in the flush routine.

        Attachments

          Issue Links

            Activity

              People

                johnc John Cuthbertson
                johnc John Cuthbertson
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: