-
Notifications
You must be signed in to change notification settings - Fork 28.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: lazily load internalBinding('uv') and build the errmap lazily #25143
Conversation
cc @addaleax |
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.
Btw, I’ve also thought about creating a static array from the macro here, instead of generating the full code for each entry… that might make things a bit easier as well?
I don't think I follow..what do you mean by creating a static array? |
@joyeecheung This might not compile because I wrote it here in Github, but I think you get the idea: static const struct {
int value;
const char* name;
const char* message;
} errors[] = {
#define V(name, msg) { UV_##name, #name, msg },
UV_ERRNO_MAP(V)
#undef V
{ 0, nullptr, nullptr }
};
for (const auto* error = errors; error->name != nullptr; error++) {
Local<Value> arr[] = {
OneByteString(isolate, error->name),
OneByteString(isolate, error->msg)
};
if (err_map->Set(context,
Integer::New(isolate, error->value),
Array::New(isolate, arr, arraysize(arr))).IsEmpty()) {
return;
}
}
The major advantage would probably be that the code isn’t several kilobytes large in this case. No strong feelings about it, though :) |
This removes the `internalBinding('uv')` call from the normal bootstrap for now, and avoids building `errmap` by default which expands to a lot of calls into V8.
Landed in c66c073 |
This removes the `internalBinding('uv')` call from the normal bootstrap for now, and avoids building `errmap` by default which expands to a lot of calls into V8. PR-URL: #25143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This removes the `internalBinding('uv')` call from the normal bootstrap for now, and avoids building `errmap` by default which expands to a lot of calls into V8. PR-URL: #25143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This removes the `internalBinding('uv')` call from the normal bootstrap for now, and avoids building `errmap` by default which expands to a lot of calls into V8. PR-URL: nodejs#25143 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This removes the
internalBinding('uv')
call from the normalbootstrap for now, and avoids building
errmap
by default whichexpands to a lot of calls into V8.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes