< prev index next >

src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp

Print this page




 954   Register temp = rbx;
 955 
 956   {
 957     __ load_klass(temp, receiver);
 958     __ cmpptr(temp, Address(holder, CompiledICHolder::holder_klass_offset()));
 959     __ movptr(rbx, Address(holder, CompiledICHolder::holder_metadata_offset()));
 960     __ jcc(Assembler::equal, ok);
 961     __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
 962 
 963     __ bind(ok);
 964     // Method might have been compiled since the call site was patched to
 965     // interpreted if that is the case treat it as a miss so we can get
 966     // the call site corrected.
 967     __ cmpptr(Address(rbx, in_bytes(Method::code_offset())), (int32_t)NULL_WORD);
 968     __ jcc(Assembler::equal, skip_fixup);
 969     __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
 970   }
 971 
 972   address c2i_entry = __ pc();
 973 



 974   // Class initialization barrier for static methods
 975   address c2i_no_clinit_check_entry = NULL;
 976   if (VM_Version::supports_fast_class_init_checks()) {
 977     Label L_skip_barrier;
 978     Register method = rbx;
 979 
 980     { // Bypass the barrier for non-static methods
 981       Register flags  = rscratch1;
 982       __ movl(flags, Address(method, Method::access_flags_offset()));
 983       __ testl(flags, JVM_ACC_STATIC);
 984       __ jcc(Assembler::zero, L_skip_barrier); // non-static
 985     }
 986 
 987     Register klass = rscratch1;
 988     __ load_method_holder(klass, method);
 989     __ clinit_barrier(klass, r15_thread, &L_skip_barrier /*L_fast_path*/);
 990 
 991     __ jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub())); // slow path
 992 
 993     __ bind(L_skip_barrier);
 994     c2i_no_clinit_check_entry = __ pc();
 995   }
 996 
 997   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
 998   bs->c2i_entry_barrier(masm);
 999 
