aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-12-21 18:50:23 +0100
committerRon Evans <[email protected]>2019-12-21 22:59:23 +0100
commit5a70c8848324c17683892507d622afd6a989eb45 (patch)
tree21f97861cd1a672d56ba24b33d7d7ad57d352a08 /transform
parent5510dec846d97c83075b51b4c08af8ad15da661f (diff)
downloadtinygo-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.go4
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)
}
}