Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/cpu/zero/stack_zero.cpp
40931 views
1
/*
2
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#include "precompiled.hpp"
27
#include "interpreter/interpreterRuntime.hpp"
28
#include "interpreter/zero/bytecodeInterpreter.hpp"
29
#include "runtime/thread.inline.hpp"
30
#include "stack_zero.hpp"
31
#include "stack_zero.inline.hpp"
32
#include "runtime/frame.inline.hpp"
33
#include "utilities/align.hpp"
34
35
// Inlined causes circular inclusion with thread.hpp
36
ZeroStack::ZeroStack()
37
: _base(NULL), _top(NULL), _sp(NULL) {
38
_shadow_pages_size = StackOverflow::stack_shadow_zone_size();
39
}
40
41
int ZeroStack::suggest_size(Thread *thread) const {
42
assert(needs_setup(), "already set up");
43
int abi_available = abi_stack_available(thread);
44
assert(abi_available >= 0, "available abi stack must be >= 0");
45
return align_down(abi_available / 2, wordSize);
46
}
47
48
void ZeroStack::handle_overflow(TRAPS) {
49
JavaThread *thread = THREAD;
50
51
// Set up the frame anchor if it isn't already
52
bool has_last_Java_frame = thread->has_last_Java_frame();
53
if (!has_last_Java_frame) {
54
intptr_t *sp = thread->zero_stack()->sp();
55
ZeroFrame *frame = thread->top_zero_frame();
56
while (frame) {
57
if (frame->is_interpreter_frame()) {
58
interpreterState istate =
59
frame->as_interpreter_frame()->interpreter_state();
60
if (istate->self_link() == istate)
61
break;
62
}
63
64
sp = ((intptr_t *) frame) + 1;
65
frame = frame->next();
66
}
67
68
if (frame == NULL)
69
fatal("unrecoverable stack overflow");
70
71
thread->set_last_Java_frame(frame, sp);
72
}
73
74
// Throw the exception
75
switch (thread->thread_state()) {
76
case _thread_in_Java:
77
InterpreterRuntime::throw_StackOverflowError(thread);
78
break;
79
80
case _thread_in_vm:
81
Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__,
82
methodHandle());
83
break;
84
85
default:
86
ShouldNotReachHere();
87
}
88
89
// Reset the frame anchor if necessary
90
if (!has_last_Java_frame)
91
thread->reset_last_Java_frame();
92
}
93
94
#ifndef PRODUCT
95
void ZeroStack::zap(int c) {
96
memset(_base, c, available_words() * wordSize);
97
}
98
#endif // PRODUCT
99
100