Path: blob/master/src/hotspot/cpu/s390/frame_s390.hpp
40930 views
/*1* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2016 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// Major contributions by ML, AHa.2627#ifndef CPU_S390_FRAME_S390_HPP28#define CPU_S390_FRAME_S390_HPP2930#include "runtime/synchronizer.hpp"3132// C frame layout on ZARCH_64.33//34// In this figure the stack grows upwards, while memory grows35// downwards. See "Linux for zSeries: ELF Application Binary Interface Supplement",36// IBM Corp. (LINUX-1107-01)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 8 = 0)43// [C_FRAME] <-- SP before prolog44// ...45// [C_FRAME]46//47// C_FRAME:48// 0 [ABI_160]49//50// ABI_160:51// 0 [ABI_16]52// 16 CARG_1: spill slot for outgoing arg 1. used by next callee.53// 24 CARG_2: spill slot for outgoing arg 2. used by next callee.54// 32 CARG_3: spill slot for outgoing arg 3. used by next callee.55// 40 CARG_4: spill slot for outgoing arg 4. used by next callee.56// 48 GPR_6: spill slot for GPR_6. used by next callee.57// ... ...58// 120 GPR_15: spill slot for GPR_15. used by next callee.59// 128 CFARG_1: spill slot for outgoing fp arg 1. used by next callee.60// 136 CFARG_2: spill slot for outgoing fp arg 2. used by next callee.61// 144 CFARG_3: spill slot for outgoing fp arg 3. used by next callee.62// 152 CFARG_4: spill slot for outgoing fp arg 4. used by next callee.63// 160 [REMAINING CARGS]64//65// ABI_16:66// 0 callers_sp67// 8 return_pc6869public:7071// C frame layout7273typedef enum {74// stack alignment75alignment_in_bytes = 8,76// log_2(8*8 bits) = 6.77log_2_of_alignment_in_bits = 678} frame_constants;7980struct z_abi_16 {81uint64_t callers_sp;82uint64_t return_pc;83};8485enum {86z_abi_16_size = sizeof(z_abi_16)87};8889#define _z_abi16(_component) \90(offset_of(frame::z_abi_16, _component))9192// ABI_160:9394// REMARK: This structure should reflect the "minimal" ABI frame95// layout, but it doesn't. There is an extra field at the end of the96// structure that marks the area where arguments are passed, when97// the argument registers "overflow". Thus, sizeof(z_abi_160)98// doesn't yield the expected (and desired) result. Therefore, as99// long as we do not provide extra infrastructure, one should use100// either z_abi_160_size, or _z_abi(remaining_cargs) instead of101// sizeof(...).102struct z_abi_160 {103uint64_t callers_sp;104uint64_t return_pc;105uint64_t carg_1;106uint64_t carg_2;107uint64_t carg_3;108uint64_t carg_4;109uint64_t gpr6;110uint64_t gpr7;111uint64_t gpr8;112uint64_t gpr9;113uint64_t gpr10;114uint64_t gpr11;115uint64_t gpr12;116uint64_t gpr13;117uint64_t gpr14;118uint64_t gpr15;119uint64_t cfarg_1;120uint64_t cfarg_2;121uint64_t cfarg_3;122uint64_t cfarg_4;123uint64_t remaining_cargs;124};125126enum {127z_abi_160_size = 160128};129130#define _z_abi(_component) \131(offset_of(frame::z_abi_160, _component))132133struct z_abi_160_spill : z_abi_160 {134// Additional spill slots. Use as 'offset_of(z_abi_160_spill, spill[n])'.135uint64_t spill[0];136// Aligned to frame::alignment_in_bytes (16).137};138139140// non-volatile GPRs:141142struct z_spill_nonvolatiles {143uint64_t r6;144uint64_t r7;145uint64_t r8;146uint64_t r9;147uint64_t r10;148uint64_t r11;149uint64_t r12;150uint64_t r13;151};152153enum {154z_spill_nonvolatiles_size = sizeof(z_spill_nonvolatiles)155};156157#define _z_spill_nonvolatiles_neg(_component) \158(-frame::z_spill_nonvolatiles_size + offset_of(frame::z_spill_nonvolatiles, _component))159160// Frame layout for the Java template interpreter on z/Architecture.161//162// In these figures the stack grows upwards, while memory grows163// downwards. Square brackets denote regions possibly larger than164// single 64 bit slots.165//166// STACK (no JNI, no compiled code, no library calls, template interpreter is active):167//168// 0 [TOP_IJAVA_FRAME]169// [PARENT_IJAVA_FRAME]170// [PARENT_IJAVA_FRAME]171// ...172// [PARENT_IJAVA_FRAME]173// [ENTRY_FRAME]174// [C_FRAME]175// ...176// [C_FRAME]177//178// TOP_IJAVA_FRAME:179//180// 0 [TOP_IJAVA_FRAME_ABI]181// 16 [operand stack]182// [monitors] (optional)183// [IJAVA_STATE]184// note: Own locals are located in the caller frame.185//186// PARENT_IJAVA_FRAME:187//188// 0 [PARENT_IJAVA_FRAME_ABI]189// [callee's locals w/o arguments]190// [outgoing arguments]191// [used part of operand stack w/o arguments]192// [monitors] (optional)193// [IJAVA_STATE]194//195// ENTRY_FRAME:196//197// 0 [PARENT_IJAVA_FRAME_ABI]198// [callee's locals w/o arguments]199// [outgoing arguments]200// [ENTRY_FRAME_LOCALS]201//202// TOP_IJAVA_FRAME_ABI:203//204// 0 [ABI_160]205//206//207// PARENT_IJAVA_FRAME_ABI:208//209// 0 [ABI_16]210//211// IJAVA_STATE:212//213// 0 method214// 8 locals215// monitors : monitor block top (i.e. lowest address)216// cpoolCache217// bcp218// mdx219// esp : Points to first slot above operands.220// sender_sp : See comment in z_ijava_state.221// top_frame_sp : Own SP before modification by i2c adapter.222// oop_tmp223// lresult224// fresult225//226// EXAMPLE:227// ---------228//229// 3 monitors, 5 operand stack slots max. / 3 allocated230//231// F0 callers_sp <- Z_SP (callers_sp == Z_fp (own fp))232// return_pc233// [rest of ABI_160]234// /slot 4: free235// oper. | slot 3: free <- Z_esp points to first free slot236// stack | slot 2: ref val v2 caches IJAVA_STATE.esp237// | slot 1: unused238// \slot 0: long val v1239// /slot 5 <- IJAVA_STATE.monitors = monitor block top240// | slot 4241// monitors| slot 3242// | slot 2243// | slot 1244// \slot 0245// [IJAVA_STATE] <- monitor block bot (points to first byte in IJAVA_STATE)246// F1 [PARENT_IJAVA_FRAME_ABI] <- Z_fp (== *Z_SP, points to slot just below IJAVA_STATE)247// [F0's locals] <- Z_locals, locals[i] := *(Z_locals - i*BytesPerWord)248// [F1's operand stack]249// [F1's monitors] (optional)250// [IJAVA_STATE]251252public:253254// PARENT_IJAVA_FRAME_ABI255256struct z_parent_ijava_frame_abi : z_abi_16 {257};258259enum {260z_parent_ijava_frame_abi_size = sizeof(z_parent_ijava_frame_abi)261};262263#define _z_parent_ijava_frame_abi(_component) \264(offset_of(frame::z_parent_ijava_frame_abi, _component))265266// TOP_IJAVA_FRAME_ABI267268struct z_top_ijava_frame_abi : z_abi_160 {269};270271enum {272z_top_ijava_frame_abi_size = sizeof(z_top_ijava_frame_abi)273};274275#define _z_top_ijava_frame_abi(_component) \276(offset_of(frame::z_top_ijava_frame_abi, _component))277278// IJAVA_STATE279280struct z_ijava_state{281DEBUG_ONLY(uint64_t magic;) // wrong magic -> wrong state!282uint64_t method;283uint64_t mirror;284uint64_t locals; // Z_locals285uint64_t monitors;286uint64_t cpoolCache;287uint64_t bcp; // Z_bcp288uint64_t mdx;289uint64_t esp; // Z_esp290// Caller's original SP before modification by c2i adapter (if caller is compiled)291// and before top -> parent frame conversion by the interpreter entry.292// Note: for i2i calls a correct sender_sp is required, too, because there293// we cannot use the caller's top_frame_sp as sp when removing the callee294// frame (caller could be compiled or entry frame). Therefore the sender_sp295// has to be the interpreted caller's sp as TOP_IJAVA_FRAME. See also296// AbstractInterpreter::layout_activation() used by deoptimization.297uint64_t sender_sp;298// Own SP before modification by i2c adapter and top-2-parent-resize299// by interpreted callee.300uint64_t top_frame_sp;301// Slots only needed for native calls. Maybe better to move elsewhere.302uint64_t oop_tmp;303uint64_t lresult;304uint64_t fresult;305};306307enum {308z_ijava_state_size = sizeof(z_ijava_state)309};310311#ifdef ASSERT312enum {313z_istate_magic_number = 0x900d // ~= good magic314};315#endif316317#define _z_ijava_state_neg(_component) \318(int) (-frame::z_ijava_state_size + offset_of(frame::z_ijava_state, _component))319320// ENTRY_FRAME321322struct z_entry_frame_locals {323uint64_t call_wrapper_address;324uint64_t result_address;325uint64_t result_type;326uint64_t arguments_tos_address;327// Callee saved registers are spilled to caller frame.328// Caller must have z_abi_160.329};330331enum {332z_entry_frame_locals_size = sizeof(z_entry_frame_locals)333};334335#define _z_entry_frame_locals_neg(_component) \336(int) (-frame::z_entry_frame_locals_size + offset_of(frame::z_entry_frame_locals, _component))337338// Frame layout for JIT generated methods339//340// In these figures the stack grows upwards, while memory grows341// downwards. Square brackets denote regions possibly larger than single342// 64 bit slots.343//344// STACK (interpreted Java calls JIT generated Java):345//346// [JIT_FRAME] <-- SP (mod 16 = 0)347// [TOP_IJAVA_FRAME]348// ...349//350//351// JIT_FRAME (is a C frame according to z/Architecture ABI):352//353// [out_preserve]354// [out_args]355// [spills]356// [monitor] (optional)357// ...358// [monitor] (optional)359// [in_preserve] added / removed by prolog / epilog360361public:362363struct z_top_jit_abi_32 {364uint64_t callers_sp;365uint64_t return_pc;366uint64_t toc;367uint64_t tmp;368};369370#define _z_top_jit_abi(_component) \371(offset_of(frame::z_top_jit_abi_32, _component))372373struct jit_monitor {374uint64_t monitor[1];375};376377struct jit_in_preserve {378// Used to provide a z/Architecture ABI on top of a jit frame.379// nothing to add here!380};381382struct jit_out_preserve : z_top_jit_abi_32 {383// Nothing to add here!384};385386enum {387z_jit_out_preserve_size = sizeof(jit_out_preserve)388};389390typedef enum {391jit_monitor_size_in_4_byte_units = sizeof(jit_monitor) / 4,392393// Stack alignment requirement. Log_2 of alignment size in bits.394// log_2(16*8 bits) = 7.395jit_log_2_of_stack_alignment_in_bits = 7,396397jit_out_preserve_size_in_4_byte_units = sizeof(jit_out_preserve) / 4,398399jit_in_preserve_size_in_4_byte_units = sizeof(jit_in_preserve) / 4400} jit_frame_constants;401402403// C2I adapter frames:404//405// STACK (interpreted called from compiled, on entry to frame manager):406//407// [TOP_C2I_FRAME]408// [JIT_FRAME]409// ...410//411//412// STACK (interpreted called from compiled, after interpreter has been pushed):413//414// [TOP_IJAVA_FRAME]415// [PARENT_C2I_FRAME]416// [JIT_FRAME]417// ...418//419//420// TOP_C2I_FRAME:421//422// [TOP_IJAVA_FRAME_ABI]423// [outgoing Java arguments]424// alignment (optional)425//426//427// PARENT_C2I_FRAME:428//429// [PARENT_IJAVA_FRAME_ABI]430// alignment (optional)431// [callee's locals w/o arguments]432// [outgoing Java arguments]433// alignment (optional)434435private:436437// STACK:438// ...439// [THIS_FRAME] <-- this._sp (stack pointer for this frame)440// [CALLER_FRAME] <-- this.fp() (_sp of caller's frame)441// ...442//443444// NOTE: Stack pointer is now held in the base class, so remove it from here.445446// Needed by deoptimization.447intptr_t* _unextended_sp;448449// Frame pointer for this frame.450intptr_t* _fp;451452public:453454// Interface for all frames:455456// Accessors457458inline intptr_t* fp() const { return _fp; }459460private:461462inline void find_codeblob_and_set_pc_and_deopt_state(address pc);463464// Constructors465466public:467inline frame(intptr_t* sp);468// To be used, if sp was not extended to match callee's calling convention.469inline frame(intptr_t* sp, address pc);470inline frame(intptr_t* sp, address pc, intptr_t* unextended_sp);471472// Access frame via stack pointer.473inline intptr_t* sp_addr_at(int index) const { return &sp()[index]; }474inline intptr_t sp_at( int index) const { return *sp_addr_at(index); }475476// Access ABIs.477inline z_abi_16* own_abi() const { return (z_abi_16*) sp(); }478inline z_abi_160* callers_abi() const { return (z_abi_160*) fp(); }479480private:481482intptr_t* compiled_sender_sp(CodeBlob* cb) const;483address* compiled_sender_pc_addr(CodeBlob* cb) const;484485address* sender_pc_addr(void) const;486487public:488489// Additional interface for interpreter frames:490static int interpreter_frame_interpreterstate_size_in_bytes();491static int interpreter_frame_monitor_size_in_bytes();492493494// template interpreter state495inline z_ijava_state* ijava_state_unchecked() const;496497private:498499inline z_ijava_state* ijava_state() const;500501// Where z_ijava_state.monitors is saved.502inline BasicObjectLock** interpreter_frame_monitors_addr() const;503// Where z_ijava_state.esp is saved.504inline intptr_t** interpreter_frame_esp_addr() const;505506public:507inline intptr_t* interpreter_frame_top_frame_sp();508inline void interpreter_frame_set_tos_address(intptr_t* x);509inline void interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp);510inline void interpreter_frame_set_sender_sp(intptr_t* sender_sp);511#ifdef ASSERT512inline void interpreter_frame_set_magic();513#endif514515// monitors:516517// Next two functions read and write z_ijava_state.monitors.518private:519inline BasicObjectLock* interpreter_frame_monitors() const;520inline void interpreter_frame_set_monitors(BasicObjectLock* monitors);521522public:523524// Additional interface for entry frames:525inline z_entry_frame_locals* entry_frame_locals() const {526return (z_entry_frame_locals*) (((address) fp()) - z_entry_frame_locals_size);527}528529public:530531// Get caller pc from stack slot of gpr14.532address native_sender_pc() const;533// Get caller pc from stack slot of gpr10.534address callstub_sender_pc() const;535536// Dump all frames starting at a given C stack pointer.537// max_frames: Limit number of traced frames.538// <= 0 --> full trace539// > 0 --> trace the #max_frames topmost frames540static void back_trace(outputStream* st, intptr_t* start_sp, intptr_t* top_pc,541unsigned long flags, int max_frames = 0);542543enum {544// This enum value specifies the offset from the pc remembered by545// call instructions to the location where control returns to546// after a normal return. Most architectures remember the return547// location directly, i.e. the offset is zero. This is the case548// for z/Architecture, too.549//550// Normal return address is the instruction following the branch.551pc_return_offset = 0,552};553554static jint interpreter_frame_expression_stack_direction() { return -1; }555556#endif // CPU_S390_FRAME_S390_HPP557558559