src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8022585 Sdiff src/share/vm/opto

src/share/vm/opto/library_call.cpp

Print this page




 526 
 527   // -XX:-InlineUnsafeOps disables natives from the Unsafe class.
 528   if (m->holder()->name() == ciSymbol::sun_misc_Unsafe()) {
 529     if (!InlineUnsafeOps)  return NULL;
 530   }
 531 
 532   return new LibraryIntrinsic(m, is_virtual, is_predicted, (vmIntrinsics::ID) id);
 533 }
 534 
 535 //----------------------register_library_intrinsics-----------------------
 536 // Initialize this file's data structures, for each Compile instance.
 537 void Compile::register_library_intrinsics() {
 538   // Nothing to do here.
 539 }
 540 
 541 JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
 542   LibraryCallKit kit(jvms, this);
 543   Compile* C = kit.C;
 544   int nodes = C->unique();
 545 #ifndef PRODUCT
 546   if ((PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) && Verbose) {
 547     char buf[1000];
 548     const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
 549     tty->print_cr("Intrinsic %s", str);
 550   }
 551 #endif
 552   ciMethod* callee = kit.callee();
 553   const int bci    = kit.bci();
 554 
 555   // Try to inline the intrinsic.
 556   if (kit.try_to_inline()) {
 557     if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
 558       C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
 559     }
 560     C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
 561     if (C->log()) {
 562       C->log()->elem("intrinsic id='%s'%s nodes='%d'",
 563                      vmIntrinsics::name_at(intrinsic_id()),
 564                      (is_virtual() ? " virtual='1'" : ""),
 565                      C->unique() - nodes);
 566     }
 567     // Push the result from the inlined method onto the stack.
 568     kit.push_result();
 569     return kit.transfer_exceptions_into_jvms();
 570   }
 571 
 572   // The intrinsic bailed out
 573   if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
 574     if (jvms->has_method()) {
 575       // Not a root compile.
 576       const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
 577       C->print_inlining(callee, jvms->depth() - 1, bci, msg);
 578     } else {
 579       // Root compile
 580       tty->print("Did not generate intrinsic %s%s at bci:%d in",
 581                vmIntrinsics::name_at(intrinsic_id()),
 582                (is_virtual() ? " (virtual)" : ""), bci);
 583     }
 584   }
 585   C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
 586   return NULL;
 587 }
 588 
 589 Node* LibraryIntrinsic::generate_predicate(JVMState* jvms) {
 590   LibraryCallKit kit(jvms, this);
 591   Compile* C = kit.C;
 592   int nodes = C->unique();
 593 #ifndef PRODUCT
 594   assert(is_predicted(), "sanity");
 595   if ((PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) && Verbose) {
 596     char buf[1000];
 597     const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
 598     tty->print_cr("Predicate for intrinsic %s", str);
 599   }
 600 #endif
 601   ciMethod* callee = kit.callee();
 602   const int bci    = kit.bci();
 603 
 604   Node* slow_ctl = kit.try_to_predicate();
 605   if (!kit.failing()) {
 606     if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
 607       C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
 608     }
 609     C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
 610     if (C->log()) {
 611       C->log()->elem("predicate_intrinsic id='%s'%s nodes='%d'",
 612                      vmIntrinsics::name_at(intrinsic_id()),
 613                      (is_virtual() ? " virtual='1'" : ""),
 614                      C->unique() - nodes);
 615     }
 616     return slow_ctl; // Could be NULL if the check folds.
 617   }
 618 
 619   // The intrinsic bailed out
 620   if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
 621     if (jvms->has_method()) {
 622       // Not a root compile.
 623       const char* msg = "failed to generate predicate for intrinsic";
 624       C->print_inlining(kit.callee(), jvms->depth() - 1, bci, msg);
 625     } else {
 626       // Root compile
 627       C->print_inlining_stream()->print("Did not generate predicate for intrinsic %s%s at bci:%d in",
 628                                         vmIntrinsics::name_at(intrinsic_id()),
 629                                         (is_virtual() ? " (virtual)" : ""), bci);
 630     }
 631   }
 632   C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
 633   return NULL;
 634 }
 635 
 636 bool LibraryCallKit::try_to_inline() {
 637   // Handle symbolic names for otherwise undistinguished boolean switches:
 638   const bool is_store       = true;
 639   const bool is_native_ptr  = true;
 640   const bool is_static      = true;


2282       sharpened_klass = alias_type->field()->type()->as_klass();
2283     }
2284   }
2285 
2286   // See if it is a narrow oop array.
2287   if (adr_type->isa_aryptr()) {
2288     if (adr_type->offset() >= objArrayOopDesc::base_offset_in_bytes()) {
2289       const TypeOopPtr *elem_type = adr_type->is_aryptr()->elem()->isa_oopptr();
2290       if (elem_type != NULL) {
2291         sharpened_klass = elem_type->klass();
2292       }
2293     }
2294   }
2295 
2296   // The sharpened class might be unloaded if there is no class loader
2297   // contraint in place.
2298   if (sharpened_klass != NULL && sharpened_klass->is_loaded()) {
2299     const TypeOopPtr* tjp = TypeOopPtr::make_from_klass(sharpened_klass);
2300 
2301 #ifndef PRODUCT
2302     if (PrintIntrinsics || PrintInlining || PrintOptoInlining) {
2303       tty->print("  from base type: ");  adr_type->dump();
2304       tty->print("  sharpened value: ");  tjp->dump();
2305     }
2306 #endif
2307     // Sharpen the value type.
2308     return tjp;
2309   }
2310   return NULL;
2311 }
2312 
2313 bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile) {
2314   if (callee()->is_static())  return false;  // caller must have the capability!
2315 
2316 #ifndef PRODUCT
2317   {
2318     ResourceMark rm;
2319     // Check the signatures.
2320     ciSignature* sig = callee()->signature();
2321 #ifdef ASSERT
2322     if (!is_store) {


3243     prim_return_value = null();
3244     return_type = TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR);
3245     break;
3246   case vmIntrinsics::_getComponentType:
3247     prim_return_value = null();
3248     return_type = TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR);
3249     break;
3250   case vmIntrinsics::_getClassAccessFlags:
3251     prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC);
3252     return_type = TypeInt::INT;  // not bool!  6297094
3253     break;
3254   default:
3255     fatal_unexpected_iid(id);
3256     break;
3257   }
3258 
3259   const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr();
3260   if (mirror_con == NULL)  return false;  // cannot happen?
3261 
3262 #ifndef PRODUCT
3263   if (PrintIntrinsics || PrintInlining || PrintOptoInlining) {
3264     ciType* k = mirror_con->java_mirror_type();
3265     if (k) {
3266       tty->print("Inlining %s on constant Class ", vmIntrinsics::name_at(intrinsic_id()));
3267       k->print_name();
3268       tty->cr();
3269     }
3270   }
3271 #endif
3272 
3273   // Null-check the mirror, and the mirror's klass ptr (in case it is a primitive).
3274   RegionNode* region = new (C) RegionNode(PATH_LIMIT);
3275   record_for_igvn(region);
3276   PhiNode* phi = new (C) PhiNode(region, return_type);
3277 
3278   // The mirror will never be null of Reflection.getClassAccessFlags, however
3279   // it may be null for Class.isInstance or Class.getModifiers. Throw a NPE
3280   // if it is. See bug 4774291.
3281 
3282   // For Reflection.getClassAccessFlags(), the null check occurs in
3283   // the wrong place; see inline_unsafe_access(), above, for a similar


