Skip to content
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] Migrate to ref/out param while reading data from typed array #70823

Merged
merged 6 commits into from
Jun 21, 2022

Conversation

maraf
Copy link
Member

@maraf maraf commented Jun 16, 2022

  • Migrate to ref/out param while reading data from typed array in mono_wasm_typed_array_to_array_ref
  • The test case doesn't prove the fix, because it doesn't fail without the fix. Could it be related to the publish requirement?

@maraf maraf added this to the 7.0.0 milestone Jun 16, 2022
@maraf maraf requested review from kg and pavelsavara June 16, 2022 12:57
@maraf maraf self-assigned this Jun 16, 2022
@ghost
Copy link

ghost commented Jun 16, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Migrate to ref/out param while reading data from typed array in mono_wasm_typed_array_to_array_ref
Author: maraf
Assignees: maraf
Labels:

arch-wasm, area-System.Runtime.InteropServices.JavaScript

Milestone: 7.0.0

Copy link
Member

@kg kg left a comment

Choose a reason for hiding this comment

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

Good catch

@pavelsavara
Copy link
Member

[FAIL] System.Runtime.InteropServices.JavaScript.Tests.TypedArrayTests.Uint8ArrayToArray
[13:50:25] info: System.Runtime.InteropServices.JavaScript.JSException : RangeError: Array buffer allocation failed
[13:50:25] info:     at new ArrayBuffer (<anonymous>)
[13:50:25] info:     at eval (eval at t (http://127.0.0.1:33131/dotnet.js:3:44553), <anonymous>:3:23)
[13:50:25] info:     at Object.mono_wasm_invoke_js_with_args_ref (http://127.0.0.1:33131/dotnet.js:3:59772)

@pavelsavara
Copy link
Member

Are there other obsolete js functions used internally, which could be replaced with better one ?

@kg
Copy link
Member

kg commented Jun 16, 2022

[FAIL] System.Runtime.InteropServices.JavaScript.Tests.TypedArrayTests.Uint8ArrayToArray
[13:50:25] info: System.Runtime.InteropServices.JavaScript.JSException : RangeError: Array buffer allocation failed
[13:50:25] info:     at new ArrayBuffer (<anonymous>)
[13:50:25] info:     at eval (eval at t (http://127.0.0.1:33131/dotnet.js:3:44553), <anonymous>:3:23)
[13:50:25] info:     at Object.mono_wasm_invoke_js_with_args_ref (http://127.0.0.1:33131/dotnet.js:3:59772)

Interesting, that usually means Node ran out of memory.

@kg
Copy link
Member

kg commented Jun 16, 2022

Are there other obsolete js functions used internally, which could be replaced with better one ?

There are a bunch of them still in the codebase, we should consider deleting them all and fixing whatever touches them. I wouldn't be surprised if it broke some stuff though.

@pavelsavara
Copy link
Member

Could we also rename mono_obj_array_new_ref, mono_obj_array_set_ref, conv_string_rooted to *_root to be more consistent ?

TBH: if we are able to land the new interop, I would much rather not extend the scope of this private API and moved all of it to undocumented INTERNAL.

@maraf
Copy link
Member Author

maraf commented Jun 17, 2022

Interesting, that usually means Node ran out of memory.

Yea, I should allocate less in the test. I put there some high numbers, because I wasn't able to make the test fail before the fix. But @pavelsavara suggested some changes.

@kg
Copy link
Member

kg commented Jun 17, 2022

Could we also rename mono_obj_array_new_ref, mono_obj_array_set_ref, conv_string_rooted to *_root to be more consistent ?

TBH: if we are able to land the new interop, I would much rather not extend the scope of this private API and moved all of it to undocumented INTERNAL.

I don't consider it expanding the scope, since we're just replacing broken APIs with fixed ones. If you're proposing that we delete the API I understand the reasoning but I think we would need to do that in 8

@maraf
Copy link
Member Author

maraf commented Jun 21, 2022

Could we also rename mono_obj_array_new_ref, mono_obj_array_set_ref, conv_string_rooted to *_root to be more consistent ?

I think the names are correct

  • conv_string_rooted is already remapped to conv_string_root and marked as obsolete,
  • mono_obj_array_new_ref and mono_obj_array_set_ref takes MonoObjectRef, not WasmRoot

@pavelsavara
Copy link
Member

the caller has to get WasmRoot instance first by calling mono_wasm_new_root_buffer and then call get_address on it and only then they could call mono_obj_array_new_ref with it. I think we could do that on behalf of the user and return WasmRoot instance from mono_obj_array_new_root for him.

@maraf
Copy link
Member Author

maraf commented Jun 21, 2022

the caller has to get WasmRoot instance first by calling mono_wasm_new_root_buffer and then call get_address on it and only then they could call mono_obj_array_new_ref with it. I think we could do that on behalf of the user and return WasmRoot instance from mono_obj_array_new_root for him.

I'm not opposed refactoring the API in a new PR.

@maraf
Copy link
Member Author

maraf commented Jun 21, 2022

/azp run runtime-wasm

@maraf maraf marked this pull request as ready for review June 21, 2022 12:55
@maraf maraf requested a review from marek-safar as a code owner June 21, 2022 12:55
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@maraf
Copy link
Member Author

maraf commented Jun 21, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@maraf maraf merged commit c158591 into dotnet:main Jun 21, 2022
@maraf maraf deleted the WasmTypedArrayToArrayRefUseRoot branch June 21, 2022 20:32
@ghost ghost locked as resolved and limited conversation to collaborators Jul 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants