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

src: integrate ContextifyContext to cppgc #56522

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Jan 8, 2025

This simplifies the memory management of ContextifyContext,
making all references visible to V8.

The destructors don't need to do anything because when the wrapper is
going away, the context is already going away or otherwise it would've
been holding the wrapper alive, so there's no need to reset the
pointers in the context. Also, any global handles to the context
would've been empty at this point, and the per-Environment context
tracking code is capable of dealing with empty handles from contexts
purged elsewhere.

To this end, the context tracking code also purges empty handles
from the list now, to prevent keeping too many empty handles around.

@joyeecheung joyeecheung marked this pull request as draft January 8, 2025 17:44
@nodejs-github-bot nodejs-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 Jan 8, 2025
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 69.23077% with 8 lines in your changes missing coverage. Please review.

Project coverage is 89.17%. Comparing base (19c8cc1) to head (a4ef690).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/node_contextify.cc 61.11% 7 Missing ⚠️
src/node_contextify.h 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #56522   +/-   ##
=======================================
  Coverage   89.16%   89.17%           
=======================================
  Files         662      662           
  Lines      191745   191750    +5     
  Branches    36902    36901    -1     
=======================================
+ Hits       170971   170985   +14     
- Misses      13627    13628    +1     
+ Partials     7147     7137   -10     
Files with missing lines Coverage Δ
src/env.cc 85.95% <100.00%> (+0.29%) ⬆️
src/env.h 98.14% <ø> (ø)
src/node_contextify.h 80.00% <66.66%> (+6.66%) ⬆️
src/node_contextify.cc 81.37% <61.11%> (+<0.01%) ⬆️

... and 33 files with indirect coverage changes

@joyeecheung joyeecheung force-pushed the contextify-cppgc branch 2 times, most recently from 28b6b67 to 4cfe15f Compare January 9, 2025 16:49
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 9, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 9, 2025
@nodejs-github-bot
Copy link
Collaborator

@joyeecheung joyeecheung force-pushed the contextify-cppgc branch 2 times, most recently from 38132a2 to bcb919d Compare January 10, 2025 16:30
This simplifies the memory management of ContextifyContext,
making all references visible to V8.

The destructors don't need to do anything because when the wrapper is
going away, the context is already going away or otherwise it would've
been holding the wrapper alive, so there's no need to reset the
pointers in the context. Also, any global handles to the context
would've been empty at this point, and the per-Environment context
tracking code is capable of dealing with empty handles from contexts
purged elsewhere.

To this end, the context tracking code also purges empty handles
from the list now, to prevent keeping too many empty handles around.
@joyeecheung joyeecheung marked this pull request as ready for review January 10, 2025 16:38
@joyeecheung joyeecheung changed the title [WIP] Migrate ContextifyContext to cppgc src: igrate ContextifyContext to cppgc Jan 10, 2025
@joyeecheung
Copy link
Member Author

joyeecheung commented Jan 10, 2025

After tracing the lifetime of ContextifyContexts a bit I realized that ContextifyContext does not even need to do any special cleanups, as the weak global handles in the context list would just become empty when the cycle involving Context/ContextifyContext is unreachable and will get purged sooner or later. So this no longer depend on #56534

@joyeecheung joyeecheung changed the title src: igrate ContextifyContext to cppgc src: integrate ContextifyContext to cppgc Jan 10, 2025
Sign up for free to 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 / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants