From c779d69e4300303b62e6c464d56e683486f83745 Mon Sep 17 00:00:00 2001 From: jangko Date: Mon, 25 Sep 2023 17:20:14 +0700 Subject: [PATCH] Prepare interpreter dispatch for upcoming nim 1.6.16 Nim 1.6.16 only support {.optimization:speed.} pragma as a top level statement --- nimbus/evm/interpreter_dispatch.nim | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/nimbus/evm/interpreter_dispatch.nim b/nimbus/evm/interpreter_dispatch.nim index c06a395e3..f0edc1c2d 100644 --- a/nimbus/evm/interpreter_dispatch.nim +++ b/nimbus/evm/interpreter_dispatch.nim @@ -31,6 +31,14 @@ logScope: # Private functions # ------------------------------------------------------------------------------ +const + supportedOS = defined(windows) or defined(linux) or defined(macosx) + optimizationCondition = not lowMemoryCompileTime and defined(release) and supportedOS + +when optimizationCondition: + # this is a top level pragma since nim 1.6.16 + {.optimization: speed.} + proc selectVM(c: Computation, fork: EVMFork, shouldPrepareTracer: bool) {.gcsafe, raises: [CatchableError].} = ## Op code execution handler main loop. @@ -68,27 +76,27 @@ proc selectVM(c: Computation, fork: EVMFork, shouldPrepareTracer: bool) when defined(windows): when defined(cpu64): {.warning: "*** Win64/VM2 handler switch => computedGoto".} - {.computedGoto, optimization: speed.} + {.computedGoto.} else: # computedGoto not compiling on github/ci (out of memory) -- jordan {.warning: "*** Win32/VM2 handler switch => optimisation disabled".} - # {.computedGoto, optimization: speed.} + # {.computedGoto.} elif defined(linux): when defined(cpu64): {.warning: "*** Linux64/VM2 handler switch => computedGoto".} - {.computedGoto, optimization: speed.} + {.computedGoto.} else: {.warning: "*** Linux32/VM2 handler switch => computedGoto".} - {.computedGoto, optimization: speed.} + {.computedGoto.} elif defined(macosx): when defined(cpu64): {.warning: "*** MacOs64/VM2 handler switch => computedGoto".} - {.computedGoto, optimization: speed.} + {.computedGoto.} else: {.warning: "*** MacOs32/VM2 handler switch => computedGoto".} - {.computedGoto, optimization: speed.} + {.computedGoto.} else: {.warning: "*** Unsupported OS => no handler switch optimisation".}