hotspot/src/share/vm/utilities/preserveException.hpp
author kvn
Thu, 06 Mar 2008 10:30:17 -0800
changeset 211 e2b60448c234
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6667610: (Escape Analysis) retry compilation without EA if it fails Summary: During split unique types EA could exceed nodes limit and fail the method compilation. Reviewed-by: rasbold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// This file provides more support for exception handling; see also exceptions.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class PreserveExceptionMark {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
  Thread*     _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  Handle      _preserved_exception_oop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  int         _preserved_exception_line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  const char* _preserved_exception_file;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  PreserveExceptionMark(Thread*& thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  ~PreserveExceptionMark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// This is a clone of PreserveExceptionMark which asserts instead
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// of failing when what it wraps generates a pending exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// It also addresses bug 6431341.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class CautiouslyPreserveExceptionMark {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  Thread*     _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  Handle      _preserved_exception_oop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  int         _preserved_exception_line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  const char* _preserved_exception_file;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  CautiouslyPreserveExceptionMark(Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  ~CautiouslyPreserveExceptionMark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// Like PreserveExceptionMark but allows new exceptions to be generated in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// the body of the mark. If a new exception is generated then the original one
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// is discarded.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class WeakPreserveExceptionMark {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  Thread*     _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  Handle      _preserved_exception_oop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  int         _preserved_exception_line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  const char* _preserved_exception_file;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  void        preserve();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  void        restore();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    WeakPreserveExceptionMark(Thread* pThread) :  _thread(pThread), _preserved_exception_oop()  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
      if (pThread->has_pending_exception()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        preserve();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    ~WeakPreserveExceptionMark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      if (_preserved_exception_oop.not_null()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        restore();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// use global exception mark when allowing pending exception to be set and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// saving and restoring them
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
#define PRESERVE_EXCEPTION_MARK                    Thread* THREAD; PreserveExceptionMark __em(THREAD);