Java对象方法堆栈帧参数

时间:2021-09-15 21:32:41

So in java, say you have a non-static method 'bar()' in an class 'Foo'.

所以在java中,假设你在类'Foo'中有一个非静态方法'bar()'。

class Foo
{
    private int m_answer;

    public Foo()
    {
        m_answer = -1;
    }

    public void bar(int newAnswer)
    {
        m_answer = newAnswer;
    }
}

Say then that you call this method like so:

然后说你像这样调用这个方法:

Foo myFoo = new Foo();
myFoo.bar(42);

Now the stack frame for the call includes the integer parameter, as well as a 'this' parameter to be used as an internal reference to the object.

现在,调用的堆栈帧包括整数参数,以及用作对象内部引用的“this”参数。

What other interesting parameters are copied to the new stack frame, in addition to 'this' and the method parameters?

除了'this'和方法参数之外,还有哪些其他有趣的参数被复制到新的堆栈帧?

.

1 个解决方案

#1


Usually a pointer to the calling instruction, so that the VM (in this case, the CPU in native apps) will know where to set the instruction pointer (or PC - Program Counter) so the stack will be unfolded correctly

通常是指向调用指令的指针,以便VM(在本例中为本机应用程序中的CPU)将知道在何处设置指令指针(或PC - 程序计数器),以便堆栈将正确展开

#1


Usually a pointer to the calling instruction, so that the VM (in this case, the CPU in native apps) will know where to set the instruction pointer (or PC - Program Counter) so the stack will be unfolded correctly

通常是指向调用指令的指针,以便VM(在本例中为本机应用程序中的CPU)将知道在何处设置指令指针(或PC - 程序计数器),以便堆栈将正确展开