annotate src/hotspot/share/c1/c1_FrameMap.hpp @ 49945:d7df2dd501ce

8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files Summary: Remove frame.inline.hpp,etc from header files and adjust transitive includes. Reviewed-by: stefank, stuefe
author coleenp
date Wed, 21 Mar 2018 19:45:24 -0400
parents 71c04702a3d5
children 9807daeb47c4
rev   line source
duke@1 1 /*
coleenp@49945 2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #ifndef SHARE_VM_C1_C1_FRAMEMAP_HPP
stefank@7397 26 #define SHARE_VM_C1_C1_FRAMEMAP_HPP
stefank@7397 27
coleenp@49945 28 #include "asm/macroAssembler.hpp"
stefank@7397 29 #include "c1/c1_Defs.hpp"
stefank@7397 30 #include "c1/c1_LIR.hpp"
stefank@7397 31 #include "code/vmreg.hpp"
stefank@7397 32 #include "memory/allocation.hpp"
stefank@7397 33 #include "runtime/frame.hpp"
stefank@7397 34 #include "runtime/synchronizer.hpp"
stefank@7397 35 #include "utilities/globalDefinitions.hpp"
goetz@40010 36 #include "utilities/macros.hpp"
stefank@7397 37
duke@1 38 class ciMethod;
duke@1 39 class CallingConvention;
duke@1 40
duke@1 41 //--------------------------------------------------------
duke@1 42 // FrameMap
duke@1 43 //--------------------------------------------------------
duke@1 44
duke@1 45 // This class is responsible of mapping items (locals, monitors, spill
duke@1 46 // slots and registers to their frame location
duke@1 47 //
duke@1 48 // The monitors are specified by a consecutive index, although each monitor entry
duke@1 49 // occupies two words. The monitor_index is 0.._num_monitors
duke@1 50 // The spill index is similar to local index; it is in range 0..(open)
duke@1 51 //
duke@1 52 // The CPU registers are mapped using a fixed table; register with number 0
duke@1 53 // is the most used one.
duke@1 54
duke@1 55
duke@1 56 // stack grow direction --> SP
duke@1 57 // +----------+---+----------+-------+------------------------+-----+
duke@1 58 // |arguments | x | monitors | spill | reserved argument area | ABI |
duke@1 59 // +----------+---+----------+-------+------------------------+-----+
duke@1 60 //
duke@1 61 // x = ABI area (SPARC) or return adress and link (i486)
duke@1 62 // ABI = ABI area (SPARC) or nothing (i486)
duke@1 63
duke@1 64
duke@1 65 class LIR_OprDesc;
duke@1 66 typedef LIR_OprDesc* LIR_Opr;
duke@1 67
duke@1 68
duke@1 69 class FrameMap : public CompilationResourceObj {
duke@1 70 public:
duke@1 71 enum {
duke@1 72 nof_cpu_regs = pd_nof_cpu_regs_frame_map,
duke@1 73 nof_fpu_regs = pd_nof_fpu_regs_frame_map,
duke@1 74
duke@1 75 nof_cpu_regs_reg_alloc = pd_nof_cpu_regs_reg_alloc,
duke@1 76 nof_fpu_regs_reg_alloc = pd_nof_fpu_regs_reg_alloc,
duke@1 77
iveresov@7427 78 max_nof_caller_save_cpu_regs = pd_nof_caller_save_cpu_regs_frame_map,
iveresov@7427 79 nof_caller_save_fpu_regs = pd_nof_caller_save_fpu_regs_frame_map,
duke@1 80
duke@1 81 spill_slot_size_in_bytes = 4
duke@1 82 };
duke@1 83
goetz@40010 84 #include CPU_HEADER(c1_FrameMap)
duke@1 85
duke@1 86 friend class LIR_OprDesc;
duke@1 87
duke@1 88 private:
duke@1 89 static bool _init_done;
duke@1 90 static Register _cpu_rnr2reg [nof_cpu_regs];
duke@1 91 static int _cpu_reg2rnr [nof_cpu_regs];
duke@1 92
iveresov@7427 93 static LIR_Opr _caller_save_cpu_regs [max_nof_caller_save_cpu_regs];
duke@1 94 static LIR_Opr _caller_save_fpu_regs [nof_caller_save_fpu_regs];
duke@1 95
duke@1 96 int _framesize;
duke@1 97 int _argcount;
duke@1 98 int _num_monitors;
duke@1 99 int _num_spills;
duke@1 100 int _reserved_argument_area_size;
duke@1 101 int _oop_map_arg_count;
duke@1 102
duke@1 103 CallingConvention* _incoming_arguments;
duke@1 104 intArray* _argument_locations;
duke@1 105
duke@1 106 void check_spill_index (int spill_index) const { assert(spill_index >= 0, "bad index"); }
duke@1 107 void check_monitor_index (int monitor_index) const { assert(monitor_index >= 0 &&
duke@1 108 monitor_index < _num_monitors, "bad index"); }
duke@1 109
duke@1 110 static Register cpu_rnr2reg (int rnr) {
duke@1 111 assert(_init_done, "tables not initialized");
duke@1 112 debug_only(cpu_range_check(rnr);)
duke@1 113 return _cpu_rnr2reg[rnr];
duke@1 114 }
duke@1 115
duke@1 116 static int cpu_reg2rnr (Register reg) {
duke@1 117 assert(_init_done, "tables not initialized");
duke@1 118 debug_only(cpu_range_check(reg->encoding());)
duke@1 119 return _cpu_reg2rnr[reg->encoding()];
duke@1 120 }
duke@1 121
duke@1 122 static void map_register(int rnr, Register reg) {
duke@1 123 debug_only(cpu_range_check(rnr);)
duke@1 124 debug_only(cpu_range_check(reg->encoding());)
duke@1 125 _cpu_rnr2reg[rnr] = reg;
duke@1 126 _cpu_reg2rnr[reg->encoding()] = rnr;
duke@1 127 }
duke@1 128
duke@1 129 void update_reserved_argument_area_size (int size) {
duke@1 130 assert(size >= 0, "check");
duke@1 131 _reserved_argument_area_size = MAX2(_reserved_argument_area_size, size);
duke@1 132 }
duke@1 133
duke@1 134 protected:
duke@1 135 #ifndef PRODUCT
duke@1 136 static void cpu_range_check (int rnr) { assert(0 <= rnr && rnr < nof_cpu_regs, "cpu register number is too big"); }
duke@1 137 static void fpu_range_check (int rnr) { assert(0 <= rnr && rnr < nof_fpu_regs, "fpu register number is too big"); }
duke@1 138 #endif
duke@1 139
duke@1 140
duke@1 141 ByteSize sp_offset_for_monitor_base(const int idx) const;
duke@1 142
duke@1 143 Address make_new_address(ByteSize sp_offset) const;
duke@1 144
duke@1 145 ByteSize sp_offset_for_slot(const int idx) const;
duke@1 146 ByteSize sp_offset_for_double_slot(const int idx) const;
duke@1 147 ByteSize sp_offset_for_spill(const int idx) const;
duke@1 148 ByteSize sp_offset_for_monitor_lock(int monitor_index) const;
duke@1 149 ByteSize sp_offset_for_monitor_object(int monitor_index) const;
duke@1 150
duke@1 151 VMReg sp_offset2vmreg(ByteSize offset) const;
duke@1 152
duke@1 153 // platform dependent hook used to check that frame is properly
duke@1 154 // addressable on the platform. Used by sparc to verify that all
duke@1 155 // stack addresses are expressable in a simm13.
duke@1 156 bool validate_frame();
duke@1 157
duke@1 158 static LIR_Opr map_to_opr(BasicType type, VMRegPair* reg, bool incoming);
duke@1 159
duke@1 160 public:
duke@1 161 // Opr representing the stack_pointer on this platform
duke@1 162 static LIR_Opr stack_pointer();
duke@1 163
twisti@5687 164 // JSR 292
twisti@5687 165 static LIR_Opr method_handle_invoke_SP_save_opr();
twisti@5687 166
duke@1 167 static BasicTypeArray* signature_type_array_for(const ciMethod* method);
duke@1 168
duke@1 169 // for outgoing calls, these also update the reserved area to
duke@1 170 // include space for arguments and any ABI area.
twisti@13391 171 CallingConvention* c_calling_convention(const BasicTypeArray* signature);
twisti@13391 172 CallingConvention* java_calling_convention(const BasicTypeArray* signature, bool outgoing);
duke@1 173
duke@1 174 // deopt support
duke@1 175 ByteSize sp_offset_for_orig_pc() { return sp_offset_for_monitor_base(_num_monitors); }
duke@1 176
duke@1 177 static LIR_Opr as_opr(Register r) {
duke@1 178 return LIR_OprFact::single_cpu(cpu_reg2rnr(r));
duke@1 179 }
duke@1 180 static LIR_Opr as_oop_opr(Register r) {
duke@1 181 return LIR_OprFact::single_cpu_oop(cpu_reg2rnr(r));
duke@1 182 }
duke@1 183
roland@13742 184 static LIR_Opr as_metadata_opr(Register r) {
roland@13742 185 return LIR_OprFact::single_cpu_metadata(cpu_reg2rnr(r));
roland@13742 186 }
roland@13742 187
duke@1 188 FrameMap(ciMethod* method, int monitors, int reserved_argument_area_size);
duke@1 189 bool finalize_frame(int nof_slots);
duke@1 190
duke@1 191 int reserved_argument_area_size () const { return _reserved_argument_area_size; }
duke@1 192 int framesize () const { assert(_framesize != -1, "hasn't been calculated"); return _framesize; }
duke@1 193 ByteSize framesize_in_bytes () const { return in_ByteSize(framesize() * 4); }
duke@1 194 int num_monitors () const { return _num_monitors; }
duke@1 195 int num_spills () const { assert(_num_spills >= 0, "not set"); return _num_spills; }
duke@1 196 int argcount () const { assert(_argcount >= 0, "not set"); return _argcount; }
duke@1 197
duke@1 198 int oop_map_arg_count() const { return _oop_map_arg_count; }
duke@1 199
duke@1 200 CallingConvention* incoming_arguments() const { return _incoming_arguments; }
duke@1 201
duke@1 202 // convenience routines
duke@1 203 Address address_for_slot(int index, int sp_adjust = 0) const {
duke@1 204 return make_new_address(sp_offset_for_slot(index) + in_ByteSize(sp_adjust));
duke@1 205 }
duke@1 206 Address address_for_double_slot(int index, int sp_adjust = 0) const {
duke@1 207 return make_new_address(sp_offset_for_double_slot(index) + in_ByteSize(sp_adjust));
duke@1 208 }
duke@1 209 Address address_for_monitor_lock(int monitor_index) const {
duke@1 210 return make_new_address(sp_offset_for_monitor_lock(monitor_index));
duke@1 211 }
duke@1 212 Address address_for_monitor_object(int monitor_index) const {
duke@1 213 return make_new_address(sp_offset_for_monitor_object(monitor_index));
duke@1 214 }
duke@1 215
duke@1 216 // Creates Location describing desired slot and returns it via pointer
duke@1 217 // to Location object. Returns true if the stack frame offset was legal
duke@1 218 // (as defined by Location::legal_offset_in_bytes()), false otherwise.
duke@1 219 // Do not use the returned location if this returns false.
duke@1 220 bool location_for_sp_offset(ByteSize byte_offset_from_sp,
duke@1 221 Location::Type loc_type, Location* loc) const;
duke@1 222
duke@1 223 bool location_for_monitor_lock (int monitor_index, Location* loc) const {
duke@1 224 return location_for_sp_offset(sp_offset_for_monitor_lock(monitor_index), Location::normal, loc);
duke@1 225 }
duke@1 226 bool location_for_monitor_object(int monitor_index, Location* loc) const {
duke@1 227 return location_for_sp_offset(sp_offset_for_monitor_object(monitor_index), Location::oop, loc);
duke@1 228 }
duke@1 229 bool locations_for_slot (int index, Location::Type loc_type,
duke@1 230 Location* loc, Location* second = NULL) const;
duke@1 231
duke@1 232 VMReg slot_regname(int index) const {
duke@1 233 return sp_offset2vmreg(sp_offset_for_slot(index));
duke@1 234 }
duke@1 235 VMReg monitor_object_regname(int monitor_index) const {
duke@1 236 return sp_offset2vmreg(sp_offset_for_monitor_object(monitor_index));
duke@1 237 }
duke@1 238 VMReg regname(LIR_Opr opr) const;
duke@1 239
duke@1 240 static LIR_Opr caller_save_cpu_reg_at(int i) {
iveresov@7427 241 assert(i >= 0 && i < max_nof_caller_save_cpu_regs, "out of bounds");
duke@1 242 return _caller_save_cpu_regs[i];
duke@1 243 }
duke@1 244
duke@1 245 static LIR_Opr caller_save_fpu_reg_at(int i) {
duke@1 246 assert(i >= 0 && i < nof_caller_save_fpu_regs, "out of bounds");
duke@1 247 return _caller_save_fpu_regs[i];
duke@1 248 }
duke@1 249
iveresov@5707 250 static void initialize();
duke@1 251 };
duke@1 252
duke@1 253 // CallingConvention
duke@1 254 //--------------------------------------------------------
duke@1 255
duke@1 256 class CallingConvention: public ResourceObj {
duke@1 257 private:
duke@1 258 LIR_OprList* _args;
duke@1 259 int _reserved_stack_slots;
duke@1 260
duke@1 261 public:
duke@1 262 CallingConvention (LIR_OprList* args, int reserved_stack_slots)
duke@1 263 : _args(args)
duke@1 264 , _reserved_stack_slots(reserved_stack_slots) {}
duke@1 265
duke@1 266 LIR_OprList* args() { return _args; }
duke@1 267
duke@1 268 LIR_Opr at(int i) const { return _args->at(i); }
duke@1 269 int length() const { return _args->length(); }
duke@1 270
duke@1 271 // Indicates number of real frame slots used by arguments passed on stack.
duke@1 272 int reserved_stack_slots() const { return _reserved_stack_slots; }
duke@1 273
duke@1 274 #ifndef PRODUCT
duke@1 275 void print () const {
duke@1 276 for (int i = 0; i < length(); i++) {
duke@1 277 at(i)->print();
duke@1 278 }
duke@1 279 }
duke@1 280 #endif // PRODUCT
duke@1 281 };
stefank@7397 282
stefank@7397 283 #endif // SHARE_VM_C1_C1_FRAMEMAP_HPP