Stream: cargo-component

Topic: where is the core function stored?


view this post on Zulip 林子篆 (Jul 11 2024 at 09:49):

Hi, I'm working on component model on WasmEdge. I notice in the definition section, there is a core func <id>?

(canon resource.new <typeidx> (core func <id>?))

but in binary section, there is only a type index

| 0x02 rt:<typeidx>                                   => (canon resource.new rt (core func))

where can I found the core function when loading the binary? Also for any similar cases.

view this post on Zulip Alex Crichton (Jul 11 2024 at 14:13):

The (core func <id>?) is indicating that a core function is created with the canon resource.new intrinsic, and the name of that function is <id> (it's optional), those parts aren't in the binary format

view this post on Zulip 林子篆 (Jul 15 2024 at 06:26):

I see, so does runtime must know how to provide new/drop etc functions for any type? Since some of types are hard to imagine a common zero constructor, e.g. function.

view this post on Zulip Alex Crichton (Jul 15 2024 at 14:31):

<typeidx> in this case must be a resource, but yes runtimes must be able to create a new instance of this resource type. Note though that this intrinsic is only valid of <typeidx> was a resource defined in the current component, so it's probably not quite as free-form as you're thinking

view this post on Zulip 林子篆 (Jul 15 2024 at 16:19):

I see, thanks you!


Last updated: Oct 23 2024 at 20:03 UTC