comparison src/cpu/x86/vm/assembler_x86.cpp @ 6266:1d7922586cf6

7023639: JSR 292 method handle invocation needs a fast path for compiled code 6984705: JSR 292 method handle creation should not go through JNI Summary: remove assembly code for JDK 7 chained method handles Reviewed-by: jrose, twisti, kvn, mhaupt Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
author twisti
date Tue, 24 Jul 2012 10:51:00 -0700
parents 2c368ea3e844
children 957c266d8bc5 006050192a5a
comparison
equal deleted inserted replaced
6241:aba91a731143 6266:1d7922586cf6
39 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 39 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
40 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" 40 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
41 #include "gc_implementation/g1/heapRegion.hpp" 41 #include "gc_implementation/g1/heapRegion.hpp"
42 #endif 42 #endif
43 43
44 #ifdef PRODUCT
45 #define BLOCK_COMMENT(str) /* nothing */
46 #define STOP(error) stop(error)
47 #else
48 #define BLOCK_COMMENT(str) block_comment(str)
49 #define STOP(error) block_comment(error); stop(error)
50 #endif
51
52 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
44 // Implementation of AddressLiteral 53 // Implementation of AddressLiteral
45 54
46 AddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) { 55 AddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) {
47 _is_lval = false; 56 _is_lval = false;
48 _target = target; 57 _target = target;
5506 BytecodeCounter::print(); 5515 BytecodeCounter::print();
5507 } 5516 }
5508 // To see where a verify_oop failed, get $ebx+40/X for this frame. 5517 // To see where a verify_oop failed, get $ebx+40/X for this frame.
5509 // This is the value of eip which points to where verify_oop will return. 5518 // This is the value of eip which points to where verify_oop will return.
5510 if (os::message_box(msg, "Execution stopped, print registers?")) { 5519 if (os::message_box(msg, "Execution stopped, print registers?")) {
5511 ttyLocker ttyl; 5520 print_state32(rdi, rsi, rbp, rsp, rbx, rdx, rcx, rax, eip);
5512 tty->print_cr("eip = 0x%08x", eip);
5513 #ifndef PRODUCT
5514 if ((WizardMode || Verbose) && PrintMiscellaneous) {
5515 tty->cr();
5516 findpc(eip);
5517 tty->cr();
5518 }
5519 #endif
5520 tty->print_cr("rax = 0x%08x", rax);
5521 tty->print_cr("rbx = 0x%08x", rbx);
5522 tty->print_cr("rcx = 0x%08x", rcx);
5523 tty->print_cr("rdx = 0x%08x", rdx);
5524 tty->print_cr("rdi = 0x%08x", rdi);
5525 tty->print_cr("rsi = 0x%08x", rsi);
5526 tty->print_cr("rbp = 0x%08x", rbp);
5527 tty->print_cr("rsp = 0x%08x", rsp);
5528 BREAKPOINT; 5521 BREAKPOINT;
5529 assert(false, "start up GDB"); 5522 assert(false, "start up GDB");
5530 } 5523 }
5531 } else { 5524 } else {
5532 ttyLocker ttyl; 5525 ttyLocker ttyl;
5533 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg); 5526 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
5534 assert(false, err_msg("DEBUG MESSAGE: %s", msg)); 5527 assert(false, err_msg("DEBUG MESSAGE: %s", msg));
5535 } 5528 }
5536 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state); 5529 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
5530 }
5531
5532 void MacroAssembler::print_state32(int rdi, int rsi, int rbp, int rsp, int rbx, int rdx, int rcx, int rax, int eip) {
5533 ttyLocker ttyl;
5534 FlagSetting fs(Debugging, true);
5535 tty->print_cr("eip = 0x%08x", eip);
5536 #ifndef PRODUCT
5537 if ((WizardMode || Verbose) && PrintMiscellaneous) {
5538 tty->cr();
5539 findpc(eip);
5540 tty->cr();
5541 }
5542 #endif
5543 #define PRINT_REG(rax) \
5544 { tty->print("%s = ", #rax); os::print_location(tty, rax); }
5545 PRINT_REG(rax);
5546 PRINT_REG(rbx);
5547 PRINT_REG(rcx);
5548 PRINT_REG(rdx);
5549 PRINT_REG(rdi);
5550 PRINT_REG(rsi);
5551 PRINT_REG(rbp);
5552 PRINT_REG(rsp);
5553 #undef PRINT_REG
5554 // Print some words near top of staack.
5555 int* dump_sp = (int*) rsp;
5556 for (int col1 = 0; col1 < 8; col1++) {
5557 tty->print("(rsp+0x%03x) 0x%08x: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (intptr_t)dump_sp);
5558 os::print_location(tty, *dump_sp++);
5559 }
5560 for (int row = 0; row < 16; row++) {
5561 tty->print("(rsp+0x%03x) 0x%08x: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (intptr_t)dump_sp);
5562 for (int col = 0; col < 8; col++) {
5563 tty->print(" 0x%08x", *dump_sp++);
5564 }
5565 tty->cr();
5566 }
5567 // Print some instructions around pc:
5568 Disassembler::decode((address)eip-64, (address)eip);
5569 tty->print_cr("--------");
5570 Disassembler::decode((address)eip, (address)eip+32);
5537 } 5571 }
5538 5572
5539 void MacroAssembler::stop(const char* msg) { 5573 void MacroAssembler::stop(const char* msg) {
5540 ExternalAddress message((address)msg); 5574 ExternalAddress message((address)msg);
5541 // push address of message 5575 // push address of message
5542 pushptr(message.addr()); 5576 pushptr(message.addr());
5543 { Label L; call(L, relocInfo::none); bind(L); } // push eip 5577 { Label L; call(L, relocInfo::none); bind(L); } // push eip
5544 pusha(); // push registers 5578 pusha(); // push registers
5545 call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug32))); 5579 call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug32)));
5546 hlt(); 5580 hlt();
5547 } 5581 }
5548 5582
5549 void MacroAssembler::warn(const char* msg) { 5583 void MacroAssembler::warn(const char* msg) {
5554 pushptr(message.addr()); 5588 pushptr(message.addr());
5555 5589
5556 call(RuntimeAddress(CAST_FROM_FN_PTR(address, warning))); 5590 call(RuntimeAddress(CAST_FROM_FN_PTR(address, warning)));
5557 addl(rsp, wordSize); // discard argument 5591 addl(rsp, wordSize); // discard argument
5558 pop_CPU_state(); 5592 pop_CPU_state();
5593 }
5594
5595 void MacroAssembler::print_state() {
5596 { Label L; call(L, relocInfo::none); bind(L); } // push eip
5597 pusha(); // push registers
5598
5599 push_CPU_state();
5600 call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::print_state32)));
5601 pop_CPU_state();
5602
5603 popa();
5604 addl(rsp, wordSize);
5559 } 5605 }
5560 5606
5561 #else // _LP64 5607 #else // _LP64
5562 5608
5563 // 64 bit versions 5609 // 64 bit versions
6021 call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug64))); 6067 call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug64)));
6022 hlt(); 6068 hlt();
6023 } 6069 }
6024 6070
6025 void MacroAssembler::warn(const char* msg) { 6071 void MacroAssembler::warn(const char* msg) {
6026 push(rsp); 6072 push(rbp);
6073 movq(rbp, rsp);
6027 andq(rsp, -16); // align stack as required by push_CPU_state and call 6074 andq(rsp, -16); // align stack as required by push_CPU_state and call
6028
6029 push_CPU_state(); // keeps alignment at 16 bytes 6075 push_CPU_state(); // keeps alignment at 16 bytes
6030 lea(c_rarg0, ExternalAddress((address) msg)); 6076 lea(c_rarg0, ExternalAddress((address) msg));
6031 call_VM_leaf(CAST_FROM_FN_PTR(address, warning), c_rarg0); 6077 call_VM_leaf(CAST_FROM_FN_PTR(address, warning), c_rarg0);
6032 pop_CPU_state(); 6078 pop_CPU_state();
6033 pop(rsp); 6079 mov(rsp, rbp);
6080 pop(rbp);
6081 }
6082
6083 void MacroAssembler::print_state() {
6084 address rip = pc();
6085 pusha(); // get regs on stack
6086 push(rbp);
6087 movq(rbp, rsp);
6088 andq(rsp, -16); // align stack as required by push_CPU_state and call
6089 push_CPU_state(); // keeps alignment at 16 bytes
6090
6091 lea(c_rarg0, InternalAddress(rip));
6092 lea(c_rarg1, Address(rbp, wordSize)); // pass pointer to regs array
6093 call_VM_leaf(CAST_FROM_FN_PTR(address, MacroAssembler::print_state64), c_rarg0, c_rarg1);
6094
6095 pop_CPU_state();
6096 mov(rsp, rbp);
6097 pop(rbp);
6098 popa();
6034 } 6099 }
6035 6100
6036 #ifndef PRODUCT 6101 #ifndef PRODUCT
6037 extern "C" void findpc(intptr_t x); 6102 extern "C" void findpc(intptr_t x);
6038 #endif 6103 #endif
6039 6104
6040 void MacroAssembler::debug64(char* msg, int64_t pc, int64_t regs[]) { 6105 void MacroAssembler::debug64(char* msg, int64_t pc, int64_t regs[]) {
6041 // In order to get locks to work, we need to fake a in_VM state 6106 // In order to get locks to work, we need to fake a in_VM state
6042 if (ShowMessageBoxOnError ) { 6107 if (ShowMessageBoxOnError) {
6043 JavaThread* thread = JavaThread::current(); 6108 JavaThread* thread = JavaThread::current();
6044 JavaThreadState saved_state = thread->thread_state(); 6109 JavaThreadState saved_state = thread->thread_state();
6045 thread->set_thread_state(_thread_in_vm); 6110 thread->set_thread_state(_thread_in_vm);
6046 #ifndef PRODUCT 6111 #ifndef PRODUCT
6047 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) { 6112 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
6051 #endif 6116 #endif
6052 // To see where a verify_oop failed, get $ebx+40/X for this frame. 6117 // To see where a verify_oop failed, get $ebx+40/X for this frame.
6053 // XXX correct this offset for amd64 6118 // XXX correct this offset for amd64
6054 // This is the value of eip which points to where verify_oop will return. 6119 // This is the value of eip which points to where verify_oop will return.
6055 if (os::message_box(msg, "Execution stopped, print registers?")) { 6120 if (os::message_box(msg, "Execution stopped, print registers?")) {
6056 ttyLocker ttyl; 6121 print_state64(pc, regs);
6057 tty->print_cr("rip = 0x%016lx", pc);
6058 #ifndef PRODUCT
6059 tty->cr();
6060 findpc(pc);
6061 tty->cr();
6062 #endif
6063 tty->print_cr("rax = 0x%016lx", regs[15]);
6064 tty->print_cr("rbx = 0x%016lx", regs[12]);
6065 tty->print_cr("rcx = 0x%016lx", regs[14]);
6066 tty->print_cr("rdx = 0x%016lx", regs[13]);
6067 tty->print_cr("rdi = 0x%016lx", regs[8]);
6068 tty->print_cr("rsi = 0x%016lx", regs[9]);
6069 tty->print_cr("rbp = 0x%016lx", regs[10]);
6070 tty->print_cr("rsp = 0x%016lx", regs[11]);
6071 tty->print_cr("r8 = 0x%016lx", regs[7]);
6072 tty->print_cr("r9 = 0x%016lx", regs[6]);
6073 tty->print_cr("r10 = 0x%016lx", regs[5]);
6074 tty->print_cr("r11 = 0x%016lx", regs[4]);
6075 tty->print_cr("r12 = 0x%016lx", regs[3]);
6076 tty->print_cr("r13 = 0x%016lx", regs[2]);
6077 tty->print_cr("r14 = 0x%016lx", regs[1]);
6078 tty->print_cr("r15 = 0x%016lx", regs[0]);
6079 BREAKPOINT; 6122 BREAKPOINT;
6123 assert(false, "start up GDB");
6080 } 6124 }
6081 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state); 6125 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
6082 } else { 6126 } else {
6083 ttyLocker ttyl; 6127 ttyLocker ttyl;
6084 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", 6128 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n",
6085 msg); 6129 msg);
6086 assert(false, err_msg("DEBUG MESSAGE: %s", msg)); 6130 assert(false, err_msg("DEBUG MESSAGE: %s", msg));
6087 } 6131 }
6132 }
6133
6134 void MacroAssembler::print_state64(int64_t pc, int64_t regs[]) {
6135 ttyLocker ttyl;
6136 FlagSetting fs(Debugging, true);
6137 tty->print_cr("rip = 0x%016lx", pc);
6138 #ifndef PRODUCT
6139 tty->cr();
6140 findpc(pc);
6141 tty->cr();
6142 #endif
6143 #define PRINT_REG(rax, value) \
6144 { tty->print("%s = ", #rax); os::print_location(tty, value); }
6145 PRINT_REG(rax, regs[15]);
6146 PRINT_REG(rbx, regs[12]);
6147 PRINT_REG(rcx, regs[14]);
6148 PRINT_REG(rdx, regs[13]);
6149 PRINT_REG(rdi, regs[8]);
6150 PRINT_REG(rsi, regs[9]);
6151 PRINT_REG(rbp, regs[10]);
6152 PRINT_REG(rsp, regs[11]);
6153 PRINT_REG(r8 , regs[7]);
6154 PRINT_REG(r9 , regs[6]);
6155 PRINT_REG(r10, regs[5]);
6156 PRINT_REG(r11, regs[4]);
6157 PRINT_REG(r12, regs[3]);
6158 PRINT_REG(r13, regs[2]);
6159 PRINT_REG(r14, regs[1]);
6160 PRINT_REG(r15, regs[0]);
6161 #undef PRINT_REG
6162 // Print some words near top of staack.
6163 int64_t* rsp = (int64_t*) regs[11];
6164 int64_t* dump_sp = rsp;
6165 for (int col1 = 0; col1 < 8; col1++) {
6166 tty->print("(rsp+0x%03x) 0x%016lx: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (int64_t)dump_sp);
6167 os::print_location(tty, *dump_sp++);
6168 }
6169 for (int row = 0; row < 25; row++) {
6170 tty->print("(rsp+0x%03x) 0x%016lx: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (int64_t)dump_sp);
6171 for (int col = 0; col < 4; col++) {
6172 tty->print(" 0x%016lx", *dump_sp++);
6173 }
6174 tty->cr();
6175 }
6176 // Print some instructions around pc:
6177 Disassembler::decode((address)pc-64, (address)pc);
6178 tty->print_cr("--------");
6179 Disassembler::decode((address)pc, (address)pc+32);
6088 } 6180 }
6089 6181
6090 #endif // _LP64 6182 #endif // _LP64
6091 6183
6092 // Now versions that are common to 32/64 bit 6184 // Now versions that are common to 32/64 bit
6454 push(rax); 6546 push(rax);
6455 { Label L; 6547 { Label L;
6456 get_thread(rax); 6548 get_thread(rax);
6457 cmpptr(java_thread, rax); 6549 cmpptr(java_thread, rax);
6458 jcc(Assembler::equal, L); 6550 jcc(Assembler::equal, L);
6459 stop("MacroAssembler::call_VM_base: rdi not callee saved?"); 6551 STOP("MacroAssembler::call_VM_base: rdi not callee saved?");
6460 bind(L); 6552 bind(L);
6461 } 6553 }
6462 pop(rax); 6554 pop(rax);
6463 #endif 6555 #endif
6464 } else { 6556 } else {
7194 Label integer; 7286 Label integer;
7195 testl(tmp2, tmp2); 7287 testl(tmp2, tmp2);
7196 jcc(Assembler::notZero, integer); 7288 jcc(Assembler::notZero, integer);
7197 cmpl(tmp3, 0x80000000); 7289 cmpl(tmp3, 0x80000000);
7198 jcc(Assembler::notZero, integer); 7290 jcc(Assembler::notZero, integer);
7199 stop("integer indefinite value shouldn't be seen here"); 7291 STOP("integer indefinite value shouldn't be seen here");
7200 bind(integer); 7292 bind(integer);
7201 } 7293 }
7202 #else 7294 #else
7203 { 7295 {
7204 Label integer; 7296 Label integer;
7205 mov(tmp3, tmp2); // preserve tmp2 for parity check below 7297 mov(tmp3, tmp2); // preserve tmp2 for parity check below
7206 shlq(tmp3, 1); 7298 shlq(tmp3, 1);
7207 jcc(Assembler::carryClear, integer); 7299 jcc(Assembler::carryClear, integer);
7208 jcc(Assembler::notZero, integer); 7300 jcc(Assembler::notZero, integer);
7209 stop("integer indefinite value shouldn't be seen here"); 7301 STOP("integer indefinite value shouldn't be seen here");
7210 bind(integer); 7302 bind(integer);
7211 } 7303 }
7212 #endif 7304 #endif
7213 #endif 7305 #endif
7214 7306
8386 push(tsize); 8478 push(tsize);
8387 movptr(tsize, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset()))); 8479 movptr(tsize, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
8388 shlptr(tsize, LogHeapWordSize); 8480 shlptr(tsize, LogHeapWordSize);
8389 cmpptr(t1, tsize); 8481 cmpptr(t1, tsize);
8390 jcc(Assembler::equal, ok); 8482 jcc(Assembler::equal, ok);
8391 stop("assert(t1 != tlab size)"); 8483 STOP("assert(t1 != tlab size)");
8392 should_not_reach_here(); 8484 should_not_reach_here();
8393 8485
8394 bind(ok); 8486 bind(ok);
8395 pop(tsize); 8487 pop(tsize);
8396 } 8488 }
8725 movl(scan_temp, Address(scan_temp, itableOffsetEntry::offset_offset_in_bytes())); 8817 movl(scan_temp, Address(scan_temp, itableOffsetEntry::offset_offset_in_bytes()));
8726 movptr(method_result, Address(recv_klass, scan_temp, Address::times_1)); 8818 movptr(method_result, Address(recv_klass, scan_temp, Address::times_1));
8727 } 8819 }
8728 8820
8729 8821
8822 // virtual method calling
8823 void MacroAssembler::lookup_virtual_method(Register recv_klass,
8824 RegisterOrConstant vtable_index,
8825 Register method_result) {
8826 const int base = instanceKlass::vtable_start_offset() * wordSize;
8827 assert(vtableEntry::size() * wordSize == wordSize, "else adjust the scaling in the code below");
8828 Address vtable_entry_addr(recv_klass,
8829 vtable_index, Address::times_ptr,
8830 base + vtableEntry::method_offset_in_bytes());
8831 movptr(method_result, vtable_entry_addr);
8832 }
8833
8834
8730 void MacroAssembler::check_klass_subtype(Register sub_klass, 8835 void MacroAssembler::check_klass_subtype(Register sub_klass,
8731 Register super_klass, 8836 Register super_klass,
8732 Register temp_reg, 8837 Register temp_reg,
8733 Label& L_success) { 8838 Label& L_success) {
8734 Label L_failure; 8839 Label L_failure;
8974 if (!VerifyOops) return; 9079 if (!VerifyOops) return;
8975 9080
8976 // Pass register number to verify_oop_subroutine 9081 // Pass register number to verify_oop_subroutine
8977 char* b = new char[strlen(s) + 50]; 9082 char* b = new char[strlen(s) + 50];
8978 sprintf(b, "verify_oop: %s: %s", reg->name(), s); 9083 sprintf(b, "verify_oop: %s: %s", reg->name(), s);
9084 BLOCK_COMMENT("verify_oop {");
8979 #ifdef _LP64 9085 #ifdef _LP64
8980 push(rscratch1); // save r10, trashed by movptr() 9086 push(rscratch1); // save r10, trashed by movptr()
8981 #endif 9087 #endif
8982 push(rax); // save rax, 9088 push(rax); // save rax,
8983 push(reg); // pass register argument 9089 push(reg); // pass register argument
8988 push(rax); 9094 push(rax);
8989 // call indirectly to solve generation ordering problem 9095 // call indirectly to solve generation ordering problem
8990 movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address())); 9096 movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
8991 call(rax); 9097 call(rax);
8992 // Caller pops the arguments (oop, message) and restores rax, r10 9098 // Caller pops the arguments (oop, message) and restores rax, r10
9099 BLOCK_COMMENT("} verify_oop");
8993 } 9100 }
8994 9101
8995 9102
8996 RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr, 9103 RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
8997 Register tmp, 9104 Register tmp,
9008 testptr(tmp, tmp); 9115 testptr(tmp, tmp);
9009 if (WizardMode) { 9116 if (WizardMode) {
9010 jcc(Assembler::notZero, L); 9117 jcc(Assembler::notZero, L);
9011 char* buf = new char[40]; 9118 char* buf = new char[40];
9012 sprintf(buf, "DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]); 9119 sprintf(buf, "DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]);
9013 stop(buf); 9120 STOP(buf);
9014 } else { 9121 } else {
9015 jccb(Assembler::notZero, L); 9122 jccb(Assembler::notZero, L);
9016 hlt(); 9123 hlt();
9017 } 9124 }
9018 bind(L); 9125 bind(L);
9021 9128
9022 if (offset != 0) 9129 if (offset != 0)
9023 addptr(tmp, offset); 9130 addptr(tmp, offset);
9024 9131
9025 return RegisterOrConstant(tmp); 9132 return RegisterOrConstant(tmp);
9026 }
9027
9028
9029 // registers on entry:
9030 // - rax ('check' register): required MethodType
9031 // - rcx: method handle
9032 // - rdx, rsi, or ?: killable temp
9033 void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
9034 Register temp_reg,
9035 Label& wrong_method_type) {
9036 Address type_addr(mh_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg));
9037 // compare method type against that of the receiver
9038 if (UseCompressedOops) {
9039 load_heap_oop(temp_reg, type_addr);
9040 cmpptr(mtype_reg, temp_reg);
9041 } else {
9042 cmpptr(mtype_reg, type_addr);
9043 }
9044 jcc(Assembler::notEqual, wrong_method_type);
9045 }
9046
9047
9048 // A method handle has a "vmslots" field which gives the size of its
9049 // argument list in JVM stack slots. This field is either located directly
9050 // in every method handle, or else is indirectly accessed through the
9051 // method handle's MethodType. This macro hides the distinction.
9052 void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register mh_reg,
9053 Register temp_reg) {
9054 assert_different_registers(vmslots_reg, mh_reg, temp_reg);
9055 // load mh.type.form.vmslots
9056 Register temp2_reg = vmslots_reg;
9057 load_heap_oop(temp2_reg, Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)));
9058 load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)));
9059 movl(vmslots_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
9060 }
9061
9062
9063 // registers on entry:
9064 // - rcx: method handle
9065 // - rdx: killable temp (interpreted only)
9066 // - rax: killable temp (compiled only)
9067 void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_reg) {
9068 assert(mh_reg == rcx, "caller must put MH object in rcx");
9069 assert_different_registers(mh_reg, temp_reg);
9070
9071 // pick out the interpreted side of the handler
9072 // NOTE: vmentry is not an oop!
9073 movptr(temp_reg, Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes, temp_reg)));
9074
9075 // off we go...
9076 jmp(Address(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes()));
9077
9078 // for the various stubs which take control at this point,
9079 // see MethodHandles::generate_method_handle_stub
9080 } 9133 }
9081 9134
9082 9135
9083 Address MacroAssembler::argument_address(RegisterOrConstant arg_slot, 9136 Address MacroAssembler::argument_address(RegisterOrConstant arg_slot,
9084 int extra_slot_offset) { 9137 int extra_slot_offset) {
9150 NOT_LP64(get_thread(thread_reg)); 9203 NOT_LP64(get_thread(thread_reg));
9151 9204
9152 movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset()))); 9205 movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
9153 cmpptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset()))); 9206 cmpptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())));
9154 jcc(Assembler::aboveEqual, next); 9207 jcc(Assembler::aboveEqual, next);
9155 stop("assert(top >= start)"); 9208 STOP("assert(top >= start)");
9156 should_not_reach_here(); 9209 should_not_reach_here();
9157 9210
9158 bind(next); 9211 bind(next);
9159 movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_end_offset()))); 9212 movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())));
9160 cmpptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset()))); 9213 cmpptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
9161 jcc(Assembler::aboveEqual, ok); 9214 jcc(Assembler::aboveEqual, ok);
9162 stop("assert(top <= end)"); 9215 STOP("assert(top <= end)");
9163 should_not_reach_here(); 9216 should_not_reach_here();
9164 9217
9165 bind(ok); 9218 bind(ok);
9166 NOT_LP64(pop(thread_reg)); 9219 NOT_LP64(pop(thread_reg));
9167 pop(t1); 9220 pop(t1);
9590 } else 9643 } else
9591 #endif 9644 #endif
9592 movptr(dst, src); 9645 movptr(dst, src);
9593 } 9646 }
9594 9647
9648 void MacroAssembler::cmp_heap_oop(Register src1, Address src2, Register tmp) {
9649 assert_different_registers(src1, tmp);
9650 #ifdef _LP64
9651 if (UseCompressedOops) {
9652 bool did_push = false;
9653 if (tmp == noreg) {
9654 tmp = rax;
9655 push(tmp);
9656 did_push = true;
9657 assert(!src2.uses(rsp), "can't push");
9658 }
9659 load_heap_oop(tmp, src2);
9660 cmpptr(src1, tmp);
9661 if (did_push) pop(tmp);
9662 } else
9663 #endif
9664 cmpptr(src1, src2);
9665 }
9666
9595 // Used for storing NULLs. 9667 // Used for storing NULLs.
9596 void MacroAssembler::store_heap_oop_null(Address dst) { 9668 void MacroAssembler::store_heap_oop_null(Address dst) {
9597 #ifdef _LP64 9669 #ifdef _LP64
9598 if (UseCompressedOops) { 9670 if (UseCompressedOops) {
9599 movl(dst, (int32_t)NULL_WORD); 9671 movl(dst, (int32_t)NULL_WORD);
9620 if (CheckCompressedOops) { 9692 if (CheckCompressedOops) {
9621 Label ok; 9693 Label ok;
9622 push(rscratch1); // cmpptr trashes rscratch1 9694 push(rscratch1); // cmpptr trashes rscratch1
9623 cmpptr(r12_heapbase, ExternalAddress((address)Universe::narrow_oop_base_addr())); 9695 cmpptr(r12_heapbase, ExternalAddress((address)Universe::narrow_oop_base_addr()));
9624 jcc(Assembler::equal, ok); 9696 jcc(Assembler::equal, ok);
9625 stop(msg); 9697 STOP(msg);
9626 bind(ok); 9698 bind(ok);
9627 pop(rscratch1); 9699 pop(rscratch1);
9628 } 9700 }
9629 } 9701 }
9630 #endif 9702 #endif
9653 verify_heapbase("MacroAssembler::encode_heap_oop_not_null: heap base corrupted?"); 9725 verify_heapbase("MacroAssembler::encode_heap_oop_not_null: heap base corrupted?");
9654 if (CheckCompressedOops) { 9726 if (CheckCompressedOops) {
9655 Label ok; 9727 Label ok;
9656 testq(r, r); 9728 testq(r, r);
9657 jcc(Assembler::notEqual, ok); 9729 jcc(Assembler::notEqual, ok);
9658 stop("null oop passed to encode_heap_oop_not_null"); 9730 STOP("null oop passed to encode_heap_oop_not_null");
9659 bind(ok); 9731 bind(ok);
9660 } 9732 }
9661 #endif 9733 #endif
9662 verify_oop(r, "broken oop in encode_heap_oop_not_null"); 9734 verify_oop(r, "broken oop in encode_heap_oop_not_null");
9663 if (Universe::narrow_oop_base() != NULL) { 9735 if (Universe::narrow_oop_base() != NULL) {
9674 verify_heapbase("MacroAssembler::encode_heap_oop_not_null2: heap base corrupted?"); 9746 verify_heapbase("MacroAssembler::encode_heap_oop_not_null2: heap base corrupted?");
9675 if (CheckCompressedOops) { 9747 if (CheckCompressedOops) {
9676 Label ok; 9748 Label ok;
9677 testq(src, src); 9749 testq(src, src);
9678 jcc(Assembler::notEqual, ok); 9750 jcc(Assembler::notEqual, ok);
9679 stop("null oop passed to encode_heap_oop_not_null2"); 9751 STOP("null oop passed to encode_heap_oop_not_null2");
9680 bind(ok); 9752 bind(ok);
9681 } 9753 }
9682 #endif 9754 #endif
9683 verify_oop(src, "broken oop in encode_heap_oop_not_null2"); 9755 verify_oop(src, "broken oop in encode_heap_oop_not_null2");
9684 if (dst != src) { 9756 if (dst != src) {
9865 mov(rax, rsp); 9937 mov(rax, rsp);
9866 andptr(rax, StackAlignmentInBytes-1); 9938 andptr(rax, StackAlignmentInBytes-1);
9867 cmpptr(rax, StackAlignmentInBytes-wordSize); 9939 cmpptr(rax, StackAlignmentInBytes-wordSize);
9868 pop(rax); 9940 pop(rax);
9869 jcc(Assembler::equal, L); 9941 jcc(Assembler::equal, L);
9870 stop("Stack is not properly aligned!"); 9942 STOP("Stack is not properly aligned!");
9871 bind(L); 9943 bind(L);
9872 } 9944 }
9873 #endif 9945 #endif
9874 9946
9875 } 9947 }
10539 10611
10540 // That's it 10612 // That's it
10541 bind(DONE); 10613 bind(DONE);
10542 } 10614 }
10543 10615
10544 #ifdef PRODUCT
10545 #define BLOCK_COMMENT(str) /* nothing */
10546 #else
10547 #define BLOCK_COMMENT(str) block_comment(str)
10548 #endif
10549
10550 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
10551 void MacroAssembler::generate_fill(BasicType t, bool aligned, 10616 void MacroAssembler::generate_fill(BasicType t, bool aligned,
10552 Register to, Register value, Register count, 10617 Register to, Register value, Register count,
10553 Register rtmp, XMMRegister xtmp) { 10618 Register rtmp, XMMRegister xtmp) {
10554 ShortBranchVerifier sbv(this); 10619 ShortBranchVerifier sbv(this);
10555 assert_different_registers(to, value, count, rtmp); 10620 assert_different_registers(to, value, count, rtmp);