29183
|
1 |
/*
|
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
|
|
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 |
#ifndef CPU_AARCH64_VM_FRAME_AARCH64_HPP
|
|
27 |
#define CPU_AARCH64_VM_FRAME_AARCH64_HPP
|
|
28 |
|
|
29 |
#include "runtime/synchronizer.hpp"
|
|
30 |
#include "utilities/top.hpp"
|
|
31 |
|
|
32 |
// A frame represents a physical stack frame (an activation). Frames can be
|
|
33 |
// C or Java frames, and the Java frames can be interpreted or compiled.
|
|
34 |
// In contrast, vframes represent source-level activations, so that one physical frame
|
|
35 |
// can correspond to multiple source level frames because of inlining.
|
|
36 |
// A frame is comprised of {pc, fp, sp}
|
|
37 |
// ------------------------------ Asm interpreter ----------------------------------------
|
|
38 |
// Layout of asm interpreter frame:
|
|
39 |
// [expression stack ] * <- sp
|
|
40 |
|
|
41 |
// [monitors[0] ] \
|
|
42 |
// ... | monitor block size = k
|
|
43 |
// [monitors[k-1] ] /
|
|
44 |
// [frame initial esp ] ( == &monitors[0], initially here) initial_sp_offset
|
|
45 |
// [byte code index/pointr] = bcx() bcx_offset
|
|
46 |
|
|
47 |
// [pointer to locals ] = locals() locals_offset
|
|
48 |
// [constant pool cache ] = cache() cache_offset
|
|
49 |
|
|
50 |
// [methodData ] = mdp() mdx_offset
|
|
51 |
// [methodOop ] = method() method_offset
|
|
52 |
|
|
53 |
// [last esp ] = last_sp() last_sp_offset
|
|
54 |
// [old stack pointer ] (sender_sp) sender_sp_offset
|
|
55 |
|
|
56 |
// [old frame pointer ] <- fp = link()
|
|
57 |
// [return pc ]
|
|
58 |
|
|
59 |
// [last sp ]
|
|
60 |
// [oop temp ] (only for native calls)
|
|
61 |
|
|
62 |
// [locals and parameters ]
|
|
63 |
// <- sender sp
|
|
64 |
// ------------------------------ Asm interpreter ----------------------------------------
|
|
65 |
|
|
66 |
// ------------------------------ C++ interpreter ----------------------------------------
|
|
67 |
//
|
|
68 |
// Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)
|
|
69 |
//
|
|
70 |
// <- SP (current esp/rsp)
|
|
71 |
// [local variables ] BytecodeInterpreter::run local variables
|
|
72 |
// ... BytecodeInterpreter::run local variables
|
|
73 |
// [local variables ] BytecodeInterpreter::run local variables
|
|
74 |
// [old frame pointer ] fp [ BytecodeInterpreter::run's ebp/rbp ]
|
|
75 |
// [return pc ] (return to frame manager)
|
|
76 |
// [interpreter_state* ] (arg to BytecodeInterpreter::run) --------------
|
|
77 |
// [expression stack ] <- last_Java_sp |
|
|
78 |
// [... ] * <- interpreter_state.stack |
|
|
79 |
// [expression stack ] * <- interpreter_state.stack_base |
|
|
80 |
// [monitors ] \ |
|
|
81 |
// ... | monitor block size |
|
|
82 |
// [monitors ] / <- interpreter_state.monitor_base |
|
|
83 |
// [struct interpretState ] <-----------------------------------------|
|
|
84 |
// [return pc ] (return to callee of frame manager [1]
|
|
85 |
// [locals and parameters ]
|
|
86 |
// <- sender sp
|
|
87 |
|
|
88 |
// [1] When the c++ interpreter calls a new method it returns to the frame
|
|
89 |
// manager which allocates a new frame on the stack. In that case there
|
|
90 |
// is no real callee of this newly allocated frame. The frame manager is
|
|
91 |
// aware of the additional frame(s) and will pop them as nested calls
|
|
92 |
// complete. Howevers tTo make it look good in the debugger the frame
|
|
93 |
// manager actually installs a dummy pc pointing to RecursiveInterpreterActivation
|
|
94 |
// with a fake interpreter_state* parameter to make it easy to debug
|
|
95 |
// nested calls.
|
|
96 |
|
|
97 |
// Note that contrary to the layout for the assembly interpreter the
|
|
98 |
// expression stack allocated for the C++ interpreter is full sized.
|
|
99 |
// However this is not as bad as it seems as the interpreter frame_manager
|
|
100 |
// will truncate the unused space on succesive method calls.
|
|
101 |
//
|
|
102 |
// ------------------------------ C++ interpreter ----------------------------------------
|
|
103 |
|
|
104 |
public:
|
|
105 |
enum {
|
|
106 |
pc_return_offset = 0,
|
|
107 |
// All frames
|
|
108 |
link_offset = 0,
|
|
109 |
return_addr_offset = 1,
|
|
110 |
sender_sp_offset = 2,
|
|
111 |
|
|
112 |
#ifndef CC_INTERP
|
|
113 |
|
|
114 |
// Interpreter frames
|
|
115 |
interpreter_frame_oop_temp_offset = 3, // for native calls only
|
|
116 |
|
|
117 |
interpreter_frame_sender_sp_offset = -1,
|
|
118 |
// outgoing sp before a call to an invoked method
|
|
119 |
interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,
|
|
120 |
interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,
|
|
121 |
interpreter_frame_mdp_offset = interpreter_frame_method_offset - 1,
|
|
122 |
interpreter_frame_cache_offset = interpreter_frame_mdp_offset - 1,
|
|
123 |
interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,
|
|
124 |
interpreter_frame_bcp_offset = interpreter_frame_locals_offset - 1,
|
|
125 |
interpreter_frame_initial_sp_offset = interpreter_frame_bcp_offset - 1,
|
|
126 |
|
|
127 |
interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,
|
|
128 |
interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,
|
|
129 |
|
|
130 |
#endif // CC_INTERP
|
|
131 |
|
|
132 |
// Entry frames
|
|
133 |
// n.b. these values are determined by the layout defined in
|
|
134 |
// stubGenerator for the Java call stub
|
|
135 |
entry_frame_after_call_words = 27,
|
|
136 |
entry_frame_call_wrapper_offset = -8,
|
|
137 |
|
|
138 |
// we don't need a save area
|
|
139 |
arg_reg_save_area_bytes = 0,
|
|
140 |
|
|
141 |
// TODO - check that this is still correct
|
|
142 |
// Native frames
|
|
143 |
|
|
144 |
native_frame_initial_param_offset = 2
|
|
145 |
|
|
146 |
};
|
|
147 |
|
|
148 |
intptr_t ptr_at(int offset) const {
|
|
149 |
return *ptr_at_addr(offset);
|
|
150 |
}
|
|
151 |
|
|
152 |
void ptr_at_put(int offset, intptr_t value) {
|
|
153 |
*ptr_at_addr(offset) = value;
|
|
154 |
}
|
|
155 |
|
|
156 |
private:
|
|
157 |
// an additional field beyond _sp and _pc:
|
|
158 |
intptr_t* _fp; // frame pointer
|
|
159 |
// The interpreter and adapters will extend the frame of the caller.
|
|
160 |
// Since oopMaps are based on the sp of the caller before extension
|
|
161 |
// we need to know that value. However in order to compute the address
|
|
162 |
// of the return address we need the real "raw" sp. Since sparc already
|
|
163 |
// uses sp() to mean "raw" sp and unextended_sp() to mean the caller's
|
|
164 |
// original sp we use that convention.
|
|
165 |
|
|
166 |
intptr_t* _unextended_sp;
|
|
167 |
void adjust_unextended_sp();
|
|
168 |
|
|
169 |
intptr_t* ptr_at_addr(int offset) const {
|
|
170 |
return (intptr_t*) addr_at(offset);
|
|
171 |
}
|
|
172 |
|
|
173 |
#ifdef ASSERT
|
|
174 |
// Used in frame::sender_for_{interpreter,compiled}_frame
|
|
175 |
static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return = false);
|
|
176 |
static void verify_deopt_mh_original_pc(nmethod* nm, intptr_t* unextended_sp) {
|
|
177 |
verify_deopt_original_pc(nm, unextended_sp, true);
|
|
178 |
}
|
|
179 |
#endif
|
|
180 |
|
|
181 |
public:
|
|
182 |
// Constructors
|
|
183 |
|
|
184 |
frame(intptr_t* sp, intptr_t* fp, address pc);
|
|
185 |
|
|
186 |
frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
|
|
187 |
|
|
188 |
frame(intptr_t* sp, intptr_t* fp);
|
|
189 |
|
|
190 |
void init(intptr_t* sp, intptr_t* fp, address pc);
|
|
191 |
|
|
192 |
// accessors for the instance variables
|
|
193 |
// Note: not necessarily the real 'frame pointer' (see real_fp)
|
|
194 |
intptr_t* fp() const { return _fp; }
|
|
195 |
|
|
196 |
inline address* sender_pc_addr() const;
|
|
197 |
|
|
198 |
// return address of param, zero origin index.
|
|
199 |
inline address* native_param_addr(int idx) const;
|
|
200 |
|
|
201 |
// expression stack tos if we are nested in a java call
|
|
202 |
intptr_t* interpreter_frame_last_sp() const;
|
|
203 |
|
|
204 |
// helper to update a map with callee-saved RBP
|
|
205 |
static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);
|
|
206 |
|
|
207 |
#ifndef CC_INTERP
|
|
208 |
// deoptimization support
|
|
209 |
void interpreter_frame_set_last_sp(intptr_t* sp);
|
|
210 |
#endif // CC_INTERP
|
|
211 |
|
|
212 |
#ifdef CC_INTERP
|
|
213 |
inline interpreterState get_interpreterState() const;
|
|
214 |
#endif // CC_INTERP
|
|
215 |
|
|
216 |
#endif // CPU_AARCH64_VM_FRAME_AARCH64_HPP
|