JVM源代码中的"intrinsify"是什么意思? [英] What does 'intrinsify' mean in the JVM source code?

查看:279
本文介绍了JVM源代码中的"intrinsify"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"intrinsify"是否意味着JVM的源代码在某种程度上是保守的",但是当JVM预热时,JIT编译器可以进行一些优化吗? 例如,

Does 'intrinsify' means that source code of JVM is somewhat 'conservative', but the JIT compiler can do some optimization when the JVM warms up? For example,

UNSAFE_ENTRY(void, Unsafe_SetOrderedObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h))
  UnsafeWrapper("Unsafe_SetOrderedObject");
  oop x = JNIHandles::resolve(x_h);
  oop p = JNIHandles::resolve(obj);
  void* addr = index_oop_from_field_offset_long(p, offset);
  OrderAccess::release();
  if (UseCompressedOops) {
    oop_store((narrowOop*)addr, x);
  } else {
    oop_store((oop*)addr, x);
  }
  OrderAccess::fence();  <==There is a full memory barrier to ensure visibility which is NOT strictly required
UNSAFE_END

不需要putOrderedObject来确保immediate visiblity,但是我们可以看到存储将附加的内存屏障附加到指定的对象,所以我说JVM是conservative,但是JIT编译器可以对此进行优化在运行时出现内存屏障,这就是所谓的instrinsify,对吗?

the putOrderedObject is not required to ensure immediate visiblity, but we can see that there is a full memory barrier attached the store to a specified object, so I said the JVM is conservative, but a JIT compiler can optimize this memory barrier out during runtime, this is what so called instrinsify, am I right?

推荐答案

JVM内在函数是JDK中的方法,为此JIT发出专门的机器指令序列,这些序列可以直接内联到调用程序中.例如,在x86上,Integer.bitCount(int)可以替换为POPCNT指令.

JVM intrinsics are methods in the JDK for which the JITs emit specialized sequences of machine instructions which can be directly inlined into the caller. For example on x86 Integer.bitCount(int) can be replaced with the POPCNT instruction.

纯Java实现可能太复杂了,无法被窥视孔优化识别(例如,与带移位的仿真旋转不同),并且JNI开销将扼杀通过将手工装配用于单个操作而获得的任何性能提升.

The pure java implementation is likely too complex to be recognized by peephole optimizations - unlike emulate-rotation-with-shifts for example - and JNI overhead would kill any performance gains from using hand-crafted assembly for a single operation.

许多不安全的方法也被引入,因此这些方法调用不是优化程序的黑匣子(就像JNI方法一样),是的,这使其不那么保守.但这只是内在化的子属性.

Many unsafe methods are also intrinsified so that those method calls are not black boxes for the optimizer (as JNI methods would be), which, yes, allows it to be less conservative. But that's just a sub-property of intrinsification.

  • Wikipedia article
  • Some slides on hotspot intrinsics

(这些基本上是热点内在函数"在google上排名最高的结果)

(those are basically the top google results for "hotspot intrinsics")

这篇关于JVM源代码中的"intrinsify"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