-
Notifications
You must be signed in to change notification settings - Fork 63
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
Wasm implementation #21
base: master
Are you sure you want to change the base?
Conversation
nearly works, but slows down with time.
I did hack it about a bit due to wasm4. The framebuffer is provided, there's no main, sprites not characters, no PAL layer. Think those were the main things. What would be best, put all those things behind #if defs? |
I'm probably not going to get to this as I have to hack the compiler to make it work and I don't understand why, so not worth pursuing unless that problem can be resolved, sorry. Basically the static field address calculation is screwed up when compiling or linking for w4 and goes off into random memory. |
I think that's also reasonable. I only trying to consolidate knowledge points if possible. I then probable would go to your fork and try to make |
I think we just need to redo the sprites to be This obviously requires bringing as much of ReadOnlySpan as needed. |
I think I tried that but got stuck in `ref struct` requirements. I'll have another look
Scott
…________________________________
From: Michal Strehovský ***@***.***>
Sent: Sunday, January 16, 2022 2:10:47 AM
To: MichalStrehovsky/SeeSharpSnake ***@***.***>
Cc: Scott Waye ***@***.***>; Mention ***@***.***>
Subject: Re: [MichalStrehovsky/SeeSharpSnake] Wasm implementation (PR #21)
I think we just need to redo the sprites to be static ReadOnlySpan<byte> Xyz => new byte[] { 1,2,3}; to avoid the problem described in dotnet/runtimelab#1822 (comment)<dotnet/runtimelab#1822 (comment)>.
This obviously requires bringing as much of ReadOnlySpan as needed.
—
Reply to this email directly, view it on GitHub<#21 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAUYCKPVVBK3HCFZL5IER23UWJVPPANCNFSM5MA2TTEQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Basically
is not allowed . |
Would I be able to create the |
Why do you need to make the Game a ref struct? My suggestion above is basically this: https://sharplab.io/#v2:C4LghgzgtgPgAgJgIwFgBQ6LAE4FcDGwABAOJhQCm6A3ukfUXEgGxEBKFYAJgPIB2AGwCeAZQAOYPgB4ARkOAUAfEQAaQgF5EAvMr4UA7kTkKA2gF0i1IkgA0RBHYDMRAL4BudC6A=== It doesn't require making Game a |
Ah, because I thought it was `=` not `=>` .
And if you take that sharplab link and switch to the IL it has a `newobj`. Maybe RyuJit removes that, I'll check.
Thanks
Scott
…________________________________
From: Michal Strehovský ***@***.***>
Sent: Sunday, January 16, 2022 8:40:14 PM
To: MichalStrehovsky/SeeSharpSnake ***@***.***>
Cc: Scott Waye ***@***.***>; Mention ***@***.***>
Subject: Re: [MichalStrehovsky/SeeSharpSnake] Wasm implementation (PR #21)
Why do you need to make the Game a ref struct?
My suggestion above is basically this: https://sharplab.io/#v2:C4LghgzgtgPgAgJgIwFgBQ6LAE4FcDGwABAOJhQCm6A3ukfUXEgGxEBKFYAJgPIB2AGwCeAZQAOYPgB4ARkOAUAfEQAaQgF5EAvMr4UA7kTkKA2gF0i1IkgA0RBHYDMRAL4BudC6A===
It doesn't require making Game a ref struct and compiles to two movs (that are also quite inlineable).
—
Reply to this email directly, view it on GitHub<#21 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAUYCKKZTNAQCDAF4VLEIALUWNXP5ANCNFSM5MA2TTEQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
The newobj is for ReadOnlySpan, which is a valuetype. It won't be a heap allocation even with optimizations disabled. |
How does that happen, when I look at the IR, I see the helper call for
|
The il in sharplab is: IL_0000: ldsflda valuetype ''/'__StaticArrayInitTypeSize=3' ''::'039058C6F2C0CB492C533B0A4D14EF77CC0F78ABCCCED5287D84A1A2011CFB81' The field is RVA static (ie the data is in the rdata section of the executable). If you see newarr, Roslyn doesn't think it's the ReadOnlySpan in your corelib. |
Aha! Right, better download Roslyn to see how it decides. Thanks! I guess |
In the Roslyn tree there should be ReadOnlySpans they use for testing that the compiler should understand as ReadOnlySpan. This one might be it: Once you have something Roslyn recognizes, you might try to make it smaller (e.g. the enumerator might not actually be needed, but who knows). |
Hmm, I guess that's obvious looking at the IL, oh well. |
This is just @yowl work from his repo.
I would like to ask him to create proper PR with just code changes and instruction, then I can improve tooling, so whole thing can be built using
dotnet publish
workflow.This PR is just for discussion whole idea, and give additional visibility for WASM work https://github.com/yowl/SeeSharpSnake/tree/wasm4