aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp
diff options
context:
space:
mode:
authorDan Kegel <[email protected]>2022-01-10 16:04:46 -0800
committerRon Evans <[email protected]>2022-01-11 22:09:15 +0100
commit69bf6e3c897c6513e986d8ee2baa7131f59fd853 (patch)
treefcd99a22dc94eac32d3a97a4f3213155a85f24d0 /interp
parent8f8d83bffef9ce21be413c1128a50ca886fceb34 (diff)
downloadtinygo-69bf6e3c897c6513e986d8ee2baa7131f59fd853.tar.gz
tinygo-69bf6e3c897c6513e986d8ee2baa7131f59fd853.zip
interp: show breadcrumbs to help developer find slow init functions; raise timeout.
Diffstat (limited to 'interp')
-rw-r--r--interp/interpreter.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/interp/interpreter.go b/interp/interpreter.go
index 8f729f0ee..94648ffd2 100644
--- a/interp/interpreter.go
+++ b/interp/interpreter.go
@@ -17,10 +17,7 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
locals := make([]value, len(fn.locals))
r.callsExecuted++
- if time.Since(r.start) > time.Minute {
- // Running for more than a minute. This should never happen.
- return nil, mem, r.errorAt(fn.blocks[0].instructions[0], fmt.Errorf("interp: running for more than a minute, timing out (executed calls: %d)", r.callsExecuted))
- }
+ t0 := time.Since(r.start)
// Parameters are considered a kind of local values.
for i, param := range params {
@@ -106,6 +103,17 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
}
switch inst.opcode {
case llvm.Ret:
+ t1 := time.Since(r.start)
+ if t1-t0 > time.Second {
+ // Provide some breadcrumbs for user trying to find their slow init functions.
+ fmt.Fprintln(os.Stderr, "interp: slow: startms", int(t0.Milliseconds()), "endms", int(t1.Milliseconds()), "func", fn.name)
+ }
+ const maxInterpSeconds = 90
+ if t0 > maxInterpSeconds*time.Second {
+ // Running for more than maxInterpSeconds seconds. This should never happen.
+ 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))
+ }
+
if len(operands) != 0 {
if r.debug {
fmt.Fprintln(os.Stderr, indent+"ret", operands[0])