Fix VM memory allocation optimizations by reducing what we allocate on the heap
Some checks failed
Build / build (push) Successful in 10m25s
Publish Image / publish (push) Failing after 39s
Test / build (push) Successful in 11m19s

This commit is contained in:
Charles Smith
2024-03-31 20:44:50 -04:00
parent a85dc73954
commit aebbe43999
61 changed files with 383 additions and 370 deletions

View File

@@ -11,23 +11,39 @@ type Frame struct {
basePointer int
}
func NewFrame(cl *object.Closure, basePointer int) *Frame {
return &Frame{
func NewFrame(cl *object.Closure, basePointer int) Frame {
return Frame{
cl: cl,
basePointer: basePointer,
}
}
func (f *Frame) Closure() *object.Closure {
return f.cl
}
func (f *Frame) GetFree(idx uint8) object.Object {
return f.cl.Free[idx]
}
func (f *Frame) SetFree(idx uint8, obj object.Object) {
f.cl.Free[idx] = obj
}
func (f *Frame) SetIP(ip int) {
f.ip = ip
}
func (f Frame) PeekNextOp() code.Opcode {
return code.Opcode(f.cl.Fn.Instructions[f.ip])
}
func (f *Frame) ReadNextOp() code.Opcode {
op := code.Opcode(f.cl.Fn.Instructions[f.ip])
f.ip++
return op
}
func (f *Frame) PeekNextOp() code.Opcode {
return code.Opcode(f.cl.Fn.Instructions[f.ip])
}
func (f *Frame) ReadUint8() uint8 {
n := code.ReadUint8(f.cl.Fn.Instructions[f.ip:])
f.ip++
@@ -40,6 +56,6 @@ func (f *Frame) ReadUint16() uint16 {
return n
}
func (f *Frame) Instructions() code.Instructions {
func (f Frame) Instructions() code.Instructions {
return f.cl.Fn.Instructions
}