src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp

Tue, 24 Dec 2013 11:48:39 -0800

author
mikael
date
Tue, 24 Dec 2013 11:48:39 -0800
changeset 6198
55fb97c4c58d
parent 5290
87a6f2df28e2
child 6620
17b2fbdb6637
permissions
-rw-r--r--

8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
Summary: Copyright year updated for files modified during 2013
Reviewed-by: twisti, iveresov

twisti@4323 1 /*
drchase@5290 2 * Copyright (c) 1997, 2013, 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_INLINE_HPP
twisti@4323 26 #define CPU_SPARC_VM_MACROASSEMBLER_SPARC_INLINE_HPP
twisti@4323 27
twisti@4323 28 #include "asm/assembler.inline.hpp"
twisti@4323 29 #include "asm/macroAssembler.hpp"
twisti@4323 30 #include "asm/codeBuffer.hpp"
twisti@4323 31 #include "code/codeCache.hpp"
twisti@4323 32
twisti@4323 33 inline bool Address::is_simm13(int offset) { return Assembler::is_simm13(disp() + offset); }
twisti@4323 34
twisti@4323 35
twisti@4323 36 inline int AddressLiteral::low10() const {
twisti@4323 37 return Assembler::low10(value());
twisti@4323 38 }
twisti@4323 39
twisti@4323 40
twisti@4323 41 inline void MacroAssembler::pd_patch_instruction(address branch, address target) {
twisti@4323 42 jint& stub_inst = *(jint*) branch;
twisti@4323 43 stub_inst = patched_branch(target - branch, stub_inst, 0);
twisti@4323 44 }
twisti@4323 45
twisti@4323 46 // Use the right loads/stores for the platform
twisti@4323 47 inline void MacroAssembler::ld_ptr( Register s1, Register s2, Register d ) {
twisti@4323 48 #ifdef _LP64
twisti@4323 49 Assembler::ldx(s1, s2, d);
twisti@4323 50 #else
twisti@4323 51 ld( s1, s2, d);
twisti@4323 52 #endif
twisti@4323 53 }
twisti@4323 54
twisti@4323 55 inline void MacroAssembler::ld_ptr( Register s1, int simm13a, Register d ) {
twisti@4323 56 #ifdef _LP64
twisti@4323 57 Assembler::ldx(s1, simm13a, d);
twisti@4323 58 #else
twisti@4323 59 ld( s1, simm13a, d);
twisti@4323 60 #endif
twisti@4323 61 }
twisti@4323 62
twisti@4323 63 #ifdef ASSERT
twisti@4323 64 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 65 inline void MacroAssembler::ld_ptr( Register s1, ByteSize simm13a, Register d ) {
twisti@4323 66 ld_ptr(s1, in_bytes(simm13a), d);
twisti@4323 67 }
twisti@4323 68 #endif
twisti@4323 69
twisti@4323 70 inline void MacroAssembler::ld_ptr( Register s1, RegisterOrConstant s2, Register d ) {
twisti@4323 71 #ifdef _LP64
twisti@4323 72 ldx(s1, s2, d);
twisti@4323 73 #else
twisti@4323 74 ld( s1, s2, d);
twisti@4323 75 #endif
twisti@4323 76 }
twisti@4323 77
twisti@4323 78 inline void MacroAssembler::ld_ptr(const Address& a, Register d, int offset) {
twisti@4323 79 #ifdef _LP64
twisti@4323 80 ldx(a, d, offset);
twisti@4323 81 #else
twisti@4323 82 ld( a, d, offset);
twisti@4323 83 #endif
twisti@4323 84 }
twisti@4323 85
twisti@4323 86 inline void MacroAssembler::st_ptr( Register d, Register s1, Register s2 ) {
twisti@4323 87 #ifdef _LP64
twisti@4323 88 Assembler::stx(d, s1, s2);
twisti@4323 89 #else
twisti@4323 90 st( d, s1, s2);
twisti@4323 91 #endif
twisti@4323 92 }
twisti@4323 93
twisti@4323 94 inline void MacroAssembler::st_ptr( Register d, Register s1, int simm13a ) {
twisti@4323 95 #ifdef _LP64
twisti@4323 96 Assembler::stx(d, s1, simm13a);
twisti@4323 97 #else
twisti@4323 98 st( d, s1, simm13a);
twisti@4323 99 #endif
twisti@4323 100 }
twisti@4323 101
twisti@4323 102 #ifdef ASSERT
twisti@4323 103 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 104 inline void MacroAssembler::st_ptr( Register d, Register s1, ByteSize simm13a ) {
twisti@4323 105 st_ptr(d, s1, in_bytes(simm13a));
twisti@4323 106 }
twisti@4323 107 #endif
twisti@4323 108
twisti@4323 109 inline void MacroAssembler::st_ptr( Register d, Register s1, RegisterOrConstant s2 ) {
twisti@4323 110 #ifdef _LP64
twisti@4323 111 stx(d, s1, s2);
twisti@4323 112 #else
twisti@4323 113 st( d, s1, s2);
twisti@4323 114 #endif
twisti@4323 115 }
twisti@4323 116
twisti@4323 117 inline void MacroAssembler::st_ptr(Register d, const Address& a, int offset) {
twisti@4323 118 #ifdef _LP64
twisti@4323 119 stx(d, a, offset);
twisti@4323 120 #else
twisti@4323 121 st( d, a, offset);
twisti@4323 122 #endif
twisti@4323 123 }
twisti@4323 124
twisti@4323 125 // Use the right loads/stores for the platform
twisti@4323 126 inline void MacroAssembler::ld_long( Register s1, Register s2, Register d ) {
twisti@4323 127 #ifdef _LP64
twisti@4323 128 Assembler::ldx(s1, s2, d);
twisti@4323 129 #else
twisti@4323 130 Assembler::ldd(s1, s2, d);
twisti@4323 131 #endif
twisti@4323 132 }
twisti@4323 133
twisti@4323 134 inline void MacroAssembler::ld_long( Register s1, int simm13a, Register d ) {
twisti@4323 135 #ifdef _LP64
twisti@4323 136 Assembler::ldx(s1, simm13a, d);
twisti@4323 137 #else
twisti@4323 138 Assembler::ldd(s1, simm13a, d);
twisti@4323 139 #endif
twisti@4323 140 }
twisti@4323 141
twisti@4323 142 inline void MacroAssembler::ld_long( Register s1, RegisterOrConstant s2, Register d ) {
twisti@4323 143 #ifdef _LP64
twisti@4323 144 ldx(s1, s2, d);
twisti@4323 145 #else
twisti@4323 146 ldd(s1, s2, d);
twisti@4323 147 #endif
twisti@4323 148 }
twisti@4323 149
twisti@4323 150 inline void MacroAssembler::ld_long(const Address& a, Register d, int offset) {
twisti@4323 151 #ifdef _LP64
twisti@4323 152 ldx(a, d, offset);
twisti@4323 153 #else
twisti@4323 154 ldd(a, d, offset);
twisti@4323 155 #endif
twisti@4323 156 }
twisti@4323 157
twisti@4323 158 inline void MacroAssembler::st_long( Register d, Register s1, Register s2 ) {
twisti@4323 159 #ifdef _LP64
twisti@4323 160 Assembler::stx(d, s1, s2);
twisti@4323 161 #else
twisti@4323 162 Assembler::std(d, s1, s2);
twisti@4323 163 #endif
twisti@4323 164 }
twisti@4323 165
twisti@4323 166 inline void MacroAssembler::st_long( Register d, Register s1, int simm13a ) {
twisti@4323 167 #ifdef _LP64
twisti@4323 168 Assembler::stx(d, s1, simm13a);
twisti@4323 169 #else
twisti@4323 170 Assembler::std(d, s1, simm13a);
twisti@4323 171 #endif
twisti@4323 172 }
twisti@4323 173
twisti@4323 174 inline void MacroAssembler::st_long( Register d, Register s1, RegisterOrConstant s2 ) {
twisti@4323 175 #ifdef _LP64
twisti@4323 176 stx(d, s1, s2);
twisti@4323 177 #else
twisti@4323 178 std(d, s1, s2);
twisti@4323 179 #endif
twisti@4323 180 }
twisti@4323 181
twisti@4323 182 inline void MacroAssembler::st_long( Register d, const Address& a, int offset ) {
twisti@4323 183 #ifdef _LP64
twisti@4323 184 stx(d, a, offset);
twisti@4323 185 #else
twisti@4323 186 std(d, a, offset);
twisti@4323 187 #endif
twisti@4323 188 }
twisti@4323 189
twisti@4323 190 // Functions for isolating 64 bit shifts for LP64
twisti@4323 191
twisti@4323 192 inline void MacroAssembler::sll_ptr( Register s1, Register s2, Register d ) {
twisti@4323 193 #ifdef _LP64
twisti@4323 194 Assembler::sllx(s1, s2, d);
twisti@4323 195 #else
twisti@4323 196 Assembler::sll( s1, s2, d);
twisti@4323 197 #endif
twisti@4323 198 }
twisti@4323 199
twisti@4323 200 inline void MacroAssembler::sll_ptr( Register s1, int imm6a, Register d ) {
twisti@4323 201 #ifdef _LP64
twisti@4323 202 Assembler::sllx(s1, imm6a, d);
twisti@4323 203 #else
twisti@4323 204 Assembler::sll( s1, imm6a, d);
twisti@4323 205 #endif
twisti@4323 206 }
twisti@4323 207
twisti@4323 208 inline void MacroAssembler::srl_ptr( Register s1, Register s2, Register d ) {
twisti@4323 209 #ifdef _LP64
twisti@4323 210 Assembler::srlx(s1, s2, d);
twisti@4323 211 #else
twisti@4323 212 Assembler::srl( s1, s2, d);
twisti@4323 213 #endif
twisti@4323 214 }
twisti@4323 215
twisti@4323 216 inline void MacroAssembler::srl_ptr( Register s1, int imm6a, Register d ) {
twisti@4323 217 #ifdef _LP64
twisti@4323 218 Assembler::srlx(s1, imm6a, d);
twisti@4323 219 #else
twisti@4323 220 Assembler::srl( s1, imm6a, d);
twisti@4323 221 #endif
twisti@4323 222 }
twisti@4323 223
twisti@4323 224 inline void MacroAssembler::sll_ptr( Register s1, RegisterOrConstant s2, Register d ) {
twisti@4323 225 if (s2.is_register()) sll_ptr(s1, s2.as_register(), d);
twisti@4323 226 else sll_ptr(s1, s2.as_constant(), d);
twisti@4323 227 }
twisti@4323 228
twisti@4323 229 // Use the right branch for the platform
twisti@4323 230
twisti@4323 231 inline void MacroAssembler::br( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
morris@5283 232 Assembler::bp(c, a, icc, p, d, rt);
twisti@4323 233 }
twisti@4323 234
twisti@4323 235 inline void MacroAssembler::br( Condition c, bool a, Predict p, Label& L ) {
twisti@4323 236 br(c, a, p, target(L));
twisti@4323 237 }
twisti@4323 238
twisti@4323 239
twisti@4323 240 // Branch that tests either xcc or icc depending on the
twisti@4323 241 // architecture compiled (LP64 or not)
twisti@4323 242 inline void MacroAssembler::brx( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
twisti@4323 243 #ifdef _LP64
twisti@4323 244 Assembler::bp(c, a, xcc, p, d, rt);
twisti@4323 245 #else
twisti@4323 246 MacroAssembler::br(c, a, p, d, rt);
twisti@4323 247 #endif
twisti@4323 248 }
twisti@4323 249
twisti@4323 250 inline void MacroAssembler::brx( Condition c, bool a, Predict p, Label& L ) {
twisti@4323 251 brx(c, a, p, target(L));
twisti@4323 252 }
twisti@4323 253
twisti@4323 254 inline void MacroAssembler::ba( Label& L ) {
twisti@4323 255 br(always, false, pt, L);
twisti@4323 256 }
twisti@4323 257
twisti@4323 258 // Warning: V9 only functions
twisti@4323 259 inline void MacroAssembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) {
twisti@4323 260 Assembler::bp(c, a, cc, p, d, rt);
twisti@4323 261 }
twisti@4323 262
twisti@4323 263 inline void MacroAssembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) {
twisti@4323 264 Assembler::bp(c, a, cc, p, L);
twisti@4323 265 }
twisti@4323 266
twisti@4323 267 inline void MacroAssembler::fb( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
morris@5283 268 fbp(c, a, fcc0, p, d, rt);
twisti@4323 269 }
twisti@4323 270
twisti@4323 271 inline void MacroAssembler::fb( Condition c, bool a, Predict p, Label& L ) {
twisti@4323 272 fb(c, a, p, target(L));
twisti@4323 273 }
twisti@4323 274
twisti@4323 275 inline void MacroAssembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) {
twisti@4323 276 Assembler::fbp(c, a, cc, p, d, rt);
twisti@4323 277 }
twisti@4323 278
twisti@4323 279 inline void MacroAssembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) {
twisti@4323 280 Assembler::fbp(c, a, cc, p, L);
twisti@4323 281 }
twisti@4323 282
twisti@4323 283 inline void MacroAssembler::jmp( Register s1, Register s2 ) { jmpl( s1, s2, G0 ); }
twisti@4323 284 inline void MacroAssembler::jmp( Register s1, int simm13a, RelocationHolder const& rspec ) { jmpl( s1, simm13a, G0, rspec); }
twisti@4323 285
twisti@4323 286 inline bool MacroAssembler::is_far_target(address d) {
twisti@4323 287 if (ForceUnreachable) {
twisti@4323 288 // References outside the code cache should be treated as far
twisti@4323 289 return d < CodeCache::low_bound() || d > CodeCache::high_bound();
twisti@4323 290 }
twisti@4323 291 return !is_in_wdisp30_range(d, CodeCache::low_bound()) || !is_in_wdisp30_range(d, CodeCache::high_bound());
twisti@4323 292 }
twisti@4323 293
twisti@4323 294 // Call with a check to see if we need to deal with the added
twisti@4323 295 // expense of relocation and if we overflow the displacement
twisti@4323 296 // of the quick call instruction.
twisti@4323 297 inline void MacroAssembler::call( address d, relocInfo::relocType rt ) {
twisti@4323 298 #ifdef _LP64
twisti@4323 299 intptr_t disp;
twisti@4323 300 // NULL is ok because it will be relocated later.
twisti@4323 301 // Must change NULL to a reachable address in order to
twisti@4323 302 // pass asserts here and in wdisp.
twisti@4323 303 if ( d == NULL )
twisti@4323 304 d = pc();
twisti@4323 305
twisti@4323 306 // Is this address within range of the call instruction?
twisti@4323 307 // If not, use the expensive instruction sequence
twisti@4323 308 if (is_far_target(d)) {
twisti@4323 309 relocate(rt);
twisti@4323 310 AddressLiteral dest(d);
twisti@4323 311 jumpl_to(dest, O7, O7);
twisti@4323 312 } else {
twisti@4323 313 Assembler::call(d, rt);
twisti@4323 314 }
twisti@4323 315 #else
twisti@4323 316 Assembler::call( d, rt );
twisti@4323 317 #endif
twisti@4323 318 }
twisti@4323 319
twisti@4323 320 inline void MacroAssembler::call( Label& L, relocInfo::relocType rt ) {
twisti@4323 321 MacroAssembler::call( target(L), rt);
twisti@4323 322 }
twisti@4323 323
twisti@4323 324
twisti@4323 325
twisti@4323 326 inline void MacroAssembler::callr( Register s1, Register s2 ) { jmpl( s1, s2, O7 ); }
twisti@4323 327 inline void MacroAssembler::callr( Register s1, int simm13a, RelocationHolder const& rspec ) { jmpl( s1, simm13a, O7, rspec); }
twisti@4323 328
twisti@4323 329 // prefetch instruction
twisti@4323 330 inline void MacroAssembler::iprefetch( address d, relocInfo::relocType rt ) {
morris@5283 331 Assembler::bp( never, true, xcc, pt, d, rt );
twisti@4323 332 Assembler::bp( never, true, xcc, pt, d, rt );
twisti@4323 333 }
twisti@4323 334 inline void MacroAssembler::iprefetch( Label& L) { iprefetch( target(L) ); }
twisti@4323 335
twisti@4323 336
twisti@4323 337 // clobbers o7 on V8!!
twisti@4323 338 // returns delta from gotten pc to addr after
twisti@4323 339 inline int MacroAssembler::get_pc( Register d ) {
twisti@4323 340 int x = offset();
morris@5283 341 rdpc(d);
twisti@4323 342 return offset() - x;
twisti@4323 343 }
twisti@4323 344
twisti@4323 345
twisti@4323 346 // Note: All MacroAssembler::set_foo functions are defined out-of-line.
twisti@4323 347
twisti@4323 348
twisti@4323 349 // Loads the current PC of the following instruction as an immediate value in
twisti@4323 350 // 2 instructions. All PCs in the CodeCache are within 2 Gig of each other.
twisti@4323 351 inline intptr_t MacroAssembler::load_pc_address( Register reg, int bytes_to_skip ) {
twisti@4323 352 intptr_t thepc = (intptr_t)pc() + 2*BytesPerInstWord + bytes_to_skip;
twisti@4323 353 #ifdef _LP64
twisti@4323 354 Unimplemented();
twisti@4323 355 #else
twisti@4323 356 Assembler::sethi( thepc & ~0x3ff, reg, internal_word_Relocation::spec((address)thepc));
twisti@4323 357 add(reg, thepc & 0x3ff, reg, internal_word_Relocation::spec((address)thepc));
twisti@4323 358 #endif
twisti@4323 359 return thepc;
twisti@4323 360 }
twisti@4323 361
twisti@4323 362
twisti@4323 363 inline void MacroAssembler::load_contents(const AddressLiteral& addrlit, Register d, int offset) {
twisti@4323 364 assert_not_delayed();
twisti@4323 365 if (ForceUnreachable) {
twisti@4323 366 patchable_sethi(addrlit, d);
twisti@4323 367 } else {
twisti@4323 368 sethi(addrlit, d);
twisti@4323 369 }
twisti@4323 370 ld(d, addrlit.low10() + offset, d);
twisti@4323 371 }
twisti@4323 372
twisti@4323 373
twisti@4323 374 inline void MacroAssembler::load_bool_contents(const AddressLiteral& addrlit, Register d, int offset) {
twisti@4323 375 assert_not_delayed();
twisti@4323 376 if (ForceUnreachable) {
twisti@4323 377 patchable_sethi(addrlit, d);
twisti@4323 378 } else {
twisti@4323 379 sethi(addrlit, d);
twisti@4323 380 }
twisti@4323 381 ldub(d, addrlit.low10() + offset, d);
twisti@4323 382 }
twisti@4323 383
twisti@4323 384
twisti@4323 385 inline void MacroAssembler::load_ptr_contents(const AddressLiteral& addrlit, Register d, int offset) {
twisti@4323 386 assert_not_delayed();
twisti@4323 387 if (ForceUnreachable) {
twisti@4323 388 patchable_sethi(addrlit, d);
twisti@4323 389 } else {
twisti@4323 390 sethi(addrlit, d);
twisti@4323 391 }
twisti@4323 392 ld_ptr(d, addrlit.low10() + offset, d);
twisti@4323 393 }
twisti@4323 394
twisti@4323 395
twisti@4323 396 inline void MacroAssembler::store_contents(Register s, const AddressLiteral& addrlit, Register temp, int offset) {
twisti@4323 397 assert_not_delayed();
twisti@4323 398 if (ForceUnreachable) {
twisti@4323 399 patchable_sethi(addrlit, temp);
twisti@4323 400 } else {
twisti@4323 401 sethi(addrlit, temp);
twisti@4323 402 }
twisti@4323 403 st(s, temp, addrlit.low10() + offset);
twisti@4323 404 }
twisti@4323 405
twisti@4323 406
twisti@4323 407 inline void MacroAssembler::store_ptr_contents(Register s, const AddressLiteral& addrlit, Register temp, int offset) {
twisti@4323 408 assert_not_delayed();
twisti@4323 409 if (ForceUnreachable) {
twisti@4323 410 patchable_sethi(addrlit, temp);
twisti@4323 411 } else {
twisti@4323 412 sethi(addrlit, temp);
twisti@4323 413 }
twisti@4323 414 st_ptr(s, temp, addrlit.low10() + offset);
twisti@4323 415 }
twisti@4323 416
twisti@4323 417
twisti@4323 418 // This code sequence is relocatable to any address, even on LP64.
twisti@4323 419 inline void MacroAssembler::jumpl_to(const AddressLiteral& addrlit, Register temp, Register d, int offset) {
twisti@4323 420 assert_not_delayed();
twisti@4323 421 // Force fixed length sethi because NativeJump and NativeFarCall don't handle
twisti@4323 422 // variable length instruction streams.
twisti@4323 423 patchable_sethi(addrlit, temp);
twisti@4323 424 jmpl(temp, addrlit.low10() + offset, d);
twisti@4323 425 }
twisti@4323 426
twisti@4323 427
twisti@4323 428 inline void MacroAssembler::jump_to(const AddressLiteral& addrlit, Register temp, int offset) {
twisti@4323 429 jumpl_to(addrlit, temp, G0, offset);
twisti@4323 430 }
twisti@4323 431
twisti@4323 432
twisti@4323 433 inline void MacroAssembler::jump_indirect_to(Address& a, Register temp,
twisti@4323 434 int ld_offset, int jmp_offset) {
twisti@4323 435 assert_not_delayed();
twisti@4323 436 //sethi(al); // sethi is caller responsibility for this one
twisti@4323 437 ld_ptr(a, temp, ld_offset);
twisti@4323 438 jmp(temp, jmp_offset);
twisti@4323 439 }
twisti@4323 440
twisti@4323 441
twisti@4323 442 inline void MacroAssembler::set_metadata(Metadata* obj, Register d) {
twisti@4323 443 set_metadata(allocate_metadata_address(obj), d);
twisti@4323 444 }
twisti@4323 445
twisti@4323 446 inline void MacroAssembler::set_metadata_constant(Metadata* obj, Register d) {
twisti@4323 447 set_metadata(constant_metadata_address(obj), d);
twisti@4323 448 }
twisti@4323 449
twisti@4323 450 inline void MacroAssembler::set_metadata(const AddressLiteral& obj_addr, Register d) {
twisti@4323 451 assert(obj_addr.rspec().type() == relocInfo::metadata_type, "must be a metadata reloc");
twisti@4323 452 set(obj_addr, d);
twisti@4323 453 }
twisti@4323 454
twisti@4323 455 inline void MacroAssembler::set_oop(jobject obj, Register d) {
twisti@4323 456 set_oop(allocate_oop_address(obj), d);
twisti@4323 457 }
twisti@4323 458
twisti@4323 459
twisti@4323 460 inline void MacroAssembler::set_oop_constant(jobject obj, Register d) {
twisti@4323 461 set_oop(constant_oop_address(obj), d);
twisti@4323 462 }
twisti@4323 463
twisti@4323 464
twisti@4323 465 inline void MacroAssembler::set_oop(const AddressLiteral& obj_addr, Register d) {
twisti@4323 466 assert(obj_addr.rspec().type() == relocInfo::oop_type, "must be an oop reloc");
twisti@4323 467 set(obj_addr, d);
twisti@4323 468 }
twisti@4323 469
twisti@4323 470
twisti@4323 471 inline void MacroAssembler::load_argument( Argument& a, Register d ) {
twisti@4323 472 if (a.is_register())
twisti@4323 473 mov(a.as_register(), d);
twisti@4323 474 else
twisti@4323 475 ld (a.as_address(), d);
twisti@4323 476 }
twisti@4323 477
twisti@4323 478 inline void MacroAssembler::store_argument( Register s, Argument& a ) {
twisti@4323 479 if (a.is_register())
twisti@4323 480 mov(s, a.as_register());
twisti@4323 481 else
twisti@4323 482 st_ptr (s, a.as_address()); // ABI says everything is right justified.
twisti@4323 483 }
twisti@4323 484
twisti@4323 485 inline void MacroAssembler::store_ptr_argument( Register s, Argument& a ) {
twisti@4323 486 if (a.is_register())
twisti@4323 487 mov(s, a.as_register());
twisti@4323 488 else
twisti@4323 489 st_ptr (s, a.as_address());
twisti@4323 490 }
twisti@4323 491
twisti@4323 492
twisti@4323 493 #ifdef _LP64
twisti@4323 494 inline void MacroAssembler::store_float_argument( FloatRegister s, Argument& a ) {
twisti@4323 495 if (a.is_float_register())
twisti@4323 496 // V9 ABI has F1, F3, F5 are used to pass instead of O0, O1, O2
twisti@4323 497 fmov(FloatRegisterImpl::S, s, a.as_float_register() );
twisti@4323 498 else
twisti@4323 499 // Floats are stored in the high half of the stack entry
twisti@4323 500 // The low half is undefined per the ABI.
twisti@4323 501 stf(FloatRegisterImpl::S, s, a.as_address(), sizeof(jfloat));
twisti@4323 502 }
twisti@4323 503
twisti@4323 504 inline void MacroAssembler::store_double_argument( FloatRegister s, Argument& a ) {
twisti@4323 505 if (a.is_float_register())
twisti@4323 506 // V9 ABI has D0, D2, D4 are used to pass instead of O0, O1, O2
twisti@4323 507 fmov(FloatRegisterImpl::D, s, a.as_double_register() );
twisti@4323 508 else
twisti@4323 509 stf(FloatRegisterImpl::D, s, a.as_address());
twisti@4323 510 }
twisti@4323 511
twisti@4323 512 inline void MacroAssembler::store_long_argument( Register s, Argument& a ) {
twisti@4323 513 if (a.is_register())
twisti@4323 514 mov(s, a.as_register());
twisti@4323 515 else
twisti@4323 516 stx(s, a.as_address());
twisti@4323 517 }
twisti@4323 518 #endif
twisti@4323 519
twisti@4323 520 inline void MacroAssembler::add(Register s1, int simm13a, Register d, relocInfo::relocType rtype) {
twisti@4323 521 relocate(rtype);
twisti@4323 522 add(s1, simm13a, d);
twisti@4323 523 }
twisti@4323 524 inline void MacroAssembler::add(Register s1, int simm13a, Register d, RelocationHolder const& rspec) {
twisti@4323 525 relocate(rspec);
twisti@4323 526 add(s1, simm13a, d);
twisti@4323 527 }
twisti@4323 528
twisti@4323 529 // form effective addresses this way:
twisti@4323 530 inline void MacroAssembler::add(const Address& a, Register d, int offset) {
twisti@4323 531 if (a.has_index()) add(a.base(), a.index(), d);
twisti@4323 532 else { add(a.base(), a.disp() + offset, d, a.rspec(offset)); offset = 0; }
twisti@4323 533 if (offset != 0) add(d, offset, d);
twisti@4323 534 }
twisti@4323 535 inline void MacroAssembler::add(Register s1, RegisterOrConstant s2, Register d, int offset) {
twisti@4323 536 if (s2.is_register()) add(s1, s2.as_register(), d);
twisti@4323 537 else { add(s1, s2.as_constant() + offset, d); offset = 0; }
twisti@4323 538 if (offset != 0) add(d, offset, d);
twisti@4323 539 }
twisti@4323 540
twisti@4323 541 inline void MacroAssembler::andn(Register s1, RegisterOrConstant s2, Register d) {
twisti@4323 542 if (s2.is_register()) andn(s1, s2.as_register(), d);
twisti@4323 543 else andn(s1, s2.as_constant(), d);
twisti@4323 544 }
twisti@4323 545
twisti@4323 546 inline void MacroAssembler::clrb( Register s1, Register s2) { stb( G0, s1, s2 ); }
twisti@4323 547 inline void MacroAssembler::clrh( Register s1, Register s2) { sth( G0, s1, s2 ); }
twisti@4323 548 inline void MacroAssembler::clr( Register s1, Register s2) { stw( G0, s1, s2 ); }
twisti@4323 549 inline void MacroAssembler::clrx( Register s1, Register s2) { stx( G0, s1, s2 ); }
twisti@4323 550
twisti@4323 551 inline void MacroAssembler::clrb( Register s1, int simm13a) { stb( G0, s1, simm13a); }
twisti@4323 552 inline void MacroAssembler::clrh( Register s1, int simm13a) { sth( G0, s1, simm13a); }
twisti@4323 553 inline void MacroAssembler::clr( Register s1, int simm13a) { stw( G0, s1, simm13a); }
twisti@4323 554 inline void MacroAssembler::clrx( Register s1, int simm13a) { stx( G0, s1, simm13a); }
twisti@4323 555
twisti@4323 556 #ifdef _LP64
twisti@4323 557 // Make all 32 bit loads signed so 64 bit registers maintain proper sign
twisti@4323 558 inline void MacroAssembler::ld( Register s1, Register s2, Register d) { ldsw( s1, s2, d); }
twisti@4323 559 inline void MacroAssembler::ld( Register s1, int simm13a, Register d) { ldsw( s1, simm13a, d); }
twisti@4323 560 #else
twisti@4323 561 inline void MacroAssembler::ld( Register s1, Register s2, Register d) { lduw( s1, s2, d); }
twisti@4323 562 inline void MacroAssembler::ld( Register s1, int simm13a, Register d) { lduw( s1, simm13a, d); }
twisti@4323 563 #endif
twisti@4323 564
twisti@4323 565 #ifdef ASSERT
twisti@4323 566 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 567 # ifdef _LP64
twisti@4323 568 inline void MacroAssembler::ld(Register s1, ByteSize simm13a, Register d) { ldsw( s1, in_bytes(simm13a), d); }
twisti@4323 569 # else
twisti@4323 570 inline void MacroAssembler::ld(Register s1, ByteSize simm13a, Register d) { lduw( s1, in_bytes(simm13a), d); }
twisti@4323 571 # endif
twisti@4323 572 #endif
twisti@4323 573
twisti@4323 574 inline void MacroAssembler::ld( const Address& a, Register d, int offset) {
twisti@4323 575 if (a.has_index()) { assert(offset == 0, ""); ld( a.base(), a.index(), d); }
twisti@4323 576 else { ld( a.base(), a.disp() + offset, d); }
twisti@4323 577 }
twisti@4323 578
twisti@4323 579 inline void MacroAssembler::ldsb(const Address& a, Register d, int offset) {
twisti@4323 580 if (a.has_index()) { assert(offset == 0, ""); ldsb(a.base(), a.index(), d); }
twisti@4323 581 else { ldsb(a.base(), a.disp() + offset, d); }
twisti@4323 582 }
twisti@4323 583 inline void MacroAssembler::ldsh(const Address& a, Register d, int offset) {
twisti@4323 584 if (a.has_index()) { assert(offset == 0, ""); ldsh(a.base(), a.index(), d); }
twisti@4323 585 else { ldsh(a.base(), a.disp() + offset, d); }
twisti@4323 586 }
twisti@4323 587 inline void MacroAssembler::ldsw(const Address& a, Register d, int offset) {
twisti@4323 588 if (a.has_index()) { assert(offset == 0, ""); ldsw(a.base(), a.index(), d); }
twisti@4323 589 else { ldsw(a.base(), a.disp() + offset, d); }
twisti@4323 590 }
twisti@4323 591 inline void MacroAssembler::ldub(const Address& a, Register d, int offset) {
twisti@4323 592 if (a.has_index()) { assert(offset == 0, ""); ldub(a.base(), a.index(), d); }
twisti@4323 593 else { ldub(a.base(), a.disp() + offset, d); }
twisti@4323 594 }
twisti@4323 595 inline void MacroAssembler::lduh(const Address& a, Register d, int offset) {
twisti@4323 596 if (a.has_index()) { assert(offset == 0, ""); lduh(a.base(), a.index(), d); }
twisti@4323 597 else { lduh(a.base(), a.disp() + offset, d); }
twisti@4323 598 }
twisti@4323 599 inline void MacroAssembler::lduw(const Address& a, Register d, int offset) {
twisti@4323 600 if (a.has_index()) { assert(offset == 0, ""); lduw(a.base(), a.index(), d); }
twisti@4323 601 else { lduw(a.base(), a.disp() + offset, d); }
twisti@4323 602 }
twisti@4323 603 inline void MacroAssembler::ldd( const Address& a, Register d, int offset) {
twisti@4323 604 if (a.has_index()) { assert(offset == 0, ""); ldd( a.base(), a.index(), d); }
twisti@4323 605 else { ldd( a.base(), a.disp() + offset, d); }
twisti@4323 606 }
twisti@4323 607 inline void MacroAssembler::ldx( const Address& a, Register d, int offset) {
twisti@4323 608 if (a.has_index()) { assert(offset == 0, ""); ldx( a.base(), a.index(), d); }
twisti@4323 609 else { ldx( a.base(), a.disp() + offset, d); }
twisti@4323 610 }
twisti@4323 611
twisti@4323 612 inline void MacroAssembler::ldub(Register s1, RegisterOrConstant s2, Register d) { ldub(Address(s1, s2), d); }
twisti@4323 613 inline void MacroAssembler::ldsb(Register s1, RegisterOrConstant s2, Register d) { ldsb(Address(s1, s2), d); }
twisti@4323 614 inline void MacroAssembler::lduh(Register s1, RegisterOrConstant s2, Register d) { lduh(Address(s1, s2), d); }
twisti@4323 615 inline void MacroAssembler::ldsh(Register s1, RegisterOrConstant s2, Register d) { ldsh(Address(s1, s2), d); }
twisti@4323 616 inline void MacroAssembler::lduw(Register s1, RegisterOrConstant s2, Register d) { lduw(Address(s1, s2), d); }
twisti@4323 617 inline void MacroAssembler::ldsw(Register s1, RegisterOrConstant s2, Register d) { ldsw(Address(s1, s2), d); }
twisti@4323 618 inline void MacroAssembler::ldx( Register s1, RegisterOrConstant s2, Register d) { ldx( Address(s1, s2), d); }
twisti@4323 619 inline void MacroAssembler::ld( Register s1, RegisterOrConstant s2, Register d) { ld( Address(s1, s2), d); }
twisti@4323 620 inline void MacroAssembler::ldd( Register s1, RegisterOrConstant s2, Register d) { ldd( Address(s1, s2), d); }
twisti@4323 621
twisti@4323 622 inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, Register s1, RegisterOrConstant s2, FloatRegister d) {
twisti@4323 623 if (s2.is_register()) ldf(w, s1, s2.as_register(), d);
twisti@4323 624 else ldf(w, s1, s2.as_constant(), d);
twisti@4323 625 }
twisti@4323 626
twisti@4323 627 inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset) {
twisti@4323 628 relocate(a.rspec(offset));
twisti@4323 629 ldf(w, a.base(), a.disp() + offset, d);
twisti@4323 630 }
twisti@4323 631
twisti@4323 632 // returns if membar generates anything, obviously this code should mirror
twisti@4323 633 // membar below.
twisti@4323 634 inline bool MacroAssembler::membar_has_effect( Membar_mask_bits const7a ) {
morris@5283 635 if (!os::is_MP())
morris@5283 636 return false; // Not needed on single CPU
morris@5283 637 const Membar_mask_bits effective_mask =
morris@5283 638 Membar_mask_bits(const7a & ~(LoadLoad | LoadStore | StoreStore));
morris@5283 639 return (effective_mask != 0);
twisti@4323 640 }
twisti@4323 641
twisti@4323 642 inline void MacroAssembler::membar( Membar_mask_bits const7a ) {
twisti@4323 643 // Uniprocessors do not need memory barriers
morris@5283 644 if (!os::is_MP())
morris@5283 645 return;
twisti@4323 646 // Weakened for current Sparcs and TSO. See the v9 manual, sections 8.4.3,
twisti@4323 647 // 8.4.4.3, a.31 and a.50.
morris@5283 648 // Under TSO, setting bit 3, 2, or 0 is redundant, so the only value
morris@5283 649 // of the mmask subfield of const7a that does anything that isn't done
morris@5283 650 // implicitly is StoreLoad.
morris@5283 651 const Membar_mask_bits effective_mask =
morris@5283 652 Membar_mask_bits(const7a & ~(LoadLoad | LoadStore | StoreStore));
morris@5283 653 if (effective_mask != 0) {
morris@5283 654 Assembler::membar(effective_mask);
twisti@4323 655 }
twisti@4323 656 }
twisti@4323 657
twisti@4323 658 inline void MacroAssembler::prefetch(const Address& a, PrefetchFcn f, int offset) {
twisti@4323 659 relocate(a.rspec(offset));
twisti@4323 660 assert(!a.has_index(), "");
twisti@4323 661 prefetch(a.base(), a.disp() + offset, f);
twisti@4323 662 }
twisti@4323 663
twisti@4323 664 inline void MacroAssembler::st(Register d, Register s1, Register s2) { stw(d, s1, s2); }
twisti@4323 665 inline void MacroAssembler::st(Register d, Register s1, int simm13a) { stw(d, s1, simm13a); }
twisti@4323 666
twisti@4323 667 #ifdef ASSERT
twisti@4323 668 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@4323 669 inline void MacroAssembler::st(Register d, Register s1, ByteSize simm13a) { stw(d, s1, in_bytes(simm13a)); }
twisti@4323 670 #endif
twisti@4323 671
twisti@4323 672 inline void MacroAssembler::st(Register d, const Address& a, int offset) {
twisti@4323 673 if (a.has_index()) { assert(offset == 0, ""); st( d, a.base(), a.index() ); }
twisti@4323 674 else { st( d, a.base(), a.disp() + offset); }
twisti@4323 675 }
twisti@4323 676
twisti@4323 677 inline void MacroAssembler::stb(Register d, const Address& a, int offset) {
twisti@4323 678 if (a.has_index()) { assert(offset == 0, ""); stb(d, a.base(), a.index() ); }
twisti@4323 679 else { stb(d, a.base(), a.disp() + offset); }
twisti@4323 680 }
twisti@4323 681 inline void MacroAssembler::sth(Register d, const Address& a, int offset) {
twisti@4323 682 if (a.has_index()) { assert(offset == 0, ""); sth(d, a.base(), a.index() ); }
twisti@4323 683 else { sth(d, a.base(), a.disp() + offset); }
twisti@4323 684 }
twisti@4323 685 inline void MacroAssembler::stw(Register d, const Address& a, int offset) {
twisti@4323 686 if (a.has_index()) { assert(offset == 0, ""); stw(d, a.base(), a.index() ); }
twisti@4323 687 else { stw(d, a.base(), a.disp() + offset); }
twisti@4323 688 }
twisti@4323 689 inline void MacroAssembler::std(Register d, const Address& a, int offset) {
twisti@4323 690 if (a.has_index()) { assert(offset == 0, ""); std(d, a.base(), a.index() ); }
twisti@4323 691 else { std(d, a.base(), a.disp() + offset); }
twisti@4323 692 }
twisti@4323 693 inline void MacroAssembler::stx(Register d, const Address& a, int offset) {
twisti@4323 694 if (a.has_index()) { assert(offset == 0, ""); stx(d, a.base(), a.index() ); }
twisti@4323 695 else { stx(d, a.base(), a.disp() + offset); }
twisti@4323 696 }
twisti@4323 697
twisti@4323 698 inline void MacroAssembler::stb(Register d, Register s1, RegisterOrConstant s2) { stb(d, Address(s1, s2)); }
twisti@4323 699 inline void MacroAssembler::sth(Register d, Register s1, RegisterOrConstant s2) { sth(d, Address(s1, s2)); }
twisti@4323 700 inline void MacroAssembler::stw(Register d, Register s1, RegisterOrConstant s2) { stw(d, Address(s1, s2)); }
twisti@4323 701 inline void MacroAssembler::stx(Register d, Register s1, RegisterOrConstant s2) { stx(d, Address(s1, s2)); }
twisti@4323 702 inline void MacroAssembler::std(Register d, Register s1, RegisterOrConstant s2) { std(d, Address(s1, s2)); }
twisti@4323 703 inline void MacroAssembler::st( Register d, Register s1, RegisterOrConstant s2) { st( d, Address(s1, s2)); }
twisti@4323 704
twisti@4323 705 inline void MacroAssembler::stf(FloatRegisterImpl::Width w, FloatRegister d, Register s1, RegisterOrConstant s2) {
twisti@4323 706 if (s2.is_register()) stf(w, d, s1, s2.as_register());
twisti@4323 707 else stf(w, d, s1, s2.as_constant());
twisti@4323 708 }
twisti@4323 709
twisti@4323 710 inline void MacroAssembler::stf(FloatRegisterImpl::Width w, FloatRegister d, const Address& a, int offset) {
twisti@4323 711 relocate(a.rspec(offset));
twisti@4323 712 if (a.has_index()) { assert(offset == 0, ""); stf(w, d, a.base(), a.index() ); }
twisti@4323 713 else { stf(w, d, a.base(), a.disp() + offset); }
twisti@4323 714 }
twisti@4323 715
twisti@4323 716 inline void MacroAssembler::sub(Register s1, RegisterOrConstant s2, Register d, int offset) {
twisti@4323 717 if (s2.is_register()) sub(s1, s2.as_register(), d);
twisti@4323 718 else { sub(s1, s2.as_constant() + offset, d); offset = 0; }
twisti@4323 719 if (offset != 0) sub(d, offset, d);
twisti@4323 720 }
twisti@4323 721
drchase@5290 722 inline void MacroAssembler::swap(const Address& a, Register d, int offset) {
twisti@4323 723 relocate(a.rspec(offset));
twisti@4323 724 if (a.has_index()) { assert(offset == 0, ""); swap(a.base(), a.index(), d ); }
twisti@4323 725 else { swap(a.base(), a.disp() + offset, d); }
twisti@4323 726 }
twisti@4323 727
twisti@4323 728 #endif // CPU_SPARC_VM_MACROASSEMBLER_SPARC_INLINE_HPP

mercurial