Merge changes I4ca880f6,I6ebe18fe

* changes:
  Fix test failures with -Xjitthreshold:0.
  Pass --runtime-option from testrunner to run-test.
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 7a0850d..2284100 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -2338,10 +2338,6 @@
   ArtMethod* called = *sp;
   DCHECK(called->IsNative()) << called->PrettyMethod(true);
   Runtime* runtime = Runtime::Current();
-  jit::Jit* jit = runtime->GetJit();
-  if (jit != nullptr) {
-    jit->AddSamples(self, called, 1u, /*with_backedges*/ false);
-  }
   uint32_t shorty_len = 0;
   const char* shorty = called->GetShorty(&shorty_len);
   bool critical_native = called->IsCriticalNative();
@@ -2367,6 +2363,12 @@
 
   self->VerifyStack();
 
+  // We can now walk the stack if needed by JIT GC from MethodEntered() for JIT-on-first-use.
+  jit::Jit* jit = runtime->GetJit();
+  if (jit != nullptr) {
+    jit->MethodEntered(self, called);
+  }
+
   uint32_t cookie;
   uint32_t* sp32;
   // Skip calling JniMethodStart for @CriticalNative.
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 23cf071..813430f 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -718,10 +718,11 @@
   Runtime* runtime = Runtime::Current();
   if (UNLIKELY(runtime->UseJitCompilation() && runtime->GetJit()->JitAtFirstUse())) {
     ArtMethod* np_method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
-    DCHECK(!np_method->IsNative());
     if (np_method->IsCompilable()) {
-      // The compiler requires a ProfilingInfo object.
-      ProfilingInfo::Create(thread, np_method, /* retry_allocation */ true);
+      if (!np_method->IsNative()) {
+        // The compiler requires a ProfilingInfo object for non-native methods.
+        ProfilingInfo::Create(thread, np_method, /* retry_allocation */ true);
+      }
       JitCompileTask compile_task(method, JitCompileTask::kCompile);
       compile_task.Run(thread);
     }
diff --git a/test/1935-get-set-current-frame-jit/expected.txt b/test/1935-get-set-current-frame-jit/expected.txt
index fed993c..cdb8f6a 100644
--- a/test/1935-get-set-current-frame-jit/expected.txt
+++ b/test/1935-get-set-current-frame-jit/expected.txt
@@ -1,7 +1,7 @@
 JNI_OnLoad called
 From GetLocalInt(), value is 42
-isInterpreted? true
+isInOsrCode? false
 	Value is '42'
 Setting TARGET to 1337
-isInterpreted? true
+isInOsrCode? false
 	Value is '1337'
diff --git a/test/1935-get-set-current-frame-jit/src/Main.java b/test/1935-get-set-current-frame-jit/src/Main.java
index eb0a637..714a98a 100644
--- a/test/1935-get-set-current-frame-jit/src/Main.java
+++ b/test/1935-get-set-current-frame-jit/src/Main.java
@@ -64,9 +64,9 @@
         Main.ensureJitCompiled(IntRunner.class, "run");
         i++;
       }
-      // We shouldn't be doing OSR since we are using JVMTI and the get/set local will push us to
-      // interpreter.
-      System.out.println("isInterpreted? " + Main.isInterpreted());
+      // We shouldn't be doing OSR since we are using JVMTI and the get/set prevents OSR.
+      // Set local will also push us to interpreter but the get local may remain in compiled code.
+      System.out.println("isInOsrCode? " + (hasJit() && Main.isInOsrCode("run")));
       reportValue(TARGET);
     }
     public void waitForBusyLoopStart() { while (!inBusyLoop) {} }
@@ -159,4 +159,6 @@
 
   public static native void ensureJitCompiled(Class k, String f);
   public static native boolean isInterpreted();
+  public static native boolean isInOsrCode(String methodName);
+  public static native boolean hasJit();
 }
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index a2215f9..734a600 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -114,6 +114,7 @@
 build = False
 gdb = False
 gdb_arg = ''
+runtime_option = ''
 stop_testrunner = False
 dex2oat_jobs = -1   # -1 corresponds to default threads for dex2oat
 run_all_configs = False
@@ -346,6 +347,10 @@
     if gdb_arg:
       options_all += ' --gdb-arg ' + gdb_arg
 
+  if runtime_option:
+    for opt in runtime_option:
+      options_all += ' --runtime-option ' + opt
+
   if dex2oat_jobs != -1:
     options_all += ' --dex2oat-jobs ' + str(dex2oat_jobs)
 
@@ -921,6 +926,7 @@
   global build
   global gdb
   global gdb_arg
+  global runtime_option
   global timeout
   global dex2oat_jobs
   global run_all_configs
@@ -933,9 +939,9 @@
   global_group.add_argument('--timeout', default=timeout, type=int, dest='timeout')
   global_group.add_argument('--verbose', '-v', action='store_true', dest='verbose')
   global_group.add_argument('--dry-run', action='store_true', dest='dry_run')
-  global_group.add_argument("--skip", action="append", dest="skips", default=[],
+  global_group.add_argument("--skip", action='append', dest="skips", default=[],
                             help="Skip the given test in all circumstances.")
-  global_group.add_argument("--no-skips", dest="ignore_skips", action="store_true", default=False,
+  global_group.add_argument("--no-skips", dest="ignore_skips", action='store_true', default=False,
                             help="""Don't skip any run-test configurations listed in
                             knownfailures.json.""")
   global_group.add_argument('--no-build-dependencies',
@@ -950,6 +956,10 @@
   global_group.set_defaults(build = env.ART_TEST_RUN_TEST_BUILD)
   global_group.add_argument('--gdb', action='store_true', dest='gdb')
   global_group.add_argument('--gdb-arg', dest='gdb_arg')
+  global_group.add_argument('--runtime-option', action='append', dest='runtime_option',
+                            help="""Pass an option to the runtime. Runtime options
+                            starting with a '-' must be separated by a '=', for
+                            example '--runtime-option=-Xjitthreshold:0'.""")
   global_group.add_argument('--dex2oat-jobs', type=int, dest='dex2oat_jobs',
                             help='Number of dex2oat jobs')
   global_group.add_argument('-a', '--all', action='store_true', dest='run_all',
@@ -993,6 +1003,7 @@
     gdb = True
     if options['gdb_arg']:
       gdb_arg = options['gdb_arg']
+  runtime_option = options['runtime_option'];
   timeout = options['timeout']
   if options['dex2oat_jobs']:
     dex2oat_jobs = options['dex2oat_jobs']