src/share/vm/code/vmreg.hpp

Tue, 09 Oct 2012 10:09:34 -0700

author
mikael
date
Tue, 09 Oct 2012 10:09:34 -0700
changeset 4153
b9a9ed0f8eeb
parent 3929
2c368ea3e844
child 4323
f0c2369fda5a
permissions
-rw-r--r--

7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp

duke@435 1 /*
mikael@4153 2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CODE_VMREG_HPP
stefank@2314 26 #define SHARE_VM_CODE_VMREG_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "utilities/globalDefinitions.hpp"
stefank@2314 30 #ifdef TARGET_ARCH_x86
stefank@2314 31 # include "register_x86.hpp"
stefank@2314 32 #endif
stefank@2314 33 #ifdef TARGET_ARCH_sparc
stefank@2314 34 # include "register_sparc.hpp"
stefank@2314 35 #endif
stefank@2314 36 #ifdef TARGET_ARCH_zero
stefank@2314 37 # include "register_zero.hpp"
stefank@2314 38 #endif
bobv@2508 39 #ifdef TARGET_ARCH_arm
bobv@2508 40 # include "register_arm.hpp"
bobv@2508 41 #endif
bobv@2508 42 #ifdef TARGET_ARCH_ppc
bobv@2508 43 # include "register_ppc.hpp"
bobv@2508 44 #endif
stefank@2314 45 #ifdef COMPILER2
stefank@2314 46 #include "opto/adlcVMDeps.hpp"
stefank@2314 47 #include "utilities/ostream.hpp"
stefank@2314 48 #ifdef TARGET_ARCH_MODEL_x86_32
stefank@2314 49 # include "adfiles/adGlobals_x86_32.hpp"
stefank@2314 50 #endif
stefank@2314 51 #ifdef TARGET_ARCH_MODEL_x86_64
stefank@2314 52 # include "adfiles/adGlobals_x86_64.hpp"
stefank@2314 53 #endif
stefank@2314 54 #ifdef TARGET_ARCH_MODEL_sparc
stefank@2314 55 # include "adfiles/adGlobals_sparc.hpp"
stefank@2314 56 #endif
stefank@2314 57 #ifdef TARGET_ARCH_MODEL_zero
stefank@2314 58 # include "adfiles/adGlobals_zero.hpp"
stefank@2314 59 #endif
bobv@2508 60 #ifdef TARGET_ARCH_MODEL_arm
bobv@2508 61 # include "adfiles/adGlobals_arm.hpp"
bobv@2508 62 #endif
bobv@2508 63 #ifdef TARGET_ARCH_MODEL_ppc
bobv@2508 64 # include "adfiles/adGlobals_ppc.hpp"
bobv@2508 65 #endif
stefank@2314 66 #endif
stefank@2314 67
duke@435 68 //------------------------------VMReg------------------------------------------
duke@435 69 // The VM uses 'unwarped' stack slots; the compiler uses 'warped' stack slots.
duke@435 70 // Register numbers below VMRegImpl::stack0 are the same for both. Register
duke@435 71 // numbers above stack0 are either warped (in the compiler) or unwarped
duke@435 72 // (in the VM). Unwarped numbers represent stack indices, offsets from
duke@435 73 // the current stack pointer. Warped numbers are required during compilation
duke@435 74 // when we do not yet know how big the frame will be.
duke@435 75
duke@435 76 class VMRegImpl;
duke@435 77 typedef VMRegImpl* VMReg;
duke@435 78
duke@435 79 class VMRegImpl {
duke@435 80 // friend class OopMap;
duke@435 81 friend class VMStructs;
duke@435 82 friend class OptoReg;
duke@435 83 // friend class Location;
duke@435 84 private:
duke@435 85 enum {
duke@435 86 BAD = -1
duke@435 87 };
duke@435 88
duke@435 89
duke@435 90
duke@435 91 static VMReg stack0;
duke@435 92 // Names for registers
duke@435 93 static const char *regName[];
duke@435 94 static const int register_count;
duke@435 95
duke@435 96
duke@435 97 public:
duke@435 98
duke@435 99 static VMReg as_VMReg(int val, bool bad_ok = false) { assert(val > BAD || bad_ok, "invalid"); return (VMReg) (intptr_t) val; }
duke@435 100
duke@435 101 const char* name() {
duke@435 102 if (is_reg()) {
duke@435 103 return regName[value()];
duke@435 104 } else if (!is_valid()) {
duke@435 105 return "BAD";
duke@435 106 } else {
duke@435 107 // shouldn't really be called with stack
duke@435 108 return "STACKED REG";
duke@435 109 }
duke@435 110 }
duke@435 111 static VMReg Bad() { return (VMReg) (intptr_t) BAD; }
kvn@460 112 bool is_valid() const { return ((intptr_t) this) != BAD; }
kvn@460 113 bool is_stack() const { return (intptr_t) this >= (intptr_t) stack0; }
kvn@460 114 bool is_reg() const { return is_valid() && !is_stack(); }
duke@435 115
duke@435 116 // A concrete register is a value that returns true for is_reg() and is
duke@435 117 // also a register you could use in the assembler. On machines with
duke@435 118 // 64bit registers only one half of the VMReg (and OptoReg) is considered
duke@435 119 // concrete.
duke@435 120 bool is_concrete();
duke@435 121
duke@435 122 // VMRegs are 4 bytes wide on all platforms
duke@435 123 static const int stack_slot_size;
duke@435 124 static const int slots_per_word;
duke@435 125
duke@435 126
duke@435 127 // This really ought to check that the register is "real" in the sense that
duke@435 128 // we don't try and get the VMReg number of a physical register that doesn't
duke@435 129 // have an expressible part. That would be pd specific code
duke@435 130 VMReg next() {
duke@435 131 assert((is_reg() && value() < stack0->value() - 1) || is_stack(), "must be");
duke@435 132 return (VMReg)(intptr_t)(value() + 1);
duke@435 133 }
kvn@3929 134 VMReg next(int i) {
kvn@3929 135 assert((is_reg() && value() < stack0->value() - i) || is_stack(), "must be");
kvn@3929 136 return (VMReg)(intptr_t)(value() + i);
kvn@3929 137 }
duke@435 138 VMReg prev() {
duke@435 139 assert((is_stack() && value() > stack0->value()) || (is_reg() && value() != 0), "must be");
duke@435 140 return (VMReg)(intptr_t)(value() - 1);
duke@435 141 }
duke@435 142
duke@435 143
duke@435 144 intptr_t value() const {return (intptr_t) this; }
duke@435 145
jrose@535 146 void print_on(outputStream* st) const;
kvn@460 147 void print() const { print_on(tty); }
duke@435 148
duke@435 149 // bias a stack slot.
duke@435 150 // Typically used to adjust a virtual frame slots by amounts that are offset by
duke@435 151 // amounts that are part of the native abi. The VMReg must be a stack slot
duke@435 152 // and the result must be also.
duke@435 153
duke@435 154 VMReg bias(int offset) {
duke@435 155 assert(is_stack(), "must be");
duke@435 156 // VMReg res = VMRegImpl::as_VMReg(value() + offset);
duke@435 157 VMReg res = stack2reg(reg2stack() + offset);
duke@435 158 assert(res->is_stack(), "must be");
duke@435 159 return res;
duke@435 160 }
duke@435 161
duke@435 162 // Convert register numbers to stack slots and vice versa
duke@435 163 static VMReg stack2reg( int idx ) {
duke@435 164 return (VMReg) (intptr_t) (stack0->value() + idx);
duke@435 165 }
duke@435 166
duke@435 167 uintptr_t reg2stack() {
duke@435 168 assert( is_stack(), "Not a stack-based register" );
duke@435 169 return value() - stack0->value();
duke@435 170 }
duke@435 171
duke@435 172 static void set_regName();
duke@435 173
stefank@2314 174 #ifdef TARGET_ARCH_x86
stefank@2314 175 # include "vmreg_x86.hpp"
stefank@2314 176 #endif
stefank@2314 177 #ifdef TARGET_ARCH_sparc
stefank@2314 178 # include "vmreg_sparc.hpp"
stefank@2314 179 #endif
stefank@2314 180 #ifdef TARGET_ARCH_zero
stefank@2314 181 # include "vmreg_zero.hpp"
stefank@2314 182 #endif
bobv@2508 183 #ifdef TARGET_ARCH_arm
bobv@2508 184 # include "vmreg_arm.hpp"
bobv@2508 185 #endif
bobv@2508 186 #ifdef TARGET_ARCH_ppc
bobv@2508 187 # include "vmreg_ppc.hpp"
bobv@2508 188 #endif
stefank@2314 189
duke@435 190
duke@435 191 };
duke@435 192
duke@435 193 //---------------------------VMRegPair-------------------------------------------
duke@435 194 // Pairs of 32-bit registers for arguments.
duke@435 195 // SharedRuntime::java_calling_convention will overwrite the structs with
duke@435 196 // the calling convention's registers. VMRegImpl::Bad is returned for any
duke@435 197 // unused 32-bit register. This happens for the unused high half of Int
duke@435 198 // arguments, or for 32-bit pointers or for longs in the 32-bit sparc build
duke@435 199 // (which are passed to natives in low 32-bits of e.g. O0/O1 and the high
duke@435 200 // 32-bits of O0/O1 are set to VMRegImpl::Bad). Longs in one register & doubles
duke@435 201 // always return a high and a low register, as do 64-bit pointers.
duke@435 202 //
duke@435 203 class VMRegPair {
duke@435 204 private:
duke@435 205 VMReg _second;
duke@435 206 VMReg _first;
duke@435 207 public:
duke@435 208 void set_bad ( ) { _second=VMRegImpl::Bad(); _first=VMRegImpl::Bad(); }
duke@435 209 void set1 ( VMReg v ) { _second=VMRegImpl::Bad(); _first=v; }
duke@435 210 void set2 ( VMReg v ) { _second=v->next(); _first=v; }
duke@435 211 void set_pair( VMReg second, VMReg first ) { _second= second; _first= first; }
duke@435 212 void set_ptr ( VMReg ptr ) {
duke@435 213 #ifdef _LP64
duke@435 214 _second = ptr->next();
duke@435 215 #else
duke@435 216 _second = VMRegImpl::Bad();
duke@435 217 #endif
duke@435 218 _first = ptr;
duke@435 219 }
duke@435 220 // Return true if single register, even if the pair is really just adjacent stack slots
jrose@535 221 bool is_single_reg() const {
duke@435 222 return (_first->is_valid()) && (_first->value() + 1 == _second->value());
duke@435 223 }
duke@435 224
duke@435 225 // Return true if single stack based "register" where the slot alignment matches input alignment
jrose@535 226 bool is_adjacent_on_stack(int alignment) const {
duke@435 227 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
duke@435 228 }
duke@435 229
duke@435 230 // Return true if single stack based "register" where the slot alignment matches input alignment
jrose@535 231 bool is_adjacent_aligned_on_stack(int alignment) const {
duke@435 232 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
duke@435 233 }
duke@435 234
duke@435 235 // Return true if single register but adjacent stack slots do not count
jrose@535 236 bool is_single_phys_reg() const {
duke@435 237 return (_first->is_reg() && (_first->value() + 1 == _second->value()));
duke@435 238 }
duke@435 239
duke@435 240 VMReg second() const { return _second; }
duke@435 241 VMReg first() const { return _first; }
duke@435 242 VMRegPair(VMReg s, VMReg f) { _second = s; _first = f; }
duke@435 243 VMRegPair(VMReg f) { _second = VMRegImpl::Bad(); _first = f; }
duke@435 244 VMRegPair() { _second = VMRegImpl::Bad(); _first = VMRegImpl::Bad(); }
duke@435 245 };
stefank@2314 246
stefank@2314 247 #endif // SHARE_VM_CODE_VMREG_HPP

mercurial