harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dtan...@apache.org
Subject svn commit: r355115 - in /incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc: ./ Makefile.am arch_functions.c ppc_definitions.h ppc_libjc.h ppc_structures.h
Date Thu, 08 Dec 2005 15:13:42 GMT
Author: dtanzer
Date: Thu Dec  8 07:13:26 2005
New Revision: 355115

URL: http://svn.apache.org/viewcvs?rev=355115&view=rev
Log:
I added a direcotry for ppc specific stuff.

ppc_definitions.h: Added file. This file includes architecture specific definitions for the
    power pc.
    For _JC_REGISTER_OFFS I used the same definitions as in i386_definitions.h
    where used for FreeBSD, I'm not sure if this is really the right way...

ppc_libjc.h: Added file. Again I copied the content from the i386-specific file and took
    the FreeBSD section where OS-specific things were done. I'm not sure if this
    is correct. To be compile-clean I left some functions unimplemented here for
    the moment. They just print a warning statement to stderr and then exit(0).

ppc_functions.c: Added file. I used the parts from libjc/arch/i386/arch_functions.c where
    !defined(_JC_I386_REG_PARAM) as a starting point.


Added:
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/Makefile.am
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_definitions.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_libjc.h
    incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_structures.h

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/Makefile.am
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/Makefile.am?rev=355115&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/Makefile.am
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/Makefile.am
Thu Dec  8 07:13:26 2005
@@ -0,0 +1,5 @@
+noinst_HEADERS=		arch_functions.c \
+			ppc_definitions.h \
+			ppc_libjc.h \
+			ppc_structures.h
+

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c?rev=355115&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/arch_functions.c
Thu Dec  8 07:13:26 2005
@@ -0,0 +1,268 @@
+
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+#include "libjc.h"
+
+int
+_jc_build_trampoline(u_char *code, _jc_method *method, const void *func)
+{
+	u_char buf[100 + 14 * method->num_parameters];
+	u_char *pc;
+
+	/* Sanity check */
+	_JC_ASSERT(_JC_OFFSETOF(_jc_env, interp) < 0x80);
+
+	/* Handle length only computation */
+	if (code == NULL)
+		code = buf;
+	pc = code;
+
+    {
+    	u_char ptypebuf[2];
+	u_char offsets[4];
+	u_char isfloat[3];
+    	const u_char *ptypes;
+	int nparams2;
+	int nparams;
+	int offset;
+	int pnum;
+
+	/* Count total number of parameter words */
+	nparams2 = 1;						/* "env" */
+	if (!_JC_ACC_TEST(method, STATIC))
+		nparams2++;					/* "this" */
+	nparams2 += method->num_parameters;
+	for (pnum = 0; pnum < method->num_parameters; pnum++) {
+		if (_jc_dword_type[method->param_ptypes[pnum]])
+			nparams2++;
+	}
+
+	/* Get types of parameter words 1 and 2 (we know type for 0, "env") */
+	if (_JC_ACC_TEST(method, STATIC)) {
+		ptypes = method->param_ptypes;
+		nparams = method->num_parameters;
+	} else {
+		ptypebuf[0] = _JC_TYPE_REFERENCE;	/* this */
+		ptypebuf[1] = method->param_ptypes[0];	/* first parameter */
+		ptypes = ptypebuf;
+		nparams = method->num_parameters + 1;
+	}
+
+	/* Prologue */
+	*pc++ = 0x55;				/* push %ebp */
+	*pc++ = 0x89;				/* mov %esp,%ebp */
+	*pc++ = 0xe5;
+
+	/* Calculate offsets to parameter words not passed in registers */
+	memset(&offsets, 0, sizeof(offsets));
+	memset(&isfloat, 0, sizeof(isfloat));
+	offset = 2;				/* skip %ebp, return address */
+	if (nparams >= 1) {
+		switch (ptypes[0]) {
+		case _JC_TYPE_DOUBLE:
+			offsets[1] = offset++;
+			offsets[2] = offset++;
+			break;
+		case _JC_TYPE_FLOAT:
+			offsets[1] = offset++;
+			isfloat[1] = JNI_TRUE;
+			if (nparams >= 2) {
+				switch (ptypes[1]) {
+				case _JC_TYPE_DOUBLE:
+				case _JC_TYPE_LONG:
+					offsets[2] = offset++;
+					break;
+				case _JC_TYPE_FLOAT:
+					offsets[2] = offset++;
+					isfloat[2] = JNI_TRUE;
+					break;
+				default:
+					break;
+				}
+			}
+			break;
+		case _JC_TYPE_LONG:
+			break;
+		default:
+			if (nparams >= 2) {
+				switch (ptypes[1]) {
+				case _JC_TYPE_DOUBLE:
+				case _JC_TYPE_LONG:
+					offsets[2] = offset++;
+					break;
+				case _JC_TYPE_FLOAT:
+					offsets[2] = offset++;
+					isfloat[2] = JNI_TRUE;
+					break;
+				default:
+					break;
+				}
+			}
+			break;
+		}
+		offsets[3] = offset++;
+	}
+
+	/* Copy 4th and later parameter words into parameter array */
+	if (nparams2 >= 4) {
+		int pword;
+
+		/* Save %eax */
+		*pc++ = 0x50;		/* push %eax */
+
+		/* Copy 4th and later parameter words */
+		offset = (offsets[3] + (nparams2 - 4)) * 4;
+		pnum = method->num_parameters - 1;
+		if (_jc_dword_type[method->param_ptypes[pnum]])
+			pnum = -pnum;
+		for (pword = nparams2 - 1; pword >= 3; pword--, offset -= 4) {
+
+			/* Load parameter word from stack and then push it */
+			if (pnum >= 0
+			    && method->param_ptypes[pnum] == _JC_TYPE_FLOAT) {
+
+				/* Load float */
+				if (offset < 0x80) {
+					/* flds 0xOFFSET(%ebp) */
+					*pc++ = 0xd9;
+					*pc++ = 0x45;
+					*pc++ = offset;
+				} else {
+					/* flds 0xOFFSET(%ebp) */
+					*pc++ = 0xd9;
+					*pc++ = 0x85;
+					memcpy(pc, &offset, 4);
+					pc += 4;
+				}
+
+				/* Push double */
+				*pc++ = 0x83;		/* sub 0x8,%esp */
+				*pc++ = 0xec;
+				*pc++ = 0x8;
+				*pc++ = 0xdd;		/* fstpl (%esp,1) */
+				*pc++ = 0x1c;
+				*pc++ = 0x24;
+			} else {
+				if (offset < 0x80) {
+					/* mov 0xOFFSET(%ebp),%eax */
+					*pc++ = 0x8b;
+					*pc++ = 0x45;
+					*pc++ = offset;
+				} else {
+					/* mov 0xOFFSET(%ebp),%eax */
+					*pc++ = 0x8b;
+					*pc++ = 0x85;
+					memcpy(pc, &offset, 4);
+					pc += 4;
+				}
+				*pc++ = 0x50;		/* push %eax */
+			}
+
+			/* Keep track of corresponding parameter index */
+			if (pnum < 0)	/* was second word of long/double */
+				pnum = -pnum;
+			else if (_jc_dword_type[method->param_ptypes[--pnum]])
+				pnum = -pnum;
+		}
+
+		/* Restore %eax */
+		*pc++ = 0x8b;		/* mov -4(%ebp),%eax */
+		*pc++ = 0x45;
+		*pc++ = 0xfc;
+	}
+
+	/* Recall 3rd parameter word from stack (if necessary) and push */
+	if (nparams2 >= 3) {
+		if (isfloat[2]) {
+			*pc++ = 0xd9;		/* flds 0xNN(%ebp) */
+			*pc++ = 0x45;
+			*pc++ = offsets[2] * 4;
+			*pc++ = 0x83;		/* sub 0x8,%esp */
+			*pc++ = 0xec;
+			*pc++ = 0x8;
+			*pc++ = 0xdd;		/* fstpl (%esp,1) */
+			*pc++ = 0x1c;
+			*pc++ = 0x24;
+		} else {
+			if (offsets[2] > 0) {
+				*pc++ = 0x8b;	/* mov 0xNN(%ebp),%ecx */
+				*pc++ = 0x4d;
+				*pc++ = offsets[2] * 4;
+			}
+			*pc++ = 0x51;		/* push %ecx */
+		}
+	}
+
+	/* Recall 2nd parameter word from stack (if necessary) and push */
+	if (nparams2 >= 2) {
+		if (isfloat[1]) {
+			*pc++ = 0xd9;		/* flds 0xNN(%ebp) */
+			*pc++ = 0x45;
+			*pc++ = offsets[1] * 4;
+			*pc++ = 0x83;		/* sub 0x8,%esp */
+			*pc++ = 0xec;
+			*pc++ = 0x8;
+			*pc++ = 0xdd;		/* fstpl (%esp,1) */
+			*pc++ = 0x1c;
+			*pc++ = 0x24;
+		} else {
+			if (offsets[1] > 0) {
+				*pc++ = 0x8b;	/* mov 0xNN(%ebp),%edx */
+				*pc++ = 0x55;
+				*pc++ = offsets[1] * 4;
+			}
+			*pc++ = 0x52;		/* push %edx */
+		}
+	}
+
+	/* Push "env" (first parameter) onto the stack */
+	*pc++ = 0x50;				/* push %eax */
+
+	/* Set env->interp = method */
+	*pc++ = 0xc7;				/* mov METHOD,OFFSET(%eax) */
+	*pc++ = 0x40;
+	*pc++ = _JC_OFFSETOF(_jc_env, interp);
+	memcpy(pc, &method, 4);
+	pc += 4;
+
+	/* Call function */
+	*pc++ = 0xe8;				/* call func */
+	func = (void *)((jint)func - (jint)(pc + 4));
+	memcpy(pc, &func, 4);
+	pc += 4;
+
+	/* Epilogue */
+	*pc++ = 0xc9;				/* leave */
+	*pc++ = 0xc3;				/* ret */
+    }
+
+	/* Done */
+	return pc - code;
+}
+
+#include <stdio.h>
+
+void
+_jc_dynamic_invoke(const void *func, int jcni, int nparams,
+	const u_char *ptypes, int nwords, _jc_word *words, _jc_value *retval)
+{
+	fprintf(stdout, "WARNING: Call to unimplemented function _jc_dynamic_invoke(...).\n");
+	exit(0);
+}
+

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_definitions.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_definitions.h?rev=355115&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_definitions.h
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_definitions.h
Thu Dec  8 07:13:26 2005
@@ -0,0 +1,52 @@
+
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+#ifndef _ARCH_PPC_DEFINITIONS_H_
+#define _ARCH_PPC_DEFINITIONS_H_
+
+#if !defined(__ppc__)
+#error "This include file is for the ppc architecture only"
+#endif
+
+#define	_JC_PAGE_SHIFT		12		/* 4096 byte pages */
+
+#define _JC_STACK_ALIGN		2
+
+#define _JC_BIG_ENDIAN		1
+
+#define	_JC_REGISTER_OFFS	{					\
+	_JC_OFFSETOF(mcontext_t, mc_gs),				\
+	_JC_OFFSETOF(mcontext_t, mc_fs),				\
+	_JC_OFFSETOF(mcontext_t, mc_es),				\
+	_JC_OFFSETOF(mcontext_t, mc_ds),				\
+	_JC_OFFSETOF(mcontext_t, mc_edi),				\
+	_JC_OFFSETOF(mcontext_t, mc_esi),				\
+	_JC_OFFSETOF(mcontext_t, mc_ebp),				\
+	_JC_OFFSETOF(mcontext_t, mc_isp),				\
+	_JC_OFFSETOF(mcontext_t, mc_ebx),				\
+	_JC_OFFSETOF(mcontext_t, mc_edx),				\
+	_JC_OFFSETOF(mcontext_t, mc_ecx),				\
+	_JC_OFFSETOF(mcontext_t, mc_eax),				\
+	_JC_OFFSETOF(mcontext_t, mc_cs),				\
+	_JC_OFFSETOF(mcontext_t, mc_esp),				\
+	_JC_OFFSETOF(mcontext_t, mc_ss),				\
+    }
+
+#endif	/* _ARCH_PPC_DEFINITIONS_H_ */
+

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_libjc.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_libjc.h?rev=355115&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_libjc.h
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_libjc.h
Thu Dec  8 07:13:26 2005
@@ -0,0 +1,144 @@
+
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+#ifndef _ARCH_PPC_LIBJC_H_
+#define _ARCH_PPC_LIBJC_H_
+
+#ifndef __ppc__
+#error "This header file is meant for the PPC architecture only."
+#endif /* __ppc__ */
+
+/* stdio.h included to print warning outputs in the stub functions which return
+ * NULL for the moment... 
+ */
+#include <stdio.h>
+
+/*
+ * Architecture-specific functions for ppc architecture.
+ */
+
+/**
+ * @todo Left unimplemented for the moment.
+ */
+extern inline int
+_jc_compare_and_swap(volatile _jc_word *word, _jc_word old, _jc_word new)
+{
+	if (*word == old) {
+		*word = new;
+		return JNI_TRUE;
+	} else {
+		return JNI_FALSE;
+	}
+}
+
+/**
+ * @todo Is there nothing todo on the ppc too?
+ */
+extern inline void
+_jc_iflush(const void *mem, size_t len)
+{
+	/* From the original header file: "nothing to do: i386 has coherent data and
+	 * instruction caches"
+	 */
+}
+
+extern inline void
+_jc_stack_frame_init(_jc_stack_frame *framep)
+{
+	*framep = NULL;
+}
+
+#define _jc_stack_frame_current(framep)					\
+    do {								\
+	*(framep) = __builtin_frame_address(0);				\
+    } while (0)
+
+extern inline void
+_jc_stack_frame_next(_jc_stack_frame *framep, const void **pcp)
+{
+	_jc_word *const ebp = *framep;
+
+	*pcp = (const void *)ebp[1];	/* saved %eip is one slot above %ebp */
+	*framep = (_jc_word *)ebp[0];	/* %ebp points to saved %ebp */
+}
+
+extern inline jboolean
+_jc_stack_frame_valid(_jc_stack_frame frame)
+{
+	return frame != NULL;
+}
+
+extern inline jboolean
+_jc_stack_frame_equal(_jc_stack_frame frame1, _jc_stack_frame frame2)
+{
+	return frame1 == frame2;
+}
+
+extern inline const void *
+_jc_stack_frame_sp(_jc_stack_frame frame)
+{
+	return (const void *)frame;
+}
+
+/**
+ * @todo Returning NULL to be compile-clean for the moment.
+ */
+extern inline const void *
+_jc_mcontext_sp(const mcontext_t *mctx)
+{
+	fprintf(stderr, "WARNING: call to unimplemented function _jc_mcontext_sp(...)\n");
+	exit(0);
+	return (const void *) NULL;
+}
+
+/**
+ * @todo Returning NULL to be compile-clean for the moment.
+ */
+extern inline const void *
+_jc_mcontext_pc(const mcontext_t *mctx)
+{
+	fprintf(stderr, "WARNING: call to unimplemented function _jc_mcontext_pc(...)\n");
+	exit(0);
+	return (const void *) NULL;
+}
+
+/**
+ * @todo Returning NULL to be compile-clean for the moment.
+ */
+extern inline _jc_stack_frame
+_jc_mcontext_frame(const mcontext_t *mctx)
+{
+	fprintf(stderr, "WARNING: call to unimplemented function _jc_mcontext_frame(...)\n");
+	exit(0);
+	return (_jc_word *) NULL;
+}
+
+/**
+ * @todo Returning NULL to be compile-clean for the moment.
+ */
+extern inline const void *
+_jc_signal_fault_address(int sig_num, siginfo_t *info, ucontext_t *uctx)
+{
+	fprintf(stderr, "WARNING: call to unimplemented function _jc_signal_falut_address(...)\n");
+	exit(0);
+	return (const void *) NULL;
+}
+
+#endif	/* _ARCH_PPC_LIBJC_H_ */
+

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_structures.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_structures.h?rev=355115&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_structures.h
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/jchevm/jchevm/libjc/arch/ppc/ppc_structures.h
Thu Dec  8 07:13:26 2005
@@ -0,0 +1,26 @@
+
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+#ifndef _ARCH_PPC_STRUCTURES_H_
+#define _ARCH_PPC_STRUCTURES_H_
+
+typedef _jc_word	*_jc_stack_frame;	/* pointer to saved %epb */
+
+#endif	/* _ARCH_PPC_STRUCTURES_H_ */
+



Mime
View raw message