hello, world!

This commit is contained in:
dicej 2008-06-15 14:17:52 -06:00
parent fb6624b9ae
commit 04724b657d
3 changed files with 40 additions and 20 deletions

View File

@ -137,6 +137,10 @@ struct JavaVMVTable {
void* reserved1; void* reserved1;
void* reserved2; void* reserved2;
#if (! TARGET_RT_MAC_CFM) && defined(__ppc__)
void* cfm_vectors[4];
#endif
jint jint
(JNICALL *DestroyJavaVM) (JNICALL *DestroyJavaVM)
(JavaVM*); (JavaVM*);
@ -156,6 +160,10 @@ struct JavaVMVTable {
jint jint
(JNICALL *AttachCurrentThreadAsDaemon) (JNICALL *AttachCurrentThreadAsDaemon)
(JavaVM*, JNIEnv**, void*); (JavaVM*, JNIEnv**, void*);
#if TARGET_RT_MAC_CFM && defined(__ppc__)
void* real_functions[5];
#endif
}; };
struct JNIEnvVTable { struct JNIEnvVTable {
@ -1083,6 +1091,10 @@ struct JNIEnvVTable {
jlong jlong
(JNICALL *GetDirectBufferCapacity) (JNICALL *GetDirectBufferCapacity)
(JNIEnv*, jobject); (JNIEnv*, jobject);
#if TARGET_RT_MAC_CFM && defined(__ppc__)
void* real_functions[228];
#endif
}; };
inline int inline int

View File

@ -113,13 +113,18 @@ LOCAL(float):
cmpwi r14,FLOAT_TYPE cmpwi r14,FLOAT_TYPE
beq LOCAL(copy) beq LOCAL(copy)
cmpwi r14,DOUBLE_TYPE cmpwi r14,DOUBLE_TYPE
bne LOCAL(exit) beq LOCAL(copy)
cmpwi r14,INT64_TYPE
beq LOCAL(exit)
mr r4,r3
b LOCAL(exit)
LOCAL(copy): LOCAL(copy):
// move floating point return value to GPRs via memory // move floating point return value to GPRs via memory
stfd f1,8(r1) stfd f1,8(r1)
lwz r3,8(r1) lwz r3,8(r1)
lwz r4,12(r1) lwz r4,12(r1)
b LOCAL(exit)
LOCAL(exit): LOCAL(exit):
// restore stack pointer // restore stack pointer

View File

@ -42,7 +42,8 @@ namespace vm {
inline uint64_t inline uint64_t
dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes,
unsigned, unsigned argumentsSize, unsigned returnType) unsigned argumentCount, unsigned argumentsSize,
unsigned returnType)
{ {
const unsigned LinkageArea = 24; const unsigned LinkageArea = 24;
@ -54,64 +55,66 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes,
uint64_t fprTable[FprCount]; uint64_t fprTable[FprCount];
unsigned fprIndex = 0; unsigned fprIndex = 0;
uint64_t stack[argumentsSize]; uintptr_t stack[argumentsSize / BytesPerWord];
unsigned stackSkip = 0; unsigned stackSkip = 0;
unsigned stackIndex = 0; unsigned stackIndex = 0;
for (unsigned i = 0; i < argumentsSize; ++i) { unsigned ai = 0;
switch (argumentTypes[i]) { for (unsigned ati = 0; ati < argumentCount; ++ ati) {
switch (argumentTypes[ati]) {
case FLOAT_TYPE: { case FLOAT_TYPE: {
if (fprIndex < FprCount) { if (fprIndex < FprCount) {
fprTable[fprIndex++] = arguments[i]; fprTable[fprIndex++] = arguments[ai];
++ gprIndex; ++ gprIndex;
++ stackSkip; ++ stackSkip;
} else { } else {
stack[stackIndex++] = arguments[i]; stack[stackIndex++] = arguments[ai];
} }
++ ai;
} break; } break;
case DOUBLE_TYPE: { case DOUBLE_TYPE: {
if (fprIndex < FprCount) { if (fprIndex < FprCount) {
memcpy(fprTable + fprIndex, arguments + i, 8); memcpy(fprTable + fprIndex, arguments + ai, 8);
++ fprIndex; ++ fprIndex;
gprIndex += BytesPerWord / 4; gprIndex += BytesPerWord / 4;
stackSkip += BytesPerWord / 4; stackSkip += BytesPerWord / 4;
i += (BytesPerWord / 4) - 1;
} else { } else {
memcpy(stack + stackIndex, arguments + i, 8); memcpy(stack + stackIndex, arguments + ai, 8);
stackIndex += BytesPerWord / 4; stackIndex += BytesPerWord / 4;
i += (BytesPerWord / 4) - 1;
} }
ai += BytesPerWord / 4;
} break; } break;
case INT64_TYPE: { case INT64_TYPE: {
if (gprIndex < GprCount) { if (gprIndex + BytesPerWord / 4 <= GprCount) {
memcpy(gprTable + gprIndex, arguments + i, 8); memcpy(gprTable + gprIndex, arguments + ai, 8);
gprIndex += BytesPerWord / 4; gprIndex += BytesPerWord / 4;
stackSkip += BytesPerWord / 4; stackSkip += BytesPerWord / 4;
i += (BytesPerWord / 4) - 1;
} else { } else {
memcpy(stack + stackIndex, arguments + i, 8); memcpy(stack + stackIndex, arguments + ai, 8);
stackIndex += BytesPerWord / 4; stackIndex += BytesPerWord / 4;
i += (BytesPerWord / 4) - 1;
} }
ai += BytesPerWord / 4;
} break; } break;
default: { default: {
if (gprIndex < GprCount) { if (gprIndex < GprCount) {
gprTable[gprIndex++] = arguments[i]; gprTable[gprIndex++] = arguments[ai];
++ stackSkip; ++ stackSkip;
} else { } else {
stack[stackIndex++] = arguments[i]; stack[stackIndex++] = arguments[ai];
} }
++ ai;
} break; } break;
} }
} }
return vmNativeCall return vmNativeCall
(function, (function,
(((1 + stackSkip + stackIndex) * BytesPerWord) + LinkageArea + 15) & -16, - ((((1 + stackSkip + stackIndex) * BytesPerWord) + LinkageArea + 15)
stack, stackIndex, & -16),
stack, stackIndex * BytesPerWord,
(gprIndex ? gprTable : 0), (gprIndex ? gprTable : 0),
(fprIndex ? fprTable : 0), returnType); (fprIndex ? fprTable : 0), returnType);
} }