< prev index next >

src/share/vm/c1/c1_LIRGenerator.cpp

Print this page




1180   Unimplemented();
1181 }
1182 
1183 
1184 void LIRGenerator::do_Return(Return* x) {
1185   if (compilation()->env()->dtrace_method_probes()) {
1186     BasicTypeList signature;
1187     signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT));    // thread
1188     signature.append(T_METADATA); // Method*
1189     LIR_OprList* args = new LIR_OprList();
1190     args->append(getThreadPointer());
1191     LIR_Opr meth = new_register(T_METADATA);
1192     __ metadata2reg(method()->constant_encoding(), meth);
1193     args->append(meth);
1194     call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), voidType, NULL);
1195   }
1196 
1197   if (x->type()->is_void()) {
1198     __ return_op(LIR_OprFact::illegalOpr);
1199   } else {



1200     LIR_Opr reg = result_register_for(x->type(), /*callee=*/true);

1201     LIRItem result(x->result(), this);
1202 
1203     result.load_item_force(reg);
1204     __ return_op(result.result());
1205   }
1206   set_no_result(x);
1207 }
1208 
1209 // Examble: ref.get()
1210 // Combination of LoadField and g1 pre-write barrier
1211 void LIRGenerator::do_Reference_get(Intrinsic* x) {
1212 
1213   const int referent_offset = java_lang_ref_Reference::referent_offset;
1214   guarantee(referent_offset > 0, "referent offset not initialized");
1215 
1216   assert(x->number_of_arguments() == 1, "wrong type");
1217 
1218   LIRItem reference(x->argument_at(0), this);
1219   reference.load_item();
1220 


2910 // The problem is where to invoke spill-save.
2911 // - if invoked between e) and f), we may lock callee save
2912 //   register in "spill-save" that destroys the receiver register
2913 //   before f) is executed
2914 // - if we rearrange f) to be earlier (by loading %o0) it
2915 //   may destroy a value on the stack that is currently in %o0
2916 //   and is waiting to be spilled
2917 // - if we keep the receiver locked while doing spill-save,
2918 //   we cannot spill it as it is spill-locked
2919 //
2920 void LIRGenerator::do_Invoke(Invoke* x) {
2921   CallingConvention* cc = frame_map()->java_calling_convention(x->signature(), true);
2922 
2923   LIR_OprList* arg_list = cc->args();
2924   LIRItemList* args = invoke_visit_arguments(x);
2925   LIR_Opr receiver = LIR_OprFact::illegalOpr;
2926 
2927   // setup result register
2928   LIR_Opr result_register = LIR_OprFact::illegalOpr;
2929   if (x->type() != voidType) {



2930     result_register = result_register_for(x->type());

2931   }
2932 
2933   CodeEmitInfo* info = state_for(x, x->state());
2934 
2935   invoke_load_arguments(x, args, arg_list);
2936 
2937   if (x->has_receiver()) {
2938     args->at(0)->load_item_force(LIR_Assembler::receiverOpr());
2939     receiver = args->at(0)->result();
2940   }
2941 
2942   // emit invoke code
2943   bool optimized = x->target_is_loaded() && x->target_is_final();
2944   assert(receiver->is_illegal() || receiver->is_equal(LIR_Assembler::receiverOpr()), "must match");
2945 
2946   // JSR 292
2947   // Preserve the SP over MethodHandle call sites, if needed.
2948   ciMethod* target = x->target();
2949   bool is_method_handle_invoke = (// %%% FIXME: Are both of these relevant?
2950                                   target->is_method_handle_intrinsic() ||


3173   case vmIntrinsics::_Reference_get:
3174     do_Reference_get(x);
3175     break;
3176 
3177   case vmIntrinsics::_updateCRC32:
3178   case vmIntrinsics::_updateBytesCRC32:
3179   case vmIntrinsics::_updateByteBufferCRC32:
3180     do_update_CRC32(x);
3181     break;
3182 
3183   default: ShouldNotReachHere(); break;
3184   }
3185 }
3186 
3187 void LIRGenerator::profile_arguments(ProfileCall* x) {
3188   if (compilation()->profile_arguments()) {
3189     int bci = x->bci_of_invoke();
3190     ciMethodData* md = x->method()->method_data_or_null();
3191     ciProfileData* data = md->bci_to_data(bci);
3192     if (data != NULL) {
3193       if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
3194           (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
3195         ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
3196         int base_offset = md->byte_offset_of_slot(data, extra);
3197         LIR_Opr mdp = LIR_OprFact::illegalOpr;
3198         ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args();
3199 
3200         Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
3201         int start = 0;
3202         int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
3203         if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
3204           // first argument is not profiled at call (method handle invoke)
3205           assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
3206           start = 1;
3207         }
3208         ciSignature* callee_signature = x->callee()->signature();
3209         // method handle call to virtual method
3210         bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
3211         ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
3212 
3213         bool ignored_will_link;
3214         ciSignature* signature_at_call = NULL;
3215         x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
3216         ciSignatureStream signature_at_call_stream(signature_at_call);
3217 
3218         // if called through method handle invoke, some arguments may have been popped
3219         for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) {
3220           int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset());
3221           ciKlass* exact = profile_type(md, base_offset, off,
3222               args->type(i), x->profiled_arg_at(i+start), mdp,
3223               !x->arg_needs_null_check(i+start),
3224               signature_at_call_stream.next_klass(), callee_signature_stream.next_klass());
3225           if (exact != NULL) {
3226             md->set_argument_type(bci, i, exact);
3227           }
3228         }
3229       } else {

3230 #ifdef ASSERT
3231         Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke());
3232         int n = x->nb_profiled_args();
3233         assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() ||
3234             (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))),
3235             "only at JSR292 bytecodes");
3236 #endif
3237       }
3238     }
3239   }
3240 }

