Repository navigation
[js-api] Use OrdinaryObjectCreate for GC objects - #138
Conversation
Create Exported GC Objects using OrdinaryObjectCreate and SetIntegrityLevel("frozen") rather than defining custom exotic internal methods, and update JS API tests to cover ordinary frozen object behavior.
|
@o-, can you take a look as well? |
|
Now that I think more on it, shouldn't they be sealed rather than frozen? It doesn't really make a difference for now, since they have no own properties. But in a possible future with "own properties", it would matter. |
| @@ -1581,103 +1580,22 @@ The <dfn constructor for="Tag" lt="Tag(type)">new Tag(|type|)</dfn> constructor | |||
| <h3 id="gc-exotic-objects">Garbage Collected Objects</h3> | |||
There was a problem hiding this comment.
Optional nit: Shouldn't we update the id here to something like "gc-objects" as well?
There was a problem hiding this comment.
Done. Gemini also added this oldids thing, which I hadn't known about, but apparently keeps old links working: https://speced.github.io/bikeshed/#id-gen.
| 1. Set |object|.\[[Set]] as specified in [=[[Set]] internal method of an Exported GC Object=]. | ||
| 1. Set |object|.\[[Delete]] as specified in [=[[Delete]] internal method of an Exported GC Object=]. | ||
| 1. Set |object|.\[[OwnPropertyKeys]] as specified in [=[[OwnPropertyKeys]] internal method of an Exported GC Object=]. | ||
| 1. Perform [=!=] [$SetIntegrityLevel$](|object|, "frozen"). |
There was a problem hiding this comment.
The second parameter here should be an enum constant ~frozen~ instead of a string "frozen". Since this file already defines <emu-const>, this should be <emu-const>frozen</emu-const>.
| 1. Perform [=!=] [$SetIntegrityLevel$](|object|, "frozen"). | ||
| 1. [=map/Set=] |map|[|objectaddr|] to |object|. | ||
| 1. Return |object|. | ||
| </div> |
There was a problem hiding this comment.
I saw your comment about tc39/proposal-nonextensible-applies-to-private in the test, but I think it is better to have a Note: here about it as well. This will prevent any confusion for readers.
| } | ||
| } | ||
| class StampField extends Base { | ||
| #field = 42; |
There was a problem hiding this comment.
Can we also add tests for private methods and private getter/setter here?
Hmm, interesting question. I'm inclined to keep them frozen for now, since that communicates "maximally locked down." In a future where we allow configuring mutable own properties, we can make just the objects with such configuration sealed rather than frozen. |
"frozen" also suggests (shallow) immutability. Wasm structs are not shallow-immutable because we can mutate their Wasm fields. Anyway, I don't feel strongly about it. |
That makes sense to me. I'll switch to using sealed. If someone wants to keep "frozen" enough to say something, we can always continue the discussion :) |
Create Exported GC Objects using OrdinaryObjectCreate and SetIntegrityLevel("sealed") rather than defining custom exotic internal methods, and update JS API tests to cover ordinary empty, sealed object behavior.
Fixes #131.