Skip to content

Commit 322f3a3

Browse files
committed
8381932: Publish stubgen entries when -XX:-AOTStubCaching configured
Reviewed-by: asmehra, kvn
1 parent aa5677a commit 322f3a3

3 files changed

Lines changed: 33 additions & 26 deletions

File tree

src/hotspot/share/code/aotCodeCache.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,11 +1862,8 @@ void AOTCodeReader::read_dbg_strings(DbgStrings& dbg_strings) {
18621862
// addresses, respectively, keyed by the relevant address
18631863

18641864
void AOTCodeAddressTable::hash_address(address addr, int idx) {
1865-
// only do this if we are caching stubs and we have a non-null
1866-
// address to record
1867-
if (!AOTStubCaching) {
1868-
return;
1869-
}
1865+
// only do this if we have a non-null address to record and the
1866+
// cache is open for dumping
18701867
if (addr == nullptr) {
18711868
return;
18721869
}
@@ -2515,10 +2512,11 @@ AOTStubData::AOTStubData(BlobId blob_id) :
25152512
// cannot be accessed before initialising the universe
25162513
if (blob_id == BlobId::stubgen_preuniverse_id) {
25172514
// invalidate any attempt to use this
2518-
_flags |= INVALID;
2515+
_flags = INVALID;
25192516
return;
25202517
}
25212518
if (AOTCodeCache::is_on()) {
2519+
_flags = OPEN;
25222520
// allow update of stub entry addresses
25232521
if (AOTCodeCache::is_using_stub()) {
25242522
// allow stub loading

src/hotspot/share/code/aotCodeCache.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ class AOTStubData : public StackObj {
236236
// whether we are loading or storing stubs or have encountered any
237237
// invalid stubs.
238238
enum Flags {
239-
USING = 1 << 0, // open and loading stubs
240-
DUMPING = 1 << 1, // open and storing stubs
241-
INVALID = 1 << 2, // found invalid stub when loading
239+
OPEN = 1 << 0, // cache is open
240+
USING = 1 << 1, // open and loading stubs
241+
DUMPING = 1 << 2, // open and storing stubs
242+
INVALID = 1 << 3, // found invalid stub when loading
242243
};
243244

244245
uint32_t _flags;
@@ -253,6 +254,7 @@ class AOTStubData : public StackObj {
253254

254255
~AOTStubData() CDS_ONLY({FREE_C_HEAP_ARRAY(StubAddrRange, _ranges);}) NOT_CDS({})
255256

257+
bool is_open() CDS_ONLY({ return (_flags & OPEN) != 0; }) NOT_CDS_RETURN_(false);
256258
bool is_using() CDS_ONLY({ return (_flags & USING) != 0; }) NOT_CDS_RETURN_(false);
257259
bool is_dumping() CDS_ONLY({ return (_flags & DUMPING) != 0; }) NOT_CDS_RETURN_(false);
258260
bool is_invalid() CDS_ONLY({ return (_flags & INVALID) != 0; }) NOT_CDS_RETURN_(false);

src/hotspot/share/runtime/stubRoutines.cpp

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,23 @@ static BufferBlob* initialize_stubs(BlobId blob_id,
178178
AOTStubData* stub_data_p = nullptr;
179179
LogTarget(Info, stubs) lt;
180180

181+
// we need to track and publish details of stubs in a stubgen blob
182+
// when we are 1) using stubs from the cache 2) dumping stubs to the
183+
// cache 3) generating stubs that may be needed by other cache
184+
// elements.
185+
186+
if (stub_data.is_open()) {
187+
stub_data_p = &stub_data;
188+
}
181189
if (code_size > 0 && stub_data.is_using()) {
182-
// AOTCodeEntry tracks and logs status of any cached blob
183-
bool loaded = stub_data.load_code_blob();
184-
if (loaded) {
190+
// try to load the blob and details of its stubs from cache. if
191+
// that fails we will still generate all necessary stubs
192+
if (stub_data.load_code_blob()) {
185193
if (lt.is_enabled()) {
186194
LogStream ls(lt);
187195
ls.print_cr("Found blob %s in AOT cache", StubInfo::name(blob_id));
188196
}
189-
stub_data_p = &stub_data;
190197
}
191-
} else if (stub_data.is_dumping()) {
192-
stub_data_p = &stub_data;
193198
}
194199

195200
// Even if we managed to load a blob from the AOT cache we still
@@ -236,17 +241,8 @@ static BufferBlob* initialize_stubs(BlobId blob_id,
236241
"increase %s, code_size: %d, used: %d, free: %d",
237242
assert_msg, code_size, buffer.total_content_size(), buffer.insts_remaining());
238243

239-
if (stub_data.is_using()) {
240-
// we generated some new entries so republish all entries TODO -
241-
// ensure we publish collect and publish the preuniverse stubs but
242-
// don't try to save them
243-
AOTCodeCache::publish_stub_addresses(*stubs_code, blob_id, &stub_data);
244-
if (lt.is_enabled()) {
245-
LogStream ls(lt);
246-
ls.print_cr("Republished entries for blob '%s'", buffer_name);
247-
}
248-
} else if (stub_data.is_dumping()) {
249-
// save the blob and publihs the entry addresses
244+
if (stub_data.is_dumping()) {
245+
// save the blob and publish the entry addresses
250246
if (stub_data.store_code_blob(*stubs_code, &buffer)) {
251247
if (lt.is_enabled()) {
252248
LogStream ls(lt);
@@ -258,6 +254,17 @@ static BufferBlob* initialize_stubs(BlobId blob_id,
258254
ls.print_cr("Failed to store blob '%s' to Startup Code Cache", buffer_name);
259255
}
260256
}
257+
} else if (stub_data.is_open()) {
258+
// we either loaded some entries or generated new entries so
259+
// publish all entries
260+
//
261+
// TODO - ensure we publish collect and publish the preuniverse
262+
// stubs but don't try to save them
263+
AOTCodeCache::publish_stub_addresses(*stubs_code, blob_id, &stub_data);
264+
if (lt.is_enabled()) {
265+
LogStream ls(lt);
266+
ls.print_cr("Republished entries for blob '%s'", buffer_name);
267+
}
261268
}
262269

263270
// close off recording of any further stubgen generation

0 commit comments

Comments
 (0)