< prev index next >

src/share/vm/c1/c1_LIRGenerator.cpp

Print this page




3042 
3043   LIRItem left(x->x(), this);
3044   LIRItem right(x->y(), this);
3045   left.load_item();
3046   if (can_inline_as_constant(right.value())) {
3047     right.dont_load_item();
3048   } else {
3049     right.load_item();
3050   }
3051 
3052   LIRItem t_val(x->tval(), this);
3053   LIRItem f_val(x->fval(), this);
3054   t_val.dont_load_item();
3055   f_val.dont_load_item();
3056   LIR_Opr reg = rlock_result(x);
3057 
3058   __ cmp(lir_cond(x->cond()), left.result(), right.result());
3059   __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
3060 }
3061 













































3062 void LIRGenerator::do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x) {
3063     assert(x->number_of_arguments() == expected_arguments, "wrong type");
3064     LIR_Opr reg = result_register_for(x->type());
3065     __ call_runtime_leaf(routine, getThreadTemp(),
3066                          reg, new LIR_OprList());
3067     LIR_Opr result = rlock_result(x);
3068     __ move(reg, result);
3069 }
3070 
3071 #ifdef TRACE_HAVE_INTRINSICS
3072 void LIRGenerator::do_ThreadIDIntrinsic(Intrinsic* x) {
3073     LIR_Opr thread = getThreadPointer();
3074     LIR_Opr osthread = new_pointer_register();
3075     __ move(new LIR_Address(thread, in_bytes(JavaThread::osthread_offset()), osthread->type()), osthread);
3076     size_t thread_id_size = OSThread::thread_id_size();
3077     if (thread_id_size == (size_t) BytesPerLong) {
3078       LIR_Opr id = new_register(T_LONG);
3079       __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_LONG), id);
3080       __ convert(Bytecodes::_l2i, id, rlock_result(x));
3081     } else if (thread_id_size == (size_t) BytesPerInt) {


3098     ByteSize offset = TRACE_ID_OFFSET;
3099     LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
3100     __ move(trace_id_addr, id);
3101     __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
3102     __ store(id, trace_id_addr);
3103     __ logical_and(id, LIR_OprFact::longConst(~0x3l), id);
3104     __ move(id, rlock_result(x));
3105 }
3106 #endif
3107 
3108 void LIRGenerator::do_Intrinsic(Intrinsic* x) {
3109   switch (x->id()) {
3110   case vmIntrinsics::_intBitsToFloat      :
3111   case vmIntrinsics::_doubleToRawLongBits :
3112   case vmIntrinsics::_longBitsToDouble    :
3113   case vmIntrinsics::_floatToRawIntBits   : {
3114     do_FPIntrinsics(x);
3115     break;
3116   }
3117 
3118 #ifdef TRACE_HAVE_INTRINSICS
3119   case vmIntrinsics::_threadID: do_ThreadIDIntrinsic(x); break;
3120   case vmIntrinsics::_classID: do_ClassIDIntrinsic(x); break;




3121   case vmIntrinsics::_counterTime:
3122     do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), 0, x);
3123     break;
3124 #endif
3125 
3126   case vmIntrinsics::_currentTimeMillis:
3127     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), 0, x);
3128     break;
3129 
3130   case vmIntrinsics::_nanoTime:
3131     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), 0, x);
3132     break;
3133 
3134   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
3135   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
3136   case vmIntrinsics::_getClass:       do_getClass(x);      break;
3137   case vmIntrinsics::_currentThread:  do_currentThread(x); break;
3138 
3139   case vmIntrinsics::_dlog:           // fall through
3140   case vmIntrinsics::_dlog10:         // fall through
3141   case vmIntrinsics::_dabs:           // fall through
3142   case vmIntrinsics::_dsqrt:          // fall through




