JVM instruction ALOAD_0 in the 'main' method points to 'args' instead of 'this'?

后端 未结 1 642
半阙折子戏
半阙折子戏 2021-02-07 02:27

I am trying to implement a subset of Java for an academic study. Well, I\'m in the last stages (code generation) and I wrote a rather simple program to see how method arguments

相关标签:
1条回答
  • 2021-02-07 02:46

    aload_0 is supposed to push 'this' on to the stack

    Not quite … aload_0 reads the first reference argument (or, more generally, the first local reference variable) of the method and pushes it onto the stack.

    In member functions, the first local variable happens to be the this reference.

    But main is not a member function, it’s a static function so there is no this argument, and the true first argument of the method is args.

    0 讨论(0)
提交回复
热议问题