From 6ad287650440aeb3c78929a8d09a80035f33b3fe Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Fri, 9 Jul 2021 21:05:55 -0400 Subject: [PATCH] * BugFix: Correct 3 missing defines in the GCC types include file. * BugFix: Move several compiledEval declarations around to resolve ordering issues. * BugFix: Experimentally remove the reference on an engineAPI template function to allow parameter types to match. --- Engine/source/console/compiledEval.cpp | 120 ++++++++++++------------- Engine/source/console/engineAPI.h | 2 +- Engine/source/platform/types.gcc.h | 3 + 3 files changed, 64 insertions(+), 61 deletions(-) diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index 061484659..10d201874 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -459,6 +459,39 @@ enum class FloatOperation NE }; +template +TORQUE_NOINLINE void doSlowMathOp() +{ + ConsoleValue& a = stack[_STK]; + ConsoleValue& b = stack[_STK - 1]; + + // Arithmetic + if constexpr (Op == FloatOperation::Add) + stack[_STK - 1].setFloat(a.getFloat() + b.getFloat()); + else if constexpr (Op == FloatOperation::Sub) + stack[_STK - 1].setFloat(a.getFloat() - b.getFloat()); + else if constexpr (Op == FloatOperation::Mul) + stack[_STK - 1].setFloat(a.getFloat() * b.getFloat()); + else if constexpr (Op == FloatOperation::Div) + stack[_STK - 1].setFloat(a.getFloat() / b.getFloat()); + + // Logical + if constexpr (Op == FloatOperation::LT) + stack[_STK - 1].setInt(a.getFloat() < b.getFloat()); + if constexpr (Op == FloatOperation::LE) + stack[_STK - 1].setInt(a.getFloat() <= b.getFloat()); + if constexpr (Op == FloatOperation::GR) + stack[_STK - 1].setInt(a.getFloat() > b.getFloat()); + if constexpr (Op == FloatOperation::GE) + stack[_STK - 1].setInt(a.getFloat() >= b.getFloat()); + if constexpr (Op == FloatOperation::EQ) + stack[_STK - 1].setInt(a.getFloat() == b.getFloat()); + if constexpr (Op == FloatOperation::NE) + stack[_STK - 1].setInt(a.getFloat() != b.getFloat()); + + _STK--; +} + template TORQUE_FORCEINLINE void doFloatMathOperation() { @@ -500,39 +533,6 @@ TORQUE_FORCEINLINE void doFloatMathOperation() } } -template -TORQUE_NOINLINE void doSlowMathOp() -{ - ConsoleValue& a = stack[_STK]; - ConsoleValue& b = stack[_STK - 1]; - - // Arithmetic - if constexpr (Op == FloatOperation::Add) - stack[_STK - 1].setFloat(a.getFloat() + b.getFloat()); - else if constexpr (Op == FloatOperation::Sub) - stack[_STK - 1].setFloat(a.getFloat() - b.getFloat()); - else if constexpr (Op == FloatOperation::Mul) - stack[_STK - 1].setFloat(a.getFloat() * b.getFloat()); - else if constexpr (Op == FloatOperation::Div) - stack[_STK - 1].setFloat(a.getFloat() / b.getFloat()); - - // Logical - if constexpr (Op == FloatOperation::LT) - stack[_STK - 1].setInt(a.getFloat() < b.getFloat()); - if constexpr (Op == FloatOperation::LE) - stack[_STK - 1].setInt(a.getFloat() <= b.getFloat()); - if constexpr (Op == FloatOperation::GR) - stack[_STK - 1].setInt(a.getFloat() > b.getFloat()); - if constexpr (Op == FloatOperation::GE) - stack[_STK - 1].setInt(a.getFloat() >= b.getFloat()); - if constexpr (Op == FloatOperation::EQ) - stack[_STK - 1].setInt(a.getFloat() == b.getFloat()); - if constexpr (Op == FloatOperation::NE) - stack[_STK - 1].setInt(a.getFloat() != b.getFloat()); - - _STK--; -} - //----------------------------------------------------------------------------- enum class IntegerOperation @@ -547,6 +547,33 @@ enum class IntegerOperation LogicalOr }; +template +TORQUE_NOINLINE void doSlowIntegerOp() +{ + ConsoleValue& a = stack[_STK]; + ConsoleValue& b = stack[_STK - 1]; + + // Bitwise Op + if constexpr (Op == IntegerOperation::BitAnd) + stack[_STK - 1].setInt(a.getInt() & b.getInt()); + if constexpr (Op == IntegerOperation::BitOr) + stack[_STK - 1].setInt(a.getInt() | b.getInt()); + if constexpr (Op == IntegerOperation::Xor) + stack[_STK - 1].setInt(a.getInt() ^ b.getInt()); + if constexpr (Op == IntegerOperation::LShift) + stack[_STK - 1].setInt(a.getInt() << b.getInt()); + if constexpr (Op == IntegerOperation::RShift) + stack[_STK - 1].setInt(a.getInt() >> b.getInt()); + + // Logical Op + if constexpr (Op == IntegerOperation::LogicalAnd) + stack[_STK - 1].setInt(a.getInt() && b.getInt()); + if constexpr (Op == IntegerOperation::LogicalOr) + stack[_STK - 1].setInt(a.getInt() || b.getInt()); + + _STK--; +} + template TORQUE_FORCEINLINE void doIntOperation() { @@ -581,33 +608,6 @@ TORQUE_FORCEINLINE void doIntOperation() } } -template -TORQUE_NOINLINE void doSlowIntegerOp() -{ - ConsoleValue& a = stack[_STK]; - ConsoleValue& b = stack[_STK - 1]; - - // Bitwise Op - if constexpr (Op == IntegerOperation::BitAnd) - stack[_STK - 1].setInt(a.getInt() & b.getInt()); - if constexpr (Op == IntegerOperation::BitOr) - stack[_STK - 1].setInt(a.getInt() | b.getInt()); - if constexpr (Op == IntegerOperation::Xor) - stack[_STK - 1].setInt(a.getInt() ^ b.getInt()); - if constexpr (Op == IntegerOperation::LShift) - stack[_STK - 1].setInt(a.getInt() << b.getInt()); - if constexpr (Op == IntegerOperation::RShift) - stack[_STK - 1].setInt(a.getInt() >> b.getInt()); - - // Logical Op - if constexpr (Op == IntegerOperation::LogicalAnd) - stack[_STK - 1].setInt(a.getInt() && b.getInt()); - if constexpr (Op == IntegerOperation::LogicalOr) - stack[_STK - 1].setInt(a.getInt() || b.getInt()); - - _STK--; -} - //----------------------------------------------------------------------------- U32 gExecCount = 0; diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index a8540968a..0a6af3dcd 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -292,7 +292,7 @@ struct EngineUnmarshallData< void > template<> struct EngineUnmarshallData< ConsoleValue > { - ConsoleValue operator()( ConsoleValue &ref ) const + ConsoleValue operator()( ConsoleValue ref ) const { return std::move(ref); } diff --git a/Engine/source/platform/types.gcc.h b/Engine/source/platform/types.gcc.h index 53538dd8d..4e65b23dc 100644 --- a/Engine/source/platform/types.gcc.h +++ b/Engine/source/platform/types.gcc.h @@ -43,6 +43,9 @@ typedef unsigned long U64; // Compiler Version #define TORQUE_COMPILER_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#define TORQUE_FORCEINLINE __attribute__((always_inline)) +#define TORQUE_CASE_FALLTHROUGH __attribute__((fallthrough)) +#define TORQUE_NOINLINE __attribute__ ((noinline)) //-------------------------------------- // Identify the compiler string