Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions gnovm/pkg/gnolang/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (pv *PackageValue) GetShallowSize() int64 {
return 0
}

return allocPackage
return overflow.Addp(allocPackage, overflow.Mulp(allocStringByte, int64(len(pv.PkgName))))
}

func (b *Block) GetShallowSize() int64 {
Expand All @@ -419,25 +419,25 @@ func (b *Block) GetShallowSize() int64 {
ss += allocRefValue
}

ss = allocBlock + allocBlockItem*int64(len(b.Values))
ss = overflow.Addp(allocBlock, overflow.Mulp(allocBlockItem, int64(len(b.Values))))

return ss
}

func (av *ArrayValue) GetShallowSize() int64 {
if av.Data != nil {
return allocArray + int64(len(av.Data))
return overflow.Addp(allocArray, int64(len(av.Data)))
} else {
return allocArray + int64(len(av.List)*allocArrayItem)
return overflow.Addp(allocArray, overflow.Mulp(int64(len(av.List)), allocArrayItem))
}
}

func (sv *StructValue) GetShallowSize() int64 {
return allocStruct + int64(len(sv.Fields))*allocStructField
return overflow.Addp(allocStruct, overflow.Mulp(int64(len(sv.Fields)), allocStructField))
}

func (mv *MapValue) GetShallowSize() int64 {
return allocMap + allocMapItem*int64(mv.GetLength())
return overflow.Addp(allocMap, overflow.Mulp(allocMapItem, int64(mv.GetLength())))
}

func (bmv *BoundMethodValue) GetShallowSize() int64 {
Expand Down Expand Up @@ -481,7 +481,7 @@ func (fv *FuncValue) GetShallowSize() int64 {
}

func (sv StringValue) GetShallowSize() int64 {
return allocString + allocStringByte*int64(len(sv))
return overflow.Addp(allocString, overflow.Mulp(allocStringByte, int64(len(sv))))
}

func (biv BigintValue) GetShallowSize() int64 {
Expand Down
1 change: 1 addition & 0 deletions gnovm/pkg/gnolang/alloc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ func TestAllocSizes(t *testing.T) {
println("TypeValue{}", unsafe.Sizeof(TypeValue{}))
println("TypedValue{}", unsafe.Sizeof(TypedValue{}))
println("ObjectInfo{}", unsafe.Sizeof(ObjectInfo{}))
println("PackageValue{}", unsafe.Sizeof(PackageValue{}))
}
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_0.gno
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
}

// Output:
// MemStats: Allocator{maxBytes:100000000, bytes:6398}
// MemStats: Allocator{maxBytes:100000000, bytes:6409}

// TypeCheckError:
// main/alloc_0.gno:13:2: declared and not used: f1
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_1.gno
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
}

// Output:
// MemStats: Allocator{maxBytes:100000000, bytes:7648}
// MemStats: Allocator{maxBytes:100000000, bytes:7659}

// TypeCheckError:
// main/alloc_1.gno:18:2: declared and not used: S1
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_3.gno
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func main() {
}

// Output:
// MemStats after GC: Allocator{maxBytes:110000000, bytes:5744}
// MemStats after GC: Allocator{maxBytes:110000000, bytes:5755}

// TypeCheckError:
// main/alloc_3.gno:7:2: declared and not used: data
4 changes: 2 additions & 2 deletions gnovm/tests/files/alloc_4.gno
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ func main() {
}

// Output:
// memstats in main after first GC: Allocator{maxBytes:50000, bytes:16511}
// memstats in main after second GC: Allocator{maxBytes:50000, bytes:6901}
// memstats in main after first GC: Allocator{maxBytes:50000, bytes:16522}
// memstats in main after second GC: Allocator{maxBytes:50000, bytes:6912}
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_5.gno
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ func main() {
}

// Output:
// memstats in main after GC: Allocator{maxBytes:100000000, bytes:6088}
// memstats in main after GC: Allocator{maxBytes:100000000, bytes:6099}
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_6.gno
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ func main() {
}

// Output:
// memstats in main after GC: Allocator{maxBytes:100000000, bytes:6088}
// memstats in main after GC: Allocator{maxBytes:100000000, bytes:6099}
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_6a.gno
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ func main() {
}

// Output:
// memstats in main after GC: Allocator{maxBytes:100000000, bytes:6592}
// memstats in main after GC: Allocator{maxBytes:100000000, bytes:6603}
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_7.gno
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ func main() {
}

// Output:
// MemStats: Allocator{maxBytes:100000000, bytes:5851}
// MemStats: Allocator{maxBytes:100000000, bytes:5862}
2 changes: 1 addition & 1 deletion gnovm/tests/files/alloc_7a.gno
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ func main() {
}

// Output:
// MemStats: Allocator{maxBytes:100000000, bytes:8059}
// MemStats: Allocator{maxBytes:100000000, bytes:8077}
Loading