Skip to content
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

Should structs be freezeable? #12

Open
takikawa opened this issue Oct 21, 2021 · 1 comment
Open

Should structs be freezeable? #12

takikawa opened this issue Oct 21, 2021 · 1 comment

Comments

@takikawa
Copy link
Collaborator

Something that came up when I was working on a spec draft is what the interaction between freezing and structs should be. Normally sealed objects can still be frozen afterwards.

However, perhaps struct instances should not be freezable? I believe JS engines may need to modify flags, etc. in the hidden class on Object.freeze (e.g., https://searchfox.org/mozilla-central/source/js/src/vm/Shape.cpp#776), and struct hidden classes are intended to be fixed.

Additionally, in the shared struct case, there is a possibility of one thread freezing an object concurrent with mutations occurring in another thread. Would this be a problem?

@rbuckton
Copy link
Collaborator

Supporting Object.freeze could be problematic since it could be racy, but then again shared structs might be represented by an exotic object with a [[Set]] that could handle the race, similar to an SAB-backed TypedArray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants