harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arc...@apache.org
Subject svn commit: r355995 - in /incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm: include/jc_defs.h libjc/interp.c libjc/resolve2.c
Date Sun, 11 Dec 2005 19:13:21 GMT
Author: archie
Date: Sun Dec 11 11:13:17 2005
New Revision: 355995

URL: http://svn.apache.org/viewcvs?rev=355995&view=rev
Log:
Implement two easy/obvious optimizations:
- Precompute the number of words to pop off the stack for method invocations.
- Devirtualize final method invocations.

Modified:
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve2.c

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h?rev=355995&r1=355994&r2=355995&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h Sun
Dec 11 11:13:17 2005
@@ -116,6 +116,7 @@
 
 typedef struct _jc_lookup		_jc_lookup;
 typedef struct _jc_iinc			_jc_iinc;
+typedef struct _jc_invoke		_jc_invoke;
 typedef struct _jc_linemap		_jc_linemap;
 typedef struct _jc_lookupswitch		_jc_lookupswitch;
 typedef union _jc_insn_info		_jc_insn_info;
@@ -211,6 +212,11 @@
 	jint	  	value;
 };
 
+struct _jc_invoke {
+	_jc_method	*method;
+	_jc_uint16  	pop;
+};
+
 struct _jc_multianewarray {
 	_jc_type	*type;
 	unsigned char	dims;
@@ -247,7 +253,7 @@
 };
 
 union _jc_insn_info {
-	_jc_method		*method;
+	_jc_invoke		invoke;
 	_jc_field		*field;
 	_jc_iinc		iinc;
 	_jc_multianewarray	multianewarray;

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c?rev=355995&r1=355994&r2=355995&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c Sun Dec
11 11:13:17 2005
@@ -936,26 +936,17 @@
 do_invokestatic:
 do_invokeinterface:
     {
-	_jc_method *imethod = INFO(method);
+	const _jc_invoke *const invoke = &INFO(invoke);
+	_jc_method *imethod = invoke->method;
 	_jc_word *params;
 	_jc_object *obj;
-	int ndoubles;
 	jint status;
-	int i;
-
-	/* Count number of long/double parameters */
-	ndoubles = 0;
-	for (i = 0; i < imethod->num_parameters; i++) {
-		if (_jc_dword_type[imethod->param_ptypes[i]])
-			ndoubles++;
-	}
 
 	/* Pop the stack and check for null */
-	if (code->opcodes[pc] == _JC_invokestatic) {
-		POP(imethod->num_parameters + ndoubles);
+	POP(invoke->pop);
+	if (code->opcodes[pc] == _JC_invokestatic)
 		obj = NULL;
-	} else {
-		POP(imethod->num_parameters + ndoubles + 1);
+	else {
 		if ((obj = STACKL(0)) == NULL)
 			goto null_pointer_exception;
 	}

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve2.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve2.c?rev=355995&r1=355994&r2=355995&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve2.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve2.c Sun Dec
11 11:13:17 2005
@@ -750,8 +750,10 @@
 		case _JC_invokevirtual:
 		    {
 			_jc_cf_ref *const ref = insn->u.invoke.method;
+			_jc_invoke *const invoke = &info->invoke;
 			_jc_method *imethod;
 			_jc_type *type;
+			int j;
 
 			/* Resolve method's class */
 			if ((type = _jc_load_type(env,
@@ -855,8 +857,21 @@
 			_JC_ASSERT((opcode == _JC_invokeinterface)
 			    == _JC_ACC_TEST(imethod->class, INTERFACE));
 
+			/* Count the number of words to pop off the stack */
+			invoke->pop = imethod->num_parameters
+			    + (opcode != _JC_invokestatic);
+			for (j = 0; j < imethod->num_parameters; j++) {
+				if (_jc_dword_type[imethod->param_ptypes[j]])
+					invoke->pop++;
+			}
+
+			/* Optimization: de-virtualize final methods */
+			if (_JC_ACC_TEST(imethod->class, FINAL)
+			    && opcode == _JC_invokevirtual)
+				opcode = _JC_invokespecial;
+
 			/* OK */
-			info->method = imethod;
+			invoke->method = imethod;
 			break;
 		    }
 		case _JC_ldc:



Mime
View raw message