5339
|
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 |
*/
|
|
25 |
|
|
26 |
#include "incls/_precompiled.incl"
|
|
27 |
#include "incls/_stack_zero.cpp.incl"
|
|
28 |
|
|
29 |
void ZeroStack::handle_overflow(TRAPS) {
|
|
30 |
JavaThread *thread = (JavaThread *) THREAD;
|
|
31 |
|
|
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) {
|
5418
|
35 |
intptr_t *sp = thread->zero_stack()->sp();
|
5339
|
36 |
ZeroFrame *frame = thread->top_zero_frame();
|
|
37 |
while (frame) {
|
|
38 |
if (frame->is_shark_frame())
|
|
39 |
break;
|
|
40 |
|
|
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 |
}
|
|
47 |
|
5418
|
48 |
sp = ((intptr_t *) frame) + 1;
|
5339
|
49 |
frame = frame->next();
|
|
50 |
}
|
|
51 |
|
|
52 |
if (frame == NULL)
|
|
53 |
fatal("unrecoverable stack overflow");
|
|
54 |
|
5418
|
55 |
thread->set_last_Java_frame(frame, sp);
|
5339
|
56 |
}
|
|
57 |
|
|
58 |
// Throw the exception
|
|
59 |
switch (thread->thread_state()) {
|
|
60 |
case _thread_in_Java:
|
|
61 |
InterpreterRuntime::throw_StackOverflowError(thread);
|
|
62 |
break;
|
|
63 |
|
|
64 |
case _thread_in_vm:
|
|
65 |
Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__);
|
|
66 |
break;
|
|
67 |
|
|
68 |
default:
|
|
69 |
ShouldNotReachHere();
|
|
70 |
}
|
|
71 |
|
|
72 |
// Reset the frame anchor if necessary
|
|
73 |
if (!has_last_Java_frame)
|
|
74 |
thread->reset_last_Java_frame();
|
|
75 |
}
|
5418
|
76 |
|
|
77 |
#ifndef PRODUCT
|
|
78 |
void ZeroStack::zap(int c) {
|
|
79 |
memset(_base, c, available_words() * wordSize);
|
|
80 |
}
|
|
81 |
#endif // PRODUCT
|