< prev index next >

src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp

Print this page

1641                                                 VMRegPair *in_regs,
1642                                                 BasicType ret_type) {
1643   if (method->is_method_handle_intrinsic()) {
1644     vmIntrinsics::ID iid = method->intrinsic_id();
1645     intptr_t start = (intptr_t)__ pc();
1646     int vep_offset = ((intptr_t)__ pc()) - start;
1647     gen_special_dispatch(masm,
1648                          method,
1649                          in_sig_bt,
1650                          in_regs);
1651     int frame_complete = ((intptr_t)__ pc()) - start;  // not complete, period
1652     __ flush();
1653     int stack_slots = SharedRuntime::out_preserve_stack_slots();  // no out slots at all, actually
1654     return nmethod::new_native_nmethod(method,
1655                                        compile_id,
1656                                        masm->code(),
1657                                        vep_offset,
1658                                        frame_complete,
1659                                        stack_slots / VMRegImpl::slots_per_word,
1660                                        in_ByteSize(-1),
1661                                        in_ByteSize(-1),
1662                                        (OopMapSet*)NULL);
1663   }
1664 
1665   address native_func = method->native_function();
1666   assert(native_func != NULL, "must have function");
1667 
1668   // First, create signature for outgoing C call
1669   // --------------------------------------------------------------------------
1670 
1671   int total_in_args = method->size_of_parameters();
1672   // We have received a description of where all the java args are located
1673   // on entry to the wrapper. We need to convert these args to where
1674   // the jni function will expect them. To figure out where they go
1675   // we convert the java signature to a C signature by inserting
1676   // the hidden arguments as arg[0] and possibly arg[1] (static method)
1677 
1678   // Calculate the total number of C arguments and create arrays for the
1679   // signature and the outgoing registers.
1680   // On ppc64, we have two arrays for the outgoing registers, because
1681   // some floating-point arguments must be passed in registers _and_

1738   // - *_slot_offset Indicates offset from SP in number of stack slots.
1739   // - *_offset      Indicates offset from SP in bytes.
1740 
1741   int stack_slots = c_calling_convention(out_sig_bt, out_regs, out_regs2, total_c_args) + // 1+2)
1742                     SharedRuntime::out_preserve_stack_slots(); // See c_calling_convention.
1743 
1744   // Now the space for the inbound oop handle area.
1745   int total_save_slots = num_java_iarg_registers * VMRegImpl::slots_per_word;
1746 
1747   int oop_handle_slot_offset = stack_slots;
1748   stack_slots += total_save_slots;                                                // 3)
1749 
1750   int klass_slot_offset = 0;
1751   int klass_offset      = -1;
1752   if (method_is_static) {                                                         // 4)
1753     klass_slot_offset  = stack_slots;
1754     klass_offset       = klass_slot_offset * VMRegImpl::stack_slot_size;
1755     stack_slots       += VMRegImpl::slots_per_word;
1756   }
1757 
1758   int lock_slot_offset = 0;
1759   int lock_offset      = -1;
1760   if (method->is_synchronized()) {                                                // 5)
1761     lock_slot_offset   = stack_slots;
1762     lock_offset        = lock_slot_offset * VMRegImpl::stack_slot_size;
1763     stack_slots       += VMRegImpl::slots_per_word;
1764   }
1765 
1766   int workspace_slot_offset = stack_slots;                                        // 6)
1767   stack_slots         += 2;
1768 
1769   // Now compute actual number of stack words we need.
1770   // Rounding to make stack properly aligned.
1771   stack_slots = align_up(stack_slots,                                             // 7)
1772                          frame::alignment_in_bytes / VMRegImpl::stack_slot_size);
1773   int frame_size_in_bytes = stack_slots * VMRegImpl::stack_slot_size;
1774 
1775 
1776   // Now we can start generating code.
1777   // --------------------------------------------------------------------------
1778 
1779   intptr_t start_pc = (intptr_t)__ pc();
1780   intptr_t vep_start_pc;
1781   intptr_t frame_done_pc;
1782   intptr_t oopmap_pc;
1783 
1784   Label    ic_miss;
1785   Label    handle_pending_exception;

1997   assert(R16_thread->is_nonvolatile(), "thread must be in non-volatile register");
1998 
1999 # if 0
2000   // DTrace method entry
2001 # endif
2002 
2003   // Lock a synchronized method.
2004   // --------------------------------------------------------------------------
2005 
2006   if (method->is_synchronized()) {
2007     ConditionRegister r_flag = CCR1;
2008     Register          r_oop  = r_temp_4;
2009     const Register    r_box  = r_temp_5;
2010     Label             done, locked;
2011 
2012     // Load the oop for the object or class. r_carg2_classorobject contains
2013     // either the handlized oop from the incoming arguments or the handlized
2014     // class mirror (if the method is static).
2015     __ ld(r_oop, 0, r_carg2_classorobject);
2016 
2017     // Get the lock box slot's address.
2018     __ addi(r_box, R1_SP, lock_offset);
2019 
2020     // Try fastpath for locking.
2021     // fast_lock kills r_temp_1, r_temp_2, r_temp_3.
2022     __ compiler_fast_lock_object(r_flag, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
2023     __ beq(r_flag, locked);
2024 
2025     // None of the above fast optimizations worked so we have to get into the
2026     // slow case of monitor enter. Inline a special case of call_VM that
2027     // disallows any pending_exception.
2028 
2029     // Save argument registers and leave room for C-compatible ABI_REG_ARGS.
2030     int frame_size = frame::abi_reg_args_size + align_up(total_c_args * wordSize, frame::alignment_in_bytes);
2031     __ mr(R11_scratch1, R1_SP);
2032     RegisterSaver::push_frame_and_save_argument_registers(masm, R12_scratch2, frame_size, total_c_args, out_regs, out_regs2);
2033 
2034     // Do the call.
2035     __ set_last_Java_frame(R11_scratch1, r_return_pc);
2036     assert(r_return_pc->is_nonvolatile(), "expecting return pc to be in non-volatile register");
2037     __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_locking_C), r_oop, r_box, R16_thread);
2038     __ reset_last_Java_frame();
2039 

2211 
2212   // Unlock
2213   // --------------------------------------------------------------------------
2214 
2215   if (method->is_synchronized()) {
2216 
2217     ConditionRegister r_flag   = CCR1;
2218     const Register r_oop       = r_temp_4;
2219     const Register r_box       = r_temp_5;
2220     const Register r_exception = r_temp_6;
2221     Label done;
2222 
2223     // Get oop and address of lock object box.
2224     if (method_is_static) {
2225       assert(klass_offset != -1, "");
2226       __ ld(r_oop, klass_offset, R1_SP);
2227     } else {
2228       assert(receiver_offset != -1, "");
2229       __ ld(r_oop, receiver_offset, R1_SP);
2230     }
2231     __ addi(r_box, R1_SP, lock_offset);
2232 
2233     // Try fastpath for unlocking.
2234     __ compiler_fast_unlock_object(r_flag, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
2235     __ beq(r_flag, done);
2236 
2237     // Save and restore any potential method result value around the unlocking operation.
2238     save_native_result(masm, ret_type, workspace_slot_offset);
2239 
2240     // Must save pending exception around the slow-path VM call. Since it's a
2241     // leaf call, the pending exception (if any) can be kept in a register.
2242     __ ld(r_exception, thread_(pending_exception));
2243     assert(r_exception->is_nonvolatile(), "exception register must be non-volatile");
2244     __ li(R0, 0);
2245     __ std(R0, thread_(pending_exception));
2246 
2247     // Slow case of monitor enter.
2248     // Inline a special case of call_VM that disallows any pending_exception.
2249     // Arguments are (oop obj, BasicLock* lock, JavaThread* thread).
2250     __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_unlocking_C), r_oop, r_box, R16_thread);
2251 

2325 
2326   if (!method_is_static) {
2327   __ bind(ic_miss);
2328 
2329   __ b64_patchable((address)SharedRuntime::get_ic_miss_stub(),
2330                        relocInfo::runtime_call_type);
2331   }
2332 
2333   // Done.
2334   // --------------------------------------------------------------------------
2335 
2336   __ flush();
2337 
2338   nmethod *nm = nmethod::new_native_nmethod(method,
2339                                             compile_id,
2340                                             masm->code(),
2341                                             vep_start_pc-start_pc,
2342                                             frame_done_pc-start_pc,
2343                                             stack_slots / VMRegImpl::slots_per_word,
2344                                             (method_is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
2345                                             in_ByteSize(lock_offset),
2346                                             oop_maps);
2347 
2348   return nm;
2349 }
2350 
2351 // This function returns the adjust size (in number of words) to a c2i adapter
2352 // activation for use during deoptimization.
2353 int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals) {
2354   return align_up((callee_locals - callee_parameters) * Interpreter::stackElementWords, frame::alignment_in_bytes);
2355 }
2356 
2357 uint SharedRuntime::in_preserve_stack_slots() {
2358   return frame::jit_in_preserve_size / VMRegImpl::stack_slot_size;
2359 }
2360 
2361 uint SharedRuntime::out_preserve_stack_slots() {
2362 #if defined(COMPILER1) || defined(COMPILER2)
2363   return frame::jit_out_preserve_size / VMRegImpl::stack_slot_size;
2364 #else
2365   return 0;

1641                                                 VMRegPair *in_regs,
1642                                                 BasicType ret_type) {
1643   if (method->is_method_handle_intrinsic()) {
1644     vmIntrinsics::ID iid = method->intrinsic_id();
1645     intptr_t start = (intptr_t)__ pc();
1646     int vep_offset = ((intptr_t)__ pc()) - start;
1647     gen_special_dispatch(masm,
1648                          method,
1649                          in_sig_bt,
1650                          in_regs);
1651     int frame_complete = ((intptr_t)__ pc()) - start;  // not complete, period
1652     __ flush();
1653     int stack_slots = SharedRuntime::out_preserve_stack_slots();  // no out slots at all, actually
1654     return nmethod::new_native_nmethod(method,
1655                                        compile_id,
1656                                        masm->code(),
1657                                        vep_offset,
1658                                        frame_complete,
1659                                        stack_slots / VMRegImpl::slots_per_word,
1660                                        in_ByteSize(-1),

1661                                        (OopMapSet*)NULL);
1662   }
1663 
1664   address native_func = method->native_function();
1665   assert(native_func != NULL, "must have function");
1666 
1667   // First, create signature for outgoing C call
1668   // --------------------------------------------------------------------------
1669 
1670   int total_in_args = method->size_of_parameters();
1671   // We have received a description of where all the java args are located
1672   // on entry to the wrapper. We need to convert these args to where
1673   // the jni function will expect them. To figure out where they go
1674   // we convert the java signature to a C signature by inserting
1675   // the hidden arguments as arg[0] and possibly arg[1] (static method)
1676 
1677   // Calculate the total number of C arguments and create arrays for the
1678   // signature and the outgoing registers.
1679   // On ppc64, we have two arrays for the outgoing registers, because
1680   // some floating-point arguments must be passed in registers _and_

1737   // - *_slot_offset Indicates offset from SP in number of stack slots.
1738   // - *_offset      Indicates offset from SP in bytes.
1739 
1740   int stack_slots = c_calling_convention(out_sig_bt, out_regs, out_regs2, total_c_args) + // 1+2)
1741                     SharedRuntime::out_preserve_stack_slots(); // See c_calling_convention.
1742 
1743   // Now the space for the inbound oop handle area.
1744   int total_save_slots = num_java_iarg_registers * VMRegImpl::slots_per_word;
1745 
1746   int oop_handle_slot_offset = stack_slots;
1747   stack_slots += total_save_slots;                                                // 3)
1748 
1749   int klass_slot_offset = 0;
1750   int klass_offset      = -1;
1751   if (method_is_static) {                                                         // 4)
1752     klass_slot_offset  = stack_slots;
1753     klass_offset       = klass_slot_offset * VMRegImpl::stack_slot_size;
1754     stack_slots       += VMRegImpl::slots_per_word;
1755   }
1756 








1757   int workspace_slot_offset = stack_slots;                                        // 6)
1758   stack_slots         += 2;
1759 
1760   // Now compute actual number of stack words we need.
1761   // Rounding to make stack properly aligned.
1762   stack_slots = align_up(stack_slots,                                             // 7)
1763                          frame::alignment_in_bytes / VMRegImpl::stack_slot_size);
1764   int frame_size_in_bytes = stack_slots * VMRegImpl::stack_slot_size;
1765 
1766 
1767   // Now we can start generating code.
1768   // --------------------------------------------------------------------------
1769 
1770   intptr_t start_pc = (intptr_t)__ pc();
1771   intptr_t vep_start_pc;
1772   intptr_t frame_done_pc;
1773   intptr_t oopmap_pc;
1774 
1775   Label    ic_miss;
1776   Label    handle_pending_exception;

1988   assert(R16_thread->is_nonvolatile(), "thread must be in non-volatile register");
1989 
1990 # if 0
1991   // DTrace method entry
1992 # endif
1993 
1994   // Lock a synchronized method.
1995   // --------------------------------------------------------------------------
1996 
1997   if (method->is_synchronized()) {
1998     ConditionRegister r_flag = CCR1;
1999     Register          r_oop  = r_temp_4;
2000     const Register    r_box  = r_temp_5;
2001     Label             done, locked;
2002 
2003     // Load the oop for the object or class. r_carg2_classorobject contains
2004     // either the handlized oop from the incoming arguments or the handlized
2005     // class mirror (if the method is static).
2006     __ ld(r_oop, 0, r_carg2_classorobject);
2007 



2008     // Try fastpath for locking.
2009     // fast_lock kills r_temp_1, r_temp_2, r_temp_3.
2010     __ compiler_fast_lock_object(r_flag, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
2011     __ beq(r_flag, locked);
2012 
2013     // None of the above fast optimizations worked so we have to get into the
2014     // slow case of monitor enter. Inline a special case of call_VM that
2015     // disallows any pending_exception.
2016 
2017     // Save argument registers and leave room for C-compatible ABI_REG_ARGS.
2018     int frame_size = frame::abi_reg_args_size + align_up(total_c_args * wordSize, frame::alignment_in_bytes);
2019     __ mr(R11_scratch1, R1_SP);
2020     RegisterSaver::push_frame_and_save_argument_registers(masm, R12_scratch2, frame_size, total_c_args, out_regs, out_regs2);
2021 
2022     // Do the call.
2023     __ set_last_Java_frame(R11_scratch1, r_return_pc);
2024     assert(r_return_pc->is_nonvolatile(), "expecting return pc to be in non-volatile register");
2025     __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_locking_C), r_oop, r_box, R16_thread);
2026     __ reset_last_Java_frame();
2027 

2199 
2200   // Unlock
2201   // --------------------------------------------------------------------------
2202 
2203   if (method->is_synchronized()) {
2204 
2205     ConditionRegister r_flag   = CCR1;
2206     const Register r_oop       = r_temp_4;
2207     const Register r_box       = r_temp_5;
2208     const Register r_exception = r_temp_6;
2209     Label done;
2210 
2211     // Get oop and address of lock object box.
2212     if (method_is_static) {
2213       assert(klass_offset != -1, "");
2214       __ ld(r_oop, klass_offset, R1_SP);
2215     } else {
2216       assert(receiver_offset != -1, "");
2217       __ ld(r_oop, receiver_offset, R1_SP);
2218     }

2219 
2220     // Try fastpath for unlocking.
2221     __ compiler_fast_unlock_object(r_flag, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3);
2222     __ beq(r_flag, done);
2223 
2224     // Save and restore any potential method result value around the unlocking operation.
2225     save_native_result(masm, ret_type, workspace_slot_offset);
2226 
2227     // Must save pending exception around the slow-path VM call. Since it's a
2228     // leaf call, the pending exception (if any) can be kept in a register.
2229     __ ld(r_exception, thread_(pending_exception));
2230     assert(r_exception->is_nonvolatile(), "exception register must be non-volatile");
2231     __ li(R0, 0);
2232     __ std(R0, thread_(pending_exception));
2233 
2234     // Slow case of monitor enter.
2235     // Inline a special case of call_VM that disallows any pending_exception.
2236     // Arguments are (oop obj, BasicLock* lock, JavaThread* thread).
2237     __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_unlocking_C), r_oop, r_box, R16_thread);
2238 

