shithub: libmujs

Download patch

ref: d3d92291f613adb0fbdac4c271fbb43fc4c69031
parent: 24f48308ce95e5d582c8b0ae23485140f62d233e
author: Tor Andersson <tor@ccxvii.net>
date: Sat Jan 18 12:44:20 EST 2014

Reorder switch cases to match opcode order.

--- a/jscompile.h
+++ b/jscompile.h
@@ -50,25 +50,25 @@
 	OP_BITNOT,
 	OP_LOGNOT,
 
-	OP_BITOR,
-	OP_BITXOR,
-	OP_BITAND,
-	OP_EQ,
-	OP_NE,
-	OP_STRICTEQ,
-	OP_STRICTNE,
+	OP_MUL,
+	OP_DIV,
+	OP_MOD,
+	OP_ADD,
+	OP_SUB,
+	OP_SHL,
+	OP_SHR,
+	OP_USHR,
 	OP_LT,
 	OP_GT,
 	OP_LE,
 	OP_GE,
-	OP_SHL,
-	OP_SHR,
-	OP_USHR,
-	OP_ADD,
-	OP_SUB,
-	OP_MUL,
-	OP_DIV,
-	OP_MOD,
+	OP_EQ,
+	OP_NE,
+	OP_STRICTEQ,
+	OP_STRICTNE,
+	OP_BITAND,
+	OP_BITXOR,
+	OP_BITOR,
 
 	OP_INSTANCEOF,
 
--- a/jsrun.c
+++ b/jsrun.c
@@ -590,6 +590,8 @@
 			}
 			break;
 
+		/* Function calls */
+
 		case OP_CALL:
 			js_call(J, *pc++);
 			break;
@@ -598,7 +600,7 @@
 			js_construct(J, *pc++);
 			break;
 
-		/* Unary expressions */
+		/* Unary operators */
 
 		case OP_TYPEOF:
 			str = js_typeof(J, -1);
@@ -630,19 +632,8 @@
 			js_pushboolean(J, !b);
 			break;
 
-		/* Binary expressions */
+		/* Multiplicative operators */
 
-		case OP_ADD:
-			jsR_concat(J);
-			break;
-
-		case OP_SUB:
-			x = js_tonumber(J, -2);
-			y = js_tonumber(J, -1);
-			js_pop(J, 2);
-			js_pushnumber(J, x - y);
-			break;
-
 		case OP_MUL:
 			x = js_tonumber(J, -2);
 			y = js_tonumber(J, -1);
@@ -664,49 +655,43 @@
 			js_pushnumber(J, fmod(x, y));
 			break;
 
-		case OP_SHL:
-			x = js_tonumber(J, -2);
-			y = js_tonumber(J, -1);
-			js_pop(J, 2);
-			js_pushnumber(J, toint32(x) << (touint32(y) & 0x1F));
-			break;
+		/* Additive operators */
 
-		case OP_SHR:
-			x = js_tonumber(J, -2);
-			y = js_tonumber(J, -1);
-			js_pop(J, 2);
-			js_pushnumber(J, toint32(x) >> (touint32(y) & 0x1F)); break;
+		case OP_ADD:
+			jsR_concat(J);
 			break;
 
-		case OP_USHR:
+		case OP_SUB:
 			x = js_tonumber(J, -2);
 			y = js_tonumber(J, -1);
 			js_pop(J, 2);
-			js_pushnumber(J, touint32(x) >> (touint32(y) & 0x1F)); break;
+			js_pushnumber(J, x - y);
 			break;
 
-		case OP_BITAND:
+		/* Shift operators */
+
+		case OP_SHL:
 			x = js_tonumber(J, -2);
 			y = js_tonumber(J, -1);
 			js_pop(J, 2);
-			js_pushnumber(J, toint32(x) & toint32(y));
+			js_pushnumber(J, toint32(x) << (touint32(y) & 0x1F));
 			break;
 
-		case OP_BITXOR:
+		case OP_SHR:
 			x = js_tonumber(J, -2);
 			y = js_tonumber(J, -1);
 			js_pop(J, 2);
-			js_pushnumber(J, toint32(x) ^ toint32(y));
+			js_pushnumber(J, toint32(x) >> (touint32(y) & 0x1F)); break;
 			break;
 
-		case OP_BITOR:
+		case OP_USHR:
 			x = js_tonumber(J, -2);
 			y = js_tonumber(J, -1);
 			js_pop(J, 2);
-			js_pushnumber(J, toint32(x) | toint32(y));
+			js_pushnumber(J, touint32(x) >> (touint32(y) & 0x1F)); break;
 			break;
 
-		/* Relational expressions */
+		/* Relational operators */
 
 		/* TODO: string comparisons */
 		case OP_LT:
@@ -734,6 +719,8 @@
 			js_pushboolean(J, x >= y);
 			break;
 
+		/* Equality */
+
 		case OP_EQ:
 		case OP_STRICTEQ:
 			x = js_tonumber(J, -2);
@@ -747,6 +734,29 @@
 			y = js_tonumber(J, -1);
 			js_pop(J, 2);
 			js_pushboolean(J, x != y);
+			break;
+
+		/* Binary bitwise operators */
+
+		case OP_BITAND:
+			x = js_tonumber(J, -2);
+			y = js_tonumber(J, -1);
+			js_pop(J, 2);
+			js_pushnumber(J, toint32(x) & toint32(y));
+			break;
+
+		case OP_BITXOR:
+			x = js_tonumber(J, -2);
+			y = js_tonumber(J, -1);
+			js_pop(J, 2);
+			js_pushnumber(J, toint32(x) ^ toint32(y));
+			break;
+
+		case OP_BITOR:
+			x = js_tonumber(J, -2);
+			y = js_tonumber(J, -1);
+			js_pop(J, 2);
+			js_pushnumber(J, toint32(x) | toint32(y));
 			break;
 
 		/* Branching */