Remove line opcode in favor of storing the line for each instruction.

This commit is contained in:
Tor Andersson
2019-03-07 14:38:18 +01:00
parent 20d0fa04df
commit f5de9d4d2e
5 changed files with 7 additions and 17 deletions

View File

@@ -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);

View File

@@ -108,8 +108,6 @@ enum js_OpCode
OP_JTRUE,
OP_JFALSE,
OP_RETURN,
OP_LINE, /* -K- */
};
struct js_Function

View File

@@ -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:

View File

@@ -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;
}
}
}

View File

@@ -84,4 +84,3 @@
"jtrue",
"jfalse",
"return",
"line",