hotspot/src/share/vm/runtime/interfaceSupport.cpp
author kamg
Thu, 22 May 2008 13:03:52 -0400
changeset 602 92e03692ddd6
parent 1 489c9b5090e2
child 2995 d8283445992a
permissions -rw-r--r--
6705523: Fix for 6695506 will violate spec when used in JDK6 Summary: Make max classfile version number dependent on JDK version Reviewed-by: acorn, never
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 1997-2007 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
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_interfaceSupport.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// Implementation of InterfaceSupport
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
long InterfaceSupport::_number_of_calls       = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
long InterfaceSupport::_scavenge_alot_counter = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
long InterfaceSupport::_fullgc_alot_counter   = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
long InterfaceSupport::_fullgc_alot_invocation = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
Histogram* RuntimeHistogram;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
RuntimeHistogramElement::RuntimeHistogramElement(const char* elementName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  static volatile jint RuntimeHistogram_lock = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  _name = elementName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  uintx count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  while (Atomic::cmpxchg(1, &RuntimeHistogram_lock, 0) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    while (OrderAccess::load_acquire(&RuntimeHistogram_lock) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
      count +=1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
      if ( (WarnOnStalledSpinLock > 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
        && (count % WarnOnStalledSpinLock == 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
        warning("RuntimeHistogram_lock seems to be stalled");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
      }
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
  if (RuntimeHistogram == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    RuntimeHistogram = new Histogram("VM Runtime Call Counts",200);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  RuntimeHistogram->add_element(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  Atomic::dec(&RuntimeHistogram_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
void InterfaceSupport::trace(const char* result_type, const char* header) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  tty->print_cr("%6d  %s", _number_of_calls, header);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
void InterfaceSupport::gc_alot() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  Thread *thread = Thread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  if (thread->is_VM_thread()) return; // Avoid concurrent calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // Check for new, not quite initialized thread. A thread in new mode cannot initiate a GC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  JavaThread *current_thread = (JavaThread *)thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  if (current_thread->active_handles() == NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  if (is_init_completed()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    if (++_fullgc_alot_invocation < FullGCALotStart) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    // Use this line if you want to block at a specific point,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    // e.g. one number_of_calls/scavenge/gc before you got into problems
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    if (FullGCALot) _fullgc_alot_counter--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    // Check if we should force a full gc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    if (_fullgc_alot_counter == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      // Release dummy so objects are forced to move
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      if (!Universe::release_fullgc_alot_dummy()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
        warning("FullGCALot: Unable to release more dummies at bottom of heap");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      HandleMark hm(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      Universe::heap()->collect(GCCause::_full_gc_alot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      unsigned int invocations = Universe::heap()->total_full_collections();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      // Compute new interval
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      if (FullGCALotInterval > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
        _fullgc_alot_counter = 1+(long)((double)FullGCALotInterval*os::random()/(max_jint+1.0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
        if (PrintGCDetails && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
          tty->print_cr("Full gc no: %u\tInterval: %d", invocations,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                        _fullgc_alot_counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
        _fullgc_alot_counter = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      // Print progress message
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      if (invocations % 100 == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        if (PrintGCDetails && Verbose) tty->print_cr("Full gc no: %u", invocations);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      if (ScavengeALot) _scavenge_alot_counter--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      // Check if we should force a scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      if (_scavenge_alot_counter == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
        HandleMark hm(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
        Universe::heap()->collect(GCCause::_scavenge_alot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
        unsigned int invocations = Universe::heap()->total_collections() - Universe::heap()->total_full_collections();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
        // Compute new interval
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
        if (ScavengeALotInterval > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
          _scavenge_alot_counter = 1+(long)((double)ScavengeALotInterval*os::random()/(max_jint+1.0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
          if (PrintGCDetails && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
            tty->print_cr("Scavenge no: %u\tInterval: %d", invocations,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
                          _scavenge_alot_counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
          _scavenge_alot_counter = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
        // Print progress message
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
        if (invocations % 1000 == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
          if (PrintGCDetails && Verbose) tty->print_cr("Scavenge no: %u", invocations);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
vframe* vframe_array[50];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
int walk_stack_counter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
void InterfaceSupport::walk_stack_from(vframe* start_vf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // walk
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  for (vframe* f = start_vf; f; f = f->sender() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    if (i < 50) vframe_array[i++] = f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
void InterfaceSupport::walk_stack() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  JavaThread* thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  walk_stack_counter++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  if (!thread->has_last_Java_frame()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  ResourceMark rm(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  RegisterMap reg_map(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  walk_stack_from(thread->last_java_vframe(&reg_map));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
# ifdef ENABLE_ZAP_DEAD_LOCALS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
static int zap_traversals = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
void InterfaceSupport::zap_dead_locals_old() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  JavaThread* thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  if (zap_traversals == -1) // edit constant for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    warning("I am here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  int zap_frame_count = 0; // count frames to help debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    sfs.current()->zap_dead_locals(thread, sfs.register_map());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    ++zap_frame_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  ++zap_traversals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
# endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
int deoptimizeAllCounter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
int zombieAllCounter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
void InterfaceSupport::zombieAll() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  if (is_init_completed() && zombieAllCounter > ZombieALotInterval) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    zombieAllCounter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    VM_ZombieAll op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    VMThread::execute(&op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    zombieAllCounter++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
void InterfaceSupport::deoptimizeAll() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  if (is_init_completed() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    if (DeoptimizeALot && deoptimizeAllCounter > DeoptimizeALotInterval) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      deoptimizeAllCounter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      VM_DeoptimizeAll op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      VMThread::execute(&op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    } else if (DeoptimizeRandom && (deoptimizeAllCounter & 0x1f) == (os::random() & 0x1f)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
      VM_DeoptimizeAll op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
      VMThread::execute(&op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  deoptimizeAllCounter++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
void InterfaceSupport::stress_derived_pointers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  JavaThread *thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  if (!is_init_completed()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  ResourceMark rm(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  bool found = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  for (StackFrameStream sfs(thread); !sfs.is_done() && !found; sfs.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    CodeBlob* cb = sfs.current()->cb();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    if (cb != NULL && cb->oop_maps() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      // Find oopmap for current method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      OopMap* map = cb->oop_map_for_return_address(sfs.current()->pc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      assert(map != NULL, "no oopmap found for pc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      found = map->has_derived_pointer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  if (found) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    // $$$ Not sure what to do here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    Scavenge::invoke(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
void InterfaceSupport::verify_stack() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  JavaThread* thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  ResourceMark rm(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // disabled because it throws warnings that oop maps should only be accessed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  // in VM thread or during debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  if (!thread->has_pending_exception()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    // verification does not work if there are pending exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    StackFrameStream sfs(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    CodeBlob* cb = sfs.current()->cb();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      // In case of exceptions we might not have a runtime_stub on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
      // top of stack, hence, all callee-saved registers are not going
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      // to be setup correctly, hence, we cannot do stack verify
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    if (cb != NULL && !(cb->is_runtime_stub() || cb->is_uncommon_trap_stub())) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    for (; !sfs.is_done(); sfs.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
      sfs.current()->verify(sfs.register_map());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
void InterfaceSupport::verify_last_frame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  JavaThread* thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  ResourceMark rm(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  RegisterMap reg_map(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  frame fr = thread->last_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  fr.verify(&reg_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
void InterfaceSupport_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  if (ScavengeALot || FullGCALot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    srand(ScavengeALotInterval * FullGCALotInterval);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
}