<tfoot id='9ckKW'></tfoot>

    1. <small id='9ckKW'></small><noframes id='9ckKW'>

    2. <i id='9ckKW'><tr id='9ckKW'><dt id='9ckKW'><q id='9ckKW'><span id='9ckKW'><b id='9ckKW'><form id='9ckKW'><ins id='9ckKW'></ins><ul id='9ckKW'></ul><sub id='9ckKW'></sub></form><legend id='9ckKW'></legend><bdo id='9ckKW'><pre id='9ckKW'><center id='9ckKW'></center></pre></bdo></b><th id='9ckKW'></th></span></q></dt></tr></i><div id='9ckKW'><tfoot id='9ckKW'></tfoot><dl id='9ckKW'><fieldset id='9ckKW'></fieldset></dl></div>
        <bdo id='9ckKW'></bdo><ul id='9ckKW'></ul>

      1. <legend id='9ckKW'><style id='9ckKW'><dir id='9ckKW'><q id='9ckKW'></q></dir></style></legend>
      2. JVM 压缩 Oops 背后的技巧

        Trick behind JVM#39;s compressed Oops(JVM 压缩 Oops 背后的技巧)

          <legend id='4HhZd'><style id='4HhZd'><dir id='4HhZd'><q id='4HhZd'></q></dir></style></legend>
          <tfoot id='4HhZd'></tfoot>

            <bdo id='4HhZd'></bdo><ul id='4HhZd'></ul>
              1. <i id='4HhZd'><tr id='4HhZd'><dt id='4HhZd'><q id='4HhZd'><span id='4HhZd'><b id='4HhZd'><form id='4HhZd'><ins id='4HhZd'></ins><ul id='4HhZd'></ul><sub id='4HhZd'></sub></form><legend id='4HhZd'></legend><bdo id='4HhZd'><pre id='4HhZd'><center id='4HhZd'></center></pre></bdo></b><th id='4HhZd'></th></span></q></dt></tr></i><div id='4HhZd'><tfoot id='4HhZd'></tfoot><dl id='4HhZd'><fieldset id='4HhZd'></fieldset></dl></div>
                    <tbody id='4HhZd'></tbody>

                  <small id='4HhZd'></small><noframes id='4HhZd'>

                  本文介绍了JVM 压缩 Oops 背后的技巧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我知道 HotSpot VM 现在默认启用压缩 oops.从 Java SE 6u23 开始,它通过 VM 选项 -XX:+UseCompressedOops 对此提供了支持.我知道它允许有效地利用 CPU 缓存,因为 CPU 缓存可以容纳更多的引用,而不是它们必须处理 64 位大小的引用.但我不明白的是,仅使用 32 位 JVM 可以寻址多达 264 个地址.

                  So I understand the compressed oops is enabled by default in HotSpot VM now. It has support for this from Java SE 6u23 onwards through the VM option -XX:+UseCompressedOops. I understand that it allows for efficient CPU cache utilization as the CPU caches can hold a larger number of references than if they had to deal with 64 bit sized references. But what I do not understand is how using only 32 bits JVM can address up to 264 addresses.

                  为了简化问题,我们如何仅使用 2 位寻址多达 24 个内存地址?这种地址方案的可能编码/解码是什么?

                  To simplify the problem how can we address up to 24 memory address's using just 2 bits? What can be a possible encoding/decoding of such an address scheme?

                  推荐答案

                  压缩oops的详细解释见Hotspot JVM 中的压缩 oops" 文章,作者 John Rose @ Oracle.

                  For a detailed explanation of compressed oops, see the "Compressed oops in the Hotspot JVM" article by John Rose @ Oracle.

                  TL;DR 版本是:

                  • 在现代计算机架构中,内存地址是字节地址,
                  • Java 对象引用是指向单词开头的地址1,
                  • 在 64 位机器上,字对齐意味着对象引用/地址的低 3 位为零2
                  • 因此,通过将地址向右移动 3 位,我们可以将 64 位地址的最多 35 位压缩"为 32 位字,
                  • 而且,解压缩可以通过左移 3 位来完成,这会将这 3 个零位放回原处,
                  • 35 位寻址允许我们使用适合 64 位机器上 32 位(半)字的压缩 oop 来表示最多 32 GB 堆内存的对象指针.

                  请注意,这适用于 64 位 JVM.我们仍然需要能够寻址包含(最多)32 GB 堆的内存1,这意味着 64 位硬件地址(在现代 CPU/计算机架构上).

                  Note that this only works on a 64-bit JVM. We still need to be able to address the memory containing that (up to) 32 GB heap1, and that means 64-bit hardware addresses (on modern CPUs / computer architectures).

                  还请注意,这样做会有一点点惩罚;即在常规和压缩引用之间转换所需的移位指令.但是,另一方面是消耗的实际内存更少3,因此内存缓存通常更有效.

                  Note also that there is a small penalty in doing this; i.e. the shift instructions required to translate between regular and compressed references. However, the flip side is that less actual memory is consumed3, and memory caches are typically more effective as a consequence.

                  1 - 这是因为现代计算机架构针对字对齐内存访问进行了优化.

                  2 - 这假设您没有使用 -XX:ObjectAlignmentInBytes 来增加其默认(和最小值)8 字节的对齐值.

                  2 - This assumes that you haven't used -XX:ObjectAlignmentInBytes to increase the alignment from its default (and minimum) value of 8 bytes.

                  3 - 事实上,内存节省是特定于应用程序的.它取决于平均对象对齐损耗、参考与非参考字段的比率等.如果您考虑调整对象对齐,它会变得更加复杂.

                  为了简化问题,我们如何仅使用 2 位寻址多达 24 个内存地址?这种地址方案的可能编码/解码是什么?

                  To simplify the problem how can we address up to 24 memory addresses using just 2 bits? What can be a possible encoding/decoding of such an address scheme?

                  您不能寻址 24 字节地址.但是您可以使用 2 位字地址寻址 22 个字地址(假设为 32 位字).如果您可以假设所有字节地址都是字对齐的,那么您可以将 4 位字节地址压缩为 2 位字地址,方法是将其移动 2 位位置.

                  You can't address 24 byte addresses. But you can address 22 word addresses (assuming 32-bit words) using 2-bit word addresses. If you can assume that all byte addresses are word-aligned, then you can compress a 4-bit byte address as 2-bit word address by shifting it by 2-bit positions.

                  这篇关于JVM 压缩 Oops 背后的技巧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  <i id='8LTNE'><tr id='8LTNE'><dt id='8LTNE'><q id='8LTNE'><span id='8LTNE'><b id='8LTNE'><form id='8LTNE'><ins id='8LTNE'></ins><ul id='8LTNE'></ul><sub id='8LTNE'></sub></form><legend id='8LTNE'></legend><bdo id='8LTNE'><pre id='8LTNE'><center id='8LTNE'></center></pre></bdo></b><th id='8LTNE'></th></span></q></dt></tr></i><div id='8LTNE'><tfoot id='8LTNE'></tfoot><dl id='8LTNE'><fieldset id='8LTNE'></fieldset></dl></div>
                • <legend id='8LTNE'><style id='8LTNE'><dir id='8LTNE'><q id='8LTNE'></q></dir></style></legend>

                    <bdo id='8LTNE'></bdo><ul id='8LTNE'></ul>
                        1. <small id='8LTNE'></small><noframes id='8LTNE'>

                            <tfoot id='8LTNE'></tfoot>
                              <tbody id='8LTNE'></tbody>