-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some expected executions not observed when en_SINGLE_WRITES disabled #22
Comments
Hi Conrad, |
Hi Conrad, |
Hi Cristian In the current specification, AllocateSharedArrayBuffer inserts Init events covering the length of the buffer through CreateSharedByteDataBlock, with each Init event being a single-byte write of the value 0: https://tc39.github.io/ecma262/#sec-createsharedbytedatablock. This is the only place I can find in the spec where Init events are used. |
The CreateSharedByteDataBlock( size ) is parameterized on the size of the SharedArrayBuffer. In fact, the function initializes to 0 every byte (see for loop at step 6.). |
But each byte is initialised in the loop with a separate 1-byte Init event, not one Init event covering the entire size. If I'm interpreting the spec correctly, this means that a 2-byte read event can read-from an aligned 2-byte write event, but still tear with the init event(s), since it appears in the model as two 1-byte writes. That being said, I don't think the informal intention of the spec authors was to allow this behaviour (I think it's a bug and am planning to draft a normative PR) - I was just expecting to observe it in EMME to confirm I hadn't misread the spec. |
Now I see your point. I have added a new branch that supports the multiple init values (https://github.com/FMJS/EMME/tree/multiple_inits). |
Thanks for the quick response! I'll have a play around with this. |
Hi Cristian!
I've found EMME very useful for double-checking expectations I've had about the JS memory model. I currently believe that the JS spec mis-specifies "Init" actions, and I tried to use EMME to confirm that the pathological executions I was expecting were exhibited, but it's not giving the output I was expecting.
For the following test, with en_SINGLE_WRITES disabled, I expected to observe 4 valid executions, for each bytewise combination of thread 2 reading from the init event/thread 1's write.
test.zip (see test.bex in the zip)
However, EMME only reported 2 executions, where thread 2 reads from one or the other, but never a bytewise combination. Graphs are included in the above zip.
However, if I add an unrelated read event on a different thread, at a disjoint section of the arraybuffer, I get the 4 executions I was expecting.
test_unrelated_read.zip (see test.bex in the zip)
This seems to be affected by the tear-free reads predicate. In the first example, if I comment this predicate out of the model, I observe the 4 executions I'm expecting. I don't believe that the tear-free reads condition should affect my test, since "Init" events are specified as being one byte in size.
The text was updated successfully, but these errors were encountered: