src/cpu/zero/vm/stack_zero.cpp

Fri, 30 Apr 2010 04:27:25 -0700

author
twisti
date
Fri, 30 Apr 2010 04:27:25 -0700
changeset 1860
0c5b3cf3c1f5
parent 1818
aa9c266de52a
child 1866
348346af6676
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>

     1 /*
     2  * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
     3  * Copyright 2010 Red Hat, Inc.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    21  * CA 95054 USA or visit www.sun.com if you need additional information or
    22  * have any questions.
    23  *
    24  */
    26 #include "incls/_precompiled.incl"
    27 #include "incls/_stack_zero.cpp.incl"
    29 void ZeroStack::handle_overflow(TRAPS) {
    30   JavaThread *thread = (JavaThread *) THREAD;
    32   // Set up the frame anchor if it isn't already
    33   bool has_last_Java_frame = thread->has_last_Java_frame();
    34   if (!has_last_Java_frame) {
    35     intptr_t *sp = thread->zero_stack()->sp();
    36     ZeroFrame *frame = thread->top_zero_frame();
    37     while (frame) {
    38       if (frame->is_shark_frame())
    39         break;
    41       if (frame->is_interpreter_frame()) {
    42         interpreterState istate =
    43           frame->as_interpreter_frame()->interpreter_state();
    44         if (istate->self_link() == istate)
    45           break;
    46       }
    48       sp = ((intptr_t *) frame) + 1;
    49       frame = frame->next();
    50     }
    52     if (frame == NULL)
    53       fatal("unrecoverable stack overflow");
    55     thread->set_last_Java_frame(frame, sp);
    56   }
    58   // Throw the exception
    59   switch (thread->thread_state()) {
    60   case _thread_in_Java:
    61     InterpreterRuntime::throw_StackOverflowError(thread);
    62     break;
    64   case _thread_in_vm:
    65     Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__);
    66     break;
    68   default:
    69     ShouldNotReachHere();
    70   }
    72   // Reset the frame anchor if necessary
    73   if (!has_last_Java_frame)
    74     thread->reset_last_Java_frame();
    75 }
    77 #ifndef PRODUCT
    78 void ZeroStack::zap(int c) {
    79   memset(_base, c, available_words() * wordSize);
    80 }
    81 #endif // PRODUCT

mercurial