Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

The meaning of providing a constant for a mutable global import #9

@lars-t-hansen

Description

@lars-t-hansen

Suppose a module is this:

(module (import "m" "g" (global (mut i32))))

and we try to instantiate it with the import object {m: {g: 42}}. Is this allowed or not?

Firefox currently allows it and there seems to be no difficulty in allowing it generally, but I think the spec is vague here. The current spec text to cover this seems to be (document/js-api/index.bs line 335):

        1. If |externtype| is of the form [=𝗀𝗅𝗈𝖻𝖺𝗅=] |globaltype|,
            1. If |globaltype| [=Type=](|v|) is [=Number=],
                1. If |globaltype| is [=𝗂𝟨𝟦=], throw a {{LinkError}} exception.
                1. Let |value| be [=ToWebAssemblyValue=](|v|, |globaltype|.<em>[=global type|valtype=]</em>)
                1. Let |store| be the current agent's [=associated store=].
                1. Let (|store|, |globaladdr|) be [=alloc_global=](|store|, |globaltype|, |value|).
                1. Set the current agent's [=associated store=] to |store|.

A globaltype can't be just a JS type I think, it needs to carry a mutability specifier. One could argue that since this is a number value the implicit mutability specifier is const, but need it be so?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions