Skip to content

Commit 7940729

Browse files
committed
Bangle.js1: dump() now doesn't write out interpreter state as JS (saves 1.5kB Flash)
1 parent 9feb8de commit 7940729

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Added ability to execute JS from an a timer with `require("timer").add({type:"EXEC",...)`
88
Bangle.js: Add Bangle.setOptions({stepCounterDisabled:bool}) to disable the step counter
99
Date: fix parsing of ISO8601 timezones (+HHMM worked, but +HH:MM and +HH added) (fix #2669)
10+
Bangle.js1: dump() now doesn't write out interpreter state as JS (saves 1.5kB Flash)
1011

1112
2v28 : Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]`
1213
Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)

README_BuildProcess.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ There are some specifically that are useful for cutting a few bytes out of the b
173173
* `ESPR_LIMIT_DATE_RANGE` - limits the acceptable range for Date years (saves a few hundred bytes)
174174
* `ESPR_NO_REGEX_OPTIMISE` - strips out some speed optimisations from the regex library
175175
* On nRF52, `'LDFLAGS += -nostartfiles', 'ASFLAGS += -D__STARTUP_CLEAR_BSS -D__START=main',` can save ~300b by not including CRT startup code
176+
* `ESPR_NO_DUMP_STATE` - stops `dump()` from trying to reconstruct interpreter state as JS (saves almost 1.5kB)
176177

177178

178179
These are set automatically when `SAVE_ON_FLASH` is set (see `jsutils.h`)

boards/BANGLEJS.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'DEFINES+=-DCUSTOM_GETBATTERY=jswrap_banglejs_getBattery',
5050
'DEFINES+=-DESPR_UNICODE_SUPPORT=1',
5151
'DEFINES+=-DESPR_NO_SOFTWARE_SERIAL=1',
52+
'DEFINES+=-DESPR_NO_DUMP_STATE=1', # don't let dump() output current state - saves a lot of flash
5253
'DEFINES+=-DDUMP_IGNORE_VARIABLES=\'"g\\0"\'',
5354
'DEFINES+=-DSAVE_ON_FLASH_MATH',
5455
'DEFINES+=-DESPR_PACKED_SYMPTR', # Pack builtin symbols' offset into pointer to save 2 bytes/symbol

src/jsinteractive.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,8 +2699,10 @@ bool jsiLoop() {
26992699

27002700
/** Output current interpreter state such that it can be copied to a new device */
27012701
void jsiDumpState(vcbprintf_callback user_callback, void *user_data) {
2702+
#if defined(ESPR_NO_DUMP_STATE)
2703+
cbprintf(user_callback, user_data, "// This build can't output RAM contants as JS (ESPR_NO_DUMP_STATE=1)\n");
2704+
#else
27022705
JsvObjectIterator it;
2703-
27042706
jsvObjectIteratorNew(&it, execInfo.root);
27052707
while (jsvObjectIteratorHasValue(&it)) {
27062708
JsVar *child = jsvObjectIteratorGetKey(&it);
@@ -2812,7 +2814,7 @@ void jsiDumpState(vcbprintf_callback user_callback, void *user_data) {
28122814

28132815
// and now the actual hardware
28142816
jsiDumpHardwareInitialisation(user_callback, user_data, true/*human readable*/);
2815-
2817+
#endif
28162818
JsVar *code = jsfGetBootCodeFromFlash(false);
28172819
if (code) {
28182820
cbprintf(user_callback, user_data, "// Code saved with E.setBootCode\n");

0 commit comments

Comments
 (0)