Skip to content

Conversation

@justinclift
Copy link
Member

It's working in initial testing, but could likely be improved somewhat. 😄

It's working in initial testing, but could likely be improved
somewhat. :)
@deadprogram
Copy link
Member

Any chance of an automated test that exercises this?

@justinclift
Copy link
Member Author

Good idea. Probably best to wait a few days, to see if it works ok with the further WebGL stuff. There's every chance it'll need tweaking/adjusting (etc). 😉

@justinclift justinclift changed the title Add initial syscall/js.copyBytesToJS support WIP: Add initial syscall/js.copyBytesToJS support Nov 10, 2019
// Originally copied from upstream Go project, then modified:
// https://github.com/golang/go/blob/3f995c3f3b43033013013e6c7ccc93a9b1411ca9/misc/wasm/wasm_exec.js#L404-L416
// param4 and param5 (below) are likely "length" variables of some sort
"syscall/js.copyBytesToJS": (ret_addr, dest_addr, source_addr, param4, param5) => {
Copy link
Member

@aykevl aykevl Nov 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calling convention changes have changed this function conceptually to the following:

func copyBytesToJS(returnValue *struct{int; bool}, dst *ref, srcPtr *byte, srcLen, srcCap uintptr)

The following three rules apply to it:

  • large return values are passed as a pointer-to-struct and prepended to the parameter list
  • int64/uint64 (the ref type) are passed as a pointer-to-value
  • slices are split into 3 parts: the pointer to the underlying array, the length, and the capacity.

So yes, param4 is len and param5 is cap.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll update things accordingly over the next few days. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you can take a look at this PR? The next release is getting close.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I can make time this weekend. 😄

@justinclift justinclift self-assigned this Nov 12, 2019
@justinclift justinclift added this to the v0.10 milestone Nov 12, 2019
@deadprogram
Copy link
Member

Is this PR still valid? if so, any chance of it being able to bring it back to life?

@justinclift
Copy link
Member Author

justinclift commented Jan 29, 2020

No idea, haven't touched Go at all in months. Might as well close it, and if there turns out to be need for it in future it can be re-opened or re-submitted.

@justinclift
Copy link
Member Author

@deadprogram Looking back at this now, it turns out this PR is still needed after all. 😉

@justinclift justinclift modified the milestones: v0.10, v0.13 Feb 29, 2020
@justinclift
Copy link
Member Author

Wasn't able to re-open this PR for some unknown reason (GitHub technical issue?), so recreated it in #933.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants