Skip to content

Commit

Permalink
Merge branch 'main' into fix-49848
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJithil authored Sep 30, 2023
2 parents 4c7229c + 51f4ff2 commit 3f99951
Show file tree
Hide file tree
Showing 140 changed files with 2,344 additions and 881 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,6 @@ module.exports = {
WritableStream: 'readable',
WritableStreamDefaultWriter: 'readable',
WritableStreamDefaultController: 'readable',
WebSocket: 'readable',
},
};
8 changes: 4 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
/LICENSE @nodejs/tsc
/onboarding.md @nodejs/tsc

# website
/doc/api_assets @nodejs/website
/doc/template.html @nodejs/website
/tools/doc @nodejs/website
# nodejs.org website
/doc/api_assets @nodejs/nodejs-website
/doc/template.html @nodejs/nodejs-website
/tools/doc @nodejs/web-infra

# streams

Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ release.
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V20.md#20.7.0">20.7.0</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V20.md#20.8.0">20.8.0</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.7.0">20.7.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.6.1">20.6.1</a><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.6.0">20.6.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.5.1">20.5.1</a><br/>
Expand Down
1 change: 1 addition & 0 deletions android_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def patch_android():
GYP_DEFINES += " v8_target_arch=" + arch
GYP_DEFINES += " android_target_arch=" + arch
GYP_DEFINES += " host_os=" + host_os + " OS=android"
GYP_DEFINES += " android_ndk_path=" + android_ndk_path
os.environ['GYP_DEFINES'] = GYP_DEFINES

if os.path.exists("./configure"):
Expand Down
44 changes: 44 additions & 0 deletions benchmark/error/format-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [1e7],
input: [
'',
'a',
'a,b',
'a,b,c',
'a,b,c,d',
],
type: [
'undefined',
'and',
'or',
],
}, {
flags: ['--expose-internals'],
});

function main({ n, input, type }) {
const {
formatList,
} = require('internal/errors');

const list = input.split(',');

if (type === 'undefined') {
bench.start();
for (let i = 0; i < n; ++i) {
formatList(list);
}
bench.end(n);
return;
}

bench.start();
for (let i = 0; i < n; ++i) {
formatList(list, type);
}
bench.end(n);
}
4 changes: 2 additions & 2 deletions benchmark/streams/writable-manywrites.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common');
const Writable = require('stream').Writable;

