< prev index next >

src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp

Print this page
rev 49290 : [mq]: JDK-8199735.01.patch
   1 /*
   2  * Copyright (c) 2002, 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  *


  98   }
  99 }
 100 
 101 inline void PSPromotionManager::push_contents(oop obj) {
 102   obj->ps_push_contents(this);
 103 }
 104 //
 105 // This method is pretty bulky. It would be nice to split it up
 106 // into smaller submethods, but we need to be careful not to hurt
 107 // performance.
 108 //
 109 template<bool promote_immediately>
 110 inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
 111   assert(should_scavenge(&o), "Sanity");
 112 
 113   oop new_obj = NULL;
 114 
 115   // NOTE! We must be very careful with any methods that access the mark
 116   // in o. There may be multiple threads racing on it, and it may be forwarded
 117   // at any time. Do not use oop methods for accessing the mark!
 118   markOop test_mark = o->mark();
 119 
 120   // The same test as "o->is_forwarded()"
 121   if (!test_mark->is_marked()) {
 122     bool new_obj_is_tenured = false;
 123     size_t new_obj_size = o->size();
 124 
 125     // Find the objects age, MT safe.
 126     uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
 127       test_mark->displaced_mark_helper()->age() : test_mark->age();
 128 
 129     if (!promote_immediately) {
 130       // Try allocating obj in to-space (unless too old)
 131       if (age < PSScavenge::tenuring_threshold()) {
 132         new_obj = (oop) _young_lab.allocate(new_obj_size);
 133         if (new_obj == NULL && !_young_gen_is_full) {
 134           // Do we allocate directly, or flush and refill?
 135           if (new_obj_size > (YoungPLABSize / 2)) {
 136             // Allocate this object directly
 137             new_obj = (oop)young_space()->cas_allocate(new_obj_size);
 138             promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL);


   1 /*
   2  * Copyright (c) 2002, 2018, 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  *


  98   }
  99 }
 100 
 101 inline void PSPromotionManager::push_contents(oop obj) {
 102   obj->ps_push_contents(this);
 103 }
 104 //
 105 // This method is pretty bulky. It would be nice to split it up
 106 // into smaller submethods, but we need to be careful not to hurt
 107 // performance.
 108 //
 109 template<bool promote_immediately>
 110 inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
 111   assert(should_scavenge(&o), "Sanity");
 112 
 113   oop new_obj = NULL;
 114 
 115   // NOTE! We must be very careful with any methods that access the mark
 116   // in o. There may be multiple threads racing on it, and it may be forwarded
 117   // at any time. Do not use oop methods for accessing the mark!
 118   markOop test_mark = o->mark_raw();
 119 
 120   // The same test as "o->is_forwarded()"
 121   if (!test_mark->is_marked()) {
 122     bool new_obj_is_tenured = false;
 123     size_t new_obj_size = o->size();
 124 
 125     // Find the objects age, MT safe.
 126     uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
 127       test_mark->displaced_mark_helper()->age() : test_mark->age();
 128 
 129     if (!promote_immediately) {
 130       // Try allocating obj in to-space (unless too old)
 131       if (age < PSScavenge::tenuring_threshold()) {
 132         new_obj = (oop) _young_lab.allocate(new_obj_size);
 133         if (new_obj == NULL && !_young_gen_is_full) {
 134           // Do we allocate directly, or flush and refill?
 135           if (new_obj_size > (YoungPLABSize / 2)) {
 136             // Allocate this object directly
 137             new_obj = (oop)young_space()->cas_allocate(new_obj_size);
 138             promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL);


< prev index next >