aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/utils/make_preload
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-06-17 05:11:29 +0200
committerBjörn Gustavsson <[email protected]>2016-06-17 10:28:13 +0200
commit4443bc775442d568357f72d96e2fbdae2ea58c3d (patch)
tree9571348e1f57e1b0cf667e39813fe3da1537ac68 /erts/emulator/utils/make_preload
parent29864ba25d395aa57b88cd9d4357aa5a935b7535 (diff)
downloadotp-4443bc775442d568357f72d96e2fbdae2ea58c3d.tar.gz
otp-4443bc775442d568357f72d96e2fbdae2ea58c3d.tar.bz2
otp-4443bc775442d568357f72d96e2fbdae2ea58c3d.zip
make_preload: Save some memory by making preloaded code 'const'
Mark the preloaded code 'const' to allow the compiler to put it into the 'text' segment instead of into the 'data' segment. Since the 'text' segment is shared among all instances of the Erlang virtual machine, this change could potentially reduce memory consumption (slightly). Before the change: $ size bin/x86_64-unknown-linux-gnu/beam.smp text data bss dec hex filename 2920246 352273 158472 3430991 345a4f bin/x86_64-unknown-linux-gnu/beam.smp After the change: $ size bin/x86_64-unknown-linux-gnu/beam.smp text data bss dec hex filename 3081046 191473 158472 3430991 345a4f bin/x86_64-unknown-linux-gnu/beam.smp Roughly speaking, this change cuts the size of the data segment in half.
Diffstat (limited to 'erts/emulator/utils/make_preload')
-rwxr-xr-xerts/emulator/utils/make_preload8
1 files changed, 4 insertions, 4 deletions
diff --git a/erts/emulator/utils/make_preload b/erts/emulator/utils/make_preload
index f489bc2a39..8b629d9517 100755
--- a/erts/emulator/utils/make_preload
+++ b/erts/emulator/utils/make_preload
@@ -94,8 +94,8 @@ foreach $file (@ARGV) {
close(FILE);
push(@modules, " {\"$module\", " . length($_) . ", preloaded_$module},\n");
- print "unsigned preloaded_size_$module = ", length($_), ";\n";
- print "unsigned char preloaded_$module", "[] = {\n";
+ print "const unsigned preloaded_size_$module = ", length($_), ";\n";
+ print "const unsigned char preloaded_$module", "[] = {\n";
for ($i = 0; $i < length($_); $i++) {
if ($i % 8 == 0 && $comment ne '') {
$comment =~ s@/\*@..@g; # Comment start -- avoid warning.
@@ -125,10 +125,10 @@ if ($gen_rc) {
print @modules;
print "END\n";
} elsif ($gen_old) {
- print "struct {\n";
+ print "const struct {\n";
print " char* name;\n";
print " int size;\n";
- print " unsigned char* code;\n";
+ print " const unsigned char* code;\n";
print "} pre_loaded[] = {\n";
foreach (@modules) {
print;