2017-10-26 4 views
0
hotspot/src/share/vm/utilities/exceptions.hpp에서

에서`__the_thread__` 매크로 란, 몇 가지 코드가있다 :이 OpenJDK8

// The THREAD & TRAPS macros facilitate the declaration of functions that throw exceptions. 
// Convention: Use the TRAPS macro as the last argument of such a function; e.g.: 
// 
// int this_function_may_trap(int x, float y, TRAPS) 

#define THREAD __the_thread__ 
#define TRAPS Thread* THREAD 

THREAD 매크로 예외가 던져에만 사용

// The THROW... macros should be used to throw an exception. They require a THREAD variable to be 
// visible within the scope containing the THROW. Usually this is achieved by declaring the function 
// with a TRAPS argument. 

#define THREAD_AND_LOCATION      THREAD, __FILE__, __LINE__ 

#define THROW_OOP(e)        \ 
    { Exceptions::_throw_oop(THREAD_AND_LOCATION, e);        return; } 

#define THROW_HANDLE(e)        \ 
    { Exceptions::_throw(THREAD_AND_LOCATION, e);        return; } 

// the real place to use __the_thread__ macro 
void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) {......} 

그러나, 내가 검색 grep를 사용을 모든 OpenJDK8의 코드는 여기에 단 한 곳 밖에 없다는 것을 알아 내기 위해 __the_thread__ 매크로를 가지고 있습니다. 실제 매크로가 무엇을 정의 할 수 있습니까?

답변

2

__the_thread__ 여기에는 예외의 가능성이있는 변수의 이름 또는 VM 함수에 대한 인수가 있습니다. 항상 THREAD 또는 TRAPS 매크로를 통해 액세스하므로 다른 참조가 없으며 변수의 실제 이름은 중요하지 않습니다. 예를 들어

, 정의

jint find_field_offset(jobject field, int must_be_static, TRAPS) 

jint find_field_offset(jobject field, int must_be_static, Thread* __the_thread__) 
처리기에 의해 확장된다