harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arc...@apache.org
Subject svn commit: r366074 - in /incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm: include/jc_defs.h libjc/analysis.c libjc/interp.c libjc/libjc.h libjc/resolve2.c libjc/stack.c libjc/structures.h libjc/vm.c
Date Thu, 05 Jan 2006 04:07:31 GMT
Author: archie
Date: Wed Jan  4 20:07:26 2006
New Revision: 366074

URL: http://svn.apache.org/viewcvs?rev=366074&view=rev
Log:
- More optimizations:
  - Store instructions as jump targets instead of opcodes, which require a
    table lookup for each instruction.
  - Don't take the address of the "pc" in _jc_interp(), in hopes the compiler
    will put it in a register.
  - Prefer _jc_assignable_from() instead of _jc_instance_of() when appropriate.
  These give a 25% speedup on Linpack.
- Remove unused structure _jc_trap_info.

Modified:
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/include/jc_defs.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/analysis.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/interp.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve2.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/stack.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/vm.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=366074&r1=366073&r2=366074&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 Wed
Jan  4 20:07:26 2006
@@ -119,8 +119,10 @@
 typedef struct _jc_invoke		_jc_invoke;
 typedef struct _jc_linemap		_jc_linemap;
 typedef struct _jc_lookupswitch		_jc_lookupswitch;
+typedef struct _jc_insn			_jc_insn;
 typedef union _jc_insn_info		_jc_insn_info;
 typedef struct _jc_field_info		_jc_field_info;
+typedef struct _jc_string_info		_jc_string_info;
 typedef struct _jc_multianewarray	_jc_multianewarray;
 typedef struct _jc_tableswitch		_jc_tableswitch;
 typedef struct _jc_interp_trap		_jc_interp_trap;
@@ -238,11 +240,16 @@
 
 struct _jc_lookup {
 	jint		match;
-	_jc_uint16	target;
+	_jc_insn	*target;
+};
+
+struct _jc_string_info {
+	_jc_object	*string;
+	const char	*utf8;
 };
 
 struct _jc_lookupswitch {
-	_jc_uint16	default_target;
+	_jc_insn	*default_target;
 	_jc_uint16	num_pairs;
 	_jc_lookup	pairs[0];
 };
@@ -250,14 +257,14 @@
 struct _jc_tableswitch {
 	jint		low;
 	jint		high;
-	_jc_uint16	default_target;
-	_jc_uint16	targets[0];
+	_jc_insn	*default_target;
+	_jc_insn	*targets[0];
 };
 
 struct _jc_interp_trap {
-	_jc_uint16	start;
-	_jc_uint16	end;
-	_jc_uint16	target;
+	_jc_insn	*start;
+	_jc_insn	*end;
+	_jc_insn	*target;
 	_jc_type	*type;
 };
 
@@ -282,10 +289,15 @@
 	_jc_type		*type;
 	_jc_lookupswitch	*lookupswitch;
 	_jc_tableswitch		*tableswitch;
-	_jc_uint16		target;
+	_jc_insn		*target;
 	jint			local;
 	_jc_value		constant;
-	const char		*utf8;
+	_jc_string_info 	string;
+};
+
+struct _jc_insn {
+	_jc_word		action;
+	_jc_insn_info		info;
 };
 
 /************************************************************************
@@ -305,8 +317,7 @@
 
 /* Interpreted method info */
 struct _jc_method_code {
-	unsigned char	*opcodes;
-	_jc_insn_info	*info;
+	_jc_insn	*insns;
 	_jc_interp_trap	*traps;
 	_jc_linemap	*linemaps;
 	_jc_uint16	max_stack;
@@ -404,13 +415,6 @@
 struct _jc_inner_class {
 	_jc_type		*type;
 	_jc_uint16		access_flags;
-};
-
-/* Trap table entry */
-struct _jc_trap_info {
-	_jc_type		*type;		/* (sub)class of Throwable */
-	_jc_uint16		start;		/* starting trap region */
-	_jc_uint16		end;		/* ending trap region */
 };
 
 /* Exception catcher */

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/analysis.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/analysis.c?rev=366074&r1=366073&r2=366074&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/analysis.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/analysis.c Wed Jan
 4 20:07:26 2006
@@ -55,7 +55,7 @@
 		_jc_interp_trap *const trap = &code->traps[i];
 
 		if (_jc_compute_stack_depth2(env,
-		    &state, trap->target) != JNI_OK)
+		    &state, trap->target - code->insns) != JNI_OK)
 			return JNI_ERR;
 	}
 
@@ -90,7 +90,8 @@
 
 	/* Flow forward */
 	while (JNI_TRUE) {
-		_jc_insn_info *const info = &code->info[state.ip];
+		_jc_insn *const insn = &code->insns[state.ip];
+		_jc_insn_info *const info = &insn->info;
 		int delta;
 
 		/* Sanity check */
@@ -109,7 +110,7 @@
 		 * operations that can affect "returnAddress" values,
 		 * which we must track in order to handle "ret".
 		 */
-		switch (code->opcodes[state.ip]) {
+		switch (insn->action) {
 		case _JC_astore:
 			_JC_ASSERT(state.sp >= 1);
 			state.locals[info->local] = state.stack[state.sp - 1];
@@ -169,7 +170,7 @@
 		}
 
 		/* Update stack pointer */
-		switch (code->opcodes[state.ip]) {
+		switch (insn->action) {
 		case _JC_getstatic:
 			delta = _jc_dword_type[_jc_sig_types[
 			    (u_char)*info->field.field->signature]] ? 2 : 1;
@@ -197,16 +198,16 @@
 			break;
 		default:
 			delta = (signed char)(_jc_bytecode_stackadj[
-			    code->opcodes[state.ip]] ^ _JC_STACKADJ_INVALID);
+			    insn->action] ^ _JC_STACKADJ_INVALID);
 			_JC_ASSERT(delta >= -4 && delta <= 2);
 			break;
 		}
 		state.sp += delta;
 
 		/* Flow to next instruction(s) */
-		switch (code->opcodes[state.ip]) {
+		switch (insn->action) {
 		case _JC_goto:
-			state.ip = info->target;
+			state.ip = info->target - code->insns;
 			break;
 		case _JC_areturn:
 		case _JC_dreturn:
@@ -233,7 +234,7 @@
 		case _JC_ifnonnull:
 		case _JC_ifnull:
 			if (_jc_compute_stack_depth2(env,
-			    &state, info->target) != JNI_OK)
+			    &state, info->target - code->insns) != JNI_OK)
 				return JNI_ERR;
 			state.ip++;
 			break;
@@ -241,12 +242,12 @@
 
 			/* Flow into subroutine */
 			if (_jc_compute_stack_depth2(env,
-			    &state, info->target) != JNI_OK)
+			    &state, info->target - code->insns) != JNI_OK)
 				return JNI_ERR;
 
 			/* Retrieve our new stack depth */
