@@ -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