void InstanceClass::bootstrap_initialize(JVM_SINGLE_ARG_TRAPS) { UsingFastOops fast_oops; #ifndef PRODUCT Method::Fast init = find_local_method(Symbols::class_initializer_name(), Symbols::void_signature()); GUARANTEE(init.is_null(), "cannot have class initializer"); AZZERT_ONLY_VAR(init); #endif set_initialized(); #if USE_EMBEDDED_VTABLE_BITMAP update_vtable_bitmaps(JVM_SINGLE_ARG_CHECK); #endif verify(JVM_SINGLE_ARG_NO_CHECK_AT_BOTTOM); }
void ROMInliner::initialize(int max_len JVM_TRAPS) { // create array able to hold all methods int method_count = 0; for (SystemClassStream st; st.has_next();) { InstanceClass::Raw klass = st.next(); ObjArray::Raw methods = klass().methods(); method_count += methods().length(); } _methods = Universe::new_obj_array(method_count * 3 JVM_CHECK); // iterate over all methods and put potentially inlineable methods in hash UsingFastOops level1; Method::Fast method; ObjArray::Fast methods; for (SystemClassStream stream; stream.has_next();) { InstanceClass::Raw klass = stream.next(); methods = klass().methods(); for (int i=0; i<methods().length(); i++) { method = methods().obj_at(i); if (method.is_null()) { // A nulled-out method continue; } // callees like these can't really be inlined if (method().is_abstract() || method().is_native() || method().code_size() >= max_len) { continue; } add(&method); } } }
jboolean LocationModifier::set_method_opcode(Bytecodes::Code new_opcode, bool is_setting) { UsingFastOops fast_oops; Method::Fast m = method(); jlong offs = offset(); Bytecodes::Code opcode; SETUP_ERROR_CHECKER_ARG; if (m.is_null()) { // If we are clearing a breakpoint and this was a <clinit> method // and we removed <clinit> after the class was intialized then we // return since there's nothing to do return false; } #ifdef AZZERT /* Determine if this is a legal offset * into the bytecode for this method */ if (!JavaDebugger::is_legal_offset(&m, offs)) { return false; } #endif if (offs >= m().code_size()) { // quick check for out of bounds, could happen if method was // converted to fast_accessor return false; } if (ROM::system_text_contains(m.obj())) { // This method is in ROM so we need to copy it out so that // we can modify breakpoints. UsingFastOops fast_oops_2; Method::Fast dm = get_dup_rom_method(&m); if (is_setting) { if (dm.is_null()) { AccessFlags af = m().access_flags(); dm = Universe::new_method(m().code_size(), af JVM_CHECK_0); jvm_memcpy((char *)dm.obj() + dm().access_flags_offset(), (char *) m.obj() + m().access_flags_offset(), Method::base_offset() + m().code_size() - m().access_flags_offset()); // ROM method constants pointer points into ROM text if we // merged pools ConstantPool::Raw cp = m().constants(); dm().set_constants(&cp); if (!m().has_no_stackmaps()) { Oop::Raw stackmaps = m().stackmaps(); dm().set_stackmaps(&stackmaps); } if (!m().has_no_exception_table()) { Oop::Raw exception_table = m().exception_table(); dm().set_exception_table(&exception_table); } #if ENABLE_REFLECTION Oop::Raw thrown_exceptions = m().thrown_exceptions(); dm().set_thrown_exceptions(&thrown_exceptions); #endif set_rom_debug_method(&dm); } opcode = m().bytecode_at_raw((int)offs); dm().bytecode_at_put_raw((int)offs, new_opcode); m().set_execution_entry((address)shared_invoke_debug); dm().set_execution_entry((address)shared_invoke_debug); } else { // We are clearing a breakpoint that was set in ROM (actually in // a copy of the ROM method) dm = rom_debug_method(); GUARANTEE(!dm.is_null(), "Clearing ROM breakpoint, but method is null!"); opcode = dm().bytecode_at_raw((int)offs); // install new opcode into bytecode stream dm().bytecode_at_put_raw((int)offs, new_opcode); } } else { opcode = m().bytecode_at_raw((int)offs); // install new opcode into bytecode stream m().bytecode_at_put_raw((int)offs, new_opcode); } if (is_setting) { set_save_opcode(opcode); } return (true); }
void VMEvent::clear_impossible_to_compile(LocationModifier *mod, VMEvent *ep) { UsingFastOops fast_oops; // If we are using the compiler then we should reset the // impossible_to_compile flag for this method (and potentially one frame // up if it's a single step). // We also check the previous state of the method, if it was // "impossible_to_compile" we don't reset the flag. InstanceClass::Fast clazz; Method::Fast method, callerMethod; LocationModifier::Fast thisMod; Method::Fast m = mod->method(); // if (!m().has_compiled_code()) { // if method does not have compiled code then just return // return; // } if (m.is_null()) { // Method was removed. Most likely it was a <clinit> method return; } VMEvent::Fast epm; VMEventStream es; bool found_one = false; while (!es.at_end()) { epm = es.next(); if ((epm().event_kind() == JDWP_EventKind_BREAKPOINT || epm().event_kind() == JDWP_EventKind_SINGLE_STEP) && (ep == NULL || !epm.equals(ep))) { thisMod = get_modifier(&epm, JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly); if (thisMod.not_null()) { method = thisMod().method(); if (method.equals(&m)) { // another breakpoint in this method, keep impossible_to_compile set found_one = true; break; } } } } if (!found_one) { // we must have looped through the whole list and not found another // breakpoint in this method so clear the impossible_to_compile flag if (mod->rom_debug_method() != NULL) { // This method is in ROM, let's check all method pointers on the java // stack to see if any of them point to this rom_debug_method. // We may be called as a result of JVM::cleanup(). Thread doesn't have // a stack in that case. Thread *thread = Thread::current(); if (thread->last_java_fp() != NULL && thread->last_java_sp() != NULL) { Frame fr(Thread::current()); while (true) { if (fr.is_entry_frame()) { EntryFrame e = fr.as_EntryFrame(); if (e.is_first_frame()) { break; } e.caller_is(fr); } else if (fr.is_java_frame()) { JavaFrame jf = fr.as_JavaFrame(); if (jf.method() == mod->rom_debug_method()) { MethodDesc *md = (MethodDesc *)mod->method(); // fix up the stored bcp in this frame int bci = jf.bci_with_flags(); jf.set_raw_method(md); Method::Raw m = jf.method(); jf.set_raw_bcp((address)(bci + m().code_base())); } jf.caller_is(fr); } } } } // We also check the previous state of the method, if it was // "impossible_to_compile" we don't reset the flag. if (mod->compile_state() == true) { // Method was compilable so set entry to default m().set_default_entry(false); } else { if (ep->event_kind() == JDWP_EventKind_BREAKPOINT) { // May have been a special native method like String.charAt. // Just replace the entry with what we had saved earlier GUARANTEE(!ObjectHeap::contains((OopDesc*)mod->saved_method_entry()), "ROM method entry is in heap"); m().variable_part()->set_execution_entry(mod->saved_method_entry()); } } } }