Ejemplo n.º 1
0
// ------------------------------------------------------------------
// ciKlass::ciKlass
ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) {
  assert(get_Klass()->is_klass(), "wrong type");
  Klass* k = get_Klass();
  _layout_helper = k->layout_helper();
  Symbol* klass_name = k->name();
  assert(klass_name != NULL, "wrong ciKlass constructor");
  _name = CURRENT_ENV->get_symbol(klass_name);
}
Ejemplo n.º 2
0
// ------------------------------------------------------------------
// ciKlass::can_be_primary_super
bool ciKlass::can_be_primary_super() {
  assert(is_loaded(), "must be loaded");

  VM_ENTRY_MARK;
  Klass* this_klass = get_Klass();
  return this_klass->can_be_primary_super();
}
Ejemplo n.º 3
0
// ------------------------------------------------------------------
// ciKlass::least_common_ancestor
//
// Get the shared parent of two klasses.
//
// Implementation note: this method currently goes "over the wall"
// and does all of the work on the VM side.  It could be rewritten
// to use the super() method and do all of the work (aside from the
// lazy computation of super()) in native mode.  This may be
// worthwhile if the compiler is repeatedly requesting the same lca
// computation or possibly if most of the superklasses have already
// been created as ciObjects anyway.  Something to think about...
ciKlass*
ciKlass::least_common_ancestor(ciKlass* that) {
  assert(is_loaded() && that->is_loaded(), "must be loaded");
  // Check to see if the klasses are identical.
  if (this == that) {
    return this;
  }

  VM_ENTRY_MARK;
  Klass* this_klass = get_Klass();
  Klass* that_klass = that->get_Klass();
  Klass* lca        = this_klass->LCA(that_klass);

  // Many times the LCA will be either this_klass or that_klass.
  // Treat these as special cases.
  if (lca == that_klass) {
    return that;
  }
  if (this_klass == lca) {
    return this;
  }

  // Create the ciInstanceKlass for the lca.
  ciKlass* result =
    CURRENT_THREAD_ENV->get_klass(lca);

  return result;
}
Ejemplo n.º 4
0
// ------------------------------------------------------------------
// ciKlass::super_depth
juint ciKlass::super_depth() {
  assert(is_loaded(), "must be loaded");

  VM_ENTRY_MARK;
  Klass* this_klass = get_Klass();
  return this_klass->super_depth();
}
Ejemplo n.º 5
0
// ------------------------------------------------------------------
// ciKlass::super_of_depth
ciKlass* ciKlass::super_of_depth(juint i) {
  assert(is_loaded(), "must be loaded");

  VM_ENTRY_MARK;
  Klass* this_klass = get_Klass();
  Klass* super = this_klass->primary_super_of_depth(i);
  return (super != NULL) ? CURRENT_THREAD_ENV->get_klass(super) : NULL;
}
Ejemplo n.º 6
0
// ------------------------------------------------------------------
// ciKlass::super_check_offset
juint ciKlass::super_check_offset() {
    assert(is_loaded(), "must be loaded");
    assert(is_java_klass(), "must be java klasses");

    VM_ENTRY_MARK;
    Klass* this_klass = get_Klass();
    return this_klass->super_check_offset();
}
Ejemplo n.º 7
0
// ------------------------------------------------------------------
// ciKlass::super_of_depth
ciKlass* ciKlass::super_of_depth(juint i) {
    assert(is_loaded(), "must be loaded");
    assert(is_java_klass(), "must be java klasses");

    VM_ENTRY_MARK;
    Klass* this_klass = get_Klass();
    klassOop super = this_klass->primary_super_of_depth(i);
    return (super != NULL) ? CURRENT_THREAD_ENV->get_object(super)->as_klass() : NULL;
}
Ejemplo n.º 8
0
// ------------------------------------------------------------------
// ciKlass::is_subclass_of
bool ciKlass::is_subclass_of(ciKlass* that) {
  assert(this->is_loaded(), err_msg("must be loaded: %s", this->name()->as_quoted_ascii()));
  assert(that->is_loaded(), err_msg("must be loaded: %s", that->name()->as_quoted_ascii()));

  VM_ENTRY_MARK;
  Klass* this_klass = get_Klass();
  Klass* that_klass = that->get_Klass();
  bool result = this_klass->is_subclass_of(that_klass);

  return result;
}
Ejemplo n.º 9
0
// ------------------------------------------------------------------
// ciKlass::is_subclass_of
bool ciKlass::is_subclass_of(ciKlass* that) {
  assert(is_loaded() && that->is_loaded(), "must be loaded");
  // Check to see if the klasses are identical.

  VM_ENTRY_MARK;
  Klass* this_klass = get_Klass();
  Klass* that_klass = that->get_Klass();
  bool result = this_klass->is_subclass_of(that_klass);

  return result;
}
Ejemplo n.º 10
0
// ------------------------------------------------------------------
// ciKlass::is_subtype_of
bool ciKlass::is_subtype_of(ciKlass* that) {
    assert(is_loaded() && that->is_loaded(), "must be loaded");
    assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
    // Check to see if the klasses are identical.
    if (this == that) {
        return true;
    }

    VM_ENTRY_MARK;
    Klass* this_klass = get_Klass();
    klassOop that_klass = that->get_klassOop();
    bool result = this_klass->is_subtype_of(that_klass);

    return result;
}
Ejemplo n.º 11
0
// ------------------------------------------------------------------
// ciObjArrayKlass::ciObjArrayKlass
//
// Constructor for loaded object array klasses.
ciObjArrayKlass::ciObjArrayKlass(KlassHandle h_k) : ciArrayKlass(h_k) {
  assert(get_Klass()->oop_is_objArray(), "wrong type");
  klassOop element_klassOop = get_objArrayKlass()->bottom_klass();
  _base_element_klass = CURRENT_ENV->get_object(element_klassOop)->as_klass();
  assert(_base_element_klass->is_instance_klass() ||
         _base_element_klass->is_type_array_klass(), "bad base klass");
  if (dimension() == 1) {
    _element_klass = _base_element_klass;
  } else {
    _element_klass = NULL;
  }
  if (!ciObjectFactory::is_initialized()) {
    assert(_element_klass->is_java_lang_Object(), "only arrays of object are shared");
  }
}
Ejemplo n.º 12
0
// ------------------------------------------------------------------
// ciKlass::is_subtype_of
bool ciKlass::is_subtype_of(ciKlass* that) {
  assert(this->is_loaded(), err_msg("must be loaded: %s", this->name()->as_quoted_ascii()));
  assert(that->is_loaded(), err_msg("must be loaded: %s", that->name()->as_quoted_ascii()));

  // Check to see if the klasses are identical.
  if (this == that) {
    return true;
  }

  VM_ENTRY_MARK;
  Klass* this_klass = get_Klass();
  Klass* that_klass = that->get_Klass();
  bool result = this_klass->is_subtype_of(that_klass);

  return result;
}
// ------------------------------------------------------------------
// ciInstanceKlass::ciInstanceKlass
//
// Loaded instance klass.
ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
  ciKlass(h_k)
{
  assert(get_Klass()->oop_is_instance(), "wrong type");
  assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
  InstanceKlass* ik = get_instanceKlass();

  AccessFlags access_flags = ik->access_flags();
  _flags = ciFlags(access_flags);
  _has_finalizer = access_flags.has_finalizer();
  _has_subklass = ik->subklass() != NULL;
  _init_state = ik->init_state();
  _nonstatic_field_size = ik->nonstatic_field_size();
  _has_nonstatic_fields = ik->has_nonstatic_fields();
  _has_default_methods = ik->has_default_methods();
  _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  _has_injected_fields = -1;
  _implementor = NULL; // we will fill these lazily

  Thread *thread = Thread::current();
  if (ciObjectFactory::is_initialized()) {
    _loader = JNIHandles::make_local(thread, ik->class_loader());
    _protection_domain = JNIHandles::make_local(thread,
                                                ik->protection_domain());
    _is_shared = false;
  } else {
    Handle h_loader(thread, ik->class_loader());
    Handle h_protection_domain(thread, ik->protection_domain());
    _loader = JNIHandles::make_global(h_loader);
    _protection_domain = JNIHandles::make_global(h_protection_domain);
    _is_shared = true;
  }

  // Lazy fields get filled in only upon request.
  _super  = NULL;
  _java_mirror = NULL;

  if (is_shared()) {
    if (h_k() != SystemDictionary::Object_klass()) {
      super();
    }
    //compute_nonstatic_fields();  // done outside of constructor
  }

  _field_cache = NULL;
}
Ejemplo n.º 14
0
// ------------------------------------------------------------------
// ciInstanceKlass::ciInstanceKlass
//
// Loaded instance klass.
ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : ciKlass(h_k) {
  assert(get_Klass()->oop_is_instance(), "wrong type");
  instanceKlass* ik = get_instanceKlass();

  AccessFlags access_flags = ik->access_flags();
  _flags = ciFlags(access_flags);
  _has_finalizer = access_flags.has_finalizer();
  _has_subklass = ik->subklass() != NULL;
  _is_initialized = ik->is_initialized();
  _is_being_initialized = ik->is_being_initialized();
  _size_helper = ik->size_helper();
  _nonstatic_field_size = ik->nonstatic_field_size();

  _checked_implementor = false;
  _implementor = NULL;

  Thread *thread = Thread::current();
  if (ciObjectFactory::shared_is_initialized()) {
    _loader = JNIHandles::make_local(thread, ik->class_loader());
    _protection_domain = JNIHandles::make_local(thread,
                                                ik->protection_domain());
    _is_shared = false;
  } else {
    Handle h_loader(thread, ik->class_loader());
    Handle h_protection_domain(thread, ik->protection_domain());
    _loader = JNIHandles::make_global(h_loader, false);
    _protection_domain = JNIHandles::make_global(h_protection_domain, false);
    _is_shared = true;
  }
  
  // Lazy fields get filled in only upon request.
  _super  = NULL;
  _java_mirror = NULL;

  if (_is_shared) {
    if (h_k() != SystemDictionary::object_klass()) {
      super();
    }
    java_mirror();
  }

  _field_cache = NULL;
}
 arrayKlass* get_arrayKlass() {
   return (arrayKlass*)get_Klass();
 }
