Skip to content

Add some more consts to get data moved from .data to .rodata #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

akosthekiss
Copy link
Member

We already had some consts but it was still not enough.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu

@akosthekiss
Copy link
Member Author

Interestingly, the effect is visible in debug builds only: large chunks (2-4K) of data get moved from .data to .rodata. Details below.

filename master/text master/data pr906/text pr906/data gain/text gain/data
release.armv7lhf_linux/jerry 197295 1096 197298 1096 -3 0
release.armv7lhf_linux-cp/jerry 143284 812 143284 812 0 0
release.armv7lhf_linux-cp_minimal/jerry 88091 192 88091 192 0 0
release.armv7lhf_linux-mem_stats/jerry 197855 1096 197858 1096 -3 0
release.armv7lhf_linux-mem_stress_test/jerry 197231 1096 197234 1096 -3 0
release.mcu_stm32f3-cp.bin/jerry 144356 260 144356 260 0 0
release.mcu_stm32f3-cp_minimal.bin/jerry 82704 68 82704 68 0 0
release.mcu_stm32f4-cp.bin/jerry 144356 260 144356 260 0 0
release.mcu_stm32f4-cp_minimal.bin/jerry 82704 68 82704 68 0 0
release.x64_linux/jerry 279890 1373 279890 1373 0 0
release.x64_linux-cp/jerry 211932 989 211932 989 0 0
release.x64_linux-cp_minimal/jerry 133068 204 133068 204 0 0
release.x64_linux-mem_stats/jerry 280923 1373 280923 1373 0 0
release.x64_linux-mem_stress_test/jerry 279917 1373 279917 1373 0 0
debug.armv7lhf_linux/jerry 732048 3272 734224 1104 -2176 2168
debug.armv7lhf_linux-cp/jerry 536720 2988 538904 820 -2184 2168
debug.armv7lhf_linux-cp_minimal/jerry 366772 2384 368952 216 -2180 2168
debug.armv7lhf_linux-mem_stats/jerry 735596 3272 737772 1104 -2176 2168
debug.armv7lhf_linux-mem_stress_test/jerry 732096 3272 734272 1104 -2176 2168
debug.mcu_stm32f4-cp.bin/jerry 547060 2484 549244 316 -2184 2168
debug.mcu_stm32f4-cp_minimal.bin/jerry 365828 2272 368008 104 -2180 2168
debug.x64_linux/jerry 808414 5780 812894 1348 -4480 4432
debug.x64_linux-cp/jerry 628393 5492 632937 1060 -4544 4432
debug.x64_linux-cp_minimal/jerry 438533 4688 442981 272 -4448 4416
debug.x64_linux-mem_stats/jerry 813019 5780 817499 1348 -4480 4432
debug.x64_linux-mem_stress_test/jerry 808434 5780 812914 1348 -4480 4432

@akosthekiss
Copy link
Member Author

If applied together with #905, it does not matter anymore whether debug or release configuration is built, r/w data is always less than 100 bytes. Details below.

filename master/text master/data pr905+906/text pr905+906/data gain/text gain/data
release.armv7lhf_linux/jerry 197295 1096 195940 52 1355 1044
release.armv7lhf_linux-cp/jerry 143284 812 142140 52 1144 760
release.armv7lhf_linux-cp_minimal/jerry 88091 192 87953 0 138 192
release.armv7lhf_linux-mem_stats/jerry 197855 1096 196536 52 1319 1044
release.armv7lhf_linux-mem_stress_test/jerry 197231 1096 195572 52 1659 1044
release.mcu_stm32f3-cp.bin/jerry 144356 260 142748 72 1608 188
release.mcu_stm32f3-cp_minimal.bin/jerry 82704 68 82436 20 268 48
release.mcu_stm32f4-cp.bin/jerry 144356 260 142748 72 1608 188
release.mcu_stm32f4-cp_minimal.bin/jerry 82704 68 82436 20 268 48
release.x64_linux/jerry 279890 1373 278590 61 1300 1312
release.x64_linux-cp/jerry 211932 989 210702 61 1230 928
release.x64_linux-cp_minimal/jerry 133068 204 132993 0 75 204
release.x64_linux-mem_stats/jerry 280923 1373 280071 61 852 1312
release.x64_linux-mem_stress_test/jerry 279917 1373 279031 61 886 1312
debug.armv7lhf_linux/jerry 732048 3272 734008 60 -1960 3212
debug.armv7lhf_linux-cp/jerry 536720 2988 537776 60 -1056 2928
debug.armv7lhf_linux-cp_minimal/jerry 366772 2384 368268 24 -1496 2360
debug.armv7lhf_linux-mem_stats/jerry 735596 3272 737508 60 -1912 3212
debug.armv7lhf_linux-mem_stress_test/jerry 732096 3272 734056 60 -1960 3212
debug.mcu_stm32f4-cp.bin/jerry 547060 2484 547212 76 -152 2408
debug.mcu_stm32f4-cp_minimal.bin/jerry 365828 2272 367392 44 -1564 2228
debug.x64_linux/jerry 808414 5780 817371 68 -8957 5712
debug.x64_linux-cp/jerry 628393 5492 635223 68 -6830 5424
debug.x64_linux-cp_minimal/jerry 438533 4688 443438 32 -4905 4656
debug.x64_linux-mem_stats/jerry 813019 5780 821176 68 -8157 5712
debug.x64_linux-mem_stress_test/jerry 808434 5780 817391 68 -8957 5712

@akosthekiss akosthekiss added enhancement An improvement memory consumption Affects memory consumption labels Feb 20, 2016
@akosthekiss
Copy link
Member Author

Note to the PR, might help others as it helped me:

  • const T * is a read-write pointer to read-only data
  • T * const is a read-only pointer to read-write data
  • const T * const is a read-only pointer to read-only data

@LaszloLango
Copy link
Contributor

LGTM

@zherczeg
Copy link
Member

I thought quoted string constants are always .rodata. At least compiler complains if you pass them as char* in when certain compiler flags are enabled.

@akosthekiss
Copy link
Member Author

@zherczeg Does that mean that we should avoid these changes?

@zherczeg
Copy link
Member

I am not sure which part provides the gain here. But it looks like a gain, so I have no objection.

We already had some `const`s but it was still not enough.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
@akosthekiss
Copy link
Member Author

I've taken an objdump of jerry, and that has revealed that those globals which have been touched in this PR were all in .data, not in .rodata.

@akosthekiss akosthekiss merged commit 866ef5b into jerryscript-project:master Feb 22, 2016
@akosthekiss akosthekiss deleted the const-const-const branch February 22, 2016 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement memory consumption Affects memory consumption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants