Mercurial > hg > truffle
comparison src/share/vm/opto/compile.cpp @ 2091:51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
Summary: remove clear_scratch_buffer_blob and let init_scratch_buffer_blob free and allocate a new blob if required.
Reviewed-by: twisti
author | kvn |
---|---|
date | Wed, 29 Dec 2010 10:41:43 -0800 |
parents | 2f644f85485d |
children | b92c45f2bc75 |
comparison
equal
deleted
inserted
replaced
2090:2ddb2fab82cb | 2091:51bd2d261853 |
---|---|
442 } | 442 } |
443 #endif | 443 #endif |
444 } | 444 } |
445 | 445 |
446 | 446 |
447 //-----------------------init_scratch_buffer_blob------------------------------ | |
448 // Construct a temporary BufferBlob and cache it for this compile. | |
447 void Compile::init_scratch_buffer_blob(int const_size) { | 449 void Compile::init_scratch_buffer_blob(int const_size) { |
448 if (scratch_buffer_blob() != NULL) return; | 450 // If there is already a scratch buffer blob allocated and the |
449 | 451 // constant section is big enough, use it. Otherwise free the |
450 // Construct a temporary CodeBuffer to have it construct a BufferBlob | 452 // current and allocate a new one. |
451 // Cache this BufferBlob for this compile. | 453 BufferBlob* blob = scratch_buffer_blob(); |
452 ResourceMark rm; | 454 if ((blob != NULL) && (const_size <= _scratch_const_size)) { |
453 _scratch_const_size = const_size; | 455 // Use the current blob. |
454 int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); | 456 } else { |
455 BufferBlob* blob = BufferBlob::create("Compile::scratch_buffer", size); | 457 if (blob != NULL) { |
456 // Record the buffer blob for next time. | 458 BufferBlob::free(blob); |
457 set_scratch_buffer_blob(blob); | 459 } |
458 // Have we run out of code space? | 460 |
459 if (scratch_buffer_blob() == NULL) { | 461 ResourceMark rm; |
460 // Let CompilerBroker disable further compilations. | 462 _scratch_const_size = const_size; |
461 record_failure("Not enough space for scratch buffer in CodeCache"); | 463 int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); |
462 return; | 464 blob = BufferBlob::create("Compile::scratch_buffer", size); |
465 // Record the buffer blob for next time. | |
466 set_scratch_buffer_blob(blob); | |
467 // Have we run out of code space? | |
468 if (scratch_buffer_blob() == NULL) { | |
469 // Let CompilerBroker disable further compilations. | |
470 record_failure("Not enough space for scratch buffer in CodeCache"); | |
471 return; | |
472 } | |
463 } | 473 } |
464 | 474 |
465 // Initialize the relocation buffers | 475 // Initialize the relocation buffers |
466 relocInfo* locs_buf = (relocInfo*) blob->content_end() - MAX_locs_size; | 476 relocInfo* locs_buf = (relocInfo*) blob->content_end() - MAX_locs_size; |
467 set_scratch_locs_memory(locs_buf); | 477 set_scratch_locs_memory(locs_buf); |
468 } | |
469 | |
470 | |
471 void Compile::clear_scratch_buffer_blob() { | |
472 assert(scratch_buffer_blob(), "no BufferBlob set"); | |
473 set_scratch_buffer_blob(NULL); | |
474 set_scratch_locs_memory(NULL); | |
475 } | 478 } |
476 | 479 |
477 | 480 |
478 //-----------------------scratch_emit_size------------------------------------- | 481 //-----------------------scratch_emit_size------------------------------------- |
479 // Helper function that computes size by emitting code | 482 // Helper function that computes size by emitting code |