-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: clean up ArrayBufferAllocator #7082
Conversation
flags[kNoZeroFill] = 0; | ||
} | ||
if (noZeroFill) | ||
zeroFill[0] = 0; // Reset by the runtime. |
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.
Why drop kNoZeroFill
?
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.
You mean the constant? No real reason except that it's a single-element array now.
Generally LGTM. CI is green. Nothing sticks out immediately as a concern. |
// without a context. | ||
IsolateData isolate_data(isolate, instance_data->event_loop()); | ||
|
||
Environment* env = CreateEnvironment(&isolate_data, |
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 could be totally off, but why not use direct initialization with Environment
? Its lifetime can't exceed that of IsolateData
.
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 confess I'm not sure what you mean by 'direct initialization'. Making Environment a member of IsolateData? There can be more than one Environment per isolate so that won't work.
Or do you mean making env
a stack-allocated variable?
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.
@bnoordhuis making it a stack-allocated variable. basically doing:
Environment env(&isolate_data,
I just can't see a case where it would outlive the stack it's declared in.
EDIT: TBH Google helped me find the term about a minute before I posted this.
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.
ah, I see now that it's a private constructor. welp, no reason to change it if it's not broken.
@bnoordhuis Just got back last night. Thanks for cleaning up that implementation. LGTM. |
A follow-up commit is going to make IsolateData creation explicit. In order for that to work, it needs to move out of Environment. PR-URL: nodejs#7082 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Make it easier to reason about the lifetime and the ownership of the IsolateData instance by making its creation explicit and by removing reference counting logic. The creator of the Environment is now responsible for passing in the IsolateData instance and for keeping it alive as long as the Environment is alive. PR-URL: nodejs#7082 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Said function requires that a v8::Context has been entered first, introducing a chicken-and-egg problem when creating the first context. PR-URL: nodejs#7082 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Remove the direct dependency on node::Environment (which is per-context) from node::ArrayBufferAllocator (which is per-isolate.) Contexts that want to toggle the zero fill flag, now do so through a field that is owned by ArrayBufferAllocator. Better, still not great. PR-URL: nodejs#7082 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
e50ffd3
to
27e84dd
Compare
zeroFill[0] = 0; // Reset by the runtime. | ||
const ui8 = new Uint8Array(size); | ||
Object.setPrototypeOf(ui8, Buffer.prototype); | ||
return ui8; |
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.
Why was try-finally dropped here? It breaks things.
Perhaps revert this and give it more review time? |
This reverts commit 27e84dd. nodejs#7082 was landed too fast and did not have sufficient review time. That PR also broke some things (testcases will follow separately).
This reverts commit 334ef4f. nodejs#7082 was landed too fast and did not have sufficient review time. That PR also broke some things (testcases will follow separately).
This reverts commit c3cd453. nodejs#7082 was landed too fast and did not have sufficient review time. That PR also broke some things (testcases will follow separately).
This reverts commit 0301ce9. nodejs#7082 was landed too fast and did not have sufficient review time. That PR also broke some things (testcases will follow separately).
|
Makes it easier to reason about the lifetime of the Environment object. PR-URL: nodejs#7090 Refs: nodejs#7082 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This is prep work for multi-isolate support. The main goal is to break the dependency between ArrayBufferAllocator and Environment, which is an unholy union that should never have been.
I think it's rather nice that it manages to do that while still reducing the line count by 90 lines.
R=@jasnell? I'd R=@trevnorris too but I think he is on holiday?
CI: https://ci.nodejs.org/job/node-test-pull-request/2881/