title: Why is -XX:ReservedCodeCacheSize not getting applied?
body: <p>I tried to understand how <code>-XX:ReservedCodeCacheSize=512m</code> works but it did not get applied when running java as follows: </p>
  
  <p><code>java --version -XX:ReservedCodeCacheSize=512m</code></p>
  
  <p>It simply set to the default <code>48M</code> on <code>x86</code> at this <a href="https://hg.openjdk.java.net/jdk/jdk12/file/06222165c35f/src/hotspot/cpu/x86/c2_globals_x86.hpp#l87" rel="nofollow noreferrer">point</a>:</p>
  
  <pre><code>define_pd_global(uintx, ReservedCodeCacheSize,       48*M);
  </code></pre>
  
  <p>And then got 5 times increased at that <a href="https://hg.openjdk.java.net/jdk/jdk12/file/06222165c35f/src/hotspot/share/compiler/compilerDefinitions.cpp#l201" rel="nofollow noreferrer">point</a>:</p>
  
  <pre><code>// Increase the code cache size - tiered compiles a lot more.
  if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
      FLAG_SET_ERGO(uintx, ReservedCodeCacheSize,
                    MIN2(CODE_CACHE_DEFAULT_LIMIT, (size_t)ReservedCodeCacheSize * 5));
    }
  </code></pre>
  
  <p>causing <a href="https://hg.openjdk.java.net/jdk/jdk12/file/06222165c35f/src/hotspot/share/code/codeCache.cpp#l303" rel="nofollow noreferrer">reservation code space</a> to <code>48*5 M</code> instead of the value I configured:</p>
  
  <pre><code>size_t cache_size         = ReservedCodeCacheSize;
  //...
  ReservedCodeSpace rs = reserve_heap_memory(cache_size);
  </code></pre>
  
  <p>I first though that <code>ReservedCodeCacheSize</code> is a development option and therefore not allowed to be overriden, but it is marked as product <a href="https://hg.openjdk.java.net/jdk/jdk12/file/06222165c35f/src/hotspot/share/runtime/globals.hpp#l1881" rel="nofollow noreferrer">here</a> so this is not the case.</p>
  
  <p>What's wrong and why was the option silently ignored?</p>