author | stefank |
Thu, 09 May 2019 14:28:30 +0200 | |
changeset 54786 | ebf733a324d4 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
4013 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47687
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
5335 | 3 |
* Copyright 2008, 2009, 2010 Red Hat, Inc. |
4013 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5424
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5424
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5424
diff
changeset
|
22 |
* questions. |
4013 | 23 |
* |
24 |
*/ |
|
25 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47687
diff
changeset
|
26 |
#ifndef CPU_ZERO_STACK_ZERO_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47687
diff
changeset
|
27 |
#define CPU_ZERO_STACK_ZERO_HPP |
7397 | 28 |
|
46625 | 29 |
#include "utilities/align.hpp" |
7397 | 30 |
#include "utilities/sizes.hpp" |
31 |
||
4013 | 32 |
class ZeroStack { |
33 |
private: |
|
34 |
intptr_t *_base; // the last available word |
|
35 |
intptr_t *_top; // the word past the end of the stack |
|
36 |
intptr_t *_sp; // the top word on the stack |
|
37 |
||
5335 | 38 |
private: |
39 |
int _shadow_pages_size; // how much ABI stack must we keep free? |
|
40 |
||
4013 | 41 |
public: |
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35201
diff
changeset
|
42 |
ZeroStack(); |
4013 | 43 |
|
44 |
bool needs_setup() const { |
|
45 |
return _base == NULL; |
|
46 |
} |
|
47 |
||
5424 | 48 |
int suggest_size(Thread *thread) const; |
49 |
||
4013 | 50 |
void setup(void *mem, size_t size) { |
51 |
assert(needs_setup(), "already set up"); |
|
52 |
assert(!(size & WordAlignmentMask), "unaligned"); |
|
53 |
||
54 |
_base = (intptr_t *) mem; |
|
55 |
_top = _base + (size >> LogBytesPerWord); |
|
56 |
_sp = _top; |
|
57 |
} |
|
58 |
void teardown() { |
|
59 |
assert(!needs_setup(), "not set up"); |
|
60 |
assert(_sp == _top, "stuff on stack at teardown"); |
|
61 |
||
62 |
_base = NULL; |
|
63 |
_top = NULL; |
|
64 |
_sp = NULL; |
|
65 |
} |
|
66 |
||
67 |
intptr_t *sp() const { |
|
68 |
return _sp; |
|
69 |
} |
|
70 |
void set_sp(intptr_t *new_sp) { |
|
71 |
assert(_top >= new_sp && new_sp >= _base, "bad stack pointer"); |
|
72 |
_sp = new_sp; |
|
73 |
} |
|
74 |
||
5424 | 75 |
int total_words() const { |
76 |
return _top - _base; |
|
77 |
} |
|
4013 | 78 |
int available_words() const { |
79 |
return _sp - _base; |
|
80 |
} |
|
81 |
||
82 |
void push(intptr_t value) { |
|
83 |
assert(_sp > _base, "stack overflow"); |
|
84 |
*(--_sp) = value; |
|
85 |
} |
|
86 |
intptr_t pop() { |
|
87 |
assert(_sp < _top, "stack underflow"); |
|
88 |
return *(_sp++); |
|
89 |
} |
|
90 |
||
91 |
void *alloc(size_t size) { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
35479
diff
changeset
|
92 |
int count = align_up(size, wordSize) >> LogBytesPerWord; |
4013 | 93 |
assert(count <= available_words(), "stack overflow"); |
94 |
return _sp -= count; |
|
95 |
} |
|
96 |
||
5335 | 97 |
int shadow_pages_size() const { |
98 |
return _shadow_pages_size; |
|
99 |
} |
|
5424 | 100 |
int abi_stack_available(Thread *thread) const; |
5335 | 101 |
|
102 |
public: |
|
103 |
void overflow_check(int required_words, TRAPS); |
|
104 |
static void handle_overflow(TRAPS); |
|
105 |
||
4013 | 106 |
public: |
5418 | 107 |
void zap(int c) PRODUCT_RETURN; |
108 |
||
109 |
public: |
|
4013 | 110 |
static ByteSize base_offset() { |
111 |
return byte_offset_of(ZeroStack, _base); |
|
112 |
} |
|
113 |
static ByteSize top_offset() { |
|
114 |
return byte_offset_of(ZeroStack, _top); |
|
115 |
} |
|
116 |
static ByteSize sp_offset() { |
|
117 |
return byte_offset_of(ZeroStack, _sp); |
|
118 |
} |
|
119 |
}; |
|
120 |
||
121 |
||
122 |
class EntryFrame; |
|
123 |
class InterpreterFrame; |
|
124 |
class FakeStubFrame; |
|
125 |
||
126 |
// |
|
127 |
// | ... | |
|
128 |
// +--------------------+ ------------------ |
|
129 |
// | ... | low addresses |
|
130 |
// | frame_type | |
|
131 |
// | next_frame | high addresses |
|
132 |
// +--------------------+ ------------------ |
|
133 |
// | ... | |
|
134 |
||
135 |
class ZeroFrame { |
|
136 |
friend class frame; |
|
137 |
friend class ZeroStackPrinter; |
|
138 |
||
139 |
protected: |
|
140 |
ZeroFrame() { |
|
141 |
ShouldNotCallThis(); |
|
142 |
} |
|
143 |
||
144 |
enum Layout { |
|
145 |
next_frame_off, |
|
146 |
frame_type_off, |
|
147 |
jf_header_words |
|
148 |
}; |
|
149 |
||
150 |
enum FrameType { |
|
151 |
ENTRY_FRAME = 1, |
|
152 |
INTERPRETER_FRAME, |
|
153 |
FAKE_STUB_FRAME |
|
154 |
}; |
|
155 |
||
156 |
protected: |
|
157 |
intptr_t *addr_of_word(int offset) const { |
|
158 |
return (intptr_t *) this - offset; |
|
159 |
} |
|
160 |
intptr_t value_of_word(int offset) const { |
|
161 |
return *addr_of_word(offset); |
|
162 |
} |
|
163 |
||
164 |
public: |
|
165 |
ZeroFrame *next() const { |
|
166 |
return (ZeroFrame *) value_of_word(next_frame_off); |
|
167 |
} |
|
168 |
||
169 |
protected: |
|
170 |
FrameType type() const { |
|
171 |
return (FrameType) value_of_word(frame_type_off); |
|
172 |
} |
|
173 |
||
174 |
public: |
|
175 |
bool is_entry_frame() const { |
|
176 |
return type() == ENTRY_FRAME; |
|
177 |
} |
|
178 |
bool is_interpreter_frame() const { |
|
179 |
return type() == INTERPRETER_FRAME; |
|
180 |
} |
|
181 |
bool is_fake_stub_frame() const { |
|
182 |
return type() == FAKE_STUB_FRAME; |
|
183 |
} |
|
184 |
||
185 |
public: |
|
186 |
EntryFrame *as_entry_frame() const { |
|
187 |
assert(is_entry_frame(), "should be"); |
|
188 |
return (EntryFrame *) this; |
|
189 |
} |
|
190 |
InterpreterFrame *as_interpreter_frame() const { |
|
191 |
assert(is_interpreter_frame(), "should be"); |
|
192 |
return (InterpreterFrame *) this; |
|
193 |
} |
|
194 |
FakeStubFrame *as_fake_stub_frame() const { |
|
195 |
assert(is_fake_stub_frame(), "should be"); |
|
196 |
return (FakeStubFrame *) this; |
|
197 |
} |
|
198 |
||
199 |
public: |
|
200 |
void identify_word(int frame_index, |
|
201 |
int offset, |
|
202 |
char* fieldbuf, |
|
203 |
char* valuebuf, |
|
204 |
int buflen) const; |
|
205 |
||
206 |
protected: |
|
207 |
void identify_vp_word(int frame_index, |
|
208 |
intptr_t* addr, |
|
209 |
intptr_t* monitor_base, |
|
210 |
intptr_t* stack_base, |
|
211 |
char* fieldbuf, |
|
212 |
int buflen) const; |
|
213 |
}; |
|
7397 | 214 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47687
diff
changeset
|
215 |
#endif // CPU_ZERO_STACK_ZERO_HPP |