mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8366948: AOT cache creation crashes when iterating training data
Reviewed-by: vlivanov, iklam
This commit is contained in:
parent
a2870d6b49
commit
2aafda1968
@ -152,6 +152,9 @@ public:
|
||||
_lock_mode = need_data() ? +1 : -1; // if -1, we go lock-free
|
||||
#endif
|
||||
}
|
||||
static void assert_locked_or_snapshotted() {
|
||||
assert(safely_locked() || _snapshot, "use under TrainingDataLocker or after snapshot");
|
||||
}
|
||||
static void assert_locked() {
|
||||
assert(safely_locked(), "use under TrainingDataLocker");
|
||||
}
|
||||
@ -338,20 +341,24 @@ private:
|
||||
}
|
||||
|
||||
int length() const {
|
||||
TrainingDataLocker::assert_locked_or_snapshotted();
|
||||
return (_deps_dyn != nullptr ? _deps_dyn->length()
|
||||
: _deps != nullptr ? _deps->length()
|
||||
: 0);
|
||||
}
|
||||
E* adr_at(int i) const {
|
||||
TrainingDataLocker::assert_locked_or_snapshotted();
|
||||
return (_deps_dyn != nullptr ? _deps_dyn->adr_at(i)
|
||||
: _deps != nullptr ? _deps->adr_at(i)
|
||||
: nullptr);
|
||||
}
|
||||
E at(int i) const {
|
||||
TrainingDataLocker::assert_locked_or_snapshotted();
|
||||
assert(i >= 0 && i < length(), "oob");
|
||||
return *adr_at(i);
|
||||
}
|
||||
bool append_if_missing(E dep) {
|
||||
TrainingDataLocker::assert_can_add();
|
||||
if (_deps_dyn == nullptr) {
|
||||
_deps_dyn = new GrowableArrayCHeap<E, mtCompiler>(10);
|
||||
_deps_dyn->append(dep);
|
||||
@ -361,23 +368,27 @@ private:
|
||||
}
|
||||
}
|
||||
bool remove_if_existing(E dep) {
|
||||
TrainingDataLocker::assert_can_add();
|
||||
if (_deps_dyn != nullptr) {
|
||||
return _deps_dyn->remove_if_existing(dep);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void clear() {
|
||||
TrainingDataLocker::assert_can_add();
|
||||
if (_deps_dyn != nullptr) {
|
||||
_deps_dyn->clear();
|
||||
}
|
||||
}
|
||||
void append(E dep) {
|
||||
TrainingDataLocker::assert_can_add();
|
||||
if (_deps_dyn == nullptr) {
|
||||
_deps_dyn = new GrowableArrayCHeap<E, mtCompiler>(10);
|
||||
}
|
||||
_deps_dyn->append(dep);
|
||||
}
|
||||
bool contains(E dep) {
|
||||
TrainingDataLocker::assert_locked();
|
||||
for (int i = 0; i < length(); i++) {
|
||||
if (dep == at(i)) {
|
||||
return true; // found
|
||||
@ -591,6 +602,7 @@ public:
|
||||
DepList<Record> _data;
|
||||
public:
|
||||
OptionalReturnType find(const Args&... args) {
|
||||
TrainingDataLocker l;
|
||||
ArgumentsType a(args...);
|
||||
for (int i = 0; i < _data.length(); i++) {
|
||||
if (_data.at(i).arguments() == a) {
|
||||
@ -599,8 +611,11 @@ public:
|
||||
}
|
||||
return OptionalReturnType(false, ReturnType());
|
||||
}
|
||||
bool append_if_missing(const ReturnType& result, const Args&... args) {
|
||||
return _data.append_if_missing(Record(result, ArgumentsType(args...)));
|
||||
void append_if_missing(const ReturnType& result, const Args&... args) {
|
||||
TrainingDataLocker l;
|
||||
if (l.can_add()) {
|
||||
_data.append_if_missing(Record(result, ArgumentsType(args...)));
|
||||
}
|
||||
}
|
||||
#if INCLUDE_CDS
|
||||
void remove_unshareable_info() { _data.remove_unshareable_info(); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user