3935 // public final native Class<?> java.lang.Object.getClass();
3936 //
3937 // Build special case code for calls to getClass on an object.
3938 bool LibraryCallKit::inline_native_getClass() {
3939   Node* obj = null_check_receiver();
3940   if (stopped())  return true;
3941   set_result(load_mirror_from_klass(load_object_klass(obj)));
3942   return true;
3943 }
3944 
3945 //-----------------inline_native_Reflection_getCallerClass---------------------
3946 // public static native Class<?> sun.reflect.Reflection.getCallerClass();
3947 //
3948 // In the presence of deep enough inlining, getCallerClass() becomes a no-op.
3949 //
3950 // NOTE: This code must perform the same logic as JVM_GetCallerClass
3951 // in that it must skip particular security frames and checks for
3952 // caller sensitive methods.
3953 bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
3954 #ifndef PRODUCT
3955   if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
3956     tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass");
3957   }
3958 #endif
3959 
3960   if (!jvms()->has_method()) {
3961 #ifndef PRODUCT
3962     if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
3963       tty->print_cr("  Bailing out because intrinsic was inlined at top level");
3964     }
3965 #endif
3966     return false;
3967   }
3968 
3969   // Walk back up the JVM state to find the caller at the required
3970   // depth.
3971   JVMState* caller_jvms = jvms();
3972 
3973   // Cf. JVM_GetCallerClass
3974   // NOTE: Start the loop at depth 1 because the current JVM state does
3975   // not include the Reflection.getCallerClass() frame.
3976   for (int n = 1; caller_jvms != NULL; caller_jvms = caller_jvms->caller(), n++) {
3977     ciMethod* m = caller_jvms->method();
3978     switch (n) {
3979     case 0:
3980       fatal("current JVM state does not include the Reflection.getCallerClass frame");
3981       break;
3982     case 1:
3983       // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).
3984       if (!m->caller_sensitive()) {
3985 #ifndef PRODUCT
3986         if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
3987           tty->print_cr("  Bailing out: CallerSensitive annotation expected at frame %d", n);
3988         }
3989 #endif
3990         return false;  // bail-out; let JVM_GetCallerClass do the work
3991       }
3992       break;
3993     default:
3994       if (!m->is_ignored_by_security_stack_walk()) {
3995         // We have reached the desired frame; return the holder class.
3996         // Acquire method holder as java.lang.Class and push as constant.
3997         ciInstanceKlass* caller_klass = caller_jvms->method()->holder();
3998         ciInstance* caller_mirror = caller_klass->java_mirror();
3999         set_result(makecon(TypeInstPtr::make(caller_mirror)));
4000 
4001 #ifndef PRODUCT
4002         if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
4003           tty->print_cr("  Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth());
4004           tty->print_cr("  JVM state at this point:");
4005           for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
4006             ciMethod* m = jvms()->of_depth(i)->method();
4007             tty->print_cr("   %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8());
4008           }
4009         }
4010 #endif
4011         return true;
4012       }
4013       break;
4014     }
4015   }
4016 
4017 #ifndef PRODUCT
4018   if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
4019     tty->print_cr("  Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth());
4020     tty->print_cr("  JVM state at this point:");
4021     for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
4022       ciMethod* m = jvms()->of_depth(i)->method();
4023       tty->print_cr("   %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8());
4024     }
4025   }
4026 #endif
4027 
4028   return false;  // bail-out; let JVM_GetCallerClass do the work
4029 }
4030 
4031 bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) {
4032   Node* arg = argument(0);
4033   Node* result;
4034 
4035   switch (id) {
4036   case vmIntrinsics::_floatToRawIntBits:    result = new (C) MoveF2INode(arg);  break;
4037   case vmIntrinsics::_intBitsToFloat:       result = new (C) MoveI2FNode(arg);  break;
4038   case vmIntrinsics::_doubleToRawLongBits:  result = new (C) MoveD2LNode(arg);  break;




 526 
 527   // -XX:-InlineUnsafeOps disables natives from the Unsafe class.
 528   if (m->holder()->name() == ciSymbol::sun_misc_Unsafe()) {
 529     if (!InlineUnsafeOps)  return NULL;
 530   }
 531 
 532   return new LibraryIntrinsic(m, is_virtual, is_predicted, (vmIntrinsics::ID) id);
 533 }
 534 
 535 //----------------------register_library_intrinsics-----------------------
 536 // Initialize this file's data structures, for each Compile instance.
 537 void Compile::register_library_intrinsics() {
 538   // Nothing to do here.
 539 }
 540 
 541 JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
 542   LibraryCallKit kit(jvms, this);
 543   Compile* C = kit.C;
 544   int nodes = C->unique();
 545 #ifndef PRODUCT
 546   if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
 547     char buf[1000];
 548     const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
 549     tty->print_cr("Intrinsic %s", str);
 550   }
 551 #endif
 552   ciMethod* callee = kit.callee();
 553   const int bci    = kit.bci();
 554 
 555   // Try to inline the intrinsic.
 556   if (kit.try_to_inline()) {
 557     if (C->print_intrinsics() || C->print_inlining()) {
 558       C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
 559     }
 560     C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
 561     if (C->log()) {
 562       C->log()->elem("intrinsic id='%s'%s nodes='%d'",
 563                      vmIntrinsics::name_at(intrinsic_id()),
 564                      (is_virtual() ? " virtual='1'" : ""),
 565                      C->unique() - nodes);
 566     }
 567     // Push the result from the inlined method onto the stack.
 568     kit.push_result();
 569     return kit.transfer_exceptions_into_jvms();
 570   }
 571 
 572   // The intrinsic bailed out
 573   if (C->print_intrinsics() || C->print_inlining()) {
 574     if (jvms->has_method()) {
 575       // Not a root compile.
 576       const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
 577       C->print_inlining(callee, jvms->depth() - 1, bci, msg);
 578     } else {
 579       // Root compile
 580       tty->print("Did not generate intrinsic %s%s at bci:%d in",
 581                vmIntrinsics::name_at(intrinsic_id()),
 582                (is_virtual() ? " (virtual)" : ""), bci);
 583     }
 584   }
 585   C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
 586   return NULL;
 587 }
 588 
 589 Node* LibraryIntrinsic::generate_predicate(JVMState* jvms) {
 590   LibraryCallKit kit(jvms, this);
 591   Compile* C = kit.C;
 592   int nodes = C->unique();
 593 #ifndef PRODUCT
 594   assert(is_predicted(), "sanity");
 595   if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
 596     char buf[1000];
 597     const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
 598     tty->print_cr("Predicate for intrinsic %s", str);
 599   }
 600 #endif
 601   ciMethod* callee = kit.callee();
 602   const int bci    = kit.bci();
 603 
 604   Node* slow_ctl = kit.try_to_predicate();
 605   if (!kit.failing()) {
 606     if (C->print_intrinsics() || C->print_inlining()) {
 607       C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
 608     }
 609     C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
 610     if (C->log()) {
 611       C->log()->elem("predicate_intrinsic id='%s'%s nodes='%d'",
 612                      vmIntrinsics::name_at(intrinsic_id()),
 613                      (is_virtual() ? " virtual='1'" : ""),
 614                      C->unique() - nodes);
 615     }
 616     return slow_ctl; // Could be NULL if the check folds.
 617   }
 618 
 619   // The intrinsic bailed out
 620   if (C->print_intrinsics() || C->print_inlining()) {
 621     if (jvms->has_method()) {
 622       // Not a root compile.
 623       const char* msg = "failed to generate predicate for intrinsic";
 624       C->print_inlining(kit.callee(), jvms->depth() - 1, bci, msg);
 625     } else {
 626       // Root compile
 627       C->print_inlining_stream()->print("Did not generate predicate for intrinsic %s%s at bci:%d in",
 628                                         vmIntrinsics::name_at(intrinsic_id()),
 629                                         (is_virtual() ? " (virtual)" : ""), bci);
 630     }
 631   }
 632   C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
 633   return NULL;
 634 }
 635 
 636 bool LibraryCallKit::try_to_inline() {
 637   // Handle symbolic names for otherwise undistinguished boolean switches:
 638   const bool is_store       = true;
 639   const bool is_native_ptr  = true;
 640   const bool is_static      = true;


2282       sharpened_klass = alias_type->field()->type()->as_klass();
2283     }
2284   }
2285 
2286   // See if it is a narrow oop array.
2287   if (adr_type->isa_aryptr()) {
2288     if (adr_type->offset() >= objArrayOopDesc::base_offset_in_bytes()) {
2289       const TypeOopPtr *elem_type = adr_type->is_aryptr()->elem()->isa_oopptr();
2290       if (elem_type != NULL) {
2291         sharpened_klass = elem_type->klass();
2292       }
2293     }
2294   }
2295 
2296   // The sharpened class might be unloaded if there is no class loader
2297   // contraint in place.
2298   if (sharpened_klass != NULL && sharpened_klass->is_loaded()) {
2299     const TypeOopPtr* tjp = TypeOopPtr::make_from_klass(sharpened_klass);
2300 
2301 #ifndef PRODUCT
2302     if (C->print_intrinsics() || C->print_inlining()) {
2303       tty->print("  from base type: ");  adr_type->dump();
2304       tty->print("  sharpened value: ");  tjp->dump();
2305     }
2306 #endif
2307     // Sharpen the value type.
2308     return tjp;
2309   }
2310   return NULL;
2311 }
2312 
2313 bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile) {
2314   if (callee()->is_static())  return false;  // caller must have the capability!
2315 
2316 #ifndef PRODUCT
2317   {
2318     ResourceMark rm;
2319     // Check the signatures.
2320     ciSignature* sig = callee()->signature();
2321 #ifdef ASSERT
2322     if (!is_store) {


3243     prim_return_value = null();
3244     return_type = TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR);
3245     break;
3246   case vmIntrinsics::_getComponentType:
3247     prim_return_value = null();
3248     return_type = TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR);
3249     break;
3250   case vmIntrinsics::_getClassAccessFlags:
3251     prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC);
3252     return_type = TypeInt::INT;  // not bool!  6297094
3253     break;
3254   default:
3255     fatal_unexpected_iid(id);
3256     break;
3257   }
3258 
3259   const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr();
3260   if (mirror_con == NULL)  return false;  // cannot happen?
3261 
3262 #ifndef PRODUCT
3263   if (C->print_intrinsics() || C->print_inlining()) {
3264     ciType* k = mirror_con->java_mirror_type();
3265     if (k) {
3266       tty->print("Inlining %s on constant Class ", vmIntrinsics::name_at(intrinsic_id()));
3267       k->print_name();
3268       tty->cr();
3269     }
3270   }
3271 #endif
3272 
3273   // Null-check the mirror, and the mirror's klass ptr (in case it is a primitive).
3274   RegionNode* region = new (C) RegionNode(PATH_LIMIT);
3275   record_for_igvn(region);
3276   PhiNode* phi = new (C) PhiNode(region, return_type);
3277 
3278   // The mirror will never be null of Reflection.getClassAccessFlags, however
3279   // it may be null for Class.isInstance or Class.getModifiers. Throw a NPE
3280   // if it is. See bug 4774291.
3281 
3282   // For Reflection.getClassAccessFlags(), the null check occurs in
3283   // the wrong place; see inline_unsafe_access(), above, for a similar


