src/cpu/ppc/vm/frame_ppc.hpp

Thu, 06 Mar 2014 10:55:28 -0800

author
goetz
date
Thu, 06 Mar 2014 10:55:28 -0800
changeset 6511
31e80afe3fed
parent 6495
67fa91961822
child 6512
fd1b9f02cc91
permissions
-rw-r--r--

8035647: PPC64: Support for elf v2 abi.
Summary: ELFv2 ABI used by the little endian PowerPC64 on Linux.
Reviewed-by: kvn
Contributed-by: asmundak@google.com

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

mercurial