src/cpu/x86/vm/assembler_x86_64.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6689060 Sdiff src/cpu/x86/vm

src/cpu/x86/vm/assembler_x86_64.cpp

Print this page




4133   reset_last_Java_frame(true, false);
4134 
4135   check_and_handle_popframe(noreg);
4136   check_and_handle_earlyret(noreg);
4137 
4138   if (check_exceptions) {
4139     cmpq(Address(r15_thread, Thread::pending_exception_offset()), (int) NULL);
4140     // This used to conditionally jump to forward_exception however it is
4141     // possible if we relocate that the branch will not reach. So we must jump
4142     // around so we can always reach
4143     Label ok;
4144     jcc(Assembler::equal, ok);
4145     jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
4146     bind(ok);
4147   }
4148 
4149   // get oop result if there is one and reset the value in the thread
4150   if (oop_result->is_valid()) {
4151     movq(oop_result, Address(r15_thread, JavaThread::vm_result_offset()));
4152     movptr(Address(r15_thread, JavaThread::vm_result_offset()), NULL_WORD);
4153     verify_oop(oop_result);
4154   }
4155 }
4156 
4157 void MacroAssembler::check_and_handle_popframe(Register java_thread) {}
4158 void MacroAssembler::check_and_handle_earlyret(Register java_thread) {}
4159 
4160 void MacroAssembler::call_VM_helper(Register oop_result,
4161                                     address entry_point,
4162                                     int num_args,
4163                                     bool check_exceptions) {
4164   // Java thread becomes first argument of C function
4165   movq(c_rarg0, r15_thread);
4166 
4167   // We've pushed one address, correct last_Java_sp
4168   leaq(rax, Address(rsp, wordSize));
4169 
4170   call_VM_base(oop_result, noreg, rax, entry_point, num_args,
4171                check_exceptions);
4172 }
4173 


4672   movq(c_rarg2, rsp); // pass pointer to regs array
4673   andq(rsp, -16); // align stack as required by ABI
4674   call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug)));
4675   hlt();
4676 }
4677 
4678 void MacroAssembler::warn(const char* msg) {
4679   pushq(r12);
4680   movq(r12, rsp);
4681   andq(rsp, -16);     // align stack as required by push_CPU_state and call
4682 
4683   push_CPU_state();   // keeps alignment at 16 bytes
4684   lea(c_rarg0, ExternalAddress((address) msg));
4685   call_VM_leaf(CAST_FROM_FN_PTR(address, warning), c_rarg0);
4686   pop_CPU_state();
4687 
4688   movq(rsp, r12);
4689   popq(r12);
4690 }
4691 




