322 // These also use the arraycopy intrinsic mechanism: 323 if (!InlineArrayCopy) return NULL; 324 break; 325 case vmIntrinsics::_checkIndex: 326 // We do not intrinsify this. The optimizer does fine with it. 327 return NULL; 328 329 case vmIntrinsics::_get_AtomicLong: 330 case vmIntrinsics::_attemptUpdate: 331 if (!InlineAtomicLong) return NULL; 332 break; 333 334 case vmIntrinsics::_getCallerClass: 335 if (!UseNewReflection) return NULL; 336 if (!InlineReflectionGetCallerClass) return NULL; 337 if (!JDK_Version::is_gte_jdk14x_version()) return NULL; 338 break; 339 340 case vmIntrinsics::_bitCount_i: 341 case vmIntrinsics::_bitCount_l: 342 if (!UsePopCountInstruction) return NULL; 343 break; 344 345 case vmIntrinsics::_Reference_get: 346 // It is only when G1 is enabled that we absolutely 347 // need to use the intrinsic version of Reference.get() 348 // so that the value in the referent field, if necessary, 349 // can be registered by the pre-barrier code. 350 if (!UseG1GC) return NULL; 351 break; 352 353 default: 354 assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility"); 355 assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?"); 356 break; 357 } 358 359 // -XX:-InlineClassNatives disables natives from the Class class. 360 // The flag applies to all reflective calls, notably Array.newArray 361 // (visible to Java programmers as Array.newInstance). 399 char buf[1000]; 400 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); 401 tty->print_cr("Intrinsic %s", str); 402 } 403 #endif 404 405 if (kit.try_to_inline()) { 406 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { 407 CompileTask::print_inlining(kit.callee(), jvms->depth() - 1, kit.bci(), is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); 408 } 409 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); 410 if (C->log()) { 411 C->log()->elem("intrinsic id='%s'%s nodes='%d'", 412 vmIntrinsics::name_at(intrinsic_id()), 413 (is_virtual() ? " virtual='1'" : ""), 414 C->unique() - nodes); 415 } 416 return kit.transfer_exceptions_into_jvms(); 417 } 418 419 if (PrintIntrinsics) { 420 if (jvms->has_method()) { 421 // Not a root compile. 422 tty->print("Did not inline intrinsic %s%s at bci:%d in", 423 vmIntrinsics::name_at(intrinsic_id()), 424 (is_virtual() ? " (virtual)" : ""), kit.bci()); 425 kit.caller()->print_short_name(tty); 426 tty->print_cr(" (%d bytes)", kit.caller()->code_size()); 427 } else { 428 // Root compile 429 tty->print("Did not generate intrinsic %s%s at bci:%d in", 430 vmIntrinsics::name_at(intrinsic_id()), 431 (is_virtual() ? " (virtual)" : ""), kit.bci()); 432 } 433 } 434 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); 435 return NULL; 436 } 437 438 bool LibraryCallKit::try_to_inline() { 439 // Handle symbolic names for otherwise undistinguished boolean switches: 440 const bool is_store = true; 441 const bool is_native_ptr = true; 442 const bool is_static = true; 443 444 if (!jvms()->has_method()) { 445 // Root JVMState has a null method. 446 assert(map()->memory()->Opcode() == Op_Parm, ""); | 322 // These also use the arraycopy intrinsic mechanism: 323 if (!InlineArrayCopy) return NULL; 324 break; 325 case vmIntrinsics::_checkIndex: 326 // We do not intrinsify this. The optimizer does fine with it. 327 return NULL; 328 329 case vmIntrinsics::_get_AtomicLong: 330 case vmIntrinsics::_attemptUpdate: 331 if (!InlineAtomicLong) return NULL; 332 break; 333 334 case vmIntrinsics::_getCallerClass: 335 if (!UseNewReflection) return NULL; 336 if (!InlineReflectionGetCallerClass) return NULL; 337 if (!JDK_Version::is_gte_jdk14x_version()) return NULL; 338 break; 339 340 case vmIntrinsics::_bitCount_i: 341 case vmIntrinsics::_bitCount_l: 342 #ifdef SPARC 343 // On sparc these depend on the popcount instruction 344 // On x86 these intrinsics always exist but may use bsr 345 case vmIntrinsics::_numberOfLeadingZeros_i: 346 case vmIntrinsics::_numberOfLeadingZeros_l: 347 case vmIntrinsics::_numberOfTrailingZeros_i: 348 case vmIntrinsics::_numberOfTrailingZeros_l: 349 #endif 350 if (!UsePopCountInstruction) return NULL; 351 break; 352 353 case vmIntrinsics::_Reference_get: 354 // It is only when G1 is enabled that we absolutely 355 // need to use the intrinsic version of Reference.get() 356 // so that the value in the referent field, if necessary, 357 // can be registered by the pre-barrier code. 358 if (!UseG1GC) return NULL; 359 break; 360 361 default: 362 assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility"); 363 assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?"); 364 break; 365 } 366 367 // -XX:-InlineClassNatives disables natives from the Class class. 368 // The flag applies to all reflective calls, notably Array.newArray 369 // (visible to Java programmers as Array.newInstance). 407 char buf[1000]; 408 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); 409 tty->print_cr("Intrinsic %s", str); 410 } 411 #endif 412 413 if (kit.try_to_inline()) { 414 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { 415 CompileTask::print_inlining(kit.callee(), jvms->depth() - 1, kit.bci(), is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); 416 } 417 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); 418 if (C->log()) { 419 C->log()->elem("intrinsic id='%s'%s nodes='%d'", 420 vmIntrinsics::name_at(intrinsic_id()), 421 (is_virtual() ? " virtual='1'" : ""), 422 C->unique() - nodes); 423 } 424 return kit.transfer_exceptions_into_jvms(); 425 } 426 427 // The intrinsic bailed out 428 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { 429 const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)"; 430 if (jvms->has_method()) { 431 // Not a root compile. 432 CompileTask::print_inlining(kit.callee(), jvms->depth() - 1, kit.bci(), msg); 433 } else { 434 // Root compile 435 tty->print("Did not generate intrinsic %s%s at bci:%d in", 436 vmIntrinsics::name_at(intrinsic_id()), 437 (is_virtual() ? " (virtual)" : ""), kit.bci()); 438 } 439 } 440 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); 441 return NULL; 442 } 443 444 bool LibraryCallKit::try_to_inline() { 445 // Handle symbolic names for otherwise undistinguished boolean switches: 446 const bool is_store = true; 447 const bool is_native_ptr = true; 448 const bool is_static = true; 449 450 if (!jvms()->has_method()) { 451 // Root JVMState has a null method. 452 assert(map()->memory()->Opcode() == Op_Parm, ""); |