将methodData以0为初始值压入栈,根据methodOop的ConstantPoolOop成员将常量池缓冲地址压入栈,r14中保存着局部变量区(第一个参数的地址)指针,将其压入栈,此外如果调用的是native调用,那么字节码指针部分为0,否则正常将字节码指针压入栈,最后为栈留出一个字的表达式栈底空间,并更新rsp
最后栈的空间结构如下:
(9).增加方法的调用计数
// increment invocation count & check for overflow Label invocation_counter_overflow; Label profile_method; Label profile_method_continue; if (inc_counter) { generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue); if (ProfileInterpreter) { __ bind(profile_method_continue); } }
(当调用深度过大会抛出StackOverFlow异常)
(10).同步方法的Monitor对象分配和方法的加锁(在汇编部分分析中没有该部分,如果对同步感兴趣的请自行分析)
if (synchronized) { // Allocate monitor and lock method lock_method();
(11).JVM工具接口部分
// jvmti support __ notify_method_entry();
(12).跳转到第一条字节码的本地代码处执行
__ dispatch_next(vtos);
以上分析可能略显复杂,但重要的是明白方法的入口例程是如何为Java方法构造新的栈帧,从而为字节码的运行提供调用栈环境。
method entry point汇编代码的分析可以参考随后的一篇文章。