comparison src/cpu/ppc/vm/frame_ppc.hpp @ 14408:ec28f9c041ff

8019972: PPC64 (part 9): platform files for interpreter only VM. Summary: With this change the HotSpot core build works on Linux/PPC64. The VM succesfully executes simple test programs. Reviewed-by: kvn
author goetz
date Fri, 02 Aug 2013 16:46:45 +0200
parents
children 67fa91961822
comparison
equal deleted inserted replaced
14407:94c202aa2646 14408:ec28f9c041ff
1 /*
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2012, 2013 SAP AG. 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_PPC_VM_FRAME_PPC_HPP
27 #define CPU_PPC_VM_FRAME_PPC_HPP
28
29 #include "runtime/synchronizer.hpp"
30 #include "utilities/top.hpp"
31
32 #ifndef CC_INTERP
33 #error "CC_INTERP must be defined on PPC64"
34 #endif
35
36 // C frame layout on PPC-64.
37 //
38 // In this figure the stack grows upwards, while memory grows
39 // downwards. See "64-bit PowerPC ELF ABI Supplement Version 1.7",
40 // IBM Corp. (2003-10-29)
41 // (http://math-atlas.sourceforge.net/devel/assembly/PPC-elf64abi-1.7.pdf).
42 //
43 // Square brackets denote stack regions possibly larger
44 // than a single 64 bit slot.
45 //
46 // STACK:
47 // 0 [C_FRAME] <-- SP after prolog (mod 16 = 0)
48 // [C_FRAME] <-- SP before prolog
49 // ...
50 // [C_FRAME]
51 //
52 // C_FRAME:
53 // 0 [ABI_112]
54 // 112 CARG_9: outgoing arg 9 (arg_1 ... arg_8 via gpr_3 ... gpr_{10})
55 // ...
56 // 40+M*8 CARG_M: outgoing arg M (M is the maximum of outgoing args taken over all call sites in the procedure)
57 // local 1
58 // ...
59 // local N
60 // spill slot for vector reg (16 bytes aligned)
61 // ...
62 // spill slot for vector reg
63 // alignment (4 or 12 bytes)
64 // V SR_VRSAVE
65 // V+4 spill slot for GR
66 // ... ...
67 // spill slot for GR
68 // spill slot for FR
69 // ...
70 // spill slot for FR
71 //
72 // ABI_48:
73 // 0 caller's SP
74 // 8 space for condition register (CR) for next call
75 // 16 space for link register (LR) for next call
76 // 24 reserved
77 // 32 reserved
78 // 40 space for TOC (=R2) register for next call
79 //
80 // ABI_112:
81 // 0 [ABI_48]
82 // 48 CARG_1: spill slot for outgoing arg 1. used by next callee.
83 // ... ...
84 // 104 CARG_8: spill slot for outgoing arg 8. used by next callee.
85 //
86
87 public:
88
89 // C frame layout
90
91 enum {
92 // stack alignment
93 alignment_in_bytes = 16,
94 // log_2(16*8 bits) = 7.
95 log_2_of_alignment_in_bits = 7
96 };
97
98 // ABI_48:
99 struct abi_48 {
100 uint64_t callers_sp;
101 uint64_t cr; //_16
102 uint64_t lr;
103 uint64_t reserved1; //_16
104 uint64_t reserved2;
105 uint64_t toc; //_16
106 // nothing to add here!
107 // aligned to frame::alignment_in_bytes (16)
108 };
109
110 enum {
111 abi_48_size = sizeof(abi_48)
112 };
113
114 struct abi_112 : abi_48 {
115 uint64_t carg_1;
116 uint64_t carg_2; //_16
117 uint64_t carg_3;
118 uint64_t carg_4; //_16
119 uint64_t carg_5;
120 uint64_t carg_6; //_16
121 uint64_t carg_7;
122 uint64_t carg_8; //_16
123 // aligned to frame::alignment_in_bytes (16)
124 };
125
126 enum {
127 abi_112_size = sizeof(abi_112)
128 };
129
130 #define _abi(_component) \
131 (offset_of(frame::abi_112, _component))
132
133 struct abi_112_spill : abi_112 {
134 // additional spill slots
135 uint64_t spill_ret;
136 uint64_t spill_fret; //_16
137 // aligned to frame::alignment_in_bytes (16)
138 };
139
140 enum {
141 abi_112_spill_size = sizeof(abi_112_spill)
142 };
143
144 #define _abi_112_spill(_component) \
145 (offset_of(frame::abi_112_spill, _component))
146
147 // non-volatile GPRs:
148
149 struct spill_nonvolatiles {
150 uint64_t r14;
151 uint64_t r15; //_16
152 uint64_t r16;
153 uint64_t r17; //_16
154 uint64_t r18;
155 uint64_t r19; //_16
156 uint64_t r20;
157 uint64_t r21; //_16
158 uint64_t r22;
159 uint64_t r23; //_16
160 uint64_t r24;
161 uint64_t r25; //_16
162 uint64_t r26;
163 uint64_t r27; //_16
164 uint64_t r28;
165 uint64_t r29; //_16
166 uint64_t r30;
167 uint64_t r31; //_16
168
169 double f14;
170 double f15;
171 double f16;
172 double f17;
173 double f18;
174 double f19;
175 double f20;
176 double f21;
177 double f22;
178 double f23;
179 double f24;
180 double f25;
181 double f26;
182 double f27;
183 double f28;
184 double f29;
185 double f30;
186 double f31;
187
188 // aligned to frame::alignment_in_bytes (16)
189 };
190
191 enum {
192 spill_nonvolatiles_size = sizeof(spill_nonvolatiles)
193 };
194
195 #define _spill_nonvolatiles_neg(_component) \
196 (int)(-frame::spill_nonvolatiles_size + offset_of(frame::spill_nonvolatiles, _component))
197
198 // Frame layout for the Java interpreter on PPC64.
199 //
200 // This frame layout provides a C-like frame for every Java frame.
201 //
202 // In these figures the stack grows upwards, while memory grows
203 // downwards. Square brackets denote regions possibly larger than
204 // single 64 bit slots.
205 //
206 // STACK (no JNI, no compiled code, no library calls,
207 // interpreter-loop is active):
208 // 0 [InterpretMethod]
209 // [TOP_IJAVA_FRAME]
210 // [PARENT_IJAVA_FRAME]
211 // ...
212 // [PARENT_IJAVA_FRAME]
213 // [ENTRY_FRAME]
214 // [C_FRAME]
215 // ...
216 // [C_FRAME]
217 //
218 // TOP_IJAVA_FRAME:
219 // 0 [TOP_IJAVA_FRAME_ABI]
220 // alignment (optional)
221 // [operand stack]
222 // [monitors] (optional)
223 // [cInterpreter object]
224 // result, locals, and arguments are in parent frame!
225 //
226 // PARENT_IJAVA_FRAME:
227 // 0 [PARENT_IJAVA_FRAME_ABI]
228 // alignment (optional)
229 // [callee's Java result]
230 // [callee's locals w/o arguments]
231 // [outgoing arguments]
232 // [used part of operand stack w/o arguments]
233 // [monitors] (optional)
234 // [cInterpreter object]
235 //
236 // ENTRY_FRAME:
237 // 0 [PARENT_IJAVA_FRAME_ABI]
238 // alignment (optional)
239 // [callee's Java result]
240 // [callee's locals w/o arguments]
241 // [outgoing arguments]
242 // [ENTRY_FRAME_LOCALS]
243 //
244 // PARENT_IJAVA_FRAME_ABI:
245 // 0 [ABI_48]
246 // top_frame_sp
247 // initial_caller_sp
248 //
249 // TOP_IJAVA_FRAME_ABI:
250 // 0 [PARENT_IJAVA_FRAME_ABI]
251 // carg_3_unused
252 // carg_4_unused
253 // carg_5_unused
254 // carg_6_unused
255 // carg_7_unused
256 // frame_manager_lr
257 //
258
259 // PARENT_IJAVA_FRAME_ABI
260
261 struct parent_ijava_frame_abi : abi_48 {
262 // SOE registers.
263 // C2i adapters spill their top-frame stack-pointer here.
264 uint64_t top_frame_sp; // carg_1
265 // Sp of calling compiled frame before it was resized by the c2i
266 // adapter or sp of call stub. Does not contain a valid value for
267 // non-initial frames.
268 uint64_t initial_caller_sp; // carg_2
269 // aligned to frame::alignment_in_bytes (16)
270 };
271
272 enum {
273 parent_ijava_frame_abi_size = sizeof(parent_ijava_frame_abi)
274 };
275
276 #define _parent_ijava_frame_abi(_component) \
277 (offset_of(frame::parent_ijava_frame_abi, _component))
278
279 // TOP_IJAVA_FRAME_ABI
280
281 struct top_ijava_frame_abi : parent_ijava_frame_abi {
282 uint64_t carg_3_unused; // carg_3
283 uint64_t card_4_unused; //_16 carg_4
284 uint64_t carg_5_unused; // carg_5
285 uint64_t carg_6_unused; //_16 carg_6
286 uint64_t carg_7_unused; // carg_7
287 // Use arg8 for storing frame_manager_lr. The size of
288 // top_ijava_frame_abi must match abi_112.
289 uint64_t frame_manager_lr; //_16 carg_8
290 // nothing to add here!
291 // aligned to frame::alignment_in_bytes (16)
292 };
293
294 enum {
295 top_ijava_frame_abi_size = sizeof(top_ijava_frame_abi)
296 };
297
298 #define _top_ijava_frame_abi(_component) \
299 (offset_of(frame::top_ijava_frame_abi, _component))
300
301 // ENTRY_FRAME
302
303 struct entry_frame_locals {
304 uint64_t call_wrapper_address;
305 uint64_t result_address; //_16
306 uint64_t result_type;
307 uint64_t arguments_tos_address; //_16
308 // aligned to frame::alignment_in_bytes (16)
309 uint64_t r[spill_nonvolatiles_size/sizeof(uint64_t)];
310 };
311
312 enum {
313 entry_frame_locals_size = sizeof(entry_frame_locals)
314 };
315
316 #define _entry_frame_locals_neg(_component) \
317 (int)(-frame::entry_frame_locals_size + offset_of(frame::entry_frame_locals, _component))
318
319
320 // Frame layout for JIT generated methods
321 //
322 // In these figures the stack grows upwards, while memory grows
323 // downwards. Square brackets denote regions possibly larger than single
324 // 64 bit slots.
325 //
326 // STACK (interpreted Java calls JIT generated Java):
327 // [JIT_FRAME] <-- SP (mod 16 = 0)
328 // [TOP_IJAVA_FRAME]
329 // ...
330 //
331 // JIT_FRAME (is a C frame according to PPC-64 ABI):
332 // [out_preserve]
333 // [out_args]
334 // [spills]
335 // [pad_1]
336 // [monitor] (optional)
337 // ...
338 // [monitor] (optional)
339 // [pad_2]
340 // [in_preserve] added / removed by prolog / epilog
341 //
342
343 // JIT_ABI (TOP and PARENT)
344
345 struct jit_abi {
346 uint64_t callers_sp;
347 uint64_t cr;
348 uint64_t lr;
349 uint64_t toc;
350 // Nothing to add here!
351 // NOT ALIGNED to frame::alignment_in_bytes (16).
352 };
353
354 struct jit_out_preserve : jit_abi {
355 // Nothing to add here!
356 };
357
358 struct jit_in_preserve {
359 // Nothing to add here!
360 };
361
362 enum {
363 jit_out_preserve_size = sizeof(jit_out_preserve),
364 jit_in_preserve_size = sizeof(jit_in_preserve)
365 };
366
367 struct jit_monitor {
368 uint64_t monitor[1];
369 };
370
371 enum {
372 jit_monitor_size = sizeof(jit_monitor),
373 };
374
375 private:
376
377 // STACK:
378 // ...
379 // [THIS_FRAME] <-- this._sp (stack pointer for this frame)
380 // [CALLER_FRAME] <-- this.fp() (_sp of caller's frame)
381 // ...
382 //
383
384 // frame pointer for this frame
385 intptr_t* _fp;
386
387 // The frame's stack pointer before it has been extended by a c2i adapter;
388 // needed by deoptimization
389 intptr_t* _unextended_sp;
390 void adjust_unextended_sp();
391
392 public:
393
394 // Accessors for fields
395 intptr_t* fp() const { return _fp; }
396
397 // Accessors for ABIs
398 inline abi_48* own_abi() const { return (abi_48*) _sp; }
399 inline abi_48* callers_abi() const { return (abi_48*) _fp; }
400
401 private:
402
403 // Find codeblob and set deopt_state.
404 inline void find_codeblob_and_set_pc_and_deopt_state(address pc);
405
406 public:
407
408 // Constructors
409 inline frame(intptr_t* sp);
410 frame(intptr_t* sp, address pc);
411 inline frame(intptr_t* sp, address pc, intptr_t* unextended_sp);
412
413 private:
414
415 intptr_t* compiled_sender_sp(CodeBlob* cb) const;
416 address* compiled_sender_pc_addr(CodeBlob* cb) const;
417 address* sender_pc_addr(void) const;
418
419 public:
420
421 #ifdef CC_INTERP
422 // Additional interface for interpreter frames:
423 inline interpreterState get_interpreterState() const;
424 #endif
425
426 // Size of a monitor in bytes.
427 static int interpreter_frame_monitor_size_in_bytes();
428
429 // The size of a cInterpreter object.
430 static inline int interpreter_frame_cinterpreterstate_size_in_bytes();
431
432 private:
433
434 // PPC port: permgen stuff
435 ConstantPoolCache** interpreter_frame_cpoolcache_addr() const;
436
437 public:
438
439 // Additional interface for entry frames:
440 inline entry_frame_locals* get_entry_frame_locals() const {
441 return (entry_frame_locals*) (((address) fp()) - entry_frame_locals_size);
442 }
443
444 enum {
445 // normal return address is 1 bundle past PC
446 pc_return_offset = 0
447 };
448
449 #endif // CPU_PPC_VM_FRAME_PPC_HPP