3 ms·
Is this a re-packaged v7 [0] (it's from Cesanta as well)? mjs.c is 477K. It looks like it as v7.c is 475K [1]. It shaves whole entire 1MB from my staticly li
by oso2k 10y ago
Is this a re-packaged v7 [0] (it's from Cesanta as well)? mjs.c is 477K. It looks like it as v7.c is 475K [1]. It shaves whole entire 1MB from my staticly linked builds (v7 1.9MB vs. mjs 998K), and almost 2MB from dynamically linked builds (v7 1.9MB vs. mjs 99K) on amd64. If it shares the same underlying architecture and api [2] then this is a pretty great achievement.
In their docs, they claim 25K storage and 10K RAM. Blog post claims 25K storage and 1K RAM.
[0] https://github.com/cesanta/mjs/blob/master/mjs.c https://github.com/cesanta/mjs/blob/master/mjs.c
[1] https://github.com/cesanta/v7/blob/master/v7.c https://github.com/cesanta/v7/blob/master/v7.c
[2] https://docs.cesanta.com/v7/master/#/v7-internals/ https://docs.cesanta.com/v7/master/#/v7-internals/
- jfe 10y agoi wonder if the size could be reduced by replacing the yacc code with a hand-written parser.
- drozd 10y agoThere is no yacc code in either V7 or mJS. V7 uses hand-written recursive-descent parser. Initially, it was using ordinary C functions, and that created a problem on systems with low stack size. E.g. each '(' starts statement parsing from the top, so 1 + (2 + (3 + (4 + 5))) consumed stack, and sometimes resulted in stack overflow in e.g. interrupt handlers or network callbacks. Therefore we have rewritten recursive descent using C coroutines, and that is extremely sophisticated piece of work. See https://raw.githubusercontent.com/cesanta/v7/master/v7.c https://raw.githubusercontent.com/cesanta/v7/master/v7.c , search for #line 1 "v7/src/parser.c" mJS on the other hand uses lemon parser generator - the one from sqlite project. It generates a LALR parser which is quite efficient in terms of memory.