src/share/vm/code/vmreg.hpp

Mon, 25 Jun 2012 21:33:35 -0400

author
coleenp
date
Mon, 25 Jun 2012 21:33:35 -0400
changeset 3875
246d977b51f2
parent 2708
1d1603768966
child 3929
2c368ea3e844
permissions
-rw-r--r--

7178670: runtime/7158800/BadUtf8.java fails in SymbolTable::rehash_table
Summary: Cannot delete _buckets and HashtableEntries in shared space (CDS)
Reviewed-by: acorn, kvn, dlong, dcubed, kamg

duke@435 1 /*
trims@2708 2 * Copyright (c) 1998, 2011, 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 }
duke@435 134 VMReg prev() {
duke@435 135 assert((is_stack() && value() > stack0->value()) || (is_reg() && value() != 0), "must be");
duke@435 136 return (VMReg)(intptr_t)(value() - 1);
duke@435 137 }
duke@435 138
duke@435 139
duke@435 140 intptr_t value() const {return (intptr_t) this; }
duke@435 141
jrose@535 142 void print_on(outputStream* st) const;
kvn@460 143 void print() const { print_on(tty); }
duke@435 144
duke@435 145 // bias a stack slot.
duke@435 146 // Typically used to adjust a virtual frame slots by amounts that are offset by
duke@435 147 // amounts that are part of the native abi. The VMReg must be a stack slot
duke@435 148 // and the result must be also.
duke@435 149
duke@435 150 VMReg bias(int offset) {
duke@435 151 assert(is_stack(), "must be");
duke@435 152 // VMReg res = VMRegImpl::as_VMReg(value() + offset);
duke@435 153 VMReg res = stack2reg(reg2stack() + offset);
duke@435 154 assert(res->is_stack(), "must be");
duke@435 155 return res;
duke@435 156 }
duke@435 157
duke@435 158 // Convert register numbers to stack slots and vice versa
duke@435 159 static VMReg stack2reg( int idx ) {
duke@435 160 return (VMReg) (intptr_t) (stack0->value() + idx);
duke@435 161 }
duke@435 162
duke@435 163 uintptr_t reg2stack() {
duke@435 164 assert( is_stack(), "Not a stack-based register" );
duke@435 165 return value() - stack0->value();
duke@435 166 }
duke@435 167
duke@435 168 static void set_regName();
duke@435 169
stefank@2314 170 #ifdef TARGET_ARCH_x86
stefank@2314 171 # include "vmreg_x86.hpp"
stefank@2314 172 #endif
stefank@2314 173 #ifdef TARGET_ARCH_sparc
stefank@2314 174 # include "vmreg_sparc.hpp"
stefank@2314 175 #endif
stefank@2314 176 #ifdef TARGET_ARCH_zero
stefank@2314 177 # include "vmreg_zero.hpp"
stefank@2314 178 #endif
bobv@2508 179 #ifdef TARGET_ARCH_arm
bobv@2508 180 # include "vmreg_arm.hpp"
bobv@2508 181 #endif
bobv@2508 182 #ifdef TARGET_ARCH_ppc
bobv@2508 183 # include "vmreg_ppc.hpp"
bobv@2508 184 #endif
stefank@2314 185
duke@435 186
duke@435 187 };
duke@435 188
duke@435 189 //---------------------------VMRegPair-------------------------------------------
duke@435 190 // Pairs of 32-bit registers for arguments.
duke@435 191 // SharedRuntime::java_calling_convention will overwrite the structs with
duke@435 192 // the calling convention's registers. VMRegImpl::Bad is returned for any
duke@435 193 // unused 32-bit register. This happens for the unused high half of Int
duke@435 194 // arguments, or for 32-bit pointers or for longs in the 32-bit sparc build
duke@435 195 // (which are passed to natives in low 32-bits of e.g. O0/O1 and the high
duke@435 196 // 32-bits of O0/O1 are set to VMRegImpl::Bad). Longs in one register & doubles
duke@435 197 // always return a high and a low register, as do 64-bit pointers.
duke@435 198 //
duke@435 199 class VMRegPair {
duke@435 200 private:
duke@435 201 VMReg _second;
duke@435 202 VMReg _first;
duke@435 203 public:
duke@435 204 void set_bad ( ) { _second=VMRegImpl::Bad(); _first=VMRegImpl::Bad(); }
duke@435 205 void set1 ( VMReg v ) { _second=VMRegImpl::Bad(); _first=v; }
duke@435 206 void set2 ( VMReg v ) { _second=v->next(); _first=v; }
duke@435 207 void set_pair( VMReg second, VMReg first ) { _second= second; _first= first; }
duke@435 208 void set_ptr ( VMReg ptr ) {
duke@435 209 #ifdef _LP64
duke@435 210 _second = ptr->next();
duke@435 211 #else
duke@435 212 _second = VMRegImpl::Bad();
duke@435 213 #endif
duke@435 214 _first = ptr;
duke@435 215 }
duke@435 216 // Return true if single register, even if the pair is really just adjacent stack slots
jrose@535 217 bool is_single_reg() const {
duke@435 218 return (_first->is_valid()) && (_first->value() + 1 == _second->value());
duke@435 219 }
duke@435 220
duke@435 221 // Return true if single stack based "register" where the slot alignment matches input alignment
jrose@535 222 bool is_adjacent_on_stack(int alignment) const {
duke@435 223 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
duke@435 224 }
duke@435 225
duke@435 226 // Return true if single stack based "register" where the slot alignment matches input alignment
jrose@535 227 bool is_adjacent_aligned_on_stack(int alignment) const {
duke@435 228 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
duke@435 229 }
duke@435 230
duke@435 231 // Return true if single register but adjacent stack slots do not count
jrose@535 232 bool is_single_phys_reg() const {
duke@435 233 return (_first->is_reg() && (_first->value() + 1 == _second->value()));
duke@435 234 }
duke@435 235
duke@435 236 VMReg second() const { return _second; }
duke@435 237 VMReg first() const { return _first; }
duke@435 238 VMRegPair(VMReg s, VMReg f) { _second = s; _first = f; }
duke@435 239 VMRegPair(VMReg f) { _second = VMRegImpl::Bad(); _first = f; }
duke@435 240 VMRegPair() { _second = VMRegImpl::Bad(); _first = VMRegImpl::Bad(); }
duke@435 241 };
stefank@2314 242
stefank@2314 243 #endif // SHARE_VM_CODE_VMREG_HPP

mercurial