Skip to content

Commit a695f6a

Browse files
Merge pull request #1009 from nodejs/main
Create a new pull request by comparing changes across two branches
2 parents b32641c + 3c50297 commit a695f6a

File tree

150 files changed

+1921
-1541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+1921
-1541
lines changed

.github/label-pr-config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ allJsSubSystems:
187187
- readline
188188
- repl
189189
- report
190+
- sqlite
190191
- stream
191192
- string_decoder
192193
- timers

.github/workflows/coverage-linux-without-intl.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: Environment Information
6161
run: npx envinfo
6262
- name: Install gcovr
63-
run: pip install gcovr==4.2
63+
run: pip install gcovr==7.2
6464
- name: Build
6565
run: make build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn --coverage --without-intl"
6666
# TODO(bcoe): fix the couple tests that fail with the inspector enabled.
@@ -72,7 +72,7 @@ jobs:
7272
env:
7373
NODE_OPTIONS: --max-old-space-size=8192
7474
- name: Report C++
75-
run: cd out && gcovr --gcov-exclude='.*\b(deps|usr|out|obj|cctest|embedding)\b' -v -r Release/obj.target --xml -o ../coverage/coverage-cxx.xml --root=$(cd ../ && pwd)
75+
run: gcovr --object-directory=out -v --filter src --xml -o ./coverage/coverage-cxx.xml --root=./ --gcov-executable="llvm-cov-18 gcov"
7676
# Clean temporary output from gcov and c8, so that it's not uploaded:
7777
- name: Clean tmp
7878
run: rm -rf coverage/tmp && rm -rf out

.github/workflows/coverage-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: Environment Information
6161
run: npx envinfo
6262
- name: Install gcovr
63-
run: pip install gcovr==4.2
63+
run: pip install gcovr==7.2
6464
- name: Build
6565
run: make build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn --coverage"
6666
# TODO(bcoe): fix the couple tests that fail with the inspector enabled.
@@ -72,7 +72,7 @@ jobs:
7272
env:
7373
NODE_OPTIONS: --max-old-space-size=8192
7474
- name: Report C++
75-
run: cd out && gcovr --gcov-exclude='.*\b(deps|usr|out|obj|cctest|embedding)\b' -v -r Release/obj.target --xml -o ../coverage/coverage-cxx.xml --root=$(cd ../ && pwd)
75+
run: gcovr --object-directory=out -v --filter src --xml -o ./coverage/coverage-cxx.xml --root=./ --gcov-executable="llvm-cov-18 gcov"
7676
# Clean temporary output from gcov and c8, so that it's not uploaded:
7777
- name: Clean tmp
7878
run: rm -rf coverage/tmp && rm -rf out

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ coverage: coverage-test ## Run the tests and generate a coverage report.
254254
.PHONY: coverage-build
255255
coverage-build: all
256256
-$(MAKE) coverage-build-js
257-
if [ ! -d gcovr ]; then $(PYTHON) -m pip install -t gcovr gcovr==4.2; fi
257+
if [ ! -d gcovr ]; then $(PYTHON) -m pip install -t gcovr gcovr==7.2; fi
258258
$(MAKE)
259259

