comparison src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @ 304:dc7f315e41f7

5108146: Merge i486 and amd64 cpu directories 6459804: Want client (c1) compiler for x86_64 (amd64) for faster start-up Reviewed-by: kvn
author never
date Wed, 27 Aug 2008 00:21:55 -0700
parents d1605aabd0a1
children 6e7305abe64c
comparison
equal deleted inserted replaced
303:fa4d1d240383 304:dc7f315e41f7
111 return false; 111 return false;
112 } 112 }
113 113
114 114
115 LIR_Opr LIR_Assembler::receiverOpr() { 115 LIR_Opr LIR_Assembler::receiverOpr() {
116 return FrameMap::rcx_oop_opr; 116 return FrameMap::receiver_opr;
117 } 117 }
118 118
119 LIR_Opr LIR_Assembler::incomingReceiverOpr() { 119 LIR_Opr LIR_Assembler::incomingReceiverOpr() {
120 return receiverOpr(); 120 return receiverOpr();
121 } 121 }
122 122
123 LIR_Opr LIR_Assembler::osrBufferPointer() { 123 LIR_Opr LIR_Assembler::osrBufferPointer() {
124 return FrameMap::rcx_opr; 124 return FrameMap::as_pointer_opr(receiverOpr()->as_register());
125 } 125 }
126 126
127 //--------------fpu register translations----------------------- 127 //--------------fpu register translations-----------------------
128 128
129 129
179 179
180 void LIR_Assembler::push(LIR_Opr opr) { 180 void LIR_Assembler::push(LIR_Opr opr) {
181 if (opr->is_single_cpu()) { 181 if (opr->is_single_cpu()) {
182 __ push_reg(opr->as_register()); 182 __ push_reg(opr->as_register());
183 } else if (opr->is_double_cpu()) { 183 } else if (opr->is_double_cpu()) {
184 __ push_reg(opr->as_register_hi()); 184 NOT_LP64(__ push_reg(opr->as_register_hi()));
185 __ push_reg(opr->as_register_lo()); 185 __ push_reg(opr->as_register_lo());
186 } else if (opr->is_stack()) { 186 } else if (opr->is_stack()) {
187 __ push_addr(frame_map()->address_for_slot(opr->single_stack_ix())); 187 __ push_addr(frame_map()->address_for_slot(opr->single_stack_ix()));
188 } else if (opr->is_constant()) { 188 } else if (opr->is_constant()) {
189 LIR_Const* const_opr = opr->as_constant_ptr(); 189 LIR_Const* const_opr = opr->as_constant_ptr();
200 } 200 }
201 } 201 }
202 202
203 void LIR_Assembler::pop(LIR_Opr opr) { 203 void LIR_Assembler::pop(LIR_Opr opr) {
204 if (opr->is_single_cpu()) { 204 if (opr->is_single_cpu()) {
205 __ pop(opr->as_register()); 205 __ pop_reg(opr->as_register());
206 } else { 206 } else {
207 ShouldNotReachHere(); 207 ShouldNotReachHere();
208 } 208 }
209 } 209 }
210 210
211 bool LIR_Assembler::is_literal_address(LIR_Address* addr) {
212 return addr->base()->is_illegal() && addr->index()->is_illegal();
213 }
214
211 //------------------------------------------- 215 //-------------------------------------------
216
212 Address LIR_Assembler::as_Address(LIR_Address* addr) { 217 Address LIR_Assembler::as_Address(LIR_Address* addr) {
218 return as_Address(addr, rscratch1);
219 }
220
221 Address LIR_Assembler::as_Address(LIR_Address* addr, Register tmp) {
213 if (addr->base()->is_illegal()) { 222 if (addr->base()->is_illegal()) {
214 assert(addr->index()->is_illegal(), "must be illegal too"); 223 assert(addr->index()->is_illegal(), "must be illegal too");
215 //return Address(addr->disp(), relocInfo::none); 224 AddressLiteral laddr((address)addr->disp(), relocInfo::none);
216 // hack for now since this should really return an AddressLiteral 225 if (! __ reachable(laddr)) {
217 // which will have to await 64bit c1 changes. 226 __ movptr(tmp, laddr.addr());
218 return Address(noreg, addr->disp()); 227 Address res(tmp, 0);
219 } 228 return res;
220 229 } else {
221 Register base = addr->base()->as_register(); 230 return __ as_Address(laddr);
231 }
232 }
233
234 Register base = addr->base()->as_pointer_register();
222 235
223 if (addr->index()->is_illegal()) { 236 if (addr->index()->is_illegal()) {
224 return Address( base, addr->disp()); 237 return Address( base, addr->disp());
225 } else if (addr->index()->is_single_cpu()) { 238 } else if (addr->index()->is_cpu_register()) {
226 Register index = addr->index()->as_register(); 239 Register index = addr->index()->as_pointer_register();
227 return Address(base, index, (Address::ScaleFactor) addr->scale(), addr->disp()); 240 return Address(base, index, (Address::ScaleFactor) addr->scale(), addr->disp());
228 } else if (addr->index()->is_constant()) { 241 } else if (addr->index()->is_constant()) {
229 int addr_offset = (addr->index()->as_constant_ptr()->as_jint() << addr->scale()) + addr->disp(); 242 intptr_t addr_offset = (addr->index()->as_constant_ptr()->as_jint() << addr->scale()) + addr->disp();
243 assert(Assembler::is_simm32(addr_offset), "must be");
230 244
231 return Address(base, addr_offset); 245 return Address(base, addr_offset);
232 } else { 246 } else {
233 Unimplemented(); 247 Unimplemented();
234 return Address(); 248 return Address();
282 // rcx: pointer to osr buffer 296 // rcx: pointer to osr buffer
283 // 297 //
284 // All other registers are dead at this point and the locals will be 298 // All other registers are dead at this point and the locals will be
285 // copied into place by code emitted in the IR. 299 // copied into place by code emitted in the IR.
286 300
287 Register OSR_buf = osrBufferPointer()->as_register(); 301 Register OSR_buf = osrBufferPointer()->as_pointer_register();
288 { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below"); 302 { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
289 int monitor_offset = BytesPerWord * method()->max_locals() + 303 int monitor_offset = BytesPerWord * method()->max_locals() +
290 (BasicObjectLock::size() * BytesPerWord) * (number_of_locks - 1); 304 (BasicObjectLock::size() * BytesPerWord) * (number_of_locks - 1);
291 for (int i = 0; i < number_of_locks; i++) { 305 for (int i = 0; i < number_of_locks; i++) {
292 int slot_offset = monitor_offset - ((i * BasicObjectLock::size()) * BytesPerWord); 306 int slot_offset = monitor_offset - ((i * BasicObjectLock::size()) * BytesPerWord);
293 #ifdef ASSERT 307 #ifdef ASSERT
294 // verify the interpreter's monitor has a non-null object 308 // verify the interpreter's monitor has a non-null object
295 { 309 {
296 Label L; 310 Label L;
297 __ cmpl(Address(OSR_buf, slot_offset + BasicObjectLock::obj_offset_in_bytes()), NULL_WORD); 311 __ cmpptr(Address(OSR_buf, slot_offset + BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD);
298 __ jcc(Assembler::notZero, L); 312 __ jcc(Assembler::notZero, L);
299 __ stop("locked object is NULL"); 313 __ stop("locked object is NULL");
300 __ bind(L); 314 __ bind(L);
301 } 315 }
302 #endif 316 #endif
303 __ movl(rbx, Address(OSR_buf, slot_offset + BasicObjectLock::lock_offset_in_bytes())); 317 __ movptr(rbx, Address(OSR_buf, slot_offset + BasicObjectLock::lock_offset_in_bytes()));
304 __ movl(frame_map()->address_for_monitor_lock(i), rbx); 318 __ movptr(frame_map()->address_for_monitor_lock(i), rbx);
305 __ movl(rbx, Address(OSR_buf, slot_offset + BasicObjectLock::obj_offset_in_bytes())); 319 __ movptr(rbx, Address(OSR_buf, slot_offset + BasicObjectLock::obj_offset_in_bytes()));
306 __ movl(frame_map()->address_for_monitor_object(i), rbx); 320 __ movptr(frame_map()->address_for_monitor_object(i), rbx);
307 } 321 }
308 } 322 }
309 } 323 }
310 324
311 325
312 // inline cache check; done before the frame is built. 326 // inline cache check; done before the frame is built.
313 int LIR_Assembler::check_icache() { 327 int LIR_Assembler::check_icache() {
314 Register receiver = FrameMap::receiver_opr->as_register(); 328 Register receiver = FrameMap::receiver_opr->as_register();
315 Register ic_klass = IC_Klass; 329 Register ic_klass = IC_Klass;
330 const int ic_cmp_size = LP64_ONLY(10) NOT_LP64(9);
316 331
317 if (!VerifyOops) { 332 if (!VerifyOops) {
318 // insert some nops so that the verified entry point is aligned on CodeEntryAlignment 333 // insert some nops so that the verified entry point is aligned on CodeEntryAlignment
319 while ((__ offset() + 9) % CodeEntryAlignment != 0) { 334 while ((__ offset() + ic_cmp_size) % CodeEntryAlignment != 0) {
320 __ nop(); 335 __ nop();
321 } 336 }
322 } 337 }
323 int offset = __ offset(); 338 int offset = __ offset();
324 __ inline_cache_check(receiver, IC_Klass); 339 __ inline_cache_check(receiver, IC_Klass);
345 // preserve exception 360 // preserve exception
346 // note: the monitor_exit runtime call is a leaf routine 361 // note: the monitor_exit runtime call is a leaf routine
347 // and cannot block => no GC can happen 362 // and cannot block => no GC can happen
348 // The slow case (MonitorAccessStub) uses the first two stack slots 363 // The slow case (MonitorAccessStub) uses the first two stack slots
349 // ([esp+0] and [esp+4]), therefore we store the exception at [esp+8] 364 // ([esp+0] and [esp+4]), therefore we store the exception at [esp+8]
350 __ movl (Address(rsp, 2*wordSize), exception); 365 __ movptr (Address(rsp, 2*wordSize), exception);
351 } 366 }
352 367
353 Register obj_reg = obj_opr->as_register(); 368 Register obj_reg = obj_opr->as_register();
354 Register lock_reg = lock_opr->as_register(); 369 Register lock_reg = lock_opr->as_register();
355 370
358 Register hdr = lock_reg; 373 Register hdr = lock_reg;
359 assert(new_hdr == SYNC_header, "wrong register"); 374 assert(new_hdr == SYNC_header, "wrong register");
360 lock_reg = new_hdr; 375 lock_reg = new_hdr;
361 // compute pointer to BasicLock 376 // compute pointer to BasicLock
362 Address lock_addr = frame_map()->address_for_monitor_lock(monitor_no); 377 Address lock_addr = frame_map()->address_for_monitor_lock(monitor_no);
363 __ leal(lock_reg, lock_addr); 378 __ lea(lock_reg, lock_addr);
364 // unlock object 379 // unlock object
365 MonitorAccessStub* slow_case = new MonitorExitStub(lock_opr, true, monitor_no); 380 MonitorAccessStub* slow_case = new MonitorExitStub(lock_opr, true, monitor_no);
366 // _slow_case_stubs->append(slow_case); 381 // _slow_case_stubs->append(slow_case);
367 // temporary fix: must be created after exceptionhandler, therefore as call stub 382 // temporary fix: must be created after exceptionhandler, therefore as call stub
368 _slow_case_stubs->append(slow_case); 383 _slow_case_stubs->append(slow_case);
383 // done 398 // done
384 __ bind(*slow_case->continuation()); 399 __ bind(*slow_case->continuation());
385 400
386 if (exception->is_valid()) { 401 if (exception->is_valid()) {
387 // restore exception 402 // restore exception
388 __ movl (exception, Address(rsp, 2 * wordSize)); 403 __ movptr (exception, Address(rsp, 2 * wordSize));
389 } 404 }
390 } 405 }
391 406
392 // This specifies the rsp decrement needed to build the frame 407 // This specifies the rsp decrement needed to build the frame
393 int LIR_Assembler::initial_frame_size_in_bytes() { 408 int LIR_Assembler::initial_frame_size_in_bytes() {
394 // if rounding, must let FrameMap know! 409 // if rounding, must let FrameMap know!
395 return (frame_map()->framesize() - 2) * BytesPerWord; // subtract two words to account for return address and link 410
411 // The frame_map records size in slots (32bit word)
412
413 // subtract two words to account for return address and link
414 return (frame_map()->framesize() - (2*VMRegImpl::slots_per_word)) * VMRegImpl::stack_slot_size;
396 } 415 }
397 416
398 417
399 void LIR_Assembler::emit_exception_handler() { 418 void LIR_Assembler::emit_exception_handler() {
400 // if the last instruction is a call (typically to do a throw which 419 // if the last instruction is a call (typically to do a throw which
493 512
494 513
495 // This is the fast version of java.lang.String.compare; it has not 514 // This is the fast version of java.lang.String.compare; it has not
496 // OSR-entry and therefore, we generate a slow version for OSR's 515 // OSR-entry and therefore, we generate a slow version for OSR's
497 void LIR_Assembler::emit_string_compare(LIR_Opr arg0, LIR_Opr arg1, LIR_Opr dst, CodeEmitInfo* info) { 516 void LIR_Assembler::emit_string_compare(LIR_Opr arg0, LIR_Opr arg1, LIR_Opr dst, CodeEmitInfo* info) {
498 __ movl (rbx, rcx); // receiver is in rcx 517 __ movptr (rbx, rcx); // receiver is in rcx
499 __ movl (rax, arg1->as_register()); 518 __ movptr (rax, arg1->as_register());
500 519
501 // Get addresses of first characters from both Strings 520 // Get addresses of first characters from both Strings
502 __ movl (rsi, Address(rax, java_lang_String::value_offset_in_bytes())); 521 __ movptr (rsi, Address(rax, java_lang_String::value_offset_in_bytes()));
503 __ movl (rcx, Address(rax, java_lang_String::offset_offset_in_bytes())); 522 __ movptr (rcx, Address(rax, java_lang_String::offset_offset_in_bytes()));
504 __ leal (rsi, Address(rsi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); 523 __ lea (rsi, Address(rsi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
505 524
506 525
507 // rbx, may be NULL 526 // rbx, may be NULL
508 add_debug_info_for_null_check_here(info); 527 add_debug_info_for_null_check_here(info);
509 __ movl (rdi, Address(rbx, java_lang_String::value_offset_in_bytes())); 528 __ movptr (rdi, Address(rbx, java_lang_String::value_offset_in_bytes()));
510 __ movl (rcx, Address(rbx, java_lang_String::offset_offset_in_bytes())); 529 __ movptr (rcx, Address(rbx, java_lang_String::offset_offset_in_bytes()));
511 __ leal (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); 530 __ lea (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
512 531
513 // compute minimum length (in rax) and difference of lengths (on top of stack) 532 // compute minimum length (in rax) and difference of lengths (on top of stack)
514 if (VM_Version::supports_cmov()) { 533 if (VM_Version::supports_cmov()) {
515 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes())); 534 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
516 __ movl (rax, Address(rax, java_lang_String::count_offset_in_bytes())); 535 __ movl (rax, Address(rax, java_lang_String::count_offset_in_bytes()));
517 __ movl (rcx, rbx); 536 __ mov (rcx, rbx);
518 __ subl (rbx, rax); // subtract lengths 537 __ subptr (rbx, rax); // subtract lengths
519 __ pushl(rbx); // result 538 __ push (rbx); // result
520 __ cmovl(Assembler::lessEqual, rax, rcx); 539 __ cmov (Assembler::lessEqual, rax, rcx);
521 } else { 540 } else {
522 Label L; 541 Label L;
523 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes())); 542 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
524 __ movl (rcx, Address(rax, java_lang_String::count_offset_in_bytes())); 543 __ movl (rcx, Address(rax, java_lang_String::count_offset_in_bytes()));
525 __ movl (rax, rbx); 544 __ mov (rax, rbx);
526 __ subl (rbx, rcx); 545 __ subptr (rbx, rcx);
527 __ pushl(rbx); 546 __ push (rbx);
528 __ jcc (Assembler::lessEqual, L); 547 __ jcc (Assembler::lessEqual, L);
529 __ movl (rax, rcx); 548 __ mov (rax, rcx);
530 __ bind (L); 549 __ bind (L);
531 } 550 }
532 // is minimum length 0? 551 // is minimum length 0?
533 Label noLoop, haveResult; 552 Label noLoop, haveResult;
534 __ testl (rax, rax); 553 __ testptr (rax, rax);
535 __ jcc (Assembler::zero, noLoop); 554 __ jcc (Assembler::zero, noLoop);
536 555
537 // compare first characters 556 // compare first characters
538 __ load_unsigned_word(rcx, Address(rdi, 0)); 557 __ load_unsigned_word(rcx, Address(rdi, 0));
539 __ load_unsigned_word(rbx, Address(rsi, 0)); 558 __ load_unsigned_word(rbx, Address(rsi, 0));
544 __ jcc(Assembler::zero, noLoop); 563 __ jcc(Assembler::zero, noLoop);
545 564
546 // set rsi.edi to the end of the arrays (arrays have same length) 565 // set rsi.edi to the end of the arrays (arrays have same length)
547 // negate the index 566 // negate the index
548 567
549 __ leal(rsi, Address(rsi, rax, Address::times_2, type2aelembytes(T_CHAR))); 568 __ lea(rsi, Address(rsi, rax, Address::times_2, type2aelembytes(T_CHAR)));
550 __ leal(rdi, Address(rdi, rax, Address::times_2, type2aelembytes(T_CHAR))); 569 __ lea(rdi, Address(rdi, rax, Address::times_2, type2aelembytes(T_CHAR)));
551 __ negl(rax); 570 __ negptr(rax);
552 571
553 // compare the strings in a loop 572 // compare the strings in a loop
554 573
555 Label loop; 574 Label loop;
556 __ align(wordSize); 575 __ align(wordSize);
563 __ jcc(Assembler::notZero, loop); 582 __ jcc(Assembler::notZero, loop);
564 583
565 // strings are equal up to min length 584 // strings are equal up to min length
566 585
567 __ bind(noLoop); 586 __ bind(noLoop);
568 __ popl(rax); 587 __ pop(rax);
569 return_op(LIR_OprFact::illegalOpr); 588 return_op(LIR_OprFact::illegalOpr);
570 589
571 __ bind(haveResult); 590 __ bind(haveResult);
572 // leave instruction is going to discard the TOS value 591 // leave instruction is going to discard the TOS value
573 __ movl (rax, rcx); // result of call is in rax, 592 __ mov (rax, rcx); // result of call is in rax,
574 } 593 }
575 594
576 595
577 void LIR_Assembler::return_op(LIR_Opr result) { 596 void LIR_Assembler::return_op(LIR_Opr result) {
578 assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == rax, "word returns are in rax,"); 597 assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == rax, "word returns are in rax,");
587 606
588 // Note: we do not need to round double result; float result has the right precision 607 // Note: we do not need to round double result; float result has the right precision
589 // the poll sets the condition code, but no data registers 608 // the poll sets the condition code, but no data registers
590 AddressLiteral polling_page(os::get_polling_page() + (SafepointPollOffset % os::vm_page_size()), 609 AddressLiteral polling_page(os::get_polling_page() + (SafepointPollOffset % os::vm_page_size()),
591 relocInfo::poll_return_type); 610 relocInfo::poll_return_type);
611
612 // NOTE: the requires that the polling page be reachable else the reloc
613 // goes to the movq that loads the address and not the faulting instruction
614 // which breaks the signal handler code
615
592 __ test32(rax, polling_page); 616 __ test32(rax, polling_page);
593 617
594 __ ret(0); 618 __ ret(0);
595 } 619 }
596 620
604 } else { 628 } else {
605 ShouldNotReachHere(); 629 ShouldNotReachHere();
606 } 630 }
607 631
608 int offset = __ offset(); 632 int offset = __ offset();
633
634 // NOTE: the requires that the polling page be reachable else the reloc
635 // goes to the movq that loads the address and not the faulting instruction
636 // which breaks the signal handler code
637
609 __ test32(rax, polling_page); 638 __ test32(rax, polling_page);
610 return offset; 639 return offset;
611 } 640 }
612 641
613 642
614 void LIR_Assembler::move_regs(Register from_reg, Register to_reg) { 643 void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
615 if (from_reg != to_reg) __ movl(to_reg, from_reg); 644 if (from_reg != to_reg) __ mov(to_reg, from_reg);
616 } 645 }
617 646
618 void LIR_Assembler::swap_reg(Register a, Register b) { 647 void LIR_Assembler::swap_reg(Register a, Register b) {
619 __ xchgl(a, b); 648 __ xchgptr(a, b);
620 } 649 }
621 650
622 651
623 void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) { 652 void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
624 assert(src->is_constant(), "should not call otherwise"); 653 assert(src->is_constant(), "should not call otherwise");
632 break; 661 break;
633 } 662 }
634 663
635 case T_LONG: { 664 case T_LONG: {
636 assert(patch_code == lir_patch_none, "no patching handled here"); 665 assert(patch_code == lir_patch_none, "no patching handled here");
637 __ movl(dest->as_register_lo(), c->as_jint_lo()); 666 #ifdef _LP64
638 __ movl(dest->as_register_hi(), c->as_jint_hi()); 667 __ movptr(dest->as_register_lo(), (intptr_t)c->as_jlong());
668 #else
669 __ movptr(dest->as_register_lo(), c->as_jint_lo());
670 __ movptr(dest->as_register_hi(), c->as_jint_hi());
671 #endif // _LP64
639 break; 672 break;
640 } 673 }
641 674
642 case T_OBJECT: { 675 case T_OBJECT: {
643 if (patch_code != lir_patch_none) { 676 if (patch_code != lir_patch_none) {
712 __ movoop(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jobject()); 745 __ movoop(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jobject());
713 break; 746 break;
714 747
715 case T_LONG: // fall through 748 case T_LONG: // fall through
716 case T_DOUBLE: 749 case T_DOUBLE:
717 __ movl(frame_map()->address_for_slot(dest->double_stack_ix(), 750 #ifdef _LP64
718 lo_word_offset_in_bytes), c->as_jint_lo_bits()); 751 __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
719 __ movl(frame_map()->address_for_slot(dest->double_stack_ix(), 752 lo_word_offset_in_bytes), (intptr_t)c->as_jlong_bits());
720 hi_word_offset_in_bytes), c->as_jint_hi_bits()); 753 #else
754 __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
755 lo_word_offset_in_bytes), c->as_jint_lo_bits());
756 __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
757 hi_word_offset_in_bytes), c->as_jint_hi_bits());
758 #endif // _LP64
721 break; 759 break;
722 760
723 default: 761 default:
724 ShouldNotReachHere(); 762 ShouldNotReachHere();
725 } 763 }
729 assert(src->is_constant(), "should not call otherwise"); 767 assert(src->is_constant(), "should not call otherwise");
730 assert(dest->is_address(), "should not call otherwise"); 768 assert(dest->is_address(), "should not call otherwise");
731 LIR_Const* c = src->as_constant_ptr(); 769 LIR_Const* c = src->as_constant_ptr();
732 LIR_Address* addr = dest->as_address_ptr(); 770 LIR_Address* addr = dest->as_address_ptr();
733 771
734 if (info != NULL) add_debug_info_for_null_check_here(info); 772 int null_check_here = code_offset();
735 switch (type) { 773 switch (type) {
736 case T_INT: // fall through 774 case T_INT: // fall through
737 case T_FLOAT: 775 case T_FLOAT:
738 __ movl(as_Address(addr), c->as_jint_bits()); 776 __ movl(as_Address(addr), c->as_jint_bits());
739 break; 777 break;
740 778
741 case T_OBJECT: // fall through 779 case T_OBJECT: // fall through
742 case T_ARRAY: 780 case T_ARRAY:
743 if (c->as_jobject() == NULL) { 781 if (c->as_jobject() == NULL) {
744 __ movl(as_Address(addr), NULL_WORD); 782 __ movptr(as_Address(addr), (int32_t)NULL_WORD);
745 } else { 783 } else {
746 __ movoop(as_Address(addr), c->as_jobject()); 784 if (is_literal_address(addr)) {
785 ShouldNotReachHere();
786 __ movoop(as_Address(addr, noreg), c->as_jobject());
787 } else {
788 __ movoop(as_Address(addr), c->as_jobject());
789 }
747 } 790 }
748 break; 791 break;
749 792
750 case T_LONG: // fall through 793 case T_LONG: // fall through
751 case T_DOUBLE: 794 case T_DOUBLE:
752 __ movl(as_Address_hi(addr), c->as_jint_hi_bits()); 795 #ifdef _LP64
753 __ movl(as_Address_lo(addr), c->as_jint_lo_bits()); 796 if (is_literal_address(addr)) {
797 ShouldNotReachHere();
798 __ movptr(as_Address(addr, r15_thread), (intptr_t)c->as_jlong_bits());
799 } else {
800 __ movptr(r10, (intptr_t)c->as_jlong_bits());
801 null_check_here = code_offset();
802 __ movptr(as_Address_lo(addr), r10);
803 }
804 #else
805 // Always reachable in 32bit so this doesn't produce useless move literal
806 __ movptr(as_Address_hi(addr), c->as_jint_hi_bits());
807 __ movptr(as_Address_lo(addr), c->as_jint_lo_bits());
808 #endif // _LP64
754 break; 809 break;
755 810
756 case T_BOOLEAN: // fall through 811 case T_BOOLEAN: // fall through
757 case T_BYTE: 812 case T_BYTE:
758 __ movb(as_Address(addr), c->as_jint() & 0xFF); 813 __ movb(as_Address(addr), c->as_jint() & 0xFF);
764 break; 819 break;
765 820
766 default: 821 default:
767 ShouldNotReachHere(); 822 ShouldNotReachHere();
768 }; 823 };
824
825 if (info != NULL) {
826 add_debug_info_for_null_check(null_check_here, info);
827 }
769 } 828 }
770 829
771 830
772 void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) { 831 void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) {
773 assert(src->is_register(), "should not call otherwise"); 832 assert(src->is_register(), "should not call otherwise");
774 assert(dest->is_register(), "should not call otherwise"); 833 assert(dest->is_register(), "should not call otherwise");
775 834
776 // move between cpu-registers 835 // move between cpu-registers
777 if (dest->is_single_cpu()) { 836 if (dest->is_single_cpu()) {
837 #ifdef _LP64
838 if (src->type() == T_LONG) {
839 // Can do LONG -> OBJECT
840 move_regs(src->as_register_lo(), dest->as_register());
841 return;
842 }
843 #endif
778 assert(src->is_single_cpu(), "must match"); 844 assert(src->is_single_cpu(), "must match");
779 if (src->type() == T_OBJECT) { 845 if (src->type() == T_OBJECT) {
780 __ verify_oop(src->as_register()); 846 __ verify_oop(src->as_register());
781 } 847 }
782 move_regs(src->as_register(), dest->as_register()); 848 move_regs(src->as_register(), dest->as_register());
783 849
784 } else if (dest->is_double_cpu()) { 850 } else if (dest->is_double_cpu()) {
851 #ifdef _LP64
852 if (src->type() == T_OBJECT || src->type() == T_ARRAY) {
853 // Surprising to me but we can see move of a long to t_object
854 __ verify_oop(src->as_register());
855 move_regs(src->as_register(), dest->as_register_lo());
856 return;
857 }
858 #endif
785 assert(src->is_double_cpu(), "must match"); 859 assert(src->is_double_cpu(), "must match");
786 Register f_lo = src->as_register_lo(); 860 Register f_lo = src->as_register_lo();
787 Register f_hi = src->as_register_hi(); 861 Register f_hi = src->as_register_hi();
788 Register t_lo = dest->as_register_lo(); 862 Register t_lo = dest->as_register_lo();
789 Register t_hi = dest->as_register_hi(); 863 Register t_hi = dest->as_register_hi();
864 #ifdef _LP64
865 assert(f_hi == f_lo, "must be same");
866 assert(t_hi == t_lo, "must be same");
867 move_regs(f_lo, t_lo);
868 #else
790 assert(f_lo != f_hi && t_lo != t_hi, "invalid register allocation"); 869 assert(f_lo != f_hi && t_lo != t_hi, "invalid register allocation");
870
791 871
792 if (f_lo == t_hi && f_hi == t_lo) { 872 if (f_lo == t_hi && f_hi == t_lo) {
793 swap_reg(f_lo, f_hi); 873 swap_reg(f_lo, f_hi);
794 } else if (f_hi == t_lo) { 874 } else if (f_hi == t_lo) {
795 assert(f_lo != t_hi, "overwriting register"); 875 assert(f_lo != t_hi, "overwriting register");
798 } else { 878 } else {
799 assert(f_hi != t_lo, "overwriting register"); 879 assert(f_hi != t_lo, "overwriting register");
800 move_regs(f_lo, t_lo); 880 move_regs(f_lo, t_lo);
801 move_regs(f_hi, t_hi); 881 move_regs(f_hi, t_hi);
802 } 882 }
883 #endif // LP64
803 884
804 // special moves from fpu-register to xmm-register 885 // special moves from fpu-register to xmm-register
805 // necessary for method results 886 // necessary for method results
806 } else if (src->is_single_xmm() && !dest->is_single_xmm()) { 887 } else if (src->is_single_xmm() && !dest->is_single_xmm()) {
807 __ movflt(Address(rsp, 0), src->as_xmm_float_reg()); 888 __ movflt(Address(rsp, 0), src->as_xmm_float_reg());
839 920
840 if (src->is_single_cpu()) { 921 if (src->is_single_cpu()) {
841 Address dst = frame_map()->address_for_slot(dest->single_stack_ix()); 922 Address dst = frame_map()->address_for_slot(dest->single_stack_ix());
842 if (type == T_OBJECT || type == T_ARRAY) { 923 if (type == T_OBJECT || type == T_ARRAY) {
843 __ verify_oop(src->as_register()); 924 __ verify_oop(src->as_register());
844 } 925 __ movptr (dst, src->as_register());
845 __ movl (dst, src->as_register()); 926 } else {
927 __ movl (dst, src->as_register());
928 }
846 929
847 } else if (src->is_double_cpu()) { 930 } else if (src->is_double_cpu()) {
848 Address dstLO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes); 931 Address dstLO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes);
849 Address dstHI = frame_map()->address_for_slot(dest->double_stack_ix(), hi_word_offset_in_bytes); 932 Address dstHI = frame_map()->address_for_slot(dest->double_stack_ix(), hi_word_offset_in_bytes);
850 __ movl (dstLO, src->as_register_lo()); 933 __ movptr (dstLO, src->as_register_lo());
851 __ movl (dstHI, src->as_register_hi()); 934 NOT_LP64(__ movptr (dstHI, src->as_register_hi()));
852 935
853 } else if (src->is_single_xmm()) { 936 } else if (src->is_single_xmm()) {
854 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix()); 937 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
855 __ movflt(dst_addr, src->as_xmm_float_reg()); 938 __ movflt(dst_addr, src->as_xmm_float_reg());
856 939
883 if (type == T_ARRAY || type == T_OBJECT) { 966 if (type == T_ARRAY || type == T_OBJECT) {
884 __ verify_oop(src->as_register()); 967 __ verify_oop(src->as_register());
885 } 968 }
886 if (patch_code != lir_patch_none) { 969 if (patch_code != lir_patch_none) {
887 patch = new PatchingStub(_masm, PatchingStub::access_field_id); 970 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
971 Address toa = as_Address(to_addr);
972 assert(toa.disp() != 0, "must have");
888 } 973 }
889 if (info != NULL) { 974 if (info != NULL) {
890 add_debug_info_for_null_check_here(info); 975 add_debug_info_for_null_check_here(info);
891 } 976 }
892 977
916 } 1001 }
917 1002
918 case T_ADDRESS: // fall through 1003 case T_ADDRESS: // fall through
919 case T_ARRAY: // fall through 1004 case T_ARRAY: // fall through
920 case T_OBJECT: // fall through 1005 case T_OBJECT: // fall through
1006 #ifdef _LP64
1007 __ movptr(as_Address(to_addr), src->as_register());
1008 break;
1009 #endif // _LP64
921 case T_INT: 1010 case T_INT:
922 __ movl(as_Address(to_addr), src->as_register()); 1011 __ movl(as_Address(to_addr), src->as_register());
923 break; 1012 break;
924 1013
925 case T_LONG: { 1014 case T_LONG: {
926 Register from_lo = src->as_register_lo(); 1015 Register from_lo = src->as_register_lo();
927 Register from_hi = src->as_register_hi(); 1016 Register from_hi = src->as_register_hi();
1017 #ifdef _LP64
1018 __ movptr(as_Address_lo(to_addr), from_lo);
1019 #else
928 Register base = to_addr->base()->as_register(); 1020 Register base = to_addr->base()->as_register();
929 Register index = noreg; 1021 Register index = noreg;
930 if (to_addr->index()->is_register()) { 1022 if (to_addr->index()->is_register()) {
931 index = to_addr->index()->as_register(); 1023 index = to_addr->index()->as_register();
932 } 1024 }
948 patch = new PatchingStub(_masm, PatchingStub::access_field_id); 1040 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
949 patch_code = lir_patch_high; 1041 patch_code = lir_patch_high;
950 } 1042 }
951 __ movl(as_Address_hi(to_addr), from_hi); 1043 __ movl(as_Address_hi(to_addr), from_hi);
952 } 1044 }
1045 #endif // _LP64
953 break; 1046 break;
954 } 1047 }
955 1048
956 case T_BYTE: // fall through 1049 case T_BYTE: // fall through
957 case T_BOOLEAN: { 1050 case T_BOOLEAN: {
980 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) { 1073 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
981 assert(src->is_stack(), "should not call otherwise"); 1074 assert(src->is_stack(), "should not call otherwise");
982 assert(dest->is_register(), "should not call otherwise"); 1075 assert(dest->is_register(), "should not call otherwise");
983 1076
984 if (dest->is_single_cpu()) { 1077 if (dest->is_single_cpu()) {
985 __ movl(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
986 if (type == T_ARRAY || type == T_OBJECT) { 1078 if (type == T_ARRAY || type == T_OBJECT) {
1079 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
987 __ verify_oop(dest->as_register()); 1080 __ verify_oop(dest->as_register());
1081 } else {
1082 __ movl(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
988 } 1083 }
989 1084
990 } else if (dest->is_double_cpu()) { 1085 } else if (dest->is_double_cpu()) {
991 Address src_addr_LO = frame_map()->address_for_slot(src->double_stack_ix(), lo_word_offset_in_bytes); 1086 Address src_addr_LO = frame_map()->address_for_slot(src->double_stack_ix(), lo_word_offset_in_bytes);
992 Address src_addr_HI = frame_map()->address_for_slot(src->double_stack_ix(), hi_word_offset_in_bytes); 1087 Address src_addr_HI = frame_map()->address_for_slot(src->double_stack_ix(), hi_word_offset_in_bytes);
993 __ movl(dest->as_register_hi(), src_addr_HI); 1088 __ movptr(dest->as_register_lo(), src_addr_LO);
994 __ movl(dest->as_register_lo(), src_addr_LO); 1089 NOT_LP64(__ movptr(dest->as_register_hi(), src_addr_HI));
995 1090
996 } else if (dest->is_single_xmm()) { 1091 } else if (dest->is_single_xmm()) {
997 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix()); 1092 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
998 __ movflt(dest->as_xmm_float_reg(), src_addr); 1093 __ movflt(dest->as_xmm_float_reg(), src_addr);
999 1094
1017 } 1112 }
1018 1113
1019 1114
1020 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) { 1115 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
1021 if (src->is_single_stack()) { 1116 if (src->is_single_stack()) {
1022 __ pushl(frame_map()->address_for_slot(src ->single_stack_ix())); 1117 if (type == T_OBJECT || type == T_ARRAY) {
1023 __ popl (frame_map()->address_for_slot(dest->single_stack_ix())); 1118 __ pushptr(frame_map()->address_for_slot(src ->single_stack_ix()));
1119 __ popptr (frame_map()->address_for_slot(dest->single_stack_ix()));
1120 } else {
1121 __ pushl(frame_map()->address_for_slot(src ->single_stack_ix()));
1122 __ popl (frame_map()->address_for_slot(dest->single_stack_ix()));
1123 }
1024 1124
1025 } else if (src->is_double_stack()) { 1125 } else if (src->is_double_stack()) {
1126 #ifdef _LP64
1127 __ pushptr(frame_map()->address_for_slot(src ->double_stack_ix()));
1128 __ popptr (frame_map()->address_for_slot(dest->double_stack_ix()));
1129 #else
1026 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 0)); 1130 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 0));
1027 // push and pop the part at src + 4, adding 4 for the previous push 1131 // push and pop the part at src + wordSize, adding wordSize for the previous push
1028 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 4 + 4)); 1132 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), wordSize));
1029 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 4 + 4)); 1133 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), wordSize));
1030 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 0)); 1134 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 0));
1135 #endif // _LP64
1031 1136
1032 } else { 1137 } else {
1033 ShouldNotReachHere(); 1138 ShouldNotReachHere();
1034 } 1139 }
1035 } 1140 }
1050 if (!VM_Version::is_P6() && !from_addr.uses(dest->as_register())) { 1155 if (!VM_Version::is_P6() && !from_addr.uses(dest->as_register())) {
1051 // on pre P6 processors we may get partial register stalls 1156 // on pre P6 processors we may get partial register stalls
1052 // so blow away the value of to_rinfo before loading a 1157 // so blow away the value of to_rinfo before loading a
1053 // partial word into it. Do it here so that it precedes 1158 // partial word into it. Do it here so that it precedes
1054 // the potential patch point below. 1159 // the potential patch point below.
1055 __ xorl(dest->as_register(), dest->as_register()); 1160 __ xorptr(dest->as_register(), dest->as_register());
1056 } 1161 }
1057 break; 1162 break;
1058 } 1163 }
1059 1164
1060 PatchingStub* patch = NULL; 1165 PatchingStub* patch = NULL;
1061 if (patch_code != lir_patch_none) { 1166 if (patch_code != lir_patch_none) {
1062 patch = new PatchingStub(_masm, PatchingStub::access_field_id); 1167 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
1168 assert(from_addr.disp() != 0, "must have");
1063 } 1169 }
1064 if (info != NULL) { 1170 if (info != NULL) {
1065 add_debug_info_for_null_check_here(info); 1171 add_debug_info_for_null_check_here(info);
1066 } 1172 }
1067 1173
1089 } 1195 }
1090 1196
1091 case T_ADDRESS: // fall through 1197 case T_ADDRESS: // fall through
1092 case T_OBJECT: // fall through 1198 case T_OBJECT: // fall through
1093 case T_ARRAY: // fall through 1199 case T_ARRAY: // fall through
1200 #ifdef _LP64
1201 __ movptr(dest->as_register(), from_addr);
1202 break;
1203 #endif // _L64
1094 case T_INT: 1204 case T_INT:
1095 __ movl(dest->as_register(), from_addr); 1205 // %%% could this be a movl? this is safer but longer instruction
1206 __ movl2ptr(dest->as_register(), from_addr);
1096 break; 1207 break;
1097 1208
1098 case T_LONG: { 1209 case T_LONG: {
1099 Register to_lo = dest->as_register_lo(); 1210 Register to_lo = dest->as_register_lo();
1100 Register to_hi = dest->as_register_hi(); 1211 Register to_hi = dest->as_register_hi();
1212 #ifdef _LP64
1213 __ movptr(to_lo, as_Address_lo(addr));
1214 #else
1101 Register base = addr->base()->as_register(); 1215 Register base = addr->base()->as_register();
1102 Register index = noreg; 1216 Register index = noreg;
1103 if (addr->index()->is_register()) { 1217 if (addr->index()->is_register()) {
1104 index = addr->index()->as_register(); 1218 index = addr->index()->as_register();
1105 } 1219 }
1107 (base == to_hi && index == to_lo)) { 1221 (base == to_hi && index == to_lo)) {
1108 // addresses with 2 registers are only formed as a result of 1222 // addresses with 2 registers are only formed as a result of
1109 // array access so this code will never have to deal with 1223 // array access so this code will never have to deal with
1110 // patches or null checks. 1224 // patches or null checks.
1111 assert(info == NULL && patch == NULL, "must be"); 1225 assert(info == NULL && patch == NULL, "must be");
1112 __ leal(to_hi, as_Address(addr)); 1226 __ lea(to_hi, as_Address(addr));
1113 __ movl(to_lo, Address(to_hi, 0)); 1227 __ movl(to_lo, Address(to_hi, 0));
1114 __ movl(to_hi, Address(to_hi, BytesPerWord)); 1228 __ movl(to_hi, Address(to_hi, BytesPerWord));
1115 } else if (base == to_lo || index == to_lo) { 1229 } else if (base == to_lo || index == to_lo) {
1116 assert(base != to_hi, "can't be"); 1230 assert(base != to_hi, "can't be");
1117 assert(index == noreg || (index != base && index != to_hi), "can't handle this"); 1231 assert(index == noreg || (index != base && index != to_hi), "can't handle this");
1130 patch = new PatchingStub(_masm, PatchingStub::access_field_id); 1244 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
1131 patch_code = lir_patch_high; 1245 patch_code = lir_patch_high;
1132 } 1246 }
1133 __ movl(to_hi, as_Address_hi(addr)); 1247 __ movl(to_hi, as_Address_hi(addr));
1134 } 1248 }
1249 #endif // _LP64
1135 break; 1250 break;
1136 } 1251 }
1137 1252
1138 case T_BOOLEAN: // fall through 1253 case T_BOOLEAN: // fall through
1139 case T_BYTE: { 1254 case T_BYTE: {
1140 Register dest_reg = dest->as_register(); 1255 Register dest_reg = dest->as_register();
1141 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6"); 1256 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
1142 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) { 1257 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
1143 __ movsxb(dest_reg, from_addr); 1258 __ movsbl(dest_reg, from_addr);
1144 } else { 1259 } else {
1145 __ movb(dest_reg, from_addr); 1260 __ movb(dest_reg, from_addr);
1146 __ shll(dest_reg, 24); 1261 __ shll(dest_reg, 24);
1147 __ sarl(dest_reg, 24); 1262 __ sarl(dest_reg, 24);
1148 } 1263 }
1264 // These are unsigned so the zero extension on 64bit is just what we need
1149 break; 1265 break;
1150 } 1266 }
1151 1267
1152 case T_CHAR: { 1268 case T_CHAR: {
1153 Register dest_reg = dest->as_register(); 1269 Register dest_reg = dest->as_register();
1154 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6"); 1270 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
1155 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) { 1271 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
1156 __ movzxw(dest_reg, from_addr); 1272 __ movzwl(dest_reg, from_addr);
1157 } else { 1273 } else {
1158 __ movw(dest_reg, from_addr); 1274 __ movw(dest_reg, from_addr);
1159 } 1275 }
1276 // This is unsigned so the zero extension on 64bit is just what we need
1277 // __ movl2ptr(dest_reg, dest_reg);
1160 break; 1278 break;
1161 } 1279 }
1162 1280
1163 case T_SHORT: { 1281 case T_SHORT: {
1164 Register dest_reg = dest->as_register(); 1282 Register dest_reg = dest->as_register();
1165 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) { 1283 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
1166 __ movsxw(dest_reg, from_addr); 1284 __ movswl(dest_reg, from_addr);
1167 } else { 1285 } else {
1168 __ movw(dest_reg, from_addr); 1286 __ movw(dest_reg, from_addr);
1169 __ shll(dest_reg, 16); 1287 __ shll(dest_reg, 16);
1170 __ sarl(dest_reg, 16); 1288 __ sarl(dest_reg, 16);
1171 } 1289 }
1290 // Might not be needed in 64bit but certainly doesn't hurt (except for code size)
1291 __ movl2ptr(dest_reg, dest_reg);
1172 break; 1292 break;
1173 } 1293 }
1174 1294
1175 default: 1295 default:
1176 ShouldNotReachHere(); 1296 ShouldNotReachHere();
1304 LIR_Opr src = op->in_opr(); 1424 LIR_Opr src = op->in_opr();
1305 LIR_Opr dest = op->result_opr(); 1425 LIR_Opr dest = op->result_opr();
1306 1426
1307 switch (op->bytecode()) { 1427 switch (op->bytecode()) {
1308 case Bytecodes::_i2l: 1428 case Bytecodes::_i2l:
1429 #ifdef _LP64
1430 __ movl2ptr(dest->as_register_lo(), src->as_register());
1431 #else
1309 move_regs(src->as_register(), dest->as_register_lo()); 1432 move_regs(src->as_register(), dest->as_register_lo());
1310 move_regs(src->as_register(), dest->as_register_hi()); 1433 move_regs(src->as_register(), dest->as_register_hi());
1311 __ sarl(dest->as_register_hi(), 31); 1434 __ sarl(dest->as_register_hi(), 31);
1435 #endif // LP64
1312 break; 1436 break;
1313 1437
1314 case Bytecodes::_l2i: 1438 case Bytecodes::_l2i:
1315 move_regs(src->as_register_lo(), dest->as_register()); 1439 move_regs(src->as_register_lo(), dest->as_register());
1316 break; 1440 break;
1344 break; 1468 break;
1345 1469
1346 case Bytecodes::_i2f: 1470 case Bytecodes::_i2f:
1347 case Bytecodes::_i2d: 1471 case Bytecodes::_i2d:
1348 if (dest->is_single_xmm()) { 1472 if (dest->is_single_xmm()) {
1349 __ cvtsi2ss(dest->as_xmm_float_reg(), src->as_register()); 1473 __ cvtsi2ssl(dest->as_xmm_float_reg(), src->as_register());
1350 } else if (dest->is_double_xmm()) { 1474 } else if (dest->is_double_xmm()) {
1351 __ cvtsi2sd(dest->as_xmm_double_reg(), src->as_register()); 1475 __ cvtsi2sdl(dest->as_xmm_double_reg(), src->as_register());
1352 } else { 1476 } else {
1353 assert(dest->fpu() == 0, "result must be on TOS"); 1477 assert(dest->fpu() == 0, "result must be on TOS");
1354 __ movl(Address(rsp, 0), src->as_register()); 1478 __ movl(Address(rsp, 0), src->as_register());
1355 __ fild_s(Address(rsp, 0)); 1479 __ fild_s(Address(rsp, 0));
1356 } 1480 }
1357 break; 1481 break;
1358 1482
1359 case Bytecodes::_f2i: 1483 case Bytecodes::_f2i:
1360 case Bytecodes::_d2i: 1484 case Bytecodes::_d2i:
1361 if (src->is_single_xmm()) { 1485 if (src->is_single_xmm()) {
1362 __ cvttss2si(dest->as_register(), src->as_xmm_float_reg()); 1486 __ cvttss2sil(dest->as_register(), src->as_xmm_float_reg());
1363 } else if (src->is_double_xmm()) { 1487 } else if (src->is_double_xmm()) {
1364 __ cvttsd2si(dest->as_register(), src->as_xmm_double_reg()); 1488 __ cvttsd2sil(dest->as_register(), src->as_xmm_double_reg());
1365 } else { 1489 } else {
1366 assert(src->fpu() == 0, "input must be on TOS"); 1490 assert(src->fpu() == 0, "input must be on TOS");
1367 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_trunc())); 1491 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_trunc()));
1368 __ fist_s(Address(rsp, 0)); 1492 __ fist_s(Address(rsp, 0));
1369 __ movl(dest->as_register(), Address(rsp, 0)); 1493 __ movl(dest->as_register(), Address(rsp, 0));
1380 case Bytecodes::_l2f: 1504 case Bytecodes::_l2f:
1381 case Bytecodes::_l2d: 1505 case Bytecodes::_l2d:
1382 assert(!dest->is_xmm_register(), "result in xmm register not supported (no SSE instruction present)"); 1506 assert(!dest->is_xmm_register(), "result in xmm register not supported (no SSE instruction present)");
1383 assert(dest->fpu() == 0, "result must be on TOS"); 1507 assert(dest->fpu() == 0, "result must be on TOS");
1384 1508
1385 __ movl(Address(rsp, 0), src->as_register_lo()); 1509 __ movptr(Address(rsp, 0), src->as_register_lo());
1386 __ movl(Address(rsp, BytesPerWord), src->as_register_hi()); 1510 NOT_LP64(__ movl(Address(rsp, BytesPerWord), src->as_register_hi()));
1387 __ fild_d(Address(rsp, 0)); 1511 __ fild_d(Address(rsp, 0));
1388 // float result is rounded later through spilling 1512 // float result is rounded later through spilling
1389 break; 1513 break;
1390 1514
1391 case Bytecodes::_f2l: 1515 case Bytecodes::_f2l:
1392 case Bytecodes::_d2l: 1516 case Bytecodes::_d2l:
1393 assert(!src->is_xmm_register(), "input in xmm register not supported (no SSE instruction present)"); 1517 assert(!src->is_xmm_register(), "input in xmm register not supported (no SSE instruction present)");
1394 assert(src->fpu() == 0, "input must be on TOS"); 1518 assert(src->fpu() == 0, "input must be on TOS");
1395 assert(dest == FrameMap::rax_rdx_long_opr, "runtime stub places result in these registers"); 1519 assert(dest == FrameMap::long0_opr, "runtime stub places result in these registers");
1396 1520
1397 // instruction sequence too long to inline it here 1521 // instruction sequence too long to inline it here
1398 { 1522 {
1399 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::fpu2long_stub_id))); 1523 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::fpu2long_stub_id)));
1400 } 1524 }
1437 } else if (len == tmp2) { 1561 } else if (len == tmp2) {
1438 tmp2 = tmp3; 1562 tmp2 = tmp3;
1439 } else if (len == tmp3) { 1563 } else if (len == tmp3) {
1440 // everything is ok 1564 // everything is ok
1441 } else { 1565 } else {
1442 __ movl(tmp3, len); 1566 __ mov(tmp3, len);
1443 } 1567 }
1444 __ allocate_array(op->obj()->as_register(), 1568 __ allocate_array(op->obj()->as_register(),
1445 len, 1569 len,
1446 tmp1, 1570 tmp1,
1447 tmp2, 1571 tmp2,
1464 Register klass_RInfo = op->tmp2()->as_register(); 1588 Register klass_RInfo = op->tmp2()->as_register();
1465 Register Rtmp1 = op->tmp3()->as_register(); 1589 Register Rtmp1 = op->tmp3()->as_register();
1466 1590
1467 CodeStub* stub = op->stub(); 1591 CodeStub* stub = op->stub();
1468 Label done; 1592 Label done;
1469 __ cmpl(value, 0); 1593 __ cmpptr(value, (int32_t)NULL_WORD);
1470 __ jcc(Assembler::equal, done); 1594 __ jcc(Assembler::equal, done);
1471 add_debug_info_for_null_check_here(op->info_for_exception()); 1595 add_debug_info_for_null_check_here(op->info_for_exception());
1472 __ movl(k_RInfo, Address(array, oopDesc::klass_offset_in_bytes())); 1596 __ movptr(k_RInfo, Address(array, oopDesc::klass_offset_in_bytes()));
1473 __ movl(klass_RInfo, Address(value, oopDesc::klass_offset_in_bytes())); 1597 __ movptr(klass_RInfo, Address(value, oopDesc::klass_offset_in_bytes()));
1474 1598
1475 // get instance klass 1599 // get instance klass
1476 __ movl(k_RInfo, Address(k_RInfo, objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc))); 1600 __ movptr(k_RInfo, Address(k_RInfo, objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc)));
1477 // get super_check_offset 1601 // get super_check_offset
1478 __ movl(Rtmp1, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes())); 1602 __ movl(Rtmp1, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes()));
1479 // See if we get an immediate positive hit 1603 // See if we get an immediate positive hit
1480 __ cmpl(k_RInfo, Address(klass_RInfo, Rtmp1, Address::times_1)); 1604 __ cmpptr(k_RInfo, Address(klass_RInfo, Rtmp1, Address::times_1));
1481 __ jcc(Assembler::equal, done); 1605 __ jcc(Assembler::equal, done);
1482 // check for immediate negative hit 1606 // check for immediate negative hit
1483 __ cmpl(Rtmp1, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes()); 1607 __ cmpl(Rtmp1, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes());
1484 __ jcc(Assembler::notEqual, *stub->entry()); 1608 __ jcc(Assembler::notEqual, *stub->entry());
1485 // check for self 1609 // check for self
1486 __ cmpl(klass_RInfo, k_RInfo); 1610 __ cmpptr(klass_RInfo, k_RInfo);
1487 __ jcc(Assembler::equal, done); 1611 __ jcc(Assembler::equal, done);
1488 1612
1489 __ pushl(klass_RInfo); 1613 __ push(klass_RInfo);
1490 __ pushl(k_RInfo); 1614 __ push(k_RInfo);
1491 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); 1615 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1492 __ popl(klass_RInfo); 1616 __ pop(klass_RInfo);
1493 __ popl(k_RInfo); 1617 __ pop(k_RInfo);
1618 // result is a boolean
1494 __ cmpl(k_RInfo, 0); 1619 __ cmpl(k_RInfo, 0);
1495 __ jcc(Assembler::equal, *stub->entry()); 1620 __ jcc(Assembler::equal, *stub->entry());
1496 __ bind(done); 1621 __ bind(done);
1497 } else if (op->code() == lir_checkcast) { 1622 } else if (op->code() == lir_checkcast) {
1498 // we always need a stub for the failure case. 1623 // we always need a stub for the failure case.
1519 1644
1520 assert_different_registers(obj, k_RInfo, klass_RInfo); 1645 assert_different_registers(obj, k_RInfo, klass_RInfo);
1521 if (!k->is_loaded()) { 1646 if (!k->is_loaded()) {
1522 jobject2reg_with_patching(k_RInfo, op->info_for_patch()); 1647 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
1523 } else { 1648 } else {
1649 #ifdef _LP64
1650 __ movoop(k_RInfo, k->encoding());
1651 #else
1524 k_RInfo = noreg; 1652 k_RInfo = noreg;
1653 #endif // _LP64
1525 } 1654 }
1526 assert(obj != k_RInfo, "must be different"); 1655 assert(obj != k_RInfo, "must be different");
1527 __ cmpl(obj, 0); 1656 __ cmpptr(obj, (int32_t)NULL_WORD);
1528 if (op->profiled_method() != NULL) { 1657 if (op->profiled_method() != NULL) {
1529 ciMethod* method = op->profiled_method(); 1658 ciMethod* method = op->profiled_method();
1530 int bci = op->profiled_bci(); 1659 int bci = op->profiled_bci();
1531 1660
1532 Label profile_done; 1661 Label profile_done;
1554 1683
1555 if (op->fast_check()) { 1684 if (op->fast_check()) {
1556 // get object classo 1685 // get object classo
1557 // not a safepoint as obj null check happens earlier 1686 // not a safepoint as obj null check happens earlier
1558 if (k->is_loaded()) { 1687 if (k->is_loaded()) {
1688 #ifdef _LP64
1689 __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
1690 #else
1559 __ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding()); 1691 __ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding());
1692 #endif // _LP64
1560 } else { 1693 } else {
1561 __ cmpl(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes())); 1694 __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
1562 1695
1563 } 1696 }
1564 __ jcc(Assembler::notEqual, *stub->entry()); 1697 __ jcc(Assembler::notEqual, *stub->entry());
1565 __ bind(done); 1698 __ bind(done);
1566 } else { 1699 } else {
1567 // get object class 1700 // get object class
1568 // not a safepoint as obj null check happens earlier 1701 // not a safepoint as obj null check happens earlier
1569 __ movl(klass_RInfo, Address(obj, oopDesc::klass_offset_in_bytes())); 1702 __ movptr(klass_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
1570 if (k->is_loaded()) { 1703 if (k->is_loaded()) {
1571 // See if we get an immediate positive hit 1704 // See if we get an immediate positive hit
1705 #ifdef _LP64
1706 __ cmpptr(k_RInfo, Address(klass_RInfo, k->super_check_offset()));
1707 #else
1572 __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding()); 1708 __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding());
1709 #endif // _LP64
1573 if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() != k->super_check_offset()) { 1710 if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() != k->super_check_offset()) {
1574 __ jcc(Assembler::notEqual, *stub->entry()); 1711 __ jcc(Assembler::notEqual, *stub->entry());
1575 } else { 1712 } else {
1576 // See if we get an immediate positive hit 1713 // See if we get an immediate positive hit
1577 __ jcc(Assembler::equal, done); 1714 __ jcc(Assembler::equal, done);
1578 // check for self 1715 // check for self
1716 #ifdef _LP64
1717 __ cmpptr(klass_RInfo, k_RInfo);
1718 #else
1579 __ cmpoop(klass_RInfo, k->encoding()); 1719 __ cmpoop(klass_RInfo, k->encoding());
1720 #endif // _LP64
1580 __ jcc(Assembler::equal, done); 1721 __ jcc(Assembler::equal, done);
1581 1722
1582 __ pushl(klass_RInfo); 1723 __ push(klass_RInfo);
1724 #ifdef _LP64
1725 __ push(k_RInfo);
1726 #else
1583 __ pushoop(k->encoding()); 1727 __ pushoop(k->encoding());
1728 #endif // _LP64
1584 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); 1729 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1585 __ popl(klass_RInfo); 1730 __ pop(klass_RInfo);
1586 __ popl(klass_RInfo); 1731 __ pop(klass_RInfo);
1732 // result is a boolean
1587 __ cmpl(klass_RInfo, 0); 1733 __ cmpl(klass_RInfo, 0);
1588 __ jcc(Assembler::equal, *stub->entry()); 1734 __ jcc(Assembler::equal, *stub->entry());
1589 } 1735 }
1590 __ bind(done); 1736 __ bind(done);
1591 } else { 1737 } else {
1592 __ movl(Rtmp1, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes())); 1738 __ movl(Rtmp1, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes()));
1593 // See if we get an immediate positive hit 1739 // See if we get an immediate positive hit
1594 __ cmpl(k_RInfo, Address(klass_RInfo, Rtmp1, Address::times_1)); 1740 __ cmpptr(k_RInfo, Address(klass_RInfo, Rtmp1, Address::times_1));
1595 __ jcc(Assembler::equal, done); 1741 __ jcc(Assembler::equal, done);
1596 // check for immediate negative hit 1742 // check for immediate negative hit
1597 __ cmpl(Rtmp1, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes()); 1743 __ cmpl(Rtmp1, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes());
1598 __ jcc(Assembler::notEqual, *stub->entry()); 1744 __ jcc(Assembler::notEqual, *stub->entry());
1599 // check for self 1745 // check for self
1600 __ cmpl(klass_RInfo, k_RInfo); 1746 __ cmpptr(klass_RInfo, k_RInfo);
1601 __ jcc(Assembler::equal, done); 1747 __ jcc(Assembler::equal, done);
1602 1748
1603 __ pushl(klass_RInfo); 1749 __ push(klass_RInfo);
1604 __ pushl(k_RInfo); 1750 __ push(k_RInfo);
1605 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); 1751 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1606 __ popl(klass_RInfo); 1752 __ pop(klass_RInfo);
1607 __ popl(k_RInfo); 1753 __ pop(k_RInfo);
1754 // result is a boolean
1608 __ cmpl(k_RInfo, 0); 1755 __ cmpl(k_RInfo, 0);
1609 __ jcc(Assembler::equal, *stub->entry()); 1756 __ jcc(Assembler::equal, *stub->entry());
1610 __ bind(done); 1757 __ bind(done);
1611 } 1758 }
1612 1759
1613 } 1760 }
1614 if (dst != obj) { 1761 if (dst != obj) {
1615 __ movl(dst, obj); 1762 __ mov(dst, obj);
1616 } 1763 }
1617 } else if (code == lir_instanceof) { 1764 } else if (code == lir_instanceof) {
1618 Register obj = op->object()->as_register(); 1765 Register obj = op->object()->as_register();
1619 Register k_RInfo = op->tmp1()->as_register(); 1766 Register k_RInfo = op->tmp1()->as_register();
1620 Register klass_RInfo = op->tmp2()->as_register(); 1767 Register klass_RInfo = op->tmp2()->as_register();
1630 } 1777 }
1631 // patching may screw with our temporaries on sparc, 1778 // patching may screw with our temporaries on sparc,
1632 // so let's do it before loading the class 1779 // so let's do it before loading the class
1633 if (!k->is_loaded()) { 1780 if (!k->is_loaded()) {
1634 jobject2reg_with_patching(k_RInfo, op->info_for_patch()); 1781 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
1782 } else {
1783 LP64_ONLY(__ movoop(k_RInfo, k->encoding()));
1635 } 1784 }
1636 assert(obj != k_RInfo, "must be different"); 1785 assert(obj != k_RInfo, "must be different");
1637 1786
1638 __ verify_oop(obj); 1787 __ verify_oop(obj);
1639 if (op->fast_check()) { 1788 if (op->fast_check()) {
1640 __ cmpl(obj, 0); 1789 __ cmpptr(obj, (int32_t)NULL_WORD);
1641 __ jcc(Assembler::equal, zero); 1790 __ jcc(Assembler::equal, zero);
1642 // get object class 1791 // get object class
1643 // not a safepoint as obj null check happens earlier 1792 // not a safepoint as obj null check happens earlier
1644 if (k->is_loaded()) { 1793 if (LP64_ONLY(false &&) k->is_loaded()) {
1645 __ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding()); 1794 NOT_LP64(__ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding()));
1646 k_RInfo = noreg; 1795 k_RInfo = noreg;
1647 } else { 1796 } else {
1648 __ cmpl(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes())); 1797 __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
1649 1798
1650 } 1799 }
1651 __ jcc(Assembler::equal, one); 1800 __ jcc(Assembler::equal, one);
1652 } else { 1801 } else {
1653 // get object class 1802 // get object class
1654 // not a safepoint as obj null check happens earlier 1803 // not a safepoint as obj null check happens earlier
1655 __ cmpl(obj, 0); 1804 __ cmpptr(obj, (int32_t)NULL_WORD);
1656 __ jcc(Assembler::equal, zero); 1805 __ jcc(Assembler::equal, zero);
1657 __ movl(klass_RInfo, Address(obj, oopDesc::klass_offset_in_bytes())); 1806 __ movptr(klass_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
1807
1808 #ifndef _LP64
1658 if (k->is_loaded()) { 1809 if (k->is_loaded()) {
1659 // See if we get an immediate positive hit 1810 // See if we get an immediate positive hit
1660 __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding()); 1811 __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding());
1661 __ jcc(Assembler::equal, one); 1812 __ jcc(Assembler::equal, one);
1662 if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() == k->super_check_offset()) { 1813 if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() == k->super_check_offset()) {
1663 // check for self 1814 // check for self
1664 __ cmpoop(klass_RInfo, k->encoding()); 1815 __ cmpoop(klass_RInfo, k->encoding());
1665 __ jcc(Assembler::equal, one); 1816 __ jcc(Assembler::equal, one);
1666 __ pushl(klass_RInfo); 1817 __ push(klass_RInfo);
1667 __ pushoop(k->encoding()); 1818 __ pushoop(k->encoding());
1668 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); 1819 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1669 __ popl(klass_RInfo); 1820 __ pop(klass_RInfo);
1670 __ popl(dst); 1821 __ pop(dst);
1671 __ jmp(done); 1822 __ jmp(done);
1672 } 1823 }
1673 } else { 1824 } else {
1825 #else
1826 { // YUCK
1827 #endif // LP64
1674 assert(dst != klass_RInfo && dst != k_RInfo, "need 3 registers"); 1828 assert(dst != klass_RInfo && dst != k_RInfo, "need 3 registers");
1675 1829
1676 __ movl(dst, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes())); 1830 __ movl(dst, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes()));
1677 // See if we get an immediate positive hit 1831 // See if we get an immediate positive hit
1678 __ cmpl(k_RInfo, Address(klass_RInfo, dst, Address::times_1)); 1832 __ cmpptr(k_RInfo, Address(klass_RInfo, dst, Address::times_1));
1679 __ jcc(Assembler::equal, one); 1833 __ jcc(Assembler::equal, one);
1680 // check for immediate negative hit 1834 // check for immediate negative hit
1681 __ cmpl(dst, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes()); 1835 __ cmpl(dst, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes());
1682 __ jcc(Assembler::notEqual, zero); 1836 __ jcc(Assembler::notEqual, zero);
1683 // check for self 1837 // check for self
1684 __ cmpl(klass_RInfo, k_RInfo); 1838 __ cmpptr(klass_RInfo, k_RInfo);
1685 __ jcc(Assembler::equal, one); 1839 __ jcc(Assembler::equal, one);
1686 1840
1687 __ pushl(klass_RInfo); 1841 __ push(klass_RInfo);
1688 __ pushl(k_RInfo); 1842 __ push(k_RInfo);
1689 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); 1843 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1690 __ popl(klass_RInfo); 1844 __ pop(klass_RInfo);
1691 __ popl(dst); 1845 __ pop(dst);
1692 __ jmp(done); 1846 __ jmp(done);
1693 } 1847 }
1694 } 1848 }
1695 __ bind(zero); 1849 __ bind(zero);
1696 __ xorl(dst, dst); 1850 __ xorptr(dst, dst);
1697 __ jmp(done); 1851 __ jmp(done);
1698 __ bind(one); 1852 __ bind(one);
1699 __ movl(dst, 1); 1853 __ movptr(dst, 1);
1700 __ bind(done); 1854 __ bind(done);
1701 } else { 1855 } else {
1702 ShouldNotReachHere(); 1856 ShouldNotReachHere();
1703 } 1857 }
1704 1858
1705 } 1859 }
1706 1860
1707 1861
1708 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) { 1862 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
1709 if (op->code() == lir_cas_long) { 1863 if (LP64_ONLY(false &&) op->code() == lir_cas_long && VM_Version::supports_cx8()) {
1710 assert(VM_Version::supports_cx8(), "wrong machine");
1711 assert(op->cmp_value()->as_register_lo() == rax, "wrong register"); 1864 assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
1712 assert(op->cmp_value()->as_register_hi() == rdx, "wrong register"); 1865 assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
1713 assert(op->new_value()->as_register_lo() == rbx, "wrong register"); 1866 assert(op->new_value()->as_register_lo() == rbx, "wrong register");
1714 assert(op->new_value()->as_register_hi() == rcx, "wrong register"); 1867 assert(op->new_value()->as_register_hi() == rcx, "wrong register");
1715 Register addr = op->addr()->as_register(); 1868 Register addr = op->addr()->as_register();
1716 if (os::is_MP()) { 1869 if (os::is_MP()) {
1717 __ lock(); 1870 __ lock();
1718 } 1871 }
1719 __ cmpxchg8(Address(addr, 0)); 1872 NOT_LP64(__ cmpxchg8(Address(addr, 0)));
1720 1873
1721 } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj) { 1874 } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj ) {
1722 Register addr = op->addr()->as_register(); 1875 NOT_LP64(assert(op->addr()->is_single_cpu(), "must be single");)
1876 Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
1723 Register newval = op->new_value()->as_register(); 1877 Register newval = op->new_value()->as_register();
1724 Register cmpval = op->cmp_value()->as_register(); 1878 Register cmpval = op->cmp_value()->as_register();
1725 assert(cmpval == rax, "wrong register"); 1879 assert(cmpval == rax, "wrong register");
1726 assert(newval != NULL, "new val must be register"); 1880 assert(newval != NULL, "new val must be register");
1727 assert(cmpval != newval, "cmp and new values must be in different registers"); 1881 assert(cmpval != newval, "cmp and new values must be in different registers");
1728 assert(cmpval != addr, "cmp and addr must be in different registers"); 1882 assert(cmpval != addr, "cmp and addr must be in different registers");
1729 assert(newval != addr, "new value and addr must be in different registers"); 1883 assert(newval != addr, "new value and addr must be in different registers");
1730 if (os::is_MP()) { 1884 if (os::is_MP()) {
1731 __ lock(); 1885 __ lock();
1732 } 1886 }
1733 __ cmpxchg(newval, Address(addr, 0)); 1887 if ( op->code() == lir_cas_obj) {
1888 __ cmpxchgptr(newval, Address(addr, 0));
1889 } else if (op->code() == lir_cas_int) {
1890 __ cmpxchgl(newval, Address(addr, 0));
1891 } else {
1892 LP64_ONLY(__ cmpxchgq(newval, Address(addr, 0)));
1893 }
1894 #ifdef _LP64
1895 } else if (op->code() == lir_cas_long) {
1896 Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
1897 Register newval = op->new_value()->as_register_lo();
1898 Register cmpval = op->cmp_value()->as_register_lo();
1899 assert(cmpval == rax, "wrong register");
1900 assert(newval != NULL, "new val must be register");
1901 assert(cmpval != newval, "cmp and new values must be in different registers");
1902 assert(cmpval != addr, "cmp and addr must be in different registers");
1903 assert(newval != addr, "new value and addr must be in different registers");
1904 if (os::is_MP()) {
1905 __ lock();
1906 }
1907 __ cmpxchgq(newval, Address(addr, 0));
1908 #endif // _LP64
1734 } else { 1909 } else {
1735 Unimplemented(); 1910 Unimplemented();
1736 } 1911 }
1737 } 1912 }
1738 1913
1763 1938
1764 if (VM_Version::supports_cmov() && !opr2->is_constant()) { 1939 if (VM_Version::supports_cmov() && !opr2->is_constant()) {
1765 // optimized version that does not require a branch 1940 // optimized version that does not require a branch
1766 if (opr2->is_single_cpu()) { 1941 if (opr2->is_single_cpu()) {
1767 assert(opr2->cpu_regnr() != result->cpu_regnr(), "opr2 already overwritten by previous move"); 1942 assert(opr2->cpu_regnr() != result->cpu_regnr(), "opr2 already overwritten by previous move");
1768 __ cmovl(ncond, result->as_register(), opr2->as_register()); 1943 __ cmov(ncond, result->as_register(), opr2->as_register());
1769 } else if (opr2->is_double_cpu()) { 1944 } else if (opr2->is_double_cpu()) {
1770 assert(opr2->cpu_regnrLo() != result->cpu_regnrLo() && opr2->cpu_regnrLo() != result->cpu_regnrHi(), "opr2 already overwritten by previous move"); 1945 assert(opr2->cpu_regnrLo() != result->cpu_regnrLo() && opr2->cpu_regnrLo() != result->cpu_regnrHi(), "opr2 already overwritten by previous move");
1771 assert(opr2->cpu_regnrHi() != result->cpu_regnrLo() && opr2->cpu_regnrHi() != result->cpu_regnrHi(), "opr2 already overwritten by previous move"); 1946 assert(opr2->cpu_regnrHi() != result->cpu_regnrLo() && opr2->cpu_regnrHi() != result->cpu_regnrHi(), "opr2 already overwritten by previous move");
1772 __ cmovl(ncond, result->as_register_lo(), opr2->as_register_lo()); 1947 __ cmovptr(ncond, result->as_register_lo(), opr2->as_register_lo());
1773 __ cmovl(ncond, result->as_register_hi(), opr2->as_register_hi()); 1948 NOT_LP64(__ cmovptr(ncond, result->as_register_hi(), opr2->as_register_hi());)
1774 } else if (opr2->is_single_stack()) { 1949 } else if (opr2->is_single_stack()) {
1775 __ cmovl(ncond, result->as_register(), frame_map()->address_for_slot(opr2->single_stack_ix())); 1950 __ cmovl(ncond, result->as_register(), frame_map()->address_for_slot(opr2->single_stack_ix()));
1776 } else if (opr2->is_double_stack()) { 1951 } else if (opr2->is_double_stack()) {
1777 __ cmovl(ncond, result->as_register_lo(), frame_map()->address_for_slot(opr2->double_stack_ix(), lo_word_offset_in_bytes)); 1952 __ cmovptr(ncond, result->as_register_lo(), frame_map()->address_for_slot(opr2->double_stack_ix(), lo_word_offset_in_bytes));
1778 __ cmovl(ncond, result->as_register_hi(), frame_map()->address_for_slot(opr2->double_stack_ix(), hi_word_offset_in_bytes)); 1953 NOT_LP64(__ cmovptr(ncond, result->as_register_hi(), frame_map()->address_for_slot(opr2->double_stack_ix(), hi_word_offset_in_bytes));)
1779 } else { 1954 } else {
1780 ShouldNotReachHere(); 1955 ShouldNotReachHere();
1781 } 1956 }
1782 1957
1783 } else { 1958 } else {
1849 2024
1850 if (right->is_double_cpu()) { 2025 if (right->is_double_cpu()) {
1851 // cpu register - cpu register 2026 // cpu register - cpu register
1852 Register rreg_lo = right->as_register_lo(); 2027 Register rreg_lo = right->as_register_lo();
1853 Register rreg_hi = right->as_register_hi(); 2028 Register rreg_hi = right->as_register_hi();
1854 assert_different_registers(lreg_lo, lreg_hi, rreg_lo, rreg_hi); 2029 NOT_LP64(assert_different_registers(lreg_lo, lreg_hi, rreg_lo, rreg_hi));
2030 LP64_ONLY(assert_different_registers(lreg_lo, rreg_lo));
1855 switch (code) { 2031 switch (code) {
1856 case lir_add: 2032 case lir_add:
1857 __ addl(lreg_lo, rreg_lo); 2033 __ addptr(lreg_lo, rreg_lo);
1858 __ adcl(lreg_hi, rreg_hi); 2034 NOT_LP64(__ adcl(lreg_hi, rreg_hi));
1859 break; 2035 break;
1860 case lir_sub: 2036 case lir_sub:
1861 __ subl(lreg_lo, rreg_lo); 2037 __ subptr(lreg_lo, rreg_lo);
1862 __ sbbl(lreg_hi, rreg_hi); 2038 NOT_LP64(__ sbbl(lreg_hi, rreg_hi));
1863 break; 2039 break;
1864 case lir_mul: 2040 case lir_mul:
2041 #ifdef _LP64
2042 __ imulq(lreg_lo, rreg_lo);
2043 #else
1865 assert(lreg_lo == rax && lreg_hi == rdx, "must be"); 2044 assert(lreg_lo == rax && lreg_hi == rdx, "must be");
1866 __ imull(lreg_hi, rreg_lo); 2045 __ imull(lreg_hi, rreg_lo);
1867 __ imull(rreg_hi, lreg_lo); 2046 __ imull(rreg_hi, lreg_lo);
1868 __ addl (rreg_hi, lreg_hi); 2047 __ addl (rreg_hi, lreg_hi);
1869 __ mull (rreg_lo); 2048 __ mull (rreg_lo);
1870 __ addl (lreg_hi, rreg_hi); 2049 __ addl (lreg_hi, rreg_hi);
2050 #endif // _LP64
1871 break; 2051 break;
1872 default: 2052 default:
1873 ShouldNotReachHere(); 2053 ShouldNotReachHere();
1874 } 2054 }
1875 2055
1876 } else if (right->is_constant()) { 2056 } else if (right->is_constant()) {
1877 // cpu register - constant 2057 // cpu register - constant
2058 #ifdef _LP64
2059 jlong c = right->as_constant_ptr()->as_jlong_bits();
2060 __ movptr(r10, (intptr_t) c);
2061 switch (code) {
2062 case lir_add:
2063 __ addptr(lreg_lo, r10);
2064 break;
2065 case lir_sub:
2066 __ subptr(lreg_lo, r10);
2067 break;
2068 default:
2069 ShouldNotReachHere();
2070 }
2071 #else
1878 jint c_lo = right->as_constant_ptr()->as_jint_lo(); 2072 jint c_lo = right->as_constant_ptr()->as_jint_lo();
1879 jint c_hi = right->as_constant_ptr()->as_jint_hi(); 2073 jint c_hi = right->as_constant_ptr()->as_jint_hi();
1880 switch (code) { 2074 switch (code) {
1881 case lir_add: 2075 case lir_add:
1882 __ addl(lreg_lo, c_lo); 2076 __ addptr(lreg_lo, c_lo);
1883 __ adcl(lreg_hi, c_hi); 2077 __ adcl(lreg_hi, c_hi);
1884 break; 2078 break;
1885 case lir_sub: 2079 case lir_sub:
1886 __ subl(lreg_lo, c_lo); 2080 __ subptr(lreg_lo, c_lo);
1887 __ sbbl(lreg_hi, c_hi); 2081 __ sbbl(lreg_hi, c_hi);
1888 break; 2082 break;
1889 default: 2083 default:
1890 ShouldNotReachHere(); 2084 ShouldNotReachHere();
1891 } 2085 }
2086 #endif // _LP64
1892 2087
1893 } else { 2088 } else {
1894 ShouldNotReachHere(); 2089 ShouldNotReachHere();
1895 } 2090 }
1896 2091
2063 } 2258 }
2064 } else if (right->is_constant()) { 2259 } else if (right->is_constant()) {
2065 jint c = right->as_constant_ptr()->as_jint(); 2260 jint c = right->as_constant_ptr()->as_jint();
2066 switch (code) { 2261 switch (code) {
2067 case lir_add: { 2262 case lir_add: {
2068 __ increment(laddr, c); 2263 __ incrementl(laddr, c);
2069 break; 2264 break;
2070 } 2265 }
2071 case lir_sub: { 2266 case lir_sub: {
2072 __ decrement(laddr, c); 2267 __ decrementl(laddr, c);
2073 break; 2268 break;
2074 } 2269 }
2075 default: ShouldNotReachHere(); 2270 default: ShouldNotReachHere();
2076 } 2271 }
2077 } else { 2272 } else {
2209 default: ShouldNotReachHere(); 2404 default: ShouldNotReachHere();
2210 } 2405 }
2211 } else { 2406 } else {
2212 Register rright = right->as_register(); 2407 Register rright = right->as_register();
2213 switch (code) { 2408 switch (code) {
2214 case lir_logic_and: __ andl (reg, rright); break; 2409 case lir_logic_and: __ andptr (reg, rright); break;
2215 case lir_logic_or : __ orl (reg, rright); break; 2410 case lir_logic_or : __ orptr (reg, rright); break;
2216 case lir_logic_xor: __ xorl (reg, rright); break; 2411 case lir_logic_xor: __ xorptr (reg, rright); break;
2217 default: ShouldNotReachHere(); 2412 default: ShouldNotReachHere();
2218 } 2413 }
2219 } 2414 }
2220 move_regs(reg, dst->as_register()); 2415 move_regs(reg, dst->as_register());
2221 } else { 2416 } else {
2222 Register l_lo = left->as_register_lo(); 2417 Register l_lo = left->as_register_lo();
2223 Register l_hi = left->as_register_hi(); 2418 Register l_hi = left->as_register_hi();
2224 if (right->is_constant()) { 2419 if (right->is_constant()) {
2420 #ifdef _LP64
2421 __ mov64(rscratch1, right->as_constant_ptr()->as_jlong());
2422 switch (code) {
2423 case lir_logic_and:
2424 __ andq(l_lo, rscratch1);
2425 break;
2426 case lir_logic_or:
2427 __ orq(l_lo, rscratch1);
2428 break;
2429 case lir_logic_xor:
2430 __ xorq(l_lo, rscratch1);
2431 break;
2432 default: ShouldNotReachHere();
2433 }
2434 #else
2225 int r_lo = right->as_constant_ptr()->as_jint_lo(); 2435 int r_lo = right->as_constant_ptr()->as_jint_lo();
2226 int r_hi = right->as_constant_ptr()->as_jint_hi(); 2436 int r_hi = right->as_constant_ptr()->as_jint_hi();
2227 switch (code) { 2437 switch (code) {
2228 case lir_logic_and: 2438 case lir_logic_and:
2229 __ andl(l_lo, r_lo); 2439 __ andl(l_lo, r_lo);
2237 __ xorl(l_lo, r_lo); 2447 __ xorl(l_lo, r_lo);
2238 __ xorl(l_hi, r_hi); 2448 __ xorl(l_hi, r_hi);
2239 break; 2449 break;
2240 default: ShouldNotReachHere(); 2450 default: ShouldNotReachHere();
2241 } 2451 }
2452 #endif // _LP64
2242 } else { 2453 } else {
2243 Register r_lo = right->as_register_lo(); 2454 Register r_lo = right->as_register_lo();
2244 Register r_hi = right->as_register_hi(); 2455 Register r_hi = right->as_register_hi();
2245 assert(l_lo != r_hi, "overwriting registers"); 2456 assert(l_lo != r_hi, "overwriting registers");
2246 switch (code) { 2457 switch (code) {
2247 case lir_logic_and: 2458 case lir_logic_and:
2248 __ andl(l_lo, r_lo); 2459 __ andptr(l_lo, r_lo);
2249 __ andl(l_hi, r_hi); 2460 NOT_LP64(__ andptr(l_hi, r_hi);)
2250 break; 2461 break;
2251 case lir_logic_or: 2462 case lir_logic_or:
2252 __ orl(l_lo, r_lo); 2463 __ orptr(l_lo, r_lo);
2253 __ orl(l_hi, r_hi); 2464 NOT_LP64(__ orptr(l_hi, r_hi);)
2254 break; 2465 break;
2255 case lir_logic_xor: 2466 case lir_logic_xor:
2256 __ xorl(l_lo, r_lo); 2467 __ xorptr(l_lo, r_lo);
2257 __ xorl(l_hi, r_hi); 2468 NOT_LP64(__ xorptr(l_hi, r_hi);)
2258 break; 2469 break;
2259 default: ShouldNotReachHere(); 2470 default: ShouldNotReachHere();
2260 } 2471 }
2261 } 2472 }
2262 2473
2263 Register dst_lo = dst->as_register_lo(); 2474 Register dst_lo = dst->as_register_lo();
2264 Register dst_hi = dst->as_register_hi(); 2475 Register dst_hi = dst->as_register_hi();
2265 2476
2477 #ifdef _LP64
2478 move_regs(l_lo, dst_lo);
2479 #else
2266 if (dst_lo == l_hi) { 2480 if (dst_lo == l_hi) {
2267 assert(dst_hi != l_lo, "overwriting registers"); 2481 assert(dst_hi != l_lo, "overwriting registers");
2268 move_regs(l_hi, dst_hi); 2482 move_regs(l_hi, dst_hi);
2269 move_regs(l_lo, dst_lo); 2483 move_regs(l_lo, dst_lo);
2270 } else { 2484 } else {
2271 assert(dst_lo != l_hi, "overwriting registers"); 2485 assert(dst_lo != l_hi, "overwriting registers");
2272 move_regs(l_lo, dst_lo); 2486 move_regs(l_lo, dst_lo);
2273 move_regs(l_hi, dst_hi); 2487 move_regs(l_hi, dst_hi);
2274 } 2488 }
2489 #endif // _LP64
2275 } 2490 }
2276 } 2491 }
2277 2492
2278 2493
2279 // we assume that rax, and rdx can be overwritten 2494 // we assume that rax, and rdx can be overwritten
2304 } 2519 }
2305 __ sarl(lreg, log2_intptr(divisor)); 2520 __ sarl(lreg, log2_intptr(divisor));
2306 move_regs(lreg, dreg); 2521 move_regs(lreg, dreg);
2307 } else if (code == lir_irem) { 2522 } else if (code == lir_irem) {
2308 Label done; 2523 Label done;
2309 __ movl(dreg, lreg); 2524 __ mov(dreg, lreg);
2310 __ andl(dreg, 0x80000000 | (divisor - 1)); 2525 __ andl(dreg, 0x80000000 | (divisor - 1));
2311 __ jcc(Assembler::positive, done); 2526 __ jcc(Assembler::positive, done);
2312 __ decrement(dreg); 2527 __ decrement(dreg);
2313 __ orl(dreg, ~(divisor - 1)); 2528 __ orl(dreg, ~(divisor - 1));
2314 __ increment(dreg); 2529 __ increment(dreg);
2338 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) { 2553 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
2339 if (opr1->is_single_cpu()) { 2554 if (opr1->is_single_cpu()) {
2340 Register reg1 = opr1->as_register(); 2555 Register reg1 = opr1->as_register();
2341 if (opr2->is_single_cpu()) { 2556 if (opr2->is_single_cpu()) {
2342 // cpu register - cpu register 2557 // cpu register - cpu register
2343 __ cmpl(reg1, opr2->as_register()); 2558 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
2559 __ cmpptr(reg1, opr2->as_register());
2560 } else {
2561 assert(opr2->type() != T_OBJECT && opr2->type() != T_ARRAY, "cmp int, oop?");
2562 __ cmpl(reg1, opr2->as_register());
2563 }
2344 } else if (opr2->is_stack()) { 2564 } else if (opr2->is_stack()) {
2345 // cpu register - stack 2565 // cpu register - stack
2346 __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix())); 2566 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
2567 __ cmpptr(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
2568 } else {
2569 __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
2570 }
2347 } else if (opr2->is_constant()) { 2571 } else if (opr2->is_constant()) {
2348 // cpu register - constant 2572 // cpu register - constant
2349 LIR_Const* c = opr2->as_constant_ptr(); 2573 LIR_Const* c = opr2->as_constant_ptr();
2350 if (c->type() == T_INT) { 2574 if (c->type() == T_INT) {
2351 __ cmpl(reg1, c->as_jint()); 2575 __ cmpl(reg1, c->as_jint());
2352 } else if (c->type() == T_OBJECT) { 2576 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
2577 // In 64bit oops are single register
2353 jobject o = c->as_jobject(); 2578 jobject o = c->as_jobject();
2354 if (o == NULL) { 2579 if (o == NULL) {
2355 __ cmpl(reg1, NULL_WORD); 2580 __ cmpptr(reg1, (int32_t)NULL_WORD);
2356 } else { 2581 } else {
2582 #ifdef _LP64
2583 __ movoop(rscratch1, o);
2584 __ cmpptr(reg1, rscratch1);
2585 #else
2357 __ cmpoop(reg1, c->as_jobject()); 2586 __ cmpoop(reg1, c->as_jobject());
2587 #endif // _LP64
2358 } 2588 }
2359 } else { 2589 } else {
2360 ShouldNotReachHere(); 2590 ShouldNotReachHere();
2361 } 2591 }
2362 // cpu register - address 2592 // cpu register - address
2371 2601
2372 } else if(opr1->is_double_cpu()) { 2602 } else if(opr1->is_double_cpu()) {
2373 Register xlo = opr1->as_register_lo(); 2603 Register xlo = opr1->as_register_lo();
2374 Register xhi = opr1->as_register_hi(); 2604 Register xhi = opr1->as_register_hi();
2375 if (opr2->is_double_cpu()) { 2605 if (opr2->is_double_cpu()) {
2606 #ifdef _LP64
2607 __ cmpptr(xlo, opr2->as_register_lo());
2608 #else
2376 // cpu register - cpu register 2609 // cpu register - cpu register
2377 Register ylo = opr2->as_register_lo(); 2610 Register ylo = opr2->as_register_lo();
2378 Register yhi = opr2->as_register_hi(); 2611 Register yhi = opr2->as_register_hi();
2379 __ subl(xlo, ylo); 2612 __ subl(xlo, ylo);
2380 __ sbbl(xhi, yhi); 2613 __ sbbl(xhi, yhi);
2381 if (condition == lir_cond_equal || condition == lir_cond_notEqual) { 2614 if (condition == lir_cond_equal || condition == lir_cond_notEqual) {
2382 __ orl(xhi, xlo); 2615 __ orl(xhi, xlo);
2383 } 2616 }
2617 #endif // _LP64
2384 } else if (opr2->is_constant()) { 2618 } else if (opr2->is_constant()) {
2385 // cpu register - constant 0 2619 // cpu register - constant 0
2386 assert(opr2->as_jlong() == (jlong)0, "only handles zero"); 2620 assert(opr2->as_jlong() == (jlong)0, "only handles zero");
2621 #ifdef _LP64
2622 __ cmpptr(xlo, (int32_t)opr2->as_jlong());
2623 #else
2387 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles equals case"); 2624 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles equals case");
2388 __ orl(xhi, xlo); 2625 __ orl(xhi, xlo);
2626 #endif // _LP64
2389 } else { 2627 } else {
2390 ShouldNotReachHere(); 2628 ShouldNotReachHere();
2391 } 2629 }
2392 2630
2393 } else if (opr1->is_single_xmm()) { 2631 } else if (opr1->is_single_xmm()) {
2436 assert(opr1->is_fpu_register() && opr1->fpu() == 0, "currently left-hand side must be on TOS (relax this restriction)"); 2674 assert(opr1->is_fpu_register() && opr1->fpu() == 0, "currently left-hand side must be on TOS (relax this restriction)");
2437 assert(opr2->is_fpu_register(), "both must be registers"); 2675 assert(opr2->is_fpu_register(), "both must be registers");
2438 __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1); 2676 __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
2439 2677
2440 } else if (opr1->is_address() && opr2->is_constant()) { 2678 } else if (opr1->is_address() && opr2->is_constant()) {
2679 LIR_Const* c = opr2->as_constant_ptr();
2680 #ifdef _LP64
2681 if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
2682 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "need to reverse");
2683 __ movoop(rscratch1, c->as_jobject());
2684 }
2685 #endif // LP64
2441 if (op->info() != NULL) { 2686 if (op->info() != NULL) {
2442 add_debug_info_for_null_check_here(op->info()); 2687 add_debug_info_for_null_check_here(op->info());
2443 } 2688 }
2444 // special case: address - constant 2689 // special case: address - constant
2445 LIR_Address* addr = opr1->as_address_ptr(); 2690 LIR_Address* addr = opr1->as_address_ptr();
2446 LIR_Const* c = opr2->as_constant_ptr();
2447 if (c->type() == T_INT) { 2691 if (c->type() == T_INT) {
2448 __ cmpl(as_Address(addr), c->as_jint()); 2692 __ cmpl(as_Address(addr), c->as_jint());
2449 } else if (c->type() == T_OBJECT) { 2693 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
2694 #ifdef _LP64
2695 // %%% Make this explode if addr isn't reachable until we figure out a
2696 // better strategy by giving noreg as the temp for as_Address
2697 __ cmpptr(rscratch1, as_Address(addr, noreg));
2698 #else
2450 __ cmpoop(as_Address(addr), c->as_jobject()); 2699 __ cmpoop(as_Address(addr), c->as_jobject());
2700 #endif // _LP64
2451 } else { 2701 } else {
2452 ShouldNotReachHere(); 2702 ShouldNotReachHere();
2453 } 2703 }
2454 2704
2455 } else { 2705 } else {
2474 __ fcmp2int(dst->as_register(), code == lir_ucmp_fd2i, right->fpu(), 2724 __ fcmp2int(dst->as_register(), code == lir_ucmp_fd2i, right->fpu(),
2475 op->fpu_pop_count() > 0, op->fpu_pop_count() > 1); 2725 op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
2476 } 2726 }
2477 } else { 2727 } else {
2478 assert(code == lir_cmp_l2i, "check"); 2728 assert(code == lir_cmp_l2i, "check");
2729 #ifdef _LP64
2730 Register dest = dst->as_register();
2731 __ xorptr(dest, dest);
2732 Label high, done;
2733 __ cmpptr(left->as_register_lo(), right->as_register_lo());
2734 __ jcc(Assembler::equal, done);
2735 __ jcc(Assembler::greater, high);
2736 __ decrement(dest);
2737 __ jmp(done);
2738 __ bind(high);
2739 __ increment(dest);
2740
2741 __ bind(done);
2742
2743 #else
2479 __ lcmp2int(left->as_register_hi(), 2744 __ lcmp2int(left->as_register_hi(),
2480 left->as_register_lo(), 2745 left->as_register_lo(),
2481 right->as_register_hi(), 2746 right->as_register_hi(),
2482 right->as_register_lo()); 2747 right->as_register_lo());
2483 move_regs(left->as_register_hi(), dst->as_register()); 2748 move_regs(left->as_register_hi(), dst->as_register());
2749 #endif // _LP64
2484 } 2750 }
2485 } 2751 }
2486 2752
2487 2753
2488 void LIR_Assembler::align_call(LIR_Code code) { 2754 void LIR_Assembler::align_call(LIR_Code code) {
2549 } 2815 }
2550 __ relocate(static_stub_Relocation::spec(call_pc)); 2816 __ relocate(static_stub_Relocation::spec(call_pc));
2551 __ movoop(rbx, (jobject)NULL); 2817 __ movoop(rbx, (jobject)NULL);
2552 // must be set to -1 at code generation time 2818 // must be set to -1 at code generation time
2553 assert(!os::is_MP() || ((__ offset() + 1) % BytesPerWord) == 0, "must be aligned on MP"); 2819 assert(!os::is_MP() || ((__ offset() + 1) % BytesPerWord) == 0, "must be aligned on MP");
2554 __ jump(RuntimeAddress((address)-1)); 2820 // On 64bit this will die since it will take a movq & jmp, must be only a jmp
2821 __ jump(RuntimeAddress(__ pc()));
2555 2822
2556 assert(__ offset() - start <= call_stub_size, "stub too big") 2823 assert(__ offset() - start <= call_stub_size, "stub too big")
2557 __ end_a_stub(); 2824 __ end_a_stub();
2558 } 2825 }
2559 2826
2614 } 2881 }
2615 } else if (left->is_double_cpu()) { 2882 } else if (left->is_double_cpu()) {
2616 Register lo = left->as_register_lo(); 2883 Register lo = left->as_register_lo();
2617 Register hi = left->as_register_hi(); 2884 Register hi = left->as_register_hi();
2618 assert(lo != SHIFT_count && hi != SHIFT_count, "left cannot be ECX"); 2885 assert(lo != SHIFT_count && hi != SHIFT_count, "left cannot be ECX");
2886 #ifdef _LP64
2887 switch (code) {
2888 case lir_shl: __ shlptr(lo); break;
2889 case lir_shr: __ sarptr(lo); break;
2890 case lir_ushr: __ shrptr(lo); break;
2891 default: ShouldNotReachHere();
2892 }
2893 #else
2619 2894
2620 switch (code) { 2895 switch (code) {
2621 case lir_shl: __ lshl(hi, lo); break; 2896 case lir_shl: __ lshl(hi, lo); break;
2622 case lir_shr: __ lshr(hi, lo, true); break; 2897 case lir_shr: __ lshr(hi, lo, true); break;
2623 case lir_ushr: __ lshr(hi, lo, false); break; 2898 case lir_ushr: __ lshr(hi, lo, false); break;
2624 default: ShouldNotReachHere(); 2899 default: ShouldNotReachHere();
2625 } 2900 }
2901 #endif // LP64
2626 } else { 2902 } else {
2627 ShouldNotReachHere(); 2903 ShouldNotReachHere();
2628 } 2904 }
2629 } 2905 }
2630 2906
2641 case lir_shr: __ sarl(value, count); break; 2917 case lir_shr: __ sarl(value, count); break;
2642 case lir_ushr: __ shrl(value, count); break; 2918 case lir_ushr: __ shrl(value, count); break;
2643 default: ShouldNotReachHere(); 2919 default: ShouldNotReachHere();
2644 } 2920 }
2645 } else if (dest->is_double_cpu()) { 2921 } else if (dest->is_double_cpu()) {
2922 #ifndef _LP64
2646 Unimplemented(); 2923 Unimplemented();
2924 #else
2925 // first move left into dest so that left is not destroyed by the shift
2926 Register value = dest->as_register_lo();
2927 count = count & 0x1F; // Java spec
2928
2929 move_regs(left->as_register_lo(), value);
2930 switch (code) {
2931 case lir_shl: __ shlptr(value, count); break;
2932 case lir_shr: __ sarptr(value, count); break;
2933 case lir_ushr: __ shrptr(value, count); break;
2934 default: ShouldNotReachHere();
2935 }
2936 #endif // _LP64
2647 } else { 2937 } else {
2648 ShouldNotReachHere(); 2938 ShouldNotReachHere();
2649 } 2939 }
2650 } 2940 }
2651 2941
2652 2942
2653 void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) { 2943 void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
2654 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp"); 2944 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
2655 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord; 2945 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
2656 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset"); 2946 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
2657 __ movl (Address(rsp, offset_from_rsp_in_bytes), r); 2947 __ movptr (Address(rsp, offset_from_rsp_in_bytes), r);
2658 } 2948 }
2659 2949
2660 2950
2661 void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) { 2951 void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
2662 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp"); 2952 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
2663 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord; 2953 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
2664 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset"); 2954 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
2665 __ movl (Address(rsp, offset_from_rsp_in_bytes), c); 2955 __ movptr (Address(rsp, offset_from_rsp_in_bytes), c);
2666 } 2956 }
2667 2957
2668 2958
2669 void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) { 2959 void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) {
2670 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp"); 2960 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
2708 store_parameter(dst, 0); 2998 store_parameter(dst, 0);
2709 2999
2710 // these are just temporary placements until we need to reload 3000 // these are just temporary placements until we need to reload
2711 store_parameter(src_pos, 3); 3001 store_parameter(src_pos, 3);
2712 store_parameter(src, 4); 3002 store_parameter(src, 4);
2713 assert(src == rcx && src_pos == rdx, "mismatch in calling convention"); 3003 NOT_LP64(assert(src == rcx && src_pos == rdx, "mismatch in calling convention");)
3004
3005 address entry = CAST_FROM_FN_PTR(address, Runtime1::arraycopy);
2714 3006
2715 // pass arguments: may push as this is not a safepoint; SP must be fix at each safepoint 3007 // pass arguments: may push as this is not a safepoint; SP must be fix at each safepoint
2716 __ pushl(length); 3008 #ifdef _LP64
2717 __ pushl(dst_pos); 3009 // The arguments are in java calling convention so we can trivially shift them to C
2718 __ pushl(dst); 3010 // convention
2719 __ pushl(src_pos); 3011 assert_different_registers(c_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4);
2720 __ pushl(src); 3012 __ mov(c_rarg0, j_rarg0);
2721 address entry = CAST_FROM_FN_PTR(address, Runtime1::arraycopy); 3013 assert_different_registers(c_rarg1, j_rarg2, j_rarg3, j_rarg4);
3014 __ mov(c_rarg1, j_rarg1);
3015 assert_different_registers(c_rarg2, j_rarg3, j_rarg4);
3016 __ mov(c_rarg2, j_rarg2);
3017 assert_different_registers(c_rarg3, j_rarg4);
3018 __ mov(c_rarg3, j_rarg3);
3019 #ifdef _WIN64
3020 // Allocate abi space for args but be sure to keep stack aligned
3021 __ subptr(rsp, 6*wordSize);
3022 store_parameter(j_rarg4, 4);
3023 __ call(RuntimeAddress(entry));
3024 __ addptr(rsp, 6*wordSize);
3025 #else
3026 __ mov(c_rarg4, j_rarg4);
3027 __ call(RuntimeAddress(entry));
3028 #endif // _WIN64
3029 #else
3030 __ push(length);
3031 __ push(dst_pos);
3032 __ push(dst);
3033 __ push(src_pos);
3034 __ push(src);
2722 __ call_VM_leaf(entry, 5); // removes pushed parameter from the stack 3035 __ call_VM_leaf(entry, 5); // removes pushed parameter from the stack
3036
3037 #endif // _LP64
2723 3038
2724 __ cmpl(rax, 0); 3039 __ cmpl(rax, 0);
2725 __ jcc(Assembler::equal, *stub->continuation()); 3040 __ jcc(Assembler::equal, *stub->continuation());
2726 3041
2727 // Reload values from the stack so they are where the stub 3042 // Reload values from the stack so they are where the stub
2728 // expects them. 3043 // expects them.
2729 __ movl (dst, Address(rsp, 0*BytesPerWord)); 3044 __ movptr (dst, Address(rsp, 0*BytesPerWord));
2730 __ movl (dst_pos, Address(rsp, 1*BytesPerWord)); 3045 __ movptr (dst_pos, Address(rsp, 1*BytesPerWord));
2731 __ movl (length, Address(rsp, 2*BytesPerWord)); 3046 __ movptr (length, Address(rsp, 2*BytesPerWord));
2732 __ movl (src_pos, Address(rsp, 3*BytesPerWord)); 3047 __ movptr (src_pos, Address(rsp, 3*BytesPerWord));
2733 __ movl (src, Address(rsp, 4*BytesPerWord)); 3048 __ movptr (src, Address(rsp, 4*BytesPerWord));
2734 __ jmp(*stub->entry()); 3049 __ jmp(*stub->entry());
2735 3050
2736 __ bind(*stub->continuation()); 3051 __ bind(*stub->continuation());
2737 return; 3052 return;
2738 } 3053 }
2767 Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes()); 3082 Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
2768 Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes()); 3083 Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());
2769 Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes()); 3084 Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
2770 Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes()); 3085 Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
2771 3086
3087 // length and pos's are all sign extended at this point on 64bit
3088
2772 // test for NULL 3089 // test for NULL
2773 if (flags & LIR_OpArrayCopy::src_null_check) { 3090 if (flags & LIR_OpArrayCopy::src_null_check) {
2774 __ testl(src, src); 3091 __ testptr(src, src);
2775 __ jcc(Assembler::zero, *stub->entry()); 3092 __ jcc(Assembler::zero, *stub->entry());
2776 } 3093 }
2777 if (flags & LIR_OpArrayCopy::dst_null_check) { 3094 if (flags & LIR_OpArrayCopy::dst_null_check) {
2778 __ testl(dst, dst); 3095 __ testptr(dst, dst);
2779 __ jcc(Assembler::zero, *stub->entry()); 3096 __ jcc(Assembler::zero, *stub->entry());
2780 } 3097 }
2781 3098
2782 // check if negative 3099 // check if negative
2783 if (flags & LIR_OpArrayCopy::src_pos_positive_check) { 3100 if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
2792 __ testl(length, length); 3109 __ testl(length, length);
2793 __ jcc(Assembler::less, *stub->entry()); 3110 __ jcc(Assembler::less, *stub->entry());
2794 } 3111 }
2795 3112
2796 if (flags & LIR_OpArrayCopy::src_range_check) { 3113 if (flags & LIR_OpArrayCopy::src_range_check) {
2797 __ leal(tmp, Address(src_pos, length, Address::times_1, 0)); 3114 __ lea(tmp, Address(src_pos, length, Address::times_1, 0));
2798 __ cmpl(tmp, src_length_addr); 3115 __ cmpl(tmp, src_length_addr);
2799 __ jcc(Assembler::above, *stub->entry()); 3116 __ jcc(Assembler::above, *stub->entry());
2800 } 3117 }
2801 if (flags & LIR_OpArrayCopy::dst_range_check) { 3118 if (flags & LIR_OpArrayCopy::dst_range_check) {
2802 __ leal(tmp, Address(dst_pos, length, Address::times_1, 0)); 3119 __ lea(tmp, Address(dst_pos, length, Address::times_1, 0));
2803 __ cmpl(tmp, dst_length_addr); 3120 __ cmpl(tmp, dst_length_addr);
2804 __ jcc(Assembler::above, *stub->entry()); 3121 __ jcc(Assembler::above, *stub->entry());
2805 } 3122 }
2806 3123
2807 if (flags & LIR_OpArrayCopy::type_check) { 3124 if (flags & LIR_OpArrayCopy::type_check) {
2808 __ movl(tmp, src_klass_addr); 3125 __ movptr(tmp, src_klass_addr);
2809 __ cmpl(tmp, dst_klass_addr); 3126 __ cmpptr(tmp, dst_klass_addr);
2810 __ jcc(Assembler::notEqual, *stub->entry()); 3127 __ jcc(Assembler::notEqual, *stub->entry());
2811 } 3128 }
2812 3129
2813 #ifdef ASSERT 3130 #ifdef ASSERT
2814 if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) { 3131 if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
2820 // subtype which we can't check or src is the same array as dst 3137 // subtype which we can't check or src is the same array as dst
2821 // but not necessarily exactly of type default_type. 3138 // but not necessarily exactly of type default_type.
2822 Label known_ok, halt; 3139 Label known_ok, halt;
2823 __ movoop(tmp, default_type->encoding()); 3140 __ movoop(tmp, default_type->encoding());
2824 if (basic_type != T_OBJECT) { 3141 if (basic_type != T_OBJECT) {
2825 __ cmpl(tmp, dst_klass_addr); 3142 __ cmpptr(tmp, dst_klass_addr);
2826 __ jcc(Assembler::notEqual, halt); 3143 __ jcc(Assembler::notEqual, halt);
2827 __ cmpl(tmp, src_klass_addr); 3144 __ cmpptr(tmp, src_klass_addr);
2828 __ jcc(Assembler::equal, known_ok); 3145 __ jcc(Assembler::equal, known_ok);
2829 } else { 3146 } else {
2830 __ cmpl(tmp, dst_klass_addr); 3147 __ cmpptr(tmp, dst_klass_addr);
2831 __ jcc(Assembler::equal, known_ok); 3148 __ jcc(Assembler::equal, known_ok);
2832 __ cmpl(src, dst); 3149 __ cmpptr(src, dst);
2833 __ jcc(Assembler::equal, known_ok); 3150 __ jcc(Assembler::equal, known_ok);
2834 } 3151 }
2835 __ bind(halt); 3152 __ bind(halt);
2836 __ stop("incorrect type information in arraycopy"); 3153 __ stop("incorrect type information in arraycopy");
2837 __ bind(known_ok); 3154 __ bind(known_ok);
2838 } 3155 }
2839 #endif 3156 #endif
2840 3157
2841 __ leal(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type))); 3158 if (shift_amount > 0 && basic_type != T_OBJECT) {
3159 __ shlptr(length, shift_amount);
3160 }
3161
3162 #ifdef _LP64
3163 assert_different_registers(c_rarg0, dst, dst_pos, length);
3164 __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
3165 assert_different_registers(c_rarg1, length);
3166 __ lea(c_rarg1, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
3167 __ mov(c_rarg2, length);
3168
3169 #else
3170 __ lea(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
2842 store_parameter(tmp, 0); 3171 store_parameter(tmp, 0);
2843 __ leal(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type))); 3172 __ lea(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
2844 store_parameter(tmp, 1); 3173 store_parameter(tmp, 1);
2845 if (shift_amount > 0 && basic_type != T_OBJECT) {
2846 __ shll(length, shift_amount);
2847 }
2848 store_parameter(length, 2); 3174 store_parameter(length, 2);
3175 #endif // _LP64
2849 if (basic_type == T_OBJECT) { 3176 if (basic_type == T_OBJECT) {
2850 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Runtime1::oop_arraycopy), 0); 3177 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Runtime1::oop_arraycopy), 0);
2851 } else { 3178 } else {
2852 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Runtime1::primitive_arraycopy), 0); 3179 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Runtime1::primitive_arraycopy), 0);
2853 } 3180 }
2943 __ addl(data_addr, DataLayout::counter_increment); 3270 __ addl(data_addr, DataLayout::counter_increment);
2944 return; 3271 return;
2945 } 3272 }
2946 } 3273 }
2947 } else { 3274 } else {
2948 __ movl(recv, Address(recv, oopDesc::klass_offset_in_bytes())); 3275 __ movptr(recv, Address(recv, oopDesc::klass_offset_in_bytes()));
2949 Label update_done; 3276 Label update_done;
2950 uint i; 3277 uint i;
2951 for (i = 0; i < VirtualCallData::row_limit(); i++) { 3278 for (i = 0; i < VirtualCallData::row_limit(); i++) {
2952 Label next_test; 3279 Label next_test;
2953 // See if the receiver is receiver[n]. 3280 // See if the receiver is receiver[n].
2954 __ cmpl(recv, Address(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)))); 3281 __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i))));
2955 __ jcc(Assembler::notEqual, next_test); 3282 __ jcc(Assembler::notEqual, next_test);
2956 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))); 3283 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
2957 __ addl(data_addr, DataLayout::counter_increment); 3284 __ addl(data_addr, DataLayout::counter_increment);
2958 __ jmp(update_done); 3285 __ jmp(update_done);
2959 __ bind(next_test); 3286 __ bind(next_test);
2961 3288
2962 // Didn't find receiver; find next empty slot and fill it in 3289 // Didn't find receiver; find next empty slot and fill it in
2963 for (i = 0; i < VirtualCallData::row_limit(); i++) { 3290 for (i = 0; i < VirtualCallData::row_limit(); i++) {
2964 Label next_test; 3291 Label next_test;
2965 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i))); 3292 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
2966 __ cmpl(recv_addr, NULL_WORD); 3293 __ cmpptr(recv_addr, (int32_t)NULL_WORD);
2967 __ jcc(Assembler::notEqual, next_test); 3294 __ jcc(Assembler::notEqual, next_test);
2968 __ movl(recv_addr, recv); 3295 __ movptr(recv_addr, recv);
2969 __ movl(Address(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))), DataLayout::counter_increment); 3296 __ movl(Address(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))), DataLayout::counter_increment);
2970 if (i < (VirtualCallData::row_limit() - 1)) { 3297 if (i < (VirtualCallData::row_limit() - 1)) {
2971 __ jmp(update_done); 3298 __ jmp(update_done);
2972 } 3299 }
2973 __ bind(next_test); 3300 __ bind(next_test);
2983 Unimplemented(); 3310 Unimplemented();
2984 } 3311 }
2985 3312
2986 3313
2987 void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) { 3314 void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
2988 __ leal(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no)); 3315 __ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
2989 } 3316 }
2990 3317
2991 3318
2992 void LIR_Assembler::align_backward_branch_target() { 3319 void LIR_Assembler::align_backward_branch_target() {
2993 __ align(BytesPerWord); 3320 __ align(BytesPerWord);
2999 __ negl(left->as_register()); 3326 __ negl(left->as_register());
3000 move_regs(left->as_register(), dest->as_register()); 3327 move_regs(left->as_register(), dest->as_register());
3001 3328
3002 } else if (left->is_double_cpu()) { 3329 } else if (left->is_double_cpu()) {
3003 Register lo = left->as_register_lo(); 3330 Register lo = left->as_register_lo();
3331 #ifdef _LP64
3332 Register dst = dest->as_register_lo();
3333 __ movptr(dst, lo);
3334 __ negptr(dst);
3335 #else
3004 Register hi = left->as_register_hi(); 3336 Register hi = left->as_register_hi();
3005 __ lneg(hi, lo); 3337 __ lneg(hi, lo);
3006 if (dest->as_register_lo() == hi) { 3338 if (dest->as_register_lo() == hi) {
3007 assert(dest->as_register_hi() != lo, "destroying register"); 3339 assert(dest->as_register_hi() != lo, "destroying register");
3008 move_regs(hi, dest->as_register_hi()); 3340 move_regs(hi, dest->as_register_hi());
3009 move_regs(lo, dest->as_register_lo()); 3341 move_regs(lo, dest->as_register_lo());
3010 } else { 3342 } else {
3011 move_regs(lo, dest->as_register_lo()); 3343 move_regs(lo, dest->as_register_lo());
3012 move_regs(hi, dest->as_register_hi()); 3344 move_regs(hi, dest->as_register_hi());
3013 } 3345 }
3346 #endif // _LP64
3014 3347
3015 } else if (dest->is_single_xmm()) { 3348 } else if (dest->is_single_xmm()) {
3016 if (left->as_xmm_float_reg() != dest->as_xmm_float_reg()) { 3349 if (left->as_xmm_float_reg() != dest->as_xmm_float_reg()) {
3017 __ movflt(dest->as_xmm_float_reg(), left->as_xmm_float_reg()); 3350 __ movflt(dest->as_xmm_float_reg(), left->as_xmm_float_reg());
3018 } 3351 }
3037 } 3370 }
3038 3371
3039 3372
3040 void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest) { 3373 void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest) {
3041 assert(addr->is_address() && dest->is_register(), "check"); 3374 assert(addr->is_address() && dest->is_register(), "check");
3042 Register reg = dest->as_register(); 3375 Register reg;
3043 __ leal(dest->as_register(), as_Address(addr->as_address_ptr())); 3376 reg = dest->as_pointer_register();
3377 __ lea(reg, as_Address(addr->as_address_ptr()));
3044 } 3378 }
3045 3379
3046 3380
3047 3381
3048 void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) { 3382 void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) {
3061 add_debug_info_for_null_check_here(info); 3395 add_debug_info_for_null_check_here(info);
3062 } 3396 }
3063 3397
3064 if (src->is_double_xmm()) { 3398 if (src->is_double_xmm()) {
3065 if (dest->is_double_cpu()) { 3399 if (dest->is_double_cpu()) {
3066 __ movd(dest->as_register_lo(), src->as_xmm_double_reg()); 3400 #ifdef _LP64
3401 __ movdq(dest->as_register_lo(), src->as_xmm_double_reg());
3402 #else
3403 __ movdl(dest->as_register_lo(), src->as_xmm_double_reg());
3067 __ psrlq(src->as_xmm_double_reg(), 32); 3404 __ psrlq(src->as_xmm_double_reg(), 32);
3068 __ movd(dest->as_register_hi(), src->as_xmm_double_reg()); 3405 __ movdl(dest->as_register_hi(), src->as_xmm_double_reg());
3406 #endif // _LP64
3069 } else if (dest->is_double_stack()) { 3407 } else if (dest->is_double_stack()) {
3070 __ movdbl(frame_map()->address_for_slot(dest->double_stack_ix()), src->as_xmm_double_reg()); 3408 __ movdbl(frame_map()->address_for_slot(dest->double_stack_ix()), src->as_xmm_double_reg());
3071 } else if (dest->is_address()) { 3409 } else if (dest->is_address()) {
3072 __ movdbl(as_Address(dest->as_address_ptr()), src->as_xmm_double_reg()); 3410 __ movdbl(as_Address(dest->as_address_ptr()), src->as_xmm_double_reg());
3073 } else { 3411 } else {
3107 } 3445 }
3108 } 3446 }
3109 3447
3110 3448
3111 void LIR_Assembler::membar() { 3449 void LIR_Assembler::membar() {
3112 __ membar(); 3450 // QQQ sparc TSO uses this,
3451 __ membar( Assembler::Membar_mask_bits(Assembler::StoreLoad));
3113 } 3452 }
3114 3453
3115 void LIR_Assembler::membar_acquire() { 3454 void LIR_Assembler::membar_acquire() {
3116 // No x86 machines currently require load fences 3455 // No x86 machines currently require load fences
3117 // __ load_fence(); 3456 // __ load_fence();
3122 // __ store_fence(); 3461 // __ store_fence();
3123 } 3462 }
3124 3463
3125 void LIR_Assembler::get_thread(LIR_Opr result_reg) { 3464 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
3126 assert(result_reg->is_register(), "check"); 3465 assert(result_reg->is_register(), "check");
3466 #ifdef _LP64
3467 // __ get_thread(result_reg->as_register_lo());
3468 __ mov(result_reg->as_register(), r15_thread);
3469 #else
3127 __ get_thread(result_reg->as_register()); 3470 __ get_thread(result_reg->as_register());
3471 #endif // _LP64
3128 } 3472 }
3129 3473
3130 3474
3131 void LIR_Assembler::peephole(LIR_List*) { 3475 void LIR_Assembler::peephole(LIR_List*) {
3132 // do nothing for now 3476 // do nothing for now