diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index f9cbc90147930..4e558b24eddc2 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -581,6 +581,9 @@ CodeBlob* CodeCache::allocate(int size, CodeBlobType code_blob_type, bool handle assert(heap != nullptr, "No heap for given code_blob_type %d, heap is null", (int) code_blob_type); while (true) { + if ((EmulateFragmentation != 1) && (code_blob_type == CodeBlobType::MethodNonProfiled)) { + size *= EmulateFragmentation; + } cb = (CodeBlob*)heap->allocate(size); if (cb != nullptr) break; if (!heap->expand_by(CodeCacheExpansionSize)) { diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index fe9c14781cefb..a292eaac38638 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1544,6 +1544,10 @@ const int ObjectAlignmentInBytes = 8; product(bool, SegmentedCodeCache, false, \ "Use a segmented code cache") \ \ + product(uintx, EmulateFragmentation, 1, \ + "blow up the CodeHeap with code blobs larger than needed for nmethod") \ + range(1, 100) \ + \ product_pd(uintx, ReservedCodeCacheSize, \ "Reserved code cache size (in bytes) - maximum code cache size") \ constraint(VMPageSizeConstraintFunc, AtParse) \