diff options
author | Ayke van Laethem <[email protected]> | 2019-12-21 18:50:23 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-12-21 22:59:23 +0100 |
commit | 5a70c8848324c17683892507d622afd6a989eb45 (patch) | |
tree | 21f97861cd1a672d56ba24b33d7d7ad57d352a08 /transform | |
parent | 5510dec846d97c83075b51b4c08af8ad15da661f (diff) | |
download | tinygo-5a70c8848324c17683892507d622afd6a989eb45.tar.gz tinygo-5a70c8848324c17683892507d622afd6a989eb45.zip |
transform: make reflection sidetables constant globals
These globals are (and must be!) never modified by the reflect package.
By marking them as constant, they will be put in read-only memory. This
reduces RAM consumption on microcontrollers.
Diffstat (limited to 'transform')
-rw-r--r-- | transform/reflect.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/transform/reflect.go b/transform/reflect.go index 9bfd16904..fcab9a068 100644 --- a/transform/reflect.go +++ b/transform/reflect.go @@ -160,21 +160,25 @@ func assignTypeCodes(mod llvm.Module, typeSlice typeInfoSlice) { global := replaceGlobalIntWithArray(mod, "reflect.namedNonBasicTypesSidetable", state.namedNonBasicTypesSidetable) global.SetLinkage(llvm.InternalLinkage) global.SetUnnamedAddr(true) + global.SetGlobalConstant(true) } if state.needsArrayTypesSidetable { global := replaceGlobalIntWithArray(mod, "reflect.arrayTypesSidetable", state.arrayTypesSidetable) global.SetLinkage(llvm.InternalLinkage) global.SetUnnamedAddr(true) + global.SetGlobalConstant(true) } if state.needsStructTypesSidetable { global := replaceGlobalIntWithArray(mod, "reflect.structTypesSidetable", state.structTypesSidetable) global.SetLinkage(llvm.InternalLinkage) global.SetUnnamedAddr(true) + global.SetGlobalConstant(true) } if state.needsStructNamesSidetable { global := replaceGlobalIntWithArray(mod, "reflect.structNamesSidetable", state.structNamesSidetable) global.SetLinkage(llvm.InternalLinkage) global.SetUnnamedAddr(true) + global.SetGlobalConstant(true) } } |