src/cpu/x86/vm/templateTable_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/cpu/x86/vm

src/cpu/x86/vm/templateTable_x86_32.cpp

Print this page
rev 5240 : 8023657: New type profiling points: arguments to call
Summary: x86 interpreter and c1 type profiling for arguments at calls
Reviewed-by:


2953   assert(recv  == rcx, "");
2954 
2955   // Test for an invoke of a final method
2956   Label notFinal;
2957   __ movl(rax, flags);
2958   __ andl(rax, (1 << ConstantPoolCacheEntry::is_vfinal_shift));
2959   __ jcc(Assembler::zero, notFinal);
2960 
2961   const Register method = index;  // method must be rbx
2962   assert(method == rbx,
2963          "Method* must be rbx for interpreter calling convention");
2964 
2965   // do the call - the index is actually the method to call
2966   // that is, f2 is a vtable index if !is_vfinal, else f2 is a Method*
2967 
2968   // It's final, need a null check here!
2969   __ null_check(recv);
2970 
2971   // profile this call
2972   __ profile_final_call(rax);

2973 
2974   __ jump_from_interpreted(method, rax);
2975 
2976   __ bind(notFinal);
2977 
2978   // get receiver klass
2979   __ null_check(recv, oopDesc::klass_offset_in_bytes());
2980   __ load_klass(rax, recv);
2981 
2982   // profile this call
2983   __ profile_virtual_call(rax, rdi, rdx);
2984 
2985   // get target Method* & entry point
2986   __ lookup_virtual_method(rax, index, method);

