< prev index next >

hotspot/src/share/vm/runtime/thread.hpp

Print this page
rev 7151 : 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
Summary: Warning when not checking exceptions from function that require so, also when local refs expand beyond capacity.
Reviewed-by: dsimms
   1 /*
   2  * Copyright (c) 1997, 2014, 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  *


 909 
 910  private:
 911 
 912   StackGuardState  _stack_guard_state;
 913 
 914   // Precompute the limit of the stack as used in stack overflow checks.
 915   // We load it from here to simplify the stack overflow check in assembly.
 916   address          _stack_overflow_limit;
 917 
 918   // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
 919   // used to temp. parsing values into and out of the runtime system during exception handling for compiled
 920   // code)
 921   volatile oop     _exception_oop;               // Exception thrown in compiled code
 922   volatile address _exception_pc;                // PC where exception happened
 923   volatile address _exception_handler_pc;        // PC for handler of exception
 924   volatile int     _is_method_handle_return;     // true (== 1) if the current exception PC is a MethodHandle call site.
 925 
 926   // support for JNI critical regions
 927   jint    _jni_active_critical;                  // count of entries into JNI critical region
 928 



 929   // For deadlock detection.
 930   int _depth_first_number;
 931 
 932   // JVMTI PopFrame support
 933   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 934   int _popframe_condition;
 935 
 936   // If reallocation of scalar replaced objects fails, we throw OOM
 937   // and during exception propagation, pop the top
 938   // _frames_to_pop_failed_realloc frames, the ones that reference
 939   // failed reallocations.
 940   int _frames_to_pop_failed_realloc;
 941 
 942 #ifndef PRODUCT
 943   int _jmp_ring_index;
 944   struct {
 945       // We use intptr_t instead of address so debugger doesn't try and display strings
 946       intptr_t _target;
 947       intptr_t _instruction;
 948       const char*  _file;


1391        thread_from_jni_env->block_if_vm_exited();
1392        return NULL;
1393     } else {
1394        return thread_from_jni_env;
1395     }
1396   }
1397 
1398   // JNI critical regions. These can nest.
1399   bool in_critical()    { return _jni_active_critical > 0; }
1400   bool in_last_critical()  { return _jni_active_critical == 1; }
1401   void enter_critical() { assert(Thread::current() == this ||
1402                                  Thread::current()->is_VM_thread() && SafepointSynchronize::is_synchronizing(),
1403                                  "this must be current thread or synchronizing");
1404                           _jni_active_critical++; }
1405   void exit_critical()  { assert(Thread::current() == this,
1406                                  "this must be current thread");
1407                           _jni_active_critical--;
1408                           assert(_jni_active_critical >= 0,
1409                                  "JNI critical nesting problem?"); }
1410 






1411   // For deadlock detection
1412   int depth_first_number() { return _depth_first_number; }
1413   void set_depth_first_number(int dfn) { _depth_first_number = dfn; }
1414 
1415  private:
1416   void set_monitor_chunks(MonitorChunk* monitor_chunks) { _monitor_chunks = monitor_chunks; }
1417 
1418  public:
1419   MonitorChunk* monitor_chunks() const           { return _monitor_chunks; }
1420   void add_monitor_chunk(MonitorChunk* chunk);
1421   void remove_monitor_chunk(MonitorChunk* chunk);
1422   bool in_deopt_handler() const                  { return _in_deopt_handler > 0; }
1423   void inc_in_deopt_handler()                    { _in_deopt_handler++; }
1424   void dec_in_deopt_handler()                    {
1425     assert(_in_deopt_handler > 0, "mismatched deopt nesting");
1426     if (_in_deopt_handler > 0) { // robustness
1427       _in_deopt_handler--;
1428     }
1429   }
1430 


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


 909 
 910  private:
 911 
 912   StackGuardState  _stack_guard_state;
 913 
 914   // Precompute the limit of the stack as used in stack overflow checks.
 915   // We load it from here to simplify the stack overflow check in assembly.
 916   address          _stack_overflow_limit;
 917 
 918   // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
 919   // used to temp. parsing values into and out of the runtime system during exception handling for compiled
 920   // code)
 921   volatile oop     _exception_oop;               // Exception thrown in compiled code
 922   volatile address _exception_pc;                // PC where exception happened
 923   volatile address _exception_handler_pc;        // PC for handler of exception
 924   volatile int     _is_method_handle_return;     // true (== 1) if the current exception PC is a MethodHandle call site.
 925 
 926   // support for JNI critical regions
 927   jint    _jni_active_critical;                  // count of entries into JNI critical region
 928 
 929   // Checked JNI: function name requires exception check
 930   char* _pending_jni_exception_check_fn;
 931 
 932   // For deadlock detection.
 933   int _depth_first_number;
 934 
 935   // JVMTI PopFrame support
 936   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 937   int _popframe_condition;
 938 
 939   // If reallocation of scalar replaced objects fails, we throw OOM
 940   // and during exception propagation, pop the top
 941   // _frames_to_pop_failed_realloc frames, the ones that reference
 942   // failed reallocations.
 943   int _frames_to_pop_failed_realloc;
 944 
 945 #ifndef PRODUCT
 946   int _jmp_ring_index;
 947   struct {
 948       // We use intptr_t instead of address so debugger doesn't try and display strings
 949       intptr_t _target;
 950       intptr_t _instruction;
 951       const char*  _file;


1394        thread_from_jni_env->block_if_vm_exited();
1395        return NULL;
1396     } else {
1397        return thread_from_jni_env;
1398     }
1399   }
1400 
1401   // JNI critical regions. These can nest.
1402   bool in_critical()    { return _jni_active_critical > 0; }
1403   bool in_last_critical()  { return _jni_active_critical == 1; }
1404   void enter_critical() { assert(Thread::current() == this ||
1405                                  Thread::current()->is_VM_thread() && SafepointSynchronize::is_synchronizing(),
1406                                  "this must be current thread or synchronizing");
1407                           _jni_active_critical++; }
1408   void exit_critical()  { assert(Thread::current() == this,
1409                                  "this must be current thread");
1410                           _jni_active_critical--;
1411                           assert(_jni_active_critical >= 0,
1412                                  "JNI critical nesting problem?"); }
1413 
1414   // Checked JNI, is the programmer required to check for exceptions, specify which function name
1415   bool is_pending_jni_exception_check() const { return _pending_jni_exception_check_fn != NULL; }
1416   void clear_pending_jni_exception_check() { _pending_jni_exception_check_fn = NULL; }
1417   const char* get_pending_jni_exception_check() const { return _pending_jni_exception_check_fn; }
1418   void set_pending_jni_exception_check(const char* fn_name) { _pending_jni_exception_check_fn = (char*) fn_name; }
1419 
1420   // For deadlock detection
1421   int depth_first_number() { return _depth_first_number; }
1422   void set_depth_first_number(int dfn) { _depth_first_number = dfn; }
1423 
1424  private:
1425   void set_monitor_chunks(MonitorChunk* monitor_chunks) { _monitor_chunks = monitor_chunks; }
1426 
1427  public:
1428   MonitorChunk* monitor_chunks() const           { return _monitor_chunks; }
1429   void add_monitor_chunk(MonitorChunk* chunk);
1430   void remove_monitor_chunk(MonitorChunk* chunk);
1431   bool in_deopt_handler() const                  { return _in_deopt_handler > 0; }
1432   void inc_in_deopt_handler()                    { _in_deopt_handler++; }
1433   void dec_in_deopt_handler()                    {
1434     assert(_in_deopt_handler > 0, "mismatched deopt nesting");
1435     if (_in_deopt_handler > 0) { // robustness
1436       _in_deopt_handler--;
1437     }
1438   }
1439 


< prev index next >