ARM toolchain: heap setup micro-optimisation

Locating and checking the length of the `ARM_LIB_HEAP` region is an
extra task, when we're just interested in the base and limit. Looking at
only those saves 8 bytes of ROM.

More space could be saved if we ensured all targets had `ARM_LIB_HEAP`,
removing the need for this run-time fallback code.
pull/11701/head
Kevin Bracey 2019-10-17 12:36:03 +03:00
parent 8c860524fb
commit 93fbfafedf
1 changed files with 2 additions and 3 deletions

View File

@ -927,7 +927,6 @@ __asm(".global __use_no_semihosting\n\t");
// Through weak-reference, we can check if ARM_LIB_HEAP is defined at run-time.
// If ARM_LIB_HEAP is defined, we can fix heap allocation.
extern MBED_WEAK uint32_t Image$$ARM_LIB_HEAP$$ZI$$Base[];
extern MBED_WEAK uint32_t Image$$ARM_LIB_HEAP$$ZI$$Length[];
extern MBED_WEAK uint32_t Image$$ARM_LIB_HEAP$$ZI$$Limit[];
// Heap here is considered starting after ZI ends to Stack start
@ -942,7 +941,7 @@ extern "C" MBED_WEAK __value_in_regs struct __initial_stackheap _mbed_user_setup
struct __initial_stackheap r;
// Fix heap if ARM_LIB_HEAP is defined
if (Image$$ARM_LIB_HEAP$$ZI$$Length) {
if (Image$$ARM_LIB_HEAP$$ZI$$Base != Image$$ARM_LIB_HEAP$$ZI$$Limit) {
heap_base = (uint32_t) Image$$ARM_LIB_HEAP$$ZI$$Base;
heap_limit = (uint32_t) Image$$ARM_LIB_HEAP$$ZI$$Limit;
}
@ -965,7 +964,7 @@ extern "C" __value_in_regs struct __argc_argv $Sub$$__rt_lib_init(unsigned heapb
uint32_t heap_limit = (uint32_t)Image$$ARM_LIB_STACK$$ZI$$Base;
// Fix heap if ARM_LIB_HEAP is defined
if (Image$$ARM_LIB_HEAP$$ZI$$Length) {
if (Image$$ARM_LIB_HEAP$$ZI$$Base != Image$$ARM_LIB_HEAP$$ZI$$Limit) {
heap_base = (uint32_t) Image$$ARM_LIB_HEAP$$ZI$$Base;
heap_limit = (uint32_t) Image$$ARM_LIB_HEAP$$ZI$$Limit;
}