Exemplo n.º 1
0
void testProxy0OneArgOfEach_handler(CallInfo* ci) {
    proxy0ReturnLong(ci, 0);
    void* p = proxy0NextPtr(ci);
    jint i = proxy0NextInt(ci);
    jlong l = proxy0NextLong(ci);
    jfloat f = proxy0NextFloat(ci);
    jdouble d = proxy0NextDouble(ci);
    if (p != testProxy0OneArgOfEach_handler) return;
    if (i != -100) return;
    if (l != 0xfedcba9876543210LL) return;
    if (f != 3.14f) return;
    if (d != -3.14) return;
    proxy0ReturnLong(ci, 0x0123456789abcdefLL);
}
Exemplo n.º 2
0
static void testProxy0ReturnPtr_handler(CallInfo* ci) {
    void* p = proxy0NextPtr(ci);
    proxy0ReturnPtr(ci, p + sizeof(void*));
}
Exemplo n.º 3
0
void testProxy0Unwind_handler(CallInfo* ci) {
    void** ptrs = proxy0NextPtr(ci);
    unwindBacktrace(NULL, unwindCallStack, ptrs);
}
Exemplo n.º 4
0
void testProxy0ManyArgsOfEach_handler(CallInfo* ci) {
    proxy0ReturnInt(ci, 0);

    void* p1 = proxy0NextPtr(ci);
    jint i1 = proxy0NextInt(ci);
    jlong l1 = proxy0NextLong(ci);
    jfloat f1 = proxy0NextFloat(ci);
    jdouble d1 = proxy0NextDouble(ci);
    void* p2 = proxy0NextPtr(ci);
    jint i2 = proxy0NextInt(ci);
    jlong l2 = proxy0NextLong(ci);
    jfloat f2 = proxy0NextFloat(ci);
    jdouble d2 = proxy0NextDouble(ci);
    void* p3 = proxy0NextPtr(ci);
    jint i3 = proxy0NextInt(ci);
    jlong l3 = proxy0NextLong(ci);
    jfloat f3 = proxy0NextFloat(ci);
    jdouble d3 = proxy0NextDouble(ci);
    void* p4 = proxy0NextPtr(ci);
    jint i4 = proxy0NextInt(ci);
    jlong l4 = proxy0NextLong(ci);
    jfloat f4 = proxy0NextFloat(ci);
    jdouble d4 = proxy0NextDouble(ci);
    void* p5 = proxy0NextPtr(ci);
    jint i5 = proxy0NextInt(ci);
    jlong l5 = proxy0NextLong(ci);
    jfloat f5 = proxy0NextFloat(ci);
    jdouble d5 = proxy0NextDouble(ci);
    void* p6 = proxy0NextPtr(ci);
    jint i6 = proxy0NextInt(ci);
    jlong l6 = proxy0NextLong(ci);
    jfloat f6 = proxy0NextFloat(ci);
    jdouble d6 = proxy0NextDouble(ci);
    void* p7 = proxy0NextPtr(ci);
    jint i7 = proxy0NextInt(ci);
    jlong l7 = proxy0NextLong(ci);
    jfloat f7 = proxy0NextFloat(ci);
    jdouble d7 = proxy0NextDouble(ci);
    void* p8 = proxy0NextPtr(ci);
    jint i8 = proxy0NextInt(ci);
    jlong l8 = proxy0NextLong(ci);
    jfloat f8 = proxy0NextFloat(ci);
    jdouble d8 = proxy0NextDouble(ci);

    if (p1 != testProxy0ManyArgsOfEach_handler + 0xcab1) return;
    if (i1 != -100) return;
    if (l1 != 0xfedcba9876543211LL) return;
    if (f1 != 3.11f) return;
    if (d1 != -3.11) return;
    if (p2 != testProxy0ManyArgsOfEach_handler + 0xcab2) return;
    if (i2 != -200) return;
    if (l2 != 0xfedcba9876543212LL) return;
    if (f2 != 3.12f) return;
    if (d2 != -3.12) return;
    if (p3 != testProxy0ManyArgsOfEach_handler + 0xcab3) return;
    if (i3 != -300) return;
    if (l3 != 0xfedcba9876543213LL) return;
    if (f3 != 3.13f) return;
    if (d3 != -3.13) return;
    if (p4 != testProxy0ManyArgsOfEach_handler + 0xcab4) return;
    if (i4 != -400) return;
    if (l4 != 0xfedcba9876543214LL) return;
    if (f4 != 3.14f) return;
    if (d4 != -3.14) return;
    if (p5 != testProxy0ManyArgsOfEach_handler + 0xcab5) return;
    if (i5 != -500) return;
    if (l5 != 0xfedcba9876543215LL) return;
    if (f5 != 3.15f) return;
    if (d5 != -3.15) return;
    if (p6 != testProxy0ManyArgsOfEach_handler + 0xcab6) return;
    if (i6 != -600) return;
    if (l6 != 0xfedcba9876543216LL) return;
    if (f6 != 3.16f) return;
    if (d6 != -3.16) return;
    if (p7 != testProxy0ManyArgsOfEach_handler + 0xcab7) return;
    if (i7 != -700) return;
    if (l7 != 0xfedcba9876543217LL) return;
    if (f7 != 3.17f) return;
    if (d7 != -3.17) return;
    if (p8 != testProxy0ManyArgsOfEach_handler + 0xcab8) return;
    if (i8 != -800) return;
    if (l8 != 0xfedcba9876543218LL) return;
    if (f8 != 3.18f) return;
    if (d8 != -3.18) return;

    proxy0ReturnInt(ci, 1);
}
Exemplo n.º 5
0
void _rvmProxyHandler(CallInfo* callInfo) {
    Env* env = (Env*) proxy0NextPtr(callInfo);
    Object* receiver = (Object*) proxy0NextPtr(callInfo);
    Class* proxyClass = receiver->clazz;
    ProxyClassData* proxyClassData = (ProxyClassData*) proxyClass->data;

    LookupKey key;
    memset(&key, 0, sizeof(LookupKey));
    key.name = (char*) env->reserved0;
    key.desc = (char*) env->reserved1;
    LookupEntry* entry;
    HASH_FIND(hh, proxyClassData->lookupsHash, &key, sizeof(LookupKey), entry);
    if (!entry) {
        rvmThrowNoSuchMethodError(env, "Failed to determine which method was called on proxy class");
        goto error;
    }

    ProxyMethod* method = entry->method;

    rvmPushGatewayFrameProxy(env, method);

    jint argsCount = rvmGetParameterCount((Method*) method);
    jvalue *jvalueArgs = NULL;
    if (argsCount > 0) {
        jvalueArgs = (jvalue*) rvmAllocateMemory(env, sizeof(jvalue) * argsCount);
        if (!jvalueArgs) goto errorPop;

        const char* desc = method->method.desc;
        const char* c;
        jint i = 0;
        while ((c = rvmGetNextParameterType(&desc))) {
            switch (c[0]) {
            case 'B':
                jvalueArgs[i++].b = (jbyte) proxy0NextInt(callInfo);
                break;
            case 'Z':
                jvalueArgs[i++].z = (jboolean) proxy0NextInt(callInfo);
                break;
            case 'S':
                jvalueArgs[i++].s = (jshort) proxy0NextInt(callInfo);
                break;
            case 'C':
                jvalueArgs[i++].c = (jchar) proxy0NextInt(callInfo);
                break;
            case 'I':
                jvalueArgs[i++].i = proxy0NextInt(callInfo);
                break;
            case 'J':
                jvalueArgs[i++].j = proxy0NextLong(callInfo);
                break;
            case 'F':
                jvalueArgs[i++].f = proxy0NextFloat(callInfo);
                break;
            case 'D':
                jvalueArgs[i++].d = proxy0NextDouble(callInfo);
                break;
            case '[':
            case 'L':
                jvalueArgs[i++].l = (jobject) proxy0NextPtr(callInfo);
                break;
            }
        }
    }

    jvalue returnValue;
    proxyClassData->handler(env, receiver, method, jvalueArgs, &returnValue);

    rvmPopGatewayFrame(env);

    if (rvmExceptionCheck(env)) goto error;

    proxy0ReturnInt(callInfo, 0);
    switch (rvmGetReturnType(method->method.desc)[0]) {
    case 'B':
        proxy0ReturnInt(callInfo, (jint) returnValue.b);
        break;
    case 'Z':
        proxy0ReturnInt(callInfo, (jint) returnValue.z);
        break;
    case 'S':
        proxy0ReturnInt(callInfo, (jint) returnValue.s);
        break;
    case 'C':
        proxy0ReturnInt(callInfo, (jint) returnValue.c);
        break;
    case 'I':
        proxy0ReturnInt(callInfo, returnValue.i);
        break;
    case 'J':
        proxy0ReturnLong(callInfo, returnValue.j);
        break;
    case 'F':
        proxy0ReturnFloat(callInfo, returnValue.f);
        break;
    case 'D':
        proxy0ReturnDouble(callInfo, returnValue.d);
        break;
    case '[':
    case 'L':
        proxy0ReturnPtr(callInfo, returnValue.l);
        break;
    }

    return;

errorPop:
    rvmPopGatewayFrame(env);
error:
    rvmRaiseException(env, rvmExceptionOccurred(env));
}