Fix regression with open array index by byte generated by a subtract

This commit is contained in:
drmortalwombat 2022-07-10 10:07:33 +02:00
parent 9424723536
commit 5f8797b4be
5 changed files with 47 additions and 14 deletions

View File

@ -5302,7 +5302,7 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray
case IA_EXT8TO16U: case IA_EXT8TO16U:
vr = ins->mSrc[0].mRange; vr = ins->mSrc[0].mRange;
if (vr.mMaxState != IntegerValueRange::S_BOUND || vr.mMaxValue < 0 || vr.mMaxValue > 255) if (vr.mMaxState != IntegerValueRange::S_BOUND || vr.mMaxValue < 0 || vr.mMaxValue > 255 || vr.mMinValue < 0)
{ {
vr.mMaxState = IntegerValueRange::S_BOUND; vr.mMaxState = IntegerValueRange::S_BOUND;
vr.mMaxValue = 255; vr.mMaxValue = 255;

View File

@ -7829,14 +7829,20 @@ NativeCodeBasicBlock* NativeCodeBasicBlock::BinaryOperator(InterCodeProcedure* p
if (sins0) if (sins0)
{ {
insl = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_WORK + 0); insl = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_WORK + 0);
insh = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_WORK + 1); if (ins->mDst.IsUByte())
insh = NativeCodeInstruction(ASMIT_AND, ASMIM_IMMEDIATE, 0);
else
insh = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_WORK + 1);
LoadValueToReg(proc, sins0, BC_REG_WORK, nullptr, nullptr); LoadValueToReg(proc, sins0, BC_REG_WORK, nullptr, nullptr);
} }
else else
{ {
insl = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]); insl = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]);
insh = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp] + 1); if (ins->mDst.IsUByte())
insh = NativeCodeInstruction(ASMIT_AND, ASMIM_IMMEDIATE, 0);
else
insh = NativeCodeInstruction(ASMIT_SBC, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp] + 1);
} }
if (sins1) if (sins1)
@ -7851,9 +7857,17 @@ NativeCodeBasicBlock* NativeCodeBasicBlock::BinaryOperator(InterCodeProcedure* p
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg));
if (InterTypeSize[ins->mDst.mType] > 1) if (InterTypeSize[ins->mDst.mType] > 1)
{ {
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp] + 1)); if (ins->mDst.IsUByte())
mIns.Push(insh); {
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg + 1)); mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0));
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg + 1));
}
else
{
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp] + 1));
mIns.Push(insh);
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg + 1));
}
} }
} }
} }
@ -13929,7 +13943,16 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock*
mPatched = true; mPatched = true;
if (!mEntryRequiredRegs[reg]) if (!mEntryRequiredRegs[reg])
{
if (mExitRequiredRegs[reg])
{
if (mTrueJump && !mTrueJump->CheckPatchFail(block, reg))
return false;
if (mFalseJump && !mFalseJump->CheckPatchFail(block, reg))
return false;
}
return true; return true;
}
assert(mNumEntries == mEntryBlocks.Size()); assert(mNumEntries == mEntryBlocks.Size());
@ -13976,7 +13999,17 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock*
} }
} }
else else
{
if (mExitRequiredRegs[reg])
{
if (mTrueJump && !mTrueJump->CheckPatchFail(block, reg))
return false;
if (mFalseJump && !mFalseJump->CheckPatchFail(block, reg))
return false;
}
return true; return true;
}
} }
else if (ins.mType == ASMIT_JSR) else if (ins.mType == ASMIT_JSR)
{ {

View File

@ -74,7 +74,7 @@ int main2(int argc, const char** argv)
#else #else
strcpy(strProductName, "oscar64"); strcpy(strProductName, "oscar64");
strcpy(strProductVersion, "1.7.142"); strcpy(strProductVersion, "1.7.143");
#ifdef __APPLE__ #ifdef __APPLE__
uint32_t length = sizeof(basePath); uint32_t length = sizeof(basePath);

View File

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,142,0 FILEVERSION 1,7,143,0
PRODUCTVERSION 1,7,142,0 PRODUCTVERSION 1,7,143,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -43,12 +43,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "oscar64" VALUE "CompanyName", "oscar64"
VALUE "FileDescription", "oscar64 compiler" VALUE "FileDescription", "oscar64 compiler"
VALUE "FileVersion", "1.7.142.0" VALUE "FileVersion", "1.7.143.0"
VALUE "InternalName", "oscar64.exe" VALUE "InternalName", "oscar64.exe"
VALUE "LegalCopyright", "Copyright (C) 2021" VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "oscar64.exe" VALUE "OriginalFilename", "oscar64.exe"
VALUE "ProductName", "oscar64" VALUE "ProductName", "oscar64"
VALUE "ProductVersion", "1.7.142.0" VALUE "ProductVersion", "1.7.143.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -4153,15 +4153,15 @@
{ {
"Name" = "8:Microsoft Visual Studio" "Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:oscar64" "ProductName" = "8:oscar64"
"ProductCode" = "8:{54C9EB87-4154-49FD-B146-2408492EDE3B}" "ProductCode" = "8:{18D1362C-EAD7-45F4-85FD-9D9963D9795D}"
"PackageCode" = "8:{A90AA9BF-452A-4C37-B592-CAF52893124A}" "PackageCode" = "8:{561C0763-7D5B-4666-9DE0-2326AF7DA4CF}"
"UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}" "UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}"
"AspNetVersion" = "8:2.0.50727.0" "AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE" "RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE" "RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE" "InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.7.142" "ProductVersion" = "8:1.7.143"
"Manufacturer" = "8:oscar64" "Manufacturer" = "8:oscar64"
"ARPHELPTELEPHONE" = "8:" "ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:" "ARPHELPLINK" = "8:"