3073 rem = fc->size() - n * word_sz; |
3073 rem = fc->size() - n * word_sz; |
3074 // If there is a remainder, and it's too small, allocate one fewer. |
3074 // If there is a remainder, and it's too small, allocate one fewer. |
3075 if (rem > 0 && rem < MinChunkSize) { |
3075 if (rem > 0 && rem < MinChunkSize) { |
3076 n--; rem += word_sz; |
3076 n--; rem += word_sz; |
3077 } |
3077 } |
3078 assert((ssize_t)n >= 1, "Control point invariant"); |
3078 // Note that at this point we may have n == 0. |
|
3079 assert((ssize_t)n >= 0, "Control point invariant"); |
|
3080 |
|
3081 // If n is 0, the chunk fc that was found is not large |
|
3082 // enough to leave a viable remainder. We are unable to |
|
3083 // allocate even one block. Return fc to the |
|
3084 // dictionary and return, leaving "fl" empty. |
|
3085 if (n == 0) { |
|
3086 returnChunkToDictionary(fc); |
|
3087 return; |
|
3088 } |
|
3089 |
3079 // First return the remainder, if any. |
3090 // First return the remainder, if any. |
3080 // Note that we hold the lock until we decide if we're going to give |
3091 // Note that we hold the lock until we decide if we're going to give |
3081 // back the remainder to the dictionary, since a concurrent allocation |
3092 // back the remainder to the dictionary, since a concurrent allocation |
3082 // may otherwise see the heap as empty. (We're willing to take that |
3093 // may otherwise see the heap as empty. (We're willing to take that |
3083 // hit if the block is a small block.) |
3094 // hit if the block is a small block.) |