Rewrite static/instance field search by index.

The old search was looking for a field with the given field
index in the class as well as superclasses and, for static
fields, all interfaces. This was useless as as a field index
can match only in the declaring class. So, if the field was
not found in the declaring class we would have unnecessarily
searched wrong classes before resorting to string search.

Reuse the optimized `Class::FindField` by turning it into
a template implementation that can skip unnecessary static
or instance field searches. Implementing the static and
instance field search this way allows ClassLinker to call
only one overload of `Class::Find{Static,Instance}Field`
and helps avoid string searches in more cases.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --interpreter
Bug: 181943478
Change-Id: I23309c87c3702d98812adfec0279c483c9037f2c
3 files changed