關於:MUW structure (STM word、hash code、字符狀態位、對象的同步鎖、EMU)

MUW structure
-------------
The structure of the MUW on a 32-bit system is as follows:
  | 31            3 | 2  | 1 0 |
  |      payload    |mark| tag |

And on a 64-bit system:
  | 63            3 | 2  | 1 0 |
  |      payload    |mark| tag |

This class provides fast-path code for a number of operations which
potentially require additional information to be associated with each
object in the heap:
這個類提供"快速管道"代碼,用於操作一批建立在堆上的對象,這些對象需要更
多的相關信息.

- Object ownership and versioning information needed by the STM
  implementation.
- 對象擁有"STM?"執行,所需的所有權信息和版本信息。

- Location-insensitive hash codes that have been allocated to objects.
- 對位置不敏感的,並且已經分配給對象的hashcode。

- Monitor objects that have been associate with objects.
- 將同步對象鎖與對象進行關聯.

- StringState bits associated with String objects
- 將StringState位與String對象相關

Overview
--------
Each object has a value of type MultiUseWord (MUW) held as a header
word.  This can be used directly for any *one* of the three purposes
listed above.  If more than one kind of usage is required on the same
object then the MUW is "inflated" -- i.e. replaced by a value that
indicates an external multi-use object (EMU) which contains space for
all three purposes.
對象都會有一個類型相關的MUW值,作爲"header word?".能夠直接用於上這三個
目標之一.如果一個對象需要同時使用多個屬性,MUW將被擴充後的EMU取代,MUW
的值能提供更多的空間,達到上述三個目標。

NB: the StringState and HashCode words share the same storage locations,
distinguished by value.  We rely on ChooseHashCode to not use small
integer values corresponding to the StringState enumeration.
注:StringState和hashCode能夠被區分,並共享相同的存儲位置.我們避免選擇
小數值的HashCode來對應StringState枚舉值。

In addition, the MUW provides a single per-object 'mark' bit.  This
is used in the MemoryAccounting module when counting the volume of
different kinds of object in the heap.  Placing this bit in the MUW
(rather than using spare vtable-bits as the GC does) allows
memory accounting to be invoked at any time (e.g. after a crash during
a GC).
此外,MUW提供了每個單一對象的'mark'標誌.這個主要是用於MemoryAccounting
模塊計算不同類型的對象在堆中的容量。設置該MUW標誌(好於將虛表位置爲GC)
允許內存在任何時候計數(比如,在GC操作崩潰後).

On 32-bit systems, this allows us to support pointers through the entire
4 GB address range.  However, it means that pointers must be constrained
to fit in the limited space of the payload.  For instance, the Monitor
is 8-byte aligned so the low 3 bits are available for encoding the tag
and mark.
在32位系統中,這種結構完全支持4GB範圍的內存尋址.但是,這也意味着指針必須適
應有限空間的有效荷載.例如,"Monitor?"是8位對齊的,所以最後3位是空閒的,可用
於tag和mark的編碼.

By convention, all modules using the mark bit must (a) work with the
world stopped and (b) leave all object's mark bits 0 after their operation.
(They may assume this is true when they start).  This restriction avoids
needing to mask off the mark bit in common code paths in this file.
按照慣例,所有模塊使用該Mark掩碼,首先在操作時必須稍等片刻,然後在離開所有
對象時要將mark掩碼復位.(假設開始時是這樣的)。些約定能夠避免,在該文件中
通用代碼的標誌位復位工作.

The payload field forms the majority of the MUW.  The contents of the
payload are taken from bits 3..31 in the MUW, padded with three 0-bits
at the least significant end.  This means that the payload can hold a
pointer to an 8-byte aligned address.
有效載荷位域構成了MUW的主體。載荷內容取自MUW中3..31位,在未尾填充的3個0
標誌着結束。這意味着,有效載荷可以容納一個指針,並指向8字節對齊的地址.

The tag values distinguish between four states that the MUW can be in:
tag標記值區分了下列4種MUW

00 => The MUW is either unused (if the payload is 0), or holds the
      STM word for the object (if the payload is non-0).
00 => 如果地址爲0,表示未使用,否則包含object的"STM word?".

01 => The payload holds the object's hash code or StringState bits.
01 => 包含object's的hash code或"字符狀態位?".

10 => The payload refers to the object's Monitor.
10 => 指向該對象的同步鎖.

11 => The payload refers to an external multi-use object (EMU).
11 => 指向"EMU?"

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章