Improved assembler performance
All checks were successful
/ test (push) Successful in 15s

This commit is contained in:
Eduard Urbach 2025-06-27 15:43:17 +02:00
parent 312e3b2e31
commit a67bc440fc
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
2 changed files with 7 additions and 4 deletions

View file

@ -73,11 +73,14 @@ func (a *Assembler) Compile(b *build.Build) (code []byte, data []byte) {
// Merge combines the contents of this assembler with another one. // Merge combines the contents of this assembler with another one.
func (a *Assembler) Merge(b *Assembler) { func (a *Assembler) Merge(b *Assembler) {
maps.Copy(a.Data, b.Data) skip := 0
for _, instr := range b.Instructions { for a.Skip(b.Instructions[skip]) {
a.Append(instr) skip++
} }
a.Instructions = append(a.Instructions, b.Instructions[skip:]...)
maps.Copy(a.Data, b.Data)
} }
// SetData sets the data for the given label. // SetData sets the data for the given label.

View file

@ -22,7 +22,7 @@ func WriteFile(executable string, b *build.Build, env *core.Environment) error {
traversed := make(map[*core.Function]bool, len(env.Functions)) traversed := make(map[*core.Function]bool, len(env.Functions))
final := asm.Assembler{ final := asm.Assembler{
Instructions: make([]asm.Instruction, 0, 8), Instructions: make([]asm.Instruction, 0, 32),
Data: make(data.Data, 32), Data: make(data.Data, 32),
} }