Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAtomics and memory model specification questions/issues #800
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Feb 6, 2017
Collaborator
re "semantic object": Probably a different term should be used. (Elsewhere, "specification type value" is used, but it's kind of clunky.)
At first glance, it seems like a WaiterList could be modelled as just a List. But apparently it also has a 'critical section' (which is never defined, by the way), so perhaps it would be better modelled as a Record with 2 fields.
|
re "semantic object": Probably a different term should be used. (Elsewhere, "specification type value" is used, but it's kind of clunky.) At first glance, it seems like a WaiterList could be modelled as just a List. But apparently it also has a 'critical section' (which is never defined, by the way), so perhaps it would be better modelled as a Record with 2 fields. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Feb 6, 2017
Collaborator
re "semantic function": I think this just means a function in the mathematical sense. The 'Algorithm Conventions' clause uses the term "mathematical function" for this. The RegExp clause uses the term "internal procedure" for something similar.
Alternatively, I think you could argue that the things referred to as "semantic functions" qualify as "abstract operations".
|
re "semantic function": I think this just means a function in the mathematical sense. The 'Algorithm Conventions' clause uses the term "mathematical function" for this. The RegExp clause uses the term "internal procedure" for something similar. Alternatively, I think you could argue that the things referred to as "semantic functions" qualify as "abstract operations". |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lars-t-hansen
Feb 6, 2017
Contributor
Related background:
tc39/ecmascript_sharedmem#118
tc39/ecmascript_sharedmem#120
I have no clear memory of where "semantic function" came from, but ISTR it is the result of an earlier bikeshed aimed at ensuring that there was no confusion between these functions and ES functions, at the time when the higher-order operation was introduced (the original spec draft just spelled out the algorithms individually). Any term will suffice as long as that confusion is avoided.
(SIMD has the same concern, presumably.)
|
Related background: I have no clear memory of where "semantic function" came from, but ISTR it is the result of an earlier bikeshed aimed at ensuring that there was no confusion between these functions and ES functions, at the time when the higher-order operation was introduced (the original spec draft just spelled out the algorithms individually). Any term will suffice as long as that confusion is avoided. (SIMD has the same concern, presumably.) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lars-t-hansen
Feb 6, 2017
Contributor
The critical section is orthogonal to the list, it just needs to be clear that the critical section protects that list. The list can be any data structure, since it's only accessed inside the critical section.
What a "Critical Section" is was never defined because, like addition, it is supposed to be a well understood abstraction. Obviously I could have been wrong about that, but at this point I expect there's 60 years of usage of the term backing it. (Not meaning to be snide, just factual.)
|
The critical section is orthogonal to the list, it just needs to be clear that the critical section protects that list. The list can be any data structure, since it's only accessed inside the critical section. What a "Critical Section" is was never defined because, like addition, it is supposed to be a well understood abstraction. Obviously I could have been wrong about that, but at this point I expect there's 60 years of usage of the term backing it. (Not meaning to be snide, just factual.) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Feb 6, 2017
Collaborator
(Note that 60 years of usage doesn't exempt a term from definition: the spec even defines 'context-free grammar'!)
Anyway, while I more-or-less understand what a critical section is, it's not clear to me how one comes to be associated with a list of agents. For me, it would make sense to read "the critical section of an algorithm or process" but not "the critical section for a data structure".
|
(Note that 60 years of usage doesn't exempt a term from definition: the spec even defines 'context-free grammar'!) Anyway, while I more-or-less understand what a critical section is, it's not clear to me how one comes to be associated with a list of agents. For me, it would make sense to read "the critical section of an algorithm or process" but not "the critical section for a data structure". |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
syg
Feb 7, 2017
Member
@anba Regarding the reference to "Access Atomicity" in 27.7.3 Tear Free Reads, it is a stale note from the SAB draft referencing an informative section that was not merged into the final draft. I'll file an editorial PR to remove.
|
@anba Regarding the reference to "Access Atomicity" in 27.7.3 Tear Free Reads, it is a stale note from the SAB draft referencing an informative section that was not merged into the final draft. I'll file an editorial PR to remove. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
syg
Feb 9, 2017
Member
@anba I don't understand the point about using numbers and list of bytes values. The list-of-bytes abstraction is to interface with the event semantics of the memory model. Is the confusion here the same as the "semantic function" one, i.e., the exact semantics of the add semantic function acting on two lists-of-bytes?
|
@anba I don't understand the point about using numbers and list of bytes values. The list-of-bytes abstraction is to interface with the event semantics of the memory model. Is the confusion here the same as the "semantic function" one, i.e., the exact semantics of the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Feb 9, 2017
Contributor
The issue is that the conversion from list of bytes -> Number value -> list of bytes isn't sufficiently specified because the result after applying the operation can exceed the input type's domain as demonstrated for the input « 255 ».
I'd prefer to add [[ElementType]] to ReadModifyWriteSharedMemory and to change 27.5.4 ComposeWriteEventBytes, step 3.d.iii as follows:
- Let isLittleEndian be the value of the [[LittleEndian]] field of the surrounding agent's Agent Record.
- Let bytesNum be RawBytesToNumber(W.[[ElementType]], bytesRead, isLittleEndian).
- Let payloadNum be RawBytesToNumber(W.[[ElementType]], W.[[Payload]], isLittleEndian).
- Let result be W.[[ModifyOp]](bytesNum, payloadNum).
- Let bytesModified be NumberToRawBytes(W.[[ElementType]], result, isLittleEndian).
And then update the various semantic functions for Atomics.* to operate on Number values.
|
The issue is that the conversion from list of bytes -> Number value -> list of bytes isn't sufficiently specified because the result after applying the operation can exceed the input type's domain as demonstrated for the input « 255 ». I'd prefer to add [[ElementType]] to ReadModifyWriteSharedMemory and to change 27.5.4 ComposeWriteEventBytes, step 3.d.iii as follows:
And then update the various semantic functions for Atomics.* to operate on Number values. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
syg
Feb 9, 2017
Member
I see, so explicitly spelling out the prose "applies the addition operation to the Number values corresponding to the List of byte values arguments and returns a List of byte values corresponding to the result of that operation" and clarifies overflow.
That is a-ok with me.
|
I see, so explicitly spelling out the prose "applies the addition operation to the Number values corresponding to the List of byte values arguments and returns a List of byte values corresponding to the result of that operation" and clarifies overflow. That is a-ok with me. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Feb 10, 2017
Contributor
and clarifies overflow.
For overflow but also in general to select the correct length of the returned List of byte values (I forgot to mention this aspect in my last comment). For example the Number value 0 could be encoded as « 0 » or « 0, 0 » or « 0, 0, 0, 0 », so we need to define the type of the semantic function as (List[N], List[N]) → List[N]. Or switch to using Number values as proposed above.
For overflow but also in general to select the correct length of the returned List of byte values (I forgot to mention this aspect in my last comment). For example the Number value |
anba commentedFeb 6, 2017
24.4.1.3 GetWaiterList
24.4.*
addwhen called with « 255 » and « 255 » is currently somewhat ambiguous, because the element type is not given which means i.a. that the length of the returned list of byte values isn't specified.27.7.3 Tear Free Reads