< prev index next >

src/hotspot/share/ci/ciObjectFactory.cpp

Print this page
@@ -42,15 +42,17 @@
  #include "ci/ciTypeArray.hpp"
  #include "ci/ciTypeArrayKlass.hpp"
  #include "ci/ciUtilities.inline.hpp"
  #include "classfile/javaClasses.inline.hpp"
  #include "classfile/vmClasses.hpp"
+ #include "compiler/compileTask.hpp"
  #include "compiler/compiler_globals.hpp"
  #include "gc/shared/collectedHeap.inline.hpp"
  #include "memory/allocation.inline.hpp"
  #include "memory/universe.hpp"
  #include "oops/oop.inline.hpp"
+ #include "oops/trainingData.hpp"
  #include "runtime/handles.inline.hpp"
  #include "runtime/signature.hpp"
  #include "utilities/macros.hpp"
  
  // ciObjectFactory

@@ -248,13 +250,27 @@
    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 (RecordTraining) {
+     ciEnv* env = ciEnv::current();
+     if (env->task() != nullptr) {
+       // Note: task will be null during init_compiler_runtime.
+       CompileTrainingData* tdata = env->task()->training_data();
+       if (tdata != nullptr) {
+         tdata->notice_jit_observation(env, new_object);
+       }
+     }
+   }
+ }
+ 
  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;
    else                  return 0;

@@ -330,10 +346,11 @@
        // 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();
  }
  
< prev index next >