Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/sharedRuntime_x86_64.cpp @ 21559:be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 28 May 2015 15:36:48 +0200 |
parents | 2e35a4ea22ac |
children | b3d5463a8362 |
comparison
equal
deleted
inserted
replaced
21558:d563baeca9df | 21559:be896a1983c0 |
---|---|
38 #include "c1/c1_Runtime1.hpp" | 38 #include "c1/c1_Runtime1.hpp" |
39 #endif | 39 #endif |
40 #ifdef COMPILER2 | 40 #ifdef COMPILER2 |
41 #include "opto/runtime.hpp" | 41 #include "opto/runtime.hpp" |
42 #endif | 42 #endif |
43 #ifdef GRAAL | 43 #ifdef JVMCI |
44 #include "graal/graalJavaAccess.hpp" | 44 #include "jvmci/jvmciJavaAccess.hpp" |
45 #endif | 45 #endif |
46 | 46 |
47 #define __ masm-> | 47 #define __ masm-> |
48 | 48 |
49 const int StackAlignmentInSlots = StackAlignmentInBytes / VMRegImpl::stack_slot_size; | 49 const int StackAlignmentInSlots = StackAlignmentInBytes / VMRegImpl::stack_slot_size; |
71 // units because compiler frame slots are jints. | 71 // units because compiler frame slots are jints. |
72 #define DEF_XMM_OFFS(regnum) xmm ## regnum ## _off = xmm_off + (regnum)*16/BytesPerInt, xmm ## regnum ## H_off | 72 #define DEF_XMM_OFFS(regnum) xmm ## regnum ## _off = xmm_off + (regnum)*16/BytesPerInt, xmm ## regnum ## H_off |
73 #define DEF_YMM_HI_OFFS(regnum) ymm_hi ## regnum ## _off = ymm_off + (regnum)*16/BytesPerInt | 73 #define DEF_YMM_HI_OFFS(regnum) ymm_hi ## regnum ## _off = ymm_off + (regnum)*16/BytesPerInt |
74 enum layout { | 74 enum layout { |
75 fpu_state_off = frame::arg_reg_save_area_bytes/BytesPerInt, // fxsave save area | 75 fpu_state_off = frame::arg_reg_save_area_bytes/BytesPerInt, // fxsave save area |
76 #if defined(COMPILER2) || defined(GRAAL) | 76 #if defined(COMPILER2) || defined(JVMCI) |
77 ymm_off = fpu_state_off, // offset in fxsave save area | 77 ymm_off = fpu_state_off, // offset in fxsave save area |
78 DEF_YMM_HI_OFFS(0), | 78 DEF_YMM_HI_OFFS(0), |
79 DEF_YMM_HI_OFFS(1), | 79 DEF_YMM_HI_OFFS(1), |
80 DEF_YMM_HI_OFFS(2), | 80 DEF_YMM_HI_OFFS(2), |
81 DEF_YMM_HI_OFFS(3), | 81 DEF_YMM_HI_OFFS(3), |
180 // to be under the return like a normal enter. | 180 // to be under the return like a normal enter. |
181 | 181 |
182 __ enter(); // rsp becomes 16-byte aligned here | 182 __ enter(); // rsp becomes 16-byte aligned here |
183 __ push_CPU_state(); // Push a multiple of 16 bytes | 183 __ push_CPU_state(); // Push a multiple of 16 bytes |
184 | 184 |
185 #if defined(COMPILER2) || defined(GRAAL) | 185 #if defined(COMPILER2) || defined(JVMCI) |
186 __ subptr(rsp, 256); // Save upper half of YMM registers | 186 __ subptr(rsp, 256); // Save upper half of YMM registers |
187 if (save_vectors) { | 187 if (save_vectors) { |
188 assert(UseAVX > 0, "256bit vectors are supported only with AVX"); | 188 assert(UseAVX > 0, "256bit vectors are supported only with AVX"); |
189 assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); | 189 assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); |
190 // Save upper half of YMM registers | 190 // Save upper half of YMM registers |
204 __ vextractf128h(Address(rsp, ymm_hi13_off * BytesPerInt), xmm13); | 204 __ vextractf128h(Address(rsp, ymm_hi13_off * BytesPerInt), xmm13); |
205 __ vextractf128h(Address(rsp, ymm_hi14_off * BytesPerInt), xmm14); | 205 __ vextractf128h(Address(rsp, ymm_hi14_off * BytesPerInt), xmm14); |
206 __ vextractf128h(Address(rsp, ymm_hi15_off * BytesPerInt), xmm15); | 206 __ vextractf128h(Address(rsp, ymm_hi15_off * BytesPerInt), xmm15); |
207 } | 207 } |
208 #else | 208 #else |
209 assert(!save_vectors, "vectors are generated only by C2 and Graal"); | 209 assert(!save_vectors, "vectors are generated only by C2 and JVMCI"); |
210 #endif | 210 #endif |
211 if (frame::arg_reg_save_area_bytes != 0) { | 211 if (frame::arg_reg_save_area_bytes != 0) { |
212 // Allocate argument register save area | 212 // Allocate argument register save area |
213 __ subptr(rsp, frame::arg_reg_save_area_bytes); | 213 __ subptr(rsp, frame::arg_reg_save_area_bytes); |
214 } | 214 } |
255 map->set_callee_saved(STACK_OFFSET(xmm13_off), xmm13->as_VMReg()); | 255 map->set_callee_saved(STACK_OFFSET(xmm13_off), xmm13->as_VMReg()); |
256 map->set_callee_saved(STACK_OFFSET(xmm14_off), xmm14->as_VMReg()); | 256 map->set_callee_saved(STACK_OFFSET(xmm14_off), xmm14->as_VMReg()); |
257 map->set_callee_saved(STACK_OFFSET(xmm15_off), xmm15->as_VMReg()); | 257 map->set_callee_saved(STACK_OFFSET(xmm15_off), xmm15->as_VMReg()); |
258 | 258 |
259 | 259 |
260 #if defined(COMPILER2) || defined(GRAAL) | 260 #if defined(COMPILER2) || defined(JVMCI) |
261 if (save_vectors) { | 261 if (save_vectors) { |
262 map->set_callee_saved(STACK_OFFSET(ymm_hi0_off ), xmm0->as_VMReg()->next()->next()->next()->next()); | 262 map->set_callee_saved(STACK_OFFSET(ymm_hi0_off ), xmm0->as_VMReg()->next()->next()->next()->next()); |
263 map->set_callee_saved(STACK_OFFSET(ymm_hi1_off ), xmm1->as_VMReg()->next()->next()->next()->next()); | 263 map->set_callee_saved(STACK_OFFSET(ymm_hi1_off ), xmm1->as_VMReg()->next()->next()->next()->next()); |
264 map->set_callee_saved(STACK_OFFSET(ymm_hi2_off ), xmm2->as_VMReg()->next()->next()->next()->next()); | 264 map->set_callee_saved(STACK_OFFSET(ymm_hi2_off ), xmm2->as_VMReg()->next()->next()->next()->next()); |
265 map->set_callee_saved(STACK_OFFSET(ymm_hi3_off ), xmm3->as_VMReg()->next()->next()->next()->next()); | 265 map->set_callee_saved(STACK_OFFSET(ymm_hi3_off ), xmm3->as_VMReg()->next()->next()->next()->next()); |
319 void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_vectors) { | 319 void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_vectors) { |
320 if (frame::arg_reg_save_area_bytes != 0) { | 320 if (frame::arg_reg_save_area_bytes != 0) { |
321 // Pop arg register save area | 321 // Pop arg register save area |
322 __ addptr(rsp, frame::arg_reg_save_area_bytes); | 322 __ addptr(rsp, frame::arg_reg_save_area_bytes); |
323 } | 323 } |
324 #if defined(COMPILER2) || defined(GRAAL) | 324 #if defined(COMPILER2) || defined(JVMCI) |
325 if (restore_vectors) { | 325 if (restore_vectors) { |
326 // Restore upper half of YMM registes. | 326 // Restore upper half of YMM registes. |
327 assert(UseAVX > 0, "256bit vectors are supported only with AVX"); | 327 assert(UseAVX > 0, "256bit vectors are supported only with AVX"); |
328 assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); | 328 assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); |
329 __ vinsertf128h(xmm0, Address(rsp, ymm_hi0_off * BytesPerInt)); | 329 __ vinsertf128h(xmm0, Address(rsp, ymm_hi0_off * BytesPerInt)); |
343 __ vinsertf128h(xmm14, Address(rsp, ymm_hi14_off * BytesPerInt)); | 343 __ vinsertf128h(xmm14, Address(rsp, ymm_hi14_off * BytesPerInt)); |
344 __ vinsertf128h(xmm15, Address(rsp, ymm_hi15_off * BytesPerInt)); | 344 __ vinsertf128h(xmm15, Address(rsp, ymm_hi15_off * BytesPerInt)); |
345 } | 345 } |
346 __ addptr(rsp, 256); | 346 __ addptr(rsp, 256); |
347 #else | 347 #else |
348 assert(!restore_vectors, "vectors are generated only by C2 and Graal"); | 348 assert(!restore_vectors, "vectors are generated only by C2 and JVMCI"); |
349 #endif | 349 #endif |
350 // Recover CPU state | 350 // Recover CPU state |
351 __ pop_CPU_state(); | 351 __ pop_CPU_state(); |
352 // Get the rbp described implicitly by the calling convention (no oopMap) | 352 // Get the rbp described implicitly by the calling convention (no oopMap) |
353 __ pop(rbp); | 353 __ pop(rbp); |
741 __ stop(msg); | 741 __ stop(msg); |
742 __ bind(L_ok); | 742 __ bind(L_ok); |
743 __ block_comment("} verify_i2ce "); | 743 __ block_comment("} verify_i2ce "); |
744 } | 744 } |
745 | 745 |
746 #ifdef GRAAL | 746 #ifdef JVMCI |
747 if (frame_extension_argument != -1) { | 747 if (frame_extension_argument != -1) { |
748 // The frame_extension_argument is an int that describes the | 748 // The frame_extension_argument is an int that describes the |
749 // expected amount of argument space in the caller frame. If that | 749 // expected amount of argument space in the caller frame. If that |
750 // is greater than total_args_passed then enlarge the caller frame | 750 // is greater than total_args_passed then enlarge the caller frame |
751 // by that amount to ensure deopt works correctly. | 751 // by that amount to ensure deopt works correctly. |
812 | 812 |
813 // Will jump to the compiled code just as if compiled code was doing it. | 813 // Will jump to the compiled code just as if compiled code was doing it. |
814 // Pre-load the register-jump target early, to schedule it better. | 814 // Pre-load the register-jump target early, to schedule it better. |
815 __ movptr(r11, Address(rbx, in_bytes(Method::from_compiled_offset()))); | 815 __ movptr(r11, Address(rbx, in_bytes(Method::from_compiled_offset()))); |
816 | 816 |
817 #ifdef GRAAL | 817 #ifdef JVMCI |
818 // check if this call should be routed towards a specific entry point | 818 // check if this call should be routed towards a specific entry point |
819 __ cmpptr(Address(r15_thread, in_bytes(JavaThread::graal_alternate_call_target_offset())), 0); | 819 __ cmpptr(Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())), 0); |
820 Label no_alternative_target; | 820 Label no_alternative_target; |
821 __ jcc(Assembler::equal, no_alternative_target); | 821 __ jcc(Assembler::equal, no_alternative_target); |
822 __ movptr(r11, Address(r15_thread, in_bytes(JavaThread::graal_alternate_call_target_offset()))); | 822 __ movptr(r11, Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); |
823 __ movptr(Address(r15_thread, in_bytes(JavaThread::graal_alternate_call_target_offset())), 0); | 823 __ movptr(Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())), 0); |
824 __ bind(no_alternative_target); | 824 __ bind(no_alternative_target); |
825 #endif | 825 #endif |
826 | 826 |
827 // Now generate the shuffle code. Pick up all register args and move the | 827 // Now generate the shuffle code. Pick up all register args and move the |
828 // rest through the floating point stack top. | 828 // rest through the floating point stack top. |
3426 // Normal deoptimization. Save exec mode for unpack_frames. | 3426 // Normal deoptimization. Save exec mode for unpack_frames. |
3427 __ movl(r14, Deoptimization::Unpack_deopt); // callee-saved | 3427 __ movl(r14, Deoptimization::Unpack_deopt); // callee-saved |
3428 __ jmp(cont); | 3428 __ jmp(cont); |
3429 | 3429 |
3430 int reexecute_offset = __ pc() - start; | 3430 int reexecute_offset = __ pc() - start; |
3431 #if defined(COMPILERGRAAL) && !defined(COMPILER1) | 3431 #if defined(COMPILERJVMCI) && !defined(COMPILER1) |
3432 // Graal does not use this kind of deoptimization | 3432 // JVMCI does not use this kind of deoptimization |
3433 __ should_not_reach_here(); | 3433 __ should_not_reach_here(); |
3434 #endif | 3434 #endif |
3435 | 3435 |
3436 // Reexecute case | 3436 // Reexecute case |
3437 // return address is the pc describes what bci to do re-execute at | 3437 // return address is the pc describes what bci to do re-execute at |
3440 (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words); | 3440 (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words); |
3441 | 3441 |
3442 __ movl(r14, Deoptimization::Unpack_reexecute); // callee-saved | 3442 __ movl(r14, Deoptimization::Unpack_reexecute); // callee-saved |
3443 __ jmp(cont); | 3443 __ jmp(cont); |
3444 | 3444 |
3445 #ifdef GRAAL | 3445 #ifdef JVMCI |
3446 int implicit_exception_uncommon_trap_offset = __ pc() - start; | 3446 int implicit_exception_uncommon_trap_offset = __ pc() - start; |
3447 | 3447 |
3448 __ pushptr(Address(r15_thread, in_bytes(JavaThread::graal_implicit_exception_pc_offset()))); | 3448 __ pushptr(Address(r15_thread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()))); |
3449 | 3449 |
3450 int uncommon_trap_offset = __ pc() - start; | 3450 int uncommon_trap_offset = __ pc() - start; |
3451 | 3451 |
3452 // Save everything in sight. | 3452 // Save everything in sight. |
3453 RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words); | 3453 RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words); |
3464 | 3464 |
3465 __ reset_last_Java_frame(false, false); | 3465 __ reset_last_Java_frame(false, false); |
3466 | 3466 |
3467 Label after_fetch_unroll_info_call; | 3467 Label after_fetch_unroll_info_call; |
3468 __ jmp(after_fetch_unroll_info_call); | 3468 __ jmp(after_fetch_unroll_info_call); |
3469 #endif // GRAAL | 3469 #endif // JVMCI |
3470 | 3470 |
3471 int exception_offset = __ pc() - start; | 3471 int exception_offset = __ pc() - start; |
3472 | 3472 |
3473 // Prolog for exception case | 3473 // Prolog for exception case |
3474 | 3474 |
3551 // find any register it might need. | 3551 // find any register it might need. |
3552 oop_maps->add_gc_map(__ pc() - start, map); | 3552 oop_maps->add_gc_map(__ pc() - start, map); |
3553 | 3553 |
3554 __ reset_last_Java_frame(false, false); | 3554 __ reset_last_Java_frame(false, false); |
3555 | 3555 |
3556 #ifdef GRAAL | 3556 #ifdef JVMCI |
3557 __ bind(after_fetch_unroll_info_call); | 3557 __ bind(after_fetch_unroll_info_call); |
3558 #endif | 3558 #endif |
3559 | 3559 |
3560 // Load UnrollBlock* into rdi | 3560 // Load UnrollBlock* into rdi |
3561 __ mov(rdi, rax); | 3561 __ mov(rdi, rax); |
3729 // Make sure all code is generated | 3729 // Make sure all code is generated |
3730 masm->flush(); | 3730 masm->flush(); |
3731 | 3731 |
3732 _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); | 3732 _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); |
3733 _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); | 3733 _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); |
3734 #ifdef GRAAL | 3734 #ifdef JVMCI |
3735 _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset); | 3735 _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset); |
3736 _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); | 3736 _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); |
3737 #endif | 3737 #endif |
3738 } | 3738 } |
3739 | 3739 |