Mercurial > hg > graal-compiler
comparison src/cpu/x86/vm/macroAssembler_x86.cpp @ 8883:b9a918201d47
Merge with hsx25
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Sat, 06 Apr 2013 20:04:06 +0200 |
parents | ded5288f5b96 e961c11b85fe |
children | 6b0fd0964b87 |
comparison
equal
deleted
inserted
replaced
8660:d47b52b0ff68 | 8883:b9a918201d47 |
---|---|
4260 | 4260 |
4261 void MacroAssembler::verify_oop(Register reg, const char* s) { | 4261 void MacroAssembler::verify_oop(Register reg, const char* s) { |
4262 if (!VerifyOops) return; | 4262 if (!VerifyOops) return; |
4263 | 4263 |
4264 // Pass register number to verify_oop_subroutine | 4264 // Pass register number to verify_oop_subroutine |
4265 char* b = new char[strlen(s) + 50]; | 4265 const char* b = NULL; |
4266 sprintf(b, "verify_oop: %s: %s", reg->name(), s); | 4266 { |
4267 ResourceMark rm; | |
4268 stringStream ss; | |
4269 ss.print("verify_oop: %s: %s", reg->name(), s); | |
4270 b = code_string(ss.as_string()); | |
4271 } | |
4267 BLOCK_COMMENT("verify_oop {"); | 4272 BLOCK_COMMENT("verify_oop {"); |
4268 #ifdef _LP64 | 4273 #ifdef _LP64 |
4269 push(rscratch1); // save r10, trashed by movptr() | 4274 push(rscratch1); // save r10, trashed by movptr() |
4270 #endif | 4275 #endif |
4271 push(rax); // save rax, | 4276 push(rax); // save rax, |
4295 | 4300 |
4296 #ifdef ASSERT | 4301 #ifdef ASSERT |
4297 { Label L; | 4302 { Label L; |
4298 testptr(tmp, tmp); | 4303 testptr(tmp, tmp); |
4299 if (WizardMode) { | 4304 if (WizardMode) { |
4305 const char* buf = NULL; | |
4306 { | |
4307 ResourceMark rm; | |
4308 stringStream ss; | |
4309 ss.print("DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]); | |
4310 buf = code_string(ss.as_string()); | |
4311 } | |
4300 jcc(Assembler::notZero, L); | 4312 jcc(Assembler::notZero, L); |
4301 char* buf = new char[40]; | |
4302 sprintf(buf, "DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]); | |
4303 STOP(buf); | 4313 STOP(buf); |
4304 } else { | 4314 } else { |
4305 jccb(Assembler::notZero, L); | 4315 jccb(Assembler::notZero, L); |
4306 hlt(); | 4316 hlt(); |
4307 } | 4317 } |
4341 void MacroAssembler::verify_oop_addr(Address addr, const char* s) { | 4351 void MacroAssembler::verify_oop_addr(Address addr, const char* s) { |
4342 if (!VerifyOops) return; | 4352 if (!VerifyOops) return; |
4343 | 4353 |
4344 // Address adjust(addr.base(), addr.index(), addr.scale(), addr.disp() + BytesPerWord); | 4354 // Address adjust(addr.base(), addr.index(), addr.scale(), addr.disp() + BytesPerWord); |
4345 // Pass register number to verify_oop_subroutine | 4355 // Pass register number to verify_oop_subroutine |
4346 char* b = new char[strlen(s) + 50]; | 4356 const char* b = NULL; |
4347 sprintf(b, "verify_oop_addr: %s", s); | 4357 { |
4348 | 4358 ResourceMark rm; |
4359 stringStream ss; | |
4360 ss.print("verify_oop_addr: %s", s); | |
4361 b = code_string(ss.as_string()); | |
4362 } | |
4349 #ifdef _LP64 | 4363 #ifdef _LP64 |
4350 push(rscratch1); // save r10, trashed by movptr() | 4364 push(rscratch1); // save r10, trashed by movptr() |
4351 #endif | 4365 #endif |
4352 push(rax); // save rax, | 4366 push(rax); // save rax, |
4353 // addr may contain rsp so we will have to adjust it based on the push | 4367 // addr may contain rsp so we will have to adjust it based on the push |
4749 bind(L); | 4763 bind(L); |
4750 } | 4764 } |
4751 pop_CPU_state(); | 4765 pop_CPU_state(); |
4752 } | 4766 } |
4753 | 4767 |
4768 void MacroAssembler::restore_cpu_control_state_after_jni() { | |
4769 // Either restore the MXCSR register after returning from the JNI Call | |
4770 // or verify that it wasn't changed (with -Xcheck:jni flag). | |
4771 if (VM_Version::supports_sse()) { | |
4772 if (RestoreMXCSROnJNICalls) { | |
4773 ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); | |
4774 } else if (CheckJNICalls) { | |
4775 call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); | |
4776 } | |
4777 } | |
4778 if (VM_Version::supports_avx()) { | |
4779 // Clear upper bits of YMM registers to avoid SSE <-> AVX transition penalty. | |
4780 vzeroupper(); | |
4781 } | |
4782 | |
4783 #ifndef _LP64 | |
4784 // Either restore the x87 floating pointer control word after returning | |
4785 // from the JNI call or verify that it wasn't changed. | |
4786 if (CheckJNICalls) { | |
4787 call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); | |
4788 } | |
4789 #endif // _LP64 | |
4790 } | |
4791 | |
4792 | |
4754 void MacroAssembler::load_klass(Register dst, Register src) { | 4793 void MacroAssembler::load_klass(Register dst, Register src) { |
4755 #ifdef _LP64 | 4794 #ifdef _LP64 |
4756 if (UseCompressedKlassPointers) { | 4795 if (UseCompressedKlassPointers) { |
4757 movl(dst, Address(src, oopDesc::klass_offset_in_bytes())); | 4796 movl(dst, Address(src, oopDesc::klass_offset_in_bytes())); |
4758 decode_klass_not_null(dst); | 4797 decode_klass_not_null(dst); |
5743 vptest(vec1, vec1); | 5782 vptest(vec1, vec1); |
5744 jccb(Assembler::notZero, VECTOR_NOT_EQUAL); | 5783 jccb(Assembler::notZero, VECTOR_NOT_EQUAL); |
5745 addptr(result, stride2); | 5784 addptr(result, stride2); |
5746 subl(cnt2, stride2); | 5785 subl(cnt2, stride2); |
5747 jccb(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP); | 5786 jccb(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP); |
5787 // clean upper bits of YMM registers | |
5788 vzeroupper(); | |
5748 | 5789 |
5749 // compare wide vectors tail | 5790 // compare wide vectors tail |
5750 bind(COMPARE_WIDE_TAIL); | 5791 bind(COMPARE_WIDE_TAIL); |
5751 testptr(result, result); | 5792 testptr(result, result); |
5752 jccb(Assembler::zero, LENGTH_DIFF_LABEL); | 5793 jccb(Assembler::zero, LENGTH_DIFF_LABEL); |
5756 negptr(result); | 5797 negptr(result); |
5757 jmpb(COMPARE_WIDE_VECTORS_LOOP); | 5798 jmpb(COMPARE_WIDE_VECTORS_LOOP); |
5758 | 5799 |
5759 // Identifies the mismatching (higher or lower)16-bytes in the 32-byte vectors. | 5800 // Identifies the mismatching (higher or lower)16-bytes in the 32-byte vectors. |
5760 bind(VECTOR_NOT_EQUAL); | 5801 bind(VECTOR_NOT_EQUAL); |
5802 // clean upper bits of YMM registers | |
5803 vzeroupper(); | |
5761 lea(str1, Address(str1, result, scale)); | 5804 lea(str1, Address(str1, result, scale)); |
5762 lea(str2, Address(str2, result, scale)); | 5805 lea(str2, Address(str2, result, scale)); |
5763 jmp(COMPARE_16_CHARS); | 5806 jmp(COMPARE_16_CHARS); |
5764 | 5807 |
5765 // Compare tail chars, length between 1 to 15 chars | 5808 // Compare tail chars, length between 1 to 15 chars |
6012 bind(FALSE_LABEL); | 6055 bind(FALSE_LABEL); |
6013 xorl(result, result); // return false | 6056 xorl(result, result); // return false |
6014 | 6057 |
6015 // That's it | 6058 // That's it |
6016 bind(DONE); | 6059 bind(DONE); |
6060 if (UseAVX >= 2) { | |
6061 // clean upper bits of YMM registers | |
6062 vzeroupper(); | |
6063 } | |
6017 } | 6064 } |
6018 | 6065 |
6019 void MacroAssembler::generate_fill(BasicType t, bool aligned, | 6066 void MacroAssembler::generate_fill(BasicType t, bool aligned, |
6020 Register to, Register value, Register count, | 6067 Register to, Register value, Register count, |
6021 Register rtmp, XMMRegister xtmp) { | 6068 Register rtmp, XMMRegister xtmp) { |
6141 addl(count, 8 << shift); | 6188 addl(count, 8 << shift); |
6142 jccb(Assembler::less, L_check_fill_8_bytes); | 6189 jccb(Assembler::less, L_check_fill_8_bytes); |
6143 vmovdqu(Address(to, 0), xtmp); | 6190 vmovdqu(Address(to, 0), xtmp); |
6144 addptr(to, 32); | 6191 addptr(to, 32); |
6145 subl(count, 8 << shift); | 6192 subl(count, 8 << shift); |
6193 | |
6194 BIND(L_check_fill_8_bytes); | |
6195 // clean upper bits of YMM registers | |
6196 vzeroupper(); | |
6146 } else { | 6197 } else { |
6147 // Fill 32-byte chunks | 6198 // Fill 32-byte chunks |
6148 pshufd(xtmp, xtmp, 0); | 6199 pshufd(xtmp, xtmp, 0); |
6149 | 6200 |
6150 subl(count, 8 << shift); | 6201 subl(count, 8 << shift); |
6164 } | 6215 } |
6165 | 6216 |
6166 addptr(to, 32); | 6217 addptr(to, 32); |
6167 subl(count, 8 << shift); | 6218 subl(count, 8 << shift); |
6168 jcc(Assembler::greaterEqual, L_fill_32_bytes_loop); | 6219 jcc(Assembler::greaterEqual, L_fill_32_bytes_loop); |
6220 | |
6221 BIND(L_check_fill_8_bytes); | |
6169 } | 6222 } |
6170 BIND(L_check_fill_8_bytes); | |
6171 addl(count, 8 << shift); | 6223 addl(count, 8 << shift); |
6172 jccb(Assembler::zero, L_exit); | 6224 jccb(Assembler::zero, L_exit); |
6173 jmpb(L_fill_8_bytes); | 6225 jmpb(L_fill_8_bytes); |
6174 | 6226 |
6175 // | 6227 // |
6300 bind(L_chars_16_check); | 6352 bind(L_chars_16_check); |
6301 addptr(len, 16); | 6353 addptr(len, 16); |
6302 jccb(Assembler::lessEqual, L_copy_16_chars); | 6354 jccb(Assembler::lessEqual, L_copy_16_chars); |
6303 | 6355 |
6304 bind(L_copy_16_chars_exit); | 6356 bind(L_copy_16_chars_exit); |
6357 if (UseAVX >= 2) { | |
6358 // clean upper bits of YMM registers | |
6359 vzeroupper(); | |
6360 } | |
6305 subptr(len, 8); | 6361 subptr(len, 8); |
6306 jccb(Assembler::greater, L_copy_8_chars_exit); | 6362 jccb(Assembler::greater, L_copy_8_chars_exit); |
6307 | 6363 |
6308 bind(L_copy_8_chars); | 6364 bind(L_copy_8_chars); |
6309 movdqu(tmp3Reg, Address(src, len, Address::times_2, -16)); | 6365 movdqu(tmp3Reg, Address(src, len, Address::times_2, -16)); |