noinline various things in main.c

This commit is contained in:
dzaima 2022-11-06 02:32:04 +02:00
parent 28d434a201
commit fc059a77d0

View File

@ -16,7 +16,7 @@ static B replPath;
static Scope* gsc; static Scope* gsc;
static bool init = false; static bool init = false;
static void repl_init() { static NOINLINE void repl_init() {
if (init) return; if (init) return;
cbqn_init(); cbqn_init();
replPath = m_c8vec_0("."); gc_add(replPath); replPath = m_c8vec_0("."); gc_add(replPath);
@ -27,7 +27,7 @@ static void repl_init() {
init = true; init = true;
} }
static B gsc_exec_inline(B src, B path, B args) { static NOINLINE B gsc_exec_inline(B src, B path, B args) {
Block* block = bqn_compSc(src, path, args, gsc, true); Block* block = bqn_compSc(src, path, args, gsc, true);
ptr_dec(gsc->body); // redirect new errors to the newly executed code; initial scope had 0 vars, so this is safe ptr_dec(gsc->body); // redirect new errors to the newly executed code; initial scope had 0 vars, so this is safe
gsc->body = ptr_inc(block->bodies[0]); gsc->body = ptr_inc(block->bodies[0]);
@ -36,15 +36,21 @@ static B gsc_exec_inline(B src, B path, B args) {
return r; return r;
} }
static bool isCmd(char* s, char** e, const char* cmd) { typedef struct { bool r; char* e; } IsCmdTmp;
static NOINLINE IsCmdTmp isCmd0(char* s, const char* cmd) {
while (*cmd) { while (*cmd) {
if (*cmd==' ' && *s==0) { *e = s; return true; } if (*cmd==' ' && *s==0) return (IsCmdTmp){.r=true, .e=s};
if (*s!=*cmd || *s==0) return false; if (*s!=*cmd || *s==0) return (IsCmdTmp){.r=false, .e=s};
s++; cmd++; s++; cmd++;
} }
*e = s; return (IsCmdTmp){.r=true, .e=s};
return true;
} }
static bool isCmd(char* s, char** e, const char* cmd) {
IsCmdTmp t = isCmd0(s, cmd);
*e = t.e;
return t.r;
}
bool profiler_alloc(void); bool profiler_alloc(void);
bool profiler_start(i64 hz); bool profiler_start(i64 hz);
bool profiler_stop(void); bool profiler_stop(void);
@ -53,7 +59,7 @@ void profiler_displayResults(void);
void clearImportCache(void); void clearImportCache(void);
static B escape_parser; static B escape_parser;
B simple_unescape(B x) { static B simple_unescape(B x) {
if (RARE(escape_parser.u==0)) { if (RARE(escape_parser.u==0)) {
escape_parser = bqn_exec(utf8Decode0("{m←\"Expected surrounding quotes\" ⋄ m!2≤≠𝕩 ⋄ m!\"\"\"\"\"\"≡0‿¯1⊏𝕩 ⋄ s←¬e←<`'\\'=𝕩 ⋄ i‿o←\"\\\"\"nr\"\"\\\"\"\"∾@+10‿13 ⋄ 1↓¯1↓{n←i⊐𝕩\"Unknown escape\"!∧´n≠≠i ⋄ n⊏o}⌾((s/»e)⊸/) s/𝕩}"), bi_N, bi_N); escape_parser = bqn_exec(utf8Decode0("{m←\"Expected surrounding quotes\" ⋄ m!2≤≠𝕩 ⋄ m!\"\"\"\"\"\"≡0‿¯1⊏𝕩 ⋄ s←¬e←<`'\\'=𝕩 ⋄ i‿o←\"\\\"\"nr\"\"\\\"\"\"∾@+10‿13 ⋄ 1↓¯1↓{n←i⊐𝕩\"Unknown escape\"!∧´n≠≠i ⋄ n⊏o}⌾((s/»e)⊸/) s/𝕩}"), bi_N, bi_N);
gc_add(escape_parser); gc_add(escape_parser);
@ -61,7 +67,7 @@ B simple_unescape(B x) {
return c1(escape_parser, x); return c1(escape_parser, x);
} }
i64 readInt(char** p) { static NOINLINE i64 readInt(char** p) {
char* c = *p; char* c = *p;
i64 am = 0; i64 am = 0;
while (*c>='0' & *c<='9') { while (*c>='0' & *c<='9') {