summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2019-07-29 15:10:31 +0100
committer David Srbecky <dsrbecky@google.com> 2019-07-31 09:40:18 +0000
commit2182147af64ac462635d212473c3ffab400a7831 (patch)
treea529e9cc57c2b720f35f3a74407b8ec281e6c65d
parente65ade70584728c544c8db5a4e0a729750813380 (diff)
Call Jit::MaybeCompileMethod less frequently.
We have added more logic into the method (and may still add more). Test: test.py -b --host --64 --jit Change-Id: I8198db36b42a63c9e4ebf88651bea0e1ae70d5ae
-rw-r--r--runtime/jit/jit-inl.h4
-rw-r--r--runtime/jit/jit.cc11
-rw-r--r--runtime/jit/jit.h5
-rw-r--r--test/638-checker-inline-cache-intrinsic/run4
-rw-r--r--test/638-checker-inline-cache-intrinsic/src/Main.java4
5 files changed, 13 insertions, 15 deletions
diff --git a/runtime/jit/jit-inl.h b/runtime/jit/jit-inl.h
index 80324addcb..e6b4095e1d 100644
--- a/runtime/jit/jit-inl.h
+++ b/runtime/jit/jit-inl.h
@@ -46,14 +46,12 @@ inline void Jit::AddSamples(Thread* self,
// NB: The method needs to see the transitions of the counter past the thresholds.
uint32_t old_batch = RoundDown(old_count, kJitSamplesBatchSize); // Clear lower bits.
uint32_t new_batch = RoundDown(new_count, kJitSamplesBatchSize); // Clear lower bits.
- if (UNLIKELY(old_batch == 0)) {
- // For low sample counts, we check every time (which is important for tests).
+ if (UNLIKELY(kSlowMode)) { // Check every time in slow-debug mode.
if (!MaybeCompileMethod(self, method, old_count, new_count, with_backedges)) {
// Tests may check that the counter is 0 for methods that we never compile.
return; // Ignore the samples for now and retry later.
}
} else if (UNLIKELY(old_batch != new_batch)) {
- // For high sample counts, we check only when we move past the batch boundary.
if (!MaybeCompileMethod(self, method, old_batch, new_batch, with_backedges)) {
// OSR compilation will ignore the samples if they don't have backedges.
return; // Ignore the samples for now and retry later.
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 6bdc8dee1c..902d92494c 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -59,6 +59,8 @@ static constexpr size_t kJitDefaultCompileThreshold = 10000; // Non-d
static constexpr size_t kJitStressDefaultCompileThreshold = 100; // Fast-debug build.
static constexpr size_t kJitSlowStressDefaultCompileThreshold = 2; // Slow-debug build.
+DEFINE_RUNTIME_DEBUG_FLAG(Jit, kSlowMode);
+
// JIT compiler
void* Jit::jit_library_handle_ = nullptr;
void* Jit::jit_compiler_handle_ = nullptr;
@@ -70,13 +72,8 @@ void (*Jit::jit_types_loaded_)(void*, mirror::Class**, size_t count) = nullptr;
bool (*Jit::jit_generate_debug_info_)(void*) = nullptr;
void (*Jit::jit_update_options_)(void*) = nullptr;
-struct StressModeHelper {
- DECLARE_RUNTIME_DEBUG_FLAG(kSlowMode);
-};
-DEFINE_RUNTIME_DEBUG_FLAG(StressModeHelper, kSlowMode);
-
uint32_t JitOptions::RoundUpThreshold(uint32_t threshold) {
- if (threshold > kJitSamplesBatchSize) {
+ if (!Jit::kSlowMode) {
threshold = RoundUp(threshold, kJitSamplesBatchSize);
}
CHECK_LE(threshold, std::numeric_limits<uint16_t>::max());
@@ -103,7 +100,7 @@ JitOptions* JitOptions::CreateFromRuntimeArguments(const RuntimeArgumentMap& opt
} else {
jit_options->compile_threshold_ =
kIsDebugBuild
- ? (StressModeHelper::kSlowMode
+ ? (Jit::kSlowMode
? kJitSlowStressDefaultCompileThreshold
: kJitStressDefaultCompileThreshold)
: kJitDefaultCompileThreshold;
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index 0147f37325..1c7be7cc37 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -20,6 +20,7 @@
#include "base/histogram-inl.h"
#include "base/macros.h"
#include "base/mutex.h"
+#include "base/runtime_debug.h"
#include "base/timing_logger.h"
#include "handle.h"
#include "jit/profile_saver_options.h"
@@ -54,7 +55,7 @@ static constexpr int16_t kJitHotnessDisabled = -2;
// At what priority to schedule jit threads. 9 is the lowest foreground priority on device.
// See android/os/Process.java.
static constexpr int kJitPoolThreadPthreadDefaultPriority = 9;
-static constexpr uint32_t kJitSamplesBatchSize = 32; // Must be power of 2.
+static constexpr uint32_t kJitSamplesBatchSize = 1024; // Must be power of 2.
class JitOptions {
public:
@@ -168,6 +169,8 @@ class Jit {
// How frequently should the interpreter check to see if OSR compilation is ready.
static constexpr int16_t kJitRecheckOSRThreshold = 101; // Prime number to avoid patterns.
+ DECLARE_RUNTIME_DEBUG_FLAG(kSlowMode);
+
virtual ~Jit();
// Create JIT itself.
diff --git a/test/638-checker-inline-cache-intrinsic/run b/test/638-checker-inline-cache-intrinsic/run
index 15403100f5..d5d03cd050 100644
--- a/test/638-checker-inline-cache-intrinsic/run
+++ b/test/638-checker-inline-cache-intrinsic/run
@@ -14,6 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Set threshold to 100 to math the iterations done in the test.
+# Set threshold to 1000 to match the iterations done in the test.
# Pass --verbose-methods to only generate the CFG of these methods.
-exec ${RUN} --jit --runtime-option -Xjitthreshold:100 -Xcompiler-option --verbose-methods=inlineMonomorphic,knownReceiverType,stringEquals $@
+exec ${RUN} --jit --runtime-option -Xjitthreshold:1000 -Xcompiler-option --verbose-methods=inlineMonomorphic,knownReceiverType,stringEquals $@
diff --git a/test/638-checker-inline-cache-intrinsic/src/Main.java b/test/638-checker-inline-cache-intrinsic/src/Main.java
index 4a9aba570c..1449f0a867 100644
--- a/test/638-checker-inline-cache-intrinsic/src/Main.java
+++ b/test/638-checker-inline-cache-intrinsic/src/Main.java
@@ -64,10 +64,10 @@ public class Main {
public static void test() {
// Warm up inline cache.
- for (int i = 0; i < 45; i++) {
+ for (int i = 0; i < 450; i++) {
$noinline$inlineMonomorphic(str);
}
- for (int i = 0; i < 60; i++) {
+ for (int i = 0; i < 600; i++) {
$noinline$stringEquals(str);
}
ensureJitCompiled(Main.class, "$noinline$stringEquals");