diff options
author | George Marques <george@gmarqu.es> | 2023-07-28 13:08:21 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2023-07-28 13:08:21 -0300 |
commit | c1bca65d09b78dafafc496dcf47782e30887cf6e (patch) | |
tree | 017763c0e35c45e3be772af17b15ef773d6a66fa /modules/gdscript/gdscript_disassembler.cpp | |
parent | 202e4b2c1e7f8b25738b93d0e4d5066453d3edf3 (diff) | |
download | redot-engine-c1bca65d09b78dafafc496dcf47782e30887cf6e.tar.gz |
GDScript: Optimize operators by assuming the types
This assumes that operators are called usually with the same type of
operands as the first time. So it stores the types of the first run and
if matched it uses an optimized path by calling the validated operator
function directly. Otherwise it uses the regular untyped evaluator.
With this change, if operators do use the same type they run quite
faster. OTOH, if the types mismatch it takes longer to run than they
would with the previous code.
Diffstat (limited to 'modules/gdscript/gdscript_disassembler.cpp')
-rw-r--r-- | modules/gdscript/gdscript_disassembler.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_disassembler.cpp b/modules/gdscript/gdscript_disassembler.cpp index ec1d0af329..438ec02740 100644 --- a/modules/gdscript/gdscript_disassembler.cpp +++ b/modules/gdscript/gdscript_disassembler.cpp @@ -113,6 +113,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const { switch (opcode) { case OPCODE_OPERATOR: { + constexpr int _pointer_size = sizeof(Variant::ValidatedOperatorEvaluator) / sizeof(*_code_ptr); int operation = _code_ptr[ip + 4]; text += "operator "; @@ -125,7 +126,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const { text += " "; text += DADDR(2); - incr += 5; + incr += 7 + _pointer_size; } break; case OPCODE_OPERATOR_VALIDATED: { text += "validated operator "; |