1 /* |
1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
252 return false; |
252 return false; |
253 } |
253 } |
254 |
254 |
255 |
255 |
256 address ExceptionCache::test_address(address addr) { |
256 address ExceptionCache::test_address(address addr) { |
257 for (int i=0; i<count(); i++) { |
257 int limit = count(); |
|
258 for (int i = 0; i < limit; i++) { |
258 if (pc_at(i) == addr) { |
259 if (pc_at(i) == addr) { |
259 return handler_at(i); |
260 return handler_at(i); |
260 } |
261 } |
261 } |
262 } |
262 return NULL; |
263 return NULL; |
263 } |
264 } |
264 |
265 |
265 |
266 |
266 bool ExceptionCache::add_address_and_handler(address addr, address handler) { |
267 bool ExceptionCache::add_address_and_handler(address addr, address handler) { |
267 if (test_address(addr) == handler) return true; |
268 if (test_address(addr) == handler) return true; |
268 if (count() < cache_size) { |
269 |
269 set_pc_at(count(),addr); |
270 int index = count(); |
270 set_handler_at(count(), handler); |
271 if (index < cache_size) { |
|
272 set_pc_at(index, addr); |
|
273 set_handler_at(index, handler); |
271 increment_count(); |
274 increment_count(); |
272 return true; |
275 return true; |
273 } |
276 } |
274 return false; |
277 return false; |
275 } |
278 } |
378 void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) { |
381 void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) { |
379 assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock"); |
382 assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock"); |
380 assert(new_entry != NULL,"Must be non null"); |
383 assert(new_entry != NULL,"Must be non null"); |
381 assert(new_entry->next() == NULL, "Must be null"); |
384 assert(new_entry->next() == NULL, "Must be null"); |
382 |
385 |
383 if (exception_cache() != NULL) { |
386 ExceptionCache *ec = exception_cache(); |
384 new_entry->set_next(exception_cache()); |
387 if (ec != NULL) { |
385 } |
388 new_entry->set_next(ec); |
386 set_exception_cache(new_entry); |
389 } |
|
390 release_set_exception_cache(new_entry); |
387 } |
391 } |
388 |
392 |
389 void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) { |
393 void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) { |
390 ExceptionCache* prev = NULL; |
394 ExceptionCache* prev = NULL; |
391 ExceptionCache* curr = exception_cache(); |
395 ExceptionCache* curr = exception_cache(); |