我什么时候可以在从Java源代码编译的.class文件中获得pop2操作码?

时间:2021-05-03 20:45:12

I'm currently working on a Java decompiler.

我目前正在研究Java反编译器。

I read the JVM specification, and I know pop2 can operate one stack value (category 2 values) or two stack values (other category values).

我读了JVM规范,我知道pop2可以运行一个堆栈值(类别2值)或两个堆栈值(其他类别值)。

I just want to know when a two stack values operation of pop2 can happen? Could anyone show me some Java source code whose compilation result contains two stack values operations pop2?

我只是想知道pop2的两个堆栈值操作何时会发生?谁能告诉我一些Java源代码,其编译结果包含两个堆栈值操作pop2?

2 个解决方案

#1


1  

Based on my brief reading of the source code for the javac compiler in Java 8, there are no places where it will emit a POP2 to pop 2 category-1 values from the stack. If two category-1 values need to be popped, then two POP bytecodes will be emitted by the compiler.

基于我在Java 8中简要阅读javac编译器的源代码,没有地方可以发出POP2来从堆栈中弹出2个category-1值。如果需要弹出两个category-1值,则编译器将发出两个POP字节码。

Caveats:

  • I only looked at one version of the OpenJDK javac compiler
  • 我只看了一个版本的OpenJDK javac编译器

  • there are other (non-Sun/Oracle) Java bytecode compilers
  • 还有其他(非Sun / Oracle)Java字节码编译器

  • bytecodes can be generated or modified by other means .... including code obfuscators!
  • 字节码可以通过其他方式生成或修改....包括代码混淆器!


It is plausible that the two value pop behavior of POP2 was used in early Java bytecode compilers before the advent of JIT compilers. But now that we have JIT compilers, there is no point in the bytecode compilers "optimizing" two POP bytecodes to a POP2.

在JIT编译器出现之前,POP2的两个值pop流行为用于早期Java字节码编译器似乎是合理的。但是现在我们有了JIT编译器,字节码编译器没有必要“优化”两个POP字节码到POP2。

#2


2  

POP2 will definitely be called if you pop a double or long, such as

如果你弹出一个double或long,肯定会调用POP2,例如

thisMethodReturnsALong(); thisMethodReturnsADouble();

among other cases.

在其他情况下。

#1


1  

Based on my brief reading of the source code for the javac compiler in Java 8, there are no places where it will emit a POP2 to pop 2 category-1 values from the stack. If two category-1 values need to be popped, then two POP bytecodes will be emitted by the compiler.

基于我在Java 8中简要阅读javac编译器的源代码,没有地方可以发出POP2来从堆栈中弹出2个category-1值。如果需要弹出两个category-1值,则编译器将发出两个POP字节码。

Caveats:

  • I only looked at one version of the OpenJDK javac compiler
  • 我只看了一个版本的OpenJDK javac编译器

  • there are other (non-Sun/Oracle) Java bytecode compilers
  • 还有其他(非Sun / Oracle)Java字节码编译器

  • bytecodes can be generated or modified by other means .... including code obfuscators!
  • 字节码可以通过其他方式生成或修改....包括代码混淆器!


It is plausible that the two value pop behavior of POP2 was used in early Java bytecode compilers before the advent of JIT compilers. But now that we have JIT compilers, there is no point in the bytecode compilers "optimizing" two POP bytecodes to a POP2.

在JIT编译器出现之前,POP2的两个值pop流行为用于早期Java字节码编译器似乎是合理的。但是现在我们有了JIT编译器,字节码编译器没有必要“优化”两个POP字节码到POP2。

#2


2  

POP2 will definitely be called if you pop a double or long, such as

如果你弹出一个double或long,肯定会调用POP2,例如

thisMethodReturnsALong(); thisMethodReturnsADouble();

among other cases.

在其他情况下。