Esempio n. 1
0
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);
}
Esempio n. 2
0
void CompilerTest::run_tests(JVM_SINGLE_ARG_TRAPS) {
  UsingFastOops fast_oops;
  ObjArray::Fast classes;
  ObjArray::Fast methods;
  InstanceClass::Fast klass;
  Method::Fast m;

  Os::suspend_profiler();
  {
    classes = load_and_sort_classes(JVM_SINGLE_ARG_CHECK);
  }
  Os::resume_profiler();

  int num_classes = classes().length();
  for (int i=0; i<num_classes; i++) {
    klass = classes().obj_at(i);

    Os::suspend_profiler();
    {
      methods = sort_methods(&klass JVM_CHECK);
    }
    Os::resume_profiler();

    if (Verbose) {
      tty->print("Compiling class: ");
      klass().print_name_on(tty);
      tty->cr();
    }

    int num_methods = methods().length();
    for (int j=0; j<num_methods; j++) {
      m = methods().obj_at(j);
      if (m.not_null()
          && !m().is_impossible_to_compile() && !m().is_abstract()) {
        test_compile(&m JVM_CHECK);
      }
    }
  }

  Os::suspend_profiler();
  {
    print_summary();
  }
  Os::resume_profiler();
}
void VMEventModifier::deoptimize_method(Method *m) {
#if ENABLE_COMPILER
  // If we insert a breakpoint into a method, that method may be compiled
  // and there may be countless frames in the system that reference
  // that method.  We must find all these frames and deoptimized them so that
  // we hit this breakpoint.
  UsingFastOops fast_oops;
  Thread::Fast thread = Universe::global_threadlist();
  while (thread.not_null() && thread().last_java_fp() != NULL) {
    JavaFrame fr(&thread);
    bool top_frame = true;
    while(true) {
      if (fr.is_entry_frame()) {
        if (fr.as_EntryFrame().is_first_frame()) {
          break;
        }
        top_frame = false;
        fr.as_EntryFrame().caller_is(fr);
      } else {
        UsingFastOops fast_oops2;
        GUARANTEE(fr.is_java_frame(), "Neither JavaFrame or EntryFrame");
        Method::Fast method = fr.method();
        if (method.equals(*m)) {
          // found a reference to this method on some frame, deoptimize it
          if (fr.is_compiled_frame()) {
            // deoptimize essentially restarts the current instruction in this
            // frame when we return to interpreter_deoptimize_entry.
            // However, in our case we can't restart the instruction 
            // since all the stack (with args etc) is popped off.  We really
            // want to continue in the interpreter at the following instruction
            // Hence we bump up the bci by 3 (after checking to make sure
            // it's an invoke we are pointing at).
            fr.deoptimize_and_continue(!top_frame);
          }
        }
        top_frame = false;
        fr.caller_is(fr);
      }
    }
    thread = thread().global_next();
  }
#endif
}
Esempio n. 4
0
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);
}
Esempio n. 6
0
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());
      }
    }
  }
}