260260
.PHONY: coverage-build-js
@@ -270,9 +270,10 @@ coverage-test: coverage-build
270270
-NODE_V8_COVERAGE=coverage/tmp \
271271
TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) $(COVTESTS)
272272
$(MAKE) coverage-report-js
273-
-(cd out && PYTHONPATH=../gcovr $(PYTHON) -m gcovr \
274-
--gcov-exclude='.*\b(deps|usr|out|cctest|embedding)\b' -v \
275-
-r ../src/ --object-directory Release/obj.target \
273+
-(PYTHONPATH=./gcovr $(PYTHON) -m gcovr \
274+
--object-directory=out \
275+
--filter src -v \
276+
--root ./ \
276277
--html --html-details -o ../coverage/cxxcoverage.html \
277278
--gcov-executable="$(GCOV)")
278279
@printf "Javascript coverage %%: "
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#include <node_api.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
5+
#define NODE_API_CALL(call) \
6+
do { \
7+
napi_status status = call; \
8+
if (status != napi_ok) { \
9+
fprintf(stderr, #call " failed: %d\n", status); \
10+
abort(); \
11+
} \
12+
} while (0)
13+
14+
#define ABORT_IF_FALSE(condition) \
15+
if (!(condition)) { \
16+
fprintf(stderr, #condition " failed\n"); \
17+
abort(); \
18+
}
19+
20+
static napi_value Runner(napi_env env,
21+
napi_callback_info info,
22+
napi_value property_key) {
23+
napi_value argv[2], undefined, js_array_length, start, end;
24+
size_t argc = 2;
25+
napi_valuetype val_type = napi_undefined;
26+
bool is_array = false;
27+
uint32_t array_length = 0;
28+
napi_value* native_array;
29+
30+
// Validate params and retrieve start and end function.
31+
NODE_API_CALL(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
32+
ABORT_IF_FALSE(argc == 2);
33+
NODE_API_CALL(napi_typeof(env, argv[0], &val_type));
34+
ABORT_IF_FALSE(val_type == napi_object);
35+
NODE_API_CALL(napi_is_array(env, argv[1], &is_array));
36+
ABORT_IF_FALSE(is_array);
37+
NODE_API_CALL(napi_get_array_length(env, argv[1], &array_length));
38+
NODE_API_CALL(napi_get_named_property(env, argv[0], "start", &start));
39+
NODE_API_CALL(napi_typeof(env, start, &val_type));
40+
ABORT_IF_FALSE(val_type == napi_function);
41+
NODE_API_CALL(napi_get_named_property(env, argv[0], "end", &end));
42+
NODE_API_CALL(napi_typeof(env, end, &val_type));
43+
ABORT_IF_FALSE(val_type == napi_function);
44+
45+
NODE_API_CALL(napi_get_undefined(env, &undefined));
46+
NODE_API_CALL(napi_create_uint32(env, array_length, &js_array_length));
47+
48+
// Copy objects into a native array.
49+
native_array =
50+
static_cast<napi_value*>(malloc(array_length * sizeof(napi_value)));
51+
for (uint32_t idx = 0; idx < array_length; idx++) {
52+
NODE_API_CALL(napi_get_element(env, argv[1], idx, &native_array[idx]));
53+
}
54+
55+
// Start the benchmark.
56+
napi_call_function(env, argv[0], start, 0, nullptr, nullptr);
57+
58+
for (uint32_t idx = 0; idx < array_length; idx++) {
59+
NODE_API_CALL(
60+
napi_set_property(env, native_array[idx], property_key, undefined));
61+
}
62+
63+
// Conclude the benchmark.
64+
NODE_API_CALL(
65+
napi_call_function(env, argv[0], end, 1, &js_array_length, nullptr));
66+
67+
free(native_array);
68+
69+
return undefined;
70+
}
71+
72+
static napi_value RunPropertyKey(napi_env env, napi_callback_info info) {
73+
napi_value property_key;
74+
NODE_API_CALL(node_api_create_property_key_utf16(
75+
env, u"prop", NAPI_AUTO_LENGTH, &property_key));
76+
return Runner(env, info, property_key);
77+
}
78+
79+
static napi_value RunNormalString(napi_env env, napi_callback_info info) {
80+
napi_value property_key;
81+
NODE_API_CALL(
82+
napi_create_string_utf16(env, u"prop", NAPI_AUTO_LENGTH, &property_key));
83+
return Runner(env, info, property_key);
84+
}
85+
86+
NAPI_MODULE_INIT() {
87+
napi_property_descriptor props[] = {
88+
{"RunPropertyKey",
89+
nullptr,
90+
RunPropertyKey,
91+
nullptr,
92+
nullptr,
93+
nullptr,
94+
static_cast<napi_property_attributes>(napi_writable | napi_configurable |
95+
napi_enumerable),
96+
nullptr},
97+
{"RunNormalString",
98+
nullptr,
99+
RunNormalString,
100+
nullptr,
101+
nullptr,
102+
nullptr,
103+
static_cast<napi_property_attributes>(napi_writable | napi_configurable |
104+
napi_enumerable),
105+
nullptr},
106+
};
107+
108+
NODE_API_CALL(napi_define_properties(
109+
env, exports, sizeof(props) / sizeof(*props), props));
110+
return exports;
111+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'binding',
5+
'sources': [ 'binding.cc' ],
6+
'defines': [ 'NAPI_EXPERIMENTAL' ],
7+
}
8+
]
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
const common = require('../../common.js');
4+
5+
const binding = require(`./build/${common.buildType}/binding`);
6+
7+
const bench = common.createBenchmark(main, {
8+
n: [5e6],
9+
implem: ['RunPropertyKey', 'RunNormalString'],
10+
});
11+
12+
function main({ n, implem }) {
13+
const objs = Array(n).fill(null).map((item) => new Object());
14+
binding[implem](bench, objs);
15+
}

benchmark/napi/ref/addon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ SetCount(napi_env env, napi_callback_info info) {
3333
return NULL;
3434
}
3535

36-
static void IncrementCounter(node_api_nogc_env env, void* data, void* hint) {
36+
static void IncrementCounter(node_api_basic_env env, void* data, void* hint) {
3737
size_t* count = data;
3838
(*count) = (*count) + 1;
3939
}

codecov.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
# TODO(bcoe): re-enable coverage report comments, once we can figure out
2-
# how to make them more accurate for the Node.js project,
3-
# See: https://github.com/nodejs/node/issues/35759
4-
comment: false
5-
# # Only show diff and files changed:
6-
# layout: "diff, files"
7-
# # Don't post if no changes in coverage:
8-
# require_changes: true
1+
comment:
2+
# Only show diff and files changed:
3+
layout: diff, files
4+
# Don't post if no changes in coverage:
5+
require_changes: true
96

107
codecov:
11-
branch: main
128
notify:
139
# Wait for all coverage builds:
1410
# - coverage-linux.yml
15-
# - coverage-windows.yml
11+
# - coverage-windows.yml [manually disabled see #50489]
1612
# - coverage-linux-without-intl.yml
17-
after_n_builds: 3
13+
after_n_builds: 2
1814

1915
coverage:
2016
# Useful for blocking Pull Requests that don't meet a particular coverage threshold.

0 commit comments

Comments
 (0)