< prev index next >

src/share/vm/opto/runtime.cpp

Print this page


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


1217     if (nm->is_deopt_pc(pc)) {
1218       deopting = true;
1219       RegisterMap map(thread, false);
1220       frame deoptee = thread->last_frame().sender(&map);
1221       assert(deoptee.is_deoptimized_frame(), "must be deopted");
1222       // Adjust the pc back to the original throwing pc
1223       pc = deoptee.pc();
1224     }
1225 
1226     // If we are forcing an unwind because of stack overflow then deopt is
1227     // irrelevant since we are throwing the frame away anyway.
1228 
1229     if (deopting && !force_unwind) {
1230       handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1231     } else {
1232 
1233       handler_address =
1234         force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
1235 
1236       if (handler_address == NULL) {
1237         Handle original_exception(thread, exception());
1238         handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true);
1239         assert (handler_address != NULL, "must have compiled handler");
1240         // Update the exception cache only when the unwind was not forced
1241         // and there didn't happen another exception during the computation of the
1242         // compiled exception handler.
1243         if (!force_unwind && original_exception() == exception()) {

1244           nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
1245         }
1246       } else {
1247         assert(handler_address == SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true), "Must be the same");





1248       }
1249     }
1250 
1251     thread->set_exception_pc(pc);
1252     thread->set_exception_handler_pc(handler_address);
1253 
1254     // Check if the exception PC is a MethodHandle call site.
1255     thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
1256   }
1257 
1258   // Restore correct return pc.  Was saved above.
1259   thread->set_exception_oop(exception());
1260   return handler_address;
1261 
1262 JRT_END
1263 
1264 // We are entering here from exception_blob
1265 // If there is a compiled exception handler in this method, we will continue there;
1266 // otherwise we will unwind the stack and continue at the caller of top frame method
1267 // Note we enter without the usual JRT wrapper. We will call a helper routine that


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


1217     if (nm->is_deopt_pc(pc)) {
1218       deopting = true;
1219       RegisterMap map(thread, false);
1220       frame deoptee = thread->last_frame().sender(&map);
1221       assert(deoptee.is_deoptimized_frame(), "must be deopted");
1222       // Adjust the pc back to the original throwing pc
1223       pc = deoptee.pc();
1224     }
1225 
1226     // If we are forcing an unwind because of stack overflow then deopt is
1227     // irrelevant since we are throwing the frame away anyway.
1228 
1229     if (deopting && !force_unwind) {
1230       handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1231     } else {
1232 
1233       handler_address =
1234         force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
1235 
1236       if (handler_address == NULL) {
1237         bool recursive_exception = false;
1238         handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1239         assert (handler_address != NULL, "must have compiled handler");
1240         // Update the exception cache only when the unwind was not forced
1241         // and there didn't happen another exception during the computation of the
1242         // compiled exception handler. Checking for exception oop equality is not
1243         // sufficient because some exceptions are pre-allocated and reused.
1244         if (!force_unwind && !recursive_exception) {
1245           nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
1246         }
1247       } else {
1248 #ifdef ASSERT
1249         bool recursive_exception = false;
1250         address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1251         assert(recursive_exception || (handler_address == computed_address), err_msg("Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT,
1252                  p2i(handler_address), p2i(computed_address)));
1253 #endif
1254       }
1255     }
1256 
1257     thread->set_exception_pc(pc);
1258     thread->set_exception_handler_pc(handler_address);
1259 
1260     // Check if the exception PC is a MethodHandle call site.
1261     thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
1262   }
1263 
1264   // Restore correct return pc.  Was saved above.
1265   thread->set_exception_oop(exception());
1266   return handler_address;
1267 
1268 JRT_END
1269 
1270 // We are entering here from exception_blob
1271 // If there is a compiled exception handler in this method, we will continue there;
1272 // otherwise we will unwind the stack and continue at the caller of top frame method
1273 // Note we enter without the usual JRT wrapper. We will call a helper routine that


< prev index next >