GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: migrate to new V8 array API by kt3k · Pull Request #24613 · nodejs/node

Conversation

@kt3k

@kt3k kt3k commented Nov 24, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR uses new V8 API for array creation, instead of old one.

related PR: #24125

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kt3k
src: migrate to new V8 array API
b3a0e1f
This change migrates the deprecated V8 Array API to new APIs.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. util Issues and PRs related to the built-in util module. labels Nov 24, 2018
addaleax
addaleax approved these changes Nov 24, 2018
View reviewed changes
@addaleax addaleax added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Nov 24, 2018
@addaleax

addaleax commented Nov 24, 2018

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung
joyeecheung approved these changes Nov 24, 2018
View reviewed changes
cjihrig
cjihrig approved these changes Nov 24, 2018
View reviewed changes
gireeshpunathil
gireeshpunathil approved these changes Nov 25, 2018
View reviewed changes
devsnek
devsnek approved these changes Nov 25, 2018
View reviewed changes
TimothyGu
TimothyGu approved these changes Nov 25, 2018
View reviewed changes
Comment thread src/node_util.cc Outdated

int state = promise->State();
ret->Set(env->context(), 0, Integer::New(isolate, state)).FromJust();
std::vector<Local<Value>> values;

@TimothyGu TimothyGu Nov 25, 2018

Copy link
Copy Markdown
Member

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.

values(2), as we can have a maximum of two values.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

refack reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@refack refack Nov 25, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Then way not simply:

Suggested change
std::vector<Local<Value>> values;
Local<Value> values[2] = { Integer::New(isolate, state) };
size_t number_of_values = 1;
if (state != Promise::PromiseState::kPending)
values[number_of_values++] = promise->Result();
DCHECK_LE(number_of_values, arraysize(values));
Local<Array> ret = Array::New(isolate, values, number_of_values);

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TimothyGu TimothyGu Nov 26, 2018

Copy link
Copy Markdown
Member

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.

That’s much longer and doesn’t really provide too much of an advantage over using a vector.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@refack refack Nov 26, 2018

Copy link
Copy Markdown
Contributor

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.

AFAICT it's only one line longer, and we get everything on the stack with no free-store allocations.
I thought that when possible, we prefer static sized data structures?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kt3k kt3k Nov 27, 2018

Copy link
Copy Markdown
Contributor Author

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 tried @refack's suggestion, but I couldn't find a reasonable way to include DCHECK_LE in this file. DCHECK_LE is defined in deps/v8/src/base/logging.h, and when I add #include "../deps/v8/src/base/logging.h" at the top, the compile doesn't seem passing (relative path inside logging.h doesn't seem resolving...)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kt3k kt3k Nov 27, 2018

Copy link
Copy Markdown
Contributor Author

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 followed @TimothyGu's comment for the moment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kt3k kt3k Nov 28, 2018

Copy link
Copy Markdown
Contributor Author

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.

With values(2), the values are initialized with empty values and it has size 2. So I needed to add an else block and .pop_back() the last (empty) value. (I think that's unnecessarily complex and not desirable code.)

So I changed the code to follow @refack's comment (without DCHECK_LE assertion).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kt3k
src: set maximum of vector
11230d2
This addresses the comment in nodejs#24613
@kt3k
kt3k force-pushed the feature/node-util-improvement branch 2 times, most recently from fe987df to 0098eb2 Compare November 28, 2018 04:57
@kt3k
src: refactor src/node_util.cc
3729328
Use static sized data structure
@kt3k
kt3k force-pushed the feature/node-util-improvement branch from 0098eb2 to 3729328 Compare November 28, 2018 12:50
@kt3k

kt3k commented Nov 28, 2018

Copy link
Copy Markdown
Contributor Author

(I force-pushed with empty change a few times to fix CI status but it keeps failing because of the rate limit of github API, which is used for fetching the commit message.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung
joyeecheung approved these changes Nov 28, 2018
View reviewed changes
@joyeecheung

joyeecheung commented Nov 28, 2018

Copy link
Copy Markdown
Member

@kt3k We don't have our own DCHECK macros - it's being added in #24359

kt3k reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gireeshpunathil

gireeshpunathil commented Nov 28, 2018

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Nov 29, 2018

Copy link
Copy Markdown
Member

Landed in 27139fc

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott closed this Nov 29, 2018
Trott pushed a commit to Trott/io.js that referenced this pull request Nov 29, 2018
@kt3k @Trott
src: migrate to new V8 array API
27139fc
This change migrates the deprecated V8 Array API to new APIs.

PR-URL: nodejs#24613
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@kt3k

kt3k commented Nov 29, 2018

Copy link
Copy Markdown
Contributor Author

Thank you for the reviews! Thank you for landing!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kt3k
kt3k deleted the feature/node-util-improvement branch November 29, 2018 03:21
targos pushed a commit that referenced this pull request Nov 29, 2018
@kt3k @targos
src: migrate to new V8 array API
c26b10c
This change migrates the deprecated V8 Array API to new APIs.

PR-URL: #24613
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Dec 5, 2018
v11.4.0 proposal #24854
Merged
4 tasks done
This was referenced Dec 7, 2018
2018-12-07 Version 11.4.0 (Current) @BridgeAR beevelop/docker-android-nodejs#261
Closed
2018-12-07 Version 11.4.0 (Current) @BridgeAR beevelop/docker-android-nodejs#262
Closed
This was referenced Dec 7, 2018
2018-12-07 Version 11.4.0 (Current) @BridgeAR beevelop/docker-android-nodejs#263
Closed
2018-12-07 Version 11.4.0 (Current) @BridgeAR beevelop/docker-android-nodejs#264
Closed
2018-12-07 Version 11.4.0 (Current) @BridgeAR beevelop/docker-android-nodejs#265
Closed
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
@kt3k @refack
src: migrate to new V8 array API
db12fb9
This change migrates the deprecated V8 Array API to new APIs.

PR-URL: nodejs#24613
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@BethGriggs BethGriggs added the dont-land-on-v10.x label Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax approved these changes
@cjihrig cjihrig cjihrig approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
@gireeshpunathil gireeshpunathil gireeshpunathil approved these changes
+3 more reviewers
@refack refack refack left review comments
@TimothyGu TimothyGu TimothyGu approved these changes
@devsnek devsnek devsnek approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. util Issues and PRs related to the built-in util module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@kt3k @addaleax @joyeecheung @gireeshpunathil @Trott @refack @TimothyGu @cjihrig @devsnek @BethGriggs @nodejs-github-bot
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.