★ wanayoo — archive 1999 https://github.com/nodejs/node/pull/25143Nouvelle recherche | Portail wanayoo
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: lazily load internalBinding('uv') and build the errmap lazily #25143

Closed
wants to merge 2 commits into from

Conversation

Projects
None yet
6 participants
@joyeecheung
Copy link
Member

commented Dec 19, 2018

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.

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

This comment has been minimized.

Copy link
Member Author

commented Dec 19, 2018

@addaleax
Copy link
Member

left a comment

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?

Show resolved Hide resolved src/uv.cc Outdated
@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented Dec 19, 2018

creating a static array from the macro here

I don't think I follow..what do you mean by creating a static array?

@addaleax

This comment has been minimized.

Copy link
Member

commented Dec 19, 2018

@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 :)
@danbev

danbev approved these changes Dec 20, 2018

Show resolved Hide resolved lib/internal/util.js

joyeecheung added some commits Dec 19, 2018

src: lazily load internalBinding('uv') and build the errmap lazily
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.

@joyeecheung joyeecheung force-pushed the joyeecheung:uv-lazy branch from 6b72c60 to 0226fe1 Dec 28, 2018

@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented Dec 28, 2018

Rebased and used the static struct array based the suggestion from @addaleax (thanks!), @addaleax @danbev @jasnell @BridgeAR PTAL.

CI: https://ci.nodejs.org/job/node-test-pull-request/19855/

@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented Dec 29, 2018

Landed in c66c073

joyeecheung added a commit that referenced this pull request Dec 29, 2018

src: lazily load internalBinding('uv') and build the errmap lazily
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>

targos added a commit that referenced this pull request Jan 1, 2019

src: lazily load internalBinding('uv') and build the errmap lazily
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>

refack added a commit to refack/node that referenced this pull request Jan 14, 2019

src: lazily load internalBinding('uv') and build the errmap lazily
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>

@BridgeAR BridgeAR referenced this pull request Jan 16, 2019

Merged

v11.7.0 proposal #25537

@MylesBorins MylesBorins referenced this pull request Jan 24, 2019

Merged

v11.8.0 proposal #25687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.