From d047152646975c6efe384f4c7ec2201c04c0e4bf Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Mon, 1 May 2023 15:38:48 +0200 Subject: [PATCH] Reduce line number toggling in debug file --- oscar64/Linker.h | 1 + oscar64/NativeCodeGenerator.cpp | 32 +++++++++++++++++++++++++------- oscar64/NativeCodeGenerator.h | 2 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/oscar64/Linker.h b/oscar64/Linker.h index 02812eb..e3ee519 100644 --- a/oscar64/Linker.h +++ b/oscar64/Linker.h @@ -163,6 +163,7 @@ struct CodeLocation { Location mLocation; int mStart, mEnd; + bool mWeak; }; diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 14caf6a..216f470 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -4354,8 +4354,16 @@ void NativeCodeInstruction::CopyMode(const NativeCodeInstruction& ins) void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block) { + bool weak = true; + if (mIns) - block->PutLocation(mIns->mLocation); + { + if (ChangesAddress() && (mMode != ASMIM_ZERO_PAGE || mLinkerObject)) + weak = false; + else if (mType == ASMIT_JSR && !(mFlags & NCIF_RUNTIME)) + weak = false; + block->PutLocation(mIns->mLocation, weak); + } if (mType == ASMIT_BYTE) block->PutByte(mAddress); @@ -4526,23 +4534,33 @@ void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block) } if (mIns) - block->PutLocation(mIns->mLocation); + block->PutLocation(mIns->mLocation, weak); } -void NativeCodeBasicBlock::PutLocation(const Location& location) +void NativeCodeBasicBlock::PutLocation(const Location& location, bool weak) { int sz = mCodeLocations.Size(); if (sz > 0 && - mCodeLocations[sz - 1].mLocation.mFileName == location.mFileName && - mCodeLocations[sz - 1].mLocation.mLine == location.mLine) + (weak || + (mCodeLocations[sz - 1].mLocation.mFileName == location.mFileName && + mCodeLocations[sz - 1].mLocation.mLine == location.mLine))) { mCodeLocations[sz - 1].mEnd = this->mCode.Size(); + if (mCodeLocations[sz - 1].mWeak) + mCodeLocations[sz - 1].mWeak = weak; + } + else if (sz > 0 && mCodeLocations[sz - 1].mWeak) + { + mCodeLocations[sz - 1].mLocation = location; + mCodeLocations[sz - 1].mEnd = this->mCode.Size(); + mCodeLocations[sz - 1].mWeak = weak; } else { CodeLocation loc; loc.mLocation = location; loc.mStart = loc.mEnd = this->mCode.Size(); + loc.mWeak = weak; mCodeLocations.Push(loc); } } @@ -38081,7 +38099,7 @@ void NativeCodeBasicBlock::CopyCode(NativeCodeProcedure * proc, uint8* target) next = mOffset + mSize; if (mBranchIns) - PutLocation(mBranchIns->mLocation); + PutLocation(mBranchIns->mLocation, false); if (mFalseJump) { @@ -38111,7 +38129,7 @@ void NativeCodeBasicBlock::CopyCode(NativeCodeProcedure * proc, uint8* target) } if (mBranchIns) - PutLocation(mBranchIns->mLocation); + PutLocation(mBranchIns->mLocation, false); assert(end == next); diff --git a/oscar64/NativeCodeGenerator.h b/oscar64/NativeCodeGenerator.h index d3829f0..c7cb77e 100644 --- a/oscar64/NativeCodeGenerator.h +++ b/oscar64/NativeCodeGenerator.h @@ -283,7 +283,7 @@ public: NativeCodeBasicBlock* BuildSingleEntry(NativeCodeProcedure* proc, NativeCodeBasicBlock* block); NativeCodeBasicBlock* BuildSingleExit(NativeCodeProcedure* proc, NativeCodeBasicBlock* block); - void PutLocation(const Location& loc); + void PutLocation(const Location& loc, bool weak); void PutOpcode(short opcode); void PutByte(uint8 code); void PutWord(uint16 code);