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

feat(node): custom Buffer implementation #1072

Merged
merged 11 commits into from
Jul 21, 2024
Merged

feat(node): custom Buffer implementation #1072

merged 11 commits into from
Jul 21, 2024

Conversation

darvld
Copy link
Member

@darvld darvld commented Jul 11, 2024

Draft Powered by Pull Request Badge

Summary

Adds a custom implementation of the Node.js Buffer class, for use both as a global symbol and as part of the node:buffer built-in module. Two new interfaces are added: BufferInstance represents actual Buffer objects, with BufferClass serving as meta-object, holding all static (class-level) properties and methods.

This means that when injected into a guest context, there should only be one instance of BufferClass, which is bound as the Buffer symbol (and inside node:buffer), which can in turn be used to create multiple BufferInstance objects using the Node.js API.

Pending changes

The following changes are vital to the feature and currently block merge:

  • ProxyObject implementation for BufferClass.
  • Update the node:buffer builtin module to use the new implementation.
  • Inject a BufferClass instance as a global Buffer symbol.
  • Remove the Buffer polyfill and ensure only the new implementation is available in guest contexts.
  • Extensive testing for the Buffer APIs.

@darvld darvld added 🚧 WIP Works-in-progress. Blocks merge api:node Node API and stdlib labels Jul 11, 2024
@darvld darvld changed the title Feat/buffer type feat(node): custom Buffer implementation Jul 11, 2024
@darvld darvld marked this pull request as ready for review July 20, 2024 01:34
@darvld darvld requested a review from sgammon as a code owner July 20, 2024 01:34
@darvld darvld force-pushed the feat/buffer-type branch 3 times, most recently from c359790 to 9c41494 Compare July 21, 2024 13:19
Copy link

sonarcloud bot commented Jul 21, 2024

Copy link

codecov bot commented Jul 21, 2024

Codecov Report

Attention: Patch coverage is 51.26147% with 425 lines in your changes missing coverage. Please review.

Project coverage is 52.55%. Comparing base (84ec973) to head (40acda6).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1072      +/-   ##
==========================================
- Coverage   53.17%   52.55%   -0.62%     
==========================================
  Files         405      413       +8     
  Lines       14207    15055     +848     
  Branches     2394     2720     +326     
==========================================
+ Hits         7554     7912     +358     
- Misses       5903     6236     +333     
- Partials      750      907     +157     
Flag Coverage Δ
jvm 52.55% <51.26%> (-0.62%) ⬇️
lib 52.55% <51.26%> (-0.62%) ⬇️
native 79.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...de/runtime/gvm/internals/node/buffer/NodeBuffer.kt 47.69% <100.00%> (+0.81%) ⬆️
.../elide/runtime/intrinsics/js/node/FilesystemAPI.kt 85.71% <ø> (ø)
...de/runtime/gvm/internals/node/stream/NodeStream.kt 34.49% <0.00%> (ø)
...ntime/gvm/internals/node/buffer/GuestBufferView.kt 81.81% <81.81%> (ø)
...de/runtime/gvm/internals/node/fs/NodeFilesystem.kt 63.24% <0.00%> (ø)
...de/runtime/gvm/internals/node/buffer/GuestBytes.kt 57.14% <57.14%> (ø)
...e/runtime/intrinsics/js/node/buffer/BufferClass.kt 0.00% <0.00%> (ø)
...untime/intrinsics/js/node/buffer/BufferInstance.kt 75.75% <75.75%> (ø)
...me/gvm/internals/node/buffer/NodeBufferEncoding.kt 50.00% <50.00%> (ø)
...untime/gvm/internals/node/buffer/NodeHostBuffer.kt 60.78% <60.78%> (ø)
... and 3 more

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84ec973...40acda6. Read the comment docs.

@sgammon sgammon merged commit 9d0da41 into main Jul 21, 2024
23 checks passed
@sgammon sgammon deleted the feat/buffer-type branch July 21, 2024 22:34
@darvld darvld mentioned this pull request Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:node Node API and stdlib 🚧 WIP Works-in-progress. Blocks merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants