Skip to content

Commit 6a701b8

Browse files
committedFeb 26, 2025
Fix a problem with ciObject creation
1 parent 3268600 commit 6a701b8

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed
 

‎src/hotspot/share/ci/ciObjectFactory.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -234,35 +234,35 @@ void ciObjectFactory::remove_symbols() {
234234
ciObject* ciObjectFactory::get(oop key) {
235235
ASSERT_IN_VM;
236236

237-
assert(Universe::heap()->is_in(key), "must be");
237+
Handle keyHandle(Thread::current(), key);
238+
assert(Universe::heap()->is_in(keyHandle()), "must be");
238239

239-
NonPermObject* &bucket = find_non_perm(key);
240+
NonPermObject* &bucket = find_non_perm(keyHandle);
240241
if (bucket != nullptr) {
241242
return bucket->object();
242243
}
243244

244245
// The ciObject does not yet exist. Create it and insert it
245246
// into the cache.
246-
Handle keyHandle(Thread::current(), key);
247247
ciObject* new_object = create_new_object(keyHandle());
248248
assert(keyHandle() == new_object->get_oop(), "must be properly recorded");
249249
init_ident_of(new_object);
250250
assert(Universe::heap()->is_in(new_object->get_oop()), "must be");
251251

252252
// Not a perm-space object.
253-
insert_non_perm(bucket, keyHandle(), new_object);
253+
insert_non_perm(bucket, keyHandle, new_object);
254254
notice_new_object(new_object);
255255
return new_object;
256256
}
257257

258258
void ciObjectFactory::notice_new_object(ciBaseObject* new_object) {
259-
if (RecordTraining) {
259+
if (TrainingData::need_data()) {
260260
ciEnv* env = ciEnv::current();
261261
if (env->task() != nullptr) {
262262
// Note: task will be null during init_compiler_runtime.
263-
CompileTrainingData* tdata = env->task()->training_data();
264-
if (tdata != nullptr) {
265-
tdata->notice_jit_observation(env, new_object);
263+
CompileTrainingData* td = env->task()->training_data();
264+
if (td != nullptr) {
265+
td->notice_jit_observation(env, new_object);
266266
}
267267
}
268268
}
@@ -653,12 +653,12 @@ static ciObjectFactory::NonPermObject* emptyBucket = nullptr;
653653
// Use a small hash table, hashed on the klass of the key.
654654
// If there is no entry in the cache corresponding to this oop, return
655655
// the null tail of the bucket into which the oop should be inserted.
656-
ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(oop key) {
657-
assert(Universe::heap()->is_in(key), "must be");
658-
ciMetadata* klass = get_metadata(key->klass());
656+
ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(Handle keyHandle) {
657+
assert(Universe::heap()->is_in(keyHandle()), "must be");
658+
ciMetadata* klass = get_metadata(keyHandle->klass()); // This may safepoint!
659659
NonPermObject* *bp = &_non_perm_bucket[(unsigned) klass->hash() % NON_PERM_BUCKETS];
660660
for (NonPermObject* p; (p = (*bp)) != nullptr; bp = &p->next()) {
661-
if (is_equal(p, key)) break;
661+
if (is_equal(p, keyHandle())) break;
662662
}
663663
return (*bp);
664664
}
@@ -681,12 +681,12 @@ inline ciObjectFactory::NonPermObject::NonPermObject(ciObjectFactory::NonPermObj
681681
// ciObjectFactory::insert_non_perm
682682
//
683683
// Insert a ciObject into the non-perm table.
684-
void ciObjectFactory::insert_non_perm(ciObjectFactory::NonPermObject* &where, oop key, ciObject* obj) {
685-
assert(Universe::heap()->is_in_or_null(key), "must be");
684+
void ciObjectFactory::insert_non_perm(ciObjectFactory::NonPermObject* &where, Handle keyHandle, ciObject* obj) {
685+
assert(Universe::heap()->is_in_or_null(keyHandle()), "must be");
686686
assert(&where != &emptyBucket, "must not try to fill empty bucket");
687-
NonPermObject* p = new (arena()) NonPermObject(where, key, obj);
688-
assert(where == p && is_equal(p, key) && p->object() == obj, "entry must match");
689-
assert(find_non_perm(key) == p, "must find the same spot");
687+
NonPermObject* p = new (arena()) NonPermObject(where, keyHandle(), obj);
688+
assert(where == p && is_equal(p, keyHandle()) && p->object() == obj, "entry must match");
689+
assert(find_non_perm(keyHandle) == p, "must find the same spot");
690690
++_non_perm_count;
691691
}
692692

‎src/hotspot/share/ci/ciObjectFactory.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class ciObjectFactory : public ArenaObj {
7878
return p->object()->get_oop() == key;
7979
}
8080

81-
NonPermObject* &find_non_perm(oop key);
82-
void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
81+
NonPermObject* &find_non_perm(Handle keyHandle);
82+
void insert_non_perm(NonPermObject* &where, Handle keyHandle, ciObject* obj);
8383

8484
void init_ident_of(ciBaseObject* obj);
8585

0 commit comments

Comments
 (0)
Please sign in to comment.