< prev index next >

src/share/vm/code/stubs.cpp

Print this page
rev 13455 : 8166317: InterpreterCodeSize should be computed
Reviewed-by: kvn

@@ -22,10 +22,11 @@
  *
  */
 
 #include "precompiled.hpp"
 #include "code/codeBlob.hpp"
+#include "code/codeCache.hpp"
 #include "code/stubs.hpp"
 #include "memory/allocation.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "utilities/align.hpp"

@@ -87,10 +88,20 @@
   //       allocated in the constructor (i.e., we need to keep it around or look it
   //       up via CodeCache::find_blob(...).
   Unimplemented();
 }
 
+void StubQueue::deallocate_unused_tail() {
+  CodeBlob* blob = CodeCache::find_blob((void*)_stub_buffer);
+  // We also have to account for the extra space (i.e. header) used by the CodeBlob
+  // which provides our memory (see BufferBlob::create() in codeBlob.cpp).
+  size_t header_size = CodeBlob::align_code_offset(blob->header_size());
+  CodeCache::free_unused_tail(blob, header_size + used_space());
+  // Update the limits to the new, trimmed CodeBlob size
+  _buffer_size = blob->content_size();
+  _buffer_limit = blob->content_size();
+}
 
 Stub* StubQueue::stub_containing(address pc) const {
   if (contains(pc)) {
     for (Stub* s = first(); s != NULL; s = next(s)) {
       if (stub_contains(s, pc)) return s;
< prev index next >