< prev index next >

src/hotspot/share/gc/cms/parNewGeneration.cpp

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


1116 // is successfully promoted, a forwarding pointer will be installed in
1117 // the object in the young generation.  This method claims the right
1118 // to install the forwarding pointer before it copies the object,
1119 // thus avoiding the need to undo the copy as in
1120 // copy_to_survivor_space_avoiding_with_undo.
1121 
1122 oop ParNewGeneration::copy_to_survivor_space(ParScanThreadState* par_scan_state,
1123                                              oop old,
1124                                              size_t sz,
1125                                              markOop m) {
1126   // In the sequential version, this assert also says that the object is
1127   // not forwarded.  That might not be the case here.  It is the case that
1128   // the caller observed it to be not forwarded at some time in the past.
1129   assert(is_in_reserved(old), "shouldn't be scavenging this oop");
1130 
1131   // The sequential code read "old->age()" below.  That doesn't work here,
1132   // since the age is in the mark word, and that might be overwritten with
1133   // a forwarding pointer by a parallel thread.  So we must save the mark
1134   // word in a local and then analyze it.
1135   oopDesc dummyOld;
1136   dummyOld.set_mark(m);
1137   assert(!dummyOld.is_forwarded(),
1138          "should not be called with forwarding pointer mark word.");
1139 
1140   oop new_obj = NULL;
1141   oop forward_ptr;
1142 
1143   // Try allocating obj in to-space (unless too old)
1144   if (dummyOld.age() < tenuring_threshold()) {
1145     new_obj = (oop)par_scan_state->alloc_in_to_space(sz);
1146     if (new_obj == NULL) {
1147       set_survivor_overflow(true);
1148     }
1149   }
1150 
1151   if (new_obj == NULL) {
1152     // Either to-space is full or we decided to promote try allocating obj tenured
1153 
1154     // Attempt to install a null forwarding pointer (atomically),
1155     // to claim the right to install the real forwarding pointer.
1156     forward_ptr = old->forward_to_atomic(ClaimedForwardPtr);


1164                                       old, m, sz);
1165     }
1166 
1167     if (new_obj == NULL) {
1168       // promotion failed, forward to self
1169       _promotion_failed = true;
1170       new_obj = old;
1171 
1172       par_scan_state->preserved_marks()->push_if_necessary(old, m);
1173       par_scan_state->register_promotion_failure(sz);
1174     }
1175 
1176     old->forward_to(new_obj);
1177     forward_ptr = NULL;
1178   } else {
1179     // Is in to-space; do copying ourselves.
1180     Copy::aligned_disjoint_words((HeapWord*)old, (HeapWord*)new_obj, sz);
1181     assert(CMSHeap::heap()->is_in_reserved(new_obj), "illegal forwarding pointer value.");
1182     forward_ptr = old->forward_to_atomic(new_obj);
1183     // Restore the mark word copied above.
1184     new_obj->set_mark(m);
1185     // Increment age if obj still in new generation
1186     new_obj->incr_age();
1187     par_scan_state->age_table()->add(new_obj, sz);
1188   }
1189   assert(new_obj != NULL, "just checking");
1190 
1191   // This code must come after the CAS test, or it will print incorrect
1192   // information.
1193   log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
1194                                   is_in_reserved(new_obj) ? "copying" : "tenuring",
1195                                   new_obj->klass()->internal_name(), p2i(old), p2i(new_obj), new_obj->size());
1196 
1197   if (forward_ptr == NULL) {
1198     oop obj_to_push = new_obj;
1199     if (par_scan_state->should_be_partially_scanned(obj_to_push, old)) {
1200       // Length field used as index of next element to be scanned.
1201       // Real length can be obtained from real_forwardee()
1202       arrayOop(old)->set_length(0);
1203       obj_to_push = old;
1204       assert(obj_to_push->is_forwarded() && obj_to_push->forwardee() != obj_to_push,


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


1116 // is successfully promoted, a forwarding pointer will be installed in
1117 // the object in the young generation.  This method claims the right
1118 // to install the forwarding pointer before it copies the object,
1119 // thus avoiding the need to undo the copy as in
1120 // copy_to_survivor_space_avoiding_with_undo.
1121 
1122 oop ParNewGeneration::copy_to_survivor_space(ParScanThreadState* par_scan_state,
1123                                              oop old,
1124                                              size_t sz,
1125                                              markOop m) {
1126   // In the sequential version, this assert also says that the object is
1127   // not forwarded.  That might not be the case here.  It is the case that
1128   // the caller observed it to be not forwarded at some time in the past.
1129   assert(is_in_reserved(old), "shouldn't be scavenging this oop");
1130 
1131   // The sequential code read "old->age()" below.  That doesn't work here,
1132   // since the age is in the mark word, and that might be overwritten with
1133   // a forwarding pointer by a parallel thread.  So we must save the mark
1134   // word in a local and then analyze it.
1135   oopDesc dummyOld;
1136   dummyOld.set_mark_raw(m);
1137   assert(!dummyOld.is_forwarded(),
1138          "should not be called with forwarding pointer mark word.");
1139 
1140   oop new_obj = NULL;
1141   oop forward_ptr;
1142 
1143   // Try allocating obj in to-space (unless too old)
1144   if (dummyOld.age() < tenuring_threshold()) {
1145     new_obj = (oop)par_scan_state->alloc_in_to_space(sz);
1146     if (new_obj == NULL) {
1147       set_survivor_overflow(true);
1148     }
1149   }
1150 
1151   if (new_obj == NULL) {
1152     // Either to-space is full or we decided to promote try allocating obj tenured
1153 
1154     // Attempt to install a null forwarding pointer (atomically),
1155     // to claim the right to install the real forwarding pointer.
1156     forward_ptr = old->forward_to_atomic(ClaimedForwardPtr);


1164                                       old, m, sz);
1165     }
1166 
1167     if (new_obj == NULL) {
1168       // promotion failed, forward to self
1169       _promotion_failed = true;
1170       new_obj = old;
1171 
1172       par_scan_state->preserved_marks()->push_if_necessary(old, m);
1173       par_scan_state->register_promotion_failure(sz);
1174     }
1175 
1176     old->forward_to(new_obj);
1177     forward_ptr = NULL;
1178   } else {
1179     // Is in to-space; do copying ourselves.
1180     Copy::aligned_disjoint_words((HeapWord*)old, (HeapWord*)new_obj, sz);
1181     assert(CMSHeap::heap()->is_in_reserved(new_obj), "illegal forwarding pointer value.");
1182     forward_ptr = old->forward_to_atomic(new_obj);
1183     // Restore the mark word copied above.
1184     new_obj->set_mark_raw(m);
1185     // Increment age if obj still in new generation
1186     new_obj->incr_age();
1187     par_scan_state->age_table()->add(new_obj, sz);
1188   }
1189   assert(new_obj != NULL, "just checking");
1190 
1191   // This code must come after the CAS test, or it will print incorrect
1192   // information.
1193   log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
1194                                   is_in_reserved(new_obj) ? "copying" : "tenuring",
1195                                   new_obj->klass()->internal_name(), p2i(old), p2i(new_obj), new_obj->size());
1196 
1197   if (forward_ptr == NULL) {
1198     oop obj_to_push = new_obj;
1199     if (par_scan_state->should_be_partially_scanned(obj_to_push, old)) {
1200       // Length field used as index of next element to be scanned.
1201       // Real length can be obtained from real_forwardee()
1202       arrayOop(old)->set_length(0);
1203       obj_to_push = old;
1204       assert(obj_to_push->is_forwarded() && obj_to_push->forwardee() != obj_to_push,


< prev index next >