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: move Environment::context out of strong properties #27430

Closed
wants to merge 3 commits into from

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Apr 26, 2019

Rename ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES to
ENVIRONMENT_STRONG_PERSISTENT_DATA, and move context
out of the list, so that the data can be iterated separately.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Apr 26, 2019
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

src/env.h Outdated
@@ -340,11 +340,10 @@ constexpr size_t kFsStatsBufferLength = kFsStatsFieldsNumber * 2;
V(x_forwarded_string, "x-forwarded-for") \
V(zero_return_string, "ZERO_RETURN")

#define ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) \
#define ENVIRONMENT_STRONG_PERSISTENT_DATA(V) \
Copy link
Member

Choose a reason for hiding this comment

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

You could merge this with ENVIRONMENT_STRONG_PERSISTENT_VALUES - v8::Value is a subclass of v8::Data too and everything in ENVIRONMENT_STRONG_PERSISTENT_VALUES is a subclass of v8::Value.

That said, since everything in ENVIRONMENT_STRONG_PERSISTENT_DATA is a subclass of v8::Template now, you should name it something like PER_ISOLATE_TEMPLATE_PROPERTIES and make them per-isolate.

Copy link
Member Author

@joyeecheung joyeecheung May 1, 2019

Choose a reason for hiding this comment

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

Good point about making these v8::Template, though conceptually I think these are per-Environment, as to add these into the snapshot I'll also need to register the external references for them, which is WIP, and the reason that these can be excluded from the current minimal snapshot is that all of these should be empty prior to Environment creation.

src/env-inl.h Show resolved Hide resolved
Rename `ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES` to
`ENVIRONMENT_STRONG_PERSISTENT_DATA`, and move `context`
out of the list, so that the data can be iterated separately.
@nodejs-github-bot

This comment has been minimized.

@joyeecheung
Copy link
Member Author

joyeecheung commented May 1, 2019

Rebased and renamed ENVIRONMENT_STRONG_PERSISTENT_DATA to ENVIRONMENT_STRONG_PERSISTENT_TEMPLATE - we'll need separate routines to deserialize those for workers so I think it's best to keep them in the environment for now.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM but can you add a TODO about changing them to per-isolate properties? Cheers.

@joyeecheung
Copy link
Member Author

joyeecheung commented May 1, 2019

LGTM but can you add a TODO about changing them to per-isolate properties? Cheers.

@bnoordhuis What's the difference between per-isolate and per-Environment? So far in my brain, per-isolate stuff are more primitive and can be initialized without an Environment (i.e. before bootstrap, so it makes sense for them to be data members of IsolateData), whereas per-Environment stuff are more sophisticated and can only be initialized after there is an associated Environment (so it makes sense for them to be data members of Environment). By that standard the templates should be per-Environment because they are all empty before an associated Environment is available.

@addaleax
Copy link
Member

addaleax commented May 1, 2019

I don’t have a strong opinion on per-Isolate vs per-Environment, but I don’t think it’s a bad idea to move Context-independent values to per-Isolate storage in general.

I think practical implications would only be there if we have multiple Environments per Isolate, which should be rare enough – 1. reducing the number of templates we create and 2. enabling the use of native objects from Environment A in Environment B… that doesn’t seem like an inherently bad thing.

@joyeecheung
Copy link
Member Author

joyeecheung commented May 2, 2019

@addaleax @bnoordhuis I took a look at the templates and I think so far most of them are per-Environment - for example most of the function templates have the Environment itself attached as callback data (for Environment::GetCurrent() to work), it does not seem to make sense to make these per-Isolate if there are multiple Environments operating on one isolate..from a glance the object templates may be independent from Environments, but then a lot of them are created from other function templates.

It may make sense to make these per-Isolate if we create these templates during IsolateData creation, and detach the SetCallHandler call from function template creation, though, but if there were multiple Environments, we'd still need a way to switch the handler settings among Environments, which seems a bit complicated than just making these per-Environment?

@joyeecheung
Copy link
Member Author

Landed in Landed in 6f02f15. We'll see if these templates can be made per-Isolate afterwards..

@joyeecheung joyeecheung closed this May 2, 2019
joyeecheung added a commit that referenced this pull request May 2, 2019
Rename `ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES` to
`ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES`, and move `context`
out of the list, so that the data can be iterated separately.

PR-URL: #27430
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
targos pushed a commit that referenced this pull request May 4, 2019
Rename `ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES` to
`ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES`, and move `context`
out of the list, so that the data can be iterated separately.

PR-URL: #27430
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@targos targos mentioned this pull request May 6, 2019
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++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants