diff options
author | Ayke van Laethem <[email protected]> | 2021-07-14 15:45:11 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-07-14 22:33:32 +0200 |
commit | 607d8242111560233ffd54eda461a43cc9c4760b (patch) | |
tree | cd3e7b1691be295fa388d2b205fab596a0670bef /interp/interp.go | |
parent | 8cc7c6d57202575e2ac4fc5024830333308efee9 (diff) | |
download | tinygo-607d8242111560233ffd54eda461a43cc9c4760b.tar.gz tinygo-607d8242111560233ffd54eda461a43cc9c4760b.zip |
interp: keep reverted package initializers in order
Previously, a package initializer that could not be reverted correctly
would be called at runtime. But the initializer would be called in the
wrong order: after later packages are initialized.
This commit fixes this oversight and adds a test to verify the new
behavior.
Diffstat (limited to 'interp/interp.go')
-rw-r--r-- | interp/interp.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/interp/interp.go b/interp/interp.go index d3976ef7f..574fe01ab 100644 --- a/interp/interp.go +++ b/interp/interp.go @@ -110,17 +110,19 @@ func Run(mod llvm.Module, debug bool) error { fmt.Fprintln(os.Stderr, "call:", fn.Name()) } _, mem, callErr := r.run(r.getFunction(fn), nil, nil, " ") + call.EraseFromParentAsInstruction() if callErr != nil { if isRecoverableError(callErr.Err) { if r.debug { fmt.Fprintln(os.Stderr, "not interpreting", r.pkgName, "because of error:", callErr.Error()) } mem.revert() + i8undef := llvm.Undef(r.i8ptrType) + r.builder.CreateCall(fn, []llvm.Value{i8undef, i8undef}, "") continue } return callErr } - call.EraseFromParentAsInstruction() for index, obj := range mem.objects { r.objects[index] = obj } |