3241 
3242 // profile parameters on entry to an inlined method
3243 void LIRGenerator::profile_parameters_at_call(ProfileCall* x) {
3244   if (compilation()->profile_parameters() && x->inlined()) {
3245     ciMethodData* md = x->callee()->method_data_or_null();
3246     if (md != NULL) {
3247       ciParametersTypeData* parameters_type_data = md->parameters_type_data();
3248       if (parameters_type_data != NULL) {
3249         ciTypeStackSlotEntries* parameters =  parameters_type_data->parameters();
3250         LIR_Opr mdp = LIR_OprFact::illegalOpr;
3251         bool has_receiver = !x->callee()->is_static();
3252         ciSignature* sig = x->callee()->signature();
3253         ciSignatureStream sig_stream(sig, has_receiver ? x->callee()->holder() : NULL);
3254         int i = 0; // to iterate on the Instructions
3255         Value arg = x->recv();
3256         bool not_null = false;
3257         int bci = x->bci_of_invoke();
3258         Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
3259         // The first parameter is the receiver so that's what we start
3260         // with if it exists. One exception is method handle call to


3309 
3310   // profile parameters on inlined method entry including receiver
3311   if (x->recv() != NULL || x->nb_profiled_args() > 0) {
3312     profile_parameters_at_call(x);
3313   }
3314 
3315   if (x->recv() != NULL) {
3316     LIRItem value(x->recv(), this);
3317     value.load_item();
3318     recv = new_register(T_OBJECT);
3319     __ move(value.result(), recv);
3320   }
3321   __ profile_call(x->method(), x->bci_of_invoke(), x->callee(), mdo, recv, tmp, x->known_holder());
3322 }
3323 
3324 void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) {
3325   int bci = x->bci_of_invoke();
3326   ciMethodData* md = x->method()->method_data_or_null();
3327   ciProfileData* data = md->bci_to_data(bci);
3328   if (data != NULL) {
3329     assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
3330     ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
3331     LIR_Opr mdp = LIR_OprFact::illegalOpr;
3332 
3333     bool ignored_will_link;
3334     ciSignature* signature_at_call = NULL;
3335     x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
3336 
3337     // The offset within the MDO of the entry to update may be too large
3338     // to be used in load/store instructions on some platforms. So have
3339     // profile_type() compute the address of the profile in a register.
3340     ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
3341         ret->type(), x->ret(), mdp,
3342         !x->needs_null_check(),
3343         signature_at_call->return_type()->as_klass(),
3344         x->callee()->signature()->return_type()->as_klass());
3345     if (exact != NULL) {
3346       md->set_return_type(bci, exact);
3347     }
3348   }

3349 }
3350 
3351 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) {
3352   // We can safely ignore accessors here, since c2 will inline them anyway,
3353   // accessors are also always mature.
3354   if (!x->inlinee()->is_accessor()) {
3355     CodeEmitInfo* info = state_for(x, x->state(), true);
3356     // Notify the runtime very infrequently only to take care of counter overflows
3357     increment_event_counter_impl(info, x->inlinee(), (1 << Tier23InlineeNotifyFreqLog) - 1, InvocationEntryBci, false, true);
3358   }
3359 }
3360 
3361 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, int bci, bool backedge) {
3362   int freq_log = 0;
3363   int level = compilation()->env()->comp_level();
3364   if (level == CompLevel_limited_profile) {
3365     freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog);
3366   } else if (level == CompLevel_full_profile) {
3367     freq_log = (backedge ? Tier3BackedgeNotifyFreqLog : Tier3InvokeNotifyFreqLog);
3368   } else {




1180   Unimplemented();
1181 }
1182 
1183 
1184 void LIRGenerator::do_Return(Return* x) {
1185   if (compilation()->env()->dtrace_method_probes()) {
1186     BasicTypeList signature;
1187     signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT));    // thread
1188     signature.append(T_METADATA); // Method*
1189     LIR_OprList* args = new LIR_OprList();
1190     args->append(getThreadPointer());
1191     LIR_Opr meth = new_register(T_METADATA);
1192     __ metadata2reg(method()->constant_encoding(), meth);
1193     args->append(meth);
1194     call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), voidType, NULL);
1195   }
1196 
1197   if (x->type()->is_void()) {
1198     __ return_op(LIR_OprFact::illegalOpr);
1199   } else {
1200 #ifdef AARCH32
1201     LIR_Opr reg = java_result_register_for(x->type(), /*callee=*/true);
1202 #else
1203     LIR_Opr reg = result_register_for(x->type(), /*callee=*/true);
1204 #endif
1205     LIRItem result(x->result(), this);
1206 
1207     result.load_item_force(reg);
1208     __ return_op(result.result());
1209   }
1210   set_no_result(x);
1211 }
1212 
1213 // Examble: ref.get()
1214 // Combination of LoadField and g1 pre-write barrier
1215 void LIRGenerator::do_Reference_get(Intrinsic* x) {
1216 
1217   const int referent_offset = java_lang_ref_Reference::referent_offset;
1218   guarantee(referent_offset > 0, "referent offset not initialized");
1219 
1220   assert(x->number_of_arguments() == 1, "wrong type");
1221 
1222   LIRItem reference(x->argument_at(0), this);
1223   reference.load_item();
1224 


2914 // The problem is where to invoke spill-save.
2915 // - if invoked between e) and f), we may lock callee save
2916 //   register in "spill-save" that destroys the receiver register
2917 //   before f) is executed
2918 // - if we rearrange f) to be earlier (by loading %o0) it
2919 //   may destroy a value on the stack that is currently in %o0
2920 //   and is waiting to be spilled
2921 // - if we keep the receiver locked while doing spill-save,
2922 //   we cannot spill it as it is spill-locked
2923 //
2924 void LIRGenerator::do_Invoke(Invoke* x) {
2925   CallingConvention* cc = frame_map()->java_calling_convention(x->signature(), true);
2926 
2927   LIR_OprList* arg_list = cc->args();
2928   LIRItemList* args = invoke_visit_arguments(x);
2929   LIR_Opr receiver = LIR_OprFact::illegalOpr;
2930 
2931   // setup result register
2932   LIR_Opr result_register = LIR_OprFact::illegalOpr;
2933   if (x->type() != voidType) {
2934 #ifdef AARCH32
2935     result_register = java_result_register_for(x->type());
2936 #else
2937     result_register = result_register_for(x->type());
2938 #endif
2939   }
2940 
2941   CodeEmitInfo* info = state_for(x, x->state());
2942 
2943   invoke_load_arguments(x, args, arg_list);
2944 
2945   if (x->has_receiver()) {
2946     args->at(0)->load_item_force(LIR_Assembler::receiverOpr());
2947     receiver = args->at(0)->result();
2948   }
2949 
2950   // emit invoke code
2951   bool optimized = x->target_is_loaded() && x->target_is_final();
2952   assert(receiver->is_illegal() || receiver->is_equal(LIR_Assembler::receiverOpr()), "must match");
2953 
2954   // JSR 292
2955   // Preserve the SP over MethodHandle call sites, if needed.
2956   ciMethod* target = x->target();
2957   bool is_method_handle_invoke = (// %%% FIXME: Are both of these relevant?
2958                                   target->is_method_handle_intrinsic() ||


3181   case vmIntrinsics::_Reference_get:
3182     do_Reference_get(x);
3183     break;
3184 
3185   case vmIntrinsics::_updateCRC32:
3186   case vmIntrinsics::_updateBytesCRC32:
3187   case vmIntrinsics::_updateByteBufferCRC32:
3188     do_update_CRC32(x);
3189     break;
3190 
3191   default: ShouldNotReachHere(); break;
3192   }
3193 }
3194 
3195 void LIRGenerator::profile_arguments(ProfileCall* x) {
3196   if (compilation()->profile_arguments()) {
3197     int bci = x->bci_of_invoke();
3198     ciMethodData* md = x->method()->method_data_or_null();
3199     ciProfileData* data = md->bci_to_data(bci);
3200     if (data != NULL) {
3201     if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
3202         (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
3203       ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
3204       int base_offset = md->byte_offset_of_slot(data, extra);
3205       LIR_Opr mdp = LIR_OprFact::illegalOpr;
3206       ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args();
3207 
3208       Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
3209       int start = 0;
3210       int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
3211       if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
3212         // first argument is not profiled at call (method handle invoke)
3213         assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
3214         start = 1;
3215       }
3216       ciSignature* callee_signature = x->callee()->signature();
3217       // method handle call to virtual method
3218       bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
3219       ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
3220 
3221       bool ignored_will_link;
3222       ciSignature* signature_at_call = NULL;
3223       x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
3224       ciSignatureStream signature_at_call_stream(signature_at_call);
3225 
3226       // if called through method handle invoke, some arguments may have been popped
3227       for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) {
3228         int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset());
3229         ciKlass* exact = profile_type(md, base_offset, off,
3230                                       args->type(i), x->profiled_arg_at(i+start), mdp,
3231                                       !x->arg_needs_null_check(i+start),
3232                                       signature_at_call_stream.next_klass(), callee_signature_stream.next_klass());
3233         if (exact != NULL) {
3234           md->set_argument_type(bci, i, exact);

3235         }
3236       }
3237     } else {
3238 #ifdef ASSERT
3239       Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke());
3240       int n = x->nb_profiled_args();
3241       assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() ||
3242                                                   (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))),
3243              "only at JSR292 bytecodes");
3244 #endif

