hotspot/src/cpu/zero/vm/stack_zero.cpp
author twisti
Fri, 30 Apr 2010 04:27:25 -0700
changeset 5418 c4955cb6ed33
parent 5339 ee4d549502b1
child 5424 fc1c380199b0
permissions -rw-r--r--
6939182: Zero JNI handles fix Summary: Zero will exit with an error when invoked with -Xcheck:jni. Reviewed-by: twisti, kamg Contributed-by: Gary Benson <gbenson@redhat.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     1
/*
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     2
 * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     3
 * Copyright 2010 Red Hat, Inc.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     5
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     8
 * published by the Free Software Foundation.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     9
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    14
 * accompanied this code).
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    15
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    19
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    20
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    21
 * CA 95054 USA or visit www.sun.com if you need additional information or
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    22
 * have any questions.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    23
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    24
 */
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    25
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    26
#include "incls/_precompiled.incl"
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    27
#include "incls/_stack_zero.cpp.incl"
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    28
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    29
void ZeroStack::handle_overflow(TRAPS) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    30
  JavaThread *thread = (JavaThread *) THREAD;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    31
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    32
  // Set up the frame anchor if it isn't already
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    33
  bool has_last_Java_frame = thread->has_last_Java_frame();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    34
  if (!has_last_Java_frame) {
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    35
    intptr_t *sp = thread->zero_stack()->sp();
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    36
    ZeroFrame *frame = thread->top_zero_frame();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    37
    while (frame) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    38
      if (frame->is_shark_frame())
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    39
        break;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    40
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    41
      if (frame->is_interpreter_frame()) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    42
        interpreterState istate =
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    43
          frame->as_interpreter_frame()->interpreter_state();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    44
        if (istate->self_link() == istate)
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    45
          break;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    46
      }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    47
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    48
      sp = ((intptr_t *) frame) + 1;
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    49
      frame = frame->next();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    50
    }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    51
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    52
    if (frame == NULL)
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    53
      fatal("unrecoverable stack overflow");
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    54
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    55
    thread->set_last_Java_frame(frame, sp);
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    56
  }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    57
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    58
  // Throw the exception
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    59
  switch (thread->thread_state()) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    60
  case _thread_in_Java:
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    61
    InterpreterRuntime::throw_StackOverflowError(thread);
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    62
    break;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    63
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    64
  case _thread_in_vm:
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    65
    Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__);
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    66
    break;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    67
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    68
  default:
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    69
    ShouldNotReachHere();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    70
  }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    71
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    72
  // Reset the frame anchor if necessary
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    73
  if (!has_last_Java_frame)
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    74
    thread->reset_last_Java_frame();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    75
}
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    76
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    77
#ifndef PRODUCT
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    78
void ZeroStack::zap(int c) {
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    79
  memset(_base, c, available_words() * wordSize);
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    80
}
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    81
#endif // PRODUCT