diff options
-rw-r--r-- | compiler/utils/arm/jni_macro_assembler_arm_vixl.cc | 15 | ||||
-rw-r--r-- | compiler/utils/arm64/jni_macro_assembler_arm64.cc | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc b/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc index edb3292ea7..0bae4d4b69 100644 --- a/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc +++ b/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc @@ -164,6 +164,21 @@ void ArmVIXLJNIMacroAssembler::RemoveFrame(size_t frame_size, // AAPCS calling convention. DCHECK_NE(core_spill_mask & (1 << MR), 0) << "core_spill_mask should contain Marking Register R" << MR; + + // The following condition is a compile-time one, so it does not have a run-time cost. + if (kIsDebugBuild) { + // The following condition is a run-time one; it is executed after the + // previous compile-time test, to avoid penalizing non-debug builds. + if (emit_run_time_checks_in_debug_mode_) { + // Emit a run-time check verifying that the Marking Register is up-to-date. + UseScratchRegisterScope temps(asm_.GetVIXLAssembler()); + vixl32::Register temp = temps.Acquire(); + // Ensure we are not clobbering a callee-save register that was restored before. + DCHECK_EQ(core_spill_mask & (1 << temp.GetCode()), 0) + << "core_spill_mask hould not contain scratch register R" << temp.GetCode(); + asm_.GenerateMarkingRegisterCheck(temp); + } + } } } diff --git a/compiler/utils/arm64/jni_macro_assembler_arm64.cc b/compiler/utils/arm64/jni_macro_assembler_arm64.cc index 43c0eff8fc..573bb6d4be 100644 --- a/compiler/utils/arm64/jni_macro_assembler_arm64.cc +++ b/compiler/utils/arm64/jni_macro_assembler_arm64.cc @@ -788,6 +788,21 @@ void Arm64JNIMacroAssembler::RemoveFrame(size_t frame_size, // AAPCS64 calling convention. DCHECK(core_reg_list.IncludesAliasOf(mr)) << "core_reg_list should contain Marking Register X" << mr.GetCode(); + + // The following condition is a compile-time one, so it does not have a run-time cost. + if (kIsDebugBuild) { + // The following condition is a run-time one; it is executed after the + // previous compile-time test, to avoid penalizing non-debug builds. + if (emit_run_time_checks_in_debug_mode_) { + // Emit a run-time check verifying that the Marking Register is up-to-date. + UseScratchRegisterScope temps(asm_.GetVIXLAssembler()); + Register temp = temps.AcquireW(); + // Ensure we are not clobbering a callee-save register that was restored before. + DCHECK(!core_reg_list.IncludesAliasOf(temp.X())) + << "core_reg_list should not contain scratch register X" << temp.GetCode(); + asm_.GenerateMarkingRegisterCheck(temp); + } + } } } |