[js-api] Fix Exported GC Object cache collision Key the Exported GC Object cache by (objectkind, objectaddr) tuples so struct and array addresses do not collide, and replace the leftover object address references with struct address or array address.
diff --git a/document/js-api/index.bs b/document/js-api/index.bs index 0348c19..fb3d1d1 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs
@@ -354,7 +354,7 @@ * The <dfn>Memory object cache</dfn>, mapping [=memory address=]es to {{Memory}} objects. * The <dfn>Table object cache</dfn>, mapping [=table address=]es to {{Table}} objects. * The <dfn>Exported Function cache</dfn>, mapping [=function address=]es to [=Exported Function=] objects. - * The <dfn>Exported GC Object cache</dfn>, mapping [=struct address=]es and [=array address=]es to [=Exported GC Object=] objects. + * The <dfn>Exported GC Object cache</dfn>, mapping ("struct", [=struct address=]) and ("array", [=array address=]) [=tuple=]s to [=Exported GC Object=] objects. * The <dfn>Global object cache</dfn>, mapping [=global address=]es to {{Global}} objects. * The <dfn>Tag object cache</dfn>, mapping [=tag address=]es to {{Tag}} objects. * The <dfn>Exception object cache</dfn>, mapping [=exception address=]es to {{Exception}} objects. @@ -1586,7 +1586,7 @@ Note: These operations may be refined in the future to allow richer interactions in JavaScript with WebAssembly structs and arrays. -An [=Exported GC Object=] contains an \[[ObjectAddress]] internal slot, which holds a [=object address=] relative to the [=surrounding agent=]'s [=associated store=], +An [=Exported GC Object=] contains an \[[ObjectAddress]] internal slot, which holds a [=struct address=] or [=array address=] relative to the [=surrounding agent=]'s [=associated store=], and an \[[ObjectKind]] internal slot, which holds the string value "struct" or "array". The internal methods of an [=Exported GC Object=] use the following implementations. @@ -1658,12 +1658,12 @@ </div> <div algorithm> - To create <dfn>a new Exported GC Object</dfn> from a WebAssembly [=object address=] |objectaddr| and a string |objectkind|, perform the following steps: + To create <dfn>a new Exported GC Object</dfn> from a WebAssembly [=struct address=] or [=array address=] |objectaddr| and a string |objectkind|, perform the following steps: 1. Assert: |objectkind| is either "array" or "struct". - 1. Let |map| be the [=surrounding agent=]'s associated [=exported GC object cache=]. - 1. If |map|[|objectaddr|] [=map/exists=], - 1. Return |map|[|objectaddr|]. + 1. Let |map| be the [=surrounding agent=]'s associated [=Exported GC Object cache=]. + 1. If |map|[(|objectkind|, |objectaddr|)] [=map/exists=], + 1. Return |map|[(|objectkind|, |objectaddr|)]. 1. Let |object| be [=MakeBasicObject=](« \[[ObjectAddress]], \[[ObjectKind]] »). 1. Set |object|.\[[ObjectAddress]] to |objectaddr|. 1. Set |object|.\[[ObjectKind]] to |objectkind|. @@ -1678,7 +1678,7 @@ 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. [=map/Set=] |map|[|objectaddr|] to |object|. + 1. [=map/Set=] |map|[(|objectkind|, |objectaddr|)] to |object|. 1. Return |object|. </div>