166 // Danger Will Robinson! This method allocates a big
167 // chunk of memory, its your job to free it.
168 if (p != NULL) {
169 _oop_maps = ImmutableOopMapSet::build_from(p);
170 } else {
171 _oop_maps = NULL;
172 }
173 }
174
175
176 void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) {
177 // Do not hold the CodeCache lock during name formatting.
178 assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");
179
180 if (stub != NULL) {
181 char stub_id[256];
182 assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");
183 jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2);
184 if (PrintStubCode) {
185 ttyLocker ttyl;
186 tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub);
187 Disassembler::decode(stub->code_begin(), stub->code_end());
188 tty->cr();
189 }
190 Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
191
192 if (JvmtiExport::should_post_dynamic_code_generated()) {
193 const char* stub_name = name2;
194 if (name2[0] == '\0') stub_name = name1;
195 JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
196 }
197 }
198
199 // Track memory usage statistic after releasing CodeCache_lock
200 MemoryService::track_code_cache_memory_usage();
201 }
202
203 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
204 assert(_oop_maps != NULL, "nope");
205 return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
206 }
207
246 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
247
248 BufferBlob* blob = NULL;
249 unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));
250 assert(name != NULL, "must provide a name");
251 {
252 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
253 blob = new (size) BufferBlob(name, size, cb);
254 }
255 // Track memory usage statistic after releasing CodeCache_lock
256 MemoryService::track_code_cache_memory_usage();
257
258 return blob;
259 }
260
261 void* BufferBlob::operator new(size_t s, unsigned size) throw() {
262 return CodeCache::allocate(size, CodeBlobType::NonNMethod);
263 }
264
265 void BufferBlob::free(BufferBlob *blob) {
266 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
267 blob->flush();
268 {
269 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
270 CodeCache::free((RuntimeBlob*)blob);
271 }
272 // Track memory usage statistic after releasing CodeCache_lock
273 MemoryService::track_code_cache_memory_usage();
274 }
275
276
277 //----------------------------------------------------------------------------------------------------
278 // Implementation of AdapterBlob
279
280 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
281 BufferBlob("I2C/C2I adapters", size, cb) {
282 CodeCache::commit(this);
283 }
284
285 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
|
166 // Danger Will Robinson! This method allocates a big
167 // chunk of memory, its your job to free it.
168 if (p != NULL) {
169 _oop_maps = ImmutableOopMapSet::build_from(p);
170 } else {
171 _oop_maps = NULL;
172 }
173 }
174
175
176 void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) {
177 // Do not hold the CodeCache lock during name formatting.
178 assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");
179
180 if (stub != NULL) {
181 char stub_id[256];
182 assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");
183 jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2);
184 if (PrintStubCode) {
185 ttyLocker ttyl;
186 tty->print_cr("- - - [BEGIN] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
187 tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub);
188 Disassembler::decode(stub->code_begin(), stub->code_end(), tty);
189 if ((stub->oop_maps() != NULL) && AbstractDisassembler::show_structs()) {
190 tty->print_cr("- - - [OOP MAPS]- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
191 stub->oop_maps()->print();
192 }
193 tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
194 tty->cr();
195 }
196 Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
197
198 if (JvmtiExport::should_post_dynamic_code_generated()) {
199 const char* stub_name = name2;
200 if (name2[0] == '\0') stub_name = name1;
201 JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
202 }
203 }
204
205 // Track memory usage statistic after releasing CodeCache_lock
206 MemoryService::track_code_cache_memory_usage();
207 }
208
209 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
210 assert(_oop_maps != NULL, "nope");
211 return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
212 }
213
252 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
253
254 BufferBlob* blob = NULL;
255 unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));
256 assert(name != NULL, "must provide a name");
257 {
258 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
259 blob = new (size) BufferBlob(name, size, cb);
260 }
261 // Track memory usage statistic after releasing CodeCache_lock
262 MemoryService::track_code_cache_memory_usage();
263
264 return blob;
265 }
266
267 void* BufferBlob::operator new(size_t s, unsigned size) throw() {
268 return CodeCache::allocate(size, CodeBlobType::NonNMethod);
269 }
270
271 void BufferBlob::free(BufferBlob *blob) {
272 assert(blob != NULL, "caller must check for NULL");
273 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
274 blob->flush();
275 {
276 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
277 CodeCache::free((RuntimeBlob*)blob);
278 }
279 // Track memory usage statistic after releasing CodeCache_lock
280 MemoryService::track_code_cache_memory_usage();
281 }
282
283
284 //----------------------------------------------------------------------------------------------------
285 // Implementation of AdapterBlob
286
287 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
288 BufferBlob("I2C/C2I adapters", size, cb) {
289 CodeCache::commit(this);
290 }
291
292 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
|