2312 
2313   if (!method_is_static) {
2314   __ bind(ic_miss);
2315 
2316   __ b64_patchable((address)SharedRuntime::get_ic_miss_stub(),
2317                        relocInfo::runtime_call_type);
2318   }
2319 
2320   // Done.
2321   // --------------------------------------------------------------------------
2322 
2323   __ flush();
2324 
2325   nmethod *nm = nmethod::new_native_nmethod(method,
2326                                             compile_id,
2327                                             masm->code(),
2328                                             vep_start_pc-start_pc,
2329                                             frame_done_pc-start_pc,
2330                                             stack_slots / VMRegImpl::slots_per_word,
2331                                             (method_is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),

2332                                             oop_maps);
2333 
2334   return nm;
2335 }
2336 
2337 // This function returns the adjust size (in number of words) to a c2i adapter
2338 // activation for use during deoptimization.
2339 int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals) {
2340   return align_up((callee_locals - callee_parameters) * Interpreter::stackElementWords, frame::alignment_in_bytes);
2341 }
2342 
2343 uint SharedRuntime::in_preserve_stack_slots() {
2344   return frame::jit_in_preserve_size / VMRegImpl::stack_slot_size;
2345 }
2346 
2347 uint SharedRuntime::out_preserve_stack_slots() {
2348 #if defined(COMPILER1) || defined(COMPILER2)
2349   return frame::jit_out_preserve_size / VMRegImpl::stack_slot_size;
2350 #else
2351   return 0;
< prev index next >