3245     }
3246   }
3247 }
3248 }
3249 
3250 // profile parameters on entry to an inlined method
3251 void LIRGenerator::profile_parameters_at_call(ProfileCall* x) {
3252   if (compilation()->profile_parameters() && x->inlined()) {
3253     ciMethodData* md = x->callee()->method_data_or_null();
3254     if (md != NULL) {
3255       ciParametersTypeData* parameters_type_data = md->parameters_type_data();
3256       if (parameters_type_data != NULL) {
3257         ciTypeStackSlotEntries* parameters =  parameters_type_data->parameters();
3258         LIR_Opr mdp = LIR_OprFact::illegalOpr;
3259         bool has_receiver = !x->callee()->is_static();
3260         ciSignature* sig = x->callee()->signature();
3261         ciSignatureStream sig_stream(sig, has_receiver ? x->callee()->holder() : NULL);
3262         int i = 0; // to iterate on the Instructions
3263         Value arg = x->recv();
3264         bool not_null = false;
3265         int bci = x->bci_of_invoke();
3266         Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
3267         // The first parameter is the receiver so that's what we start
3268         // with if it exists. One exception is method handle call to


3317 
3318   // profile parameters on inlined method entry including receiver
3319   if (x->recv() != NULL || x->nb_profiled_args() > 0) {
3320     profile_parameters_at_call(x);
3321   }
3322 
3323   if (x->recv() != NULL) {
3324     LIRItem value(x->recv(), this);
3325     value.load_item();
3326     recv = new_register(T_OBJECT);
3327     __ move(value.result(), recv);
3328   }
3329   __ profile_call(x->method(), x->bci_of_invoke(), x->callee(), mdo, recv, tmp, x->known_holder());
3330 }
3331 
3332 void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) {
3333   int bci = x->bci_of_invoke();
3334   ciMethodData* md = x->method()->method_data_or_null();
3335   ciProfileData* data = md->bci_to_data(bci);
3336   if (data != NULL) {
3337   assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
3338   ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
3339   LIR_Opr mdp = LIR_OprFact::illegalOpr;
3340 
3341   bool ignored_will_link;
3342   ciSignature* signature_at_call = NULL;
3343   x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
3344 
3345   // The offset within the MDO of the entry to update may be too large
3346   // to be used in load/store instructions on some platforms. So have
3347   // profile_type() compute the address of the profile in a register.
3348   ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
3349                                 ret->type(), x->ret(), mdp,
3350                                 !x->needs_null_check(),
3351                                 signature_at_call->return_type()->as_klass(),
3352                                 x->callee()->signature()->return_type()->as_klass());
3353   if (exact != NULL) {
3354     md->set_return_type(bci, exact);

3355   }
3356 }
3357 }
3358 
3359 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) {
3360   // We can safely ignore accessors here, since c2 will inline them anyway,
3361   // accessors are also always mature.
3362   if (!x->inlinee()->is_accessor()) {
3363     CodeEmitInfo* info = state_for(x, x->state(), true);
3364     // Notify the runtime very infrequently only to take care of counter overflows
3365     increment_event_counter_impl(info, x->inlinee(), (1 << Tier23InlineeNotifyFreqLog) - 1, InvocationEntryBci, false, true);
3366   }
3367 }
3368 
3369 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, int bci, bool backedge) {
3370   int freq_log = 0;
3371   int level = compilation()->env()->comp_level();
3372   if (level == CompLevel_limited_profile) {
3373     freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog);
3374   } else if (level == CompLevel_full_profile) {
3375     freq_log = (backedge ? Tier3BackedgeNotifyFreqLog : Tier3InvokeNotifyFreqLog);
3376   } else {


< prev index next >