< prev index next >

src/share/vm/code/stubs.cpp

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


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeBlob.hpp"

  27 #include "code/stubs.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/mutexLocker.hpp"
  31 #include "utilities/align.hpp"
  32 
  33 
  34 // Implementation of StubQueue
  35 //
  36 // Standard wrap-around queue implementation; the queue dimensions
  37 // are specified by the _queue_begin & _queue_end indices. The queue
  38 // can be in two states (transparent to the outside):
  39 //
  40 // a) contiguous state: all queue entries in one block (or empty)
  41 //
  42 // Queue: |...|XXXXXXX|...............|
  43 //        ^0  ^begin  ^end            ^size = limit
  44 //            |_______|
  45 //            one block
  46 //


  72   }
  73   _stub_interface  = stub_interface;
  74   _buffer_size     = blob->content_size();
  75   _buffer_limit    = blob->content_size();
  76   _stub_buffer     = blob->content_begin();
  77   _queue_begin     = 0;
  78   _queue_end       = 0;
  79   _number_of_stubs = 0;
  80   register_queue(this);
  81 }
  82 
  83 
  84 StubQueue::~StubQueue() {
  85   // Note: Currently StubQueues are never destroyed so nothing needs to be done here.
  86   //       If we want to implement the destructor, we need to release the BufferBlob
  87   //       allocated in the constructor (i.e., we need to keep it around or look it
  88   //       up via CodeCache::find_blob(...).
  89   Unimplemented();
  90 }
  91 










  92 
  93 Stub* StubQueue::stub_containing(address pc) const {
  94   if (contains(pc)) {
  95     for (Stub* s = first(); s != NULL; s = next(s)) {
  96       if (stub_contains(s, pc)) return s;
  97     }
  98   }
  99   return NULL;
 100 }
 101 
 102 
 103 Stub* StubQueue::request_committed(int code_size) {
 104   Stub* s = request(code_size);
 105   CodeStrings strings;
 106   if (s != NULL) commit(code_size, strings);
 107   return s;
 108 }
 109 
 110 
 111 Stub* StubQueue::request(int requested_code_size) {




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeBlob.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "code/stubs.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/mutexLocker.hpp"
  32 #include "utilities/align.hpp"
  33 
  34 
  35 // Implementation of StubQueue
  36 //
  37 // Standard wrap-around queue implementation; the queue dimensions
  38 // are specified by the _queue_begin & _queue_end indices. The queue
  39 // can be in two states (transparent to the outside):
  40 //
  41 // a) contiguous state: all queue entries in one block (or empty)
  42 //
  43 // Queue: |...|XXXXXXX|...............|
  44 //        ^0  ^begin  ^end            ^size = limit
  45 //            |_______|
  46 //            one block
  47 //


  73   }
  74   _stub_interface  = stub_interface;
  75   _buffer_size     = blob->content_size();
  76   _buffer_limit    = blob->content_size();
  77   _stub_buffer     = blob->content_begin();
  78   _queue_begin     = 0;
  79   _queue_end       = 0;
  80   _number_of_stubs = 0;
  81   register_queue(this);
  82 }
  83 
  84 
  85 StubQueue::~StubQueue() {
  86   // Note: Currently StubQueues are never destroyed so nothing needs to be done here.
  87   //       If we want to implement the destructor, we need to release the BufferBlob
  88   //       allocated in the constructor (i.e., we need to keep it around or look it
  89   //       up via CodeCache::find_blob(...).
  90   Unimplemented();
  91 }
  92 
  93 void StubQueue::deallocate_unused_tail() {
  94   CodeBlob* blob = CodeCache::find_blob((void*)_stub_buffer);
  95   // We also have to account for the extra space (i.e. header) used by the CodeBlob
  96   // which provides our memory (see BufferBlob::create() in codeBlob.cpp).
  97   size_t header_size = CodeBlob::align_code_offset(blob->header_size());
  98   CodeCache::free_unused_tail(blob, header_size + used_space());
  99   // Update the limits to the new, trimmed CodeBlob size
 100   _buffer_size = blob->content_size();
 101   _buffer_limit = blob->content_size();
 102 }
 103 
 104 Stub* StubQueue::stub_containing(address pc) const {
 105   if (contains(pc)) {
 106     for (Stub* s = first(); s != NULL; s = next(s)) {
 107       if (stub_contains(s, pc)) return s;
 108     }
 109   }
 110   return NULL;
 111 }
 112 
 113 
 114 Stub* StubQueue::request_committed(int code_size) {
 115   Stub* s = request(code_size);
 116   CodeStrings strings;
 117   if (s != NULL) commit(code_size, strings);
 118   return s;
 119 }
 120 
 121 
 122 Stub* StubQueue::request(int requested_code_size) {


< prev index next >