-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs/guides: additional resources for WebAssembly #352
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: "Additional Resources" | ||
weight: 4 | ||
description: | | ||
Additional Resources for using TinyGo with WASM/WASI | ||
--- | ||
|
||
Here are a few resources for helping learn more about using TinyGo with WebAssembly. | ||
|
||
**Wasm By Example** | ||
https://wasmbyexample.dev/ | ||
|
||
**Are We Wasm Yet ? - Part 1** | ||
https://elewis.dev/are-we-wasm-yet-part-1 | ||
|
||
**Are We Wasm Yet ? - Part 2** | ||
https://elewis.dev/are-we-wasm-yet-part-2 | ||
|
||
**Writing a WebAssembly Service in TinyGo for Wagi and Spin** | ||
https://www.fermyon.com/blog/tinygo-webassembly-favicon-server | ||
|
||
**wazero - TinyGo** | ||
https://wazero.io/languages/tinygo/ | ||
|
||
**WasmEdge Runtime - Go** | ||
https://wasmedge.org/book/en/write_wasm/go.html | ||
|
||
**WASI and Node.js** | ||
https://k33g.hashnode.dev/series/wasi-nodejs | ||
|
||
**Wazero, first steps** | ||
https://k33g.hashnode.dev/series/wazero-first-steps | ||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some things I noticed: // readBufferFromMemory returns a buffer from WebAssembly
func readBufferFromMemory(bufferPosition *uint32, length uint32) []byte {
subjectBuffer := make([]byte, length)
pointer := uintptr(unsafe.Pointer(bufferPosition))
for i := 0; i < int(length); i++ {
s := *(*int32)(unsafe.Pointer(pointer + uintptr(i)))
subjectBuffer[i] = byte(s)
}
return subjectBuffer
} This is one example where // readBufferFromMemory returns a buffer from WebAssembly
func readBufferFromMemory(bufferPosition *byte, wordLength uint32) []byte {
length := wordLength * 4
subjectBuffer := make([]byte, length)
copy(subjectBuffer, unsafe.Slice(bufferPosition, length))
return subjectBuffer
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one contains some outdated information on
malloc
andfree
. I'm not sure we should encourage people reading this? (Or perhaps send a message to the blog post writers to update?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That for sure! cc @codefromthecrypt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the jury is still out on the malloc/free stuff, but coming in soon. We need to see benchmark before after and it is nearly there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically there are a lot of people using the existing approach (which was reviewed by several) we owe it when doing an update to say what the new is and what it will cost you tetratelabs/wazero#1390
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codefromthecrypt I'm not sure what you mean?
malloc
andfree
has been safe for use since tinygo-org/tinygo#3148 and I doubt we'll ever change that back.A hand rolled
malloc
will have a much bigger chance of being subtly wrong.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aykevl Thanks. We we were missing the context
What you said "malloc and free has been safe for use since tinygo-org/tinygo#3148 and I doubt we'll ever change that back." should be in the PR desc as rationale to use the CGO as the only way and remove the others, especially as the benchmarks don't show any perf regression. The same PR can update the site docs to only say one way (CGO malloc/free). @lburgazzoli can you update tetratelabs/wazero#1390 accordingly? Once that's in, I'll we can remove the manual exports from tinymem, leaving it only used for slice helper functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codefromthecrypt I'm not sure I follow. Was this a reply to me, or which PR are you referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @codefromthecrypt was asking @lburgazzoli to update tetratelabs/wazero#1390 accordingly. 😸