int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
  Klass* k = java_lang_Class::as_Klass(obj);
  if (k != NULL && k->is_instance_klass()) {
    return InstanceKlass::cast(k)->static_oop_field_count();
  }
  return 0;
}
Example #2
0
void InstanceMirrorKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
  InstanceKlass::oop_pc_follow_contents(obj, cm);

  // Follow the klass field in the mirror.
  Klass* klass = java_lang_Class::as_Klass(obj);
  if (klass != NULL) {
    // An anonymous class doesn't have its own class loader, so the call
    // to follow_klass will mark and push its java mirror instead of the
    // class loader. When handling the java mirror for an anonymous class
    // we need to make sure its class loader data is claimed, this is done
    // by calling follow_class_loader explicitly. For non-anonymous classes
    // the call to follow_class_loader is made when the class loader itself
    // is handled.
    if (klass->is_instance_klass() && InstanceKlass::cast(klass)->is_anonymous()) {
      cm->follow_class_loader(klass->class_loader_data());
    } else {
      cm->follow_klass(klass);
    }
  } else {
    // If klass is NULL then this a mirror for a primitive type.
    // We don't have to follow them, since they are handled as strong
    // roots in Universe::oops_do.
    assert(java_lang_Class::is_primitive(obj), "Sanity check");
  }

  ParCompactionManager::MarkAndPushClosure cl(cm);
  oop_oop_iterate_statics<true>(obj, &cl);
}
Example #3
0
void ClassLoaderData::methods_do(void f(Method*)) {
  for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
    if (k->is_instance_klass()) {
      InstanceKlass::cast(k)->methods_do(f);
    }
  }
}
Example #4
0
void ClassLoaderData::classes_do(void f(InstanceKlass*)) {
  for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
    if (k->is_instance_klass()) {
      f(InstanceKlass::cast(k));
    }
    assert(k != k->next_link(), "no loops!");
  }
}
Example #5
0
void ClassLoaderData::methods_do(void f(Method*)) {
  // Lock-free access requires load_ptr_acquire
  for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
    if (k->is_instance_klass()) {
      InstanceKlass::cast(k)->methods_do(f);
    }
  }
}
Example #6
0
void ClassLoaderData::classes_do(void f(InstanceKlass*)) {
  // Lock-free access requires load_ptr_acquire
  for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
    if (k->is_instance_klass()) {
      f(InstanceKlass::cast(k));
    }
    assert(k != k->next_link(), "no loops!");
  }
}
Example #7
0
void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) {
  // Lock to avoid classes being modified/added/removed during iteration
  MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
  for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
    // Do not filter ArrayKlass oops here...
    if (k->is_array_klass() || (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded())) {
      klass_closure->do_klass(k);
    }
  }
}
void CounterDecay::decay() {
  _last_timestamp = os::javaTimeMillis();

  // This operation is going to be performed only at the end of a safepoint
  // and hence GC's will not be going on, all Java mutators are suspended
  // at this point and hence SystemDictionary_lock is also not needed.
  assert(SafepointSynchronize::is_at_safepoint(), "can only be executed at a safepoint");
  int nclasses = SystemDictionary::number_of_classes();
  double classes_per_tick = nclasses * (CounterDecayMinIntervalLength * 1e-3 /
                                        CounterHalfLifeTime);
  for (int i = 0; i < classes_per_tick; i++) {
    Klass* k = SystemDictionary::try_get_next_class();
    if (k != NULL && k->is_instance_klass()) {
      InstanceKlass::cast(k)->methods_do(do_method);
    }
  }
}
Example #9
0
  // Return true if oop represents an object that is "visible"
  // to the java world.
  static inline bool visible_oop(oop o) {
    // the sentinel for deleted handles isn't visible
    if (o == JNIHandles::deleted_handle()) {
      return false;
    }

    // instance
    if (o->is_instance()) {
      // instance objects are visible
      if (o->klass() != SystemDictionary::Class_klass()) {
        return true;
      }
      if (java_lang_Class::is_primitive(o)) {
        return true;
      }
      // java.lang.Classes are visible
      Klass* k = java_lang_Class::as_Klass(o);
      if (k->is_klass()) {
        // if it's a class for an object, an object array, or
        // primitive (type) array then it's visible.
        if (k->is_instance_klass()) {
          return true;
        }
        if (k->is_objArray_klass()) {
          return true;
        }
        if (k->is_typeArray_klass()) {
          return true;
        }
      }
      return false;
    }
    // object arrays are visible if they aren't system object arrays
    if (o->is_objArray()) {
        return true;
    }
    // type arrays are visible
    if (o->is_typeArray()) {
      return true;
    }
    // everything else (Method*s, ...) aren't visible
    return false;
  };   // end of visible_oop()