273 operand[1] = hi;
274 return operand;
275 }
276
277 // Buffer for 128-bits masks used by SSE instructions.
278 static jlong fp_signmask_pool[(4+1)*2]; // 4*128bits(data) + 128bits(alignment)
279
280 // Static initialization during VM startup.
281 static jlong *float_signmask_pool = double_quadword(&fp_signmask_pool[1*2], CONST64(0x7FFFFFFF7FFFFFFF), CONST64(0x7FFFFFFF7FFFFFFF));
282 static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2], CONST64(0x7FFFFFFFFFFFFFFF), CONST64(0x7FFFFFFFFFFFFFFF));
283 static jlong *float_signflip_pool = double_quadword(&fp_signmask_pool[3*2], CONST64(0x8000000080000000), CONST64(0x8000000080000000));
284 static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000));
285
286 // Offset hacking within calls.
287 static int pre_call_resets_size() {
288 int size = 0;
289 Compile* C = Compile::current();
290 if (C->in_24_bit_fp_mode()) {
291 size += 6; // fldcw
292 }
293 if (C->max_vector_size() > 16) {
294 size += 3; // vzeroupper
295 }
296 return size;
297 }
298
299 // !!!!! Special hack to get all type of calls to specify the byte offset
300 // from the start of the call to the point where the return address
301 // will point.
302 int MachCallStaticJavaNode::ret_addr_offset() {
303 return 5 + pre_call_resets_size(); // 5 bytes from start of call to where return address points
304 }
305
306 int MachCallDynamicJavaNode::ret_addr_offset() {
307 return 10 + pre_call_resets_size(); // 10 bytes from start of call to where return address points
308 }
309
310 static int sizeof_FFree_Float_Stack_All = -1;
311
312 int MachCallRuntimeNode::ret_addr_offset() {
313 assert(sizeof_FFree_Float_Stack_All != -1, "must have been emitted already");
1867 if ((rt == T_FLOAT || rt == T_DOUBLE) && !return_value_is_used()) {
1868 // A C runtime call where the return value is unused. In SSE2+
1869 // mode the result needs to be removed from the FPU stack. It's
1870 // likely that this function call could be removed by the
1871 // optimizer if the C function is a pure function.
1872 __ ffree(0);
1873 } else if (rt == T_FLOAT) {
1874 __ lea(rsp, Address(rsp, -4));
1875 __ fstp_s(Address(rsp, 0));
1876 __ movflt(xmm0, Address(rsp, 0));
1877 __ lea(rsp, Address(rsp, 4));
1878 } else if (rt == T_DOUBLE) {
1879 __ lea(rsp, Address(rsp, -8));
1880 __ fstp_d(Address(rsp, 0));
1881 __ movdbl(xmm0, Address(rsp, 0));
1882 __ lea(rsp, Address(rsp, 8));
1883 }
1884 }
1885 %}
1886
1887
1888 enc_class pre_call_resets %{
1889 // If method sets FPU control word restore it here
1890 debug_only(int off0 = cbuf.insts_size());
1891 if (ra_->C->in_24_bit_fp_mode()) {
1892 MacroAssembler _masm(&cbuf);
1893 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
1894 }
1895 if (ra_->C->max_vector_size() > 16) {
1896 // Clear upper bits of YMM registers when current compiled code uses
1897 // wide vectors to avoid AVX <-> SSE transition penalty during call.
1898 MacroAssembler _masm(&cbuf);
1899 __ vzeroupper();
1900 }
1901 debug_only(int off1 = cbuf.insts_size());
1902 assert(off1 - off0 == pre_call_resets_size(), "correct size prediction");
1903 %}
1904
1905 enc_class post_call_FPU %{
1906 // If method sets FPU control word do it here also
1907 if (Compile::current()->in_24_bit_fp_mode()) {
1908 MacroAssembler masm(&cbuf);
1909 masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
1910 }
1911 %}
1912
1913 enc_class Java_Static_Call (method meth) %{ // JAVA STATIC CALL
1914 // CALL to fixup routine. Fixup routine uses ScopeDesc info to determine
1915 // who we intended to call.
1916 cbuf.set_insts_mark();
1917 $$$emit8$primary;
1918
1919 if (!_method) {
1920 emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
13055 match(CallLeaf);
13056 effect(USE meth);
13057
13058 ins_cost(300);
13059 format %{ "CALL_LEAF,runtime " %}
13060 opcode(0xE8); /* E8 cd */
13061 ins_encode( pre_call_resets,
13062 FFree_Float_Stack_All,
13063 Java_To_Runtime( meth ),
13064 Verify_FPU_For_Leaf, post_call_FPU );
13065 ins_pipe( pipe_slow );
13066 %}
13067
13068 instruct CallLeafNoFPDirect(method meth) %{
13069 match(CallLeafNoFP);
13070 effect(USE meth);
13071
13072 ins_cost(300);
13073 format %{ "CALL_LEAF_NOFP,runtime " %}
13074 opcode(0xE8); /* E8 cd */
13075 ins_encode(Java_To_Runtime(meth));
13076 ins_pipe( pipe_slow );
13077 %}
13078
13079
13080 // Return Instruction
13081 // Remove the return address & jump to it.
13082 instruct Ret() %{
13083 match(Return);
13084 format %{ "RET" %}
13085 opcode(0xC3);
13086 ins_encode(OpcP);
13087 ins_pipe( pipe_jmp );
13088 %}
13089
13090 // Tail Call; Jump from runtime stub to Java code.
13091 // Also known as an 'interprocedural jump'.
13092 // Target of jump will eventually return to caller.
13093 // TailJump below removes the return address.
13094 instruct TailCalljmpInd(eRegP_no_EBP jump_target, eBXRegP method_oop) %{
13095 match(TailCall jump_target method_oop );
|
273 operand[1] = hi;
274 return operand;
275 }
276
277 // Buffer for 128-bits masks used by SSE instructions.
278 static jlong fp_signmask_pool[(4+1)*2]; // 4*128bits(data) + 128bits(alignment)
279
280 // Static initialization during VM startup.
281 static jlong *float_signmask_pool = double_quadword(&fp_signmask_pool[1*2], CONST64(0x7FFFFFFF7FFFFFFF), CONST64(0x7FFFFFFF7FFFFFFF));
282 static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2], CONST64(0x7FFFFFFFFFFFFFFF), CONST64(0x7FFFFFFFFFFFFFFF));
283 static jlong *float_signflip_pool = double_quadword(&fp_signmask_pool[3*2], CONST64(0x8000000080000000), CONST64(0x8000000080000000));
284 static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000));
285
286 // Offset hacking within calls.
287 static int pre_call_resets_size() {
288 int size = 0;
289 Compile* C = Compile::current();
290 if (C->in_24_bit_fp_mode()) {
291 size += 6; // fldcw
292 }
293 if (VM_Version::supports_vzeroupper()) {
294 size += 3; // vzeroupper
295 }
296 return size;
297 }
298
299 // !!!!! Special hack to get all type of calls to specify the byte offset
300 // from the start of the call to the point where the return address
301 // will point.
302 int MachCallStaticJavaNode::ret_addr_offset() {
303 return 5 + pre_call_resets_size(); // 5 bytes from start of call to where return address points
304 }
305
306 int MachCallDynamicJavaNode::ret_addr_offset() {
307 return 10 + pre_call_resets_size(); // 10 bytes from start of call to where return address points
308 }
309
310 static int sizeof_FFree_Float_Stack_All = -1;
311
312 int MachCallRuntimeNode::ret_addr_offset() {
313 assert(sizeof_FFree_Float_Stack_All != -1, "must have been emitted already");
1867 if ((rt == T_FLOAT || rt == T_DOUBLE) && !return_value_is_used()) {
1868 // A C runtime call where the return value is unused. In SSE2+
1869 // mode the result needs to be removed from the FPU stack. It's
1870 // likely that this function call could be removed by the
1871 // optimizer if the C function is a pure function.
1872 __ ffree(0);
1873 } else if (rt == T_FLOAT) {
1874 __ lea(rsp, Address(rsp, -4));
1875 __ fstp_s(Address(rsp, 0));
1876 __ movflt(xmm0, Address(rsp, 0));
1877 __ lea(rsp, Address(rsp, 4));
1878 } else if (rt == T_DOUBLE) {
1879 __ lea(rsp, Address(rsp, -8));
1880 __ fstp_d(Address(rsp, 0));
1881 __ movdbl(xmm0, Address(rsp, 0));
1882 __ lea(rsp, Address(rsp, 8));
1883 }
1884 }
1885 %}
1886
1887 enc_class pre_call_resets %{
1888 // If method sets FPU control word restore it here
1889 debug_only(int off0 = cbuf.insts_size());
1890 if (ra_->C->in_24_bit_fp_mode()) {
1891 MacroAssembler _masm(&cbuf);
1892 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
1893 }
1894 // Clear upper bits of YMM registers when current compiled code uses
1895 // wide vectors to avoid AVX <-> SSE transition penalty during call.
1896 MacroAssembler _masm(&cbuf);
1897 __ vzeroupper();
1898 debug_only(int off1 = cbuf.insts_size());
1899 assert(off1 - off0 == pre_call_resets_size(), "correct size prediction");
1900 %}
1901
1902 enc_class post_call_FPU %{
1903 // If method sets FPU control word do it here also
1904 if (Compile::current()->in_24_bit_fp_mode()) {
1905 MacroAssembler masm(&cbuf);
1906 masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
1907 }
1908 %}
1909
1910 enc_class Java_Static_Call (method meth) %{ // JAVA STATIC CALL
1911 // CALL to fixup routine. Fixup routine uses ScopeDesc info to determine
1912 // who we intended to call.
1913 cbuf.set_insts_mark();
1914 $$$emit8$primary;
1915
1916 if (!_method) {
1917 emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
13052 match(CallLeaf);
13053 effect(USE meth);
13054
13055 ins_cost(300);
13056 format %{ "CALL_LEAF,runtime " %}
13057 opcode(0xE8); /* E8 cd */
13058 ins_encode( pre_call_resets,
13059 FFree_Float_Stack_All,
13060 Java_To_Runtime( meth ),
13061 Verify_FPU_For_Leaf, post_call_FPU );
13062 ins_pipe( pipe_slow );
13063 %}
13064
13065 instruct CallLeafNoFPDirect(method meth) %{
13066 match(CallLeafNoFP);
13067 effect(USE meth);
13068
13069 ins_cost(300);
13070 format %{ "CALL_LEAF_NOFP,runtime " %}
13071 opcode(0xE8); /* E8 cd */
13072 ins_encode(pre_call_resets, Java_To_Runtime(meth));
13073 ins_pipe( pipe_slow );
13074 %}
13075
13076
13077 // Return Instruction
13078 // Remove the return address & jump to it.
13079 instruct Ret() %{
13080 match(Return);
13081 format %{ "RET" %}
13082 opcode(0xC3);
13083 ins_encode(OpcP);
13084 ins_pipe( pipe_jmp );
13085 %}
13086
13087 // Tail Call; Jump from runtime stub to Java code.
13088 // Also known as an 'interprocedural jump'.
13089 // Target of jump will eventually return to caller.
13090 // TailJump below removes the return address.
13091 instruct TailCalljmpInd(eRegP_no_EBP jump_target, eBXRegP method_oop) %{
13092 match(TailCall jump_target method_oop );
|