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

tools: fix js2c regression #27980

Closed
wants to merge 2 commits into from
Closed

Conversation

refack
Copy link
Contributor

@refack refack commented May 30, 2019

Fix a regression that was introduced in #25518 and causes the binary to bloat by ~10%.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@refack refack added python PRs and issues that require attention from people who are familiar with Python. tools Issues and PRs related to the tools directory. regression Issues related to regressions. labels May 30, 2019
@nodejs-github-bot

This comment has been minimized.

tools/js2c.py Outdated Show resolved Hide resolved
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

protected:

static const NativeModuleRecordMap get_sources_for_test() {
return NativeModuleLoader::instance_.source_;
Copy link
Member

Choose a reason for hiding this comment

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

The builds are failing because this is private. I guess it would also make sense to add a public method to just return the source in a copy, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it a friend
https://github.com/nodejs/node/blob/84aca5ca594f86ce9b6b86e6af039e78f90deaef/src/node_native_module.h#L89
and it compiles & passes with MSVC, now I need to figure out gcc & clang 🤷‍♂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

node.gyp Outdated Show resolved Hide resolved
node.gyp Show resolved Hide resolved
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. Nice work.

tools/js2c.py Outdated
template = TWO_BYTE_STRING
# Treat non-ASCII as UTF-8 and encode as UTF-16 Little Endian.
encoded_source = bytearray(source, 'utf-16le')
code_points = [encoded_source[i] + (encoded_source[i + 1] * 256) for i in range(0, len(encoded_source), 2)]
Copy link
Member

Choose a reason for hiding this comment

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

Can you wrap this, e.g. by putting the for i in ... on its own line, lining it up with the e in [encoded_source?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Jun 2, 2019

Landed in cb92d24

@Trott Trott closed this Jun 2, 2019
Trott pushed a commit to Trott/io.js that referenced this pull request Jun 2, 2019
PR-URL: nodejs#27980
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@refack refack added the landed label Jun 2, 2019
@refack refack deleted the fix-js2c-regression branch June 2, 2019 16:18
@refack refack removed the request for review from cclauss June 2, 2019 16:18
targos pushed a commit that referenced this pull request Jun 3, 2019
PR-URL: #27980
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@targos targos mentioned this pull request Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python PRs and issues that require attention from people who are familiar with Python. regression Issues related to regressions. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants