hotspot/src/share/vm/code/stubs.cpp
changeset 46620 750c6edff33b
parent 42664 29142a56c193
child 46625 edefffab74e2
equal deleted inserted replaced
46619:a3919f5e8d2b 46620:750c6edff33b
    62 // ITS CORRECTNESS! THIS CODE IS MORE SUBTLE THAN IT LOOKS!
    62 // ITS CORRECTNESS! THIS CODE IS MORE SUBTLE THAN IT LOOKS!
    63 
    63 
    64 
    64 
    65 StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size,
    65 StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size,
    66                      Mutex* lock, const char* name) : _mutex(lock) {
    66                      Mutex* lock, const char* name) : _mutex(lock) {
    67   intptr_t size = round_to(buffer_size, 2*BytesPerWord);
    67   intptr_t size = align_up(buffer_size, 2*BytesPerWord);
    68   BufferBlob* blob = BufferBlob::create(name, size);
    68   BufferBlob* blob = BufferBlob::create(name, size);
    69   if( blob == NULL) {
    69   if( blob == NULL) {
    70     vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for %s", name);
    70     vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for %s", name);
    71   }
    71   }
    72   _stub_interface  = stub_interface;
    72   _stub_interface  = stub_interface;
   109 
   109 
   110 Stub* StubQueue::request(int requested_code_size) {
   110 Stub* StubQueue::request(int requested_code_size) {
   111   assert(requested_code_size > 0, "requested_code_size must be > 0");
   111   assert(requested_code_size > 0, "requested_code_size must be > 0");
   112   if (_mutex != NULL) _mutex->lock();
   112   if (_mutex != NULL) _mutex->lock();
   113   Stub* s = current_stub();
   113   Stub* s = current_stub();
   114   int requested_size = round_to(stub_code_size_to_size(requested_code_size), CodeEntryAlignment);
   114   int requested_size = align_up(stub_code_size_to_size(requested_code_size), CodeEntryAlignment);
   115   if (requested_size <= available_space()) {
   115   if (requested_size <= available_space()) {
   116     if (is_contiguous()) {
   116     if (is_contiguous()) {
   117       // Queue: |...|XXXXXXX|.............|
   117       // Queue: |...|XXXXXXX|.............|
   118       //        ^0  ^begin  ^end          ^size = limit
   118       //        ^0  ^begin  ^end          ^size = limit
   119       assert(_buffer_limit == _buffer_size, "buffer must be fully usable");
   119       assert(_buffer_limit == _buffer_size, "buffer must be fully usable");
   147 }
   147 }
   148 
   148 
   149 
   149 
   150 void StubQueue::commit(int committed_code_size, CodeStrings& strings) {
   150 void StubQueue::commit(int committed_code_size, CodeStrings& strings) {
   151   assert(committed_code_size > 0, "committed_code_size must be > 0");
   151   assert(committed_code_size > 0, "committed_code_size must be > 0");
   152   int committed_size = round_to(stub_code_size_to_size(committed_code_size), CodeEntryAlignment);
   152   int committed_size = align_up(stub_code_size_to_size(committed_code_size), CodeEntryAlignment);
   153   Stub* s = current_stub();
   153   Stub* s = current_stub();
   154   assert(committed_size <= stub_size(s), "committed size must not exceed requested size");
   154   assert(committed_size <= stub_size(s), "committed size must not exceed requested size");
   155   stub_initialize(s, committed_size, strings);
   155   stub_initialize(s, committed_size, strings);
   156   _queue_end += committed_size;
   156   _queue_end += committed_size;
   157   _number_of_stubs++;
   157   _number_of_stubs++;