src/cpu/zero/vm/stack_zero.cpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 7994
04ff2f6cd0eb
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * Copyright 2010 Red Hat, Inc.
aoqi@0 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 5 *
aoqi@0 6 * This code is free software; you can redistribute it and/or modify it
aoqi@0 7 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 8 * published by the Free Software Foundation.
aoqi@0 9 *
aoqi@0 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 13 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 14 * accompanied this code).
aoqi@0 15 *
aoqi@0 16 * You should have received a copy of the GNU General Public License version
aoqi@0 17 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 19 *
aoqi@0 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 21 * or visit www.oracle.com if you need additional information or have any
aoqi@0 22 * questions.
aoqi@0 23 *
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 #include "precompiled.hpp"
aoqi@0 27 #include "interpreter/interpreterRuntime.hpp"
aoqi@0 28 #include "stack_zero.hpp"
aoqi@0 29 #include "stack_zero.inline.hpp"
aoqi@0 30
aoqi@0 31 int ZeroStack::suggest_size(Thread *thread) const {
aoqi@0 32 assert(needs_setup(), "already set up");
simonis@7599 33 int abi_available = abi_stack_available(thread);
simonis@7599 34 assert(abi_available >= 0, "available abi stack must be >= 0");
simonis@7599 35 return align_size_down(abi_available / 2, wordSize);
aoqi@0 36 }
aoqi@0 37
aoqi@0 38 void ZeroStack::handle_overflow(TRAPS) {
aoqi@0 39 JavaThread *thread = (JavaThread *) THREAD;
aoqi@0 40
aoqi@0 41 // Set up the frame anchor if it isn't already
aoqi@0 42 bool has_last_Java_frame = thread->has_last_Java_frame();
aoqi@0 43 if (!has_last_Java_frame) {
aoqi@0 44 intptr_t *sp = thread->zero_stack()->sp();
aoqi@0 45 ZeroFrame *frame = thread->top_zero_frame();
aoqi@0 46 while (frame) {
aoqi@0 47 if (frame->is_shark_frame())
aoqi@0 48 break;
aoqi@0 49
aoqi@0 50 if (frame->is_interpreter_frame()) {
aoqi@0 51 interpreterState istate =
aoqi@0 52 frame->as_interpreter_frame()->interpreter_state();
aoqi@0 53 if (istate->self_link() == istate)
aoqi@0 54 break;
aoqi@0 55 }
aoqi@0 56
aoqi@0 57 sp = ((intptr_t *) frame) + 1;
aoqi@0 58 frame = frame->next();
aoqi@0 59 }
aoqi@0 60
aoqi@0 61 if (frame == NULL)
aoqi@0 62 fatal("unrecoverable stack overflow");
aoqi@0 63
aoqi@0 64 thread->set_last_Java_frame(frame, sp);
aoqi@0 65 }
aoqi@0 66
aoqi@0 67 // Throw the exception
aoqi@0 68 switch (thread->thread_state()) {
aoqi@0 69 case _thread_in_Java:
aoqi@0 70 InterpreterRuntime::throw_StackOverflowError(thread);
aoqi@0 71 break;
aoqi@0 72
aoqi@0 73 case _thread_in_vm:
aoqi@0 74 Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__,
aoqi@0 75 methodHandle());
aoqi@0 76 break;
aoqi@0 77
aoqi@0 78 default:
aoqi@0 79 ShouldNotReachHere();
aoqi@0 80 }
aoqi@0 81
aoqi@0 82 // Reset the frame anchor if necessary
aoqi@0 83 if (!has_last_Java_frame)
aoqi@0 84 thread->reset_last_Java_frame();
aoqi@0 85 }
aoqi@0 86
aoqi@0 87 #ifndef PRODUCT
aoqi@0 88 void ZeroStack::zap(int c) {
aoqi@0 89 memset(_base, c, available_words() * wordSize);
aoqi@0 90 }
aoqi@0 91 #endif // PRODUCT

mercurial