Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21079: Fixes issue with weave opcode uniqueness checks and adds more debugging #202

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Amalgam/AmalgamMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ PLATFORM_MAIN_CONSOLE

if(debug_internal_memory)
{
entity->VerifyEvaluableNodeIntegrityAndAllContainedEntities();

delete entity;

auto num_strings_used = string_intern_pool.GetNumDynamicStringsInUse();
Expand Down
7 changes: 7 additions & 0 deletions src/Amalgam/entity/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,3 +999,10 @@ void Entity::VerifyEvaluableNodeIntegrity()
for(auto &[en, _] : nr.nodesReferenced)
EvaluableNodeManager::ValidateEvaluableNodeTreeMemoryIntegrity(en);
}

void Entity::VerifyEvaluableNodeIntegrityAndAllContainedEntities()
{
VerifyEvaluableNodeIntegrity();
for(auto ce : GetContainedEntities())
ce->VerifyEvaluableNodeIntegrity();
}
3 changes: 3 additions & 0 deletions src/Amalgam/entity/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@ class Entity
//ensures that there are no reachable nodes that are deallocated
void VerifyEvaluableNodeIntegrity();

//like VerifyEvaluableNodeIntegrity but includes all contained
void VerifyEvaluableNodeIntegrityAndAllContainedEntities();

//this is an estimate of the number of nodes required to reconstruct the entity if it were flattened
// including amortization of all extra overhead
static inline size_t GetEntityCreationSizeInNodes()
Expand Down
4 changes: 4 additions & 0 deletions src/Amalgam/evaluablenode/EvaluableNodeManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ void EvaluableNodeManager::FreeNodeTreeRecurse(EvaluableNode *tree)
}
}

#ifdef AMALGAM_FAST_MEMORY_INTEGRITY
assert(!tree->GetNeedCycleCheck());
#endif

tree->Invalidate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,18 +634,21 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_WEAVE(EvaluableNode *en, b
//find the largest of all the lists and the total number of elements
size_t maximum_list_size = 0;
size_t total_num_elements = 0;
bool all_lists_unique = true;
for(auto &list : lists)
{
if(list != nullptr)
{
size_t num_elements = list->GetOrderedChildNodes().size();
maximum_list_size = std::max(maximum_list_size, num_elements);
total_num_elements += num_elements;

all_lists_unique &= list.unique;
}
}

//the result
EvaluableNodeReference woven_list(evaluableNodeManager->AllocNode(ENT_LIST), true);
EvaluableNodeReference woven_list(evaluableNodeManager->AllocNode(ENT_LIST), all_lists_unique);

//just lists, interleave
if(EvaluableNode::IsNull(function))
Expand Down
Loading