klassOop typeArrayKlassKlass::create_klass(TRAPS) {
  typeArrayKlassKlass o;
  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());  
  KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_0);
  assert(k()->size() == align_object_size(header_size()), "wrong size for object");
  java_lang_Class::create_mirror(k, CHECK_0); // Allocate mirror
  return k();
}
Exemplo n.º 2
0
klassOop arrayKlassKlass::create_klass(TRAPS) {
  arrayKlassKlass o;
  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
  KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
  // Make sure size calculation is right
  assert(k()->size() == align_object_size(header_size()), "wrong size for object");
  java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror, make links
  return k();
}
Exemplo n.º 3
0
klassOop methodDataKlass::create_klass(TRAPS) {
  methodDataKlass o;
  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());  
  KlassHandle k = base_create_klass(h_this_klass, header_size(),
				    o.vtbl_value(), CHECK_0);
  // Make sure size calculation is right
  assert(k()->size() == align_object_size(header_size()),
	 "wrong size for object");
  return k();
}
klassOop instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len, int static_field_size, 
                                                     int nonstatic_oop_map_size, ReferenceType rt, TRAPS) {

  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + static_field_size + nonstatic_oop_map_size);

  // Allocation
  KlassHandle h_this_klass(THREAD, as_klassOop());  
  KlassHandle k;
  if (rt == REF_NONE) {
    // regular klass
    instanceKlass o;
    k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_0);
  } else {
    // reference klass
    instanceRefKlass o;
    k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_0);
  }
  instanceKlass* ik = (instanceKlass*) k()->klass_part();
  assert(!k()->is_parsable(), "not expecting parsability yet.");

  // The sizes of these these three variables are used for determining the
  // size of the instanceKlassOop. It is critical that these are set to the right
  // sizes before the first GC, i.e., when we allocate the mirror.
  ik->set_vtable_length(vtable_len);  
  ik->set_itable_length(itable_len);  
  ik->set_static_field_size(static_field_size);
  ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size);
  assert(k()->size() == size, "wrong size for object");

  ik->set_array_klasses(NULL);
  ik->set_methods(NULL);
  ik->set_method_ordering(NULL);
  ik->set_local_interfaces(NULL);
  ik->set_transitive_interfaces(NULL);
  ik->init_implementor();
  ik->set_fields(NULL);
  ik->set_constants(NULL);
  ik->set_class_loader(NULL);
  ik->set_protection_domain(NULL);
  ik->set_signers(NULL);
  ik->set_source_file_name(NULL);
  ik->set_source_debug_extension(NULL);
  ik->set_inner_classes(NULL);  
  ik->set_static_oop_field_size(0);
  ik->set_nonstatic_field_size(0);  
  ik->set_is_marked_dependent(false);
  ik->set_init_state(instanceKlass::allocated);
  ik->set_init_thread(NULL);
  ik->set_reference_type(rt);
  ik->set_oop_map_cache(NULL);
  ik->set_jni_ids(NULL);
  ik->set_osr_nmethods_head(NULL);
  ik->set_breakpoints(NULL);
  ik->init_previous_version();

  // initialize the non-header words to zero
  intptr_t* p = (intptr_t*)k();
  for (int index = instanceKlass::header_size(); index < size; index++) {
    p[index] = NULL;
  }

  // To get verify to work - must be set to partial loaded before first GC point.
  NOT_PRODUCT(k()->set_partially_loaded());     

  assert(k()->is_parsable(), "should be parsable here.");

  // GC can happen here
  java_lang_Class::create_mirror(k, CHECK_0); // Allocate mirror
  return k();
}
klassOop
instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len,
                                            int static_field_size,
                                            unsigned nonstatic_oop_map_count,
                                            AccessFlags access_flags,
                                            ReferenceType rt,
                                            KlassHandle host_klass, TRAPS) {

  const int nonstatic_oop_map_size =
    instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count);
  int size = align_object_offset(vtable_len) + align_object_offset(itable_len);
  if (access_flags.is_interface() || !host_klass.is_null()) {
    size += align_object_offset(nonstatic_oop_map_size);
  } else {
    size += nonstatic_oop_map_size;
  }
  if (access_flags.is_interface()) {
    size += (int)sizeof(klassOop)/HeapWordSize;
  }
  if (!host_klass.is_null()) {
    size += (int)sizeof(klassOop)/HeapWordSize;
  }
  size = instanceKlass::object_size(size);

  // Allocation
  KlassHandle h_this_klass(THREAD, as_klassOop());
  KlassHandle k;
  if (rt == REF_NONE) {
    if (name != vmSymbols::java_lang_Class()) {
      // regular klass
      instanceKlass o;
      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
    } else {
      // Class
      instanceMirrorKlass o;
      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
    }
  } else {
    // reference klass
    instanceRefKlass o;
    k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
  }
  {
    No_Safepoint_Verifier no_safepoint; // until k becomes parsable
    instanceKlass* ik = (instanceKlass*) k()->klass_part();
    assert(!k()->is_parsable(), "not expecting parsability yet.");

    // The sizes of these these three variables are used for determining the
    // size of the instanceKlassOop. It is critical that these are set to the right
    // sizes before the first GC, i.e., when we allocate the mirror.
    ik->set_vtable_length(vtable_len);
    ik->set_itable_length(itable_len);
    ik->set_static_field_size(static_field_size);
    ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size);
    ik->set_access_flags(access_flags);
    ik->set_is_anonymous(!host_klass.is_null());
    assert(k()->size() == size, "wrong size for object");

    ik->set_array_klasses(NULL);
    ik->set_methods(NULL);
    ik->set_method_ordering(NULL);
    ik->set_local_interfaces(NULL);
    ik->set_transitive_interfaces(NULL);
    ik->init_implementor();
    ik->set_fields(NULL, 0);
    ik->set_constants(NULL);
    ik->set_class_loader(NULL);
    ik->set_protection_domain(NULL);
    ik->set_signers(NULL);
    ik->set_source_file_name(NULL);
    ik->set_source_debug_extension(NULL, 0);
    ik->set_array_name(NULL);
    ik->set_inner_classes(NULL);
    ik->set_static_oop_field_count(0);
    ik->set_nonstatic_field_size(0);
    ik->set_is_marked_dependent(false);
    ik->set_init_state(instanceKlass::allocated);
    ik->set_init_thread(NULL);
    ik->set_reference_type(rt);
    ik->set_oop_map_cache(NULL);
    ik->set_jni_ids(NULL);
    ik->set_osr_nmethods_head(NULL);
    ik->set_breakpoints(NULL);
    ik->init_previous_versions();
    ik->set_generic_signature(NULL);
    ik->release_set_methods_jmethod_ids(NULL);
    ik->release_set_methods_cached_itable_indices(NULL);
    ik->set_class_annotations(NULL);
    ik->set_fields_annotations(NULL);
    ik->set_methods_annotations(NULL);
    ik->set_methods_parameter_annotations(NULL);
    ik->set_methods_default_annotations(NULL);
    ik->set_jvmti_cached_class_field_map(NULL);
    ik->set_initial_method_idnum(0);
    assert(k()->is_parsable(), "should be parsable here.");

    // initialize the non-header words to zero
    intptr_t* p = (intptr_t*)k();
    for (int index = instanceKlass::header_size(); index < size; index++) {
      p[index] = NULL_WORD;
    }

    // To get verify to work - must be set to partial loaded before first GC point.
    k()->set_partially_loaded();
  }

  Atomic::inc(&instanceKlass::_total_instanceKlass_count);
  return k();
}