src/share/vm/utilities/exceptions.hpp

Print this page


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







  25 // This file provides the basic support for exception handling in the VM.
  26 // Note: We do not use C++ exceptions to avoid compiler dependencies and
  27 // unpredictable performance.
  28 //
  29 // Scheme: Exceptions are stored with the thread. There is never more
  30 // than one pending exception per thread. All functions that can throw
  31 // an exception carry a THREAD argument (usually the last argument and
  32 // declared with the TRAPS macro). Throwing an exception means setting
  33 // a pending exception in the thread. Upon return from a function that
  34 // can throw an exception, we must check if an exception is pending.
  35 // The CHECK macros do this in a convenient way. Carrying around the
  36 // thread provides also convenient access to it (e.g. for Handle
  37 // creation, w/o the need for recomputation).
  38 
  39 
  40 
  41 // Forward declarations to be independent of the include structure.
  42 // This allows us to have exceptions.hpp included in top.hpp.
  43 
  44 class Thread;


 259 class ExceptionMark {
 260  private:
 261   Thread* _thread;
 262 
 263  public:
 264   ExceptionMark(Thread*& thread);
 265   ~ExceptionMark();
 266 };
 267 
 268 
 269 
 270 // Use an EXCEPTION_MARK for 'local' exceptions. EXCEPTION_MARK makes sure that no
 271 // pending exception exists upon entering its scope and tests that no pending exception
 272 // exists when leaving the scope.
 273 
 274 // See also preserveException.hpp for PRESERVE_EXCEPTION_MARK macro,
 275 // which preserves pre-existing exceptions and does not allow new
 276 // exceptions.
 277 
 278 #define EXCEPTION_MARK                           Thread* THREAD; ExceptionMark __em(THREAD);


   1 /*
   2  * Copyright (c) 1998, 2010, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_UTILITIES_EXCEPTIONS_HPP
  26 #define SHARE_VM_UTILITIES_EXCEPTIONS_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "oops/oopsHierarchy.hpp"
  30 #include "utilities/sizes.hpp"
  31 
  32 // This file provides the basic support for exception handling in the VM.
  33 // Note: We do not use C++ exceptions to avoid compiler dependencies and
  34 // unpredictable performance.
  35 //
  36 // Scheme: Exceptions are stored with the thread. There is never more
  37 // than one pending exception per thread. All functions that can throw
  38 // an exception carry a THREAD argument (usually the last argument and
  39 // declared with the TRAPS macro). Throwing an exception means setting
  40 // a pending exception in the thread. Upon return from a function that
  41 // can throw an exception, we must check if an exception is pending.
  42 // The CHECK macros do this in a convenient way. Carrying around the
  43 // thread provides also convenient access to it (e.g. for Handle
  44 // creation, w/o the need for recomputation).
  45 
  46 
  47 
  48 // Forward declarations to be independent of the include structure.
  49 // This allows us to have exceptions.hpp included in top.hpp.
  50 
  51 class Thread;


 266 class ExceptionMark {
 267  private:
 268   Thread* _thread;
 269 
 270  public:
 271   ExceptionMark(Thread*& thread);
 272   ~ExceptionMark();
 273 };
 274 
 275 
 276 
 277 // Use an EXCEPTION_MARK for 'local' exceptions. EXCEPTION_MARK makes sure that no
 278 // pending exception exists upon entering its scope and tests that no pending exception
 279 // exists when leaving the scope.
 280 
 281 // See also preserveException.hpp for PRESERVE_EXCEPTION_MARK macro,
 282 // which preserves pre-existing exceptions and does not allow new
 283 // exceptions.
 284 
 285 #define EXCEPTION_MARK                           Thread* THREAD; ExceptionMark __em(THREAD);
 286 
 287 #endif // SHARE_VM_UTILITIES_EXCEPTIONS_HPP