diff options
author | Damian Gryski <[email protected]> | 2022-08-04 15:26:44 -0700 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-08-20 07:40:39 +0200 |
commit | 0b77e92c508bfd2a7d2cd871bc565ec63a679979 (patch) | |
tree | 8fb1a8c8e75b86885f01c56d8440afd9c80153ff /interp/interpreter.go | |
parent | a4ee98e0e1f7a8a30b066c97936b32e795d5733d (diff) | |
download | tinygo-0b77e92c508bfd2a7d2cd871bc565ec63a679979.tar.gz tinygo-0b77e92c508bfd2a7d2cd871bc565ec63a679979.zip |
make interp timeout configurable from command line
Diffstat (limited to 'interp/interpreter.go')
-rw-r--r-- | interp/interpreter.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/interp/interpreter.go b/interp/interpreter.go index 317bc6c03..95c99c842 100644 --- a/interp/interpreter.go +++ b/interp/interpreter.go @@ -17,8 +17,6 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent locals := make([]value, len(fn.locals)) r.callsExecuted++ - t0 := time.Since(r.start) - // Parameters are considered a kind of local values. for i, param := range params { locals[i] = param @@ -143,11 +141,10 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent } switch inst.opcode { case llvm.Ret: - const maxInterpSeconds = 180 - if t0 > maxInterpSeconds*time.Second { - // Running for more than maxInterpSeconds seconds. This should never happen, but does. + if time.Since(r.start) > r.timeout { + // Running for more than the allowed timeout; This shouldn't happen, but it does. // See github.com/tinygo-org/tinygo/issues/2124 - return nil, mem, r.errorAt(fn.blocks[0].instructions[0], fmt.Errorf("interp: running for more than %d seconds, timing out (executed calls: %d)", maxInterpSeconds, r.callsExecuted)) + return nil, mem, r.errorAt(fn.blocks[0].instructions[0], fmt.Errorf("interp: running for more than %s, timing out (executed calls: %d)", r.timeout, r.callsExecuted)) } if len(operands) != 0 { |