Replace the nterp threshold with the warmup threshold.
Replace a hardcoded value with one that can be changed at the command
line.
Test: test.py
Change-Id: I638da5b5cc2e56aa0857d2bf0862a2f8c2020949
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 5de7adf..45562c4 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1949,6 +1949,7 @@
if (!runtime->IsAotCompiler()) {
ScopedTrace trace("AppImage:UpdateCodeItemAndNterp");
bool can_use_nterp = interpreter::CanRuntimeUseNterp();
+ uint16_t hotness_threshold = runtime->GetJITOptions()->GetWarmupThreshold();
header.VisitPackedArtMethods([&](ArtMethod& method) REQUIRES_SHARED(Locks::mutator_lock_) {
// In the image, the `data` pointer field of the ArtMethod contains the code
// item offset. Change this to the actual pointer to the code item.
@@ -1958,7 +1959,7 @@
method.SetCodeItem(code_item);
// The hotness counter may have changed since we compiled the image, so
// reset it with the runtime value.
- method.ResetCounter();
+ method.ResetCounter(hotness_threshold);
}
// Set image methods' entry point that point to the interpreter bridge to the
// nterp entry point.
@@ -3687,6 +3688,7 @@
uint32_t last_dex_method_index = dex::kDexNoIndex;
size_t last_class_def_method_index = 0;
+ uint16_t hotness_threshold = runtime->GetJITOptions()->GetWarmupThreshold();
// Use the visitor since the ranged based loops are bit slower from seeking. Seeking to the
// methods needs to decode all of the fields.
accessor.VisitFieldsAndMethods([&](
@@ -3720,11 +3722,13 @@
last_dex_method_index = it_method_index;
last_class_def_method_index = class_def_method_index;
}
+ art_method->ResetCounter(hotness_threshold);
++class_def_method_index;
}, [&](const ClassAccessor::Method& method) REQUIRES_SHARED(Locks::mutator_lock_) {
ArtMethod* art_method = klass->GetVirtualMethodUnchecked(
class_def_method_index - accessor.NumDirectMethods(),
image_pointer_size_);
+ art_method->ResetCounter(hotness_threshold);
LoadMethod(dex_file, method, klass, art_method);
LinkCode(this, art_method, oat_class_ptr, class_def_method_index);
++class_def_method_index;