native() 함수의 비밀을 알아냈습니다.

아주 가까운데에 있더군요.. ㅡ.ㅡ

invokeNativeFunction() 에 있는 NativeFunctionPtr 형 native 입니다.

즉, 함수포인터 였던거죠.

그래서 인즉 Object 파일을 분석하지 않으면 어떤 함수포인터가 호출되는지 알지 못하겠

더라구요. 저도 같이 Object 파일분석해서 올리겠습니다.

그럼 이번주 토요일에 뵙겠습니다.

void invokeNativeFunction(METHOD thisMethod)
{
    ...
    NativeFunctionPtr native = thisMethod->u.native.code;

    if (native == NULL) {
        /* Native function not found; throw error */

        /* The GC may get confused by the arguments on the stack */
        setSP(getSP() - thisMethod->argCount);

        START_TEMPORARY_ROOTS
            DECLARE_TEMPORARY_ROOT(char*, className,
                     getClassName((CLASS)(thisMethod->ofClass)));
            sprintf(str_buffer,
                    KVM_MSG_NATIVE_METHOD_NOT_FOUND_2STRPARAMS,
                    className, methodName(thisMethod));
        END_TEMPORARY_ROOTS
        fatalError(str_buffer);
    }

#if INCLUDEDEBUGCODE
    if (tracemethodcalls || tracemethodcallsverbose) {
        frameTracing(thisMethod, "=>", +1);
    }
    saved_TemporaryRootsLength = TemporaryRootsLength;
#endif

#if USE_KNI
    /* Note: Unlike many other Java VMs, KVM does not create      */
    /* stack frames for native function calls.  This makes native */
    /* function calls faster.  However, at the same time it means */
    /* that the native function programmer must be careful not to */
    /* screw up the stack pointer when popping and pushing items  */
    /* to and from the operand stack.                             */

    /* Because of the lack of stack frames for native functions,  */
    /* KNI calls need special assistance to access the parameters */
    /* of a native method.  Basically, we create a new "pseudo-   */
    /* local pointer" called "nativeLp" to point to the locals of */
    /* the native method.  Old-style (pre-KNI) native methods can */
    /* simply ignore this new variable.                           */
    if ((thisMethod->accessFlags & ACC_STATIC) && CurrentThread) {
        CurrentThread->nativeLp = getSP() - (thisMethod->argCount);
    } else {
        CurrentThread->nativeLp = getSP() - (thisMethod->argCount-1);
    }
#endif /* USE_KNI */

    /* Call the native function we are supposed to call */
    CurrentNativeMethod = thisMethod;
    native();

    ...

}
번호 제목 글쓴이 날짜 조회 수
공지 [공지] IAMROOT 19차 커널 스터디 오리엔테이션 (zoom 접속 안내) [5] 문c(문영일) 2022.05.07 882
공지 [공지] IAMROOT 18차 커널 스터디 오리엔테이션 안내 [마감] [2] 문c(문영일) 2021.05.17 1249
공지 커널 스터디를 위한 문c 가이드입니다. [10] 문c(문영일) 2021.04.27 6476
» [KVM study] native() 함수의 비밀을 알아냈습니다. 좀 허무하군요. 김정수 2008.06.16 6478
256 bytecode에 제가 주석단거 추가해서 올립니다. file 김정수 2008.06.09 4625
255 [KVM Study] 정수님 보세요. [1] 이정우 2008.06.07 3851
254 두번재 세미나 시간이 확정 되었나요? [1] 남현우 2007.05.17 4304
253 홈페이지 서버는 어디에 있는거죠? [3] 정필섭 2007.03.02 4558
252 study 모집 공고 하였습니다. [7] 백창우 2007.01.28 4313
251 [소개]안녕하세요...^^ 정문수 2007.10.26 3566
250 [소개] 안녕하세요. 가입 인사 올립니다. 이완근 2007.10.26 3368
249 [소개] 안녕하세요. 박성일 2007.10.25 3597
248 [소개] 안녕하세요. 이정우 2007.10.25 3510
247 [소개] 안녕하세요. 염태근 입니다. 염태근 2007.10.25 4899
246 [소개] 4기에 함께하게된 허재영입니다. 허재영 2007.10.25 3615
245 [소개] 안녕하세요. [2] 한상은 2007.10.25 3737
244 [소개] 안녕하세요. 김기태 2007.10.25 3533
243 [소개] 인사드립니다. 김우종 2007.10.25 3621
242 [소개]안녕하세요 [2] 안소진 2007.10.25 4084
241 [소개] 안녕하세요. [1] 신예지 2007.10.25 4244
240 [소개]문경원 입니다. 문경원 2007.10.25 3973
239 [소개] 안녕하세요^^ 김성준 2007.10.25 3609
238 [소개]안녕하세요. 송대훈 2007.10.25 4016
XE Login