diff --git a/build.xml b/build.xml
index cdcdca2c5..b42eba51e 100644
--- a/build.xml
+++ b/build.xml
@@ -1555,22 +1555,13 @@ Check to make sure all required properties are specified. This includes properti
-
-
-
+
-
-
-
-
-
-
-
-
+
@@ -1582,7 +1573,7 @@ Check to make sure all required properties are specified. This includes properti
-
+
@@ -1612,7 +1603,7 @@ Check to make sure all required properties are specified. This includes properti
-
+
diff --git a/rvm/src/org/jikesrvm/tools/header_gen/GenArch_ppc.java b/rvm/src/org/jikesrvm/tools/header_gen/GenArch_ppc.java
index 86c8edc39..9b3f0d129 100644
--- a/rvm/src/org/jikesrvm/tools/header_gen/GenArch_ppc.java
+++ b/rvm/src/org/jikesrvm/tools/header_gen/GenArch_ppc.java
@@ -29,49 +29,39 @@ final class GenArch_ppc extends GenArch {
public void emitArchVirtualMachineDeclarations() {
Offset offset;
offset = ArchEntrypoints.registersLRField.getOffset();
- pln("Registers_lr_offset = ", offset);
-
- p("static const int Constants_JTOC_POINTER = " + RegisterConstants.JTOC_POINTER + ";\n");
- p("static const int Constants_FRAME_POINTER = " + RegisterConstants.FRAME_POINTER + ";\n");
- p("static const int Constants_THREAD_REGISTER = " + RegisterConstants.THREAD_REGISTER + ";\n");
- p("static const int Constants_FIRST_VOLATILE_GPR = " + RegisterConstants.FIRST_VOLATILE_GPR + ";\n");
- p("static const int Constants_DIVIDE_BY_ZERO_MASK = " + TrapConstants.DIVIDE_BY_ZERO_MASK + ";\n");
- p("static const int Constants_DIVIDE_BY_ZERO_TRAP = " + TrapConstants.DIVIDE_BY_ZERO_TRAP + ";\n");
- p("static const int Constants_MUST_IMPLEMENT_MASK = " + TrapConstants.MUST_IMPLEMENT_MASK + ";\n");
- p("static const int Constants_MUST_IMPLEMENT_TRAP = " + TrapConstants.MUST_IMPLEMENT_TRAP + ";\n");
- p("static const int Constants_STORE_CHECK_MASK = " + TrapConstants.STORE_CHECK_MASK + ";\n");
- p("static const int Constants_STORE_CHECK_TRAP = " + TrapConstants.STORE_CHECK_TRAP + ";\n");
- p("static const int Constants_ARRAY_INDEX_MASK = " + TrapConstants.ARRAY_INDEX_MASK + ";\n");
- p("static const int Constants_ARRAY_INDEX_TRAP = " + TrapConstants.ARRAY_INDEX_TRAP + ";\n");
- p("static const int Constants_ARRAY_INDEX_REG_MASK = " + TrapConstants.ARRAY_INDEX_REG_MASK + ";\n");
- p("static const int Constants_ARRAY_INDEX_REG_SHIFT = " + TrapConstants.ARRAY_INDEX_REG_SHIFT + ";\n");
- p("static const int Constants_CONSTANT_ARRAY_INDEX_MASK = " +
- TrapConstants.CONSTANT_ARRAY_INDEX_MASK + ";\n");
- p("static const int Constants_CONSTANT_ARRAY_INDEX_TRAP = " +
- TrapConstants.CONSTANT_ARRAY_INDEX_TRAP + ";\n");
- p("static const int Constants_CONSTANT_ARRAY_INDEX_INFO = " +
- TrapConstants.CONSTANT_ARRAY_INDEX_INFO + ";\n");
- p("static const int Constants_WRITE_BUFFER_OVERFLOW_MASK = " +
- TrapConstants.WRITE_BUFFER_OVERFLOW_MASK + ";\n");
- p("static const int Constants_WRITE_BUFFER_OVERFLOW_TRAP = " +
- TrapConstants.WRITE_BUFFER_OVERFLOW_TRAP + ";\n");
- p("static const int Constants_STACK_OVERFLOW_MASK = " + TrapConstants.STACK_OVERFLOW_MASK + ";\n");
- p("static const int Constants_STACK_OVERFLOW_HAVE_FRAME_TRAP = " +
- TrapConstants.STACK_OVERFLOW_HAVE_FRAME_TRAP + ";\n");
- p("static const int Constants_STACK_OVERFLOW_TRAP = " + TrapConstants.STACK_OVERFLOW_TRAP + ";\n");
- p("static const int Constants_CHECKCAST_MASK = " + TrapConstants.CHECKCAST_MASK + ";\n");
- p("static const int Constants_CHECKCAST_TRAP = " + TrapConstants.CHECKCAST_TRAP + ";\n");
- p("static const int Constants_REGENERATE_MASK = " + TrapConstants.REGENERATE_MASK + ";\n");
- p("static const int Constants_REGENERATE_TRAP = " + TrapConstants.REGENERATE_TRAP + ";\n");
- p("static const int Constants_NULLCHECK_MASK = " + TrapConstants.NULLCHECK_MASK + ";\n");
- p("static const int Constants_NULLCHECK_TRAP = " + TrapConstants.NULLCHECK_TRAP + ";\n");
- p("static const int Constants_JNI_STACK_TRAP_MASK = " +
- TrapConstants.JNI_STACK_TRAP_MASK + ";\n");
- p("static const int Constants_JNI_STACK_TRAP = " + TrapConstants.JNI_STACK_TRAP + ";\n");
- p("static const int Constants_STACKFRAME_NEXT_INSTRUCTION_OFFSET = " +
- StackframeLayoutConstants.STACKFRAME_NEXT_INSTRUCTION_OFFSET + ";\n");
- p("static const int Constants_STACKFRAME_ALIGNMENT = " +
- StackframeLayoutConstants.STACKFRAME_ALIGNMENT + " ;\n");
+ pln("Registers_lr_offset", offset);
+ pln("Constants_JTOC_POINTER", RegisterConstants.JTOC_POINTER);
+ pln("Constants_FRAME_POINTER", RegisterConstants.FRAME_POINTER);
+ pln("Constants_THREAD_REGISTER", RegisterConstants.THREAD_REGISTER);
+ pln("Constants_FIRST_VOLATILE_GPR", RegisterConstants.FIRST_VOLATILE_GPR);
+ pln("Constants_DIVIDE_BY_ZERO_MASK", TrapConstants.DIVIDE_BY_ZERO_MASK);
+ pln("Constants_DIVIDE_BY_ZERO_TRAP", TrapConstants.DIVIDE_BY_ZERO_TRAP);
+ pln("Constants_MUST_IMPLEMENT_MASK", TrapConstants.MUST_IMPLEMENT_MASK);
+ pln("Constants_MUST_IMPLEMENT_TRAP", TrapConstants.MUST_IMPLEMENT_TRAP);
+ pln("Constants_STORE_CHECK_MASK", TrapConstants.STORE_CHECK_MASK);
+ pln("Constants_STORE_CHECK_TRAP", TrapConstants.STORE_CHECK_TRAP);
+ pln("Constants_ARRAY_INDEX_MASK", TrapConstants.ARRAY_INDEX_MASK);
+ pln("Constants_ARRAY_INDEX_TRAP", TrapConstants.ARRAY_INDEX_TRAP);
+ pln("Constants_ARRAY_INDEX_REG_MASK", TrapConstants.ARRAY_INDEX_REG_MASK);
+ pln("Constants_ARRAY_INDEX_REG_SHIFT", TrapConstants.ARRAY_INDEX_REG_SHIFT);
+ pln("Constants_CONSTANT_ARRAY_INDEX_MASK", TrapConstants.CONSTANT_ARRAY_INDEX_MASK);
+ pln("Constants_CONSTANT_ARRAY_INDEX_TRAP", TrapConstants.CONSTANT_ARRAY_INDEX_TRAP);
+ pln("Constants_CONSTANT_ARRAY_INDEX_INFO", TrapConstants.CONSTANT_ARRAY_INDEX_INFO);
+ pln("Constants_WRITE_BUFFER_OVERFLOW_MASK", TrapConstants.WRITE_BUFFER_OVERFLOW_MASK);
+ pln("Constants_WRITE_BUFFER_OVERFLOW_TRAP", TrapConstants.WRITE_BUFFER_OVERFLOW_TRAP);
+ pln("Constants_STACK_OVERFLOW_MASK", TrapConstants.STACK_OVERFLOW_MASK);
+ pln("Constants_STACK_OVERFLOW_HAVE_FRAME_TRAP", TrapConstants.STACK_OVERFLOW_HAVE_FRAME_TRAP);
+ pln("Constants_STACK_OVERFLOW_TRAP", TrapConstants.STACK_OVERFLOW_TRAP);
+ pln("Constants_CHECKCAST_MASK", TrapConstants.CHECKCAST_MASK);
+ pln("Constants_CHECKCAST_TRAP", TrapConstants.CHECKCAST_TRAP);
+ pln("Constants_REGENERATE_MASK", TrapConstants.REGENERATE_MASK);
+ pln("Constants_REGENERATE_TRAP", TrapConstants.REGENERATE_TRAP);
+ pln("Constants_NULLCHECK_MASK", TrapConstants.NULLCHECK_MASK);
+ pln("Constants_NULLCHECK_TRAP", TrapConstants.NULLCHECK_TRAP);
+ pln("Constants_JNI_STACK_TRAP_MASK", TrapConstants.JNI_STACK_TRAP_MASK);
+ pln("Constants_JNI_STACK_TRAP", TrapConstants.JNI_STACK_TRAP);
+ pln("Constants_STACKFRAME_NEXT_INSTRUCTION_OFFSET", StackframeLayoutConstants.STACKFRAME_NEXT_INSTRUCTION_OFFSET);
+ pln("Constants_STACKFRAME_ALIGNMENT", StackframeLayoutConstants.STACKFRAME_ALIGNMENT);
}
public void emitArchAssemblerDeclarations() {
diff --git a/tools/bootloader/jvm.c b/tools/bootloader/jvm.c
index fbe17ea1f..e6e020e93 100644
--- a/tools/bootloader/jvm.c
+++ b/tools/bootloader/jvm.c
@@ -15,23 +15,42 @@
* Implementation of JNI Invocation API for Jikes RVM.
*/
-#define NEED_VIRTUAL_MACHINE_DECLARATIONS
-#define NEED_EXIT_STATUS_CODES
-#include
-#include "InterfaceDeclarations.h"
-#include "bootImageRunner.h" // In tools/bootImageRunner.
+#include "sys.h"
+
+/** String used for name of RVM */
+char *Me;
+
+/** C access to shared C/Java boot record data structure */
+struct BootRecord *bootRecord;
+
+/** Number of Java args */
+int JavaArgc;
+
+/** Java args */
+char **JavaArgs;
+
+#ifndef RVM_FOR_HARMONY
+/** Sink for messages relating to serious errors detected by C runtime. */
+FILE *SysErrorFile;
+#endif
+
+#ifndef RVM_FOR_HARMONY
+/** Sink for trace messages produced by VM.sysWrite(). */
+FILE *SysTraceFile;
+#endif
+
+/** Verbose command line option */
+int verbose=0;
// Fish out an address stored in an instance field of an object.
-static void *
-getFieldAsAddress(void *objPtr, int fieldOffset)
+static void *getFieldAsAddress(void *objPtr, int fieldOffset)
{
char *fieldAddress = ((char*) objPtr) + fieldOffset;
return *((void**) fieldAddress);
}
// Get the JNI environment object from the Processor.
-static JNIEnv *
-getJniEnvFromVmThread(void *vmThreadPtr)
+static JNIEnv * getJniEnvFromVmThread(void *vmThreadPtr)
{
if (vmThreadPtr == 0)
return 0; // oops
@@ -52,7 +71,8 @@ getJniEnvFromVmThread(void *vmThreadPtr)
// JNI Invocation API functions
//////////////////////////////////////////////////////////////
-/** Destroying the Java VM only makes sense if programs can create a VM
+/**
+ * Destroying the Java VM only makes sense if programs can create a VM
* on-the-fly. Further, as of Sun's Java 1.2, it sitll didn't support
* unloading virtual machine instances. It is supposed to block until all
* other user threads are gone, and then return an error code.
@@ -67,16 +87,15 @@ DestroyJavaVM(JavaVM UNUSED * vm)
return JNI_ERR;
}
-/* "Trying to attach a thread that is already attached is a no-op". We
+/**
+ * "Trying to attach a thread that is already attached is a no-op". We
* implement that common case. (In other words, it works like GetEnv()).
* However, we do not implement the more difficult case of actually attempting
* to attach a native thread that is not currently attached to the VM.
*
* TODO: Implement for actually attaching unattached threads.
*/
-static
-jint
-AttachCurrentThread(JavaVM UNUSED * vm, /* JNIEnv */ void ** penv, /* JavaVMAttachArgs */ void *args)
+static jint AttachCurrentThread(JavaVM UNUSED * vm, /* JNIEnv */ void ** penv, /* JavaVMAttachArgs */ void *args)
{
JavaVMAttachArgs *aargs = (JavaVMAttachArgs *) args;
jint version;
@@ -108,16 +127,13 @@ AttachCurrentThread(JavaVM UNUSED * vm, /* JNIEnv */ void ** penv, /* JavaVMAtta
}
/* TODO: Implement */
-static
-jint
-DetachCurrentThread(JavaVM UNUSED *vm)
+static jint DetachCurrentThread(JavaVM UNUSED *vm)
{
fprintf(stderr, "UNIMPLEMENTED JNI call DetachCurrentThread\n");
return JNI_ERR;
}
-jint
-GetEnv(JavaVM UNUSED *vm, void **penv, jint version)
+jint GetEnv(JavaVM UNUSED *vm, void **penv, jint version)
{
if (version > JNI_VERSION_1_4)
return JNI_EVERSION;
diff --git a/tools/bootloader/main.c b/tools/bootloader/main.c
index 6b6e1ab44..b8db8cf86 100644
--- a/tools/bootloader/main.c
+++ b/tools/bootloader/main.c
@@ -34,21 +34,9 @@ uint64_t initialHeapSize; /* Declared in bootImageRunner.h */
uint64_t maximumHeapSize; /* Declared in bootImageRunner.h */
-/** String used for name of RVM */
-char *Me;
-
/** Verbose boot up set */
int verboseBoot=0;
-/** Verbose command line option */
-int verbose=0;
-
-/** Number of Java args */
-int JavaArgc;
-
-/** Java args */
-char **JavaArgs;
-
/** File name for part of boot image containing code */
static char *bootCodeFilename;
@@ -58,19 +46,6 @@ static char *bootDataFilename;
/** File name for part of boot image containing the root map */
static char *bootRMapFilename;
-/** C access to shared C/Java boot record data structure */
-struct BootRecord *bootRecord;
-
-#ifndef RVM_FOR_HARMONY
-/** Sink for messages relating to serious errors detected by C runtime. */
-FILE *SysErrorFile;
-#endif
-
-#ifndef RVM_FOR_HARMONY
-/** Sink for trace messages produced by VM.sysWrite(). */
-FILE *SysTraceFile;
-#endif
-
#define BYTES_IN_PAGE MMTk_Constants_BYTES_IN_PAGE
/* These definitions must remain in sync with nonStandardArgs, the array
diff --git a/tools/bootloader/sys.h b/tools/bootloader/sys.h
index 1d7187c13..923f1bfae 100644
--- a/tools/bootloader/sys.h
+++ b/tools/bootloader/sys.h
@@ -18,6 +18,9 @@
#include
#include
#include "cAttributePortability.h"
+#ifdef __MACH__
+#include
+#endif
#ifdef __cplusplus
#define EXTERNAL extern "C"
diff --git a/tools/bootloader/sysMemory.c b/tools/bootloader/sysMemory.c
index 1f4c87267..fa34ee8f5 100644
--- a/tools/bootloader/sysMemory.c
+++ b/tools/bootloader/sysMemory.c
@@ -129,7 +129,11 @@ EXTERNAL void sysZeroPages(void *dst, int cnt)
ERROR_PRINTF("%s: munmap failed (errno=%d): ", Me, errno);
sysExit(EXIT_STATUS_SYSCALL_TROUBLE);
}
+#ifdef MAP_ANONYMOUS
addr = mmap(dst, cnt, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+#else
+ addr = mmap(dst, cnt, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED, -1, 0);
+#endif
if (addr == (void *)-1)
{
ERROR_PRINTF("%s: mmap failed (errno=%d): ", Me, errno);
diff --git a/tools/bootloader/sysSignal.c b/tools/bootloader/sysSignal.c
index 878a960f1..810dc6a67 100644
--- a/tools/bootloader/sysSignal.c
+++ b/tools/bootloader/sysSignal.c
@@ -14,6 +14,7 @@
#include "sys.h"
#include
#include
+#include
/**
* Is the given address within the RVM address space?
diff --git a/tools/bootloader/sysSignal_PowerPC.c b/tools/bootloader/sysSignal_PowerPC.c
index 1753a6f4f..5fc745df5 100644
--- a/tools/bootloader/sysSignal_PowerPC.c
+++ b/tools/bootloader/sysSignal_PowerPC.c
@@ -15,14 +15,21 @@
* Architecture specific signal handling routines
*/
#include "sys.h"
+#include
+#include
/* Macros to modify signal context */
#ifdef RVM_FOR_OSX
-#define GET_GPR(info, rnum) (info->r##rnum)
-#define SET_GPR(info, rnum, value) (info->r##rnum=value)
+#define MAKE_INFO(info, context) \
+ struct mcontext* info = ((struct ucontext *)context)->uc_mcontext
+#define MAKE_SAVE(save, info) \
+ ppc_thread_state_t *save = &info->ss;
+#define GET_GPR(save, r) ((unsigned int *)&save->r0)[(r)]
+#define SET_GPR(save, r, value) ((unsigned int *)&save->r0)[(r)] = (value)
+#define PPC_IAR(save) save->srr0
#else
-#define GET_GPR(info, r) ((info)->gpr[(r)])
-#define SET_GPR(info, r, value) (((info)->gpr[(r)]) = (value))
+#define GET_GPR(save, r) ((save)->gpr[(r)])
+#define SET_GPR(save, r, value) (((save)->gpr[(r)]) = (value))
#endif
@@ -40,10 +47,11 @@ EXTERNAL void readContextInformation(void *context, Address *instructionPtr,
Address *threadPtr, Address *jtocPtr)
{
MAKE_INFO(info, context);
- Address ip = PPC_IAR(context);
+ MAKE_SAVE(save, info);
+ Address ip = PPC_IAR(save);
*instructionPtr = ip;
*instructionFollowingPtr = ip+4;
- *threadPtr = GET_GPR(info, Constants_FRAME_POINTER);
+ *threadPtr = GET_GPR(save, Constants_FRAME_POINTER);
*jtocPtr = bootRecord->tocRegister; /* could use register holding JTOC on PPC */
}
@@ -58,7 +66,23 @@ EXTERNAL void readContextInformation(void *context, Address *instructionPtr,
EXTERNAL Address readContextFramePointer(void *context, Address UNUSED threadPtr)
{
MAKE_INFO(info, context);
- return GET_GPR(info, Constants_FRAME_POINTER);
+ MAKE_SAVE(save, info);
+ return GET_GPR(save, Constants_FRAME_POINTER);
+}
+
+/**
+ * Read trap code from context of signal
+ *
+ * @param context [in] context to read from
+ * @param threadPtr [in] address of thread information
+ * @param signo [in] signal number
+ * @param instructionPtr [in] address of instruction
+ * @param trapInfo [out] extra information about trap
+ * @return trap code
+ */
+EXTERNAL int readContextTrapCode(void UNUSED *context, Address threadPtr, int signo, Address instructionPtr, int *trapInfo)
+{
+ return 0;
}
/**
@@ -68,9 +92,11 @@ EXTERNAL Address readContextFramePointer(void *context, Address UNUSED threadPtr
*/
EXTERNAL void setupDumpStackAndDie(void *context)
{
+ MAKE_INFO(info, context);
+ MAKE_SAVE(save, info);
Offset DumpStackAndDieOffset = bootRecord->dumpStackAndDieOffset;
Address localJTOC = bootRecord->tocRegister;
- Address dumpStack = *(Address *)((char *)VmToc + DumpStackAndDieOffset);
+ Address dumpStack = *(Address *)((char *)localJTOC + DumpStackAndDieOffset);
#ifdef RVM_FOR_LINUX
save->link = save->nip + 4; // +4 so it looks like a return address
save->nip = dumpStack;
@@ -84,3 +110,27 @@ EXTERNAL void setupDumpStackAndDie(void *context)
SET_GPR(save, Constants_FIRST_VOLATILE_GPR,
GET_GPR(save, Constants_FRAME_POINTER));
}
+
+/**
+ * Print the contents of context to the screen
+ *
+ * @param context [in] registers at point of signal/trap
+ */
+EXTERNAL void dumpContext(void *context)
+{
+}
+
+/**
+ * Set up the context to invoke RuntimeEntrypoints.deliverHardwareException.
+ *
+ * @param context [in,out] registers at point of signal/trap
+ * @param vmRegisters [out]
+ */
+EXTERNAL void setupDeliverHardwareException(void *context, Address vmRegisters,
+ int trapCode, int trapInfo,
+ Address instructionPtr,
+ Address instructionFollowingPtr,
+ Address threadPtr, Address jtocPtr,
+ Address framePtr, int signo)
+{
+}
diff --git a/tools/bootloader/sysThread.c b/tools/bootloader/sysThread.c
index 961af9951..cc8593715 100644
--- a/tools/bootloader/sysThread.c
+++ b/tools/bootloader/sysThread.c
@@ -19,13 +19,11 @@
#ifndef RVM_FOR_HARMONY
#include
#include
-#include
-#include
-#endif
-
-#ifdef _AIX
-#include
-#endif
+#ifdef RVM_FOR_LINUX
+# include
+# include
+#endif // def RVM_FOR_LINUX
+#endif // ndef RVM_FOR_HARMONY
#ifdef RVM_FOR_HARMONY
#define TLS_KEY_TYPE hythread_tls_key_t
@@ -102,7 +100,7 @@ EXTERNAL void sysExit(int value)
fflush(stdout);
#endif
systemExiting = 1;
- if (DeathLock != NULL) {
+ if (DeathLock != (Address)NULL) {
sysMonitorEnter(DeathLock);
}
#ifndef RVM_FOR_HARMONY
@@ -493,7 +491,7 @@ static void* sysThreadStartup(void *args)
TRACE_PRINTF("%s: sysThreadStartup: booting\n", Me);
setThreadLocal(TerminateJmpBufKey, (void*)jb);
// branch to vm code
- bootThread(ip, tr, fp, jtoc);
+ bootThread((void*)ip, (void*)tr, (void*)fp, (void*)jtoc);
// not reached
ERROR_PRINTF("%s: sysThreadStartup: failed\n", Me);
}
diff --git a/tools/bootloader/sysThread_PowerPC.c b/tools/bootloader/sysThread_PowerPC.c
index d9150ae7e..e415d6b38 100644
--- a/tools/bootloader/sysThread_PowerPC.c
+++ b/tools/bootloader/sysThread_PowerPC.c
@@ -15,18 +15,24 @@
* Architecture specific thread code
*/
+#define NEED_ASSEMBLER_DECLARATIONS
+#include "sys.h"
+
/**
* Transfer execution from C to Java for thread startup
*/
-void bootThread (void *pc, void *tr, void *sp, void UNUSED *jtoc)
+void bootThread (void *pc, void *tr, void *sp, void *jtoc)
{
- asm ("mtlr %3\n"
- "blr \n"
- : /* outs */
- : /* ins */
- "JTOC"(jtoc),
- "THREAD_REGISTER"(tr),
- "FP"(sp),
- "r"(pc)
- );
+ asm volatile ("mr r2, %0\n"
+ "mr r13, %1\n"
+ "mr r1, %2\n"
+ "mtlr %3\n"
+ "blr \n"
+ : /* outs */
+ : /* ins */
+ "r"(jtoc),
+ "r"(tr),
+ "r"(sp),
+ "r"(pc)
+ );
}
diff --git a/tools/bootloader/sysTime.c b/tools/bootloader/sysTime.c
index 291be147f..00e81aaf6 100644
--- a/tools/bootloader/sysTime.c
+++ b/tools/bootloader/sysTime.c
@@ -53,7 +53,6 @@ EXTERNAL long long sysNanoTime()
retVal = hytime_current_time_millis() * 1000;
#else
#ifdef __MACH__
- Nanoseconds nanoTime;
unsigned long long high;
unsigned long long low;