src/cpu/ppc/vm/frame_ppc.hpp

Wed, 27 Nov 2013 16:16:21 -0800

author
goetz
date
Wed, 27 Nov 2013 16:16:21 -0800
changeset 6490
41b780b43b74
parent 6458
ec28f9c041ff
child 6495
67fa91961822
permissions
-rw-r--r--

8029015: PPC64 (part 216): opto: trap based null and range checks
Summary: On PPC64 use tdi instruction that does a compare and raises SIGTRAP for NULL and range checks.
Reviewed-by: kvn

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@6458 53 // 0 [ABI_112]
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@6458 80 // ABI_112:
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@6458 98 // ABI_48:
goetz@6458 99 struct abi_48 {
goetz@6458 100 uint64_t callers_sp;
goetz@6458 101 uint64_t cr; //_16
goetz@6458 102 uint64_t lr;
goetz@6458 103 uint64_t reserved1; //_16
goetz@6458 104 uint64_t reserved2;
goetz@6458 105 uint64_t toc; //_16
goetz@6458 106 // nothing to add here!
goetz@6458 107 // aligned to frame::alignment_in_bytes (16)
goetz@6458 108 };
goetz@6458 109
goetz@6458 110 enum {
goetz@6458 111 abi_48_size = sizeof(abi_48)
goetz@6458 112 };
goetz@6458 113
goetz@6458 114 struct abi_112 : abi_48 {
goetz@6458 115 uint64_t carg_1;
goetz@6458 116 uint64_t carg_2; //_16
goetz@6458 117 uint64_t carg_3;
goetz@6458 118 uint64_t carg_4; //_16
goetz@6458 119 uint64_t carg_5;
goetz@6458 120 uint64_t carg_6; //_16
goetz@6458 121 uint64_t carg_7;
goetz@6458 122 uint64_t carg_8; //_16
goetz@6458 123 // aligned to frame::alignment_in_bytes (16)
goetz@6458 124 };
goetz@6458 125
goetz@6458 126 enum {
goetz@6458 127 abi_112_size = sizeof(abi_112)
goetz@6458 128 };
goetz@6458 129
goetz@6458 130 #define _abi(_component) \
goetz@6458 131 (offset_of(frame::abi_112, _component))
goetz@6458 132
goetz@6458 133 struct abi_112_spill : abi_112 {
goetz@6458 134 // additional spill slots
goetz@6458 135 uint64_t spill_ret;
goetz@6458 136 uint64_t spill_fret; //_16
goetz@6458 137 // aligned to frame::alignment_in_bytes (16)
goetz@6458 138 };
goetz@6458 139
goetz@6458 140 enum {
goetz@6458 141 abi_112_spill_size = sizeof(abi_112_spill)
goetz@6458 142 };
goetz@6458 143
goetz@6458 144 #define _abi_112_spill(_component) \
goetz@6458 145 (offset_of(frame::abi_112_spill, _component))
goetz@6458 146
goetz@6458 147 // non-volatile GPRs:
goetz@6458 148
goetz@6458 149 struct spill_nonvolatiles {
goetz@6458 150 uint64_t r14;
goetz@6458 151 uint64_t r15; //_16
goetz@6458 152 uint64_t r16;
goetz@6458 153 uint64_t r17; //_16
goetz@6458 154 uint64_t r18;
goetz@6458 155 uint64_t r19; //_16
goetz@6458 156 uint64_t r20;
goetz@6458 157 uint64_t r21; //_16
goetz@6458 158 uint64_t r22;
goetz@6458 159 uint64_t r23; //_16
goetz@6458 160 uint64_t r24;
goetz@6458 161 uint64_t r25; //_16
goetz@6458 162 uint64_t r26;
goetz@6458 163 uint64_t r27; //_16
goetz@6458 164 uint64_t r28;
goetz@6458 165 uint64_t r29; //_16
goetz@6458 166 uint64_t r30;
goetz@6458 167 uint64_t r31; //_16
goetz@6458 168
goetz@6458 169 double f14;
goetz@6458 170 double f15;
goetz@6458 171 double f16;
goetz@6458 172 double f17;
goetz@6458 173 double f18;
goetz@6458 174 double f19;
goetz@6458 175 double f20;
goetz@6458 176 double f21;
goetz@6458 177 double f22;
goetz@6458 178 double f23;
goetz@6458 179 double f24;
goetz@6458 180 double f25;
goetz@6458 181 double f26;
goetz@6458 182 double f27;
goetz@6458 183 double f28;
goetz@6458 184 double f29;
goetz@6458 185 double f30;
goetz@6458 186 double f31;
goetz@6458 187
goetz@6458 188 // aligned to frame::alignment_in_bytes (16)
goetz@6458 189 };
goetz@6458 190
goetz@6458 191 enum {
goetz@6458 192 spill_nonvolatiles_size = sizeof(spill_nonvolatiles)
goetz@6458 193 };
goetz@6458 194
goetz@6458 195 #define _spill_nonvolatiles_neg(_component) \
goetz@6458 196 (int)(-frame::spill_nonvolatiles_size + offset_of(frame::spill_nonvolatiles, _component))
goetz@6458 197
goetz@6458 198 // Frame layout for the Java interpreter on PPC64.
goetz@6458 199 //
goetz@6458 200 // This frame layout provides a C-like frame for every Java frame.
goetz@6458 201 //
goetz@6458 202 // In these figures the stack grows upwards, while memory grows
goetz@6458 203 // downwards. Square brackets denote regions possibly larger than
goetz@6458 204 // single 64 bit slots.
goetz@6458 205 //
goetz@6458 206 // STACK (no JNI, no compiled code, no library calls,
goetz@6458 207 // interpreter-loop is active):
goetz@6458 208 // 0 [InterpretMethod]
goetz@6458 209 // [TOP_IJAVA_FRAME]
goetz@6458 210 // [PARENT_IJAVA_FRAME]
goetz@6458 211 // ...
goetz@6458 212 // [PARENT_IJAVA_FRAME]
goetz@6458 213 // [ENTRY_FRAME]
goetz@6458 214 // [C_FRAME]
goetz@6458 215 // ...
goetz@6458 216 // [C_FRAME]
goetz@6458 217 //
goetz@6458 218 // TOP_IJAVA_FRAME:
goetz@6458 219 // 0 [TOP_IJAVA_FRAME_ABI]
goetz@6458 220 // alignment (optional)
goetz@6458 221 // [operand stack]
goetz@6458 222 // [monitors] (optional)
goetz@6458 223 // [cInterpreter object]
goetz@6458 224 // result, locals, and arguments are in parent frame!
goetz@6458 225 //
goetz@6458 226 // PARENT_IJAVA_FRAME:
goetz@6458 227 // 0 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 228 // alignment (optional)
goetz@6458 229 // [callee's Java result]
goetz@6458 230 // [callee's locals w/o arguments]
goetz@6458 231 // [outgoing arguments]
goetz@6458 232 // [used part of operand stack w/o arguments]
goetz@6458 233 // [monitors] (optional)
goetz@6458 234 // [cInterpreter object]
goetz@6458 235 //
goetz@6458 236 // ENTRY_FRAME:
goetz@6458 237 // 0 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 238 // alignment (optional)
goetz@6458 239 // [callee's Java result]
goetz@6458 240 // [callee's locals w/o arguments]
goetz@6458 241 // [outgoing arguments]
goetz@6458 242 // [ENTRY_FRAME_LOCALS]
goetz@6458 243 //
goetz@6458 244 // PARENT_IJAVA_FRAME_ABI:
goetz@6458 245 // 0 [ABI_48]
goetz@6458 246 // top_frame_sp
goetz@6458 247 // initial_caller_sp
goetz@6458 248 //
goetz@6458 249 // TOP_IJAVA_FRAME_ABI:
goetz@6458 250 // 0 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 251 // carg_3_unused
goetz@6458 252 // carg_4_unused
goetz@6458 253 // carg_5_unused
goetz@6458 254 // carg_6_unused
goetz@6458 255 // carg_7_unused
goetz@6458 256 // frame_manager_lr
goetz@6458 257 //
goetz@6458 258
goetz@6458 259 // PARENT_IJAVA_FRAME_ABI
goetz@6458 260
goetz@6458 261 struct parent_ijava_frame_abi : abi_48 {
goetz@6458 262 // SOE registers.
goetz@6458 263 // C2i adapters spill their top-frame stack-pointer here.
goetz@6458 264 uint64_t top_frame_sp; // carg_1
goetz@6458 265 // Sp of calling compiled frame before it was resized by the c2i
goetz@6458 266 // adapter or sp of call stub. Does not contain a valid value for
goetz@6458 267 // non-initial frames.
goetz@6458 268 uint64_t initial_caller_sp; // carg_2
goetz@6458 269 // aligned to frame::alignment_in_bytes (16)
goetz@6458 270 };
goetz@6458 271
goetz@6458 272 enum {
goetz@6458 273 parent_ijava_frame_abi_size = sizeof(parent_ijava_frame_abi)
goetz@6458 274 };
goetz@6458 275
goetz@6458 276 #define _parent_ijava_frame_abi(_component) \
goetz@6458 277 (offset_of(frame::parent_ijava_frame_abi, _component))
goetz@6458 278
goetz@6458 279 // TOP_IJAVA_FRAME_ABI
goetz@6458 280
goetz@6458 281 struct top_ijava_frame_abi : parent_ijava_frame_abi {
goetz@6458 282 uint64_t carg_3_unused; // carg_3
goetz@6458 283 uint64_t card_4_unused; //_16 carg_4
goetz@6458 284 uint64_t carg_5_unused; // carg_5
goetz@6458 285 uint64_t carg_6_unused; //_16 carg_6
goetz@6458 286 uint64_t carg_7_unused; // carg_7
goetz@6458 287 // Use arg8 for storing frame_manager_lr. The size of
goetz@6458 288 // top_ijava_frame_abi must match abi_112.
goetz@6458 289 uint64_t frame_manager_lr; //_16 carg_8
goetz@6458 290 // nothing to add here!
goetz@6458 291 // aligned to frame::alignment_in_bytes (16)
goetz@6458 292 };
goetz@6458 293
goetz@6458 294 enum {
goetz@6458 295 top_ijava_frame_abi_size = sizeof(top_ijava_frame_abi)
goetz@6458 296 };
goetz@6458 297
goetz@6458 298 #define _top_ijava_frame_abi(_component) \
goetz@6458 299 (offset_of(frame::top_ijava_frame_abi, _component))
goetz@6458 300
goetz@6458 301 // ENTRY_FRAME
goetz@6458 302
goetz@6458 303 struct entry_frame_locals {
goetz@6458 304 uint64_t call_wrapper_address;
goetz@6458 305 uint64_t result_address; //_16
goetz@6458 306 uint64_t result_type;
goetz@6458 307 uint64_t arguments_tos_address; //_16
goetz@6458 308 // aligned to frame::alignment_in_bytes (16)
goetz@6458 309 uint64_t r[spill_nonvolatiles_size/sizeof(uint64_t)];
goetz@6458 310 };
goetz@6458 311
goetz@6458 312 enum {
goetz@6458 313 entry_frame_locals_size = sizeof(entry_frame_locals)
goetz@6458 314 };
goetz@6458 315
goetz@6458 316 #define _entry_frame_locals_neg(_component) \
goetz@6458 317 (int)(-frame::entry_frame_locals_size + offset_of(frame::entry_frame_locals, _component))
goetz@6458 318
goetz@6458 319
goetz@6458 320 // Frame layout for JIT generated methods
goetz@6458 321 //
goetz@6458 322 // In these figures the stack grows upwards, while memory grows
goetz@6458 323 // downwards. Square brackets denote regions possibly larger than single
goetz@6458 324 // 64 bit slots.
goetz@6458 325 //
goetz@6458 326 // STACK (interpreted Java calls JIT generated Java):
goetz@6458 327 // [JIT_FRAME] <-- SP (mod 16 = 0)
goetz@6458 328 // [TOP_IJAVA_FRAME]
goetz@6458 329 // ...
goetz@6458 330 //
goetz@6458 331 // JIT_FRAME (is a C frame according to PPC-64 ABI):
goetz@6458 332 // [out_preserve]
goetz@6458 333 // [out_args]
goetz@6458 334 // [spills]
goetz@6458 335 // [pad_1]
goetz@6458 336 // [monitor] (optional)
goetz@6458 337 // ...
goetz@6458 338 // [monitor] (optional)
goetz@6458 339 // [pad_2]
goetz@6458 340 // [in_preserve] added / removed by prolog / epilog
goetz@6458 341 //
goetz@6458 342
goetz@6458 343 // JIT_ABI (TOP and PARENT)
goetz@6458 344
goetz@6458 345 struct jit_abi {
goetz@6458 346 uint64_t callers_sp;
goetz@6458 347 uint64_t cr;
goetz@6458 348 uint64_t lr;
goetz@6458 349 uint64_t toc;
goetz@6458 350 // Nothing to add here!
goetz@6458 351 // NOT ALIGNED to frame::alignment_in_bytes (16).
goetz@6458 352 };
goetz@6458 353
goetz@6458 354 struct jit_out_preserve : jit_abi {
goetz@6458 355 // Nothing to add here!
goetz@6458 356 };
goetz@6458 357
goetz@6458 358 struct jit_in_preserve {
goetz@6458 359 // Nothing to add here!
goetz@6458 360 };
goetz@6458 361
goetz@6458 362 enum {
goetz@6458 363 jit_out_preserve_size = sizeof(jit_out_preserve),
goetz@6458 364 jit_in_preserve_size = sizeof(jit_in_preserve)
goetz@6458 365 };
goetz@6458 366
goetz@6458 367 struct jit_monitor {
goetz@6458 368 uint64_t monitor[1];
goetz@6458 369 };
goetz@6458 370
goetz@6458 371 enum {
goetz@6458 372 jit_monitor_size = sizeof(jit_monitor),
goetz@6458 373 };
goetz@6458 374
goetz@6458 375 private:
goetz@6458 376
goetz@6458 377 // STACK:
goetz@6458 378 // ...
goetz@6458 379 // [THIS_FRAME] <-- this._sp (stack pointer for this frame)
goetz@6458 380 // [CALLER_FRAME] <-- this.fp() (_sp of caller's frame)
goetz@6458 381 // ...
goetz@6458 382 //
goetz@6458 383
goetz@6458 384 // frame pointer for this frame
goetz@6458 385 intptr_t* _fp;
goetz@6458 386
goetz@6458 387 // The frame's stack pointer before it has been extended by a c2i adapter;
goetz@6458 388 // needed by deoptimization
goetz@6458 389 intptr_t* _unextended_sp;
goetz@6458 390 void adjust_unextended_sp();
goetz@6458 391
goetz@6458 392 public:
goetz@6458 393
goetz@6458 394 // Accessors for fields
goetz@6458 395 intptr_t* fp() const { return _fp; }
goetz@6458 396
goetz@6458 397 // Accessors for ABIs
goetz@6458 398 inline abi_48* own_abi() const { return (abi_48*) _sp; }
goetz@6458 399 inline abi_48* callers_abi() const { return (abi_48*) _fp; }
goetz@6458 400
goetz@6458 401 private:
goetz@6458 402
goetz@6458 403 // Find codeblob and set deopt_state.
goetz@6458 404 inline void find_codeblob_and_set_pc_and_deopt_state(address pc);
goetz@6458 405
goetz@6458 406 public:
goetz@6458 407
goetz@6458 408 // Constructors
goetz@6458 409 inline frame(intptr_t* sp);
goetz@6458 410 frame(intptr_t* sp, address pc);
goetz@6458 411 inline frame(intptr_t* sp, address pc, intptr_t* unextended_sp);
goetz@6458 412
goetz@6458 413 private:
goetz@6458 414
goetz@6458 415 intptr_t* compiled_sender_sp(CodeBlob* cb) const;
goetz@6458 416 address* compiled_sender_pc_addr(CodeBlob* cb) const;
goetz@6458 417 address* sender_pc_addr(void) const;
goetz@6458 418
goetz@6458 419 public:
goetz@6458 420
goetz@6458 421 #ifdef CC_INTERP
goetz@6458 422 // Additional interface for interpreter frames:
goetz@6458 423 inline interpreterState get_interpreterState() const;
goetz@6458 424 #endif
goetz@6458 425
goetz@6458 426 // Size of a monitor in bytes.
goetz@6458 427 static int interpreter_frame_monitor_size_in_bytes();
goetz@6458 428
goetz@6458 429 // The size of a cInterpreter object.
goetz@6458 430 static inline int interpreter_frame_cinterpreterstate_size_in_bytes();
goetz@6458 431
goetz@6458 432 private:
goetz@6458 433
goetz@6458 434 // PPC port: permgen stuff
goetz@6458 435 ConstantPoolCache** interpreter_frame_cpoolcache_addr() const;
goetz@6458 436
goetz@6458 437 public:
goetz@6458 438
goetz@6458 439 // Additional interface for entry frames:
goetz@6458 440 inline entry_frame_locals* get_entry_frame_locals() const {
goetz@6458 441 return (entry_frame_locals*) (((address) fp()) - entry_frame_locals_size);
goetz@6458 442 }
goetz@6458 443
goetz@6458 444 enum {
goetz@6458 445 // normal return address is 1 bundle past PC
goetz@6458 446 pc_return_offset = 0
goetz@6458 447 };
goetz@6458 448
goetz@6458 449 #endif // CPU_PPC_VM_FRAME_PPC_HPP

mercurial