shithub: libmujs

Download patch

ref: f5de9d4d2e3f76cc6b92f71c6f468a2a95d74bfb
parent: 20d0fa04df4d750f52ac6a41b50ebd96a1d005f0
author: Tor Andersson <tor.andersson@artifex.com>
date: Thu Mar 7 09:38:18 EST 2019

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

--- a/jscompile.c
+++ b/jscompile.c
@@ -86,6 +86,7 @@
 
 static void emit(JF, int value)
 {
+	emitraw(J, F, F->lastline);
 	emitraw(J, F, value);
 }
 
@@ -96,11 +97,7 @@
 
 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 int here(JF)
 {
-	F->lastline = -1; /* force the next emitline */
 	return F->codelen;
 }
 
@@ -1448,8 +1444,6 @@
 		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);
--- a/jscompile.h
+++ b/jscompile.h
@@ -108,8 +108,6 @@
 	OP_JTRUE,
 	OP_JFALSE,
 	OP_RETURN,
-
-	OP_LINE,	/* -K- */
 };
 
 struct js_Function
--- a/jsdump.c
+++ b/jsdump.c
@@ -791,9 +791,10 @@
 
 	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 @@
 			ps(F->strtab[*p++]);
 			break;
 
-		case OP_LINE:
 		case OP_CLOSURE:
 		case OP_INITLOCAL:
 		case OP_GETLOCAL:
--- a/jsrun.c
+++ b/jsrun.c
@@ -1306,7 +1306,10 @@
 		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 @@
 		case OP_RETURN:
 			J->strict = savestrict;
 			return;
-
-		case OP_LINE:
-			J->trace[J->tracetop].line = *pc++;
-			break;
 		}
 	}
 }
--- a/opnames.h
+++ b/opnames.h
@@ -84,4 +84,3 @@
 "jtrue",
 "jfalse",
 "return",
-"line",