372 // Implementation note: unloaded methods are currently stored in |
372 // Implementation note: unloaded methods are currently stored in |
373 // an unordered array, requiring a linear-time lookup for each |
373 // an unordered array, requiring a linear-time lookup for each |
374 // unloaded method. This may need to change. |
374 // unloaded method. This may need to change. |
375 ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder, |
375 ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder, |
376 ciSymbol* name, |
376 ciSymbol* name, |
377 ciSymbol* signature) { |
377 ciSymbol* signature, |
378 for (int i=0; i<_unloaded_methods->length(); i++) { |
378 ciInstanceKlass* accessor) { |
|
379 ciSignature* that = NULL; |
|
380 for (int i = 0; i < _unloaded_methods->length(); i++) { |
379 ciMethod* entry = _unloaded_methods->at(i); |
381 ciMethod* entry = _unloaded_methods->at(i); |
380 if (entry->holder()->equals(holder) && |
382 if (entry->holder()->equals(holder) && |
381 entry->name()->equals(name) && |
383 entry->name()->equals(name) && |
382 entry->signature()->as_symbol()->equals(signature)) { |
384 entry->signature()->as_symbol()->equals(signature)) { |
383 // We've found a match. |
385 // Short-circuit slow resolve. |
384 return entry; |
386 if (entry->signature()->accessing_klass() == accessor) { |
|
387 // We've found a match. |
|
388 return entry; |
|
389 } else { |
|
390 // Lazily create ciSignature |
|
391 if (that == NULL) that = new (arena()) ciSignature(accessor, constantPoolHandle(), signature); |
|
392 if (entry->signature()->equals(that)) { |
|
393 // We've found a match. |
|
394 return entry; |
|
395 } |
|
396 } |
385 } |
397 } |
386 } |
398 } |
387 |
399 |
388 // This is a new unloaded method. Create it and stick it in |
400 // This is a new unloaded method. Create it and stick it in |
389 // the cache. |
401 // the cache. |
390 ciMethod* new_method = new (arena()) ciMethod(holder, name, signature); |
402 ciMethod* new_method = new (arena()) ciMethod(holder, name, signature, accessor); |
391 |
403 |
392 init_ident_of(new_method); |
404 init_ident_of(new_method); |
393 _unloaded_methods->append(new_method); |
405 _unloaded_methods->append(new_method); |
394 |
406 |
395 return new_method; |
407 return new_method; |