-			_JC_ASSERT(state.retsp[info->target] != -1);
-			state.sp = state.retsp[info->target];
+			_JC_ASSERT(state.retsp[info->target - code->insns] != -1);
+			state.sp = state.retsp[info->target - code->insns];
 
 			/* Continue with next instruction */
 			state.ip++;
@@ -259,11 +260,11 @@
 			for (i = 0; i < lsw->num_pairs; i++) {
 				_jc_lookup *const entry = &lsw->pairs[i];
 
-				if (_jc_compute_stack_depth2(env,
-				    &state, entry->target) != JNI_OK)
+				if (_jc_compute_stack_depth2(env, &state,
+				    entry->target - code->insns) != JNI_OK)
 					return JNI_ERR;
 			}
-			state.ip = lsw->default_target;
+			state.ip = lsw->default_target - code->insns;
 			break;
 		    }
 		case _JC_ret:
@@ -274,8 +275,8 @@
 			/* Let JSR instruction know what SP it gets back */
 			jsr_ip = state.locals[info->local] - 1;
 			_JC_ASSERT(jsr_ip >= 0 && jsr_ip <= code->num_insns);
-			_JC_ASSERT(code->opcodes[jsr_ip] == _JC_jsr);
-			sub_ip = code->info[jsr_ip].target;
+			_JC_ASSERT(code->insns[jsr_ip].action == _JC_jsr);
+			sub_ip = code->insns[jsr_ip].info.target - code->insns;
 			_JC_ASSERT(sub_ip >= 0 && sub_ip <= code->num_insns);
 			state.retsp[sub_ip] = state.sp;
 			return JNI_OK;
@@ -286,11 +287,11 @@
 			int i;
 
 			for (i = 0; i < tsw->high - tsw->low + 1; i++) {
-				if (_jc_compute_stack_depth2(env,
-				    &state, tsw->targets[i]) != JNI_OK)
+				if (_jc_compute_stack_depth2(env, &state,
+				    tsw->targets[i] - code->insns) != JNI_OK)
 					return JNI_ERR;
 			}
-			state.ip = tsw->default_target;
+			state.ip = tsw->default_target - code->insns;
 			break;
 		    }
 		default:

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=366074&r1=366073&r2=366074&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 Wed Jan
 4 20:07:26 2006
@@ -20,6 +20,9 @@
 
 #include "libjc.h"
 
+/* Public variables */
+const _jc_word	*_jc_interp_targets;
+
 /* Internal functions */
 static jint	_jc_interp(_jc_env *env, _jc_method *const method);
 static int	_jc_lookup_compare(const void *v1, const void *v2);
@@ -31,37 +34,43 @@
  */
 #ifndef NDEBUG
 
-#define JUMP(_pc)							\
+#define CHECK_PC_SP()							\
     do {								\
-	pc = (_pc);							\
 	_JC_ASSERT(sp >= locals + code->max_locals);			\
 	_JC_ASSERT(sp <= locals + code->max_locals + code->max_stack);	\
-	_JC_ASSERT(pc >= 0 && pc < code->num_insns);			\
-	_JC_ASSERT(actions[code->opcodes[pc]] != NULL);			\
+	_JC_ASSERT(pc >= code->insns					\
+	    && pc < code->insns + code->num_insns);			\
+	_JC_ASSERT(pc->action != 0);					\
 	_JC_ASSERT(ticker > 0);						\
-	if (_JC_UNLIKELY(--ticker == 0))				\
-		goto periodic_check;					\
-	goto *actions[code->opcodes[pc]];				\
     } while (0)
 
-#define NEXT()		JUMP(pc + 1)
-
 #else	/* !NDEBUG */
 
+#define CHECK_PC_SP()							\
+    do { } while (0)							\
+
+#endif	/* !NDEBUG */
+
 #define JUMP(_pc)							\
     do {								\
 	pc = (_pc);							\
+	CHECK_PC_SP();							\
 	if (_JC_UNLIKELY(--ticker == 0))				\
 		goto periodic_check;					\
-	goto *actions[code->opcodes[pc]];				\
+	goto *(void *)pc->action;					\
     } while (0)
 
 #define NEXT()								\
     do {								\
-	goto *actions[code->opcodes[++pc]];				\
+	CHECK_PC_SP();							\
+	goto *(void *)(++pc)->action;					\
     } while (0)
 
-#endif	/* !NDEBUG */
+#define RERUN()								\
+    do {								\
+	CHECK_PC_SP();							\
+	goto *(void *)pc->action;					\
+    } while (0)
 
 #define STACKI(i)	(*(jint *)(sp + (i)))
 #define STACKF(i)	(*(jfloat *)(sp + (i)))
@@ -80,7 +89,7 @@
 #define PUSHL(v)	do { STACKL(0) = (v); sp++; } while (0)
 #define POP(i)		(sp -= (i))
 