4692 void MacroAssembler::debug(char* msg, int64_t pc, int64_t regs[]) {
4693   // In order to get locks to work, we need to fake a in_VM state
4694   if (ShowMessageBoxOnError ) {
4695     JavaThread* thread = JavaThread::current();
4696     JavaThreadState saved_state = thread->thread_state();
4697     thread->set_thread_state(_thread_in_vm);
4698 #ifndef PRODUCT
4699     if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
4700       ttyLocker ttyl;
4701       BytecodeCounter::print();
4702     }
4703 #endif
4704     // To see where a verify_oop failed, get $ebx+40/X for this frame.
4705     // XXX correct this offset for amd64
4706     // This is the value of eip which points to where verify_oop will return.
4707     if (os::message_box(msg, "Execution stopped, print registers?")) {
4708       ttyLocker ttyl;
4709       tty->print_cr("rip = 0x%016lx", pc);





4710       tty->print_cr("rax = 0x%016lx", regs[15]);
4711       tty->print_cr("rbx = 0x%016lx", regs[12]);
4712       tty->print_cr("rcx = 0x%016lx", regs[14]);
4713       tty->print_cr("rdx = 0x%016lx", regs[13]);
4714       tty->print_cr("rdi = 0x%016lx", regs[8]);
4715       tty->print_cr("rsi = 0x%016lx", regs[9]);
4716       tty->print_cr("rbp = 0x%016lx", regs[10]);
4717       tty->print_cr("rsp = 0x%016lx", regs[11]);
4718       tty->print_cr("r8  = 0x%016lx", regs[7]);
4719       tty->print_cr("r9  = 0x%016lx", regs[6]);
4720       tty->print_cr("r10 = 0x%016lx", regs[5]);
4721       tty->print_cr("r11 = 0x%016lx", regs[4]);
4722       tty->print_cr("r12 = 0x%016lx", regs[3]);
4723       tty->print_cr("r13 = 0x%016lx", regs[2]);
4724       tty->print_cr("r14 = 0x%016lx", regs[1]);
4725       tty->print_cr("r15 = 0x%016lx", regs[0]);
4726       BREAKPOINT;
4727     }
4728     ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
4729   } else {


5170     assert(!dst.uses(src), "not enough registers");
5171     encode_heap_oop(src);
5172     movl(dst, src);
5173   } else {
5174     movq(dst, src);
5175   }
5176 }
5177 
5178 // Algorithm must match oop.inline.hpp encode_heap_oop.
5179 void MacroAssembler::encode_heap_oop(Register r) {
5180   assert (UseCompressedOops, "should be compressed");
5181 #ifdef ASSERT
5182   Label ok;
5183   pushq(rscratch1); // cmpptr trashes rscratch1
5184   cmpptr(r12_heapbase, ExternalAddress((address)Universe::heap_base_addr()));
5185   jcc(Assembler::equal, ok);
5186   stop("MacroAssembler::encode_heap_oop: heap base corrupted?");
5187   bind(ok);
5188   popq(rscratch1);
5189 #endif
5190   verify_oop(r);
5191   testq(r, r);
5192   cmovq(Assembler::equal, r, r12_heapbase);
5193   subq(r, r12_heapbase);
5194   shrq(r, LogMinObjAlignmentInBytes);
5195 }
5196 
5197 void MacroAssembler::encode_heap_oop_not_null(Register r) {
5198   assert (UseCompressedOops, "should be compressed");
5199 #ifdef ASSERT
5200   Label ok;
5201   testq(r, r);
5202   jcc(Assembler::notEqual, ok);
5203   stop("null oop passed to encode_heap_oop_not_null");
5204   bind(ok);
5205 #endif
5206   verify_oop(r);
5207   subq(r, r12_heapbase);
5208   shrq(r, LogMinObjAlignmentInBytes);
5209 }
5210 

















5211 void  MacroAssembler::decode_heap_oop(Register r) {
5212   assert (UseCompressedOops, "should be compressed");
5213 #ifdef ASSERT
5214   Label ok;
5215   pushq(rscratch1);
5216   cmpptr(r12_heapbase,
5217          ExternalAddress((address)Universe::heap_base_addr()));
5218   jcc(Assembler::equal, ok);
5219   stop("MacroAssembler::decode_heap_oop: heap base corrupted?");
5220   bind(ok);
5221   popq(rscratch1);
5222 #endif
5223 
5224   Label done;
5225   shlq(r, LogMinObjAlignmentInBytes);
5226   jccb(Assembler::equal, done);
5227   addq(r, r12_heapbase);
5228 #if 0
5229    // alternate decoding probably a wash.
5230    testq(r, r);
5231    jccb(Assembler::equal, done);
5232    leaq(r, Address(r12_heapbase, r, Address::times_8, 0));
5233 #endif
5234   bind(done);
5235   verify_oop(r);
5236 }
5237 
5238 void  MacroAssembler::decode_heap_oop_not_null(Register r) {
5239   assert (UseCompressedOops, "should only be used for compressed headers");
5240   // Cannot assert, unverified entry point counts instructions (see .ad file)
5241   // vtableStubs also counts instructions in pd_code_size_limit.
5242   assert(Address::times_8 == LogMinObjAlignmentInBytes, "decode alg wrong");
5243   leaq(r, Address(r12_heapbase, r, Address::times_8, 0));
5244 }
5245 








