Closed 996ccs closed 2 weeks ago
What you are seeing there is a string header, type 2, length 2, data in 16-bit Unicode.
See also: https://www.assemblyscript.org/runtime.html#header-layout
Also note that the pointer returned by getA
is 1056, which is in the middle of the data segment (at 1048) you're looking at. The location of the A is indeed at 1056, and the managed object header is placed eight bytes before the location referred to by the pointer.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!
Question
I wrote a function getA using AssemblyScript to return an A string. After compilation, I got a wasm file. Then I used other wasm runtime to parse the wasm file and called the getA function hoping to get the ascii value 65 corresponding to A. But what I got was [2, 0, 0, 0, 2, 0, 0, 0, 65] The wat file compiled by AssemblyScript is as follows
Judging from the compiled product above, the prefix '\02\00\00\00\02\00\00\00' is obviously redundant.