comparison src/cpu/x86/vm/assembler_x86.cpp @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents c38f13903fdf a3ecd773a7b9
children 291ffc492eb6
comparison
equal deleted inserted replaced
6711:ae13cc658b80 6948:e522a00b91aa
55 AddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) { 55 AddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) {
56 _is_lval = false; 56 _is_lval = false;
57 _target = target; 57 _target = target;
58 switch (rtype) { 58 switch (rtype) {
59 case relocInfo::oop_type: 59 case relocInfo::oop_type:
60 case relocInfo::metadata_type:
60 // Oops are a special case. Normally they would be their own section 61 // Oops are a special case. Normally they would be their own section
61 // but in cases like icBuffer they are literals in the code stream that 62 // but in cases like icBuffer they are literals in the code stream that
62 // we don't have a section for. We use none so that we get a literal address 63 // we don't have a section for. We use none so that we get a literal address
63 // which is always patchable. 64 // which is always patchable.
64 break; 65 break;
152 153
153 154
154 // Convert the raw encoding form into the form expected by the constructor for 155 // Convert the raw encoding form into the form expected by the constructor for
155 // Address. An index of 4 (rsp) corresponds to having no index, so convert 156 // Address. An index of 4 (rsp) corresponds to having no index, so convert
156 // that to noreg for the Address constructor. 157 // that to noreg for the Address constructor.
157 Address Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) { 158 Address Address::make_raw(int base, int index, int scale, int disp, relocInfo::relocType disp_reloc) {
158 RelocationHolder rspec; 159 RelocationHolder rspec;
159 if (disp_is_oop) { 160 if (disp_reloc != relocInfo::none) {
160 rspec = Relocation::spec_simple(relocInfo::oop_type); 161 rspec = Relocation::spec_simple(disp_reloc);
161 } 162 }
162 bool valid_index = index != rsp->encoding(); 163 bool valid_index = index != rsp->encoding();
163 if (valid_index) { 164 if (valid_index) {
164 Address madr(as_Register(base), as_Register(index), (Address::ScaleFactor)scale, in_ByteSize(disp)); 165 Address madr(as_Register(base), as_Register(index), (Address::ScaleFactor)scale, in_ByteSize(disp));
165 madr._rspec = rspec; 166 madr._rspec = rspec;
266 } else { 267 } else {
267 emit_byte(op1); 268 emit_byte(op1);
268 emit_operand(rm, adr, 4); 269 emit_operand(rm, adr, 4);
269 emit_long(imm32); 270 emit_long(imm32);
270 } 271 }
271 }
272
273 void Assembler::emit_arith(int op1, int op2, Register dst, jobject obj) {
274 LP64_ONLY(ShouldNotReachHere());
275 assert(isByte(op1) && isByte(op2), "wrong opcode");
276 assert((op1 & 0x01) == 1, "should be 32bit operation");
277 assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
278 InstructionMark im(this);
279 emit_byte(op1);
280 emit_byte(op2 | encode(dst));
281 emit_data((intptr_t)obj, relocInfo::oop_type, 0);
282 } 272 }
283 273
284 274
285 void Assembler::emit_arith(int op1, int op2, Register dst, Register src) { 275 void Assembler::emit_arith(int op1, int op2, Register dst, Register src) {
286 assert(isByte(op1) && isByte(op2), "wrong opcode"); 276 assert(isByte(op1) && isByte(op2), "wrong opcode");
1015 void Assembler::addss(XMMRegister dst, Address src) { 1005 void Assembler::addss(XMMRegister dst, Address src) {
1016 NOT_LP64(assert(VM_Version::supports_sse(), "")); 1006 NOT_LP64(assert(VM_Version::supports_sse(), ""));
1017 emit_simd_arith(0x58, dst, src, VEX_SIMD_F3); 1007 emit_simd_arith(0x58, dst, src, VEX_SIMD_F3);
1018 } 1008 }
1019 1009
1010 void Assembler::aesdec(XMMRegister dst, Address src) {
1011 assert(VM_Version::supports_aes(), "");
1012 InstructionMark im(this);
1013 simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1014 emit_byte(0xde);
1015 emit_operand(dst, src);
1016 }
1017
1018 void Assembler::aesdec(XMMRegister dst, XMMRegister src) {
1019 assert(VM_Version::supports_aes(), "");
1020 int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1021 emit_byte(0xde);
1022 emit_byte(0xC0 | encode);
1023 }
1024
1025 void Assembler::aesdeclast(XMMRegister dst, Address src) {
1026 assert(VM_Version::supports_aes(), "");
1027 InstructionMark im(this);
1028 simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1029 emit_byte(0xdf);
1030 emit_operand(dst, src);
1031 }
1032
1033 void Assembler::aesdeclast(XMMRegister dst, XMMRegister src) {
1034 assert(VM_Version::supports_aes(), "");
1035 int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1036 emit_byte(0xdf);
1037 emit_byte(0xC0 | encode);
1038 }
1039
1040 void Assembler::aesenc(XMMRegister dst, Address src) {
1041 assert(VM_Version::supports_aes(), "");
1042 InstructionMark im(this);
1043 simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1044 emit_byte(0xdc);
1045 emit_operand(dst, src);
1046 }
1047
1048 void Assembler::aesenc(XMMRegister dst, XMMRegister src) {
1049 assert(VM_Version::supports_aes(), "");
1050 int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1051 emit_byte(0xdc);
1052 emit_byte(0xC0 | encode);
1053 }
1054
1055 void Assembler::aesenclast(XMMRegister dst, Address src) {
1056 assert(VM_Version::supports_aes(), "");
1057 InstructionMark im(this);
1058 simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1059 emit_byte(0xdd);
1060 emit_operand(dst, src);
1061 }
1062
1063 void Assembler::aesenclast(XMMRegister dst, XMMRegister src) {
1064 assert(VM_Version::supports_aes(), "");
1065 int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
1066 emit_byte(0xdd);
1067 emit_byte(0xC0 | encode);
1068 }
1069
1070
1020 void Assembler::andl(Address dst, int32_t imm32) { 1071 void Assembler::andl(Address dst, int32_t imm32) {
1021 InstructionMark im(this); 1072 InstructionMark im(this);
1022 prefix(dst); 1073 prefix(dst);
1023 emit_byte(0x81); 1074 emit_byte(0x81);
1024 emit_operand(rsp, dst, 4); 1075 emit_operand(rsp, dst, 4);
1178 1229
1179 // The 32-bit cmpxchg compares the value at adr with the contents of rax, 1230 // The 32-bit cmpxchg compares the value at adr with the contents of rax,
1180 // and stores reg into adr if so; otherwise, the value at adr is loaded into rax,. 1231 // and stores reg into adr if so; otherwise, the value at adr is loaded into rax,.
1181 // The ZF is set if the compared values were equal, and cleared otherwise. 1232 // The ZF is set if the compared values were equal, and cleared otherwise.
1182 void Assembler::cmpxchgl(Register reg, Address adr) { // cmpxchg 1233 void Assembler::cmpxchgl(Register reg, Address adr) { // cmpxchg
1183 if (Atomics & 2) { 1234 InstructionMark im(this);
1184 // caveat: no instructionmark, so this isn't relocatable. 1235 prefix(adr, reg);
1185 // Emit a synthetic, non-atomic, CAS equivalent. 1236 emit_byte(0x0F);
1186 // Beware. The synthetic form sets all ICCs, not just ZF. 1237 emit_byte(0xB1);
1187 // cmpxchg r,[m] is equivalent to rax, = CAS (m, rax, r) 1238 emit_operand(reg, adr);
1188 cmpl(rax, adr);
1189 movl(rax, adr);
1190 if (reg != rax) {
1191 Label L ;
1192 jcc(Assembler::notEqual, L);
1193 movl(adr, reg);
1194 bind(L);
1195 }
1196 } else {
1197 InstructionMark im(this);
1198 prefix(adr, reg);
1199 emit_byte(0x0F);
1200 emit_byte(0xB1);
1201 emit_operand(reg, adr);
1202 }
1203 } 1239 }
1204 1240
1205 void Assembler::comisd(XMMRegister dst, Address src) { 1241 void Assembler::comisd(XMMRegister dst, Address src) {
1206 // NOTE: dbx seems to decode this as comiss even though the 1242 // NOTE: dbx seems to decode this as comiss even though the
1207 // 0x66 is there. Strangly ucomisd comes out correct 1243 // 0x66 is there. Strangly ucomisd comes out correct
1521 emit_byte(0x8D); 1557 emit_byte(0x8D);
1522 emit_operand(dst, src); 1558 emit_operand(dst, src);
1523 } 1559 }
1524 1560
1525 void Assembler::lock() { 1561 void Assembler::lock() {
1526 if (Atomics & 1) { 1562 emit_byte(0xF0);
1527 // Emit either nothing, a NOP, or a NOP: prefix
1528 emit_byte(0x90) ;
1529 } else {
1530 emit_byte(0xF0);
1531 }
1532 } 1563 }
1533 1564
1534 void Assembler::lzcntl(Register dst, Register src) { 1565 void Assembler::lzcntl(Register dst, Register src) {
1535 assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR"); 1566 assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR");
1536 emit_byte(0xF3); 1567 emit_byte(0xF3);
2335 2366
2336 void Assembler::prefix(Prefix p) { 2367 void Assembler::prefix(Prefix p) {
2337 a_byte(p); 2368 a_byte(p);
2338 } 2369 }
2339 2370
2371 void Assembler::pshufb(XMMRegister dst, XMMRegister src) {
2372 assert(VM_Version::supports_ssse3(), "");
2373 int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
2374 emit_byte(0x00);
2375 emit_byte(0xC0 | encode);
2376 }
2377
2378 void Assembler::pshufb(XMMRegister dst, Address src) {
2379 assert(VM_Version::supports_ssse3(), "");
2380 assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
2381 InstructionMark im(this);
2382 simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38);
2383 emit_byte(0x00);
2384 emit_operand(dst, src);
2385 }
2386
2340 void Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) { 2387 void Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) {
2341 assert(isByte(mode), "invalid value"); 2388 assert(isByte(mode), "invalid value");
2342 NOT_LP64(assert(VM_Version::supports_sse2(), "")); 2389 NOT_LP64(assert(VM_Version::supports_sse2(), ""));
2343 emit_simd_arith_nonds(0x70, dst, src, VEX_SIMD_66); 2390 emit_simd_arith_nonds(0x70, dst, src, VEX_SIMD_66);
2344 emit_byte(mode & 0xFF); 2391 emit_byte(mode & 0xFF);
3504 // 0x00 - insert into lower 128 bits 3551 // 0x00 - insert into lower 128 bits
3505 // 0x01 - insert into upper 128 bits 3552 // 0x01 - insert into upper 128 bits
3506 emit_byte(0x01); 3553 emit_byte(0x01);
3507 } 3554 }
3508 3555
3556 void Assembler::vinsertf128h(XMMRegister dst, Address src) {
3557 assert(VM_Version::supports_avx(), "");
3558 InstructionMark im(this);
3559 bool vector256 = true;
3560 assert(dst != xnoreg, "sanity");
3561 int dst_enc = dst->encoding();
3562 // swap src<->dst for encoding
3563 vex_prefix(src, dst_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256);
3564 emit_byte(0x18);
3565 emit_operand(dst, src);
3566 // 0x01 - insert into upper 128 bits
3567 emit_byte(0x01);
3568 }
3569
3570 void Assembler::vextractf128h(Address dst, XMMRegister src) {
3571 assert(VM_Version::supports_avx(), "");
3572 InstructionMark im(this);
3573 bool vector256 = true;
3574 assert(src != xnoreg, "sanity");
3575 int src_enc = src->encoding();
3576 vex_prefix(dst, 0, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256);
3577 emit_byte(0x19);
3578 emit_operand(src, dst);
3579 // 0x01 - extract from upper 128 bits
3580 emit_byte(0x01);
3581 }
3582
3509 void Assembler::vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src) { 3583 void Assembler::vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src) {
3510 assert(VM_Version::supports_avx2(), ""); 3584 assert(VM_Version::supports_avx2(), "");
3511 bool vector256 = true; 3585 bool vector256 = true;
3512 int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A); 3586 int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A);
3513 emit_byte(0x38); 3587 emit_byte(0x38);
3514 emit_byte(0xC0 | encode); 3588 emit_byte(0xC0 | encode);
3515 // 0x00 - insert into lower 128 bits 3589 // 0x00 - insert into lower 128 bits
3516 // 0x01 - insert into upper 128 bits 3590 // 0x01 - insert into upper 128 bits
3591 emit_byte(0x01);
3592 }
3593
3594 void Assembler::vinserti128h(XMMRegister dst, Address src) {
3595 assert(VM_Version::supports_avx2(), "");
3596 InstructionMark im(this);
3597 bool vector256 = true;
3598 assert(dst != xnoreg, "sanity");
3599 int dst_enc = dst->encoding();
3600 // swap src<->dst for encoding
3601 vex_prefix(src, dst_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256);
3602 emit_byte(0x38);
3603 emit_operand(dst, src);
3604 // 0x01 - insert into upper 128 bits
3605 emit_byte(0x01);
3606 }
3607
3608 void Assembler::vextracti128h(Address dst, XMMRegister src) {
3609 assert(VM_Version::supports_avx2(), "");
3610 InstructionMark im(this);
3611 bool vector256 = true;
3612 assert(src != xnoreg, "sanity");
3613 int src_enc = src->encoding();
3614 vex_prefix(dst, 0, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256);
3615 emit_byte(0x39);
3616 emit_operand(src, dst);
3617 // 0x01 - extract from upper 128 bits
3517 emit_byte(0x01); 3618 emit_byte(0x01);
3518 } 3619 }
3519 3620
3520 void Assembler::vzeroupper() { 3621 void Assembler::vzeroupper() {
3521 assert(VM_Version::supports_avx(), ""); 3622 assert(VM_Version::supports_avx(), "");
5568 } 5669 }
5569 void MacroAssembler::call_VM_leaf_base(address entry_point, 5670 void MacroAssembler::call_VM_leaf_base(address entry_point,
5570 int number_of_arguments) { 5671 int number_of_arguments) {
5571 call(RuntimeAddress(entry_point)); 5672 call(RuntimeAddress(entry_point));
5572 increment(rsp, number_of_arguments * wordSize); 5673 increment(rsp, number_of_arguments * wordSize);
5674 }
5675
5676 void MacroAssembler::cmpklass(Address src1, Metadata* obj) {
5677 cmp_literal32(src1, (int32_t)obj, metadata_Relocation::spec_for_immediate());
5678 }
5679
5680 void MacroAssembler::cmpklass(Register src1, Metadata* obj) {
5681 cmp_literal32(src1, (int32_t)obj, metadata_Relocation::spec_for_immediate());
5573 } 5682 }
5574 5683
5575 void MacroAssembler::cmpoop(Address src1, jobject obj) { 5684 void MacroAssembler::cmpoop(Address src1, jobject obj) {
5576 cmp_literal32(src1, (int32_t)obj, oop_Relocation::spec_for_immediate()); 5685 cmp_literal32(src1, (int32_t)obj, oop_Relocation::spec_for_immediate());
5577 } 5686 }
5751 5860
5752 void MacroAssembler::movoop(Address dst, jobject obj) { 5861 void MacroAssembler::movoop(Address dst, jobject obj) {
5753 mov_literal32(dst, (int32_t)obj, oop_Relocation::spec_for_immediate()); 5862 mov_literal32(dst, (int32_t)obj, oop_Relocation::spec_for_immediate());
5754 } 5863 }
5755 5864
5865 void MacroAssembler::mov_metadata(Register dst, Metadata* obj) {
5866 mov_literal32(dst, (int32_t)obj, metadata_Relocation::spec_for_immediate());
5867 }
5868
5869 void MacroAssembler::mov_metadata(Address dst, Metadata* obj) {
5870 mov_literal32(dst, (int32_t)obj, metadata_Relocation::spec_for_immediate());
5871 }
5872
5756 void MacroAssembler::movptr(Register dst, AddressLiteral src) { 5873 void MacroAssembler::movptr(Register dst, AddressLiteral src) {
5757 if (src.is_lval()) { 5874 if (src.is_lval()) {
5758 mov_literal32(dst, (intptr_t)src.target(), src.rspec()); 5875 mov_literal32(dst, (intptr_t)src.target(), src.rspec());
5759 } else { 5876 } else {
5760 movl(dst, as_Address(src)); 5877 movl(dst, as_Address(src));
5802 5919
5803 void MacroAssembler::pushoop(jobject obj) { 5920 void MacroAssembler::pushoop(jobject obj) {
5804 push_literal32((int32_t)obj, oop_Relocation::spec_for_immediate()); 5921 push_literal32((int32_t)obj, oop_Relocation::spec_for_immediate());
5805 } 5922 }
5806 5923
5924 void MacroAssembler::pushklass(Metadata* obj) {
5925 push_literal32((int32_t)obj, metadata_Relocation::spec_for_immediate());
5926 }
5807 5927
5808 void MacroAssembler::pushptr(AddressLiteral src) { 5928 void MacroAssembler::pushptr(AddressLiteral src) {
5809 if (src.is_lval()) { 5929 if (src.is_lval()) {
5810 push_literal32((int32_t)src.target(), src.rspec()); 5930 push_literal32((int32_t)src.target(), src.rspec());
5811 } else { 5931 } else {
5854 // To see where a verify_oop failed, get $ebx+40/X for this frame. 5974 // To see where a verify_oop failed, get $ebx+40/X for this frame.
5855 // This is the value of eip which points to where verify_oop will return. 5975 // This is the value of eip which points to where verify_oop will return.
5856 if (os::message_box(msg, "Execution stopped, print registers?")) { 5976 if (os::message_box(msg, "Execution stopped, print registers?")) {
5857 print_state32(rdi, rsi, rbp, rsp, rbx, rdx, rcx, rax, eip); 5977 print_state32(rdi, rsi, rbp, rsp, rbx, rdx, rcx, rax, eip);
5858 BREAKPOINT; 5978 BREAKPOINT;
5859 assert(false, "start up GDB");
5860 } 5979 }
5861 } else { 5980 } else {
5862 ttyLocker ttyl; 5981 ttyLocker ttyl;
5863 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg); 5982 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
5983 }
5984 // Don't assert holding the ttyLock
5864 assert(false, err_msg("DEBUG MESSAGE: %s", msg)); 5985 assert(false, err_msg("DEBUG MESSAGE: %s", msg));
5865 }
5866 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state); 5986 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
5867 } 5987 }
5868 5988
5869 void MacroAssembler::print_state32(int rdi, int rsi, int rbp, int rsp, int rbx, int rdx, int rcx, int rax, int eip) { 5989 void MacroAssembler::print_state32(int rdi, int rsi, int rbp, int rsp, int rbx, int rdx, int rcx, int rax, int eip) {
5870 ttyLocker ttyl; 5990 ttyLocker ttyl;
6278 void MacroAssembler::movoop(Address dst, jobject obj) { 6398 void MacroAssembler::movoop(Address dst, jobject obj) {
6279 mov_literal64(rscratch1, (intptr_t)obj, oop_Relocation::spec_for_immediate()); 6399 mov_literal64(rscratch1, (intptr_t)obj, oop_Relocation::spec_for_immediate());
6280 movq(dst, rscratch1); 6400 movq(dst, rscratch1);
6281 } 6401 }
6282 6402
6403 void MacroAssembler::mov_metadata(Register dst, Metadata* obj) {
6404 mov_literal64(dst, (intptr_t)obj, metadata_Relocation::spec_for_immediate());
6405 }
6406
6407 void MacroAssembler::mov_metadata(Address dst, Metadata* obj) {
6408 mov_literal64(rscratch1, (intptr_t)obj, metadata_Relocation::spec_for_immediate());
6409 movq(dst, rscratch1);
6410 }
6411
6283 void MacroAssembler::movptr(Register dst, AddressLiteral src) { 6412 void MacroAssembler::movptr(Register dst, AddressLiteral src) {
6284 if (src.is_lval()) { 6413 if (src.is_lval()) {
6285 mov_literal64(dst, (intptr_t)src.target(), src.rspec()); 6414 mov_literal64(dst, (intptr_t)src.target(), src.rspec());
6286 } else { 6415 } else {
6287 if (reachable(src)) { 6416 if (reachable(src)) {
6316 mov64(dst, (intptr_t)src); 6445 mov64(dst, (intptr_t)src);
6317 } 6446 }
6318 6447
6319 void MacroAssembler::pushoop(jobject obj) { 6448 void MacroAssembler::pushoop(jobject obj) {
6320 movoop(rscratch1, obj); 6449 movoop(rscratch1, obj);
6450 push(rscratch1);
6451 }
6452
6453 void MacroAssembler::pushklass(Metadata* obj) {
6454 mov_metadata(rscratch1, obj);
6321 push(rscratch1); 6455 push(rscratch1);
6322 } 6456 }
6323 6457
6324 void MacroAssembler::pushptr(AddressLiteral src) { 6458 void MacroAssembler::pushptr(AddressLiteral src) {
6325 lea(rscratch1, src); 6459 lea(rscratch1, src);
6653 lea(rscratch1, entry); 6787 lea(rscratch1, entry);
6654 Assembler::call(rscratch1); 6788 Assembler::call(rscratch1);
6655 } 6789 }
6656 } 6790 }
6657 6791
6792 void MacroAssembler::ic_call(address entry) {
6793 RelocationHolder rh = virtual_call_Relocation::spec(pc());
6794 movptr(rax, (intptr_t)Universe::non_oop_word());
6795 call(AddressLiteral(entry, rh));
6796 }
6797
6658 // Implementation of call_VM versions 6798 // Implementation of call_VM versions
6659 6799
6660 void MacroAssembler::call_VM(Register oop_result, 6800 void MacroAssembler::call_VM(Register oop_result,
6661 address entry_point, 6801 address entry_point,
6662 bool check_exceptions) { 6802 bool check_exceptions) {
6851 assert(number_of_arguments >= 0 , "cannot have negative number of arguments"); 6991 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
6852 LP64_ONLY(assert(java_thread == r15_thread, "unexpected register")); 6992 LP64_ONLY(assert(java_thread == r15_thread, "unexpected register"));
6853 #ifdef ASSERT 6993 #ifdef ASSERT
6854 // TraceBytecodes does not use r12 but saves it over the call, so don't verify 6994 // TraceBytecodes does not use r12 but saves it over the call, so don't verify
6855 // r12 is the heapbase. 6995 // r12 is the heapbase.
6856 LP64_ONLY(if (UseCompressedOops && !TraceBytecodes) verify_heapbase("call_VM_base");) 6996 LP64_ONLY(if ((UseCompressedOops || UseCompressedKlassPointers) && !TraceBytecodes) verify_heapbase("call_VM_base: heap base corrupted?");)
6857 #endif // ASSERT 6997 #endif // ASSERT
6858 6998
6859 assert(java_thread != oop_result , "cannot use the same register for java_thread & oop_result"); 6999 assert(java_thread != oop_result , "cannot use the same register for java_thread & oop_result");
6860 assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp"); 7000 assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp");
6861 7001
6921 #endif // LP64 7061 #endif // LP64
6922 } 7062 }
6923 7063
6924 // get oop result if there is one and reset the value in the thread 7064 // get oop result if there is one and reset the value in the thread
6925 if (oop_result->is_valid()) { 7065 if (oop_result->is_valid()) {
6926 movptr(oop_result, Address(java_thread, JavaThread::vm_result_offset())); 7066 get_vm_result(oop_result, java_thread);
6927 movptr(Address(java_thread, JavaThread::vm_result_offset()), NULL_WORD);
6928 verify_oop(oop_result, "broken oop in call_VM_base");
6929 } 7067 }
6930 } 7068 }
6931 7069
6932 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) { 7070 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
6933 7071
7012 pass_arg2(this, arg_2); 7150 pass_arg2(this, arg_2);
7013 LP64_ONLY(assert(arg_0 != c_rarg1, "smashed arg")); 7151 LP64_ONLY(assert(arg_0 != c_rarg1, "smashed arg"));
7014 pass_arg1(this, arg_1); 7152 pass_arg1(this, arg_1);
7015 pass_arg0(this, arg_0); 7153 pass_arg0(this, arg_0);
7016 MacroAssembler::call_VM_leaf_base(entry_point, 4); 7154 MacroAssembler::call_VM_leaf_base(entry_point, 4);
7155 }
7156
7157 void MacroAssembler::get_vm_result(Register oop_result, Register java_thread) {
7158 movptr(oop_result, Address(java_thread, JavaThread::vm_result_offset()));
7159 movptr(Address(java_thread, JavaThread::vm_result_offset()), NULL_WORD);
7160 verify_oop(oop_result, "broken oop in call_VM_base");
7161 }
7162
7163 void MacroAssembler::get_vm_result_2(Register metadata_result, Register java_thread) {
7164 movptr(metadata_result, Address(java_thread, JavaThread::vm_result_2_offset()));
7165 movptr(Address(java_thread, JavaThread::vm_result_2_offset()), NULL_WORD);
7017 } 7166 }
7018 7167
7019 void MacroAssembler::check_and_handle_earlyret(Register java_thread) { 7168 void MacroAssembler::check_and_handle_earlyret(Register java_thread) {
7020 } 7169 }
7021 7170
7993 8142
7994 void MacroAssembler::movptr(Address dst, Register src) { 8143 void MacroAssembler::movptr(Address dst, Register src) {
7995 LP64_ONLY(movq(dst, src)) NOT_LP64(movl(dst, src)); 8144 LP64_ONLY(movq(dst, src)) NOT_LP64(movl(dst, src));
7996 } 8145 }
7997 8146
8147 void MacroAssembler::movdqu(XMMRegister dst, AddressLiteral src) {
8148 if (reachable(src)) {
8149 Assembler::movdqu(dst, as_Address(src));
8150 } else {
8151 lea(rscratch1, src);
8152 Assembler::movdqu(dst, Address(rscratch1, 0));
8153 }
8154 }
8155
7998 void MacroAssembler::movsd(XMMRegister dst, AddressLiteral src) { 8156 void MacroAssembler::movsd(XMMRegister dst, AddressLiteral src) {
7999 if (reachable(src)) { 8157 if (reachable(src)) {
8000 Assembler::movsd(dst, as_Address(src)); 8158 Assembler::movsd(dst, as_Address(src));
8001 } else { 8159 } else {
8002 lea(rscratch1, src); 8160 lea(rscratch1, src);
8283 lea(rscratch1, src); 8441 lea(rscratch1, src);
8284 Assembler::xorps(dst, Address(rscratch1, 0)); 8442 Assembler::xorps(dst, Address(rscratch1, 0));
8285 } 8443 }
8286 } 8444 }
8287 8445
8446 void MacroAssembler::pshufb(XMMRegister dst, AddressLiteral src) {
8447 // Used in sign-bit flipping with aligned address.
8448 assert((UseAVX > 0) || (((intptr_t)src.target() & 15) == 0), "SSE mode requires address alignment 16 bytes");
8449 if (reachable(src)) {
8450 Assembler::pshufb(dst, as_Address(src));
8451 } else {
8452 lea(rscratch1, src);
8453 Assembler::pshufb(dst, Address(rscratch1, 0));
8454 }
8455 }
8456
8288 // AVX 3-operands instructions 8457 // AVX 3-operands instructions
8289 8458
8290 void MacroAssembler::vaddsd(XMMRegister dst, XMMRegister nds, AddressLiteral src) { 8459 void MacroAssembler::vaddsd(XMMRegister dst, XMMRegister nds, AddressLiteral src) {
8291 if (reachable(src)) { 8460 if (reachable(src)) {
8292 vaddsd(dst, nds, as_Address(src)); 8461 vaddsd(dst, nds, as_Address(src));
8867 9036
8868 void MacroAssembler::fp_runtime_fallback(address runtime_entry, int nb_args, int num_fpu_regs_in_use) { 9037 void MacroAssembler::fp_runtime_fallback(address runtime_entry, int nb_args, int num_fpu_regs_in_use) {
8869 pusha(); 9038 pusha();
8870 9039
8871 // if we are coming from c1, xmm registers may be live 9040 // if we are coming from c1, xmm registers may be live
8872 if (UseSSE >= 1) {
8873 subptr(rsp, sizeof(jdouble)* LP64_ONLY(16) NOT_LP64(8));
8874 }
8875 int off = 0; 9041 int off = 0;
8876 if (UseSSE == 1) { 9042 if (UseSSE == 1) {
9043 subptr(rsp, sizeof(jdouble)*8);
8877 movflt(Address(rsp,off++*sizeof(jdouble)),xmm0); 9044 movflt(Address(rsp,off++*sizeof(jdouble)),xmm0);
8878 movflt(Address(rsp,off++*sizeof(jdouble)),xmm1); 9045 movflt(Address(rsp,off++*sizeof(jdouble)),xmm1);
8879 movflt(Address(rsp,off++*sizeof(jdouble)),xmm2); 9046 movflt(Address(rsp,off++*sizeof(jdouble)),xmm2);
8880 movflt(Address(rsp,off++*sizeof(jdouble)),xmm3); 9047 movflt(Address(rsp,off++*sizeof(jdouble)),xmm3);
8881 movflt(Address(rsp,off++*sizeof(jdouble)),xmm4); 9048 movflt(Address(rsp,off++*sizeof(jdouble)),xmm4);
8882 movflt(Address(rsp,off++*sizeof(jdouble)),xmm5); 9049 movflt(Address(rsp,off++*sizeof(jdouble)),xmm5);
8883 movflt(Address(rsp,off++*sizeof(jdouble)),xmm6); 9050 movflt(Address(rsp,off++*sizeof(jdouble)),xmm6);
8884 movflt(Address(rsp,off++*sizeof(jdouble)),xmm7); 9051 movflt(Address(rsp,off++*sizeof(jdouble)),xmm7);
8885 } else if (UseSSE >= 2) { 9052 } else if (UseSSE >= 2) {
8886 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm0); 9053 #ifdef COMPILER2
8887 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm1); 9054 if (MaxVectorSize > 16) {
8888 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm2); 9055 assert(UseAVX > 0, "256bit vectors are supported only with AVX");
8889 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm3); 9056 // Save upper half of YMM registes
8890 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm4); 9057 subptr(rsp, 16 * LP64_ONLY(16) NOT_LP64(8));
8891 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm5); 9058 vextractf128h(Address(rsp, 0),xmm0);
8892 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm6); 9059 vextractf128h(Address(rsp, 16),xmm1);
8893 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm7); 9060 vextractf128h(Address(rsp, 32),xmm2);
9061 vextractf128h(Address(rsp, 48),xmm3);
9062 vextractf128h(Address(rsp, 64),xmm4);
9063 vextractf128h(Address(rsp, 80),xmm5);
9064 vextractf128h(Address(rsp, 96),xmm6);
9065 vextractf128h(Address(rsp,112),xmm7);
8894 #ifdef _LP64 9066 #ifdef _LP64
8895 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm8); 9067 vextractf128h(Address(rsp,128),xmm8);
8896 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm9); 9068 vextractf128h(Address(rsp,144),xmm9);
8897 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm10); 9069 vextractf128h(Address(rsp,160),xmm10);
8898 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm11); 9070 vextractf128h(Address(rsp,176),xmm11);
8899 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm12); 9071 vextractf128h(Address(rsp,192),xmm12);
8900 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm13); 9072 vextractf128h(Address(rsp,208),xmm13);
8901 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm14); 9073 vextractf128h(Address(rsp,224),xmm14);
8902 movdbl(Address(rsp,off++*sizeof(jdouble)),xmm15); 9074 vextractf128h(Address(rsp,240),xmm15);
9075 #endif
9076 }
9077 #endif
9078 // Save whole 128bit (16 bytes) XMM regiters
9079 subptr(rsp, 16 * LP64_ONLY(16) NOT_LP64(8));
9080 movdqu(Address(rsp,off++*16),xmm0);
9081 movdqu(Address(rsp,off++*16),xmm1);
9082 movdqu(Address(rsp,off++*16),xmm2);
9083 movdqu(Address(rsp,off++*16),xmm3);
9084 movdqu(Address(rsp,off++*16),xmm4);
9085 movdqu(Address(rsp,off++*16),xmm5);
9086 movdqu(Address(rsp,off++*16),xmm6);
9087 movdqu(Address(rsp,off++*16),xmm7);
9088 #ifdef _LP64
9089 movdqu(Address(rsp,off++*16),xmm8);
9090 movdqu(Address(rsp,off++*16),xmm9);
9091 movdqu(Address(rsp,off++*16),xmm10);
9092 movdqu(Address(rsp,off++*16),xmm11);
9093 movdqu(Address(rsp,off++*16),xmm12);
9094 movdqu(Address(rsp,off++*16),xmm13);
9095 movdqu(Address(rsp,off++*16),xmm14);
9096 movdqu(Address(rsp,off++*16),xmm15);
8903 #endif 9097 #endif
8904 } 9098 }
8905 9099
8906 // Preserve registers across runtime call 9100 // Preserve registers across runtime call
8907 int incoming_argument_and_return_value_offset = -1; 9101 int incoming_argument_and_return_value_offset = -1;
8975 movflt(xmm3, Address(rsp,off++*sizeof(jdouble))); 9169 movflt(xmm3, Address(rsp,off++*sizeof(jdouble)));
8976 movflt(xmm4, Address(rsp,off++*sizeof(jdouble))); 9170 movflt(xmm4, Address(rsp,off++*sizeof(jdouble)));
8977 movflt(xmm5, Address(rsp,off++*sizeof(jdouble))); 9171 movflt(xmm5, Address(rsp,off++*sizeof(jdouble)));
8978 movflt(xmm6, Address(rsp,off++*sizeof(jdouble))); 9172 movflt(xmm6, Address(rsp,off++*sizeof(jdouble)));
8979 movflt(xmm7, Address(rsp,off++*sizeof(jdouble))); 9173 movflt(xmm7, Address(rsp,off++*sizeof(jdouble)));
9174 addptr(rsp, sizeof(jdouble)*8);
8980 } else if (UseSSE >= 2) { 9175 } else if (UseSSE >= 2) {
8981 movdbl(xmm0, Address(rsp,off++*sizeof(jdouble))); 9176 // Restore whole 128bit (16 bytes) XMM regiters
8982 movdbl(xmm1, Address(rsp,off++*sizeof(jdouble))); 9177 movdqu(xmm0, Address(rsp,off++*16));
8983 movdbl(xmm2, Address(rsp,off++*sizeof(jdouble))); 9178 movdqu(xmm1, Address(rsp,off++*16));
8984 movdbl(xmm3, Address(rsp,off++*sizeof(jdouble))); 9179 movdqu(xmm2, Address(rsp,off++*16));
8985 movdbl(xmm4, Address(rsp,off++*sizeof(jdouble))); 9180 movdqu(xmm3, Address(rsp,off++*16));
8986 movdbl(xmm5, Address(rsp,off++*sizeof(jdouble))); 9181 movdqu(xmm4, Address(rsp,off++*16));
8987 movdbl(xmm6, Address(rsp,off++*sizeof(jdouble))); 9182 movdqu(xmm5, Address(rsp,off++*16));
8988 movdbl(xmm7, Address(rsp,off++*sizeof(jdouble))); 9183 movdqu(xmm6, Address(rsp,off++*16));
9184 movdqu(xmm7, Address(rsp,off++*16));
8989 #ifdef _LP64 9185 #ifdef _LP64
8990 movdbl(xmm8, Address(rsp,off++*sizeof(jdouble))); 9186 movdqu(xmm8, Address(rsp,off++*16));
8991 movdbl(xmm9, Address(rsp,off++*sizeof(jdouble))); 9187 movdqu(xmm9, Address(rsp,off++*16));
8992 movdbl(xmm10, Address(rsp,off++*sizeof(jdouble))); 9188 movdqu(xmm10, Address(rsp,off++*16));
8993 movdbl(xmm11, Address(rsp,off++*sizeof(jdouble))); 9189 movdqu(xmm11, Address(rsp,off++*16));
8994 movdbl(xmm12, Address(rsp,off++*sizeof(jdouble))); 9190 movdqu(xmm12, Address(rsp,off++*16));
8995 movdbl(xmm13, Address(rsp,off++*sizeof(jdouble))); 9191 movdqu(xmm13, Address(rsp,off++*16));
8996 movdbl(xmm14, Address(rsp,off++*sizeof(jdouble))); 9192 movdqu(xmm14, Address(rsp,off++*16));
8997 movdbl(xmm15, Address(rsp,off++*sizeof(jdouble))); 9193 movdqu(xmm15, Address(rsp,off++*16));
8998 #endif 9194 #endif
8999 } 9195 addptr(rsp, 16 * LP64_ONLY(16) NOT_LP64(8));
9000 if (UseSSE >= 1) { 9196 #ifdef COMPILER2
9001 addptr(rsp, sizeof(jdouble)* LP64_ONLY(16) NOT_LP64(8)); 9197 if (MaxVectorSize > 16) {
9198 // Restore upper half of YMM registes.
9199 vinsertf128h(xmm0, Address(rsp, 0));
9200 vinsertf128h(xmm1, Address(rsp, 16));
9201 vinsertf128h(xmm2, Address(rsp, 32));
9202 vinsertf128h(xmm3, Address(rsp, 48));
9203 vinsertf128h(xmm4, Address(rsp, 64));
9204 vinsertf128h(xmm5, Address(rsp, 80));
9205 vinsertf128h(xmm6, Address(rsp, 96));
9206 vinsertf128h(xmm7, Address(rsp,112));
9207 #ifdef _LP64
9208 vinsertf128h(xmm8, Address(rsp,128));
9209 vinsertf128h(xmm9, Address(rsp,144));
9210 vinsertf128h(xmm10, Address(rsp,160));
9211 vinsertf128h(xmm11, Address(rsp,176));
9212 vinsertf128h(xmm12, Address(rsp,192));
9213 vinsertf128h(xmm13, Address(rsp,208));
9214 vinsertf128h(xmm14, Address(rsp,224));
9215 vinsertf128h(xmm15, Address(rsp,240));
9216 #endif
9217 addptr(rsp, 16 * LP64_ONLY(16) NOT_LP64(8));
9218 }
9219 #endif
9002 } 9220 }
9003 popa(); 9221 popa();
9004 } 9222 }
9005 9223
9006 static const double pi_4 = 0.7853981633974483; 9224 static const double pi_4 = 0.7853981633974483;
9095 assert_different_registers(recv_klass, intf_klass, method_result, scan_temp); 9313 assert_different_registers(recv_klass, intf_klass, method_result, scan_temp);
9096 assert(itable_index.is_constant() || itable_index.as_register() == method_result, 9314 assert(itable_index.is_constant() || itable_index.as_register() == method_result,
9097 "caller must use same register for non-constant itable index as for method"); 9315 "caller must use same register for non-constant itable index as for method");
9098 9316
9099 // Compute start of first itableOffsetEntry (which is at the end of the vtable) 9317 // Compute start of first itableOffsetEntry (which is at the end of the vtable)
9100 int vtable_base = instanceKlass::vtable_start_offset() * wordSize; 9318 int vtable_base = InstanceKlass::vtable_start_offset() * wordSize;
9101 int itentry_off = itableMethodEntry::method_offset_in_bytes(); 9319 int itentry_off = itableMethodEntry::method_offset_in_bytes();
9102 int scan_step = itableOffsetEntry::size() * wordSize; 9320 int scan_step = itableOffsetEntry::size() * wordSize;
9103 int vte_size = vtableEntry::size() * wordSize; 9321 int vte_size = vtableEntry::size() * wordSize;
9104 Address::ScaleFactor times_vte_scale = Address::times_ptr; 9322 Address::ScaleFactor times_vte_scale = Address::times_ptr;
9105 assert(vte_size == wordSize, "else adjust times_vte_scale"); 9323 assert(vte_size == wordSize, "else adjust times_vte_scale");
9106 9324
9107 movl(scan_temp, Address(recv_klass, instanceKlass::vtable_length_offset() * wordSize)); 9325 movl(scan_temp, Address(recv_klass, InstanceKlass::vtable_length_offset() * wordSize));
9108 9326
9109 // %%% Could store the aligned, prescaled offset in the klassoop. 9327 // %%% Could store the aligned, prescaled offset in the klassoop.
9110 lea(scan_temp, Address(recv_klass, scan_temp, times_vte_scale, vtable_base)); 9328 lea(scan_temp, Address(recv_klass, scan_temp, times_vte_scale, vtable_base));
9111 if (HeapWordsPerLong > 1) { 9329 if (HeapWordsPerLong > 1) {
9112 // Round up to align_object_offset boundary 9330 // Round up to align_object_offset boundary
9113 // see code for instanceKlass::start_of_itable! 9331 // see code for InstanceKlass::start_of_itable!
9114 round_to(scan_temp, BytesPerLong); 9332 round_to(scan_temp, BytesPerLong);
9115 } 9333 }
9116 9334
9117 // Adjust recv_klass by scaled itable_index, so we can free itable_index. 9335 // Adjust recv_klass by scaled itable_index, so we can free itable_index.
9118 assert(itableMethodEntry::size() * wordSize == wordSize, "adjust the scaling in the code below"); 9336 assert(itableMethodEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
9158 9376
9159 // virtual method calling 9377 // virtual method calling
9160 void MacroAssembler::lookup_virtual_method(Register recv_klass, 9378 void MacroAssembler::lookup_virtual_method(Register recv_klass,
9161 RegisterOrConstant vtable_index, 9379 RegisterOrConstant vtable_index,
9162 Register method_result) { 9380 Register method_result) {
9163 const int base = instanceKlass::vtable_start_offset() * wordSize; 9381 const int base = InstanceKlass::vtable_start_offset() * wordSize;
9164 assert(vtableEntry::size() * wordSize == wordSize, "else adjust the scaling in the code below"); 9382 assert(vtableEntry::size() * wordSize == wordSize, "else adjust the scaling in the code below");
9165 Address vtable_entry_addr(recv_klass, 9383 Address vtable_entry_addr(recv_klass,
9166 vtable_index, Address::times_ptr, 9384 vtable_index, Address::times_ptr,
9167 base + vtableEntry::method_offset_in_bytes()); 9385 base + vtableEntry::method_offset_in_bytes());
9168 movptr(method_result, vtable_entry_addr); 9386 movptr(method_result, vtable_entry_addr);
9333 #endif //PRODUCT 9551 #endif //PRODUCT
9334 9552
9335 // We will consult the secondary-super array. 9553 // We will consult the secondary-super array.
9336 movptr(rdi, secondary_supers_addr); 9554 movptr(rdi, secondary_supers_addr);
9337 // Load the array length. (Positive movl does right thing on LP64.) 9555 // Load the array length. (Positive movl does right thing on LP64.)
9338 movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes())); 9556 movl(rcx, Address(rdi, Array<Klass*>::length_offset_in_bytes()));
9339 // Skip to start of data. 9557 // Skip to start of data.
9340 addptr(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); 9558 addptr(rdi, Array<Klass*>::base_offset_in_bytes());
9341 9559
9342 // Scan RCX words at [RDI] for an occurrence of RAX. 9560 // Scan RCX words at [RDI] for an occurrence of RAX.
9343 // Set NZ/Z based on last compare. 9561 // Set NZ/Z based on last compare.
9344 // Z flag value will not be set by 'repne' if RCX == 0 since 'repne' does 9562 // Z flag value will not be set by 'repne' if RCX == 0 since 'repne' does
9345 // not change flags (only scas instruction which is repeated sets flags). 9563 // not change flags (only scas instruction which is repeated sets flags).
9346 // Set Z = 0 (not equal) before 'repne' to indicate that class was not found. 9564 // Set Z = 0 (not equal) before 'repne' to indicate that class was not found.
9347 #ifdef _LP64 9565
9348 // This part is tricky, as values in supers array could be 32 or 64 bit wide
9349 // and we store values in objArrays always encoded, thus we need to encode
9350 // the value of rax before repne. Note that rax is dead after the repne.
9351 if (UseCompressedOops) {
9352 encode_heap_oop_not_null(rax); // Changes flags.
9353 // The superclass is never null; it would be a basic system error if a null
9354 // pointer were to sneak in here. Note that we have already loaded the
9355 // Klass::super_check_offset from the super_klass in the fast path,
9356 // so if there is a null in that register, we are already in the afterlife.
9357 testl(rax,rax); // Set Z = 0
9358 repne_scanl();
9359 } else
9360 #endif // _LP64
9361 {
9362 testptr(rax,rax); // Set Z = 0 9566 testptr(rax,rax); // Set Z = 0
9363 repne_scan(); 9567 repne_scan();
9364 } 9568
9365 // Unspill the temp. registers: 9569 // Unspill the temp. registers:
9366 if (pushed_rdi) pop(rdi); 9570 if (pushed_rdi) pop(rdi);
9367 if (pushed_rcx) pop(rcx); 9571 if (pushed_rcx) pop(rcx);
9368 if (pushed_rax) pop(rax); 9572 if (pushed_rax) pop(rax);
9369 9573
9905 pop_CPU_state(); 10109 pop_CPU_state();
9906 } 10110 }
9907 10111
9908 void MacroAssembler::load_klass(Register dst, Register src) { 10112 void MacroAssembler::load_klass(Register dst, Register src) {
9909 #ifdef _LP64 10113 #ifdef _LP64
9910 if (UseCompressedOops) { 10114 if (UseCompressedKlassPointers) {
9911 movl(dst, Address(src, oopDesc::klass_offset_in_bytes())); 10115 movl(dst, Address(src, oopDesc::klass_offset_in_bytes()));
9912 decode_heap_oop_not_null(dst); 10116 decode_klass_not_null(dst);
9913 } else 10117 } else
9914 #endif 10118 #endif
9915 movptr(dst, Address(src, oopDesc::klass_offset_in_bytes())); 10119 movptr(dst, Address(src, oopDesc::klass_offset_in_bytes()));
9916 } 10120 }
9917 10121
9918 void MacroAssembler::load_prototype_header(Register dst, Register src) { 10122 void MacroAssembler::load_prototype_header(Register dst, Register src) {
9919 #ifdef _LP64 10123 #ifdef _LP64
9920 if (UseCompressedOops) { 10124 if (UseCompressedKlassPointers) {
9921 assert (Universe::heap() != NULL, "java heap should be initialized"); 10125 assert (Universe::heap() != NULL, "java heap should be initialized");
9922 movl(dst, Address(src, oopDesc::klass_offset_in_bytes())); 10126 movl(dst, Address(src, oopDesc::klass_offset_in_bytes()));
9923 if (Universe::narrow_oop_shift() != 0) { 10127 if (Universe::narrow_klass_shift() != 0) {
9924 assert(LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 10128 assert(LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
9925 if (LogMinObjAlignmentInBytes == Address::times_8) { 10129 assert(LogKlassAlignmentInBytes == Address::times_8, "klass not aligned on 64bits?");
9926 movq(dst, Address(r12_heapbase, dst, Address::times_8, Klass::prototype_header_offset())); 10130 movq(dst, Address(r12_heapbase, dst, Address::times_8, Klass::prototype_header_offset()));
9927 } else {
9928 // OK to use shift since we don't need to preserve flags.
9929 shlq(dst, LogMinObjAlignmentInBytes);
9930 movq(dst, Address(r12_heapbase, dst, Address::times_1, Klass::prototype_header_offset()));
9931 }
9932 } else { 10131 } else {
9933 movq(dst, Address(dst, Klass::prototype_header_offset())); 10132 movq(dst, Address(dst, Klass::prototype_header_offset()));
9934 } 10133 }
9935 } else 10134 } else
9936 #endif 10135 #endif
9940 } 10139 }
9941 } 10140 }
9942 10141
9943 void MacroAssembler::store_klass(Register dst, Register src) { 10142 void MacroAssembler::store_klass(Register dst, Register src) {
9944 #ifdef _LP64 10143 #ifdef _LP64
9945 if (UseCompressedOops) { 10144 if (UseCompressedKlassPointers) {
9946 encode_heap_oop_not_null(src); 10145 encode_klass_not_null(src);
9947 movl(Address(dst, oopDesc::klass_offset_in_bytes()), src); 10146 movl(Address(dst, oopDesc::klass_offset_in_bytes()), src);
9948 } else 10147 } else
9949 #endif 10148 #endif
9950 movptr(Address(dst, oopDesc::klass_offset_in_bytes()), src); 10149 movptr(Address(dst, oopDesc::klass_offset_in_bytes()), src);
9951 } 10150 }
9952 10151
9953 void MacroAssembler::load_heap_oop(Register dst, Address src) { 10152 void MacroAssembler::load_heap_oop(Register dst, Address src) {
9954 #ifdef _LP64 10153 #ifdef _LP64
10154 // FIXME: Must change all places where we try to load the klass.
9955 if (UseCompressedOops) { 10155 if (UseCompressedOops) {
9956 movl(dst, src); 10156 movl(dst, src);
9957 decode_heap_oop(dst); 10157 decode_heap_oop(dst);
9958 } else 10158 } else
9959 #endif 10159 #endif
10014 #endif 10214 #endif
10015 } 10215 }
10016 10216
10017 #ifdef _LP64 10217 #ifdef _LP64
10018 void MacroAssembler::store_klass_gap(Register dst, Register src) { 10218 void MacroAssembler::store_klass_gap(Register dst, Register src) {
10019 if (UseCompressedOops) { 10219 if (UseCompressedKlassPointers) {
10020 // Store to klass gap in destination 10220 // Store to klass gap in destination
10021 movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src); 10221 movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src);
10022 } 10222 }
10023 } 10223 }
10024 10224
10025 #ifdef ASSERT 10225 #ifdef ASSERT
10026 void MacroAssembler::verify_heapbase(const char* msg) { 10226 void MacroAssembler::verify_heapbase(const char* msg) {
10027 assert (UseCompressedOops, "should be compressed"); 10227 assert (UseCompressedOops || UseCompressedKlassPointers, "should be compressed");
10028 assert (Universe::heap() != NULL, "java heap should be initialized"); 10228 assert (Universe::heap() != NULL, "java heap should be initialized");
10029 if (CheckCompressedOops) { 10229 if (CheckCompressedOops) {
10030 Label ok; 10230 Label ok;
10031 push(rscratch1); // cmpptr trashes rscratch1 10231 push(rscratch1); // cmpptr trashes rscratch1
10032 cmpptr(r12_heapbase, ExternalAddress((address)Universe::narrow_oop_base_addr())); 10232 cmpptr(r12_heapbase, ExternalAddress((address)Universe::narrow_ptrs_base_addr()));
10033 jcc(Assembler::equal, ok); 10233 jcc(Assembler::equal, ok);
10034 STOP(msg); 10234 STOP(msg);
10035 bind(ok); 10235 bind(ok);
10036 pop(rscratch1); 10236 pop(rscratch1);
10037 } 10237 }
10165 movq(dst, src); 10365 movq(dst, src);
10166 } 10366 }
10167 } 10367 }
10168 } 10368 }
10169 10369
10370 void MacroAssembler::encode_klass_not_null(Register r) {
10371 assert(Metaspace::is_initialized(), "metaspace should be initialized");
10372 #ifdef ASSERT
10373 verify_heapbase("MacroAssembler::encode_klass_not_null: heap base corrupted?");
10374 #endif
10375 if (Universe::narrow_klass_base() != NULL) {
10376 subq(r, r12_heapbase);
10377 }
10378 if (Universe::narrow_klass_shift() != 0) {
10379 assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
10380 shrq(r, LogKlassAlignmentInBytes);
10381 }
10382 }
10383
10384 void MacroAssembler::encode_klass_not_null(Register dst, Register src) {
10385 assert(Metaspace::is_initialized(), "metaspace should be initialized");
10386 #ifdef ASSERT
10387 verify_heapbase("MacroAssembler::encode_klass_not_null2: heap base corrupted?");
10388 #endif
10389 if (dst != src) {
10390 movq(dst, src);
10391 }
10392 if (Universe::narrow_klass_base() != NULL) {
10393 subq(dst, r12_heapbase);
10394 }
10395 if (Universe::narrow_klass_shift() != 0) {
10396 assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
10397 shrq(dst, LogKlassAlignmentInBytes);
10398 }
10399 }
10400
10401 void MacroAssembler::decode_klass_not_null(Register r) {
10402 assert(Metaspace::is_initialized(), "metaspace should be initialized");
10403 // Note: it will change flags
10404 assert (UseCompressedKlassPointers, "should only be used for compressed headers");
10405 // Cannot assert, unverified entry point counts instructions (see .ad file)
10406 // vtableStubs also counts instructions in pd_code_size_limit.
10407 // Also do not verify_oop as this is called by verify_oop.
10408 if (Universe::narrow_klass_shift() != 0) {
10409 assert(LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
10410 shlq(r, LogKlassAlignmentInBytes);
10411 if (Universe::narrow_klass_base() != NULL) {
10412 addq(r, r12_heapbase);
10413 }
10414 } else {
10415 assert (Universe::narrow_klass_base() == NULL, "sanity");
10416 }
10417 }
10418
10419 void MacroAssembler::decode_klass_not_null(Register dst, Register src) {
10420 assert(Metaspace::is_initialized(), "metaspace should be initialized");
10421 // Note: it will change flags
10422 assert (UseCompressedKlassPointers, "should only be used for compressed headers");
10423 // Cannot assert, unverified entry point counts instructions (see .ad file)
10424 // vtableStubs also counts instructions in pd_code_size_limit.
10425 // Also do not verify_oop as this is called by verify_oop.
10426 if (Universe::narrow_klass_shift() != 0) {
10427 assert(LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
10428 assert(LogKlassAlignmentInBytes == Address::times_8, "klass not aligned on 64bits?");
10429 leaq(dst, Address(r12_heapbase, src, Address::times_8, 0));
10430 } else {
10431 assert (Universe::narrow_klass_base() == NULL, "sanity");
10432 if (dst != src) {
10433 movq(dst, src);
10434 }
10435 }
10436 }
10437
10170 void MacroAssembler::set_narrow_oop(Register dst, jobject obj) { 10438 void MacroAssembler::set_narrow_oop(Register dst, jobject obj) {
10171 assert (UseCompressedOops, "should only be used for compressed headers"); 10439 assert (UseCompressedOops, "should only be used for compressed headers");
10172 assert (Universe::heap() != NULL, "java heap should be initialized"); 10440 assert (Universe::heap() != NULL, "java heap should be initialized");
10173 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder"); 10441 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
10174 int oop_index = oop_recorder()->find_index(obj); 10442 int oop_index = oop_recorder()->find_index(obj);
10183 int oop_index = oop_recorder()->find_index(obj); 10451 int oop_index = oop_recorder()->find_index(obj);
10184 RelocationHolder rspec = oop_Relocation::spec(oop_index); 10452 RelocationHolder rspec = oop_Relocation::spec(oop_index);
10185 mov_narrow_oop(dst, oop_index, rspec); 10453 mov_narrow_oop(dst, oop_index, rspec);
10186 } 10454 }
10187 10455
10456 void MacroAssembler::set_narrow_klass(Register dst, Klass* k) {
10457 assert (UseCompressedKlassPointers, "should only be used for compressed headers");
10458 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
10459 int klass_index = oop_recorder()->find_index(k);
10460 RelocationHolder rspec = metadata_Relocation::spec(klass_index);
10461 mov_narrow_oop(dst, oopDesc::encode_klass(k), rspec);
10462 }
10463
10464 void MacroAssembler::set_narrow_klass(Address dst, Klass* k) {
10465 assert (UseCompressedKlassPointers, "should only be used for compressed headers");
10466 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
10467 int klass_index = oop_recorder()->find_index(k);
10468 RelocationHolder rspec = metadata_Relocation::spec(klass_index);
10469 mov_narrow_oop(dst, oopDesc::encode_klass(k), rspec);
10470 }
10471
10188 void MacroAssembler::cmp_narrow_oop(Register dst, jobject obj) { 10472 void MacroAssembler::cmp_narrow_oop(Register dst, jobject obj) {
10189 assert (UseCompressedOops, "should only be used for compressed headers"); 10473 assert (UseCompressedOops, "should only be used for compressed headers");
10190 assert (Universe::heap() != NULL, "java heap should be initialized"); 10474 assert (Universe::heap() != NULL, "java heap should be initialized");
10191 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder"); 10475 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
10192 int oop_index = oop_recorder()->find_index(obj); 10476 int oop_index = oop_recorder()->find_index(obj);
10201 int oop_index = oop_recorder()->find_index(obj); 10485 int oop_index = oop_recorder()->find_index(obj);
10202 RelocationHolder rspec = oop_Relocation::spec(oop_index); 10486 RelocationHolder rspec = oop_Relocation::spec(oop_index);
10203 Assembler::cmp_narrow_oop(dst, oop_index, rspec); 10487 Assembler::cmp_narrow_oop(dst, oop_index, rspec);
10204 } 10488 }
10205 10489
10490 void MacroAssembler::cmp_narrow_klass(Register dst, Klass* k) {
10491 assert (UseCompressedKlassPointers, "should only be used for compressed headers");
10492 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
10493 int klass_index = oop_recorder()->find_index(k);
10494 RelocationHolder rspec = metadata_Relocation::spec(klass_index);
10495 Assembler::cmp_narrow_oop(dst, oopDesc::encode_klass(k), rspec);
10496 }
10497
10498 void MacroAssembler::cmp_narrow_klass(Address dst, Klass* k) {
10499 assert (UseCompressedKlassPointers, "should only be used for compressed headers");
10500 assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
10501 int klass_index = oop_recorder()->find_index(k);
10502 RelocationHolder rspec = metadata_Relocation::spec(klass_index);
10503 Assembler::cmp_narrow_oop(dst, oopDesc::encode_klass(k), rspec);
10504 }
10505
10206 void MacroAssembler::reinit_heapbase() { 10506 void MacroAssembler::reinit_heapbase() {
10207 if (UseCompressedOops) { 10507 if (UseCompressedOops || UseCompressedKlassPointers) {
10208 movptr(r12_heapbase, ExternalAddress((address)Universe::narrow_oop_base_addr())); 10508 movptr(r12_heapbase, ExternalAddress((address)Universe::narrow_ptrs_base_addr()));
10209 } 10509 }
10210 } 10510 }
10211 #endif // _LP64 10511 #endif // _LP64
10212 10512
10213 10513
10486 movq(vec, Address(str2, 0)); // move 64 bits 10786 movq(vec, Address(str2, 0)); // move 64 bits
10487 } else { // cnt2 = { 3, 5, 6, 7 } 10787 } else { // cnt2 = { 3, 5, 6, 7 }
10488 // Array header size is 12 bytes in 32-bit VM 10788 // Array header size is 12 bytes in 32-bit VM
10489 // + 6 bytes for 3 chars == 18 bytes, 10789 // + 6 bytes for 3 chars == 18 bytes,
10490 // enough space to load vec and shift. 10790 // enough space to load vec and shift.
10491 assert(HeapWordSize*typeArrayKlass::header_size() >= 12,"sanity"); 10791 assert(HeapWordSize*TypeArrayKlass::header_size() >= 12,"sanity");
10492 movdqu(vec, Address(str2, (int_cnt2*2)-16)); 10792 movdqu(vec, Address(str2, (int_cnt2*2)-16));
10493 psrldq(vec, 16-(int_cnt2*2)); 10793 psrldq(vec, 16-(int_cnt2*2));
10494 } 10794 }
10495 } else { // not constant substring 10795 } else { // not constant substring
10496 cmpl(cnt2, 8); 10796 cmpl(cnt2, 8);