5246 Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
5247   switch (cond) {
5248     // Note some conditions are synonyms for others
5249     case Assembler::zero:         return Assembler::notZero;
5250     case Assembler::notZero:      return Assembler::zero;
5251     case Assembler::less:         return Assembler::greaterEqual;
5252     case Assembler::lessEqual:    return Assembler::greater;
5253     case Assembler::greater:      return Assembler::lessEqual;
5254     case Assembler::greaterEqual: return Assembler::less;
5255     case Assembler::below:        return Assembler::aboveEqual;
5256     case Assembler::belowEqual:   return Assembler::above;
5257     case Assembler::above:        return Assembler::belowEqual;
5258     case Assembler::aboveEqual:   return Assembler::below;
5259     case Assembler::overflow:     return Assembler::noOverflow;
5260     case Assembler::noOverflow:   return Assembler::overflow;
5261     case Assembler::negative:     return Assembler::positive;
5262     case Assembler::positive:     return Assembler::negative;
5263     case Assembler::parity:       return Assembler::noParity;
5264     case Assembler::noParity:     return Assembler::parity;
5265   }




4133   reset_last_Java_frame(true, false);
4134 
4135   check_and_handle_popframe(noreg);
4136   check_and_handle_earlyret(noreg);
4137 
4138   if (check_exceptions) {
4139     cmpq(Address(r15_thread, Thread::pending_exception_offset()), (int) NULL);
4140     // This used to conditionally jump to forward_exception however it is
4141     // possible if we relocate that the branch will not reach. So we must jump
4142     // around so we can always reach
4143     Label ok;
4144     jcc(Assembler::equal, ok);
4145     jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
4146     bind(ok);
4147   }
4148 
4149   // get oop result if there is one and reset the value in the thread
4150   if (oop_result->is_valid()) {
4151     movq(oop_result, Address(r15_thread, JavaThread::vm_result_offset()));
4152     movptr(Address(r15_thread, JavaThread::vm_result_offset()), NULL_WORD);
4153     verify_oop(oop_result, "broken oop in call_VM_base");
4154   }
4155 }
4156 
4157 void MacroAssembler::check_and_handle_popframe(Register java_thread) {}
4158 void MacroAssembler::check_and_handle_earlyret(Register java_thread) {}
4159 
4160 void MacroAssembler::call_VM_helper(Register oop_result,
4161                                     address entry_point,
4162                                     int num_args,
4163                                     bool check_exceptions) {
4164   // Java thread becomes first argument of C function
4165   movq(c_rarg0, r15_thread);
4166 
4167   // We've pushed one address, correct last_Java_sp
4168   leaq(rax, Address(rsp, wordSize));
4169 
4170   call_VM_base(oop_result, noreg, rax, entry_point, num_args,
4171                check_exceptions);
4172 }
4173 


