Skip to content

Commit

Permalink
PowerPC OS/X build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Rogers committed Mar 18, 2009
1 parent db3c06d commit 6784db1
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 130 deletions.
21 changes: 6 additions & 15 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1555,22 +1555,13 @@ Check to make sure all required properties are specified. This includes properti
<equals arg1="${config.include.perfctr}" arg2="true"/>
</condition>

<property name="rvm.syscall.src" value="${bl.dir}/sysAlignmentCheck.c ${bl.dir}/sysConsole.c ${bl.dir}/sysIO.c ${bl.dir}/sysLibrary.c ${bl.dir}/sysMath.c ${bl.dir}/sysMemory.c ${bl.dir}/sysMisc.c ${bl.dir}/sysPerfCtr.c ${bl.dir}/sysSignal.c ${bl.dir}/sysThread.c ${bl.dir}/sysTime.c"/>

<condition property="rvm.src"
value="${bl.dir}/main.c ${bl.dir}/sysGCSpy.c ${rvm.syscall.src} ${rvm.arch.src} ${perfctr.src}"
else="${bl.dir}/main.c ${rvm.syscall.src} ${rvm.arch.src} ${perfctr.src}">
<condition property="rvm.syscall.src"
value="${bl.dir}/sysGCSpy.c ${bl.dir}/sysAlignmentCheck.c ${bl.dir}/sysConsole.c ${bl.dir}/sysIO.c ${bl.dir}/sysLibrary.c ${bl.dir}/sysMath.c ${bl.dir}/sysMemory.c ${bl.dir}/sysMisc.c ${bl.dir}/sysPerfCtr.c ${bl.dir}/sysSignal.c ${bl.dir}/sysThread.c ${bl.dir}/sysTime.c ${rvm.arch.src}"
else="${bl.dir}/sysAlignmentCheck.c ${bl.dir}/sysConsole.c ${bl.dir}/sysIO.c ${bl.dir}/sysLibrary.c ${bl.dir}/sysMath.c ${bl.dir}/sysMemory.c ${bl.dir}/sysMisc.c ${bl.dir}/sysPerfCtr.c ${bl.dir}/sysSignal.c ${bl.dir}/sysThread.c ${bl.dir}/sysTime.c ${rvm.arch.src}">
<equals arg1="include.gcspy" arg2="true"/>
</condition>
</target>

<target name="build-ppc-bootThread" depends="check-bootloader-properties" if="gen-ppc-bootThread">
<test-file name="cpp.exe" location="${host.file}"/>
<exec executable="${cpp.exe}" failonerror="true" output="${build.native}/bootThread.s">
<arg line="${rvm.common.args} ${cpp.args}"/>
<arg value="-P"/>
<arg path="${basedir}/tools/bootloader/ppc/bootThread.c"/>
</exec>
<property name="rvm.src" value="${bl.dir}/main.c ${perfctr.src}"/>
</target>

<target name="build-gcspy-stub" depends="check-bootloader-properties" if="include.gcspy-stub">
Expand All @@ -1582,7 +1573,7 @@ Check to make sure all required properties are specified. This includes properti
</exec>
</target>

<target name="build-bootloader" depends="build-gcspy-stub,build-ppc-bootThread">
<target name="build-bootloader" depends="build-gcspy-stub">

<!-- rdynamic flag used to control the exporting of symbols into an ELF -->
<condition property="c.rdynamic" value="" else="-rdynamic">
Expand Down Expand Up @@ -1612,7 +1603,7 @@ Check to make sure all required properties are specified. This includes properti
<arg line="${rvm.c.args} -lpthread ${c.librt}"/>
<arg value="-o"/>
<arg path="${toString:rvm.dll}"/>
<arg path="${bl.dir}/jvm.c"/>
<arg line="${bl.dir}/jvm.c ${rvm.syscall.src}"/>
</exec>

<!-- create vmi shared library -->
Expand Down
76 changes: 33 additions & 43 deletions rvm/src/org/jikesrvm/tools/header_gen/GenArch_ppc.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
54 changes: 35 additions & 19 deletions tools/bootloader/jvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,42 @@
* Implementation of JNI Invocation API for Jikes RVM.
*/

#define NEED_VIRTUAL_MACHINE_DECLARATIONS
#define NEED_EXIT_STATUS_CODES
#include <stdlib.h>
#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
Expand All @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 0 additions & 25 deletions tools/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tools/bootloader/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include <jni.h>
#include <stdint.h>
#include "cAttributePortability.h"
#ifdef __MACH__
#include <mach/mach_time.h>
#endif

#ifdef __cplusplus
#define EXTERNAL extern "C"
Expand Down
4 changes: 4 additions & 0 deletions tools/bootloader/sysMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tools/bootloader/sysSignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "sys.h"
#include <errno.h>
#include <signal.h>
#include <string.h>

/**
* Is the given address within the RVM address space?
Expand Down
Loading

0 comments on commit 6784db1

Please sign in to comment.