diff options
author | Damian Gryski <[email protected]> | 2023-01-10 14:23:46 -0800 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-01-18 09:48:00 +0100 |
commit | 530ca0838db32cb4f07787d34c4af249d8c0819c (patch) | |
tree | a6b22855796ab9d3f7c9b97d3a878572b7683dae | |
parent | c41a212712e411952d5685605e082da65e1f75b6 (diff) | |
download | tinygo-530ca0838db32cb4f07787d34c4af249d8c0819c.tar.gz tinygo-530ca0838db32cb4f07787d34c4af249d8c0819c.zip |
compiler,runtime: allow map values >256 bytes
-rw-r--r-- | compiler/map.go | 2 | ||||
-rw-r--r-- | src/runtime/hashmap.go | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/map.go b/compiler/map.go index 7655ec707..e70c5ce7a 100644 --- a/compiler/map.go +++ b/compiler/map.go @@ -42,7 +42,7 @@ func (b *builder) createMakeMap(expr *ssa.MakeMap) (llvm.Value, error) { keySize := b.targetData.TypeAllocSize(llvmKeyType) valueSize := b.targetData.TypeAllocSize(llvmValueType) llvmKeySize := llvm.ConstInt(b.ctx.Int8Type(), keySize, false) - llvmValueSize := llvm.ConstInt(b.ctx.Int8Type(), valueSize, false) + llvmValueSize := llvm.ConstInt(b.ctx.Int32Type(), valueSize, false) sizeHint := llvm.ConstInt(b.uintptrType, 8, false) algEnum := llvm.ConstInt(b.ctx.Int8Type(), alg, false) if expr.Reserve != nil { diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 965dab29c..2e077a45f 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -15,8 +15,8 @@ type hashmap struct { buckets unsafe.Pointer // pointer to array of buckets seed uintptr count uintptr + valueSize uint32 keySize uint8 // maybe this can store the key type as well? E.g. keysize == 5 means string? - valueSize uint8 bucketBits uint8 keyEqual func(x, y unsafe.Pointer, n uintptr) bool keyHash func(key unsafe.Pointer, size, seed uintptr) uint32 @@ -60,7 +60,7 @@ func hashmapTopHash(hash uint32) uint8 { } // Create a new hashmap with the given keySize and valueSize. -func hashmapMake(keySize, valueSize uint8, sizeHint uintptr, alg uint8) *hashmap { +func hashmapMake(keySize uint8, valueSize uint32, sizeHint uintptr, alg uint8) *hashmap { numBuckets := sizeHint / 8 bucketBits := uint8(0) for numBuckets != 0 { |