-#define INFO(f)		(code->info[pc].f)
+#define INFO(f)		(pc->info.f)
 
 #define NULLPOINTERCHECK(x)						\
     do {								\
@@ -95,6 +104,7 @@
 									\
 	NULLPOINTERCHECK(_array);					\
 	if (_JC_UNLIKELY(_i < 0 || _i >= _array->length)) {		\
+		stack_frame.pc = pc;					\
 		_jc_post_exception_msg(env,				\
 		    _JC_ArrayIndexOutOfBoundsException, "%d", _i);	\
 		goto exception;						\
@@ -106,6 +116,7 @@
     	_jc_type *const _type = (t);					\
 									\
 	if (_JC_UNLIKELY(!_JC_FLG_TEST(_type, INITIALIZED))) {		\
+		stack_frame.pc = pc;					\
 		if (_jc_initialize_type(env, _type) != JNI_OK)		\
 			goto exception;					\
 	}								\
@@ -122,9 +133,11 @@
 static jint
 _jc_interp(_jc_env *const env, _jc_method *const method)
 {
-#define ACTION(name)  [_JC_ ## name]= &&do_ ## name
-#define TARGET(name)  do_ ## name:   asm ("/***** " #name " *****/");
-	static const void *const actions[0x100] = {
+#define ACTION(name)  [_JC_ ## name]= (_jc_word)&&do_ ## name
+#define TARGET(name)  							\
+	_JC_ASSERT(JNI_FALSE);		/* should never fall through */	\
+	do_ ## name:   asm ("/***** " #name " *****/");
+	static const _jc_word actions[0x100] = {
 		ACTION(aaload),
 		ACTION(aastore),
 		ACTION(aload),
@@ -308,8 +321,15 @@
 	_jc_java_stack stack_frame;
 	_jc_word *const locals = env->sp;
 	_jc_object *lock = NULL;
+	_jc_method *imethod;
+	_jc_insn *pc;
 	_jc_word *sp;
-	int pc = 0;
+
+	/* Special hack to copy out target offsets */
+	if (_JC_UNLIKELY(method == NULL)) {
+		env->retval.l = (_jc_object *)actions;
+		return JNI_OK;
+	}
 
 	/* Sanity check */
 	_JC_ASSERT(env->sp != NULL);
@@ -358,13 +378,13 @@
 	memset(&stack_frame, 0, sizeof(stack_frame));
 	stack_frame.next = env->java_stack;
 	stack_frame.method = method;
-	stack_frame.pcp = &pc;
 	env->java_stack = &stack_frame;
 	sp = locals + code->max_locals;
 	env->sp = sp + code->max_stack;
+	pc = code->insns;
 
 	/* Sanity check */
-	_JC_ASSERT(code->opcodes != NULL);
+	_JC_ASSERT(code->insns != NULL);
 	_JC_ASSERT(code->num_insns > 0);
 
 	/* Synchronize */
@@ -378,7 +398,7 @@
 	}
 
 	/* Start */
-	JUMP(0);
+	RERUN();
 
 TARGET(aaload)
     {
@@ -406,6 +426,7 @@
 	ARRAYCHECK(array, index);
 	obj = STACKL(2);
 	if (_JC_LIKELY(obj != NULL)) {
+		stack_frame.pc = pc;
 		switch (_jc_assignable_from(env, obj->type,
 		    array->type->u.array.element_type)) {
 		case 1:
@@ -429,6 +450,7 @@
     {
 	_jc_array *array;
 
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY((array = _jc_new_array(env,
 	    INFO(type), STACKI(-1))) == NULL))
 		goto exception;
@@ -453,6 +475,7 @@
 TARGET(athrow)
 	POP(1);
 	NULLPOINTERCHECK(STACKL(0));
+	stack_frame.pc = pc;
 	_jc_post_exception_object(env, STACKL(0));
 	goto exception;
 TARGET(baload)
@@ -516,7 +539,8 @@
 	if (_JC_LIKELY(obj != NULL)) {
 		_jc_type *const type = INFO(type);
 
-		switch (_jc_instance_of(env, obj, type)) {
+		stack_frame.pc = pc;
+		switch (_jc_assignable_from(env, obj->type, type)) {
 		case 1:
 			break;
 		case 0:
@@ -674,6 +698,7 @@
 	NEXT();
     }
 TARGET(failure)
+	stack_frame.pc = pc;
 	_jc_post_exception_msg(env, _JC_InternalError, "failure opcode");
 	goto exception;
 TARGET(fastore)
@@ -809,37 +834,37 @@
 	/* Update instruction and execute again */
 	switch (_jc_sig_types[(u_char)*field->signature]) {
 	case _JC_TYPE_BOOLEAN:
-		code->opcodes[pc] = _JC_getstatic_z;
+		pc->action = _jc_interp_targets[_JC_getstatic_z];
 		break;
 	case _JC_TYPE_BYTE:
-		code->opcodes[pc] = _JC_getstatic_b;
+		pc->action = _jc_interp_targets[_JC_getstatic_b];
 		break;
 	case _JC_TYPE_CHAR:
-		code->opcodes[pc] = _JC_getstatic_c;
+		pc->action = _jc_interp_targets[_JC_getstatic_c];
 		break;
 	case _JC_TYPE_SHORT:
-		code->opcodes[pc] = _JC_getstatic_s;
+		pc->action = _jc_interp_targets[_JC_getstatic_s];
 		break;
 	case _JC_TYPE_INT:
-		code->opcodes[pc] = _JC_getstatic_i;
+		pc->action = _jc_interp_targets[_JC_getstatic_i];
 		break;
 	case _JC_TYPE_FLOAT:
-		code->opcodes[pc] = _JC_getstatic_f;
+		pc->action = _jc_interp_targets[_JC_getstatic_f];
 		break;
 	case _JC_TYPE_LONG:
-		code->opcodes[pc] = _JC_getstatic_j;
+		pc->action = _jc_interp_targets[_JC_getstatic_j];
 		break;
 	case _JC_TYPE_DOUBLE:
-		code->opcodes[pc] = _JC_getstatic_d;
+		pc->action = _jc_interp_targets[_JC_getstatic_d];
 		break;
 	case _JC_TYPE_REFERENCE:
-		code->opcodes[pc] = _JC_getstatic_l;
+		pc->action = _jc_interp_targets[_JC_getstatic_l];
 		break;
 	default:
 		_JC_ASSERT(JNI_FALSE);
 		break;
 	}
-	JUMP(pc);
+	RERUN();
     }
 TARGET(getstatic_z)
 	PUSHI(*(jboolean *)INFO(field).u.data);
@@ -930,52 +955,84 @@
 	NEXT();
 TARGET(if_acmpeq)
 	POP(2);
-	JUMP(STACKL(0) == STACKL(1) ? INFO(target) : pc + 1);
+	if (STACKL(0) == STACKL(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(if_acmpne)
 	POP(2);
-	JUMP(STACKL(0) != STACKL(1) ? INFO(target) : pc + 1);
+	if (STACKL(0) != STACKL(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(if_icmpeq)
 	POP(2);
-	JUMP(STACKI(0) == STACKI(1) ? INFO(target) : pc + 1);
+	if (STACKI(0) == STACKI(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(if_icmpne)
 	POP(2);
-	JUMP(STACKI(0) != STACKI(1) ? INFO(target) : pc + 1);
+	if (STACKI(0) != STACKI(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(if_icmplt)
 	POP(2);
-	JUMP(STACKI(0) < STACKI(1) ? INFO(target) : pc + 1);
+	if (STACKI(0) < STACKI(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(if_icmpge)
 	POP(2);
-	JUMP(STACKI(0) >= STACKI(1) ? INFO(target) : pc + 1);
+	if (STACKI(0) >= STACKI(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(if_icmpgt)
 	POP(2);
-	JUMP(STACKI(0) > STACKI(1) ? INFO(target) : pc + 1);
+	if (STACKI(0) > STACKI(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(if_icmple)
 	POP(2);
-	JUMP(STACKI(0) <= STACKI(1) ? INFO(target) : pc + 1);
+	if (STACKI(0) <= STACKI(1))
+		JUMP(INFO(target));
+	NEXT();
 TARGET(ifeq)
 	POP(1);
-	JUMP(STACKI(0) == 0 ? INFO(target) : pc + 1);
+	if (STACKI(0) == 0)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(ifne)
 	POP(1);
-	JUMP(STACKI(0) != 0 ? INFO(target) : pc + 1);
+	if (STACKI(0) != 0)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(iflt)
 	POP(1);
-	JUMP(STACKI(0) < 0 ? INFO(target) : pc + 1);
+	if (STACKI(0) < 0)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(ifge)
 	POP(1);
-	JUMP(STACKI(0) >= 0 ? INFO(target) : pc + 1);
+	if (STACKI(0) >= 0)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(ifgt)
 	POP(1);
-	JUMP(STACKI(0) > 0 ? INFO(target) : pc + 1);
+	if (STACKI(0) > 0)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(ifle)
 	POP(1);
-	JUMP(STACKI(0) <= 0 ? INFO(target) : pc + 1);
+	if (STACKI(0) <= 0)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(ifnonnull)
 	POP(1);
-	JUMP(STACKL(0) != NULL ? INFO(target) : pc + 1);
+	if (STACKL(0) != NULL)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(ifnull)
 	POP(1);
-	JUMP(STACKL(0) == NULL ? INFO(target) : pc + 1);
+	if (STACKL(0) == NULL)
+		JUMP(INFO(target));
+	NEXT();
 TARGET(iinc)
 	LOCALI(INFO(iinc).local) += INFO(iinc).value;
 	NEXT();
@@ -993,6 +1050,7 @@
     {
     	jint result;
 
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY((result = _jc_instance_of(env,
 	    STACKL(-1), INFO(type))) == -1))
 		goto exception;
@@ -1001,141 +1059,153 @@
     }
 TARGET(invokestatic)
     {
-	_jc_method *const imethod = INFO(invoke).method;
-
 	/* Initialize method's class */
-	INITIALIZETYPE(imethod->class);
+	INITIALIZETYPE(INFO(invoke).method->class);
 
 	/* Update instruction and execute again */
-	code->opcodes[pc] = _JC_invokestatic2;
-	JUMP(pc);
+	pc->action = actions[_JC_invokestatic2];
+	RERUN();
     }
 TARGET(invokespecial)
+    {
+	const _jc_invoke *const invoke = &INFO(invoke);
+
+	/* Get method */
+	imethod = invoke->method;
+
+	/* Check for null */
+	NULLPOINTERCHECK(STACKL(-invoke->pop));
+
+	/* Invoke */
+	goto invoke;
+    }
 TARGET(invokevirtual)
+    {
+	const _jc_invoke *const invoke = &INFO(invoke);
+	_jc_object *obj;
+	_jc_type *vtype;
+
+	/* Check for null */
+	NULLPOINTERCHECK(obj = STACKL(-invoke->pop));
+
+	/* Resolve virtual method */
+	vtype = _JC_LW_TEST(obj->lockword, ARRAY) ?
+	    env->vm->boot.types.Object : obj->type;
+	imethod = vtype->u.nonarray.mtable[invoke->method->vtable_index];
+
+	/* Invoke */
+	goto invoke;
+    }
 TARGET(invokestatic2)
+    {
+	const _jc_invoke *const invoke = &INFO(invoke);
+
+	/* Get method */
+	imethod = invoke->method;
+
+	/* Invoke */
+	goto invoke;
+    }
 TARGET(invokeinterface)
     {
 	const _jc_invoke *const invoke = &INFO(invoke);
-	_jc_method *imethod = invoke->method;
-	jint status;
+	_jc_method *const *methodp;
+	_jc_method *quick;
+	_jc_object *obj;
+
+	/* Get interface method */
+	imethod = invoke->method;
 
 	/* Sanity check */
-	_JC_ASSERT((code->opcodes[pc] == _JC_invokeinterface)
-	    == _JC_ACC_TEST(imethod->class, INTERFACE));
+	_JC_ASSERT(_JC_ACC_TEST(imethod->class, INTERFACE));
 
-	/* Check for null and do method lookup */
-	switch (code->opcodes[pc]) {
-	case _JC_invokeinterface:
-	    {
-		_jc_method *const *methodp;
-		_jc_method *quick;
-		_jc_object *obj;
+	/* Check for null */
+	NULLPOINTERCHECK(obj = STACKL(-invoke->pop));
 
-		/* Check for null */
-		NULLPOINTERCHECK(obj = STACKL(-invoke->pop));
+	/* Verify object implements the interface */
+	stack_frame.pc = pc;
+	switch (_jc_assignable_from(env, obj->type, imethod->class)) {
+	case 0:
+		_jc_post_exception_msg(env,
+		    _JC_IncompatibleClassChangeError,
+		    "`%s' does not implement interface `%s'",
+		    obj->type->name, imethod->class->name);
+		goto exception;
+	case 1:
+		break;
+	case -1:
+		goto exception;
+	}
 
-		/* Verify object implements the interface */
-		switch (_jc_instance_of(env, obj, imethod->class)) {
-		case 0:
-			_jc_post_exception_msg(env,
-			    _JC_IncompatibleClassChangeError,
-			    "`%s' does not implement interface `%s'",
-			    obj->type->name, imethod->class->name);
-			goto exception;
-		case 1:
-			break;
-		case -1:
-			goto exception;
-		}
+	/* Sanity check */
+	_JC_ASSERT(obj->type->imethod_quick_table != NULL);
+	_JC_ASSERT(obj->type->imethod_hash_table != NULL);
+	_JC_ASSERT(imethod->signature_hash_bucket
+	    < _JC_IMETHOD_HASHSIZE);
+
+	/* Try quick hash table lookup */
+	if (_JC_LIKELY((quick = obj->type->imethod_quick_table[
+	    imethod->signature_hash_bucket]) != NULL)) {
+		imethod = quick;
+		goto got_method;
+	}
 
-		/* Sanity check */
-		_JC_ASSERT(obj->type->imethod_quick_table != NULL);
-		_JC_ASSERT(obj->type->imethod_hash_table != NULL);
-		_JC_ASSERT(imethod->signature_hash_bucket
-		    < _JC_IMETHOD_HASHSIZE);
-
-		/* Try quick hash table lookup */
-		if (_JC_LIKELY((quick = obj->type->imethod_quick_table[
-		    imethod->signature_hash_bucket]) != NULL)) {
-		    	imethod = quick;
+	/* Lookup interface method entry point in hash table */
+	if (_JC_UNLIKELY((methodp = obj->type->imethod_hash_table[
+	    imethod->signature_hash_bucket]) == NULL))
+		goto not_found;
+	do {
+		_jc_method *const entry = *methodp;
+
+		if (strcmp(entry->name, imethod->name) == 0
+		    && strcmp(entry->signature,
+		      imethod->signature) == 0) {
+			imethod = entry;
 			goto got_method;
 		}
-
-		/* Lookup interface method entry point in hash table */
-		if (_JC_UNLIKELY((methodp = obj->type->imethod_hash_table[
-		    imethod->signature_hash_bucket]) == NULL))
-			goto not_found;
-		do {
-			_jc_method *const entry = *methodp;
-
-			if (strcmp(entry->name, imethod->name) == 0
-			    && strcmp(entry->signature,
-			      imethod->signature) == 0) {
-				imethod = entry;
-				break;
-			}
-			methodp++;
-		} while (*methodp != NULL);
-		if (_JC_UNLIKELY(*methodp == NULL)) {
+		methodp++;
+	} while (*methodp != NULL);
+	if (_JC_UNLIKELY(*methodp == NULL)) {
 not_found:		_jc_post_exception_msg(env, _JC_AbstractMethodError,
-			    "%s.%s%s invoked from %s.%s%s on a %s",
-			    imethod->class->name, imethod->name,
-			    imethod->signature, method->class->name,
-			    method->name, method->signature, obj->type->name);
-			goto exception;
-		}
+		    "%s.%s%s invoked from %s.%s%s on a %s",
+		    imethod->class->name, imethod->name,
+		    imethod->signature, method->class->name,
+		    method->name, method->signature, obj->type->name);
+		goto exception;
+	}
 
 got_method:
-		/* Verify method is public */
-		if (_JC_UNLIKELY(!_JC_ACC_TEST(imethod, PUBLIC))) {
-			_jc_post_exception_msg(env, _JC_IllegalAccessError,
-			    "%s.%s%s invoked from %s.%s%s on a %s",
-			    imethod->class->name, imethod->name,
-			    imethod->signature, method->class->name,
-			    method->name, method->signature, obj->type->name);
-			goto exception;
-		}
-		break;
-	    }
-	case _JC_invokevirtual:
-	    {
-		_jc_object *obj;
-		_jc_type *vtype;
-
-		/* Check for null */
-		NULLPOINTERCHECK(obj = STACKL(-invoke->pop));
-
-		/* Resolve virtual method */
-		vtype = _JC_LW_TEST(obj->lockword, ARRAY) ?
-		    env->vm->boot.types.Object : obj->type;
-		imethod = vtype->u.nonarray.mtable[imethod->vtable_index];
-		break;
-	    }
-	case _JC_invokespecial:
-		NULLPOINTERCHECK(STACKL(-invoke->pop));
-		break;
-	case _JC_invokestatic2:
-		break;
-	default:
-		_JC_ASSERT(JNI_FALSE);
-		break;
+	/* Verify method is public */
+	if (_JC_UNLIKELY(!_JC_ACC_TEST(imethod, PUBLIC))) {
+		_jc_post_exception_msg(env, _JC_IllegalAccessError,
+		    "%s.%s%s invoked from %s.%s%s on a %s",
+		    imethod->class->name, imethod->name,
+		    imethod->signature, method->class->name,
+		    method->name, method->signature, obj->type->name);
+		goto exception;
 	}
 
+	/* Invoke it */
+	goto invoke;
+    }
+
+invoke:
+    {
+	const _jc_invoke *const invoke = &INFO(invoke);
+	jint status;
+
+	/* Pop the stack, leaving parameters above the top */
+	POP(invoke->pop);
+
 	/* Invoke the method */
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY(_JC_ACC_TEST(imethod, NATIVE))) {
 
 		/* Invoke native method */
-		status = _jc_invoke_native_method(env,
-		    imethod, JNI_TRUE, sp - invoke->pop);
-
-		/* Pop the stack */
-		POP(invoke->pop);
+		status = _jc_invoke_native_method(env, imethod, JNI_TRUE, sp);
 	} else {
 
-		/* Pop the stack, leaving parameters above the top */
-		POP(invoke->pop);
-
-		/* Invoke the method */
+		/* Invoke Java method */
 		env->sp = sp;
 		status = _jc_interp(env, imethod);
 		env->sp = locals + code->max_locals + code->max_stack;
@@ -1211,7 +1281,7 @@
 	STACKI(-1) ^= STACKI(0);
 	NEXT();
 TARGET(jsr)
-	PUSHI(pc + 1);
+	PUSHL((void *)(pc + 1));
 	JUMP(INFO(target));
 TARGET(l2d)
 	STACKD(-2) = STACKJ(-2);
@@ -1264,12 +1334,14 @@
 	NEXT();
 TARGET(ldc_string)
     {
+    	_jc_string_info *const info = &INFO(string);
 	_jc_resolve_info rinfo;
 	_jc_object *string;
 
 	/* Create intern'd string */
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY((string = _jc_new_intern_string(env,
-	    INFO(utf8), strlen(INFO(utf8)))) == NULL))
+	    info->utf8, strlen(info->utf8))) == NULL))
 		goto exception;
 
 	/* Create reference list with one reference */
@@ -1284,12 +1356,10 @@
 		goto exception;
 	}
 
-	/* Update instruction */
-	INFO(constant).l = string;
-	code->opcodes[pc] = _JC_ldc;
-
-	/* Now execute it again */
-	JUMP(pc);
+	/* Update instruction and execute again */
+	info->string = string;
+	pc->action = actions[_JC_ldc];
+	RERUN();
     }
 TARGET(ldc2_w)
 	*sp++ = ((_jc_word *)&INFO(constant))[0];
@@ -1363,12 +1433,14 @@
 TARGET(monitorenter)
 	POP(1);
 	NULLPOINTERCHECK(STACKL(0));
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY(_jc_lock_object(env, STACKL(0)) != JNI_OK))
 		goto exception;
 	NEXT();
 TARGET(monitorexit)
 	POP(1);
 	NULLPOINTERCHECK(STACKL(0));
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY(_jc_unlock_object(env, STACKL(0)) != JNI_OK))
 		goto exception;
 	NEXT();
@@ -1385,6 +1457,7 @@
 		for (i = 0; i < info->dims; i++)
 			sizes[i] = STACKI(i);
 	}
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY((array = _jc_new_multiarray(env,
 	    info->type, info->dims, sizes)) == NULL))
 		goto exception;
@@ -1395,6 +1468,7 @@
     {
 	_jc_object *obj;
 
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY((obj = _jc_new_object(env, INFO(type))) == NULL))
 		goto exception;
 	PUSHL(obj);
@@ -1405,6 +1479,7 @@
 	_jc_array *array;
 
 	POP(1);
+	stack_frame.pc = pc;
 	if (_JC_UNLIKELY((array = _jc_new_array(env,
 	    INFO(type), STACKI(0))) == NULL))
 		goto exception;
@@ -1475,37 +1550,37 @@
 	/* Update instruction and execute again */
 	switch (_jc_sig_types[(u_char)*field->signature]) {
 	case _JC_TYPE_BOOLEAN:
-		code->opcodes[pc] = _JC_putstatic_z;
+		pc->action = actions[_JC_putstatic_z];
 		break;
 	case _JC_TYPE_BYTE:
-		code->opcodes[pc] = _JC_putstatic_b;
+		pc->action = actions[_JC_putstatic_b];
 		break;
 	case _JC_TYPE_CHAR:
-		code->opcodes[pc] = _JC_putstatic_c;
+		pc->action = actions[_JC_putstatic_c];
 		break;
 	case _JC_TYPE_SHORT:
-		code->opcodes[pc] = _JC_putstatic_s;
+		pc->action = actions[_JC_putstatic_s];
 		break;
 	case _JC_TYPE_INT:
-		code->opcodes[pc] = _JC_putstatic_i;
+		pc->action = actions[_JC_putstatic_i];
 		break;
 	case _JC_TYPE_FLOAT:
-		code->opcodes[pc] = _JC_putstatic_f;
+		pc->action = actions[_JC_putstatic_f];
 		break;
 	case _JC_TYPE_LONG:
-		code->opcodes[pc] = _JC_putstatic_j;
+		pc->action = actions[_JC_putstatic_j];
 		break;
 	case _JC_TYPE_DOUBLE:
-		code->opcodes[pc] = _JC_putstatic_d;
+		pc->action = actions[_JC_putstatic_d];
 		break;
 	case _JC_TYPE_REFERENCE:
-		code->opcodes[pc] = _JC_putstatic_l;
+		pc->action = actions[_JC_putstatic_l];
 		break;
 	default:
 		_JC_ASSERT(JNI_FALSE);
 		break;
 	}
-	JUMP(pc);
+	RERUN();
     }
 TARGET(putstatic_z)
 	POP(1);
@@ -1544,7 +1619,7 @@
 	*(_jc_object **)INFO(field).u.data = STACKL(0);
 	NEXT();
 TARGET(ret)
-	JUMP(LOCALI(INFO(local)));
+	JUMP((_jc_insn *)LOCALL(INFO(local)));
 TARGET(return)
 	goto done;
 TARGET(saload)
@@ -1595,13 +1670,15 @@
 	if (_JC_UNLIKELY(_jc_thread_check(env) != JNI_OK))
 		goto exception;
 	ticker = PERIODIC_CHECK_TICKS;
-	JUMP(pc);
+	RERUN();
 
 null_pointer_exception:
+	stack_frame.pc = pc;
 	_jc_post_exception(env, _JC_NullPointerException);
 	goto exception;
 
 arithmetic_exception:
+	stack_frame.pc = pc;
 	_jc_post_exception(env, _JC_ArithmeticException);
 	goto exception;
 
@@ -1677,6 +1754,17 @@
 	/* Done */
 	return status;
     }
+}
+
+/*
+ * Fill in the interpreter instruction target table.
+ */
+void
+_jc_interp_get_targets(_jc_env *env)
+{
+	/* Get actions table via kludge */
+	(void)_jc_interp(env, NULL);
+	_jc_interp_targets = (const _jc_word *)env->retval.l;
 }
 
 /*

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h?rev=366074&r1=366073&r2=366074&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h Wed Jan
 4 20:07:26 2006
@@ -213,6 +213,8 @@
 extern _jc_object	*_jc_interp_native_l(_jc_env *env, ...);
 extern void		_jc_interp_native_v(_jc_env *env, ...);
 extern int		_jc_interp_pc_to_jline(_jc_method *method, int index);
+extern void		_jc_interp_get_targets(_jc_env *env);
+extern const _jc_word	*_jc_interp_targets;
 
 /* invoke.c */
 extern jint		_jc_invoke_nonvirtual(_jc_env *env,

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=366074&r1=366073&r2=366074&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 Wed Jan
 4 20:07:26 2006
@@ -509,11 +509,8 @@
 	/* Allocate resolved method info */
 	_JC_MUTEX_LOCK(env, loader->mutex);
 	mutex_locked = JNI_TRUE;
-	if ((interp->opcodes = _jc_cl_alloc(env, loader,
-	    code->num_insns * sizeof(*interp->opcodes))) == NULL)
-		goto post_fail;
-	if ((interp->info = _jc_cl_alloc(env, loader,
-	    code->num_insns * sizeof(*interp->info))) == NULL)
+	if ((interp->insns = _jc_cl_alloc(env, loader,
+	    code->num_insns * sizeof(*interp->insns))) == NULL)
 		goto post_fail;
 	if ((interp->traps = _jc_cl_alloc(env, loader,
 	    code->num_traps * sizeof(*interp->traps))) == NULL)
@@ -545,9 +542,9 @@
 		_jc_cf_trap *const ptrap = &code->traps[i];
 		_jc_interp_trap *const itrap = &interp->traps[i];
 
-		itrap->start = ptrap->start;
-		itrap->end = ptrap->end;
-		itrap->target = ptrap->target;
+		itrap->start = &interp->insns[ptrap->start];
+		itrap->end = &interp->insns[ptrap->end];
+		itrap->target = &interp->insns[ptrap->target];
 		if (ptrap->type == NULL) {
 			itrap->type = NULL;
 			continue;
@@ -562,12 +559,13 @@
 
 	/* Resolve and copy instructions */
 	for (i = 0; i < code->num_insns; i++) {
-		_jc_cf_insn *const insn = &code->insns[i];
-		_jc_insn_info *const info = &interp->info[i];
+		_jc_cf_insn *const cinsn = &code->insns[i];
+		_jc_insn *const insn = &interp->insns[i];
+		_jc_insn_info *const info = &insn->info;
 		u_char opcode;
 
 		/* Get opcode */
-		opcode = insn->opcode;
+		opcode = cinsn->opcode;
 
 		/* Copy and resolve additional info, possibly changing opcode */
 		switch (opcode) {
@@ -586,11 +584,11 @@
 		case _JC_lload:
 		case _JC_lstore:
 		case _JC_ret:
-			info->local = insn->u.local.index;
+			info->local = cinsn->u.local.index;
 			break;
 		case _JC_anewarray:
 		    {
-			const char *etype = insn->u.type.name;
+			const char *etype = cinsn->u.type.name;
 			const size_t elen = strlen(etype) + 1;
 			char *atype;
 
@@ -620,7 +618,7 @@
 		case _JC_instanceof:
 		case _JC_new:
 			if ((info->type = _jc_load_type(env,
-			    loader, insn->u.type.name)) == NULL)
+			    loader, cinsn->u.type.name)) == NULL)
 				goto fail;
 			if (_jc_resolve_add_loader_ref(env,
 			    rinfo, info->type->loader) != JNI_OK)
@@ -628,7 +626,7 @@
 			break;
 		case _JC_bipush:
 		case _JC_sipush:
-			info->constant.i = insn->u.immediate.value;
+			info->constant.i = cinsn->u.immediate.value;
 			opcode = _JC_ldc;
 			break;
 		case _JC_dconst_0:
@@ -694,7 +692,7 @@
 		    {
 			const int is_static = opcode == _JC_getstatic
 			    || opcode == _JC_putstatic;
-			_jc_cf_ref *const ref = insn->u.fieldref.field;
+			_jc_cf_ref *const ref = cinsn->u.fieldref.field;
 			_jc_field *field;
 			_jc_type *type;
 			u_char ptype;
@@ -816,18 +814,18 @@
 		case _JC_ifnonnull:
 		case _JC_ifnull:
 		case _JC_jsr:
-			info->target = insn->u.branch.target;
+			info->target = &interp->insns[cinsn->u.branch.target];
 			break;
 		case _JC_iinc:
-			info->iinc.local = insn->u.iinc.index;
-			info->iinc.value = insn->u.iinc.value;
+			info->iinc.local = cinsn->u.iinc.index;
+			info->iinc.value = cinsn->u.iinc.value;
 			break;
 		case _JC_invokeinterface:
 		case _JC_invokespecial:
 		case _JC_invokestatic:
 		case _JC_invokevirtual:
 		    {
-			_jc_cf_ref *const ref = insn->u.invoke.method;
+			_jc_cf_ref *const ref = cinsn->u.invoke.method;
 			_jc_invoke *const invoke = &info->invoke;
 			_jc_method *imethod;
 			_jc_type *type;
@@ -954,7 +952,7 @@
 		    }
 		case _JC_ldc:
 		    {
-			_jc_cf_constant *const c = insn->u.constant;
+			_jc_cf_constant *const c = cinsn->u.constant;
 
 			switch (c->type) {
 			case CONSTANT_Integer:
@@ -976,7 +974,8 @@
 					goto post_fail;
 				}
 				_JC_MUTEX_UNLOCK(env, loader->mutex);
-				info->utf8 = copy;
+				info->string.string = NULL;
+				info->string.utf8 = copy;
 
 				/* Set opcode */
 				opcode = _JC_ldc_string;
@@ -1003,7 +1002,7 @@
 		    }
 		case _JC_ldc2_w:
 		    {
-			_jc_cf_constant *const c = insn->u.constant;
+			_jc_cf_constant *const c = cinsn->u.constant;
 
 			switch (c->type) {
 			case CONSTANT_Long:
@@ -1019,7 +1018,7 @@
 		    }
 		case _JC_lookupswitch:
 		    {
-			_jc_cf_lookupswitch *const csw = insn->u.lookupswitch;
+			_jc_cf_lookupswitch *const csw = cinsn->u.lookupswitch;
 			_jc_lookupswitch *sw;
 			int j;
 
@@ -1033,14 +1032,14 @@
 			_JC_MUTEX_UNLOCK(env, loader->mutex);
 
 			/* Copy info */
-			sw->default_target = csw->default_target;
+			sw->default_target = &interp->insns[csw->default_target];
 			sw->num_pairs = csw->num_pairs;
 			for (j = 0; j < sw->num_pairs; j++) {
 				_jc_cf_lookup *const clup = &csw->pairs[j];
 				_jc_lookup *const lup = &sw->pairs[j];
 
 				lup->match = clup->match;
-				lup->target = clup->target;
+				lup->target = &interp->insns[clup->target];
 			}
 
 			/* Done */
@@ -1049,20 +1048,20 @@
 		    }
 		case _JC_multianewarray:
 			if ((info->multianewarray.type = _jc_load_type(env,
-			    loader, insn->u.multianewarray.type)) == NULL)
+			    loader, cinsn->u.multianewarray.type)) == NULL)
 				goto fail;
 			if (_jc_resolve_add_loader_ref(env, rinfo,
 			    info->multianewarray.type->loader) != JNI_OK)
 				goto post_fail;
-			info->multianewarray.dims = insn->u.multianewarray.dims;
+			info->multianewarray.dims = cinsn->u.multianewarray.dims;
 			break;
 		case _JC_newarray:
 			info->type = vm->boot.types.prim_array[
-			    insn->u.newarray.type];
+			    cinsn->u.newarray.type];
 			break;
 		case _JC_tableswitch:
 		    {
-			_jc_cf_tableswitch *const csw = insn->u.tableswitch;
+			_jc_cf_tableswitch *const csw = cinsn->u.tableswitch;
 			const int num_targets = csw->high - csw->low + 1;
 			_jc_tableswitch *sw;
 			int j;
@@ -1077,11 +1076,11 @@
 			_JC_MUTEX_UNLOCK(env, loader->mutex);
 
 			/* Copy info */
-			sw->default_target = csw->default_target;
+			sw->default_target = &interp->insns[csw->default_target];
 			sw->low = csw->low;
 			sw->high = csw->high;
 			for (j = 0; j < num_targets; j++)
-				sw->targets[j] = csw->targets[j];
+				sw->targets[j] = &interp->insns[csw->targets[j]];
 
 			/* Done */
 			info->tableswitch = sw;
@@ -1091,8 +1090,8 @@
 			break;
 		}
 
-		/* Copy opcode */
-		interp->opcodes[i] = opcode;
+		/* Set opcode */
+		insn->action = opcode;
 	}
 
 	/* Compute stack depth at the start of each instruction */
@@ -1108,18 +1107,18 @@
 	 * the local is referenced.
 	 */
 	for (i = 0; i < code->num_insns; i++) {
-		_jc_cf_insn *const insn = &code->insns[i];
-		_jc_insn_info *const info = &interp->info[i];
+		_jc_insn *const insn = &interp->insns[i];
+		_jc_insn_info *const info = &insn->info;
 
 		/* Handle the case of unreachable code */
 		if (depth[i] == -1) {
-			insn->opcode = _JC_failure;
+			insn->action = _JC_failure;
 			continue;
 		}
 
 		/* Change local index to SP offset */
 		_JC_ASSERT(depth[i] >= 0 && depth[i] <= code->max_stack);
-		switch (insn->opcode) {
+		switch (insn->action) {
 		case _JC_aload:
 		case _JC_dload:
 		case _JC_fload:
@@ -1145,6 +1144,14 @@
 		}
 	}
 
+	/* Finally, convert opcodes to interpreter jump targets */
+	for (i = 0; i < code->num_insns; i++) {
+		_jc_insn *const insn = &interp->insns[i];
+
+		insn->action = _jc_interp_targets[insn->action];
+		_JC_ASSERT(insn->action != 0);
+	}
+
 	/* Done */
 	return JNI_OK;
 
@@ -1159,10 +1166,8 @@
 	}
 	_jc_cl_unalloc(loader, &interp->traps,
 	    code->num_traps * sizeof(*interp->traps));
-	_jc_cl_unalloc(loader, &interp->info,
-	    code->num_insns * sizeof(*interp->info));
-	_jc_cl_unalloc(loader, &interp->opcodes,
-	    code->num_insns * sizeof(*interp->opcodes));
+	_jc_cl_unalloc(loader, &interp->insns,
+	    code->num_insns * sizeof(*interp->insns));
 	_JC_MUTEX_UNLOCK(env, loader->mutex);
 
 	/* Free parsed code */

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/stack.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/stack.c?rev=366074&r1=366073&r2=366074&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/stack.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/stack.c Wed Jan
 4 20:07:26 2006
@@ -217,7 +217,8 @@
 		/* Save this one */
 		if (i < max) {
 			frame->method = jstack->method;
-			frame->ipc = jstack->pcp != NULL ? *jstack->pcp : -1;
+			frame->ipc = jstack->pc != NULL ?
+			    jstack->pc - jstack->method->code.insns : -1;
 		}
 		i++;
 	}

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h?rev=366074&r1=366073&r2=366074&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h Wed
Jan  4 20:07:26 2006
@@ -206,7 +206,7 @@
 struct _jc_java_stack {
 	_jc_java_stack			*next;
 	_jc_method			*method;
-	const int			*pcp;
+	_jc_insn			*pc;
 };
 
 /*

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/vm.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/vm.c?rev=366074&r1=366073&r2=366074&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/vm.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/vm.c Wed Jan  4
20:07:26 2006
@@ -134,6 +134,9 @@
 	if (_jc_heap_init(env, vm) != JNI_OK)
 		goto fail_info;
 
+	/* Get interpreter targets */
+	_jc_interp_get_targets(env);
+
 	/* Create the bootstrap class loader */
 	_JC_MUTEX_LOCK(env, vm->mutex);
 	if ((vm->boot.loader = _jc_create_loader(env)) == NULL) {



Mime
View raw message