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
1037 새로운 서버가 설치 되었습니다. [14] 백창우 2008.01.16 6102
1036 위키 대문 페이지에서 각 기수별 페이지 임베드하도록 바꿨습니다. [2] 김기태 2008.01.20 5088
1035 서버 문제 [4] 백창우 2008.01.20 4445
1034 Intel VLIW Processor & Compiler 백창우 2008.01.20 7255
1033 패스워드 안바꾸신분. 백창우 2008.01.21 5258
1032 커널 정독 스터디.. [2] 박은병 2008.01.21 5273
1031 정독 스터디 논문 리뷰 [9] 백창우 2008.01.22 6016
1030 코딩 가이드 라인 [5] 백창우 2008.01.29 6634
1029 이번주 토요일 정독 스터디 참석 불가. [9] 백창우 2008.01.30 4441
1028 하드웨어 캐시 관련 문서 [1] 김기오 2008.01.30 5054
1027 스터디에 참여하고 싶습니다.. [3] 김현철 2008.01.31 5159
1026 xen 코드는 lxr에 못올리나요? [1] 김기오 2008.01.31 6390
1025 [공지] 이번주(2월 2일), 다음주(2월 9일) 정독 스터디 쉽니다. 백창우 2008.02.01 5147
1024 [논의사항] 1년에 1번 모집하는것이 가장 좋은 것일까요? [13] 백창우 2008.02.01 5111
1023 [논의사항2] 다음 세미나 주제 [21] 백창우 2008.02.01 5034
1022 세미나 참여 하고 싶습니다. [8] 전남재 2008.02.04 6473
1021 개인적으로 기다리던 기사가 떴네요. [1] 백창우 2008.02.05 5870
1020 IBM Cell SDK 3.0이 나왔습니다. 백창우 2008.02.14 6504
1019 [정독스터디] 내일 좀 늦을지도 모르겠습니다. 백창우 2008.02.16 5207
1018 안녕하세요. 구글 검색하다 들어오게 됐는데.. [2] 소두진 2008.02.19 5126
XE Login