1.1 --- a/src/share/vm/opto/compile.cpp Tue Dec 28 17:34:02 2010 -0800 1.2 +++ b/src/share/vm/opto/compile.cpp Wed Dec 29 10:41:43 2010 -0800 1.3 @@ -444,22 +444,32 @@ 1.4 } 1.5 1.6 1.7 +//-----------------------init_scratch_buffer_blob------------------------------ 1.8 +// Construct a temporary BufferBlob and cache it for this compile. 1.9 void Compile::init_scratch_buffer_blob(int const_size) { 1.10 - if (scratch_buffer_blob() != NULL) return; 1.11 + // If there is already a scratch buffer blob allocated and the 1.12 + // constant section is big enough, use it. Otherwise free the 1.13 + // current and allocate a new one. 1.14 + BufferBlob* blob = scratch_buffer_blob(); 1.15 + if ((blob != NULL) && (const_size <= _scratch_const_size)) { 1.16 + // Use the current blob. 1.17 + } else { 1.18 + if (blob != NULL) { 1.19 + BufferBlob::free(blob); 1.20 + } 1.21 1.22 - // Construct a temporary CodeBuffer to have it construct a BufferBlob 1.23 - // Cache this BufferBlob for this compile. 1.24 - ResourceMark rm; 1.25 - _scratch_const_size = const_size; 1.26 - int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); 1.27 - BufferBlob* blob = BufferBlob::create("Compile::scratch_buffer", size); 1.28 - // Record the buffer blob for next time. 1.29 - set_scratch_buffer_blob(blob); 1.30 - // Have we run out of code space? 1.31 - if (scratch_buffer_blob() == NULL) { 1.32 - // Let CompilerBroker disable further compilations. 1.33 - record_failure("Not enough space for scratch buffer in CodeCache"); 1.34 - return; 1.35 + ResourceMark rm; 1.36 + _scratch_const_size = const_size; 1.37 + int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); 1.38 + blob = BufferBlob::create("Compile::scratch_buffer", size); 1.39 + // Record the buffer blob for next time. 1.40 + set_scratch_buffer_blob(blob); 1.41 + // Have we run out of code space? 1.42 + if (scratch_buffer_blob() == NULL) { 1.43 + // Let CompilerBroker disable further compilations. 1.44 + record_failure("Not enough space for scratch buffer in CodeCache"); 1.45 + return; 1.46 + } 1.47 } 1.48 1.49 // Initialize the relocation buffers 1.50 @@ -468,13 +478,6 @@ 1.51 } 1.52 1.53 1.54 -void Compile::clear_scratch_buffer_blob() { 1.55 - assert(scratch_buffer_blob(), "no BufferBlob set"); 1.56 - set_scratch_buffer_blob(NULL); 1.57 - set_scratch_locs_memory(NULL); 1.58 -} 1.59 - 1.60 - 1.61 //-----------------------scratch_emit_size------------------------------------- 1.62 // Helper function that computes size by emitting code 1.63 uint Compile::scratch_emit_size(const Node* n) {