Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/ppc/vm/frame_ppc.hpp
32285 views
/*1* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.2* Copyright 2012, 2014 SAP AG. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef CPU_PPC_VM_FRAME_PPC_HPP26#define CPU_PPC_VM_FRAME_PPC_HPP2728#include "runtime/synchronizer.hpp"29#include "utilities/top.hpp"3031// C frame layout on PPC-64.32//33// In this figure the stack grows upwards, while memory grows34// downwards. See "64-bit PowerPC ELF ABI Supplement Version 1.7",35// IBM Corp. (2003-10-29)36// (http://math-atlas.sourceforge.net/devel/assembly/PPC-elf64abi-1.7.pdf).37//38// Square brackets denote stack regions possibly larger39// than a single 64 bit slot.40//41// STACK:42// 0 [C_FRAME] <-- SP after prolog (mod 16 = 0)43// [C_FRAME] <-- SP before prolog44// ...45// [C_FRAME]46//47// C_FRAME:48// 0 [ABI_REG_ARGS]49// 112 CARG_9: outgoing arg 9 (arg_1 ... arg_8 via gpr_3 ... gpr_{10})50// ...51// 40+M*8 CARG_M: outgoing arg M (M is the maximum of outgoing args taken over all call sites in the procedure)52// local 153// ...54// local N55// spill slot for vector reg (16 bytes aligned)56// ...57// spill slot for vector reg58// alignment (4 or 12 bytes)59// V SR_VRSAVE60// V+4 spill slot for GR61// ... ...62// spill slot for GR63// spill slot for FR64// ...65// spill slot for FR66//67// ABI_48:68// 0 caller's SP69// 8 space for condition register (CR) for next call70// 16 space for link register (LR) for next call71// 24 reserved72// 32 reserved73// 40 space for TOC (=R2) register for next call74//75// ABI_REG_ARGS:76// 0 [ABI_48]77// 48 CARG_1: spill slot for outgoing arg 1. used by next callee.78// ... ...79// 104 CARG_8: spill slot for outgoing arg 8. used by next callee.80//8182public:8384// C frame layout8586enum {87// stack alignment88alignment_in_bytes = 16,89// log_2(16*8 bits) = 7.90log_2_of_alignment_in_bits = 791};9293// ABI_MINFRAME:94struct abi_minframe {95uint64_t callers_sp;96uint64_t cr; //_1697uint64_t lr;98#if !defined(ABI_ELFv2)99uint64_t reserved1; //_16100uint64_t reserved2;101#endif102uint64_t toc; //_16103// nothing to add here!104// aligned to frame::alignment_in_bytes (16)105};106107enum {108abi_minframe_size = sizeof(abi_minframe)109};110111struct abi_reg_args : abi_minframe {112uint64_t carg_1;113uint64_t carg_2; //_16114uint64_t carg_3;115uint64_t carg_4; //_16116uint64_t carg_5;117uint64_t carg_6; //_16118uint64_t carg_7;119uint64_t carg_8; //_16120// aligned to frame::alignment_in_bytes (16)121};122123enum {124abi_reg_args_size = sizeof(abi_reg_args)125};126127#define _abi(_component) \128(offset_of(frame::abi_reg_args, _component))129130struct abi_reg_args_spill : abi_reg_args {131// additional spill slots132uint64_t spill_ret;133uint64_t spill_fret; //_16134// aligned to frame::alignment_in_bytes (16)135};136137enum {138abi_reg_args_spill_size = sizeof(abi_reg_args_spill)139};140141#define _abi_reg_args_spill(_component) \142(offset_of(frame::abi_reg_args_spill, _component))143144// non-volatile GPRs:145146struct spill_nonvolatiles {147uint64_t r14;148uint64_t r15; //_16149uint64_t r16;150uint64_t r17; //_16151uint64_t r18;152uint64_t r19; //_16153uint64_t r20;154uint64_t r21; //_16155uint64_t r22;156uint64_t r23; //_16157uint64_t r24;158uint64_t r25; //_16159uint64_t r26;160uint64_t r27; //_16161uint64_t r28;162uint64_t r29; //_16163uint64_t r30;164uint64_t r31; //_16165166double f14;167double f15;168double f16;169double f17;170double f18;171double f19;172double f20;173double f21;174double f22;175double f23;176double f24;177double f25;178double f26;179double f27;180double f28;181double f29;182double f30;183double f31;184185// aligned to frame::alignment_in_bytes (16)186};187188enum {189spill_nonvolatiles_size = sizeof(spill_nonvolatiles)190};191192#define _spill_nonvolatiles_neg(_component) \193(int)(-frame::spill_nonvolatiles_size + offset_of(frame::spill_nonvolatiles, _component))194195196197#ifndef CC_INTERP198// Frame layout for the Java template interpreter on PPC64.199//200// Diffs to the CC_INTERP are marked with 'X'.201//202// TOP_IJAVA_FRAME:203//204// 0 [TOP_IJAVA_FRAME_ABI]205// alignment (optional)206// [operand stack]207// [monitors] (optional)208// X[IJAVA_STATE]209// note: own locals are located in the caller frame.210//211// PARENT_IJAVA_FRAME:212//213// 0 [PARENT_IJAVA_FRAME_ABI]214// alignment (optional)215// [callee's Java result]216// [callee's locals w/o arguments]217// [outgoing arguments]218// [used part of operand stack w/o arguments]219// [monitors] (optional)220// X[IJAVA_STATE]221//222223struct parent_ijava_frame_abi : abi_minframe {224};225226enum {227parent_ijava_frame_abi_size = sizeof(parent_ijava_frame_abi)228};229230#define _parent_ijava_frame_abi(_component) \231(offset_of(frame::parent_ijava_frame_abi, _component))232233struct top_ijava_frame_abi : abi_reg_args {234};235236enum {237top_ijava_frame_abi_size = sizeof(top_ijava_frame_abi)238};239240#define _top_ijava_frame_abi(_component) \241(offset_of(frame::top_ijava_frame_abi, _component))242243struct ijava_state {244#ifdef ASSERT245uint64_t ijava_reserved; // Used for assertion.246uint64_t ijava_reserved2; // Inserted for alignment.247#endif248uint64_t method;249uint64_t locals;250uint64_t monitors;251uint64_t cpoolCache;252uint64_t bcp;253uint64_t esp;254uint64_t mdx;255uint64_t top_frame_sp; // Maybe define parent_frame_abi and move there.256uint64_t sender_sp;257// Slots only needed for native calls. Maybe better to move elsewhere.258uint64_t oop_tmp;259uint64_t lresult;260uint64_t fresult;261// Aligned to frame::alignment_in_bytes (16).262};263264enum {265ijava_state_size = sizeof(ijava_state)266};267268#define _ijava_state_neg(_component) \269(int) (-frame::ijava_state_size + offset_of(frame::ijava_state, _component))270271#else // CC_INTERP:272273// Frame layout for the Java C++ interpreter on PPC64.274//275// This frame layout provides a C-like frame for every Java frame.276//277// In these figures the stack grows upwards, while memory grows278// downwards. Square brackets denote regions possibly larger than279// single 64 bit slots.280//281// STACK (no JNI, no compiled code, no library calls,282// interpreter-loop is active):283// 0 [InterpretMethod]284// [TOP_IJAVA_FRAME]285// [PARENT_IJAVA_FRAME]286// ...287// [PARENT_IJAVA_FRAME]288// [ENTRY_FRAME]289// [C_FRAME]290// ...291// [C_FRAME]292//293// TOP_IJAVA_FRAME:294// 0 [TOP_IJAVA_FRAME_ABI]295// alignment (optional)296// [operand stack]297// [monitors] (optional)298// [cInterpreter object]299// result, locals, and arguments are in parent frame!300//301// PARENT_IJAVA_FRAME:302// 0 [PARENT_IJAVA_FRAME_ABI]303// alignment (optional)304// [callee's Java result]305// [callee's locals w/o arguments]306// [outgoing arguments]307// [used part of operand stack w/o arguments]308// [monitors] (optional)309// [cInterpreter object]310//311// ENTRY_FRAME:312// 0 [PARENT_IJAVA_FRAME_ABI]313// alignment (optional)314// [callee's Java result]315// [callee's locals w/o arguments]316// [outgoing arguments]317// [ENTRY_FRAME_LOCALS]318//319// PARENT_IJAVA_FRAME_ABI:320// 0 [ABI_MINFRAME]321// top_frame_sp322// initial_caller_sp323//324// TOP_IJAVA_FRAME_ABI:325// 0 [PARENT_IJAVA_FRAME_ABI]326// carg_3_unused327// carg_4_unused328// carg_5_unused329// carg_6_unused330// carg_7_unused331// frame_manager_lr332//333334// PARENT_IJAVA_FRAME_ABI335336struct parent_ijava_frame_abi : abi_minframe {337// SOE registers.338// C2i adapters spill their top-frame stack-pointer here.339uint64_t top_frame_sp; // carg_1340// Sp of calling compiled frame before it was resized by the c2i341// adapter or sp of call stub. Does not contain a valid value for342// non-initial frames.343uint64_t initial_caller_sp; // carg_2344// aligned to frame::alignment_in_bytes (16)345};346347enum {348parent_ijava_frame_abi_size = sizeof(parent_ijava_frame_abi)349};350351#define _parent_ijava_frame_abi(_component) \352(offset_of(frame::parent_ijava_frame_abi, _component))353354// TOP_IJAVA_FRAME_ABI355356struct top_ijava_frame_abi : parent_ijava_frame_abi {357uint64_t carg_3_unused; // carg_3358uint64_t card_4_unused; //_16 carg_4359uint64_t carg_5_unused; // carg_5360uint64_t carg_6_unused; //_16 carg_6361uint64_t carg_7_unused; // carg_7362// Use arg8 for storing frame_manager_lr. The size of363// top_ijava_frame_abi must match abi_reg_args.364uint64_t frame_manager_lr; //_16 carg_8365// nothing to add here!366// aligned to frame::alignment_in_bytes (16)367};368369enum {370top_ijava_frame_abi_size = sizeof(top_ijava_frame_abi)371};372373#define _top_ijava_frame_abi(_component) \374(offset_of(frame::top_ijava_frame_abi, _component))375376#endif // CC_INTERP377378// ENTRY_FRAME379380struct entry_frame_locals {381uint64_t call_wrapper_address;382uint64_t result_address; //_16383uint64_t result_type;384uint64_t arguments_tos_address; //_16385// aligned to frame::alignment_in_bytes (16)386uint64_t r[spill_nonvolatiles_size/sizeof(uint64_t)];387};388389enum {390entry_frame_locals_size = sizeof(entry_frame_locals)391};392393#define _entry_frame_locals_neg(_component) \394(int)(-frame::entry_frame_locals_size + offset_of(frame::entry_frame_locals, _component))395396397// Frame layout for JIT generated methods398//399// In these figures the stack grows upwards, while memory grows400// downwards. Square brackets denote regions possibly larger than single401// 64 bit slots.402//403// STACK (interpreted Java calls JIT generated Java):404// [JIT_FRAME] <-- SP (mod 16 = 0)405// [TOP_IJAVA_FRAME]406// ...407//408// JIT_FRAME (is a C frame according to PPC-64 ABI):409// [out_preserve]410// [out_args]411// [spills]412// [pad_1]413// [monitor] (optional)414// ...415// [monitor] (optional)416// [pad_2]417// [in_preserve] added / removed by prolog / epilog418//419420// JIT_ABI (TOP and PARENT)421422struct jit_abi {423uint64_t callers_sp;424uint64_t cr;425uint64_t lr;426uint64_t toc;427// Nothing to add here!428// NOT ALIGNED to frame::alignment_in_bytes (16).429};430431struct jit_out_preserve : jit_abi {432// Nothing to add here!433};434435struct jit_in_preserve {436// Nothing to add here!437};438439enum {440jit_out_preserve_size = sizeof(jit_out_preserve),441jit_in_preserve_size = sizeof(jit_in_preserve)442};443444struct jit_monitor {445uint64_t monitor[1];446};447448enum {449jit_monitor_size = sizeof(jit_monitor),450};451452private:453454// STACK:455// ...456// [THIS_FRAME] <-- this._sp (stack pointer for this frame)457// [CALLER_FRAME] <-- this.fp() (_sp of caller's frame)458// ...459//460461// frame pointer for this frame462intptr_t* _fp;463464// The frame's stack pointer before it has been extended by a c2i adapter;465// needed by deoptimization466intptr_t* _unextended_sp;467void adjust_unextended_sp();468469public:470471// Accessors for fields472intptr_t* fp() const { return _fp; }473474// Accessors for ABIs475inline abi_minframe* own_abi() const { return (abi_minframe*) _sp; }476inline abi_minframe* callers_abi() const { return (abi_minframe*) _fp; }477478private:479480// Find codeblob and set deopt_state.481inline void find_codeblob_and_set_pc_and_deopt_state(address pc);482483public:484485// Constructors486inline frame(intptr_t* sp);487frame(intptr_t* sp, address pc);488inline frame(intptr_t* sp, address pc, intptr_t* unextended_sp);489490private:491492intptr_t* compiled_sender_sp(CodeBlob* cb) const;493address* compiled_sender_pc_addr(CodeBlob* cb) const;494address* sender_pc_addr(void) const;495496public:497498#ifdef CC_INTERP499// Additional interface for interpreter frames:500inline interpreterState get_interpreterState() const;501#else502inline ijava_state* get_ijava_state() const;503// Some convenient register frame setters/getters for deoptimization.504inline intptr_t* interpreter_frame_esp() const;505inline void interpreter_frame_set_cpcache(ConstantPoolCache* cp);506inline void interpreter_frame_set_esp(intptr_t* esp);507inline void interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp);508inline void interpreter_frame_set_sender_sp(intptr_t* sender_sp);509#endif // CC_INTERP510511// Size of a monitor in bytes.512static int interpreter_frame_monitor_size_in_bytes();513514// The size of a cInterpreter object.515static inline int interpreter_frame_cinterpreterstate_size_in_bytes();516517private:518519ConstantPoolCache** interpreter_frame_cpoolcache_addr() const;520521public:522523// Additional interface for entry frames:524inline entry_frame_locals* get_entry_frame_locals() const {525return (entry_frame_locals*) (((address) fp()) - entry_frame_locals_size);526}527528enum {529// normal return address is 1 bundle past PC530pc_return_offset = 0531};532533#endif // CPU_PPC_VM_FRAME_PPC_HPP534535536