diff --git a/src/Amalgam/PlatformSpecific.h b/src/Amalgam/PlatformSpecific.h index 15b9e01a..0afd1556 100644 --- a/src/Amalgam/PlatformSpecific.h +++ b/src/Amalgam/PlatformSpecific.h @@ -223,23 +223,19 @@ inline void Platform_Assert(bool expr, const char *file, int line) std::cerr << "Runtime Exception: Debug Assertion Failed at line " << line << " of " << file << "\n"; //platform dependent assertion function - #ifdef _DEBUG - - #ifdef OS_WINDOWS - _ASSERT(expr); - #else - raise(SIGTRAP); - #endif - exit(-1); - + #ifdef OS_WINDOWS + _ASSERT(expr); #else - if(Platform_IsDebuggerPresent()) - { - //wait for user input - std::string temp; - std::getline(std::cin, temp); - } - exit(-1); + raise(SIGTRAP); #endif + + if(Platform_IsDebuggerPresent()) + { + //wait for user input in case the _ASSERT above was optimized out + std::string temp; + std::getline(std::cin, temp); + } + + exit(-1); } } diff --git a/src/Amalgam/evaluablenode/EvaluableNode.cpp b/src/Amalgam/evaluablenode/EvaluableNode.cpp index 5f2f0506..83680c7e 100644 --- a/src/Amalgam/evaluablenode/EvaluableNode.cpp +++ b/src/Amalgam/evaluablenode/EvaluableNode.cpp @@ -1565,8 +1565,7 @@ void EvaluableNode::DestructValue() void EvaluableNode::Invalidate() { #ifdef AMALGAM_FAST_MEMORY_INTEGRITY - if(IsNodeDeallocated()) - assert(false); + assert(!IsNodeDeallocated()); #endif if(!HasExtendedValue()) diff --git a/src/Amalgam/evaluablenode/EvaluableNode.h b/src/Amalgam/evaluablenode/EvaluableNode.h index cb02984f..27d19fa9 100644 --- a/src/Amalgam/evaluablenode/EvaluableNode.h +++ b/src/Amalgam/evaluablenode/EvaluableNode.h @@ -233,13 +233,13 @@ class EvaluableNode static bool IsTrue(EvaluableNode *n); //Returns true if the node is some form of associative array - constexpr bool IsAssociativeArray() + __forceinline bool IsAssociativeArray() { return DoesEvaluableNodeTypeUseAssocData(GetType()); } //Returns true if the node is some form of associative array - static constexpr bool IsAssociativeArray(EvaluableNode *n) + static __forceinline bool IsAssociativeArray(EvaluableNode *n) { if(n == nullptr) return false; @@ -247,19 +247,19 @@ class EvaluableNode } //returns true if the type is immediate - constexpr bool IsImmediate() + __forceinline bool IsImmediate() { return IsEvaluableNodeTypeImmediate(GetType()); } //Returns true if the node is some form of ordered array - constexpr bool IsOrderedArray() + __forceinline bool IsOrderedArray() { return DoesEvaluableNodeTypeUseOrderedData(GetType()); } //Returns true if the node is some form of ordered array - static constexpr bool IsOrderedArray(EvaluableNode *n) + static __forceinline bool IsOrderedArray(EvaluableNode *n) { if(n == nullptr) return false; @@ -267,7 +267,7 @@ class EvaluableNode } //returns true if the EvaluableNode is of a query type - static constexpr bool IsQuery(EvaluableNode *n) + static __forceinline bool IsQuery(EvaluableNode *n) { return (n != nullptr && IsEvaluableNodeTypeQuery(n->GetType())); } @@ -299,7 +299,7 @@ class EvaluableNode //if the node's contents can be represented as a number, which includes numbers, infinity, then return true // otherwise returns false - static constexpr bool CanRepresentValueAsANumber(EvaluableNode *e) + static __forceinline bool CanRepresentValueAsANumber(EvaluableNode *e) { if(e == nullptr) return true; @@ -317,7 +317,7 @@ class EvaluableNode } //returns true is node pointer e is nullptr or value of e has type ENT_NULL - static constexpr bool IsNull(EvaluableNode *e) + static __forceinline bool IsNull(EvaluableNode *e) { return (e == nullptr || e->GetType() == ENT_NULL); } @@ -327,7 +327,7 @@ class EvaluableNode static double ToNumber(EvaluableNode *e, double value_if_null = std::numeric_limits::quiet_NaN()); //returns true if the node can directly be interpreted as a number - static constexpr bool IsNumericOrNull(EvaluableNode *e) + static __forceinline bool IsNumericOrNull(EvaluableNode *e) { if(e == nullptr) return true; @@ -340,7 +340,7 @@ class EvaluableNode } //returns true if the EvaluableNode uses numeric data - constexpr bool IsNumericOrNull() + __forceinline bool IsNumericOrNull() { return DoesEvaluableNodeTypeUseNumberData(GetType()); } @@ -419,13 +419,10 @@ class EvaluableNode static size_t GetEstimatedNodeSizeInBytes(EvaluableNode *n); //gets current type - constexpr EvaluableNodeType &GetType() + __forceinline EvaluableNodeType &GetType() { #ifdef AMALGAM_FAST_MEMORY_INTEGRITY - if(type == ENT_DEALLOCATED) - { - assert(false); - } + assert(type != ENT_DEALLOCATED); #endif return type; } @@ -456,7 +453,7 @@ class EvaluableNode void InitNumberValue(); //gets the value by reference - constexpr double &GetNumberValue() + __forceinline double &GetNumberValue() { if(DoesEvaluableNodeTypeUseNumberData(GetType())) return GetNumberValueReference(); @@ -481,7 +478,7 @@ class EvaluableNode //sets up the ability to contain a string void InitStringValue(); - constexpr StringInternPool::StringID GetStringID() + __forceinline StringInternPool::StringID GetStringID() { if(DoesEvaluableNodeTypeUseStringData(GetType())) return GetStringIDReference(); @@ -650,7 +647,7 @@ class EvaluableNode GetOrderedChildNodesReference().reserve(to_reserve); } - constexpr std::vector &GetOrderedChildNodes() + __forceinline std::vector &GetOrderedChildNodes() { if(IsOrderedArray()) return GetOrderedChildNodesReference(); @@ -729,7 +726,7 @@ class EvaluableNode GetMappedChildNodesReference().reserve(to_reserve); } - constexpr AssocType &GetMappedChildNodes() + __forceinline AssocType &GetMappedChildNodes() { if(IsAssociativeArray()) return GetMappedChildNodesReference(); diff --git a/src/Amalgam/evaluablenode/EvaluableNodeManagement.h b/src/Amalgam/evaluablenode/EvaluableNodeManagement.h index ec8fca61..f3f67bf4 100644 --- a/src/Amalgam/evaluablenode/EvaluableNodeManagement.h +++ b/src/Amalgam/evaluablenode/EvaluableNodeManagement.h @@ -204,6 +204,10 @@ class EvaluableNodeStackStateSaver stack = _stack; originalStackSize = stack->size(); + #ifdef AMALGAM_FAST_MEMORY_INTEGRITY + assert(initial_element == nullptr || !initial_element->IsNodeDeallocated()); + #endif + stack->push_back(initial_element); } @@ -214,6 +218,9 @@ class EvaluableNodeStackStateSaver __forceinline void PushEvaluableNode(EvaluableNode *n) { + #ifdef AMALGAM_FAST_MEMORY_INTEGRITY + assert(n == nullptr || !n->IsNodeDeallocated()); + #endif stack->push_back(n); } @@ -231,6 +238,9 @@ class EvaluableNodeStackStateSaver //replaces the position of the stack with new_value __forceinline void SetStackLocation(size_t location, EvaluableNode *new_value) { + #ifdef AMALGAM_FAST_MEMORY_INTEGRITY + assert(new_value == nullptr || !new_value->IsNodeDeallocated()); + #endif (*stack)[location] = new_value; }