3042 
3043   LIRItem left(x->x(), this);
3044   LIRItem right(x->y(), this);
3045   left.load_item();
3046   if (can_inline_as_constant(right.value())) {
3047     right.dont_load_item();
3048   } else {
3049     right.load_item();
3050   }
3051 
3052   LIRItem t_val(x->tval(), this);
3053   LIRItem f_val(x->fval(), this);
3054   t_val.dont_load_item();
3055   f_val.dont_load_item();
3056   LIR_Opr reg = rlock_result(x);
3057 
3058   __ cmp(lir_cond(x->cond()), left.result(), right.result());
3059   __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
3060 }
3061 
3062 #ifdef JFR_HAVE_INTRINSICS
3063 void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
3064   CodeEmitInfo* info = state_for(x);
3065   CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check
3066 
3067   assert(info != NULL, "must have info");
3068   LIRItem arg(x->argument_at(0), this);
3069 
3070   arg.load_item();
3071   LIR_Opr klass = new_register(T_METADATA);
3072   __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), klass, info);
3073   LIR_Opr id = new_register(T_LONG);
3074   ByteSize offset = KLASS_TRACE_ID_OFFSET;
3075   LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
3076 
3077   __ move(trace_id_addr, id);
3078   __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
3079   __ store(id, trace_id_addr);
3080 
3081 #ifdef TRACE_ID_META_BITS
3082   __ logical_and(id, LIR_OprFact::longConst(~TRACE_ID_META_BITS), id);
3083 #endif
3084 #ifdef TRACE_ID_SHIFT
3085   __ unsigned_shift_right(id, TRACE_ID_SHIFT, id);
3086 #endif
3087 
3088   __ move(id, rlock_result(x));
3089 }
3090 
3091 void LIRGenerator::do_getEventWriter(Intrinsic* x) {
3092   LabelObj* L_end = new LabelObj();
3093 
3094   LIR_Address* jobj_addr = new LIR_Address(getThreadPointer(),
3095                                            in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR),
3096                                            T_OBJECT);
3097   LIR_Opr result = rlock_result(x);
3098   __ move_wide(jobj_addr, result);
3099   __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
3100   __ branch(lir_cond_equal, T_OBJECT, L_end->label());
3101   __ move_wide(new LIR_Address(result, T_OBJECT), result);
3102 
3103   __ branch_destination(L_end->label());
3104 }
3105 #endif
3106 
3107 void LIRGenerator::do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x) {
3108     assert(x->number_of_arguments() == expected_arguments, "wrong type");
3109     LIR_Opr reg = result_register_for(x->type());
3110     __ call_runtime_leaf(routine, getThreadTemp(),
3111                          reg, new LIR_OprList());
3112     LIR_Opr result = rlock_result(x);
3113     __ move(reg, result);
3114 }
3115 
3116 #ifdef TRACE_HAVE_INTRINSICS
3117 void LIRGenerator::do_ThreadIDIntrinsic(Intrinsic* x) {
3118     LIR_Opr thread = getThreadPointer();
3119     LIR_Opr osthread = new_pointer_register();
3120     __ move(new LIR_Address(thread, in_bytes(JavaThread::osthread_offset()), osthread->type()), osthread);
3121     size_t thread_id_size = OSThread::thread_id_size();
3122     if (thread_id_size == (size_t) BytesPerLong) {
3123       LIR_Opr id = new_register(T_LONG);
3124       __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_LONG), id);
3125       __ convert(Bytecodes::_l2i, id, rlock_result(x));
3126     } else if (thread_id_size == (size_t) BytesPerInt) {


3143     ByteSize offset = TRACE_ID_OFFSET;
3144     LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
3145     __ move(trace_id_addr, id);
3146     __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
3147     __ store(id, trace_id_addr);
3148     __ logical_and(id, LIR_OprFact::longConst(~0x3l), id);
3149     __ move(id, rlock_result(x));
3150 }
3151 #endif
3152 
3153 void LIRGenerator::do_Intrinsic(Intrinsic* x) {
3154   switch (x->id()) {
3155   case vmIntrinsics::_intBitsToFloat      :
3156   case vmIntrinsics::_doubleToRawLongBits :
3157   case vmIntrinsics::_longBitsToDouble    :
3158   case vmIntrinsics::_floatToRawIntBits   : {
3159     do_FPIntrinsics(x);
3160     break;
3161   }
3162 
3163 #ifdef JFR_HAVE_INTRINSICS
3164   case vmIntrinsics::_getClassId:
3165     do_ClassIDIntrinsic(x);
3166     break;
3167   case vmIntrinsics::_getEventWriter:
3168     do_getEventWriter(x);
3169     break;
3170   case vmIntrinsics::_counterTime:
3171     do_RuntimeCall(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), 0, x);
3172     break;
3173 #endif
3174 
3175   case vmIntrinsics::_currentTimeMillis:
3176     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), 0, x);
3177     break;
3178 
3179   case vmIntrinsics::_nanoTime:
3180     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), 0, x);
3181     break;
3182 
3183   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
3184   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
3185   case vmIntrinsics::_getClass:       do_getClass(x);      break;
3186   case vmIntrinsics::_currentThread:  do_currentThread(x); break;
3187 
3188   case vmIntrinsics::_dlog:           // fall through
3189   case vmIntrinsics::_dlog10:         // fall through
3190   case vmIntrinsics::_dabs:           // fall through
3191   case vmIntrinsics::_dsqrt:          // fall through


< prev index next >