Skip to content

Commit

Permalink
[1.6>1.7] [MERGE #3471 @mrkmarron] Fix inflate table initialization +…
Browse files Browse the repository at this point in the history
… clang warnings.

Merge pull request #3471 from mrkmarron:bugFixes16

Re-target  #3461 to release/1.6
  • Loading branch information
mrkmarron committed Aug 2, 2017
2 parents f497760 + 661776c commit 42b5d73
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
6 changes: 4 additions & 2 deletions lib/Runtime/Debug/TTEventLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,8 @@ namespace TTD
dbgScopeCount += iter.Current()->TopLevelBase.ScopeChainInfo.ScopeCount;
}

uint32 topFunctionCount = topLevelLoadScriptMap.Count() + topLevelNewScriptMap.Count() + topLevelEvalScriptMap.Count();

ThreadContextTTD* threadCtx = this->m_threadContext->TTDContext;
const UnorderedArrayList<NSSnapValues::SnapContext, TTD_ARRAY_LIST_SIZE_XSMALL>& snpCtxs = snap->GetContextList();

Expand All @@ -1509,7 +1511,7 @@ namespace TTD

if(reuseInflateMap)
{
this->m_lastInflateMap->PrepForReInflate(snap->ContextCount(), snap->HandlerCount(), snap->TypeCount(), snap->PrimitiveCount() + snap->ObjectCount(), snap->BodyCount(), dbgScopeCount, snap->EnvCount(), snap->SlotArrayCount());
this->m_lastInflateMap->PrepForReInflate(snap->ContextCount(), snap->HandlerCount(), snap->TypeCount(), snap->PrimitiveCount() + snap->ObjectCount(), snap->BodyCount() + topFunctionCount, dbgScopeCount, snap->EnvCount(), snap->SlotArrayCount());

//collect anything that is dead
threadCtx->ClearRootsForSnapRestore();
Expand Down Expand Up @@ -1546,7 +1548,7 @@ namespace TTD
}

this->m_lastInflateMap = TT_HEAP_NEW(InflateMap);
this->m_lastInflateMap->PrepForInitialInflate(this->m_threadContext, snap->ContextCount(), snap->HandlerCount(), snap->TypeCount(), snap->PrimitiveCount() + snap->ObjectCount(), snap->BodyCount(), dbgScopeCount, snap->EnvCount(), snap->SlotArrayCount());
this->m_lastInflateMap->PrepForInitialInflate(this->m_threadContext, snap->ContextCount(), snap->HandlerCount(), snap->TypeCount(), snap->PrimitiveCount() + snap->ObjectCount(), snap->BodyCount() + topFunctionCount, dbgScopeCount, snap->EnvCount(), snap->SlotArrayCount());
this->m_lastInflateSnapshotTime = etime;

