314
315 // If GC was locked out during VM operation then retry allocation
316 // and/or stall as necessary.
317 if (op.gc_locked()) {
318 assert(op.result() == NULL, "must be NULL if gc_locked() is true");
319 continue; // retry and/or stall as necessary
320 }
321
322 // Exit the loop if the gc time limit has been exceeded.
323 // The allocation must have failed above ("result" guarding
324 // this path is NULL) and the most recent collection has exceeded the
325 // gc overhead limit (although enough may have been collected to
326 // satisfy the allocation). Exit the loop so that an out-of-memory
327 // will be thrown (return a NULL ignoring the contents of
328 // op.result()),
329 // but clear gc_overhead_limit_exceeded so that the next collection
330 // starts with a clean slate (i.e., forgets about previous overhead
331 // excesses). Fill op.result() with a filler object so that the
332 // heap remains parsable.
333 const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded();
334 const bool softrefs_clear = collector_policy()->all_soft_refs_clear();
335
336 if (limit_exceeded && softrefs_clear) {
337 *gc_overhead_limit_was_exceeded = true;
338 size_policy()->set_gc_overhead_limit_exceeded(false);
339 log_trace(gc)("ParallelScavengeHeap::mem_allocate: return NULL because gc_overhead_limit_exceeded is set");
340 if (op.result() != NULL) {
341 CollectedHeap::fill_with_object(op.result(), size);
342 }
343 return NULL;
344 }
345
346 return op.result();
347 }
348 }
349
350 // The policy object will prevent us from looping forever. If the
351 // time spent in gc crosses a threshold, we will bail out.
352 loop_count++;
353 if ((result == NULL) && (QueuedAllocationWarningCount > 0) &&
354 (loop_count % QueuedAllocationWarningCount == 0)) {
|
314
315 // If GC was locked out during VM operation then retry allocation
316 // and/or stall as necessary.
317 if (op.gc_locked()) {
318 assert(op.result() == NULL, "must be NULL if gc_locked() is true");
319 continue; // retry and/or stall as necessary
320 }
321
322 // Exit the loop if the gc time limit has been exceeded.
323 // The allocation must have failed above ("result" guarding
324 // this path is NULL) and the most recent collection has exceeded the
325 // gc overhead limit (although enough may have been collected to
326 // satisfy the allocation). Exit the loop so that an out-of-memory
327 // will be thrown (return a NULL ignoring the contents of
328 // op.result()),
329 // but clear gc_overhead_limit_exceeded so that the next collection
330 // starts with a clean slate (i.e., forgets about previous overhead
331 // excesses). Fill op.result() with a filler object so that the
332 // heap remains parsable.
333 const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded();
334 const bool softrefs_clear = soft_ref_policy()->all_soft_refs_clear();
335
336 if (limit_exceeded && softrefs_clear) {
337 *gc_overhead_limit_was_exceeded = true;
338 size_policy()->set_gc_overhead_limit_exceeded(false);
339 log_trace(gc)("ParallelScavengeHeap::mem_allocate: return NULL because gc_overhead_limit_exceeded is set");
340 if (op.result() != NULL) {
341 CollectedHeap::fill_with_object(op.result(), size);
342 }
343 return NULL;
344 }
345
346 return op.result();
347 }
348 }
349
350 // The policy object will prevent us from looping forever. If the
351 // time spent in gc crosses a threshold, we will bail out.
352 loop_count++;
353 if ((result == NULL) && (QueuedAllocationWarningCount > 0) &&
354 (loop_count % QueuedAllocationWarningCount == 0)) {
|