18:43
<akaster>
I'm looking into StructuredSerializeInternal for Ladybird, and steps 22 and 23 are tripping me up. From looking into blink, it seems like they defer to v8 for the serialization steps, in v8::ValueSerializer. And v8 seems to encode all the data about whether an object (a "receiver") is a well known ES object or ES prototype in a tag field. But LibJS doesn't do that, we just have a bunch of classical c++ inheritance. Like there's no "IsExotic()" function I can call. Do all the other engines do this type of tagging of JS objects so that those two catch-all steps are trivial and/or fall out of handling the known object types?
18:45
<akaster>
There's certainly no ECMAScript abstract operation I can call to say "is this a plain old object" (I think?)
19:05
<ljharb>
the prose "is an ordinary object" is how 262 does it (in a condition, or assertion, or parameter/return type)
19:10
<akaster>
Aha, there's like 40 or so objects in the spec that say "such and such object: - is an ordinary object"
19:13
<akaster>
But I can't clone all of those. Like, no promise, no weakmap, no Finalization registry, no Arguments, ...
19:21
<akaster>
Oh lovely. If I create a new RegExp(".", "") and try to structuredClone its __proto__ property, Firefox says "can't clone RegExp.prototype", and Chromium says "here's your object"
19:24
<akaster>
Safari refuses to clone it too
19:34
<Domenic>
Step 22 excludes the ones you're worried about
19:35
<akaster>
Right.. the best idea I've got for that step at the moment is checking whether my JS::Value is an object and it's class name is "Object" 😅
19:35
<Domenic>
I do suspect the other two engines also do object type tagging, as it seems helpful for various optimizations
19:36
<akaster>
Yeah, Andreas was brainstorming a radical idea where we create custom vtables to check whether properties/methods are overridden and optimize based on that. But it seems overkill if I just want to get message serialization up and running to implement Workers properly
19:38
<akaster>
Eh. I'm sure some WPT tests for this and I can clean it up later