1 /*
2 * Copyright (c) 2002, 2012, 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 *
135 _old_lab.flush();
136
137 HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize);
138 if(lab_base != NULL) {
139 #ifdef ASSERT
140 // Delay the initialization of the promotion lab (plab).
141 // This exposes uninitialized plabs to card table processing.
142 if (GCWorkerDelayMillis > 0) {
143 os::sleep(Thread::current(), GCWorkerDelayMillis, false);
144 }
145 #endif
146 _old_lab.initialize(MemRegion(lab_base, OldPLABSize));
147 // Try the old lab allocation again.
148 new_obj = (oop) _old_lab.allocate(new_obj_size);
149 }
150 }
151 }
152
153 // This is the promotion failed test, and code handling.
154 // The code belongs here for two reasons. It is slightly
155 // different thatn the code below, and cannot share the
156 // CAS testing code. Keeping the code here also minimizes
157 // the impact on the common case fast path code.
158
159 if (new_obj == NULL) {
160 _old_gen_is_full = true;
161 return oop_promotion_failed(o, test_mark);
162 }
163 }
164 }
165
166 assert(new_obj != NULL, "allocation should have succeeded");
167
168 // Copy obj
169 Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size);
170
171 // Now we have to CAS in the header.
172 if (o->cas_forward_to(new_obj, test_mark)) {
173 // We won any races, we "own" this object.
174 assert(new_obj == o->forwardee(), "Sanity");
175
|
1 /*
2 * Copyright (c) 2002, 2013, 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 *
135 _old_lab.flush();
136
137 HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize);
138 if(lab_base != NULL) {
139 #ifdef ASSERT
140 // Delay the initialization of the promotion lab (plab).
141 // This exposes uninitialized plabs to card table processing.
142 if (GCWorkerDelayMillis > 0) {
143 os::sleep(Thread::current(), GCWorkerDelayMillis, false);
144 }
145 #endif
146 _old_lab.initialize(MemRegion(lab_base, OldPLABSize));
147 // Try the old lab allocation again.
148 new_obj = (oop) _old_lab.allocate(new_obj_size);
149 }
150 }
151 }
152
153 // This is the promotion failed test, and code handling.
154 // The code belongs here for two reasons. It is slightly
155 // different than the code below, and cannot share the
156 // CAS testing code. Keeping the code here also minimizes
157 // the impact on the common case fast path code.
158
159 if (new_obj == NULL) {
160 _old_gen_is_full = true;
161 return oop_promotion_failed(o, test_mark);
162 }
163 }
164 }
165
166 assert(new_obj != NULL, "allocation should have succeeded");
167
168 // Copy obj
169 Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size);
170
171 // Now we have to CAS in the header.
172 if (o->cas_forward_to(new_obj, test_mark)) {
173 // We won any races, we "own" this object.
174 assert(new_obj == o->forwardee(), "Sanity");
175
|