const bench = common.createBenchmark(main, {
n: [2e6],
n: [1e5],
sync: ['yes', 'no'],
writev: ['yes', 'no'],
callback: ['yes', 'no'],
Expand All @@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {

function main({ n, sync, writev, callback, len }) {
const b = Buffer.allocUnsafe(len);
const s = new Writable();
const s = new Writable({ highWaterMark: 16 * 1024 });
sync = sync === 'yes';

const writecb = (cb) => {
Expand Down
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
],
},],
['OS == "android"', {
'cflags': [ '-fPIC' ],
'cflags': [ '-fPIC', '-I<(android_ndk_path)/sources/android/cpufeatures' ],
'ldflags': [ '-fPIC' ]
}],
],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl-cl_asm.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/asm/openssl-cl.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/asm/openssl-cl.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl-cl_asm_avx2.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/asm_avx2/openssl-cl.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/asm_avx2/openssl-cl.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl-cl_no_asm.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/no-asm/openssl-cl.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/no-asm/openssl-cl.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl-fips_asm.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/asm/openssl-fips.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/asm/openssl-fips.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl-fips_asm_avx2.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/asm_avx2/openssl-fips.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/asm_avx2/openssl-fips.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl-fips_no_asm.gypi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
'defines': ['OPENSSL_NO_ASM'],
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/no-asm/openssl-fips.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/no-asm/openssl-fips.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl_asm.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/asm/openssl.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/asm/openssl.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl_asm_avx2.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/asm_avx2/openssl.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/asm_avx2/openssl.gypi'],
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
# build options specific to OS
'conditions': [
[ 'OS=="aix"', {
[ 'OS in ("aix", "os400")', {
# AIX is missing /usr/include/endian.h
'defines': [
'__LITTLE_ENDIAN=1234',
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/openssl_no_asm.gypi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
'defines': ['OPENSSL_NO_ASM'],
'conditions': [
['target_arch=="ppc64" and OS=="aix"', {
['target_arch=="ppc64" and OS in ("aix", "os400")', {
'includes': ['config/archs/aix64-gcc-as/no-asm/openssl.gypi'],
}, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', {
'includes': ['config/archs/linux-ppc64le/no-asm/openssl.gypi'],
Expand Down
11 changes: 10 additions & 1 deletion deps/uvwasi/include/uvwasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
extern "C" {
#endif

#include "uv.h"
#include "wasi_serdes.h"
#include "wasi_types.h"

#define UVWASI_VERSION_MAJOR 0
#define UVWASI_VERSION_MINOR 0
#define UVWASI_VERSION_PATCH 18
#define UVWASI_VERSION_PATCH 19
#define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \
(UVWASI_VERSION_MINOR << 8) | \
(UVWASI_VERSION_PATCH))
Expand Down Expand Up @@ -47,17 +48,25 @@ typedef struct uvwasi_s {
char* env_buf;
uvwasi_size_t env_buf_size;
const uvwasi_mem_t* allocator;
uv_loop_t* loop;
} uvwasi_t;

typedef struct uvwasi_preopen_s {
const char* mapped_path;
const char* real_path;
} uvwasi_preopen_t;

typedef struct uvwasi_preopen_socket_s {
const char* address;
int port;
} uvwasi_preopen_socket_t;

typedef struct uvwasi_options_s {
uvwasi_size_t fd_table_size;
uvwasi_size_t preopenc;
uvwasi_preopen_t* preopens;
uvwasi_size_t preopen_socketc;
uvwasi_preopen_socket_t* preopen_sockets;
uvwasi_size_t argc;
const char** argv;
const char** envp;
Expand Down
69 changes: 52 additions & 17 deletions deps/uvwasi/src/fd_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static uvwasi_errno_t uvwasi__insert_stdio(uvwasi_t* uvwasi,
err = uvwasi_fd_table_insert(uvwasi,
table,
fd,
NULL,
name,
name,
type,
Expand All @@ -58,6 +59,7 @@ static uvwasi_errno_t uvwasi__insert_stdio(uvwasi_t* uvwasi,
uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi,
struct uvwasi_fd_table_t* table,
uv_file fd,
uv_tcp_t* sock,
const char* mapped_path,
const char* real_path,
uvwasi_filetype_t type,
Expand All @@ -78,29 +80,40 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi,
char* rp_copy;
char* np_copy;

mp_len = strlen(mapped_path);
rp_len = strlen(real_path);
if (type != UVWASI_FILETYPE_SOCKET_STREAM) {
mp_len = strlen(mapped_path);
rp_len = strlen(real_path);
} else {
mp_len = 0;
rp_len = 0;
rp_copy = NULL;
mp_copy = NULL;
np_copy = NULL;
}

/* Reserve room for the mapped path, real path, and normalized mapped path. */
entry = (struct uvwasi_fd_wrap_t*)
uvwasi__malloc(uvwasi, sizeof(*entry) + mp_len + mp_len + rp_len + 3);
if (entry == NULL)
return UVWASI_ENOMEM;

mp_copy = (char*)(entry + 1);
rp_copy = mp_copy + mp_len + 1;
np_copy = rp_copy + rp_len + 1;
memcpy(mp_copy, mapped_path, mp_len);
mp_copy[mp_len] = '\0';
memcpy(rp_copy, real_path, rp_len);
rp_copy[rp_len] = '\0';

/* Calculate the normalized version of the mapped path, as it will be used for
any path calculations on this fd. Use the length of the mapped path as an
upper bound for the normalized path length. */
err = uvwasi__normalize_path(mp_copy, mp_len, np_copy, mp_len);
if (err) {
uvwasi__free(uvwasi, entry);
goto exit;
if (type != UVWASI_FILETYPE_SOCKET_STREAM) {
mp_copy = (char*)(entry + 1);
rp_copy = mp_copy + mp_len + 1;
np_copy = rp_copy + rp_len + 1;
memcpy(mp_copy, mapped_path, mp_len);
mp_copy[mp_len] = '\0';
memcpy(rp_copy, real_path, rp_len);
rp_copy[rp_len] = '\0';

/* Calculate the normalized version of the mapped path, as it will be used for
any path calculations on this fd. Use the length of the mapped path as an
upper bound for the normalized path length. */
err = uvwasi__normalize_path(mp_copy, mp_len, np_copy, mp_len);
if (err) {
uvwasi__free(uvwasi, entry);
goto exit;
}
}

uv_rwlock_wrlock(&table->rwlock);
Expand Down Expand Up @@ -150,6 +163,7 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi,

entry->id = index;
entry->fd = fd;
entry->sock = sock;
entry->path = mp_copy;
entry->real_path = rp_copy;
entry->normalized_path = np_copy;
Expand Down Expand Up @@ -280,6 +294,7 @@ uvwasi_errno_t uvwasi_fd_table_insert_preopen(uvwasi_t* uvwasi,
return uvwasi_fd_table_insert(uvwasi,
table,
fd,
NULL,
path,
real_path,
UVWASI_FILETYPE_DIRECTORY,
Expand All @@ -290,6 +305,26 @@ uvwasi_errno_t uvwasi_fd_table_insert_preopen(uvwasi_t* uvwasi,
}


uvwasi_errno_t uvwasi_fd_table_insert_preopen_socket(uvwasi_t* uvwasi,
struct uvwasi_fd_table_t* table,
uv_tcp_t* sock) {
if (table == NULL || sock == NULL)
return UVWASI_EINVAL;

return uvwasi_fd_table_insert(uvwasi,
table,
-1,
sock,
NULL,
NULL,
UVWASI_FILETYPE_SOCKET_STREAM,
UVWASI__RIGHTS_SOCKET_BASE,
UVWASI__RIGHTS_SOCKET_INHERITING,
1,
NULL);
}


uvwasi_errno_t uvwasi_fd_table_get(struct uvwasi_fd_table_t* table,
const uvwasi_fd_t id,
struct uvwasi_fd_wrap_t** wrap,
Expand Down
5 changes: 5 additions & 0 deletions deps/uvwasi/src/fd_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct uvwasi_options_s;
struct uvwasi_fd_wrap_t {
uvwasi_fd_t id;
uv_file fd;
uv_tcp_t* sock;
char* path;
char* real_path;
char* normalized_path;
Expand All @@ -35,6 +36,7 @@ void uvwasi_fd_table_free(struct uvwasi_s* uvwasi,
uvwasi_errno_t uvwasi_fd_table_insert(struct uvwasi_s* uvwasi,
struct uvwasi_fd_table_t* table,
uv_file fd,
uv_tcp_t* sock,
const char* mapped_path,
const char* real_path,
uvwasi_filetype_t type,
Expand All @@ -47,6 +49,9 @@ uvwasi_errno_t uvwasi_fd_table_insert_preopen(struct uvwasi_s* uvwasi,
const uv_file fd,
const char* path,
const char* real_path);
uvwasi_errno_t uvwasi_fd_table_insert_preopen_socket(struct uvwasi_s* uvwasi,
struct uvwasi_fd_table_t* table,
uv_tcp_t* sock);
uvwasi_errno_t uvwasi_fd_table_get(struct uvwasi_fd_table_t* table,
const uvwasi_fd_t id,
struct uvwasi_fd_wrap_t** wrap,
Expand Down
Loading

0 comments on commit 3f99951

Please sign in to comment.