mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
Remove line opcode in favor of storing the line for each instruction.
This commit is contained in:
10
jscompile.c
10
jscompile.c
@@ -86,6 +86,7 @@ static void emitraw(JF, int value)
|
||||
|
||||
static void emit(JF, int value)
|
||||
{
|
||||
emitraw(J, F, F->lastline);
|
||||
emitraw(J, F, value);
|
||||
}
|
||||
|
||||
@@ -96,11 +97,7 @@ static void emitarg(JF, int value)
|
||||
|
||||
static void emitline(JF, js_Ast *node)
|
||||
{
|
||||
if (F->lastline != node->line) {
|
||||
F->lastline = node->line;
|
||||
emit(J, F, OP_LINE);
|
||||
emitraw(J, F, node->line);
|
||||
}
|
||||
F->lastline = node->line;
|
||||
}
|
||||
|
||||
static int addfunction(JF, js_Function *value)
|
||||
@@ -232,7 +229,6 @@ static void emitlocal(JF, int oploc, int opvar, js_Ast *ident)
|
||||
|
||||
static int here(JF)
|
||||
{
|
||||
F->lastline = -1; /* force the next emitline */
|
||||
return F->codelen;
|
||||
}
|
||||
|
||||
@@ -1448,8 +1444,6 @@ static void cfunbody(JF, js_Ast *name, js_Ast *params, js_Ast *body)
|
||||
if (!strcmp(body->a->string, "use strict"))
|
||||
F->strict = 1;
|
||||
|
||||
emit(J, F, OP_LINE);
|
||||
emitraw(J, F, F->line);
|
||||
F->lastline = F->line;
|
||||
|
||||
shadow = cparams(J, F, params, name);
|
||||
|
||||
@@ -108,8 +108,6 @@ enum js_OpCode
|
||||
OP_JTRUE,
|
||||
OP_JFALSE,
|
||||
OP_RETURN,
|
||||
|
||||
OP_LINE, /* -K- */
|
||||
};
|
||||
|
||||
struct js_Function
|
||||
|
||||
4
jsdump.c
4
jsdump.c
@@ -791,9 +791,10 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
|
||||
|
||||
printf("{\n");
|
||||
while (p < end) {
|
||||
int ln = *p++;
|
||||
int c = *p++;
|
||||
|
||||
printf("% 5d: ", (int)(p - F->code) - 1);
|
||||
printf("%5d(%3d): ", (int)(p - F->code) - 2, ln);
|
||||
ps(opname[c]);
|
||||
|
||||
switch (c) {
|
||||
@@ -827,7 +828,6 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
|
||||
ps(F->strtab[*p++]);
|
||||
break;
|
||||
|
||||
case OP_LINE:
|
||||
case OP_CLOSURE:
|
||||
case OP_INITLOCAL:
|
||||
case OP_GETLOCAL:
|
||||
|
||||
7
jsrun.c
7
jsrun.c
@@ -1306,7 +1306,10 @@ static void jsR_run(js_State *J, js_Function *F)
|
||||
if (J->gccounter > JS_GCLIMIT)
|
||||
js_gc(J, 0);
|
||||
|
||||
J->trace[J->tracetop].line = *pc++;
|
||||
|
||||
opcode = *pc++;
|
||||
|
||||
switch (opcode) {
|
||||
case OP_POP: js_pop(J, 1); break;
|
||||
case OP_DUP: js_dup(J); break;
|
||||
@@ -1748,10 +1751,6 @@ static void jsR_run(js_State *J, js_Function *F)
|
||||
case OP_RETURN:
|
||||
J->strict = savestrict;
|
||||
return;
|
||||
|
||||
case OP_LINE:
|
||||
J->trace[J->tracetop].line = *pc++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user