//collect anything that is dead
Expand Down
42 changes: 21 additions & 21 deletions lib/Runtime/Debug/TTSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ namespace TTD
{
if(readSeparator)
{
byte sep;
byte sep = 0;
this->ReadBytesInto_Fixed<byte>(sep);

TTDAssert((NSTokens::Separator)sep == NSTokens::Separator::CommaSeparator, "Error in parse.");
Expand All @@ -1477,7 +1477,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

byte key;
byte key = 0;
this->ReadBytesInto_Fixed<byte>(key);

TTDAssert((NSTokens::Key)key == keyCheck, "Error in parse.");
Expand All @@ -1487,15 +1487,15 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

byte tok;
byte tok = 0;
this->ReadBytesInto_Fixed<byte>(tok);

TTDAssert(tok == '[', "Error in parse.");
}

void BinaryFormatReader::ReadSequenceEnd()
{
byte tok;
byte tok = 0;
this->ReadBytesInto_Fixed<byte>(tok);

TTDAssert(tok == ']', "Error in parse.");
Expand All @@ -1505,15 +1505,15 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

byte tok;
byte tok = 0;
this->ReadBytesInto_Fixed<byte>(tok);

TTDAssert(tok == '{', "Error in parse.");
}

void BinaryFormatReader::ReadRecordEnd()
{
byte tok;
byte tok = 0;
this->ReadBytesInto_Fixed<byte>(tok);

TTDAssert(tok == '}', "Error in parse.");
Expand All @@ -1523,7 +1523,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

byte tok;
byte tok = 0;
this->ReadBytesInto_Fixed<byte>(tok);

TTDAssert(tok == 0, "Error in parse.");
Expand All @@ -1533,7 +1533,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

byte b;
byte b = 0;
this->ReadBytesInto_Fixed<byte>(b);

return b;
Expand All @@ -1543,7 +1543,7 @@ namespace TTD
{
this->ReadKey(keyCheck, readSeparator);

byte b;
byte b = 0;
this->ReadBytesInto_Fixed<byte>(b);

return !!b;
Expand All @@ -1553,7 +1553,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

int32 i;
int32 i = 0;
this->ReadBytesInto_Fixed<int32>(i);

return i;
Expand All @@ -1563,7 +1563,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

uint32 i;
uint32 i = 0;
this->ReadBytesInto_Fixed<uint32>(i);

return i;
Expand All @@ -1573,7 +1573,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

int64 i;
int64 i = 0;
this->ReadBytesInto_Fixed<int64>(i);

return i;
Expand All @@ -1583,7 +1583,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

uint64 i;
uint64 i = 0;
this->ReadBytesInto_Fixed<uint64>(i);

return i;
Expand All @@ -1593,7 +1593,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

double d;
double d = 0.0;
this->ReadBytesInto_Fixed<double>(d);

return d;
Expand All @@ -1603,7 +1603,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

TTD_PTR_ID addr;
TTD_PTR_ID addr = TTD_INVALID_PTR_ID;
this->ReadBytesInto_Fixed<TTD_PTR_ID>(addr);

return addr;
Expand All @@ -1613,7 +1613,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

TTD_LOG_PTR_ID tag;
TTD_LOG_PTR_ID tag = TTD_INVALID_LOG_PTR_ID;
this->ReadBytesInto_Fixed<TTD_LOG_PTR_ID>(tag);

return tag;
Expand All @@ -1623,7 +1623,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

uint32 tag;
uint32 tag = 0;
this->ReadBytesInto_Fixed<uint32>(tag);

return tag;
Expand All @@ -1633,7 +1633,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

uint32 sizeField;
uint32 sizeField = 0;
this->ReadBytesInto_Fixed<uint32>(sizeField);

if(sizeField == UINT32_MAX)
Expand All @@ -1652,7 +1652,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

uint32 sizeField;
uint32 sizeField = 0;
this->ReadBytesInto_Fixed<uint32>(sizeField);

if(sizeField == UINT32_MAX)
Expand All @@ -1671,7 +1671,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

uint32 charLen;
uint32 charLen = 0;
this->ReadBytesInto_Fixed<uint32>(charLen);

char16* cbuff = alloc.SlabAllocateArray<char16>(charLen + 1);
Expand All @@ -1685,7 +1685,7 @@ namespace TTD
{
this->ReadSeperator(readSeparator);

uint32 charLen;
uint32 charLen = 0;
this->ReadBytesInto_Fixed<uint32>(charLen);

char16* cbuff = alloc.SlabAllocateArray<char16>(charLen + 1);
Expand Down
2 changes: 2 additions & 0 deletions lib/Runtime/Debug/TTSerialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ namespace TTD
{
size_t readCount = 0;
this->ReadBlock(remainingBuff, &readCount);

TTDAssert(readCount > 0, "We are out of data but still need more");
remainingBuff += readCount;
remainingBytes -= readCount;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Runtime/Debug/TTSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ namespace TTD

void AddItem(Tag id, const T& item)
{
TTDAssert(this->m_count * TTD_DICTIONARY_LOAD_FACTOR < this->m_capacity, "The dictionary is being sized incorrectly and will likely have poor performance");
Entry* entry = this->FindSlotForId<true>(id);

InitializeEntry(entry, id, item);
Expand Down

0 comments on commit 42b5d73

Please sign in to comment.