Skip to content

Conversation

@devsnek
Copy link
Member

Store WebAssembly.Memory handle as a WasmMemoryObject, which lets us directly grab the ArrayBuffer instead of doing a property lookup in this hot path.

@devsnekdevsnek requested a review from cjihrigJune 23, 2022 06:21
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/wasi

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jun 23, 2022
@devsnekdevsnekforce-pushed the use-wasm-memory-object-type branch 3 times, most recently from 0424be9 to 49c3b76CompareJune 23, 2022 06:32
@devsnekdevsnekforce-pushed the use-wasm-memory-object-type branch 2 times, most recently from d7ead7a to 5a05d10CompareJune 23, 2022 13:53

Local<ArrayBuffer> ab = prop.As<ArrayBuffer>();
std::shared_ptr<BackingStore> backing_store = ab->GetBackingStore();
Local<WasmMemoryObject> memory = PersistentToLocal::Strong(this->memory_);
Copy link
Member

Choose a reason for hiding this comment

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

tiny and very ignorable style nit:

Suggested change
Local<WasmMemoryObject> memory = PersistentToLocal::Strong(this->memory_);
Local<WasmMemoryObject> memory = PersistentToLocal::Strong(memory_);

More directly, why are we not going on step further and storing the std::shared_ptr<BackingStore> here? That should be even faster.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

the arraybuffer gets detached every time the wasm grows its memory. very annoying problem, maybe it will be fixed one day: https://github.com/tc39/proposal-resizablearraybuffer#sync-up-capability-with-webassembly-memorygrow

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@devsnekdevsnekforce-pushed the use-wasm-memory-object-type branch from c440735 to 98a1262CompareJune 25, 2022 07:03
@nodejs-github-bot
Copy link
Collaborator

PR-URL: #43544 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
@devsnekdevsnekforce-pushed the use-wasm-memory-object-type branch from 98a1262 to 4778831CompareJune 25, 2022 18:01
@devsnekdevsnek merged commit d4eef14 into mainJun 25, 2022
@devsnekdevsnek deleted the use-wasm-memory-object-type branch June 25, 2022 18:01
devsnek added a commit that referenced this pull request Jun 25, 2022
PR-URL: #43544 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #43544 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
@targostargos mentioned this pull request Jul 12, 2022
targos pushed a commit that referenced this pull request Jul 20, 2022
PR-URL: #43544 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #43544 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
@targostargos mentioned this pull request Aug 3, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.lib / srcIssues and PRs related to general changes in the lib or src directory.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@devsnek@nodejs-github-bot@addaleax@cjihrig@tniessen