< prev index next >

src/hotspot/share/ci/ciObjectFactory.cpp

Print this page
*** 152,14 ***
    }
  
    ciEnv::_null_object_instance = new (_arena) ciNullObject();
    init_ident_of(ciEnv::_null_object_instance);
  
! #define VM_CLASS_DEFN(name, ignore_s)                              \
!   if (vmClasses::name##_is_loaded()) \
!     ciEnv::_##name = get_metadata(vmClasses::name())->as_instance_klass();
! 
    VM_CLASSES_DO(VM_CLASS_DEFN)
  #undef VM_CLASS_DEFN
  
    for (int len = -1; len != _ci_metadata.length(); ) {
      len = _ci_metadata.length();
--- 152,14 ---
    }
  
    ciEnv::_null_object_instance = new (_arena) ciNullObject();
    init_ident_of(ciEnv::_null_object_instance);
  
! #define VM_CLASS_DEFN(name, ignore_s)  \
!   if (vmClasses::name##_is_loaded()) { \
!     ciEnv::_##name = get_metadata(vmClasses::name())->as_instance_klass(); \
!   }
    VM_CLASSES_DO(VM_CLASS_DEFN)
  #undef VM_CLASS_DEFN
  
    for (int len = -1; len != _ci_metadata.length(); ) {
      len = _ci_metadata.length();

*** 237,11 ***
    Handle keyHandle(Thread::current(), key);
    assert(Universe::heap()->is_in(keyHandle()), "must be");
  
    NonPermObject* &bucket = find_non_perm(keyHandle);
    if (bucket != nullptr) {
!     return bucket->object();
    }
  
    // The ciObject does not yet exist.  Create it and insert it
    // into the cache.
    ciObject* new_object = create_new_object(keyHandle());
--- 237,13 ---
    Handle keyHandle(Thread::current(), key);
    assert(Universe::heap()->is_in(keyHandle()), "must be");
  
    NonPermObject* &bucket = find_non_perm(keyHandle);
    if (bucket != nullptr) {
!     ciObject* obj = bucket->object();
+     notice_object_access(obj);
+     return obj;
    }
  
    // The ciObject does not yet exist.  Create it and insert it
    // into the cache.
    ciObject* new_object = create_new_object(keyHandle());

*** 249,15 ***
    init_ident_of(new_object);
    assert(Universe::heap()->is_in(new_object->get_oop()), "must be");
  
    // Not a perm-space object.
    insert_non_perm(bucket, keyHandle, new_object);
!   notice_new_object(new_object);
    return new_object;
  }
  
! void ciObjectFactory::notice_new_object(ciBaseObject* new_object) {
    if (TrainingData::need_data()) {
      ciEnv* env = ciEnv::current();
      if (env->task() != nullptr) {
        // Note: task will be null during init_compiler_runtime.
        CompileTrainingData* td = env->task()->training_data();
--- 251,16 ---
    init_ident_of(new_object);
    assert(Universe::heap()->is_in(new_object->get_oop()), "must be");
  
    // Not a perm-space object.
    insert_non_perm(bucket, keyHandle, new_object);
!   notice_object_access(new_object);
    return new_object;
  }
  
! #if INCLUDE_CDS
+ void ciObjectFactory::notice_object_access(ciBaseObject* new_object) {
    if (TrainingData::need_data()) {
      ciEnv* env = ciEnv::current();
      if (env->task() != nullptr) {
        // Note: task will be null during init_compiler_runtime.
        CompileTrainingData* td = env->task()->training_data();

*** 265,10 ***
--- 268,11 ---
          td->notice_jit_observation(env, new_object);
        }
      }
    }
  }
+ #endif
  
  int ciObjectFactory::metadata_compare(Metadata* const& key, ciMetadata* const& elt) {
    Metadata* value = elt->constant_encoding();
    if (key < value)      return -1;
    else if (key > value) return 1;

*** 345,14 ***
        // into the table.  We need to recompute our index.
        index = _ci_metadata.find_sorted<Metadata*, ciObjectFactory::metadata_compare>(key, found);
      }
      assert(!found, "no double insert");
      _ci_metadata.insert_before(index, new_object);
!     notice_new_object(new_object);
      return new_object;
    }
!   return _ci_metadata.at(index)->as_metadata();
  }
  
  // ------------------------------------------------------------------
  // ciObjectFactory::create_new_object
  //
--- 349,16 ---
        // into the table.  We need to recompute our index.
        index = _ci_metadata.find_sorted<Metadata*, ciObjectFactory::metadata_compare>(key, found);
      }
      assert(!found, "no double insert");
      _ci_metadata.insert_before(index, new_object);
!     notice_object_access(new_object);
      return new_object;
    }
!   ciMetadata* metadata = _ci_metadata.at(index)->as_metadata();
+   notice_object_access(metadata);
+   return metadata;
  }
  
  // ------------------------------------------------------------------
  // ciObjectFactory::create_new_object
  //

*** 412,13 ***
      methodHandle h_m(THREAD, (Method*)o);
      ciEnv *env = CURRENT_THREAD_ENV;
      ciInstanceKlass* holder = env->get_instance_klass(h_m()->method_holder());
      return new (arena()) ciMethod(h_m, holder);
    } else if (o->is_methodData()) {
!     // Hold methodHandle alive - might not be necessary ???
-     methodHandle h_m(THREAD, ((MethodData*)o)->method());
      return new (arena()) ciMethodData((MethodData*)o);
    }
  
    // The Metadata* is of some type not supported by the compiler interface.
    ShouldNotReachHere();
    return nullptr;
--- 418,15 ---
      methodHandle h_m(THREAD, (Method*)o);
      ciEnv *env = CURRENT_THREAD_ENV;
      ciInstanceKlass* holder = env->get_instance_klass(h_m()->method_holder());
      return new (arena()) ciMethod(h_m, holder);
    } else if (o->is_methodData()) {
!     // Callers ciMethod::ensure_method_data() and ::method_data() have MH already.
      return new (arena()) ciMethodData((MethodData*)o);
+   } else if (o->is_methodCounters()) {
+     // Caller ciMethod::ensure_method_counters() has MH already.
+     return new (arena()) ciMetadata(o);
    }
  
    // The Metadata* is of some type not supported by the compiler interface.
    ShouldNotReachHere();
    return nullptr;
< prev index next >