diff --git a/oscar64/Array.h b/oscar64/Array.h index 83ec110..7bca0a3 100644 --- a/oscar64/Array.h +++ b/oscar64/Array.h @@ -465,6 +465,7 @@ public: void Insert(int at, T t) { Grow(size + 1, false); + assert(at >= 0 && at < size); int j = size - 1; while (j > at) { @@ -476,6 +477,7 @@ public: void Remove(int at) { + assert(at >= 0 && at < size); while (at + 1 < size) { array[at] = array[at + 1]; @@ -486,6 +488,7 @@ public: void Remove(int at, int n) { + assert(at >= 0 && at + n <= size); while (at + n < size) { array[at] = array[at + n]; @@ -516,6 +519,7 @@ public: T Top(void) const { + assert(size > 0); return array[size - 1]; } @@ -531,6 +535,7 @@ public: void SetSize(int size, bool clear = false) { + assert(size >= 0); Grow(size, clear); } diff --git a/oscar64/Assembler.cpp b/oscar64/Assembler.cpp index 27b6f06..f103ab6 100644 --- a/oscar64/Assembler.cpp +++ b/oscar64/Assembler.cpp @@ -1,5 +1,6 @@ #include "Assembler.h" #include +#include AsmInsData DecInsData[256] = { @@ -347,7 +348,7 @@ static inline char toupper(char ch) } AsmInsType FindAsmInstruction(const char* ins) { - if (!ins[3]) + if (ins && strlen(ins) == 3) { for (int i = 0; i < NUM_ASM_INS_TYPES; i++) { diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index 12be33a..07c5c35 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -97,7 +97,7 @@ void IntegerValueRange::LimitMinWeak(int64 value) void IntegerValueRange::LimitMaxWeak(int64 value) { - if (mMaxState == S_UNBOUND || mMinState != S_UNKNOWN && mMaxValue > value) + if (mMaxState == S_UNBOUND || mMaxState != S_UNKNOWN && mMaxValue > value) { mMaxState = S_BOUND; mMaxValue = value; @@ -6152,7 +6152,6 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray if (singleLoop) { -#if 1 struct TempChain { int mBaseTemp; @@ -6197,50 +6196,6 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray } } } - - -#else - FastNumberSet changedTemps(mExitRequiredTemps.Size()); - GrowingArray expandedTemps(-1); - - for (int i = 0; i < sz; i++) - { - InterInstruction* ins(mInstructions[i]); - - if (ins->mCode == IC_BINARY_OPERATOR && ins->mOperator == IA_ADD && ins->mDst.mTemp == ins->mSrc[1].mTemp && ins->mSrc[0].mTemp < 0 && ins->mSrc[0].mIntConst > 0) - { - if (dependTemps[ins->mDst.mTemp]) - changedTemps += ins->mDst.mTemp; - else if (pblock->mTrueValueRange[ins->mDst.mTemp].IsConstant()) - dependTemps += ins->mDst.mTemp; - else - changedTemps += ins->mDst.mTemp; - } - else if (ins->mCode == IC_BINARY_OPERATOR && ins->mOperator == IA_ADD && - ins->mSrc[1].mTemp >= 0 && - ins->mDst.mTemp == expandedTemps[ins->mSrc[1].mTemp] && ins->mSrc[0].mTemp < 0 && ins->mSrc[0].mIntConst > 0) - { - if (dependTemps[ins->mDst.mTemp]) - changedTemps += ins->mDst.mTemp; - else if (pblock->mTrueValueRange[ins->mDst.mTemp].IsConstant()) - dependTemps += ins->mDst.mTemp; - else - changedTemps += ins->mDst.mTemp; - expandedTemps[ins->mSrc[1].mTemp] = -1; - } - else if (ins->mCode == IC_CONVERSION_OPERATOR && ins->mOperator == IA_EXT8TO16U && ins->mSrc[0].mTemp >= 0) - { - expandedTemps[ins->mDst.mTemp] = ins->mSrc[0].mTemp; - changedTemps += ins->mDst.mTemp; - } - else if (ins->mDst.mTemp >= 0) - { - expandedTemps[ins->mDst.mTemp] = -1; - changedTemps += ins->mDst.mTemp; - dependTemps -= ins->mDst.mTemp; - } - } -#endif } for (int i = 0; i < sz; i++) @@ -6305,46 +6260,52 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray vr.LimitMax(65535); } #endif - if (i > 0 && - mInstructions[i - 1]->mCode == IC_LEA && mInstructions[i - 1]->mDst.mTemp == ins->mSrc[0].mTemp && - mInstructions[i - 1]->mSrc[1].mTemp < 0 && mInstructions[i - 1]->mSrc[1].mMemory == IM_GLOBAL && (mInstructions[i - 1]->mSrc[1].mLinkerObject->mFlags & LOBJF_CONST)) { - if (ins->mDst.mType == IT_INT8) + LinkerObject* lo = mInstructions[i]->mSrc[0].mLinkerObject; + + if (i > 0 && + mInstructions[i - 1]->mCode == IC_LEA && mInstructions[i - 1]->mDst.mTemp == ins->mSrc[0].mTemp && + mInstructions[i - 1]->mSrc[1].mTemp < 0 && mInstructions[i - 1]->mSrc[1].mMemory == IM_GLOBAL) + lo = mInstructions[i - 1]->mSrc[1].mLinkerObject; + + if (lo && lo->mFlags & LOBJF_CONST) { - bool isUnsigned = false; - if (i + 1 < mInstructions.Size() && mInstructions[i + 1]->mCode == IC_CONVERSION_OPERATOR && mInstructions[i + 1]->mOperator == IA_EXT8TO16U && - mInstructions[i + 1]->mSrc[0].mTemp == mInstructions[i + 0]->mDst.mTemp && mInstructions[i + 1]->mSrc[0].mFinal) - isUnsigned = true; - - LinkerObject* lo = mInstructions[i - 1]->mSrc[1].mLinkerObject; - int mi = 0, ma = 0; - - if (vr.mMinState == IntegerValueRange::S_BOUND && vr.mMaxState == IntegerValueRange::S_BOUND && - vr.mMinValue >= -128 && vr.mMaxValue <= 127) + if (ins->mDst.mType == IT_INT8) { - for (int j = 0; j < lo->mSize; j++) - { - int v = isUnsigned ? lo->mData[j] : (int8)(lo->mData[j]); - if (v < mi) - mi = v; - if (v > ma) - ma = v; - } - } - else - { - for (int j = 0; j < lo->mSize; j++) - { - int v = lo->mData[j]; - if (!isUnsigned && (v & 0x80)) - mi = -128; - if (v > ma) - ma = v; - } - } + bool isUnsigned = false; + if (i + 1 < mInstructions.Size() && mInstructions[i + 1]->mCode == IC_CONVERSION_OPERATOR && mInstructions[i + 1]->mOperator == IA_EXT8TO16U && + mInstructions[i + 1]->mSrc[0].mTemp == mInstructions[i + 0]->mDst.mTemp && mInstructions[i + 1]->mSrc[0].mFinal) + isUnsigned = true; - vr.LimitMax(ma); - vr.LimitMin(mi); + int mi = 0, ma = 0; + + if (vr.mMinState == IntegerValueRange::S_BOUND && vr.mMaxState == IntegerValueRange::S_BOUND && + vr.mMinValue >= -128 && vr.mMaxValue <= 127) + { + for (int j = 0; j < lo->mSize; j++) + { + int v = isUnsigned ? lo->mData[j] : (int8)(lo->mData[j]); + if (v < mi) + mi = v; + if (v > ma) + ma = v; + } + } + else + { + for (int j = 0; j < lo->mSize; j++) + { + int v = lo->mData[j]; + if (!isUnsigned && (v & 0x80)) + mi = -128; + if (v > ma) + ma = v; + } + } + + vr.LimitMax(ma); + vr.LimitMin(mi); + } } } @@ -9365,6 +9326,84 @@ static int Find(GrowingIntArray& table, int i) return j; } +void InterCodeBasicBlock::LinkerObjectForwarding(const GrowingInstructionPtrArray& tvalue) +{ + if (!mVisited) + { + GrowingInstructionPtrArray ltvalue(tvalue); + + if (mLoopHead) + { + if (mNumEntries == 2 && (mTrueJump == this || mFalseJump == this)) + { + mLoadStoreInstructions = tvalue; + for (int i = 0; i < mInstructions.Size(); i++) + { + InterInstruction* ins(mInstructions[i]); + if (ins->mDst.mTemp >= 0) + ltvalue[ins->mDst.mTemp] = nullptr; + } + } + else + ltvalue.Clear(); + } + else if (mNumEntries > 0) + { + if (mNumEntered > 0) + { + for (int i = 0; i < ltvalue.Size(); i++) + { + if (mMergeTValues[i] != ltvalue[i]) + ltvalue[i] = nullptr; + } + } + + mNumEntered++; + + if (mNumEntered < mNumEntries) + { + mMergeTValues = ltvalue; + return; + } + } + + mVisited = true; + + for (int i = 0; i < mInstructions.Size(); i++) + { + InterInstruction * ins(mInstructions[i]); + InterInstruction* lins = nullptr; + + if (ins->mCode == IC_LEA) + { + if (ins->mSrc[1].mTemp >= 0 && ltvalue[ins->mSrc[1].mTemp]) + ins->mSrc[1].mLinkerObject = ltvalue[ins->mSrc[1].mTemp]->mSrc[1].mLinkerObject; + + if (ins->mSrc[1].mLinkerObject) + lins = ins; + } + else if (ins->mCode == IC_LOAD) + { + if (ins->mSrc[0].mTemp >= 0 && ltvalue[ins->mSrc[0].mTemp]) + ins->mSrc[0].mLinkerObject = ltvalue[ins->mSrc[0].mTemp]->mSrc[1].mLinkerObject; + } + else if (ins->mCode == IC_STORE) + { + if (ins->mSrc[1].mTemp >= 0 && ltvalue[ins->mSrc[1].mTemp]) + ins->mSrc[1].mLinkerObject = ltvalue[ins->mSrc[1].mTemp]->mSrc[1].mLinkerObject; + } + + if (lins) + ltvalue[lins->mDst.mTemp] = lins; + else if (ins->mDst.mTemp >= 0) + ltvalue[ins->mDst.mTemp] = nullptr; + } + + if (mTrueJump) mTrueJump->LinkerObjectForwarding(ltvalue); + if (mFalseJump) mFalseJump->LinkerObjectForwarding(ltvalue); + } +} + bool InterCodeBasicBlock::LoadStoreForwarding(const GrowingInstructionPtrArray& tvalue, const GrowingVariableArray& staticVars) { bool changed = false; @@ -12620,7 +12659,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa InterInstruction* sins = mInstructions[j]; if (sins->mCode == IC_STORE && CollidingMem(ins, sins)) { - if (sins->mSrc[1].mTemp >= 0) + if (sins->mSrc[1].mTemp >= 0 && ins->mSrc[0].mTemp < 0) { if ((ins->mSrc[0].mMemory != IM_PARAM && ins->mSrc[0].mMemory != IM_FPARAM) || aliasedParams[ins->mSrc[0].mVarIndex]) { @@ -12642,7 +12681,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa ins->mInvariant = false; } } - else if (CollidingMem(ins, sins)) + else { ins->mInvariant = false; } @@ -15752,7 +15791,7 @@ void InterCodeProcedure::Close(void) { GrowingTypeArray tstack(IT_NONE); - CheckFunc = !strcmp(mIdent->mString, "sieve"); + CheckFunc = !strcmp(mIdent->mString, "strtof"); mEntryBlock = mBlocks[0]; @@ -16038,6 +16077,10 @@ void InterCodeProcedure::Close(void) DisassembleDebug("Estimated value range"); + GrowingInstructionPtrArray pipa(nullptr); + ResetVisited(); + mEntryBlock->LinkerObjectForwarding(pipa); + RebuildIntegerRangeSet(); ResetVisited(); @@ -16391,6 +16434,27 @@ void InterCodeProcedure::Close(void) ResetVisited(); mEntryBlock->CollectStaticStack(mLinkerObject, mLocalVars); + + GrowingInstructionPtrArray pipa(nullptr); + ResetVisited(); + mEntryBlock->LinkerObjectForwarding(pipa); + +#if 1 + BuildLoopPrefix(); + DisassembleDebug("added dominators"); + + BuildDataFlowSets(); + + ResetVisited(); + mEntryBlock->SingleBlockLoopOptimisation(mParamAliasedSet, mModule->mGlobalVars); + + DisassembleDebug("single block loop opt 3"); + + BuildDataFlowSets(); + + BuildTraces(false); + DisassembleDebug("Rebuilt traces"); +#endif } #endif diff --git a/oscar64/InterCode.h b/oscar64/InterCode.h index a386187..9da37c5 100644 --- a/oscar64/InterCode.h +++ b/oscar64/InterCode.h @@ -441,6 +441,7 @@ public: GrowingIntArray mEntryRenameTable; GrowingIntArray mExitRenameTable; + void LinkerObjectForwarding(const GrowingInstructionPtrArray& tvalue); bool LoadStoreForwarding(const GrowingInstructionPtrArray& tvalue, const GrowingVariableArray& staticVars); void LocalRenameRegister(const GrowingIntArray& renameTable, int& num); diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 38803b3..805eec3 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -12975,6 +12975,8 @@ bool NativeCodeBasicBlock::ReduceLocalYPressure(void) if (!pblock->mFalseJump && !nblock->mEntryRequiredRegs[CPU_REG_Y]) { int pz = pblock->mIns.Size(); + while (pz > 0 && !pblock->mIns[pz - 1].ReferencesYReg() && !pblock->mIns[pz - 1].ReferencesXReg()) + pz--; if (mEntryRequiredRegs[CPU_REG_Y] && pz > 0 && pblock->mIns[pz - 1].mType == ASMIT_LDY && pblock->mIns[pz - 1].mMode == ASMIM_IMMEDIATE) { @@ -12989,7 +12991,14 @@ bool NativeCodeBasicBlock::ReduceLocalYPressure(void) mEntryRequiredRegs -= CPU_REG_Y; mExitRequiredRegs -= CPU_REG_Y; - pblock->mIns[pz - 1].mType = ASMIT_LDX; + pz--; + pblock->mIns[pz].mType = ASMIT_LDX; + while (pz < pblock->mIns.Size()) + { + pblock->mIns[pz].mLive |= LIVE_CPU_REG_X; + pz++; + } + changed = true; } } @@ -15387,6 +15396,14 @@ bool NativeCodeBasicBlock::CrossBlockStoreLoadBypass(NativeCodeProcedure* proc) lblock->mIns.Push(mTrueJump->mIns[i]); mTrueJump->mIns.SetSize(1); + mTrueJump->mTrueJump->RemEntryBlock(mTrueJump); + mTrueJump->mTrueJump->AddEntryBlock(lblock); + if (mTrueJump->mFalseJump) + { + mTrueJump->mFalseJump->RemEntryBlock(mTrueJump); + mTrueJump->mFalseJump->AddEntryBlock(lblock); + } + lblock->mTrueJump = mTrueJump->mTrueJump; lblock->mFalseJump = mTrueJump->mFalseJump; lblock->mBranch = mTrueJump->mBranch; @@ -15401,8 +15418,7 @@ bool NativeCodeBasicBlock::CrossBlockStoreLoadBypass(NativeCodeProcedure* proc) mTrueJump->mEntryRequiredRegs += CPU_REG_A; - mTrueJump->mEntryBlocks.Remove(mTrueJump->mEntryBlocks.IndexOf(this)); - mTrueJump->mNumEntries--; + mTrueJump->RemEntryBlock(this); mTrueJump->mFalseJump = nullptr; mTrueJump->mTrueJump = lblock; @@ -17556,22 +17572,23 @@ bool NativeCodeBasicBlock::HasTailSTY(int& addr, int& index) const void NativeCodeBasicBlock::AddEntryBlock(NativeCodeBasicBlock* block) { - int i = 0; - while (i < mEntryBlocks.Size() && mEntryBlocks[i] != block) - i++; - if (i == mEntryBlocks.Size()) - mEntryBlocks.Push(block); + assert(mEntryBlocks.Size() == mNumEntries); + int i = mEntryBlocks.IndexOf(block); + assert(i < 0); + mEntryBlocks.Push(block); + mNumEntries++; } void NativeCodeBasicBlock::RemEntryBlock(NativeCodeBasicBlock* block) { - int i = 0; - while (i < mEntryBlocks.Size() && mEntryBlocks[i] != block) - i++; - if (i < mEntryBlocks.Size()) - mEntryBlocks.Remove(i); + assert(mEntryBlocks.Size() == mNumEntries); + int i = mEntryBlocks.IndexOf(block); + assert(i >= 0); + mEntryBlocks.Remove(i); + mNumEntries--; } + NativeCodeBasicBlock * NativeCodeBasicBlock::SplitMatchingTails(NativeCodeProcedure* proc) { NativeCodeBasicBlock* nblock = nullptr; @@ -17874,7 +17891,7 @@ bool NativeCodeBasicBlock::PropagateSinglePath(void) { if (mTrueJump->mEntryRequiredRegs[mIns[i + 1].mAddress] && !mFalseJump->mEntryRequiredRegs[mIns[i + 1].mAddress] && - mTrueJump->mNumEntries == 1) + mTrueJump->mNumEntries == 1 && !mTrueJump->mEntryRequiredRegs[CPU_REG_Z]) { for (int j = 0; j < 2; j++) { @@ -17887,7 +17904,7 @@ bool NativeCodeBasicBlock::PropagateSinglePath(void) } else if (mFalseJump->mEntryRequiredRegs[mIns[i + 1].mAddress] && !mTrueJump->mEntryRequiredRegs[mIns[i + 1].mAddress] && - mFalseJump->mNumEntries == 1) + mFalseJump->mNumEntries == 1 && !mFalseJump->mEntryRequiredRegs[CPU_REG_Z]) { for (int j = 0; j < 2; j++) { @@ -26753,13 +26770,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data) { if (mNDataSet.mRegs[CPU_REG_A].mValue != 0) { - mTrueJump->RemoveEntryBlock(this); + mTrueJump->RemEntryBlock(this); mTrueJump = mFalseJump; mFalseJump = nullptr; } else { - mFalseJump->RemoveEntryBlock(this); + mFalseJump->RemEntryBlock(this); mFalseJump = nullptr; } mBranch = ASMIT_JMP; @@ -26782,13 +26799,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data) { if (mNDataSet.mRegs[CPU_REG_A].mValue == 0) { - mTrueJump->RemoveEntryBlock(this); + mTrueJump->RemEntryBlock(this); mTrueJump = mFalseJump; mFalseJump = nullptr; } else { - mFalseJump->RemoveEntryBlock(this); + mFalseJump->RemEntryBlock(this); mFalseJump = nullptr; } mBranch = ASMIT_JMP; @@ -26811,13 +26828,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data) { if (mNDataSet.mRegs[CPU_REG_A].mValue & 0x80) { - mTrueJump->RemoveEntryBlock(this); + mTrueJump->RemEntryBlock(this); mTrueJump = mFalseJump; mFalseJump = nullptr; } else { - mFalseJump->RemoveEntryBlock(this); + mFalseJump->RemEntryBlock(this); mFalseJump = nullptr; } mBranch = ASMIT_JMP; @@ -26844,13 +26861,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data) { if (!(mNDataSet.mRegs[CPU_REG_A].mValue & 0x80)) { - mTrueJump->RemoveEntryBlock(this); + mTrueJump->RemEntryBlock(this); mTrueJump = mFalseJump; mFalseJump = nullptr; } else { - mFalseJump->RemoveEntryBlock(this); + mFalseJump->RemEntryBlock(this); mFalseJump = nullptr; } mBranch = ASMIT_JMP; @@ -29329,6 +29346,7 @@ bool NativeCodeBasicBlock::OptimizeSimpleLoop(NativeCodeProcedure * proc, bool f { mVisited = true; + assert(mLocked || mNumEntries == mEntryBlocks.Size()); assert(mIns.Size() == 0 || mIns[0].mType != ASMIT_INV); bool changed = false; @@ -33977,7 +33995,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && !(mIns[i + 0].mLive & LIVE_MEM) && mIns[i + 1].IsShift() && mIns[i + 1].mMode == ASMIM_IMPLIED && !(mIns[i + 1].mLive & LIVE_CPU_REG_A)) { - mIns[i + 0].mType = mIns[i + 1].mType; mIns[i + 0].mLive |= LIVE_CPU_REG_C; + mIns[i + 0].mType = mIns[i + 1].mType; mIns[i + 0].mLive |= LIVE_CPU_REG_C | LIVE_CPU_REG_Z; mIns[i + 1].mType = ASMIT_NOP; mIns[i + 1].mMode = ASMIM_IMPLIED; progress = true; } @@ -38516,14 +38534,6 @@ void NativeCodeBasicBlock::Close(const InterInstruction* ins, NativeCodeBasicBlo this->mBranchIns = ins; } -void NativeCodeBasicBlock::RemoveEntryBlock(NativeCodeBasicBlock* block) -{ - int i = mEntryBlocks.IndexOf(block); - assert(i >= 0); - mEntryBlocks.Remove(i); - mNumEntries--; -} - NativeCodeBasicBlock* NativeCodeBasicBlock::BypassEmptyBlocks(void) { if (mBypassed) @@ -38852,7 +38862,9 @@ NativeCodeBasicBlock::NativeCodeBasicBlock(void) mEntryRegY = false; mExitRegA = false; mExitRegX = false; - + mVisited = false; + mLoopHead = false; + mNumEntries = 0; } NativeCodeBasicBlock::~NativeCodeBasicBlock(void) @@ -39845,6 +39857,8 @@ void NativeCodeProcedure::Optimize(void) #if 1 if (step > 0) { + RebuildEntry(); + ResetVisited(); if (mEntryBlock->OptimizeSimpleLoop(this, step > 5)) changed = true; @@ -40233,6 +40247,8 @@ void NativeCodeProcedure::Optimize(void) changed = true; } #endif + RebuildEntry(); + #if 1 if (step == 2 && !changed) { diff --git a/oscar64/NativeCodeGenerator.h b/oscar64/NativeCodeGenerator.h index dbca705..7b7f01e 100644 --- a/oscar64/NativeCodeGenerator.h +++ b/oscar64/NativeCodeGenerator.h @@ -226,7 +226,6 @@ public: int BranchByteSize(NativeCodeBasicBlock* target, int from, int to); NativeCodeBasicBlock* BypassEmptyBlocks(void); - void RemoveEntryBlock(NativeCodeBasicBlock* block); int LeadsInto(NativeCodeBasicBlock* block, int dist); void BuildPlacement(ExpandingArray& placement); diff --git a/oscar64/NumberSet.cpp b/oscar64/NumberSet.cpp index e58a96e..5fa614b 100644 --- a/oscar64/NumberSet.cpp +++ b/oscar64/NumberSet.cpp @@ -1,5 +1,7 @@ #include "NumberSet.h" +#define VALGRIND 0 + NumberSet::NumberSet(void) { size = 0; @@ -174,6 +176,10 @@ FastNumberSet::FastNumberSet(int size, bool set) { this->size = this->asize = size; buffer = new uint32[2 * size]; +#if VALGRIND + for (int i = 0; i < 2 * size; i++) + buffer[i] = 0; +#endif if (set) { for (num = 0; num < size; num++) @@ -193,6 +199,11 @@ FastNumberSet::FastNumberSet(const FastNumberSet& set) this->size = this->asize = set.size; this->num = set.num; buffer = new uint32[2 * size]; +#if VALGRIND + for (int i = 0; i < 2 * size; i++) + buffer[i] = 0; +#endif + for (i = 0; i < num; i++) { buffer[i] = set.buffer[i]; @@ -206,6 +217,10 @@ void FastNumberSet::Reset(int size, bool set) { delete[] buffer; buffer = new uint32[2 * size]; +#if VALGRIND + for (int i = 0; i < 2 * size; i++) + buffer[i] = 0; +#endif this->asize = size; } diff --git a/oscar64/Scanner.cpp b/oscar64/Scanner.cpp index dafe3dd..0d52f79 100644 --- a/oscar64/Scanner.cpp +++ b/oscar64/Scanner.cpp @@ -308,6 +308,7 @@ Scanner::Scanner(Errors* errors, Preprocessor* preprocessor) mDefines = new MacroDict(); mDefineArguments = nullptr; + mToken = TK_NONE; NextChar(); NextToken();