1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
310 // We keep track of the next start index in the length field of
311 // the to-space object. The actual length can be found in the
312 // length field of the from-space object.
313 arrayOop(obj)->set_length(0);
314 oop* old_p = set_partial_array_mask(old);
315 push_on_queue(old_p);
316 } else {
317 HeapRegion* const to_region = _g1h->heap_region_containing(obj_ptr);
318 _scanner.set_region(to_region);
319 obj->oop_iterate_backwards(&_scanner);
320 }
321 return obj;
322 } else {
323 _plab_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context);
324 return forward_ptr;
325 }
326 }
327
328 G1ParScanThreadState* G1ParScanThreadStateSet::state_for_worker(uint worker_id) {
329 assert(worker_id < _n_workers, "out of bounds access");
330 return _states[worker_id];
331 }
332
333 void G1ParScanThreadStateSet::add_cards_scanned(uint worker_id, size_t cards_scanned) {
334 assert(worker_id < _n_workers, "out of bounds access");
335 _cards_scanned[worker_id] += cards_scanned;
336 }
337
338 size_t G1ParScanThreadStateSet::total_cards_scanned() const {
339 assert(_flushed, "thread local state from the per thread states should have been flushed");
340 return _total_cards_scanned;
341 }
342
343 const size_t* G1ParScanThreadStateSet::surviving_young_words() const {
344 assert(_flushed, "thread local state from the per thread states should have been flushed");
345 return _surviving_young_words_total;
346 }
347
348 void G1ParScanThreadStateSet::flush() {
349 assert(!_flushed, "thread local state from the per thread states should be flushed once");
350 assert(_total_cards_scanned == 0, "should have been cleared");
351
352 for (uint worker_index = 0; worker_index < _n_workers; ++worker_index) {
353 G1ParScanThreadState* pss = _states[worker_index];
354
355 _total_cards_scanned += _cards_scanned[worker_index];
356
357 pss->flush(_surviving_young_words_total);
358 delete pss;
359 _states[worker_index] = NULL;
360 }
361 _flushed = true;
362 }
363
364 oop G1ParScanThreadState::handle_evacuation_failure_par(oop old, markOop m) {
365 assert(_g1h->obj_in_cs(old), "Object " PTR_FORMAT " should be in the CSet", p2i(old));
366
367 oop forward_ptr = old->forward_to_atomic(old);
368 if (forward_ptr == NULL) {
369 // Forward-to-self succeeded. We are the "owner" of the object.
370 HeapRegion* r = _g1h->heap_region_containing(old);
371
372 if (!r->evacuation_failed()) {
373 r->set_evacuation_failed(true);
|
1 /*
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
310 // We keep track of the next start index in the length field of
311 // the to-space object. The actual length can be found in the
312 // length field of the from-space object.
313 arrayOop(obj)->set_length(0);
314 oop* old_p = set_partial_array_mask(old);
315 push_on_queue(old_p);
316 } else {
317 HeapRegion* const to_region = _g1h->heap_region_containing(obj_ptr);
318 _scanner.set_region(to_region);
319 obj->oop_iterate_backwards(&_scanner);
320 }
321 return obj;
322 } else {
323 _plab_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context);
324 return forward_ptr;
325 }
326 }
327
328 G1ParScanThreadState* G1ParScanThreadStateSet::state_for_worker(uint worker_id) {
329 assert(worker_id < _n_workers, "out of bounds access");
330 if (_states[worker_id] == NULL) {
331 _states[worker_id] = new_par_scan_state(worker_id, _young_cset_length);
332 }
333 return _states[worker_id];
334 }
335
336 void G1ParScanThreadStateSet::add_cards_scanned(uint worker_id, size_t cards_scanned) {
337 assert(worker_id < _n_workers, "out of bounds access");
338 _cards_scanned[worker_id] += cards_scanned;
339 }
340
341 size_t G1ParScanThreadStateSet::total_cards_scanned() const {
342 assert(_flushed, "thread local state from the per thread states should have been flushed");
343 return _total_cards_scanned;
344 }
345
346 const size_t* G1ParScanThreadStateSet::surviving_young_words() const {
347 assert(_flushed, "thread local state from the per thread states should have been flushed");
348 return _surviving_young_words_total;
349 }
350
351 void G1ParScanThreadStateSet::flush() {
352 assert(!_flushed, "thread local state from the per thread states should be flushed once");
353 assert(_total_cards_scanned == 0, "should have been cleared");
354
355 for (uint worker_index = 0; worker_index < _n_workers; ++worker_index) {
356 G1ParScanThreadState* pss = _states[worker_index];
357
358 if (pss == NULL) {
359 continue;
360 }
361
362 _total_cards_scanned += _cards_scanned[worker_index];
363
364 pss->flush(_surviving_young_words_total);
365 delete pss;
366 _states[worker_index] = NULL;
367 }
368 _flushed = true;
369 }
370
371 oop G1ParScanThreadState::handle_evacuation_failure_par(oop old, markOop m) {
372 assert(_g1h->obj_in_cs(old), "Object " PTR_FORMAT " should be in the CSet", p2i(old));
373
374 oop forward_ptr = old->forward_to_atomic(old);
375 if (forward_ptr == NULL) {
376 // Forward-to-self succeeded. We are the "owner" of the object.
377 HeapRegion* r = _g1h->heap_region_containing(old);
378
379 if (!r->evacuation_failed()) {
380 r->set_evacuation_failed(true);
|