1000   gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
1001 
1002   __ flush();
1003   return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
1004 }
1005 
1006 int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
1007                                          VMRegPair *regs,
1008                                          VMRegPair *regs2,
1009                                          int total_args_passed) {
1010   assert(regs2 == NULL, "not needed on x86");
1011 // We return the amount of VMRegImpl stack slots we need to reserve for all
1012 // the arguments NOT counting out_preserve_stack_slots.
1013 
1014 // NOTE: These arrays will have to change when c1 is ported
1015 #ifdef _WIN64
1016     static const Register INT_ArgReg[Argument::n_int_register_parameters_c] = {
1017       c_rarg0, c_rarg1, c_rarg2, c_rarg3
1018     };
1019     static const XMMRegister FP_ArgReg[Argument::n_float_register_parameters_c] = {
1020       c_farg0, c_farg1, c_farg2, c_farg3
1021     };
1022 #else
1023     static const Register INT_ArgReg[Argument::n_int_register_parameters_c] = {


1907 // block and the check for pending exceptions it's impossible for them
1908 // to be thrown.
1909 //
1910 // They are roughly structured like this:
1911 //    if (GCLocker::needs_gc())
1912 //      SharedRuntime::block_for_jni_critical();
1913 //    tranistion to thread_in_native
1914 //    unpack arrray arguments and call native entry point
1915 //    check for safepoint in progress
1916 //    check if any thread suspend flags are set
1917 //      call into JVM and possible unlock the JNI critical
1918 //      if a GC was suppressed while in the critical native.
1919 //    transition back to thread_in_Java
1920 //    return to caller
1921 //
1922 nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
1923                                                 const methodHandle& method,
1924                                                 int compile_id,
1925                                                 BasicType* in_sig_bt,
1926                                                 VMRegPair* in_regs,
1927                                                 BasicType ret_type,
1928                                                 address critical_entry) {
1929   if (method->is_method_handle_intrinsic()) {
1930     vmIntrinsics::ID iid = method->intrinsic_id();
1931     intptr_t start = (intptr_t)__ pc();
1932     int vep_offset = ((intptr_t)__ pc()) - start;
1933     gen_special_dispatch(masm,
1934                          method,
1935                          in_sig_bt,
1936                          in_regs);
1937     int frame_complete = ((intptr_t)__ pc()) - start;  // not complete, period
1938     __ flush();
1939     int stack_slots = SharedRuntime::out_preserve_stack_slots();  // no out slots at all, actually
1940     return nmethod::new_native_nmethod(method,
1941                                        compile_id,
1942                                        masm->code(),
1943                                        vep_offset,
1944                                        frame_complete,
1945                                        stack_slots / VMRegImpl::slots_per_word,
1946                                        in_ByteSize(-1),
1947                                        in_ByteSize(-1),
1948                                        (OopMapSet*)NULL);
1949   }
1950   bool is_critical_native = true;
1951   address native_func = critical_entry;
1952   if (native_func == NULL) {
1953     native_func = method->native_function();
1954     is_critical_native = false;
1955   }
1956   assert(native_func != NULL, "must have function");
1957 
1958   // An OopMap for lock (and class if static)
1959   OopMapSet *oop_maps = new OopMapSet();
1960   intptr_t start = (intptr_t)__ pc();
1961 
1962   // We have received a description of where all the java arg are located
1963   // on entry to the wrapper. We need to convert these args to where
1964   // the jni function will expect them. To figure out where they go
1965   // we convert the java signature to a C signature by inserting
1966   // the hidden arguments as arg[0] and possibly arg[1] (static method)
1967 
1968   const int total_in_args = method->size_of_parameters();
1969   int total_c_args = total_in_args;
1970   if (!is_critical_native) {
1971     total_c_args += 1;




 954   Register temp = rbx;
 955 
 956   {
 957     __ load_klass(temp, receiver);
 958     __ cmpptr(temp, Address(holder, CompiledICHolder::holder_klass_offset()));
 959     __ movptr(rbx, Address(holder, CompiledICHolder::holder_metadata_offset()));
 960     __ jcc(Assembler::equal, ok);
 961     __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
 962 
 963     __ bind(ok);
 964     // Method might have been compiled since the call site was patched to
 965     // interpreted if that is the case treat it as a miss so we can get
 966     // the call site corrected.
 967     __ cmpptr(Address(rbx, in_bytes(Method::code_offset())), (int32_t)NULL_WORD);
 968     __ jcc(Assembler::equal, skip_fixup);
 969     __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
 970   }
 971 
 972   address c2i_entry = __ pc();
 973 
 974   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
 975   bs->c2i_entry_barrier(masm);
 976 
 977   // Class initialization barrier for static methods

 978   if (VM_Version::supports_fast_class_init_checks()) {
 979     Label L_skip_barrier;
 980     Register method = rbx;
 981 
 982     { // Bypass the barrier for non-static methods
 983       Register flags  = rscratch1;
 984       __ movl(flags, Address(method, Method::access_flags_offset()));
 985       __ testl(flags, JVM_ACC_STATIC);
 986       __ jcc(Assembler::zero, L_skip_barrier); // non-static
 987     }
 988 
 989     Register klass = rscratch1;
 990     __ load_method_holder(klass, method);
 991     __ clinit_barrier(klass, r15_thread, &L_skip_barrier /*L_fast_path*/);
 992 
 993     __ jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub())); // slow path
 994 
 995     __ bind(L_skip_barrier);

 996   }
 997 



 998   gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
 999 
1000   __ flush();
1001   return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
1002 }
1003 
1004 int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
1005                                          VMRegPair *regs,
1006                                          VMRegPair *regs2,
1007                                          int total_args_passed) {
1008   assert(regs2 == NULL, "not needed on x86");
1009 // We return the amount of VMRegImpl stack slots we need to reserve for all
1010 // the arguments NOT counting out_preserve_stack_slots.
1011 
1012 // NOTE: These arrays will have to change when c1 is ported
1013 #ifdef _WIN64
1014     static const Register INT_ArgReg[Argument::n_int_register_parameters_c] = {
1015       c_rarg0, c_rarg1, c_rarg2, c_rarg3
1016     };
1017     static const XMMRegister FP_ArgReg[Argument::n_float_register_parameters_c] = {
1018       c_farg0, c_farg1, c_farg2, c_farg3
1019     };
1020 #else
1021     static const Register INT_ArgReg[Argument::n_int_register_parameters_c] = {


1905 // block and the check for pending exceptions it's impossible for them
1906 // to be thrown.
1907 //
1908 // They are roughly structured like this:
1909 //    if (GCLocker::needs_gc())
1910 //      SharedRuntime::block_for_jni_critical();
1911 //    tranistion to thread_in_native
1912 //    unpack arrray arguments and call native entry point
1913 //    check for safepoint in progress
1914 //    check if any thread suspend flags are set
1915 //      call into JVM and possible unlock the JNI critical
1916 //      if a GC was suppressed while in the critical native.
1917 //    transition back to thread_in_Java
1918 //    return to caller
1919 //
1920 nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
1921                                                 const methodHandle& method,
1922                                                 int compile_id,
1923                                                 BasicType* in_sig_bt,
1924                                                 VMRegPair* in_regs,
1925                                                 BasicType ret_type) {

1926   if (method->is_method_handle_intrinsic()) {
1927     vmIntrinsics::ID iid = method->intrinsic_id();
1928     intptr_t start = (intptr_t)__ pc();
1929     int vep_offset = ((intptr_t)__ pc()) - start;
1930     gen_special_dispatch(masm,
1931                          method,
1932                          in_sig_bt,
1933                          in_regs);
1934     int frame_complete = ((intptr_t)__ pc()) - start;  // not complete, period
1935     __ flush();
1936     int stack_slots = SharedRuntime::out_preserve_stack_slots();  // no out slots at all, actually
1937     return nmethod::new_native_nmethod(method,
1938                                        compile_id,
1939                                        masm->code(),
1940                                        vep_offset,
1941                                        frame_complete,
1942                                        stack_slots / VMRegImpl::slots_per_word,
1943                                        in_ByteSize(-1),
1944                                        in_ByteSize(-1),
1945                                        (OopMapSet*)NULL);
1946   }
1947   bool is_critical_native = true;
1948   address native_func = method->critical_native_function();
1949   if (native_func == NULL) {
1950     native_func = method->native_function();
1951     is_critical_native = false;
1952   }
1953   assert(native_func != NULL, "must have function");
1954 
1955   // An OopMap for lock (and class if static)
1956   OopMapSet *oop_maps = new OopMapSet();
1957   intptr_t start = (intptr_t)__ pc();
1958 
1959   // We have received a description of where all the java arg are located
1960   // on entry to the wrapper. We need to convert these args to where
1961   // the jni function will expect them. To figure out where they go
1962   // we convert the java signature to a C signature by inserting
1963   // the hidden arguments as arg[0] and possibly arg[1] (static method)
1964 
1965   const int total_in_args = method->size_of_parameters();
1966   int total_c_args = total_in_args;
1967   if (!is_critical_native) {
1968     total_c_args += 1;


< prev index next >