From f87de11b193252a456b72b345aba6fe64e61e199 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 23 Jul 2016 01:08:58 +0100 Subject: [PATCH] per-thread rundepth instead of per-state --- cubescript.cc | 7 ++++--- cubescript.hh | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cubescript.cc b/cubescript.cc index 64a0b0b8..4d145532 100644 --- a/cubescript.cc +++ b/cubescript.cc @@ -2625,14 +2625,15 @@ cleanup: } static constexpr int MaxRunDepth = 255; +static thread_local int rundepth = 0; static ostd::Uint32 const *runcode(CsState &cs, ostd::Uint32 const *code, TaggedValue &result) { result.set_null(); - if (cs.rundepth >= MaxRunDepth) { + if (rundepth >= MaxRunDepth) { cs_debug_code(cs, "exceeded recursion limit"); return skipcode(code, (&result == &no_ret) ? nullptr : &result); } - ++cs.rundepth; + ++rundepth; int numargs = 0; TaggedValue args[MaxArguments + MaxResults], *prevret = cs.result; cs.result = &result; @@ -3322,7 +3323,7 @@ noid: } exit: cs.result = prevret; - --cs.rundepth; + --rundepth; return code; } diff --git a/cubescript.hh b/cubescript.hh index 312525fb..0e85defc 100644 --- a/cubescript.hh +++ b/cubescript.hh @@ -372,7 +372,6 @@ struct OSTD_EXPORT CsState { int nodebug = 0; int numargs = 0; int dbgalias = 4; - int rundepth = 0; CsState(); ~CsState();