From d43d97b990b2f31691c09b25b9f31f30fdb30111 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 13 Aug 2016 00:52:31 +0100 Subject: [PATCH] EmitX64/EmitPushRSB: Assert that patch location is of correct size --- src/backend_x64/emit_x64.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend_x64/emit_x64.cpp b/src/backend_x64/emit_x64.cpp index 460e20f5..08b51183 100644 --- a/src/backend_x64/emit_x64.cpp +++ b/src/backend_x64/emit_x64.cpp @@ -343,8 +343,10 @@ void EmitX64::EmitPushRSB(IR::Block&, IR::Inst* inst) { code->AND(32, R(rsb_index), Imm32(u32(JitState::RSBSize - 1))); code->MOV(64, R(tmp), Imm64(imm64)); code->MOV(64, MComplex(R15, rsb_index, SCALE_1, offsetof(JitState, rsb_location_descriptors)), R(tmp)); - patch_unique_hash_locations[imm64].emplace_back(code->GetCodePtr()); + CodePtr patch_location = code->GetCodePtr(); + patch_unique_hash_locations[imm64].emplace_back(patch_location); code->MOV(64, R(tmp), Imm64(code_ptr)); // This line has to match up with EmitX64::Patch. + ASSERT((code->GetCodePtr() - patch_location) == 10); code->MOV(64, MComplex(R15, rsb_index, SCALE_1, offsetof(JitState, rsb_codeptrs)), R(tmp)); code->ADD(32, R(rsb_index), Imm32(1)); code->MOV(32, MDisp(R15, offsetof(JitState, rsb_ptr)), R(rsb_index)); @@ -1756,6 +1758,7 @@ void EmitX64::Patch(Arm::LocationDescriptor desc, CodePtr bb) { for (CodePtr location : patch_unique_hash_locations[desc.UniqueHash()]) { code->SetCodePtr(const_cast(location)); code->MOV(64, R(RCX), Imm64(u64(bb))); + ASSERT((code->GetCodePtr() - location) == 10); } code->SetCodePtr(save_code_ptr);