50 // |___| |_______|
51 // 1st block 2nd block
52 //
53 // In the non-contiguous state, the wrap-around point is
54 // indicated via the _buffer_limit index since the last
55 // queue entry may not fill up the queue completely in
56 // which case we need to know where the 2nd block's end
57 // is to do the proper wrap-around. When removing the
58 // last entry of the 2nd block, _buffer_limit is reset
59 // to _buffer_size.
60 //
61 // CAUTION: DO NOT MESS WITH THIS CODE IF YOU CANNOT PROVE
62 // ITS CORRECTNESS! THIS CODE IS MORE SUBTLE THAN IT LOOKS!
63
64
65 StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size,
66 Mutex* lock, const char* name) : _mutex(lock) {
67 intptr_t size = round_to(buffer_size, 2*BytesPerWord);
68 BufferBlob* blob = BufferBlob::create(name, size);
69 if( blob == NULL) {
70 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, err_msg("CodeCache: no room for %s", name));
71 }
72 _stub_interface = stub_interface;
73 _buffer_size = blob->content_size();
74 _buffer_limit = blob->content_size();
75 _stub_buffer = blob->content_begin();
76 _queue_begin = 0;
77 _queue_end = 0;
78 _number_of_stubs = 0;
79 register_queue(this);
80 }
81
82
83 StubQueue::~StubQueue() {
84 // Note: Currently StubQueues are never destroyed so nothing needs to be done here.
85 // If we want to implement the destructor, we need to release the BufferBlob
86 // allocated in the constructor (i.e., we need to keep it around or look it
87 // up via CodeCache::find_blob(...).
88 Unimplemented();
89 }
90
|
50 // |___| |_______|
51 // 1st block 2nd block
52 //
53 // In the non-contiguous state, the wrap-around point is
54 // indicated via the _buffer_limit index since the last
55 // queue entry may not fill up the queue completely in
56 // which case we need to know where the 2nd block's end
57 // is to do the proper wrap-around. When removing the
58 // last entry of the 2nd block, _buffer_limit is reset
59 // to _buffer_size.
60 //
61 // CAUTION: DO NOT MESS WITH THIS CODE IF YOU CANNOT PROVE
62 // ITS CORRECTNESS! THIS CODE IS MORE SUBTLE THAN IT LOOKS!
63
64
65 StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size,
66 Mutex* lock, const char* name) : _mutex(lock) {
67 intptr_t size = round_to(buffer_size, 2*BytesPerWord);
68 BufferBlob* blob = BufferBlob::create(name, size);
69 if( blob == NULL) {
70 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for %s", name);
71 }
72 _stub_interface = stub_interface;
73 _buffer_size = blob->content_size();
74 _buffer_limit = blob->content_size();
75 _stub_buffer = blob->content_begin();
76 _queue_begin = 0;
77 _queue_end = 0;
78 _number_of_stubs = 0;
79 register_queue(this);
80 }
81
82
83 StubQueue::~StubQueue() {
84 // Note: Currently StubQueues are never destroyed so nothing needs to be done here.
85 // If we want to implement the destructor, we need to release the BufferBlob
86 // allocated in the constructor (i.e., we need to keep it around or look it
87 // up via CodeCache::find_blob(...).
88 Unimplemented();
89 }
90
|