Browse Source

Function Call optimization is now optional

(Can cause a problem with package lookups)
James Urquhart 11 years ago
parent
commit
06b463399b
1 changed files with 9 additions and 0 deletions
  1. 9 0
      Engine/source/console/compiledEval.cpp

+ 9 - 0
Engine/source/console/compiledEval.cpp

@@ -45,6 +45,9 @@
 #include "materials/materialManager.h"
 #include "materials/materialManager.h"
 #endif
 #endif
 
 
+// Uncomment to optimize function calls at the expense of potential invalid package lookups
+//#define COMPILER_OPTIMIZE_FUNCTION_CALLS
+
 using namespace Compiler;
 using namespace Compiler;
 
 
 enum EvalConstants {
 enum EvalConstants {
@@ -1527,6 +1530,7 @@ breakContinue:
                break;
                break;
             }
             }
             
             
+#ifdef COMPILER_OPTIMIZE_FUNCTION_CALLS
             // Now fall through to OP_CALLFUNC...
             // Now fall through to OP_CALLFUNC...
             // Now, rewrite our code a bit (ie, avoid future lookups) and fall
             // Now, rewrite our code a bit (ie, avoid future lookups) and fall
             // through to OP_CALLFUNC
             // through to OP_CALLFUNC
@@ -1536,6 +1540,7 @@ breakContinue:
             code[ip+2] = ((U32)nsEntry);
             code[ip+2] = ((U32)nsEntry);
 #endif
 #endif
             code[ip-1] = OP_CALLFUNC;
             code[ip-1] = OP_CALLFUNC;
+#endif
 
 
          case OP_CALLFUNC:
          case OP_CALLFUNC:
          {
          {
@@ -1565,10 +1570,14 @@ breakContinue:
             {
             {
                if( !nsEntry )
                if( !nsEntry )
                {
                {
+#ifdef COMPILER_OPTIMIZE_FUNCTION_CALLS
 #ifdef TORQUE_64
 #ifdef TORQUE_64
                   nsEntry = ((Namespace::Entry *) *((U64*)(code+ip-3)));
                   nsEntry = ((Namespace::Entry *) *((U64*)(code+ip-3)));
 #else
 #else
                   nsEntry = ((Namespace::Entry *) *(code+ip-3));
                   nsEntry = ((Namespace::Entry *) *(code+ip-3));
+#endif
+#else
+                  nsEntry = Namespace::global()->lookup( fnName );
 #endif
 #endif
                   ns = NULL;
                   ns = NULL;
                }
                }