Path: blob/master/src/hotspot/cpu/ppc/frame_ppc.hpp
40930 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2012, 2021 SAP SE. 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_FRAME_PPC_HPP26#define CPU_PPC_FRAME_PPC_HPP2728#include "runtime/synchronizer.hpp"2930// C frame layout on PPC-64.31//32// In this figure the stack grows upwards, while memory grows33// downwards. See "64-bit PowerPC ELF ABI Supplement Version 1.7",34// IBM Corp. (2003-10-29)35// (http://math-atlas.sourceforge.net/devel/assembly/PPC-elf64abi-1.7.pdf).36//37// Square brackets denote stack regions possibly larger38// than a single 64 bit slot.39//40// STACK:41// 0 [C_FRAME] <-- SP after prolog (mod 16 = 0)42// [C_FRAME] <-- SP before prolog43// ...44// [C_FRAME]45//46// C_FRAME:47// 0 [ABI_REG_ARGS]48// 112 CARG_9: outgoing arg 9 (arg_1 ... arg_8 via gpr_3 ... gpr_{10})49// ...50// 40+M*8 CARG_M: outgoing arg M (M is the maximum of outgoing args taken over all call sites in the procedure)51// local 152// ...53// local N54// spill slot for vector reg (16 bytes aligned)55// ...56// spill slot for vector reg57// alignment (4 or 12 bytes)58// V SR_VRSAVE59// V+4 spill slot for GR60// ... ...61// spill slot for GR62// spill slot for FR63// ...64// spill slot for FR65//66// ABI_48:67// 0 caller's SP68// 8 space for condition register (CR) for next call69// 16 space for link register (LR) for next call70// 24 reserved71// 32 reserved72// 40 space for TOC (=R2) register for next call73//74// ABI_REG_ARGS:75// 0 [ABI_48]76// 48 CARG_1: spill slot for outgoing arg 1. used by next callee.77// ... ...78// 104 CARG_8: spill slot for outgoing arg 8. used by next callee.79//8081public:8283// C frame layout84static const int alignment_in_bytes = 16;8586// ABI_MINFRAME:87struct abi_minframe {88uint64_t callers_sp;89uint64_t cr; //_1690uint64_t lr;91#if !defined(ABI_ELFv2)92uint64_t reserved1; //_1693uint64_t reserved2;94#endif95uint64_t toc; //_1696// nothing to add here!97// aligned to frame::alignment_in_bytes (16)98};99100enum {101abi_minframe_size = sizeof(abi_minframe)102};103104struct abi_reg_args : abi_minframe {105uint64_t carg_1;106uint64_t carg_2; //_16107uint64_t carg_3;108uint64_t carg_4; //_16109uint64_t carg_5;110uint64_t carg_6; //_16111uint64_t carg_7;112uint64_t carg_8; //_16113// aligned to frame::alignment_in_bytes (16)114};115116enum {117abi_reg_args_size = sizeof(abi_reg_args)118};119120#define _abi0(_component) \121(offset_of(frame::abi_reg_args, _component))122123struct abi_reg_args_spill : abi_reg_args {124// additional spill slots125uint64_t spill_ret;126uint64_t spill_fret; //_16127// aligned to frame::alignment_in_bytes (16)128};129130enum {131abi_reg_args_spill_size = sizeof(abi_reg_args_spill)132};133134#define _abi_reg_args_spill(_component) \135(offset_of(frame::abi_reg_args_spill, _component))136137// non-volatile GPRs:138139struct spill_nonvolatiles {140uint64_t r14;141uint64_t r15; //_16142uint64_t r16;143uint64_t r17; //_16144uint64_t r18;145uint64_t r19; //_16146uint64_t r20;147uint64_t r21; //_16148uint64_t r22;149uint64_t r23; //_16150uint64_t r24;151uint64_t r25; //_16152uint64_t r26;153uint64_t r27; //_16154uint64_t r28;155uint64_t r29; //_16156uint64_t r30;157uint64_t r31; //_16158159double f14;160double f15;161double f16;162double f17;163double f18;164double f19;165double f20;166double f21;167double f22;168double f23;169double f24;170double f25;171double f26;172double f27;173double f28;174double f29;175double f30;176double f31;177178// aligned to frame::alignment_in_bytes (16)179};180181enum {182spill_nonvolatiles_size = sizeof(spill_nonvolatiles)183};184185#define _spill_nonvolatiles_neg(_component) \186(int)(-frame::spill_nonvolatiles_size + offset_of(frame::spill_nonvolatiles, _component))187188// Frame layout for the Java template interpreter on PPC64.189//190// In these figures the stack grows upwards, while memory grows191// downwards. Square brackets denote regions possibly larger than192// single 64 bit slots.193//194// STACK (interpreter is active):195// 0 [TOP_IJAVA_FRAME]196// [PARENT_IJAVA_FRAME]197// ...198// [PARENT_IJAVA_FRAME]199// [ENTRY_FRAME]200// [C_FRAME]201// ...202// [C_FRAME]203//204// With the following frame layouts:205// TOP_IJAVA_FRAME:206// 0 [TOP_IJAVA_FRAME_ABI]207// alignment (optional)208// [operand stack]209// [monitors] (optional)210// [IJAVA_STATE]211// note: own locals are located in the caller frame.212//213// PARENT_IJAVA_FRAME:214// 0 [PARENT_IJAVA_FRAME_ABI]215// alignment (optional)216// [callee's Java result]217// [callee's locals w/o arguments]218// [outgoing arguments]219// [used part of operand stack w/o arguments]220// [monitors] (optional)221// [IJAVA_STATE]222//223// ENTRY_FRAME:224// 0 [PARENT_IJAVA_FRAME_ABI]225// alignment (optional)226// [callee's Java result]227// [callee's locals w/o arguments]228// [outgoing arguments]229// [ENTRY_FRAME_LOCALS]230231struct parent_ijava_frame_abi : abi_minframe {232};233234enum {235parent_ijava_frame_abi_size = sizeof(parent_ijava_frame_abi)236};237238#define _parent_ijava_frame_abi(_component) \239(offset_of(frame::parent_ijava_frame_abi, _component))240241struct top_ijava_frame_abi : abi_reg_args {242};243244enum {245top_ijava_frame_abi_size = sizeof(top_ijava_frame_abi)246};247248#define _top_ijava_frame_abi(_component) \249(offset_of(frame::top_ijava_frame_abi, _component))250251struct ijava_state {252uint64_t method;253uint64_t mirror;254uint64_t locals;255uint64_t monitors;256uint64_t cpoolCache;257uint64_t bcp;258uint64_t esp;259uint64_t mdx;260uint64_t top_frame_sp; // Maybe define parent_frame_abi and move there.261uint64_t sender_sp;262// Slots only needed for native calls. Maybe better to move elsewhere.263uint64_t oop_tmp;264uint64_t lresult;265uint64_t fresult;266};267268enum {269ijava_state_size = sizeof(ijava_state)270};271272#define _ijava_state_neg(_component) \273(int) (-frame::ijava_state_size + offset_of(frame::ijava_state, _component))274275// ENTRY_FRAME276277struct entry_frame_locals {278uint64_t call_wrapper_address;279uint64_t result_address; //_16280uint64_t result_type;281uint64_t arguments_tos_address; //_16282// aligned to frame::alignment_in_bytes (16)283uint64_t r[spill_nonvolatiles_size/sizeof(uint64_t)];284};285286enum {287entry_frame_locals_size = sizeof(entry_frame_locals)288};289290#define _entry_frame_locals_neg(_component) \291(int)(-frame::entry_frame_locals_size + offset_of(frame::entry_frame_locals, _component))292293294// Frame layout for JIT generated methods295//296// In these figures the stack grows upwards, while memory grows297// downwards. Square brackets denote regions possibly larger than single298// 64 bit slots.299//300// STACK (interpreted Java calls JIT generated Java):301// [JIT_FRAME] <-- SP (mod 16 = 0)302// [TOP_IJAVA_FRAME]303// ...304//305// JIT_FRAME (is a C frame according to PPC-64 ABI):306// [out_preserve]307// [out_args]308// [spills]309// [pad_1]310// [monitor] (optional)311// ...312// [monitor] (optional)313// [pad_2]314// [in_preserve] added / removed by prolog / epilog315//316317// JIT_ABI (TOP and PARENT)318319struct jit_abi {320uint64_t callers_sp;321uint64_t cr;322uint64_t lr;323uint64_t toc;324// Nothing to add here!325// NOT ALIGNED to frame::alignment_in_bytes (16).326};327328struct jit_out_preserve : jit_abi {329// Nothing to add here!330};331332struct jit_in_preserve {333// Nothing to add here!334};335336enum {337jit_out_preserve_size = sizeof(jit_out_preserve),338jit_in_preserve_size = sizeof(jit_in_preserve)339};340341struct jit_monitor {342uint64_t monitor[1];343};344345enum {346jit_monitor_size = sizeof(jit_monitor),347};348349private:350351// STACK:352// ...353// [THIS_FRAME] <-- this._sp (stack pointer for this frame)354// [CALLER_FRAME] <-- this.fp() (_sp of caller's frame)355// ...356//357358// The frame's stack pointer before it has been extended by a c2i adapter;359// needed by deoptimization360intptr_t* _unextended_sp;361362// frame pointer for this frame363intptr_t* _fp;364365public:366367// Accessors for fields368intptr_t* fp() const { return _fp; }369370// Accessors for ABIs371inline abi_minframe* own_abi() const { return (abi_minframe*) _sp; }372inline abi_minframe* callers_abi() const { return (abi_minframe*) _fp; }373374private:375376// Find codeblob and set deopt_state.377inline void find_codeblob_and_set_pc_and_deopt_state(address pc);378379public:380381// Constructors382inline frame(intptr_t* sp);383inline frame(intptr_t* sp, address pc);384inline frame(intptr_t* sp, address pc, intptr_t* unextended_sp);385386private:387388intptr_t* compiled_sender_sp(CodeBlob* cb) const;389address* compiled_sender_pc_addr(CodeBlob* cb) const;390address* sender_pc_addr(void) const;391392public:393394inline ijava_state* get_ijava_state() const;395// Some convenient register frame setters/getters for deoptimization.396inline intptr_t* interpreter_frame_esp() const;397inline void interpreter_frame_set_cpcache(ConstantPoolCache* cp);398inline void interpreter_frame_set_esp(intptr_t* esp);399inline void interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp);400inline void interpreter_frame_set_sender_sp(intptr_t* sender_sp);401402// Size of a monitor in bytes.403static int interpreter_frame_monitor_size_in_bytes();404405// The size of a cInterpreter object.406static inline int interpreter_frame_cinterpreterstate_size_in_bytes();407408// Additional interface for entry frames:409inline entry_frame_locals* get_entry_frame_locals() const {410return (entry_frame_locals*) (((address) fp()) - entry_frame_locals_size);411}412413enum {414// normal return address is 1 bundle past PC415pc_return_offset = 0416};417418static jint interpreter_frame_expression_stack_direction() { return -1; }419420// returns the sending frame, without applying any barriers421frame sender_raw(RegisterMap* map) const;422423#endif // CPU_PPC_FRAME_PPC_HPP424425426