-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: split out per-binding state from Environment #32538
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4fba668
src: make creating per-binding data structures easier
addaleax 824f84e
src: move HTTP/2 state out of Environment
addaleax 9f0f5f9
src: move v8 stats buffers out of Environment
addaleax 6da22d8
src: move http parser state out of Environment
addaleax ad65335
src: move fs state out of Environment
addaleax 610dfe5
src,doc: add documentation for per-binding state pattern
addaleax 9222827
fixup! src,doc: add documentation for per-binding state pattern
addaleax a68f057
fixup! src: make creating per-binding data structures easier
addaleax d9e7d38
fixup! src: move fs state out of Environment
addaleax 5a2317d
fixup! src: move v8 stats buffers out of Environment
addaleax 38e471c
fixup! src: move HTTP/2 state out of Environment
addaleax 0273dbf
fixup! src: move http parser state out of Environment
addaleax 72d24ee
fixup! src: move v8 stats buffers out of Environment
addaleax 54324b6
fixup! fixup! src: move http parser state out of Environment
addaleax 330e24b
fixup! src: move fs state out of Environment
addaleax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for noticing this late - but I came across this change after a recent rebase, and I think this constraint about
BaseObject
is incorrect (see #26382 (comment)). Context-independent templates should not point to context-dependent objects, but now every templates created byEnvironment::FunctionTemplate
, which are supposed to be context-independent, point to different callback data that are context-dependentv8::Object
s that point toBaseObject
s, making the templates non-snapshottable (and theoratically just incorrect, but this is only validated by V8's serializer and not at runtime). This was already violated by #26382 and this PR just splits one context-dependent callback data into multiple context-dependent ones, and force them to be that way sinceBaseObject
s are...associated withv8::Object
(which have to be context-dependent due to references to the constructors on the prototype chain).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that even before #26382, when we were using
v8::External
, it was still somewhat limited - by obtaining the data directly through whatever passed intoFunctiontTemplate::New
, we'll always end up with the same set of callback data in the function template callback even if we switch the invoking context. This PR only makes the binding data variable by context, but it ties the FunctionTemplates to the set of the data created by the main context. If the intention is to make the binding data variable by the invoking context, (for example, so that different vm contexts have different set of builtins), we need to associate the binding data with the contexts and obtain them from there (e.g. through embedder slots, or private properties on the global object, something likeGetBindingData<T>(args.GetIsolate()->GetCurrentContext())
), instead of associating them with and and obtaining them from the function template callback data (Unwrap<T>(args.Data())
currently being done here), since there's always only one set of data per function template.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joyeecheung Yeah, I know about these issues, but this PR doesn’t really seem to make anything worse?
There is a commit in #32761 that would switch this back to using
External
s for snapshotting, if we don’t end up with a better solution.Err, yeah, we could do that, but if you look it that way we’re just using
FunctionTemplate
s andObjectTemplate
s in a wrong way to begin with. It would be nicer if we could just create context-dependent templates, I would say.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… or, even better, if we could provide data to the per-context instantiations of the templates, separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes it worse in that it now forces the FunctionTemplates to be associated with context-dependent
BaseObject
s with theBindingData
machinery. In additionBaseObject
implicitly implies that the object is tied to the main context. If we were to add an indirection, we could add an indirection based onv8::External
directly, but an indirection based onBaseObject
(which in turn relies onObject
) still doesn't make too much sense to me.From previous discussions I think that was discouraged and it is preferred to obtain the properties from contexts.
FunctionTemplate
s andObjectTemplates
essentially belong to the isolate while theFunction
andObject
instantiated from them belong to the context.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… but previously it was also associated with a context-dependent object?
In what way? We can and do create
BaseObject
s in core that are associated with Contexts coming fromvm.createContext()
.I’m not sure what you have in mind, but as said above, #32761 does contain a commit that would switch this back to
v8::External
for snapshotting.Yeah, hence the addition that it would be even better for the data associated with the template to be set or filled per-context.
Yeah, I know. I don’t think we’re disagreeing here.