简体   繁体   English

为什么CPU寄存器充当垃圾收集器的根?

[英]Why CPU registers act like roots for Garbage Collector?

Why CPU registers act like roots for Garbage Collector? 为什么CPU寄存器充当垃圾收集器的根? When a mutator pauses, so the garbage collector can scan the roots, the variables contents are flushed to memory (using a memory fence) so the registers dont contain data that isnt in memory... if my understanding is correct... 当更改器暂停时,垃圾回收器可以扫描根,变量内容被刷新到内存(使用内存隔离),因此寄存器不包含内存中不存在的数据...如果我的理解是正确的...

Why then do you need to scan them? 为什么然后需要扫描它们? I see this as redundancy... 我认为这是多余的...

The flushing to memory is an implementation detail. 刷新到内存是一个实现细节。 The important thing is that the data contained in registers at the time a GC cycle is initiated is treated as reachable, regardless of how or where that data is stored in memory during the GC cycle itself. 重要的是,在GC周期启动时,无论寄存器在内存中的存储方式或存储位置如何,都将GC周期启动时包含在寄存器中的数据视为可访问的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM