2263 static int _hits; // number of successful lookups |
2263 static int _hits; // number of successful lookups |
2264 static int _compact; // number of equals calls with compact signature |
2264 static int _compact; // number of equals calls with compact signature |
2265 #endif |
2265 #endif |
2266 |
2266 |
2267 AdapterHandlerEntry* bucket(int i) { |
2267 AdapterHandlerEntry* bucket(int i) { |
2268 return (AdapterHandlerEntry*)BasicHashtable::bucket(i); |
2268 return (AdapterHandlerEntry*)BasicHashtable<mtCode>::bucket(i); |
2269 } |
2269 } |
2270 |
2270 |
2271 public: |
2271 public: |
2272 AdapterHandlerTable() |
2272 AdapterHandlerTable() |
2273 : BasicHashtable(293, sizeof(AdapterHandlerEntry)) { } |
2273 : BasicHashtable<mtCode>(293, sizeof(AdapterHandlerEntry)) { } |
2274 |
2274 |
2275 // Create a new entry suitable for insertion in the table |
2275 // Create a new entry suitable for insertion in the table |
2276 AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) { |
2276 AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) { |
2277 AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable::new_entry(fingerprint->compute_hash()); |
2277 AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash()); |
2278 entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
2278 entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
2279 return entry; |
2279 return entry; |
2280 } |
2280 } |
2281 |
2281 |
2282 // Insert an entry into the table |
2282 // Insert an entry into the table |
2285 add_entry(index, entry); |
2285 add_entry(index, entry); |
2286 } |
2286 } |
2287 |
2287 |
2288 void free_entry(AdapterHandlerEntry* entry) { |
2288 void free_entry(AdapterHandlerEntry* entry) { |
2289 entry->deallocate(); |
2289 entry->deallocate(); |
2290 BasicHashtable::free_entry(entry); |
2290 BasicHashtable<mtCode>::free_entry(entry); |
2291 } |
2291 } |
2292 |
2292 |
2293 // Find a entry with the same fingerprint if it exists |
2293 // Find a entry with the same fingerprint if it exists |
2294 AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) { |
2294 AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) { |
2295 NOT_PRODUCT(_lookups++); |
2295 NOT_PRODUCT(_lookups++); |
2570 |
2570 |
2571 |
2571 |
2572 void AdapterHandlerEntry::deallocate() { |
2572 void AdapterHandlerEntry::deallocate() { |
2573 delete _fingerprint; |
2573 delete _fingerprint; |
2574 #ifdef ASSERT |
2574 #ifdef ASSERT |
2575 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code); |
2575 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code, mtCode); |
2576 if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig); |
2576 if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig, mtCode); |
2577 #endif |
2577 #endif |
2578 } |
2578 } |
2579 |
2579 |
2580 |
2580 |
2581 #ifdef ASSERT |
2581 #ifdef ASSERT |
2582 // Capture the code before relocation so that it can be compared |
2582 // Capture the code before relocation so that it can be compared |
2583 // against other versions. If the code is captured after relocation |
2583 // against other versions. If the code is captured after relocation |
2584 // then relative instructions won't be equivalent. |
2584 // then relative instructions won't be equivalent. |
2585 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { |
2585 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { |
2586 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length); |
2586 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length, mtCode); |
2587 _code_length = length; |
2587 _code_length = length; |
2588 memcpy(_saved_code, buffer, length); |
2588 memcpy(_saved_code, buffer, length); |
2589 _total_args_passed = total_args_passed; |
2589 _total_args_passed = total_args_passed; |
2590 _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed); |
2590 _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed, mtCode); |
2591 memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); |
2591 memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); |
2592 } |
2592 } |
2593 |
2593 |
2594 |
2594 |
2595 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { |
2595 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { |
2891 |
2891 |
2892 methodOop moop = fr.interpreter_frame_method(); |
2892 methodOop moop = fr.interpreter_frame_method(); |
2893 int max_locals = moop->max_locals(); |
2893 int max_locals = moop->max_locals(); |
2894 // Allocate temp buffer, 1 word per local & 2 per active monitor |
2894 // Allocate temp buffer, 1 word per local & 2 per active monitor |
2895 int buf_size_words = max_locals + active_monitor_count*2; |
2895 int buf_size_words = max_locals + active_monitor_count*2; |
2896 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words); |
2896 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words, mtCode); |
2897 |
2897 |
2898 // Copy the locals. Order is preserved so that loading of longs works. |
2898 // Copy the locals. Order is preserved so that loading of longs works. |
2899 // Since there's no GC I can copy the oops blindly. |
2899 // Since there's no GC I can copy the oops blindly. |
2900 assert( sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); |
2900 assert( sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); |
2901 Copy::disjoint_words((HeapWord*)fr.interpreter_frame_local_at(max_locals-1), |
2901 Copy::disjoint_words((HeapWord*)fr.interpreter_frame_local_at(max_locals-1), |
2921 |
2921 |
2922 return buf; |
2922 return buf; |
2923 JRT_END |
2923 JRT_END |
2924 |
2924 |
2925 JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) ) |
2925 JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) ) |
2926 FREE_C_HEAP_ARRAY(intptr_t,buf); |
2926 FREE_C_HEAP_ARRAY(intptr_t,buf, mtCode); |
2927 JRT_END |
2927 JRT_END |
2928 |
2928 |
2929 bool AdapterHandlerLibrary::contains(CodeBlob* b) { |
2929 bool AdapterHandlerLibrary::contains(CodeBlob* b) { |
2930 AdapterHandlerTableIterator iter(_adapters); |
2930 AdapterHandlerTableIterator iter(_adapters); |
2931 while (iter.has_next()) { |
2931 while (iter.has_next()) { |