hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp
changeset 35495 e27da438fa13
parent 35492 c8c0273e6b91
parent 35232 76aed99c0ddd
child 36798 a00bc4ff7b23
equal deleted inserted replaced
35492:c8c0273e6b91 35495:e27da438fa13
    37 #include "runtime/vframeArray.hpp"
    37 #include "runtime/vframeArray.hpp"
    38 #include "vmreg_aarch64.inline.hpp"
    38 #include "vmreg_aarch64.inline.hpp"
    39 #ifdef COMPILER1
    39 #ifdef COMPILER1
    40 #include "c1/c1_Runtime1.hpp"
    40 #include "c1/c1_Runtime1.hpp"
    41 #endif
    41 #endif
    42 #ifdef COMPILER2
    42 #if defined(COMPILER2) || INCLUDE_JVMCI
    43 #include "adfiles/ad_aarch64.hpp"
    43 #include "adfiles/ad_aarch64.hpp"
    44 #include "opto/runtime.hpp"
    44 #include "opto/runtime.hpp"
       
    45 #endif
       
    46 #if INCLUDE_JVMCI
       
    47 #include "jvmci/jvmciJavaClasses.hpp"
    45 #endif
    48 #endif
    46 
    49 
    47 #ifdef BUILTIN_SIM
    50 #ifdef BUILTIN_SIM
    48 #include "../../../../../../simulator/simulator.hpp"
    51 #include "../../../../../../simulator/simulator.hpp"
    49 #endif
    52 #endif
   107                 reg_save_size = return_off + 2};
   110                 reg_save_size = return_off + 2};
   108 
   111 
   109 };
   112 };
   110 
   113 
   111 OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words, bool save_vectors) {
   114 OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words, bool save_vectors) {
   112 #ifdef COMPILER2
   115 #if defined(COMPILER2) || INCLUDE_JVMCI
   113   if (save_vectors) {
   116   if (save_vectors) {
   114     // Save upper half of vector registers
   117     // Save upper half of vector registers
   115     int vect_words = 32 * 8 / wordSize;
   118     int vect_words = 32 * 8 / wordSize;
   116     additional_frame_words += vect_words;
   119     additional_frame_words += vect_words;
   117   }
   120   }
   118 #else
   121 #else
   119   assert(!save_vectors, "vectors are generated only by C2");
   122   assert(!save_vectors, "vectors are generated only by C2 and JVMCI");
   120 #endif
   123 #endif
   121 
   124 
   122   int frame_size_in_bytes = round_to(additional_frame_words*wordSize +
   125   int frame_size_in_bytes = round_to(additional_frame_words*wordSize +
   123                                      reg_save_size*BytesPerInt, 16);
   126                                      reg_save_size*BytesPerInt, 16);
   124   // OopMap frame size is in compiler stack slots (jint's) not bytes or words
   127   // OopMap frame size is in compiler stack slots (jint's) not bytes or words
   164   return oop_map;
   167   return oop_map;
   165 }
   168 }
   166 
   169 
   167 void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_vectors) {
   170 void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_vectors) {
   168 #ifndef COMPILER2
   171 #ifndef COMPILER2
   169   assert(!restore_vectors, "vectors are generated only by C2");
   172   assert(!restore_vectors, "vectors are generated only by C2 and JVMCI");
   170 #endif
   173 #endif
   171   __ pop_CPU_state(restore_vectors);
   174   __ pop_CPU_state(restore_vectors);
   172   __ leave();
   175   __ leave();
   173 }
   176 }
   174 
   177 
   544   }
   547   }
   545 
   548 
   546   // Will jump to the compiled code just as if compiled code was doing it.
   549   // Will jump to the compiled code just as if compiled code was doing it.
   547   // Pre-load the register-jump target early, to schedule it better.
   550   // Pre-load the register-jump target early, to schedule it better.
   548   __ ldr(rscratch1, Address(rmethod, in_bytes(Method::from_compiled_offset())));
   551   __ ldr(rscratch1, Address(rmethod, in_bytes(Method::from_compiled_offset())));
       
   552 
       
   553 #if INCLUDE_JVMCI
       
   554   if (EnableJVMCI) {
       
   555     // check if this call should be routed towards a specific entry point
       
   556     __ ldr(rscratch2, Address(rthread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())));
       
   557     Label no_alternative_target;
       
   558     __ cbz(rscratch2, no_alternative_target);
       
   559     __ mov(rscratch1, rscratch2);
       
   560     __ str(zr, Address(rthread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())));
       
   561     __ bind(no_alternative_target);
       
   562   }
       
   563 #endif // INCLUDE_JVMCI
   549 
   564 
   550   // Now generate the shuffle code.
   565   // Now generate the shuffle code.
   551   for (int i = 0; i < total_args_passed; i++) {
   566   for (int i = 0; i < total_args_passed; i++) {
   552     if (sig_bt[i] == T_VOID) {
   567     if (sig_bt[i] == T_VOID) {
   553       assert(i > 0 && (sig_bt[i-1] == T_LONG || sig_bt[i-1] == T_DOUBLE), "missing half");
   568       assert(i > 0 && (sig_bt[i-1] == T_LONG || sig_bt[i-1] == T_DOUBLE), "missing half");
  2235 //------------------------------generate_deopt_blob----------------------------
  2250 //------------------------------generate_deopt_blob----------------------------
  2236 void SharedRuntime::generate_deopt_blob() {
  2251 void SharedRuntime::generate_deopt_blob() {
  2237   // Allocate space for the code
  2252   // Allocate space for the code
  2238   ResourceMark rm;
  2253   ResourceMark rm;
  2239   // Setup code generation tools
  2254   // Setup code generation tools
  2240   CodeBuffer buffer("deopt_blob", 2048, 1024);
  2255   int pad = 0;
       
  2256 #if INCLUDE_JVMCI
       
  2257   if (EnableJVMCI) {
       
  2258     pad += 512; // Increase the buffer size when compiling for JVMCI
       
  2259   }
       
  2260 #endif
       
  2261   CodeBuffer buffer("deopt_blob", 2048+pad, 1024);
  2241   MacroAssembler* masm = new MacroAssembler(&buffer);
  2262   MacroAssembler* masm = new MacroAssembler(&buffer);
  2242   int frame_size_in_words;
  2263   int frame_size_in_words;
  2243   OopMap* map = NULL;
  2264   OopMap* map = NULL;
  2244   OopMapSet *oop_maps = new OopMapSet();
  2265   OopMapSet *oop_maps = new OopMapSet();
  2245 
  2266 
  2292   // Normal deoptimization.  Save exec mode for unpack_frames.
  2313   // Normal deoptimization.  Save exec mode for unpack_frames.
  2293   __ movw(rcpool, Deoptimization::Unpack_deopt); // callee-saved
  2314   __ movw(rcpool, Deoptimization::Unpack_deopt); // callee-saved
  2294   __ b(cont);
  2315   __ b(cont);
  2295 
  2316 
  2296   int reexecute_offset = __ pc() - start;
  2317   int reexecute_offset = __ pc() - start;
       
  2318 #if defined(INCLUDE_JVMCI) && !defined(COMPILER1)
       
  2319   if (EnableJVMCI && UseJVMCICompiler) {
       
  2320     // JVMCI does not use this kind of deoptimization
       
  2321     __ should_not_reach_here();
       
  2322   }
       
  2323 #endif
  2297 
  2324 
  2298   // Reexecute case
  2325   // Reexecute case
  2299   // return address is the pc describes what bci to do re-execute at
  2326   // return address is the pc describes what bci to do re-execute at
  2300 
  2327 
  2301   // No need to update map as each call to save_live_registers will produce identical oopmap
  2328   // No need to update map as each call to save_live_registers will produce identical oopmap
  2302   (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words);
  2329   (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words);
  2303 
  2330 
  2304   __ movw(rcpool, Deoptimization::Unpack_reexecute); // callee-saved
  2331   __ movw(rcpool, Deoptimization::Unpack_reexecute); // callee-saved
  2305   __ b(cont);
  2332   __ b(cont);
       
  2333 
       
  2334 #if INCLUDE_JVMCI
       
  2335   Label after_fetch_unroll_info_call;
       
  2336   int implicit_exception_uncommon_trap_offset = 0;
       
  2337   int uncommon_trap_offset = 0;
       
  2338 
       
  2339   if (EnableJVMCI) {
       
  2340     implicit_exception_uncommon_trap_offset = __ pc() - start;
       
  2341 
       
  2342     __ ldr(lr, Address(rthread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset())));
       
  2343     __ str(zr, Address(rthread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset())));
       
  2344 
       
  2345     uncommon_trap_offset = __ pc() - start;
       
  2346 
       
  2347     // Save everything in sight.
       
  2348     RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words);
       
  2349     // fetch_unroll_info needs to call last_java_frame()
       
  2350     Label retaddr;
       
  2351     __ set_last_Java_frame(sp, noreg, retaddr, rscratch1);
       
  2352 
       
  2353     __ ldrw(c_rarg1, Address(rthread, in_bytes(JavaThread::pending_deoptimization_offset())));
       
  2354     __ movw(rscratch1, -1);
       
  2355     __ strw(rscratch1, Address(rthread, in_bytes(JavaThread::pending_deoptimization_offset())));
       
  2356 
       
  2357     __ movw(rcpool, (int32_t)Deoptimization::Unpack_reexecute);
       
  2358     __ mov(c_rarg0, rthread);
       
  2359     __ lea(rscratch1,
       
  2360            RuntimeAddress(CAST_FROM_FN_PTR(address,
       
  2361                                            Deoptimization::uncommon_trap)));
       
  2362     __ blrt(rscratch1, 2, 0, MacroAssembler::ret_type_integral);
       
  2363     __ bind(retaddr);
       
  2364     oop_maps->add_gc_map( __ pc()-start, map->deep_copy());
       
  2365 
       
  2366     __ reset_last_Java_frame(false, false);
       
  2367 
       
  2368     __ b(after_fetch_unroll_info_call);
       
  2369   } // EnableJVMCI
       
  2370 #endif // INCLUDE_JVMCI
  2306 
  2371 
  2307   int exception_offset = __ pc() - start;
  2372   int exception_offset = __ pc() - start;
  2308 
  2373 
  2309   // Prolog for exception case
  2374   // Prolog for exception case
  2310 
  2375 
  2393   // find any register it might need.
  2458   // find any register it might need.
  2394   oop_maps->add_gc_map(__ pc() - start, map);
  2459   oop_maps->add_gc_map(__ pc() - start, map);
  2395 
  2460 
  2396   __ reset_last_Java_frame(false, true);
  2461   __ reset_last_Java_frame(false, true);
  2397 
  2462 
  2398   // Load UnrollBlock* into rdi
  2463 #if INCLUDE_JVMCI
       
  2464   if (EnableJVMCI) {
       
  2465     __ bind(after_fetch_unroll_info_call);
       
  2466   }
       
  2467 #endif
       
  2468 
       
  2469   // Load UnrollBlock* into r5
  2399   __ mov(r5, r0);
  2470   __ mov(r5, r0);
  2400 
  2471 
  2401   __ ldrw(rcpool, Address(r5, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes()));
  2472   __ ldrw(rcpool, Address(r5, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes()));
  2402    Label noException;
  2473    Label noException;
  2403   __ cmpw(rcpool, Deoptimization::Unpack_exception);   // Was exception pending?
  2474   __ cmpw(rcpool, Deoptimization::Unpack_exception);   // Was exception pending?
  2545   // Make sure all code is generated
  2616   // Make sure all code is generated
  2546   masm->flush();
  2617   masm->flush();
  2547 
  2618 
  2548   _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words);
  2619   _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words);
  2549   _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset);
  2620   _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset);
  2550 
  2621 #if INCLUDE_JVMCI
       
  2622   if (EnableJVMCI) {
       
  2623     _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset);
       
  2624     _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset);
       
  2625   }
       
  2626 #endif
  2551 #ifdef BUILTIN_SIM
  2627 #ifdef BUILTIN_SIM
  2552   if (NotifySimulator) {
  2628   if (NotifySimulator) {
  2553     unsigned char *base = _deopt_blob->code_begin();
  2629     unsigned char *base = _deopt_blob->code_begin();
  2554     simulator->notifyRelocate(start, base - start);
  2630     simulator->notifyRelocate(start, base - start);
  2555   }
  2631   }
  2558 
  2634 
  2559 uint SharedRuntime::out_preserve_stack_slots() {
  2635 uint SharedRuntime::out_preserve_stack_slots() {
  2560   return 0;
  2636   return 0;
  2561 }
  2637 }
  2562 
  2638 
  2563 #ifdef COMPILER2
  2639 #if defined(COMPILER2) || INCLUDE_JVMCI
  2564 //------------------------------generate_uncommon_trap_blob--------------------
  2640 //------------------------------generate_uncommon_trap_blob--------------------
  2565 void SharedRuntime::generate_uncommon_trap_blob() {
  2641 void SharedRuntime::generate_uncommon_trap_blob() {
  2566   // Allocate space for the code
  2642   // Allocate space for the code
  2567   ResourceMark rm;
  2643   ResourceMark rm;
  2568   // Setup code generation tools
  2644   // Setup code generation tools
  2941   // frame_size_words or bytes??
  3017   // frame_size_words or bytes??
  2942   return RuntimeStub::new_runtime_stub(name, &buffer, frame_complete, frame_size_in_words, oop_maps, true);
  3018   return RuntimeStub::new_runtime_stub(name, &buffer, frame_complete, frame_size_in_words, oop_maps, true);
  2943 }
  3019 }
  2944 
  3020 
  2945 
  3021 
  2946 #ifdef COMPILER2
  3022 #if defined(COMPILER2) || INCLUDE_JVMCI
  2947 // This is here instead of runtime_x86_64.cpp because it uses SimpleRuntimeFrame
  3023 // This is here instead of runtime_x86_64.cpp because it uses SimpleRuntimeFrame
  2948 //
  3024 //
  2949 //------------------------------generate_exception_blob---------------------------
  3025 //------------------------------generate_exception_blob---------------------------
  2950 // creates exception blob at the end
  3026 // creates exception blob at the end
  2951 // Using exception blob, this code is jumped from a compiled method.
  3027 // Using exception blob, this code is jumped from a compiled method.