1
2
3 /*
4 * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
201 realloc_failures = Deoptimization::realloc_objects(thread, &deoptee, &map, objects, THREAD);
202 JRT_END
203 bool skip_internal = (compiled_method != NULL) && !compiled_method->is_compiled_by_jvmci();
204 Deoptimization::reassign_fields(&deoptee, &map, objects, realloc_failures, skip_internal);
205 #ifndef PRODUCT
206 if (TraceDeoptimization) {
207 ttyLocker ttyl;
208 tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, p2i(thread));
209 Deoptimization::print_objects(objects, realloc_failures);
210 }
211 #endif
212 }
213 if (save_oop_result) {
214 // Restore result.
215 deoptee.set_saved_oop_result(&map, return_value());
216 }
217 return realloc_failures;
218 }
219
220 static void eliminate_locks(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
221 #ifndef PRODUCT
222 bool first = true;
223 #endif
224 for (int i = 0; i < chunk->length(); i++) {
225 compiledVFrame* cvf = chunk->at(i);
226 assert (cvf->scope() != NULL,"expect only compiled java frames");
227 GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
228 if (monitors->is_nonempty()) {
229 Deoptimization::relock_objects(monitors, thread, realloc_failures);
230 #ifndef PRODUCT
231 if (PrintDeoptimizationDetails) {
232 ttyLocker ttyl;
233 for (int j = 0; j < monitors->length(); j++) {
234 MonitorInfo* mi = monitors->at(j);
235 if (mi->eliminated()) {
236 if (first) {
237 first = false;
238 tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, p2i(thread));
239 }
240 if (mi->owner_is_scalar_replaced()) {
1525 found = cur->id() == fr.id();
1526 }
1527 assert(found, "frame to be deoptimized not found on target thread's stack");
1528 map = sfs.register_map();
1529 }
1530
1531 vframe* vf = vframe::new_vframe(&fr, map, thread);
1532 compiledVFrame* cvf = compiledVFrame::cast(vf);
1533 // Revoke monitors' biases in all scopes
1534 while (!cvf->is_top()) {
1535 collect_monitors(cvf, objects_to_revoke);
1536 cvf = compiledVFrame::cast(cvf->sender());
1537 }
1538 collect_monitors(cvf, objects_to_revoke);
1539 }
1540
1541 void Deoptimization::revoke_from_deopt_handler(JavaThread* thread, frame fr, RegisterMap* map) {
1542 if (!UseBiasedLocking) {
1543 return;
1544 }
1545 GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
1546 get_monitors_from_stack(objects_to_revoke, thread, fr, map);
1547
1548 int len = objects_to_revoke->length();
1549 for (int i = 0; i < len; i++) {
1550 oop obj = (objects_to_revoke->at(i))();
1551 BiasedLocking::revoke_own_lock(objects_to_revoke->at(i), thread);
1552 assert(!obj->mark().has_bias_pattern(), "biases should be revoked by now");
1553 }
1554 }
1555
1556
1557 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
1558 assert(fr.can_be_deoptimized(), "checking frame type");
1559
1560 gather_statistics(reason, Action_none, Bytecodes::_illegal);
1561
1562 if (LogCompilation && xtty != NULL) {
1563 CompiledMethod* cm = fr.cb()->as_compiled_method_or_null();
1564 assert(cm != NULL, "only compiled methods can deopt");
|
1 /*
2 * Copyright (c) 1997, 2020, 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
199 realloc_failures = Deoptimization::realloc_objects(thread, &deoptee, &map, objects, THREAD);
200 JRT_END
201 bool skip_internal = (compiled_method != NULL) && !compiled_method->is_compiled_by_jvmci();
202 Deoptimization::reassign_fields(&deoptee, &map, objects, realloc_failures, skip_internal);
203 #ifndef PRODUCT
204 if (TraceDeoptimization) {
205 ttyLocker ttyl;
206 tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, p2i(thread));
207 Deoptimization::print_objects(objects, realloc_failures);
208 }
209 #endif
210 }
211 if (save_oop_result) {
212 // Restore result.
213 deoptee.set_saved_oop_result(&map, return_value());
214 }
215 return realloc_failures;
216 }
217
218 static void eliminate_locks(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
219 HandleMark hm;
220 #ifndef PRODUCT
221 bool first = true;
222 #endif
223 for (int i = 0; i < chunk->length(); i++) {
224 compiledVFrame* cvf = chunk->at(i);
225 assert (cvf->scope() != NULL,"expect only compiled java frames");
226 GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
227 if (monitors->is_nonempty()) {
228 Deoptimization::relock_objects(monitors, thread, realloc_failures);
229 #ifndef PRODUCT
230 if (PrintDeoptimizationDetails) {
231 ttyLocker ttyl;
232 for (int j = 0; j < monitors->length(); j++) {
233 MonitorInfo* mi = monitors->at(j);
234 if (mi->eliminated()) {
235 if (first) {
236 first = false;
237 tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, p2i(thread));
238 }
239 if (mi->owner_is_scalar_replaced()) {
1524 found = cur->id() == fr.id();
1525 }
1526 assert(found, "frame to be deoptimized not found on target thread's stack");
1527 map = sfs.register_map();
1528 }
1529
1530 vframe* vf = vframe::new_vframe(&fr, map, thread);
1531 compiledVFrame* cvf = compiledVFrame::cast(vf);
1532 // Revoke monitors' biases in all scopes
1533 while (!cvf->is_top()) {
1534 collect_monitors(cvf, objects_to_revoke);
1535 cvf = compiledVFrame::cast(cvf->sender());
1536 }
1537 collect_monitors(cvf, objects_to_revoke);
1538 }
1539
1540 void Deoptimization::revoke_from_deopt_handler(JavaThread* thread, frame fr, RegisterMap* map) {
1541 if (!UseBiasedLocking) {
1542 return;
1543 }
1544 ResourceMark rm;
1545 HandleMark hm;
1546 GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
1547 get_monitors_from_stack(objects_to_revoke, thread, fr, map);
1548
1549 int len = objects_to_revoke->length();
1550 for (int i = 0; i < len; i++) {
1551 oop obj = (objects_to_revoke->at(i))();
1552 BiasedLocking::revoke_own_lock(objects_to_revoke->at(i), thread);
1553 assert(!obj->mark().has_bias_pattern(), "biases should be revoked by now");
1554 }
1555 }
1556
1557
1558 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
1559 assert(fr.can_be_deoptimized(), "checking frame type");
1560
1561 gather_statistics(reason, Action_none, Bytecodes::_illegal);
1562
1563 if (LogCompilation && xtty != NULL) {
1564 CompiledMethod* cm = fr.cb()->as_compiled_method_or_null();
1565 assert(cm != NULL, "only compiled methods can deopt");
|