Skip to content

Commit 07ccd49

Browse files
jplexerclaude
andcommitted
fw/graphics: keep the glyph metadata SPI lookup inlined
35ff0d4 ("fw/graphics: consult the font's other own resource when routed lookup misses") added a second call site for prv_get_glyph_metadata_from_spi(), which stopped GCC from inlining it into prv_get_glyph_in_font(): the glyph lookup path grew from one 64-byte frame to 40 + 64 bytes of nested frames. This chain (graphics_draw_text -> walk_line -> text_resources_get_glyph -> resource/pfs syscalls) is the deepest consumer of the app task's 2 KiB stack on non-emery/gabbro platforms, and the extra 40 bytes pushed watchfaces already near the limit into the stack guard. On a Pebble 2 Duo this presented as v4.33.1 "not sticking": the active watchface overflowed on every boot seconds after launch, the fault escalated to a reboot, and after three reboots the bootloader fell back to PRF (the QR onboarding screen). Mark prv_get_glyph_metadata_from_spi() ALWAYS_INLINE. With both call sites inlined GCC overlaps their stack slots, restoring the pre-4.32.0 64-byte frame, and the merged function is slightly smaller (836 vs 878 bytes) than the outlined pair since the call overhead disappears. Fixes FIRM-3949 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Joshua Jun <lets@throw.rocks>
1 parent 5055310 commit 07ccd49

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/fw/applib/graphics/text_resources.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "applib/fonts/fonts_private.h"
1111
#include "resource/resource_ids.auto.h"
1212
#include <pbl/logging/logging.h>
13+
#include <pbl/util/attributes.h>
1314
#include "system/passert.h"
1415
#include "system/profiler.h"
1516
#include "pbl/util/math.h"
@@ -349,10 +350,10 @@ static bool prv_load_glyph_bitmap(Codepoint codepoint, const FontResource *font_
349350
return true;
350351
}
351352

352-
static const GlyphData *prv_get_glyph_metadata_from_spi(Codepoint codepoint,
353-
FontCache *font_cache,
354-
const FontResource *font_res,
355-
bool need_bitmap) {
353+
static ALWAYS_INLINE const GlyphData *prv_get_glyph_metadata_from_spi(Codepoint codepoint,
354+
FontCache *font_cache,
355+
const FontResource *font_res,
356+
bool need_bitmap) {
356357
const uint32_t cache_key = prv_get_cache_key(font_res, codepoint);
357358
LineCacheData *cached = NULL;
358359

0 commit comments

Comments
 (0)