Skip to content

Commit

Permalink
factor out allocation limit
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Oct 4, 2023
1 parent 9c71339 commit b5d9263
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vyper/codegen/memory_allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class MemoryAllocator:

next_mem: int

_ALLOCATION_LIMIT: int = 2**64

def __init__(self, start_position: int = MemoryPositions.RESERVED_MEMORY):
"""
Initializer.
Expand Down Expand Up @@ -111,10 +113,11 @@ def _expand_memory(self, size: int) -> int:
self.next_mem += size
self.size_of_mem = max(self.size_of_mem, self.next_mem)

if self.size_of_mem >= 2**64:
if self.size_of_mem >= self._ALLOCATION_LIMIT:
# this should not be caught
raise MemoryAllocationException(
"Tried to allocate {self.size_of_mem} bytes! (limit is 2**32 bytes)"
f"Tried to allocate {self.size_of_mem} bytes! "
f"(limit is 2**64 bytes)"
)

return before_value
Expand Down

0 comments on commit b5d9263

Please sign in to comment.