2987   __ jump_from_interpreted(method, rdx);
2988 }
2989 
2990 
2991 void TemplateTable::invokevirtual(int byte_no) {
2992   transition(vtos, vtos);
2993   assert(byte_no == f2_byte, "use this argument");
2994   prepare_invoke(byte_no,
2995                  rbx,    // method or vtable index
2996                  noreg,  // unused itable index
2997                  rcx, rdx); // recv, flags
2998 
2999   // rbx: index
3000   // rcx: receiver
3001   // rdx: flags
3002 
3003   invokevirtual_helper(rbx, rcx, rdx);
3004 }
3005 
3006 
3007 void TemplateTable::invokespecial(int byte_no) {
3008   transition(vtos, vtos);
3009   assert(byte_no == f1_byte, "use this argument");
3010   prepare_invoke(byte_no, rbx, noreg,  // get f1 Method*
3011                  rcx);  // get receiver also for null check
3012   __ verify_oop(rcx);
3013   __ null_check(rcx);
3014   // do the call
3015   __ profile_call(rax);

3016   __ jump_from_interpreted(rbx, rax);
3017 }
3018 
3019 
3020 void TemplateTable::invokestatic(int byte_no) {
3021   transition(vtos, vtos);
3022   assert(byte_no == f1_byte, "use this argument");
3023   prepare_invoke(byte_no, rbx);  // get f1 Method*
3024   // do the call
3025   __ profile_call(rax);

3026   __ jump_from_interpreted(rbx, rax);
3027 }
3028 
3029 
3030 void TemplateTable::fast_invokevfinal(int byte_no) {
3031   transition(vtos, vtos);
3032   assert(byte_no == f2_byte, "use this argument");
3033   __ stop("fast_invokevfinal not used on x86");
3034 }
3035 
3036 
3037 void TemplateTable::invokeinterface(int byte_no) {
3038   transition(vtos, vtos);
3039   assert(byte_no == f1_byte, "use this argument");
3040   prepare_invoke(byte_no, rax, rbx,  // get f1 Klass*, f2 itable index
3041                  rcx, rdx); // recv, flags
3042 
3043   // rax: interface klass (from f1)
3044   // rbx: itable index (from f2)
3045   // rcx: receiver


3065   // profile this call
3066   __ profile_virtual_call(rdx, rsi, rdi);
3067 
3068   Label no_such_interface, no_such_method;
3069 
3070   __ lookup_interface_method(// inputs: rec. class, interface, itable index
3071                              rdx, rax, rbx,
3072                              // outputs: method, scan temp. reg
3073                              rbx, rsi,
3074                              no_such_interface);
3075 
3076   // rbx: Method* to call
3077   // rcx: receiver
3078   // Check for abstract method error
3079   // Note: This should be done more efficiently via a throw_abstract_method_error
3080   //       interpreter entry point and a conditional jump to it in case of a null
3081   //       method.
3082   __ testptr(rbx, rbx);
3083   __ jcc(Assembler::zero, no_such_method);
3084 


3085   // do the call
3086   // rcx: receiver
3087   // rbx,: Method*
3088   __ jump_from_interpreted(rbx, rdx);
3089   __ should_not_reach_here();
3090 
3091   // exception handling code follows...
3092   // note: must restore interpreter registers to canonical
3093   //       state for exception handling to work correctly!
3094 
3095   __ bind(no_such_method);
3096   // throw exception
3097   __ pop(rbx);           // pop return address (pushed by prepare_invoke)
3098   __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
3099   __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
3100   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
3101   // the call_VM checks for exception, so we should never return here.
3102   __ should_not_reach_here();
3103 
3104   __ bind(no_such_interface);


3121   const Register rdx_flags  = rdx;
3122 
3123   if (!EnableInvokeDynamic) {
3124     // rewriter does not generate this bytecode
3125     __ should_not_reach_here();
3126     return;
3127   }
3128 
3129   prepare_invoke(byte_no, rbx_method, rax_mtype, rcx_recv);
3130   __ verify_method_ptr(rbx_method);
3131   __ verify_oop(rcx_recv);
3132   __ null_check(rcx_recv);
3133 
3134   // rax: MethodType object (from cpool->resolved_references[f1], if necessary)
3135   // rbx: MH.invokeExact_MT method (from f2)
3136 
3137   // Note:  rax_mtype is already pushed (if necessary) by prepare_invoke
3138 
3139   // FIXME: profile the LambdaForm also
3140   __ profile_final_call(rax);

3141 
3142   __ jump_from_interpreted(rbx_method, rdx);
3143 }
3144 
3145 
3146 void TemplateTable::invokedynamic(int byte_no) {
3147   transition(vtos, vtos);
3148   assert(byte_no == f1_byte, "use this argument");
3149 
3150   if (!EnableInvokeDynamic) {
3151     // We should not encounter this bytecode if !EnableInvokeDynamic.
3152     // The verifier will stop it.  However, if we get past the verifier,
3153     // this will stop the thread in a reasonable way, without crashing the JVM.
3154     __ call_VM(noreg, CAST_FROM_FN_PTR(address,
3155                      InterpreterRuntime::throw_IncompatibleClassChangeError));
3156     // the call_VM checks for exception, so we should never return here.
3157     __ should_not_reach_here();
3158     return;
3159   }
3160 
3161   const Register rbx_method   = rbx;
3162   const Register rax_callsite = rax;
3163 
3164   prepare_invoke(byte_no, rbx_method, rax_callsite);
3165 
3166   // rax: CallSite object (from cpool->resolved_references[f1])
3167   // rbx: MH.linkToCallSite method (from f2)
3168 
3169   // Note:  rax_callsite is already pushed by prepare_invoke
3170 
3171   // %%% should make a type profile for any invokedynamic that takes a ref argument
3172   // profile this call
3173   __ profile_call(rsi);

3174 
3175   __ verify_oop(rax_callsite);
3176 
3177   __ jump_from_interpreted(rbx_method, rdx);
3178 }
3179 
3180 //----------------------------------------------------------------------------------------------------
3181 // Allocation
3182 
3183 void TemplateTable::_new() {
3184   transition(vtos, atos);
3185   __ get_unsigned_2_byte_index_at_bcp(rdx, 1);
3186   Label slow_case;
3187   Label slow_case_no_pop;
3188   Label done;
3189   Label initialize_header;
3190   Label initialize_object;  // including clearing the fields
3191   Label allocate_shared;
3192 
3193   __ get_cpool_and_tags(rcx, rax);




2953   assert(recv  == rcx, "");
2954 
2955   // Test for an invoke of a final method
2956   Label notFinal;
2957   __ movl(rax, flags);
2958   __ andl(rax, (1 << ConstantPoolCacheEntry::is_vfinal_shift));
2959   __ jcc(Assembler::zero, notFinal);
2960 
2961   const Register method = index;  // method must be rbx
2962   assert(method == rbx,
2963          "Method* must be rbx for interpreter calling convention");
2964 
2965   // do the call - the index is actually the method to call
2966   // that is, f2 is a vtable index if !is_vfinal, else f2 is a Method*
2967 
2968   // It's final, need a null check here!
2969   __ null_check(recv);
2970 
2971   // profile this call
2972   __ profile_final_call(rax);
2973   __ profile_arguments_type(rax, method, rsi, true);
2974 
2975   __ jump_from_interpreted(method, rax);
2976 
2977   __ bind(notFinal);
2978 
2979   // get receiver klass
2980   __ null_check(recv, oopDesc::klass_offset_in_bytes());
2981   __ load_klass(rax, recv);
2982 
2983   // profile this call
2984   __ profile_virtual_call(rax, rdi, rdx);
2985 
2986   // get target Method* & entry point
2987   __ lookup_virtual_method(rax, index, method);
2988   __ profile_arguments_type(rdx, method, rsi, true);
2989   __ jump_from_interpreted(method, rdx);
2990 }
2991 
2992 
2993 void TemplateTable::invokevirtual(int byte_no) {
2994   transition(vtos, vtos);
2995   assert(byte_no == f2_byte, "use this argument");
2996   prepare_invoke(byte_no,
2997                  rbx,    // method or vtable index
2998                  noreg,  // unused itable index
2999                  rcx, rdx); // recv, flags
3000 
3001   // rbx: index
3002   // rcx: receiver
3003   // rdx: flags
3004 
3005   invokevirtual_helper(rbx, rcx, rdx);
3006 }
3007 
3008 
3009 void TemplateTable::invokespecial(int byte_no) {
3010   transition(vtos, vtos);
3011   assert(byte_no == f1_byte, "use this argument");
3012   prepare_invoke(byte_no, rbx, noreg,  // get f1 Method*
3013                  rcx);  // get receiver also for null check
3014   __ verify_oop(rcx);
3015   __ null_check(rcx);
3016   // do the call
3017   __ profile_call(rax);
3018   __ profile_arguments_type(rax, rbx, rsi, false);
3019   __ jump_from_interpreted(rbx, rax);
3020 }
3021 
3022 
3023 void TemplateTable::invokestatic(int byte_no) {
3024   transition(vtos, vtos);
3025   assert(byte_no == f1_byte, "use this argument");
3026   prepare_invoke(byte_no, rbx);  // get f1 Method*
3027   // do the call
3028   __ profile_call(rax);
3029   __ profile_arguments_type(rax, rbx, rsi, false);
3030   __ jump_from_interpreted(rbx, rax);
3031 }
3032 
3033 
3034 void TemplateTable::fast_invokevfinal(int byte_no) {
3035   transition(vtos, vtos);
3036   assert(byte_no == f2_byte, "use this argument");
3037   __ stop("fast_invokevfinal not used on x86");
3038 }
3039 
3040 
3041 void TemplateTable::invokeinterface(int byte_no) {
3042   transition(vtos, vtos);
3043   assert(byte_no == f1_byte, "use this argument");
3044   prepare_invoke(byte_no, rax, rbx,  // get f1 Klass*, f2 itable index
3045                  rcx, rdx); // recv, flags
3046 
3047   // rax: interface klass (from f1)
3048   // rbx: itable index (from f2)
3049   // rcx: receiver


3069   // profile this call
3070   __ profile_virtual_call(rdx, rsi, rdi);
3071 
3072   Label no_such_interface, no_such_method;
3073 
3074   __ lookup_interface_method(// inputs: rec. class, interface, itable index
3075                              rdx, rax, rbx,
3076                              // outputs: method, scan temp. reg
3077                              rbx, rsi,
3078                              no_such_interface);
3079 
3080   // rbx: Method* to call
3081   // rcx: receiver
3082   // Check for abstract method error
3083   // Note: This should be done more efficiently via a throw_abstract_method_error
3084   //       interpreter entry point and a conditional jump to it in case of a null
3085   //       method.
3086   __ testptr(rbx, rbx);
3087   __ jcc(Assembler::zero, no_such_method);
3088 
3089   __ profile_arguments_type(rdx, rbx, rsi, true);
3090 
3091   // do the call
3092   // rcx: receiver
3093   // rbx,: Method*
3094   __ jump_from_interpreted(rbx, rdx);
3095   __ should_not_reach_here();
3096 
3097   // exception handling code follows...
3098   // note: must restore interpreter registers to canonical
3099   //       state for exception handling to work correctly!
3100 
3101   __ bind(no_such_method);
3102   // throw exception
3103   __ pop(rbx);           // pop return address (pushed by prepare_invoke)
3104   __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
3105   __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
3106   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
3107   // the call_VM checks for exception, so we should never return here.
3108   __ should_not_reach_here();
3109 
3110   __ bind(no_such_interface);


3127   const Register rdx_flags  = rdx;
3128 
3129   if (!EnableInvokeDynamic) {
3130     // rewriter does not generate this bytecode
3131     __ should_not_reach_here();
3132     return;
3133   }
3134 
3135   prepare_invoke(byte_no, rbx_method, rax_mtype, rcx_recv);
3136   __ verify_method_ptr(rbx_method);
3137   __ verify_oop(rcx_recv);
3138   __ null_check(rcx_recv);
3139 
3140   // rax: MethodType object (from cpool->resolved_references[f1], if necessary)
3141   // rbx: MH.invokeExact_MT method (from f2)
3142 
3143   // Note:  rax_mtype is already pushed (if necessary) by prepare_invoke
3144 
3145   // FIXME: profile the LambdaForm also
3146   __ profile_final_call(rax);
3147   __ profile_arguments_type(rdx, rbx_method, rsi, true);
3148 
3149   __ jump_from_interpreted(rbx_method, rdx);
3150 }
3151 
3152 
3153 void TemplateTable::invokedynamic(int byte_no) {
3154   transition(vtos, vtos);
3155   assert(byte_no == f1_byte, "use this argument");
3156 
3157   if (!EnableInvokeDynamic) {
3158     // We should not encounter this bytecode if !EnableInvokeDynamic.
3159     // The verifier will stop it.  However, if we get past the verifier,
3160     // this will stop the thread in a reasonable way, without crashing the JVM.
3161     __ call_VM(noreg, CAST_FROM_FN_PTR(address,
3162                      InterpreterRuntime::throw_IncompatibleClassChangeError));
3163     // the call_VM checks for exception, so we should never return here.
3164     __ should_not_reach_here();
3165     return;
3166   }
3167 
3168   const Register rbx_method   = rbx;
3169   const Register rax_callsite = rax;
3170 
3171   prepare_invoke(byte_no, rbx_method, rax_callsite);
3172 
3173   // rax: CallSite object (from cpool->resolved_references[f1])
3174   // rbx: MH.linkToCallSite method (from f2)
3175 
3176   // Note:  rax_callsite is already pushed by prepare_invoke
3177 
3178   // %%% should make a type profile for any invokedynamic that takes a ref argument
3179   // profile this call
3180   __ profile_call(rsi);
3181   __ profile_arguments_type(rdx, rbx, rsi, false);
3182 
3183   __ verify_oop(rax_callsite);
3184 
3185   __ jump_from_interpreted(rbx_method, rdx);
3186 }
3187 
3188 //----------------------------------------------------------------------------------------------------
3189 // Allocation
3190 
3191 void TemplateTable::_new() {
3192   transition(vtos, atos);
3193   __ get_unsigned_2_byte_index_at_bcp(rdx, 1);
3194   Label slow_case;
3195   Label slow_case_no_pop;
3196   Label done;
3197   Label initialize_header;
3198   Label initialize_object;  // including clearing the fields
3199   Label allocate_shared;
3200 
3201   __ get_cpool_and_tags(rcx, rax);


src/cpu/x86/vm/templateTable_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File