1.1 --- a/src/cpu/x86/vm/x86.ad Mon Mar 24 11:51:40 2014 -0700 1.2 +++ b/src/cpu/x86/vm/x86.ad Tue Mar 25 12:54:21 2014 -0700 1.3 @@ -474,7 +474,125 @@ 1.4 1.5 %} 1.6 1.7 + 1.8 +//----------SOURCE BLOCK------------------------------------------------------- 1.9 +// This is a block of C++ code which provides values, functions, and 1.10 +// definitions necessary in the rest of the architecture description 1.11 + 1.12 +source_hpp %{ 1.13 +// Header information of the source block. 1.14 +// Method declarations/definitions which are used outside 1.15 +// the ad-scope can conveniently be defined here. 1.16 +// 1.17 +// To keep related declarations/definitions/uses close together, 1.18 +// we switch between source %{ }% and source_hpp %{ }% freely as needed. 1.19 + 1.20 +class CallStubImpl { 1.21 + 1.22 + //-------------------------------------------------------------- 1.23 + //---< Used for optimization in Compile::shorten_branches >--- 1.24 + //-------------------------------------------------------------- 1.25 + 1.26 + public: 1.27 + // Size of call trampoline stub. 1.28 + static uint size_call_trampoline() { 1.29 + return 0; // no call trampolines on this platform 1.30 + } 1.31 + 1.32 + // number of relocations needed by a call trampoline stub 1.33 + static uint reloc_call_trampoline() { 1.34 + return 0; // no call trampolines on this platform 1.35 + } 1.36 +}; 1.37 + 1.38 +class HandlerImpl { 1.39 + 1.40 + public: 1.41 + 1.42 + static int emit_exception_handler(CodeBuffer &cbuf); 1.43 + static int emit_deopt_handler(CodeBuffer& cbuf); 1.44 + 1.45 + static uint size_exception_handler() { 1.46 + // NativeCall instruction size is the same as NativeJump. 1.47 + // exception handler starts out as jump and can be patched to 1.48 + // a call be deoptimization. (4932387) 1.49 + // Note that this value is also credited (in output.cpp) to 1.50 + // the size of the code section. 1.51 + return NativeJump::instruction_size; 1.52 + } 1.53 + 1.54 +#ifdef _LP64 1.55 + static uint size_deopt_handler() { 1.56 + // three 5 byte instructions 1.57 + return 15; 1.58 + } 1.59 +#else 1.60 + static uint size_deopt_handler() { 1.61 + // NativeCall instruction size is the same as NativeJump. 1.62 + // exception handler starts out as jump and can be patched to 1.63 + // a call be deoptimization. (4932387) 1.64 + // Note that this value is also credited (in output.cpp) to 1.65 + // the size of the code section. 1.66 + return 5 + NativeJump::instruction_size; // pushl(); jmp; 1.67 + } 1.68 +#endif 1.69 +}; 1.70 + 1.71 +%} // end source_hpp 1.72 + 1.73 source %{ 1.74 + 1.75 +// Emit exception handler code. 1.76 +// Stuff framesize into a register and call a VM stub routine. 1.77 +int HandlerImpl::emit_exception_handler(CodeBuffer& cbuf) { 1.78 + 1.79 + // Note that the code buffer's insts_mark is always relative to insts. 1.80 + // That's why we must use the macroassembler to generate a handler. 1.81 + MacroAssembler _masm(&cbuf); 1.82 + address base = __ start_a_stub(size_exception_handler()); 1.83 + if (base == NULL) return 0; // CodeBuffer::expand failed 1.84 + int offset = __ offset(); 1.85 + __ jump(RuntimeAddress(OptoRuntime::exception_blob()->entry_point())); 1.86 + assert(__ offset() - offset <= (int) size_exception_handler(), "overflow"); 1.87 + __ end_a_stub(); 1.88 + return offset; 1.89 +} 1.90 + 1.91 +// Emit deopt handler code. 1.92 +int HandlerImpl::emit_deopt_handler(CodeBuffer& cbuf) { 1.93 + 1.94 + // Note that the code buffer's insts_mark is always relative to insts. 1.95 + // That's why we must use the macroassembler to generate a handler. 1.96 + MacroAssembler _masm(&cbuf); 1.97 + address base = __ start_a_stub(size_deopt_handler()); 1.98 + if (base == NULL) return 0; // CodeBuffer::expand failed 1.99 + int offset = __ offset(); 1.100 + 1.101 +#ifdef _LP64 1.102 + address the_pc = (address) __ pc(); 1.103 + Label next; 1.104 + // push a "the_pc" on the stack without destroying any registers 1.105 + // as they all may be live. 1.106 + 1.107 + // push address of "next" 1.108 + __ call(next, relocInfo::none); // reloc none is fine since it is a disp32 1.109 + __ bind(next); 1.110 + // adjust it so it matches "the_pc" 1.111 + __ subptr(Address(rsp, 0), __ offset() - offset); 1.112 +#else 1.113 + InternalAddress here(__ pc()); 1.114 + __ pushptr(here.addr()); 1.115 +#endif 1.116 + 1.117 + __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack())); 1.118 + assert(__ offset() - offset <= (int) size_deopt_handler(), "overflow"); 1.119 + __ end_a_stub(); 1.120 + return offset; 1.121 +} 1.122 + 1.123 + 1.124 +//============================================================================= 1.125 + 1.126 // Float masks come from different places depending on platform. 1.127 #ifdef _LP64 1.128 static address float_signmask() { return StubRoutines::x86::float_sign_mask(); }