问题描述
我知道Roots是:
- 静态字段
- 方法参数
- 本地fielfs
- f-队列,其中还包含指向将要完成的对象的指针
- cpu寄存器< = ???
现在我们来讨论一下寄存器。
这些代码可以包含就像:
mov bx,0034h; bx = 52(存储在16位中)
mov cl,bl; cl = bx的低8位
mov eax,ecx
call print_int
但是 wait !
如果我没有弄错,这是持有这些< 那么为什么要写这个 TWICE ? (或从另一个方向?) 为什么写(例如) 我的关于寄存器的问题来自这里: String.Split()产生一个数组,它必须保持可达。但是没有指向它的变量或参数,优化器很可能会将引用保存在寄存器中。 所以CPU(地址)寄存器必须被认为是根的一部分。 I know that Roots are : Now lets talk about registers. the code whch they can contain is like : but wait ! If im not mistaken , this is the actually code which was Holding those those So why to write this TWICE ? ( or from another direction ?) Why to write ( for example ) my question about registers comes from here : Consider String.Split() produces an array, it must be kept reachable for (part of ) this statement. But there is no variable or parameter pointing to it, the optimizer will most likely keep the reference in a register. So CPU (address) registers must be considered part of the roots. 这篇关于GC Roots的误解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! static
,本地
和参数
- 从第一位! p>
Foo f = new Foo();
**还有**
mov bx,0034h //< --------代表`f`地址或类似的那个
编辑
string sentence = ...
int wordCount = sentence.Split('') 。长度;
mov bx, 0034h ; bx = 52 (stored in 16 bits)
mov cl, bl ; cl = lower 8-bits of bx
mov eax, ecx
call print_int
static
, local
and parameters
- from the first place ! Foo f = new Foo();
**and also**
mov bx, 0034h //<-------- represents the `f` address or something like that
edit
string sentence = ...
int wordCount = sentence.Split(' ').Length;