是否可以在 AArch64 计算机中编写执行 FMOV 指令的 Java 程序?
Is it possible to write a Java program which executes the FMOV instruction in an AArch64 computer?
根据《Arm Architecture Reference Manual Armv8, for Armv8-A architecture profile》,有一条指令FMOV (scalar, immediate)
。声明“该指令将浮点立即数复制到 SIMD 和 FP 目标寄存器”。
是否可以编写一个简单的 Java 程序在 AArch64 机器上执行这条指令?另外,如何验证编写的程序是否执行了特定指令?谢谢。
PS1:我正在使用 Eclipse OpenJ9 VM (https://www.eclipse.org/openj9)。
PS2:由于javap
是基于字节码的,所以这不是我要找的。我也尝试了以下命令,但无法验证指令执行-
java -Xjit:limit={<function_name>} -Xjit:verbose,vlog=<vlogfile_name> <class_name>
java -Xjit:verbose,vlog=<vlogfile_name> <class_name>
正在阅读 armv8 规范:
The Floating-point move (register) instructions copy a scalar floating-point value from one register to another
register without performing any conversion.
Some of the Floating-point move (register) instructions overlap with the functionality provided by the Advanced
SIMD instructions DUP , INS , and UMOV . However, Arm recommends using the FMOV instructions when operating on
scalar floating-point data to avoid the creation of scalar floating-point code that depends on the availability of the
Advanced SIMD instruction set.
Table C3-64 shows the Floating-point move (register) instructions.
规范表明,如果列出的 SIMD 指令不可用,则此指令是从浮点寄存器移动到通用寄存器的唯一方法。因此,您需要 java 无需执行转换即可将 float 转换为 int 的代码,以及不支持 SIMD 的处理器。
在 java 中执行此操作的实际方法似乎是 Float.floatToIntBits
。
在我的 JVM 安装(热点 jdk8u 林)中,这是作为本机函数实现的。本机函数最终到达hotspot/src/share/vm/opto/library_call.cpp
,代码如下:
case vmIntrinsics::_floatToRawIntBits:
case vmIntrinsics::_floatToIntBits:
case vmIntrinsics::_intBitsToFloat:
case vmIntrinsics::_doubleToRawLongBits:
case vmIntrinsics::_doubleToLongBits:
case vmIntrinsics::_longBitsToDouble:
return inline_fp_conversions(intrinsic_id());
inline_fp_conversions
的定义在同一个文件中,据我所知可以输出一条 FMOV
指令。
值得注意的是 MoveF2INode
被发出,尽管这可能最终调用本机代码而不是实际 JIT 一个 FMOV
.
我有点矛盾,因为看起来这道题可能是一道作业题。但是,如果这是 homework-issuer 正在寻找的答案,这似乎是一个愚蠢的家庭作业问题,所以我对现有的答案没有意见。
虽然无法确定这条指令是否会在程序运行前执行,但我们可以找出HotSpot Disassembler(hsdis)执行的指令以及与指令相关的操作码,一个简单的Java 程序。要获取相应的操作码,首先需要生成一个日志文件。然后,通过使用这个日志文件,需要生成一个跟踪文件来找出 'that' 特定程序执行的操作码是什么。在这种情况下,最好只为目标函数限制跟踪文件的生成。因为否则那将是一个大文件。
一个带有这条语句的简单Java程序- x = x*2.0F;
运行 在一千万次的循环中导致了这条指令的执行。
根据《Arm Architecture Reference Manual Armv8, for Armv8-A architecture profile》,有一条指令FMOV (scalar, immediate)
。声明“该指令将浮点立即数复制到 SIMD 和 FP 目标寄存器”。
是否可以编写一个简单的 Java 程序在 AArch64 机器上执行这条指令?另外,如何验证编写的程序是否执行了特定指令?谢谢。
PS1:我正在使用 Eclipse OpenJ9 VM (https://www.eclipse.org/openj9)。
PS2:由于javap
是基于字节码的,所以这不是我要找的。我也尝试了以下命令,但无法验证指令执行-
java -Xjit:limit={<function_name>} -Xjit:verbose,vlog=<vlogfile_name> <class_name>
java -Xjit:verbose,vlog=<vlogfile_name> <class_name>
正在阅读 armv8 规范:
The Floating-point move (register) instructions copy a scalar floating-point value from one register to another register without performing any conversion. Some of the Floating-point move (register) instructions overlap with the functionality provided by the Advanced SIMD instructions DUP , INS , and UMOV . However, Arm recommends using the FMOV instructions when operating on scalar floating-point data to avoid the creation of scalar floating-point code that depends on the availability of the Advanced SIMD instruction set. Table C3-64 shows the Floating-point move (register) instructions.
规范表明,如果列出的 SIMD 指令不可用,则此指令是从浮点寄存器移动到通用寄存器的唯一方法。因此,您需要 java 无需执行转换即可将 float 转换为 int 的代码,以及不支持 SIMD 的处理器。
在 java 中执行此操作的实际方法似乎是 Float.floatToIntBits
。
在我的 JVM 安装(热点 jdk8u 林)中,这是作为本机函数实现的。本机函数最终到达hotspot/src/share/vm/opto/library_call.cpp
,代码如下:
case vmIntrinsics::_floatToRawIntBits:
case vmIntrinsics::_floatToIntBits:
case vmIntrinsics::_intBitsToFloat:
case vmIntrinsics::_doubleToRawLongBits:
case vmIntrinsics::_doubleToLongBits:
case vmIntrinsics::_longBitsToDouble:
return inline_fp_conversions(intrinsic_id());
inline_fp_conversions
的定义在同一个文件中,据我所知可以输出一条 FMOV
指令。
值得注意的是 MoveF2INode
被发出,尽管这可能最终调用本机代码而不是实际 JIT 一个 FMOV
.
我有点矛盾,因为看起来这道题可能是一道作业题。但是,如果这是 homework-issuer 正在寻找的答案,这似乎是一个愚蠢的家庭作业问题,所以我对现有的答案没有意见。
虽然无法确定这条指令是否会在程序运行前执行,但我们可以找出HotSpot Disassembler(hsdis)执行的指令以及与指令相关的操作码,一个简单的Java 程序。要获取相应的操作码,首先需要生成一个日志文件。然后,通过使用这个日志文件,需要生成一个跟踪文件来找出 'that' 特定程序执行的操作码是什么。在这种情况下,最好只为目标函数限制跟踪文件的生成。因为否则那将是一个大文件。
一个带有这条语句的简单Java程序- x = x*2.0F;
运行 在一千万次的循环中导致了这条指令的执行。