4672   movq(c_rarg2, rsp); // pass pointer to regs array
4673   andq(rsp, -16); // align stack as required by ABI
4674   call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug)));
4675   hlt();
4676 }
4677 
4678 void MacroAssembler::warn(const char* msg) {
4679   pushq(r12);
4680   movq(r12, rsp);
4681   andq(rsp, -16);     // align stack as required by push_CPU_state and call
4682 
4683   push_CPU_state();   // keeps alignment at 16 bytes
4684   lea(c_rarg0, ExternalAddress((address) msg));
4685   call_VM_leaf(CAST_FROM_FN_PTR(address, warning), c_rarg0);
4686   pop_CPU_state();
4687 
4688   movq(rsp, r12);
4689   popq(r12);
4690 }
4691 
4692 #ifndef PRODUCT
4693 extern "C" void findpc(intptr_t x);
4694 #endif
4695 
4696 void MacroAssembler::debug(char* msg, int64_t pc, int64_t regs[]) {
4697   // In order to get locks to work, we need to fake a in_VM state
4698   if (ShowMessageBoxOnError ) {
4699     JavaThread* thread = JavaThread::current();
4700     JavaThreadState saved_state = thread->thread_state();
4701     thread->set_thread_state(_thread_in_vm);
4702 #ifndef PRODUCT
4703     if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
4704       ttyLocker ttyl;
4705       BytecodeCounter::print();
4706     }
4707 #endif
4708     // To see where a verify_oop failed, get $ebx+40/X for this frame.
4709     // XXX correct this offset for amd64
4710     // This is the value of eip which points to where verify_oop will return.
4711     if (os::message_box(msg, "Execution stopped, print registers?")) {
4712       ttyLocker ttyl;
4713       tty->print_cr("rip = 0x%016lx", pc);
4714 #ifndef PRODUCT
4715       tty->cr();
4716       findpc(pc);
4717       tty->cr();
4718 #endif
4719       tty->print_cr("rax = 0x%016lx", regs[15]);
4720       tty->print_cr("rbx = 0x%016lx", regs[12]);
4721       tty->print_cr("rcx = 0x%016lx", regs[14]);
4722       tty->print_cr("rdx = 0x%016lx", regs[13]);
4723       tty->print_cr("rdi = 0x%016lx", regs[8]);
4724       tty->print_cr("rsi = 0x%016lx", regs[9]);
4725       tty->print_cr("rbp = 0x%016lx", regs[10]);
4726       tty->print_cr("rsp = 0x%016lx", regs[11]);
4727       tty->print_cr("r8  = 0x%016lx", regs[7]);
4728       tty->print_cr("r9  = 0x%016lx", regs[6]);
4729       tty->print_cr("r10 = 0x%016lx", regs[5]);
4730       tty->print_cr("r11 = 0x%016lx", regs[4]);
4731       tty->print_cr("r12 = 0x%016lx", regs[3]);
4732       tty->print_cr("r13 = 0x%016lx", regs[2]);
4733       tty->print_cr("r14 = 0x%016lx", regs[1]);
4734       tty->print_cr("r15 = 0x%016lx", regs[0]);
4735       BREAKPOINT;
4736     }
4737     ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
4738   } else {


5179     assert(!dst.uses(src), "not enough registers");
5180     encode_heap_oop(src);
5181     movl(dst, src);
5182   } else {
5183     movq(dst, src);
5184   }
5185 }
5186 
5187 // Algorithm must match oop.inline.hpp encode_heap_oop.
5188 void MacroAssembler::encode_heap_oop(Register r) {
5189   assert (UseCompressedOops, "should be compressed");
5190 #ifdef ASSERT
5191   Label ok;
5192   pushq(rscratch1); // cmpptr trashes rscratch1
5193   cmpptr(r12_heapbase, ExternalAddress((address)Universe::heap_base_addr()));
5194   jcc(Assembler::equal, ok);
5195   stop("MacroAssembler::encode_heap_oop: heap base corrupted?");
5196   bind(ok);
5197   popq(rscratch1);
5198 #endif
5199   verify_oop(r, "broken oop in encode_heap_oop");
5200   testq(r, r);
5201   cmovq(Assembler::equal, r, r12_heapbase);
5202   subq(r, r12_heapbase);
5203   shrq(r, LogMinObjAlignmentInBytes);
5204 }
5205 
5206 void MacroAssembler::encode_heap_oop_not_null(Register r) {
5207   assert (UseCompressedOops, "should be compressed");
5208 #ifdef ASSERT
5209   Label ok;
5210   testq(r, r);
5211   jcc(Assembler::notEqual, ok);
5212   stop("null oop passed to encode_heap_oop_not_null");
5213   bind(ok);
5214 #endif
5215   verify_oop(r, "broken oop in encode_heap_oop_not_null");
5216   subq(r, r12_heapbase);
5217   shrq(r, LogMinObjAlignmentInBytes);
5218 }
5219 
5220 void MacroAssembler::encode_heap_oop_not_null(Register dst, Register src) {
5221   assert (UseCompressedOops, "should be compressed");
5222 #ifdef ASSERT
5223   Label ok;
5224   testq(src, src);
5225   jcc(Assembler::notEqual, ok);
5226   stop("null oop passed to encode_heap_oop_not_null2");
5227   bind(ok);
5228 #endif
5229   verify_oop(src, "broken oop in encode_heap_oop_not_null2");
5230   if (dst != src) {
5231     movq(dst, src);
5232   }
5233   subq(dst, r12_heapbase);
5234   shrq(dst, LogMinObjAlignmentInBytes);
5235 }
5236 
5237 void  MacroAssembler::decode_heap_oop(Register r) {
5238   assert (UseCompressedOops, "should be compressed");
5239 #ifdef ASSERT
5240   Label ok;
5241   pushq(rscratch1);
5242   cmpptr(r12_heapbase,
5243          ExternalAddress((address)Universe::heap_base_addr()));
5244   jcc(Assembler::equal, ok);
5245   stop("MacroAssembler::decode_heap_oop: heap base corrupted?");
5246   bind(ok);
5247   popq(rscratch1);
5248 #endif
5249 
5250   Label done;
5251   shlq(r, LogMinObjAlignmentInBytes);
5252   jccb(Assembler::equal, done);
5253   addq(r, r12_heapbase);
5254 #if 0
5255    // alternate decoding probably a wash.
5256    testq(r, r);
5257    jccb(Assembler::equal, done);
5258    leaq(r, Address(r12_heapbase, r, Address::times_8, 0));
5259 #endif
5260   bind(done);
5261   verify_oop(r, "broken oop in decode_heap_oop");
5262 }
5263 
5264 void  MacroAssembler::decode_heap_oop_not_null(Register r) {
5265   assert (UseCompressedOops, "should only be used for compressed headers");
5266   // Cannot assert, unverified entry point counts instructions (see .ad file)
5267   // vtableStubs also counts instructions in pd_code_size_limit.
5268   assert(Address::times_8 == LogMinObjAlignmentInBytes, "decode alg wrong");
5269   leaq(r, Address(r12_heapbase, r, Address::times_8, 0));
5270 }
5271 
5272 void  MacroAssembler::decode_heap_oop_not_null(Register dst, Register src) {
5273   assert (UseCompressedOops, "should only be used for compressed headers");
5274   // Cannot assert, unverified entry point counts instructions (see .ad file)
5275   // vtableStubs also counts instructions in pd_code_size_limit.
5276   assert(Address::times_8 == LogMinObjAlignmentInBytes, "decode alg wrong");
5277   leaq(dst, Address(r12_heapbase, src, Address::times_8, 0));
5278 }
5279 
5280 Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
5281   switch (cond) {
5282     // Note some conditions are synonyms for others
5283     case Assembler::zero:         return Assembler::notZero;
5284     case Assembler::notZero:      return Assembler::zero;
5285     case Assembler::less:         return Assembler::greaterEqual;
5286     case Assembler::lessEqual:    return Assembler::greater;
5287     case Assembler::greater:      return Assembler::lessEqual;
5288     case Assembler::greaterEqual: return Assembler::less;
5289     case Assembler::below:        return Assembler::aboveEqual;
5290     case Assembler::belowEqual:   return Assembler::above;
5291     case Assembler::above:        return Assembler::belowEqual;
5292     case Assembler::aboveEqual:   return Assembler::below;
5293     case Assembler::overflow:     return Assembler::noOverflow;
5294     case Assembler::noOverflow:   return Assembler::overflow;
5295     case Assembler::negative:     return Assembler::positive;
5296     case Assembler::positive:     return Assembler::negative;
5297     case Assembler::parity:       return Assembler::noParity;
5298     case Assembler::noParity:     return Assembler::parity;
5299   }


src/cpu/x86/vm/assembler_x86_64.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File