Last active 1703645197

tau.patch Raw
1diff --git a/internal/vm/frame.go b/internal/vm/frame.go
2index 4d40d22..d18e159 100644
3--- a/internal/vm/frame.go
4+++ b/internal/vm/frame.go
5@@ -1,10 +1,14 @@
6 package vm
7
8 import (
9+ "fmt"
10+
11 "github.com/NicoNex/tau/internal/code"
12 "github.com/NicoNex/tau/internal/obj"
13 )
14
15+var cache = make(map[string]*Frame)
16+
17 type Frame struct {
18 cl *obj.Closure
19 ip int
20@@ -12,11 +16,22 @@ type Frame struct {
21 }
22
23 func NewFrame(cl *obj.Closure, basePointer int) *Frame {
24- return &Frame{
25+ key := fmt.Sprintf("%p:%d", cl, basePointer)
26+ if frame, ok := cache[key]; ok {
27+ frame.Reset()
28+ return frame
29+ }
30+ frame := &Frame{
31 cl: cl,
32 ip: -1,
33 basePointer: basePointer,
34 }
35+ cache[key] = frame
36+ return frame
37+}
38+
39+func (f *Frame) Reset() {
40+ f.ip = -1
41 }
42
43 func (f *Frame) Instructions() code.Instructions {
44

Powered by Opengist Load: 9ms