Removal of Token.GETBASE, Token.GETTHIS, Token.PARENT, Token.NEWTEMP, Token.USETEMP, Node.TEMP_PROP, Node.FIXUPS_PROP, Node.USES_PROP constants which are no longer used after the last changes

This commit is contained in:
igor%mir2.org 2004-05-12 15:00:41 +00:00
Родитель 92f45d1054
Коммит 8423b14b48
4 изменённых файлов: 82 добавлений и 164 удалений

Просмотреть файл

@ -791,7 +791,6 @@ public class Interpreter
break; break;
} }
case Token.GETBASE :
case Token.BINDNAME : case Token.BINDNAME :
case Token.NAME : case Token.NAME :
case Token.STRING : case Token.STRING :
@ -1595,7 +1594,6 @@ public class Interpreter
case Token.CATCH_SCOPE : case Token.CATCH_SCOPE :
case Icode_TYPEOFNAME : case Icode_TYPEOFNAME :
case Icode_NAME_AND_THIS : case Icode_NAME_AND_THIS :
case Token.GETBASE :
case Token.BINDNAME : case Token.BINDNAME :
case Token.SETNAME : case Token.SETNAME :
case Token.NAME : case Token.NAME :
@ -1767,7 +1765,6 @@ public class Interpreter
case Token.CATCH_SCOPE : case Token.CATCH_SCOPE :
case Icode_TYPEOFNAME : case Icode_TYPEOFNAME :
case Icode_NAME_AND_THIS : case Icode_NAME_AND_THIS :
case Token.GETBASE :
case Token.BINDNAME : case Token.BINDNAME :
case Token.SETNAME : case Token.SETNAME :
case Token.NAME : case Token.NAME :
@ -2472,12 +2469,6 @@ public class Interpreter
pc += 2; pc += 2;
break; break;
} }
case Token.GETBASE : {
String name = strings[getIndex(iCode, pc + 1)];
stack[++stackTop] = ScriptRuntime.getBase(scope, name);
pc += 2;
break;
}
case Token.SETNAME : { case Token.SETNAME : {
String name = strings[getIndex(iCode, pc + 1)]; String name = strings[getIndex(iCode, pc + 1)];
Object rhs = stack[stackTop]; Object rhs = stack[stackTop];

Просмотреть файл

@ -364,16 +364,13 @@ public class Node
public static final int public static final int
FUNCTION_PROP = 1, FUNCTION_PROP = 1,
TEMP_PROP = 2, LOCAL_PROP = 2,
LOCAL_PROP = 3, LOCAL_BLOCK_PROP = 3,
LOCAL_BLOCK_PROP = 4, REGEXP_PROP = 4,
FIXUPS_PROP = 5, CASES_PROP = 5,
USES_PROP = 6, DEFAULT_PROP = 6,
REGEXP_PROP = 7, CASEARRAY_PROP = 7,
CASES_PROP = 8, SPECIAL_PROP_PROP = 8,
DEFAULT_PROP = 9,
CASEARRAY_PROP = 10,
SPECIAL_PROP_PROP = 11,
/* /*
the following properties are defined and manipulated by the the following properties are defined and manipulated by the
optimizer - optimizer -
@ -386,11 +383,11 @@ public class Node
matches. matches.
*/ */
TARGETBLOCK_PROP = 12, TARGETBLOCK_PROP = 9,
VARIABLE_PROP = 13, VARIABLE_PROP = 10,
ISNUMBER_PROP = 14, ISNUMBER_PROP = 11,
DIRECTCALL_PROP = 15, DIRECTCALL_PROP = 12,
SPECIALCALL_PROP = 16; SPECIALCALL_PROP = 13;
public static final int // this value of the SPECIAL_PROP_PROP specifies public static final int // this value of the SPECIAL_PROP_PROP specifies
SPECIAL_PROP_PROTO = 1, SPECIAL_PROP_PROTO = 1,
@ -412,11 +409,8 @@ public class Node
// can remove all these strings. // can remove all these strings.
switch (propType) { switch (propType) {
case FUNCTION_PROP: return "function"; case FUNCTION_PROP: return "function";
case TEMP_PROP: return "temp";
case LOCAL_PROP: return "local"; case LOCAL_PROP: return "local";
case LOCAL_BLOCK_PROP: return "local_block"; case LOCAL_BLOCK_PROP: return "local_block";
case FIXUPS_PROP: return "fixups";
case USES_PROP: return "uses";
case REGEXP_PROP: return "regexp"; case REGEXP_PROP: return "regexp";
case CASES_PROP: return "cases"; case CASES_PROP: return "cases";
case DEFAULT_PROP: return "default"; case DEFAULT_PROP: return "default";
@ -620,9 +614,6 @@ public class Node
sb.append(": "); sb.append(": ");
String value; String value;
switch (type) { switch (type) {
case FIXUPS_PROP : // can't add this as it recurses
value = "fixups property";
break;
case TARGETBLOCK_PROP : // can't add this as it recurses case TARGETBLOCK_PROP : // can't add this as it recurses
value = "target block property"; value = "target block property";
break; break;

Просмотреть файл

@ -130,85 +130,80 @@ public class Token
INSTANCEOF = 55, INSTANCEOF = 55,
LOCAL_SAVE = 56, LOCAL_SAVE = 56,
LOCAL_LOAD = 57, LOCAL_LOAD = 57,
GETBASE = 58, GETVAR = 58,
GETVAR = 59, SETVAR = 59,
SETVAR = 60, UNDEFINED = 60,
UNDEFINED = 61, CATCH_SCOPE = 61,
CATCH_SCOPE = 62, ENUM_INIT = 62,
ENUM_INIT = 63, ENUM_NEXT = 63,
ENUM_NEXT = 64, ENUM_ID = 64,
ENUM_ID = 65, THISFN = 65,
THISFN = 66, RETURN_POPV = 66, // to return result stored as popv in functions
RETURN_POPV = 67, // to return result stored as popv in functions
LAST_BYTECODE_TOKEN = 67, LAST_BYTECODE_TOKEN = 66,
// End of interpreter bytecodes // End of interpreter bytecodes
GETTHIS = 68, TRY = 67,
TRY = 69, SEMI = 68, // semicolon
SEMI = 70, // semicolon LB = 69, // left and right brackets
LB = 71, // left and right brackets RB = 70,
RB = 72, LC = 71, // left and right curlies (braces)
LC = 73, // left and right curlies (braces) RC = 72,
RC = 74, LP = 73, // left and right parentheses
LP = 75, // left and right parentheses RP = 74,
RP = 76, COMMA = 75, // comma operator
COMMA = 77, // comma operator ASSIGN = 76, // simple assignment (=)
ASSIGN = 78, // simple assignment (=) ASSIGNOP = 77, // assignment with operation (+= -= etc.)
ASSIGNOP = 79, // assignment with operation (+= -= etc.) HOOK = 78, // conditional (?:)
HOOK = 80, // conditional (?:) COLON = 79,
COLON = 81, OR = 80, // logical or (||)
OR = 82, // logical or (||) AND = 81, // logical and (&&)
AND = 83, // logical and (&&) INC = 82, // increment/decrement (++ --)
INC = 84, // increment/decrement (++ --) DEC = 83,
DEC = 85, DOT = 84, // member operator (.)
DOT = 86, // member operator (.) FUNCTION = 85, // function keyword
FUNCTION = 87, // function keyword EXPORT = 86, // export keyword
EXPORT = 88, // export keyword IMPORT = 87, // import keyword
IMPORT = 89, // import keyword IF = 88, // if keyword
IF = 90, // if keyword ELSE = 89, // else keyword
ELSE = 91, // else keyword SWITCH = 90, // switch keyword
SWITCH = 92, // switch keyword CASE = 91, // case keyword
CASE = 93, // case keyword DEFAULT = 92, // default keyword
DEFAULT = 94, // default keyword WHILE = 93, // while keyword
WHILE = 95, // while keyword DO = 94, // do keyword
DO = 96, // do keyword FOR = 95, // for keyword
FOR = 97, // for keyword BREAK = 96, // break keyword
BREAK = 98, // break keyword CONTINUE = 97, // continue keyword
CONTINUE = 99, // continue keyword VAR = 98, // var keyword
VAR = 100, // var keyword WITH = 99, // with keyword
WITH = 101, // with keyword CATCH = 100, // catch keyword
CATCH = 102, // catch keyword FINALLY = 101, // finally keyword
FINALLY = 103, // finally keyword VOID = 102, // void keyword
VOID = 104, // void keyword RESERVED = 103, // reserved keywords
RESERVED = 105, // reserved keywords
EMPTY = 106, EMPTY = 104,
/* types used for the parse tree - these never get returned /* types used for the parse tree - these never get returned
* by the scanner. * by the scanner.
*/ */
BLOCK = 107, // statement block BLOCK = 105, // statement block
ARRAYLIT = 108, // array literal ARRAYLIT = 106, // array literal
OBJLIT = 109, // object literal OBJLIT = 107, // object literal
LABEL = 110, // label LABEL = 108, // label
TARGET = 111, TARGET = 109,
LOOP = 112, LOOP = 110,
EXPRSTMT = 113, EXPRSTMT = 111,
PARENT = 114, JSR = 112,
JSR = 115, SCRIPT = 113, // top-level node for entire script
NEWTEMP = 116, TYPEOFNAME = 114, // for typeof(simple-name)
USETEMP = 117, USE_STACK = 115,
SCRIPT = 118, // top-level node for entire script SETPROP_OP = 116, // x.y op= something
TYPEOFNAME = 119, // for typeof(simple-name) SETELEM_OP = 117, // x[y] op= something
USE_STACK = 120, INIT_LIST = 118,
SETPROP_OP = 121, // x.y op= something LOCAL_BLOCK = 119,
SETELEM_OP = 122, // x[y] op= something
INIT_LIST = 123,
LOCAL_BLOCK = 124,
LAST_TOKEN = 124; LAST_TOKEN = 119;
public static String name(int token) public static String name(int token)
{ {
@ -273,11 +268,9 @@ public class Token
case INSTANCEOF: return "INSTANCEOF"; case INSTANCEOF: return "INSTANCEOF";
case LOCAL_SAVE: return "LOCAL_SAVE"; case LOCAL_SAVE: return "LOCAL_SAVE";
case LOCAL_LOAD: return "LOCAL_LOAD"; case LOCAL_LOAD: return "LOCAL_LOAD";
case GETBASE: return "GETBASE";
case GETVAR: return "GETVAR"; case GETVAR: return "GETVAR";
case SETVAR: return "SETVAR"; case SETVAR: return "SETVAR";
case UNDEFINED: return "UNDEFINED"; case UNDEFINED: return "UNDEFINED";
case GETTHIS: return "GETTHIS";
case TRY: return "TRY"; case TRY: return "TRY";
case CATCH_SCOPE: return "CATCH_SCOPE"; case CATCH_SCOPE: return "CATCH_SCOPE";
case ENUM_INIT: return "ENUM_INIT"; case ENUM_INIT: return "ENUM_INIT";
@ -328,10 +321,7 @@ public class Token
case TARGET: return "TARGET"; case TARGET: return "TARGET";
case LOOP: return "LOOP"; case LOOP: return "LOOP";
case EXPRSTMT: return "EXPRSTMT"; case EXPRSTMT: return "EXPRSTMT";
case PARENT: return "PARENT";
case JSR: return "JSR"; case JSR: return "JSR";
case NEWTEMP: return "NEWTEMP";
case USETEMP: return "USETEMP";
case SCRIPT: return "SCRIPT"; case SCRIPT: return "SCRIPT";
case TYPEOFNAME: return "TYPEOFNAME"; case TYPEOFNAME: return "TYPEOFNAME";
case USE_STACK: return "USE_STACK"; case USE_STACK: return "USE_STACK";

Просмотреть файл

@ -1883,30 +1883,7 @@ class BodyCodegen
break; break;
case Token.BINDNAME: case Token.BINDNAME:
case Token.GETBASE: visitBind(node, child);
visitBind(node, type, child);
break;
case Token.GETTHIS:
generateCodeFromNode(child, node);
addScriptRuntimeInvoke("getThis",
"(Lorg/mozilla/javascript/Scriptable;"
+")Lorg/mozilla/javascript/Scriptable;");
break;
case Token.PARENT:
generateCodeFromNode(child, node);
addScriptRuntimeInvoke("getParent",
"(Ljava/lang/Object;"
+")Lorg/mozilla/javascript/Scriptable;");
break;
case Token.NEWTEMP:
visitNewTemp(node, child);
break;
case Token.USETEMP:
visitUseTemp(node, child);
break; break;
case Token.LOCAL_LOAD: case Token.LOCAL_LOAD:
@ -2380,8 +2357,7 @@ class BodyCodegen
private void generateFunctionAndThisObj(Node node, Node parent) private void generateFunctionAndThisObj(Node node, Node parent)
{ {
// REMOVE Token.PARENT, Token.GETBASE, Token.GETTHIS, NETEMP?, USETEMP? ! // Place on stack (function object, function this) pair
// Place on stack function object, function this pair
switch (node.getType()) { switch (node.getType()) {
case Token.GETPROP: case Token.GETPROP:
// x.y(...) // x.y(...)
@ -3295,16 +3271,12 @@ class BodyCodegen
Node nameChild = child.getNext(); Node nameChild = child.getNext();
generateCodeFromNode(nameChild, node); // the name generateCodeFromNode(nameChild, node); // the name
/* /*
for 'this.foo' we call thisGet which can skip some for 'this.foo' we call getPropScriptable which can skip some
casting overhead. casting overhead.
*/ */
int childType = child.getType(); int childType = child.getType();
if ((childType == Token.THIS if (childType == Token.THIS && nameChild.getType() == Token.STRING) {
|| (childType == Token.NEWTEMP
&& child.getFirstChild().getType() == Token.THIS))
&& nameChild.getType() == Token.STRING)
{
addOptRuntimeInvoke( addOptRuntimeInvoke(
"getPropScriptable", "getPropScriptable",
"(Lorg/mozilla/javascript/Scriptable;" "(Lorg/mozilla/javascript/Scriptable;"
@ -3430,7 +3402,7 @@ class BodyCodegen
+")Ljava/lang/Object;"); +")Ljava/lang/Object;");
} }
private void visitBind(Node node, int type, Node child) private void visitBind(Node node, Node child)
{ {
while (child != null) { while (child != null) {
generateCodeFromNode(child, node); generateCodeFromNode(child, node);
@ -3439,8 +3411,7 @@ class BodyCodegen
// Generate code for "ScriptRuntime.bind(varObj, "s")" // Generate code for "ScriptRuntime.bind(varObj, "s")"
cfw.addALoad(variableObjectLocal); // get variable object cfw.addALoad(variableObjectLocal); // get variable object
cfw.addPush(node.getString()); // push name cfw.addPush(node.getString()); // push name
addScriptRuntimeInvoke( addScriptRuntimeInvoke("bind",
type == Token.BINDNAME ? "bind" : "getBase",
"(Lorg/mozilla/javascript/Scriptable;" "(Lorg/mozilla/javascript/Scriptable;"
+"Ljava/lang/String;" +"Ljava/lang/String;"
+")Lorg/mozilla/javascript/Scriptable;"); +")Lorg/mozilla/javascript/Scriptable;");
@ -3453,31 +3424,6 @@ class BodyCodegen
return localSlot; return localSlot;
} }
private void visitNewTemp(Node node, Node child)
{
generateCodeFromNode(child, node);
int local = getNewWordLocal();
node.putIntProp(Node.LOCAL_PROP, local);
cfw.add(ByteCode.DUP);
cfw.addAStore(local);
if (node.getIntProp(Node.USES_PROP, 0) == 0)
releaseWordLocal((short)local);
}
private void visitUseTemp(Node node, Node child)
{
Node temp = (Node) node.getProp(Node.TEMP_PROP);
int local = temp.getExistingIntProp(Node.LOCAL_PROP);
cfw.addALoad(local);
int n = temp.getIntProp(Node.USES_PROP, 0);
if (n <= 1) {
releaseWordLocal((short)local);
}
if (n != 0 && n != Integer.MAX_VALUE) {
temp.putIntProp(Node.USES_PROP, n - 1);
}
}
private void dcpLoadAsNumber(int dcp_register) private void dcpLoadAsNumber(int dcp_register)
{ {
cfw.addALoad(dcp_register); cfw.addALoad(dcp_register);