79 // MarkSweep::invoke(0, "Debugging"); 80 // 81 // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000 82 83 84 85 86 // Compiled code entry points 87 address OptoRuntime::_new_instance_Java = NULL; 88 address OptoRuntime::_new_array_Java = NULL; 89 address OptoRuntime::_new_array_nozero_Java = NULL; 90 address OptoRuntime::_multianewarray2_Java = NULL; 91 address OptoRuntime::_multianewarray3_Java = NULL; 92 address OptoRuntime::_multianewarray4_Java = NULL; 93 address OptoRuntime::_multianewarray5_Java = NULL; 94 address OptoRuntime::_multianewarrayN_Java = NULL; 95 address OptoRuntime::_g1_wb_pre_Java = NULL; 96 address OptoRuntime::_g1_wb_post_Java = NULL; 97 address OptoRuntime::_vtable_must_compile_Java = NULL; 98 address OptoRuntime::_complete_monitor_locking_Java = NULL; 99 address OptoRuntime::_rethrow_Java = NULL; 100 101 address OptoRuntime::_slow_arraycopy_Java = NULL; 102 address OptoRuntime::_register_finalizer_Java = NULL; 103 104 # ifdef ENABLE_ZAP_DEAD_LOCALS 105 address OptoRuntime::_zap_dead_Java_locals_Java = NULL; 106 address OptoRuntime::_zap_dead_native_locals_Java = NULL; 107 # endif 108 109 ExceptionBlob* OptoRuntime::_exception_blob; 110 111 // This should be called in an assertion at the start of OptoRuntime routines 112 // which are entered from compiled code (all of them) 113 #ifdef ASSERT 114 static bool check_compiled_frame(JavaThread* thread) { 115 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code"); 116 RegisterMap map(thread, false); 117 frame caller = thread->last_frame().sender(&map); 118 assert(caller.is_compiled_frame(), "not being called from compiled like code"); 127 128 bool OptoRuntime::generate(ciEnv* env) { 129 130 generate_exception_blob(); 131 132 // Note: tls: Means fetching the return oop out of the thread-local storage 133 // 134 // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc 135 // ------------------------------------------------------------------------------------------------------------------------------- 136 gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false); 137 gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false); 138 gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false); 139 gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false); 140 gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false); 141 gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false); 142 gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false); 143 gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false); 144 gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false); 145 gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false); 146 gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false); 147 gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true ); 148 149 gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false); 150 gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false); 151 152 # ifdef ENABLE_ZAP_DEAD_LOCALS 153 gen(env, _zap_dead_Java_locals_Java , zap_dead_locals_Type , zap_dead_Java_locals_C , 0 , false, true , false ); 154 gen(env, _zap_dead_native_locals_Java , zap_dead_locals_Type , zap_dead_native_locals_C , 0 , false, true , false ); 155 # endif 156 return true; 157 } 158 159 #undef gen 160 161 162 // Helper method to do generation of RunTimeStub's 163 address OptoRuntime::generate_stub( ciEnv* env, 164 TypeFunc_generator gen, address C_function, 165 const char *name, int is_fancy_jump, 166 bool pass_tls, 409 thread->set_vm_result(obj); 410 JRT_END 411 412 JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread)) 413 assert(check_compiled_frame(thread), "incorrect caller"); 414 assert(elem_type->is_klass(), "not a class"); 415 assert(oop(dims)->is_typeArray(), "not an array"); 416 417 ResourceMark rm; 418 jint len = dims->length(); 419 assert(len > 0, "Dimensions array should contain data"); 420 jint *j_dims = typeArrayOop(dims)->int_at_addr(0); 421 jint *c_dims = NEW_RESOURCE_ARRAY(jint, len); 422 Copy::conjoint_jints_atomic(j_dims, c_dims, len); 423 424 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD); 425 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); 426 thread->set_vm_result(obj); 427 JRT_END 428 429 430 const TypeFunc *OptoRuntime::new_instance_Type() { 431 // create input type (domain) 432 const Type **fields = TypeTuple::fields(1); 433 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated 434 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 435 436 // create result type (range) 437 fields = TypeTuple::fields(1); 438 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop 439 440 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 441 442 return TypeFunc::make(domain, range); 443 } 444 445 446 const TypeFunc *OptoRuntime::athrow_Type() { 447 // create input type (domain) 448 const Type **fields = TypeTuple::fields(1); 449 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated 587 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 588 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock 589 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 590 591 // create result type (range) 592 fields = TypeTuple::fields(0); 593 594 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 595 596 return TypeFunc::make(domain,range); 597 } 598 599 600 //----------------------------------------------------------------------------- 601 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { 602 // create input type (domain) 603 const Type **fields = TypeTuple::fields(3); 604 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 605 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock - BasicLock 606 fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM; // Thread pointer (Self) 607 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3,fields); 608 609 // create result type (range) 610 fields = TypeTuple::fields(0); 611 612 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 613 614 return TypeFunc::make(domain,range); 615 } 616 617 const TypeFunc* OptoRuntime::flush_windows_Type() { 618 // create input type (domain) 619 const Type** fields = TypeTuple::fields(1); 620 fields[TypeFunc::Parms+0] = NULL; // void 621 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); 622 623 // create result type 624 fields = TypeTuple::fields(1); 625 fields[TypeFunc::Parms+0] = NULL; // void 626 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 627 628 return TypeFunc::make(domain, range); 629 } 630 631 const TypeFunc* OptoRuntime::l2f_Type() { 632 // create input type (domain) 633 const Type **fields = TypeTuple::fields(2); 634 fields[TypeFunc::Parms+0] = TypeLong::LONG; 635 fields[TypeFunc::Parms+1] = Type::HALF; 636 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); | 79 // MarkSweep::invoke(0, "Debugging"); 80 // 81 // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000 82 83 84 85 86 // Compiled code entry points 87 address OptoRuntime::_new_instance_Java = NULL; 88 address OptoRuntime::_new_array_Java = NULL; 89 address OptoRuntime::_new_array_nozero_Java = NULL; 90 address OptoRuntime::_multianewarray2_Java = NULL; 91 address OptoRuntime::_multianewarray3_Java = NULL; 92 address OptoRuntime::_multianewarray4_Java = NULL; 93 address OptoRuntime::_multianewarray5_Java = NULL; 94 address OptoRuntime::_multianewarrayN_Java = NULL; 95 address OptoRuntime::_g1_wb_pre_Java = NULL; 96 address OptoRuntime::_g1_wb_post_Java = NULL; 97 address OptoRuntime::_vtable_must_compile_Java = NULL; 98 address OptoRuntime::_complete_monitor_locking_Java = NULL; 99 address OptoRuntime::_monitor_notify_Java = NULL; 100 address OptoRuntime::_monitor_notifyAll_Java = NULL; 101 address OptoRuntime::_rethrow_Java = NULL; 102 103 address OptoRuntime::_slow_arraycopy_Java = NULL; 104 address OptoRuntime::_register_finalizer_Java = NULL; 105 106 # ifdef ENABLE_ZAP_DEAD_LOCALS 107 address OptoRuntime::_zap_dead_Java_locals_Java = NULL; 108 address OptoRuntime::_zap_dead_native_locals_Java = NULL; 109 # endif 110 111 ExceptionBlob* OptoRuntime::_exception_blob; 112 113 // This should be called in an assertion at the start of OptoRuntime routines 114 // which are entered from compiled code (all of them) 115 #ifdef ASSERT 116 static bool check_compiled_frame(JavaThread* thread) { 117 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code"); 118 RegisterMap map(thread, false); 119 frame caller = thread->last_frame().sender(&map); 120 assert(caller.is_compiled_frame(), "not being called from compiled like code"); 129 130 bool OptoRuntime::generate(ciEnv* env) { 131 132 generate_exception_blob(); 133 134 // Note: tls: Means fetching the return oop out of the thread-local storage 135 // 136 // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc 137 // ------------------------------------------------------------------------------------------------------------------------------- 138 gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false); 139 gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false); 140 gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false); 141 gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false); 142 gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false); 143 gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false); 144 gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false); 145 gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false); 146 gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false); 147 gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false); 148 gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false); 149 gen(env, _monitor_notify_Java , monitor_notify_Type , monitor_notify_C , 0 , false, false, false); 150 gen(env, _monitor_notifyAll_Java , monitor_notify_Type , monitor_notifyAll_C , 0 , false, false, false); 151 gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true ); 152 153 gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false); 154 gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false); 155 156 # ifdef ENABLE_ZAP_DEAD_LOCALS 157 gen(env, _zap_dead_Java_locals_Java , zap_dead_locals_Type , zap_dead_Java_locals_C , 0 , false, true , false ); 158 gen(env, _zap_dead_native_locals_Java , zap_dead_locals_Type , zap_dead_native_locals_C , 0 , false, true , false ); 159 # endif 160 return true; 161 } 162 163 #undef gen 164 165 166 // Helper method to do generation of RunTimeStub's 167 address OptoRuntime::generate_stub( ciEnv* env, 168 TypeFunc_generator gen, address C_function, 169 const char *name, int is_fancy_jump, 170 bool pass_tls, 413 thread->set_vm_result(obj); 414 JRT_END 415 416 JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread)) 417 assert(check_compiled_frame(thread), "incorrect caller"); 418 assert(elem_type->is_klass(), "not a class"); 419 assert(oop(dims)->is_typeArray(), "not an array"); 420 421 ResourceMark rm; 422 jint len = dims->length(); 423 assert(len > 0, "Dimensions array should contain data"); 424 jint *j_dims = typeArrayOop(dims)->int_at_addr(0); 425 jint *c_dims = NEW_RESOURCE_ARRAY(jint, len); 426 Copy::conjoint_jints_atomic(j_dims, c_dims, len); 427 428 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD); 429 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); 430 thread->set_vm_result(obj); 431 JRT_END 432 433 // Note that hashCode() deserves the same treatment as notify/notifyAll. 434 // The situation is slightly more complicated since hashCode() is virtual, 435 // requiring guards, whereas notify/notifyAll are final 436 437 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notify_C(oopDesc* obj, JavaThread *thread)) 438 439 // Very few notify/notifyAll operations find any threads on the waitset, so 440 // the dominant fast-path is to simply return. 441 // Relatedly, it's critical that notify/notifyAll be fast in order to 442 // reduce lock hold times. 443 if (!SafepointSynchronize::is_synchronizing()) { 444 if (ObjectSynchronizer::quick_notify(obj, thread, false)) { 445 return; 446 } 447 } 448 449 // This is the case the fast-path above isn't provisioned to handle. 450 // The fast-path is designed to handle frequently arising cases in an efficient manner. 451 // (The fast-path is just a degenerate variant of the slow-path). 452 // Perform the dreaded state transition and pass control into the slow-path. 453 JRT_BLOCK; 454 Handle h_obj(THREAD, obj); 455 ObjectSynchronizer::notify(h_obj, CHECK); 456 JRT_BLOCK_END; 457 JRT_END 458 459 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notifyAll_C(oopDesc* obj, JavaThread *thread)) 460 461 if (!SafepointSynchronize::is_synchronizing() ) { 462 if (ObjectSynchronizer::quick_notify(obj, thread, true)) { 463 return; 464 } 465 } 466 467 // This is the case the fast-path above isn't provisioned to handle. 468 // The fast-path is designed to handle frequently arising cases in an efficient manner. 469 // (The fast-path is just a degenerate variant of the slow-path). 470 // Perform the dreaded state transition and pass control into the slow-path. 471 JRT_BLOCK; 472 Handle h_obj(THREAD, obj); 473 ObjectSynchronizer::notifyall(h_obj, CHECK); 474 JRT_BLOCK_END; 475 JRT_END 476 477 const TypeFunc *OptoRuntime::new_instance_Type() { 478 // create input type (domain) 479 const Type **fields = TypeTuple::fields(1); 480 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated 481 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 482 483 // create result type (range) 484 fields = TypeTuple::fields(1); 485 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop 486 487 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 488 489 return TypeFunc::make(domain, range); 490 } 491 492 493 const TypeFunc *OptoRuntime::athrow_Type() { 494 // create input type (domain) 495 const Type **fields = TypeTuple::fields(1); 496 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated 634 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 635 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock 636 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 637 638 // create result type (range) 639 fields = TypeTuple::fields(0); 640 641 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 642 643 return TypeFunc::make(domain,range); 644 } 645 646 647 //----------------------------------------------------------------------------- 648 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { 649 // create input type (domain) 650 const Type **fields = TypeTuple::fields(3); 651 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 652 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock - BasicLock 653 fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM; // Thread pointer (Self) 654 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields); 655 656 // create result type (range) 657 fields = TypeTuple::fields(0); 658 659 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 660 661 return TypeFunc::make(domain, range); 662 } 663 664 const TypeFunc *OptoRuntime::monitor_notify_Type() { 665 // create input type (domain) 666 const Type **fields = TypeTuple::fields(1); 667 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 668 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 669 670 // create result type (range) 671 fields = TypeTuple::fields(0); 672 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 673 return TypeFunc::make(domain, range); 674 } 675 676 const TypeFunc* OptoRuntime::flush_windows_Type() { 677 // create input type (domain) 678 const Type** fields = TypeTuple::fields(1); 679 fields[TypeFunc::Parms+0] = NULL; // void 680 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); 681 682 // create result type 683 fields = TypeTuple::fields(1); 684 fields[TypeFunc::Parms+0] = NULL; // void 685 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 686 687 return TypeFunc::make(domain, range); 688 } 689 690 const TypeFunc* OptoRuntime::l2f_Type() { 691 // create input type (domain) 692 const Type **fields = TypeTuple::fields(2); 693 fields[TypeFunc::Parms+0] = TypeLong::LONG; 694 fields[TypeFunc::Parms+1] = Type::HALF; 695 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |