Fix dlsym lookup trampoline for @CriticalNative.

For @CriticalNative we do not have the JniEnv* argument to
retrieve the Thread*, we must use the thread register.

The test 178-app-image-native-method was supposed to cover
this but the profile was missing the necessary references.
We add those references and add $noinline$opt$ tags to make
sure the test actually runs the way it was supposed to and
add extra calls to the critical methods as they can take
different paths on subsequent execution.

Also add an extra test for class initialization checks that
ensures correct behavior for planned direct calls from
compiled managed code to registered @CriticalNative code.

Test: testrunner.py --target --optimizing -t 178
Bug: 112189621
Change-Id: I6a63d990bc08236ebaac7dacb0f5979d835ee321
diff --git a/test/178-app-image-native-method/run b/test/178-app-image-native-method/run
index f4b07f0..7cd0d57 100644
--- a/test/178-app-image-native-method/run
+++ b/test/178-app-image-native-method/run
@@ -14,8 +14,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Use a profile to put specific classes in the app image.
-${RUN} $@ --profile -Xcompiler-option --compiler-filter=speed-profile
+# Use a profile to put specific classes in the app image. Increase the large
+# method threshold to compile Main.$noinline$opt$testCriticalSignatures().
+${RUN} $@ --profile -Xcompiler-option --compiler-filter=speed-profile \
+    -Xcompiler-option --large-method-max=2000
 return_status1=$?
 
 # Also run with the verify filter to avoid compiling JNI stubs.