src/cpu/sparc/vm/macroAssembler_sparc.hpp

Wed, 23 Jan 2013 13:02:39 -0500

author
jprovino
date
Wed, 23 Jan 2013 13:02:39 -0500
changeset 4542
db9981fd3124
parent 4356
18d56ca3e901
child 5283
46c544b8fbfc
permissions
-rw-r--r--

8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
Summary: Rename INCLUDE_ALTERNATE_GCS to INCLUDE_ALL_GCS and replace SERIALGC with INCLUDE_ALL_GCS.
Reviewed-by: coleenp, stefank

twisti@4323 1 /*
twisti@4323 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
twisti@4323 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
twisti@4323 4 *
twisti@4323 5 * This code is free software; you can redistribute it and/or modify it
twisti@4323 6 * under the terms of the GNU General Public License version 2 only, as
twisti@4323 7 * published by the Free Software Foundation.
twisti@4323 8 *
twisti@4323 9 * This code is distributed in the hope that it will be useful, but WITHOUT
twisti@4323 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
twisti@4323 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
twisti@4323 12 * version 2 for more details (a copy is included in the LICENSE file that
twisti@4323 13 * accompanied this code).
twisti@4323 14 *
twisti@4323 15 * You should have received a copy of the GNU General Public License version
twisti@4323 16 * 2 along with this work; if not, write to the Free Software Foundation,
twisti@4323 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
twisti@4323 18 *
twisti@4323 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
twisti@4323 20 * or visit www.oracle.com if you need additional information or have any
twisti@4323 21 * questions.
twisti@4323 22 *
twisti@4323 23 */
twisti@4323 24
twisti@4323 25 #ifndef CPU_SPARC_VM_MACROASSEMBLER_SPARC_HPP
twisti@4323 26 #define CPU_SPARC_VM_MACROASSEMBLER_SPARC_HPP
twisti@4323 27
twisti@4323 28 #include "asm/assembler.hpp"
jprovino@4542 29 #include "utilities/macros.hpp"
twisti@4323 30
twisti@4323 31 // <sys/trap.h> promises that the system will not use traps 16-31
twisti@4323 32 #define ST_RESERVED_FOR_USER_0 0x10
twisti@4323 33
twisti@4323 34 class BiasedLockingCounters;
twisti@4323 35
twisti@4323 36
twisti@4323 37 // Register aliases for parts of the system:
twisti@4323 38
twisti@4323 39 // 64 bit values can be kept in g1-g5, o1-o5 and o7 and all 64 bits are safe
twisti@4323 40 // across context switches in V8+ ABI. Of course, there are no 64 bit regs
twisti@4323 41 // in V8 ABI. All 64 bits are preserved in V9 ABI for all registers.
twisti@4323 42
twisti@4323 43 // g2-g4 are scratch registers called "application globals". Their
twisti@4323 44 // meaning is reserved to the "compilation system"--which means us!
twisti@4323 45 // They are are not supposed to be touched by ordinary C code, although
twisti@4323 46 // highly-optimized C code might steal them for temps. They are safe
twisti@4323 47 // across thread switches, and the ABI requires that they be safe
twisti@4323 48 // across function calls.
twisti@4323 49 //
twisti@4323 50 // g1 and g3 are touched by more modules. V8 allows g1 to be clobbered
twisti@4323 51 // across func calls, and V8+ also allows g5 to be clobbered across
twisti@4323 52 // func calls. Also, g1 and g5 can get touched while doing shared
twisti@4323 53 // library loading.
twisti@4323 54 //
twisti@4323 55 // We must not touch g7 (it is the thread-self register) and g6 is
twisti@4323 56 // reserved for certain tools. g0, of course, is always zero.
twisti@4323 57 //
twisti@4323 58 // (Sources: SunSoft Compilers Group, thread library engineers.)
twisti@4323 59
twisti@4323 60 // %%%% The interpreter should be revisited to reduce global scratch regs.
twisti@4323 61
twisti@4323 62 // This global always holds the current JavaThread pointer:
twisti@4323 63
twisti@4323 64 REGISTER_DECLARATION(Register, G2_thread , G2);
twisti@4323 65 REGISTER_DECLARATION(Register, G6_heapbase , G6);
twisti@4323 66
twisti@4323 67 // The following globals are part of the Java calling convention:
twisti@4323 68
twisti@4323 69 REGISTER_DECLARATION(Register, G5_method , G5);
twisti@4323 70 REGISTER_DECLARATION(Register, G5_megamorphic_method , G5_method);
twisti@4323 71 REGISTER_DECLARATION(Register, G5_inline_cache_reg , G5_method);
twisti@4323 72
twisti@4323 73 // The following globals are used for the new C1 & interpreter calling convention:
twisti@4323 74 REGISTER_DECLARATION(Register, Gargs , G4); // pointing to the last argument
twisti@4323 75
twisti@4323 76 // This local is used to preserve G2_thread in the interpreter and in stubs:
twisti@4323 77 REGISTER_DECLARATION(Register, L7_thread_cache , L7);
twisti@4323 78
twisti@4323 79 // These globals are used as scratch registers in the interpreter:
twisti@4323 80
twisti@4323 81 REGISTER_DECLARATION(Register, Gframe_size , G1); // SAME REG as G1_scratch
twisti@4323 82 REGISTER_DECLARATION(Register, G1_scratch , G1); // also SAME
twisti@4323 83 REGISTER_DECLARATION(Register, G3_scratch , G3);
twisti@4323 84 REGISTER_DECLARATION(Register, G4_scratch , G4);
twisti@4323 85
twisti@4323 86 // These globals are used as short-lived scratch registers in the compiler:
twisti@4323 87
twisti@4323 88 REGISTER_DECLARATION(Register, Gtemp , G5);
twisti@4323 89
twisti@4323 90 // JSR 292 fixed register usages:
twisti@4323 91 REGISTER_DECLARATION(Register, G5_method_type , G5);
twisti@4323 92 REGISTER_DECLARATION(Register, G3_method_handle , G3);
twisti@4323 93 REGISTER_DECLARATION(Register, L7_mh_SP_save , L7);
twisti@4323 94
twisti@4323 95 // The compiler requires that G5_megamorphic_method is G5_inline_cache_klass,
twisti@4323 96 // because a single patchable "set" instruction (NativeMovConstReg,
twisti@4323 97 // or NativeMovConstPatching for compiler1) instruction
twisti@4323 98 // serves to set up either quantity, depending on whether the compiled
twisti@4323 99 // call site is an inline cache or is megamorphic. See the function
twisti@4323 100 // CompiledIC::set_to_megamorphic.
twisti@4323 101 //
twisti@4323 102 // If a inline cache targets an interpreted method, then the
twisti@4323 103 // G5 register will be used twice during the call. First,
twisti@4323 104 // the call site will be patched to load a compiledICHolder
twisti@4323 105 // into G5. (This is an ordered pair of ic_klass, method.)
twisti@4323 106 // The c2i adapter will first check the ic_klass, then load
twisti@4323 107 // G5_method with the method part of the pair just before
twisti@4323 108 // jumping into the interpreter.
twisti@4323 109 //
twisti@4323 110 // Note that G5_method is only the method-self for the interpreter,
twisti@4323 111 // and is logically unrelated to G5_megamorphic_method.
twisti@4323 112 //
twisti@4323 113 // Invariants on G2_thread (the JavaThread pointer):
twisti@4323 114 // - it should not be used for any other purpose anywhere
twisti@4323 115 // - it must be re-initialized by StubRoutines::call_stub()
twisti@4323 116 // - it must be preserved around every use of call_VM
twisti@4323 117
twisti@4323 118 // We can consider using g2/g3/g4 to cache more values than the
twisti@4323 119 // JavaThread, such as the card-marking base or perhaps pointers into
twisti@4323 120 // Eden. It's something of a waste to use them as scratch temporaries,
twisti@4323 121 // since they are not supposed to be volatile. (Of course, if we find
twisti@4323 122 // that Java doesn't benefit from application globals, then we can just
twisti@4323 123 // use them as ordinary temporaries.)
twisti@4323 124 //
twisti@4323 125 // Since g1 and g5 (and/or g6) are the volatile (caller-save) registers,
twisti@4323 126 // it makes sense to use them routinely for procedure linkage,
twisti@4323 127 // whenever the On registers are not applicable. Examples: G5_method,
twisti@4323 128 // G5_inline_cache_klass, and a double handful of miscellaneous compiler
twisti@4323 129 // stubs. This means that compiler stubs, etc., should be kept to a
twisti@4323 130 // maximum of two or three G-register arguments.
twisti@4323 131
twisti@4323 132
twisti@4323 133 // stub frames
twisti@4323 134
twisti@4323 135 REGISTER_DECLARATION(Register, Lentry_args , L0); // pointer to args passed to callee (interpreter) not stub itself
twisti@4323 136
twisti@4323 137 // Interpreter frames
twisti@4323 138
twisti@4323 139 #ifdef CC_INTERP
twisti@4323 140 REGISTER_DECLARATION(Register, Lstate , L0); // interpreter state object pointer
twisti@4323 141 REGISTER_DECLARATION(Register, L1_scratch , L1); // scratch
twisti@4323 142 REGISTER_DECLARATION(Register, Lmirror , L1); // mirror (for native methods only)
twisti@4323 143 REGISTER_DECLARATION(Register, L2_scratch , L2);
twisti@4323 144 REGISTER_DECLARATION(Register, L3_scratch , L3);
twisti@4323 145 REGISTER_DECLARATION(Register, L4_scratch , L4);
twisti@4323 146 REGISTER_DECLARATION(Register, Lscratch , L5); // C1 uses
twisti@4323 147 REGISTER_DECLARATION(Register, Lscratch2 , L6); // C1 uses
twisti@4323 148 REGISTER_DECLARATION(Register, L7_scratch , L7); // constant pool cache
twisti@4323 149 REGISTER_DECLARATION(Register, O5_savedSP , O5);
twisti@4323 150 REGISTER_DECLARATION(Register, I5_savedSP , I5); // Saved SP before bumping for locals. This is simply
twisti@4323 151 // a copy SP, so in 64-bit it's a biased value. The bias
twisti@4323 152 // is added and removed as needed in the frame code.
twisti@4323 153 // Interface to signature handler
twisti@4323 154 REGISTER_DECLARATION(Register, Llocals , L7); // pointer to locals for signature handler
twisti@4323 155 REGISTER_DECLARATION(Register, Lmethod , L6); // Method* when calling signature handler
twisti@4323 156
twisti@4323 157 #else
twisti@4323 158 REGISTER_DECLARATION(Register, Lesp , L0); // expression stack pointer
twisti@4323 159 REGISTER_DECLARATION(Register, Lbcp , L1); // pointer to next bytecode
twisti@4323 160 REGISTER_DECLARATION(Register, Lmethod , L2);
twisti@4323 161 REGISTER_DECLARATION(Register, Llocals , L3);
twisti@4323 162 REGISTER_DECLARATION(Register, Largs , L3); // pointer to locals for signature handler
twisti@4323 163 // must match Llocals in asm interpreter
twisti@4323 164 REGISTER_DECLARATION(Register, Lmonitors , L4);
twisti@4323 165 REGISTER_DECLARATION(Register, Lbyte_code , L5);
twisti@4323 166 // When calling out from the interpreter we record SP so that we can remove any extra stack
twisti@4323 167 // space allocated during adapter transitions. This register is only live from the point
twisti@4323 168 // of the call until we return.
twisti@4323 169 REGISTER_DECLARATION(Register, Llast_SP , L5);
twisti@4323 170 REGISTER_DECLARATION(Register, Lscratch , L5);
twisti@4323 171 REGISTER_DECLARATION(Register, Lscratch2 , L6);
twisti@4323 172 REGISTER_DECLARATION(Register, LcpoolCache , L6); // constant pool cache
twisti@4323 173
twisti@4323 174 REGISTER_DECLARATION(Register, O5_savedSP , O5);
twisti@4323 175 REGISTER_DECLARATION(Register, I5_savedSP , I5); // Saved SP before bumping for locals. This is simply
twisti@4323 176 // a copy SP, so in 64-bit it's a biased value. The bias
twisti@4323 177 // is added and removed as needed in the frame code.
twisti@4323 178 REGISTER_DECLARATION(Register, IdispatchTables , I4); // Base address of the bytecode dispatch tables
twisti@4323 179 REGISTER_DECLARATION(Register, IdispatchAddress , I3); // Register which saves the dispatch address for each bytecode
twisti@4323 180 REGISTER_DECLARATION(Register, ImethodDataPtr , I2); // Pointer to the current method data
twisti@4323 181 #endif /* CC_INTERP */
twisti@4323 182
twisti@4323 183 // NOTE: Lscratch2 and LcpoolCache point to the same registers in
twisti@4323 184 // the interpreter code. If Lscratch2 needs to be used for some
twisti@4323 185 // purpose than LcpoolCache should be restore after that for
twisti@4323 186 // the interpreter to work right
twisti@4323 187 // (These assignments must be compatible with L7_thread_cache; see above.)
twisti@4323 188
twisti@4323 189 // Since Lbcp points into the middle of the method object,
twisti@4323 190 // it is temporarily converted into a "bcx" during GC.
twisti@4323 191
twisti@4323 192 // Exception processing
twisti@4323 193 // These registers are passed into exception handlers.
twisti@4323 194 // All exception handlers require the exception object being thrown.
twisti@4323 195 // In addition, an nmethod's exception handler must be passed
twisti@4323 196 // the address of the call site within the nmethod, to allow
twisti@4323 197 // proper selection of the applicable catch block.
twisti@4323 198 // (Interpreter frames use their own bcp() for this purpose.)
twisti@4323 199 //
twisti@4323 200 // The Oissuing_pc value is not always needed. When jumping to a
twisti@4323 201 // handler that is known to be interpreted, the Oissuing_pc value can be
twisti@4323 202 // omitted. An actual catch block in compiled code receives (from its
twisti@4323 203 // nmethod's exception handler) the thrown exception in the Oexception,
twisti@4323 204 // but it doesn't need the Oissuing_pc.
twisti@4323 205 //
twisti@4323 206 // If an exception handler (either interpreted or compiled)
twisti@4323 207 // discovers there is no applicable catch block, it updates
twisti@4323 208 // the Oissuing_pc to the continuation PC of its own caller,
twisti@4323 209 // pops back to that caller's stack frame, and executes that
twisti@4323 210 // caller's exception handler. Obviously, this process will
twisti@4323 211 // iterate until the control stack is popped back to a method
twisti@4323 212 // containing an applicable catch block. A key invariant is
twisti@4323 213 // that the Oissuing_pc value is always a value local to
twisti@4323 214 // the method whose exception handler is currently executing.
twisti@4323 215 //
twisti@4323 216 // Note: The issuing PC value is __not__ a raw return address (I7 value).
twisti@4323 217 // It is a "return pc", the address __following__ the call.
twisti@4323 218 // Raw return addresses are converted to issuing PCs by frame::pc(),
twisti@4323 219 // or by stubs. Issuing PCs can be used directly with PC range tables.
twisti@4323 220 //
twisti@4323 221 REGISTER_DECLARATION(Register, Oexception , O0); // exception being thrown
twisti@4323 222 REGISTER_DECLARATION(Register, Oissuing_pc , O1); // where the exception is coming from
twisti@4323 223
twisti@4323 224
twisti@4323 225 // These must occur after the declarations above
twisti@4323 226 #ifndef DONT_USE_REGISTER_DEFINES
twisti@4323 227
twisti@4323 228 #define Gthread AS_REGISTER(Register, Gthread)
twisti@4323 229 #define Gmethod AS_REGISTER(Register, Gmethod)
twisti@4323 230 #define Gmegamorphic_method AS_REGISTER(Register, Gmegamorphic_method)
twisti@4323 231 #define Ginline_cache_reg AS_REGISTER(Register, Ginline_cache_reg)
twisti@4323 232 #define Gargs AS_REGISTER(Register, Gargs)
twisti@4323 233 #define Lthread_cache AS_REGISTER(Register, Lthread_cache)
twisti@4323 234 #define Gframe_size AS_REGISTER(Register, Gframe_size)
twisti@4323 235 #define Gtemp AS_REGISTER(Register, Gtemp)
twisti@4323 236
twisti@4323 237 #ifdef CC_INTERP
twisti@4323 238 #define Lstate AS_REGISTER(Register, Lstate)
twisti@4323 239 #define Lesp AS_REGISTER(Register, Lesp)
twisti@4323 240 #define L1_scratch AS_REGISTER(Register, L1_scratch)
twisti@4323 241 #define Lmirror AS_REGISTER(Register, Lmirror)
twisti@4323 242 #define L2_scratch AS_REGISTER(Register, L2_scratch)
twisti@4323 243 #define L3_scratch AS_REGISTER(Register, L3_scratch)
twisti@4323 244 #define L4_scratch AS_REGISTER(Register, L4_scratch)
twisti@4323 245 #define Lscratch AS_REGISTER(Register, Lscratch)
twisti@4323 246 #define Lscratch2 AS_REGISTER(Register, Lscratch2)
twisti@4323 247 #define L7_scratch AS_REGISTER(Register, L7_scratch)
twisti@4323 248 #define Ostate AS_REGISTER(Register, Ostate)
twisti@4323 249 #else
twisti@4323 250 #define Lesp AS_REGISTER(Register, Lesp)
twisti@4323 251 #define Lbcp AS_REGISTER(Register, Lbcp)
twisti@4323 252 #define Lmethod AS_REGISTER(Register, Lmethod)
twisti@4323 253 #define Llocals AS_REGISTER(Register, Llocals)
twisti@4323 254 #define Lmonitors AS_REGISTER(Register, Lmonitors)
twisti@4323 255 #define Lbyte_code AS_REGISTER(Register, Lbyte_code)
twisti@4323 256 #define Lscratch AS_REGISTER(Register, Lscratch)
twisti@4323 257 #define Lscratch2 AS_REGISTER(Register, Lscratch2)
twisti@4323 258 #define LcpoolCache AS_REGISTER(Register, LcpoolCache)
twisti@4323 259 #endif /* ! CC_INTERP */
twisti@4323 260
twisti@4323 261 #define Lentry_args AS_REGISTER(Register, Lentry_args)
twisti@4323 262 #define I5_savedSP AS_REGISTER(Register, I5_savedSP)
twisti@4323 263 #define O5_savedSP AS_REGISTER(Register, O5_savedSP)
twisti@4323 264 #define IdispatchAddress AS_REGISTER(Register, IdispatchAddress)
twisti@4323 265 #define ImethodDataPtr AS_REGISTER(Register, ImethodDataPtr)
twisti@4323 266 #define IdispatchTables AS_REGISTER(Register, IdispatchTables)
twisti@4323 267
twisti@4323 268 #define Oexception AS_REGISTER(Register, Oexception)
twisti@4323 269 #define Oissuing_pc AS_REGISTER(Register, Oissuing_pc)
twisti@4323 270
twisti@4323 271 #endif
twisti@4323 272
twisti@4323 273
twisti@4323 274 // Address is an abstraction used to represent a memory location.
twisti@4323 275 //
twisti@4323 276 // Note: A register location is represented via a Register, not
twisti@4323 277 // via an address for efficiency & simplicity reasons.
twisti@4323 278
twisti@4323 279 class Address VALUE_OBJ_CLASS_SPEC {
twisti@4323 280 private:
twisti@4323 281 Register _base; // Base register.
twisti@4323 282 RegisterOrConstant _index_or_disp; // Index register or constant displacement.
twisti@4323 283 RelocationHolder _rspec;
twisti@4323 284
twisti@4323 285 public:
twisti@4323 286 Address() : _base(noreg), _index_or_disp(noreg) {}
twisti@4323 287
twisti@4323 288 Address(Register base, RegisterOrConstant index_or_disp)
twisti@4323 289 : _base(base),
twisti@4323 290 _index_or_disp(index_or_disp) {
twisti@4323 291 }
twisti@4323 292
twisti@4323 293 Address(Register base, Register index)
twisti@4323 294 : _base(base),
twisti@4323 295 _index_or_disp(index) {
twisti@4323 296 }
twisti@4323 297
twisti@4323 298 Address(Register base, int disp)
twisti@4323 299 : _base(base),
twisti@4323 300 _index_or_disp(disp) {
twisti@4323 301 }
twisti@4323 302
twisti@4323 303 #ifdef ASSERT
twisti@4323 304 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 305 Address(Register base, ByteSize disp)
twisti@4323 306 : _base(base),
twisti@4323 307 _index_or_disp(in_bytes(disp)) {
twisti@4323 308 }
twisti@4323 309 #endif
twisti@4323 310
twisti@4323 311 // accessors
twisti@4323 312 Register base() const { return _base; }
twisti@4323 313 Register index() const { return _index_or_disp.as_register(); }
twisti@4323 314 int disp() const { return _index_or_disp.as_constant(); }
twisti@4323 315
twisti@4323 316 bool has_index() const { return _index_or_disp.is_register(); }
twisti@4323 317 bool has_disp() const { return _index_or_disp.is_constant(); }
twisti@4323 318
twisti@4323 319 bool uses(Register reg) const { return base() == reg || (has_index() && index() == reg); }
twisti@4323 320
twisti@4323 321 const relocInfo::relocType rtype() { return _rspec.type(); }
twisti@4323 322 const RelocationHolder& rspec() { return _rspec; }
twisti@4323 323
twisti@4323 324 RelocationHolder rspec(int offset) const {
twisti@4323 325 return offset == 0 ? _rspec : _rspec.plus(offset);
twisti@4323 326 }
twisti@4323 327
twisti@4323 328 inline bool is_simm13(int offset = 0); // check disp+offset for overflow
twisti@4323 329
twisti@4323 330 Address plus_disp(int plusdisp) const { // bump disp by a small amount
twisti@4323 331 assert(_index_or_disp.is_constant(), "must have a displacement");
twisti@4323 332 Address a(base(), disp() + plusdisp);
twisti@4323 333 return a;
twisti@4323 334 }
twisti@4323 335 bool is_same_address(Address a) const {
twisti@4323 336 // disregard _rspec
twisti@4323 337 return base() == a.base() && (has_index() ? index() == a.index() : disp() == a.disp());
twisti@4323 338 }
twisti@4323 339
twisti@4323 340 Address after_save() const {
twisti@4323 341 Address a = (*this);
twisti@4323 342 a._base = a._base->after_save();
twisti@4323 343 return a;
twisti@4323 344 }
twisti@4323 345
twisti@4323 346 Address after_restore() const {
twisti@4323 347 Address a = (*this);
twisti@4323 348 a._base = a._base->after_restore();
twisti@4323 349 return a;
twisti@4323 350 }
twisti@4323 351
twisti@4323 352 // Convert the raw encoding form into the form expected by the
twisti@4323 353 // constructor for Address.
twisti@4323 354 static Address make_raw(int base, int index, int scale, int disp, relocInfo::relocType disp_reloc);
twisti@4323 355
twisti@4323 356 friend class Assembler;
twisti@4323 357 };
twisti@4323 358
twisti@4323 359
twisti@4323 360 class AddressLiteral VALUE_OBJ_CLASS_SPEC {
twisti@4323 361 private:
twisti@4323 362 address _address;
twisti@4323 363 RelocationHolder _rspec;
twisti@4323 364
twisti@4323 365 RelocationHolder rspec_from_rtype(relocInfo::relocType rtype, address addr) {
twisti@4323 366 switch (rtype) {
twisti@4323 367 case relocInfo::external_word_type:
twisti@4323 368 return external_word_Relocation::spec(addr);
twisti@4323 369 case relocInfo::internal_word_type:
twisti@4323 370 return internal_word_Relocation::spec(addr);
twisti@4323 371 #ifdef _LP64
twisti@4323 372 case relocInfo::opt_virtual_call_type:
twisti@4323 373 return opt_virtual_call_Relocation::spec();
twisti@4323 374 case relocInfo::static_call_type:
twisti@4323 375 return static_call_Relocation::spec();
twisti@4323 376 case relocInfo::runtime_call_type:
twisti@4323 377 return runtime_call_Relocation::spec();
twisti@4323 378 #endif
twisti@4323 379 case relocInfo::none:
twisti@4323 380 return RelocationHolder();
twisti@4323 381 default:
twisti@4323 382 ShouldNotReachHere();
twisti@4323 383 return RelocationHolder();
twisti@4323 384 }
twisti@4323 385 }
twisti@4323 386
twisti@4323 387 protected:
twisti@4323 388 // creation
twisti@4323 389 AddressLiteral() : _address(NULL), _rspec(NULL) {}
twisti@4323 390
twisti@4323 391 public:
twisti@4323 392 AddressLiteral(address addr, RelocationHolder const& rspec)
twisti@4323 393 : _address(addr),
twisti@4323 394 _rspec(rspec) {}
twisti@4323 395
twisti@4323 396 // Some constructors to avoid casting at the call site.
twisti@4323 397 AddressLiteral(jobject obj, RelocationHolder const& rspec)
twisti@4323 398 : _address((address) obj),
twisti@4323 399 _rspec(rspec) {}
twisti@4323 400
twisti@4323 401 AddressLiteral(intptr_t value, RelocationHolder const& rspec)
twisti@4323 402 : _address((address) value),
twisti@4323 403 _rspec(rspec) {}
twisti@4323 404
twisti@4323 405 AddressLiteral(address addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 406 : _address((address) addr),
twisti@4323 407 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 408
twisti@4323 409 // Some constructors to avoid casting at the call site.
twisti@4323 410 AddressLiteral(address* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 411 : _address((address) addr),
twisti@4323 412 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 413
twisti@4323 414 AddressLiteral(bool* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 415 : _address((address) addr),
twisti@4323 416 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 417
twisti@4323 418 AddressLiteral(const bool* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 419 : _address((address) addr),
twisti@4323 420 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 421
twisti@4323 422 AddressLiteral(signed char* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 423 : _address((address) addr),
twisti@4323 424 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 425
twisti@4323 426 AddressLiteral(int* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 427 : _address((address) addr),
twisti@4323 428 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 429
twisti@4323 430 AddressLiteral(intptr_t addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 431 : _address((address) addr),
twisti@4323 432 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 433
twisti@4323 434 #ifdef _LP64
twisti@4323 435 // 32-bit complains about a multiple declaration for int*.
twisti@4323 436 AddressLiteral(intptr_t* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 437 : _address((address) addr),
twisti@4323 438 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 439 #endif
twisti@4323 440
twisti@4323 441 AddressLiteral(Metadata* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 442 : _address((address) addr),
twisti@4323 443 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 444
twisti@4323 445 AddressLiteral(Metadata** addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 446 : _address((address) addr),
twisti@4323 447 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 448
twisti@4323 449 AddressLiteral(float* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 450 : _address((address) addr),
twisti@4323 451 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 452
twisti@4323 453 AddressLiteral(double* addr, relocInfo::relocType rtype = relocInfo::none)
twisti@4323 454 : _address((address) addr),
twisti@4323 455 _rspec(rspec_from_rtype(rtype, (address) addr)) {}
twisti@4323 456
twisti@4323 457 intptr_t value() const { return (intptr_t) _address; }
twisti@4323 458 int low10() const;
twisti@4323 459
twisti@4323 460 const relocInfo::relocType rtype() const { return _rspec.type(); }
twisti@4323 461 const RelocationHolder& rspec() const { return _rspec; }
twisti@4323 462
twisti@4323 463 RelocationHolder rspec(int offset) const {
twisti@4323 464 return offset == 0 ? _rspec : _rspec.plus(offset);
twisti@4323 465 }
twisti@4323 466 };
twisti@4323 467
twisti@4323 468 // Convenience classes
twisti@4323 469 class ExternalAddress: public AddressLiteral {
twisti@4323 470 private:
twisti@4323 471 static relocInfo::relocType reloc_for_target(address target) {
twisti@4323 472 // Sometimes ExternalAddress is used for values which aren't
twisti@4323 473 // exactly addresses, like the card table base.
twisti@4323 474 // external_word_type can't be used for values in the first page
twisti@4323 475 // so just skip the reloc in that case.
twisti@4323 476 return external_word_Relocation::can_be_relocated(target) ? relocInfo::external_word_type : relocInfo::none;
twisti@4323 477 }
twisti@4323 478
twisti@4323 479 public:
twisti@4323 480 ExternalAddress(address target) : AddressLiteral(target, reloc_for_target( target)) {}
twisti@4323 481 ExternalAddress(Metadata** target) : AddressLiteral(target, reloc_for_target((address) target)) {}
twisti@4323 482 };
twisti@4323 483
twisti@4323 484 inline Address RegisterImpl::address_in_saved_window() const {
twisti@4323 485 return (Address(SP, (sp_offset_in_saved_window() * wordSize) + STACK_BIAS));
twisti@4323 486 }
twisti@4323 487
twisti@4323 488
twisti@4323 489
twisti@4323 490 // Argument is an abstraction used to represent an outgoing
twisti@4323 491 // actual argument or an incoming formal parameter, whether
twisti@4323 492 // it resides in memory or in a register, in a manner consistent
twisti@4323 493 // with the SPARC Application Binary Interface, or ABI. This is
twisti@4323 494 // often referred to as the native or C calling convention.
twisti@4323 495
twisti@4323 496 class Argument VALUE_OBJ_CLASS_SPEC {
twisti@4323 497 private:
twisti@4323 498 int _number;
twisti@4323 499 bool _is_in;
twisti@4323 500
twisti@4323 501 public:
twisti@4323 502 #ifdef _LP64
twisti@4323 503 enum {
twisti@4323 504 n_register_parameters = 6, // only 6 registers may contain integer parameters
twisti@4323 505 n_float_register_parameters = 16 // Can have up to 16 floating registers
twisti@4323 506 };
twisti@4323 507 #else
twisti@4323 508 enum {
twisti@4323 509 n_register_parameters = 6 // only 6 registers may contain integer parameters
twisti@4323 510 };
twisti@4323 511 #endif
twisti@4323 512
twisti@4323 513 // creation
twisti@4323 514 Argument(int number, bool is_in) : _number(number), _is_in(is_in) {}
twisti@4323 515
twisti@4323 516 int number() const { return _number; }
twisti@4323 517 bool is_in() const { return _is_in; }
twisti@4323 518 bool is_out() const { return !is_in(); }
twisti@4323 519
twisti@4323 520 Argument successor() const { return Argument(number() + 1, is_in()); }
twisti@4323 521 Argument as_in() const { return Argument(number(), true ); }
twisti@4323 522 Argument as_out() const { return Argument(number(), false); }
twisti@4323 523
twisti@4323 524 // locating register-based arguments:
twisti@4323 525 bool is_register() const { return _number < n_register_parameters; }
twisti@4323 526
twisti@4323 527 #ifdef _LP64
twisti@4323 528 // locating Floating Point register-based arguments:
twisti@4323 529 bool is_float_register() const { return _number < n_float_register_parameters; }
twisti@4323 530
twisti@4323 531 FloatRegister as_float_register() const {
twisti@4323 532 assert(is_float_register(), "must be a register argument");
twisti@4323 533 return as_FloatRegister(( number() *2 ) + 1);
twisti@4323 534 }
twisti@4323 535 FloatRegister as_double_register() const {
twisti@4323 536 assert(is_float_register(), "must be a register argument");
twisti@4323 537 return as_FloatRegister(( number() *2 ));
twisti@4323 538 }
twisti@4323 539 #endif
twisti@4323 540
twisti@4323 541 Register as_register() const {
twisti@4323 542 assert(is_register(), "must be a register argument");
twisti@4323 543 return is_in() ? as_iRegister(number()) : as_oRegister(number());
twisti@4323 544 }
twisti@4323 545
twisti@4323 546 // locating memory-based arguments
twisti@4323 547 Address as_address() const {
twisti@4323 548 assert(!is_register(), "must be a memory argument");
twisti@4323 549 return address_in_frame();
twisti@4323 550 }
twisti@4323 551
twisti@4323 552 // When applied to a register-based argument, give the corresponding address
twisti@4323 553 // into the 6-word area "into which callee may store register arguments"
twisti@4323 554 // (This is a different place than the corresponding register-save area location.)
twisti@4323 555 Address address_in_frame() const;
twisti@4323 556
twisti@4323 557 // debugging
twisti@4323 558 const char* name() const;
twisti@4323 559
twisti@4323 560 friend class Assembler;
twisti@4323 561 };
twisti@4323 562
twisti@4323 563
twisti@4323 564 class RegistersForDebugging : public StackObj {
twisti@4323 565 public:
twisti@4323 566 intptr_t i[8], l[8], o[8], g[8];
twisti@4323 567 float f[32];
twisti@4323 568 double d[32];
twisti@4323 569
twisti@4323 570 void print(outputStream* s);
twisti@4323 571
twisti@4323 572 static int i_offset(int j) { return offset_of(RegistersForDebugging, i[j]); }
twisti@4323 573 static int l_offset(int j) { return offset_of(RegistersForDebugging, l[j]); }
twisti@4323 574 static int o_offset(int j) { return offset_of(RegistersForDebugging, o[j]); }
twisti@4323 575 static int g_offset(int j) { return offset_of(RegistersForDebugging, g[j]); }
twisti@4323 576 static int f_offset(int j) { return offset_of(RegistersForDebugging, f[j]); }
twisti@4323 577 static int d_offset(int j) { return offset_of(RegistersForDebugging, d[j / 2]); }
twisti@4323 578
twisti@4323 579 // gen asm code to save regs
twisti@4323 580 static void save_registers(MacroAssembler* a);
twisti@4323 581
twisti@4323 582 // restore global registers in case C code disturbed them
twisti@4323 583 static void restore_registers(MacroAssembler* a, Register r);
twisti@4323 584 };
twisti@4323 585
twisti@4323 586
twisti@4323 587 // MacroAssembler extends Assembler by a few frequently used macros.
twisti@4323 588 //
twisti@4323 589 // Most of the standard SPARC synthetic ops are defined here.
twisti@4323 590 // Instructions for which a 'better' code sequence exists depending
twisti@4323 591 // on arguments should also go in here.
twisti@4323 592
twisti@4323 593 #define JMP2(r1, r2) jmp(r1, r2, __FILE__, __LINE__)
twisti@4323 594 #define JMP(r1, off) jmp(r1, off, __FILE__, __LINE__)
twisti@4323 595 #define JUMP(a, temp, off) jump(a, temp, off, __FILE__, __LINE__)
twisti@4323 596 #define JUMPL(a, temp, d, off) jumpl(a, temp, d, off, __FILE__, __LINE__)
twisti@4323 597
twisti@4323 598
twisti@4323 599 class MacroAssembler : public Assembler {
twisti@4323 600 // code patchers need various routines like inv_wdisp()
twisti@4323 601 friend class NativeInstruction;
twisti@4323 602 friend class NativeGeneralJump;
twisti@4323 603 friend class Relocation;
twisti@4323 604 friend class Label;
twisti@4323 605
twisti@4323 606 protected:
twisti@4323 607 static int patched_branch(int dest_pos, int inst, int inst_pos);
twisti@4323 608 static int branch_destination(int inst, int pos);
twisti@4323 609
twisti@4323 610 // Support for VM calls
twisti@4323 611 // This is the base routine called by the different versions of call_VM_leaf. The interpreter
twisti@4323 612 // may customize this version by overriding it for its purposes (e.g., to save/restore
twisti@4323 613 // additional registers when doing a VM call).
twisti@4323 614 #ifdef CC_INTERP
twisti@4323 615 #define VIRTUAL
twisti@4323 616 #else
twisti@4323 617 #define VIRTUAL virtual
twisti@4323 618 #endif
twisti@4323 619
twisti@4323 620 VIRTUAL void call_VM_leaf_base(Register thread_cache, address entry_point, int number_of_arguments);
twisti@4323 621
twisti@4323 622 //
twisti@4323 623 // It is imperative that all calls into the VM are handled via the call_VM macros.
twisti@4323 624 // They make sure that the stack linkage is setup correctly. call_VM's correspond
twisti@4323 625 // to ENTRY/ENTRY_X entry points while call_VM_leaf's correspond to LEAF entry points.
twisti@4323 626 //
twisti@4323 627 // This is the base routine called by the different versions of call_VM. The interpreter
twisti@4323 628 // may customize this version by overriding it for its purposes (e.g., to save/restore
twisti@4323 629 // additional registers when doing a VM call).
twisti@4323 630 //
twisti@4323 631 // A non-volatile java_thread_cache register should be specified so
twisti@4323 632 // that the G2_thread value can be preserved across the call.
twisti@4323 633 // (If java_thread_cache is noreg, then a slow get_thread call
twisti@4323 634 // will re-initialize the G2_thread.) call_VM_base returns the register that contains the
twisti@4323 635 // thread.
twisti@4323 636 //
twisti@4323 637 // If no last_java_sp is specified (noreg) than SP will be used instead.
twisti@4323 638
twisti@4323 639 virtual void call_VM_base(
twisti@4323 640 Register oop_result, // where an oop-result ends up if any; use noreg otherwise
twisti@4323 641 Register java_thread_cache, // the thread if computed before ; use noreg otherwise
twisti@4323 642 Register last_java_sp, // to set up last_Java_frame in stubs; use noreg otherwise
twisti@4323 643 address entry_point, // the entry point
twisti@4323 644 int number_of_arguments, // the number of arguments (w/o thread) to pop after call
twisti@4323 645 bool check_exception=true // flag which indicates if exception should be checked
twisti@4323 646 );
twisti@4323 647
twisti@4323 648 // This routine should emit JVMTI PopFrame and ForceEarlyReturn handling code.
twisti@4323 649 // The implementation is only non-empty for the InterpreterMacroAssembler,
twisti@4323 650 // as only the interpreter handles and ForceEarlyReturn PopFrame requests.
twisti@4323 651 virtual void check_and_handle_popframe(Register scratch_reg);
twisti@4323 652 virtual void check_and_handle_earlyret(Register scratch_reg);
twisti@4323 653
twisti@4323 654 public:
twisti@4323 655 MacroAssembler(CodeBuffer* code) : Assembler(code) {}
twisti@4323 656
twisti@4323 657 // Support for NULL-checks
twisti@4323 658 //
twisti@4323 659 // Generates code that causes a NULL OS exception if the content of reg is NULL.
twisti@4323 660 // If the accessed location is M[reg + offset] and the offset is known, provide the
twisti@4323 661 // offset. No explicit code generation is needed if the offset is within a certain
twisti@4323 662 // range (0 <= offset <= page_size).
twisti@4323 663 //
twisti@4323 664 // %%%%%% Currently not done for SPARC
twisti@4323 665
twisti@4323 666 void null_check(Register reg, int offset = -1);
twisti@4323 667 static bool needs_explicit_null_check(intptr_t offset);
twisti@4323 668
twisti@4323 669 // support for delayed instructions
twisti@4323 670 MacroAssembler* delayed() { Assembler::delayed(); return this; }
twisti@4323 671
twisti@4323 672 // branches that use right instruction for v8 vs. v9
twisti@4323 673 inline void br( Condition c, bool a, Predict p, address d, relocInfo::relocType rt = relocInfo::none );
twisti@4323 674 inline void br( Condition c, bool a, Predict p, Label& L );
twisti@4323 675
twisti@4323 676 inline void fb( Condition c, bool a, Predict p, address d, relocInfo::relocType rt = relocInfo::none );
twisti@4323 677 inline void fb( Condition c, bool a, Predict p, Label& L );
twisti@4323 678
twisti@4323 679 // compares register with zero (32 bit) and branches (V9 and V8 instructions)
twisti@4323 680 void cmp_zero_and_br( Condition c, Register s1, Label& L, bool a = false, Predict p = pn );
twisti@4323 681 // Compares a pointer register with zero and branches on (not)null.
twisti@4323 682 // Does a test & branch on 32-bit systems and a register-branch on 64-bit.
twisti@4323 683 void br_null ( Register s1, bool a, Predict p, Label& L );
twisti@4323 684 void br_notnull( Register s1, bool a, Predict p, Label& L );
twisti@4323 685
twisti@4323 686 //
twisti@4323 687 // Compare registers and branch with nop in delay slot or cbcond without delay slot.
twisti@4323 688 //
twisti@4323 689 // ATTENTION: use these instructions with caution because cbcond instruction
twisti@4323 690 // has very short distance: 512 instructions (2Kbyte).
twisti@4323 691
twisti@4323 692 // Compare integer (32 bit) values (icc only).
twisti@4323 693 void cmp_and_br_short(Register s1, Register s2, Condition c, Predict p, Label& L);
twisti@4323 694 void cmp_and_br_short(Register s1, int simm13a, Condition c, Predict p, Label& L);
twisti@4323 695 // Platform depending version for pointer compare (icc on !LP64 and xcc on LP64).
twisti@4323 696 void cmp_and_brx_short(Register s1, Register s2, Condition c, Predict p, Label& L);
twisti@4323 697 void cmp_and_brx_short(Register s1, int simm13a, Condition c, Predict p, Label& L);
twisti@4323 698
twisti@4323 699 // Short branch version for compares a pointer pwith zero.
twisti@4323 700 void br_null_short ( Register s1, Predict p, Label& L );
twisti@4323 701 void br_notnull_short( Register s1, Predict p, Label& L );
twisti@4323 702
twisti@4323 703 // unconditional short branch
twisti@4323 704 void ba_short(Label& L);
twisti@4323 705
twisti@4323 706 inline void bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt = relocInfo::none );
twisti@4323 707 inline void bp( Condition c, bool a, CC cc, Predict p, Label& L );
twisti@4323 708
twisti@4323 709 // Branch that tests xcc in LP64 and icc in !LP64
twisti@4323 710 inline void brx( Condition c, bool a, Predict p, address d, relocInfo::relocType rt = relocInfo::none );
twisti@4323 711 inline void brx( Condition c, bool a, Predict p, Label& L );
twisti@4323 712
twisti@4323 713 // unconditional branch
twisti@4323 714 inline void ba( Label& L );
twisti@4323 715
twisti@4323 716 // Branch that tests fp condition codes
twisti@4323 717 inline void fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt = relocInfo::none );
twisti@4323 718 inline void fbp( Condition c, bool a, CC cc, Predict p, Label& L );
twisti@4323 719
twisti@4323 720 // get PC the best way
twisti@4323 721 inline int get_pc( Register d );
twisti@4323 722
twisti@4323 723 // Sparc shorthands(pp 85, V8 manual, pp 289 V9 manual)
twisti@4323 724 inline void cmp( Register s1, Register s2 ) { subcc( s1, s2, G0 ); }
twisti@4323 725 inline void cmp( Register s1, int simm13a ) { subcc( s1, simm13a, G0 ); }
twisti@4323 726
twisti@4323 727 inline void jmp( Register s1, Register s2 );
twisti@4323 728 inline void jmp( Register s1, int simm13a, RelocationHolder const& rspec = RelocationHolder() );
twisti@4323 729
twisti@4323 730 // Check if the call target is out of wdisp30 range (relative to the code cache)
twisti@4323 731 static inline bool is_far_target(address d);
twisti@4323 732 inline void call( address d, relocInfo::relocType rt = relocInfo::runtime_call_type );
twisti@4323 733 inline void call( Label& L, relocInfo::relocType rt = relocInfo::runtime_call_type );
twisti@4323 734 inline void callr( Register s1, Register s2 );
twisti@4323 735 inline void callr( Register s1, int simm13a, RelocationHolder const& rspec = RelocationHolder() );
twisti@4323 736
twisti@4323 737 // Emits nothing on V8
twisti@4323 738 inline void iprefetch( address d, relocInfo::relocType rt = relocInfo::none );
twisti@4323 739 inline void iprefetch( Label& L);
twisti@4323 740
twisti@4323 741 inline void tst( Register s ) { orcc( G0, s, G0 ); }
twisti@4323 742
twisti@4323 743 #ifdef PRODUCT
twisti@4323 744 inline void ret( bool trace = TraceJumps ) { if (trace) {
twisti@4323 745 mov(I7, O7); // traceable register
twisti@4323 746 JMP(O7, 2 * BytesPerInstWord);
twisti@4323 747 } else {
twisti@4323 748 jmpl( I7, 2 * BytesPerInstWord, G0 );
twisti@4323 749 }
twisti@4323 750 }
twisti@4323 751
twisti@4323 752 inline void retl( bool trace = TraceJumps ) { if (trace) JMP(O7, 2 * BytesPerInstWord);
twisti@4323 753 else jmpl( O7, 2 * BytesPerInstWord, G0 ); }
twisti@4323 754 #else
twisti@4323 755 void ret( bool trace = TraceJumps );
twisti@4323 756 void retl( bool trace = TraceJumps );
twisti@4323 757 #endif /* PRODUCT */
twisti@4323 758
twisti@4323 759 // Required platform-specific helpers for Label::patch_instructions.
twisti@4323 760 // They _shadow_ the declarations in AbstractAssembler, which are undefined.
twisti@4323 761 void pd_patch_instruction(address branch, address target);
twisti@4323 762
twisti@4323 763 // sethi Macro handles optimizations and relocations
twisti@4323 764 private:
twisti@4323 765 void internal_sethi(const AddressLiteral& addrlit, Register d, bool ForceRelocatable);
twisti@4323 766 public:
twisti@4323 767 void sethi(const AddressLiteral& addrlit, Register d);
twisti@4323 768 void patchable_sethi(const AddressLiteral& addrlit, Register d);
twisti@4323 769
twisti@4323 770 // compute the number of instructions for a sethi/set
twisti@4323 771 static int insts_for_sethi( address a, bool worst_case = false );
twisti@4323 772 static int worst_case_insts_for_set();
twisti@4323 773
twisti@4323 774 // set may be either setsw or setuw (high 32 bits may be zero or sign)
twisti@4323 775 private:
twisti@4323 776 void internal_set(const AddressLiteral& al, Register d, bool ForceRelocatable);
twisti@4323 777 static int insts_for_internal_set(intptr_t value);
twisti@4323 778 public:
twisti@4323 779 void set(const AddressLiteral& addrlit, Register d);
twisti@4323 780 void set(intptr_t value, Register d);
twisti@4323 781 void set(address addr, Register d, RelocationHolder const& rspec);
twisti@4323 782 static int insts_for_set(intptr_t value) { return insts_for_internal_set(value); }
twisti@4323 783
twisti@4323 784 void patchable_set(const AddressLiteral& addrlit, Register d);
twisti@4323 785 void patchable_set(intptr_t value, Register d);
twisti@4323 786 void set64(jlong value, Register d, Register tmp);
twisti@4323 787 static int insts_for_set64(jlong value);
twisti@4323 788
twisti@4323 789 // sign-extend 32 to 64
twisti@4323 790 inline void signx( Register s, Register d ) { sra( s, G0, d); }
twisti@4323 791 inline void signx( Register d ) { sra( d, G0, d); }
twisti@4323 792
twisti@4323 793 inline void not1( Register s, Register d ) { xnor( s, G0, d ); }
twisti@4323 794 inline void not1( Register d ) { xnor( d, G0, d ); }
twisti@4323 795
twisti@4323 796 inline void neg( Register s, Register d ) { sub( G0, s, d ); }
twisti@4323 797 inline void neg( Register d ) { sub( G0, d, d ); }
twisti@4323 798
twisti@4323 799 inline void cas( Register s1, Register s2, Register d) { casa( s1, s2, d, ASI_PRIMARY); }
twisti@4323 800 inline void casx( Register s1, Register s2, Register d) { casxa(s1, s2, d, ASI_PRIMARY); }
twisti@4323 801 // Functions for isolating 64 bit atomic swaps for LP64
twisti@4323 802 // cas_ptr will perform cas for 32 bit VM's and casx for 64 bit VM's
twisti@4323 803 inline void cas_ptr( Register s1, Register s2, Register d) {
twisti@4323 804 #ifdef _LP64
twisti@4323 805 casx( s1, s2, d );
twisti@4323 806 #else
twisti@4323 807 cas( s1, s2, d );
twisti@4323 808 #endif
twisti@4323 809 }
twisti@4323 810
twisti@4323 811 // Functions for isolating 64 bit shifts for LP64
twisti@4323 812 inline void sll_ptr( Register s1, Register s2, Register d );
twisti@4323 813 inline void sll_ptr( Register s1, int imm6a, Register d );
twisti@4323 814 inline void sll_ptr( Register s1, RegisterOrConstant s2, Register d );
twisti@4323 815 inline void srl_ptr( Register s1, Register s2, Register d );
twisti@4323 816 inline void srl_ptr( Register s1, int imm6a, Register d );
twisti@4323 817
twisti@4323 818 // little-endian
twisti@4323 819 inline void casl( Register s1, Register s2, Register d) { casa( s1, s2, d, ASI_PRIMARY_LITTLE); }
twisti@4323 820 inline void casxl( Register s1, Register s2, Register d) { casxa(s1, s2, d, ASI_PRIMARY_LITTLE); }
twisti@4323 821
twisti@4323 822 inline void inc( Register d, int const13 = 1 ) { add( d, const13, d); }
twisti@4323 823 inline void inccc( Register d, int const13 = 1 ) { addcc( d, const13, d); }
twisti@4323 824
twisti@4323 825 inline void dec( Register d, int const13 = 1 ) { sub( d, const13, d); }
twisti@4323 826 inline void deccc( Register d, int const13 = 1 ) { subcc( d, const13, d); }
twisti@4323 827
twisti@4323 828 using Assembler::add;
twisti@4323 829 inline void add(Register s1, int simm13a, Register d, relocInfo::relocType rtype);
twisti@4323 830 inline void add(Register s1, int simm13a, Register d, RelocationHolder const& rspec);
twisti@4323 831 inline void add(Register s1, RegisterOrConstant s2, Register d, int offset = 0);
twisti@4323 832 inline void add(const Address& a, Register d, int offset = 0);
twisti@4323 833
twisti@4323 834 using Assembler::andn;
twisti@4323 835 inline void andn( Register s1, RegisterOrConstant s2, Register d);
twisti@4323 836
twisti@4323 837 inline void btst( Register s1, Register s2 ) { andcc( s1, s2, G0 ); }
twisti@4323 838 inline void btst( int simm13a, Register s ) { andcc( s, simm13a, G0 ); }
twisti@4323 839
twisti@4323 840 inline void bset( Register s1, Register s2 ) { or3( s1, s2, s2 ); }
twisti@4323 841 inline void bset( int simm13a, Register s ) { or3( s, simm13a, s ); }
twisti@4323 842
twisti@4323 843 inline void bclr( Register s1, Register s2 ) { andn( s1, s2, s2 ); }
twisti@4323 844 inline void bclr( int simm13a, Register s ) { andn( s, simm13a, s ); }
twisti@4323 845
twisti@4323 846 inline void btog( Register s1, Register s2 ) { xor3( s1, s2, s2 ); }
twisti@4323 847 inline void btog( int simm13a, Register s ) { xor3( s, simm13a, s ); }
twisti@4323 848
twisti@4323 849 inline void clr( Register d ) { or3( G0, G0, d ); }
twisti@4323 850
twisti@4323 851 inline void clrb( Register s1, Register s2);
twisti@4323 852 inline void clrh( Register s1, Register s2);
twisti@4323 853 inline void clr( Register s1, Register s2);
twisti@4323 854 inline void clrx( Register s1, Register s2);
twisti@4323 855
twisti@4323 856 inline void clrb( Register s1, int simm13a);
twisti@4323 857 inline void clrh( Register s1, int simm13a);
twisti@4323 858 inline void clr( Register s1, int simm13a);
twisti@4323 859 inline void clrx( Register s1, int simm13a);
twisti@4323 860
twisti@4323 861 // copy & clear upper word
twisti@4323 862 inline void clruw( Register s, Register d ) { srl( s, G0, d); }
twisti@4323 863 // clear upper word
twisti@4323 864 inline void clruwu( Register d ) { srl( d, G0, d); }
twisti@4323 865
twisti@4323 866 using Assembler::ldsb;
twisti@4323 867 using Assembler::ldsh;
twisti@4323 868 using Assembler::ldsw;
twisti@4323 869 using Assembler::ldub;
twisti@4323 870 using Assembler::lduh;
twisti@4323 871 using Assembler::lduw;
twisti@4323 872 using Assembler::ldx;
twisti@4323 873 using Assembler::ldd;
twisti@4323 874
twisti@4323 875 #ifdef ASSERT
twisti@4323 876 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 877 inline void ld(Register s1, ByteSize simm13a, Register d);
twisti@4323 878 #endif
twisti@4323 879
twisti@4323 880 inline void ld(Register s1, Register s2, Register d);
twisti@4323 881 inline void ld(Register s1, int simm13a, Register d);
twisti@4323 882
twisti@4323 883 inline void ldsb(const Address& a, Register d, int offset = 0);
twisti@4323 884 inline void ldsh(const Address& a, Register d, int offset = 0);
twisti@4323 885 inline void ldsw(const Address& a, Register d, int offset = 0);
twisti@4323 886 inline void ldub(const Address& a, Register d, int offset = 0);
twisti@4323 887 inline void lduh(const Address& a, Register d, int offset = 0);
twisti@4323 888 inline void lduw(const Address& a, Register d, int offset = 0);
twisti@4323 889 inline void ldx( const Address& a, Register d, int offset = 0);
twisti@4323 890 inline void ld( const Address& a, Register d, int offset = 0);
twisti@4323 891 inline void ldd( const Address& a, Register d, int offset = 0);
twisti@4323 892
twisti@4323 893 inline void ldub(Register s1, RegisterOrConstant s2, Register d );
twisti@4323 894 inline void ldsb(Register s1, RegisterOrConstant s2, Register d );
twisti@4323 895 inline void lduh(Register s1, RegisterOrConstant s2, Register d );
twisti@4323 896 inline void ldsh(Register s1, RegisterOrConstant s2, Register d );
twisti@4323 897 inline void lduw(Register s1, RegisterOrConstant s2, Register d );
twisti@4323 898 inline void ldsw(Register s1, RegisterOrConstant s2, Register d );
twisti@4323 899 inline void ldx( Register s1, RegisterOrConstant s2, Register d );
twisti@4323 900 inline void ld( Register s1, RegisterOrConstant s2, Register d );
twisti@4323 901 inline void ldd( Register s1, RegisterOrConstant s2, Register d );
twisti@4323 902
twisti@4323 903 using Assembler::ldf;
twisti@4323 904 inline void ldf(FloatRegisterImpl::Width w, Register s1, RegisterOrConstant s2, FloatRegister d);
twisti@4323 905 inline void ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset = 0);
twisti@4323 906
twisti@4323 907 // membar psuedo instruction. takes into account target memory model.
twisti@4323 908 inline void membar( Assembler::Membar_mask_bits const7a );
twisti@4323 909
twisti@4323 910 // returns if membar generates anything.
twisti@4323 911 inline bool membar_has_effect( Assembler::Membar_mask_bits const7a );
twisti@4323 912
twisti@4323 913 // mov pseudo instructions
twisti@4323 914 inline void mov( Register s, Register d) {
twisti@4323 915 if ( s != d ) or3( G0, s, d);
twisti@4323 916 else assert_not_delayed(); // Put something useful in the delay slot!
twisti@4323 917 }
twisti@4323 918
twisti@4323 919 inline void mov_or_nop( Register s, Register d) {
twisti@4323 920 if ( s != d ) or3( G0, s, d);
twisti@4323 921 else nop();
twisti@4323 922 }
twisti@4323 923
twisti@4323 924 inline void mov( int simm13a, Register d) { or3( G0, simm13a, d); }
twisti@4323 925
twisti@4323 926 using Assembler::prefetch;
twisti@4323 927 inline void prefetch(const Address& a, PrefetchFcn F, int offset = 0);
twisti@4323 928
twisti@4323 929 using Assembler::stb;
twisti@4323 930 using Assembler::sth;
twisti@4323 931 using Assembler::stw;
twisti@4323 932 using Assembler::stx;
twisti@4323 933 using Assembler::std;
twisti@4323 934
twisti@4323 935 #ifdef ASSERT
twisti@4323 936 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 937 inline void st(Register d, Register s1, ByteSize simm13a);
twisti@4323 938 #endif
twisti@4323 939
twisti@4323 940 inline void st(Register d, Register s1, Register s2);
twisti@4323 941 inline void st(Register d, Register s1, int simm13a);
twisti@4323 942
twisti@4323 943 inline void stb(Register d, const Address& a, int offset = 0 );
twisti@4323 944 inline void sth(Register d, const Address& a, int offset = 0 );
twisti@4323 945 inline void stw(Register d, const Address& a, int offset = 0 );
twisti@4323 946 inline void stx(Register d, const Address& a, int offset = 0 );
twisti@4323 947 inline void st( Register d, const Address& a, int offset = 0 );
twisti@4323 948 inline void std(Register d, const Address& a, int offset = 0 );
twisti@4323 949
twisti@4323 950 inline void stb(Register d, Register s1, RegisterOrConstant s2 );
twisti@4323 951 inline void sth(Register d, Register s1, RegisterOrConstant s2 );
twisti@4323 952 inline void stw(Register d, Register s1, RegisterOrConstant s2 );
twisti@4323 953 inline void stx(Register d, Register s1, RegisterOrConstant s2 );
twisti@4323 954 inline void std(Register d, Register s1, RegisterOrConstant s2 );
twisti@4323 955 inline void st( Register d, Register s1, RegisterOrConstant s2 );
twisti@4323 956
twisti@4323 957 using Assembler::stf;
twisti@4323 958 inline void stf(FloatRegisterImpl::Width w, FloatRegister d, Register s1, RegisterOrConstant s2);
twisti@4323 959 inline void stf(FloatRegisterImpl::Width w, FloatRegister d, const Address& a, int offset = 0);
twisti@4323 960
twisti@4323 961 // Note: offset is added to s2.
twisti@4323 962 using Assembler::sub;
twisti@4323 963 inline void sub(Register s1, RegisterOrConstant s2, Register d, int offset = 0);
twisti@4323 964
twisti@4323 965 using Assembler::swap;
twisti@4323 966 inline void swap(Address& a, Register d, int offset = 0);
twisti@4323 967
twisti@4323 968 // address pseudos: make these names unlike instruction names to avoid confusion
twisti@4323 969 inline intptr_t load_pc_address( Register reg, int bytes_to_skip );
twisti@4323 970 inline void load_contents(const AddressLiteral& addrlit, Register d, int offset = 0);
twisti@4323 971 inline void load_bool_contents(const AddressLiteral& addrlit, Register d, int offset = 0);
twisti@4323 972 inline void load_ptr_contents(const AddressLiteral& addrlit, Register d, int offset = 0);
twisti@4323 973 inline void store_contents(Register s, const AddressLiteral& addrlit, Register temp, int offset = 0);
twisti@4323 974 inline void store_ptr_contents(Register s, const AddressLiteral& addrlit, Register temp, int offset = 0);
twisti@4323 975 inline void jumpl_to(const AddressLiteral& addrlit, Register temp, Register d, int offset = 0);
twisti@4323 976 inline void jump_to(const AddressLiteral& addrlit, Register temp, int offset = 0);
twisti@4323 977 inline void jump_indirect_to(Address& a, Register temp, int ld_offset = 0, int jmp_offset = 0);
twisti@4323 978
twisti@4323 979 // ring buffer traceable jumps
twisti@4323 980
twisti@4323 981 void jmp2( Register r1, Register r2, const char* file, int line );
twisti@4323 982 void jmp ( Register r1, int offset, const char* file, int line );
twisti@4323 983
twisti@4323 984 void jumpl(const AddressLiteral& addrlit, Register temp, Register d, int offset, const char* file, int line);
twisti@4323 985 void jump (const AddressLiteral& addrlit, Register temp, int offset, const char* file, int line);
twisti@4323 986
twisti@4323 987
twisti@4323 988 // argument pseudos:
twisti@4323 989
twisti@4323 990 inline void load_argument( Argument& a, Register d );
twisti@4323 991 inline void store_argument( Register s, Argument& a );
twisti@4323 992 inline void store_ptr_argument( Register s, Argument& a );
twisti@4323 993 inline void store_float_argument( FloatRegister s, Argument& a );
twisti@4323 994 inline void store_double_argument( FloatRegister s, Argument& a );
twisti@4323 995 inline void store_long_argument( Register s, Argument& a );
twisti@4323 996
twisti@4323 997 // handy macros:
twisti@4323 998
twisti@4323 999 inline void round_to( Register r, int modulus ) {
twisti@4323 1000 assert_not_delayed();
twisti@4323 1001 inc( r, modulus - 1 );
twisti@4323 1002 and3( r, -modulus, r );
twisti@4323 1003 }
twisti@4323 1004
twisti@4323 1005 // --------------------------------------------------
twisti@4323 1006
twisti@4323 1007 // Functions for isolating 64 bit loads for LP64
twisti@4323 1008 // ld_ptr will perform ld for 32 bit VM's and ldx for 64 bit VM's
twisti@4323 1009 // st_ptr will perform st for 32 bit VM's and stx for 64 bit VM's
twisti@4323 1010 inline void ld_ptr(Register s1, Register s2, Register d);
twisti@4323 1011 inline void ld_ptr(Register s1, int simm13a, Register d);
twisti@4323 1012 inline void ld_ptr(Register s1, RegisterOrConstant s2, Register d);
twisti@4323 1013 inline void ld_ptr(const Address& a, Register d, int offset = 0);
twisti@4323 1014 inline void st_ptr(Register d, Register s1, Register s2);
twisti@4323 1015 inline void st_ptr(Register d, Register s1, int simm13a);
twisti@4323 1016 inline void st_ptr(Register d, Register s1, RegisterOrConstant s2);
twisti@4323 1017 inline void st_ptr(Register d, const Address& a, int offset = 0);
twisti@4323 1018
twisti@4323 1019 #ifdef ASSERT
twisti@4323 1020 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 1021 inline void ld_ptr(Register s1, ByteSize simm13a, Register d);
twisti@4323 1022 inline void st_ptr(Register d, Register s1, ByteSize simm13a);
twisti@4323 1023 #endif
twisti@4323 1024
twisti@4323 1025 // ld_long will perform ldd for 32 bit VM's and ldx for 64 bit VM's
twisti@4323 1026 // st_long will perform std for 32 bit VM's and stx for 64 bit VM's
twisti@4323 1027 inline void ld_long(Register s1, Register s2, Register d);
twisti@4323 1028 inline void ld_long(Register s1, int simm13a, Register d);
twisti@4323 1029 inline void ld_long(Register s1, RegisterOrConstant s2, Register d);
twisti@4323 1030 inline void ld_long(const Address& a, Register d, int offset = 0);
twisti@4323 1031 inline void st_long(Register d, Register s1, Register s2);
twisti@4323 1032 inline void st_long(Register d, Register s1, int simm13a);
twisti@4323 1033 inline void st_long(Register d, Register s1, RegisterOrConstant s2);
twisti@4323 1034 inline void st_long(Register d, const Address& a, int offset = 0);
twisti@4323 1035
twisti@4323 1036 // Helpers for address formation.
twisti@4323 1037 // - They emit only a move if s2 is a constant zero.
twisti@4323 1038 // - If dest is a constant and either s1 or s2 is a register, the temp argument is required and becomes the result.
twisti@4323 1039 // - If dest is a register and either s1 or s2 is a non-simm13 constant, the temp argument is required and used to materialize the constant.
twisti@4323 1040 RegisterOrConstant regcon_andn_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp = noreg);
twisti@4323 1041 RegisterOrConstant regcon_inc_ptr( RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp = noreg);
twisti@4323 1042 RegisterOrConstant regcon_sll_ptr( RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp = noreg);
twisti@4323 1043
twisti@4323 1044 RegisterOrConstant ensure_simm13_or_reg(RegisterOrConstant src, Register temp) {
twisti@4323 1045 if (is_simm13(src.constant_or_zero()))
twisti@4323 1046 return src; // register or short constant
twisti@4323 1047 guarantee(temp != noreg, "constant offset overflow");
twisti@4323 1048 set(src.as_constant(), temp);
twisti@4323 1049 return temp;
twisti@4323 1050 }
twisti@4323 1051
twisti@4323 1052 // --------------------------------------------------
twisti@4323 1053
twisti@4323 1054 public:
twisti@4323 1055 // traps as per trap.h (SPARC ABI?)
twisti@4323 1056
twisti@4323 1057 void breakpoint_trap();
twisti@4323 1058 void breakpoint_trap(Condition c, CC cc);
twisti@4323 1059 void flush_windows_trap();
twisti@4323 1060 void clean_windows_trap();
twisti@4323 1061 void get_psr_trap();
twisti@4323 1062 void set_psr_trap();
twisti@4323 1063
twisti@4323 1064 // V8/V9 flush_windows
twisti@4323 1065 void flush_windows();
twisti@4323 1066
twisti@4323 1067 // Support for serializing memory accesses between threads
twisti@4323 1068 void serialize_memory(Register thread, Register tmp1, Register tmp2);
twisti@4323 1069
twisti@4323 1070 // Stack frame creation/removal
twisti@4323 1071 void enter();
twisti@4323 1072 void leave();
twisti@4323 1073
twisti@4323 1074 // V8/V9 integer multiply
twisti@4323 1075 void mult(Register s1, Register s2, Register d);
twisti@4323 1076 void mult(Register s1, int simm13a, Register d);
twisti@4323 1077
twisti@4323 1078 // V8/V9 read and write of condition codes.
twisti@4323 1079 void read_ccr(Register d);
twisti@4323 1080 void write_ccr(Register s);
twisti@4323 1081
twisti@4323 1082 // Manipulation of C++ bools
twisti@4323 1083 // These are idioms to flag the need for care with accessing bools but on
twisti@4323 1084 // this platform we assume byte size
twisti@4323 1085
twisti@4323 1086 inline void stbool(Register d, const Address& a) { stb(d, a); }
twisti@4323 1087 inline void ldbool(const Address& a, Register d) { ldub(a, d); }
twisti@4323 1088 inline void movbool( bool boolconst, Register d) { mov( (int) boolconst, d); }
twisti@4323 1089
twisti@4323 1090 // klass oop manipulations if compressed
twisti@4323 1091 void load_klass(Register src_oop, Register klass);
twisti@4323 1092 void store_klass(Register klass, Register dst_oop);
twisti@4323 1093 void store_klass_gap(Register s, Register dst_oop);
twisti@4323 1094
twisti@4323 1095 // oop manipulations
twisti@4323 1096 void load_heap_oop(const Address& s, Register d);
twisti@4323 1097 void load_heap_oop(Register s1, Register s2, Register d);
twisti@4323 1098 void load_heap_oop(Register s1, int simm13a, Register d);
twisti@4323 1099 void load_heap_oop(Register s1, RegisterOrConstant s2, Register d);
twisti@4323 1100 void store_heap_oop(Register d, Register s1, Register s2);
twisti@4323 1101 void store_heap_oop(Register d, Register s1, int simm13a);
twisti@4323 1102 void store_heap_oop(Register d, const Address& a, int offset = 0);
twisti@4323 1103
twisti@4323 1104 void encode_heap_oop(Register src, Register dst);
twisti@4323 1105 void encode_heap_oop(Register r) {
twisti@4323 1106 encode_heap_oop(r, r);
twisti@4323 1107 }
twisti@4323 1108 void decode_heap_oop(Register src, Register dst);
twisti@4323 1109 void decode_heap_oop(Register r) {
twisti@4323 1110 decode_heap_oop(r, r);
twisti@4323 1111 }
twisti@4323 1112 void encode_heap_oop_not_null(Register r);
twisti@4323 1113 void decode_heap_oop_not_null(Register r);
twisti@4323 1114 void encode_heap_oop_not_null(Register src, Register dst);
twisti@4323 1115 void decode_heap_oop_not_null(Register src, Register dst);
twisti@4323 1116
twisti@4323 1117 void encode_klass_not_null(Register r);
twisti@4323 1118 void decode_klass_not_null(Register r);
twisti@4323 1119 void encode_klass_not_null(Register src, Register dst);
twisti@4323 1120 void decode_klass_not_null(Register src, Register dst);
twisti@4323 1121
twisti@4323 1122 // Support for managing the JavaThread pointer (i.e.; the reference to
twisti@4323 1123 // thread-local information).
twisti@4323 1124 void get_thread(); // load G2_thread
twisti@4323 1125 void verify_thread(); // verify G2_thread contents
twisti@4323 1126 void save_thread (const Register threache); // save to cache
twisti@4323 1127 void restore_thread(const Register thread_cache); // restore from cache
twisti@4323 1128
twisti@4323 1129 // Support for last Java frame (but use call_VM instead where possible)
twisti@4323 1130 void set_last_Java_frame(Register last_java_sp, Register last_Java_pc);
twisti@4323 1131 void reset_last_Java_frame(void);
twisti@4323 1132
twisti@4323 1133 // Call into the VM.
twisti@4323 1134 // Passes the thread pointer (in O0) as a prepended argument.
twisti@4323 1135 // Makes sure oop return values are visible to the GC.
twisti@4323 1136 void call_VM(Register oop_result, address entry_point, int number_of_arguments = 0, bool check_exceptions = true);
twisti@4323 1137 void call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions = true);
twisti@4323 1138 void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true);
twisti@4323 1139 void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions = true);
twisti@4323 1140
twisti@4323 1141 // these overloadings are not presently used on SPARC:
twisti@4323 1142 void call_VM(Register oop_result, Register last_java_sp, address entry_point, int number_of_arguments = 0, bool check_exceptions = true);
twisti@4323 1143 void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions = true);
twisti@4323 1144 void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true);
twisti@4323 1145 void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions = true);
twisti@4323 1146
twisti@4323 1147 void call_VM_leaf(Register thread_cache, address entry_point, int number_of_arguments = 0);
twisti@4323 1148 void call_VM_leaf(Register thread_cache, address entry_point, Register arg_1);
twisti@4323 1149 void call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2);
twisti@4323 1150 void call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2, Register arg_3);
twisti@4323 1151
twisti@4323 1152 void get_vm_result (Register oop_result);
twisti@4323 1153 void get_vm_result_2(Register metadata_result);
twisti@4323 1154
twisti@4323 1155 // vm result is currently getting hijacked to for oop preservation
twisti@4323 1156 void set_vm_result(Register oop_result);
twisti@4323 1157
twisti@4323 1158 // Emit the CompiledIC call idiom
twisti@4323 1159 void ic_call(address entry, bool emit_delay = true);
twisti@4323 1160
twisti@4323 1161 // if call_VM_base was called with check_exceptions=false, then call
twisti@4323 1162 // check_and_forward_exception to handle exceptions when it is safe
twisti@4323 1163 void check_and_forward_exception(Register scratch_reg);
twisti@4323 1164
twisti@4323 1165 private:
twisti@4323 1166 // For V8
twisti@4323 1167 void read_ccr_trap(Register ccr_save);
twisti@4323 1168 void write_ccr_trap(Register ccr_save1, Register scratch1, Register scratch2);
twisti@4323 1169
twisti@4323 1170 #ifdef ASSERT
twisti@4323 1171 // For V8 debugging. Uses V8 instruction sequence and checks
twisti@4323 1172 // result with V9 insturctions rdccr and wrccr.
twisti@4323 1173 // Uses Gscatch and Gscatch2
twisti@4323 1174 void read_ccr_v8_assert(Register ccr_save);
twisti@4323 1175 void write_ccr_v8_assert(Register ccr_save);
twisti@4323 1176 #endif // ASSERT
twisti@4323 1177
twisti@4323 1178 public:
twisti@4323 1179
twisti@4323 1180 // Write to card table for - register is destroyed afterwards.
twisti@4323 1181 void card_table_write(jbyte* byte_map_base, Register tmp, Register obj);
twisti@4323 1182
twisti@4323 1183 void card_write_barrier_post(Register store_addr, Register new_val, Register tmp);
twisti@4323 1184
jprovino@4542 1185 #if INCLUDE_ALL_GCS
twisti@4323 1186 // General G1 pre-barrier generator.
twisti@4323 1187 void g1_write_barrier_pre(Register obj, Register index, int offset, Register pre_val, Register tmp, bool preserve_o_regs);
twisti@4323 1188
twisti@4323 1189 // General G1 post-barrier generator
twisti@4323 1190 void g1_write_barrier_post(Register store_addr, Register new_val, Register tmp);
jprovino@4542 1191 #endif // INCLUDE_ALL_GCS
twisti@4323 1192
twisti@4323 1193 // pushes double TOS element of FPU stack on CPU stack; pops from FPU stack
twisti@4323 1194 void push_fTOS();
twisti@4323 1195
twisti@4323 1196 // pops double TOS element from CPU stack and pushes on FPU stack
twisti@4323 1197 void pop_fTOS();
twisti@4323 1198
twisti@4323 1199 void empty_FPU_stack();
twisti@4323 1200
twisti@4323 1201 void push_IU_state();
twisti@4323 1202 void pop_IU_state();
twisti@4323 1203
twisti@4323 1204 void push_FPU_state();
twisti@4323 1205 void pop_FPU_state();
twisti@4323 1206
twisti@4323 1207 void push_CPU_state();
twisti@4323 1208 void pop_CPU_state();
twisti@4323 1209
twisti@4323 1210 // if heap base register is used - reinit it with the correct value
twisti@4323 1211 void reinit_heapbase();
twisti@4323 1212
twisti@4323 1213 // Debugging
twisti@4323 1214 void _verify_oop(Register reg, const char * msg, const char * file, int line);
twisti@4323 1215 void _verify_oop_addr(Address addr, const char * msg, const char * file, int line);
twisti@4323 1216
twisti@4323 1217 // TODO: verify_method and klass metadata (compare against vptr?)
twisti@4323 1218 void _verify_method_ptr(Register reg, const char * msg, const char * file, int line) {}
twisti@4323 1219 void _verify_klass_ptr(Register reg, const char * msg, const char * file, int line){}
twisti@4323 1220
twisti@4323 1221 #define verify_oop(reg) _verify_oop(reg, "broken oop " #reg, __FILE__, __LINE__)
twisti@4323 1222 #define verify_oop_addr(addr) _verify_oop_addr(addr, "broken oop addr ", __FILE__, __LINE__)
twisti@4323 1223 #define verify_method_ptr(reg) _verify_method_ptr(reg, "broken method " #reg, __FILE__, __LINE__)
twisti@4323 1224 #define verify_klass_ptr(reg) _verify_klass_ptr(reg, "broken klass " #reg, __FILE__, __LINE__)
twisti@4323 1225
twisti@4323 1226 // only if +VerifyOops
twisti@4323 1227 void verify_FPU(int stack_depth, const char* s = "illegal FPU state");
twisti@4323 1228 // only if +VerifyFPU
twisti@4323 1229 void stop(const char* msg); // prints msg, dumps registers and stops execution
twisti@4323 1230 void warn(const char* msg); // prints msg, but don't stop
twisti@4323 1231 void untested(const char* what = "");
twisti@4323 1232 void unimplemented(const char* what = "") { char* b = new char[1024]; jio_snprintf(b, 1024, "unimplemented: %s", what); stop(b); }
twisti@4323 1233 void should_not_reach_here() { stop("should not reach here"); }
twisti@4323 1234 void print_CPU_state();
twisti@4323 1235
twisti@4323 1236 // oops in code
twisti@4323 1237 AddressLiteral allocate_oop_address(jobject obj); // allocate_index
twisti@4323 1238 AddressLiteral constant_oop_address(jobject obj); // find_index
twisti@4323 1239 inline void set_oop (jobject obj, Register d); // uses allocate_oop_address
twisti@4323 1240 inline void set_oop_constant (jobject obj, Register d); // uses constant_oop_address
twisti@4323 1241 inline void set_oop (const AddressLiteral& obj_addr, Register d); // same as load_address
twisti@4323 1242
twisti@4323 1243 // metadata in code that we have to keep track of
twisti@4323 1244 AddressLiteral allocate_metadata_address(Metadata* obj); // allocate_index
twisti@4323 1245 AddressLiteral constant_metadata_address(Metadata* obj); // find_index
twisti@4323 1246 inline void set_metadata (Metadata* obj, Register d); // uses allocate_metadata_address
twisti@4323 1247 inline void set_metadata_constant (Metadata* obj, Register d); // uses constant_metadata_address
twisti@4323 1248 inline void set_metadata (const AddressLiteral& obj_addr, Register d); // same as load_address
twisti@4323 1249
twisti@4323 1250 void set_narrow_oop( jobject obj, Register d );
twisti@4323 1251 void set_narrow_klass( Klass* k, Register d );
twisti@4323 1252
twisti@4323 1253 // nop padding
twisti@4323 1254 void align(int modulus);
twisti@4323 1255
twisti@4323 1256 // declare a safepoint
twisti@4323 1257 void safepoint();
twisti@4323 1258
twisti@4323 1259 // factor out part of stop into subroutine to save space
twisti@4323 1260 void stop_subroutine();
twisti@4323 1261 // factor out part of verify_oop into subroutine to save space
twisti@4323 1262 void verify_oop_subroutine();
twisti@4323 1263
twisti@4323 1264 // side-door communication with signalHandler in os_solaris.cpp
twisti@4323 1265 static address _verify_oop_implicit_branch[3];
twisti@4323 1266
twisti@4323 1267 int total_frame_size_in_bytes(int extraWords);
twisti@4323 1268
twisti@4323 1269 // used when extraWords known statically
twisti@4323 1270 void save_frame(int extraWords = 0);
twisti@4323 1271 void save_frame_c1(int size_in_bytes);
twisti@4323 1272 // make a frame, and simultaneously pass up one or two register value
twisti@4323 1273 // into the new register window
twisti@4323 1274 void save_frame_and_mov(int extraWords, Register s1, Register d1, Register s2 = Register(), Register d2 = Register());
twisti@4323 1275
twisti@4323 1276 // give no. (outgoing) params, calc # of words will need on frame
twisti@4323 1277 void calc_mem_param_words(Register Rparam_words, Register Rresult);
twisti@4323 1278
twisti@4323 1279 // used to calculate frame size dynamically
twisti@4323 1280 // result is in bytes and must be negated for save inst
twisti@4323 1281 void calc_frame_size(Register extraWords, Register resultReg);
twisti@4323 1282
twisti@4323 1283 // calc and also save
twisti@4323 1284 void calc_frame_size_and_save(Register extraWords, Register resultReg);
twisti@4323 1285
twisti@4323 1286 static void debug(char* msg, RegistersForDebugging* outWindow);
twisti@4323 1287
twisti@4323 1288 // implementations of bytecodes used by both interpreter and compiler
twisti@4323 1289
twisti@4323 1290 void lcmp( Register Ra_hi, Register Ra_low,
twisti@4323 1291 Register Rb_hi, Register Rb_low,
twisti@4323 1292 Register Rresult);
twisti@4323 1293
twisti@4323 1294 void lneg( Register Rhi, Register Rlow );
twisti@4323 1295
twisti@4323 1296 void lshl( Register Rin_high, Register Rin_low, Register Rcount,
twisti@4323 1297 Register Rout_high, Register Rout_low, Register Rtemp );
twisti@4323 1298
twisti@4323 1299 void lshr( Register Rin_high, Register Rin_low, Register Rcount,
twisti@4323 1300 Register Rout_high, Register Rout_low, Register Rtemp );
twisti@4323 1301
twisti@4323 1302 void lushr( Register Rin_high, Register Rin_low, Register Rcount,
twisti@4323 1303 Register Rout_high, Register Rout_low, Register Rtemp );
twisti@4323 1304
twisti@4323 1305 #ifdef _LP64
twisti@4323 1306 void lcmp( Register Ra, Register Rb, Register Rresult);
twisti@4323 1307 #endif
twisti@4323 1308
twisti@4323 1309 // Load and store values by size and signed-ness
twisti@4323 1310 void load_sized_value( Address src, Register dst, size_t size_in_bytes, bool is_signed);
twisti@4323 1311 void store_sized_value(Register src, Address dst, size_t size_in_bytes);
twisti@4323 1312
twisti@4323 1313 void float_cmp( bool is_float, int unordered_result,
twisti@4323 1314 FloatRegister Fa, FloatRegister Fb,
twisti@4323 1315 Register Rresult);
twisti@4323 1316
twisti@4323 1317 void fneg( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d);
twisti@4323 1318 void fneg( FloatRegisterImpl::Width w, FloatRegister sd ) { Assembler::fneg(w, sd); }
twisti@4323 1319 void fmov( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d);
twisti@4323 1320 void fabs( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d);
twisti@4323 1321
twisti@4323 1322 void save_all_globals_into_locals();
twisti@4323 1323 void restore_globals_from_locals();
twisti@4323 1324
twisti@4323 1325 void casx_under_lock(Register top_ptr_reg, Register top_reg, Register ptr_reg,
twisti@4323 1326 address lock_addr=0, bool use_call_vm=false);
twisti@4323 1327 void cas_under_lock(Register top_ptr_reg, Register top_reg, Register ptr_reg,
twisti@4323 1328 address lock_addr=0, bool use_call_vm=false);
twisti@4323 1329 void casn (Register addr_reg, Register cmp_reg, Register set_reg) ;
twisti@4323 1330
twisti@4323 1331 // These set the icc condition code to equal if the lock succeeded
twisti@4323 1332 // and notEqual if it failed and requires a slow case
twisti@4323 1333 void compiler_lock_object(Register Roop, Register Rmark, Register Rbox,
twisti@4323 1334 Register Rscratch,
twisti@4323 1335 BiasedLockingCounters* counters = NULL,
twisti@4323 1336 bool try_bias = UseBiasedLocking);
twisti@4323 1337 void compiler_unlock_object(Register Roop, Register Rmark, Register Rbox,
twisti@4323 1338 Register Rscratch,
twisti@4323 1339 bool try_bias = UseBiasedLocking);
twisti@4323 1340
twisti@4323 1341 // Biased locking support
twisti@4323 1342 // Upon entry, lock_reg must point to the lock record on the stack,
twisti@4323 1343 // obj_reg must contain the target object, and mark_reg must contain
twisti@4323 1344 // the target object's header.
twisti@4323 1345 // Destroys mark_reg if an attempt is made to bias an anonymously
twisti@4323 1346 // biased lock. In this case a failure will go either to the slow
twisti@4323 1347 // case or fall through with the notEqual condition code set with
twisti@4323 1348 // the expectation that the slow case in the runtime will be called.
twisti@4323 1349 // In the fall-through case where the CAS-based lock is done,
twisti@4323 1350 // mark_reg is not destroyed.
twisti@4323 1351 void biased_locking_enter(Register obj_reg, Register mark_reg, Register temp_reg,
twisti@4323 1352 Label& done, Label* slow_case = NULL,
twisti@4323 1353 BiasedLockingCounters* counters = NULL);
twisti@4323 1354 // Upon entry, the base register of mark_addr must contain the oop.
twisti@4323 1355 // Destroys temp_reg.
twisti@4323 1356
twisti@4323 1357 // If allow_delay_slot_filling is set to true, the next instruction
twisti@4323 1358 // emitted after this one will go in an annulled delay slot if the
twisti@4323 1359 // biased locking exit case failed.
twisti@4323 1360 void biased_locking_exit(Address mark_addr, Register temp_reg, Label& done, bool allow_delay_slot_filling = false);
twisti@4323 1361
twisti@4323 1362 // allocation
twisti@4323 1363 void eden_allocate(
twisti@4323 1364 Register obj, // result: pointer to object after successful allocation
twisti@4323 1365 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
twisti@4323 1366 int con_size_in_bytes, // object size in bytes if known at compile time
twisti@4323 1367 Register t1, // temp register
twisti@4323 1368 Register t2, // temp register
twisti@4323 1369 Label& slow_case // continuation point if fast allocation fails
twisti@4323 1370 );
twisti@4323 1371 void tlab_allocate(
twisti@4323 1372 Register obj, // result: pointer to object after successful allocation
twisti@4323 1373 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
twisti@4323 1374 int con_size_in_bytes, // object size in bytes if known at compile time
twisti@4323 1375 Register t1, // temp register
twisti@4323 1376 Label& slow_case // continuation point if fast allocation fails
twisti@4323 1377 );
twisti@4323 1378 void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case);
twisti@4323 1379 void incr_allocated_bytes(RegisterOrConstant size_in_bytes,
twisti@4323 1380 Register t1, Register t2);
twisti@4323 1381
twisti@4323 1382 // interface method calling
twisti@4323 1383 void lookup_interface_method(Register recv_klass,
twisti@4323 1384 Register intf_klass,
twisti@4323 1385 RegisterOrConstant itable_index,
twisti@4323 1386 Register method_result,
twisti@4323 1387 Register temp_reg, Register temp2_reg,
twisti@4323 1388 Label& no_such_interface);
twisti@4323 1389
twisti@4323 1390 // virtual method calling
twisti@4323 1391 void lookup_virtual_method(Register recv_klass,
twisti@4323 1392 RegisterOrConstant vtable_index,
twisti@4323 1393 Register method_result);
twisti@4323 1394
twisti@4323 1395 // Test sub_klass against super_klass, with fast and slow paths.
twisti@4323 1396
twisti@4323 1397 // The fast path produces a tri-state answer: yes / no / maybe-slow.
twisti@4323 1398 // One of the three labels can be NULL, meaning take the fall-through.
twisti@4323 1399 // If super_check_offset is -1, the value is loaded up from super_klass.
twisti@4323 1400 // No registers are killed, except temp_reg and temp2_reg.
twisti@4323 1401 // If super_check_offset is not -1, temp2_reg is not used and can be noreg.
twisti@4323 1402 void check_klass_subtype_fast_path(Register sub_klass,
twisti@4323 1403 Register super_klass,
twisti@4323 1404 Register temp_reg,
twisti@4323 1405 Register temp2_reg,
twisti@4323 1406 Label* L_success,
twisti@4323 1407 Label* L_failure,
twisti@4323 1408 Label* L_slow_path,
twisti@4323 1409 RegisterOrConstant super_check_offset = RegisterOrConstant(-1));
twisti@4323 1410
twisti@4323 1411 // The rest of the type check; must be wired to a corresponding fast path.
twisti@4323 1412 // It does not repeat the fast path logic, so don't use it standalone.
twisti@4323 1413 // The temp_reg can be noreg, if no temps are available.
twisti@4323 1414 // It can also be sub_klass or super_klass, meaning it's OK to kill that one.
twisti@4323 1415 // Updates the sub's secondary super cache as necessary.
twisti@4323 1416 void check_klass_subtype_slow_path(Register sub_klass,
twisti@4323 1417 Register super_klass,
twisti@4323 1418 Register temp_reg,
twisti@4323 1419 Register temp2_reg,
twisti@4323 1420 Register temp3_reg,
twisti@4323 1421 Register temp4_reg,
twisti@4323 1422 Label* L_success,
twisti@4323 1423 Label* L_failure);
twisti@4323 1424
twisti@4323 1425 // Simplified, combined version, good for typical uses.
twisti@4323 1426 // Falls through on failure.
twisti@4323 1427 void check_klass_subtype(Register sub_klass,
twisti@4323 1428 Register super_klass,
twisti@4323 1429 Register temp_reg,
twisti@4323 1430 Register temp2_reg,
twisti@4323 1431 Label& L_success);
twisti@4323 1432
twisti@4323 1433 // method handles (JSR 292)
twisti@4323 1434 // offset relative to Gargs of argument at tos[arg_slot].
twisti@4323 1435 // (arg_slot == 0 means the last argument, not the first).
twisti@4323 1436 RegisterOrConstant argument_offset(RegisterOrConstant arg_slot,
twisti@4323 1437 Register temp_reg,
twisti@4323 1438 int extra_slot_offset = 0);
twisti@4323 1439 // Address of Gargs and argument_offset.
twisti@4323 1440 Address argument_address(RegisterOrConstant arg_slot,
twisti@4323 1441 Register temp_reg = noreg,
twisti@4323 1442 int extra_slot_offset = 0);
twisti@4323 1443
twisti@4323 1444 // Stack overflow checking
twisti@4323 1445
twisti@4323 1446 // Note: this clobbers G3_scratch
twisti@4323 1447 void bang_stack_with_offset(int offset) {
twisti@4323 1448 // stack grows down, caller passes positive offset
twisti@4323 1449 assert(offset > 0, "must bang with negative offset");
twisti@4323 1450 set((-offset)+STACK_BIAS, G3_scratch);
twisti@4323 1451 st(G0, SP, G3_scratch);
twisti@4323 1452 }
twisti@4323 1453
twisti@4323 1454 // Writes to stack successive pages until offset reached to check for
twisti@4323 1455 // stack overflow + shadow pages. Clobbers tsp and scratch registers.
twisti@4323 1456 void bang_stack_size(Register Rsize, Register Rtsp, Register Rscratch);
twisti@4323 1457
twisti@4323 1458 virtual RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr, Register tmp, int offset);
twisti@4323 1459
twisti@4323 1460 void verify_tlab();
twisti@4323 1461
twisti@4323 1462 Condition negate_condition(Condition cond);
twisti@4323 1463
twisti@4323 1464 // Helper functions for statistics gathering.
twisti@4323 1465 // Conditionally (non-atomically) increments passed counter address, preserving condition codes.
twisti@4323 1466 void cond_inc(Condition cond, address counter_addr, Register Rtemp1, Register Rtemp2);
twisti@4323 1467 // Unconditional increment.
twisti@4323 1468 void inc_counter(address counter_addr, Register Rtmp1, Register Rtmp2);
twisti@4323 1469 void inc_counter(int* counter_addr, Register Rtmp1, Register Rtmp2);
twisti@4323 1470
twisti@4323 1471 // Compare char[] arrays aligned to 4 bytes.
twisti@4323 1472 void char_arrays_equals(Register ary1, Register ary2,
twisti@4323 1473 Register limit, Register result,
twisti@4323 1474 Register chr1, Register chr2, Label& Ldone);
twisti@4323 1475 // Use BIS for zeroing
twisti@4323 1476 void bis_zeroing(Register to, Register count, Register temp, Label& Ldone);
twisti@4323 1477
twisti@4323 1478 #undef VIRTUAL
twisti@4323 1479 };
twisti@4323 1480
twisti@4323 1481 /**
twisti@4323 1482 * class SkipIfEqual:
twisti@4323 1483 *
twisti@4323 1484 * Instantiating this class will result in assembly code being output that will
twisti@4323 1485 * jump around any code emitted between the creation of the instance and it's
twisti@4323 1486 * automatic destruction at the end of a scope block, depending on the value of
twisti@4323 1487 * the flag passed to the constructor, which will be checked at run-time.
twisti@4323 1488 */
twisti@4323 1489 class SkipIfEqual : public StackObj {
twisti@4323 1490 private:
twisti@4323 1491 MacroAssembler* _masm;
twisti@4323 1492 Label _label;
twisti@4323 1493
twisti@4323 1494 public:
twisti@4323 1495 // 'temp' is a temp register that this object can use (and trash)
twisti@4323 1496 SkipIfEqual(MacroAssembler*, Register temp,
twisti@4323 1497 const bool* flag_addr, Assembler::Condition condition);
twisti@4323 1498 ~SkipIfEqual();
twisti@4323 1499 };
twisti@4323 1500
twisti@4323 1501 #endif // CPU_SPARC_VM_MACROASSEMBLER_SPARC_HPP

mercurial