Ejemplo n.º 16
0
// ------------------------------------------------------------------
// ciKlass::ciKlass
//
// Nameless klass variant.
ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) {
  assert(get_Klass()->is_klass(), "wrong type");
  _name = name;
  _layout_helper = Klass::_lh_neutral_value;
}
Ejemplo n.º 17
0
 ArrayKlass* get_ArrayKlass() {
   return (ArrayKlass*)get_Klass();
 }
Ejemplo n.º 18
0
// ------------------------------------------------------------------
// ciTypeArrayKlass::ciTypeArrayKlass
ciTypeArrayKlass::ciTypeArrayKlass(KlassHandle h_k) : ciArrayKlass(h_k) {
  assert(get_Klass()->oop_is_typeArray(), "wrong type");
  assert(element_type() == get_typeArrayKlass()->element_type(), "");
}
Ejemplo n.º 19
0
 objArrayKlass* get_objArrayKlass() {
   return (objArrayKlass*)get_Klass();
 }
Ejemplo n.º 20
0
  assert(is_loaded(), "cannot find_klass through an unloaded klass");
  return CURRENT_ENV->get_klass_by_name(this,
                                        klass_name, false);
}

// ------------------------------------------------------------------
// ciKlass::java_mirror
//
// Get the instance of java.lang.Class corresponding to this klass.
// If it is an unloaded instance or array klass, return an unloaded
// mirror object of type Class.
ciInstance* ciKlass::java_mirror() {
  GUARDED_VM_ENTRY(
    if (!is_loaded())
      return ciEnv::current()->get_unloaded_klass_mirror(this);
    oop java_mirror = get_Klass()->java_mirror();
    return CURRENT_ENV->get_instance(java_mirror);
  )
}

// ------------------------------------------------------------------
// ciKlass::modifier_flags
jint ciKlass::modifier_flags() {
  assert(is_loaded(), "not loaded");
  GUARDED_VM_ENTRY(
    return get_Klass()->modifier_flags();
  )
}

// ------------------------------------------------------------------
// ciKlass::access_flags
Ejemplo n.º 21
0
// ------------------------------------------------------------------
// ciArrayKlass::ciArrayKlass
//
// Loaded array klass.
ciArrayKlass::ciArrayKlass(KlassHandle h_k) : ciKlass(h_k) {
  assert(get_Klass()->oop_is_array(), "wrong type");
  _dimension = get_arrayKlass()->dimension();
}
 typeArrayKlass* get_typeArrayKlass() {
   return (typeArrayKlass*)get_Klass();
 }