85 // Compiled code entry points 86 address OptoRuntime::_new_instance_Java = NULL; 87 address OptoRuntime::_new_array_Java = NULL; 88 address OptoRuntime::_new_array_nozero_Java = NULL; 89 address OptoRuntime::_multianewarray2_Java = NULL; 90 address OptoRuntime::_multianewarray3_Java = NULL; 91 address OptoRuntime::_multianewarray4_Java = NULL; 92 address OptoRuntime::_multianewarray5_Java = NULL; 93 address OptoRuntime::_multianewarrayN_Java = NULL; 94 address OptoRuntime::_g1_wb_pre_Java = NULL; 95 address OptoRuntime::_g1_wb_post_Java = NULL; 96 address OptoRuntime::_vtable_must_compile_Java = NULL; 97 address OptoRuntime::_complete_monitor_locking_Java = NULL; 98 address OptoRuntime::_monitor_notify_Java = NULL; 99 address OptoRuntime::_monitor_notifyAll_Java = NULL; 100 address OptoRuntime::_rethrow_Java = NULL; 101 102 address OptoRuntime::_slow_arraycopy_Java = NULL; 103 address OptoRuntime::_register_finalizer_Java = NULL; 104 105 # ifdef ENABLE_ZAP_DEAD_LOCALS 106 address OptoRuntime::_zap_dead_Java_locals_Java = NULL; 107 address OptoRuntime::_zap_dead_native_locals_Java = NULL; 108 # endif 109 110 ExceptionBlob* OptoRuntime::_exception_blob; 111 112 // This should be called in an assertion at the start of OptoRuntime routines 113 // which are entered from compiled code (all of them) 114 #ifdef ASSERT 115 static bool check_compiled_frame(JavaThread* thread) { 116 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code"); 117 RegisterMap map(thread, false); 118 frame caller = thread->last_frame().sender(&map); 119 assert(caller.is_compiled_frame(), "not being called from compiled like code"); 120 return true; 121 } 122 #endif // ASSERT 123 124 125 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \ 126 var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, save_arg_regs, return_pc); \ 127 if (var == NULL) { return false; } 128 129 bool OptoRuntime::generate(ciEnv* env) { 135 // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc 136 // ------------------------------------------------------------------------------------------------------------------------------- 137 gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false); 138 gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false); 139 gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false); 140 gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false); 141 gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false); 142 gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false); 143 gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false); 144 gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false); 145 gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false); 146 gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false); 147 gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false); 148 gen(env, _monitor_notify_Java , monitor_notify_Type , monitor_notify_C , 0 , false, false, false); 149 gen(env, _monitor_notifyAll_Java , monitor_notify_Type , monitor_notifyAll_C , 0 , false, false, false); 150 gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true ); 151 152 gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false); 153 gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false); 154 155 # ifdef ENABLE_ZAP_DEAD_LOCALS 156 gen(env, _zap_dead_Java_locals_Java , zap_dead_locals_Type , zap_dead_Java_locals_C , 0 , false, true , false ); 157 gen(env, _zap_dead_native_locals_Java , zap_dead_locals_Type , zap_dead_native_locals_C , 0 , false, true , false ); 158 # endif 159 return true; 160 } 161 162 #undef gen 163 164 165 // Helper method to do generation of RunTimeStub's 166 address OptoRuntime::generate_stub( ciEnv* env, 167 TypeFunc_generator gen, address C_function, 168 const char *name, int is_fancy_jump, 169 bool pass_tls, 170 bool save_argument_registers, 171 bool return_pc ) { 172 ResourceMark rm; 173 Compile C( env, gen, C_function, name, is_fancy_jump, pass_tls, save_argument_registers, return_pc ); 174 return C.stub_entry_point(); 175 } 176 177 const char* OptoRuntime::stub_name(address entry) { 178 #ifndef PRODUCT 587 // create result type (range) 588 fields = TypeTuple::fields(0); 589 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 590 591 return TypeFunc::make(domain, range); 592 } 593 594 const TypeFunc *OptoRuntime::uncommon_trap_Type() { 595 // create input type (domain) 596 const Type **fields = TypeTuple::fields(1); 597 fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action) 598 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 599 600 // create result type (range) 601 fields = TypeTuple::fields(0); 602 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 603 604 return TypeFunc::make(domain, range); 605 } 606 607 # ifdef ENABLE_ZAP_DEAD_LOCALS 608 // Type used for stub generation for zap_dead_locals. 609 // No inputs or outputs 610 const TypeFunc *OptoRuntime::zap_dead_locals_Type() { 611 // create input type (domain) 612 const Type **fields = TypeTuple::fields(0); 613 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms,fields); 614 615 // create result type (range) 616 fields = TypeTuple::fields(0); 617 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms,fields); 618 619 return TypeFunc::make(domain,range); 620 } 621 # endif 622 623 624 //----------------------------------------------------------------------------- 625 // Monitor Handling 626 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() { 627 // create input type (domain) 628 const Type **fields = TypeTuple::fields(2); 629 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 630 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock 631 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 632 633 // create result type (range) 634 fields = TypeTuple::fields(0); 635 636 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 637 638 return TypeFunc::make(domain,range); 639 } 640 641 642 //----------------------------------------------------------------------------- 643 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { 1631 ttyLocker ttyl; 1632 trace_exception_counter++; 1633 tty->print("%d [Exception (%s): ", trace_exception_counter, msg); 1634 exception_oop->print_value(); 1635 tty->print(" in "); 1636 CodeBlob* blob = CodeCache::find_blob(exception_pc); 1637 if (blob->is_nmethod()) { 1638 nmethod* nm = blob->as_nmethod_or_null(); 1639 nm->method()->print_value(); 1640 } else if (blob->is_runtime_stub()) { 1641 tty->print("<runtime-stub>"); 1642 } else { 1643 tty->print("<unknown>"); 1644 } 1645 tty->print(" at " INTPTR_FORMAT, p2i(exception_pc)); 1646 tty->print_cr("]"); 1647 } 1648 1649 #endif // PRODUCT 1650 1651 1652 # ifdef ENABLE_ZAP_DEAD_LOCALS 1653 // Called from call sites in compiled code with oop maps (actually safepoints) 1654 // Zaps dead locals in first java frame. 1655 // Is entry because may need to lock to generate oop maps 1656 // Currently, only used for compiler frames, but someday may be used 1657 // for interpreter frames, too. 1658 1659 int OptoRuntime::ZapDeadCompiledLocals_count = 0; 1660 1661 // avoid pointers to member funcs with these helpers 1662 static bool is_java_frame( frame* f) { return f->is_java_frame(); } 1663 static bool is_native_frame(frame* f) { return f->is_native_frame(); } 1664 1665 1666 void OptoRuntime::zap_dead_java_or_native_locals(JavaThread* thread, 1667 bool (*is_this_the_right_frame_to_zap)(frame*)) { 1668 assert(JavaThread::current() == thread, "is this needed?"); 1669 1670 if ( !ZapDeadCompiledLocals ) return; 1671 1672 bool skip = false; 1673 1674 if ( ZapDeadCompiledLocalsFirst == 0 ) ; // nothing special 1675 else if ( ZapDeadCompiledLocalsFirst > ZapDeadCompiledLocals_count ) skip = true; 1676 else if ( ZapDeadCompiledLocalsFirst == ZapDeadCompiledLocals_count ) 1677 warning("starting zapping after skipping"); 1678 1679 if ( ZapDeadCompiledLocalsLast == -1 ) ; // nothing special 1680 else if ( ZapDeadCompiledLocalsLast < ZapDeadCompiledLocals_count ) skip = true; 1681 else if ( ZapDeadCompiledLocalsLast == ZapDeadCompiledLocals_count ) 1682 warning("about to zap last zap"); 1683 1684 ++ZapDeadCompiledLocals_count; // counts skipped zaps, too 1685 1686 if ( skip ) return; 1687 1688 // find java frame and zap it 1689 1690 for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) { 1691 if (is_this_the_right_frame_to_zap(sfs.current()) ) { 1692 sfs.current()->zap_dead_locals(thread, sfs.register_map()); 1693 return; 1694 } 1695 } 1696 warning("no frame found to zap in zap_dead_Java_locals_C"); 1697 } 1698 1699 JRT_LEAF(void, OptoRuntime::zap_dead_Java_locals_C(JavaThread* thread)) 1700 zap_dead_java_or_native_locals(thread, is_java_frame); 1701 JRT_END 1702 1703 // The following does not work because for one thing, the 1704 // thread state is wrong; it expects java, but it is native. 1705 // Also, the invariants in a native stub are different and 1706 // I'm not sure it is safe to have a MachCalRuntimeDirectNode 1707 // in there. 1708 // So for now, we do not zap in native stubs. 1709 1710 JRT_LEAF(void, OptoRuntime::zap_dead_native_locals_C(JavaThread* thread)) 1711 zap_dead_java_or_native_locals(thread, is_native_frame); 1712 JRT_END 1713 1714 # endif | 85 // Compiled code entry points 86 address OptoRuntime::_new_instance_Java = NULL; 87 address OptoRuntime::_new_array_Java = NULL; 88 address OptoRuntime::_new_array_nozero_Java = NULL; 89 address OptoRuntime::_multianewarray2_Java = NULL; 90 address OptoRuntime::_multianewarray3_Java = NULL; 91 address OptoRuntime::_multianewarray4_Java = NULL; 92 address OptoRuntime::_multianewarray5_Java = NULL; 93 address OptoRuntime::_multianewarrayN_Java = NULL; 94 address OptoRuntime::_g1_wb_pre_Java = NULL; 95 address OptoRuntime::_g1_wb_post_Java = NULL; 96 address OptoRuntime::_vtable_must_compile_Java = NULL; 97 address OptoRuntime::_complete_monitor_locking_Java = NULL; 98 address OptoRuntime::_monitor_notify_Java = NULL; 99 address OptoRuntime::_monitor_notifyAll_Java = NULL; 100 address OptoRuntime::_rethrow_Java = NULL; 101 102 address OptoRuntime::_slow_arraycopy_Java = NULL; 103 address OptoRuntime::_register_finalizer_Java = NULL; 104 105 ExceptionBlob* OptoRuntime::_exception_blob; 106 107 // This should be called in an assertion at the start of OptoRuntime routines 108 // which are entered from compiled code (all of them) 109 #ifdef ASSERT 110 static bool check_compiled_frame(JavaThread* thread) { 111 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code"); 112 RegisterMap map(thread, false); 113 frame caller = thread->last_frame().sender(&map); 114 assert(caller.is_compiled_frame(), "not being called from compiled like code"); 115 return true; 116 } 117 #endif // ASSERT 118 119 120 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \ 121 var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, save_arg_regs, return_pc); \ 122 if (var == NULL) { return false; } 123 124 bool OptoRuntime::generate(ciEnv* env) { 130 // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc 131 // ------------------------------------------------------------------------------------------------------------------------------- 132 gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false); 133 gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false); 134 gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false); 135 gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false); 136 gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false); 137 gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false); 138 gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false); 139 gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false); 140 gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false); 141 gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false); 142 gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false); 143 gen(env, _monitor_notify_Java , monitor_notify_Type , monitor_notify_C , 0 , false, false, false); 144 gen(env, _monitor_notifyAll_Java , monitor_notify_Type , monitor_notifyAll_C , 0 , false, false, false); 145 gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true ); 146 147 gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false); 148 gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false); 149 150 return true; 151 } 152 153 #undef gen 154 155 156 // Helper method to do generation of RunTimeStub's 157 address OptoRuntime::generate_stub( ciEnv* env, 158 TypeFunc_generator gen, address C_function, 159 const char *name, int is_fancy_jump, 160 bool pass_tls, 161 bool save_argument_registers, 162 bool return_pc ) { 163 ResourceMark rm; 164 Compile C( env, gen, C_function, name, is_fancy_jump, pass_tls, save_argument_registers, return_pc ); 165 return C.stub_entry_point(); 166 } 167 168 const char* OptoRuntime::stub_name(address entry) { 169 #ifndef PRODUCT 578 // create result type (range) 579 fields = TypeTuple::fields(0); 580 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 581 582 return TypeFunc::make(domain, range); 583 } 584 585 const TypeFunc *OptoRuntime::uncommon_trap_Type() { 586 // create input type (domain) 587 const Type **fields = TypeTuple::fields(1); 588 fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action) 589 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 590 591 // create result type (range) 592 fields = TypeTuple::fields(0); 593 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 594 595 return TypeFunc::make(domain, range); 596 } 597 598 //----------------------------------------------------------------------------- 599 // Monitor Handling 600 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() { 601 // create input type (domain) 602 const Type **fields = TypeTuple::fields(2); 603 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 604 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock 605 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 606 607 // create result type (range) 608 fields = TypeTuple::fields(0); 609 610 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 611 612 return TypeFunc::make(domain,range); 613 } 614 615 616 //----------------------------------------------------------------------------- 617 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { 1605 ttyLocker ttyl; 1606 trace_exception_counter++; 1607 tty->print("%d [Exception (%s): ", trace_exception_counter, msg); 1608 exception_oop->print_value(); 1609 tty->print(" in "); 1610 CodeBlob* blob = CodeCache::find_blob(exception_pc); 1611 if (blob->is_nmethod()) { 1612 nmethod* nm = blob->as_nmethod_or_null(); 1613 nm->method()->print_value(); 1614 } else if (blob->is_runtime_stub()) { 1615 tty->print("<runtime-stub>"); 1616 } else { 1617 tty->print("<unknown>"); 1618 } 1619 tty->print(" at " INTPTR_FORMAT, p2i(exception_pc)); 1620 tty->print_cr("]"); 1621 } 1622 1623 #endif // PRODUCT 1624 |