assembler_x86.cpp revision 3932
0N/A/*
3050N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "assembler_x86.inline.hpp"
1879N/A#include "gc_interface/collectedHeap.inline.hpp"
1879N/A#include "interpreter/interpreter.hpp"
1879N/A#include "memory/cardTableModRefBS.hpp"
1879N/A#include "memory/resourceArea.hpp"
1879N/A#include "prims/methodHandles.hpp"
1879N/A#include "runtime/biasedLocking.hpp"
1879N/A#include "runtime/interfaceSupport.hpp"
1879N/A#include "runtime/objectMonitor.hpp"
1879N/A#include "runtime/os.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
1879N/A#include "runtime/stubRoutines.hpp"
1879N/A#ifndef SERIALGC
1879N/A#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
1879N/A#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
1879N/A#include "gc_implementation/g1/heapRegion.hpp"
1879N/A#endif
0N/A
3932N/A#ifdef PRODUCT
3932N/A#define BLOCK_COMMENT(str) /* nothing */
3932N/A#define STOP(error) stop(error)
3932N/A#else
3932N/A#define BLOCK_COMMENT(str) block_comment(str)
3932N/A#define STOP(error) block_comment(error); stop(error)
3932N/A#endif
3932N/A
3932N/A#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
0N/A// Implementation of AddressLiteral
0N/A
0N/AAddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) {
0N/A _is_lval = false;
0N/A _target = target;
0N/A switch (rtype) {
0N/A case relocInfo::oop_type:
0N/A // Oops are a special case. Normally they would be their own section
0N/A // but in cases like icBuffer they are literals in the code stream that
0N/A // we don't have a section for. We use none so that we get a literal address
0N/A // which is always patchable.
0N/A break;
0N/A case relocInfo::external_word_type:
0N/A _rspec = external_word_Relocation::spec(target);
0N/A break;
0N/A case relocInfo::internal_word_type:
0N/A _rspec = internal_word_Relocation::spec(target);
0N/A break;
0N/A case relocInfo::opt_virtual_call_type:
0N/A _rspec = opt_virtual_call_Relocation::spec();
0N/A break;
0N/A case relocInfo::static_call_type:
0N/A _rspec = static_call_Relocation::spec();
0N/A break;
0N/A case relocInfo::runtime_call_type:
0N/A _rspec = runtime_call_Relocation::spec();
0N/A break;
0N/A case relocInfo::poll_type:
0N/A case relocInfo::poll_return_type:
0N/A _rspec = Relocation::spec_simple(rtype);
0N/A break;
0N/A case relocInfo::none:
0N/A break;
0N/A default:
0N/A ShouldNotReachHere();
0N/A break;
0N/A }
0N/A}
0N/A
0N/A// Implementation of Address
0N/A
304N/A#ifdef _LP64
304N/A
0N/AAddress Address::make_array(ArrayAddress adr) {
0N/A // Not implementable on 64bit machines
0N/A // Should have been handled higher up the call chain.
0N/A ShouldNotReachHere();
304N/A return Address();
304N/A}
304N/A
304N/A// exceedingly dangerous constructor
304N/AAddress::Address(int disp, address loc, relocInfo::relocType rtype) {
304N/A _base = noreg;
304N/A _index = noreg;
304N/A _scale = no_scale;
304N/A _disp = disp;
304N/A switch (rtype) {
304N/A case relocInfo::external_word_type:
304N/A _rspec = external_word_Relocation::spec(loc);
304N/A break;
304N/A case relocInfo::internal_word_type:
304N/A _rspec = internal_word_Relocation::spec(loc);
304N/A break;
304N/A case relocInfo::runtime_call_type:
304N/A // HMM
304N/A _rspec = runtime_call_Relocation::spec();
304N/A break;
304N/A case relocInfo::poll_type:
304N/A case relocInfo::poll_return_type:
304N/A _rspec = Relocation::spec_simple(rtype);
304N/A break;
304N/A case relocInfo::none:
304N/A break;
304N/A default:
304N/A ShouldNotReachHere();
304N/A }
304N/A}
304N/A#else // LP64
304N/A
304N/AAddress Address::make_array(ArrayAddress adr) {
0N/A AddressLiteral base = adr.base();
0N/A Address index = adr.index();
0N/A assert(index._disp == 0, "must not have disp"); // maybe it can?
0N/A Address array(index._base, index._index, index._scale, (intptr_t) base.target());
0N/A array._rspec = base._rspec;
0N/A return array;
304N/A}
0N/A
0N/A// exceedingly dangerous constructor
0N/AAddress::Address(address loc, RelocationHolder spec) {
0N/A _base = noreg;
0N/A _index = noreg;
0N/A _scale = no_scale;
0N/A _disp = (intptr_t) loc;
0N/A _rspec = spec;
0N/A}
304N/A
0N/A#endif // _LP64
0N/A
304N/A
304N/A
0N/A// Convert the raw encoding form into the form expected by the constructor for
0N/A// Address. An index of 4 (rsp) corresponds to having no index, so convert
0N/A// that to noreg for the Address constructor.
624N/AAddress Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) {
624N/A RelocationHolder rspec;
624N/A if (disp_is_oop) {
624N/A rspec = Relocation::spec_simple(relocInfo::oop_type);
624N/A }
0N/A bool valid_index = index != rsp->encoding();
0N/A if (valid_index) {
0N/A Address madr(as_Register(base), as_Register(index), (Address::ScaleFactor)scale, in_ByteSize(disp));
624N/A madr._rspec = rspec;
0N/A return madr;
0N/A } else {
0N/A Address madr(as_Register(base), noreg, Address::no_scale, in_ByteSize(disp));
624N/A madr._rspec = rspec;
0N/A return madr;
0N/A }
0N/A}
0N/A
0N/A// Implementation of Assembler
0N/A
0N/Aint AbstractAssembler::code_fill_byte() {
0N/A return (u_char)'\xF4'; // hlt
0N/A}
0N/A
0N/A// make this go away someday
0N/Avoid Assembler::emit_data(jint data, relocInfo::relocType rtype, int format) {
0N/A if (rtype == relocInfo::none)
0N/A emit_long(data);
0N/A else emit_data(data, Relocation::spec_simple(rtype), format);
0N/A}
0N/A
0N/Avoid Assembler::emit_data(jint data, RelocationHolder const& rspec, int format) {
304N/A assert(imm_operand == 0, "default format must be immediate in this file");
0N/A assert(inst_mark() != NULL, "must be inside InstructionMark");
0N/A if (rspec.type() != relocInfo::none) {
0N/A #ifdef ASSERT
0N/A check_relocation(rspec, format);
0N/A #endif
0N/A // Do not use AbstractAssembler::relocate, which is not intended for
0N/A // embedded words. Instead, relocate to the enclosing instruction.
0N/A
0N/A // hack. call32 is too wide for mask so use disp32
0N/A if (format == call32_operand)
0N/A code_section()->relocate(inst_mark(), rspec, disp32_operand);
0N/A else
0N/A code_section()->relocate(inst_mark(), rspec, format);
0N/A }
0N/A emit_long(data);
0N/A}
0N/A
304N/Astatic int encode(Register r) {
304N/A int enc = r->encoding();
304N/A if (enc >= 8) {
304N/A enc -= 8;
304N/A }
304N/A return enc;
304N/A}
304N/A
304N/Astatic int encode(XMMRegister r) {
304N/A int enc = r->encoding();
304N/A if (enc >= 8) {
304N/A enc -= 8;
304N/A }
304N/A return enc;
304N/A}
0N/A
0N/Avoid Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) {
0N/A assert(dst->has_byte_register(), "must have byte register");
0N/A assert(isByte(op1) && isByte(op2), "wrong opcode");
0N/A assert(isByte(imm8), "not a byte");
0N/A assert((op1 & 0x01) == 0, "should be 8bit operation");
0N/A emit_byte(op1);
304N/A emit_byte(op2 | encode(dst));
0N/A emit_byte(imm8);
0N/A}
0N/A
0N/A
304N/Avoid Assembler::emit_arith(int op1, int op2, Register dst, int32_t imm32) {
0N/A assert(isByte(op1) && isByte(op2), "wrong opcode");
0N/A assert((op1 & 0x01) == 1, "should be 32bit operation");
0N/A assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
0N/A if (is8bit(imm32)) {
0N/A emit_byte(op1 | 0x02); // set sign bit
304N/A emit_byte(op2 | encode(dst));
0N/A emit_byte(imm32 & 0xFF);
0N/A } else {
0N/A emit_byte(op1);
304N/A emit_byte(op2 | encode(dst));
0N/A emit_long(imm32);
0N/A }
0N/A}
0N/A
3236N/A// Force generation of a 4 byte immediate value even if it fits into 8bit
3236N/Avoid Assembler::emit_arith_imm32(int op1, int op2, Register dst, int32_t imm32) {
3236N/A assert(isByte(op1) && isByte(op2), "wrong opcode");
3236N/A assert((op1 & 0x01) == 1, "should be 32bit operation");
3236N/A assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
3236N/A emit_byte(op1);
3236N/A emit_byte(op2 | encode(dst));
3236N/A emit_long(imm32);
3236N/A}
3236N/A
0N/A// immediate-to-memory forms
304N/Avoid Assembler::emit_arith_operand(int op1, Register rm, Address adr, int32_t imm32) {
0N/A assert((op1 & 0x01) == 1, "should be 32bit operation");
0N/A assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
0N/A if (is8bit(imm32)) {
0N/A emit_byte(op1 | 0x02); // set sign bit
304N/A emit_operand(rm, adr, 1);
0N/A emit_byte(imm32 & 0xFF);
0N/A } else {
0N/A emit_byte(op1);
304N/A emit_operand(rm, adr, 4);
0N/A emit_long(imm32);
0N/A }
0N/A}
0N/A
0N/Avoid Assembler::emit_arith(int op1, int op2, Register dst, jobject obj) {
304N/A LP64_ONLY(ShouldNotReachHere());
0N/A assert(isByte(op1) && isByte(op2), "wrong opcode");
0N/A assert((op1 & 0x01) == 1, "should be 32bit operation");
0N/A assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
0N/A InstructionMark im(this);
0N/A emit_byte(op1);
304N/A emit_byte(op2 | encode(dst));
304N/A emit_data((intptr_t)obj, relocInfo::oop_type, 0);
0N/A}
0N/A
0N/A
0N/Avoid Assembler::emit_arith(int op1, int op2, Register dst, Register src) {
0N/A assert(isByte(op1) && isByte(op2), "wrong opcode");
0N/A emit_byte(op1);
304N/A emit_byte(op2 | encode(dst) << 3 | encode(src));
304N/A}
304N/A
304N/A
304N/Avoid Assembler::emit_operand(Register reg, Register base, Register index,
304N/A Address::ScaleFactor scale, int disp,
304N/A RelocationHolder const& rspec,
304N/A int rip_relative_correction) {
0N/A relocInfo::relocType rtype = (relocInfo::relocType) rspec.type();
304N/A
304N/A // Encode the registers as needed in the fields they are used in
304N/A
304N/A int regenc = encode(reg) << 3;
304N/A int indexenc = index->is_valid() ? encode(index) << 3 : 0;
304N/A int baseenc = base->is_valid() ? encode(base) : 0;
304N/A
0N/A if (base->is_valid()) {
0N/A if (index->is_valid()) {
0N/A assert(scale != Address::no_scale, "inconsistent address");
0N/A // [base + index*scale + disp]
304N/A if (disp == 0 && rtype == relocInfo::none &&
304N/A base != rbp LP64_ONLY(&& base != r13)) {
0N/A // [base + index*scale]
0N/A // [00 reg 100][ss index base]
0N/A assert(index != rsp, "illegal addressing mode");
304N/A emit_byte(0x04 | regenc);
304N/A emit_byte(scale << 6 | indexenc | baseenc);
0N/A } else if (is8bit(disp) && rtype == relocInfo::none) {
0N/A // [base + index*scale + imm8]
0N/A // [01 reg 100][ss index base] imm8
0N/A assert(index != rsp, "illegal addressing mode");
304N/A emit_byte(0x44 | regenc);
304N/A emit_byte(scale << 6 | indexenc | baseenc);
0N/A emit_byte(disp & 0xFF);
0N/A } else {
304N/A // [base + index*scale + disp32]
304N/A // [10 reg 100][ss index base] disp32
0N/A assert(index != rsp, "illegal addressing mode");
304N/A emit_byte(0x84 | regenc);
304N/A emit_byte(scale << 6 | indexenc | baseenc);
0N/A emit_data(disp, rspec, disp32_operand);
0N/A }
304N/A } else if (base == rsp LP64_ONLY(|| base == r12)) {
304N/A // [rsp + disp]
0N/A if (disp == 0 && rtype == relocInfo::none) {
304N/A // [rsp]
0N/A // [00 reg 100][00 100 100]
304N/A emit_byte(0x04 | regenc);
0N/A emit_byte(0x24);
0N/A } else if (is8bit(disp) && rtype == relocInfo::none) {
304N/A // [rsp + imm8]
304N/A // [01 reg 100][00 100 100] disp8
304N/A emit_byte(0x44 | regenc);
0N/A emit_byte(0x24);
0N/A emit_byte(disp & 0xFF);
0N/A } else {
304N/A // [rsp + imm32]
304N/A // [10 reg 100][00 100 100] disp32
304N/A emit_byte(0x84 | regenc);
0N/A emit_byte(0x24);
0N/A emit_data(disp, rspec, disp32_operand);
0N/A }
0N/A } else {
0N/A // [base + disp]
304N/A assert(base != rsp LP64_ONLY(&& base != r12), "illegal addressing mode");
304N/A if (disp == 0 && rtype == relocInfo::none &&
304N/A base != rbp LP64_ONLY(&& base != r13)) {
0N/A // [base]
0N/A // [00 reg base]
304N/A emit_byte(0x00 | regenc | baseenc);
0N/A } else if (is8bit(disp) && rtype == relocInfo::none) {
304N/A // [base + disp8]
304N/A // [01 reg base] disp8
304N/A emit_byte(0x40 | regenc | baseenc);
0N/A emit_byte(disp & 0xFF);
0N/A } else {
304N/A // [base + disp32]
304N/A // [10 reg base] disp32
304N/A emit_byte(0x80 | regenc | baseenc);
0N/A emit_data(disp, rspec, disp32_operand);
0N/A }
0N/A }
0N/A } else {
0N/A if (index->is_valid()) {
0N/A assert(scale != Address::no_scale, "inconsistent address");
0N/A // [index*scale + disp]
304N/A // [00 reg 100][ss index 101] disp32
0N/A assert(index != rsp, "illegal addressing mode");
304N/A emit_byte(0x04 | regenc);
304N/A emit_byte(scale << 6 | indexenc | 0x05);
0N/A emit_data(disp, rspec, disp32_operand);
304N/A } else if (rtype != relocInfo::none ) {
304N/A // [disp] (64bit) RIP-RELATIVE (32bit) abs
304N/A // [00 000 101] disp32
304N/A
304N/A emit_byte(0x05 | regenc);
304N/A // Note that the RIP-rel. correction applies to the generated
304N/A // disp field, but _not_ to the target address in the rspec.
304N/A
304N/A // disp was created by converting the target address minus the pc
304N/A // at the start of the instruction. That needs more correction here.
304N/A // intptr_t disp = target - next_ip;
304N/A assert(inst_mark() != NULL, "must be inside InstructionMark");
304N/A address next_ip = pc() + sizeof(int32_t) + rip_relative_correction;
304N/A int64_t adjusted = disp;
304N/A // Do rip-rel adjustment for 64bit
304N/A LP64_ONLY(adjusted -= (next_ip - inst_mark()));
304N/A assert(is_simm32(adjusted),
304N/A "must be 32bit offset (RIP relative address)");
304N/A emit_data((int32_t) adjusted, rspec, disp32_operand);
304N/A
0N/A } else {
304N/A // 32bit never did this, did everything as the rip-rel/disp code above
304N/A // [disp] ABSOLUTE
304N/A // [00 reg 100][00 100 101] disp32
304N/A emit_byte(0x04 | regenc);
304N/A emit_byte(0x25);
0N/A emit_data(disp, rspec, disp32_operand);
0N/A }
0N/A }
0N/A}
0N/A
304N/Avoid Assembler::emit_operand(XMMRegister reg, Register base, Register index,
304N/A Address::ScaleFactor scale, int disp,
304N/A RelocationHolder const& rspec) {
304N/A emit_operand((Register)reg, base, index, scale, disp, rspec);
304N/A}
304N/A
0N/A// Secret local extension to Assembler::WhichOperand:
0N/A#define end_pc_operand (_WhichOperand_limit)
0N/A
0N/Aaddress Assembler::locate_operand(address inst, WhichOperand which) {
0N/A // Decode the given instruction, and return the address of
0N/A // an embedded 32-bit operand word.
0N/A
0N/A // If "which" is disp32_operand, selects the displacement portion
0N/A // of an effective address specifier.
304N/A // If "which" is imm64_operand, selects the trailing immediate constant.
0N/A // If "which" is call32_operand, selects the displacement of a call or jump.
0N/A // Caller is responsible for ensuring that there is such an operand,
304N/A // and that it is 32/64 bits wide.
0N/A
0N/A // If "which" is end_pc_operand, find the end of the instruction.
0N/A
0N/A address ip = inst;
304N/A bool is_64bit = false;
304N/A
304N/A debug_only(bool has_disp32 = false);
304N/A int tail_size = 0; // other random bytes (#32, #16, etc.) at end of insn
304N/A
304N/A again_after_prefix:
0N/A switch (0xFF & *ip++) {
0N/A
0N/A // These convenience macros generate groups of "case" labels for the switch.
304N/A#define REP4(x) (x)+0: case (x)+1: case (x)+2: case (x)+3
304N/A#define REP8(x) (x)+0: case (x)+1: case (x)+2: case (x)+3: \
0N/A case (x)+4: case (x)+5: case (x)+6: case (x)+7
304N/A#define REP16(x) REP8((x)+0): \
0N/A case REP8((x)+8)
0N/A
0N/A case CS_segment:
0N/A case SS_segment:
0N/A case DS_segment:
0N/A case ES_segment:
0N/A case FS_segment:
0N/A case GS_segment:
304N/A // Seems dubious
304N/A LP64_ONLY(assert(false, "shouldn't have that prefix"));
0N/A assert(ip == inst+1, "only one prefix allowed");
0N/A goto again_after_prefix;
0N/A
304N/A case 0x67:
304N/A case REX:
304N/A case REX_B:
304N/A case REX_X:
304N/A case REX_XB:
304N/A case REX_R:
304N/A case REX_RB:
304N/A case REX_RX:
304N/A case REX_RXB:
304N/A NOT_LP64(assert(false, "64bit prefixes"));
304N/A goto again_after_prefix;
304N/A
304N/A case REX_W:
304N/A case REX_WB:
304N/A case REX_WX:
304N/A case REX_WXB:
304N/A case REX_WR:
304N/A case REX_WRB:
304N/A case REX_WRX:
304N/A case REX_WRXB:
304N/A NOT_LP64(assert(false, "64bit prefixes"));
304N/A is_64bit = true;
304N/A goto again_after_prefix;
304N/A
304N/A case 0xFF: // pushq a; decl a; incl a; call a; jmp a
0N/A case 0x88: // movb a, r
0N/A case 0x89: // movl a, r
0N/A case 0x8A: // movb r, a
0N/A case 0x8B: // movl r, a
0N/A case 0x8F: // popl a
304N/A debug_only(has_disp32 = true);
0N/A break;
0N/A
304N/A case 0x68: // pushq #32
304N/A if (which == end_pc_operand) {
304N/A return ip + 4;
304N/A }
304N/A assert(which == imm_operand && !is_64bit, "pushl has no disp32 or 64bit immediate");
0N/A return ip; // not produced by emit_operand
0N/A
0N/A case 0x66: // movw ... (size prefix)
304N/A again_after_size_prefix2:
0N/A switch (0xFF & *ip++) {
304N/A case REX:
304N/A case REX_B:
304N/A case REX_X:
304N/A case REX_XB:
304N/A case REX_R:
304N/A case REX_RB:
304N/A case REX_RX:
304N/A case REX_RXB:
304N/A case REX_W:
304N/A case REX_WB:
304N/A case REX_WX:
304N/A case REX_WXB:
304N/A case REX_WR:
304N/A case REX_WRB:
304N/A case REX_WRX:
304N/A case REX_WRXB:
304N/A NOT_LP64(assert(false, "64bit prefix found"));
304N/A goto again_after_size_prefix2;
0N/A case 0x8B: // movw r, a
0N/A case 0x89: // movw a, r
304N/A debug_only(has_disp32 = true);
0N/A break;
0N/A case 0xC7: // movw a, #16
304N/A debug_only(has_disp32 = true);
0N/A tail_size = 2; // the imm16
0N/A break;
0N/A case 0x0F: // several SSE/SSE2 variants
0N/A ip--; // reparse the 0x0F
0N/A goto again_after_prefix;
0N/A default:
0N/A ShouldNotReachHere();
0N/A }
0N/A break;
0N/A
304N/A case REP8(0xB8): // movl/q r, #32/#64(oop?)
304N/A if (which == end_pc_operand) return ip + (is_64bit ? 8 : 4);
304N/A // these asserts are somewhat nonsensical
304N/A#ifndef _LP64
3655N/A assert(which == imm_operand || which == disp32_operand,
3655N/A err_msg("which %d is_64_bit %d ip " INTPTR_FORMAT, which, is_64bit, ip));
304N/A#else
304N/A assert((which == call32_operand || which == imm_operand) && is_64bit ||
3655N/A which == narrow_oop_operand && !is_64bit,
3655N/A err_msg("which %d is_64_bit %d ip " INTPTR_FORMAT, which, is_64bit, ip));
304N/A#endif // _LP64
0N/A return ip;
0N/A
0N/A case 0x69: // imul r, a, #32
0N/A case 0xC7: // movl a, #32(oop?)
0N/A tail_size = 4;
304N/A debug_only(has_disp32 = true); // has both kinds of operands!
0N/A break;
0N/A
0N/A case 0x0F: // movx..., etc.
0N/A switch (0xFF & *ip++) {
3039N/A case 0x3A: // pcmpestri
3039N/A tail_size = 1;
3039N/A case 0x38: // ptest, pmovzxbw
3039N/A ip++; // skip opcode
3039N/A debug_only(has_disp32 = true); // has both kinds of operands!
3039N/A break;
3039N/A
3039N/A case 0x70: // pshufd r, r/a, #8
3039N/A debug_only(has_disp32 = true); // has both kinds of operands!
3039N/A case 0x73: // psrldq r, #8
3039N/A tail_size = 1;
3039N/A break;
3039N/A
0N/A case 0x12: // movlps
0N/A case 0x28: // movaps
0N/A case 0x2E: // ucomiss
0N/A case 0x2F: // comiss
0N/A case 0x54: // andps
0N/A case 0x55: // andnps
0N/A case 0x56: // orps
0N/A case 0x57: // xorps
0N/A case 0x6E: // movd
0N/A case 0x7E: // movd
3039N/A case 0xAE: // ldmxcsr, stmxcsr, fxrstor, fxsave, clflush
304N/A debug_only(has_disp32 = true);
0N/A break;
0N/A
0N/A case 0xAD: // shrd r, a, %cl
0N/A case 0xAF: // imul r, a
304N/A case 0xBE: // movsbl r, a (movsxb)
304N/A case 0xBF: // movswl r, a (movsxw)
304N/A case 0xB6: // movzbl r, a (movzxb)
304N/A case 0xB7: // movzwl r, a (movzxw)
0N/A case REP16(0x40): // cmovl cc, r, a
0N/A case 0xB0: // cmpxchgb
0N/A case 0xB1: // cmpxchg
0N/A case 0xC1: // xaddl
0N/A case 0xC7: // cmpxchg8
0N/A case REP16(0x90): // setcc a
304N/A debug_only(has_disp32 = true);
0N/A // fall out of the switch to decode the address
0N/A break;
304N/A
3039N/A case 0xC4: // pinsrw r, a, #8
3039N/A debug_only(has_disp32 = true);
3039N/A case 0xC5: // pextrw r, r, #8
3039N/A tail_size = 1; // the imm8
3039N/A break;
3039N/A
0N/A case 0xAC: // shrd r, a, #8
304N/A debug_only(has_disp32 = true);
0N/A tail_size = 1; // the imm8
0N/A break;
304N/A
0N/A case REP16(0x80): // jcc rdisp32
0N/A if (which == end_pc_operand) return ip + 4;
304N/A assert(which == call32_operand, "jcc has no disp32 or imm");
0N/A return ip;
0N/A default:
0N/A ShouldNotReachHere();
0N/A }
0N/A break;
0N/A
0N/A case 0x81: // addl a, #32; addl r, #32
0N/A // also: orl, adcl, sbbl, andl, subl, xorl, cmpl
304N/A // on 32bit in the case of cmpl, the imm might be an oop
0N/A tail_size = 4;
304N/A debug_only(has_disp32 = true); // has both kinds of operands!
0N/A break;
0N/A
0N/A case 0x83: // addl a, #8; addl r, #8
0N/A // also: orl, adcl, sbbl, andl, subl, xorl, cmpl
304N/A debug_only(has_disp32 = true); // has both kinds of operands!
0N/A tail_size = 1;
0N/A break;
0N/A
0N/A case 0x9B:
0N/A switch (0xFF & *ip++) {
0N/A case 0xD9: // fnstcw a
304N/A debug_only(has_disp32 = true);
0N/A break;
0N/A default:
0N/A ShouldNotReachHere();
0N/A }
0N/A break;
0N/A
0N/A case REP4(0x00): // addb a, r; addl a, r; addb r, a; addl r, a
0N/A case REP4(0x10): // adc...
0N/A case REP4(0x20): // and...
0N/A case REP4(0x30): // xor...
0N/A case REP4(0x08): // or...
0N/A case REP4(0x18): // sbb...
0N/A case REP4(0x28): // sub...
304N/A case 0xF7: // mull a
304N/A case 0x8D: // lea r, a
304N/A case 0x87: // xchg r, a
0N/A case REP4(0x38): // cmp...
304N/A case 0x85: // test r, a
304N/A debug_only(has_disp32 = true); // has both kinds of operands!
0N/A break;
0N/A
0N/A case 0xC1: // sal a, #8; sar a, #8; shl a, #8; shr a, #8
0N/A case 0xC6: // movb a, #8
0N/A case 0x80: // cmpb a, #8
0N/A case 0x6B: // imul r, a, #8
304N/A debug_only(has_disp32 = true); // has both kinds of operands!
0N/A tail_size = 1; // the imm8
0N/A break;
0N/A
3039N/A case 0xC4: // VEX_3bytes
3039N/A case 0xC5: // VEX_2bytes
3039N/A assert((UseAVX > 0), "shouldn't have VEX prefix");
3039N/A assert(ip == inst+1, "no prefixes allowed");
3039N/A // C4 and C5 are also used as opcodes for PINSRW and PEXTRW instructions
3039N/A // but they have prefix 0x0F and processed when 0x0F processed above.
3039N/A //
3039N/A // In 32-bit mode the VEX first byte C4 and C5 alias onto LDS and LES
3039N/A // instructions (these instructions are not supported in 64-bit mode).
3039N/A // To distinguish them bits [7:6] are set in the VEX second byte since
3039N/A // ModRM byte can not be of the form 11xxxxxx in 32-bit mode. To set
3039N/A // those VEX bits REX and vvvv bits are inverted.
3039N/A //
3039N/A // Fortunately C2 doesn't generate these instructions so we don't need
3039N/A // to check for them in product version.
3039N/A
3039N/A // Check second byte
3039N/A NOT_LP64(assert((0xC0 & *ip) == 0xC0, "shouldn't have LDS and LES instructions"));
3039N/A
3039N/A // First byte
3039N/A if ((0xFF & *inst) == VEX_3bytes) {
3039N/A ip++; // third byte
3039N/A is_64bit = ((VEX_W & *ip) == VEX_W);
3039N/A }
3039N/A ip++; // opcode
3039N/A // To find the end of instruction (which == end_pc_operand).
3039N/A switch (0xFF & *ip) {
3039N/A case 0x61: // pcmpestri r, r/a, #8
3039N/A case 0x70: // pshufd r, r/a, #8
3039N/A case 0x73: // psrldq r, #8
3039N/A tail_size = 1; // the imm8
3039N/A break;
3039N/A default:
3039N/A break;
3039N/A }
3039N/A ip++; // skip opcode
3039N/A debug_only(has_disp32 = true); // has both kinds of operands!
3039N/A break;
0N/A
0N/A case 0xD1: // sal a, 1; sar a, 1; shl a, 1; shr a, 1
0N/A case 0xD3: // sal a, %cl; sar a, %cl; shl a, %cl; shr a, %cl
0N/A case 0xD9: // fld_s a; fst_s a; fstp_s a; fldcw a
0N/A case 0xDD: // fld_d a; fst_d a; fstp_d a
0N/A case 0xDB: // fild_s a; fistp_s a; fld_x a; fstp_x a
0N/A case 0xDF: // fild_d a; fistp_d a
0N/A case 0xD8: // fadd_s a; fsubr_s a; fmul_s a; fdivr_s a; fcomp_s a
0N/A case 0xDC: // fadd_d a; fsubr_d a; fmul_d a; fdivr_d a; fcomp_d a
0N/A case 0xDE: // faddp_d a; fsubrp_d a; fmulp_d a; fdivrp_d a; fcompp_d a
304N/A debug_only(has_disp32 = true);
0N/A break;
0N/A
3039N/A case 0xE8: // call rdisp32
3039N/A case 0xE9: // jmp rdisp32
3039N/A if (which == end_pc_operand) return ip + 4;
3039N/A assert(which == call32_operand, "call has no disp32 or imm");
3039N/A return ip;
3039N/A
420N/A case 0xF0: // Lock
420N/A assert(os::is_MP(), "only on MP");
420N/A goto again_after_prefix;
420N/A
0N/A case 0xF3: // For SSE
0N/A case 0xF2: // For SSE2
304N/A switch (0xFF & *ip++) {
304N/A case REX:
304N/A case REX_B:
304N/A case REX_X:
304N/A case REX_XB:
304N/A case REX_R:
304N/A case REX_RB:
304N/A case REX_RX:
304N/A case REX_RXB:
304N/A case REX_W:
304N/A case REX_WB:
304N/A case REX_WX:
304N/A case REX_WXB:
304N/A case REX_WR:
304N/A case REX_WRB:
304N/A case REX_WRX:
304N/A case REX_WRXB:
304N/A NOT_LP64(assert(false, "found 64bit prefix"));
304N/A ip++;
304N/A default:
304N/A ip++;
304N/A }
304N/A debug_only(has_disp32 = true); // has both kinds of operands!
0N/A break;
0N/A
0N/A default:
0N/A ShouldNotReachHere();
0N/A
304N/A#undef REP8
304N/A#undef REP16
0N/A }
0N/A
0N/A assert(which != call32_operand, "instruction is not a call, jmp, or jcc");
304N/A#ifdef _LP64
304N/A assert(which != imm_operand, "instruction is not a movq reg, imm64");
304N/A#else
304N/A // assert(which != imm_operand || has_imm32, "instruction has no imm32 field");
304N/A assert(which != imm_operand || has_disp32, "instruction has no imm32 field");
304N/A#endif // LP64
304N/A assert(which != disp32_operand || has_disp32, "instruction has no disp32 field");
0N/A
0N/A // parse the output of emit_operand
0N/A int op2 = 0xFF & *ip++;
0N/A int base = op2 & 0x07;
0N/A int op3 = -1;
0N/A const int b100 = 4;
0N/A const int b101 = 5;
0N/A if (base == b100 && (op2 >> 6) != 3) {
0N/A op3 = 0xFF & *ip++;
0N/A base = op3 & 0x07; // refetch the base
0N/A }
0N/A // now ip points at the disp (if any)
0N/A
0N/A switch (op2 >> 6) {
0N/A case 0:
0N/A // [00 reg 100][ss index base]
304N/A // [00 reg 100][00 100 esp]
0N/A // [00 reg base]
0N/A // [00 reg 100][ss index 101][disp32]
0N/A // [00 reg 101] [disp32]
0N/A
0N/A if (base == b101) {
0N/A if (which == disp32_operand)
0N/A return ip; // caller wants the disp32
0N/A ip += 4; // skip the disp32
0N/A }
0N/A break;
0N/A
0N/A case 1:
0N/A // [01 reg 100][ss index base][disp8]
304N/A // [01 reg 100][00 100 esp][disp8]
0N/A // [01 reg base] [disp8]
0N/A ip += 1; // skip the disp8
0N/A break;
0N/A
0N/A case 2:
0N/A // [10 reg 100][ss index base][disp32]
304N/A // [10 reg 100][00 100 esp][disp32]
0N/A // [10 reg base] [disp32]
0N/A if (which == disp32_operand)
0N/A return ip; // caller wants the disp32
0N/A ip += 4; // skip the disp32
0N/A break;
0N/A
0N/A case 3:
0N/A // [11 reg base] (not a memory addressing mode)
0N/A break;
0N/A }
0N/A
0N/A if (which == end_pc_operand) {
0N/A return ip + tail_size;
0N/A }
0N/A
304N/A#ifdef _LP64
642N/A assert(which == narrow_oop_operand && !is_64bit, "instruction is not a movl adr, imm32");
304N/A#else
304N/A assert(which == imm_operand, "instruction has only an imm field");
304N/A#endif // LP64
0N/A return ip;
0N/A}
0N/A
0N/Aaddress Assembler::locate_next_instruction(address inst) {
0N/A // Secretly share code with locate_operand:
0N/A return locate_operand(inst, end_pc_operand);
0N/A}
0N/A
0N/A
0N/A#ifdef ASSERT
0N/Avoid Assembler::check_relocation(RelocationHolder const& rspec, int format) {
0N/A address inst = inst_mark();
0N/A assert(inst != NULL && inst < pc(), "must point to beginning of instruction");
0N/A address opnd;
0N/A
0N/A Relocation* r = rspec.reloc();
0N/A if (r->type() == relocInfo::none) {
0N/A return;
0N/A } else if (r->is_call() || format == call32_operand) {
0N/A // assert(format == imm32_operand, "cannot specify a nonzero format");
0N/A opnd = locate_operand(inst, call32_operand);
0N/A } else if (r->is_data()) {
304N/A assert(format == imm_operand || format == disp32_operand
304N/A LP64_ONLY(|| format == narrow_oop_operand), "format ok");
0N/A opnd = locate_operand(inst, (WhichOperand)format);
0N/A } else {
304N/A assert(format == imm_operand, "cannot specify a format");
0N/A return;
0N/A }
0N/A assert(opnd == pc(), "must put operand where relocs can find it");
0N/A}
304N/A#endif // ASSERT
304N/A
304N/Avoid Assembler::emit_operand32(Register reg, Address adr) {
304N/A assert(reg->encoding() < 8, "no extended registers");
304N/A assert(!adr.base_needs_rex() && !adr.index_needs_rex(), "no extended registers");
304N/A emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp,
304N/A adr._rspec);
304N/A}
304N/A
304N/Avoid Assembler::emit_operand(Register reg, Address adr,
304N/A int rip_relative_correction) {
304N/A emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp,
304N/A adr._rspec,
304N/A rip_relative_correction);
304N/A}
304N/A
304N/Avoid Assembler::emit_operand(XMMRegister reg, Address adr) {
304N/A emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp,
304N/A adr._rspec);
304N/A}
304N/A
304N/A// MMX operations
304N/Avoid Assembler::emit_operand(MMXRegister reg, Address adr) {
304N/A assert(!adr.base_needs_rex() && !adr.index_needs_rex(), "no extended registers");
304N/A emit_operand((Register)reg, adr._base, adr._index, adr._scale, adr._disp, adr._rspec);
304N/A}
304N/A
304N/A// work around gcc (3.2.1-7a) bug
304N/Avoid Assembler::emit_operand(Address adr, MMXRegister reg) {
304N/A assert(!adr.base_needs_rex() && !adr.index_needs_rex(), "no extended registers");
304N/A emit_operand((Register)reg, adr._base, adr._index, adr._scale, adr._disp, adr._rspec);
0N/A}
0N/A
0N/A
0N/Avoid Assembler::emit_farith(int b1, int b2, int i) {
0N/A assert(isByte(b1) && isByte(b2), "wrong opcode");
0N/A assert(0 <= i && i < 8, "illegal stack offset");
0N/A emit_byte(b1);
0N/A emit_byte(b2 + i);
0N/A}
0N/A
0N/A
1988N/A// Now the Assembler instructions (identical for 32/64 bits)
1988N/A
1988N/Avoid Assembler::adcl(Address dst, int32_t imm32) {
1988N/A InstructionMark im(this);
1988N/A prefix(dst);
1988N/A emit_arith_operand(0x81, rdx, dst, imm32);
1988N/A}
1988N/A
1988N/Avoid Assembler::adcl(Address dst, Register src) {
1988N/A InstructionMark im(this);
1988N/A prefix(dst, src);
1988N/A emit_byte(0x11);
1988N/A emit_operand(src, dst);
1988N/A}
304N/A
304N/Avoid Assembler::adcl(Register dst, int32_t imm32) {
304N/A prefix(dst);
0N/A emit_arith(0x81, 0xD0, dst, imm32);
0N/A}
0N/A
0N/Avoid Assembler::adcl(Register dst, Address src) {
0N/A InstructionMark im(this);
304N/A prefix(src, dst);
0N/A emit_byte(0x13);
0N/A emit_operand(dst, src);
0N/A}
0N/A
0N/Avoid Assembler::adcl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
0N/A emit_arith(0x13, 0xC0, dst, src);
0N/A}
0N/A
304N/Avoid Assembler::addl(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_arith_operand(0x81, rax, dst, imm32);
304N/A}
0N/A
0N/Avoid Assembler::addl(Address dst, Register src) {
0N/A InstructionMark im(this);
304N/A prefix(dst, src);
0N/A emit_byte(0x01);
0N/A emit_operand(src, dst);
0N/A}
0N/A
304N/Avoid Assembler::addl(Register dst, int32_t imm32) {
304N/A prefix(dst);
0N/A emit_arith(0x81, 0xC0, dst, imm32);
0N/A}
0N/A
0N/Avoid Assembler::addl(Register dst, Address src) {
0N/A InstructionMark im(this);
304N/A prefix(src, dst);
0N/A emit_byte(0x03);
0N/A emit_operand(dst, src);
0N/A}
0N/A
0N/Avoid Assembler::addl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
0N/A emit_arith(0x03, 0xC0, dst, src);
0N/A}
0N/A
0N/Avoid Assembler::addr_nop_4() {
3236N/A assert(UseAddressNop, "no CPU support");
0N/A // 4 bytes: NOP DWORD PTR [EAX+0]
0N/A emit_byte(0x0F);
0N/A emit_byte(0x1F);
0N/A emit_byte(0x40); // emit_rm(cbuf, 0x1, EAX_enc, EAX_enc);
0N/A emit_byte(0); // 8-bits offset (1 byte)
0N/A}
0N/A
0N/Avoid Assembler::addr_nop_5() {
3236N/A assert(UseAddressNop, "no CPU support");
0N/A // 5 bytes: NOP DWORD PTR [EAX+EAX*0+0] 8-bits offset
0N/A emit_byte(0x0F);
0N/A emit_byte(0x1F);
0N/A emit_byte(0x44); // emit_rm(cbuf, 0x1, EAX_enc, 0x4);
0N/A emit_byte(0x00); // emit_rm(cbuf, 0x0, EAX_enc, EAX_enc);
0N/A emit_byte(0); // 8-bits offset (1 byte)
0N/A}
0N/A
0N/Avoid Assembler::addr_nop_7() {
3236N/A assert(UseAddressNop, "no CPU support");
0N/A // 7 bytes: NOP DWORD PTR [EAX+0] 32-bits offset
0N/A emit_byte(0x0F);
0N/A emit_byte(0x1F);
0N/A emit_byte(0x80); // emit_rm(cbuf, 0x2, EAX_enc, EAX_enc);
0N/A emit_long(0); // 32-bits offset (4 bytes)
0N/A}
0N/A
0N/Avoid Assembler::addr_nop_8() {
3236N/A assert(UseAddressNop, "no CPU support");
0N/A // 8 bytes: NOP DWORD PTR [EAX+EAX*0+0] 32-bits offset
0N/A emit_byte(0x0F);
0N/A emit_byte(0x1F);
0N/A emit_byte(0x84); // emit_rm(cbuf, 0x2, EAX_enc, 0x4);
0N/A emit_byte(0x00); // emit_rm(cbuf, 0x0, EAX_enc, EAX_enc);
0N/A emit_long(0); // 32-bits offset (4 bytes)
0N/A}
0N/A
304N/Avoid Assembler::addsd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x58);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::addsd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x58);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::addss(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x58);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::addss(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x58);
304N/A emit_operand(dst, src);
304N/A}
304N/A
3039N/Avoid Assembler::andl(Address dst, int32_t imm32) {
3039N/A InstructionMark im(this);
3039N/A prefix(dst);
3039N/A emit_byte(0x81);
3039N/A emit_operand(rsp, dst, 4);
3039N/A emit_long(imm32);
3039N/A}
3039N/A
304N/Avoid Assembler::andl(Register dst, int32_t imm32) {
304N/A prefix(dst);
304N/A emit_arith(0x81, 0xE0, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::andl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x23);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::andl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x23, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::andpd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
304N/A emit_byte(0x54);
304N/A emit_operand(dst, src);
304N/A}
304N/A
3039N/Avoid Assembler::andpd(XMMRegister dst, XMMRegister src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x54);
3039N/A emit_byte(0xC0 | encode);
3039N/A}
3039N/A
3039N/Avoid Assembler::andps(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_NONE);
3039N/A emit_byte(0x54);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
3039N/Avoid Assembler::andps(XMMRegister dst, XMMRegister src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_NONE);
3039N/A emit_byte(0x54);
3039N/A emit_byte(0xC0 | encode);
3039N/A}
3039N/A
775N/Avoid Assembler::bsfl(Register dst, Register src) {
775N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
775N/A emit_byte(0x0F);
775N/A emit_byte(0xBC);
775N/A emit_byte(0xC0 | encode);
775N/A}
775N/A
775N/Avoid Assembler::bsrl(Register dst, Register src) {
775N/A assert(!VM_Version::supports_lzcnt(), "encoding is treated as LZCNT");
775N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
775N/A emit_byte(0x0F);
775N/A emit_byte(0xBD);
775N/A emit_byte(0xC0 | encode);
775N/A}
775N/A
304N/Avoid Assembler::bswapl(Register reg) { // bswap
304N/A int encode = prefix_and_encode(reg->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0xC8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::call(Label& L, relocInfo::relocType rtype) {
304N/A // suspect disp32 is always good
304N/A int operand = LP64_ONLY(disp32_operand) NOT_LP64(imm_operand);
304N/A
304N/A if (L.is_bound()) {
304N/A const int long_size = 5;
304N/A int offs = (int)( target(L) - pc() );
304N/A assert(offs <= 0, "assembler error");
304N/A InstructionMark im(this);
304N/A // 1110 1000 #32-bit disp
304N/A emit_byte(0xE8);
304N/A emit_data(offs - long_size, rtype, operand);
304N/A } else {
304N/A InstructionMark im(this);
304N/A // 1110 1000 #32-bit disp
304N/A L.add_patch_at(code(), locator());
304N/A
304N/A emit_byte(0xE8);
304N/A emit_data(int(0), rtype, operand);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::call(Register dst) {
3039N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xFF);
304N/A emit_byte(0xD0 | encode);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::call(Address adr) {
304N/A InstructionMark im(this);
304N/A prefix(adr);
304N/A emit_byte(0xFF);
304N/A emit_operand(rdx, adr);
304N/A}
304N/A
304N/Avoid Assembler::call_literal(address entry, RelocationHolder const& rspec) {
304N/A assert(entry != NULL, "call most probably wrong");
304N/A InstructionMark im(this);
304N/A emit_byte(0xE8);
304N/A intptr_t disp = entry - (_code_pos + sizeof(int32_t));
304N/A assert(is_simm32(disp), "must be 32bit offset (call2)");
304N/A // Technically, should use call32_operand, but this format is
304N/A // implied by the fact that we're emitting a call instruction.
304N/A
304N/A int operand = LP64_ONLY(disp32_operand) NOT_LP64(call32_operand);
304N/A emit_data((int) disp, rspec, operand);
304N/A}
304N/A
304N/Avoid Assembler::cdql() {
304N/A emit_byte(0x99);
304N/A}
304N/A
304N/Avoid Assembler::cmovl(Condition cc, Register dst, Register src) {
304N/A NOT_LP64(guarantee(VM_Version::supports_cmov(), "illegal instruction"));
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0x40 | cc);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::cmovl(Condition cc, Register dst, Address src) {
304N/A NOT_LP64(guarantee(VM_Version::supports_cmov(), "illegal instruction"));
304N/A prefix(src, dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0x40 | cc);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::cmpb(Address dst, int imm8) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0x80);
304N/A emit_operand(rdi, dst, 1);
304N/A emit_byte(imm8);
304N/A}
304N/A
304N/Avoid Assembler::cmpl(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0x81);
304N/A emit_operand(rdi, dst, 4);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::cmpl(Register dst, int32_t imm32) {
304N/A prefix(dst);
304N/A emit_arith(0x81, 0xF8, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::cmpl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x3B, 0xC0, dst, src);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::cmpl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x3B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::cmpw(Address dst, int imm16) {
304N/A InstructionMark im(this);
304N/A assert(!dst.base_needs_rex() && !dst.index_needs_rex(), "no extended registers");
304N/A emit_byte(0x66);
304N/A emit_byte(0x81);
304N/A emit_operand(rdi, dst, 2);
304N/A emit_word(imm16);
304N/A}
304N/A
304N/A// The 32-bit cmpxchg compares the value at adr with the contents of rax,
304N/A// and stores reg into adr if so; otherwise, the value at adr is loaded into rax,.
304N/A// The ZF is set if the compared values were equal, and cleared otherwise.
304N/Avoid Assembler::cmpxchgl(Register reg, Address adr) { // cmpxchg
304N/A if (Atomics & 2) {
304N/A // caveat: no instructionmark, so this isn't relocatable.
304N/A // Emit a synthetic, non-atomic, CAS equivalent.
304N/A // Beware. The synthetic form sets all ICCs, not just ZF.
304N/A // cmpxchg r,[m] is equivalent to rax, = CAS (m, rax, r)
304N/A cmpl(rax, adr);
304N/A movl(rax, adr);
304N/A if (reg != rax) {
304N/A Label L ;
304N/A jcc(Assembler::notEqual, L);
304N/A movl(adr, reg);
304N/A bind(L);
304N/A }
304N/A } else {
304N/A InstructionMark im(this);
304N/A prefix(adr, reg);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xB1);
304N/A emit_operand(reg, adr);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::comisd(XMMRegister dst, Address src) {
304N/A // NOTE: dbx seems to decode this as comiss even though the
304N/A // 0x66 is there. Strangly ucomisd comes out correct
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x2F);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
3039N/Avoid Assembler::comisd(XMMRegister dst, XMMRegister src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x2F);
3039N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::comiss(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_NONE);
304N/A emit_byte(0x2F);
304N/A emit_operand(dst, src);
304N/A}
304N/A
3039N/Avoid Assembler::comiss(XMMRegister dst, XMMRegister src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_NONE);
3039N/A emit_byte(0x2F);
3039N/A emit_byte(0xC0 | encode);
3039N/A}
3039N/A
304N/Avoid Assembler::cvtdq2pd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F3);
304N/A emit_byte(0xE6);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_NONE);
304N/A emit_byte(0x5B);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x5A);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3039N/Avoid Assembler::cvtsd2ss(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F2);
3039N/A emit_byte(0x5A);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
304N/Avoid Assembler::cvtsi2sdl(XMMRegister dst, Register src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x2A);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3039N/Avoid Assembler::cvtsi2sdl(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F2);
3039N/A emit_byte(0x2A);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
304N/Avoid Assembler::cvtsi2ssl(XMMRegister dst, Register src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x2A);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3039N/Avoid Assembler::cvtsi2ssl(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F3);
3039N/A emit_byte(0x2A);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
304N/Avoid Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x5A);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3039N/Avoid Assembler::cvtss2sd(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F3);
3039N/A emit_byte(0x5A);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
3039N/A
304N/Avoid Assembler::cvttsd2sil(Register dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x2C);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::cvttss2sil(Register dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x2C);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::decl(Address dst) {
304N/A // Don't use it directly. Use MacroAssembler::decrement() instead.
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0xFF);
304N/A emit_operand(rcx, dst);
304N/A}
304N/A
304N/Avoid Assembler::divsd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x5E);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::divsd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x5E);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::divss(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x5E);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::divss(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x5E);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::emms() {
304N/A NOT_LP64(assert(VM_Version::supports_mmx(), ""));
304N/A emit_byte(0x0F);
304N/A emit_byte(0x77);
304N/A}
304N/A
304N/Avoid Assembler::hlt() {
304N/A emit_byte(0xF4);
304N/A}
304N/A
304N/Avoid Assembler::idivl(Register src) {
304N/A int encode = prefix_and_encode(src->encoding());
304N/A emit_byte(0xF7);
304N/A emit_byte(0xF8 | encode);
304N/A}
304N/A
1840N/Avoid Assembler::divl(Register src) { // Unsigned
1840N/A int encode = prefix_and_encode(src->encoding());
1840N/A emit_byte(0xF7);
1840N/A emit_byte(0xF0 | encode);
1840N/A}
1840N/A
304N/Avoid Assembler::imull(Register dst, Register src) {
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0xAF);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::imull(Register dst, Register src, int value) {
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
304N/A if (is8bit(value)) {
304N/A emit_byte(0x6B);
304N/A emit_byte(0xC0 | encode);
1834N/A emit_byte(value & 0xFF);
304N/A } else {
304N/A emit_byte(0x69);
304N/A emit_byte(0xC0 | encode);
304N/A emit_long(value);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::incl(Address dst) {
304N/A // Don't use it directly. Use MacroAssembler::increment() instead.
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0xFF);
304N/A emit_operand(rax, dst);
304N/A}
304N/A
2676N/Avoid Assembler::jcc(Condition cc, Label& L, bool maybe_short) {
2676N/A InstructionMark im(this);
304N/A assert((0 <= cc) && (cc < 16), "illegal cc");
304N/A if (L.is_bound()) {
304N/A address dst = target(L);
304N/A assert(dst != NULL, "jcc most probably wrong");
304N/A
304N/A const int short_size = 2;
304N/A const int long_size = 6;
304N/A intptr_t offs = (intptr_t)dst - (intptr_t)_code_pos;
2676N/A if (maybe_short && is8bit(offs - short_size)) {
304N/A // 0111 tttn #8-bit disp
304N/A emit_byte(0x70 | cc);
304N/A emit_byte((offs - short_size) & 0xFF);
304N/A } else {
304N/A // 0000 1111 1000 tttn #32-bit disp
304N/A assert(is_simm32(offs - long_size),
304N/A "must be 32bit offset (call4)");
304N/A emit_byte(0x0F);
304N/A emit_byte(0x80 | cc);
304N/A emit_long(offs - long_size);
304N/A }
304N/A } else {
304N/A // Note: could eliminate cond. jumps to this jump if condition
304N/A // is the same however, seems to be rather unlikely case.
304N/A // Note: use jccb() if label to be bound is very close to get
304N/A // an 8-bit displacement
304N/A L.add_patch_at(code(), locator());
304N/A emit_byte(0x0F);
304N/A emit_byte(0x80 | cc);
304N/A emit_long(0);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::jccb(Condition cc, Label& L) {
304N/A if (L.is_bound()) {
304N/A const int short_size = 2;
304N/A address entry = target(L);
3046N/A#ifdef ASSERT
3046N/A intptr_t dist = (intptr_t)entry - ((intptr_t)_code_pos + short_size);
3046N/A intptr_t delta = short_branch_delta();
3046N/A if (delta != 0) {
3046N/A dist += (dist < 0 ? (-delta) :delta);
3046N/A }
3046N/A assert(is8bit(dist), "Dispacement too large for a short jmp");
3046N/A#endif
304N/A intptr_t offs = (intptr_t)entry - (intptr_t)_code_pos;
304N/A // 0111 tttn #8-bit disp
304N/A emit_byte(0x70 | cc);
304N/A emit_byte((offs - short_size) & 0xFF);
304N/A } else {
304N/A InstructionMark im(this);
304N/A L.add_patch_at(code(), locator());
304N/A emit_byte(0x70 | cc);
304N/A emit_byte(0);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::jmp(Address adr) {
304N/A InstructionMark im(this);
304N/A prefix(adr);
304N/A emit_byte(0xFF);
304N/A emit_operand(rsp, adr);
304N/A}
304N/A
2676N/Avoid Assembler::jmp(Label& L, bool maybe_short) {
304N/A if (L.is_bound()) {
304N/A address entry = target(L);
304N/A assert(entry != NULL, "jmp most probably wrong");
304N/A InstructionMark im(this);
304N/A const int short_size = 2;
304N/A const int long_size = 5;
304N/A intptr_t offs = entry - _code_pos;
2676N/A if (maybe_short && is8bit(offs - short_size)) {
304N/A emit_byte(0xEB);
304N/A emit_byte((offs - short_size) & 0xFF);
304N/A } else {
304N/A emit_byte(0xE9);
304N/A emit_long(offs - long_size);
304N/A }
304N/A } else {
304N/A // By default, forward jumps are always 32-bit displacements, since
304N/A // we can't yet know where the label will be bound. If you're sure that
304N/A // the forward jump will not run beyond 256 bytes, use jmpb to
304N/A // force an 8-bit displacement.
304N/A InstructionMark im(this);
304N/A L.add_patch_at(code(), locator());
304N/A emit_byte(0xE9);
304N/A emit_long(0);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::jmp(Register entry) {
304N/A int encode = prefix_and_encode(entry->encoding());
304N/A emit_byte(0xFF);
304N/A emit_byte(0xE0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::jmp_literal(address dest, RelocationHolder const& rspec) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xE9);
304N/A assert(dest != NULL, "must have a target");
304N/A intptr_t disp = dest - (_code_pos + sizeof(int32_t));
304N/A assert(is_simm32(disp), "must be 32bit offset (jmp)");
304N/A emit_data(disp, rspec.reloc(), call32_operand);
304N/A}
304N/A
304N/Avoid Assembler::jmpb(Label& L) {
304N/A if (L.is_bound()) {
304N/A const int short_size = 2;
304N/A address entry = target(L);
304N/A assert(entry != NULL, "jmp most probably wrong");
3046N/A#ifdef ASSERT
3046N/A intptr_t dist = (intptr_t)entry - ((intptr_t)_code_pos + short_size);
3046N/A intptr_t delta = short_branch_delta();
3046N/A if (delta != 0) {
3046N/A dist += (dist < 0 ? (-delta) :delta);
3046N/A }
3046N/A assert(is8bit(dist), "Dispacement too large for a short jmp");
3046N/A#endif
304N/A intptr_t offs = entry - _code_pos;
304N/A emit_byte(0xEB);
304N/A emit_byte((offs - short_size) & 0xFF);
304N/A } else {
304N/A InstructionMark im(this);
304N/A L.add_patch_at(code(), locator());
304N/A emit_byte(0xEB);
304N/A emit_byte(0);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::ldmxcsr( Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
304N/A prefix(src);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xAE);
304N/A emit_operand(as_Register(2), src);
304N/A}
304N/A
304N/Avoid Assembler::leal(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A#ifdef _LP64
304N/A emit_byte(0x67); // addr32
304N/A prefix(src, dst);
304N/A#endif // LP64
304N/A emit_byte(0x8D);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::lock() {
304N/A if (Atomics & 1) {
304N/A // Emit either nothing, a NOP, or a NOP: prefix
304N/A emit_byte(0x90) ;
304N/A } else {
304N/A emit_byte(0xF0);
304N/A }
304N/A}
304N/A
775N/Avoid Assembler::lzcntl(Register dst, Register src) {
775N/A assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR");
775N/A emit_byte(0xF3);
775N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
775N/A emit_byte(0x0F);
775N/A emit_byte(0xBD);
775N/A emit_byte(0xC0 | encode);
775N/A}
775N/A
671N/A// Emit mfence instruction
304N/Avoid Assembler::mfence() {
671N/A NOT_LP64(assert(VM_Version::supports_sse2(), "unsupported");)
671N/A emit_byte( 0x0F );
671N/A emit_byte( 0xAE );
671N/A emit_byte( 0xF0 );
304N/A}
304N/A
304N/Avoid Assembler::mov(Register dst, Register src) {
304N/A LP64_ONLY(movq(dst, src)) NOT_LP64(movl(dst, src));
304N/A}
304N/A
304N/Avoid Assembler::movapd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66);
304N/A emit_byte(0x28);
3039N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movaps(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_NONE);
304N/A emit_byte(0x28);
3039N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3845N/Avoid Assembler::movlhps(XMMRegister dst, XMMRegister src) {
3845N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3845N/A int encode = simd_prefix_and_encode(dst, src, src, VEX_SIMD_NONE);
3845N/A emit_byte(0x16);
3845N/A emit_byte(0xC0 | encode);
3845N/A}
3845N/A
304N/Avoid Assembler::movb(Register dst, Address src) {
304N/A NOT_LP64(assert(dst->has_byte_register(), "must have byte register"));
304N/A InstructionMark im(this);
304N/A prefix(src, dst, true);
304N/A emit_byte(0x8A);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::movb(Address dst, int imm8) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0xC6);
304N/A emit_operand(rax, dst, 1);
304N/A emit_byte(imm8);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::movb(Address dst, Register src) {
304N/A assert(src->has_byte_register(), "must have byte register");
304N/A InstructionMark im(this);
304N/A prefix(dst, src, true);
304N/A emit_byte(0x88);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::movdl(XMMRegister dst, Register src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66);
304N/A emit_byte(0x6E);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movdl(Register dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A // swap src/dst to get correct prefix
3039N/A int encode = simd_prefix_and_encode(src, dst, VEX_SIMD_66);
304N/A emit_byte(0x7E);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
2167N/Avoid Assembler::movdl(XMMRegister dst, Address src) {
2167N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
2167N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66);
2167N/A emit_byte(0x6E);
2167N/A emit_operand(dst, src);
2167N/A}
2167N/A
3845N/Avoid Assembler::movdl(Address dst, XMMRegister src) {
3845N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3845N/A InstructionMark im(this);
3845N/A simd_prefix(dst, src, VEX_SIMD_66);
3845N/A emit_byte(0x7E);
3845N/A emit_operand(src, dst);
3845N/A}
3845N/A
304N/Avoid Assembler::movdqa(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66);
304N/A emit_byte(0x6F);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
405N/Avoid Assembler::movdqu(XMMRegister dst, Address src) {
405N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
405N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F3);
405N/A emit_byte(0x6F);
405N/A emit_operand(dst, src);
405N/A}
405N/A
405N/Avoid Assembler::movdqu(XMMRegister dst, XMMRegister src) {
405N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F3);
405N/A emit_byte(0x6F);
405N/A emit_byte(0xC0 | encode);
405N/A}
405N/A
405N/Avoid Assembler::movdqu(Address dst, XMMRegister src) {
405N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
405N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F3);
405N/A emit_byte(0x7F);
405N/A emit_operand(src, dst);
405N/A}
405N/A
3845N/A// Move Unaligned 256bit Vector
3845N/Avoid Assembler::vmovdqu(XMMRegister dst, XMMRegister src) {
3845N/A assert(UseAVX, "");
3845N/A bool vector256 = true;
3845N/A int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_F3, vector256);
3845N/A emit_byte(0x6F);
3845N/A emit_byte(0xC0 | encode);
3845N/A}
3845N/A
3845N/Avoid Assembler::vmovdqu(XMMRegister dst, Address src) {
3845N/A assert(UseAVX, "");
3845N/A InstructionMark im(this);
3845N/A bool vector256 = true;
3845N/A vex_prefix(dst, xnoreg, src, VEX_SIMD_F3, vector256);
3845N/A emit_byte(0x6F);
3845N/A emit_operand(dst, src);
3845N/A}
3845N/A
3845N/Avoid Assembler::vmovdqu(Address dst, XMMRegister src) {
3845N/A assert(UseAVX, "");
3845N/A InstructionMark im(this);
3845N/A bool vector256 = true;
3845N/A // swap src<->dst for encoding
3845N/A assert(src != xnoreg, "sanity");
3845N/A vex_prefix(src, xnoreg, dst, VEX_SIMD_F3, vector256);
3845N/A emit_byte(0x7F);
3845N/A emit_operand(src, dst);
3845N/A}
3845N/A
304N/A// Uses zero extension on 64bit
304N/A
304N/Avoid Assembler::movl(Register dst, int32_t imm32) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xB8 | encode);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::movl(Register dst, Register src) {
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x8B);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x8B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movl(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0xC7);
304N/A emit_operand(rax, dst, 4);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::movl(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefix(dst, src);
304N/A emit_byte(0x89);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/A// New cpus require to use movsd and movss to avoid partial register stall
304N/A// when loading from memory. But for old Opteron use movlpd instead of movsd.
304N/A// The selection is done in MacroAssembler::movdbl() and movflt().
304N/Avoid Assembler::movlpd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
304N/A emit_byte(0x12);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movq( MMXRegister dst, Address src ) {
304N/A assert( VM_Version::supports_mmx(), "" );
304N/A emit_byte(0x0F);
304N/A emit_byte(0x6F);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movq( Address dst, MMXRegister src ) {
304N/A assert( VM_Version::supports_mmx(), "" );
304N/A emit_byte(0x0F);
304N/A emit_byte(0x7F);
304N/A // workaround gcc (3.2.1-7a) bug
304N/A // In that version of gcc with only an emit_operand(MMX, Address)
304N/A // gcc will tail jump and try and reverse the parameters completely
304N/A // obliterating dst in the process. By having a version available
304N/A // that doesn't need to swap the args at the tail jump the bug is
304N/A // avoided.
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movq(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x7E);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movq(Address dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66);
304N/A emit_byte(0xD6);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::movsbl(Register dst, Address src) { // movsxb
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xBE);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movsbl(Register dst, Register src) { // movsxb
304N/A NOT_LP64(assert(src->has_byte_register(), "must have byte register"));
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding(), true);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xBE);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movsd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x10);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movsd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x10);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movsd(Address dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x11);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::movss(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x10);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movss(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x10);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movss(Address dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x11);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::movswl(Register dst, Address src) { // movsxw
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xBF);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movswl(Register dst, Register src) { // movsxw
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0xBF);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movw(Address dst, int imm16) {
304N/A InstructionMark im(this);
304N/A
304N/A emit_byte(0x66); // switch to 16-bit mode
304N/A prefix(dst);
304N/A emit_byte(0xC7);
304N/A emit_operand(rax, dst, 2);
304N/A emit_word(imm16);
304N/A}
304N/A
304N/Avoid Assembler::movw(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0x66);
304N/A prefix(src, dst);
304N/A emit_byte(0x8B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movw(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0x66);
304N/A prefix(dst, src);
304N/A emit_byte(0x89);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::movzbl(Register dst, Address src) { // movzxb
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xB6);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movzbl(Register dst, Register src) { // movzxb
304N/A NOT_LP64(assert(src->has_byte_register(), "must have byte register"));
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding(), true);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xB6);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movzwl(Register dst, Address src) { // movzxw
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xB7);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movzwl(Register dst, Register src) { // movzxw
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0xB7);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::mull(Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src);
304N/A emit_byte(0xF7);
304N/A emit_operand(rsp, src);
304N/A}
304N/A
304N/Avoid Assembler::mull(Register src) {
304N/A int encode = prefix_and_encode(src->encoding());
304N/A emit_byte(0xF7);
304N/A emit_byte(0xE0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::mulsd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x59);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::mulsd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x59);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::mulss(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x59);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::mulss(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x59);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::negl(Register dst) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xF7);
304N/A emit_byte(0xD8 | encode);
304N/A}
304N/A
0N/Avoid Assembler::nop(int i) {
304N/A#ifdef ASSERT
0N/A assert(i > 0, " ");
304N/A // The fancy nops aren't currently recognized by debuggers making it a
304N/A // pain to disassemble code while debugging. If asserts are on clearly
304N/A // speed is not an issue so simply use the single byte traditional nop
304N/A // to do alignment.
304N/A
304N/A for (; i > 0 ; i--) emit_byte(0x90);
304N/A return;
304N/A
304N/A#endif // ASSERT
304N/A
0N/A if (UseAddressNop && VM_Version::is_intel()) {
0N/A //
0N/A // Using multi-bytes nops "0x0F 0x1F [address]" for Intel
0N/A // 1: 0x90
0N/A // 2: 0x66 0x90
0N/A // 3: 0x66 0x66 0x90 (don't use "0x0F 0x1F 0x00" - need patching safe padding)
0N/A // 4: 0x0F 0x1F 0x40 0x00
0N/A // 5: 0x0F 0x1F 0x44 0x00 0x00
0N/A // 6: 0x66 0x0F 0x1F 0x44 0x00 0x00
0N/A // 7: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
0N/A // 8: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A // 9: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A // 10: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A // 11: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A
0N/A // The rest coding is Intel specific - don't use consecutive address nops
0N/A
0N/A // 12: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
0N/A // 13: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
0N/A // 14: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
0N/A // 15: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
0N/A
0N/A while(i >= 15) {
0N/A // For Intel don't generate consecutive addess nops (mix with regular nops)
0N/A i -= 15;
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A addr_nop_8();
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x90); // nop
0N/A }
0N/A switch (i) {
0N/A case 14:
0N/A emit_byte(0x66); // size prefix
0N/A case 13:
0N/A emit_byte(0x66); // size prefix
0N/A case 12:
0N/A addr_nop_8();
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x90); // nop
0N/A break;
0N/A case 11:
0N/A emit_byte(0x66); // size prefix
0N/A case 10:
0N/A emit_byte(0x66); // size prefix
0N/A case 9:
0N/A emit_byte(0x66); // size prefix
0N/A case 8:
0N/A addr_nop_8();
0N/A break;
0N/A case 7:
0N/A addr_nop_7();
0N/A break;
0N/A case 6:
0N/A emit_byte(0x66); // size prefix
0N/A case 5:
0N/A addr_nop_5();
0N/A break;
0N/A case 4:
0N/A addr_nop_4();
0N/A break;
0N/A case 3:
0N/A // Don't use "0x0F 0x1F 0x00" - need patching safe padding
0N/A emit_byte(0x66); // size prefix
0N/A case 2:
0N/A emit_byte(0x66); // size prefix
0N/A case 1:
0N/A emit_byte(0x90); // nop
0N/A break;
0N/A default:
0N/A assert(i == 0, " ");
0N/A }
0N/A return;
0N/A }
0N/A if (UseAddressNop && VM_Version::is_amd()) {
0N/A //
0N/A // Using multi-bytes nops "0x0F 0x1F [address]" for AMD.
0N/A // 1: 0x90
0N/A // 2: 0x66 0x90
0N/A // 3: 0x66 0x66 0x90 (don't use "0x0F 0x1F 0x00" - need patching safe padding)
0N/A // 4: 0x0F 0x1F 0x40 0x00
0N/A // 5: 0x0F 0x1F 0x44 0x00 0x00
0N/A // 6: 0x66 0x0F 0x1F 0x44 0x00 0x00
0N/A // 7: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
0N/A // 8: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A // 9: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A // 10: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A // 11: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A
0N/A // The rest coding is AMD specific - use consecutive address nops
0N/A
0N/A // 12: 0x66 0x0F 0x1F 0x44 0x00 0x00 0x66 0x0F 0x1F 0x44 0x00 0x00
0N/A // 13: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00 0x66 0x0F 0x1F 0x44 0x00 0x00
0N/A // 14: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
0N/A // 15: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
0N/A // 16: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
0N/A // Size prefixes (0x66) are added for larger sizes
0N/A
0N/A while(i >= 22) {
0N/A i -= 11;
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66); // size prefix
0N/A addr_nop_8();
0N/A }
0N/A // Generate first nop for size between 21-12
0N/A switch (i) {
0N/A case 21:
0N/A i -= 1;
0N/A emit_byte(0x66); // size prefix
0N/A case 20:
0N/A case 19:
0N/A i -= 1;
0N/A emit_byte(0x66); // size prefix
0N/A case 18:
0N/A case 17:
0N/A i -= 1;
0N/A emit_byte(0x66); // size prefix
0N/A case 16:
0N/A case 15:
0N/A i -= 8;
0N/A addr_nop_8();
0N/A break;
0N/A case 14:
0N/A case 13:
0N/A i -= 7;
0N/A addr_nop_7();
0N/A break;
0N/A case 12:
0N/A i -= 6;
0N/A emit_byte(0x66); // size prefix
0N/A addr_nop_5();
0N/A break;
0N/A default:
0N/A assert(i < 12, " ");
0N/A }
0N/A
0N/A // Generate second nop for size between 11-1
0N/A switch (i) {
0N/A case 11:
0N/A emit_byte(0x66); // size prefix
0N/A case 10:
0N/A emit_byte(0x66); // size prefix
0N/A case 9:
0N/A emit_byte(0x66); // size prefix
0N/A case 8:
0N/A addr_nop_8();
0N/A break;
0N/A case 7:
0N/A addr_nop_7();
0N/A break;
0N/A case 6:
0N/A emit_byte(0x66); // size prefix
0N/A case 5:
0N/A addr_nop_5();
0N/A break;
0N/A case 4:
0N/A addr_nop_4();
0N/A break;
0N/A case 3:
0N/A // Don't use "0x0F 0x1F 0x00" - need patching safe padding
0N/A emit_byte(0x66); // size prefix
0N/A case 2:
0N/A emit_byte(0x66); // size prefix
0N/A case 1:
0N/A emit_byte(0x90); // nop
0N/A break;
0N/A default:
0N/A assert(i == 0, " ");
0N/A }
0N/A return;
0N/A }
0N/A
0N/A // Using nops with size prefixes "0x66 0x90".
0N/A // From AMD Optimization Guide:
0N/A // 1: 0x90
0N/A // 2: 0x66 0x90
0N/A // 3: 0x66 0x66 0x90
0N/A // 4: 0x66 0x66 0x66 0x90
0N/A // 5: 0x66 0x66 0x90 0x66 0x90
0N/A // 6: 0x66 0x66 0x90 0x66 0x66 0x90
0N/A // 7: 0x66 0x66 0x66 0x90 0x66 0x66 0x90
0N/A // 8: 0x66 0x66 0x66 0x90 0x66 0x66 0x66 0x90
0N/A // 9: 0x66 0x66 0x90 0x66 0x66 0x90 0x66 0x66 0x90
0N/A // 10: 0x66 0x66 0x66 0x90 0x66 0x66 0x90 0x66 0x66 0x90
0N/A //
0N/A while(i > 12) {
0N/A i -= 4;
0N/A emit_byte(0x66); // size prefix
0N/A emit_byte(0x66);
0N/A emit_byte(0x66);
0N/A emit_byte(0x90); // nop
0N/A }
0N/A // 1 - 12 nops
0N/A if(i > 8) {
0N/A if(i > 9) {
0N/A i -= 1;
0N/A emit_byte(0x66);
0N/A }
0N/A i -= 3;
0N/A emit_byte(0x66);
0N/A emit_byte(0x66);
0N/A emit_byte(0x90);
0N/A }
0N/A // 1 - 8 nops
0N/A if(i > 4) {
0N/A if(i > 6) {
0N/A i -= 1;
0N/A emit_byte(0x66);
0N/A }
0N/A i -= 3;
0N/A emit_byte(0x66);
0N/A emit_byte(0x66);
0N/A emit_byte(0x90);
0N/A }
0N/A switch (i) {
0N/A case 4:
0N/A emit_byte(0x66);
0N/A case 3:
0N/A emit_byte(0x66);
0N/A case 2:
0N/A emit_byte(0x66);
0N/A case 1:
0N/A emit_byte(0x90);
0N/A break;
0N/A default:
0N/A assert(i == 0, " ");
0N/A }
0N/A}
0N/A
304N/Avoid Assembler::notl(Register dst) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xF7);
304N/A emit_byte(0xD0 | encode );
304N/A}
304N/A
304N/Avoid Assembler::orl(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
1988N/A emit_arith_operand(0x81, rcx, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::orl(Register dst, int32_t imm32) {
304N/A prefix(dst);
304N/A emit_arith(0x81, 0xC8, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::orl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x0B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::orl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x0B, 0xC0, dst, src);
304N/A}
304N/A
3039N/Avoid Assembler::packuswb(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x67);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
3039N/Avoid Assembler::packuswb(XMMRegister dst, XMMRegister src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x67);
3039N/A emit_byte(0xC0 | encode);
3039N/A}
3039N/A
681N/Avoid Assembler::pcmpestri(XMMRegister dst, Address src, int imm8) {
681N/A assert(VM_Version::supports_sse4_2(), "");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A);
681N/A emit_byte(0x61);
681N/A emit_operand(dst, src);
681N/A emit_byte(imm8);
681N/A}
681N/A
681N/Avoid Assembler::pcmpestri(XMMRegister dst, XMMRegister src, int imm8) {
681N/A assert(VM_Version::supports_sse4_2(), "");
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A);
681N/A emit_byte(0x61);
681N/A emit_byte(0xC0 | encode);
681N/A emit_byte(imm8);
681N/A}
681N/A
3039N/Avoid Assembler::pmovzxbw(XMMRegister dst, Address src) {
3039N/A assert(VM_Version::supports_sse4_1(), "");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
3039N/A emit_byte(0x30);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
3039N/Avoid Assembler::pmovzxbw(XMMRegister dst, XMMRegister src) {
3039N/A assert(VM_Version::supports_sse4_1(), "");
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
3039N/A emit_byte(0x30);
3039N/A emit_byte(0xC0 | encode);
3039N/A}
3039N/A
304N/A// generic
304N/Avoid Assembler::pop(Register dst) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0x58 | encode);
304N/A}
304N/A
643N/Avoid Assembler::popcntl(Register dst, Address src) {
643N/A assert(VM_Version::supports_popcnt(), "must support");
643N/A InstructionMark im(this);
643N/A emit_byte(0xF3);
643N/A prefix(src, dst);
643N/A emit_byte(0x0F);
643N/A emit_byte(0xB8);
643N/A emit_operand(dst, src);
643N/A}
643N/A
643N/Avoid Assembler::popcntl(Register dst, Register src) {
643N/A assert(VM_Version::supports_popcnt(), "must support");
643N/A emit_byte(0xF3);
643N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
643N/A emit_byte(0x0F);
643N/A emit_byte(0xB8);
643N/A emit_byte(0xC0 | encode);
643N/A}
643N/A
304N/Avoid Assembler::popf() {
304N/A emit_byte(0x9D);
304N/A}
304N/A
1060N/A#ifndef _LP64 // no 32bit push/pop on amd64
304N/Avoid Assembler::popl(Address dst) {
304N/A // NOTE: this will adjust stack by 8byte on 64bits
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0x8F);
304N/A emit_operand(rax, dst);
304N/A}
1060N/A#endif
304N/A
304N/Avoid Assembler::prefetch_prefix(Address src) {
304N/A prefix(src);
304N/A emit_byte(0x0F);
304N/A}
304N/A
304N/Avoid Assembler::prefetchnta(Address src) {
2701N/A NOT_LP64(assert(VM_Version::supports_sse(), "must support"));
304N/A InstructionMark im(this);
304N/A prefetch_prefix(src);
304N/A emit_byte(0x18);
304N/A emit_operand(rax, src); // 0, src
304N/A}
304N/A
304N/Avoid Assembler::prefetchr(Address src) {
2679N/A assert(VM_Version::supports_3dnow_prefetch(), "must support");
304N/A InstructionMark im(this);
304N/A prefetch_prefix(src);
304N/A emit_byte(0x0D);
304N/A emit_operand(rax, src); // 0, src
304N/A}
304N/A
304N/Avoid Assembler::prefetcht0(Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), "must support"));
304N/A InstructionMark im(this);
304N/A prefetch_prefix(src);
304N/A emit_byte(0x18);
304N/A emit_operand(rcx, src); // 1, src
304N/A}
304N/A
304N/Avoid Assembler::prefetcht1(Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), "must support"));
304N/A InstructionMark im(this);
304N/A prefetch_prefix(src);
304N/A emit_byte(0x18);
304N/A emit_operand(rdx, src); // 2, src
304N/A}
304N/A
304N/Avoid Assembler::prefetcht2(Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), "must support"));
304N/A InstructionMark im(this);
304N/A prefetch_prefix(src);
304N/A emit_byte(0x18);
304N/A emit_operand(rbx, src); // 3, src
304N/A}
304N/A
304N/Avoid Assembler::prefetchw(Address src) {
2679N/A assert(VM_Version::supports_3dnow_prefetch(), "must support");
304N/A InstructionMark im(this);
304N/A prefetch_prefix(src);
304N/A emit_byte(0x0D);
304N/A emit_operand(rcx, src); // 1, src
304N/A}
304N/A
304N/Avoid Assembler::prefix(Prefix p) {
304N/A a_byte(p);
304N/A}
304N/A
2134N/Avoid Assembler::por(XMMRegister dst, XMMRegister src) {
2134N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
2134N/A emit_byte(0xEB);
2134N/A emit_byte(0xC0 | encode);
2134N/A}
2134N/A
3039N/Avoid Assembler::por(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0xEB);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
304N/Avoid Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) {
304N/A assert(isByte(mode), "invalid value");
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66);
304N/A emit_byte(0x70);
304N/A emit_byte(0xC0 | encode);
304N/A emit_byte(mode & 0xFF);
304N/A
304N/A}
304N/A
304N/Avoid Assembler::pshufd(XMMRegister dst, Address src, int mode) {
304N/A assert(isByte(mode), "invalid value");
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66);
304N/A emit_byte(0x70);
304N/A emit_operand(dst, src);
304N/A emit_byte(mode & 0xFF);
304N/A}
304N/A
304N/Avoid Assembler::pshuflw(XMMRegister dst, XMMRegister src, int mode) {
304N/A assert(isByte(mode), "invalid value");
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x70);
304N/A emit_byte(0xC0 | encode);
304N/A emit_byte(mode & 0xFF);
304N/A}
304N/A
304N/Avoid Assembler::pshuflw(XMMRegister dst, Address src, int mode) {
304N/A assert(isByte(mode), "invalid value");
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x70);
304N/A emit_operand(dst, src);
304N/A emit_byte(mode & 0xFF);
304N/A}
304N/A
304N/Avoid Assembler::psrlq(XMMRegister dst, int shift) {
2167N/A // Shift 64 bit value logically right by specified number of bits.
2167N/A // HMM Table D-1 says sse2 or mmx.
2167N/A // Do not confuse it with psrldq SSE2 instruction which
2167N/A // shifts 128 bit value in xmm register by number of bytes.
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66);
304N/A emit_byte(0x73);
304N/A emit_byte(0xC0 | encode);
304N/A emit_byte(shift);
304N/A}
304N/A
2167N/Avoid Assembler::psrldq(XMMRegister dst, int shift) {
2167N/A // Shift 128 bit value in xmm register by number of bytes.
2167N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(xmm3, dst, dst, VEX_SIMD_66);
2167N/A emit_byte(0x73);
2167N/A emit_byte(0xC0 | encode);
2167N/A emit_byte(shift);
2167N/A}
2167N/A
681N/Avoid Assembler::ptest(XMMRegister dst, Address src) {
681N/A assert(VM_Version::supports_sse4_1(), "");
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
681N/A emit_byte(0x17);
681N/A emit_operand(dst, src);
681N/A}
681N/A
681N/Avoid Assembler::ptest(XMMRegister dst, XMMRegister src) {
681N/A assert(VM_Version::supports_sse4_1(), "");
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
681N/A emit_byte(0x17);
681N/A emit_byte(0xC0 | encode);
681N/A}
681N/A
3039N/Avoid Assembler::punpcklbw(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x60);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
304N/Avoid Assembler::punpcklbw(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
304N/A emit_byte(0x60);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3039N/Avoid Assembler::punpckldq(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x62);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
3039N/Avoid Assembler::punpckldq(XMMRegister dst, XMMRegister src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x62);
3039N/A emit_byte(0xC0 | encode);
3039N/A}
3039N/A
3891N/Avoid Assembler::punpcklqdq(XMMRegister dst, XMMRegister src) {
3891N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3891N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
3891N/A emit_byte(0x6C);
3891N/A emit_byte(0xC0 | encode);
3891N/A}
3891N/A
304N/Avoid Assembler::push(int32_t imm32) {
304N/A // in 64bits we push 64bits onto the stack but only
304N/A // take a 32bit immediate
304N/A emit_byte(0x68);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::push(Register src) {
304N/A int encode = prefix_and_encode(src->encoding());
304N/A
304N/A emit_byte(0x50 | encode);
304N/A}
304N/A
304N/Avoid Assembler::pushf() {
304N/A emit_byte(0x9C);
304N/A}
304N/A
1060N/A#ifndef _LP64 // no 32bit push/pop on amd64
304N/Avoid Assembler::pushl(Address src) {
304N/A // Note this will push 64bit on 64bit
304N/A InstructionMark im(this);
304N/A prefix(src);
304N/A emit_byte(0xFF);
304N/A emit_operand(rsi, src);
304N/A}
1060N/A#endif
304N/A
304N/Avoid Assembler::pxor(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
304N/A emit_byte(0xEF);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::pxor(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
304N/A emit_byte(0xEF);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::rcll(Register dst, int imm8) {
304N/A assert(isShiftCount(imm8), "illegal shift count");
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A if (imm8 == 1) {
304N/A emit_byte(0xD1);
304N/A emit_byte(0xD0 | encode);
304N/A } else {
304N/A emit_byte(0xC1);
304N/A emit_byte(0xD0 | encode);
304N/A emit_byte(imm8);
304N/A }
304N/A}
304N/A
304N/A// copies data from [esi] to [edi] using rcx pointer sized words
304N/A// generic
304N/Avoid Assembler::rep_mov() {
304N/A emit_byte(0xF3);
304N/A // MOVSQ
304N/A LP64_ONLY(prefix(REX_W));
304N/A emit_byte(0xA5);
304N/A}
304N/A
304N/A// sets rcx pointer sized words with rax, value at [edi]
304N/A// generic
304N/Avoid Assembler::rep_set() { // rep_set
304N/A emit_byte(0xF3);
304N/A // STOSQ
304N/A LP64_ONLY(prefix(REX_W));
304N/A emit_byte(0xAB);
304N/A}
304N/A
304N/A// scans rcx pointer sized words at [edi] for occurance of rax,
304N/A// generic
304N/Avoid Assembler::repne_scan() { // repne_scan
304N/A emit_byte(0xF2);
304N/A // SCASQ
304N/A LP64_ONLY(prefix(REX_W));
304N/A emit_byte(0xAF);
304N/A}
304N/A
304N/A#ifdef _LP64
304N/A// scans rcx 4 byte words at [edi] for occurance of rax,
304N/A// generic
304N/Avoid Assembler::repne_scanl() { // repne_scan
304N/A emit_byte(0xF2);
304N/A // SCASL
304N/A emit_byte(0xAF);
304N/A}
304N/A#endif
304N/A
0N/Avoid Assembler::ret(int imm16) {
0N/A if (imm16 == 0) {
0N/A emit_byte(0xC3);
0N/A } else {
0N/A emit_byte(0xC2);
0N/A emit_word(imm16);
0N/A }
0N/A}
0N/A
304N/Avoid Assembler::sahf() {
304N/A#ifdef _LP64
304N/A // Not supported in 64bit mode
304N/A ShouldNotReachHere();
304N/A#endif
304N/A emit_byte(0x9E);
304N/A}
304N/A
304N/Avoid Assembler::sarl(Register dst, int imm8) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A assert(isShiftCount(imm8), "illegal shift count");
304N/A if (imm8 == 1) {
304N/A emit_byte(0xD1);
304N/A emit_byte(0xF8 | encode);
304N/A } else {
304N/A emit_byte(0xC1);
304N/A emit_byte(0xF8 | encode);
304N/A emit_byte(imm8);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::sarl(Register dst) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xD3);
304N/A emit_byte(0xF8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::sbbl(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_arith_operand(0x81, rbx, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::sbbl(Register dst, int32_t imm32) {
304N/A prefix(dst);
304N/A emit_arith(0x81, 0xD8, dst, imm32);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::sbbl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x1B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::sbbl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x1B, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::setb(Condition cc, Register dst) {
304N/A assert(0 <= cc && cc < 16, "illegal cc");
304N/A int encode = prefix_and_encode(dst->encoding(), true);
0N/A emit_byte(0x0F);
304N/A emit_byte(0x90 | cc);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::shll(Register dst, int imm8) {
304N/A assert(isShiftCount(imm8), "illegal shift count");
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A if (imm8 == 1 ) {
304N/A emit_byte(0xD1);
304N/A emit_byte(0xE0 | encode);
304N/A } else {
304N/A emit_byte(0xC1);
304N/A emit_byte(0xE0 | encode);
304N/A emit_byte(imm8);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::shll(Register dst) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xD3);
304N/A emit_byte(0xE0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::shrl(Register dst, int imm8) {
304N/A assert(isShiftCount(imm8), "illegal shift count");
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xC1);
304N/A emit_byte(0xE8 | encode);
304N/A emit_byte(imm8);
304N/A}
304N/A
304N/Avoid Assembler::shrl(Register dst) {
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xD3);
304N/A emit_byte(0xE8 | encode);
304N/A}
0N/A
0N/A// copies a single word from [esi] to [edi]
0N/Avoid Assembler::smovl() {
0N/A emit_byte(0xA5);
0N/A}
0N/A
304N/Avoid Assembler::sqrtsd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x51);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
1915N/Avoid Assembler::sqrtsd(XMMRegister dst, Address src) {
1915N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
1915N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F2);
1915N/A emit_byte(0x51);
1915N/A emit_operand(dst, src);
1915N/A}
1915N/A
1915N/Avoid Assembler::sqrtss(XMMRegister dst, XMMRegister src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
1915N/A emit_byte(0x51);
1915N/A emit_byte(0xC0 | encode);
1915N/A}
1915N/A
1915N/Avoid Assembler::sqrtss(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F3);
1915N/A emit_byte(0x51);
1915N/A emit_operand(dst, src);
1915N/A}
1915N/A
304N/Avoid Assembler::stmxcsr( Address dst) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
304N/A prefix(dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xAE);
304N/A emit_operand(as_Register(3), dst);
304N/A}
304N/A
304N/Avoid Assembler::subl(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefix(dst);
1988N/A emit_arith_operand(0x81, rbp, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::subl(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefix(dst, src);
304N/A emit_byte(0x29);
304N/A emit_operand(src, dst);
304N/A}
304N/A
1988N/Avoid Assembler::subl(Register dst, int32_t imm32) {
1988N/A prefix(dst);
1988N/A emit_arith(0x81, 0xE8, dst, imm32);
1988N/A}
1988N/A
3236N/A// Force generation of a 4 byte immediate value even if it fits into 8bit
3236N/Avoid Assembler::subl_imm32(Register dst, int32_t imm32) {
3236N/A prefix(dst);
3236N/A emit_arith_imm32(0x81, 0xE8, dst, imm32);
3236N/A}
3236N/A
304N/Avoid Assembler::subl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x2B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::subl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x2B, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::subsd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x5C);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::subsd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x5C);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::subss(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x5C);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::subss(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x5C);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::testb(Register dst, int imm8) {
304N/A NOT_LP64(assert(dst->has_byte_register(), "must have byte register"));
304N/A (void) prefix_and_encode(dst->encoding(), true);
304N/A emit_arith_b(0xF6, 0xC0, dst, imm8);
304N/A}
304N/A
304N/Avoid Assembler::testl(Register dst, int32_t imm32) {
304N/A // not using emit_arith because test
304N/A // doesn't support sign-extension of
304N/A // 8bit operands
304N/A int encode = dst->encoding();
304N/A if (encode == 0) {
304N/A emit_byte(0xA9);
304N/A } else {
304N/A encode = prefix_and_encode(encode);
304N/A emit_byte(0xF7);
304N/A emit_byte(0xC0 | encode);
304N/A }
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::testl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x85, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::testl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x85);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::ucomisd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x2E);
3039N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::ucomisd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x2E);
3039N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::ucomiss(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix(dst, src, VEX_SIMD_NONE);
304N/A emit_byte(0x2E);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::ucomiss(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_NONE);
304N/A emit_byte(0x2E);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::xaddl(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefix(dst, src);
0N/A emit_byte(0x0F);
304N/A emit_byte(0xC1);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::xchgl(Register dst, Address src) { // xchg
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x87);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::xchgl(Register dst, Register src) {
304N/A int encode = prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x87);
304N/A emit_byte(0xc0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::xorl(Register dst, int32_t imm32) {
304N/A prefix(dst);
304N/A emit_arith(0x81, 0xF0, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::xorl(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefix(src, dst);
304N/A emit_byte(0x33);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::xorl(Register dst, Register src) {
304N/A (void) prefix_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x33, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::xorpd(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66);
3039N/A emit_byte(0x57);
3039N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::xorpd(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_66);
304N/A emit_byte(0x57);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::xorps(XMMRegister dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_NONE);
304N/A emit_byte(0x57);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::xorps(XMMRegister dst, Address src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
304N/A InstructionMark im(this);
3039N/A simd_prefix(dst, dst, src, VEX_SIMD_NONE);
304N/A emit_byte(0x57);
304N/A emit_operand(dst, src);
304N/A}
304N/A
3041N/A// AVX 3-operands non destructive source instructions (encoded with VEX prefix)
3041N/A
3041N/Avoid Assembler::vaddsd(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x58);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vaddsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x58);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/Avoid Assembler::vaddss(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x58);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vaddss(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x58);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/Avoid Assembler::vandpd(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_66); // 128-bit vector
3041N/A emit_byte(0x54);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vandps(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_NONE); // 128-bit vector
3041N/A emit_byte(0x54);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vdivsd(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x5E);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vdivsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x5E);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/Avoid Assembler::vdivss(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x5E);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vdivss(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x5E);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/Avoid Assembler::vmulsd(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x59);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vmulsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x59);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/Avoid Assembler::vmulss(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x59);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vmulss(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x59);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/A
3041N/Avoid Assembler::vsubsd(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x5C);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vsubsd(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F2);
3041N/A emit_byte(0x5C);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/Avoid Assembler::vsubss(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x5C);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3041N/Avoid Assembler::vsubss(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_F3);
3041N/A emit_byte(0x5C);
3041N/A emit_byte(0xC0 | encode);
3041N/A}
3041N/A
3041N/Avoid Assembler::vxorpd(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_66); // 128-bit vector
3041N/A emit_byte(0x57);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3845N/Avoid Assembler::vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) {
3845N/A assert(VM_Version::supports_avx(), "");
3845N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256);
3845N/A emit_byte(0x57);
3845N/A emit_byte(0xC0 | encode);
3845N/A}
3845N/A
3041N/Avoid Assembler::vxorps(XMMRegister dst, XMMRegister nds, Address src) {
3041N/A assert(VM_Version::supports_avx(), "");
3041N/A InstructionMark im(this);
3041N/A vex_prefix(dst, nds, src, VEX_SIMD_NONE); // 128-bit vector
3041N/A emit_byte(0x57);
3041N/A emit_operand(dst, src);
3041N/A}
3041N/A
3845N/Avoid Assembler::vxorps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) {
3845N/A assert(VM_Version::supports_avx(), "");
3845N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_NONE, vector256);
3845N/A emit_byte(0x57);
3845N/A emit_byte(0xC0 | encode);
3845N/A}
3845N/A
3891N/Avoid Assembler::vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) {
3891N/A assert(VM_Version::supports_avx2() || (!vector256) && VM_Version::supports_avx(), "");
3891N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256);
3891N/A emit_byte(0xEF);
3891N/A emit_byte(0xC0 | encode);
3891N/A}
3891N/A
3845N/Avoid Assembler::vinsertf128h(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3845N/A assert(VM_Version::supports_avx(), "");
3845N/A bool vector256 = true;
3845N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A);
3845N/A emit_byte(0x18);
3845N/A emit_byte(0xC0 | encode);
3845N/A // 0x00 - insert into lower 128 bits
3845N/A // 0x01 - insert into upper 128 bits
3845N/A emit_byte(0x01);
3845N/A}
3845N/A
3891N/Avoid Assembler::vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3891N/A assert(VM_Version::supports_avx2(), "");
3891N/A bool vector256 = true;
3891N/A int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A);
3891N/A emit_byte(0x38);
3891N/A emit_byte(0xC0 | encode);
3891N/A // 0x00 - insert into lower 128 bits
3891N/A // 0x01 - insert into upper 128 bits
3891N/A emit_byte(0x01);
3891N/A}
3891N/A
3845N/Avoid Assembler::vzeroupper() {
3845N/A assert(VM_Version::supports_avx(), "");
3845N/A (void)vex_prefix_and_encode(xmm0, xmm0, xmm0, VEX_SIMD_NONE);
3845N/A emit_byte(0x77);
3845N/A}
3845N/A
3041N/A
304N/A#ifndef _LP64
304N/A// 32bit only pieces of the assembler
304N/A
304N/Avoid Assembler::cmp_literal32(Register src1, int32_t imm32, RelocationHolder const& rspec) {
304N/A // NO PREFIX AS NEVER 64BIT
304N/A InstructionMark im(this);
304N/A emit_byte(0x81);
304N/A emit_byte(0xF8 | src1->encoding());
304N/A emit_data(imm32, rspec, 0);
304N/A}
304N/A
304N/Avoid Assembler::cmp_literal32(Address src1, int32_t imm32, RelocationHolder const& rspec) {
304N/A // NO PREFIX AS NEVER 64BIT (not even 32bit versions of 64bit regs
304N/A InstructionMark im(this);
304N/A emit_byte(0x81);
304N/A emit_operand(rdi, src1);
304N/A emit_data(imm32, rspec, 0);
304N/A}
304N/A
304N/A// The 64-bit (32bit platform) cmpxchg compares the value at adr with the contents of rdx:rax,
304N/A// and stores rcx:rbx into adr if so; otherwise, the value at adr is loaded
304N/A// into rdx:rax. The ZF is set if the compared values were equal, and cleared otherwise.
304N/Avoid Assembler::cmpxchg8(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xc7);
304N/A emit_operand(rcx, adr);
304N/A}
304N/A
304N/Avoid Assembler::decl(Register dst) {
304N/A // Don't use it directly. Use MacroAssembler::decrementl() instead.
304N/A emit_byte(0x48 | dst->encoding());
304N/A}
304N/A
304N/A#endif // _LP64
304N/A
304N/A// 64bit typically doesn't use the x87 but needs to for the trig funcs
304N/A
304N/Avoid Assembler::fabs() {
304N/A emit_byte(0xD9);
304N/A emit_byte(0xE1);
304N/A}
304N/A
304N/Avoid Assembler::fadd(int i) {
304N/A emit_farith(0xD8, 0xC0, i);
304N/A}
304N/A
304N/Avoid Assembler::fadd_d(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDC);
304N/A emit_operand32(rax, src);
304N/A}
304N/A
304N/Avoid Assembler::fadd_s(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD8);
304N/A emit_operand32(rax, src);
304N/A}
304N/A
304N/Avoid Assembler::fadda(int i) {
304N/A emit_farith(0xDC, 0xC0, i);
304N/A}
304N/A
304N/Avoid Assembler::faddp(int i) {
304N/A emit_farith(0xDE, 0xC0, i);
304N/A}
304N/A
304N/Avoid Assembler::fchs() {
304N/A emit_byte(0xD9);
304N/A emit_byte(0xE0);
304N/A}
304N/A
304N/Avoid Assembler::fcom(int i) {
304N/A emit_farith(0xD8, 0xD0, i);
304N/A}
304N/A
304N/Avoid Assembler::fcomp(int i) {
304N/A emit_farith(0xD8, 0xD8, i);
304N/A}
304N/A
304N/Avoid Assembler::fcomp_d(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDC);
304N/A emit_operand32(rbx, src);
304N/A}
304N/A
304N/Avoid Assembler::fcomp_s(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD8);
304N/A emit_operand32(rbx, src);
304N/A}
304N/A
304N/Avoid Assembler::fcompp() {
304N/A emit_byte(0xDE);
304N/A emit_byte(0xD9);
304N/A}
304N/A
304N/Avoid Assembler::fcos() {
304N/A emit_byte(0xD9);
0N/A emit_byte(0xFF);
304N/A}
304N/A
304N/Avoid Assembler::fdecstp() {
304N/A emit_byte(0xD9);
304N/A emit_byte(0xF6);
304N/A}
304N/A
304N/Avoid Assembler::fdiv(int i) {
304N/A emit_farith(0xD8, 0xF0, i);
304N/A}
304N/A
304N/Avoid Assembler::fdiv_d(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDC);
304N/A emit_operand32(rsi, src);
304N/A}
304N/A
304N/Avoid Assembler::fdiv_s(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD8);
304N/A emit_operand32(rsi, src);
304N/A}
304N/A
304N/Avoid Assembler::fdiva(int i) {
304N/A emit_farith(0xDC, 0xF8, i);
304N/A}
304N/A
304N/A// Note: The Intel manual (Pentium Processor User's Manual, Vol.3, 1994)
304N/A// is erroneous for some of the floating-point instructions below.
304N/A
304N/Avoid Assembler::fdivp(int i) {
304N/A emit_farith(0xDE, 0xF8, i); // ST(0) <- ST(0) / ST(1) and pop (Intel manual wrong)
304N/A}
304N/A
304N/Avoid Assembler::fdivr(int i) {
304N/A emit_farith(0xD8, 0xF8, i);
304N/A}
304N/A
304N/Avoid Assembler::fdivr_d(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDC);
304N/A emit_operand32(rdi, src);
304N/A}
304N/A
304N/Avoid Assembler::fdivr_s(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD8);
304N/A emit_operand32(rdi, src);
304N/A}
304N/A
304N/Avoid Assembler::fdivra(int i) {
304N/A emit_farith(0xDC, 0xF0, i);
304N/A}
304N/A
304N/Avoid Assembler::fdivrp(int i) {
304N/A emit_farith(0xDE, 0xF0, i); // ST(0) <- ST(1) / ST(0) and pop (Intel manual wrong)
304N/A}
304N/A
304N/Avoid Assembler::ffree(int i) {
304N/A emit_farith(0xDD, 0xC0, i);
304N/A}
304N/A
304N/Avoid Assembler::fild_d(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDF);
304N/A emit_operand32(rbp, adr);
304N/A}
304N/A
304N/Avoid Assembler::fild_s(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDB);
304N/A emit_operand32(rax, adr);
304N/A}
304N/A
304N/Avoid Assembler::fincstp() {
304N/A emit_byte(0xD9);
304N/A emit_byte(0xF7);
304N/A}
304N/A
304N/Avoid Assembler::finit() {
304N/A emit_byte(0x9B);
304N/A emit_byte(0xDB);
304N/A emit_byte(0xE3);
304N/A}
304N/A
304N/Avoid Assembler::fist_s(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDB);
304N/A emit_operand32(rdx, adr);
304N/A}
304N/A
304N/Avoid Assembler::fistp_d(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDF);
304N/A emit_operand32(rdi, adr);
304N/A}
304N/A
304N/Avoid Assembler::fistp_s(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDB);
304N/A emit_operand32(rbx, adr);
304N/A}
0N/A
0N/Avoid Assembler::fld1() {
0N/A emit_byte(0xD9);
0N/A emit_byte(0xE8);
0N/A}
0N/A
304N/Avoid Assembler::fld_d(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDD);
304N/A emit_operand32(rax, adr);
304N/A}
0N/A
0N/Avoid Assembler::fld_s(Address adr) {
0N/A InstructionMark im(this);
0N/A emit_byte(0xD9);
304N/A emit_operand32(rax, adr);
304N/A}
304N/A
304N/A
304N/Avoid Assembler::fld_s(int index) {
0N/A emit_farith(0xD9, 0xC0, index);
0N/A}
0N/A
0N/Avoid Assembler::fld_x(Address adr) {
0N/A InstructionMark im(this);
0N/A emit_byte(0xDB);
304N/A emit_operand32(rbp, adr);
304N/A}
304N/A
304N/Avoid Assembler::fldcw(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xd9);
304N/A emit_operand32(rbp, src);
304N/A}
304N/A
304N/Avoid Assembler::fldenv(Address src) {
0N/A InstructionMark im(this);
0N/A emit_byte(0xD9);
304N/A emit_operand32(rsp, src);
304N/A}
304N/A
304N/Avoid Assembler::fldlg2() {
0N/A emit_byte(0xD9);
304N/A emit_byte(0xEC);
304N/A}
0N/A
0N/Avoid Assembler::fldln2() {
0N/A emit_byte(0xD9);
0N/A emit_byte(0xED);
0N/A}
0N/A
304N/Avoid Assembler::fldz() {
0N/A emit_byte(0xD9);
304N/A emit_byte(0xEE);
304N/A}
0N/A
0N/Avoid Assembler::flog() {
0N/A fldln2();
0N/A fxch();
0N/A fyl2x();
0N/A}
0N/A
0N/Avoid Assembler::flog10() {
0N/A fldlg2();
0N/A fxch();
0N/A fyl2x();
0N/A}
0N/A
304N/Avoid Assembler::fmul(int i) {
304N/A emit_farith(0xD8, 0xC8, i);
304N/A}
304N/A
304N/Avoid Assembler::fmul_d(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDC);
304N/A emit_operand32(rcx, src);
304N/A}
304N/A
304N/Avoid Assembler::fmul_s(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD8);
304N/A emit_operand32(rcx, src);
304N/A}
304N/A
304N/Avoid Assembler::fmula(int i) {
304N/A emit_farith(0xDC, 0xC8, i);
304N/A}
304N/A
304N/Avoid Assembler::fmulp(int i) {
304N/A emit_farith(0xDE, 0xC8, i);
304N/A}
304N/A
304N/Avoid Assembler::fnsave(Address dst) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDD);
304N/A emit_operand32(rsi, dst);
304N/A}
304N/A
304N/Avoid Assembler::fnstcw(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0x9B);
304N/A emit_byte(0xD9);
304N/A emit_operand32(rdi, src);
304N/A}
304N/A
304N/Avoid Assembler::fnstsw_ax() {
304N/A emit_byte(0xdF);
304N/A emit_byte(0xE0);
304N/A}
304N/A
304N/Avoid Assembler::fprem() {
304N/A emit_byte(0xD9);
304N/A emit_byte(0xF8);
304N/A}
304N/A
304N/Avoid Assembler::fprem1() {
304N/A emit_byte(0xD9);
304N/A emit_byte(0xF5);
304N/A}
304N/A
304N/Avoid Assembler::frstor(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDD);
304N/A emit_operand32(rsp, src);
304N/A}
0N/A
0N/Avoid Assembler::fsin() {
0N/A emit_byte(0xD9);
0N/A emit_byte(0xFE);
0N/A}
0N/A
304N/Avoid Assembler::fsqrt() {
304N/A emit_byte(0xD9);
304N/A emit_byte(0xFA);
304N/A}
304N/A
304N/Avoid Assembler::fst_d(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDD);
304N/A emit_operand32(rdx, adr);
304N/A}
304N/A
304N/Avoid Assembler::fst_s(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD9);
304N/A emit_operand32(rdx, adr);
304N/A}
304N/A
304N/Avoid Assembler::fstp_d(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDD);
304N/A emit_operand32(rbx, adr);
304N/A}
304N/A
304N/Avoid Assembler::fstp_d(int index) {
304N/A emit_farith(0xDD, 0xD8, index);
304N/A}
304N/A
304N/Avoid Assembler::fstp_s(Address adr) {
304N/A InstructionMark im(this);
0N/A emit_byte(0xD9);
304N/A emit_operand32(rbx, adr);
304N/A}
304N/A
304N/Avoid Assembler::fstp_x(Address adr) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDB);
304N/A emit_operand32(rdi, adr);
304N/A}
304N/A
304N/Avoid Assembler::fsub(int i) {
304N/A emit_farith(0xD8, 0xE0, i);
304N/A}
304N/A
304N/Avoid Assembler::fsub_d(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDC);
304N/A emit_operand32(rsp, src);
304N/A}
304N/A
304N/Avoid Assembler::fsub_s(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD8);
304N/A emit_operand32(rsp, src);
304N/A}
304N/A
304N/Avoid Assembler::fsuba(int i) {
304N/A emit_farith(0xDC, 0xE8, i);
304N/A}
304N/A
304N/Avoid Assembler::fsubp(int i) {
304N/A emit_farith(0xDE, 0xE8, i); // ST(0) <- ST(0) - ST(1) and pop (Intel manual wrong)
304N/A}
304N/A
304N/Avoid Assembler::fsubr(int i) {
304N/A emit_farith(0xD8, 0xE8, i);
304N/A}
304N/A
304N/Avoid Assembler::fsubr_d(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xDC);
304N/A emit_operand32(rbp, src);
304N/A}
304N/A
304N/Avoid Assembler::fsubr_s(Address src) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xD8);
304N/A emit_operand32(rbp, src);
304N/A}
304N/A
304N/Avoid Assembler::fsubra(int i) {
304N/A emit_farith(0xDC, 0xE0, i);
304N/A}
304N/A
304N/Avoid Assembler::fsubrp(int i) {
304N/A emit_farith(0xDE, 0xE0, i); // ST(0) <- ST(1) - ST(0) and pop (Intel manual wrong)
0N/A}
0N/A
0N/Avoid Assembler::ftan() {
0N/A emit_byte(0xD9);
0N/A emit_byte(0xF2);
0N/A emit_byte(0xDD);
0N/A emit_byte(0xD8);
0N/A}
0N/A
304N/Avoid Assembler::ftst() {
0N/A emit_byte(0xD9);
304N/A emit_byte(0xE4);
304N/A}
0N/A
0N/Avoid Assembler::fucomi(int i) {
0N/A // make sure the instruction is supported (introduced for P6, together with cmov)
0N/A guarantee(VM_Version::supports_cmov(), "illegal instruction");
0N/A emit_farith(0xDB, 0xE8, i);
0N/A}
0N/A
0N/Avoid Assembler::fucomip(int i) {
0N/A // make sure the instruction is supported (introduced for P6, together with cmov)
0N/A guarantee(VM_Version::supports_cmov(), "illegal instruction");
0N/A emit_farith(0xDF, 0xE8, i);
0N/A}
0N/A
0N/Avoid Assembler::fwait() {
0N/A emit_byte(0x9B);
0N/A}
0N/A
304N/Avoid Assembler::fxch(int i) {
304N/A emit_farith(0xD9, 0xC8, i);
304N/A}
304N/A
304N/Avoid Assembler::fyl2x() {
0N/A emit_byte(0xD9);
304N/A emit_byte(0xF1);
304N/A}
304N/A
3752N/Avoid Assembler::frndint() {
3752N/A emit_byte(0xD9);
3752N/A emit_byte(0xFC);
3752N/A}
3752N/A
3752N/Avoid Assembler::f2xm1() {
3752N/A emit_byte(0xD9);
3752N/A emit_byte(0xF0);
3752N/A}
3752N/A
3752N/Avoid Assembler::fldl2e() {
3752N/A emit_byte(0xD9);
3752N/A emit_byte(0xEA);
3752N/A}
3752N/A
3039N/A// SSE SIMD prefix byte values corresponding to VexSimdPrefix encoding.
3039N/Astatic int simd_pre[4] = { 0, 0x66, 0xF3, 0xF2 };
3039N/A// SSE opcode second byte values (first is 0x0F) corresponding to VexOpcode encoding.
3039N/Astatic int simd_opc[4] = { 0, 0, 0x38, 0x3A };
3039N/A
3039N/A// Generate SSE legacy REX prefix and SIMD opcode based on VEX encoding.
3039N/Avoid Assembler::rex_prefix(Address adr, XMMRegister xreg, VexSimdPrefix pre, VexOpcode opc, bool rex_w) {
3039N/A if (pre > 0) {
3039N/A emit_byte(simd_pre[pre]);
3039N/A }
3039N/A if (rex_w) {
3039N/A prefixq(adr, xreg);
3039N/A } else {
3039N/A prefix(adr, xreg);
3039N/A }
3039N/A if (opc > 0) {
3039N/A emit_byte(0x0F);
3039N/A int opc2 = simd_opc[opc];
3039N/A if (opc2 > 0) {
3039N/A emit_byte(opc2);
3039N/A }
3039N/A }
3039N/A}
3039N/A
3039N/Aint Assembler::rex_prefix_and_encode(int dst_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, bool rex_w) {
3039N/A if (pre > 0) {
3039N/A emit_byte(simd_pre[pre]);
3039N/A }
3039N/A int encode = (rex_w) ? prefixq_and_encode(dst_enc, src_enc) :
3039N/A prefix_and_encode(dst_enc, src_enc);
3039N/A if (opc > 0) {
3039N/A emit_byte(0x0F);
3039N/A int opc2 = simd_opc[opc];
3039N/A if (opc2 > 0) {
3039N/A emit_byte(opc2);
3039N/A }
3039N/A }
3039N/A return encode;
3039N/A}
3039N/A
3039N/A
3039N/Avoid Assembler::vex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, int nds_enc, VexSimdPrefix pre, VexOpcode opc, bool vector256) {
3039N/A if (vex_b || vex_x || vex_w || (opc == VEX_OPCODE_0F_38) || (opc == VEX_OPCODE_0F_3A)) {
3039N/A prefix(VEX_3bytes);
3039N/A
3039N/A int byte1 = (vex_r ? VEX_R : 0) | (vex_x ? VEX_X : 0) | (vex_b ? VEX_B : 0);
3039N/A byte1 = (~byte1) & 0xE0;
3039N/A byte1 |= opc;
3039N/A a_byte(byte1);
3039N/A
3039N/A int byte2 = ((~nds_enc) & 0xf) << 3;
3039N/A byte2 |= (vex_w ? VEX_W : 0) | (vector256 ? 4 : 0) | pre;
3039N/A emit_byte(byte2);
3039N/A } else {
3039N/A prefix(VEX_2bytes);
3039N/A
3039N/A int byte1 = vex_r ? VEX_R : 0;
3039N/A byte1 = (~byte1) & 0x80;
3039N/A byte1 |= ((~nds_enc) & 0xf) << 3;
3039N/A byte1 |= (vector256 ? 4 : 0) | pre;
3039N/A emit_byte(byte1);
3039N/A }
3039N/A}
3039N/A
3039N/Avoid Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, bool vex_w, bool vector256){
3039N/A bool vex_r = (xreg_enc >= 8);
3039N/A bool vex_b = adr.base_needs_rex();
3039N/A bool vex_x = adr.index_needs_rex();
3039N/A vex_prefix(vex_r, vex_b, vex_x, vex_w, nds_enc, pre, opc, vector256);
3039N/A}
3039N/A
3039N/Aint Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, bool vex_w, bool vector256) {
3039N/A bool vex_r = (dst_enc >= 8);
3039N/A bool vex_b = (src_enc >= 8);
3039N/A bool vex_x = false;
3039N/A vex_prefix(vex_r, vex_b, vex_x, vex_w, nds_enc, pre, opc, vector256);
3039N/A return (((dst_enc & 7) << 3) | (src_enc & 7));
3039N/A}
3039N/A
3039N/A
3039N/Avoid Assembler::simd_prefix(XMMRegister xreg, XMMRegister nds, Address adr, VexSimdPrefix pre, VexOpcode opc, bool rex_w, bool vector256) {
3039N/A if (UseAVX > 0) {
3039N/A int xreg_enc = xreg->encoding();
3039N/A int nds_enc = nds->is_valid() ? nds->encoding() : 0;
3039N/A vex_prefix(adr, nds_enc, xreg_enc, pre, opc, rex_w, vector256);
3039N/A } else {
3039N/A assert((nds == xreg) || (nds == xnoreg), "wrong sse encoding");
3039N/A rex_prefix(adr, xreg, pre, opc, rex_w);
3039N/A }
3039N/A}
3039N/A
3039N/Aint Assembler::simd_prefix_and_encode(XMMRegister dst, XMMRegister nds, XMMRegister src, VexSimdPrefix pre, VexOpcode opc, bool rex_w, bool vector256) {
3039N/A int dst_enc = dst->encoding();
3039N/A int src_enc = src->encoding();
3039N/A if (UseAVX > 0) {
3039N/A int nds_enc = nds->is_valid() ? nds->encoding() : 0;
3039N/A return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, rex_w, vector256);
3039N/A } else {
3039N/A assert((nds == dst) || (nds == src) || (nds == xnoreg), "wrong sse encoding");
3039N/A return rex_prefix_and_encode(dst_enc, src_enc, pre, opc, rex_w);
3039N/A }
3039N/A}
304N/A
304N/A#ifndef _LP64
304N/A
304N/Avoid Assembler::incl(Register dst) {
304N/A // Don't use it directly. Use MacroAssembler::incrementl() instead.
3039N/A emit_byte(0x40 | dst->encoding());
304N/A}
304N/A
304N/Avoid Assembler::lea(Register dst, Address src) {
304N/A leal(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::mov_literal32(Address dst, int32_t imm32, RelocationHolder const& rspec) {
304N/A InstructionMark im(this);
304N/A emit_byte(0xC7);
304N/A emit_operand(rax, dst);
304N/A emit_data((int)imm32, rspec, 0);
304N/A}
304N/A
642N/Avoid Assembler::mov_literal32(Register dst, int32_t imm32, RelocationHolder const& rspec) {
642N/A InstructionMark im(this);
642N/A int encode = prefix_and_encode(dst->encoding());
642N/A emit_byte(0xB8 | encode);
642N/A emit_data((int)imm32, rspec, 0);
642N/A}
304N/A
304N/Avoid Assembler::popa() { // 32bit
304N/A emit_byte(0x61);
304N/A}
304N/A
304N/Avoid Assembler::push_literal32(int32_t imm32, RelocationHolder const& rspec) {
304N/A InstructionMark im(this);
304N/A emit_byte(0x68);
304N/A emit_data(imm32, rspec, 0);
304N/A}
304N/A
304N/Avoid Assembler::pusha() { // 32bit
304N/A emit_byte(0x60);
304N/A}
304N/A
304N/Avoid Assembler::set_byte_if_not_zero(Register dst) {
0N/A emit_byte(0x0F);
304N/A emit_byte(0x95);
304N/A emit_byte(0xE0 | dst->encoding());
304N/A}
304N/A
304N/Avoid Assembler::shldl(Register dst, Register src) {
0N/A emit_byte(0x0F);
304N/A emit_byte(0xA5);
304N/A emit_byte(0xC0 | src->encoding() << 3 | dst->encoding());
304N/A}
304N/A
304N/Avoid Assembler::shrdl(Register dst, Register src) {
0N/A emit_byte(0x0F);
304N/A emit_byte(0xAD);
304N/A emit_byte(0xC0 | src->encoding() << 3 | dst->encoding());
304N/A}
304N/A
304N/A#else // LP64
304N/A
1369N/Avoid Assembler::set_byte_if_not_zero(Register dst) {
1369N/A int enc = prefix_and_encode(dst->encoding(), true);
1369N/A emit_byte(0x0F);
1369N/A emit_byte(0x95);
1369N/A emit_byte(0xE0 | enc);
1369N/A}
1369N/A
304N/A// 64bit only pieces of the assembler
304N/A// This should only be used by 64bit instructions that can use rip-relative
304N/A// it cannot be used by instructions that want an immediate value.
304N/A
304N/Abool Assembler::reachable(AddressLiteral adr) {
304N/A int64_t disp;
304N/A // None will force a 64bit literal to the code stream. Likely a placeholder
304N/A // for something that will be patched later and we need to certain it will
304N/A // always be reachable.
304N/A if (adr.reloc() == relocInfo::none) {
304N/A return false;
304N/A }
304N/A if (adr.reloc() == relocInfo::internal_word_type) {
304N/A // This should be rip relative and easily reachable.
304N/A return true;
304N/A }
304N/A if (adr.reloc() == relocInfo::virtual_call_type ||
304N/A adr.reloc() == relocInfo::opt_virtual_call_type ||
304N/A adr.reloc() == relocInfo::static_call_type ||
304N/A adr.reloc() == relocInfo::static_stub_type ) {
304N/A // This should be rip relative within the code cache and easily
304N/A // reachable until we get huge code caches. (At which point
304N/A // ic code is going to have issues).
304N/A return true;
304N/A }
304N/A if (adr.reloc() != relocInfo::external_word_type &&
304N/A adr.reloc() != relocInfo::poll_return_type && // these are really external_word but need special
304N/A adr.reloc() != relocInfo::poll_type && // relocs to identify them
304N/A adr.reloc() != relocInfo::runtime_call_type ) {
304N/A return false;
304N/A }
304N/A
304N/A // Stress the correction code
304N/A if (ForceUnreachable) {
304N/A // Must be runtimecall reloc, see if it is in the codecache
304N/A // Flipping stuff in the codecache to be unreachable causes issues
304N/A // with things like inline caches where the additional instructions
304N/A // are not handled.
304N/A if (CodeCache::find_blob(adr._target) == NULL) {
304N/A return false;
304N/A }
304N/A }
304N/A // For external_word_type/runtime_call_type if it is reachable from where we
304N/A // are now (possibly a temp buffer) and where we might end up
304N/A // anywhere in the codeCache then we are always reachable.
304N/A // This would have to change if we ever save/restore shared code
304N/A // to be more pessimistic.
304N/A disp = (int64_t)adr._target - ((int64_t)CodeCache::low_bound() + sizeof(int));
304N/A if (!is_simm32(disp)) return false;
304N/A disp = (int64_t)adr._target - ((int64_t)CodeCache::high_bound() + sizeof(int));
304N/A if (!is_simm32(disp)) return false;
304N/A
304N/A disp = (int64_t)adr._target - ((int64_t)_code_pos + sizeof(int));
304N/A
304N/A // Because rip relative is a disp + address_of_next_instruction and we
304N/A // don't know the value of address_of_next_instruction we apply a fudge factor
304N/A // to make sure we will be ok no matter the size of the instruction we get placed into.
304N/A // We don't have to fudge the checks above here because they are already worst case.
304N/A
304N/A // 12 == override/rex byte, opcode byte, rm byte, sib byte, a 4-byte disp , 4-byte literal
304N/A // + 4 because better safe than sorry.
304N/A const int fudge = 12 + 4;
304N/A if (disp < 0) {
304N/A disp -= fudge;
304N/A } else {
304N/A disp += fudge;
304N/A }
304N/A return is_simm32(disp);
304N/A}
304N/A
2251N/A// Check if the polling page is not reachable from the code cache using rip-relative
2251N/A// addressing.
2251N/Abool Assembler::is_polling_page_far() {
2251N/A intptr_t addr = (intptr_t)os::get_polling_page();
2961N/A return ForceUnreachable ||
2961N/A !is_simm32(addr - (intptr_t)CodeCache::low_bound()) ||
2251N/A !is_simm32(addr - (intptr_t)CodeCache::high_bound());
2251N/A}
2251N/A
304N/Avoid Assembler::emit_data64(jlong data,
304N/A relocInfo::relocType rtype,
304N/A int format) {
304N/A if (rtype == relocInfo::none) {
304N/A emit_long64(data);
304N/A } else {
304N/A emit_data64(data, Relocation::spec_simple(rtype), format);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::emit_data64(jlong data,
304N/A RelocationHolder const& rspec,
304N/A int format) {
304N/A assert(imm_operand == 0, "default format must be immediate in this file");
304N/A assert(imm_operand == format, "must be immediate");
304N/A assert(inst_mark() != NULL, "must be inside InstructionMark");
304N/A // Do not use AbstractAssembler::relocate, which is not intended for
304N/A // embedded words. Instead, relocate to the enclosing instruction.
304N/A code_section()->relocate(inst_mark(), rspec, format);
304N/A#ifdef ASSERT
304N/A check_relocation(rspec, format);
304N/A#endif
304N/A emit_long64(data);
304N/A}
304N/A
304N/Aint Assembler::prefix_and_encode(int reg_enc, bool byteinst) {
304N/A if (reg_enc >= 8) {
304N/A prefix(REX_B);
304N/A reg_enc -= 8;
304N/A } else if (byteinst && reg_enc >= 4) {
304N/A prefix(REX);
304N/A }
304N/A return reg_enc;
304N/A}
304N/A
304N/Aint Assembler::prefixq_and_encode(int reg_enc) {
304N/A if (reg_enc < 8) {
304N/A prefix(REX_W);
304N/A } else {
304N/A prefix(REX_WB);
304N/A reg_enc -= 8;
304N/A }
304N/A return reg_enc;
304N/A}
304N/A
304N/Aint Assembler::prefix_and_encode(int dst_enc, int src_enc, bool byteinst) {
304N/A if (dst_enc < 8) {
304N/A if (src_enc >= 8) {
304N/A prefix(REX_B);
304N/A src_enc -= 8;
304N/A } else if (byteinst && src_enc >= 4) {
304N/A prefix(REX);
304N/A }
304N/A } else {
304N/A if (src_enc < 8) {
304N/A prefix(REX_R);
304N/A } else {
304N/A prefix(REX_RB);
304N/A src_enc -= 8;
304N/A }
304N/A dst_enc -= 8;
304N/A }
304N/A return dst_enc << 3 | src_enc;
304N/A}
304N/A
304N/Aint Assembler::prefixq_and_encode(int dst_enc, int src_enc) {
304N/A if (dst_enc < 8) {
304N/A if (src_enc < 8) {
304N/A prefix(REX_W);
304N/A } else {
304N/A prefix(REX_WB);
304N/A src_enc -= 8;
304N/A }
304N/A } else {
304N/A if (src_enc < 8) {
304N/A prefix(REX_WR);
304N/A } else {
304N/A prefix(REX_WRB);
304N/A src_enc -= 8;
304N/A }
304N/A dst_enc -= 8;
304N/A }
304N/A return dst_enc << 3 | src_enc;
304N/A}
304N/A
304N/Avoid Assembler::prefix(Register reg) {
304N/A if (reg->encoding() >= 8) {
304N/A prefix(REX_B);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::prefix(Address adr) {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_XB);
304N/A } else {
304N/A prefix(REX_B);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_X);
304N/A }
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::prefixq(Address adr) {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_WXB);
304N/A } else {
304N/A prefix(REX_WB);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_WX);
304N/A } else {
304N/A prefix(REX_W);
304N/A }
304N/A }
304N/A}
304N/A
304N/A
304N/Avoid Assembler::prefix(Address adr, Register reg, bool byteinst) {
304N/A if (reg->encoding() < 8) {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_XB);
304N/A } else {
304N/A prefix(REX_B);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_X);
2680N/A } else if (byteinst && reg->encoding() >= 4 ) {
304N/A prefix(REX);
304N/A }
304N/A }
304N/A } else {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_RXB);
304N/A } else {
304N/A prefix(REX_RB);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_RX);
304N/A } else {
304N/A prefix(REX_R);
304N/A }
304N/A }
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::prefixq(Address adr, Register src) {
304N/A if (src->encoding() < 8) {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_WXB);
304N/A } else {
304N/A prefix(REX_WB);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_WX);
304N/A } else {
304N/A prefix(REX_W);
304N/A }
304N/A }
304N/A } else {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_WRXB);
304N/A } else {
304N/A prefix(REX_WRB);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_WRX);
304N/A } else {
304N/A prefix(REX_WR);
304N/A }
304N/A }
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::prefix(Address adr, XMMRegister reg) {
304N/A if (reg->encoding() < 8) {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_XB);
304N/A } else {
304N/A prefix(REX_B);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_X);
304N/A }
304N/A }
304N/A } else {
304N/A if (adr.base_needs_rex()) {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_RXB);
304N/A } else {
304N/A prefix(REX_RB);
304N/A }
304N/A } else {
304N/A if (adr.index_needs_rex()) {
304N/A prefix(REX_RX);
304N/A } else {
304N/A prefix(REX_R);
304N/A }
304N/A }
304N/A }
304N/A}
304N/A
3039N/Avoid Assembler::prefixq(Address adr, XMMRegister src) {
3039N/A if (src->encoding() < 8) {
3039N/A if (adr.base_needs_rex()) {
3039N/A if (adr.index_needs_rex()) {
3039N/A prefix(REX_WXB);
3039N/A } else {
3039N/A prefix(REX_WB);
3039N/A }
3039N/A } else {
3039N/A if (adr.index_needs_rex()) {
3039N/A prefix(REX_WX);
3039N/A } else {
3039N/A prefix(REX_W);
3039N/A }
3039N/A }
3039N/A } else {
3039N/A if (adr.base_needs_rex()) {
3039N/A if (adr.index_needs_rex()) {
3039N/A prefix(REX_WRXB);
3039N/A } else {
3039N/A prefix(REX_WRB);
3039N/A }
3039N/A } else {
3039N/A if (adr.index_needs_rex()) {
3039N/A prefix(REX_WRX);
3039N/A } else {
3039N/A prefix(REX_WR);
3039N/A }
3039N/A }
3039N/A }
3039N/A}
3039N/A
304N/Avoid Assembler::adcq(Register dst, int32_t imm32) {
304N/A (void) prefixq_and_encode(dst->encoding());
304N/A emit_arith(0x81, 0xD0, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::adcq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x13);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::adcq(Register dst, Register src) {
304N/A (int) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x13, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::addq(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_arith_operand(0x81, rax, dst,imm32);
304N/A}
304N/A
304N/Avoid Assembler::addq(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefixq(dst, src);
304N/A emit_byte(0x01);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::addq(Register dst, int32_t imm32) {
304N/A (void) prefixq_and_encode(dst->encoding());
304N/A emit_arith(0x81, 0xC0, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::addq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x03);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::addq(Register dst, Register src) {
304N/A (void) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x03, 0xC0, dst, src);
304N/A}
304N/A
2608N/Avoid Assembler::andq(Address dst, int32_t imm32) {
2608N/A InstructionMark im(this);
2608N/A prefixq(dst);
2608N/A emit_byte(0x81);
2608N/A emit_operand(rsp, dst, 4);
2608N/A emit_long(imm32);
2608N/A}
2608N/A
304N/Avoid Assembler::andq(Register dst, int32_t imm32) {
304N/A (void) prefixq_and_encode(dst->encoding());
304N/A emit_arith(0x81, 0xE0, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::andq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x23);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::andq(Register dst, Register src) {
304N/A (int) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x23, 0xC0, dst, src);
304N/A}
304N/A
775N/Avoid Assembler::bsfq(Register dst, Register src) {
775N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
775N/A emit_byte(0x0F);
775N/A emit_byte(0xBC);
775N/A emit_byte(0xC0 | encode);
775N/A}
775N/A
775N/Avoid Assembler::bsrq(Register dst, Register src) {
775N/A assert(!VM_Version::supports_lzcnt(), "encoding is treated as LZCNT");
775N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
775N/A emit_byte(0x0F);
775N/A emit_byte(0xBD);
775N/A emit_byte(0xC0 | encode);
775N/A}
775N/A
304N/Avoid Assembler::bswapq(Register reg) {
304N/A int encode = prefixq_and_encode(reg->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0xC8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::cdqq() {
304N/A prefix(REX_W);
304N/A emit_byte(0x99);
304N/A}
304N/A
304N/Avoid Assembler::clflush(Address adr) {
304N/A prefix(adr);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xAE);
304N/A emit_operand(rdi, adr);
304N/A}
304N/A
304N/Avoid Assembler::cmovq(Condition cc, Register dst, Register src) {
304N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0x40 | cc);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::cmovq(Condition cc, Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0x40 | cc);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::cmpq(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_byte(0x81);
304N/A emit_operand(rdi, dst, 4);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::cmpq(Register dst, int32_t imm32) {
304N/A (void) prefixq_and_encode(dst->encoding());
304N/A emit_arith(0x81, 0xF8, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::cmpq(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefixq(dst, src);
304N/A emit_byte(0x3B);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::cmpq(Register dst, Register src) {
304N/A (void) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x3B, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::cmpq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x3B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::cmpxchgq(Register reg, Address adr) {
304N/A InstructionMark im(this);
304N/A prefixq(adr, reg);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xB1);
304N/A emit_operand(reg, adr);
304N/A}
304N/A
304N/Avoid Assembler::cvtsi2sdq(XMMRegister dst, Register src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode_q(dst, dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x2A);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3039N/Avoid Assembler::cvtsi2sdq(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix_q(dst, dst, src, VEX_SIMD_F2);
3039N/A emit_byte(0x2A);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
304N/Avoid Assembler::cvtsi2ssq(XMMRegister dst, Register src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode_q(dst, dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x2A);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
3039N/Avoid Assembler::cvtsi2ssq(XMMRegister dst, Address src) {
3039N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A InstructionMark im(this);
3039N/A simd_prefix_q(dst, dst, src, VEX_SIMD_F3);
3039N/A emit_byte(0x2A);
3039N/A emit_operand(dst, src);
3039N/A}
3039N/A
304N/Avoid Assembler::cvttsd2siq(Register dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_F2);
304N/A emit_byte(0x2C);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::cvttss2siq(Register dst, XMMRegister src) {
304N/A NOT_LP64(assert(VM_Version::supports_sse(), ""));
3039N/A int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_F3);
304N/A emit_byte(0x2C);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::decl(Register dst) {
304N/A // Don't use it directly. Use MacroAssembler::decrementl() instead.
304N/A // Use two-byte form (one-byte form is a REX prefix in 64-bit mode)
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xFF);
304N/A emit_byte(0xC8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::decq(Register dst) {
304N/A // Don't use it directly. Use MacroAssembler::decrementq() instead.
304N/A // Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xFF);
304N/A emit_byte(0xC8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::decq(Address dst) {
304N/A // Don't use it directly. Use MacroAssembler::decrementq() instead.
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_byte(0xFF);
304N/A emit_operand(rcx, dst);
304N/A}
304N/A
304N/Avoid Assembler::fxrstor(Address src) {
304N/A prefixq(src);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xAE);
304N/A emit_operand(as_Register(1), src);
304N/A}
304N/A
304N/Avoid Assembler::fxsave(Address dst) {
304N/A prefixq(dst);
304N/A emit_byte(0x0F);
304N/A emit_byte(0xAE);
304N/A emit_operand(as_Register(0), dst);
304N/A}
304N/A
304N/Avoid Assembler::idivq(Register src) {
304N/A int encode = prefixq_and_encode(src->encoding());
304N/A emit_byte(0xF7);
304N/A emit_byte(0xF8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::imulq(Register dst, Register src) {
304N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x0F);
304N/A emit_byte(0xAF);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::imulq(Register dst, Register src, int value) {
304N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
304N/A if (is8bit(value)) {
304N/A emit_byte(0x6B);
304N/A emit_byte(0xC0 | encode);
1834N/A emit_byte(value & 0xFF);
304N/A } else {
304N/A emit_byte(0x69);
304N/A emit_byte(0xC0 | encode);
304N/A emit_long(value);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::incl(Register dst) {
304N/A // Don't use it directly. Use MacroAssembler::incrementl() instead.
304N/A // Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
304N/A int encode = prefix_and_encode(dst->encoding());
304N/A emit_byte(0xFF);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::incq(Register dst) {
304N/A // Don't use it directly. Use MacroAssembler::incrementq() instead.
304N/A // Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xFF);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::incq(Address dst) {
304N/A // Don't use it directly. Use MacroAssembler::incrementq() instead.
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_byte(0xFF);
304N/A emit_operand(rax, dst);
304N/A}
304N/A
304N/Avoid Assembler::lea(Register dst, Address src) {
304N/A leaq(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::leaq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x8D);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::mov64(Register dst, int64_t imm64) {
304N/A InstructionMark im(this);
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xB8 | encode);
304N/A emit_long64(imm64);
304N/A}
304N/A
304N/Avoid Assembler::mov_literal64(Register dst, intptr_t imm64, RelocationHolder const& rspec) {
304N/A InstructionMark im(this);
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xB8 | encode);
304N/A emit_data64(imm64, rspec);
304N/A}
304N/A
642N/Avoid Assembler::mov_narrow_oop(Register dst, int32_t imm32, RelocationHolder const& rspec) {
642N/A InstructionMark im(this);
642N/A int encode = prefix_and_encode(dst->encoding());
642N/A emit_byte(0xB8 | encode);
642N/A emit_data((int)imm32, rspec, narrow_oop_operand);
642N/A}
642N/A
642N/Avoid Assembler::mov_narrow_oop(Address dst, int32_t imm32, RelocationHolder const& rspec) {
642N/A InstructionMark im(this);
642N/A prefix(dst);
642N/A emit_byte(0xC7);
642N/A emit_operand(rax, dst, 4);
642N/A emit_data((int)imm32, rspec, narrow_oop_operand);
642N/A}
642N/A
642N/Avoid Assembler::cmp_narrow_oop(Register src1, int32_t imm32, RelocationHolder const& rspec) {
642N/A InstructionMark im(this);
642N/A int encode = prefix_and_encode(src1->encoding());
642N/A emit_byte(0x81);
642N/A emit_byte(0xF8 | encode);
642N/A emit_data((int)imm32, rspec, narrow_oop_operand);
642N/A}
642N/A
642N/Avoid Assembler::cmp_narrow_oop(Address src1, int32_t imm32, RelocationHolder const& rspec) {
642N/A InstructionMark im(this);
642N/A prefix(src1);
642N/A emit_byte(0x81);
642N/A emit_operand(rax, src1, 4);
642N/A emit_data((int)imm32, rspec, narrow_oop_operand);
642N/A}
642N/A
775N/Avoid Assembler::lzcntq(Register dst, Register src) {
775N/A assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR");
775N/A emit_byte(0xF3);
775N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
775N/A emit_byte(0x0F);
775N/A emit_byte(0xBD);
775N/A emit_byte(0xC0 | encode);
775N/A}
775N/A
304N/Avoid Assembler::movdq(XMMRegister dst, Register src) {
304N/A // table D-1 says MMX/SSE2
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
3039N/A int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_66);
304N/A emit_byte(0x6E);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movdq(Register dst, XMMRegister src) {
304N/A // table D-1 says MMX/SSE2
3039N/A NOT_LP64(assert(VM_Version::supports_sse2(), ""));
304N/A // swap src/dst to get correct prefix
3039N/A int encode = simd_prefix_and_encode_q(src, dst, VEX_SIMD_66);
0N/A emit_byte(0x7E);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movq(Register dst, Register src) {
304N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x8B);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::movq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x8B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movq(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefixq(dst, src);
304N/A emit_byte(0x89);
304N/A emit_operand(src, dst);
304N/A}
304N/A
624N/Avoid Assembler::movsbq(Register dst, Address src) {
624N/A InstructionMark im(this);
624N/A prefixq(src, dst);
624N/A emit_byte(0x0F);
624N/A emit_byte(0xBE);
624N/A emit_operand(dst, src);
624N/A}
624N/A
624N/Avoid Assembler::movsbq(Register dst, Register src) {
624N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
624N/A emit_byte(0x0F);
624N/A emit_byte(0xBE);
624N/A emit_byte(0xC0 | encode);
624N/A}
624N/A
304N/Avoid Assembler::movslq(Register dst, int32_t imm32) {
304N/A // dbx shows movslq(rcx, 3) as movq $0x0000000049000000,(%rbx)
304N/A // and movslq(r8, 3); as movl $0x0000000048000000,(%rbx)
304N/A // as a result we shouldn't use until tested at runtime...
304N/A ShouldNotReachHere();
304N/A InstructionMark im(this);
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xC7 | encode);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::movslq(Address dst, int32_t imm32) {
304N/A assert(is_simm32(imm32), "lost bits");
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_byte(0xC7);
304N/A emit_operand(rax, dst, 4);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::movslq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x63);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::movslq(Register dst, Register src) {
304N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x63);
304N/A emit_byte(0xC0 | encode);
304N/A}
304N/A
624N/Avoid Assembler::movswq(Register dst, Address src) {
624N/A InstructionMark im(this);
624N/A prefixq(src, dst);
624N/A emit_byte(0x0F);
624N/A emit_byte(0xBF);
624N/A emit_operand(dst, src);
624N/A}
624N/A
624N/Avoid Assembler::movswq(Register dst, Register src) {
624N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
624N/A emit_byte(0x0F);
624N/A emit_byte(0xBF);
624N/A emit_byte(0xC0 | encode);
624N/A}
624N/A
624N/Avoid Assembler::movzbq(Register dst, Address src) {
624N/A InstructionMark im(this);
624N/A prefixq(src, dst);
624N/A emit_byte(0x0F);
624N/A emit_byte(0xB6);
624N/A emit_operand(dst, src);
624N/A}
624N/A
624N/Avoid Assembler::movzbq(Register dst, Register src) {
624N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
624N/A emit_byte(0x0F);
624N/A emit_byte(0xB6);
624N/A emit_byte(0xC0 | encode);
624N/A}
624N/A
624N/Avoid Assembler::movzwq(Register dst, Address src) {
624N/A InstructionMark im(this);
624N/A prefixq(src, dst);
624N/A emit_byte(0x0F);
624N/A emit_byte(0xB7);
624N/A emit_operand(dst, src);
624N/A}
624N/A
624N/Avoid Assembler::movzwq(Register dst, Register src) {
624N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
624N/A emit_byte(0x0F);
624N/A emit_byte(0xB7);
624N/A emit_byte(0xC0 | encode);
624N/A}
624N/A
304N/Avoid Assembler::negq(Register dst) {
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xF7);
304N/A emit_byte(0xD8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::notq(Register dst) {
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xF7);
304N/A emit_byte(0xD0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::orq(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_byte(0x81);
304N/A emit_operand(rcx, dst, 4);
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::orq(Register dst, int32_t imm32) {
304N/A (void) prefixq_and_encode(dst->encoding());
304N/A emit_arith(0x81, 0xC8, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::orq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x0B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::orq(Register dst, Register src) {
304N/A (void) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x0B, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::popa() { // 64bit
304N/A movq(r15, Address(rsp, 0));
304N/A movq(r14, Address(rsp, wordSize));
304N/A movq(r13, Address(rsp, 2 * wordSize));
304N/A movq(r12, Address(rsp, 3 * wordSize));
304N/A movq(r11, Address(rsp, 4 * wordSize));
304N/A movq(r10, Address(rsp, 5 * wordSize));
304N/A movq(r9, Address(rsp, 6 * wordSize));
304N/A movq(r8, Address(rsp, 7 * wordSize));
304N/A movq(rdi, Address(rsp, 8 * wordSize));
304N/A movq(rsi, Address(rsp, 9 * wordSize));
304N/A movq(rbp, Address(rsp, 10 * wordSize));
304N/A // skip rsp
304N/A movq(rbx, Address(rsp, 12 * wordSize));
304N/A movq(rdx, Address(rsp, 13 * wordSize));
304N/A movq(rcx, Address(rsp, 14 * wordSize));
304N/A movq(rax, Address(rsp, 15 * wordSize));
304N/A
304N/A addq(rsp, 16 * wordSize);
304N/A}
304N/A
643N/Avoid Assembler::popcntq(Register dst, Address src) {
643N/A assert(VM_Version::supports_popcnt(), "must support");
643N/A InstructionMark im(this);
643N/A emit_byte(0xF3);
643N/A prefixq(src, dst);
643N/A emit_byte(0x0F);
643N/A emit_byte(0xB8);
643N/A emit_operand(dst, src);
643N/A}
643N/A
643N/Avoid Assembler::popcntq(Register dst, Register src) {
643N/A assert(VM_Version::supports_popcnt(), "must support");
643N/A emit_byte(0xF3);
643N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
643N/A emit_byte(0x0F);
643N/A emit_byte(0xB8);
643N/A emit_byte(0xC0 | encode);
643N/A}
643N/A
304N/Avoid Assembler::popq(Address dst) {
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_byte(0x8F);
304N/A emit_operand(rax, dst);
304N/A}
304N/A
304N/Avoid Assembler::pusha() { // 64bit
304N/A // we have to store original rsp. ABI says that 128 bytes
304N/A // below rsp are local scratch.
304N/A movq(Address(rsp, -5 * wordSize), rsp);
304N/A
304N/A subq(rsp, 16 * wordSize);
304N/A
304N/A movq(Address(rsp, 15 * wordSize), rax);
304N/A movq(Address(rsp, 14 * wordSize), rcx);
304N/A movq(Address(rsp, 13 * wordSize), rdx);
304N/A movq(Address(rsp, 12 * wordSize), rbx);
304N/A // skip rsp
304N/A movq(Address(rsp, 10 * wordSize), rbp);
304N/A movq(Address(rsp, 9 * wordSize), rsi);
304N/A movq(Address(rsp, 8 * wordSize), rdi);
304N/A movq(Address(rsp, 7 * wordSize), r8);
304N/A movq(Address(rsp, 6 * wordSize), r9);
304N/A movq(Address(rsp, 5 * wordSize), r10);
304N/A movq(Address(rsp, 4 * wordSize), r11);
304N/A movq(Address(rsp, 3 * wordSize), r12);
304N/A movq(Address(rsp, 2 * wordSize), r13);
304N/A movq(Address(rsp, wordSize), r14);
304N/A movq(Address(rsp, 0), r15);
304N/A}
304N/A
304N/Avoid Assembler::pushq(Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src);
304N/A emit_byte(0xFF);
304N/A emit_operand(rsi, src);
304N/A}
304N/A
304N/Avoid Assembler::rclq(Register dst, int imm8) {
304N/A assert(isShiftCount(imm8 >> 1), "illegal shift count");
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A if (imm8 == 1) {
304N/A emit_byte(0xD1);
304N/A emit_byte(0xD0 | encode);
304N/A } else {
304N/A emit_byte(0xC1);
304N/A emit_byte(0xD0 | encode);
304N/A emit_byte(imm8);
304N/A }
304N/A}
304N/Avoid Assembler::sarq(Register dst, int imm8) {
304N/A assert(isShiftCount(imm8 >> 1), "illegal shift count");
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A if (imm8 == 1) {
304N/A emit_byte(0xD1);
304N/A emit_byte(0xF8 | encode);
304N/A } else {
304N/A emit_byte(0xC1);
304N/A emit_byte(0xF8 | encode);
304N/A emit_byte(imm8);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::sarq(Register dst) {
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xD3);
304N/A emit_byte(0xF8 | encode);
304N/A}
1988N/A
304N/Avoid Assembler::sbbq(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefixq(dst);
304N/A emit_arith_operand(0x81, rbx, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::sbbq(Register dst, int32_t imm32) {
304N/A (void) prefixq_and_encode(dst->encoding());
304N/A emit_arith(0x81, 0xD8, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::sbbq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x1B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::sbbq(Register dst, Register src) {
304N/A (void) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x1B, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::shlq(Register dst, int imm8) {
304N/A assert(isShiftCount(imm8 >> 1), "illegal shift count");
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A if (imm8 == 1) {
304N/A emit_byte(0xD1);
304N/A emit_byte(0xE0 | encode);
304N/A } else {
304N/A emit_byte(0xC1);
304N/A emit_byte(0xE0 | encode);
304N/A emit_byte(imm8);
304N/A }
304N/A}
304N/A
304N/Avoid Assembler::shlq(Register dst) {
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xD3);
304N/A emit_byte(0xE0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::shrq(Register dst, int imm8) {
304N/A assert(isShiftCount(imm8 >> 1), "illegal shift count");
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xC1);
304N/A emit_byte(0xE8 | encode);
304N/A emit_byte(imm8);
304N/A}
304N/A
304N/Avoid Assembler::shrq(Register dst) {
304N/A int encode = prefixq_and_encode(dst->encoding());
304N/A emit_byte(0xD3);
304N/A emit_byte(0xE8 | encode);
304N/A}
304N/A
304N/Avoid Assembler::subq(Address dst, int32_t imm32) {
304N/A InstructionMark im(this);
304N/A prefixq(dst);
1988N/A emit_arith_operand(0x81, rbp, dst, imm32);
304N/A}
304N/A
304N/Avoid Assembler::subq(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefixq(dst, src);
304N/A emit_byte(0x29);
304N/A emit_operand(src, dst);
304N/A}
304N/A
1988N/Avoid Assembler::subq(Register dst, int32_t imm32) {
1988N/A (void) prefixq_and_encode(dst->encoding());
1988N/A emit_arith(0x81, 0xE8, dst, imm32);
1988N/A}
1988N/A
3236N/A// Force generation of a 4 byte immediate value even if it fits into 8bit
3236N/Avoid Assembler::subq_imm32(Register dst, int32_t imm32) {
3236N/A (void) prefixq_and_encode(dst->encoding());
3236N/A emit_arith_imm32(0x81, 0xE8, dst, imm32);
3236N/A}
3236N/A
304N/Avoid Assembler::subq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x2B);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::subq(Register dst, Register src) {
304N/A (void) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x2B, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::testq(Register dst, int32_t imm32) {
304N/A // not using emit_arith because test
304N/A // doesn't support sign-extension of
304N/A // 8bit operands
304N/A int encode = dst->encoding();
304N/A if (encode == 0) {
304N/A prefix(REX_W);
304N/A emit_byte(0xA9);
304N/A } else {
304N/A encode = prefixq_and_encode(encode);
304N/A emit_byte(0xF7);
304N/A emit_byte(0xC0 | encode);
304N/A }
304N/A emit_long(imm32);
304N/A}
304N/A
304N/Avoid Assembler::testq(Register dst, Register src) {
304N/A (void) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x85, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::xaddq(Address dst, Register src) {
304N/A InstructionMark im(this);
304N/A prefixq(dst, src);
71N/A emit_byte(0x0F);
304N/A emit_byte(0xC1);
304N/A emit_operand(src, dst);
304N/A}
304N/A
304N/Avoid Assembler::xchgq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x87);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/Avoid Assembler::xchgq(Register dst, Register src) {
304N/A int encode = prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_byte(0x87);
304N/A emit_byte(0xc0 | encode);
304N/A}
304N/A
304N/Avoid Assembler::xorq(Register dst, Register src) {
304N/A (void) prefixq_and_encode(dst->encoding(), src->encoding());
304N/A emit_arith(0x33, 0xC0, dst, src);
304N/A}
304N/A
304N/Avoid Assembler::xorq(Register dst, Address src) {
304N/A InstructionMark im(this);
304N/A prefixq(src, dst);
304N/A emit_byte(0x33);
304N/A emit_operand(dst, src);
304N/A}
304N/A
304N/A#endif // !LP64
304N/A
304N/Astatic Assembler::Condition reverse[] = {
304N/A Assembler::noOverflow /* overflow = 0x0 */ ,
304N/A Assembler::overflow /* noOverflow = 0x1 */ ,
304N/A Assembler::aboveEqual /* carrySet = 0x2, below = 0x2 */ ,
304N/A Assembler::below /* aboveEqual = 0x3, carryClear = 0x3 */ ,
304N/A Assembler::notZero /* zero = 0x4, equal = 0x4 */ ,
304N/A Assembler::zero /* notZero = 0x5, notEqual = 0x5 */ ,
304N/A Assembler::above /* belowEqual = 0x6 */ ,
304N/A Assembler::belowEqual /* above = 0x7 */ ,
304N/A Assembler::positive /* negative = 0x8 */ ,
304N/A Assembler::negative /* positive = 0x9 */ ,
304N/A Assembler::noParity /* parity = 0xa */ ,
304N/A Assembler::parity /* noParity = 0xb */ ,
304N/A Assembler::greaterEqual /* less = 0xc */ ,
304N/A Assembler::less /* greaterEqual = 0xd */ ,
304N/A Assembler::greater /* lessEqual = 0xe */ ,
304N/A Assembler::lessEqual /* greater = 0xf, */
304N/A
304N/A};
304N/A
0N/A
0N/A// Implementation of MacroAssembler
0N/A
304N/A// First all the versions that have distinct versions depending on 32/64 bit
304N/A// Unless the difference is trivial (1 line or so).
304N/A
304N/A#ifndef _LP64
304N/A
304N/A// 32bit versions
304N/A
0N/AAddress MacroAssembler::as_Address(AddressLiteral adr) {
0N/A return Address(adr.target(), adr.rspec());
0N/A}
0N/A
0N/AAddress MacroAssembler::as_Address(ArrayAddress adr) {
0N/A return Address::make_array(adr);
0N/A}
0N/A
304N/Aint MacroAssembler::biased_locking_enter(Register lock_reg,
304N/A Register obj_reg,
304N/A Register swap_reg,
304N/A Register tmp_reg,
304N/A bool swap_reg_contains_mark,
304N/A Label& done,
304N/A Label* slow_case,
304N/A BiasedLockingCounters* counters) {
304N/A assert(UseBiasedLocking, "why call this otherwise?");
304N/A assert(swap_reg == rax, "swap_reg must be rax, for cmpxchg");
304N/A assert_different_registers(lock_reg, obj_reg, swap_reg);
304N/A
304N/A if (PrintBiasedLockingStatistics && counters == NULL)
304N/A counters = BiasedLocking::counters();
304N/A
304N/A bool need_tmp_reg = false;
304N/A if (tmp_reg == noreg) {
304N/A need_tmp_reg = true;
304N/A tmp_reg = lock_reg;
304N/A } else {
304N/A assert_different_registers(lock_reg, obj_reg, swap_reg, tmp_reg);
304N/A }
304N/A assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
304N/A Address mark_addr (obj_reg, oopDesc::mark_offset_in_bytes());
304N/A Address klass_addr (obj_reg, oopDesc::klass_offset_in_bytes());
304N/A Address saved_mark_addr(lock_reg, 0);
304N/A
304N/A // Biased locking
304N/A // See whether the lock is currently biased toward our thread and
304N/A // whether the epoch is still valid
304N/A // Note that the runtime guarantees sufficient alignment of JavaThread
304N/A // pointers to allow age to be placed into low bits
304N/A // First check to see whether biasing is even enabled for this object
304N/A Label cas_label;
304N/A int null_check_offset = -1;
304N/A if (!swap_reg_contains_mark) {
304N/A null_check_offset = offset();
304N/A movl(swap_reg, mark_addr);
304N/A }
304N/A if (need_tmp_reg) {
304N/A push(tmp_reg);
304N/A }
304N/A movl(tmp_reg, swap_reg);
304N/A andl(tmp_reg, markOopDesc::biased_lock_mask_in_place);
304N/A cmpl(tmp_reg, markOopDesc::biased_lock_pattern);
304N/A if (need_tmp_reg) {
304N/A pop(tmp_reg);
304N/A }
304N/A jcc(Assembler::notEqual, cas_label);
304N/A // The bias pattern is present in the object's header. Need to check
304N/A // whether the bias owner and the epoch are both still current.
304N/A // Note that because there is no current thread register on x86 we
304N/A // need to store off the mark word we read out of the object to
304N/A // avoid reloading it and needing to recheck invariants below. This
304N/A // store is unfortunate but it makes the overall code shorter and
304N/A // simpler.
304N/A movl(saved_mark_addr, swap_reg);
304N/A if (need_tmp_reg) {
304N/A push(tmp_reg);
304N/A }
304N/A get_thread(tmp_reg);
304N/A xorl(swap_reg, tmp_reg);
304N/A if (swap_reg_contains_mark) {
304N/A null_check_offset = offset();
304N/A }
304N/A movl(tmp_reg, klass_addr);
3042N/A xorl(swap_reg, Address(tmp_reg, Klass::prototype_header_offset()));
304N/A andl(swap_reg, ~((int) markOopDesc::age_mask_in_place));
304N/A if (need_tmp_reg) {
304N/A pop(tmp_reg);
304N/A }
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address)counters->biased_lock_entry_count_addr()));
304N/A }
304N/A jcc(Assembler::equal, done);
304N/A
304N/A Label try_revoke_bias;
304N/A Label try_rebias;
304N/A
304N/A // At this point we know that the header has the bias pattern and
304N/A // that we are not the bias owner in the current epoch. We need to
304N/A // figure out more details about the state of the header in order to
304N/A // know what operations can be legally performed on the object's
304N/A // header.
304N/A
304N/A // If the low three bits in the xor result aren't clear, that means
304N/A // the prototype header is no longer biased and we have to revoke
304N/A // the bias on this object.
304N/A testl(swap_reg, markOopDesc::biased_lock_mask_in_place);
304N/A jcc(Assembler::notZero, try_revoke_bias);
304N/A
304N/A // Biasing is still enabled for this data type. See whether the
304N/A // epoch of the current bias is still valid, meaning that the epoch
304N/A // bits of the mark word are equal to the epoch bits of the
304N/A // prototype header. (Note that the prototype header's epoch bits
304N/A // only change at a safepoint.) If not, attempt to rebias the object
304N/A // toward the current thread. Note that we must be absolutely sure
304N/A // that the current epoch is invalid in order to do this because
304N/A // otherwise the manipulations it performs on the mark word are
304N/A // illegal.
304N/A testl(swap_reg, markOopDesc::epoch_mask_in_place);
304N/A jcc(Assembler::notZero, try_rebias);
304N/A
304N/A // The epoch of the current bias is still valid but we know nothing
304N/A // about the owner; it might be set or it might be clear. Try to
304N/A // acquire the bias of the object using an atomic operation. If this
304N/A // fails we will go in to the runtime to revoke the object's bias.
304N/A // Note that we first construct the presumed unbiased header so we
304N/A // don't accidentally blow away another thread's valid bias.
304N/A movl(swap_reg, saved_mark_addr);
304N/A andl(swap_reg,
304N/A markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place);
304N/A if (need_tmp_reg) {
304N/A push(tmp_reg);
304N/A }
304N/A get_thread(tmp_reg);
304N/A orl(tmp_reg, swap_reg);
304N/A if (os::is_MP()) {
304N/A lock();
304N/A }
304N/A cmpxchgptr(tmp_reg, Address(obj_reg, 0));
304N/A if (need_tmp_reg) {
304N/A pop(tmp_reg);
304N/A }
304N/A // If the biasing toward our thread failed, this means that
304N/A // another thread succeeded in biasing it toward itself and we
304N/A // need to revoke that bias. The revocation will occur in the
304N/A // interpreter runtime in the slow case.
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address)counters->anonymously_biased_lock_entry_count_addr()));
304N/A }
304N/A if (slow_case != NULL) {
304N/A jcc(Assembler::notZero, *slow_case);
304N/A }
304N/A jmp(done);
304N/A
304N/A bind(try_rebias);
304N/A // At this point we know the epoch has expired, meaning that the
304N/A // current "bias owner", if any, is actually invalid. Under these
304N/A // circumstances _only_, we are allowed to use the current header's
304N/A // value as the comparison value when doing the cas to acquire the
304N/A // bias in the current epoch. In other words, we allow transfer of
304N/A // the bias from one thread to another directly in this situation.
304N/A //
304N/A // FIXME: due to a lack of registers we currently blow away the age
304N/A // bits in this situation. Should attempt to preserve them.
304N/A if (need_tmp_reg) {
304N/A push(tmp_reg);
304N/A }
304N/A get_thread(tmp_reg);
304N/A movl(swap_reg, klass_addr);
3042N/A orl(tmp_reg, Address(swap_reg, Klass::prototype_header_offset()));
304N/A movl(swap_reg, saved_mark_addr);
304N/A if (os::is_MP()) {
304N/A lock();
304N/A }
304N/A cmpxchgptr(tmp_reg, Address(obj_reg, 0));
304N/A if (need_tmp_reg) {
304N/A pop(tmp_reg);
304N/A }
304N/A // If the biasing toward our thread failed, then another thread
304N/A // succeeded in biasing it toward itself and we need to revoke that
304N/A // bias. The revocation will occur in the runtime in the slow case.
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address)counters->rebiased_lock_entry_count_addr()));
304N/A }
304N/A if (slow_case != NULL) {
304N/A jcc(Assembler::notZero, *slow_case);
304N/A }
304N/A jmp(done);
304N/A
304N/A bind(try_revoke_bias);
304N/A // The prototype mark in the klass doesn't have the bias bit set any
304N/A // more, indicating that objects of this data type are not supposed
304N/A // to be biased any more. We are going to try to reset the mark of
304N/A // this object to the prototype value and fall through to the
304N/A // CAS-based locking scheme. Note that if our CAS fails, it means
304N/A // that another thread raced us for the privilege of revoking the
304N/A // bias of this particular object, so it's okay to continue in the
304N/A // normal locking code.
304N/A //
304N/A // FIXME: due to a lack of registers we currently blow away the age
304N/A // bits in this situation. Should attempt to preserve them.
304N/A movl(swap_reg, saved_mark_addr);
304N/A if (need_tmp_reg) {
304N/A push(tmp_reg);
304N/A }
304N/A movl(tmp_reg, klass_addr);
3042N/A movl(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset()));
304N/A if (os::is_MP()) {
304N/A lock();
304N/A }
304N/A cmpxchgptr(tmp_reg, Address(obj_reg, 0));
304N/A if (need_tmp_reg) {
304N/A pop(tmp_reg);
304N/A }
304N/A // Fall through to the normal CAS-based lock, because no matter what
304N/A // the result of the above CAS, some thread must have succeeded in
304N/A // removing the bias bit from the object's header.
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address)counters->revoked_lock_entry_count_addr()));
304N/A }
304N/A
304N/A bind(cas_label);
304N/A
304N/A return null_check_offset;
304N/A}
304N/Avoid MacroAssembler::call_VM_leaf_base(address entry_point,
304N/A int number_of_arguments) {
304N/A call(RuntimeAddress(entry_point));
304N/A increment(rsp, number_of_arguments * wordSize);
304N/A}
304N/A
304N/Avoid MacroAssembler::cmpoop(Address src1, jobject obj) {
304N/A cmp_literal32(src1, (int32_t)obj, oop_Relocation::spec_for_immediate());
304N/A}
304N/A
304N/Avoid MacroAssembler::cmpoop(Register src1, jobject obj) {
304N/A cmp_literal32(src1, (int32_t)obj, oop_Relocation::spec_for_immediate());
304N/A}
304N/A
304N/Avoid MacroAssembler::extend_sign(Register hi, Register lo) {
304N/A // According to Intel Doc. AP-526, "Integer Divide", p.18.
304N/A if (VM_Version::is_P6() && hi == rdx && lo == rax) {
304N/A cdql();
304N/A } else {
304N/A movl(hi, lo);
304N/A sarl(hi, 31);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::jC2(Register tmp, Label& L) {
304N/A // set parity bit if FPU flag C2 is set (via rax)
304N/A save_rax(tmp);
304N/A fwait(); fnstsw_ax();
304N/A sahf();
304N/A restore_rax(tmp);
304N/A // branch
304N/A jcc(Assembler::parity, L);
304N/A}
304N/A
304N/Avoid MacroAssembler::jnC2(Register tmp, Label& L) {
304N/A // set parity bit if FPU flag C2 is set (via rax)
304N/A save_rax(tmp);
304N/A fwait(); fnstsw_ax();
304N/A sahf();
304N/A restore_rax(tmp);
304N/A // branch
304N/A jcc(Assembler::noParity, L);
304N/A}
304N/A
0N/A// 32bit can do a case table jump in one instruction but we no longer allow the base
0N/A// to be installed in the Address class
0N/Avoid MacroAssembler::jump(ArrayAddress entry) {
0N/A jmp(as_Address(entry));
0N/A}
0N/A
304N/A// Note: y_lo will be destroyed
304N/Avoid MacroAssembler::lcmp2int(Register x_hi, Register x_lo, Register y_hi, Register y_lo) {
304N/A // Long compare for Java (semantics as described in JVM spec.)
304N/A Label high, low, done;
304N/A
304N/A cmpl(x_hi, y_hi);
304N/A jcc(Assembler::less, low);
304N/A jcc(Assembler::greater, high);
304N/A // x_hi is the return register
304N/A xorl(x_hi, x_hi);
304N/A cmpl(x_lo, y_lo);
304N/A jcc(Assembler::below, low);
304N/A jcc(Assembler::equal, done);
304N/A
304N/A bind(high);
304N/A xorl(x_hi, x_hi);
304N/A increment(x_hi);
304N/A jmp(done);
304N/A
304N/A bind(low);
304N/A xorl(x_hi, x_hi);
304N/A decrementl(x_hi);
304N/A
304N/A bind(done);
304N/A}
304N/A
304N/Avoid MacroAssembler::lea(Register dst, AddressLiteral src) {
304N/A mov_literal32(dst, (int32_t)src.target(), src.rspec());
0N/A}
0N/A
0N/Avoid MacroAssembler::lea(Address dst, AddressLiteral adr) {
0N/A // leal(dst, as_Address(adr));
304N/A // see note in movl as to why we must use a move
0N/A mov_literal32(dst, (int32_t) adr.target(), adr.rspec());
0N/A}
0N/A
0N/Avoid MacroAssembler::leave() {
304N/A mov(rsp, rbp);
304N/A pop(rbp);
304N/A}
0N/A
0N/Avoid MacroAssembler::lmul(int x_rsp_offset, int y_rsp_offset) {
0N/A // Multiplication of two Java long values stored on the stack
0N/A // as illustrated below. Result is in rdx:rax.
0N/A //
0N/A // rsp ---> [ ?? ] \ \
0N/A // .... | y_rsp_offset |
0N/A // [ y_lo ] / (in bytes) | x_rsp_offset
0N/A // [ y_hi ] | (in bytes)
0N/A // .... |
0N/A // [ x_lo ] /
0N/A // [ x_hi ]
0N/A // ....
0N/A //
0N/A // Basic idea: lo(result) = lo(x_lo * y_lo)
0N/A // hi(result) = hi(x_lo * y_lo) + lo(x_hi * y_lo) + lo(x_lo * y_hi)
0N/A Address x_hi(rsp, x_rsp_offset + wordSize); Address x_lo(rsp, x_rsp_offset);
0N/A Address y_hi(rsp, y_rsp_offset + wordSize); Address y_lo(rsp, y_rsp_offset);
0N/A Label quick;
0N/A // load x_hi, y_hi and check if quick
0N/A // multiplication is possible
0N/A movl(rbx, x_hi);
0N/A movl(rcx, y_hi);
0N/A movl(rax, rbx);
0N/A orl(rbx, rcx); // rbx, = 0 <=> x_hi = 0 and y_hi = 0
0N/A jcc(Assembler::zero, quick); // if rbx, = 0 do quick multiply
0N/A // do full multiplication
0N/A // 1st step
0N/A mull(y_lo); // x_hi * y_lo
0N/A movl(rbx, rax); // save lo(x_hi * y_lo) in rbx,
0N/A // 2nd step
0N/A movl(rax, x_lo);
0N/A mull(rcx); // x_lo * y_hi
0N/A addl(rbx, rax); // add lo(x_lo * y_hi) to rbx,
0N/A // 3rd step
0N/A bind(quick); // note: rbx, = 0 if quick multiply!
0N/A movl(rax, x_lo);
0N/A mull(y_lo); // x_lo * y_lo
0N/A addl(rdx, rbx); // correct hi(x_lo * y_lo)
0N/A}
0N/A
304N/Avoid MacroAssembler::lneg(Register hi, Register lo) {
304N/A negl(lo);
304N/A adcl(hi, 0);
304N/A negl(hi);
304N/A}
0N/A
0N/Avoid MacroAssembler::lshl(Register hi, Register lo) {
0N/A // Java shift left long support (semantics as described in JVM spec., p.305)
0N/A // (basic idea for shift counts s >= n: x << s == (x << n) << (s - n))
0N/A // shift value is in rcx !
0N/A assert(hi != rcx, "must not use rcx");
0N/A assert(lo != rcx, "must not use rcx");
0N/A const Register s = rcx; // shift count
0N/A const int n = BitsPerWord;
0N/A Label L;
0N/A andl(s, 0x3f); // s := s & 0x3f (s < 0x40)
0N/A cmpl(s, n); // if (s < n)
0N/A jcc(Assembler::less, L); // else (s >= n)
0N/A movl(hi, lo); // x := x << n
0N/A xorl(lo, lo);
0N/A // Note: subl(s, n) is not needed since the Intel shift instructions work rcx mod n!
0N/A bind(L); // s (mod n) < n
0N/A shldl(hi, lo); // x := x << s
0N/A shll(lo);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::lshr(Register hi, Register lo, bool sign_extension) {
0N/A // Java shift right long support (semantics as described in JVM spec., p.306 & p.310)
0N/A // (basic idea for shift counts s >= n: x >> s == (x >> n) >> (s - n))
0N/A assert(hi != rcx, "must not use rcx");
0N/A assert(lo != rcx, "must not use rcx");
0N/A const Register s = rcx; // shift count
0N/A const int n = BitsPerWord;
0N/A Label L;
0N/A andl(s, 0x3f); // s := s & 0x3f (s < 0x40)
0N/A cmpl(s, n); // if (s < n)
0N/A jcc(Assembler::less, L); // else (s >= n)
0N/A movl(lo, hi); // x := x >> n
0N/A if (sign_extension) sarl(hi, 31);
0N/A else xorl(hi, hi);
0N/A // Note: subl(s, n) is not needed since the Intel shift instructions work rcx mod n!
0N/A bind(L); // s (mod n) < n
0N/A shrdl(lo, hi); // x := x >> s
0N/A if (sign_extension) sarl(hi);
0N/A else shrl(hi);
0N/A}
0N/A
304N/Avoid MacroAssembler::movoop(Register dst, jobject obj) {
304N/A mov_literal32(dst, (int32_t)obj, oop_Relocation::spec_for_immediate());
304N/A}
304N/A
304N/Avoid MacroAssembler::movoop(Address dst, jobject obj) {
304N/A mov_literal32(dst, (int32_t)obj, oop_Relocation::spec_for_immediate());
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Register dst, AddressLiteral src) {
304N/A if (src.is_lval()) {
304N/A mov_literal32(dst, (intptr_t)src.target(), src.rspec());
304N/A } else {
304N/A movl(dst, as_Address(src));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(ArrayAddress dst, Register src) {
304N/A movl(as_Address(dst), src);
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Register dst, ArrayAddress src) {
304N/A movl(dst, as_Address(src));
304N/A}
304N/A
304N/A// src should NEVER be a real pointer. Use AddressLiteral for true pointers
304N/Avoid MacroAssembler::movptr(Address dst, intptr_t src) {
304N/A movl(dst, src);
304N/A}
304N/A
304N/A
304N/Avoid MacroAssembler::pop_callee_saved_registers() {
304N/A pop(rcx);
304N/A pop(rdx);
304N/A pop(rdi);
304N/A pop(rsi);
304N/A}
304N/A
304N/Avoid MacroAssembler::pop_fTOS() {
304N/A fld_d(Address(rsp, 0));
304N/A addl(rsp, 2 * wordSize);
304N/A}
304N/A
304N/Avoid MacroAssembler::push_callee_saved_registers() {
304N/A push(rsi);
304N/A push(rdi);
304N/A push(rdx);
304N/A push(rcx);
304N/A}
304N/A
304N/Avoid MacroAssembler::push_fTOS() {
304N/A subl(rsp, 2 * wordSize);
304N/A fstp_d(Address(rsp, 0));
304N/A}
304N/A
304N/A
304N/Avoid MacroAssembler::pushoop(jobject obj) {
304N/A push_literal32((int32_t)obj, oop_Relocation::spec_for_immediate());
304N/A}
304N/A
304N/A
304N/Avoid MacroAssembler::pushptr(AddressLiteral src) {
304N/A if (src.is_lval()) {
304N/A push_literal32((int32_t)src.target(), src.rspec());
304N/A } else {
304N/A pushl(as_Address(src));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::set_word_if_not_zero(Register dst) {
304N/A xorl(dst, dst);
304N/A set_byte_if_not_zero(dst);
304N/A}
304N/A
304N/Astatic void pass_arg0(MacroAssembler* masm, Register arg) {
304N/A masm->push(arg);
304N/A}
304N/A
304N/Astatic void pass_arg1(MacroAssembler* masm, Register arg) {
304N/A masm->push(arg);
304N/A}
304N/A
304N/Astatic void pass_arg2(MacroAssembler* masm, Register arg) {
304N/A masm->push(arg);
304N/A}
304N/A
304N/Astatic void pass_arg3(MacroAssembler* masm, Register arg) {
304N/A masm->push(arg);
304N/A}
304N/A
304N/A#ifndef PRODUCT
304N/Aextern "C" void findpc(intptr_t x);
304N/A#endif
304N/A
304N/Avoid MacroAssembler::debug32(int rdi, int rsi, int rbp, int rsp, int rbx, int rdx, int rcx, int rax, int eip, char* msg) {
304N/A // In order to get locks to work, we need to fake a in_VM state
304N/A JavaThread* thread = JavaThread::current();
304N/A JavaThreadState saved_state = thread->thread_state();
304N/A thread->set_thread_state(_thread_in_vm);
304N/A if (ShowMessageBoxOnError) {
304N/A JavaThread* thread = JavaThread::current();
304N/A JavaThreadState saved_state = thread->thread_state();
304N/A thread->set_thread_state(_thread_in_vm);
304N/A if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
304N/A ttyLocker ttyl;
304N/A BytecodeCounter::print();
304N/A }
304N/A // To see where a verify_oop failed, get $ebx+40/X for this frame.
304N/A // This is the value of eip which points to where verify_oop will return.
304N/A if (os::message_box(msg, "Execution stopped, print registers?")) {
3932N/A print_state32(rdi, rsi, rbp, rsp, rbx, rdx, rcx, rax, eip);
304N/A BREAKPOINT;
1713N/A assert(false, "start up GDB");
304N/A }
304N/A } else {
304N/A ttyLocker ttyl;
304N/A ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
2578N/A assert(false, err_msg("DEBUG MESSAGE: %s", msg));
304N/A }
304N/A ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
304N/A}
304N/A
3932N/Avoid MacroAssembler::print_state32(int rdi, int rsi, int rbp, int rsp, int rbx, int rdx, int rcx, int rax, int eip) {
3932N/A ttyLocker ttyl;
3932N/A FlagSetting fs(Debugging, true);
3932N/A tty->print_cr("eip = 0x%08x", eip);
3932N/A#ifndef PRODUCT
3932N/A if ((WizardMode || Verbose) && PrintMiscellaneous) {
3932N/A tty->cr();
3932N/A findpc(eip);
3932N/A tty->cr();
3932N/A }
3932N/A#endif
3932N/A#define PRINT_REG(rax) \
3932N/A { tty->print("%s = ", #rax); os::print_location(tty, rax); }
3932N/A PRINT_REG(rax);
3932N/A PRINT_REG(rbx);
3932N/A PRINT_REG(rcx);
3932N/A PRINT_REG(rdx);
3932N/A PRINT_REG(rdi);
3932N/A PRINT_REG(rsi);
3932N/A PRINT_REG(rbp);
3932N/A PRINT_REG(rsp);
3932N/A#undef PRINT_REG
3932N/A // Print some words near top of staack.
3932N/A int* dump_sp = (int*) rsp;
3932N/A for (int col1 = 0; col1 < 8; col1++) {
3932N/A tty->print("(rsp+0x%03x) 0x%08x: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (intptr_t)dump_sp);
3932N/A os::print_location(tty, *dump_sp++);
3932N/A }
3932N/A for (int row = 0; row < 16; row++) {
3932N/A tty->print("(rsp+0x%03x) 0x%08x: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (intptr_t)dump_sp);
3932N/A for (int col = 0; col < 8; col++) {
3932N/A tty->print(" 0x%08x", *dump_sp++);
3932N/A }
3932N/A tty->cr();
3932N/A }
3932N/A // Print some instructions around pc:
3932N/A Disassembler::decode((address)eip-64, (address)eip);
3932N/A tty->print_cr("--------");
3932N/A Disassembler::decode((address)eip, (address)eip+32);
3932N/A}
3932N/A
304N/Avoid MacroAssembler::stop(const char* msg) {
304N/A ExternalAddress message((address)msg);
304N/A // push address of message
304N/A pushptr(message.addr());
304N/A { Label L; call(L, relocInfo::none); bind(L); } // push eip
3932N/A pusha(); // push registers
304N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug32)));
304N/A hlt();
304N/A}
304N/A
304N/Avoid MacroAssembler::warn(const char* msg) {
304N/A push_CPU_state();
304N/A
304N/A ExternalAddress message((address) msg);
304N/A // push address of message
304N/A pushptr(message.addr());
304N/A
304N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, warning)));
304N/A addl(rsp, wordSize); // discard argument
304N/A pop_CPU_state();
304N/A}
304N/A
3932N/Avoid MacroAssembler::print_state() {
3932N/A { Label L; call(L, relocInfo::none); bind(L); } // push eip
3932N/A pusha(); // push registers
3932N/A
3932N/A push_CPU_state();
3932N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::print_state32)));
3932N/A pop_CPU_state();
3932N/A
3932N/A popa();
3932N/A addl(rsp, wordSize);
3932N/A}
3932N/A
304N/A#else // _LP64
304N/A
304N/A// 64 bit versions
304N/A
304N/AAddress MacroAssembler::as_Address(AddressLiteral adr) {
304N/A // amd64 always does this as a pc-rel
304N/A // we can be absolute or disp based on the instruction type
304N/A // jmp/call are displacements others are absolute
304N/A assert(!adr.is_lval(), "must be rval");
304N/A assert(reachable(adr), "must be");
304N/A return Address((int32_t)(intptr_t)(adr.target() - pc()), adr.target(), adr.reloc());
304N/A
304N/A}
304N/A
304N/AAddress MacroAssembler::as_Address(ArrayAddress adr) {
304N/A AddressLiteral base = adr.base();
304N/A lea(rscratch1, base);
304N/A Address index = adr.index();
304N/A assert(index._disp == 0, "must not have disp"); // maybe it can?
304N/A Address array(rscratch1, index._index, index._scale, index._disp);
304N/A return array;
304N/A}
304N/A
304N/Aint MacroAssembler::biased_locking_enter(Register lock_reg,
304N/A Register obj_reg,
304N/A Register swap_reg,
304N/A Register tmp_reg,
304N/A bool swap_reg_contains_mark,
304N/A Label& done,
304N/A Label* slow_case,
304N/A BiasedLockingCounters* counters) {
304N/A assert(UseBiasedLocking, "why call this otherwise?");
304N/A assert(swap_reg == rax, "swap_reg must be rax for cmpxchgq");
304N/A assert(tmp_reg != noreg, "tmp_reg must be supplied");
304N/A assert_different_registers(lock_reg, obj_reg, swap_reg, tmp_reg);
304N/A assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
304N/A Address mark_addr (obj_reg, oopDesc::mark_offset_in_bytes());
304N/A Address saved_mark_addr(lock_reg, 0);
304N/A
304N/A if (PrintBiasedLockingStatistics && counters == NULL)
304N/A counters = BiasedLocking::counters();
304N/A
304N/A // Biased locking
304N/A // See whether the lock is currently biased toward our thread and
304N/A // whether the epoch is still valid
304N/A // Note that the runtime guarantees sufficient alignment of JavaThread
304N/A // pointers to allow age to be placed into low bits
304N/A // First check to see whether biasing is even enabled for this object
304N/A Label cas_label;
304N/A int null_check_offset = -1;
304N/A if (!swap_reg_contains_mark) {
304N/A null_check_offset = offset();
304N/A movq(swap_reg, mark_addr);
304N/A }
304N/A movq(tmp_reg, swap_reg);
304N/A andq(tmp_reg, markOopDesc::biased_lock_mask_in_place);
304N/A cmpq(tmp_reg, markOopDesc::biased_lock_pattern);
304N/A jcc(Assembler::notEqual, cas_label);
304N/A // The bias pattern is present in the object's header. Need to check
304N/A // whether the bias owner and the epoch are both still current.
304N/A load_prototype_header(tmp_reg, obj_reg);
304N/A orq(tmp_reg, r15_thread);
304N/A xorq(tmp_reg, swap_reg);
304N/A andq(tmp_reg, ~((int) markOopDesc::age_mask_in_place));
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address) counters->anonymously_biased_lock_entry_count_addr()));
304N/A }
0N/A jcc(Assembler::equal, done);
0N/A
304N/A Label try_revoke_bias;
304N/A Label try_rebias;
304N/A
304N/A // At this point we know that the header has the bias pattern and
304N/A // that we are not the bias owner in the current epoch. We need to
304N/A // figure out more details about the state of the header in order to
304N/A // know what operations can be legally performed on the object's
304N/A // header.
304N/A
304N/A // If the low three bits in the xor result aren't clear, that means
304N/A // the prototype header is no longer biased and we have to revoke
304N/A // the bias on this object.
304N/A testq(tmp_reg, markOopDesc::biased_lock_mask_in_place);
304N/A jcc(Assembler::notZero, try_revoke_bias);
304N/A
304N/A // Biasing is still enabled for this data type. See whether the
304N/A // epoch of the current bias is still valid, meaning that the epoch
304N/A // bits of the mark word are equal to the epoch bits of the
304N/A // prototype header. (Note that the prototype header's epoch bits
304N/A // only change at a safepoint.) If not, attempt to rebias the object
304N/A // toward the current thread. Note that we must be absolutely sure
304N/A // that the current epoch is invalid in order to do this because
304N/A // otherwise the manipulations it performs on the mark word are
304N/A // illegal.
304N/A testq(tmp_reg, markOopDesc::epoch_mask_in_place);
304N/A jcc(Assembler::notZero, try_rebias);
304N/A
304N/A // The epoch of the current bias is still valid but we know nothing
304N/A // about the owner; it might be set or it might be clear. Try to
304N/A // acquire the bias of the object using an atomic operation. If this
304N/A // fails we will go in to the runtime to revoke the object's bias.
304N/A // Note that we first construct the presumed unbiased header so we
304N/A // don't accidentally blow away another thread's valid bias.
304N/A andq(swap_reg,
304N/A markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place);
304N/A movq(tmp_reg, swap_reg);
304N/A orq(tmp_reg, r15_thread);
304N/A if (os::is_MP()) {
304N/A lock();
304N/A }
304N/A cmpxchgq(tmp_reg, Address(obj_reg, 0));
304N/A // If the biasing toward our thread failed, this means that
304N/A // another thread succeeded in biasing it toward itself and we
304N/A // need to revoke that bias. The revocation will occur in the
304N/A // interpreter runtime in the slow case.
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address) counters->anonymously_biased_lock_entry_count_addr()));
304N/A }
304N/A if (slow_case != NULL) {
304N/A jcc(Assembler::notZero, *slow_case);
304N/A }
0N/A jmp(done);
0N/A
304N/A bind(try_rebias);
304N/A // At this point we know the epoch has expired, meaning that the
304N/A // current "bias owner", if any, is actually invalid. Under these
304N/A // circumstances _only_, we are allowed to use the current header's
304N/A // value as the comparison value when doing the cas to acquire the
304N/A // bias in the current epoch. In other words, we allow transfer of
304N/A // the bias from one thread to another directly in this situation.
304N/A //
304N/A // FIXME: due to a lack of registers we currently blow away the age
304N/A // bits in this situation. Should attempt to preserve them.
304N/A load_prototype_header(tmp_reg, obj_reg);
304N/A orq(tmp_reg, r15_thread);
304N/A if (os::is_MP()) {
304N/A lock();
304N/A }
304N/A cmpxchgq(tmp_reg, Address(obj_reg, 0));
304N/A // If the biasing toward our thread failed, then another thread
304N/A // succeeded in biasing it toward itself and we need to revoke that
304N/A // bias. The revocation will occur in the runtime in the slow case.
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address) counters->rebiased_lock_entry_count_addr()));
304N/A }
304N/A if (slow_case != NULL) {
304N/A jcc(Assembler::notZero, *slow_case);
0N/A }
0N/A jmp(done);
0N/A
304N/A bind(try_revoke_bias);
304N/A // The prototype mark in the klass doesn't have the bias bit set any
304N/A // more, indicating that objects of this data type are not supposed
304N/A // to be biased any more. We are going to try to reset the mark of
304N/A // this object to the prototype value and fall through to the
304N/A // CAS-based locking scheme. Note that if our CAS fails, it means
304N/A // that another thread raced us for the privilege of revoking the
304N/A // bias of this particular object, so it's okay to continue in the
304N/A // normal locking code.
304N/A //
304N/A // FIXME: due to a lack of registers we currently blow away the age
304N/A // bits in this situation. Should attempt to preserve them.
304N/A load_prototype_header(tmp_reg, obj_reg);
304N/A if (os::is_MP()) {
304N/A lock();
304N/A }
304N/A cmpxchgq(tmp_reg, Address(obj_reg, 0));
304N/A // Fall through to the normal CAS-based lock, because no matter what
304N/A // the result of the above CAS, some thread must have succeeded in
304N/A // removing the bias bit from the object's header.
304N/A if (counters != NULL) {
304N/A cond_inc32(Assembler::zero,
304N/A ExternalAddress((address) counters->revoked_lock_entry_count_addr()));
304N/A }
304N/A
304N/A bind(cas_label);
304N/A
304N/A return null_check_offset;
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM_leaf_base(address entry_point, int num_args) {
304N/A Label L, E;
304N/A
304N/A#ifdef _WIN64
304N/A // Windows always allocates space for it's register args
304N/A assert(num_args <= 4, "only register arguments supported");
304N/A subq(rsp, frame::arg_reg_save_area_bytes);
304N/A#endif
304N/A
304N/A // Align stack if necessary
304N/A testl(rsp, 15);
304N/A jcc(Assembler::zero, L);
304N/A
304N/A subq(rsp, 8);
304N/A {
304N/A call(RuntimeAddress(entry_point));
304N/A }
304N/A addq(rsp, 8);
304N/A jmp(E);
304N/A
304N/A bind(L);
304N/A {
304N/A call(RuntimeAddress(entry_point));
304N/A }
304N/A
304N/A bind(E);
304N/A
304N/A#ifdef _WIN64
304N/A // restore stack pointer
304N/A addq(rsp, frame::arg_reg_save_area_bytes);
304N/A#endif
304N/A
304N/A}
304N/A
304N/Avoid MacroAssembler::cmp64(Register src1, AddressLiteral src2) {
304N/A assert(!src2.is_lval(), "should use cmpptr");
304N/A
304N/A if (reachable(src2)) {
304N/A cmpq(src1, as_Address(src2));
304N/A } else {
304N/A lea(rscratch1, src2);
304N/A Assembler::cmpq(src1, Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Aint MacroAssembler::corrected_idivq(Register reg) {
304N/A // Full implementation of Java ldiv and lrem; checks for special
304N/A // case as described in JVM spec., p.243 & p.271. The function
304N/A // returns the (pc) offset of the idivl instruction - may be needed
304N/A // for implicit exceptions.
304N/A //
304N/A // normal case special case
304N/A //
304N/A // input : rax: dividend min_long
304N/A // reg: divisor (may not be eax/edx) -1
304N/A //
304N/A // output: rax: quotient (= rax idiv reg) min_long
304N/A // rdx: remainder (= rax irem reg) 0
304N/A assert(reg != rax && reg != rdx, "reg cannot be rax or rdx register");
304N/A static const int64_t min_long = 0x8000000000000000;
304N/A Label normal_case, special_case;
304N/A
304N/A // check for special case
304N/A cmp64(rax, ExternalAddress((address) &min_long));
304N/A jcc(Assembler::notEqual, normal_case);
304N/A xorl(rdx, rdx); // prepare rdx for possible special case (where
304N/A // remainder = 0)
304N/A cmpq(reg, -1);
304N/A jcc(Assembler::equal, special_case);
304N/A
304N/A // handle normal case
304N/A bind(normal_case);
304N/A cdqq();
304N/A int idivq_offset = offset();
304N/A idivq(reg);
304N/A
304N/A // normal and special case exit
304N/A bind(special_case);
304N/A
304N/A return idivq_offset;
304N/A}
304N/A
304N/Avoid MacroAssembler::decrementq(Register reg, int value) {
304N/A if (value == min_jint) { subq(reg, value); return; }
304N/A if (value < 0) { incrementq(reg, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { decq(reg) ; return; }
304N/A /* else */ { subq(reg, value) ; return; }
304N/A}
304N/A
304N/Avoid MacroAssembler::decrementq(Address dst, int value) {
304N/A if (value == min_jint) { subq(dst, value); return; }
304N/A if (value < 0) { incrementq(dst, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { decq(dst) ; return; }
304N/A /* else */ { subq(dst, value) ; return; }
304N/A}
304N/A
304N/Avoid MacroAssembler::incrementq(Register reg, int value) {
304N/A if (value == min_jint) { addq(reg, value); return; }
304N/A if (value < 0) { decrementq(reg, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { incq(reg) ; return; }
304N/A /* else */ { addq(reg, value) ; return; }
304N/A}
304N/A
304N/Avoid MacroAssembler::incrementq(Address dst, int value) {
304N/A if (value == min_jint) { addq(dst, value); return; }
304N/A if (value < 0) { decrementq(dst, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { incq(dst) ; return; }
304N/A /* else */ { addq(dst, value) ; return; }
304N/A}
304N/A
304N/A// 32bit can do a case table jump in one instruction but we no longer allow the base
304N/A// to be installed in the Address class
304N/Avoid MacroAssembler::jump(ArrayAddress entry) {
304N/A lea(rscratch1, entry.base());
304N/A Address dispatch = entry.index();
304N/A assert(dispatch._base == noreg, "must be");
304N/A dispatch._base = rscratch1;
304N/A jmp(dispatch);
304N/A}
304N/A
304N/Avoid MacroAssembler::lcmp2int(Register x_hi, Register x_lo, Register y_hi, Register y_lo) {
304N/A ShouldNotReachHere(); // 64bit doesn't use two regs
304N/A cmpq(x_lo, y_lo);
304N/A}
304N/A
304N/Avoid MacroAssembler::lea(Register dst, AddressLiteral src) {
304N/A mov_literal64(dst, (intptr_t)src.target(), src.rspec());
304N/A}
304N/A
304N/Avoid MacroAssembler::lea(Address dst, AddressLiteral adr) {
304N/A mov_literal64(rscratch1, (intptr_t)adr.target(), adr.rspec());
304N/A movptr(dst, rscratch1);
304N/A}
304N/A
304N/Avoid MacroAssembler::leave() {
304N/A // %%% is this really better? Why not on 32bit too?
304N/A emit_byte(0xC9); // LEAVE
304N/A}
304N/A
304N/Avoid MacroAssembler::lneg(Register hi, Register lo) {
304N/A ShouldNotReachHere(); // 64bit doesn't use two regs
304N/A negq(lo);
304N/A}
304N/A
304N/Avoid MacroAssembler::movoop(Register dst, jobject obj) {
304N/A mov_literal64(dst, (intptr_t)obj, oop_Relocation::spec_for_immediate());
304N/A}
304N/A
304N/Avoid MacroAssembler::movoop(Address dst, jobject obj) {
304N/A mov_literal64(rscratch1, (intptr_t)obj, oop_Relocation::spec_for_immediate());
304N/A movq(dst, rscratch1);
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Register dst, AddressLiteral src) {
304N/A if (src.is_lval()) {
304N/A mov_literal64(dst, (intptr_t)src.target(), src.rspec());
304N/A } else {
304N/A if (reachable(src)) {
304N/A movq(dst, as_Address(src));
304N/A } else {
304N/A lea(rscratch1, src);
304N/A movq(dst, Address(rscratch1,0));
0N/A }
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(ArrayAddress dst, Register src) {
304N/A movq(as_Address(dst), src);
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Register dst, ArrayAddress src) {
304N/A movq(dst, as_Address(src));
304N/A}
304N/A
304N/A// src should NEVER be a real pointer. Use AddressLiteral for true pointers
304N/Avoid MacroAssembler::movptr(Address dst, intptr_t src) {
304N/A mov64(rscratch1, src);
304N/A movq(dst, rscratch1);
304N/A}
304N/A
304N/A// These are mostly for initializing NULL
304N/Avoid MacroAssembler::movptr(Address dst, int32_t src) {
304N/A movslq(dst, src);
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Register dst, int32_t src) {
304N/A mov64(dst, (intptr_t)src);
304N/A}
304N/A
304N/Avoid MacroAssembler::pushoop(jobject obj) {
304N/A movoop(rscratch1, obj);
304N/A push(rscratch1);
304N/A}
304N/A
304N/Avoid MacroAssembler::pushptr(AddressLiteral src) {
304N/A lea(rscratch1, src);
304N/A if (src.is_lval()) {
304N/A push(rscratch1);
304N/A } else {
304N/A pushq(Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::reset_last_Java_frame(bool clear_fp,
304N/A bool clear_pc) {
304N/A // we must set sp to zero to clear frame
512N/A movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
304N/A // must clear fp, so that compiled frames are not confused; it is
304N/A // possible that we need it only for debugging
304N/A if (clear_fp) {
512N/A movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
304N/A }
304N/A
304N/A if (clear_pc) {
512N/A movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::set_last_Java_frame(Register last_java_sp,
304N/A Register last_java_fp,
304N/A address last_java_pc) {
304N/A // determine last_java_sp register
304N/A if (!last_java_sp->is_valid()) {
304N/A last_java_sp = rsp;
304N/A }
304N/A
304N/A // last_java_fp is optional
304N/A if (last_java_fp->is_valid()) {
304N/A movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()),
304N/A last_java_fp);
304N/A }
304N/A
304N/A // last_java_pc is optional
304N/A if (last_java_pc != NULL) {
304N/A Address java_pc(r15_thread,
304N/A JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset());
304N/A lea(rscratch1, InternalAddress(last_java_pc));
304N/A movptr(java_pc, rscratch1);
304N/A }
304N/A
304N/A movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
304N/A}
304N/A
304N/Astatic void pass_arg0(MacroAssembler* masm, Register arg) {
304N/A if (c_rarg0 != arg ) {
304N/A masm->mov(c_rarg0, arg);
304N/A }
304N/A}
304N/A
304N/Astatic void pass_arg1(MacroAssembler* masm, Register arg) {
304N/A if (c_rarg1 != arg ) {
304N/A masm->mov(c_rarg1, arg);
304N/A }
304N/A}
304N/A
304N/Astatic void pass_arg2(MacroAssembler* masm, Register arg) {
304N/A if (c_rarg2 != arg ) {
304N/A masm->mov(c_rarg2, arg);
304N/A }
304N/A}
304N/A
304N/Astatic void pass_arg3(MacroAssembler* masm, Register arg) {
304N/A if (c_rarg3 != arg ) {
304N/A masm->mov(c_rarg3, arg);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::stop(const char* msg) {
304N/A address rip = pc();
304N/A pusha(); // get regs on stack
304N/A lea(c_rarg0, ExternalAddress((address) msg));
304N/A lea(c_rarg1, InternalAddress(rip));
304N/A movq(c_rarg2, rsp); // pass pointer to regs array
304N/A andq(rsp, -16); // align stack as required by ABI
304N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug64)));
304N/A hlt();
304N/A}
304N/A
304N/Avoid MacroAssembler::warn(const char* msg) {
3932N/A push(rbp);
3932N/A movq(rbp, rsp);
304N/A andq(rsp, -16); // align stack as required by push_CPU_state and call
304N/A push_CPU_state(); // keeps alignment at 16 bytes
304N/A lea(c_rarg0, ExternalAddress((address) msg));
304N/A call_VM_leaf(CAST_FROM_FN_PTR(address, warning), c_rarg0);
304N/A pop_CPU_state();
3932N/A mov(rsp, rbp);
3932N/A pop(rbp);
3932N/A}
3932N/A
3932N/Avoid MacroAssembler::print_state() {
3932N/A address rip = pc();
3932N/A pusha(); // get regs on stack
3932N/A push(rbp);
3932N/A movq(rbp, rsp);
3932N/A andq(rsp, -16); // align stack as required by push_CPU_state and call
3932N/A push_CPU_state(); // keeps alignment at 16 bytes
3932N/A
3932N/A lea(c_rarg0, InternalAddress(rip));
3932N/A lea(c_rarg1, Address(rbp, wordSize)); // pass pointer to regs array
3932N/A call_VM_leaf(CAST_FROM_FN_PTR(address, MacroAssembler::print_state64), c_rarg0, c_rarg1);
3932N/A
3932N/A pop_CPU_state();
3932N/A mov(rsp, rbp);
3932N/A pop(rbp);
3932N/A popa();
304N/A}
304N/A
304N/A#ifndef PRODUCT
304N/Aextern "C" void findpc(intptr_t x);
304N/A#endif
304N/A
304N/Avoid MacroAssembler::debug64(char* msg, int64_t pc, int64_t regs[]) {
304N/A // In order to get locks to work, we need to fake a in_VM state
3932N/A if (ShowMessageBoxOnError) {
304N/A JavaThread* thread = JavaThread::current();
304N/A JavaThreadState saved_state = thread->thread_state();
304N/A thread->set_thread_state(_thread_in_vm);
304N/A#ifndef PRODUCT
304N/A if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
304N/A ttyLocker ttyl;
304N/A BytecodeCounter::print();
0N/A }
304N/A#endif
304N/A // To see where a verify_oop failed, get $ebx+40/X for this frame.
304N/A // XXX correct this offset for amd64
304N/A // This is the value of eip which points to where verify_oop will return.
304N/A if (os::message_box(msg, "Execution stopped, print registers?")) {
3932N/A print_state64(pc, regs);
304N/A BREAKPOINT;
3932N/A assert(false, "start up GDB");
0N/A }
304N/A ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
304N/A } else {
304N/A ttyLocker ttyl;
304N/A ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n",
304N/A msg);
2578N/A assert(false, err_msg("DEBUG MESSAGE: %s", msg));
304N/A }
304N/A}
304N/A
3932N/Avoid MacroAssembler::print_state64(int64_t pc, int64_t regs[]) {
3932N/A ttyLocker ttyl;
3932N/A FlagSetting fs(Debugging, true);
3932N/A tty->print_cr("rip = 0x%016lx", pc);
3932N/A#ifndef PRODUCT
3932N/A tty->cr();
3932N/A findpc(pc);
3932N/A tty->cr();
3932N/A#endif
3932N/A#define PRINT_REG(rax, value) \
3932N/A { tty->print("%s = ", #rax); os::print_location(tty, value); }
3932N/A PRINT_REG(rax, regs[15]);
3932N/A PRINT_REG(rbx, regs[12]);
3932N/A PRINT_REG(rcx, regs[14]);
3932N/A PRINT_REG(rdx, regs[13]);
3932N/A PRINT_REG(rdi, regs[8]);
3932N/A PRINT_REG(rsi, regs[9]);
3932N/A PRINT_REG(rbp, regs[10]);
3932N/A PRINT_REG(rsp, regs[11]);
3932N/A PRINT_REG(r8 , regs[7]);
3932N/A PRINT_REG(r9 , regs[6]);
3932N/A PRINT_REG(r10, regs[5]);
3932N/A PRINT_REG(r11, regs[4]);
3932N/A PRINT_REG(r12, regs[3]);
3932N/A PRINT_REG(r13, regs[2]);
3932N/A PRINT_REG(r14, regs[1]);
3932N/A PRINT_REG(r15, regs[0]);
3932N/A#undef PRINT_REG
3932N/A // Print some words near top of staack.
3932N/A int64_t* rsp = (int64_t*) regs[11];
3932N/A int64_t* dump_sp = rsp;
3932N/A for (int col1 = 0; col1 < 8; col1++) {
3932N/A tty->print("(rsp+0x%03x) 0x%016lx: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (int64_t)dump_sp);
3932N/A os::print_location(tty, *dump_sp++);
3932N/A }
3932N/A for (int row = 0; row < 25; row++) {
3932N/A tty->print("(rsp+0x%03x) 0x%016lx: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (int64_t)dump_sp);
3932N/A for (int col = 0; col < 4; col++) {
3932N/A tty->print(" 0x%016lx", *dump_sp++);
3932N/A }
3932N/A tty->cr();
3932N/A }
3932N/A // Print some instructions around pc:
3932N/A Disassembler::decode((address)pc-64, (address)pc);
3932N/A tty->print_cr("--------");
3932N/A Disassembler::decode((address)pc, (address)pc+32);
3932N/A}
3932N/A
304N/A#endif // _LP64
304N/A
304N/A// Now versions that are common to 32/64 bit
304N/A
304N/Avoid MacroAssembler::addptr(Register dst, int32_t imm32) {
304N/A LP64_ONLY(addq(dst, imm32)) NOT_LP64(addl(dst, imm32));
304N/A}
304N/A
304N/Avoid MacroAssembler::addptr(Register dst, Register src) {
304N/A LP64_ONLY(addq(dst, src)) NOT_LP64(addl(dst, src));
304N/A}
304N/A
304N/Avoid MacroAssembler::addptr(Address dst, Register src) {
304N/A LP64_ONLY(addq(dst, src)) NOT_LP64(addl(dst, src));
304N/A}
304N/A
3039N/Avoid MacroAssembler::addsd(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::addsd(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::addsd(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::addss(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A addss(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A addss(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
304N/Avoid MacroAssembler::align(int modulus) {
304N/A if (offset() % modulus != 0) {
304N/A nop(modulus - (offset() % modulus));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::andpd(XMMRegister dst, AddressLiteral src) {
3039N/A // Used in sign-masking with aligned address.
3039N/A assert((UseAVX > 0) || (((intptr_t)src.target() & 15) == 0), "SSE mode requires address alignment 16 bytes");
1060N/A if (reachable(src)) {
3039N/A Assembler::andpd(dst, as_Address(src));
1060N/A } else {
1060N/A lea(rscratch1, src);
3039N/A Assembler::andpd(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::andps(XMMRegister dst, AddressLiteral src) {
3039N/A // Used in sign-masking with aligned address.
3039N/A assert((UseAVX > 0) || (((intptr_t)src.target() & 15) == 0), "SSE mode requires address alignment 16 bytes");
3039N/A if (reachable(src)) {
3039N/A Assembler::andps(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::andps(dst, Address(rscratch1, 0));
1060N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::andptr(Register dst, int32_t imm32) {
304N/A LP64_ONLY(andq(dst, imm32)) NOT_LP64(andl(dst, imm32));
304N/A}
304N/A
304N/Avoid MacroAssembler::atomic_incl(AddressLiteral counter_addr) {
304N/A pushf();
304N/A if (os::is_MP())
304N/A lock();
304N/A incrementl(counter_addr);
304N/A popf();
304N/A}
304N/A
304N/A// Writes to stack successive pages until offset reached to check for
304N/A// stack overflow + shadow pages. This clobbers tmp.
304N/Avoid MacroAssembler::bang_stack_size(Register size, Register tmp) {
304N/A movptr(tmp, rsp);
304N/A // Bang stack for total size given plus shadow page size.
304N/A // Bang one page at a time because large size can bang beyond yellow and
304N/A // red zones.
304N/A Label loop;
304N/A bind(loop);
304N/A movl(Address(tmp, (-os::vm_page_size())), size );
304N/A subptr(tmp, os::vm_page_size());
304N/A subl(size, os::vm_page_size());
304N/A jcc(Assembler::greater, loop);
304N/A
304N/A // Bang down shadow pages too.
304N/A // The -1 because we already subtracted 1 page.
304N/A for (int i = 0; i< StackShadowPages-1; i++) {
304N/A // this could be any sized move but this is can be a debugging crumb
304N/A // so the bigger the better.
304N/A movptr(Address(tmp, (-i*os::vm_page_size())), size );
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::biased_locking_exit(Register obj_reg, Register temp_reg, Label& done) {
304N/A assert(UseBiasedLocking, "why call this otherwise?");
304N/A
304N/A // Check for biased locking unlock case, which is a no-op
304N/A // Note: we do not have to check the thread ID for two reasons.
304N/A // First, the interpreter checks for IllegalMonitorStateException at
304N/A // a higher level. Second, if the bias was revoked while we held the
304N/A // lock, the object could not be rebiased toward another thread, so
304N/A // the bias bit would be clear.
304N/A movptr(temp_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
304N/A andptr(temp_reg, markOopDesc::biased_lock_mask_in_place);
304N/A cmpptr(temp_reg, markOopDesc::biased_lock_pattern);
304N/A jcc(Assembler::equal, done);
304N/A}
304N/A
304N/Avoid MacroAssembler::c2bool(Register x) {
304N/A // implements x == 0 ? 0 : 1
304N/A // note: must only look at least-significant byte of x
304N/A // since C-style booleans are stored in one byte
304N/A // only! (was bug)
304N/A andl(x, 0xFF);
304N/A setb(Assembler::notZero, x);
304N/A}
304N/A
304N/A// Wouldn't need if AddressLiteral version had new name
304N/Avoid MacroAssembler::call(Label& L, relocInfo::relocType rtype) {
304N/A Assembler::call(L, rtype);
304N/A}
304N/A
304N/Avoid MacroAssembler::call(Register entry) {
304N/A Assembler::call(entry);
304N/A}
304N/A
304N/Avoid MacroAssembler::call(AddressLiteral entry) {
304N/A if (reachable(entry)) {
304N/A Assembler::call_literal(entry.target(), entry.rspec());
304N/A } else {
304N/A lea(rscratch1, entry);
304N/A Assembler::call(rscratch1);
304N/A }
304N/A}
304N/A
304N/A// Implementation of call_VM versions
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A address entry_point,
304N/A bool check_exceptions) {
304N/A Label C, E;
304N/A call(C, relocInfo::none);
304N/A jmp(E);
304N/A
304N/A bind(C);
304N/A call_VM_helper(oop_result, entry_point, 0, check_exceptions);
304N/A ret(0);
304N/A
304N/A bind(E);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A address entry_point,
304N/A Register arg_1,
304N/A bool check_exceptions) {
304N/A Label C, E;
304N/A call(C, relocInfo::none);
304N/A jmp(E);
304N/A
304N/A bind(C);
304N/A pass_arg1(this, arg_1);
304N/A call_VM_helper(oop_result, entry_point, 1, check_exceptions);
304N/A ret(0);
304N/A
304N/A bind(E);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A address entry_point,
304N/A Register arg_1,
304N/A Register arg_2,
304N/A bool check_exceptions) {
304N/A Label C, E;
304N/A call(C, relocInfo::none);
304N/A jmp(E);
304N/A
304N/A bind(C);
304N/A
304N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
304N/A
304N/A pass_arg2(this, arg_2);
304N/A pass_arg1(this, arg_1);
304N/A call_VM_helper(oop_result, entry_point, 2, check_exceptions);
304N/A ret(0);
304N/A
304N/A bind(E);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A address entry_point,
304N/A Register arg_1,
304N/A Register arg_2,
304N/A Register arg_3,
304N/A bool check_exceptions) {
304N/A Label C, E;
304N/A call(C, relocInfo::none);
304N/A jmp(E);
304N/A
304N/A bind(C);
304N/A
304N/A LP64_ONLY(assert(arg_1 != c_rarg3, "smashed arg"));
304N/A LP64_ONLY(assert(arg_2 != c_rarg3, "smashed arg"));
304N/A pass_arg3(this, arg_3);
304N/A
304N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
304N/A pass_arg2(this, arg_2);
304N/A
304N/A pass_arg1(this, arg_1);
304N/A call_VM_helper(oop_result, entry_point, 3, check_exceptions);
304N/A ret(0);
304N/A
304N/A bind(E);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A Register last_java_sp,
304N/A address entry_point,
304N/A int number_of_arguments,
304N/A bool check_exceptions) {
304N/A Register thread = LP64_ONLY(r15_thread) NOT_LP64(noreg);
304N/A call_VM_base(oop_result, thread, last_java_sp, entry_point, number_of_arguments, check_exceptions);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A Register last_java_sp,
304N/A address entry_point,
304N/A Register arg_1,
304N/A bool check_exceptions) {
304N/A pass_arg1(this, arg_1);
304N/A call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A Register last_java_sp,
304N/A address entry_point,
304N/A Register arg_1,
304N/A Register arg_2,
304N/A bool check_exceptions) {
304N/A
304N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
304N/A pass_arg2(this, arg_2);
304N/A pass_arg1(this, arg_1);
304N/A call_VM(oop_result, last_java_sp, entry_point, 2, check_exceptions);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM(Register oop_result,
304N/A Register last_java_sp,
304N/A address entry_point,
304N/A Register arg_1,
304N/A Register arg_2,
304N/A Register arg_3,
304N/A bool check_exceptions) {
304N/A LP64_ONLY(assert(arg_1 != c_rarg3, "smashed arg"));
304N/A LP64_ONLY(assert(arg_2 != c_rarg3, "smashed arg"));
304N/A pass_arg3(this, arg_3);
304N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
304N/A pass_arg2(this, arg_2);
304N/A pass_arg1(this, arg_1);
304N/A call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
304N/A}
304N/A
2580N/Avoid MacroAssembler::super_call_VM(Register oop_result,
2580N/A Register last_java_sp,
2580N/A address entry_point,
2580N/A int number_of_arguments,
2580N/A bool check_exceptions) {
2580N/A Register thread = LP64_ONLY(r15_thread) NOT_LP64(noreg);
2580N/A MacroAssembler::call_VM_base(oop_result, thread, last_java_sp, entry_point, number_of_arguments, check_exceptions);
2580N/A}
2580N/A
2580N/Avoid MacroAssembler::super_call_VM(Register oop_result,
2580N/A Register last_java_sp,
2580N/A address entry_point,
2580N/A Register arg_1,
2580N/A bool check_exceptions) {
2580N/A pass_arg1(this, arg_1);
2580N/A super_call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
2580N/A}
2580N/A
2580N/Avoid MacroAssembler::super_call_VM(Register oop_result,
2580N/A Register last_java_sp,
2580N/A address entry_point,
2580N/A Register arg_1,
2580N/A Register arg_2,
2580N/A bool check_exceptions) {
2580N/A
2580N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
2580N/A pass_arg2(this, arg_2);
2580N/A pass_arg1(this, arg_1);
2580N/A super_call_VM(oop_result, last_java_sp, entry_point, 2, check_exceptions);
2580N/A}
2580N/A
2580N/Avoid MacroAssembler::super_call_VM(Register oop_result,
2580N/A Register last_java_sp,
2580N/A address entry_point,
2580N/A Register arg_1,
2580N/A Register arg_2,
2580N/A Register arg_3,
2580N/A bool check_exceptions) {
2580N/A LP64_ONLY(assert(arg_1 != c_rarg3, "smashed arg"));
2580N/A LP64_ONLY(assert(arg_2 != c_rarg3, "smashed arg"));
2580N/A pass_arg3(this, arg_3);
2580N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
2580N/A pass_arg2(this, arg_2);
2580N/A pass_arg1(this, arg_1);
2580N/A super_call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
2580N/A}
2580N/A
304N/Avoid MacroAssembler::call_VM_base(Register oop_result,
304N/A Register java_thread,
304N/A Register last_java_sp,
304N/A address entry_point,
304N/A int number_of_arguments,
304N/A bool check_exceptions) {
304N/A // determine java_thread register
304N/A if (!java_thread->is_valid()) {
304N/A#ifdef _LP64
304N/A java_thread = r15_thread;
304N/A#else
304N/A java_thread = rdi;
304N/A get_thread(java_thread);
304N/A#endif // LP64
304N/A }
304N/A // determine last_java_sp register
304N/A if (!last_java_sp->is_valid()) {
304N/A last_java_sp = rsp;
304N/A }
304N/A // debugging support
304N/A assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
304N/A LP64_ONLY(assert(java_thread == r15_thread, "unexpected register"));
1883N/A#ifdef ASSERT
2990N/A // TraceBytecodes does not use r12 but saves it over the call, so don't verify
2990N/A // r12 is the heapbase.
2990N/A LP64_ONLY(if (UseCompressedOops && !TraceBytecodes) verify_heapbase("call_VM_base");)
1883N/A#endif // ASSERT
1883N/A
304N/A assert(java_thread != oop_result , "cannot use the same register for java_thread & oop_result");
304N/A assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp");
304N/A
304N/A // push java thread (becomes first argument of C function)
304N/A
304N/A NOT_LP64(push(java_thread); number_of_arguments++);
304N/A LP64_ONLY(mov(c_rarg0, r15_thread));
304N/A
304N/A // set last Java frame before call
304N/A assert(last_java_sp != rbp, "can't use ebp/rbp");
304N/A
304N/A // Only interpreter should have to set fp
304N/A set_last_Java_frame(java_thread, last_java_sp, rbp, NULL);
304N/A
304N/A // do the call, remove parameters
304N/A MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments);
304N/A
304N/A // restore the thread (cannot use the pushed argument since arguments
304N/A // may be overwritten by C code generated by an optimizing compiler);
304N/A // however can use the register value directly if it is callee saved.
304N/A if (LP64_ONLY(true ||) java_thread == rdi || java_thread == rsi) {
304N/A // rdi & rsi (also r15) are callee saved -> nothing to do
304N/A#ifdef ASSERT
304N/A guarantee(java_thread != rax, "change this code");
304N/A push(rax);
304N/A { Label L;
304N/A get_thread(rax);
304N/A cmpptr(java_thread, rax);
304N/A jcc(Assembler::equal, L);
3932N/A STOP("MacroAssembler::call_VM_base: rdi not callee saved?");
304N/A bind(L);
0N/A }
304N/A pop(rax);
304N/A#endif
304N/A } else {
304N/A get_thread(java_thread);
304N/A }
304N/A // reset last Java frame
304N/A // Only interpreter should have to clear fp
304N/A reset_last_Java_frame(java_thread, true, false);
304N/A
304N/A#ifndef CC_INTERP
304N/A // C++ interp handles this in the interpreter
304N/A check_and_handle_popframe(java_thread);
304N/A check_and_handle_earlyret(java_thread);
304N/A#endif /* CC_INTERP */
304N/A
304N/A if (check_exceptions) {
304N/A // check for pending exceptions (java_thread is set upon return)
304N/A cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD);
304N/A#ifndef _LP64
304N/A jump_cc(Assembler::notEqual,
304N/A RuntimeAddress(StubRoutines::forward_exception_entry()));
304N/A#else
304N/A // This used to conditionally jump to forward_exception however it is
304N/A // possible if we relocate that the branch will not reach. So we must jump
304N/A // around so we can always reach
304N/A
304N/A Label ok;
304N/A jcc(Assembler::equal, ok);
304N/A jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
304N/A bind(ok);
304N/A#endif // LP64
304N/A }
304N/A
304N/A // get oop result if there is one and reset the value in the thread
304N/A if (oop_result->is_valid()) {
304N/A movptr(oop_result, Address(java_thread, JavaThread::vm_result_offset()));
512N/A movptr(Address(java_thread, JavaThread::vm_result_offset()), NULL_WORD);
304N/A verify_oop(oop_result, "broken oop in call_VM_base");
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
304N/A
304N/A // Calculate the value for last_Java_sp
304N/A // somewhat subtle. call_VM does an intermediate call
304N/A // which places a return address on the stack just under the
304N/A // stack pointer as the user finsihed with it. This allows
304N/A // use to retrieve last_Java_pc from last_Java_sp[-1].
304N/A // On 32bit we then have to push additional args on the stack to accomplish
304N/A // the actual requested call. On 64bit call_VM only can use register args
304N/A // so the only extra space is the return address that call_VM created.
304N/A // This hopefully explains the calculations here.
304N/A
304N/A#ifdef _LP64
304N/A // We've pushed one address, correct last_Java_sp
304N/A lea(rax, Address(rsp, wordSize));
304N/A#else
304N/A lea(rax, Address(rsp, (1 + number_of_arguments) * wordSize));
304N/A#endif // LP64
304N/A
304N/A call_VM_base(oop_result, noreg, rax, entry_point, number_of_arguments, check_exceptions);
304N/A
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM_leaf(address entry_point, int number_of_arguments) {
304N/A call_VM_leaf_base(entry_point, number_of_arguments);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM_leaf(address entry_point, Register arg_0) {
304N/A pass_arg0(this, arg_0);
304N/A call_VM_leaf(entry_point, 1);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM_leaf(address entry_point, Register arg_0, Register arg_1) {
304N/A
304N/A LP64_ONLY(assert(arg_0 != c_rarg1, "smashed arg"));
304N/A pass_arg1(this, arg_1);
304N/A pass_arg0(this, arg_0);
304N/A call_VM_leaf(entry_point, 2);
304N/A}
304N/A
304N/Avoid MacroAssembler::call_VM_leaf(address entry_point, Register arg_0, Register arg_1, Register arg_2) {
304N/A LP64_ONLY(assert(arg_0 != c_rarg2, "smashed arg"));
304N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
304N/A pass_arg2(this, arg_2);
304N/A LP64_ONLY(assert(arg_0 != c_rarg1, "smashed arg"));
304N/A pass_arg1(this, arg_1);
304N/A pass_arg0(this, arg_0);
304N/A call_VM_leaf(entry_point, 3);
304N/A}
304N/A
2433N/Avoid MacroAssembler::super_call_VM_leaf(address entry_point, Register arg_0) {
2433N/A pass_arg0(this, arg_0);
2433N/A MacroAssembler::call_VM_leaf_base(entry_point, 1);
2433N/A}
2433N/A
2433N/Avoid MacroAssembler::super_call_VM_leaf(address entry_point, Register arg_0, Register arg_1) {
2433N/A
2433N/A LP64_ONLY(assert(arg_0 != c_rarg1, "smashed arg"));
2433N/A pass_arg1(this, arg_1);
2433N/A pass_arg0(this, arg_0);
2433N/A MacroAssembler::call_VM_leaf_base(entry_point, 2);
2433N/A}
2433N/A
2433N/Avoid MacroAssembler::super_call_VM_leaf(address entry_point, Register arg_0, Register arg_1, Register arg_2) {
2433N/A LP64_ONLY(assert(arg_0 != c_rarg2, "smashed arg"));
2433N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
2433N/A pass_arg2(this, arg_2);
2433N/A LP64_ONLY(assert(arg_0 != c_rarg1, "smashed arg"));
2433N/A pass_arg1(this, arg_1);
2433N/A pass_arg0(this, arg_0);
2433N/A MacroAssembler::call_VM_leaf_base(entry_point, 3);
2433N/A}
2433N/A
2433N/Avoid MacroAssembler::super_call_VM_leaf(address entry_point, Register arg_0, Register arg_1, Register arg_2, Register arg_3) {
2433N/A LP64_ONLY(assert(arg_0 != c_rarg3, "smashed arg"));
2433N/A LP64_ONLY(assert(arg_1 != c_rarg3, "smashed arg"));
2433N/A LP64_ONLY(assert(arg_2 != c_rarg3, "smashed arg"));
2433N/A pass_arg3(this, arg_3);
2433N/A LP64_ONLY(assert(arg_0 != c_rarg2, "smashed arg"));
2433N/A LP64_ONLY(assert(arg_1 != c_rarg2, "smashed arg"));
2433N/A pass_arg2(this, arg_2);
2433N/A LP64_ONLY(assert(arg_0 != c_rarg1, "smashed arg"));
2433N/A pass_arg1(this, arg_1);
2433N/A pass_arg0(this, arg_0);
2433N/A MacroAssembler::call_VM_leaf_base(entry_point, 4);
2433N/A}
2433N/A
304N/Avoid MacroAssembler::check_and_handle_earlyret(Register java_thread) {
304N/A}
304N/A
304N/Avoid MacroAssembler::check_and_handle_popframe(Register java_thread) {
304N/A}
304N/A
304N/Avoid MacroAssembler::cmp32(AddressLiteral src1, int32_t imm) {
304N/A if (reachable(src1)) {
304N/A cmpl(as_Address(src1), imm);
304N/A } else {
304N/A lea(rscratch1, src1);
304N/A cmpl(Address(rscratch1, 0), imm);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::cmp32(Register src1, AddressLiteral src2) {
304N/A assert(!src2.is_lval(), "use cmpptr");
304N/A if (reachable(src2)) {
304N/A cmpl(src1, as_Address(src2));
304N/A } else {
304N/A lea(rscratch1, src2);
304N/A cmpl(src1, Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::cmp32(Register src1, int32_t imm) {
304N/A Assembler::cmpl(src1, imm);
304N/A}
304N/A
304N/Avoid MacroAssembler::cmp32(Register src1, Address src2) {
304N/A Assembler::cmpl(src1, src2);
304N/A}
304N/A
304N/Avoid MacroAssembler::cmpsd2int(XMMRegister opr1, XMMRegister opr2, Register dst, bool unordered_is_less) {
304N/A ucomisd(opr1, opr2);
304N/A
304N/A Label L;
304N/A if (unordered_is_less) {
304N/A movl(dst, -1);
304N/A jcc(Assembler::parity, L);
304N/A jcc(Assembler::below , L);
304N/A movl(dst, 0);
304N/A jcc(Assembler::equal , L);
304N/A increment(dst);
304N/A } else { // unordered is greater
304N/A movl(dst, 1);
304N/A jcc(Assembler::parity, L);
304N/A jcc(Assembler::above , L);
304N/A movl(dst, 0);
304N/A jcc(Assembler::equal , L);
304N/A decrementl(dst);
304N/A }
304N/A bind(L);
304N/A}
304N/A
304N/Avoid MacroAssembler::cmpss2int(XMMRegister opr1, XMMRegister opr2, Register dst, bool unordered_is_less) {
304N/A ucomiss(opr1, opr2);
304N/A
304N/A Label L;
304N/A if (unordered_is_less) {
304N/A movl(dst, -1);
304N/A jcc(Assembler::parity, L);
304N/A jcc(Assembler::below , L);
304N/A movl(dst, 0);
304N/A jcc(Assembler::equal , L);
304N/A increment(dst);
304N/A } else { // unordered is greater
304N/A movl(dst, 1);
304N/A jcc(Assembler::parity, L);
304N/A jcc(Assembler::above , L);
304N/A movl(dst, 0);
304N/A jcc(Assembler::equal , L);
304N/A decrementl(dst);
304N/A }
304N/A bind(L);
304N/A}
304N/A
304N/A
304N/Avoid MacroAssembler::cmp8(AddressLiteral src1, int imm) {
304N/A if (reachable(src1)) {
304N/A cmpb(as_Address(src1), imm);
304N/A } else {
304N/A lea(rscratch1, src1);
304N/A cmpb(Address(rscratch1, 0), imm);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::cmpptr(Register src1, AddressLiteral src2) {
304N/A#ifdef _LP64
304N/A if (src2.is_lval()) {
304N/A movptr(rscratch1, src2);
304N/A Assembler::cmpq(src1, rscratch1);
304N/A } else if (reachable(src2)) {
304N/A cmpq(src1, as_Address(src2));
304N/A } else {
304N/A lea(rscratch1, src2);
304N/A Assembler::cmpq(src1, Address(rscratch1, 0));
304N/A }
304N/A#else
304N/A if (src2.is_lval()) {
304N/A cmp_literal32(src1, (int32_t) src2.target(), src2.rspec());
304N/A } else {
304N/A cmpl(src1, as_Address(src2));
304N/A }
304N/A#endif // _LP64
304N/A}
304N/A
304N/Avoid MacroAssembler::cmpptr(Address src1, AddressLiteral src2) {
304N/A assert(src2.is_lval(), "not a mem-mem compare");
304N/A#ifdef _LP64
304N/A // moves src2's literal address
304N/A movptr(rscratch1, src2);
304N/A Assembler::cmpq(src1, rscratch1);
304N/A#else
304N/A cmp_literal32(src1, (int32_t) src2.target(), src2.rspec());
304N/A#endif // _LP64
304N/A}
304N/A
304N/Avoid MacroAssembler::locked_cmpxchgptr(Register reg, AddressLiteral adr) {
304N/A if (reachable(adr)) {
304N/A if (os::is_MP())
304N/A lock();
304N/A cmpxchgptr(reg, as_Address(adr));
304N/A } else {
304N/A lea(rscratch1, adr);
304N/A if (os::is_MP())
304N/A lock();
304N/A cmpxchgptr(reg, Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::cmpxchgptr(Register reg, Address adr) {
304N/A LP64_ONLY(cmpxchgq(reg, adr)) NOT_LP64(cmpxchgl(reg, adr));
304N/A}
304N/A
304N/Avoid MacroAssembler::comisd(XMMRegister dst, AddressLiteral src) {
1060N/A if (reachable(src)) {
3039N/A Assembler::comisd(dst, as_Address(src));
1060N/A } else {
1060N/A lea(rscratch1, src);
3039N/A Assembler::comisd(dst, Address(rscratch1, 0));
1060N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::comiss(XMMRegister dst, AddressLiteral src) {
1060N/A if (reachable(src)) {
3039N/A Assembler::comiss(dst, as_Address(src));
1060N/A } else {
1060N/A lea(rscratch1, src);
3039N/A Assembler::comiss(dst, Address(rscratch1, 0));
1060N/A }
304N/A}
304N/A
304N/A
304N/Avoid MacroAssembler::cond_inc32(Condition cond, AddressLiteral counter_addr) {
304N/A Condition negated_cond = negate_condition(cond);
304N/A Label L;
304N/A jcc(negated_cond, L);
304N/A atomic_incl(counter_addr);
304N/A bind(L);
304N/A}
304N/A
304N/Aint MacroAssembler::corrected_idivl(Register reg) {
304N/A // Full implementation of Java idiv and irem; checks for
304N/A // special case as described in JVM spec., p.243 & p.271.
304N/A // The function returns the (pc) offset of the idivl
304N/A // instruction - may be needed for implicit exceptions.
304N/A //
304N/A // normal case special case
304N/A //
304N/A // input : rax,: dividend min_int
304N/A // reg: divisor (may not be rax,/rdx) -1
304N/A //
304N/A // output: rax,: quotient (= rax, idiv reg) min_int
304N/A // rdx: remainder (= rax, irem reg) 0
304N/A assert(reg != rax && reg != rdx, "reg cannot be rax, or rdx register");
304N/A const int min_int = 0x80000000;
304N/A Label normal_case, special_case;
304N/A
304N/A // check for special case
304N/A cmpl(rax, min_int);
304N/A jcc(Assembler::notEqual, normal_case);
304N/A xorl(rdx, rdx); // prepare rdx for possible special case (where remainder = 0)
304N/A cmpl(reg, -1);
304N/A jcc(Assembler::equal, special_case);
304N/A
304N/A // handle normal case
304N/A bind(normal_case);
304N/A cdql();
304N/A int idivl_offset = offset();
304N/A idivl(reg);
304N/A
304N/A // normal and special case exit
304N/A bind(special_case);
304N/A
304N/A return idivl_offset;
304N/A}
304N/A
304N/A
304N/A
304N/Avoid MacroAssembler::decrementl(Register reg, int value) {
304N/A if (value == min_jint) {subl(reg, value) ; return; }
304N/A if (value < 0) { incrementl(reg, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { decl(reg) ; return; }
304N/A /* else */ { subl(reg, value) ; return; }
304N/A}
304N/A
304N/Avoid MacroAssembler::decrementl(Address dst, int value) {
304N/A if (value == min_jint) {subl(dst, value) ; return; }
304N/A if (value < 0) { incrementl(dst, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { decl(dst) ; return; }
304N/A /* else */ { subl(dst, value) ; return; }
304N/A}
304N/A
304N/Avoid MacroAssembler::division_with_shift (Register reg, int shift_value) {
304N/A assert (shift_value > 0, "illegal shift value");
304N/A Label _is_positive;
304N/A testl (reg, reg);
304N/A jcc (Assembler::positive, _is_positive);
304N/A int offset = (1 << shift_value) - 1 ;
304N/A
304N/A if (offset == 1) {
304N/A incrementl(reg);
304N/A } else {
304N/A addl(reg, offset);
304N/A }
304N/A
304N/A bind (_is_positive);
304N/A sarl(reg, shift_value);
304N/A}
304N/A
3039N/Avoid MacroAssembler::divsd(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::divsd(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::divsd(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::divss(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::divss(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::divss(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
304N/A// !defined(COMPILER2) is because of stupid core builds
304N/A#if !defined(_LP64) || defined(COMPILER1) || !defined(COMPILER2)
304N/Avoid MacroAssembler::empty_FPU_stack() {
304N/A if (VM_Version::supports_mmx()) {
304N/A emms();
304N/A } else {
304N/A for (int i = 8; i-- > 0; ) ffree(i);
304N/A }
304N/A}
304N/A#endif // !LP64 || C1 || !C2
304N/A
304N/A
304N/A// Defines obj, preserves var_size_in_bytes
304N/Avoid MacroAssembler::eden_allocate(Register obj,
304N/A Register var_size_in_bytes,
304N/A int con_size_in_bytes,
304N/A Register t1,
304N/A Label& slow_case) {
304N/A assert(obj == rax, "obj must be in rax, for cmpxchg");
304N/A assert_different_registers(obj, var_size_in_bytes, t1);
362N/A if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
362N/A jmp(slow_case);
304N/A } else {
362N/A Register end = t1;
362N/A Label retry;
362N/A bind(retry);
362N/A ExternalAddress heap_top((address) Universe::heap()->top_addr());
362N/A movptr(obj, heap_top);
362N/A if (var_size_in_bytes == noreg) {
362N/A lea(end, Address(obj, con_size_in_bytes));
362N/A } else {
362N/A lea(end, Address(obj, var_size_in_bytes, Address::times_1));
362N/A }
362N/A // if end < obj then we wrapped around => object too long => slow case
362N/A cmpptr(end, obj);
362N/A jcc(Assembler::below, slow_case);
362N/A cmpptr(end, ExternalAddress((address) Universe::heap()->end_addr()));
362N/A jcc(Assembler::above, slow_case);
362N/A // Compare obj with the top addr, and if still equal, store the new top addr in
362N/A // end at the address of the top addr pointer. Sets ZF if was equal, and clears
362N/A // it otherwise. Use lock prefix for atomicity on MPs.
362N/A locked_cmpxchgptr(end, heap_top);
362N/A jcc(Assembler::notEqual, retry);
362N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::enter() {
304N/A push(rbp);
304N/A mov(rbp, rsp);
304N/A}
0N/A
3236N/A// A 5 byte nop that is safe for patching (see patch_verified_entry)
3236N/Avoid MacroAssembler::fat_nop() {
3236N/A if (UseAddressNop) {
3236N/A addr_nop_5();
3236N/A } else {
3236N/A emit_byte(0x26); // es:
3236N/A emit_byte(0x2e); // cs:
3236N/A emit_byte(0x64); // fs:
3236N/A emit_byte(0x65); // gs:
3236N/A emit_byte(0x90);
3236N/A }
3236N/A}
3236N/A
0N/Avoid MacroAssembler::fcmp(Register tmp) {
0N/A fcmp(tmp, 1, true, true);
0N/A}
0N/A
0N/Avoid MacroAssembler::fcmp(Register tmp, int index, bool pop_left, bool pop_right) {
0N/A assert(!pop_right || pop_left, "usage error");
0N/A if (VM_Version::supports_cmov()) {
0N/A assert(tmp == noreg, "unneeded temp");
0N/A if (pop_left) {
0N/A fucomip(index);
0N/A } else {
0N/A fucomi(index);
0N/A }
0N/A if (pop_right) {
0N/A fpop();
0N/A }
0N/A } else {
0N/A assert(tmp != noreg, "need temp");
0N/A if (pop_left) {
0N/A if (pop_right) {
0N/A fcompp();
0N/A } else {
0N/A fcomp(index);
0N/A }
0N/A } else {
0N/A fcom(index);
0N/A }
0N/A // convert FPU condition into eflags condition via rax,
0N/A save_rax(tmp);
0N/A fwait(); fnstsw_ax();
0N/A sahf();
0N/A restore_rax(tmp);
0N/A }
0N/A // condition codes set as follows:
0N/A //
0N/A // CF (corresponds to C0) if x < y
0N/A // PF (corresponds to C2) if unordered
0N/A // ZF (corresponds to C3) if x = y
0N/A}
0N/A
0N/Avoid MacroAssembler::fcmp2int(Register dst, bool unordered_is_less) {
0N/A fcmp2int(dst, unordered_is_less, 1, true, true);
0N/A}
0N/A
0N/Avoid MacroAssembler::fcmp2int(Register dst, bool unordered_is_less, int index, bool pop_left, bool pop_right) {
0N/A fcmp(VM_Version::supports_cmov() ? noreg : dst, index, pop_left, pop_right);
0N/A Label L;
0N/A if (unordered_is_less) {
0N/A movl(dst, -1);
0N/A jcc(Assembler::parity, L);
0N/A jcc(Assembler::below , L);
0N/A movl(dst, 0);
0N/A jcc(Assembler::equal , L);
0N/A increment(dst);
0N/A } else { // unordered is greater
0N/A movl(dst, 1);
0N/A jcc(Assembler::parity, L);
0N/A jcc(Assembler::above , L);
0N/A movl(dst, 0);
0N/A jcc(Assembler::equal , L);
304N/A decrementl(dst);
0N/A }
0N/A bind(L);
0N/A}
0N/A
304N/Avoid MacroAssembler::fld_d(AddressLiteral src) {
304N/A fld_d(as_Address(src));
304N/A}
304N/A
304N/Avoid MacroAssembler::fld_s(AddressLiteral src) {
304N/A fld_s(as_Address(src));
304N/A}
304N/A
304N/Avoid MacroAssembler::fld_x(AddressLiteral src) {
304N/A Assembler::fld_x(as_Address(src));
304N/A}
304N/A
304N/Avoid MacroAssembler::fldcw(AddressLiteral src) {
304N/A Assembler::fldcw(as_Address(src));
304N/A}
0N/A
3752N/Avoid MacroAssembler::pow_exp_core_encoding() {
3752N/A // kills rax, rcx, rdx
3752N/A subptr(rsp,sizeof(jdouble));
3752N/A // computes 2^X. Stack: X ...
3752N/A // f2xm1 computes 2^X-1 but only operates on -1<=X<=1. Get int(X) and
3752N/A // keep it on the thread's stack to compute 2^int(X) later
3752N/A // then compute 2^(X-int(X)) as (2^(X-int(X)-1+1)
3752N/A // final result is obtained with: 2^X = 2^int(X) * 2^(X-int(X))
3752N/A fld_s(0); // Stack: X X ...
3752N/A frndint(); // Stack: int(X) X ...
3752N/A fsuba(1); // Stack: int(X) X-int(X) ...
3752N/A fistp_s(Address(rsp,0)); // move int(X) as integer to thread's stack. Stack: X-int(X) ...
3752N/A f2xm1(); // Stack: 2^(X-int(X))-1 ...
3752N/A fld1(); // Stack: 1 2^(X-int(X))-1 ...
3752N/A faddp(1); // Stack: 2^(X-int(X))
3752N/A // computes 2^(int(X)): add exponent bias (1023) to int(X), then
3752N/A // shift int(X)+1023 to exponent position.
3752N/A // Exponent is limited to 11 bits if int(X)+1023 does not fit in 11
3752N/A // bits, set result to NaN. 0x000 and 0x7FF are reserved exponent
3752N/A // values so detect them and set result to NaN.
3752N/A movl(rax,Address(rsp,0));
3752N/A movl(rcx, -2048); // 11 bit mask and valid NaN binary encoding
3752N/A addl(rax, 1023);
3752N/A movl(rdx,rax);
3752N/A shll(rax,20);
3752N/A // Check that 0 < int(X)+1023 < 2047. Otherwise set rax to NaN.
3752N/A addl(rdx,1);
3752N/A // Check that 1 < int(X)+1023+1 < 2048
3752N/A // in 3 steps:
3752N/A // 1- (int(X)+1023+1)&-2048 == 0 => 0 <= int(X)+1023+1 < 2048
3752N/A // 2- (int(X)+1023+1)&-2048 != 0
3752N/A // 3- (int(X)+1023+1)&-2048 != 1
3752N/A // Do 2- first because addl just updated the flags.
3752N/A cmov32(Assembler::equal,rax,rcx);
3752N/A cmpl(rdx,1);
3752N/A cmov32(Assembler::equal,rax,rcx);
3752N/A testl(rdx,rcx);
3752N/A cmov32(Assembler::notEqual,rax,rcx);
3752N/A movl(Address(rsp,4),rax);
3752N/A movl(Address(rsp,0),0);
3752N/A fmul_d(Address(rsp,0)); // Stack: 2^X ...
3752N/A addptr(rsp,sizeof(jdouble));
3752N/A}
3752N/A
3808N/Avoid MacroAssembler::increase_precision() {
3808N/A subptr(rsp, BytesPerWord);
3808N/A fnstcw(Address(rsp, 0));
3808N/A movl(rax, Address(rsp, 0));
3808N/A orl(rax, 0x300);
3808N/A push(rax);
3808N/A fldcw(Address(rsp, 0));
3808N/A pop(rax);
3808N/A}
3808N/A
3808N/Avoid MacroAssembler::restore_precision() {
3808N/A fldcw(Address(rsp, 0));
3808N/A addptr(rsp, BytesPerWord);
3808N/A}
3808N/A
3752N/Avoid MacroAssembler::fast_pow() {
3752N/A // computes X^Y = 2^(Y * log2(X))
3752N/A // if fast computation is not possible, result is NaN. Requires
3752N/A // fallback from user of this macro.
3808N/A // increase precision for intermediate steps of the computation
3808N/A increase_precision();
3752N/A fyl2x(); // Stack: (Y*log2(X)) ...
3752N/A pow_exp_core_encoding(); // Stack: exp(X) ...
3808N/A restore_precision();
3752N/A}
3752N/A
3752N/Avoid MacroAssembler::fast_exp() {
3752N/A // computes exp(X) = 2^(X * log2(e))
3752N/A // if fast computation is not possible, result is NaN. Requires
3752N/A // fallback from user of this macro.
3808N/A // increase precision for intermediate steps of the computation
3808N/A increase_precision();
3752N/A fldl2e(); // Stack: log2(e) X ...
3752N/A fmulp(1); // Stack: (X*log2(e)) ...
3752N/A pow_exp_core_encoding(); // Stack: exp(X) ...
3808N/A restore_precision();
3752N/A}
3752N/A
3752N/Avoid MacroAssembler::pow_or_exp(bool is_exp, int num_fpu_regs_in_use) {
3752N/A // kills rax, rcx, rdx
3752N/A // pow and exp needs 2 extra registers on the fpu stack.
3752N/A Label slow_case, done;
3752N/A Register tmp = noreg;
3752N/A if (!VM_Version::supports_cmov()) {
3752N/A // fcmp needs a temporary so preserve rdx,
3752N/A tmp = rdx;
3752N/A }
3752N/A Register tmp2 = rax;
3755N/A Register tmp3 = rcx;
3752N/A
3752N/A if (is_exp) {
3752N/A // Stack: X
3752N/A fld_s(0); // duplicate argument for runtime call. Stack: X X
3752N/A fast_exp(); // Stack: exp(X) X
3752N/A fcmp(tmp, 0, false, false); // Stack: exp(X) X
3752N/A // exp(X) not equal to itself: exp(X) is NaN go to slow case.
3752N/A jcc(Assembler::parity, slow_case);
3752N/A // get rid of duplicate argument. Stack: exp(X)
3752N/A if (num_fpu_regs_in_use > 0) {
3752N/A fxch();
3752N/A fpop();
3752N/A } else {
3752N/A ffree(1);
3752N/A }
3752N/A jmp(done);
3752N/A } else {
3752N/A // Stack: X Y
3752N/A Label x_negative, y_odd;
3752N/A
3752N/A fldz(); // Stack: 0 X Y
3752N/A fcmp(tmp, 1, true, false); // Stack: X Y
3752N/A jcc(Assembler::above, x_negative);
3752N/A
3752N/A // X >= 0
3752N/A
3752N/A fld_s(1); // duplicate arguments for runtime call. Stack: Y X Y
3752N/A fld_s(1); // Stack: X Y X Y
3752N/A fast_pow(); // Stack: X^Y X Y
3752N/A fcmp(tmp, 0, false, false); // Stack: X^Y X Y
3752N/A // X^Y not equal to itself: X^Y is NaN go to slow case.
3752N/A jcc(Assembler::parity, slow_case);
3752N/A // get rid of duplicate arguments. Stack: X^Y
3752N/A if (num_fpu_regs_in_use > 0) {
3752N/A fxch(); fpop();
3752N/A fxch(); fpop();
3752N/A } else {
3752N/A ffree(2);
3752N/A ffree(1);
3752N/A }
3752N/A jmp(done);
3752N/A
3752N/A // X <= 0
3752N/A bind(x_negative);
3752N/A
3752N/A fld_s(1); // Stack: Y X Y
3752N/A frndint(); // Stack: int(Y) X Y
3752N/A fcmp(tmp, 2, false, false); // Stack: int(Y) X Y
3752N/A jcc(Assembler::notEqual, slow_case);
3752N/A
3752N/A subptr(rsp, 8);
3752N/A
3752N/A // For X^Y, when X < 0, Y has to be an integer and the final
3752N/A // result depends on whether it's odd or even. We just checked
3752N/A // that int(Y) == Y. We move int(Y) to gp registers as a 64 bit
3752N/A // integer to test its parity. If int(Y) is huge and doesn't fit
3752N/A // in the 64 bit integer range, the integer indefinite value will
3752N/A // end up in the gp registers. Huge numbers are all even, the
3752N/A // integer indefinite number is even so it's fine.
3752N/A
3752N/A#ifdef ASSERT
3752N/A // Let's check we don't end up with an integer indefinite number
3752N/A // when not expected. First test for huge numbers: check whether
3752N/A // int(Y)+1 == int(Y) which is true for very large numbers and
3752N/A // those are all even. A 64 bit integer is guaranteed to not
3752N/A // overflow for numbers where y+1 != y (when precision is set to
3752N/A // double precision).
3752N/A Label y_not_huge;
3752N/A
3752N/A fld1(); // Stack: 1 int(Y) X Y
3752N/A fadd(1); // Stack: 1+int(Y) int(Y) X Y
3752N/A
3752N/A#ifdef _LP64
3752N/A // trip to memory to force the precision down from double extended
3752N/A // precision
3752N/A fstp_d(Address(rsp, 0));
3752N/A fld_d(Address(rsp, 0));
3752N/A#endif
3752N/A
3752N/A fcmp(tmp, 1, true, false); // Stack: int(Y) X Y
3752N/A#endif
3752N/A
3752N/A // move int(Y) as 64 bit integer to thread's stack
3752N/A fistp_d(Address(rsp,0)); // Stack: X Y
3752N/A
3752N/A#ifdef ASSERT
3752N/A jcc(Assembler::notEqual, y_not_huge);
3752N/A
3752N/A // Y is huge so we know it's even. It may not fit in a 64 bit
3752N/A // integer and we don't want the debug code below to see the
3752N/A // integer indefinite value so overwrite int(Y) on the thread's
3752N/A // stack with 0.
3752N/A movl(Address(rsp, 0), 0);
3752N/A movl(Address(rsp, 4), 0);
3752N/A
3752N/A bind(y_not_huge);
3752N/A#endif
3752N/A
3752N/A fld_s(1); // duplicate arguments for runtime call. Stack: Y X Y
3752N/A fld_s(1); // Stack: X Y X Y
3752N/A fabs(); // Stack: abs(X) Y X Y
3752N/A fast_pow(); // Stack: abs(X)^Y X Y
3752N/A fcmp(tmp, 0, false, false); // Stack: abs(X)^Y X Y
3752N/A // abs(X)^Y not equal to itself: abs(X)^Y is NaN go to slow case.
3752N/A
3752N/A pop(tmp2);
3752N/A NOT_LP64(pop(tmp3));
3752N/A jcc(Assembler::parity, slow_case);
3752N/A
3752N/A#ifdef ASSERT
3752N/A // Check that int(Y) is not integer indefinite value (int
3752N/A // overflow). Shouldn't happen because for values that would
3752N/A // overflow, 1+int(Y)==Y which was tested earlier.
3752N/A#ifndef _LP64
3752N/A {
3752N/A Label integer;
3752N/A testl(tmp2, tmp2);
3752N/A jcc(Assembler::notZero, integer);
3752N/A cmpl(tmp3, 0x80000000);
3752N/A jcc(Assembler::notZero, integer);
3932N/A STOP("integer indefinite value shouldn't be seen here");
3752N/A bind(integer);
3752N/A }
3752N/A#else
3752N/A {
3752N/A Label integer;
3755N/A mov(tmp3, tmp2); // preserve tmp2 for parity check below
3755N/A shlq(tmp3, 1);
3752N/A jcc(Assembler::carryClear, integer);
3752N/A jcc(Assembler::notZero, integer);
3932N/A STOP("integer indefinite value shouldn't be seen here");
3752N/A bind(integer);
3752N/A }
3752N/A#endif
3752N/A#endif
3752N/A
3752N/A // get rid of duplicate arguments. Stack: X^Y
3752N/A if (num_fpu_regs_in_use > 0) {
3752N/A fxch(); fpop();
3752N/A fxch(); fpop();
3752N/A } else {
3752N/A ffree(2);
3752N/A ffree(1);
3752N/A }
3752N/A
3752N/A testl(tmp2, 1);
3752N/A jcc(Assembler::zero, done); // X <= 0, Y even: X^Y = abs(X)^Y
3752N/A // X <= 0, Y even: X^Y = -abs(X)^Y
3752N/A
3752N/A fchs(); // Stack: -abs(X)^Y Y
3752N/A jmp(done);
3752N/A }
3752N/A
3752N/A // slow case: runtime call
3752N/A bind(slow_case);
3752N/A
3752N/A fpop(); // pop incorrect result or int(Y)
3752N/A
3752N/A fp_runtime_fallback(is_exp ? CAST_FROM_FN_PTR(address, SharedRuntime::dexp) : CAST_FROM_FN_PTR(address, SharedRuntime::dpow),
3752N/A is_exp ? 1 : 2, num_fpu_regs_in_use);
3752N/A
3752N/A // Come here with result in F-TOS
3752N/A bind(done);
3752N/A}
3752N/A
0N/Avoid MacroAssembler::fpop() {
0N/A ffree();
0N/A fincstp();
0N/A}
0N/A
304N/Avoid MacroAssembler::fremr(Register tmp) {
304N/A save_rax(tmp);
304N/A { Label L;
304N/A bind(L);
304N/A fprem();
304N/A fwait(); fnstsw_ax();
304N/A#ifdef _LP64
304N/A testl(rax, 0x400);
304N/A jcc(Assembler::notEqual, L);
304N/A#else
304N/A sahf();
304N/A jcc(Assembler::parity, L);
304N/A#endif // _LP64
304N/A }
304N/A restore_rax(tmp);
304N/A // Result is in ST0.
304N/A // Note: fxch & fpop to get rid of ST1
304N/A // (otherwise FPU stack could overflow eventually)
304N/A fxch(1);
304N/A fpop();
304N/A}
304N/A
304N/A
304N/Avoid MacroAssembler::incrementl(AddressLiteral dst) {
304N/A if (reachable(dst)) {
304N/A incrementl(as_Address(dst));
0N/A } else {
304N/A lea(rscratch1, dst);
304N/A incrementl(Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::incrementl(ArrayAddress dst) {
304N/A incrementl(as_Address(dst));
304N/A}
304N/A
304N/Avoid MacroAssembler::incrementl(Register reg, int value) {
304N/A if (value == min_jint) {addl(reg, value) ; return; }
304N/A if (value < 0) { decrementl(reg, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { incl(reg) ; return; }
304N/A /* else */ { addl(reg, value) ; return; }
304N/A}
304N/A
304N/Avoid MacroAssembler::incrementl(Address dst, int value) {
304N/A if (value == min_jint) {addl(dst, value) ; return; }
304N/A if (value < 0) { decrementl(dst, -value); return; }
304N/A if (value == 0) { ; return; }
304N/A if (value == 1 && UseIncDec) { incl(dst) ; return; }
304N/A /* else */ { addl(dst, value) ; return; }
304N/A}
304N/A
304N/Avoid MacroAssembler::jump(AddressLiteral dst) {
304N/A if (reachable(dst)) {
304N/A jmp_literal(dst.target(), dst.rspec());
304N/A } else {
304N/A lea(rscratch1, dst);
304N/A jmp(rscratch1);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::jump_cc(Condition cc, AddressLiteral dst) {
304N/A if (reachable(dst)) {
304N/A InstructionMark im(this);
304N/A relocate(dst.reloc());
304N/A const int short_size = 2;
304N/A const int long_size = 6;
304N/A int offs = (intptr_t)dst.target() - ((intptr_t)_code_pos);
304N/A if (dst.reloc() == relocInfo::none && is8bit(offs - short_size)) {
304N/A // 0111 tttn #8-bit disp
304N/A emit_byte(0x70 | cc);
304N/A emit_byte((offs - short_size) & 0xFF);
304N/A } else {
304N/A // 0000 1111 1000 tttn #32-bit disp
304N/A emit_byte(0x0F);
304N/A emit_byte(0x80 | cc);
304N/A emit_long(offs - long_size);
304N/A }
0N/A } else {
304N/A#ifdef ASSERT
304N/A warning("reversing conditional branch");
304N/A#endif /* ASSERT */
304N/A Label skip;
304N/A jccb(reverse[cc], skip);
304N/A lea(rscratch1, dst);
304N/A Assembler::jmp(rscratch1);
304N/A bind(skip);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::ldmxcsr(AddressLiteral src) {
304N/A if (reachable(src)) {
304N/A Assembler::ldmxcsr(as_Address(src));
304N/A } else {
304N/A lea(rscratch1, src);
304N/A Assembler::ldmxcsr(Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Aint MacroAssembler::load_signed_byte(Register dst, Address src) {
304N/A int off;
304N/A if (LP64_ONLY(true ||) VM_Version::is_P6()) {
304N/A off = offset();
304N/A movsbl(dst, src); // movsxb
304N/A } else {
304N/A off = load_unsigned_byte(dst, src);
304N/A shll(dst, 24);
304N/A sarl(dst, 24);
304N/A }
304N/A return off;
304N/A}
304N/A
622N/A// Note: load_signed_short used to be called load_signed_word.
622N/A// Although the 'w' in x86 opcodes refers to the term "word" in the assembler
622N/A// manual, which means 16 bits, that usage is found nowhere in HotSpot code.
622N/A// The term "word" in HotSpot means a 32- or 64-bit machine word.
622N/Aint MacroAssembler::load_signed_short(Register dst, Address src) {
304N/A int off;
304N/A if (LP64_ONLY(true ||) VM_Version::is_P6()) {
304N/A // This is dubious to me since it seems safe to do a signed 16 => 64 bit
304N/A // version but this is what 64bit has always done. This seems to imply
304N/A // that users are only using 32bits worth.
304N/A off = offset();
304N/A movswl(dst, src); // movsxw
304N/A } else {
622N/A off = load_unsigned_short(dst, src);
304N/A shll(dst, 16);
304N/A sarl(dst, 16);
304N/A }
304N/A return off;
304N/A}
304N/A
304N/Aint MacroAssembler::load_unsigned_byte(Register dst, Address src) {
304N/A // According to Intel Doc. AP-526, "Zero-Extension of Short", p.16,
304N/A // and "3.9 Partial Register Penalties", p. 22).
304N/A int off;
304N/A if (LP64_ONLY(true || ) VM_Version::is_P6() || src.uses(dst)) {
304N/A off = offset();
304N/A movzbl(dst, src); // movzxb
304N/A } else {
304N/A xorl(dst, dst);
304N/A off = offset();
304N/A movb(dst, src);
304N/A }
304N/A return off;
304N/A}
304N/A
622N/A// Note: load_unsigned_short used to be called load_unsigned_word.
622N/Aint MacroAssembler::load_unsigned_short(Register dst, Address src) {
304N/A // According to Intel Doc. AP-526, "Zero-Extension of Short", p.16,
304N/A // and "3.9 Partial Register Penalties", p. 22).
304N/A int off;
304N/A if (LP64_ONLY(true ||) VM_Version::is_P6() || src.uses(dst)) {
304N/A off = offset();
304N/A movzwl(dst, src); // movzxw
304N/A } else {
304N/A xorl(dst, dst);
304N/A off = offset();
304N/A movw(dst, src);
304N/A }
304N/A return off;
304N/A}
304N/A
2130N/Avoid MacroAssembler::load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed, Register dst2) {
1423N/A switch (size_in_bytes) {
622N/A#ifndef _LP64
2130N/A case 8:
2130N/A assert(dst2 != noreg, "second dest register required");
2130N/A movl(dst, src);
2130N/A movl(dst2, src.plus_disp(BytesPerInt));
2130N/A break;
622N/A#else
2130N/A case 8: movq(dst, src); break;
622N/A#endif
2130N/A case 4: movl(dst, src); break;
2130N/A case 2: is_signed ? load_signed_short(dst, src) : load_unsigned_short(dst, src); break;
2130N/A case 1: is_signed ? load_signed_byte( dst, src) : load_unsigned_byte( dst, src); break;
2130N/A default: ShouldNotReachHere();
2130N/A }
2130N/A}
2130N/A
2130N/Avoid MacroAssembler::store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2) {
2130N/A switch (size_in_bytes) {
2130N/A#ifndef _LP64
2130N/A case 8:
2130N/A assert(src2 != noreg, "second source register required");
2130N/A movl(dst, src);
2130N/A movl(dst.plus_disp(BytesPerInt), src2);
2130N/A break;
2130N/A#else
2130N/A case 8: movq(dst, src); break;
2130N/A#endif
2130N/A case 4: movl(dst, src); break;
2130N/A case 2: movw(dst, src); break;
2130N/A case 1: movb(dst, src); break;
2130N/A default: ShouldNotReachHere();
622N/A }
622N/A}
622N/A
304N/Avoid MacroAssembler::mov32(AddressLiteral dst, Register src) {
304N/A if (reachable(dst)) {
304N/A movl(as_Address(dst), src);
304N/A } else {
304N/A lea(rscratch1, dst);
304N/A movl(Address(rscratch1, 0), src);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::mov32(Register dst, AddressLiteral src) {
304N/A if (reachable(src)) {
304N/A movl(dst, as_Address(src));
304N/A } else {
304N/A lea(rscratch1, src);
304N/A movl(dst, Address(rscratch1, 0));
304N/A }
0N/A}
0N/A
0N/A// C++ bool manipulation
0N/A
0N/Avoid MacroAssembler::movbool(Register dst, Address src) {
0N/A if(sizeof(bool) == 1)
0N/A movb(dst, src);
0N/A else if(sizeof(bool) == 2)
0N/A movw(dst, src);
0N/A else if(sizeof(bool) == 4)
0N/A movl(dst, src);
0N/A else
0N/A // unsupported
0N/A ShouldNotReachHere();
0N/A}
0N/A
0N/Avoid MacroAssembler::movbool(Address dst, bool boolconst) {
0N/A if(sizeof(bool) == 1)
0N/A movb(dst, (int) boolconst);
0N/A else if(sizeof(bool) == 2)
0N/A movw(dst, (int) boolconst);
0N/A else if(sizeof(bool) == 4)
0N/A movl(dst, (int) boolconst);
0N/A else
0N/A // unsupported
0N/A ShouldNotReachHere();
0N/A}
0N/A
0N/Avoid MacroAssembler::movbool(Address dst, Register src) {
0N/A if(sizeof(bool) == 1)
0N/A movb(dst, src);
0N/A else if(sizeof(bool) == 2)
0N/A movw(dst, src);
0N/A else if(sizeof(bool) == 4)
0N/A movl(dst, src);
0N/A else
0N/A // unsupported
0N/A ShouldNotReachHere();
0N/A}
0N/A
304N/Avoid MacroAssembler::movbyte(ArrayAddress dst, int src) {
304N/A movb(as_Address(dst), src);
304N/A}
304N/A
3891N/Avoid MacroAssembler::movdl(XMMRegister dst, AddressLiteral src) {
3891N/A if (reachable(src)) {
3891N/A movdl(dst, as_Address(src));
3891N/A } else {
3891N/A lea(rscratch1, src);
3891N/A movdl(dst, Address(rscratch1, 0));
3891N/A }
3891N/A}
3891N/A
3891N/Avoid MacroAssembler::movq(XMMRegister dst, AddressLiteral src) {
3891N/A if (reachable(src)) {
3891N/A movq(dst, as_Address(src));
3891N/A } else {
3891N/A lea(rscratch1, src);
3891N/A movq(dst, Address(rscratch1, 0));
3891N/A }
3891N/A}
3891N/A
304N/Avoid MacroAssembler::movdbl(XMMRegister dst, AddressLiteral src) {
304N/A if (reachable(src)) {
304N/A if (UseXmmLoadAndClearUpper) {
304N/A movsd (dst, as_Address(src));
304N/A } else {
304N/A movlpd(dst, as_Address(src));
304N/A }
304N/A } else {
304N/A lea(rscratch1, src);
304N/A if (UseXmmLoadAndClearUpper) {
304N/A movsd (dst, Address(rscratch1, 0));
304N/A } else {
304N/A movlpd(dst, Address(rscratch1, 0));
304N/A }
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::movflt(XMMRegister dst, AddressLiteral src) {
304N/A if (reachable(src)) {
304N/A movss(dst, as_Address(src));
304N/A } else {
304N/A lea(rscratch1, src);
304N/A movss(dst, Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Register dst, Register src) {
304N/A LP64_ONLY(movq(dst, src)) NOT_LP64(movl(dst, src));
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Register dst, Address src) {
304N/A LP64_ONLY(movq(dst, src)) NOT_LP64(movl(dst, src));
304N/A}
304N/A
304N/A// src should NEVER be a real pointer. Use AddressLiteral for true pointers
304N/Avoid MacroAssembler::movptr(Register dst, intptr_t src) {
304N/A LP64_ONLY(mov64(dst, src)) NOT_LP64(movl(dst, src));
304N/A}
304N/A
304N/Avoid MacroAssembler::movptr(Address dst, Register src) {
304N/A LP64_ONLY(movq(dst, src)) NOT_LP64(movl(dst, src));
304N/A}
304N/A
3039N/Avoid MacroAssembler::movsd(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::movsd(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::movsd(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
304N/Avoid MacroAssembler::movss(XMMRegister dst, AddressLiteral src) {
304N/A if (reachable(src)) {
3039N/A Assembler::movss(dst, as_Address(src));
304N/A } else {
304N/A lea(rscratch1, src);
3039N/A Assembler::movss(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::mulsd(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::mulsd(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::mulsd(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::mulss(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::mulss(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::mulss(dst, Address(rscratch1, 0));
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::null_check(Register reg, int offset) {
304N/A if (needs_explicit_null_check(offset)) {
304N/A // provoke OS NULL exception if reg = NULL by
304N/A // accessing M[reg] w/o changing any (non-CC) registers
304N/A // NOTE: cmpl is plenty here to provoke a segv
304N/A cmpptr(rax, Address(reg, 0));
304N/A // Note: should probably use testl(rax, Address(reg, 0));
304N/A // may be shorter code (however, this version of
304N/A // testl needs to be implemented first)
304N/A } else {
304N/A // nothing to do, (later) access of M[reg + offset]
304N/A // will provoke OS NULL exception if reg = NULL
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::os_breakpoint() {
304N/A // instead of directly emitting a breakpoint, call os:breakpoint for better debugability
304N/A // (e.g., MSVC can't call ps() otherwise)
304N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
304N/A}
304N/A
304N/Avoid MacroAssembler::pop_CPU_state() {
304N/A pop_FPU_state();
304N/A pop_IU_state();
304N/A}
304N/A
304N/Avoid MacroAssembler::pop_FPU_state() {
304N/A NOT_LP64(frstor(Address(rsp, 0));)
304N/A LP64_ONLY(fxrstor(Address(rsp, 0));)
304N/A addptr(rsp, FPUStateSizeInWords * wordSize);
304N/A}
304N/A
304N/Avoid MacroAssembler::pop_IU_state() {
304N/A popa();
304N/A LP64_ONLY(addq(rsp, 8));
304N/A popf();
304N/A}
304N/A
304N/A// Save Integer and Float state
304N/A// Warning: Stack must be 16 byte aligned (64bit)
304N/Avoid MacroAssembler::push_CPU_state() {
304N/A push_IU_state();
304N/A push_FPU_state();
304N/A}
304N/A
304N/Avoid MacroAssembler::push_FPU_state() {
304N/A subptr(rsp, FPUStateSizeInWords * wordSize);
304N/A#ifndef _LP64
304N/A fnsave(Address(rsp, 0));
304N/A fwait();
304N/A#else
304N/A fxsave(Address(rsp, 0));
304N/A#endif // LP64
304N/A}
304N/A
304N/Avoid MacroAssembler::push_IU_state() {
304N/A // Push flags first because pusha kills them
304N/A pushf();
304N/A // Make sure rsp stays 16-byte aligned
304N/A LP64_ONLY(subq(rsp, 8));
304N/A pusha();
304N/A}
304N/A
304N/Avoid MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp, bool clear_pc) {
304N/A // determine java_thread register
304N/A if (!java_thread->is_valid()) {
304N/A java_thread = rdi;
304N/A get_thread(java_thread);
304N/A }
304N/A // we must set sp to zero to clear frame
512N/A movptr(Address(java_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
304N/A if (clear_fp) {
512N/A movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
304N/A }
304N/A
304N/A if (clear_pc)
512N/A movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
304N/A
304N/A}
304N/A
304N/Avoid MacroAssembler::restore_rax(Register tmp) {
304N/A if (tmp == noreg) pop(rax);
304N/A else if (tmp != rax) mov(rax, tmp);
304N/A}
304N/A
304N/Avoid MacroAssembler::round_to(Register reg, int modulus) {
304N/A addptr(reg, modulus - 1);
304N/A andptr(reg, -modulus);
304N/A}
304N/A
304N/Avoid MacroAssembler::save_rax(Register tmp) {
304N/A if (tmp == noreg) push(rax);
304N/A else if (tmp != rax) mov(tmp, rax);
304N/A}
304N/A
304N/A// Write serialization page so VM thread can do a pseudo remote membar.
304N/A// We use the current thread pointer to calculate a thread specific
304N/A// offset to write to within the page. This minimizes bus traffic
304N/A// due to cache line collision.
304N/Avoid MacroAssembler::serialize_memory(Register thread, Register tmp) {
304N/A movl(tmp, thread);
304N/A shrl(tmp, os::get_serialize_page_shift_count());
304N/A andl(tmp, (os::vm_page_size() - sizeof(int)));
304N/A
304N/A Address index(noreg, tmp, Address::times_1);
304N/A ExternalAddress page(os::get_memory_serialize_page());
304N/A
606N/A // Size of store must match masking code above
606N/A movl(as_Address(ArrayAddress(page, index)), tmp);
304N/A}
304N/A
304N/A// Calls to C land
304N/A//
304N/A// When entering C land, the rbp, & rsp of the last Java frame have to be recorded
304N/A// in the (thread-local) JavaThread object. When leaving C land, the last Java fp
304N/A// has to be reset to 0. This is required to allow proper stack traversal.
304N/Avoid MacroAssembler::set_last_Java_frame(Register java_thread,
304N/A Register last_java_sp,
304N/A Register last_java_fp,
304N/A address last_java_pc) {
304N/A // determine java_thread register
304N/A if (!java_thread->is_valid()) {
304N/A java_thread = rdi;
304N/A get_thread(java_thread);
304N/A }
304N/A // determine last_java_sp register
304N/A if (!last_java_sp->is_valid()) {
304N/A last_java_sp = rsp;
304N/A }
304N/A
304N/A // last_java_fp is optional
304N/A
304N/A if (last_java_fp->is_valid()) {
304N/A movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), last_java_fp);
304N/A }
304N/A
304N/A // last_java_pc is optional
304N/A
304N/A if (last_java_pc != NULL) {
304N/A lea(Address(java_thread,
304N/A JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset()),
304N/A InternalAddress(last_java_pc));
304N/A
304N/A }
304N/A movptr(Address(java_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
304N/A}
304N/A
304N/Avoid MacroAssembler::shlptr(Register dst, int imm8) {
304N/A LP64_ONLY(shlq(dst, imm8)) NOT_LP64(shll(dst, imm8));
304N/A}
304N/A
304N/Avoid MacroAssembler::shrptr(Register dst, int imm8) {
304N/A LP64_ONLY(shrq(dst, imm8)) NOT_LP64(shrl(dst, imm8));
304N/A}
304N/A
304N/Avoid MacroAssembler::sign_extend_byte(Register reg) {
304N/A if (LP64_ONLY(true ||) (VM_Version::is_P6() && reg->has_byte_register())) {
304N/A movsbl(reg, reg); // movsxb
304N/A } else {
304N/A shll(reg, 24);
304N/A sarl(reg, 24);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::sign_extend_short(Register reg) {
304N/A if (LP64_ONLY(true ||) VM_Version::is_P6()) {
304N/A movswl(reg, reg); // movsxw
304N/A } else {
304N/A shll(reg, 16);
304N/A sarl(reg, 16);
304N/A }
304N/A}
304N/A
2251N/Avoid MacroAssembler::testl(Register dst, AddressLiteral src) {
2251N/A assert(reachable(src), "Address should be reachable");
2251N/A testl(dst, as_Address(src));
2251N/A}
2251N/A
3039N/Avoid MacroAssembler::sqrtsd(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::sqrtsd(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::sqrtsd(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::sqrtss(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::sqrtss(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::sqrtss(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::subsd(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::subsd(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::subsd(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3039N/Avoid MacroAssembler::subss(XMMRegister dst, AddressLiteral src) {
3039N/A if (reachable(src)) {
3039N/A Assembler::subss(dst, as_Address(src));
3039N/A } else {
3039N/A lea(rscratch1, src);
3039N/A Assembler::subss(dst, Address(rscratch1, 0));
3039N/A }
3039N/A}
3039N/A
3041N/Avoid MacroAssembler::ucomisd(XMMRegister dst, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A Assembler::ucomisd(dst, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A Assembler::ucomisd(dst, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::ucomiss(XMMRegister dst, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A Assembler::ucomiss(dst, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A Assembler::ucomiss(dst, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::xorpd(XMMRegister dst, AddressLiteral src) {
3041N/A // Used in sign-bit flipping with aligned address.
3041N/A assert((UseAVX > 0) || (((intptr_t)src.target() & 15) == 0), "SSE mode requires address alignment 16 bytes");
3041N/A if (reachable(src)) {
3041N/A Assembler::xorpd(dst, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A Assembler::xorpd(dst, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::xorps(XMMRegister dst, AddressLiteral src) {
3041N/A // Used in sign-bit flipping with aligned address.
3041N/A assert((UseAVX > 0) || (((intptr_t)src.target() & 15) == 0), "SSE mode requires address alignment 16 bytes");
3041N/A if (reachable(src)) {
3041N/A Assembler::xorps(dst, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A Assembler::xorps(dst, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/A// AVX 3-operands instructions
3041N/A
3041N/Avoid MacroAssembler::vaddsd(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vaddsd(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vaddsd(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vaddss(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vaddss(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vaddss(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vandpd(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vandpd(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vandpd(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vandps(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vandps(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vandps(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vdivsd(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vdivsd(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vdivsd(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vdivss(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vdivss(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vdivss(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vmulsd(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vmulsd(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vmulsd(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vmulss(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vmulss(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vmulss(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vsubsd(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vsubsd(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vsubsd(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vsubss(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vsubss(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vsubss(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vxorpd(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vxorpd(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vxorpd(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/Avoid MacroAssembler::vxorps(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
3041N/A if (reachable(src)) {
3041N/A vxorps(dst, nds, as_Address(src));
3041N/A } else {
3041N/A lea(rscratch1, src);
3041N/A vxorps(dst, nds, Address(rscratch1, 0));
3041N/A }
3041N/A}
3041N/A
3041N/A
362N/A//////////////////////////////////////////////////////////////////////////////////
362N/A#ifndef SERIALGC
362N/A
362N/Avoid MacroAssembler::g1_write_barrier_pre(Register obj,
2346N/A Register pre_val,
362N/A Register thread,
362N/A Register tmp,
2346N/A bool tosca_live,
2346N/A bool expand_call) {
2346N/A
2346N/A // If expand_call is true then we expand the call_VM_leaf macro
2346N/A // directly to skip generating the check by
2346N/A // InterpreterMacroAssembler::call_VM_leaf_base that checks _last_sp.
2346N/A
2346N/A#ifdef _LP64
2346N/A assert(thread == r15_thread, "must be");
2346N/A#endif // _LP64
2346N/A
2346N/A Label done;
2346N/A Label runtime;
2346N/A
2346N/A assert(pre_val != noreg, "check this code");
2346N/A
2346N/A if (obj != noreg) {
2346N/A assert_different_registers(obj, pre_val, tmp);
2346N/A assert(pre_val != rax, "check this code");
2346N/A }
2346N/A
362N/A Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
362N/A PtrQueue::byte_offset_of_active()));
362N/A Address index(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
362N/A PtrQueue::byte_offset_of_index()));
362N/A Address buffer(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
362N/A PtrQueue::byte_offset_of_buf()));
362N/A
362N/A
2346N/A // Is marking active?
362N/A if (in_bytes(PtrQueue::byte_width_of_active()) == 4) {
362N/A cmpl(in_progress, 0);
362N/A } else {
362N/A assert(in_bytes(PtrQueue::byte_width_of_active()) == 1, "Assumption");
362N/A cmpb(in_progress, 0);
362N/A }
362N/A jcc(Assembler::equal, done);
362N/A
2346N/A // Do we need to load the previous value?
2346N/A if (obj != noreg) {
2346N/A load_heap_oop(pre_val, Address(obj, 0));
2346N/A }
2346N/A
2346N/A // Is the previous value null?
2346N/A cmpptr(pre_val, (int32_t) NULL_WORD);
362N/A jcc(Assembler::equal, done);
362N/A
362N/A // Can we store original value in the thread's buffer?
2346N/A // Is index == 0?
2346N/A // (The index field is typed as size_t.)
2346N/A
2346N/A movptr(tmp, index); // tmp := *index_adr
2346N/A cmpptr(tmp, 0); // tmp == 0?
2346N/A jcc(Assembler::equal, runtime); // If yes, goto runtime
2346N/A
2346N/A subptr(tmp, wordSize); // tmp := tmp - wordSize
2346N/A movptr(index, tmp); // *index_adr := tmp
2346N/A addptr(tmp, buffer); // tmp := tmp + *buffer_adr
2346N/A
2346N/A // Record the previous value
2346N/A movptr(Address(tmp, 0), pre_val);
362N/A jmp(done);
2346N/A
362N/A bind(runtime);
362N/A // save the live input values
362N/A if(tosca_live) push(rax);
2346N/A
2346N/A if (obj != noreg && obj != rax)
2346N/A push(obj);
2346N/A
2346N/A if (pre_val != rax)
2346N/A push(pre_val);
2346N/A
2346N/A // Calling the runtime using the regular call_VM_leaf mechanism generates
2346N/A // code (generated by InterpreterMacroAssember::call_VM_leaf_base)
2346N/A // that checks that the *(ebp+frame::interpreter_frame_last_sp) == NULL.
2346N/A //
2346N/A // If we care generating the pre-barrier without a frame (e.g. in the
2346N/A // intrinsified Reference.get() routine) then ebp might be pointing to
2346N/A // the caller frame and so this check will most likely fail at runtime.
2346N/A //
2346N/A // Expanding the call directly bypasses the generation of the check.
2346N/A // So when we do not have have a full interpreter frame on the stack
2346N/A // expand_call should be passed true.
2346N/A
2346N/A NOT_LP64( push(thread); )
2346N/A
2346N/A if (expand_call) {
2346N/A LP64_ONLY( assert(pre_val != c_rarg1, "smashed arg"); )
2346N/A pass_arg1(this, thread);
2346N/A pass_arg0(this, pre_val);
2346N/A MacroAssembler::call_VM_leaf_base(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), 2);
2346N/A } else {
2346N/A call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, thread);
2346N/A }
2346N/A
2346N/A NOT_LP64( pop(thread); )
2346N/A
2346N/A // save the live input values
2346N/A if (pre_val != rax)
2346N/A pop(pre_val);
2346N/A
2346N/A if (obj != noreg && obj != rax)
2346N/A pop(obj);
2346N/A
362N/A if(tosca_live) pop(rax);
2346N/A
362N/A bind(done);
362N/A}
362N/A
362N/Avoid MacroAssembler::g1_write_barrier_post(Register store_addr,
362N/A Register new_val,
362N/A Register thread,
362N/A Register tmp,
362N/A Register tmp2) {
2346N/A#ifdef _LP64
2346N/A assert(thread == r15_thread, "must be");
2346N/A#endif // _LP64
2346N/A
362N/A Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
362N/A PtrQueue::byte_offset_of_index()));
362N/A Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
362N/A PtrQueue::byte_offset_of_buf()));
2346N/A
362N/A BarrierSet* bs = Universe::heap()->barrier_set();
362N/A CardTableModRefBS* ct = (CardTableModRefBS*)bs;
362N/A Label done;
362N/A Label runtime;
362N/A
362N/A // Does store cross heap regions?
362N/A
362N/A movptr(tmp, store_addr);
362N/A xorptr(tmp, new_val);
362N/A shrptr(tmp, HeapRegion::LogOfHRGrainBytes);
362N/A jcc(Assembler::equal, done);
362N/A
362N/A // crosses regions, storing NULL?
362N/A
362N/A cmpptr(new_val, (int32_t) NULL_WORD);
362N/A jcc(Assembler::equal, done);
362N/A
362N/A // storing region crossing non-NULL, is card already dirty?
362N/A
362N/A ExternalAddress cardtable((address) ct->byte_map_base);
362N/A assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
362N/A#ifdef _LP64
362N/A const Register card_addr = tmp;
362N/A
362N/A movq(card_addr, store_addr);
362N/A shrq(card_addr, CardTableModRefBS::card_shift);
362N/A
362N/A lea(tmp2, cardtable);
362N/A
362N/A // get the address of the card
362N/A addq(card_addr, tmp2);
362N/A#else
362N/A const Register card_index = tmp;
362N/A
362N/A movl(card_index, store_addr);
362N/A shrl(card_index, CardTableModRefBS::card_shift);
362N/A
362N/A Address index(noreg, card_index, Address::times_1);
362N/A const Register card_addr = tmp;
362N/A lea(card_addr, as_Address(ArrayAddress(cardtable, index)));
362N/A#endif
362N/A cmpb(Address(card_addr, 0), 0);
362N/A jcc(Assembler::equal, done);
362N/A
362N/A // storing a region crossing, non-NULL oop, card is clean.
362N/A // dirty card and log.
362N/A
362N/A movb(Address(card_addr, 0), 0);
362N/A
362N/A cmpl(queue_index, 0);
362N/A jcc(Assembler::equal, runtime);
362N/A subl(queue_index, wordSize);
362N/A movptr(tmp2, buffer);
362N/A#ifdef _LP64
362N/A movslq(rscratch1, queue_index);
362N/A addq(tmp2, rscratch1);
362N/A movq(Address(tmp2, 0), card_addr);
362N/A#else
362N/A addl(tmp2, queue_index);
362N/A movl(Address(tmp2, 0), card_index);
362N/A#endif
362N/A jmp(done);
362N/A
362N/A bind(runtime);
362N/A // save the live input values
362N/A push(store_addr);
362N/A push(new_val);
362N/A#ifdef _LP64
362N/A call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, r15_thread);
362N/A#else
362N/A push(thread);
362N/A call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
362N/A pop(thread);
362N/A#endif
362N/A pop(new_val);
362N/A pop(store_addr);
362N/A
362N/A bind(done);
362N/A}
362N/A
362N/A#endif // SERIALGC
362N/A//////////////////////////////////////////////////////////////////////////////////
362N/A
362N/A
304N/Avoid MacroAssembler::store_check(Register obj) {
304N/A // Does a store check for the oop in register obj. The content of
304N/A // register obj is destroyed afterwards.
304N/A store_check_part_1(obj);
304N/A store_check_part_2(obj);
304N/A}
304N/A
304N/Avoid MacroAssembler::store_check(Register obj, Address dst) {
304N/A store_check(obj);
304N/A}
304N/A
304N/A
304N/A// split the store check operation so that other instructions can be scheduled inbetween
304N/Avoid MacroAssembler::store_check_part_1(Register obj) {
304N/A BarrierSet* bs = Universe::heap()->barrier_set();
304N/A assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
304N/A shrptr(obj, CardTableModRefBS::card_shift);
304N/A}
304N/A
304N/Avoid MacroAssembler::store_check_part_2(Register obj) {
304N/A BarrierSet* bs = Universe::heap()->barrier_set();
304N/A assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
304N/A CardTableModRefBS* ct = (CardTableModRefBS*)bs;
304N/A assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
304N/A
304N/A // The calculation for byte_map_base is as follows:
304N/A // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
304N/A // So this essentially converts an address to a displacement and
304N/A // it will never need to be relocated. On 64bit however the value may be too
304N/A // large for a 32bit displacement
304N/A
304N/A intptr_t disp = (intptr_t) ct->byte_map_base;
304N/A if (is_simm32(disp)) {
304N/A Address cardtable(noreg, obj, Address::times_1, disp);
304N/A movb(cardtable, 0);
304N/A } else {
304N/A // By doing it as an ExternalAddress disp could be converted to a rip-relative
304N/A // displacement and done in a single instruction given favorable mapping and
304N/A // a smarter version of as_Address. Worst case it is two instructions which
304N/A // is no worse off then loading disp into a register and doing as a simple
304N/A // Address() as above.
304N/A // We can't do as ExternalAddress as the only style since if disp == 0 we'll
304N/A // assert since NULL isn't acceptable in a reloci (see 6644928). In any case
304N/A // in some cases we'll get a single instruction version.
304N/A
304N/A ExternalAddress cardtable((address)disp);
304N/A Address index(noreg, obj, Address::times_1);
304N/A movb(as_Address(ArrayAddress(cardtable, index)), 0);
304N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::subptr(Register dst, int32_t imm32) {
304N/A LP64_ONLY(subq(dst, imm32)) NOT_LP64(subl(dst, imm32));
304N/A}
304N/A
3236N/A// Force generation of a 4 byte immediate value even if it fits into 8bit
3236N/Avoid MacroAssembler::subptr_imm32(Register dst, int32_t imm32) {
3236N/A LP64_ONLY(subq_imm32(dst, imm32)) NOT_LP64(subl_imm32(dst, imm32));
3236N/A}
3236N/A
304N/Avoid MacroAssembler::subptr(Register dst, Register src) {
304N/A LP64_ONLY(subq(dst, src)) NOT_LP64(subl(dst, src));
304N/A}
304N/A
304N/A// C++ bool manipulation
0N/Avoid MacroAssembler::testbool(Register dst) {
0N/A if(sizeof(bool) == 1)
304N/A testb(dst, 0xff);
0N/A else if(sizeof(bool) == 2) {
0N/A // testw implementation needed for two byte bools
0N/A ShouldNotReachHere();
0N/A } else if(sizeof(bool) == 4)
0N/A testl(dst, dst);
0N/A else
0N/A // unsupported
0N/A ShouldNotReachHere();
0N/A}
0N/A
304N/Avoid MacroAssembler::testptr(Register dst, Register src) {
304N/A LP64_ONLY(testq(dst, src)) NOT_LP64(testl(dst, src));
304N/A}
304N/A
304N/A// Defines obj, preserves var_size_in_bytes, okay for t2 == var_size_in_bytes.
304N/Avoid MacroAssembler::tlab_allocate(Register obj,
304N/A Register var_size_in_bytes,
304N/A int con_size_in_bytes,
304N/A Register t1,
304N/A Register t2,
304N/A Label& slow_case) {
304N/A assert_different_registers(obj, t1, t2);
304N/A assert_different_registers(obj, var_size_in_bytes, t1);
304N/A Register end = t2;
304N/A Register thread = NOT_LP64(t1) LP64_ONLY(r15_thread);
304N/A
304N/A verify_tlab();
304N/A
304N/A NOT_LP64(get_thread(thread));
304N/A
304N/A movptr(obj, Address(thread, JavaThread::tlab_top_offset()));
304N/A if (var_size_in_bytes == noreg) {
304N/A lea(end, Address(obj, con_size_in_bytes));
304N/A } else {
304N/A lea(end, Address(obj, var_size_in_bytes, Address::times_1));
304N/A }
304N/A cmpptr(end, Address(thread, JavaThread::tlab_end_offset()));
304N/A jcc(Assembler::above, slow_case);
304N/A
304N/A // update the tlab top pointer
304N/A movptr(Address(thread, JavaThread::tlab_top_offset()), end);
304N/A
304N/A // recover var_size_in_bytes if necessary
304N/A if (var_size_in_bytes == end) {
304N/A subptr(var_size_in_bytes, obj);
304N/A }
304N/A verify_tlab();
304N/A}
304N/A
304N/A// Preserves rbx, and rdx.
1988N/ARegister MacroAssembler::tlab_refill(Label& retry,
1988N/A Label& try_eden,
1988N/A Label& slow_case) {
304N/A Register top = rax;
304N/A Register t1 = rcx;
304N/A Register t2 = rsi;
304N/A Register thread_reg = NOT_LP64(rdi) LP64_ONLY(r15_thread);
304N/A assert_different_registers(top, thread_reg, t1, t2, /* preserve: */ rbx, rdx);
304N/A Label do_refill, discard_tlab;
304N/A
304N/A if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
304N/A // No allocation in the shared eden.
304N/A jmp(slow_case);
304N/A }
304N/A
304N/A NOT_LP64(get_thread(thread_reg));
304N/A
304N/A movptr(top, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
304N/A movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())));
304N/A
304N/A // calculate amount of free space
304N/A subptr(t1, top);
304N/A shrptr(t1, LogHeapWordSize);
304N/A
304N/A // Retain tlab and allocate object in shared space if
304N/A // the amount free in the tlab is too large to discard.
304N/A cmpptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_refill_waste_limit_offset())));
304N/A jcc(Assembler::lessEqual, discard_tlab);
304N/A
304N/A // Retain
304N/A // %%% yuck as movptr...
304N/A movptr(t2, (int32_t) ThreadLocalAllocBuffer::refill_waste_limit_increment());
304N/A addptr(Address(thread_reg, in_bytes(JavaThread::tlab_refill_waste_limit_offset())), t2);
304N/A if (TLABStats) {
304N/A // increment number of slow_allocations
304N/A addl(Address(thread_reg, in_bytes(JavaThread::tlab_slow_allocations_offset())), 1);
304N/A }
304N/A jmp(try_eden);
304N/A
304N/A bind(discard_tlab);
304N/A if (TLABStats) {
304N/A // increment number of refills
304N/A addl(Address(thread_reg, in_bytes(JavaThread::tlab_number_of_refills_offset())), 1);
304N/A // accumulate wastage -- t1 is amount free in tlab
304N/A addl(Address(thread_reg, in_bytes(JavaThread::tlab_fast_refill_waste_offset())), t1);
304N/A }
304N/A
304N/A // if tlab is currently allocated (top or end != null) then
304N/A // fill [top, end + alignment_reserve) with array object
1988N/A testptr(top, top);
304N/A jcc(Assembler::zero, do_refill);
304N/A
304N/A // set up the mark word
304N/A movptr(Address(top, oopDesc::mark_offset_in_bytes()), (intptr_t)markOopDesc::prototype()->copy_set_hash(0x2));
304N/A // set the length to the remaining space
304N/A subptr(t1, typeArrayOopDesc::header_size(T_INT));
304N/A addptr(t1, (int32_t)ThreadLocalAllocBuffer::alignment_reserve());
304N/A shlptr(t1, log2_intptr(HeapWordSize/sizeof(jint)));
1610N/A movl(Address(top, arrayOopDesc::length_offset_in_bytes()), t1);
304N/A // set klass to intArrayKlass
304N/A // dubious reloc why not an oop reloc?
1988N/A movptr(t1, ExternalAddress((address)Universe::intArrayKlassObj_addr()));
304N/A // store klass last. concurrent gcs assumes klass length is valid if
304N/A // klass field is not null.
304N/A store_klass(top, t1);
304N/A
1988N/A movptr(t1, top);
1988N/A subptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())));
1988N/A incr_allocated_bytes(thread_reg, t1, 0);
1988N/A
304N/A // refill the tlab with an eden allocation
304N/A bind(do_refill);
304N/A movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
304N/A shlptr(t1, LogHeapWordSize);
1988N/A // allocate new tlab, address returned in top
304N/A eden_allocate(top, t1, 0, t2, slow_case);
304N/A
304N/A // Check that t1 was preserved in eden_allocate.
304N/A#ifdef ASSERT
304N/A if (UseTLAB) {
304N/A Label ok;
304N/A Register tsize = rsi;
304N/A assert_different_registers(tsize, thread_reg, t1);
304N/A push(tsize);
304N/A movptr(tsize, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
304N/A shlptr(tsize, LogHeapWordSize);
304N/A cmpptr(t1, tsize);
304N/A jcc(Assembler::equal, ok);
3932N/A STOP("assert(t1 != tlab size)");
304N/A should_not_reach_here();
304N/A
304N/A bind(ok);
304N/A pop(tsize);
304N/A }
304N/A#endif
304N/A movptr(Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())), top);
304N/A movptr(Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())), top);
304N/A addptr(top, t1);
304N/A subptr(top, (int32_t)ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
304N/A movptr(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top);
304N/A verify_tlab();
304N/A jmp(retry);
1988N/A
1988N/A return thread_reg; // for use by caller
1988N/A}
1988N/A
1988N/Avoid MacroAssembler::incr_allocated_bytes(Register thread,
1988N/A Register var_size_in_bytes,
1988N/A int con_size_in_bytes,
1988N/A Register t1) {
3050N/A if (!thread->is_valid()) {
3050N/A#ifdef _LP64
3050N/A thread = r15_thread;
3050N/A#else
3050N/A assert(t1->is_valid(), "need temp reg");
3050N/A thread = t1;
3050N/A get_thread(thread);
3050N/A#endif
3050N/A }
3050N/A
1988N/A#ifdef _LP64
1988N/A if (var_size_in_bytes->is_valid()) {
1988N/A addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
1988N/A } else {
1988N/A addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
1988N/A }
1988N/A#else
1988N/A if (var_size_in_bytes->is_valid()) {
1988N/A addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
1988N/A } else {
1988N/A addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
1988N/A }
1988N/A adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0);
1988N/A#endif
304N/A}
304N/A
3752N/Avoid MacroAssembler::fp_runtime_fallback(address runtime_entry, int nb_args, int num_fpu_regs_in_use) {
3752N/A pusha();
3752N/A
3752N/A // if we are coming from c1, xmm registers may be live
3752N/A if (UseSSE >= 1) {
3752N/A subptr(rsp, sizeof(jdouble)* LP64_ONLY(16) NOT_LP64(8));
3752N/A }
3752N/A int off = 0;
3752N/A if (UseSSE == 1) {
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm0);
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm1);
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm2);
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm3);
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm4);
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm5);
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm6);
3752N/A movflt(Address(rsp,off++*sizeof(jdouble)),xmm7);
3752N/A } else if (UseSSE >= 2) {
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm0);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm1);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm2);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm3);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm4);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm5);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm6);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm7);
3752N/A#ifdef _LP64
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm8);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm9);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm10);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm11);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm12);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm13);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm14);
3752N/A movdbl(Address(rsp,off++*sizeof(jdouble)),xmm15);
3752N/A#endif
3752N/A }
3752N/A
3752N/A // Preserve registers across runtime call
3752N/A int incoming_argument_and_return_value_offset = -1;
3752N/A if (num_fpu_regs_in_use > 1) {
3752N/A // Must preserve all other FPU regs (could alternatively convert
3752N/A // SharedRuntime::dsin, dcos etc. into assembly routines known not to trash
3752N/A // FPU state, but can not trust C compiler)
3752N/A NEEDS_CLEANUP;
3752N/A // NOTE that in this case we also push the incoming argument(s) to
3752N/A // the stack and restore it later; we also use this stack slot to
3752N/A // hold the return value from dsin, dcos etc.
3752N/A for (int i = 0; i < num_fpu_regs_in_use; i++) {
3752N/A subptr(rsp, sizeof(jdouble));
3752N/A fstp_d(Address(rsp, 0));
3752N/A }
3752N/A incoming_argument_and_return_value_offset = sizeof(jdouble)*(num_fpu_regs_in_use-1);
3752N/A for (int i = nb_args-1; i >= 0; i--) {
3752N/A fld_d(Address(rsp, incoming_argument_and_return_value_offset-i*sizeof(jdouble)));
3752N/A }
3752N/A }
3752N/A
3752N/A subptr(rsp, nb_args*sizeof(jdouble));
3752N/A for (int i = 0; i < nb_args; i++) {
3752N/A fstp_d(Address(rsp, i*sizeof(jdouble)));
3752N/A }
3752N/A
3752N/A#ifdef _LP64
3752N/A if (nb_args > 0) {
3752N/A movdbl(xmm0, Address(rsp, 0));
3752N/A }
3752N/A if (nb_args > 1) {
3752N/A movdbl(xmm1, Address(rsp, sizeof(jdouble)));
3752N/A }
3752N/A assert(nb_args <= 2, "unsupported number of args");
3752N/A#endif // _LP64
3752N/A
3752N/A // NOTE: we must not use call_VM_leaf here because that requires a
3752N/A // complete interpreter frame in debug mode -- same bug as 4387334
3752N/A // MacroAssembler::call_VM_leaf_base is perfectly safe and will
3752N/A // do proper 64bit abi
3752N/A
3752N/A NEEDS_CLEANUP;
3752N/A // Need to add stack banging before this runtime call if it needs to
3752N/A // be taken; however, there is no generic stack banging routine at
3752N/A // the MacroAssembler level
3752N/A
3752N/A MacroAssembler::call_VM_leaf_base(runtime_entry, 0);
3752N/A
3752N/A#ifdef _LP64
3752N/A movsd(Address(rsp, 0), xmm0);
3752N/A fld_d(Address(rsp, 0));
3752N/A#endif // _LP64
3752N/A addptr(rsp, sizeof(jdouble) * nb_args);
3752N/A if (num_fpu_regs_in_use > 1) {
3752N/A // Must save return value to stack and then restore entire FPU
3752N/A // stack except incoming arguments
3752N/A fstp_d(Address(rsp, incoming_argument_and_return_value_offset));
3752N/A for (int i = 0; i < num_fpu_regs_in_use - nb_args; i++) {
3752N/A fld_d(Address(rsp, 0));
3752N/A addptr(rsp, sizeof(jdouble));
3752N/A }
3752N/A fld_d(Address(rsp, (nb_args-1)*sizeof(jdouble)));
3752N/A addptr(rsp, sizeof(jdouble) * nb_args);
3752N/A }
3752N/A
3752N/A off = 0;
3752N/A if (UseSSE == 1) {
3752N/A movflt(xmm0, Address(rsp,off++*sizeof(jdouble)));
3752N/A movflt(xmm1, Address(rsp,off++*sizeof(jdouble)));
3752N/A movflt(xmm2, Address(rsp,off++*sizeof(jdouble)));
3752N/A movflt(xmm3, Address(rsp,off++*sizeof(jdouble)));
3752N/A movflt(xmm4, Address(rsp,off++*sizeof(jdouble)));
3752N/A movflt(xmm5, Address(rsp,off++*sizeof(jdouble)));
3752N/A movflt(xmm6, Address(rsp,off++*sizeof(jdouble)));
3752N/A movflt(xmm7, Address(rsp,off++*sizeof(jdouble)));
3752N/A } else if (UseSSE >= 2) {
3752N/A movdbl(xmm0, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm1, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm2, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm3, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm4, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm5, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm6, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm7, Address(rsp,off++*sizeof(jdouble)));
3752N/A#ifdef _LP64
3752N/A movdbl(xmm8, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm9, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm10, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm11, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm12, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm13, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm14, Address(rsp,off++*sizeof(jdouble)));
3752N/A movdbl(xmm15, Address(rsp,off++*sizeof(jdouble)));
3752N/A#endif
3752N/A }
3752N/A if (UseSSE >= 1) {
3752N/A addptr(rsp, sizeof(jdouble)* LP64_ONLY(16) NOT_LP64(8));
3752N/A }
3752N/A popa();
3752N/A}
3752N/A
304N/Astatic const double pi_4 = 0.7853981633974483;
304N/A
304N/Avoid MacroAssembler::trigfunc(char trig, int num_fpu_regs_in_use) {
304N/A // A hand-coded argument reduction for values in fabs(pi/4, pi/2)
304N/A // was attempted in this code; unfortunately it appears that the
304N/A // switch to 80-bit precision and back causes this to be
304N/A // unprofitable compared with simply performing a runtime call if
304N/A // the argument is out of the (-pi/4, pi/4) range.
304N/A
304N/A Register tmp = noreg;
304N/A if (!VM_Version::supports_cmov()) {
304N/A // fcmp needs a temporary so preserve rbx,
304N/A tmp = rbx;
304N/A push(tmp);
304N/A }
304N/A
304N/A Label slow_case, done;
304N/A
520N/A ExternalAddress pi4_adr = (address)&pi_4;
520N/A if (reachable(pi4_adr)) {
520N/A // x ?<= pi/4
520N/A fld_d(pi4_adr);
520N/A fld_s(1); // Stack: X PI/4 X
520N/A fabs(); // Stack: |X| PI/4 X
520N/A fcmp(tmp);
520N/A jcc(Assembler::above, slow_case);
520N/A
520N/A // fastest case: -pi/4 <= x <= pi/4
520N/A switch(trig) {
520N/A case 's':
520N/A fsin();
520N/A break;
520N/A case 'c':
520N/A fcos();
520N/A break;
520N/A case 't':
520N/A ftan();
520N/A break;
520N/A default:
520N/A assert(false, "bad intrinsic");
520N/A break;
520N/A }
520N/A jmp(done);
520N/A }
304N/A
304N/A // slow case: runtime call
304N/A bind(slow_case);
3752N/A
304N/A switch(trig) {
304N/A case 's':
304N/A {
3752N/A fp_runtime_fallback(CAST_FROM_FN_PTR(address, SharedRuntime::dsin), 1, num_fpu_regs_in_use);
304N/A }
304N/A break;
304N/A case 'c':
304N/A {
3752N/A fp_runtime_fallback(CAST_FROM_FN_PTR(address, SharedRuntime::dcos), 1, num_fpu_regs_in_use);
304N/A }
304N/A break;
304N/A case 't':
304N/A {
3752N/A fp_runtime_fallback(CAST_FROM_FN_PTR(address, SharedRuntime::dtan), 1, num_fpu_regs_in_use);
304N/A }
304N/A break;
304N/A default:
304N/A assert(false, "bad intrinsic");
304N/A break;
304N/A }
304N/A
304N/A // Come here with result in F-TOS
304N/A bind(done);
304N/A
304N/A if (tmp != noreg) {
304N/A pop(tmp);
304N/A }
304N/A}
304N/A
304N/A
623N/A// Look up the method for a megamorphic invokeinterface call.
623N/A// The target method is determined by <intf_klass, itable_index>.
623N/A// The receiver klass is in recv_klass.
623N/A// On success, the result will be in method_result, and execution falls through.
623N/A// On failure, execution transfers to the given label.
623N/Avoid MacroAssembler::lookup_interface_method(Register recv_klass,
623N/A Register intf_klass,
665N/A RegisterOrConstant itable_index,
623N/A Register method_result,
623N/A Register scan_temp,
623N/A Label& L_no_such_interface) {
623N/A assert_different_registers(recv_klass, intf_klass, method_result, scan_temp);
623N/A assert(itable_index.is_constant() || itable_index.as_register() == method_result,
623N/A "caller must use same register for non-constant itable index as for method");
623N/A
623N/A // Compute start of first itableOffsetEntry (which is at the end of the vtable)
623N/A int vtable_base = instanceKlass::vtable_start_offset() * wordSize;
623N/A int itentry_off = itableMethodEntry::method_offset_in_bytes();
623N/A int scan_step = itableOffsetEntry::size() * wordSize;
623N/A int vte_size = vtableEntry::size() * wordSize;
623N/A Address::ScaleFactor times_vte_scale = Address::times_ptr;
623N/A assert(vte_size == wordSize, "else adjust times_vte_scale");
623N/A
623N/A movl(scan_temp, Address(recv_klass, instanceKlass::vtable_length_offset() * wordSize));
623N/A
623N/A // %%% Could store the aligned, prescaled offset in the klassoop.
623N/A lea(scan_temp, Address(recv_klass, scan_temp, times_vte_scale, vtable_base));
623N/A if (HeapWordsPerLong > 1) {
623N/A // Round up to align_object_offset boundary
623N/A // see code for instanceKlass::start_of_itable!
623N/A round_to(scan_temp, BytesPerLong);
623N/A }
623N/A
623N/A // Adjust recv_klass by scaled itable_index, so we can free itable_index.
623N/A assert(itableMethodEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
623N/A lea(recv_klass, Address(recv_klass, itable_index, Address::times_ptr, itentry_off));
623N/A
623N/A // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
623N/A // if (scan->interface() == intf) {
623N/A // result = (klass + scan->offset() + itable_index);
623N/A // }
623N/A // }
623N/A Label search, found_method;
623N/A
623N/A for (int peel = 1; peel >= 0; peel--) {
623N/A movptr(method_result, Address(scan_temp, itableOffsetEntry::interface_offset_in_bytes()));
623N/A cmpptr(intf_klass, method_result);
623N/A
623N/A if (peel) {
623N/A jccb(Assembler::equal, found_method);
623N/A } else {
623N/A jccb(Assembler::notEqual, search);
623N/A // (invert the test to fall through to found_method...)
623N/A }
623N/A
623N/A if (!peel) break;
623N/A
623N/A bind(search);
623N/A
623N/A // Check that the previous entry is non-null. A null entry means that
623N/A // the receiver class doesn't implement the interface, and wasn't the
623N/A // same as when the caller was compiled.
623N/A testptr(method_result, method_result);
623N/A jcc(Assembler::zero, L_no_such_interface);
623N/A addptr(scan_temp, scan_step);
623N/A }
623N/A
623N/A bind(found_method);
623N/A
623N/A // Got a hit.
623N/A movl(scan_temp, Address(scan_temp, itableOffsetEntry::offset_offset_in_bytes()));
623N/A movptr(method_result, Address(recv_klass, scan_temp, Address::times_1));
623N/A}
623N/A
623N/A
3932N/A// virtual method calling
3932N/Avoid MacroAssembler::lookup_virtual_method(Register recv_klass,
3932N/A RegisterOrConstant vtable_index,
3932N/A Register method_result) {
3932N/A const int base = instanceKlass::vtable_start_offset() * wordSize;
3932N/A assert(vtableEntry::size() * wordSize == wordSize, "else adjust the scaling in the code below");
3932N/A Address vtable_entry_addr(recv_klass,
3932N/A vtable_index, Address::times_ptr,
3932N/A base + vtableEntry::method_offset_in_bytes());
3932N/A movptr(method_result, vtable_entry_addr);
3932N/A}
3932N/A
3932N/A
644N/Avoid MacroAssembler::check_klass_subtype(Register sub_klass,
644N/A Register super_klass,
644N/A Register temp_reg,
644N/A Label& L_success) {
644N/A Label L_failure;
644N/A check_klass_subtype_fast_path(sub_klass, super_klass, temp_reg, &L_success, &L_failure, NULL);
644N/A check_klass_subtype_slow_path(sub_klass, super_klass, temp_reg, noreg, &L_success, NULL);
644N/A bind(L_failure);
644N/A}
644N/A
644N/A
644N/Avoid MacroAssembler::check_klass_subtype_fast_path(Register sub_klass,
644N/A Register super_klass,
644N/A Register temp_reg,
644N/A Label* L_success,
644N/A Label* L_failure,
644N/A Label* L_slow_path,
665N/A RegisterOrConstant super_check_offset) {
644N/A assert_different_registers(sub_klass, super_klass, temp_reg);
644N/A bool must_load_sco = (super_check_offset.constant_or_zero() == -1);
644N/A if (super_check_offset.is_register()) {
644N/A assert_different_registers(sub_klass, super_klass,
644N/A super_check_offset.as_register());
644N/A } else if (must_load_sco) {
644N/A assert(temp_reg != noreg, "supply either a temp or a register offset");
644N/A }
644N/A
644N/A Label L_fallthrough;
644N/A int label_nulls = 0;
644N/A if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; }
644N/A if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; }
644N/A if (L_slow_path == NULL) { L_slow_path = &L_fallthrough; label_nulls++; }
644N/A assert(label_nulls <= 1, "at most one NULL in the batch");
644N/A
3042N/A int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
3042N/A int sco_offset = in_bytes(Klass::super_check_offset_offset());
644N/A Address super_check_offset_addr(super_klass, sco_offset);
644N/A
644N/A // Hacked jcc, which "knows" that L_fallthrough, at least, is in
644N/A // range of a jccb. If this routine grows larger, reconsider at
644N/A // least some of these.
644N/A#define local_jcc(assembler_cond, label) \
644N/A if (&(label) == &L_fallthrough) jccb(assembler_cond, label); \
644N/A else jcc( assembler_cond, label) /*omit semi*/
644N/A
644N/A // Hacked jmp, which may only be used just before L_fallthrough.
644N/A#define final_jmp(label) \
644N/A if (&(label) == &L_fallthrough) { /*do nothing*/ } \
644N/A else jmp(label) /*omit semi*/
644N/A
644N/A // If the pointers are equal, we are done (e.g., String[] elements).
644N/A // This self-check enables sharing of secondary supertype arrays among
644N/A // non-primary types such as array-of-interface. Otherwise, each such
644N/A // type would need its own customized SSA.
644N/A // We move this check to the front of the fast path because many
644N/A // type checks are in fact trivially successful in this manner,
644N/A // so we get a nicely predicted branch right at the start of the check.
644N/A cmpptr(sub_klass, super_klass);
644N/A local_jcc(Assembler::equal, *L_success);
644N/A
644N/A // Check the supertype display:
644N/A if (must_load_sco) {
644N/A // Positive movl does right thing on LP64.
644N/A movl(temp_reg, super_check_offset_addr);
665N/A super_check_offset = RegisterOrConstant(temp_reg);
644N/A }
644N/A Address super_check_addr(sub_klass, super_check_offset, Address::times_1, 0);
644N/A cmpptr(super_klass, super_check_addr); // load displayed supertype
644N/A
644N/A // This check has worked decisively for primary supers.
644N/A // Secondary supers are sought in the super_cache ('super_cache_addr').
644N/A // (Secondary supers are interfaces and very deeply nested subtypes.)
644N/A // This works in the same check above because of a tricky aliasing
644N/A // between the super_cache and the primary super display elements.
644N/A // (The 'super_check_addr' can address either, as the case requires.)
644N/A // Note that the cache is updated below if it does not help us find
644N/A // what we need immediately.
644N/A // So if it was a primary super, we can just fail immediately.
644N/A // Otherwise, it's the slow path for us (no success at this point).
644N/A
644N/A if (super_check_offset.is_register()) {
644N/A local_jcc(Assembler::equal, *L_success);
644N/A cmpl(super_check_offset.as_register(), sc_offset);
644N/A if (L_failure == &L_fallthrough) {
644N/A local_jcc(Assembler::equal, *L_slow_path);
644N/A } else {
644N/A local_jcc(Assembler::notEqual, *L_failure);
644N/A final_jmp(*L_slow_path);
644N/A }
644N/A } else if (super_check_offset.as_constant() == sc_offset) {
644N/A // Need a slow path; fast failure is impossible.
644N/A if (L_slow_path == &L_fallthrough) {
644N/A local_jcc(Assembler::equal, *L_success);
644N/A } else {
644N/A local_jcc(Assembler::notEqual, *L_slow_path);
644N/A final_jmp(*L_success);
644N/A }
644N/A } else {
644N/A // No slow path; it's a fast decision.
644N/A if (L_failure == &L_fallthrough) {
644N/A local_jcc(Assembler::equal, *L_success);
644N/A } else {
644N/A local_jcc(Assembler::notEqual, *L_failure);
644N/A final_jmp(*L_success);
644N/A }
644N/A }
644N/A
644N/A bind(L_fallthrough);
644N/A
644N/A#undef local_jcc
644N/A#undef final_jmp
644N/A}
644N/A
644N/A
644N/Avoid MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
644N/A Register super_klass,
644N/A Register temp_reg,
644N/A Register temp2_reg,
644N/A Label* L_success,
644N/A Label* L_failure,
644N/A bool set_cond_codes) {
644N/A assert_different_registers(sub_klass, super_klass, temp_reg);
644N/A if (temp2_reg != noreg)
644N/A assert_different_registers(sub_klass, super_klass, temp_reg, temp2_reg);
644N/A#define IS_A_TEMP(reg) ((reg) == temp_reg || (reg) == temp2_reg)
644N/A
644N/A Label L_fallthrough;
644N/A int label_nulls = 0;
644N/A if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; }
644N/A if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; }
644N/A assert(label_nulls <= 1, "at most one NULL in the batch");
644N/A
644N/A // a couple of useful fields in sub_klass:
3042N/A int ss_offset = in_bytes(Klass::secondary_supers_offset());
3042N/A int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
644N/A Address secondary_supers_addr(sub_klass, ss_offset);
644N/A Address super_cache_addr( sub_klass, sc_offset);
644N/A
644N/A // Do a linear scan of the secondary super-klass chain.
644N/A // This code is rarely used, so simplicity is a virtue here.
644N/A // The repne_scan instruction uses fixed registers, which we must spill.
644N/A // Don't worry too much about pre-existing connections with the input regs.
644N/A
644N/A assert(sub_klass != rax, "killed reg"); // killed by mov(rax, super)
644N/A assert(sub_klass != rcx, "killed reg"); // killed by lea(rcx, &pst_counter)
644N/A
644N/A // Get super_klass value into rax (even if it was in rdi or rcx).
644N/A bool pushed_rax = false, pushed_rcx = false, pushed_rdi = false;
644N/A if (super_klass != rax || UseCompressedOops) {
644N/A if (!IS_A_TEMP(rax)) { push(rax); pushed_rax = true; }
644N/A mov(rax, super_klass);
644N/A }
644N/A if (!IS_A_TEMP(rcx)) { push(rcx); pushed_rcx = true; }
644N/A if (!IS_A_TEMP(rdi)) { push(rdi); pushed_rdi = true; }
644N/A
644N/A#ifndef PRODUCT
644N/A int* pst_counter = &SharedRuntime::_partial_subtype_ctr;
644N/A ExternalAddress pst_counter_addr((address) pst_counter);
644N/A NOT_LP64( incrementl(pst_counter_addr) );
644N/A LP64_ONLY( lea(rcx, pst_counter_addr) );
644N/A LP64_ONLY( incrementl(Address(rcx, 0)) );
644N/A#endif //PRODUCT
644N/A
644N/A // We will consult the secondary-super array.
644N/A movptr(rdi, secondary_supers_addr);
644N/A // Load the array length. (Positive movl does right thing on LP64.)
644N/A movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes()));
644N/A // Skip to start of data.
644N/A addptr(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
644N/A
644N/A // Scan RCX words at [RDI] for an occurrence of RAX.
644N/A // Set NZ/Z based on last compare.
1604N/A // Z flag value will not be set by 'repne' if RCX == 0 since 'repne' does
1604N/A // not change flags (only scas instruction which is repeated sets flags).
1604N/A // Set Z = 0 (not equal) before 'repne' to indicate that class was not found.
644N/A#ifdef _LP64
644N/A // This part is tricky, as values in supers array could be 32 or 64 bit wide
644N/A // and we store values in objArrays always encoded, thus we need to encode
644N/A // the value of rax before repne. Note that rax is dead after the repne.
644N/A if (UseCompressedOops) {
1604N/A encode_heap_oop_not_null(rax); // Changes flags.
644N/A // The superclass is never null; it would be a basic system error if a null
644N/A // pointer were to sneak in here. Note that we have already loaded the
644N/A // Klass::super_check_offset from the super_klass in the fast path,
644N/A // so if there is a null in that register, we are already in the afterlife.
1604N/A testl(rax,rax); // Set Z = 0
644N/A repne_scanl();
644N/A } else
644N/A#endif // _LP64
1604N/A {
1604N/A testptr(rax,rax); // Set Z = 0
644N/A repne_scan();
1604N/A }
644N/A // Unspill the temp. registers:
644N/A if (pushed_rdi) pop(rdi);
644N/A if (pushed_rcx) pop(rcx);
644N/A if (pushed_rax) pop(rax);
644N/A
644N/A if (set_cond_codes) {
644N/A // Special hack for the AD files: rdi is guaranteed non-zero.
644N/A assert(!pushed_rdi, "rdi must be left non-NULL");
644N/A // Also, the condition codes are properly set Z/NZ on succeed/failure.
644N/A }
644N/A
644N/A if (L_failure == &L_fallthrough)
644N/A jccb(Assembler::notEqual, *L_failure);
644N/A else jcc(Assembler::notEqual, *L_failure);
644N/A
644N/A // Success. Cache the super we found and proceed in triumph.
644N/A movptr(super_cache_addr, super_klass);
644N/A
644N/A if (L_success != &L_fallthrough) {
644N/A jmp(*L_success);
644N/A }
644N/A
644N/A#undef IS_A_TEMP
644N/A
644N/A bind(L_fallthrough);
644N/A}
644N/A
644N/A
2262N/Avoid MacroAssembler::cmov32(Condition cc, Register dst, Address src) {
2262N/A if (VM_Version::supports_cmov()) {
2262N/A cmovl(cc, dst, src);
2262N/A } else {
2262N/A Label L;
2262N/A jccb(negate_condition(cc), L);
2262N/A movl(dst, src);
2262N/A bind(L);
2262N/A }
2262N/A}
2262N/A
2262N/Avoid MacroAssembler::cmov32(Condition cc, Register dst, Register src) {
2262N/A if (VM_Version::supports_cmov()) {
2262N/A cmovl(cc, dst, src);
2262N/A } else {
2262N/A Label L;
2262N/A jccb(negate_condition(cc), L);
2262N/A movl(dst, src);
2262N/A bind(L);
2262N/A }
2262N/A}
2262N/A
0N/Avoid MacroAssembler::verify_oop(Register reg, const char* s) {
0N/A if (!VerifyOops) return;
304N/A
0N/A // Pass register number to verify_oop_subroutine
0N/A char* b = new char[strlen(s) + 50];
0N/A sprintf(b, "verify_oop: %s: %s", reg->name(), s);
3932N/A BLOCK_COMMENT("verify_oop {");
1503N/A#ifdef _LP64
1503N/A push(rscratch1); // save r10, trashed by movptr()
1503N/A#endif
304N/A push(rax); // save rax,
304N/A push(reg); // pass register argument
0N/A ExternalAddress buffer((address) b);
304N/A // avoid using pushptr, as it modifies scratch registers
304N/A // and our contract is not to modify anything
304N/A movptr(rax, buffer.addr());
304N/A push(rax);
0N/A // call indirectly to solve generation ordering problem
0N/A movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
0N/A call(rax);
1503N/A // Caller pops the arguments (oop, message) and restores rax, r10
3932N/A BLOCK_COMMENT("} verify_oop");
0N/A}
0N/A
0N/A
665N/ARegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
665N/A Register tmp,
665N/A int offset) {
622N/A intptr_t value = *delayed_value_addr;
622N/A if (value != 0)
665N/A return RegisterOrConstant(value + offset);
622N/A
622N/A // load indirectly to solve generation ordering problem
622N/A movptr(tmp, ExternalAddress((address) delayed_value_addr));
622N/A
622N/A#ifdef ASSERT
1713N/A { Label L;
1713N/A testptr(tmp, tmp);
1713N/A if (WizardMode) {
1713N/A jcc(Assembler::notZero, L);
1713N/A char* buf = new char[40];
1713N/A sprintf(buf, "DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]);
3932N/A STOP(buf);
1713N/A } else {
1713N/A jccb(Assembler::notZero, L);
1713N/A hlt();
1713N/A }
1713N/A bind(L);
1713N/A }
622N/A#endif
622N/A
622N/A if (offset != 0)
622N/A addptr(tmp, offset);
622N/A
665N/A return RegisterOrConstant(tmp);
622N/A}
622N/A
622N/A
710N/AAddress MacroAssembler::argument_address(RegisterOrConstant arg_slot,
710N/A int extra_slot_offset) {
710N/A // cf. TemplateTable::prepare_invoke(), if (load_receiver).
1426N/A int stackElementSize = Interpreter::stackElementSize;
710N/A int offset = Interpreter::expr_offset_in_bytes(extra_slot_offset+0);
710N/A#ifdef ASSERT
710N/A int offset1 = Interpreter::expr_offset_in_bytes(extra_slot_offset+1);
710N/A assert(offset1 - offset == stackElementSize, "correct arithmetic");
710N/A#endif
710N/A Register scale_reg = noreg;
710N/A Address::ScaleFactor scale_factor = Address::no_scale;
710N/A if (arg_slot.is_constant()) {
710N/A offset += arg_slot.as_constant() * stackElementSize;
710N/A } else {
710N/A scale_reg = arg_slot.as_register();
710N/A scale_factor = Address::times(stackElementSize);
710N/A }
710N/A offset += wordSize; // return PC is on stack
710N/A return Address(rsp, scale_reg, scale_factor, offset);
710N/A}
710N/A
710N/A
0N/Avoid MacroAssembler::verify_oop_addr(Address addr, const char* s) {
0N/A if (!VerifyOops) return;
304N/A
0N/A // Address adjust(addr.base(), addr.index(), addr.scale(), addr.disp() + BytesPerWord);
0N/A // Pass register number to verify_oop_subroutine
0N/A char* b = new char[strlen(s) + 50];
0N/A sprintf(b, "verify_oop_addr: %s", s);
304N/A
1503N/A#ifdef _LP64
1503N/A push(rscratch1); // save r10, trashed by movptr()
1503N/A#endif
304N/A push(rax); // save rax,
0N/A // addr may contain rsp so we will have to adjust it based on the push
2311N/A // we just did (and on 64 bit we do two pushes)
304N/A // NOTE: 64bit seemed to have had a bug in that it did movq(addr, rax); which
304N/A // stores rax into addr which is backwards of what was intended.
0N/A if (addr.uses(rsp)) {
304N/A lea(rax, addr);
2311N/A pushptr(Address(rax, LP64_ONLY(2 *) BytesPerWord));
0N/A } else {
304N/A pushptr(addr);
304N/A }
304N/A
0N/A ExternalAddress buffer((address) b);
0N/A // pass msg argument
304N/A // avoid using pushptr, as it modifies scratch registers
304N/A // and our contract is not to modify anything
304N/A movptr(rax, buffer.addr());
304N/A push(rax);
304N/A
0N/A // call indirectly to solve generation ordering problem
0N/A movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
0N/A call(rax);
1503N/A // Caller pops the arguments (addr, message) and restores rax, r10.
0N/A}
0N/A
304N/Avoid MacroAssembler::verify_tlab() {
304N/A#ifdef ASSERT
304N/A if (UseTLAB && VerifyOops) {
304N/A Label next, ok;
304N/A Register t1 = rsi;
304N/A Register thread_reg = NOT_LP64(rbx) LP64_ONLY(r15_thread);
304N/A
304N/A push(t1);
304N/A NOT_LP64(push(thread_reg));
304N/A NOT_LP64(get_thread(thread_reg));
304N/A
304N/A movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
304N/A cmpptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())));
304N/A jcc(Assembler::aboveEqual, next);
3932N/A STOP("assert(top >= start)");
304N/A should_not_reach_here();
304N/A
304N/A bind(next);
304N/A movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())));
304N/A cmpptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
304N/A jcc(Assembler::aboveEqual, ok);
3932N/A STOP("assert(top <= end)");
304N/A should_not_reach_here();
304N/A
304N/A bind(ok);
304N/A NOT_LP64(pop(thread_reg));
304N/A pop(t1);
304N/A }
304N/A#endif
304N/A}
0N/A
0N/Aclass ControlWord {
0N/A public:
0N/A int32_t _value;
0N/A
0N/A int rounding_control() const { return (_value >> 10) & 3 ; }
0N/A int precision_control() const { return (_value >> 8) & 3 ; }
0N/A bool precision() const { return ((_value >> 5) & 1) != 0; }
0N/A bool underflow() const { return ((_value >> 4) & 1) != 0; }
0N/A bool overflow() const { return ((_value >> 3) & 1) != 0; }
0N/A bool zero_divide() const { return ((_value >> 2) & 1) != 0; }
0N/A bool denormalized() const { return ((_value >> 1) & 1) != 0; }
0N/A bool invalid() const { return ((_value >> 0) & 1) != 0; }
0N/A
0N/A void print() const {
0N/A // rounding control
0N/A const char* rc;
0N/A switch (rounding_control()) {
0N/A case 0: rc = "round near"; break;
0N/A case 1: rc = "round down"; break;
0N/A case 2: rc = "round up "; break;
0N/A case 3: rc = "chop "; break;
0N/A };
0N/A // precision control
0N/A const char* pc;
0N/A switch (precision_control()) {
0N/A case 0: pc = "24 bits "; break;
0N/A case 1: pc = "reserved"; break;
0N/A case 2: pc = "53 bits "; break;
0N/A case 3: pc = "64 bits "; break;
0N/A };
0N/A // flags
0N/A char f[9];
0N/A f[0] = ' ';
0N/A f[1] = ' ';
0N/A f[2] = (precision ()) ? 'P' : 'p';
0N/A f[3] = (underflow ()) ? 'U' : 'u';
0N/A f[4] = (overflow ()) ? 'O' : 'o';
0N/A f[5] = (zero_divide ()) ? 'Z' : 'z';
0N/A f[6] = (denormalized()) ? 'D' : 'd';
0N/A f[7] = (invalid ()) ? 'I' : 'i';
0N/A f[8] = '\x0';
0N/A // output
0N/A printf("%04x masks = %s, %s, %s", _value & 0xFFFF, f, rc, pc);
0N/A }
0N/A
0N/A};
0N/A
0N/Aclass StatusWord {
0N/A public:
0N/A int32_t _value;
0N/A
0N/A bool busy() const { return ((_value >> 15) & 1) != 0; }
0N/A bool C3() const { return ((_value >> 14) & 1) != 0; }
0N/A bool C2() const { return ((_value >> 10) & 1) != 0; }
0N/A bool C1() const { return ((_value >> 9) & 1) != 0; }
0N/A bool C0() const { return ((_value >> 8) & 1) != 0; }
0N/A int top() const { return (_value >> 11) & 7 ; }
0N/A bool error_status() const { return ((_value >> 7) & 1) != 0; }
0N/A bool stack_fault() const { return ((_value >> 6) & 1) != 0; }
0N/A bool precision() const { return ((_value >> 5) & 1) != 0; }
0N/A bool underflow() const { return ((_value >> 4) & 1) != 0; }
0N/A bool overflow() const { return ((_value >> 3) & 1) != 0; }
0N/A bool zero_divide() const { return ((_value >> 2) & 1) != 0; }
0N/A bool denormalized() const { return ((_value >> 1) & 1) != 0; }
0N/A bool invalid() const { return ((_value >> 0) & 1) != 0; }
0N/A
0N/A void print() const {
0N/A // condition codes
0N/A char c[5];
0N/A c[0] = (C3()) ? '3' : '-';
0N/A c[1] = (C2()) ? '2' : '-';
0N/A c[2] = (C1()) ? '1' : '-';
0N/A c[3] = (C0()) ? '0' : '-';
0N/A c[4] = '\x0';
0N/A // flags
0N/A char f[9];
0N/A f[0] = (error_status()) ? 'E' : '-';
0N/A f[1] = (stack_fault ()) ? 'S' : '-';
0N/A f[2] = (precision ()) ? 'P' : '-';
0N/A f[3] = (underflow ()) ? 'U' : '-';
0N/A f[4] = (overflow ()) ? 'O' : '-';
0N/A f[5] = (zero_divide ()) ? 'Z' : '-';
0N/A f[6] = (denormalized()) ? 'D' : '-';
0N/A f[7] = (invalid ()) ? 'I' : '-';
0N/A f[8] = '\x0';
0N/A // output
0N/A printf("%04x flags = %s, cc = %s, top = %d", _value & 0xFFFF, f, c, top());
0N/A }
0N/A
0N/A};
0N/A
0N/Aclass TagWord {
0N/A public:
0N/A int32_t _value;
0N/A
0N/A int tag_at(int i) const { return (_value >> (i*2)) & 3; }
0N/A
0N/A void print() const {
0N/A printf("%04x", _value & 0xFFFF);
0N/A }
0N/A
0N/A};
0N/A
0N/Aclass FPU_Register {
0N/A public:
0N/A int32_t _m0;
0N/A int32_t _m1;
0N/A int16_t _ex;
0N/A
0N/A bool is_indefinite() const {
0N/A return _ex == -1 && _m1 == (int32_t)0xC0000000 && _m0 == 0;
0N/A }
0N/A
0N/A void print() const {
0N/A char sign = (_ex < 0) ? '-' : '+';
0N/A const char* kind = (_ex == 0x7FFF || _ex == (int16_t)-1) ? "NaN" : " ";
0N/A printf("%c%04hx.%08x%08x %s", sign, _ex, _m1, _m0, kind);
0N/A };
0N/A
0N/A};
0N/A
0N/Aclass FPU_State {
0N/A public:
0N/A enum {
0N/A register_size = 10,
0N/A number_of_registers = 8,
0N/A register_mask = 7
0N/A };
0N/A
0N/A ControlWord _control_word;
0N/A StatusWord _status_word;
0N/A TagWord _tag_word;
0N/A int32_t _error_offset;
0N/A int32_t _error_selector;
0N/A int32_t _data_offset;
0N/A int32_t _data_selector;
0N/A int8_t _register[register_size * number_of_registers];
0N/A
0N/A int tag_for_st(int i) const { return _tag_word.tag_at((_status_word.top() + i) & register_mask); }
0N/A FPU_Register* st(int i) const { return (FPU_Register*)&_register[register_size * i]; }
0N/A
0N/A const char* tag_as_string(int tag) const {
0N/A switch (tag) {
0N/A case 0: return "valid";
0N/A case 1: return "zero";
0N/A case 2: return "special";
0N/A case 3: return "empty";
0N/A }
1409N/A ShouldNotReachHere();
0N/A return NULL;
0N/A }
0N/A
0N/A void print() const {
0N/A // print computation registers
0N/A { int t = _status_word.top();
0N/A for (int i = 0; i < number_of_registers; i++) {
0N/A int j = (i - t) & register_mask;
0N/A printf("%c r%d = ST%d = ", (j == 0 ? '*' : ' '), i, j);
0N/A st(j)->print();
0N/A printf(" %s\n", tag_as_string(_tag_word.tag_at(i)));
0N/A }
0N/A }
0N/A printf("\n");
0N/A // print control registers
0N/A printf("ctrl = "); _control_word.print(); printf("\n");
0N/A printf("stat = "); _status_word .print(); printf("\n");
0N/A printf("tags = "); _tag_word .print(); printf("\n");
0N/A }
0N/A
0N/A};
0N/A
0N/Aclass Flag_Register {
0N/A public:
0N/A int32_t _value;
0N/A
0N/A bool overflow() const { return ((_value >> 11) & 1) != 0; }
0N/A bool direction() const { return ((_value >> 10) & 1) != 0; }
0N/A bool sign() const { return ((_value >> 7) & 1) != 0; }
0N/A bool zero() const { return ((_value >> 6) & 1) != 0; }
0N/A bool auxiliary_carry() const { return ((_value >> 4) & 1) != 0; }
0N/A bool parity() const { return ((_value >> 2) & 1) != 0; }
0N/A bool carry() const { return ((_value >> 0) & 1) != 0; }
0N/A
0N/A void print() const {
0N/A // flags
0N/A char f[8];
0N/A f[0] = (overflow ()) ? 'O' : '-';
0N/A f[1] = (direction ()) ? 'D' : '-';
0N/A f[2] = (sign ()) ? 'S' : '-';
0N/A f[3] = (zero ()) ? 'Z' : '-';
0N/A f[4] = (auxiliary_carry()) ? 'A' : '-';
0N/A f[5] = (parity ()) ? 'P' : '-';
0N/A f[6] = (carry ()) ? 'C' : '-';
0N/A f[7] = '\x0';
0N/A // output
0N/A printf("%08x flags = %s", _value, f);
0N/A }
0N/A
0N/A};
0N/A
0N/Aclass IU_Register {
0N/A public:
0N/A int32_t _value;
0N/A
0N/A void print() const {
0N/A printf("%08x %11d", _value, _value);
0N/A }
0N/A
0N/A};
0N/A
0N/Aclass IU_State {
0N/A public:
0N/A Flag_Register _eflags;
0N/A IU_Register _rdi;
0N/A IU_Register _rsi;
0N/A IU_Register _rbp;
0N/A IU_Register _rsp;
0N/A IU_Register _rbx;
0N/A IU_Register _rdx;
0N/A IU_Register _rcx;
0N/A IU_Register _rax;
0N/A
0N/A void print() const {
0N/A // computation registers
0N/A printf("rax, = "); _rax.print(); printf("\n");
0N/A printf("rbx, = "); _rbx.print(); printf("\n");
0N/A printf("rcx = "); _rcx.print(); printf("\n");
0N/A printf("rdx = "); _rdx.print(); printf("\n");
0N/A printf("rdi = "); _rdi.print(); printf("\n");
0N/A printf("rsi = "); _rsi.print(); printf("\n");
0N/A printf("rbp, = "); _rbp.print(); printf("\n");
0N/A printf("rsp = "); _rsp.print(); printf("\n");
0N/A printf("\n");
0N/A // control registers
0N/A printf("flgs = "); _eflags.print(); printf("\n");
0N/A }
0N/A};
0N/A
0N/A
0N/Aclass CPU_State {
0N/A public:
0N/A FPU_State _fpu_state;
0N/A IU_State _iu_state;
0N/A
0N/A void print() const {
0N/A printf("--------------------------------------------------\n");
0N/A _iu_state .print();
0N/A printf("\n");
0N/A _fpu_state.print();
0N/A printf("--------------------------------------------------\n");
0N/A }
0N/A
0N/A};
0N/A
0N/A
0N/Astatic void _print_CPU_state(CPU_State* state) {
0N/A state->print();
0N/A};
0N/A
0N/A
0N/Avoid MacroAssembler::print_CPU_state() {
0N/A push_CPU_state();
304N/A push(rsp); // pass CPU state
0N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, _print_CPU_state)));
304N/A addptr(rsp, wordSize); // discard argument
0N/A pop_CPU_state();
0N/A}
0N/A
0N/A
0N/Astatic bool _verify_FPU(int stack_depth, char* s, CPU_State* state) {
0N/A static int counter = 0;
0N/A FPU_State* fs = &state->_fpu_state;
0N/A counter++;
0N/A // For leaf calls, only verify that the top few elements remain empty.
0N/A // We only need 1 empty at the top for C2 code.
0N/A if( stack_depth < 0 ) {
0N/A if( fs->tag_for_st(7) != 3 ) {
0N/A printf("FPR7 not empty\n");
0N/A state->print();
0N/A assert(false, "error");
0N/A return false;
0N/A }
0N/A return true; // All other stack states do not matter
0N/A }
0N/A
0N/A assert((fs->_control_word._value & 0xffff) == StubRoutines::_fpu_cntrl_wrd_std,
0N/A "bad FPU control word");
0N/A
0N/A // compute stack depth
0N/A int i = 0;
0N/A while (i < FPU_State::number_of_registers && fs->tag_for_st(i) < 3) i++;
0N/A int d = i;
0N/A while (i < FPU_State::number_of_registers && fs->tag_for_st(i) == 3) i++;
0N/A // verify findings
0N/A if (i != FPU_State::number_of_registers) {
0N/A // stack not contiguous
0N/A printf("%s: stack not contiguous at ST%d\n", s, i);
0N/A state->print();
0N/A assert(false, "error");
0N/A return false;
0N/A }
0N/A // check if computed stack depth corresponds to expected stack depth
0N/A if (stack_depth < 0) {
0N/A // expected stack depth is -stack_depth or less
0N/A if (d > -stack_depth) {
0N/A // too many elements on the stack
0N/A printf("%s: <= %d stack elements expected but found %d\n", s, -stack_depth, d);
0N/A state->print();
0N/A assert(false, "error");
0N/A return false;
0N/A }
0N/A } else {
0N/A // expected stack depth is stack_depth
0N/A if (d != stack_depth) {
0N/A // wrong stack depth
0N/A printf("%s: %d stack elements expected but found %d\n", s, stack_depth, d);
0N/A state->print();
0N/A assert(false, "error");
0N/A return false;
0N/A }
0N/A }
0N/A // everything is cool
0N/A return true;
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::verify_FPU(int stack_depth, const char* s) {
0N/A if (!VerifyFPU) return;
0N/A push_CPU_state();
304N/A push(rsp); // pass CPU state
0N/A ExternalAddress msg((address) s);
0N/A // pass message string s
0N/A pushptr(msg.addr());
304N/A push(stack_depth); // pass stack depth
0N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, _verify_FPU)));
304N/A addptr(rsp, 3 * wordSize); // discard arguments
0N/A // check for error
0N/A { Label L;
0N/A testl(rax, rax);
0N/A jcc(Assembler::notZero, L);
0N/A int3(); // break if error condition
0N/A bind(L);
0N/A }
0N/A pop_CPU_state();
0N/A}
0N/A
304N/Avoid MacroAssembler::load_klass(Register dst, Register src) {
304N/A#ifdef _LP64
304N/A if (UseCompressedOops) {
304N/A movl(dst, Address(src, oopDesc::klass_offset_in_bytes()));
304N/A decode_heap_oop_not_null(dst);
304N/A } else
304N/A#endif
304N/A movptr(dst, Address(src, oopDesc::klass_offset_in_bytes()));
304N/A}
304N/A
304N/Avoid MacroAssembler::load_prototype_header(Register dst, Register src) {
304N/A#ifdef _LP64
304N/A if (UseCompressedOops) {
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
304N/A movl(dst, Address(src, oopDesc::klass_offset_in_bytes()));
642N/A if (Universe::narrow_oop_shift() != 0) {
1491N/A assert(LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
1491N/A if (LogMinObjAlignmentInBytes == Address::times_8) {
3042N/A movq(dst, Address(r12_heapbase, dst, Address::times_8, Klass::prototype_header_offset()));
1491N/A } else {
1491N/A // OK to use shift since we don't need to preserve flags.
1491N/A shlq(dst, LogMinObjAlignmentInBytes);
3042N/A movq(dst, Address(r12_heapbase, dst, Address::times_1, Klass::prototype_header_offset()));
1491N/A }
642N/A } else {
3042N/A movq(dst, Address(dst, Klass::prototype_header_offset()));
642N/A }
304N/A } else
304N/A#endif
642N/A {
642N/A movptr(dst, Address(src, oopDesc::klass_offset_in_bytes()));
3042N/A movptr(dst, Address(dst, Klass::prototype_header_offset()));
642N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::store_klass(Register dst, Register src) {
304N/A#ifdef _LP64
304N/A if (UseCompressedOops) {
304N/A encode_heap_oop_not_null(src);
304N/A movl(Address(dst, oopDesc::klass_offset_in_bytes()), src);
304N/A } else
304N/A#endif
304N/A movptr(Address(dst, oopDesc::klass_offset_in_bytes()), src);
304N/A}
304N/A
1766N/Avoid MacroAssembler::load_heap_oop(Register dst, Address src) {
1766N/A#ifdef _LP64
1766N/A if (UseCompressedOops) {
1766N/A movl(dst, src);
1766N/A decode_heap_oop(dst);
1766N/A } else
1766N/A#endif
1766N/A movptr(dst, src);
1766N/A}
1766N/A
2311N/A// Doesn't do verfication, generates fixed size code
2311N/Avoid MacroAssembler::load_heap_oop_not_null(Register dst, Address src) {
2311N/A#ifdef _LP64
2311N/A if (UseCompressedOops) {
2311N/A movl(dst, src);
2311N/A decode_heap_oop_not_null(dst);
2311N/A } else
2311N/A#endif
2311N/A movptr(dst, src);
2311N/A}
2311N/A
1766N/Avoid MacroAssembler::store_heap_oop(Address dst, Register src) {
1766N/A#ifdef _LP64
1766N/A if (UseCompressedOops) {
1766N/A assert(!dst.uses(src), "not enough registers");
1766N/A encode_heap_oop(src);
1766N/A movl(dst, src);
1766N/A } else
1766N/A#endif
1766N/A movptr(dst, src);
1766N/A}
1766N/A
3932N/Avoid MacroAssembler::cmp_heap_oop(Register src1, Address src2, Register tmp) {
3932N/A assert_different_registers(src1, tmp);
3932N/A#ifdef _LP64
3932N/A if (UseCompressedOops) {
3932N/A bool did_push = false;
3932N/A if (tmp == noreg) {
3932N/A tmp = rax;
3932N/A push(tmp);
3932N/A did_push = true;
3932N/A assert(!src2.uses(rsp), "can't push");
3932N/A }
3932N/A load_heap_oop(tmp, src2);
3932N/A cmpptr(src1, tmp);
3932N/A if (did_push) pop(tmp);
3932N/A } else
3932N/A#endif
3932N/A cmpptr(src1, src2);
3932N/A}
3932N/A
1766N/A// Used for storing NULLs.
1766N/Avoid MacroAssembler::store_heap_oop_null(Address dst) {
1766N/A#ifdef _LP64
1766N/A if (UseCompressedOops) {
1766N/A movl(dst, (int32_t)NULL_WORD);
1766N/A } else {
1766N/A movslq(dst, (int32_t)NULL_WORD);
1766N/A }
1766N/A#else
1766N/A movl(dst, (int32_t)NULL_WORD);
1766N/A#endif
1766N/A}
1766N/A
304N/A#ifdef _LP64
304N/Avoid MacroAssembler::store_klass_gap(Register dst, Register src) {
304N/A if (UseCompressedOops) {
304N/A // Store to klass gap in destination
304N/A movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src);
304N/A }
304N/A}
304N/A
1604N/A#ifdef ASSERT
1604N/Avoid MacroAssembler::verify_heapbase(const char* msg) {
1604N/A assert (UseCompressedOops, "should be compressed");
1604N/A assert (Universe::heap() != NULL, "java heap should be initialized");
1604N/A if (CheckCompressedOops) {
1604N/A Label ok;
1604N/A push(rscratch1); // cmpptr trashes rscratch1
1604N/A cmpptr(r12_heapbase, ExternalAddress((address)Universe::narrow_oop_base_addr()));
1604N/A jcc(Assembler::equal, ok);
3932N/A STOP(msg);
1604N/A bind(ok);
1604N/A pop(rscratch1);
1604N/A }
1604N/A}
1604N/A#endif
1604N/A
304N/A// Algorithm must match oop.inline.hpp encode_heap_oop.
304N/Avoid MacroAssembler::encode_heap_oop(Register r) {
1604N/A#ifdef ASSERT
1604N/A verify_heapbase("MacroAssembler::encode_heap_oop: heap base corrupted?");
1604N/A#endif
1604N/A verify_oop(r, "broken oop in encode_heap_oop");
642N/A if (Universe::narrow_oop_base() == NULL) {
642N/A if (Universe::narrow_oop_shift() != 0) {
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
642N/A shrq(r, LogMinObjAlignmentInBytes);
642N/A }
642N/A return;
642N/A }
304N/A testq(r, r);
304N/A cmovq(Assembler::equal, r, r12_heapbase);
304N/A subq(r, r12_heapbase);
304N/A shrq(r, LogMinObjAlignmentInBytes);
304N/A}
304N/A
304N/Avoid MacroAssembler::encode_heap_oop_not_null(Register r) {
0N/A#ifdef ASSERT
1604N/A verify_heapbase("MacroAssembler::encode_heap_oop_not_null: heap base corrupted?");
304N/A if (CheckCompressedOops) {
0N/A Label ok;
304N/A testq(r, r);
304N/A jcc(Assembler::notEqual, ok);
3932N/A STOP("null oop passed to encode_heap_oop_not_null");
0N/A bind(ok);
304N/A }
304N/A#endif
304N/A verify_oop(r, "broken oop in encode_heap_oop_not_null");
642N/A if (Universe::narrow_oop_base() != NULL) {
642N/A subq(r, r12_heapbase);
642N/A }
642N/A if (Universe::narrow_oop_shift() != 0) {
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
642N/A shrq(r, LogMinObjAlignmentInBytes);
642N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::encode_heap_oop_not_null(Register dst, Register src) {
304N/A#ifdef ASSERT
1604N/A verify_heapbase("MacroAssembler::encode_heap_oop_not_null2: heap base corrupted?");
304N/A if (CheckCompressedOops) {
304N/A Label ok;
304N/A testq(src, src);
304N/A jcc(Assembler::notEqual, ok);
3932N/A STOP("null oop passed to encode_heap_oop_not_null2");
304N/A bind(ok);
0N/A }
0N/A#endif
304N/A verify_oop(src, "broken oop in encode_heap_oop_not_null2");
304N/A if (dst != src) {
304N/A movq(dst, src);
304N/A }
642N/A if (Universe::narrow_oop_base() != NULL) {
642N/A subq(dst, r12_heapbase);
642N/A }
642N/A if (Universe::narrow_oop_shift() != 0) {
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
642N/A shrq(dst, LogMinObjAlignmentInBytes);
642N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::decode_heap_oop(Register r) {
1604N/A#ifdef ASSERT
1604N/A verify_heapbase("MacroAssembler::decode_heap_oop: heap base corrupted?");
1604N/A#endif
642N/A if (Universe::narrow_oop_base() == NULL) {
642N/A if (Universe::narrow_oop_shift() != 0) {
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
642N/A shlq(r, LogMinObjAlignmentInBytes);
642N/A }
1604N/A } else {
1604N/A Label done;
1604N/A shlq(r, LogMinObjAlignmentInBytes);
1604N/A jccb(Assembler::equal, done);
1604N/A addq(r, r12_heapbase);
1604N/A bind(done);
1604N/A }
304N/A verify_oop(r, "broken oop in decode_heap_oop");
304N/A}
304N/A
304N/Avoid MacroAssembler::decode_heap_oop_not_null(Register r) {
1491N/A // Note: it will change flags
304N/A assert (UseCompressedOops, "should only be used for compressed headers");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
304N/A // Cannot assert, unverified entry point counts instructions (see .ad file)
304N/A // vtableStubs also counts instructions in pd_code_size_limit.
304N/A // Also do not verify_oop as this is called by verify_oop.
898N/A if (Universe::narrow_oop_shift() != 0) {
1491N/A assert(LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
1491N/A shlq(r, LogMinObjAlignmentInBytes);
1491N/A if (Universe::narrow_oop_base() != NULL) {
1491N/A addq(r, r12_heapbase);
1491N/A }
642N/A } else {
898N/A assert (Universe::narrow_oop_base() == NULL, "sanity");
642N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::decode_heap_oop_not_null(Register dst, Register src) {
1491N/A // Note: it will change flags
304N/A assert (UseCompressedOops, "should only be used for compressed headers");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
304N/A // Cannot assert, unverified entry point counts instructions (see .ad file)
304N/A // vtableStubs also counts instructions in pd_code_size_limit.
304N/A // Also do not verify_oop as this is called by verify_oop.
642N/A if (Universe::narrow_oop_shift() != 0) {
1491N/A assert(LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
1491N/A if (LogMinObjAlignmentInBytes == Address::times_8) {
1491N/A leaq(dst, Address(r12_heapbase, src, Address::times_8, 0));
1491N/A } else {
1491N/A if (dst != src) {
1491N/A movq(dst, src);
1491N/A }
1491N/A shlq(dst, LogMinObjAlignmentInBytes);
1491N/A if (Universe::narrow_oop_base() != NULL) {
1491N/A addq(dst, r12_heapbase);
1491N/A }
1491N/A }
1604N/A } else {
898N/A assert (Universe::narrow_oop_base() == NULL, "sanity");
1604N/A if (dst != src) {
1604N/A movq(dst, src);
1604N/A }
642N/A }
304N/A}
304N/A
304N/Avoid MacroAssembler::set_narrow_oop(Register dst, jobject obj) {
642N/A assert (UseCompressedOops, "should only be used for compressed headers");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
642N/A int oop_index = oop_recorder()->find_index(obj);
642N/A RelocationHolder rspec = oop_Relocation::spec(oop_index);
642N/A mov_narrow_oop(dst, oop_index, rspec);
642N/A}
642N/A
642N/Avoid MacroAssembler::set_narrow_oop(Address dst, jobject obj) {
642N/A assert (UseCompressedOops, "should only be used for compressed headers");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
304N/A int oop_index = oop_recorder()->find_index(obj);
304N/A RelocationHolder rspec = oop_Relocation::spec(oop_index);
642N/A mov_narrow_oop(dst, oop_index, rspec);
642N/A}
642N/A
642N/Avoid MacroAssembler::cmp_narrow_oop(Register dst, jobject obj) {
642N/A assert (UseCompressedOops, "should only be used for compressed headers");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
642N/A int oop_index = oop_recorder()->find_index(obj);
642N/A RelocationHolder rspec = oop_Relocation::spec(oop_index);
642N/A Assembler::cmp_narrow_oop(dst, oop_index, rspec);
642N/A}
642N/A
642N/Avoid MacroAssembler::cmp_narrow_oop(Address dst, jobject obj) {
642N/A assert (UseCompressedOops, "should only be used for compressed headers");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
642N/A int oop_index = oop_recorder()->find_index(obj);
642N/A RelocationHolder rspec = oop_Relocation::spec(oop_index);
642N/A Assembler::cmp_narrow_oop(dst, oop_index, rspec);
304N/A}
304N/A
304N/Avoid MacroAssembler::reinit_heapbase() {
304N/A if (UseCompressedOops) {
642N/A movptr(r12_heapbase, ExternalAddress((address)Universe::narrow_oop_base_addr()));
304N/A }
304N/A}
304N/A#endif // _LP64
0N/A
3236N/A
3236N/A// C2 compiled method's prolog code.
3236N/Avoid MacroAssembler::verified_entry(int framesize, bool stack_bang, bool fp_mode_24b) {
3236N/A
3236N/A // WARNING: Initial instruction MUST be 5 bytes or longer so that
3236N/A // NativeJump::patch_verified_entry will be able to patch out the entry
3236N/A // code safely. The push to verify stack depth is ok at 5 bytes,
3236N/A // the frame allocation can be either 3 or 6 bytes. So if we don't do
3236N/A // stack bang then we must use the 6 byte frame allocation even if
3236N/A // we have no frame. :-(
3236N/A
3236N/A assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
3236N/A // Remove word for return addr
3236N/A framesize -= wordSize;
3236N/A
3236N/A // Calls to C2R adapters often do not accept exceptional returns.
3236N/A // We require that their callers must bang for them. But be careful, because
3236N/A // some VM calls (such as call site linkage) can use several kilobytes of
3236N/A // stack. But the stack safety zone should account for that.
3236N/A // See bugs 4446381, 4468289, 4497237.
3236N/A if (stack_bang) {
3236N/A generate_stack_overflow_check(framesize);
3236N/A
3236N/A // We always push rbp, so that on return to interpreter rbp, will be
3236N/A // restored correctly and we can correct the stack.
3236N/A push(rbp);
3236N/A // Remove word for ebp
3236N/A framesize -= wordSize;
3236N/A
3236N/A // Create frame
3236N/A if (framesize) {
3236N/A subptr(rsp, framesize);
3236N/A }
3236N/A } else {
3236N/A // Create frame (force generation of a 4 byte immediate value)
3236N/A subptr_imm32(rsp, framesize);
3236N/A
3236N/A // Save RBP register now.
3236N/A framesize -= wordSize;
3236N/A movptr(Address(rsp, framesize), rbp);
3236N/A }
3236N/A
3236N/A if (VerifyStackAtCalls) { // Majik cookie to verify stack depth
3236N/A framesize -= wordSize;
3236N/A movptr(Address(rsp, framesize), (int32_t)0xbadb100d);
3236N/A }
3236N/A
3236N/A#ifndef _LP64
3236N/A // If method sets FPU control word do it now
3236N/A if (fp_mode_24b) {
3236N/A fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
3236N/A }
3236N/A if (UseSSE >= 2 && VerifyFPU) {
3236N/A verify_FPU(0, "FPU stack must be clean on entry");
3236N/A }
3236N/A#endif
3236N/A
3236N/A#ifdef ASSERT
3236N/A if (VerifyStackAtCalls) {
3236N/A Label L;
3236N/A push(rax);
3236N/A mov(rax, rsp);
3236N/A andptr(rax, StackAlignmentInBytes-1);
3236N/A cmpptr(rax, StackAlignmentInBytes-wordSize);
3236N/A pop(rax);
3236N/A jcc(Assembler::equal, L);
3932N/A STOP("Stack is not properly aligned!");
3236N/A bind(L);
3236N/A }
3236N/A#endif
3236N/A
3236N/A}
3236N/A
3236N/A
2167N/A// IndexOf for constant substrings with size >= 8 chars
2167N/A// which don't need to be loaded through stack.
2167N/Avoid MacroAssembler::string_indexofC8(Register str1, Register str2,
2167N/A Register cnt1, Register cnt2,
2167N/A int int_cnt2, Register result,
2167N/A XMMRegister vec, Register tmp) {
3046N/A ShortBranchVerifier sbv(this);
986N/A assert(UseSSE42Intrinsics, "SSE4.2 is required");
986N/A
2167N/A // This method uses pcmpestri inxtruction with bound registers
986N/A // inputs:
986N/A // xmm - substring
986N/A // rax - substring length (elements count)
2167N/A // mem - scanned string
2167N/A // rdx - string length (elements count)
2167N/A // 0xd - mode: 1100 (substring search) + 01 (unsigned shorts)
2167N/A // outputs:
2167N/A // rcx - matched index in string
2167N/A assert(cnt1 == rdx && cnt2 == rax && tmp == rcx, "pcmpestri");
2167N/A
2167N/A Label RELOAD_SUBSTR, SCAN_TO_SUBSTR, SCAN_SUBSTR,
2167N/A RET_FOUND, RET_NOT_FOUND, EXIT, FOUND_SUBSTR,
2167N/A MATCH_SUBSTR_HEAD, RELOAD_STR, FOUND_CANDIDATE;
2167N/A
2167N/A // Note, inline_string_indexOf() generates checks:
2167N/A // if (substr.count > string.count) return -1;
2167N/A // if (substr.count == 0) return 0;
2167N/A assert(int_cnt2 >= 8, "this code isused only for cnt2 >= 8 chars");
2167N/A
2167N/A // Load substring.
2167N/A movdqu(vec, Address(str2, 0));
2167N/A movl(cnt2, int_cnt2);
2167N/A movptr(result, str1); // string addr
2167N/A
2167N/A if (int_cnt2 > 8) {
2167N/A jmpb(SCAN_TO_SUBSTR);
2167N/A
2167N/A // Reload substr for rescan, this code
2167N/A // is executed only for large substrings (> 8 chars)
2167N/A bind(RELOAD_SUBSTR);
2167N/A movdqu(vec, Address(str2, 0));
2167N/A negptr(cnt2); // Jumped here with negative cnt2, convert to positive
2167N/A
2167N/A bind(RELOAD_STR);
2167N/A // We came here after the beginning of the substring was
2167N/A // matched but the rest of it was not so we need to search
2167N/A // again. Start from the next element after the previous match.
2167N/A
2167N/A // cnt2 is number of substring reminding elements and
2167N/A // cnt1 is number of string reminding elements when cmp failed.
2167N/A // Restored cnt1 = cnt1 - cnt2 + int_cnt2
2167N/A subl(cnt1, cnt2);
2167N/A addl(cnt1, int_cnt2);
2167N/A movl(cnt2, int_cnt2); // Now restore cnt2
2167N/A
2167N/A decrementl(cnt1); // Shift to next element
2167N/A cmpl(cnt1, cnt2);
2167N/A jccb(Assembler::negative, RET_NOT_FOUND); // Left less then substring
2167N/A
2167N/A addptr(result, 2);
2167N/A
2167N/A } // (int_cnt2 > 8)
2167N/A
2167N/A // Scan string for start of substr in 16-byte vectors
2167N/A bind(SCAN_TO_SUBSTR);
2167N/A pcmpestri(vec, Address(result, 0), 0x0d);
2167N/A jccb(Assembler::below, FOUND_CANDIDATE); // CF == 1
2167N/A subl(cnt1, 8);
2167N/A jccb(Assembler::lessEqual, RET_NOT_FOUND); // Scanned full string
2167N/A cmpl(cnt1, cnt2);
2167N/A jccb(Assembler::negative, RET_NOT_FOUND); // Left less then substring
2167N/A addptr(result, 16);
2167N/A jmpb(SCAN_TO_SUBSTR);
2167N/A
2167N/A // Found a potential substr
2167N/A bind(FOUND_CANDIDATE);
2167N/A // Matched whole vector if first element matched (tmp(rcx) == 0).
2167N/A if (int_cnt2 == 8) {
2167N/A jccb(Assembler::overflow, RET_FOUND); // OF == 1
2167N/A } else { // int_cnt2 > 8
2167N/A jccb(Assembler::overflow, FOUND_SUBSTR);
2167N/A }
2167N/A // After pcmpestri tmp(rcx) contains matched element index
2167N/A // Compute start addr of substr
2167N/A lea(result, Address(result, tmp, Address::times_2));
2167N/A
2167N/A // Make sure string is still long enough
2167N/A subl(cnt1, tmp);
2167N/A cmpl(cnt1, cnt2);
2167N/A if (int_cnt2 == 8) {
2167N/A jccb(Assembler::greaterEqual, SCAN_TO_SUBSTR);
2167N/A } else { // int_cnt2 > 8
2167N/A jccb(Assembler::greaterEqual, MATCH_SUBSTR_HEAD);
2167N/A }
2167N/A // Left less then substring.
2167N/A
2167N/A bind(RET_NOT_FOUND);
2167N/A movl(result, -1);
2167N/A jmpb(EXIT);
2167N/A
2167N/A if (int_cnt2 > 8) {
2167N/A // This code is optimized for the case when whole substring
2167N/A // is matched if its head is matched.
2167N/A bind(MATCH_SUBSTR_HEAD);
2167N/A pcmpestri(vec, Address(result, 0), 0x0d);
2167N/A // Reload only string if does not match
2167N/A jccb(Assembler::noOverflow, RELOAD_STR); // OF == 0
2167N/A
2167N/A Label CONT_SCAN_SUBSTR;
2167N/A // Compare the rest of substring (> 8 chars).
2167N/A bind(FOUND_SUBSTR);
2167N/A // First 8 chars are already matched.
2167N/A negptr(cnt2);
2167N/A addptr(cnt2, 8);
2167N/A
2167N/A bind(SCAN_SUBSTR);
2167N/A subl(cnt1, 8);
2167N/A cmpl(cnt2, -8); // Do not read beyond substring
2167N/A jccb(Assembler::lessEqual, CONT_SCAN_SUBSTR);
2167N/A // Back-up strings to avoid reading beyond substring:
2167N/A // cnt1 = cnt1 - cnt2 + 8
2167N/A addl(cnt1, cnt2); // cnt2 is negative
2167N/A addl(cnt1, 8);
2167N/A movl(cnt2, 8); negptr(cnt2);
2167N/A bind(CONT_SCAN_SUBSTR);
2167N/A if (int_cnt2 < (int)G) {
2167N/A movdqu(vec, Address(str2, cnt2, Address::times_2, int_cnt2*2));
2167N/A pcmpestri(vec, Address(result, cnt2, Address::times_2, int_cnt2*2), 0x0d);
2167N/A } else {
2167N/A // calculate index in register to avoid integer overflow (int_cnt2*2)
2167N/A movl(tmp, int_cnt2);
2167N/A addptr(tmp, cnt2);
2167N/A movdqu(vec, Address(str2, tmp, Address::times_2, 0));
2167N/A pcmpestri(vec, Address(result, tmp, Address::times_2, 0), 0x0d);
2167N/A }
2167N/A // Need to reload strings pointers if not matched whole vector
3046N/A jcc(Assembler::noOverflow, RELOAD_SUBSTR); // OF == 0
2167N/A addptr(cnt2, 8);
3046N/A jcc(Assembler::negative, SCAN_SUBSTR);
2167N/A // Fall through if found full substring
2167N/A
2167N/A } // (int_cnt2 > 8)
2167N/A
2167N/A bind(RET_FOUND);
2167N/A // Found result if we matched full small substring.
2167N/A // Compute substr offset
2167N/A subptr(result, str1);
2167N/A shrl(result, 1); // index
2167N/A bind(EXIT);
2167N/A
2167N/A} // string_indexofC8
2167N/A
2167N/A// Small strings are loaded through stack if they cross page boundary.
2167N/Avoid MacroAssembler::string_indexof(Register str1, Register str2,
2167N/A Register cnt1, Register cnt2,
2167N/A int int_cnt2, Register result,
2167N/A XMMRegister vec, Register tmp) {
3046N/A ShortBranchVerifier sbv(this);
2167N/A assert(UseSSE42Intrinsics, "SSE4.2 is required");
2167N/A //
2167N/A // int_cnt2 is length of small (< 8 chars) constant substring
2167N/A // or (-1) for non constant substring in which case its length
2167N/A // is in cnt2 register.
2167N/A //
2167N/A // Note, inline_string_indexOf() generates checks:
2167N/A // if (substr.count > string.count) return -1;
2167N/A // if (substr.count == 0) return 0;
2167N/A //
2167N/A assert(int_cnt2 == -1 || (0 < int_cnt2 && int_cnt2 < 8), "should be != 0");
2167N/A
2167N/A // This method uses pcmpestri inxtruction with bound registers
2167N/A // inputs:
2167N/A // xmm - substring
2167N/A // rax - substring length (elements count)
2167N/A // mem - scanned string
986N/A // rdx - string length (elements count)
986N/A // 0xd - mode: 1100 (substring search) + 01 (unsigned shorts)
986N/A // outputs:
986N/A // rcx - matched index in string
986N/A assert(cnt1 == rdx && cnt2 == rax && tmp == rcx, "pcmpestri");
986N/A
2167N/A Label RELOAD_SUBSTR, SCAN_TO_SUBSTR, SCAN_SUBSTR, ADJUST_STR,
2167N/A RET_FOUND, RET_NOT_FOUND, CLEANUP, FOUND_SUBSTR,
2167N/A FOUND_CANDIDATE;
2167N/A
2167N/A { //========================================================
2167N/A // We don't know where these strings are located
2167N/A // and we can't read beyond them. Load them through stack.
2167N/A Label BIG_STRINGS, CHECK_STR, COPY_SUBSTR, COPY_STR;
2167N/A
2167N/A movptr(tmp, rsp); // save old SP
2167N/A
2167N/A if (int_cnt2 > 0) { // small (< 8 chars) constant substring
2167N/A if (int_cnt2 == 1) { // One char
2167N/A load_unsigned_short(result, Address(str2, 0));
2167N/A movdl(vec, result); // move 32 bits
2167N/A } else if (int_cnt2 == 2) { // Two chars
2167N/A movdl(vec, Address(str2, 0)); // move 32 bits
2167N/A } else if (int_cnt2 == 4) { // Four chars
2167N/A movq(vec, Address(str2, 0)); // move 64 bits
2167N/A } else { // cnt2 = { 3, 5, 6, 7 }
2167N/A // Array header size is 12 bytes in 32-bit VM
2167N/A // + 6 bytes for 3 chars == 18 bytes,
2167N/A // enough space to load vec and shift.
2167N/A assert(HeapWordSize*typeArrayKlass::header_size() >= 12,"sanity");
2167N/A movdqu(vec, Address(str2, (int_cnt2*2)-16));
2167N/A psrldq(vec, 16-(int_cnt2*2));
2167N/A }
2167N/A } else { // not constant substring
2167N/A cmpl(cnt2, 8);
2167N/A jccb(Assembler::aboveEqual, BIG_STRINGS); // Both strings are big enough
2167N/A
2167N/A // We can read beyond string if srt+16 does not cross page boundary
2167N/A // since heaps are aligned and mapped by pages.
2167N/A assert(os::vm_page_size() < (int)G, "default page should be small");
2167N/A movl(result, str2); // We need only low 32 bits
2167N/A andl(result, (os::vm_page_size()-1));
2167N/A cmpl(result, (os::vm_page_size()-16));
2167N/A jccb(Assembler::belowEqual, CHECK_STR);
2167N/A
2167N/A // Move small strings to stack to allow load 16 bytes into vec.
2167N/A subptr(rsp, 16);
2167N/A int stk_offset = wordSize-2;
2167N/A push(cnt2);
2167N/A
2167N/A bind(COPY_SUBSTR);
2167N/A load_unsigned_short(result, Address(str2, cnt2, Address::times_2, -2));
2167N/A movw(Address(rsp, cnt2, Address::times_2, stk_offset), result);
2167N/A decrement(cnt2);
2167N/A jccb(Assembler::notZero, COPY_SUBSTR);
2167N/A
2167N/A pop(cnt2);
2167N/A movptr(str2, rsp); // New substring address
2167N/A } // non constant
2167N/A
2167N/A bind(CHECK_STR);
2167N/A cmpl(cnt1, 8);
2167N/A jccb(Assembler::aboveEqual, BIG_STRINGS);
2167N/A
2167N/A // Check cross page boundary.
2167N/A movl(result, str1); // We need only low 32 bits
2167N/A andl(result, (os::vm_page_size()-1));
2167N/A cmpl(result, (os::vm_page_size()-16));
2167N/A jccb(Assembler::belowEqual, BIG_STRINGS);
2167N/A
2167N/A subptr(rsp, 16);
2167N/A int stk_offset = -2;
2167N/A if (int_cnt2 < 0) { // not constant
2167N/A push(cnt2);
2167N/A stk_offset += wordSize;
2167N/A }
2167N/A movl(cnt2, cnt1);
2167N/A
2167N/A bind(COPY_STR);
2167N/A load_unsigned_short(result, Address(str1, cnt2, Address::times_2, -2));
2167N/A movw(Address(rsp, cnt2, Address::times_2, stk_offset), result);
2167N/A decrement(cnt2);
2167N/A jccb(Assembler::notZero, COPY_STR);
2167N/A
2167N/A if (int_cnt2 < 0) { // not constant
2167N/A pop(cnt2);
2167N/A }
2167N/A movptr(str1, rsp); // New string address
2167N/A
2167N/A bind(BIG_STRINGS);
2167N/A // Load substring.
2167N/A if (int_cnt2 < 0) { // -1
2167N/A movdqu(vec, Address(str2, 0));
2167N/A push(cnt2); // substr count
2167N/A push(str2); // substr addr
2167N/A push(str1); // string addr
2167N/A } else {
2167N/A // Small (< 8 chars) constant substrings are loaded already.
2167N/A movl(cnt2, int_cnt2);
2167N/A }
2167N/A push(tmp); // original SP
2167N/A
2167N/A } // Finished loading
2167N/A
2167N/A //========================================================
2167N/A // Start search
2167N/A //
2167N/A
2167N/A movptr(result, str1); // string addr
2167N/A
2167N/A if (int_cnt2 < 0) { // Only for non constant substring
2167N/A jmpb(SCAN_TO_SUBSTR);
2167N/A
2167N/A // SP saved at sp+0
2167N/A // String saved at sp+1*wordSize
2167N/A // Substr saved at sp+2*wordSize
2167N/A // Substr count saved at sp+3*wordSize
2167N/A
2167N/A // Reload substr for rescan, this code
2167N/A // is executed only for large substrings (> 8 chars)
2167N/A bind(RELOAD_SUBSTR);
2167N/A movptr(str2, Address(rsp, 2*wordSize));
2167N/A movl(cnt2, Address(rsp, 3*wordSize));
2167N/A movdqu(vec, Address(str2, 0));
2167N/A // We came here after the beginning of the substring was
2167N/A // matched but the rest of it was not so we need to search
2167N/A // again. Start from the next element after the previous match.
2167N/A subptr(str1, result); // Restore counter
2167N/A shrl(str1, 1);
2167N/A addl(cnt1, str1);
2167N/A decrementl(cnt1); // Shift to next element
2167N/A cmpl(cnt1, cnt2);
2167N/A jccb(Assembler::negative, RET_NOT_FOUND); // Left less then substring
2167N/A
2167N/A addptr(result, 2);
2167N/A } // non constant
2167N/A
2167N/A // Scan string for start of substr in 16-byte vectors
2167N/A bind(SCAN_TO_SUBSTR);
2167N/A assert(cnt1 == rdx && cnt2 == rax && tmp == rcx, "pcmpestri");
2167N/A pcmpestri(vec, Address(result, 0), 0x0d);
2167N/A jccb(Assembler::below, FOUND_CANDIDATE); // CF == 1
2167N/A subl(cnt1, 8);
2167N/A jccb(Assembler::lessEqual, RET_NOT_FOUND); // Scanned full string
2167N/A cmpl(cnt1, cnt2);
2167N/A jccb(Assembler::negative, RET_NOT_FOUND); // Left less then substring
2167N/A addptr(result, 16);
2167N/A
2167N/A bind(ADJUST_STR);
2167N/A cmpl(cnt1, 8); // Do not read beyond string
2167N/A jccb(Assembler::greaterEqual, SCAN_TO_SUBSTR);
2167N/A // Back-up string to avoid reading beyond string.
2167N/A lea(result, Address(result, cnt1, Address::times_2, -16));
2167N/A movl(cnt1, 8);
2167N/A jmpb(SCAN_TO_SUBSTR);
2167N/A
2167N/A // Found a potential substr
2167N/A bind(FOUND_CANDIDATE);
2167N/A // After pcmpestri tmp(rcx) contains matched element index
986N/A
986N/A // Make sure string is still long enough
986N/A subl(cnt1, tmp);
986N/A cmpl(cnt1, cnt2);
2167N/A jccb(Assembler::greaterEqual, FOUND_SUBSTR);
2167N/A // Left less then substring.
986N/A
986N/A bind(RET_NOT_FOUND);
986N/A movl(result, -1);
2167N/A jmpb(CLEANUP);
2167N/A
2167N/A bind(FOUND_SUBSTR);
2167N/A // Compute start addr of substr
2167N/A lea(result, Address(result, tmp, Address::times_2));
2167N/A
2167N/A if (int_cnt2 > 0) { // Constant substring
2167N/A // Repeat search for small substring (< 8 chars)
2167N/A // from new point without reloading substring.
2167N/A // Have to check that we don't read beyond string.
2167N/A cmpl(tmp, 8-int_cnt2);
2167N/A jccb(Assembler::greater, ADJUST_STR);
2167N/A // Fall through if matched whole substring.
2167N/A } else { // non constant
2167N/A assert(int_cnt2 == -1, "should be != 0");
2167N/A
2167N/A addl(tmp, cnt2);
2167N/A // Found result if we matched whole substring.
2167N/A cmpl(tmp, 8);
2167N/A jccb(Assembler::lessEqual, RET_FOUND);
2167N/A
2167N/A // Repeat search for small substring (<= 8 chars)
2167N/A // from new point 'str1' without reloading substring.
2167N/A cmpl(cnt2, 8);
2167N/A // Have to check that we don't read beyond string.
2167N/A jccb(Assembler::lessEqual, ADJUST_STR);
2167N/A
2167N/A Label CHECK_NEXT, CONT_SCAN_SUBSTR, RET_FOUND_LONG;
2167N/A // Compare the rest of substring (> 8 chars).
2167N/A movptr(str1, result);
2167N/A
2167N/A cmpl(tmp, cnt2);
2167N/A // First 8 chars are already matched.
2167N/A jccb(Assembler::equal, CHECK_NEXT);
2167N/A
2167N/A bind(SCAN_SUBSTR);
2167N/A pcmpestri(vec, Address(str1, 0), 0x0d);
2167N/A // Need to reload strings pointers if not matched whole vector
2167N/A jcc(Assembler::noOverflow, RELOAD_SUBSTR); // OF == 0
2167N/A
2167N/A bind(CHECK_NEXT);
2167N/A subl(cnt2, 8);
2167N/A jccb(Assembler::lessEqual, RET_FOUND_LONG); // Found full substring
2167N/A addptr(str1, 16);
2167N/A addptr(str2, 16);
2167N/A subl(cnt1, 8);
2167N/A cmpl(cnt2, 8); // Do not read beyond substring
2167N/A jccb(Assembler::greaterEqual, CONT_SCAN_SUBSTR);
2167N/A // Back-up strings to avoid reading beyond substring.
2167N/A lea(str2, Address(str2, cnt2, Address::times_2, -16));
2167N/A lea(str1, Address(str1, cnt2, Address::times_2, -16));
2167N/A subl(cnt1, cnt2);
2167N/A movl(cnt2, 8);
2167N/A addl(cnt1, 8);
2167N/A bind(CONT_SCAN_SUBSTR);
2167N/A movdqu(vec, Address(str2, 0));
2167N/A jmpb(SCAN_SUBSTR);
2167N/A
2167N/A bind(RET_FOUND_LONG);
2167N/A movptr(str1, Address(rsp, wordSize));
2167N/A } // non constant
2167N/A
2167N/A bind(RET_FOUND);
2167N/A // Compute substr offset
2167N/A subptr(result, str1);
2167N/A shrl(result, 1); // index
986N/A
986N/A bind(CLEANUP);
2167N/A pop(rsp); // restore SP
2167N/A
2167N/A} // string_indexof
986N/A
986N/A// Compare strings.
986N/Avoid MacroAssembler::string_compare(Register str1, Register str2,
986N/A Register cnt1, Register cnt2, Register result,
2134N/A XMMRegister vec1) {
3046N/A ShortBranchVerifier sbv(this);
986N/A Label LENGTH_DIFF_LABEL, POP_LABEL, DONE_LABEL, WHILE_HEAD_LABEL;
986N/A
986N/A // Compute the minimum of the string lengths and the
986N/A // difference of the string lengths (stack).
986N/A // Do the conditional move stuff
986N/A movl(result, cnt1);
986N/A subl(cnt1, cnt2);
986N/A push(cnt1);
2262N/A cmov32(Assembler::lessEqual, cnt2, result);
986N/A
986N/A // Is the minimum length zero?
986N/A testl(cnt2, cnt2);
986N/A jcc(Assembler::zero, LENGTH_DIFF_LABEL);
986N/A
986N/A // Load first characters
986N/A load_unsigned_short(result, Address(str1, 0));
986N/A load_unsigned_short(cnt1, Address(str2, 0));
986N/A
986N/A // Compare first characters
986N/A subl(result, cnt1);
986N/A jcc(Assembler::notZero, POP_LABEL);
986N/A decrementl(cnt2);
986N/A jcc(Assembler::zero, LENGTH_DIFF_LABEL);
986N/A
986N/A {
986N/A // Check after comparing first character to see if strings are equivalent
986N/A Label LSkip2;
986N/A // Check if the strings start at same location
986N/A cmpptr(str1, str2);
986N/A jccb(Assembler::notEqual, LSkip2);
986N/A
986N/A // Check if the length difference is zero (from stack)
986N/A cmpl(Address(rsp, 0), 0x0);
986N/A jcc(Assembler::equal, LENGTH_DIFF_LABEL);
986N/A
986N/A // Strings might not be equivalent
986N/A bind(LSkip2);
986N/A }
986N/A
2134N/A Address::ScaleFactor scale = Address::times_2;
2134N/A int stride = 8;
2134N/A
2134N/A // Advance to next element
2134N/A addptr(str1, 16/stride);
2134N/A addptr(str2, 16/stride);
986N/A
986N/A if (UseSSE42Intrinsics) {
2134N/A Label COMPARE_WIDE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL;
2134N/A int pcmpmask = 0x19;
986N/A // Setup to compare 16-byte vectors
2134N/A movl(result, cnt2);
2134N/A andl(cnt2, ~(stride - 1)); // cnt2 holds the vector count
986N/A jccb(Assembler::zero, COMPARE_TAIL);
986N/A
2134N/A lea(str1, Address(str1, result, scale));
2134N/A lea(str2, Address(str2, result, scale));
2134N/A negptr(result);
2134N/A
2134N/A // pcmpestri
2134N/A // inputs:
2134N/A // vec1- substring
2134N/A // rax - negative string length (elements count)
2134N/A // mem - scaned string
2134N/A // rdx - string length (elements count)
2134N/A // pcmpmask - cmp mode: 11000 (string compare with negated result)
2134N/A // + 00 (unsigned bytes) or + 01 (unsigned shorts)
2134N/A // outputs:
2134N/A // rcx - first mismatched element index
2134N/A assert(result == rax && cnt2 == rdx && cnt1 == rcx, "pcmpestri");
2134N/A
2134N/A bind(COMPARE_WIDE_VECTORS);
2134N/A movdqu(vec1, Address(str1, result, scale));
2134N/A pcmpestri(vec1, Address(str2, result, scale), pcmpmask);
2134N/A // After pcmpestri cnt1(rcx) contains mismatched element index
2134N/A
2134N/A jccb(Assembler::below, VECTOR_NOT_EQUAL); // CF==1
2134N/A addptr(result, stride);
2134N/A subptr(cnt2, stride);
2134N/A jccb(Assembler::notZero, COMPARE_WIDE_VECTORS);
2134N/A
2134N/A // compare wide vectors tail
2134N/A testl(result, result);
2134N/A jccb(Assembler::zero, LENGTH_DIFF_LABEL);
2134N/A
2134N/A movl(cnt2, stride);
2134N/A movl(result, stride);
2134N/A negptr(result);
2134N/A movdqu(vec1, Address(str1, result, scale));
2134N/A pcmpestri(vec1, Address(str2, result, scale), pcmpmask);
2134N/A jccb(Assembler::aboveEqual, LENGTH_DIFF_LABEL);
986N/A
986N/A // Mismatched characters in the vectors
986N/A bind(VECTOR_NOT_EQUAL);
2134N/A addptr(result, cnt1);
2134N/A movptr(cnt2, result);
2134N/A load_unsigned_short(result, Address(str1, cnt2, scale));
2134N/A load_unsigned_short(cnt1, Address(str2, cnt2, scale));
2134N/A subl(result, cnt1);
2134N/A jmpb(POP_LABEL);
2134N/A
2134N/A bind(COMPARE_TAIL); // limit is zero
2134N/A movl(cnt2, result);
986N/A // Fallthru to tail compare
986N/A }
986N/A
986N/A // Shift str2 and str1 to the end of the arrays, negate min
2134N/A lea(str1, Address(str1, cnt2, scale, 0));
2134N/A lea(str2, Address(str2, cnt2, scale, 0));
986N/A negptr(cnt2);
986N/A
2134N/A // Compare the rest of the elements
986N/A bind(WHILE_HEAD_LABEL);
2134N/A load_unsigned_short(result, Address(str1, cnt2, scale, 0));
2134N/A load_unsigned_short(cnt1, Address(str2, cnt2, scale, 0));
986N/A subl(result, cnt1);
986N/A jccb(Assembler::notZero, POP_LABEL);
986N/A increment(cnt2);
2134N/A jccb(Assembler::notZero, WHILE_HEAD_LABEL);
986N/A
986N/A // Strings are equal up to min length. Return the length difference.
986N/A bind(LENGTH_DIFF_LABEL);
986N/A pop(result);
986N/A jmpb(DONE_LABEL);
986N/A
986N/A // Discard the stored length difference
986N/A bind(POP_LABEL);
2134N/A pop(cnt1);
986N/A
986N/A // That's it
986N/A bind(DONE_LABEL);
986N/A}
986N/A
986N/A// Compare char[] arrays aligned to 4 bytes or substrings.
986N/Avoid MacroAssembler::char_arrays_equals(bool is_array_equ, Register ary1, Register ary2,
986N/A Register limit, Register result, Register chr,
986N/A XMMRegister vec1, XMMRegister vec2) {
3046N/A ShortBranchVerifier sbv(this);
986N/A Label TRUE_LABEL, FALSE_LABEL, DONE, COMPARE_VECTORS, COMPARE_CHAR;
986N/A
986N/A int length_offset = arrayOopDesc::length_offset_in_bytes();
986N/A int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
986N/A
986N/A // Check the input args
986N/A cmpptr(ary1, ary2);
986N/A jcc(Assembler::equal, TRUE_LABEL);
986N/A
986N/A if (is_array_equ) {
986N/A // Need additional checks for arrays_equals.
1016N/A testptr(ary1, ary1);
1016N/A jcc(Assembler::zero, FALSE_LABEL);
1016N/A testptr(ary2, ary2);
1016N/A jcc(Assembler::zero, FALSE_LABEL);
986N/A
986N/A // Check the lengths
986N/A movl(limit, Address(ary1, length_offset));
986N/A cmpl(limit, Address(ary2, length_offset));
986N/A jcc(Assembler::notEqual, FALSE_LABEL);
986N/A }
986N/A
986N/A // count == 0
986N/A testl(limit, limit);
986N/A jcc(Assembler::zero, TRUE_LABEL);
986N/A
986N/A if (is_array_equ) {
986N/A // Load array address
986N/A lea(ary1, Address(ary1, base_offset));
986N/A lea(ary2, Address(ary2, base_offset));
986N/A }
986N/A
986N/A shll(limit, 1); // byte count != 0
986N/A movl(result, limit); // copy
986N/A
986N/A if (UseSSE42Intrinsics) {
986N/A // With SSE4.2, use double quad vector compare
986N/A Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
2134N/A
986N/A // Compare 16-byte vectors
986N/A andl(result, 0x0000000e); // tail count (in bytes)
986N/A andl(limit, 0xfffffff0); // vector count (in bytes)
986N/A jccb(Assembler::zero, COMPARE_TAIL);
986N/A
986N/A lea(ary1, Address(ary1, limit, Address::times_1));
986N/A lea(ary2, Address(ary2, limit, Address::times_1));
986N/A negptr(limit);
986N/A
986N/A bind(COMPARE_WIDE_VECTORS);
986N/A movdqu(vec1, Address(ary1, limit, Address::times_1));
986N/A movdqu(vec2, Address(ary2, limit, Address::times_1));
986N/A pxor(vec1, vec2);
2134N/A
986N/A ptest(vec1, vec1);
986N/A jccb(Assembler::notZero, FALSE_LABEL);
986N/A addptr(limit, 16);
986N/A jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
986N/A
2134N/A testl(result, result);
2134N/A jccb(Assembler::zero, TRUE_LABEL);
2134N/A
2134N/A movdqu(vec1, Address(ary1, result, Address::times_1, -16));
2134N/A movdqu(vec2, Address(ary2, result, Address::times_1, -16));
2134N/A pxor(vec1, vec2);
2134N/A
2134N/A ptest(vec1, vec1);
2134N/A jccb(Assembler::notZero, FALSE_LABEL);
2134N/A jmpb(TRUE_LABEL);
2134N/A
986N/A bind(COMPARE_TAIL); // limit is zero
986N/A movl(limit, result);
986N/A // Fallthru to tail compare
986N/A }
986N/A
986N/A // Compare 4-byte vectors
986N/A andl(limit, 0xfffffffc); // vector count (in bytes)
986N/A jccb(Assembler::zero, COMPARE_CHAR);
986N/A
986N/A lea(ary1, Address(ary1, limit, Address::times_1));
986N/A lea(ary2, Address(ary2, limit, Address::times_1));
986N/A negptr(limit);
986N/A
986N/A bind(COMPARE_VECTORS);
986N/A movl(chr, Address(ary1, limit, Address::times_1));
986N/A cmpl(chr, Address(ary2, limit, Address::times_1));
986N/A jccb(Assembler::notEqual, FALSE_LABEL);
986N/A addptr(limit, 4);
986N/A jcc(Assembler::notZero, COMPARE_VECTORS);
986N/A
986N/A // Compare trailing char (final 2 bytes), if any
986N/A bind(COMPARE_CHAR);
986N/A testl(result, 0x2); // tail char
986N/A jccb(Assembler::zero, TRUE_LABEL);
986N/A load_unsigned_short(chr, Address(ary1, 0));
986N/A load_unsigned_short(limit, Address(ary2, 0));
986N/A cmpl(chr, limit);
986N/A jccb(Assembler::notEqual, FALSE_LABEL);
986N/A
986N/A bind(TRUE_LABEL);
986N/A movl(result, 1); // return true
986N/A jmpb(DONE);
986N/A
986N/A bind(FALSE_LABEL);
986N/A xorl(result, result); // return false
986N/A
986N/A // That's it
986N/A bind(DONE);
986N/A}
986N/A
1683N/Avoid MacroAssembler::generate_fill(BasicType t, bool aligned,
1683N/A Register to, Register value, Register count,
1683N/A Register rtmp, XMMRegister xtmp) {
3046N/A ShortBranchVerifier sbv(this);
1683N/A assert_different_registers(to, value, count, rtmp);
1683N/A Label L_exit, L_skip_align1, L_skip_align2, L_fill_byte;
1683N/A Label L_fill_2_bytes, L_fill_4_bytes;
1683N/A
1683N/A int shift = -1;
1683N/A switch (t) {
1683N/A case T_BYTE:
1683N/A shift = 2;
1683N/A break;
1683N/A case T_SHORT:
1683N/A shift = 1;
1683N/A break;
1683N/A case T_INT:
1683N/A shift = 0;
1683N/A break;
1683N/A default: ShouldNotReachHere();
1683N/A }
1683N/A
1683N/A if (t == T_BYTE) {
1683N/A andl(value, 0xff);
1683N/A movl(rtmp, value);
1683N/A shll(rtmp, 8);
1683N/A orl(value, rtmp);
1683N/A }
1683N/A if (t == T_SHORT) {
1683N/A andl(value, 0xffff);
1683N/A }
1683N/A if (t == T_BYTE || t == T_SHORT) {
1683N/A movl(rtmp, value);
1683N/A shll(rtmp, 16);
1683N/A orl(value, rtmp);
1683N/A }
1683N/A
1683N/A cmpl(count, 2<<shift); // Short arrays (< 8 bytes) fill by element
1683N/A jcc(Assembler::below, L_fill_4_bytes); // use unsigned cmp
1683N/A if (!UseUnalignedLoadStores && !aligned && (t == T_BYTE || t == T_SHORT)) {
1683N/A // align source address at 4 bytes address boundary
1683N/A if (t == T_BYTE) {
1683N/A // One byte misalignment happens only for byte arrays
1683N/A testptr(to, 1);
1683N/A jccb(Assembler::zero, L_skip_align1);
1683N/A movb(Address(to, 0), value);
1683N/A increment(to);
1683N/A decrement(count);
1683N/A BIND(L_skip_align1);
1683N/A }
1683N/A // Two bytes misalignment happens only for byte and short (char) arrays
1683N/A testptr(to, 2);
1683N/A jccb(Assembler::zero, L_skip_align2);
1683N/A movw(Address(to, 0), value);
1683N/A addptr(to, 2);
1683N/A subl(count, 1<<(shift-1));
1683N/A BIND(L_skip_align2);
1683N/A }
1683N/A if (UseSSE < 2) {
1683N/A Label L_fill_32_bytes_loop, L_check_fill_8_bytes, L_fill_8_bytes_loop, L_fill_8_bytes;
1683N/A // Fill 32-byte chunks
1683N/A subl(count, 8 << shift);
1683N/A jcc(Assembler::less, L_check_fill_8_bytes);
1683N/A align(16);
1683N/A
1683N/A BIND(L_fill_32_bytes_loop);
1683N/A
1683N/A for (int i = 0; i < 32; i += 4) {
1683N/A movl(Address(to, i), value);
1683N/A }
1683N/A
1683N/A addptr(to, 32);
1683N/A subl(count, 8 << shift);
1683N/A jcc(Assembler::greaterEqual, L_fill_32_bytes_loop);
1683N/A BIND(L_check_fill_8_bytes);
1683N/A addl(count, 8 << shift);
1683N/A jccb(Assembler::zero, L_exit);
1683N/A jmpb(L_fill_8_bytes);
1683N/A
1683N/A //
1683N/A // length is too short, just fill qwords
1683N/A //
1683N/A BIND(L_fill_8_bytes_loop);
1683N/A movl(Address(to, 0), value);
1683N/A movl(Address(to, 4), value);
1683N/A addptr(to, 8);
1683N/A BIND(L_fill_8_bytes);
1683N/A subl(count, 1 << (shift + 1));
1683N/A jcc(Assembler::greaterEqual, L_fill_8_bytes_loop);
1683N/A // fall through to fill 4 bytes
1683N/A } else {
1683N/A Label L_fill_32_bytes;
1683N/A if (!UseUnalignedLoadStores) {
1683N/A // align to 8 bytes, we know we are 4 byte aligned to start
1683N/A testptr(to, 4);
1683N/A jccb(Assembler::zero, L_fill_32_bytes);
1683N/A movl(Address(to, 0), value);
1683N/A addptr(to, 4);
1683N/A subl(count, 1<<shift);
1683N/A }
1683N/A BIND(L_fill_32_bytes);
1683N/A {
1683N/A assert( UseSSE >= 2, "supported cpu only" );
1683N/A Label L_fill_32_bytes_loop, L_check_fill_8_bytes, L_fill_8_bytes_loop, L_fill_8_bytes;
1683N/A // Fill 32-byte chunks
1683N/A movdl(xtmp, value);
1683N/A pshufd(xtmp, xtmp, 0);
1683N/A
1683N/A subl(count, 8 << shift);
1683N/A jcc(Assembler::less, L_check_fill_8_bytes);
1683N/A align(16);
1683N/A
1683N/A BIND(L_fill_32_bytes_loop);
1683N/A
1683N/A if (UseUnalignedLoadStores) {
1683N/A movdqu(Address(to, 0), xtmp);
1683N/A movdqu(Address(to, 16), xtmp);
1683N/A } else {
1683N/A movq(Address(to, 0), xtmp);
1683N/A movq(Address(to, 8), xtmp);
1683N/A movq(Address(to, 16), xtmp);
1683N/A movq(Address(to, 24), xtmp);
1683N/A }
1683N/A
1683N/A addptr(to, 32);
1683N/A subl(count, 8 << shift);
1683N/A jcc(Assembler::greaterEqual, L_fill_32_bytes_loop);
1683N/A BIND(L_check_fill_8_bytes);
1683N/A addl(count, 8 << shift);
1683N/A jccb(Assembler::zero, L_exit);
1683N/A jmpb(L_fill_8_bytes);
1683N/A
1683N/A //
1683N/A // length is too short, just fill qwords
1683N/A //
1683N/A BIND(L_fill_8_bytes_loop);
1683N/A movq(Address(to, 0), xtmp);
1683N/A addptr(to, 8);
1683N/A BIND(L_fill_8_bytes);
1683N/A subl(count, 1 << (shift + 1));
1683N/A jcc(Assembler::greaterEqual, L_fill_8_bytes_loop);
1683N/A }
1683N/A }
1683N/A // fill trailing 4 bytes
1683N/A BIND(L_fill_4_bytes);
1683N/A testl(count, 1<<shift);
1683N/A jccb(Assembler::zero, L_fill_2_bytes);
1683N/A movl(Address(to, 0), value);
1683N/A if (t == T_BYTE || t == T_SHORT) {
1683N/A addptr(to, 4);
1683N/A BIND(L_fill_2_bytes);
1683N/A // fill trailing 2 bytes
1683N/A testl(count, 1<<(shift-1));
1683N/A jccb(Assembler::zero, L_fill_byte);
1683N/A movw(Address(to, 0), value);
1683N/A if (t == T_BYTE) {
1683N/A addptr(to, 2);
1683N/A BIND(L_fill_byte);
1683N/A // fill trailing byte
1683N/A testl(count, 1);
1683N/A jccb(Assembler::zero, L_exit);
1683N/A movb(Address(to, 0), value);
1683N/A } else {
1683N/A BIND(L_fill_byte);
1683N/A }
1683N/A } else {
1683N/A BIND(L_fill_2_bytes);
1683N/A }
1683N/A BIND(L_exit);
1683N/A}
1683N/A#undef BIND
1683N/A#undef BLOCK_COMMENT
1683N/A
1683N/A
0N/AAssembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
0N/A switch (cond) {
0N/A // Note some conditions are synonyms for others
0N/A case Assembler::zero: return Assembler::notZero;
0N/A case Assembler::notZero: return Assembler::zero;
0N/A case Assembler::less: return Assembler::greaterEqual;
0N/A case Assembler::lessEqual: return Assembler::greater;
0N/A case Assembler::greater: return Assembler::lessEqual;
0N/A case Assembler::greaterEqual: return Assembler::less;
0N/A case Assembler::below: return Assembler::aboveEqual;
0N/A case Assembler::belowEqual: return Assembler::above;
0N/A case Assembler::above: return Assembler::belowEqual;
0N/A case Assembler::aboveEqual: return Assembler::below;
0N/A case Assembler::overflow: return Assembler::noOverflow;
0N/A case Assembler::noOverflow: return Assembler::overflow;
0N/A case Assembler::negative: return Assembler::positive;
0N/A case Assembler::positive: return Assembler::negative;
0N/A case Assembler::parity: return Assembler::noParity;
0N/A case Assembler::noParity: return Assembler::parity;
0N/A }
0N/A ShouldNotReachHere(); return Assembler::overflow;
0N/A}
0N/A
0N/ASkipIfEqual::SkipIfEqual(
0N/A MacroAssembler* masm, const bool* flag_addr, bool value) {
0N/A _masm = masm;
0N/A _masm->cmp8(ExternalAddress((address)flag_addr), value);
0N/A _masm->jcc(Assembler::equal, _label);
0N/A}
0N/A
0N/ASkipIfEqual::~SkipIfEqual() {
0N/A _masm->bind(_label);
0N/A}