Hotspot调用

来源:/src/share/vm/runtime/stubRoutines.hpp

static CallStub call_stub() { 
    return CAST_TO_FN_PTR(CallStub, _call_stub_entry); 
}

其中CAST_TO_FN_PTR是宏,定义在/src/share/vm/runtime/utilities/globalDefinitions.hpp文件中,具体定义如下:

#define CAST_TO_FN_PTR(func_type, value) ((func_type)(castable_address(value)))  

 对call_stub函数进行宏替换和展开后会变为如下的形式:

static CallStub call_stub(){
    return (CallStub)(castable_address(_call_stub_entry));
}

 CallStub定义在/src/share/vm/runtime/stubRoutines.hpp文件中,具体的定义如下:

// Calls to Java
typedef void (*CallStub)(
    address   link,
    intptr_t* result,
    BasicType result_type,
    Method* method,
    address   entry_point,
    intptr_t* parameters,
    int       size_of_parameters,
    TRAPS
); 

如上定义了一种函数指针类型,指向的函数声明了8个形式参数。 

在call_stub()函数中调用的castable_address()函数在globalDefinitions.hpp文件中实现,具体如下:

inline address_word  castable_address(address x)  { 
    return address_word(x) ; 
}

address_word是一定自定义的类型,具体在globalDefinitions.hpp文件中的定义如下:

// unsigned integer which will hold a pointer
// except for some implementations of a C++
// linkage pointer to function. Should never
// need one of those to be placed in this type anyway.
typedef uintptr_t     address_word;
                                   

  

  

扫描二维码关注公众号,回复: 6686418 查看本文章

  

猜你喜欢

转载自www.cnblogs.com/mazhimazhi/p/11109736.html
今日推荐