Skip to content

Commit

Permalink
feat: Optimize allocating immediate amounts of memory (#8579)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Sep 16, 2024
1 parent 0c54224 commit e0185e7
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::{
brillig_variable::{BrilligArray, BrilligVariable, BrilligVector, SingleAddrVariable},
debug_show::DebugToString,
registers::RegisterAllocator,
BrilligContext, BRILLIG_MEMORY_ADDRESSING_BIT_SIZE,
BrilligContext, ReservedRegisters, BRILLIG_MEMORY_ADDRESSING_BIT_SIZE,
};

impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<F, Registers> {
Expand All @@ -20,9 +20,12 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
pointer_register: MemoryAddress,
size: usize,
) {
let size_register = self.make_usize_constant_instruction(size.into());
self.codegen_allocate_mem(pointer_register, size_register.address);
self.deallocate_single_addr(size_register);
self.load_free_memory_pointer_instruction(pointer_register);
self.codegen_usize_op_in_place(
ReservedRegisters::free_memory_pointer(),
BrilligBinaryOp::Add,
size,
);
}

/// Allocates an array of size contained in size_register and stores the
Expand Down

0 comments on commit e0185e7

Please sign in to comment.