3935 // public final native Class<?> java.lang.Object.getClass();
3936 //
3937 // Build special case code for calls to getClass on an object.
3938 bool LibraryCallKit::inline_native_getClass() {
3939   Node* obj = null_check_receiver();
3940   if (stopped())  return true;
3941   set_result(load_mirror_from_klass(load_object_klass(obj)));
3942   return true;
3943 }
3944 
3945 //-----------------inline_native_Reflection_getCallerClass---------------------
3946 // public static native Class<?> sun.reflect.Reflection.getCallerClass();
3947 //
3948 // In the presence of deep enough inlining, getCallerClass() becomes a no-op.
3949 //
3950 // NOTE: This code must perform the same logic as JVM_GetCallerClass
3951 // in that it must skip particular security frames and checks for
3952 // caller sensitive methods.
3953 bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
3954 #ifndef PRODUCT
3955   if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
3956     tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass");
3957   }
3958 #endif
3959 
3960   if (!jvms()->has_method()) {
3961 #ifndef PRODUCT
3962     if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
3963       tty->print_cr("  Bailing out because intrinsic was inlined at top level");
3964     }
3965 #endif
3966     return false;
3967   }
3968 
3969   // Walk back up the JVM state to find the caller at the required
3970   // depth.
3971   JVMState* caller_jvms = jvms();
3972 
3973   // Cf. JVM_GetCallerClass
3974   // NOTE: Start the loop at depth 1 because the current JVM state does
3975   // not include the Reflection.getCallerClass() frame.
3976   for (int n = 1; caller_jvms != NULL; caller_jvms = caller_jvms->caller(), n++) {
3977     ciMethod* m = caller_jvms->method();
3978     switch (n) {
3979     case 0:
3980       fatal("current JVM state does not include the Reflection.getCallerClass frame");
3981       break;
3982     case 1:
3983       // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).
3984       if (!m->caller_sensitive()) {
3985 #ifndef PRODUCT
3986         if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
3987           tty->print_cr("  Bailing out: CallerSensitive annotation expected at frame %d", n);
3988         }
3989 #endif
3990         return false;  // bail-out; let JVM_GetCallerClass do the work
3991       }
3992       break;
3993     default:
3994       if (!m->is_ignored_by_security_stack_walk()) {
3995         // We have reached the desired frame; return the holder class.
3996         // Acquire method holder as java.lang.Class and push as constant.
3997         ciInstanceKlass* caller_klass = caller_jvms->method()->holder();
3998         ciInstance* caller_mirror = caller_klass->java_mirror();
3999         set_result(makecon(TypeInstPtr::make(caller_mirror)));
4000 
4001 #ifndef PRODUCT
4002         if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
4003           tty->print_cr("  Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth());
4004           tty->print_cr("  JVM state at this point:");
4005           for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
4006             ciMethod* m = jvms()->of_depth(i)->method();
4007             tty->print_cr("   %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8());
4008           }
4009         }
4010 #endif
4011         return true;
4012       }
4013       break;
4014     }
4015   }
4016 
4017 #ifndef PRODUCT
4018   if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
4019     tty->print_cr("  Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth());
4020     tty->print_cr("  JVM state at this point:");
4021     for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
4022       ciMethod* m = jvms()->of_depth(i)->method();
4023       tty->print_cr("   %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8());
4024     }
4025   }
4026 #endif
4027 
4028   return false;  // bail-out; let JVM_GetCallerClass do the work
4029 }
4030 
4031 bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) {
4032   Node* arg = argument(0);
4033   Node* result;
4034 
4035   switch (id) {
4036   case vmIntrinsics::_floatToRawIntBits:    result = new (C) MoveF2INode(arg);  break;
4037   case vmIntrinsics::_intBitsToFloat:       result = new (C) MoveI2FNode(arg);  break;
4038   case vmIntrinsics::_doubleToRawLongBits:  result = new (C) MoveD2LNode(arg);  break;


src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File