Merge "Test assembler driver utilities."
diff --git a/compiler/optimizing/bounds_check_elimination.cc b/compiler/optimizing/bounds_check_elimination.cc
index 6b832da..a170734 100644
--- a/compiler/optimizing/bounds_check_elimination.cc
+++ b/compiler/optimizing/bounds_check_elimination.cc
@@ -596,6 +596,7 @@
// Helper method to assign a new range to an instruction in given basic block.
void AssignRange(HBasicBlock* basic_block, HInstruction* instruction, ValueRange* range) {
+ DCHECK(!range->IsMonotonicValueRange() || instruction->IsLoopHeaderPhi());
GetValueRangeMap(basic_block)->Overwrite(instruction->GetId(), range);
}
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 835d940..9e5ecd0 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4427,10 +4427,6 @@
DCHECK(proxy_constructor != nullptr)
<< "Could not find <init> method in java.lang.reflect.Proxy";
- // Ensure constructor is in dex cache so that we can use the dex cache to look up the overridden
- // constructor method.
- GetClassRoot(kJavaLangReflectProxy)->GetDexCache()->SetResolvedMethod(
- proxy_constructor->GetDexMethodIndex(), proxy_constructor, image_pointer_size_);
// Clone the existing constructor of Proxy (our constructor would just invoke it so steal its
// code_ too)
DCHECK(out != nullptr);
@@ -4457,15 +4453,6 @@
void ClassLinker::CreateProxyMethod(Handle<mirror::Class> klass, ArtMethod* prototype,
ArtMethod* out) {
- // Ensure prototype is in dex cache so that we can use the dex cache to look up the overridden
- // prototype method
- auto* dex_cache = prototype->GetDeclaringClass()->GetDexCache();
- // Avoid dirtying the dex cache unless we need to.
- if (dex_cache->GetResolvedMethod(prototype->GetDexMethodIndex(), image_pointer_size_) !=
- prototype) {
- dex_cache->SetResolvedMethod(
- prototype->GetDexMethodIndex(), prototype, image_pointer_size_);
- }
// We steal everything from the prototype (such as DexCache, invoke stub, etc.) then specialize
// as necessary
DCHECK(out != nullptr);
diff --git a/runtime/interpreter/mterp/arm/entry.S b/runtime/interpreter/mterp/arm/entry.S
index e53c054..ce14b54 100644
--- a/runtime/interpreter/mterp/arm/entry.S
+++ b/runtime/interpreter/mterp/arm/entry.S
@@ -67,6 +67,7 @@
/* Set up for backwards branches & osr profiling */
ldr r0, [rFP, #OFF_FP_METHOD]
add r1, rFP, #OFF_FP_SHADOWFRAME
+ mov r2, rSELF
bl MterpSetUpHotnessCountdown
mov rPROFILE, r0 @ Starting hotness countdown to rPROFILE
diff --git a/runtime/interpreter/mterp/arm64/entry.S b/runtime/interpreter/mterp/arm64/entry.S
index 441c1a1..73c5a88 100644
--- a/runtime/interpreter/mterp/arm64/entry.S
+++ b/runtime/interpreter/mterp/arm64/entry.S
@@ -60,6 +60,7 @@
/* Set up for backwards branches & osr profiling */
ldr x0, [xFP, #OFF_FP_METHOD]
add x1, xFP, #OFF_FP_SHADOWFRAME
+ mov x2, xSELF
bl MterpSetUpHotnessCountdown
mov wPROFILE, w0 // Starting hotness countdown to xPROFILE
diff --git a/runtime/interpreter/mterp/mips/entry.S b/runtime/interpreter/mterp/mips/entry.S
index c806a67..f617a4d 100644
--- a/runtime/interpreter/mterp/mips/entry.S
+++ b/runtime/interpreter/mterp/mips/entry.S
@@ -63,7 +63,8 @@
/* Set up for backwards branches & osr profiling */
lw a0, OFF_FP_METHOD(rFP)
addu a1, rFP, OFF_FP_SHADOWFRAME
- JAL(MterpSetUpHotnessCountdown) # (method, shadow_frame)
+ move a2, rSELF
+ JAL(MterpSetUpHotnessCountdown) # (method, shadow_frame, self)
move rPROFILE, v0 # Starting hotness countdown to rPROFILE
/* start executing the instruction at rPC */
diff --git a/runtime/interpreter/mterp/mips64/entry.S b/runtime/interpreter/mterp/mips64/entry.S
index cc48d45..5536966 100644
--- a/runtime/interpreter/mterp/mips64/entry.S
+++ b/runtime/interpreter/mterp/mips64/entry.S
@@ -82,6 +82,7 @@
/* Set up for backwards branches & osr profiling */
ld a0, OFF_FP_METHOD(rFP)
daddu a1, rFP, OFF_FP_SHADOWFRAME
+ move a2, rSELF
jal MterpSetUpHotnessCountdown
move rPROFILE, v0 # Starting hotness countdown to rPROFILE
diff --git a/runtime/interpreter/mterp/mterp.cc b/runtime/interpreter/mterp/mterp.cc
index b8a7a2a..6c24753 100644
--- a/runtime/interpreter/mterp/mterp.cc
+++ b/runtime/interpreter/mterp/mterp.cc
@@ -888,7 +888,9 @@
* to the full instrumentation via MterpAddHotnessBatch. Called once on entry to the method,
* and regenerated following batch updates.
*/
-extern "C" ssize_t MterpSetUpHotnessCountdown(ArtMethod* method, ShadowFrame* shadow_frame)
+extern "C" ssize_t MterpSetUpHotnessCountdown(ArtMethod* method,
+ ShadowFrame* shadow_frame,
+ Thread* self)
REQUIRES_SHARED(Locks::mutator_lock_) {
uint16_t hotness_count = method->GetCounter();
int32_t countdown_value = jit::kJitHotnessDisabled;
@@ -906,7 +908,7 @@
} else {
countdown_value = jit::kJitCheckForOSR;
}
- if (jit::Jit::ShouldUsePriorityThreadWeight()) {
+ if (jit::Jit::ShouldUsePriorityThreadWeight(self)) {
int32_t priority_thread_weight = jit->PriorityThreadWeight();
countdown_value = std::min(countdown_value, countdown_value / priority_thread_weight);
}
@@ -935,7 +937,7 @@
int16_t count = shadow_frame->GetCachedHotnessCountdown() - shadow_frame->GetHotnessCountdown();
jit->AddSamples(self, method, count, /*with_backedges*/ true);
}
- return MterpSetUpHotnessCountdown(method, shadow_frame);
+ return MterpSetUpHotnessCountdown(method, shadow_frame, self);
}
extern "C" size_t MterpMaybeDoOnStackReplacement(Thread* self,
diff --git a/runtime/interpreter/mterp/out/mterp_arm.S b/runtime/interpreter/mterp/out/mterp_arm.S
index e2b693f..d6a27b8 100644
--- a/runtime/interpreter/mterp/out/mterp_arm.S
+++ b/runtime/interpreter/mterp/out/mterp_arm.S
@@ -386,6 +386,7 @@
/* Set up for backwards branches & osr profiling */
ldr r0, [rFP, #OFF_FP_METHOD]
add r1, rFP, #OFF_FP_SHADOWFRAME
+ mov r2, rSELF
bl MterpSetUpHotnessCountdown
mov rPROFILE, r0 @ Starting hotness countdown to rPROFILE
diff --git a/runtime/interpreter/mterp/out/mterp_arm64.S b/runtime/interpreter/mterp/out/mterp_arm64.S
index ef5a4da..3d05996 100644
--- a/runtime/interpreter/mterp/out/mterp_arm64.S
+++ b/runtime/interpreter/mterp/out/mterp_arm64.S
@@ -401,6 +401,7 @@
/* Set up for backwards branches & osr profiling */
ldr x0, [xFP, #OFF_FP_METHOD]
add x1, xFP, #OFF_FP_SHADOWFRAME
+ mov x2, xSELF
bl MterpSetUpHotnessCountdown
mov wPROFILE, w0 // Starting hotness countdown to xPROFILE
diff --git a/runtime/interpreter/mterp/out/mterp_mips.S b/runtime/interpreter/mterp/out/mterp_mips.S
index 6362897..144c8e5 100644
--- a/runtime/interpreter/mterp/out/mterp_mips.S
+++ b/runtime/interpreter/mterp/out/mterp_mips.S
@@ -797,7 +797,8 @@
/* Set up for backwards branches & osr profiling */
lw a0, OFF_FP_METHOD(rFP)
addu a1, rFP, OFF_FP_SHADOWFRAME
- JAL(MterpSetUpHotnessCountdown) # (method, shadow_frame)
+ move a2, rSELF
+ JAL(MterpSetUpHotnessCountdown) # (method, shadow_frame, self)
move rPROFILE, v0 # Starting hotness countdown to rPROFILE
/* start executing the instruction at rPC */
diff --git a/runtime/interpreter/mterp/out/mterp_mips64.S b/runtime/interpreter/mterp/out/mterp_mips64.S
index bc0d90c..28f1887 100644
--- a/runtime/interpreter/mterp/out/mterp_mips64.S
+++ b/runtime/interpreter/mterp/out/mterp_mips64.S
@@ -383,6 +383,7 @@
/* Set up for backwards branches & osr profiling */
ld a0, OFF_FP_METHOD(rFP)
daddu a1, rFP, OFF_FP_SHADOWFRAME
+ move a2, rSELF
jal MterpSetUpHotnessCountdown
move rPROFILE, v0 # Starting hotness countdown to rPROFILE
@@ -3764,7 +3765,6 @@
GOTO_OPCODE v0 # jump to next instruction
-
/* ------------------------------ */
.balign 128
.L_op_float_to_double: /* 0x89 */
diff --git a/runtime/interpreter/mterp/out/mterp_x86.S b/runtime/interpreter/mterp/out/mterp_x86.S
index 21d9671..169501d 100644
--- a/runtime/interpreter/mterp/out/mterp_x86.S
+++ b/runtime/interpreter/mterp/out/mterp_x86.S
@@ -387,6 +387,8 @@
movl %eax, OUT_ARG0(%esp)
leal OFF_FP_SHADOWFRAME(rFP), %ecx
movl %ecx, OUT_ARG1(%esp)
+ movl rSELF, %eax
+ movl %eax, OUT_ARG2(%esp)
call SYMBOL(MterpSetUpHotnessCountdown)
/* Starting ibase */
diff --git a/runtime/interpreter/mterp/out/mterp_x86_64.S b/runtime/interpreter/mterp/out/mterp_x86_64.S
index b5a5ae5..b643072 100644
--- a/runtime/interpreter/mterp/out/mterp_x86_64.S
+++ b/runtime/interpreter/mterp/out/mterp_x86_64.S
@@ -198,9 +198,12 @@
* restore it in such cases also.
*
*/
+.macro REFRESH_IBASE_REG self_reg
+ movq THREAD_CURRENT_IBASE_OFFSET(\self_reg), rIBASE
+.endm
.macro REFRESH_IBASE
movq rSELF, rIBASE
- movq THREAD_CURRENT_IBASE_OFFSET(rIBASE), rIBASE
+ REFRESH_IBASE_REG rIBASE
.endm
/*
@@ -364,9 +367,10 @@
/* Starting ibase */
movq IN_ARG0, rSELF
- REFRESH_IBASE
+ REFRESH_IBASE_REG IN_ARG0
/* Set up for backwards branches & osr profiling */
+ movq IN_ARG0, OUT_ARG2 /* Set up OUT_ARG2 before clobbering IN_ARG0 */
movq OFF_FP_METHOD(rFP), OUT_ARG0
leaq OFF_FP_SHADOWFRAME(rFP), OUT_ARG1
call SYMBOL(MterpSetUpHotnessCountdown)
@@ -11908,7 +11912,7 @@
.L_resume_backward_branch:
movq rSELF, %rax
testl $(THREAD_SUSPEND_OR_CHECKPOINT_REQUEST), THREAD_FLAGS_OFFSET(%rax)
- REFRESH_IBASE
+ REFRESH_IBASE_REG %rax
leaq (rPC, rINSTq, 2), rPC
FETCH_INST
jnz .L_suspend_request_pending
diff --git a/runtime/interpreter/mterp/x86/entry.S b/runtime/interpreter/mterp/x86/entry.S
index 384dd9a..34adf53 100644
--- a/runtime/interpreter/mterp/x86/entry.S
+++ b/runtime/interpreter/mterp/x86/entry.S
@@ -69,6 +69,8 @@
movl %eax, OUT_ARG0(%esp)
leal OFF_FP_SHADOWFRAME(rFP), %ecx
movl %ecx, OUT_ARG1(%esp)
+ movl rSELF, %eax
+ movl %eax, OUT_ARG2(%esp)
call SYMBOL(MterpSetUpHotnessCountdown)
/* Starting ibase */
diff --git a/runtime/interpreter/mterp/x86_64/entry.S b/runtime/interpreter/mterp/x86_64/entry.S
index d992956..0f969eb 100644
--- a/runtime/interpreter/mterp/x86_64/entry.S
+++ b/runtime/interpreter/mterp/x86_64/entry.S
@@ -63,9 +63,10 @@
/* Starting ibase */
movq IN_ARG0, rSELF
- REFRESH_IBASE
+ REFRESH_IBASE_REG IN_ARG0
/* Set up for backwards branches & osr profiling */
+ movq IN_ARG0, OUT_ARG2 /* Set up OUT_ARG2 before clobbering IN_ARG0 */
movq OFF_FP_METHOD(rFP), OUT_ARG0
leaq OFF_FP_SHADOWFRAME(rFP), OUT_ARG1
call SYMBOL(MterpSetUpHotnessCountdown)
diff --git a/runtime/interpreter/mterp/x86_64/footer.S b/runtime/interpreter/mterp/x86_64/footer.S
index ed5e5ea..ac6cd19 100644
--- a/runtime/interpreter/mterp/x86_64/footer.S
+++ b/runtime/interpreter/mterp/x86_64/footer.S
@@ -152,7 +152,7 @@
.L_resume_backward_branch:
movq rSELF, %rax
testl $$(THREAD_SUSPEND_OR_CHECKPOINT_REQUEST), THREAD_FLAGS_OFFSET(%rax)
- REFRESH_IBASE
+ REFRESH_IBASE_REG %rax
leaq (rPC, rINSTq, 2), rPC
FETCH_INST
jnz .L_suspend_request_pending
diff --git a/runtime/interpreter/mterp/x86_64/header.S b/runtime/interpreter/mterp/x86_64/header.S
index 7699fc4..f229e84 100644
--- a/runtime/interpreter/mterp/x86_64/header.S
+++ b/runtime/interpreter/mterp/x86_64/header.S
@@ -191,9 +191,12 @@
* restore it in such cases also.
*
*/
+.macro REFRESH_IBASE_REG self_reg
+ movq THREAD_CURRENT_IBASE_OFFSET(\self_reg), rIBASE
+.endm
.macro REFRESH_IBASE
movq rSELF, rIBASE
- movq THREAD_CURRENT_IBASE_OFFSET(rIBASE), rIBASE
+ REFRESH_IBASE_REG rIBASE
.endm
/*
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 7abf52e..8c27bfe 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -144,9 +144,8 @@
return jit_options;
}
-bool Jit::ShouldUsePriorityThreadWeight() {
- return Runtime::Current()->InJankPerceptibleProcessState()
- && Thread::Current()->IsJitSensitiveThread();
+bool Jit::ShouldUsePriorityThreadWeight(Thread* self) {
+ return self->IsJitSensitiveThread() && Runtime::Current()->InJankPerceptibleProcessState();
}
void Jit::DumpInfo(std::ostream& os) {
@@ -653,7 +652,7 @@
DCHECK_LE(priority_thread_weight_, hot_method_threshold_);
int32_t starting_count = method->GetCounter();
- if (Jit::ShouldUsePriorityThreadWeight()) {
+ if (Jit::ShouldUsePriorityThreadWeight(self)) {
count *= priority_thread_weight_;
}
int32_t new_count = starting_count + count; // int32 here to avoid wrap-around;
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index 51e49ec..791c338 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -152,7 +152,7 @@
bool CanInvokeCompiledCode(ArtMethod* method);
// Return whether the runtime should use a priority thread weight when sampling.
- static bool ShouldUsePriorityThreadWeight();
+ static bool ShouldUsePriorityThreadWeight(Thread* self);
// If an OSR compiled version is available for `method`,
// and `dex_pc + dex_pc_offset` is an entry point of that compiled
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index 2e4db7a..d767e98 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -154,7 +154,7 @@
}
}
-static void EnableDebugFeatures(uint32_t debug_flags) {
+static void EnableDebugFeatures(uint32_t runtime_flags) {
// Must match values in com.android.internal.os.Zygote.
enum {
DEBUG_ENABLE_JDWP = 1,
@@ -169,7 +169,7 @@
};
Runtime* const runtime = Runtime::Current();
- if ((debug_flags & DEBUG_ENABLE_CHECKJNI) != 0) {
+ if ((runtime_flags & DEBUG_ENABLE_CHECKJNI) != 0) {
JavaVMExt* vm = runtime->GetJavaVM();
if (!vm->IsCheckJniEnabled()) {
LOG(INFO) << "Late-enabling -Xcheck:jni";
@@ -179,66 +179,66 @@
} else {
LOG(INFO) << "Not late-enabling -Xcheck:jni (already on)";
}
- debug_flags &= ~DEBUG_ENABLE_CHECKJNI;
+ runtime_flags &= ~DEBUG_ENABLE_CHECKJNI;
}
- if ((debug_flags & DEBUG_ENABLE_JNI_LOGGING) != 0) {
+ if ((runtime_flags & DEBUG_ENABLE_JNI_LOGGING) != 0) {
gLogVerbosity.third_party_jni = true;
- debug_flags &= ~DEBUG_ENABLE_JNI_LOGGING;
+ runtime_flags &= ~DEBUG_ENABLE_JNI_LOGGING;
}
- Dbg::SetJdwpAllowed((debug_flags & DEBUG_ENABLE_JDWP) != 0);
- if ((debug_flags & DEBUG_ENABLE_JDWP) != 0) {
+ Dbg::SetJdwpAllowed((runtime_flags & DEBUG_ENABLE_JDWP) != 0);
+ if ((runtime_flags & DEBUG_ENABLE_JDWP) != 0) {
EnableDebugger();
}
- debug_flags &= ~DEBUG_ENABLE_JDWP;
+ runtime_flags &= ~DEBUG_ENABLE_JDWP;
- const bool safe_mode = (debug_flags & DEBUG_ENABLE_SAFEMODE) != 0;
+ const bool safe_mode = (runtime_flags & DEBUG_ENABLE_SAFEMODE) != 0;
if (safe_mode) {
// Only quicken oat files.
runtime->AddCompilerOption("--compiler-filter=quicken");
runtime->SetSafeMode(true);
- debug_flags &= ~DEBUG_ENABLE_SAFEMODE;
+ runtime_flags &= ~DEBUG_ENABLE_SAFEMODE;
}
- const bool generate_debug_info = (debug_flags & DEBUG_GENERATE_DEBUG_INFO) != 0;
+ const bool generate_debug_info = (runtime_flags & DEBUG_GENERATE_DEBUG_INFO) != 0;
if (generate_debug_info) {
runtime->AddCompilerOption("--generate-debug-info");
- debug_flags &= ~DEBUG_GENERATE_DEBUG_INFO;
+ runtime_flags &= ~DEBUG_GENERATE_DEBUG_INFO;
}
// This is for backwards compatibility with Dalvik.
- debug_flags &= ~DEBUG_ENABLE_ASSERT;
+ runtime_flags &= ~DEBUG_ENABLE_ASSERT;
- if ((debug_flags & DEBUG_ALWAYS_JIT) != 0) {
+ if ((runtime_flags & DEBUG_ALWAYS_JIT) != 0) {
jit::JitOptions* jit_options = runtime->GetJITOptions();
CHECK(jit_options != nullptr);
jit_options->SetJitAtFirstUse();
- debug_flags &= ~DEBUG_ALWAYS_JIT;
+ runtime_flags &= ~DEBUG_ALWAYS_JIT;
}
bool needs_non_debuggable_classes = false;
- if ((debug_flags & DEBUG_JAVA_DEBUGGABLE) != 0) {
+ if ((runtime_flags & DEBUG_JAVA_DEBUGGABLE) != 0) {
runtime->AddCompilerOption("--debuggable");
runtime->SetJavaDebuggable(true);
// Deoptimize the boot image as it may be non-debuggable.
runtime->DeoptimizeBootImage();
- debug_flags &= ~DEBUG_JAVA_DEBUGGABLE;
+ runtime_flags &= ~DEBUG_JAVA_DEBUGGABLE;
needs_non_debuggable_classes = true;
}
if (needs_non_debuggable_classes || kAlwaysCollectNonDebuggableClasses) {
CollectNonDebuggableClasses();
}
- if ((debug_flags & DEBUG_NATIVE_DEBUGGABLE) != 0) {
+ if ((runtime_flags & DEBUG_NATIVE_DEBUGGABLE) != 0) {
runtime->AddCompilerOption("--debuggable");
runtime->AddCompilerOption("--generate-debug-info");
runtime->SetNativeDebuggable(true);
- debug_flags &= ~DEBUG_NATIVE_DEBUGGABLE;
+ runtime_flags &= ~DEBUG_NATIVE_DEBUGGABLE;
}
- if (debug_flags != 0) {
- LOG(ERROR) << StringPrintf("Unknown bits set in debug_flags: %#x", debug_flags);
+ if (runtime_flags != 0) {
+ LOG(ERROR) << StringPrintf("Unknown bits set in runtime_flags: %#x", runtime_flags);
}
}
@@ -260,13 +260,13 @@
static void ZygoteHooks_nativePostForkChild(JNIEnv* env,
jclass,
jlong token,
- jint debug_flags,
+ jint runtime_flags,
jboolean is_system_server,
jstring instruction_set) {
Thread* thread = reinterpret_cast<Thread*>(token);
// Our system thread ID, etc, has changed so reset Thread state.
thread->InitAfterFork();
- EnableDebugFeatures(debug_flags);
+ EnableDebugFeatures(runtime_flags);
// Update tracing.
if (Trace::GetMethodTracingMode() != TracingMode::kTracingInactive) {
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 3edf343..5888762 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -134,6 +134,7 @@
#include "native_bridge_art_interface.h"
#include "native_stack_dump.h"
#include "nativehelper/JniConstants.h"
+#include "nativehelper/JniConstants-priv.h"
#include "nativehelper/ScopedLocalRef.h"
#include "oat_file.h"
#include "oat_file_manager.h"
@@ -405,6 +406,10 @@
// instance. We rely on a small initialization order issue in Runtime::Start() that requires
// elements of WellKnownClasses to be null, see b/65500943.
WellKnownClasses::Clear();
+
+ // Ensure that libnativehelper caching is invalidated, in case a new runtime is to be brought
+ // up later.
+ android::ClearJniConstantsCache();
}
struct AbortState {