Skip to content

Commit 88cd5b6

Browse files
committed
compiler: move allocations > 256 bytes to the heap
1 parent 010cc13 commit 88cd5b6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/compiler.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,9 @@ func (b *builder) createExpr(expr ssa.Value) (llvm.Value, error) {
15711571
switch expr := expr.(type) {
15721572
case *ssa.Alloc:
15731573
typ := b.getLLVMType(expr.Type().Underlying().(*types.Pointer).Elem())
1574-
if expr.Heap {
1575-
size := b.targetData.TypeAllocSize(typ)
1574+
size := b.targetData.TypeAllocSize(typ)
1575+
// move all allocations larger than 256 bytes to the heap
1576+
if expr.Heap || size > 256 {
15761577
// Calculate ^uintptr(0)
15771578
maxSize := llvm.ConstNot(llvm.ConstInt(b.uintptrType, 0, false)).ZExtValue()
15781579
if size > maxSize {

0 commit comments

Comments
 (0)