mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
clean-up esp8266 PR to move symbols to flash
This commit is contained in:
parent
4493b09eef
commit
4885b28bf2
@ -1,5 +1,6 @@
|
||||
1v86 : Compile Telnet server into linux by default, Add '--telnet' command-line option to enable it
|
||||
Fix lock 'leak' in Telnet when Telnet is turned off
|
||||
Add Telnet serial device to allow redirection
|
||||
Create errors for unterminated expressions (fix #814)
|
||||
Remove Espruino's built-in strcpy/etc
|
||||
Remove Espruino's built-in maths
|
||||
@ -14,6 +15,8 @@
|
||||
'Expecting a number or something iterable, got X' changed to exception rather than warning (gives stack trace)
|
||||
Drop '.init' and '.fini' symbols, allowing GCC 5.x compilation on STM32
|
||||
Ensure that pinMode/digitalWrite is re-constituted properly by dump() and save() (fix #833)
|
||||
ESP8266: add stack dump on fatal exception, ./targets/esp8266/printstack can extract a backtrace
|
||||
ESP8266: move JswSymPtr and JswSymList to flash to free up gobs of RAM, bump jsvars to 1600
|
||||
|
||||
1v85 : Ensure HttpServerResponse.writeHead actually sends the header right away
|
||||
- enables WebSocket Server support from JS
|
||||
|
||||
@ -269,8 +269,9 @@ extern int os_printf_plus();
|
||||
|
||||
JsVar *jswBinarySearch(const JswSymList *symbolsPtr, JsVar *parent, const char *name) {
|
||||
//os_printf_plus("bs%p %s\\n", symbolsPtr, name);
|
||||
uint8_t symbolCount = READ_FLASH_UINT8(&symbolsPtr->symbolCount);
|
||||
int searchMin = 0;
|
||||
int searchMax = symbolsPtr->symbolCount -1;
|
||||
int searchMax = symbolCount - 1;
|
||||
while (searchMin <= searchMax) {
|
||||
int idx = (searchMin+searchMax) >> 1;
|
||||
const JswSymPtr *sym = &symbolsPtr->symbols[idx];
|
||||
|
||||
@ -222,13 +222,18 @@ void jswrap_object_keys_or_property_names_cb(
|
||||
|
||||
while (symbols) {
|
||||
unsigned int i;
|
||||
unsigned short symbolCount = READ_FLASH_UINT16(&symbols->symbolCount);
|
||||
unsigned char symbolCount = READ_FLASH_UINT8(&symbols->symbolCount);
|
||||
unsigned short strOffset = READ_FLASH_UINT16(&symbols->symbols[i].strOffset);
|
||||
for (i=0;i<symbolCount;i++) {
|
||||
char buf[256], *b, c;
|
||||
#ifndef ESP8266
|
||||
JsVar *name = jsvNewFromString(&symbols->symbolChars[strOffset]);
|
||||
#else
|
||||
// On the esp8266 the string is in flash, so we have to copy it to RAM first
|
||||
char buf[64], *b, c;
|
||||
const char *s = &symbols->symbolChars[strOffset];
|
||||
do { c = READ_FLASH_UINT8(s++); *b++ = c; } while(c);
|
||||
do { c = READ_FLASH_UINT8(s++); *b++ = c; } while(c && b != buf+64);
|
||||
JsVar *name = jsvNewFromString(buf);
|
||||
#endif
|
||||
//os_printf_plus("OBJ cb %s\n", buf);
|
||||
callback(data, name);
|
||||
jsvUnLock(name);
|
||||
|
||||
@ -58,19 +58,27 @@ typedef enum {
|
||||
// number of bits needed for each argument bit
|
||||
#define JSWAT_BITS GET_BIT_NUMBER(JSWAT_MASK+1)
|
||||
|
||||
#ifndef ESP8266
|
||||
#define PACKED_JSW_SYM PACKED_FLAGS
|
||||
#else
|
||||
// On the esp8266 we put the JswSym* structures into flash and thus must make word-sized aligned
|
||||
// reads. Telling the compiler to pack the structs defeats that, so we have to take it out.
|
||||
#define PACKED_JSW_SYM
|
||||
#endif
|
||||
|
||||
/// Structure for each symbol in the list of built-in symbols
|
||||
typedef struct {
|
||||
unsigned short strOffset;
|
||||
unsigned short functionSpec; // JsnArgumentType
|
||||
void (*functionPtr)(void);
|
||||
} JswSymPtr;//PACKED_FLAGS
|
||||
} PACKED_JSW_SYM JswSymPtr;
|
||||
|
||||
/// Information for each list of built-in symbols
|
||||
typedef struct {
|
||||
const JswSymPtr *symbols;
|
||||
const char *symbolChars;
|
||||
uint32_t symbolCount;
|
||||
} JswSymList;//PACKED_FLAGS
|
||||
unsigned char symbolCount;
|
||||
} PACKED_JSW_SYM JswSymList;
|
||||
|
||||
/// Do a binary search of the symbol table list
|
||||
JsVar *jswBinarySearch(const JswSymList *symbolsPtr, JsVar *parent, const char *name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user