Skip to content

Commit

Permalink
Merge 0ed15de into 1519d3b
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Mar 11, 2024
2 parents 1519d3b + 0ed15de commit 3cc2464
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 158 deletions.
2 changes: 1 addition & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ library Constants {
uint256 internal constant ARGS_HASH_CHUNK_COUNT = 32;
uint256 internal constant INITIAL_L2_BLOCK_NUM = 1;
uint256 internal constant BLOB_SIZE_IN_BYTES = 126976;
uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 9000;
uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 10000;
uint256 internal constant MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 500;
uint256 internal constant MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS = 500;
uint256 internal constant REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ global INITIAL_L2_BLOCK_NUM: Field = 1;
global BLOB_SIZE_IN_BYTES: Field = 126976;

// CONTRACT CLASS CONSTANTS
global MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS: u64 = 9000;
global MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS: u64 = 10000;
// Bytecode size for private functions is per function, not for the entire contract.
// Note that private functions bytecode includes a mix of acir and brillig.
global MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS: u64 = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,25 @@ impl FunctionBuilder {
self.increment_array_reference_count(value);
}
}
Type::Array(..) | Type::Slice(..) => {
self.insert_instruction(Instruction::IncrementRc { value }, None);
typ @ Type::Array(..) | typ @ Type::Slice(..) => {
// If there are nested arrays or slices, we wait until ArrayGet
// is issued to increment the count of that array.
self.insert_instruction(Instruction::IncrementRc { value }, None);

// This is a bit odd, but in brillig the inc_rc instruction operates on
// a copy of the array's metadata, so we need to re-store a loaded array
// even if there have been no other changes to it.
if let Value::Instruction { instruction, .. } = &self.current_function.dfg[value] {
let instruction = &self.current_function.dfg[*instruction];
if let Instruction::Load { address } = instruction {
// We can't re-use `value` in case the original address was stored
// to again in the meantime. So introduce another load.
let address = *address;
let value = self.insert_load(address, typ);
self.insert_instruction(Instruction::IncrementRc { value }, None);
self.insert_store(address, value);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ impl<'a> FunctionContext<'a> {
let lhs = self.extract_current_value(&assign.lvalue)?;
let rhs = self.codegen_expression(&assign.expression)?;

rhs.clone().for_each(|value| {
let value = value.eval(self);
self.builder.increment_array_reference_count(value);
});

self.assign_new_value(lhs, rhs);
Ok(Self::unit_value())
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const ARGS_HASH_CHUNK_LENGTH = 32;
export const ARGS_HASH_CHUNK_COUNT = 32;
export const INITIAL_L2_BLOCK_NUM = 1;
export const BLOB_SIZE_IN_BYTES = 126976;
export const MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 9000;
export const MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 10000;
export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 500;
export const MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS = 500;
export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE =
Expand Down
Loading

0 comments on commit 3cc2464

Please sign in to comment.