Skip to content

Commit ad88d56

Browse files
committed
compiler,runtime: allow map values >256 bytes
1 parent 655075e commit ad88d56

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (b *builder) createMakeMap(expr *ssa.MakeMap) (llvm.Value, error) {
4242
keySize := b.targetData.TypeAllocSize(llvmKeyType)
4343
valueSize := b.targetData.TypeAllocSize(llvmValueType)
4444
llvmKeySize := llvm.ConstInt(b.ctx.Int8Type(), keySize, false)
45-
llvmValueSize := llvm.ConstInt(b.ctx.Int8Type(), valueSize, false)
45+
llvmValueSize := llvm.ConstInt(b.ctx.Int32Type(), valueSize, false)
4646
sizeHint := llvm.ConstInt(b.uintptrType, 8, false)
4747
algEnum := llvm.ConstInt(b.ctx.Int8Type(), alg, false)
4848
if expr.Reserve != nil {

src/runtime/hashmap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type hashmap struct {
1515
buckets unsafe.Pointer // pointer to array of buckets
1616
seed uintptr
1717
count uintptr
18+
valueSize uint32
1819
keySize uint8 // maybe this can store the key type as well? E.g. keysize == 5 means string?
19-
valueSize uint8
2020
bucketBits uint8
2121
keyEqual func(x, y unsafe.Pointer, n uintptr) bool
2222
keyHash func(key unsafe.Pointer, size, seed uintptr) uint32
@@ -60,7 +60,7 @@ func hashmapTopHash(hash uint32) uint8 {
6060
}
6161

6262
// Create a new hashmap with the given keySize and valueSize.
63-
func hashmapMake(keySize, valueSize uint8, sizeHint uintptr, alg uint8) *hashmap {
63+
func hashmapMake(keySize uint8, valueSize uint32, sizeHint uintptr, alg uint8) *hashmap {
6464
numBuckets := sizeHint / 8
6565
bucketBits := uint8(0)
6666
for numBuckets != 0 {

0 commit comments

Comments
 (0)