[英]Is it possible to write a Java program which executes the FMOV instruction in an AArch64 computer?
According to the "Arm Architecture Reference Manual Armv8, for Armv8-A architecture profile", there is an instruction FMOV (scalar, immediate)
.根据《Arm Architecture Reference Manual Armv8, for Armv8-A architecture profile》,有一条指令
FMOV (scalar, immediate)
。 It is stated that "This instruction copies a floating-point immediate constant into the SIMD & FP destination register".声明“该指令将浮点立即数常量复制到 SIMD 和 FP 目标寄存器”。
Is it possible to write a simple Java program that executes this instruction in an AArch64 machine?是否可以编写一个简单的 Java 程序在 AArch64 机器中执行该指令? Also, how can I verify that the written program executes a particular instruction?
另外,如何验证编写的程序是否执行特定指令? Thanks.
谢谢。
PS1: I'm using Eclipse OpenJ9 VM ( https://www.eclipse.org/openj9 ). PS1:我正在使用 Eclipse OpenJ9 VM( https://www.eclipse.org/openj9 )。
PS2: As javap
is based on bytecode, it's not what I'm looking for. PS2:由于
javap
是基于字节码的,所以这不是我想要的。 I also tried below commands, but was unable to verify the instruction execution-我也尝试了以下命令,但无法验证指令执行 -
java -Xjit:limit={<function_name>} -Xjit:verbose,vlog=<vlogfile_name> <class_name>
java -Xjit:verbose,vlog=<vlogfile_name> <class_name>
Reading the armv8 spec:阅读 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.
一些浮点移动(寄存器)指令与高级 SIMD 指令 DUP、INS 和 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.
但是,Arm 建议在对标量浮点数据进行操作时使用 FMOV 指令,以避免创建取决于高级 SIMD 指令集的可用性的标量浮点代码。 Table C3-64 shows the Floating-point move (register) instructions.
表 C3-64 显示了浮点移动(寄存器)指令。
The spec suggests that this instruction is the only way to move from a floating point register to a general purpose register, if the listed SIMD instructions aren't available.规范表明,如果列出的 SIMD 指令不可用,则该指令是从浮点寄存器移动到通用寄存器的唯一方法。 So you need java code that converts a float to an int without performing a conversion, and a processor that doesn't have SIMD support.
因此,您需要 java 代码将浮点数转换为 int 而不执行转换,以及不支持 SIMD 的处理器。
The defacto way to do this in java seems to be Float.floatToIntBits
.在 java 中执行此操作的事实上的方法似乎是
Float.floatToIntBits
。
On my JVM install(hotspot jdk8u forest) this is implemented as a native function.在我的 JVM 安装(热点 jdk8u 森林)上,这是作为本机 function 实现的。 This native function eventually reaches
hotspot/src/share/vm/opto/library_call.cpp
, with the following code:这个原生的 function 最终到达了
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());
The definition of inline_fp_conversions
is in the same file and as far as I can tell could output a FMOV
instruction. inline_fp_conversions
的定义在同一个文件中,据我所知 output 是一条FMOV
指令。
Notably MoveF2INode
is emited, though this may end up calling native code instead of actually JIT'ing an FMOV
.值得注意的是
MoveF2INode
被发出,尽管这最终可能会调用本机代码而不是实际 JIT 的FMOV
。
I'm a little conflicted, since it appears this question could be a homework question.我有点矛盾,因为看起来这个问题可能是一个家庭作业问题。 But if this is the answer homework-issuer is looking for it seems like a dumb homework question, so I'm fine with this answer existing.
但是,如果这是作业发行人正在寻找的答案,那似乎是一个愚蠢的作业问题,所以我对现有的答案很好。
Although it is not possible to be certain if this instruction will be executed before the program runs, we can find-out the executed instructions by HotSpot Disassembler (hsdis) and the opcodes associated with the instructions of a simple Java program.虽然无法确定该指令是否会在程序运行之前执行,但我们可以通过 HotSpot Disassembler (hsdis) 找出执行的指令以及与简单 Java 程序的指令相关的操作码。 For getting the respective opcodes, first, a log file needs to be generated.
为了获取相应的操作码,首先需要生成一个日志文件。 Then, by using this log file, a trace file needs to be generated to find-out what the executed opcodes are for 'that' particular program.
然后,通过使用这个日志文件,需要生成一个跟踪文件来找出“那个”特定程序的执行操作码是什么。 In this case, it is better to limit the generation of the trace file for the targeted function only.
在这种情况下,最好只为目标 function 限制跟踪文件的生成。 Because that would be a big file otherwise.
因为否则那将是一个大文件。
A simple Java program with this statement- x = x*2.0F;
带有此语句的简单 Java 程序 -
x = x*2.0F;
running on a loop of 10 million times caused the execution of this instruction.在 1000 万次循环上运行导致该指令的执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.