< prev index next >

src/share/vm/asm/codeBuffer.cpp

Print this page
rev 8847 : 8140482: Various minor code improvements (runtime)
Reviewed-by: dholmes, coleenp, sspitsyn, dsamersoff


 841     static int expand_count = 0;
 842     if (expand_count >= 0)  expand_count += 1;
 843     if (expand_count > 100 && is_power_of_2(expand_count)) {
 844       tty->print_cr("StressCodeBuffers: have expanded %d times", expand_count);
 845       // simulate an occasional allocation failure:
 846       free_blob();
 847     }
 848   }
 849 #endif //PRODUCT
 850 
 851   // Resizing must be allowed
 852   {
 853     if (blob() == NULL)  return;  // caller must check for blob == NULL
 854     for (int n = 0; n < (int)SECT_LIMIT; n++) {
 855       guarantee(!code_section(n)->is_frozen(), "resizing not allowed when frozen");
 856     }
 857   }
 858 
 859   // Figure new capacity for each section.
 860   csize_t new_capacity[SECT_LIMIT];

 861   csize_t new_total_cap
 862     = figure_expanded_capacities(which_cs, amount, new_capacity);
 863 
 864   // Create a new (temporary) code buffer to hold all the new data
 865   CodeBuffer cb(name(), new_total_cap, 0);
 866   if (cb.blob() == NULL) {
 867     // Failed to allocate in code cache.
 868     free_blob();
 869     return;
 870   }
 871 
 872   // Create an old code buffer to remember which addresses used to go where.
 873   // This will be useful when we do final assembly into the code cache,
 874   // because we will need to know how to warp any internal address that
 875   // has been created at any time in this CodeBuffer's past.
 876   CodeBuffer* bxp = new CodeBuffer(_total_start, _total_size);
 877   bxp->take_over_code_from(this);  // remember the old undersized blob
 878   DEBUG_ONLY(this->_blob = NULL);  // silence a later assert
 879   bxp->_before_expand = this->_before_expand;
 880   this->_before_expand = bxp;




 841     static int expand_count = 0;
 842     if (expand_count >= 0)  expand_count += 1;
 843     if (expand_count > 100 && is_power_of_2(expand_count)) {
 844       tty->print_cr("StressCodeBuffers: have expanded %d times", expand_count);
 845       // simulate an occasional allocation failure:
 846       free_blob();
 847     }
 848   }
 849 #endif //PRODUCT
 850 
 851   // Resizing must be allowed
 852   {
 853     if (blob() == NULL)  return;  // caller must check for blob == NULL
 854     for (int n = 0; n < (int)SECT_LIMIT; n++) {
 855       guarantee(!code_section(n)->is_frozen(), "resizing not allowed when frozen");
 856     }
 857   }
 858 
 859   // Figure new capacity for each section.
 860   csize_t new_capacity[SECT_LIMIT];
 861   memset(new_capacity, 0, sizeof(csize_t) * SECT_LIMIT);
 862   csize_t new_total_cap
 863     = figure_expanded_capacities(which_cs, amount, new_capacity);
 864 
 865   // Create a new (temporary) code buffer to hold all the new data
 866   CodeBuffer cb(name(), new_total_cap, 0);
 867   if (cb.blob() == NULL) {
 868     // Failed to allocate in code cache.
 869     free_blob();
 870     return;
 871   }
 872 
 873   // Create an old code buffer to remember which addresses used to go where.
 874   // This will be useful when we do final assembly into the code cache,
 875   // because we will need to know how to warp any internal address that
 876   // has been created at any time in this CodeBuffer's past.
 877   CodeBuffer* bxp = new CodeBuffer(_total_start, _total_size);
 878   bxp->take_over_code_from(this);  // remember the old undersized blob
 879   DEBUG_ONLY(this->_blob = NULL);  // silence a later assert
 880   bxp->_before_expand = this->_before_expand;
 881   this->_before_expand = bxp;


< prev index next >