src/hotspot/share/runtime/deoptimization.cpp
changeset 53546 63eb7e38ce84
parent 51997 9ce37fa2e179
child 53582 881c5fbeb849
equal deleted inserted replaced
53545:2c38991dd9b0 53546:63eb7e38ce84
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
  1279   if (SafepointSynchronize::is_at_safepoint()) {
  1279   if (SafepointSynchronize::is_at_safepoint()) {
  1280     BiasedLocking::revoke_at_safepoint(objects_to_revoke);
  1280     BiasedLocking::revoke_at_safepoint(objects_to_revoke);
  1281   } else {
  1281   } else {
  1282     BiasedLocking::revoke(objects_to_revoke);
  1282     BiasedLocking::revoke(objects_to_revoke);
  1283   }
  1283   }
  1284 }
       
  1285 
       
  1286 
       
  1287 void Deoptimization::revoke_biases_of_monitors(CodeBlob* cb) {
       
  1288   if (!UseBiasedLocking) {
       
  1289     return;
       
  1290   }
       
  1291 
       
  1292   assert(SafepointSynchronize::is_at_safepoint(), "must only be called from safepoint");
       
  1293   GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
       
  1294   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
       
  1295     if (jt->has_last_Java_frame()) {
       
  1296       StackFrameStream sfs(jt, true);
       
  1297       while (!sfs.is_done()) {
       
  1298         frame* cur = sfs.current();
       
  1299         if (cb->contains(cur->pc())) {
       
  1300           vframe* vf = vframe::new_vframe(cur, sfs.register_map(), jt);
       
  1301           compiledVFrame* cvf = compiledVFrame::cast(vf);
       
  1302           // Revoke monitors' biases in all scopes
       
  1303           while (!cvf->is_top()) {
       
  1304             collect_monitors(cvf, objects_to_revoke);
       
  1305             cvf = compiledVFrame::cast(cvf->sender());
       
  1306           }
       
  1307           collect_monitors(cvf, objects_to_revoke);
       
  1308         }
       
  1309         sfs.next();
       
  1310       }
       
  1311     }
       
  1312   }
       
  1313   BiasedLocking::revoke_at_safepoint(objects_to_revoke);
       
  1314 }
  1284 }
  1315 
  1285 
  1316 
  1286 
  1317 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
  1287 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
  1318   assert(fr.can_be_deoptimized(), "checking frame type");
  1288   assert(fr.can_be_deoptimized(), "checking frame type");
  2298 
  2268 
  2299 jint Deoptimization::total_deoptimization_count() {
  2269 jint Deoptimization::total_deoptimization_count() {
  2300   return _deoptimization_hist[Reason_none][0][0];
  2270   return _deoptimization_hist[Reason_none][0][0];
  2301 }
  2271 }
  2302 
  2272 
  2303 jint Deoptimization::deoptimization_count(DeoptReason reason) {
       
  2304   assert(reason >= 0 && reason < Reason_LIMIT, "oob");
       
  2305   return _deoptimization_hist[reason][0][0];
       
  2306 }
       
  2307 
       
  2308 void Deoptimization::print_statistics() {
  2273 void Deoptimization::print_statistics() {
  2309   juint total = total_deoptimization_count();
  2274   juint total = total_deoptimization_count();
  2310   juint account = total;
  2275   juint account = total;
  2311   if (total != 0) {
  2276   if (total != 0) {
  2312     ttyLocker ttyl;
  2277     ttyLocker ttyl;