harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dtan...@apache.org
Subject svn commit: r355107 - in /incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc: Makefile.am arch/i386/Makefile.am class_loader.c class_object.c debug_line.c definitions.h derive.c gc_root.c libjc.h resolve.c structures.h
Date Thu, 08 Dec 2005 15:06:35 GMT
Author: dtanzer
Date: Thu Dec  8 07:05:50 2005
New Revision: 355107

URL: http://svn.apache.org/viewcvs?rev=355107&view=rev
Log:
Removed ELF-Specific stuff.

libjc/Makefile.am: Also removed the "-module" from the LDFLAGS which made the
    linker fail on OSX/PPC.
libjc/class_object.c: Removed content completely. Maybe this file can be removed
    (TODO: Test this).


Modified:
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/Makefile.am
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/Makefile.am
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_object.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/debug_line.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/definitions.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/derive.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_root.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/libjc.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/structures.h

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/Makefile.am
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/Makefile.am?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/Makefile.am (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/Makefile.am Thu Dec  8 07:05:50 2005
@@ -4,7 +4,7 @@
 
 lib_LTLIBRARIES=	libjc.la
 
-libjc_la_LDFLAGS=	-version-info @LIBRARY_VERSION@ -module
+libjc_la_LDFLAGS=	-version-info @LIBRARY_VERSION@
 
 # Standard source files
 libjc_la_SOURCES= \
@@ -20,7 +20,6 @@
 			debug_line.c \
 			derive.c \
 			derive2.c \
-			elf.c \
 			exception.c \
 			fatal.c \
 			gc_final.c \
@@ -80,8 +79,7 @@
 			native/org_dellroad_jc_vm_FinalizerThread.c
 
 # Architecture specific source files
-libjc_la_SOURCES+=	arch/@JC_ARCH@/arch_elf_reloc.c \
-			arch/@JC_ARCH@/arch_functions.c
+libjc_la_SOURCES+= arch/@JC_ARCH@/arch_functions.c
 
 # Header files
 libjc_la_SOURCES+=	cf_parse.h \

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/Makefile.am
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/Makefile.am?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/Makefile.am (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/i386/Makefile.am Thu Dec  8 07:05:50 2005
@@ -1,7 +1,6 @@
-## $Id: Makefile.am,v 1.1.1.1 2004/02/20 05:15:49 archiecobbs Exp $
+## $Id$
 
-noinst_HEADERS=		arch_elf_reloc.c \
-			arch_functions.c \
+noinst_HEADERS=		arch_functions.c \
 			i386_definitions.h \
 			i386_libjc.h \
 			i386_structures.h

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_loader.c Thu Dec  8 07:05:50 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: class_loader.c,v 1.13 2005/11/09 18:14:22 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
@@ -253,11 +253,8 @@
 		/* Free supers info (unresolved ELF types) */
 		_jc_vm_free(&type->u.nonarray.supers);
 
-		/* Unreference parsed class file or ELF object */
-		if (_JC_ACC_TEST(type, INTERP))
-			_jc_destroy_classfile(&type->u.nonarray.u.cfile);
-		else
-			_jc_elf_unref(&type->u.nonarray.u.elf);
+		/* Unreference parsed class file */
+		_jc_destroy_classfile(&type->u.nonarray.u.cfile);
 
 remove_type:
 		/* Remove this type from the tree */

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_object.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_object.c?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_object.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/class_object.c Thu Dec  8 07:05:50 2005
@@ -15,291 +15,8 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: class_object.c,v 1.12 2005/05/18 22:04:45 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
-
-/* Internal functions */
-static _jc_elf	*_jc_load_object_dir(_jc_env *env, _jc_class_loader *loader,
-			const char *dir, const char *name);
-
-/*
- * Find the ELF object that defines the named class, then load the ELF object
- * and all types defined within it. All class file hash values in the ELF
- * object must match any already stored in the VM class file tree.
- *
- * If unsuccessful an exception is stored.
- */
-jint
-_jc_load_object(_jc_env *env, _jc_class_loader *loader, const char *name)
-{
-	_jc_jvm *const vm = env->vm;
-	_jc_type *const key = (_jc_type *)((char *)&name
-	    - _JC_OFFSETOF(_jc_type, name));
-	int i;
-
-	/* Sanity check */
-	_JC_ASSERT(vm->loader_enabled);
-
-	/* Try each entry in the object path */
-	for (i = 0; i < vm->object_path_len; i++) {
-		_jc_objpath_entry *const ent = &vm->object_path[i];
-		_jc_elf *elf;
-
-try_again:
-		switch (ent->type) {
-		case _JC_OBJPATH_DIRECTORY:
-
-			/* Look for object file in this directory */
-			if ((elf = _jc_load_object_dir(env,
-			    loader, ent->pathname, name)) != NULL)
-				break;
-
-			/* If something unexpected happened, bail out */
-			if (env->ex.num != _JC_LinkageError)
-				return JNI_ERR;
-
-			/* Try next entry */
-			continue;
-		case _JC_OBJPATH_ELFFILE:
-
-			/* Has this loader already loaded this object? */
-			if (loader->objects_loaded[i])
-				continue;
-
-			/* Try to load specified ELF object file */
-			if ((elf = _jc_elf_load(env,
-			    loader, ent->pathname)) != NULL)
-				break;
-
-			/* If something unexpected happened, bail out */
-			if (env->ex.num != _JC_LinkageError)
-				return JNI_ERR;
-
-			/* Mark this entry as erroneous */
-			VERBOSE(OBJ, vm, "`%s' is invalid: %s",
-			    ent->pathname, env->ex.msg);
-			ent->type = _JC_OBJPATH_ERROR;
-
-			/* Try next entry */
-			continue;
-		case _JC_OBJPATH_UNKNOWN:
-		    {
-			struct stat info;
-
-			/* Examine file; if invalid, skip it from now on */
-			if (stat(ent->pathname, &info) == -1) {
-				VERBOSE(OBJ, vm, "`%s' is invalid: %s",
-				    ent->pathname, strerror(errno));
-				continue;
-			}
-
-			/* If it's a directory, change type and try again */
-			if ((info.st_mode & S_IFMT) == S_IFDIR) {
-				_JC_MUTEX_LOCK(env, vm->mutex);
-				if (ent->type == _JC_OBJPATH_UNKNOWN)
-					ent->type = _JC_OBJPATH_DIRECTORY;
-				_JC_MUTEX_UNLOCK(env, vm->mutex);
-				goto try_again;
-			}
-
-			/* Assume it's an ELF file and try again */
-			_JC_MUTEX_LOCK(env, vm->mutex);
-			if (ent->type == _JC_OBJPATH_UNKNOWN)
-				ent->type = _JC_OBJPATH_ELFFILE;
-			_JC_MUTEX_UNLOCK(env, vm->mutex);
-			goto try_again;
-		    }
-		case _JC_OBJPATH_ERROR:
-			continue;
-		default:
-			_JC_ASSERT(JNI_FALSE);
-		}
-
-		/* We should have a loaded ELF object at this point */
-		_JC_ASSERT(elf != NULL);
-
-		/* Does the ELF file define the type we're looking for? */
-		if (_jc_splay_find(&elf->types, key) == NULL) {
-			VERBOSE(OBJ, vm, "failed: `%s' does not define `%s'",
-			    elf->pathname, name);
-			_jc_elf_unref(&elf);
-			continue;
-		}
-
-		/* Load all types defined in the object */
-		if (_jc_derive_types_from_object(env, elf) != JNI_OK) {
-			if (env->ex.num != _JC_LinkageError)
-				return JNI_ERR;
-			VERBOSE(OBJ, vm, "failed: %s%s%s",
-			    _jc_vmex_names[env->ex.num],
-			    *env->ex.msg != '\0' ? ": " : "", env->ex.msg);
-			_jc_elf_unref(&elf);
-			continue;
-		}
-
-		/* Output object file in object file list if desired */
-		if (vm->object_list != NULL) {
-			fprintf(vm->object_list, "%s\n", elf->pathname);
-			fflush(vm->object_list);
-		}
-
-		/* If object path entry was an ELF file, mark it as loaded */
-		if (ent->type == _JC_OBJPATH_ELFFILE) {
-			_JC_ASSERT(!loader->objects_loaded[i]);
-			loader->objects_loaded[i] = JNI_TRUE;
-		}
-
-		/* Release our reference on ELF file */
-		_jc_elf_unref(&elf);
-
-		/* Done */
-		return JNI_OK;
-	}
-
-	/* Not found */
-	_JC_EX_STORE(env, LinkageError,
-	    "no valid ELF object found containing `%s'", name);
-	return JNI_ERR;
-}
-
-/*
- * Find a class' ELF object file in a directory hierarchy and read
- * it in if found. Here we also look for "_package.o".
- *
- * If unsuccessful an exception is stored.
- */
-static _jc_elf *
-_jc_load_object_dir(_jc_env *env, _jc_class_loader *loader,
-	const char *dir, const char *name)
-{
-	_jc_elf *elf;
-	char *ename;
-	char *path;
-	char *s;
-
-	/* Generate encoded name for class */
-	if ((ename = _JC_STACK_ALLOC(env,
-	    _jc_name_encode(name, NULL, JNI_TRUE) + 1)) == NULL)
-		return NULL;
-	_jc_name_encode(name, ename, JNI_TRUE);
-
-	/* Get buffer big enough for both pathnames we'll try */
-	if ((path = _JC_STACK_ALLOC(env, strlen(dir)
-	    + sizeof(_JC_FILE_SEPARATOR) + strlen(ename)
-	    + sizeof(_JC_PACKAGE_OBJECT_NAME))) == NULL)
-		return NULL;
-
-	/* Generate class-specific object file name */
-	sprintf(path, "%s%s%s.o", dir, _JC_FILE_SEPARATOR, ename);
-
-	/* Try to load class-specific ELF object file */
-	if ((elf = _jc_elf_load(env, loader, path)) != NULL)
-		return elf;
-
-	/* Generate package object file name */
-	for (s = path + strlen(path); s > path && s[-1] != '/'; s--);
-	strcpy(s, _JC_PACKAGE_OBJECT_NAME);
-
-	/* Try to load combo ELF object file */
-	if ((elf = _jc_elf_load(env, loader, path)) != NULL)
-		return elf;
-
-	/* Not found */
-	return NULL;
-}
-
-/*
- * Generate the ELF object file for the named class.
- *
- * If unsuccessful an exception is posted.
- */
-jint
-_jc_generate_object(_jc_env *env, _jc_class_loader *loader, const char *name)
-{
-	_jc_jvm *const vm = env->vm;
-	jobject nameString = NULL;
-	jobject genObj = NULL;
-	jint status = JNI_ERR;
-
-	/* Sanity check */
-	_JC_ASSERT(vm->loader_enabled);
-	_JC_ASSERT(vm->generation_enabled);
-
-	/* Is the "compiler" disabled? */
-	if (vm->compiler_disabled) {
-		_jc_post_exception_msg(env, _JC_LinkageError,
-		    "code generated is disabled");
-		return JNI_ERR;
-	}
-
-	/* Don't generate code during VM initialization */
-	if (vm->initialization != NULL) {
-		_jc_post_exception_msg(env, _JC_LinkageError,
-		    "can't generate code during VM initialization");
-		return JNI_ERR;
-	}
-
-	/*
-	 * Are we already in the middle of generating something?
-	 * If so, don't recurse because Soot is probably not reentrant.
-	 * Hopefully we're just trying to acquire the class file.
-	 */
-	if (env->generating != NULL) {
-		_jc_post_exception_msg(env, _JC_LinkageError,
-		    "recursive attempt to generate `%s' while generating `%s'",
-		    name, env->generating);
-		return JNI_ERR;
-	}
-
-	/* Verbosity */
-	VERBOSE(GEN, vm, "generating ELF object for `%s'", name);
-
-	/* Note that we're generating this object */
-	env->generating = name;
-
-	/* Get the Generate singleton object */
-	if (_jc_invoke_static(env, vm->boot.methods.Generate.v) != JNI_OK)
-		goto fail;
-	if ((genObj = _jc_new_local_native_ref(env, env->retval.l)) == NULL)
-		goto fail;
-
-	/* Put class name in a String object */
-	if ((nameString = _jc_new_local_native_ref(env,
-	    _jc_new_string(env, name, strlen(name)))) == NULL)
-		goto fail;
-
-	/* Invoke Generate.v().generateObject() */
-	if (_jc_invoke_virtual(env, vm->boot.methods.Generate.generateObject,
-	    *genObj, *nameString, loader->instance) != JNI_OK)
-		goto fail;
-
-	/* Done */
-	status = JNI_OK;
-
-fail:
-	/* Turn off generating flag */
-	_JC_ASSERT(env->generating == name);
-	env->generating = NULL;
-
-	/* Clean up native refs */
-	_jc_free_local_native_ref(&genObj);
-	_jc_free_local_native_ref(&nameString);
-
-	/* Report any error */
-	if (status != JNI_OK) {
-		if ((env->vm->verbose_flags & (1 << _JC_VERBOSE_GEN)) != 0) {
-			_jc_printf(vm,
-			    "[verbose %s: object generation for `%s' failed: ",
-			    _jc_verbose_names[_JC_VERBOSE_GEN], name);
-			_jc_fprint_exception_headline(env,
-			    stdout, env->head.pending);
-			_jc_printf(vm, "]\n");
-		}
-	}
-
-	/* Done */
-	return status;
-}
 

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/debug_line.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/debug_line.c?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/debug_line.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/debug_line.c Thu Dec  8 07:05:50 2005
@@ -15,412 +15,11 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: debug_line.c,v 1.7 2005/03/13 02:59:43 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
 
-/* Internal functions */
-static jint		_jc_debug_line_add(_jc_env *env, _jc_map_state *state,
-				const void *pc, uint32_t cline);
-static jint		_jc_debug_line_finish(_jc_env *env, _jc_method *method,
-				_jc_class_loader *loader, _jc_map_state *state);
-static Elf_Word		_jc_read_leb128(const u_char **datap, int is_signed);
-static int		_jc_method_addr_cmp(const void *v1, const void *v2);
-
-/*
- * Process stabs line number information.
- *
- * If unsuccessful an exception is stored.
- */
-jint
-_jc_debug_line_stabs(_jc_env *env, _jc_elf *elf, _jc_splay_tree *tree)
-{
-	_jc_elf_info *const info = elf->info;
-	const Elf_Shdr *const shdr = info->debug_lines.loadable.shdr;
-	_jc_stab *const stabs = (_jc_stab *)(info->map_base + shdr->sh_offset);
-	const int num_stabs = shdr->sh_size / sizeof(*stabs);
-	_jc_map_state state;
-	_jc_method *method;
-	int i;
-
-	/* Sanity check */
-	_JC_ASSERT(info->debug_lines.type == _JC_LINE_DEBUG_STABS);
-
-	/* Initialize state */
-	memset(&state, 0, sizeof(state));
-	method = NULL;
-
-	/* Run through stabs section */
-	for (i = 0; i < num_stabs; i++) {
-		_jc_stab *const stab = &stabs[i];
-
-		/* Check type */
-		switch (stab->type) {
-		case STAB_FUN:
-		    {
-			_jc_method_node *node;
-			_jc_method_node key;
-			const char *fun;
-			const char *s;
-
-			/* Check for end of method; reset state if so */
-			if (stab->sindex == 0) {
-
-				/* Were we skipping this method? */
-				if (method == NULL)
-					continue;
-
-				/* Finalize map */
-				if (_jc_debug_line_finish(env,
-				    method, elf->loader, &state) != JNI_OK)
-					goto fail;
-				method = NULL;
-				break;
-			}
-
-			/* Already doing this function? */
-			if (method != NULL)
-				continue;
-
-			/* Get FUN string containing function name */
-			fun = (const char *)info->debug_lines.strings
-			    + stab->sindex;
-
-			/* Sanity check not already within a method */
-			if (method != NULL) {
-				_JC_EX_STORE(env, LinkageError,
-				    "double opening stabs FUN entry `%s'", fun);
-				goto fail;
-			}
-
-			/* Try to parse out class & method name from symbol */
-			if (strncmp(fun, "_jc_", 4) != 0
-			    || (s = strchr(fun + 4, '$')) == NULL
-			    || strncmp(s + 1, "method$", 7) != 0)
-				continue;
-			key.cname = fun + 4;
-			key.clen = s - key.cname;
-			key.mname = s + 8;
-			if ((s = strchr(key.mname, ':')) == NULL)
-				s += strlen(s);		/* can this happen? */
-			key.mlen = s - key.mname;
-
-			/* Find corresponding method node, if any */
-			if ((node = _jc_splay_find(tree, &key)) == NULL)
-				continue;
-			method = node->method;
-			_JC_ASSERT(method != NULL);
-			_JC_ASSERT(method->function != NULL);
-			_JC_ASSERT(!_JC_ACC_TEST(method, INTERP));
-			_JC_ASSERT(method->u.exec.function_end != NULL);
-
-			/* If method has no line number table, nothing to do */
-			if (method->u.exec.u.linenum.len == 0) {
-				memset(&method->u.exec.u,
-				    0, sizeof(method->u.exec.u));
-				method = NULL;
-				continue;
-			}
-
-			/* Initialize state for this method */
-			_JC_ASSERT(state.pc_map.len == 0);
-			_JC_ASSERT(state.last_linenum == 0);
-			_JC_ASSERT(state.last_map == 0);
-			state.linenum = method->u.exec.u.linenum;
-			memset(&method->u.exec.u, 0, sizeof(method->u.exec.u));
-			break;
-		    }
-		case STAB_SLINE:
-
-			/* If skipping this method, skip lines */
-			if (method == NULL)
-				continue;
-
-			/* Add entry */
-			if (_jc_debug_line_add(env, &state,
-			    (const char *)method->function + stab->value,
-			    stab->desc) != JNI_OK)
-				goto fail;
-			break;
-		default:
-			break;
-		}
-	}
-
-	/* Clean up and exit */
-	_jc_vm_free(&state.pc_map.map);
-	return JNI_OK;
-
-fail:
-	/* Clean up after failure */
-	_jc_vm_free(&state.pc_map.map);
-	return JNI_ERR;
-}
-
-/*
- * Read a DWARF leb128 value.
- */
-static inline Elf_Word
-_jc_read_leb128(const u_char **datap, int is_signed)
-{
-	Elf_Word value; 
-	int bitpos;
-
-	for (bitpos = value = 0; ; bitpos += 7) {
-		const u_char byte = *(*datap)++;
-
-		value |= (byte & 0x7f) << bitpos;
-		if ((byte & 0x80) == 0)
-			break;
-	}
-	if (is_signed && (value & (1 << (bitpos + 6))) != 0)
-		value |= (Elf_Word)~0L << (bitpos + 7);
-	return value;
-}
-
-/*
- * Process DWARF2 line number information.
- *
- * If unsuccessful an exception is stored.
- */
-jint
-_jc_debug_line_dwarf2(_jc_env *env, _jc_elf *elf, _jc_splay_tree *tree)
-{
-	_jc_elf_info *const info = elf->info;
-	const Elf_Shdr *const shdr = info->debug_lines.loadable.shdr;
-	const u_char *ptr = (const u_char *)info->map_base + shdr->sh_offset;
-	const u_char *const section_end = ptr + shdr->sh_size;
-	jboolean using64bit = JNI_FALSE;
-	_jc_dwarf2_line_hdr *hdr;
-	_jc_method_node **nodes;
-	_jc_map_state state;
-	_jc_method *method;
-	unsigned long totlen;
-	union _jc_value jvalue;
-	int node_index;
-	const u_char *ptr_end;
-	const u_char *pc;
-	int num_nodes;
-	int cline;
-	int i;
-
-	/* Put nodes in a list and elide methods with no line number table */
-	if ((nodes = _JC_STACK_ALLOC(env,
-	    tree->size * sizeof(*nodes))) == NULL)
-		goto fail;
-	_jc_splay_list(tree, (void **)nodes);
-	for (i = num_nodes = 0; i < tree->size; i++) {
-		_jc_method_node *const node = nodes[i];
-		_jc_method *const method = node->method;
-
-		_JC_ASSERT(method != NULL);
-		_JC_ASSERT(method->function != NULL);
-		_JC_ASSERT(!_JC_ACC_TEST(method, INTERP));
-		_JC_ASSERT(method->u.exec.function_end != NULL);
-		if (method->u.exec.u.linenum.len > 0)
-			nodes[num_nodes++] = nodes[i];
-	}
-
-	/* Anything to do? */
-	if (num_nodes == 0)
-		return JNI_OK;
-
-	/* Sort methods by starting address */
-	qsort(nodes, num_nodes, sizeof(*nodes), _jc_method_addr_cmp);
-
-	/* Initialize map state */
-	memset(&state, 0, sizeof(state));
-	node_index = 0;
-	method = NULL;
-
-again:
-	/* Read prologue header */
-	memcpy(&jvalue, ptr, sizeof(jint));
-	ptr += sizeof(jint);
-	totlen = jvalue.i;
-	if (totlen == 0xffffffff) {
-		memcpy(&jvalue, ptr, sizeof(jlong));
-		ptr += sizeof(jlong);
-		totlen = jvalue.j;
-		using64bit = JNI_TRUE;
-	} else if (totlen == 0) {
-		memcpy(&jvalue, ptr, sizeof(jint));
-		ptr += sizeof(jint);
-		totlen = jvalue.i;
-		using64bit = JNI_TRUE;
-	}
-	ptr_end = ptr + totlen;
-	ptr += 2;					/* skip version */
-	ptr += 4;					/* skip header len */
-	if (using64bit)
-		ptr += 4;
-	hdr = (_jc_dwarf2_line_hdr *)ptr;
-	ptr += sizeof(*hdr) + hdr->opcode_base - 1;
-
-	/* Skip over directory table */
-	while (*ptr++ != '\0')
-		ptr += strlen((const char *)ptr) + 1;
-
-	/* Skip over file name table */
-	while (*ptr++ != '\0') {
-		ptr += strlen((const char *)ptr) + 1;
-		(void)_jc_read_leb128(&ptr, JNI_FALSE);
-		(void)_jc_read_leb128(&ptr, JNI_FALSE);
-		(void)_jc_read_leb128(&ptr, JNI_FALSE);
-	}
-
-	/* Initialize statement program state */
-	pc = NULL;
-	cline = 1;
-
-	/* Process statement program */
-	while (ptr < ptr_end) {
-		jboolean writeout = JNI_FALSE;
-		jboolean reset = JNI_FALSE;
-		u_char opcode;
-
-		if ((opcode = *ptr++) >= hdr->opcode_base) {	/* special */
-			opcode -= hdr->opcode_base;
-			pc += (opcode / hdr->line_range)
-			    * hdr->minimum_instruction_length;
-			cline += hdr->line_base + opcode % hdr->line_range;
-			writeout = JNI_TRUE;
-		} else if (opcode == 0) {			/* extended */
-			unsigned int oplen;
-			u_char exop;
-
-			oplen = _jc_read_leb128(&ptr, JNI_FALSE);
-			exop = *ptr++;
-			switch (exop) {
-			case DW_LNE_end_sequence:
-				reset = JNI_TRUE;
-				writeout = JNI_TRUE;
-				break;
-			case DW_LNE_set_address:
-			    {
-				const u_char *new_pc;
-
-				/* Get new PC */
-				memcpy(&new_pc, ptr, sizeof(new_pc));
-
-				/* We don't support out-of-spec reversals */
-				if (new_pc < pc) {
-					_JC_EX_STORE(env, LinkageError,
-					    "address reversals in .debug_line"
-					    " section are not supported");
-					goto fail;
-				}
-
-				/* OK */
-				pc = new_pc;
-				break;
-			    }
-			default:
-				break;
-			}
-			ptr += oplen - 1;
-		} else {					/* standard */
-			switch (opcode) {
-			case DW_LNS_copy:
-				writeout = JNI_TRUE;
-				break;
-			case DW_LNS_advance_pc:
-				pc += _jc_read_leb128(&ptr, JNI_FALSE)
-				    * hdr->minimum_instruction_length;
-				break;
-			case DW_LNS_advance_line:
-				cline += _jc_read_leb128(&ptr, JNI_TRUE);
-				break;
-			case DW_LNS_const_add_pc:
-				pc += ((255 - hdr->opcode_base)
-				      / hdr->line_range)
-				    * hdr->minimum_instruction_length;
-				break;
-			case DW_LNS_fixed_advance_pc:
-			    {
-				uint16_t advance;
-
-				memcpy(&advance, ptr, 2);
-				pc += advance;
-				ptr += 2;
-				break;
-			    }
-			default:
-				for (i = 0; i < hdr->standard_opcode_lengths[
-				    opcode - 1]; i++)
-					_jc_read_leb128(&ptr, JNI_FALSE);
-				break;
-			}
-		}
-
-		/* Have we reached the next method? */
-		if (method == NULL
-		    && (const void *)pc
-		      >= nodes[node_index]->method->function) {
-
-			/* Initialize state for this method */
-			_JC_ASSERT(state.pc_map.len == 0);
-			_JC_ASSERT(state.last_linenum == 0);
-			_JC_ASSERT(state.last_map == 0);
-			method = nodes[node_index]->method;
-			_JC_ASSERT(!_JC_ACC_TEST(method, INTERP));
-			state.linenum = method->u.exec.u.linenum;
-			memset(&method->u.exec.u, 0, sizeof(method->u.exec.u));
-		}
-
-		/* Finished with the current method? */
-		if (method != NULL
-		    && (const void *)pc >= method->u.exec.function_end) {
-
-			/* Finalize map for current method */
-			if (_jc_debug_line_finish(env,
-			    method, elf->loader, &state) != JNI_OK)
-				goto fail;
-			method = NULL;
-
-			/* Look for next method */
-			if (++node_index == num_nodes)
-				goto done;
-		}
-
-		/* Write matrix row */
-		if (writeout && method != NULL) {
-			if (_jc_debug_line_add(env,
-			    &state, pc, cline) != JNI_OK)
-				goto fail;
-		}
-
-		/* Reset after DW_LNE_end_sequence */
-		if (reset) {
-			pc = NULL;
-			cline = 1;
-		}
-	}
-	if (ptr < section_end)
-		goto again;
-
-done:
-	/* Sanity check */
-	_JC_ASSERT(method == NULL);
-#ifndef NDEBUG
-	for (i = 0; i < num_nodes; i++) {
-		_jc_method_node *const node = nodes[i];
-		_jc_method *const method = node->method;
-
-		_JC_ASSERT(!_JC_ACC_TEST(method, INTERP));
-		_JC_ASSERT(method->u.exec.u.pc_map.map != NULL);
-	}
-#endif
-
-	/* Done */
-	return JNI_OK;
-
-fail:
-	/* Failed */
-	return JNI_ERR;
-}
-
 /*
  * Map a PC return address within a function to a Java line number.
  * This assumes the PC is within the function. Returns 0 if unknown.
@@ -462,186 +61,4 @@
 	/* Not found */
 	return 0;
 }
-
-/*
- * Add a new [addr => java line number] pair to the PC map, given
- * an [addr => cline] mapping. We search the line number table to derive
- * the intermediate [cline => line number table entry] mapping. If the
- * address is before the first line number table entry, do nothing.
- *
- * We assume that the entries in the map are delivered roughly in order.
- * Otherwise, this algorithm could be O(n^2) slow.
- *
- * If unsuccessful an exception is stored.
- */
-static jint
-_jc_debug_line_add(_jc_env *env, _jc_map_state *state,
-	const void *pc, uint32_t cline)
-{
-	int linenum_index;
-	int map_index;
-
-	/* Sanity check */
-	_JC_ASSERT(state->linenum.len > 0);
-
-	/*
-	 * Map C line number into line number table index. We expect
-	 * this line number table index to be close to the last one.
-	 * If it's not in the table, no mapping is needed.
-	 */
-	linenum_index = state->last_linenum;
-	if (cline > state->linenum.table[linenum_index].cline) {
-		while (linenum_index < state->linenum.len - 1
-		    && cline >= state->linenum.table[linenum_index + 1].cline)
-			linenum_index++;
-	} else {
-		while (linenum_index > 0
-		   && cline < state->linenum.table[linenum_index].cline)
-			linenum_index--;
-		if (cline < state->linenum.table[0].cline)
-			return JNI_OK;
-	}
-
-	/*
-	 * Find insertion point for the new entry. We expect it
-	 * to be near the previous insertion point, if any.
-	 */
-	map_index = state->last_map;
-	if (state->pc_map.len == 0) {
-		_JC_ASSERT(map_index == 0);
-		goto insert;
-	}
-	if (pc > state->pc_map.map[map_index].pc) {
-		while (map_index < state->pc_map.len
-		    && pc >= state->pc_map.map[++map_index].pc)
-			;
-	} else {
-		while (map_index > 0 && pc < state->pc_map.map[map_index].pc)
-			map_index--;
-	}
-
-insert:
-	/* Extend PC map to make room for the new entry */
-	if (state->pc_map.len == state->map_alloc) {
-		void *mem;
-
-		state->map_alloc = state->map_alloc * 2 + 32;
-		if ((mem = _jc_vm_realloc(env, state->pc_map.map,
-		    state->map_alloc * sizeof(*state->pc_map.map))) == NULL)
-			return JNI_ERR;
-		state->pc_map.map = mem;
-	}
-
-	/* Shift higher entries up by one to make room */
-	if (map_index < state->pc_map.len) {
-		memmove(state->pc_map.map + map_index + 1,
-		    state->pc_map.map + map_index,
-		    (state->pc_map.len - map_index)
-		      * sizeof(*state->pc_map.map));
-	}
-
-	/* Fill in new entry */
-	state->pc_map.map[map_index].pc = pc;
-	state->pc_map.map[map_index].jline
-	    = state->linenum.table[linenum_index].jline;
-
-	/* Update state */
-	state->last_linenum = linenum_index;
-	state->last_map = map_index;
-	state->pc_map.len++;
-
-	/* Done */
-	return JNI_OK;
-}
-
-/*
- * Finalize a PC map and store it with its method.
- *
- * If unsuccessful an exception is stored.
- */
-static jint
-_jc_debug_line_finish(_jc_env *env, _jc_method *method,
-	_jc_class_loader *loader, _jc_map_state *state)
-{
-	_jc_pc_map_info *const pcmap = &method->u.exec.u.pc_map;
-	int num_dups;
-	int i;
-	int j;
-
-	/* Sanity check */
-	_JC_ASSERT(!_JC_ACC_TEST(method, INTERP));
-
-	/* TODO XXX understand why this happens */
-	if (_JC_ACC_TEST(method, PCMAP))
-		goto done;
-
-	/* Count number of redundant entries */
-	for (num_dups = 0, i = 0; i < state->pc_map.len - 1; i++) {
-		_jc_pc_map *const this = &state->pc_map.map[i];
-		_jc_pc_map *const next = &state->pc_map.map[i + 1];
-
-		_JC_ASSERT(this->pc <= next->pc);
-		if (this->jline == next->jline)
-			num_dups++;
-	}
-
-	/* Allocate memory for compressed PC map */
-	_JC_ASSERT(pcmap->map == NULL);
-	pcmap->len = state->pc_map.len - num_dups;
-	_JC_MUTEX_LOCK(env, loader->mutex);
-	pcmap->map = _jc_cl_alloc(env, loader,
-	    (pcmap->len + 1) * sizeof(*state->pc_map.map));
-	_JC_MUTEX_UNLOCK(env, loader->mutex);
-	if (pcmap->map == NULL)
-		return JNI_ERR;
-
-	/* Copy non-redundant entries */
-	for (i = j = 0; i < state->pc_map.len; j++) {
-		memcpy(&pcmap->map[j],
-		    &state->pc_map.map[i], sizeof(*state->pc_map.map));
-		while (++i < state->pc_map.len
-		    && state->pc_map.map[i].jline
-		      == state->pc_map.map[i - 1].jline);
-	}
-	_JC_ASSERT(j == pcmap->len);
-
-	/* Add terminating entry */
-	pcmap->map[j].pc = method->u.exec.function_end;
-	pcmap->map[j].jline = 0;
-
-#if 0
-    {
-	printf("MAP FOR `%s.%s%s':\n",
-	    method->class->name, method->name, method->signature);
-	for (i = 0; i < pcmap->len; i++) {
-		_jc_pc_map *const map = &pcmap->map[i];
-
-		printf("    [%d] %p -> %d\n", i, map->pc, map->jline);
-	}
-    }
-#endif
-
-done:
-	/* Reset map state */
-	state->pc_map.len = 0;
-	state->last_linenum = 0;
-	state->last_map = 0;
-	state->linenum.len = 0;
-	state->linenum.table = NULL;
-
-	/* Done */
-	method->access_flags |= _JC_ACC_PCMAP;
-	return JNI_OK;
-}
-
-static int
-_jc_method_addr_cmp(const void *v1, const void *v2)
-{
-	_jc_method_node *const node1 = *((_jc_method_node **)v1);
-	_jc_method_node *const node2 = *((_jc_method_node **)v2);
-
-	return (node1->method->function > node2->method->function)
-	    - (node1->method->function < node2->method->function);
-}
-
 

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/definitions.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/definitions.h?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/definitions.h (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/definitions.h Thu Dec  8 07:05:50 2005
@@ -575,12 +575,6 @@
 #define _JC_PAGE_MASK	(_JC_PAGE_SIZE - 1)
 
 /*
- * ELF symbol resolver function type.
- */
-typedef jint	_jc_elf_resolver(_jc_env *env, void *arg,
-			const char *name, Elf_Addr *result);
-
-/*
  * Splay tree node comparision function type.
  */
 typedef int	_jc_splay_cmp_t(const void *item1, const void *item2);
@@ -693,6 +687,9 @@
 									\
 	_JC_ASSERT(_env == NULL || (mutex ## _owner) != _env);		\
 	_r = pthread_mutex_lock(_mutex);				\
+	/* TODO: remove the following two lines... */ \
+	if(_r==EINVAL) fprintf(stdout, "EINVAL\n"); \
+	else if(_r==EDEADLK) fprintf(stdout, "EDEADLK\n"); \
 	_JC_ASSERT(_r == 0);						\
 	(mutex ## _owner) = _env;					\
     } while (0)

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/derive.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/derive.c?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/derive.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/derive.c Thu Dec  8 07:05:50 2005
@@ -15,17 +15,11 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: derive.c,v 1.20 2005/05/10 14:41:38 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
 
-/* Internal functions */
-static jint	_jc_derive_type(_jc_env *env, _jc_type *type,
-			_jc_type_node *node);
-static void	_jc_underive_type(_jc_env *env, _jc_type *type,
-			_jc_type_node *node);
-
 /*
  * List of types that need to be specially recognized during garbage
  * collection in order to handle implicit references. All under java.lang.
@@ -294,322 +288,6 @@
 	/* Done */
 	_JC_ASSERT(type == NULL || _JC_FLG_TEST(type, LOADED));
 	return type;
-}
-
-/*
- * Given an object file, load all the types defined in that file at once.
- *
- * If unsuccessful an exception is stored.
- */
-jint
-_jc_derive_types_from_object(_jc_env *env, _jc_elf *elf)
-{
-	_jc_jvm *const vm = env->vm;
-	const int num_types = elf->types.size;
-	_jc_class_loader *const loader = elf->loader;
-	_jc_type_node *nodes = NULL;
-	_jc_type **types;
-	int i;
-
-	/* Get the list of types defined in this object */
-	if ((types = _JC_STACK_ALLOC(env, num_types * sizeof(*types))) == NULL)
-		return JNI_ERR;
-	_jc_splay_list(&elf->types, (void **)types);
-
-	/* Point types at ELF file and verify object versions */
-	for (i = 0; i < num_types; i++) {
-		_jc_type *const type = types[i];
-
-		type->u.nonarray.u.elf = elf;
-		if (type->u.nonarray.block_size_index != _JC_LIBJC_VERSION) {
-			_JC_EX_STORE(env, LinkageError,
-			    "type `%s' in ELF object `%s' was created from an"
-			    " incompatible `_jc_defs.h' version 0x%04x !="
-			    " 0x%04x", type->name, elf->pathname,
-			    type->u.nonarray.block_size_index,
-			    _JC_LIBJC_VERSION);
-			return JNI_ERR;
-		}
-	}
-
-	/* Lock loader */
-	_JC_MUTEX_LOCK(env, loader->mutex);
-
-	/* Verify that all types defined in the object are not yet loaded */
-	for (i = 0; i < num_types; i++) {
-		_jc_type *const type = types[i];
-		_jc_type *otype;
-
-		if ((otype = _jc_splay_find(&loader->defined_types,
-		    type)) != NULL) {
-			_JC_EX_STORE(env, LinkageError,
-			    "can't load `%s' because it defines the type `%s'"
-			    " which was already defined by the previously"
-			    " loaded object `%s'", elf->pathname, type->name,
-			    otype->u.nonarray.u.elf->pathname);
-			goto fail;
-		}
-	}
-
-	/* Allocate and initialize type nodes */
-	if ((nodes = _jc_cl_alloc(env, loader,
-	    num_types * sizeof(*nodes))) == NULL)
-		goto fail;
-	for (i = 0; i < num_types; i++) {
-		_jc_type_node *const node = &nodes[i];
-
-		/* Initialize node */
-		node->type = types[i];
-		node->thread = NULL;
-#ifndef NDEBUG
-		memset(&node->node, 0, sizeof(node->node));
-#endif
-	}
-
-	/* Derive all types; if something fails, un-do everything */
-	for (i = 0; i < num_types; i++) {
-		_jc_type_node *const node = &nodes[i];
-		_jc_type *const type = types[i];
-
-		if (_jc_derive_type(env, type, node) != JNI_OK) {
-			while (--i > 0)
-				_jc_underive_type(env, types[i], &nodes[i]);
-			goto fail;
-		}
-	}
-
-	/* Unlock loader */
-	_JC_MUTEX_UNLOCK(env, loader->mutex);
-
-	/* Verbosity */
-	if ((vm->verbose_flags & (1 << _JC_VERBOSE_OBJ)) != 0) {
-		if (num_types == 1) {
-			_jc_printf(vm, "[verbose %s: loaded `%s' from `%s']\n",
-			    _jc_verbose_names[_JC_VERBOSE_OBJ], types[0]->name,
-			    elf->pathname);
-		} else {
-			_jc_printf(vm, "[verbose %s: types loaded from `%s':\n",
-			    _jc_verbose_names[_JC_VERBOSE_OBJ], elf->pathname);
-			for (i = 0; i < num_types; i++) {
-				_jc_type *const type = types[i];
-
-				_jc_printf(vm, "\t%s%s\n", type->name,
-				    i == num_types - 1 ? "]" : "");
-			}
-		}
-	}
-
-	/* Done */
-	return JNI_OK;
-
-fail:
-	/* Attempt to give back class loader memory */
-	_jc_cl_unalloc(loader, &nodes, num_types * sizeof(*nodes));
-
-	/* Done */
-	_JC_MUTEX_UNLOCK(env, loader->mutex);
-	return JNI_ERR;
-}
-
-/*
- * Derive a non-array type. This fills in all the runtime field of
- * the _jc_type structure and adds the type to the derived types tree.
- *
- * If unsuccessful an exception is stored.
- *
- * NOTE: This assumes the type's class loader mutex is locked.
- */
-static jint
-_jc_derive_type(_jc_env *env, _jc_type *type, _jc_type_node *node)
-{
-	_jc_jvm *const vm = env->vm;
-	_jc_nonarray_type *const ntype = &type->u.nonarray;
-	_jc_class_loader *const loader = type->loader;
-	_jc_class_node *cnode;
-	int i;
-
-	/* Sanity check */
-	_JC_ASSERT(!_JC_FLG_TEST(type, ARRAY));
-	_JC_ASSERT(!_JC_FLG_TEST(type, LOADED));
-	_JC_MUTEX_ASSERT(env, loader->mutex);
-
-	/*
-	 * Create the java.lang.Class instance for this type, unless during
-	 * initialization when java.lang.Class hasn't been loaded yet.
-	 */
-	if ((vm->initialization == NULL || vm->initialization->create_class)
-	    && _jc_create_class_instance(env, type) != JNI_OK)
-		return JNI_ERR;
-
-	/* Create mtable if needed (i.e., if interpreter is enabled) */
-	if (!_JC_ACC_TEST(type, INTERFACE)
-	    && (!vm->loader_enabled || !vm->generation_enabled)) {
-
-		/* Allocate mtable */
-		if ((ntype->mtable = _jc_cl_alloc(env, loader,
-		    ntype->num_vmethods * sizeof(*ntype->mtable))) == NULL)
-			return JNI_ERR;
-
-		/* Fill in this class' portion */
-		for (i = 0; i < ntype->num_methods; i++) {
-			_jc_method *const method = ntype->methods[i];
-
-			if (_JC_ACC_TEST(method, STATIC)
-			    || *method->name == '<')
-			    	continue;
-			_JC_ASSERT(method->vtable_index < ntype->num_vmethods);
-			_JC_ASSERT(type->vtable[method->vtable_index]
-			    == method->function);
-			ntype->mtable[method->vtable_index] = method;
-		}
-	}
-
-	/* Lock VM */
-	_JC_MUTEX_LOCK(env, vm->mutex);
-
-	/* Add reference to the type's class file in the VM class file tree */
-	if ((cnode = _jc_ref_class_node(env,
-	    type->name, ntype->hash, NULL)) == NULL) {
-		_JC_MUTEX_UNLOCK(env, vm->mutex);
-		goto fail;
-	}
-
-	/* Add reference to all other class files this type depends on */
-	for (i = 0; i < ntype->num_class_depends; i++) {
-		_jc_class_depend *const dep
-		    = &type->u.nonarray.class_depends[i];
-
-		/* Find/create class file node and add reference to it */
-		if (_jc_ref_class_node(env,
-		    dep->name, dep->hash, NULL) != NULL)
-			continue;
-
-		/* Failed; un-reference previously referenced class nodes */
-		_jc_unref_class_deps(vm, ntype->class_depends, i);
-		_jc_unref_class_node(vm, &cnode);
-
-		/* Bail out */
-		_JC_MUTEX_UNLOCK(env, vm->mutex);
-		goto fail;
-	}
-
-	/* Add this class' methods to the VM method tree */
-	for (i = 0; i < ntype->num_methods; i++) {
-		_jc_method *method = ntype->methods[i];
-
-		/* Add method to the method tree if it exists */
-		if (method->function != NULL)
-			_jc_splay_insert(&vm->method_tree, method);
-	}
-
-	/* Unlock VM */
-	_JC_MUTEX_UNLOCK(env, vm->mutex);
-
-	/* Initialize heap block size index skip word flag */
-	if (!_JC_ACC_TEST(type, ABSTRACT))
-		_jc_initialize_bsi(vm, type);
-
-	/* Add node to the loader's initiated types tree */
-	_jc_splay_insert(&loader->initiated_types, node);
-
-	/* Remove type from the ELF file's unloaded types tree */
-	_jc_splay_remove(&ntype->u.elf->types, type);
-
-	/* Add type to the loader's defined types tree */
-	_jc_splay_insert(&loader->defined_types, type);
-
-	/* Point type node at real type */
-	_JC_ASSERT(strcmp(node->type->name, type->name) == 0);
-	node->type = type;
-
-	/* Add reference to ELF file */
-	_jc_elf_addref(ntype->u.elf);
-
-	/* Set type loaded flag */
-	type->flags |= _JC_TYPE_LOADED;
-
-	/* Done */
-	return JNI_OK;
-
-fail:
-	/* Give back Class object memory */
-	if (vm->initialization == NULL || vm->initialization->create_class) {
-		_jc_cl_unalloc(loader, &type->instance,
-		    vm->boot.types.Class->u.nonarray.instance_size);
-	}
-
-	/* Done */
-	return JNI_ERR;
-}
-
-/*
- * Reverse the effects of _jc_derive_type().
- *
- * NOTE: This assumes the type's class loader mutex is locked.
- */
-static void
-_jc_underive_type(_jc_env *env, _jc_type *type, _jc_type_node *node)
-{
-	_jc_jvm *const vm = env->vm;
-	_jc_nonarray_type *const ntype = &type->u.nonarray;
-	_jc_class_loader *const loader = type->loader;
-	_jc_class_node key;
-	_jc_class_node *cnode;
-	int i;
-
-	/* Sanity check */
-	_JC_ASSERT(!_JC_FLG_TEST(type, ARRAY));
-	_JC_ASSERT(_JC_FLG_TEST(type, LOADED));
-	_JC_ASSERT(type->instance != NULL
-	    || (vm->initialization != NULL
-	      && !vm->initialization->create_class));
-	_JC_MUTEX_ASSERT(env, loader->mutex);
-
-	/* Unset type loaded flag */
-	type->flags &= ~_JC_TYPE_LOADED;
-
-	/* Remove type from the loader's defined types tree */
-	_jc_splay_remove(&loader->defined_types, type);
-
-	/* Put type back in ELF file's unloaded types tree */
-	_jc_splay_insert(&ntype->u.elf->types, type);
-
-	/* Remove type node from the loader's initiated types tree */
-	_jc_splay_remove(&loader->initiated_types, node);
-
-	/* Unreference ELF file */
-	_jc_elf_unref(&ntype->u.elf);
-
-	/* Lock VM */
-	_JC_MUTEX_LOCK(env, vm->mutex);
-
-	/* Unreference class file in VM class file tree */
-	key.name = type->name;
-	cnode = _jc_splay_find(&vm->classfiles, &key);
-	_JC_ASSERT(node != NULL);
-	_jc_unref_class_node(vm, &cnode);
-
-	/* Unreference class file dependencies */
-	_jc_unref_class_deps(vm, ntype->class_depends,
-	    ntype->num_class_depends);
-
-	/* Remove class' methods from the VM method tree */
-	for (i = 0; i < ntype->num_methods; i++) {
-		_jc_method *method = ntype->methods[i];
-
-		/* Add method to the method tree if it exists */
-		if (method->function != NULL)
-			_jc_splay_remove(&vm->method_tree, method);
-	}
-
-	/* Unlock VM */
-	_JC_MUTEX_UNLOCK(env, vm->mutex);
-
-	/* Give back java.lang.Class object memory */
-	if (vm->initialization == NULL || vm->initialization->create_class) {
-		_jc_cl_unalloc(loader, &type->instance,
-		    vm->boot.types.Class->u.nonarray.instance_size);
-	}
 }
 
 /*

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_root.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_root.c?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_root.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/gc_root.c Thu Dec  8 07:05:50 2005
@@ -15,15 +15,11 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: gc_root.c,v 1.12 2005/03/20 23:05:31 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
 
-/* Internal definitions */
-#define _JC_NUM_REGISTER_OFFS						\
-	(sizeof(_jc_register_offs) / sizeof(*_jc_register_offs))
-
 /* Internal functions */
 static _jc_object	*_jc_locate_object(_jc_jvm *vm,
 				const _jc_word *info, const void *ptr);
@@ -31,15 +27,10 @@
 				const _jc_word *info, _jc_object ***refsp);
 static int		_jc_root_walk_native_refs(_jc_native_frame_list *list,
 				_jc_object ***refsp);
-static int		_jc_scan_exec_stack(_jc_jvm *vm, _jc_exec_stack *stack,
-				const _jc_word *info, _jc_object ***refsp);
 static int		_jc_scan_interp_stack(_jc_jvm *vm,
 				_jc_interp_stack *stack, const _jc_word *info,
 				_jc_object ***refsp);
 
-/* Internal variables */
-static const int	_jc_register_offs[] = _JC_REGISTER_OFFS;
-
 /*
  * Find the head of the object given a pointer into its interior.
  * This is used for conservative GC scan.
@@ -247,11 +238,8 @@
 	/* Scan each contiguous Java stack segment */
 	for (jstack = thread->java_stack;
 	    jstack != NULL; jstack = jstack->next) {
-		count += jstack->interp ?
-		    _jc_scan_interp_stack(vm,
-		      (_jc_interp_stack *)jstack, info, &refs) :
-		    _jc_scan_exec_stack(vm,
-		      (_jc_exec_stack *)jstack, info, &refs);
+		count += _jc_scan_interp_stack(vm,
+		      (_jc_interp_stack *)jstack, info, &refs);
 	}
 
 	/* Get implicit references from Java methods to their classes */
@@ -327,79 +315,6 @@
 
 		/* Find object pointed to, if any */
 		if ((obj = _jc_locate_object(vm, info, ref)) == NULL)
-			continue;
-
-		/* Add object to list */
-		if (refs != NULL)
-			*refs++ = obj;
-		count++;
-	}
-
-	/* Done */
-	*refsp = refs;
-	return count;
-}
-
-/*
- * Scan a contiguous executable stack chunk.
- */
-static int
-_jc_scan_exec_stack(_jc_jvm *vm, _jc_exec_stack *stack,
-	const _jc_word *info, _jc_object ***refsp)
-{
-	const size_t stack_step = (_JC_STACK_ALIGN < sizeof(void *)) ?
-	    _JC_STACK_ALIGN : sizeof(void *);
-	_jc_object **refs = *refsp;
-	const char *stack_bot = NULL;
-	const char *stack_top = NULL;
-	_jc_stack_crawl crawl;
-	_jc_object *obj;
-	const char *ptr;
-	int count = 0;
-	int regnum;
-
-	/* Get references from saved registers */
-	for (regnum = 0; regnum < _JC_NUM_REGISTER_OFFS; regnum++) {
-
-		/* Find object pointed to by register, if any */
-		if ((obj = _jc_locate_object(vm, info,
-		    *(_jc_word **)((char *)&stack->regs
-		      + _jc_register_offs[regnum]))) == NULL)
-			continue;
-
-		/* Add object to list */
-		if (refs != NULL)
-			*refs++ = obj;
-		count++;
-	}
-
-	/* Compute the top of this Java stack segment */
-	stack_top = _jc_mcontext_sp(&stack->regs);
-
-	/* Find the bottom of this Java stack segment */
-	memset(&crawl, 0, sizeof(crawl));
-	crawl.frame = stack->frame;
-	crawl.pc = stack->pc;
-	while (crawl.method != &vm->invoke_method) {
-		_jc_stack_frame_next(&crawl.frame, &crawl.pc);
-		_jc_stack_crawl_skip(vm, &crawl);
-	}
-	stack_bot = _jc_stack_frame_sp(crawl.frame);
-
-	/* Sanity check stack alignment */
-	_JC_ASSERT(((_jc_word)stack_top & (_JC_STACK_ALIGN - 1)) == 0);
-	_JC_ASSERT(((_jc_word)stack_bot & (_JC_STACK_ALIGN - 1)) == 0);
-
-	/* Conservatively find references in this Java stack segment */
-#if _JC_DOWNWARD_STACK
-	for (ptr = stack_top; ptr < stack_bot; ptr += stack_step)
-#else
-	for (ptr = stack_bot; ptr < stack_top; ptr += stack_step)
-#endif
-	{
-		/* Find object pointed into, if any */
-		if ((obj = _jc_locate_object(vm,
-		    info, *(_jc_word **)ptr)) == NULL)
 			continue;
 
 		/* Add object to list */

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=355107&r1=355106&r2=355107&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 Thu Dec  8 07:05:50 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: libjc.h,v 1.34 2005/11/09 18:14:22 archiecobbs Exp $
+ * $Id$
  */
 
 #ifndef _LIBJC_H_
@@ -45,7 +45,6 @@
 #include <sched.h>
 #include <math.h>
 #include <pwd.h>
-#include <elf.h>
 
 #include <zlib.h>
 
@@ -151,8 +150,6 @@
 extern _jc_type		*_jc_derive_type_from_classfile(_jc_env *env,
 				_jc_class_loader *loader, const char *name,
 				_jc_classbytes *cbytes);
-extern jint		_jc_derive_types_from_object(_jc_env *env,
-				_jc_elf *elf);
 extern _jc_type		*_jc_derive_array_type(_jc_env *env,
 				_jc_class_loader *loader, const char *name);
 extern void		_jc_initialize_lockword(_jc_env *env, _jc_type *type,
@@ -163,20 +160,6 @@
 extern _jc_type		*_jc_derive_type_interp(_jc_env *env,
 				_jc_class_loader *loader,
 				_jc_classbytes *cbytes);
-
-/* elf.c */
-extern _jc_elf		*_jc_elf_load(_jc_env *env, _jc_class_loader *loader,
-				const char *path);
-extern jint		_jc_elf_link(_jc_env *env, _jc_elf *elf,
-				_jc_elf_resolver *resolver, void *arg);
-extern void		_jc_elf_link_cleanup(_jc_elf *elf);
-extern void		_jc_elf_addref(_jc_elf *elf);
-extern void		_jc_elf_unref(_jc_elf **elfp);
-
-/* elf_reloc.c */
-extern jint		_jc_elf_arch_reloc(_jc_env *env, const char *path,
-				char *target_base, Elf_Addr target_offset,
-				Elf_Word type, Elf_Addr value, Elf_Off addend);
 
 /* exception.c */
 extern void		_jc_post_exception_object(_jc_env *env,

Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve.c?rev=355107&r1=355106&r2=355107&view=diff
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve.c (original)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/resolve.c Thu Dec  8 07:05:50 2005
@@ -15,20 +15,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: resolve.c,v 1.18 2005/05/10 17:21:07 archiecobbs Exp $
+ * $Id$
  */
 
 #include "libjc.h"
 
 /* Internal functions */
 static void		_jc_resolve_vtable(_jc_jvm *vm, _jc_type *type);
-static jint		_jc_resolve_exec(_jc_env *env, _jc_type *type,
-				_jc_resolve_info *info);
-static jint		_jc_resolve_java_symbol(_jc_env *env,
-				_jc_resolve_info *info, const char *name,
-				Elf_Addr *result, jboolean *found);
-
-static _jc_elf_resolver	_jc_resolve_symbol;
 
 /* Empty interface method lookup tables */
 const void		*_jc_empty_quick_table[_JC_IMETHOD_HASHSIZE];
@@ -85,11 +78,6 @@
 	    && _jc_prepare_type(env, type) != JNI_OK)
 		goto fail;
 
-	/* For ELF types, resolve type by resolving all ELF symbols */
-	if (!_JC_ACC_TEST(type, INTERP)
-	    && _jc_resolve_exec(env, type, &info) != JNI_OK)
-	    	goto fail;
-
 	/* Ensure superclass and superinterfaces are resolved */
 	if (type->superclass != NULL
 	    && !_JC_FLG_TEST(type->superclass, RESOLVED)
@@ -207,13 +195,8 @@
 				continue;
 
 			/* Override in vtable */
-			if (_JC_ACC_TEST(type, INTERP)) {
-				type->vtable[orm->vtable_index]
-				    = method->function;
-			} else {
-				_JC_ASSERT(type->vtable[orm->vtable_index]
-				    == method->function);
-			}
+			type->vtable[orm->vtable_index]
+				= method->function;
 
 			/* Override in mtable */
 			ntype->mtable[orm->vtable_index] = method;
@@ -222,95 +205,6 @@
 }
 
 /*
- * Resolve a non-interpreted type, i.e., an ELF-loaded type.
- */
-static jint
-_jc_resolve_exec(_jc_env *env, _jc_type *type, _jc_resolve_info *info)
-{
-	_jc_jvm *const vm = env->vm;
-	_jc_class_loader *const loader = type->loader;
-	_jc_elf *const elf = type->u.nonarray.u.elf;
-	jint status;
-
-	/* Sanity check */
-	_JC_ASSERT(!_JC_ACC_TEST(type, INTERP));
-
-	/* Lock loader */
-	_JC_MUTEX_LOCK(env, loader->mutex);
-
-retry:
-	/* Is this type defined in an ELF file that's already resolved? */
-	if (elf->info == NULL) {
-		_JC_MUTEX_UNLOCK(env, loader->mutex);
-		return JNI_OK;
-	}
-
-	/* Is another thread currently resolving this ELF object? */
-	if (elf->info->resolver != NULL) {
-
-		/* If recursively resolving, something wierd is happening */
-		if (elf->info->resolver == env) {
-			_JC_MUTEX_UNLOCK(env, loader->mutex);
-			_jc_post_exception_msg(env, _JC_LinkageError,
-			    "recursively resolving `%s'", elf->pathname);
-			return JNI_ERR;
-		}
-
-		/* Wait for the other thread to finish */
-		_jc_loader_wait(env, loader);
-		goto retry;
-	}
-
-	/* Mark this thread as resolving */
-	elf->info->resolver = env;
-
-	/* Unlock loader */
-	_JC_MUTEX_UNLOCK(env, loader->mutex);
-
-	/* Verbosity */
-	if (loader == vm->boot.loader) {
-		VERBOSE(RESOLUTION, vm,
-		    "resolving `%s' (via bootstrap loader)", type->name);
-	} else {
-		VERBOSE(RESOLUTION, vm,
-		    "resolving `%s' (via %s@%p)", type->name,
-		    loader->instance->type->name, loader->instance);
-	}
-
-	/*
-	 * Resolve all external symbols in the ELF image. As we resolve
-	 * symbols that refer to other types, update the list of implicit
-	 * references from this type to other types.
-	 */
-	status = _jc_elf_link(env, elf, _jc_resolve_symbol, info);
-
-	/* Lock loader */
-	_JC_MUTEX_LOCK(env, loader->mutex);
-
-	/* Mark this thread as no longer resolving */
-	_JC_ASSERT(elf->info->resolver == env);
-	elf->info->resolver = NULL;
-
-	/* Free ELF linking info; this signals that the ELF file is resolved */
-	if (status == JNI_OK) {
-		_jc_elf_link_cleanup(elf);
-		_JC_ASSERT(elf->info == NULL);
-	}
-
-	/* Wake up other threads waiting on us */
-	if (loader->waiters) {
-		loader->waiters = JNI_FALSE;
-		_JC_COND_BROADCAST(loader->cond);
-	}
-
-	/* Unlock loader */
-	_JC_MUTEX_UNLOCK(env, loader->mutex);
-
-	/* Done */
-	return status;
-}
-
-/*
  * Resolve a field per JVMS section 5.4.3.2.
  * Note the static-ness of the field is not checked.
  *
@@ -405,399 +299,6 @@
 
 	/* Not found */
 	return NULL;
-}
-
-/*
- * Resolve an unresolved external reference in an ELF file.
- *
- * This function is used as a callback from the ELF linker code.
- */
-static jint
-_jc_resolve_symbol(_jc_env *env, void *arg, const char *name, Elf_Addr *result)
-{
-	_jc_jvm *const vm = env->vm;
-	_jc_resolve_info *const info = arg;
-	_jc_native_lib *lib;
-	const void *func;
-	jboolean found;
-
-	/* If not a symbol we know about? */
-	if (strncmp(name, "_jc_", 4) != 0)
-		goto search_external;
-
-	/* Handle "_jc_check_address" */
-	if (strcmp(name, "_jc_check_address") == 0) {
-		*result = (Elf_Addr)vm->check_address;
-		return JNI_OK;
-	}
-
-	/* Handle empty interface method tables */
-	if (strcmp(name, "_jc_empty_quick_table") == 0) {
-		*result = (Elf_Addr)_jc_empty_quick_table;
-		return JNI_OK;
-	}
-	if (strcmp(name, "_jc_empty_imethod_table") == 0) {
-		*result = (Elf_Addr)_jc_empty_imethod_table;
-		return JNI_OK;
-	}
-
-	/* Search C support functions, which all have "_jc_cs_" prefix */
-	if (strncmp(name, "_jc_cs_", 7) == 0) {
-		if ((func = dlsym(NULL, name)) != NULL) {
-			*result = (Elf_Addr)func;
-			return JNI_OK;
-		}
-	}
-
-	/* Try to parse a Java type, method, etc. symbol */
-	if (_jc_resolve_java_symbol(env, info, name, result, &found) != JNI_OK)
-		return JNI_ERR;
-	if (found)
-		return JNI_OK;
-
-	/*
-	 * If symbol started with "_jc_" but was not found, then
-	 * generate an error. Alternately, we could try to search
-	 * for it in external libraries, but that is likely to not
-	 * be correct and means a less clear namespace separation.
-	 */
-	goto not_found;
-
-search_external:
-	/*
-	 * If we get here, the symbol is not a Java symbol.
-	 * Search for it first in the shared libraries associated with
-	 * the class loader, then in the shared C libraries that are
-	 * loaded on behalf of this process by the normal runtime linker.
-	 */
-
-	/* Search the loader's shared libraries */
-	STAILQ_FOREACH(lib, &info->loader->native_libs, link) {
-		if ((func = dlsym(lib->handle, name)) != NULL) {
-			*result = (Elf_Addr)func;
-			return JNI_OK;
-		}
-	}
-
-	/* Search normally loaded shared libraries */
-	if ((func = dlsym(RTLD_DEFAULT, name)) != NULL) {
-		*result = (Elf_Addr)func;
-		return JNI_OK;
-	}
-
-#ifdef __linux__
-    {
-    	static void *kludge;
-
-	/* Stupid Linux. dlsym() won't retrieve GCC helper functions */
-	if ((kludge != NULL
-	      || (kludge = dlopen("/lib/libgcc_s.so.1", RTLD_NOW)) != NULL)
-	    && (func = dlsym(kludge, name)) != NULL) {
-		*result = (Elf_Addr)func;
-		return JNI_OK;
-	}
-    }
-#endif
-
-not_found:
-	/* Symbol not found */
-	_jc_post_exception_msg(env, _JC_LinkageError,
-	    "can't resolve symbol `%s' in ELF object `%s'",
-	    name, info->type->u.nonarray.u.elf->pathname);
-	return JNI_ERR;
-}
-
-/*
- * Resolve a symbol that refers to a Java type, method, etc.
- *
- * Sets *found to true or false depending on the outcome.
- * If not found, *result will not be modified and JNI_OK
- * is returned.
- *
- * An error is returned only if an exception is thrown.
- */
-static jint
-_jc_resolve_java_symbol(_jc_env *env, _jc_resolve_info *info,
-	const char *name, Elf_Addr *result, jboolean *found)
-{
-	_jc_jvm *const vm = env->vm;
-	int ptype = _JC_TYPE_INVALID;
-	char *class_name;
-	const char *s;
-	_jc_type *type;
-	int dims = 0;
-	char *p;
-	int i;
-
-	/* Find dollar sign */
-	if (strncmp(name, "_jc_", 4) != 0)
-		goto unknown;
-	name += 4;
-	if ((s = strchr(name, '$')) == NULL)
-		goto unknown;
-	s++;
-
-	/* Check for an array type and get dimensions if so */
-	if (strncmp(s, "array", 5) == 0) {
-		s += 5;
-		for (i = 0; i < 3; i++) {
-			if (!isdigit(s[i]))
-				break;
-			if (dims == 0 && s[i] == '0')
-				break;
-			dims = dims * 10 + (s[i] - '0');
-			if (dims < 0 || dims > 255)
-				goto unknown;
-		}
-		if (dims == 0)		/* "$array$x" abbreviates "$array1$x" */
-			dims = 1;
-		if (s[i] != '$')
-			goto unknown;
-		s += i + 1;
-	}
-
-	/* Check for a primitive base type */
-	if (strncmp(s, "prim$", 5) == 0) {
-		s += 5;				/* advance past the "prim$" */
-		switch (*name) {
-		case 'b':			/* boolean or byte */
-			if (strncmp(name, "boolean$", 8) == 0)
-				ptype = _JC_TYPE_BOOLEAN;
-			else if (strncmp(name, "byte$", 5) == 0)
-				ptype = _JC_TYPE_BYTE;
-			break;
-		case 'c':			/* char */
-			if (strncmp(name, "char$", 5) == 0)
-				ptype = _JC_TYPE_CHAR;
-			break;
-		case 's':			/* short */
-			if (strncmp(name, "short$", 6) == 0)
-				ptype = _JC_TYPE_SHORT;
-			break;
-		case 'i':			/* int */
-			if (strncmp(name, "int$", 4) == 0)
-				ptype = _JC_TYPE_INT;
-			break;
-		case 'l':			/* long */
-			if (strncmp(name, "long$", 5) == 0)
-				ptype = _JC_TYPE_LONG;
-			break;
-		case 'f':			/* float */
-			if (strncmp(name, "float$", 6) == 0)
-				ptype = _JC_TYPE_FLOAT;
-			break;
-		case 'd':			/* double */
-			if (strncmp(name, "double$", 7) == 0)
-				ptype = _JC_TYPE_DOUBLE;
-			break;
-		case 'v':			/* void */
-			if (strncmp(name, "void$", 5) == 0)
-				ptype = _JC_TYPE_VOID;
-			break;
-		default:
-			break;
-		}
-
-		/* Bail out if none matched */
-		if (ptype == _JC_TYPE_INVALID)
-			goto unknown;
-
-		/* Handle zero and one dimensional types directly */
-		switch (dims) {
-		case 0:
-			type = vm->boot.types.prim[ptype];
-			goto got_type;
-		case 1:
-			if (ptype == _JC_TYPE_VOID)
-				goto unknown;		/* no void[] type */
-			type = vm->boot.types.prim_array[ptype];
-			goto got_type;
-		default:
-			break;
-		}
-
-		/* Generate multi-dimensional array type name */
-		if ((class_name = _JC_STACK_ALLOC(env, dims + 2)) == NULL) {
-			_jc_post_exception_info(env);
-			return JNI_ERR;
-		}
-		memset(class_name, '[', dims);
-		class_name[dims] = _jc_prim_chars[ptype];
-		class_name[dims + 1] = '\0';
-		goto resolve_type;
-	}
-
-	/* Generate (possibly array) type name */
-	if ((class_name = _JC_STACK_ALLOC(env,
-	    dims + (s - name) + 3)) == NULL) {
-		_jc_post_exception_info(env);
-		return JNI_ERR;
-	}
-	p = class_name;
-	if (dims > 0) {
-		memset(p, '[', dims);
-		p += dims;
-		*p++ = 'L';
-	}
-	if ((p = _jc_name_decode(name, p)) == NULL)
-		goto unknown;
-	if (dims > 0)
-		*p++ = ';';
-	*p = '\0';
-
-resolve_type:
-	/*
-	 * Resolve the type. If we can't, but "jc.ignore.resolution.failures"
-	 * is set to true, then ignore the failure and just return zero.
-	 */
-	if ((type = _jc_load_type(env, info->loader, class_name)) == NULL) {
-		if (vm->ignore_resolution_failures
-		    && _jc_unpost_exception(env, _JC_LinkageError)) {
-			*result = (Elf_Addr)0;
-			goto found;
-		}
-		return JNI_ERR;
-	}
-
-got_type:
-	/* Sanity check */
-	_JC_ASSERT(type->instance != NULL);
-
-	/* Add a reference to the resolved type's class loader */
-	if (_jc_resolve_add_loader_ref(env, info, type->loader) != JNI_OK) {
-		_jc_post_exception_info(env);
-		return JNI_ERR;
-	}
-
-	/* Is just the type needed? */
-	if (strcmp(s, "type") == 0) {
-		*result = (Elf_Addr)type;
-		goto found;
-	}
-
-	/* Is the type's Class instance needed? */
-	if (strcmp(s, "class_object") == 0) {
-		*result = (Elf_Addr)type->instance;
-		_JC_ASSERT(*result != 0);
-		goto found;
-	}
-
-	/* Is the type's static fields structure needed? */
-	if (strcmp(s, "class_fields") == 0) {
-		if (_JC_FLG_TEST(type, ARRAY)
-		    || type->u.nonarray.class_fields == NULL)
-			goto unknown;
-		*result = (Elf_Addr)type->u.nonarray.class_fields;
-		_JC_ASSERT(*result != 0);
-		goto found;
-	}
-
-	/* Is one of the type's methods or method info structures needed? */
-	if (strncmp(s, "method$", 7) == 0
-	    || strncmp(s, "method_info$", 12) == 0) {
-		const int is_info = (s[6] == '_');
-		size_t name_len;
-		jlong sig_hash;
-		char *buf;
-
-		/* Sanity check */
-		if (_JC_FLG_TEST(type, ARRAY))
-			goto unknown;
-
-		/* Parse out and decode method name */
-		name = s + (is_info ? 12 : 7);
-		if ((s = strchr(name, '$')) == NULL)
-			goto unknown;
-		name_len = s - name;
-		s++;
-		if (strncmp(name, "_init", 5) == 0)
-			name = "<init>";
-		else if (strncmp(name, "_clinit", 7) == 0)
-			name = "<clinit>";
-		else {
-			if ((buf = _JC_STACK_ALLOC(env,
-			    name_len + 1)) == NULL) {
-				_jc_post_exception_info(env);
-				return JNI_ERR;
-			}
-			if (_jc_name_decode(name, buf) == NULL)
-				goto unknown;
-			name = buf;
-		}
-
-		/* Parse out method signature hash */
-		for (sig_hash = 0, i = 0; i < 16 && s[i] != '\0'; i++) {
-			if (!isxdigit(s[i]))
-				goto unknown;
-			sig_hash = (sig_hash << 4) | _JC_HEXVAL(s[i]);
-		}
-
-		/* Intpreted types must be resolved here */
-		if (_JC_ACC_TEST(type, INTERP)
-		    && _jc_resolve_type(env, type) != JNI_OK)
-			return JNI_ERR;
-
-		/* Search for method */
-		for (i = 0; i < type->u.nonarray.num_methods; i++) {
-			_jc_method *const method = type->u.nonarray.methods[i];
-
-			/* Is this the method? */
-			if (method->signature_hash != sig_hash
-			    || strcmp(method->name, name) != 0)
-				continue;
-
-			/* Return method info if desired */
-			if (is_info) {
-				*result = (Elf_Addr)method;
-				_JC_ASSERT(*result != 0);
-				goto found;
-			}
-
-			/*
-			 * If method is native, JCNI, and resolved,
-			 * optimize by linking directly to it if enabled.
-			 */
-			if (_JC_ACC_TEST(method, NATIVE)
-			    && vm->resolve_native_directly) {
-
-				/* Resolve native method if not already */
-				if (method->native_function == NULL) {
-					if (_jc_resolve_native_method(env,
-					      method) != JNI_OK
-					    && !_jc_unpost_exception(env,
-					      _JC_UnsatisfiedLinkError))
-						return JNI_ERR;
-				}
-
-				/* Method must be resolved and a JCNI method */
-				if (method->native_function != NULL
-				    && _JC_ACC_TEST(method, JCNI)) {
-					*result = (Elf_Addr)
-					    method->native_function;
-					_JC_ASSERT(*result != 0);
-					goto found;
-				}
-			}
-
-			/* Resolve normally to method's C function */
-			*result = (Elf_Addr)method->function;
-			_JC_ASSERT(*result != 0);
-			goto found;
-		}
-
-		/* Not found */
-		goto unknown;
-	}
-
-unknown:
-	/* Not a recognized symbol */
-	*found = JNI_FALSE;
-	return JNI_OK;
-
-found:
-	/* Found it */
-	*found = JNI_TRUE;
-	return JNI_OK;
 }
 
 /*

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=355107&r1=355106&r2=355107&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 Thu Dec  8 07:05:50 2005
@@ -15,7 +15,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *
- * $Id: structures.h,v 1.37 2005/11/09 18:14:22 archiecobbs Exp $
+ * $Id$
  */
 
 #ifndef _STRUCTURES_H_
@@ -98,56 +98,6 @@
  *			ELF file structures				*
  ************************************************************************/
 
-/* This describes a loadable section within an ELF object */
-struct _jc_elf_loadable {
-	const char		*name;		/* name of section */
-	const Elf_Shdr		*shdr;		/* section header */
-	const Elf_Shdr		*rel;		/* normal relocations section */
-	const Elf_Shdr		*rela;		/* addend relocations section */
-	const char		*bytes;		/* start of section in file */
-	char			*vaddr;		/* start of loaded section */
-	Elf_Off			offset;		/* offset of loaded section */
-};
-
-/* This describes the ELF debug section containing line number info */
-struct _jc_elf_debug_lines {
-	u_char			type;		/* _JC_LINE_DEBUG_* */
-	const char		*strings;	/* associated string section */
-	_jc_elf_loadable	loadable;	/* loading info */
-};
-
-/*
- * Linking and symbol information associated with an ELF object.
- * This information is only needed for loading and linking.
- */
-struct _jc_elf_info {
-	char			*map_base;	/* base of mmap() region */
-	size_t			map_size;	/* size of mmap() region */
-	const Elf_Ehdr		*ehdr;		/* ELF header (=map_base) */
-	const Elf_Shdr		*shdrs;		/* section headers */
-	int			num_symbols;	/* number of symbols */
-	const Elf_Sym		*symbols;	/* symbols */
-	int			num_loadables;	/* number loadable sections */
-	_jc_elf_loadable	*loadables;	/* loadable sections */
-	_jc_elf_loadable	**shdr2section;	/* maps shdr index -> section */
-	const char		*strings;	/* strings in string table */
-	_jc_env			*resolver;	/* currently resolving thread */
-	_jc_elf_debug_lines	debug_lines;	/* ELF debug line info */
-};
-
-/*
- * Information associated with a loaded ELF object.
- */
-struct _jc_elf {
-	_jc_elf_info		*info;		/* transient linking info */
-	_jc_class_loader	*loader;	/* loader who loaded me */
-	char			*vaddr;		/* load address of object */
-	Elf_Off			vsize;		/* size of loaded object */
-	_jc_splay_tree		types;		/* types defined in file */
-	volatile _jc_word	refs;		/* number of references */
-	char			pathname[0];	/* original file pathname */
-};
-
 /* One entry in the object file search path */
 struct _jc_objpath_entry {
 	int			type;		/* _JC_OBJPATH_* */
@@ -197,15 +147,6 @@
 	int			last_map;
 	_jc_linenum_info	linenum;
 	_jc_pc_map_info		pc_map;
-};
-
-/* ELF stabs entry format */
-struct _jc_stab {
-	uint32_t	sindex;
-	u_char		type;
-	u_char		misc;
-	uint16_t	desc;
-	Elf_Addr	value;
 };
 
 /* DWARF line program header */



Mime
View raw message