2984 if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting. 2985 profile_parameters(x); 2986 CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false); 2987 increment_invocation_counter(info); 2988 } 2989 2990 // all blocks with a successor must end with an unconditional jump 2991 // to the successor even if they are consecutive 2992 __ jump(x->default_sux()); 2993 } 2994 2995 2996 void LIRGenerator::do_OsrEntry(OsrEntry* x) { 2997 // construct our frame and model the production of incoming pointer 2998 // to the OSR buffer. 2999 __ osr_entry(LIR_Assembler::osrBufferPointer()); 3000 LIR_Opr result = rlock_result(x); 3001 __ move(LIR_Assembler::osrBufferPointer(), result); 3002 } 3003 3004 3005 void LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) { 3006 assert(args->length() == arg_list->length(), 3007 "args=%d, arg_list=%d", args->length(), arg_list->length()); 3008 for (int i = x->has_receiver() ? 1 : 0; i < args->length(); i++) { 3009 LIRItem* param = args->at(i); 3010 LIR_Opr loc = arg_list->at(i); 3011 if (loc->is_register()) { 3012 param->load_item_force(loc); 3013 } else { 3014 LIR_Address* addr = loc->as_address_ptr(); 3015 param->load_for_store(addr->type()); 3016 assert(addr->type() != T_VALUETYPE, "not supported yet"); 3017 if (addr->type() == T_OBJECT) { 3018 __ move_wide(param->result(), addr); 3019 } else 3020 if (addr->type() == T_LONG || addr->type() == T_DOUBLE) { 3021 __ unaligned_move(param->result(), addr); 3022 } else { 3023 __ move(param->result(), addr); 3024 } 3025 } 3026 } 3027 3028 if (x->has_receiver()) { 3029 LIRItem* receiver = args->at(0); 3030 LIR_Opr loc = arg_list->at(0); 3031 if (loc->is_register()) { 3032 receiver->load_item_force(loc); 3033 } else { 3034 assert(loc->is_address(), "just checking"); 3035 receiver->load_for_store(T_OBJECT); 3036 __ move_wide(receiver->result(), loc->as_address_ptr()); 3037 } 3038 } 3039 } 3040 3041 3042 // Visits all arguments, returns appropriate items without loading them 3043 LIRItemList* LIRGenerator::invoke_visit_arguments(Invoke* x) { 3044 LIRItemList* argument_items = new LIRItemList(); 3045 if (x->has_receiver()) { 3046 LIRItem* receiver = new LIRItem(x->receiver(), this); 3186 __ move(tmp, reg); 3187 } 3188 3189 3190 3191 // Code for : x->x() {x->cond()} x->y() ? x->tval() : x->fval() 3192 void LIRGenerator::do_IfOp(IfOp* x) { 3193 #ifdef ASSERT 3194 { 3195 ValueTag xtag = x->x()->type()->tag(); 3196 ValueTag ttag = x->tval()->type()->tag(); 3197 assert(xtag == intTag || xtag == objectTag, "cannot handle others"); 3198 assert(ttag == addressTag || ttag == intTag || ttag == objectTag || ttag == longTag, "cannot handle others"); 3199 assert(ttag == x->fval()->type()->tag(), "cannot handle others"); 3200 } 3201 #endif 3202 3203 LIRItem left(x->x(), this); 3204 LIRItem right(x->y(), this); 3205 left.load_item(); 3206 if (can_inline_as_constant(right.value())) { 3207 right.dont_load_item(); 3208 } else { 3209 right.load_item(); 3210 } 3211 3212 LIRItem t_val(x->tval(), this); 3213 LIRItem f_val(x->fval(), this); 3214 t_val.dont_load_item(); 3215 f_val.dont_load_item(); 3216 LIR_Opr reg = rlock_result(x); 3217 3218 __ cmp(lir_cond(x->cond()), left.result(), right.result()); 3219 __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type())); 3220 } 3221 3222 #ifdef JFR_HAVE_INTRINSICS 3223 void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) { 3224 CodeEmitInfo* info = state_for(x); 3225 CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check 3226 3227 assert(info != NULL, "must have info"); 3228 LIRItem arg(x->argument_at(0), this); 3229 3230 arg.load_item(); 3231 LIR_Opr klass = new_register(T_METADATA); 3232 __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), klass, info); 3233 LIR_Opr id = new_register(T_LONG); 3234 ByteSize offset = KLASS_TRACE_ID_OFFSET; 3235 LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG); 3236 3237 __ move(trace_id_addr, id); 3238 __ logical_or(id, LIR_OprFact::longConst(0x01l), id); 3239 __ store(id, trace_id_addr); | 2984 if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting. 2985 profile_parameters(x); 2986 CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false); 2987 increment_invocation_counter(info); 2988 } 2989 2990 // all blocks with a successor must end with an unconditional jump 2991 // to the successor even if they are consecutive 2992 __ jump(x->default_sux()); 2993 } 2994 2995 2996 void LIRGenerator::do_OsrEntry(OsrEntry* x) { 2997 // construct our frame and model the production of incoming pointer 2998 // to the OSR buffer. 2999 __ osr_entry(LIR_Assembler::osrBufferPointer()); 3000 LIR_Opr result = rlock_result(x); 3001 __ move(LIR_Assembler::osrBufferPointer(), result); 3002 } 3003 3004 void LIRGenerator::invoke_load_one_argument(LIRItem* param, LIR_Opr loc) { 3005 if (loc->is_register()) { 3006 param->load_item_force(loc); 3007 } else { 3008 LIR_Address* addr = loc->as_address_ptr(); 3009 param->load_for_store(addr->type()); 3010 assert(addr->type() != T_VALUETYPE, "not supported yet"); 3011 if (addr->type() == T_OBJECT) { 3012 __ move_wide(param->result(), addr); 3013 } else { 3014 if (addr->type() == T_LONG || addr->type() == T_DOUBLE) { 3015 __ unaligned_move(param->result(), addr); 3016 } else { 3017 __ move(param->result(), addr); 3018 } 3019 } 3020 } 3021 } 3022 3023 void LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) { 3024 assert(args->length() == arg_list->length(), 3025 "args=%d, arg_list=%d", args->length(), arg_list->length()); 3026 for (int i = x->has_receiver() ? 1 : 0; i < args->length(); i++) { 3027 LIRItem* param = args->at(i); 3028 LIR_Opr loc = arg_list->at(i); 3029 invoke_load_one_argument(param, loc); 3030 } 3031 3032 if (x->has_receiver()) { 3033 LIRItem* receiver = args->at(0); 3034 LIR_Opr loc = arg_list->at(0); 3035 if (loc->is_register()) { 3036 receiver->load_item_force(loc); 3037 } else { 3038 assert(loc->is_address(), "just checking"); 3039 receiver->load_for_store(T_OBJECT); 3040 __ move_wide(receiver->result(), loc->as_address_ptr()); 3041 } 3042 } 3043 } 3044 3045 3046 // Visits all arguments, returns appropriate items without loading them 3047 LIRItemList* LIRGenerator::invoke_visit_arguments(Invoke* x) { 3048 LIRItemList* argument_items = new LIRItemList(); 3049 if (x->has_receiver()) { 3050 LIRItem* receiver = new LIRItem(x->receiver(), this); 3190 __ move(tmp, reg); 3191 } 3192 3193 3194 3195 // Code for : x->x() {x->cond()} x->y() ? x->tval() : x->fval() 3196 void LIRGenerator::do_IfOp(IfOp* x) { 3197 #ifdef ASSERT 3198 { 3199 ValueTag xtag = x->x()->type()->tag(); 3200 ValueTag ttag = x->tval()->type()->tag(); 3201 assert(xtag == intTag || xtag == objectTag, "cannot handle others"); 3202 assert(ttag == addressTag || ttag == intTag || ttag == objectTag || ttag == longTag, "cannot handle others"); 3203 assert(ttag == x->fval()->type()->tag(), "cannot handle others"); 3204 } 3205 #endif 3206 3207 LIRItem left(x->x(), this); 3208 LIRItem right(x->y(), this); 3209 left.load_item(); 3210 if (can_inline_as_constant(right.value()) && !x->substituability_check()) { 3211 right.dont_load_item(); 3212 } else { 3213 // substituability_check() needs to use right as a base register. 3214 right.load_item(); 3215 } 3216 3217 LIRItem t_val(x->tval(), this); 3218 LIRItem f_val(x->fval(), this); 3219 t_val.dont_load_item(); 3220 f_val.dont_load_item(); 3221 3222 if (x->substituability_check()) { 3223 substituability_check(x, left, right, t_val, f_val); 3224 } else { 3225 LIR_Opr reg = rlock_result(x); 3226 __ cmp(lir_cond(x->cond()), left.result(), right.result()); 3227 __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type())); 3228 } 3229 } 3230 3231 void LIRGenerator::substituability_check(IfOp* x, LIRItem& left, LIRItem& right, LIRItem& t_val, LIRItem& f_val) { 3232 assert(x->cond() == If::eql || x->cond() == If::neq, "must be"); 3233 bool is_acmpeq = (x->cond() == If::eql); 3234 LIR_Opr reg = rlock_result(x); 3235 LIR_Opr equal_result = is_acmpeq ? t_val.result() : f_val.result(); 3236 LIR_Opr not_equal_result = is_acmpeq ? f_val.result() : t_val.result(); 3237 3238 LabelObj* L_oops_equal = new LabelObj(); 3239 LabelObj* L_oops_not_equal = new LabelObj(); 3240 LabelObj* L_do_subst_check = new LabelObj(); 3241 LabelObj* L_end = new LabelObj(); 3242 3243 __ cmp(lir_cond_equal, left.result(), right.result()); 3244 __ branch(lir_cond_equal, T_ILLEGAL, L_oops_equal->label()); 3245 3246 // The two operands are not the same reference. Do a more costly substituability check. 3247 3248 ciKlass* left_klass = x->x()->as_loaded_klass_or_null(); 3249 ciKlass* right_klass = x->y()->as_loaded_klass_or_null(); 3250 3251 // (1) Null check -- if one of the operands is null, the other must not be null (because 3252 // the two references are not equal), so they are not substitutable, 3253 // FIXME: do null check only if the operand is nullable 3254 { 3255 __ cmp(lir_cond_equal, left.result(), LIR_OprFact::oopConst(NULL)); 3256 __ branch(lir_cond_equal, T_ILLEGAL, L_oops_not_equal->label()); 3257 3258 __ cmp(lir_cond_equal, right.result(), LIR_OprFact::oopConst(NULL)); 3259 __ branch(lir_cond_equal, T_ILLEGAL, L_oops_not_equal->label()); 3260 } 3261 3262 // (2) Value object check -- if either of the operands is not a value object, 3263 // they are not substitutable. We do this only if we are not sure that the 3264 // operands value objects 3265 if ((left_klass == NULL || right_klass == NULL) ||// The klass is still unloaded, or came from a Phi node. 3266 !left_klass->is_valuetype() || !right_klass->is_valuetype()) { 3267 // FIXME: on x64, this can be optimized as: 3268 // mov $0x405,%r10d 3269 // and (%left), %r10d /* if need to check left */ 3270 // and (%right), %r10d /* if need to check right */ 3271 // cmp $0x405, $r10d 3272 // jne L_oops_not_equal 3273 3274 LIR_Opr mark = new_register(T_LONG); 3275 LIR_Opr always_locked_pattern = new_register(T_LONG); 3276 __ move(LIR_OprFact::longConst(markOopDesc::always_locked_pattern), always_locked_pattern); 3277 3278 if (left_klass == NULL || !left_klass->is_valuetype()) { 3279 __ move(new LIR_Address(left.result(), oopDesc::mark_offset_in_bytes(), T_LONG), mark); 3280 __ logical_and(mark, always_locked_pattern, mark); 3281 __ cmp(lir_cond_notEqual, mark, always_locked_pattern); 3282 __ branch(lir_cond_notEqual, T_ILLEGAL, L_oops_not_equal->label()); 3283 } 3284 3285 if (right_klass == NULL || !right_klass->is_valuetype()) { 3286 __ move(new LIR_Address(right.result(), oopDesc::mark_offset_in_bytes(), T_LONG), mark); 3287 __ logical_and(mark, always_locked_pattern, mark); 3288 __ cmp(lir_cond_notEqual, mark, always_locked_pattern); 3289 __ branch(lir_cond_notEqual, T_ILLEGAL, L_oops_not_equal->label()); 3290 } 3291 } 3292 3293 // (3) Same klass check: if the operands are of different klasses, they are not substitutable. 3294 if (left_klass != NULL && left_klass->is_valuetype() && left_klass == right_klass) { 3295 // No need to check -- they are known to be the same value klass. 3296 __ branch(lir_cond_always, T_ILLEGAL, L_do_subst_check->label()); 3297 } else { 3298 BasicType t_klass = UseCompressedOops ? T_INT : T_METADATA; 3299 BasicType t_addr = UseCompressedOops ? T_INT : T_ADDRESS; 3300 3301 LIR_Opr left_klass = new_register(t_klass); 3302 LIR_Opr right_klass = new_register(t_klass); 3303 __ move(new LIR_Address(left.result(), oopDesc::klass_offset_in_bytes(), t_addr), left_klass); 3304 __ move(new LIR_Address(right.result(), oopDesc::klass_offset_in_bytes(), t_addr), right_klass); 3305 __ cmp(lir_cond_equal, left_klass, right_klass); 3306 __ branch(lir_cond_equal, T_ILLEGAL, L_do_subst_check->label()); 3307 3308 // fall through to L_oops_not_equal 3309 } 3310 3311 __ branch_destination(L_oops_not_equal->label()); 3312 __ move(not_equal_result, reg); 3313 __ branch(lir_cond_always, T_ILLEGAL, L_end->label()); 3314 3315 3316 // FIXME -- for simple case (no non-flattened value fields), do a per-field comparison 3317 3318 __ branch_destination(L_do_subst_check->label()); 3319 { 3320 // Call into ValueBootstrapMethods::isSubstitutable() 3321 ciMethod* subst_method = ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbol::isSubstitutable_name(), ciSymbol::object_object_boolean_signature()); 3322 assert(method() != subst_method, "cannot recurse!"); 3323 3324 const LIR_Opr result = result_register_for(x->type()); 3325 CodeEmitInfo* info = state_for(x, x->state_before()); 3326 BasicTypeList signature(2); 3327 signature.append(T_OBJECT); 3328 signature.append(T_OBJECT); 3329 3330 CallingConvention* cc = frame_map()->java_calling_convention(&signature, true); 3331 LIR_OprList* arg_list = cc->args(); 3332 3333 left.set_destroys_register(); 3334 right.set_destroys_register(); 3335 invoke_load_one_argument(&left, arg_list->at(0)); 3336 invoke_load_one_argument(&right, arg_list->at(1)); 3337 __ call_static(subst_method, result, 3338 SharedRuntime::get_resolve_static_call_stub(), 3339 arg_list, info); 3340 __ cmp(lir_cond_notEqual, result, LIR_OprFact::intConst(1)); 3341 } 3342 __ move(not_equal_result, reg); 3343 __ branch(lir_cond_notEqual, T_ILLEGAL, L_end->label()); 3344 3345 __ branch_destination(L_oops_equal->label()); 3346 __ move(equal_result, reg); 3347 3348 __ branch_destination(L_end->label()); 3349 } 3350 3351 #ifdef JFR_HAVE_INTRINSICS 3352 void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) { 3353 CodeEmitInfo* info = state_for(x); 3354 CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check 3355 3356 assert(info != NULL, "must have info"); 3357 LIRItem arg(x->argument_at(0), this); 3358 3359 arg.load_item(); 3360 LIR_Opr klass = new_register(T_METADATA); 3361 __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), klass, info); 3362 LIR_Opr id = new_register(T_LONG); 3363 ByteSize offset = KLASS_TRACE_ID_OFFSET; 3364 LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG); 3365 3366 __ move(trace_id_addr, id); 3367 __ logical_or(id, LIR_OprFact::longConst(0x01l), id); 3368 __ store(id, trace_id_addr); |