?um/p1-90`memory consistency model、またはmemory modelは、SharedArrayBufferにbackされた
memory modelは、evaluation中にSharedArrayBuffer上の
このsectionは、SharedArrayBuffers上の
Shared memory accesses(readsおよびwrites)は、以下で定義されるatomic accessesとdata accessesという2つのgroupsに分けられる。Atomic accessesはsequentially consistentである、すなわち
release-acquireなど、sequentially consistentより弱くunorderedより強いorderingsはsupportされない。
Shared Data Block eventは、ReadSharedMemory、WriteSharedMemory、またはReadModifyWriteSharedMemory
| Field Name | Value | Meaning |
|---|---|---|
| [[Order]] | ||
| [[NoTear]] | Boolean | このeventが、このeventとequal |
| [[Block]] | eventがoperateするblock。 | |
| [[ByteIndex]] | non-negative |
[[Block]]内のreadのbyte address。 |
| [[ElementSize]] | non-negative |
readのsize。 |
| Field Name | Value | Meaning |
|---|---|---|
| [[Order]] | ||
| [[NoTear]] | Boolean | このeventが、このeventとequal |
| [[Block]] | eventがoperateするblock。 | |
| [[ByteIndex]] | non-negative |
[[Block]]内のwriteのbyte address。 |
| [[ElementSize]] | non-negative |
writeのsize。 |
| [[Payload]] | 他のeventsによってreadされる |
| Field Name | Value | Meaning |
|---|---|---|
| [[Order]] | Read-modify- |
|
| [[NoTear]] | Read-modify- |
|
| [[Block]] | eventがoperateするblock。 | |
| [[ByteIndex]] | non-negative |
[[Block]]内のread-modify-writeのbyte address。 |
| [[ElementSize]] | non-negative |
read-modify-writeのsize。 |
| [[Payload]] | [[ModifyOp]]に渡される |
|
| [[ModifyOp]] | readされた |
Shared Data Block eventsは、
Shared Data Block event eのmemory rangeを、e.[[ByteIndex]](inclusive)からe.[[ByteIndex]] + e.[[ElementSize]](exclusive)までの
考慮されるべきhost-specific synchronizing eventsの例は:SharedArrayBufferをあるpostMessage)、
Eventsは、以下で定義されるrelationsによって
Agent Events Recordは、以下のfieldsを持つ
| Field Name | Value | Meaning |
|---|---|---|
| [[AgentSignifier]] | このorderingをevaluationのresultとして生じさせた |
|
| [[EventList]] | Eventsはevaluation中にlistへappendされる。 | |
| [[AgentSynchronizesWith]] | operational semanticsによって導入された |
Chosen Value Recordは、以下のfieldsを持つ
| Field Name | Value | Meaning |
|---|---|---|
| [[Event]] | このchosen valueのために導入された |
|
| [[ChosenValue]] | evaluation中にnondeterministically chosenされたbytes。 |
| Field Name | Value | Meaning |
|---|---|---|
| [[EventsRecords]] | ||
| [[ChosenValues]] |
empty candidate executionは、そのfieldsがempty
The abstract operation EventSet takes argument execution (a
The abstract operation SharedDataBlockEventSet takes argument execution (a
The abstract operation HostEventSet takes argument execution (a
The abstract operation ComposeWriteEventBytes takes arguments execution (a
read-modify-write modification [[ModifyOp]]は、
このabstract operationは、
The abstract operation ValueOfReadEvent takes arguments execution (a
以下のrelationsおよびmathematical functionsは、particular
各
このpostMessageなどの追加のsynchronization mechanismsを提供することをallowする。
events eventAおよびeventBについて、以下のconditionsのいずれかがtrueなら、eventAはexecutionにおいてeventBのhappens-beforeである。
happens-beforeは
直観的には、このrequirementは、
executionにおいてreadEventがwriteEventから
このclauseはさらにequal
このclauseは
is-memory-order-beforeは
すべてのprogramsには少なくとも1つのvalid executionが存在する。
execution executionと、
execution executionと、
execution executionは、
programは、そのすべてのexecutionsがdata race freeであるならdata race freeである。
以下は、shared memoryを扱うECMAScript programmers向けのguidelinesである。
programsは
より一般には、programが
以下は、shared memoryを使用するprogramsに対するcompiler transformationsを書くECMAScript implementers向けのguidelinesである。
multi-
agent-order sliceを、single
shared memoryがない場合にvalidなagent-order sliceの任意のtransformationは、以下のexceptionsを除き、shared memoryがある場合にもvalidである。
Atomics are carved in stone:Program transformationsは、[[Order]]が
(実際には、reorderingsの禁止は、compilerに、すべての
Reads must be stable:任意のgiven shared memory readは、execution内でsingle valueのみをobserveしなければならない。
(例えば、program内でsemanticallyにはsingle readであるものが複数回executedされた場合、その後programはreadされたvaluesのうち1つだけをobserveすることをallowedされる。rematerializationとして知られるtransformationはこのruleにviolateする可能性がある。)
Writes must be stable:shared memoryへのすべてのobservable writesは、execution内のprogram semanticsからfollowしなければならない。
(例えば、transformationは、より小さいdatumを書くためにより大きなlocation上のread-modify-write operationsを使用すること、programがwriteできなかったvalueをmemoryにwriteすること、またはreadされたlocationがread後に別の
Possible read values must be non-empty:Program transformationsは、shared memory readのpossible read valuesをemptyにしてはならない。
(counterintuitively、このruleはeffectとしてwrites上のtransformationsを制限する。なぜなら、writesは
validのままであるtransformationsの例は:同じlocationからの複数のnon-atomic readsをmergeすること、non-atomic readsをreorderすること、speculative non-atomic readsをintroduceすること、同じlocationへの複数のnon-atomic writesをmergeすること、different locationsへのnon-atomic writesをreorderすること、およびterminationに影響する場合でもnon-atomic readsをloopsの外へhoistすること、である。一般に、aliased
以下は、shared memory accessesのためにmachine codeを生成するECMAScript implementers向けのguidelinesである。
memory modelsがARMまたはPowerのものと同程度以上にweakでないarchitecturesについては、non-atomic storesおよびloadsはtarget architecture上のbare storesおよびloadsへcompileしてよい。Atomic storesおよびloadsはsequential consistencyをguaranteeするinstructionsへcompileされてよい。そのようなinstructionsが存在しない場合、bare storeまたはloadの両側にbarriersを配置するなど、memory barriersをemployすることになる。Read-modify-write operationsは、x86上のLOCK-prefixed instructions、ARM上のload-exclusive/store-exclusive instructions、およびPower上のload-link/store-conditional instructionsなど、target architecture上のread-modify-write instructionsへcompileされてよい。
Specifically、
Naive code generationはこれらのpatternsを使用する:
そのmappingは、
LOCK-prefixed instructionsを使用するからである。多くのplatformsにはseveral strengthsのfencesがあり、sequential consistencyをdestroyしない特定のcontextsではweaker fencesを使用できる。