Skip to content

Commit a31a123

Browse files
guangwongoraluben
authored andcommitted
cli: add version for anode and fix lint issues
1 parent b6904fe commit a31a123

26 files changed

+75
-54
lines changed

.github/workflows/build-tarball.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ permissions:
3636

3737
jobs:
3838
build-tarball:
39-
if: github.event.pull_request.draft == false
39+
if: github.event.pull_request.draft == false && false
4040
runs-on: ubuntu-latest
4141
steps:
4242
- uses: actions/checkout@v3

.github/workflows/build-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ permissions:
3131

3232
jobs:
3333
build-windows:
34-
if: github.event.pull_request.draft == false
34+
if: github.event.pull_request.draft == false && false
3535
runs-on: windows-2019
3636
steps:
3737
- uses: actions/checkout@v3

.github/workflows/coverage-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ permissions:
3434

3535
jobs:
3636
coverage-linux:
37-
if: github.event.pull_request.draft == false
37+
if: github.event.pull_request.draft == false && false
3838
runs-on: ubuntu-latest
3939
steps:
4040
- uses: actions/checkout@v3

.github/workflows/coverage-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ permissions:
3636

3737
jobs:
3838
coverage-windows:
39-
if: github.event.pull_request.draft == false
39+
if: github.event.pull_request.draft == false && false
4040
runs-on: windows-2019
4141
steps:
4242
- uses: actions/checkout@v3

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ permissions:
2121

2222
jobs:
2323
build-docs:
24-
if: github.event.pull_request.draft == false
24+
if: github.event.pull_request.draft == false && false
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v3

.github/workflows/test-asan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ permissions:
3838

3939
jobs:
4040
test-asan:
41-
if: github.event.pull_request.draft == false
41+
if: github.event.pull_request.draft == false && false
4242
runs-on: ubuntu-20.04
4343
env:
4444
CC: clang

.github/workflows/test-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ permissions:
3131

3232
jobs:
3333
test-linux:
34-
if: github.event.pull_request.draft == false
34+
if: github.event.pull_request.draft == false && false
3535
runs-on: ubuntu-latest
3636
steps:
3737
- uses: actions/checkout@v3

.github/workflows/test-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ permissions:
3737

3838
jobs:
3939
test-macOS:
40-
if: github.event.pull_request.draft == false
40+
if: github.event.pull_request.draft == false && false
4141
runs-on: macos-latest
4242
steps:
4343
- uses: actions/checkout@v3

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -800,17 +800,16 @@ external libraries that are available under a variety of licenses. See
800800
[LICENSE](https://github.com/nodejs/node/blob/HEAD/LICENSE) for the full
801801
license text.
802802

803+
## Noslate-Anode
804+
805+
Noslate-Anode is developed by Alibaba and based on the Node.js project.
806+
All changes licensed under the MIT License.
807+
See the NOTICE file for more information.
808+
803809
[Code of Conduct]: https://github.com/nodejs/admin/blob/HEAD/CODE_OF_CONDUCT.md
804810
[Contributing to the project]: CONTRIBUTING.md
805811
[Node.js website]: https://nodejs.org/
806812
[OpenJS Foundation]: https://openjsf.org/
807813
[Strategic initiatives]: doc/contributing/strategic-initiatives.md
808814
[Technical values and prioritization]: doc/contributing/technical-values.md
809815
[Working Groups]: https://github.com/nodejs/TSC/blob/HEAD/WORKING_GROUPS.md
810-
811-
812-
## Noslate-Node
813-
814-
Noslate-Node is developed by Alibaba and based on the Node.js project.
815-
All changes licensed under the MIT License.
816-
See the NOTICE file for more information.

deps/metacache/city.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ static uint32 UNALIGNED_LOAD32(const char *p) {
7373

7474
#endif // __BIG_ENDIAN__
7575

76-
#if !defined(LIKELY)
7776
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
78-
#define LIKELY(x) (__builtin_expect(!!(x), 1))
77+
#define MY_LIKELY(x) (__builtin_expect(!!(x), 1))
7978
#else
80-
#define LIKELY(x) (x)
81-
#endif
79+
#define MY_LIKELY(x) (x)
8280
#endif
8381

8482
static uint64 Fetch64(const char *p) {
@@ -313,7 +311,7 @@ uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed) {
313311
std::swap(z, x);
314312
s += 64;
315313
len -= 128;
316-
} while (LIKELY(len >= 128));
314+
} while (MY_LIKELY(len >= 128));
317315
x += Rotate(v.first + z, 49) * k0;
318316
z += Rotate(w.first, 37) * k0;
319317
// If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
@@ -432,7 +430,7 @@ static void CityHashCrc256Short(const char *s, size_t len, uint64 *result) {
432430
}
433431

434432
void CityHashCrc256(const char *s, size_t len, uint64 *result) {
435-
if (LIKELY(len >= 240)) {
433+
if (MY_LIKELY(len >= 240)) {
436434
CityHashCrc256Long(s, len, 0, result);
437435
} else {
438436
CityHashCrc256Short(s, len, result);
@@ -463,3 +461,5 @@ uint128 CityHashCrc128(const char *s, size_t len) {
463461
}
464462

465463
#endif
464+
465+
undef MY_LIKELY

deps/metacache/metacache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int metacache::savefile(const char *file)
8383
std::ofstream f(file, std::ios::binary);
8484
void *ptr = vmem_cur;
8585
size_t size = (uint64_t)ptr - MC_VMEM;
86-
f.write((char *)MC_VMEM, ALIGN_PAGE(size));
86+
f.write((char *)MC_VMEM, MC_ALIGN_PAGE(size));
8787
f.close();
8888
printf("%s(%s) = %lu\n", __func__, file, size);
8989
return 0;

deps/metacache/metacache.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <unistd.h>
1212
#include <string.h>
1313
#include <assert.h>
14+
#include <inttypes.h>
1415

1516
#include <new>
1617
#include <string>
@@ -38,8 +39,8 @@ namespace strontium {
3839
namespace metacache {
3940

4041
// likely and unlikey
41-
#define LIKELY(x) (__builtin_expect(!!(x), 1))
42-
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
42+
#define MY_LIKELY(x) (__builtin_expect(!!(x), 1))
43+
#define MY_UNLIKELY(x) (__builtin_expect(!!(x), 0))
4344

4445
// default vm address the cache loading to.
4546
// it could be a dynamic virtual address, depends on plantform.
@@ -53,11 +54,11 @@ namespace metacache {
5354

5455
// page aligned
5556
// const int kPageSize = sysconf(_SC_PAGE_SIZE);
56-
#define PAGE_SIZE (4096)
57+
#define MC_PAGE_SIZE (4096)
5758
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
58-
//#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
59-
#define ALIGN(x,a) __ALIGN_MASK(x,((a)-1))
60-
#define ALIGN_PAGE(x) ALIGN(x,PAGE_SIZE)
59+
//#define MC_ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
60+
#define MC_ALIGN(x,a) __ALIGN_MASK(x,((a)-1))
61+
#define MC_ALIGN_PAGE(x) MC_ALIGN(x,MC_PAGE_SIZE)
6162

6263
// metacache uses offset for memory saving.
6364
// the whole metacache using 32b pointer in 64b platform.
@@ -415,7 +416,7 @@ class city {
415416
std::swap(z, x);
416417
s += 64;
417418
len -= 128;
418-
} while (LIKELY(len >= 128));
419+
} while (MY_LIKELY(len >= 128));
419420
x += Rotate(v.first + z, 49) * k0;
420421
z += Rotate(w.first, 37) * k0;
421422
// If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
@@ -595,7 +596,7 @@ struct cm {
595596
std::ofstream f(file, std::ios::binary);
596597
void *ptr = _vmcur;
597598
size_t size = (uint64_t)ptr - MC_DEF_VMADDR;
598-
f.write((char *)MC_DEF_VMADDR, ALIGN_PAGE(size));
599+
f.write((char *)MC_DEF_VMADDR, MC_ALIGN_PAGE(size));
599600
f.close();
600601
printf("%s(%s) = %lu\n", __func__, file, size);
601602
return 0;
@@ -2482,7 +2483,7 @@ struct fs_w : _wT {
24822483
void debug_print()
24832484
{
24842485
// show records table
2485-
printf("Records table: %u\n", _records.size());
2486+
printf("Records table: %lu\n", _records.size());
24862487
printf("%4s %4s %s\n", "STAT", "OPEN", "FILE_PATH");
24872488
auto it = _records.begin();
24882489
for (; it != _records.end(); it++) {
@@ -2547,7 +2548,7 @@ struct metacache_w : _wT {
25472548
{
25482549
str_w w(s);
25492550
auto it = _set_str.insert(w);
2550-
printf(" wc::str('%s'), hash(%lx), cmptr(%p)\n", w._sz.c_str(), w._hash, w._cm_ptr);
2551+
printf(" wc::str('%s'), hash(%" PRIx64 "), cmptr(%p)\n", w._sz.c_str(), w._hash, w._cm_ptr);
25512552
return *it.first;
25522553
}
25532554

@@ -2577,3 +2578,6 @@ struct metacache_w : _wT {
25772578
}; // namespace strontium
25782579

25792580
#endif // _STRONTIUM_METACACHE_H_
2581+
2582+
#undef MY_LIKELY
2583+
#undef MY_UNLIKELY

deps/strontium/src/pgo/require-cache.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ RequireCacheWrap::RequireCacheWrap(Environment* env,
7979
mc_(metacache::load(cache_filename)),
8080
error_info_(""),
8181
cache_filename_(cache_filename),
82-
type_(READER),
82+
// type_(READER),
8383
contents_(),
8484
relationship_(),
8585
internal_meta_kv_() {
@@ -125,8 +125,8 @@ RequireCacheWrap::RequireCacheWrap(Environment* env,
125125
Local<Array> entries)
126126
: BaseObject(env, obj),
127127
mc_(metacache::create(METACACHE_MAX_SIZE)),
128-
cache_filename_(""),
129-
type_(WRITER) {
128+
// type_(WRITER),
129+
cache_filename_("") {
130130
MakeWeak();
131131

132132
if (mc_ == nullptr) {
@@ -317,12 +317,12 @@ string RequireCacheWrap::TransformFilenameBack(const char* filename,
317317
return *ret;
318318
}
319319

320-
size_t index = -1;
320+
ssize_t index = -1;
321321
node::MaybeStackBuffer<char, PATH_MAX_BYTES> temp;
322-
sscanf(num, "%lu", &index);
322+
sscanf(num, "%ld", &index);
323323
snprintf(*temp, PATH_MAX_BYTES - 1, ".%s", filename + pos);
324324

325-
if (index < 0 || index >= entries_count_) {
325+
if (index < 0 || index >= (ssize_t) entries_count_) {
326326
env->ThrowError("Broken entry index.");
327327
return "";
328328
}

deps/strontium/src/pgo/require-cache.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class MetaCacheTypeUnion {
5454
~MetaCacheTypeUnion() {
5555
if (body_.ptr != nullptr) {
5656
// TODO(zl131478): 需要完整的析构
57-
delete body_.ptr;
57+
// TODO(guangwong): 不知道该转成哪个类型来析构,先转个基础类型逃避下检查
58+
delete (int*) body_.ptr;
5859
body_.ptr = nullptr;
5960
}
6061
}
@@ -147,7 +148,7 @@ class RequireCacheWrap : public BaseObject {
147148
string error_info_;
148149
string cache_filename_;
149150

150-
WrapType type_;
151+
// WrapType type_;
151152
MetaCacheTypeUnion<MetaCacheFileBufferR, MetaCacheFileBufferW> contents_;
152153
MetaCacheTypeUnion<MetaCacheRelationR, MetaCacheRelationW> relationship_;
153154
MetaCacheTypeUnion<MetaCacheMetaKVR, MetaCacheMetaKVW> internal_meta_kv_;

lib/alinode/relational_require_cache.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
'use strict';
22

3-
/* eslint-disable max-len */
4-
5-
63
const { ArrayIsArray } = primordials;
74
const assert = require('assert');
85

lib/internal/relational_require_cache/loader.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
/* eslint-disable max-len */
4-
53
const { Symbol } = primordials;
64
const { Error } = primordials;
75
const { JSONParse } = primordials;

lib/internal/relational_require_cache/recorder.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
/* eslint-disable max-len */
4-
53
const { Symbol } = primordials;
64
const { Error } = primordials;
75

lib/internal/relational_require_cache/require_cache.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
/* eslint-disable max-len */
4-
53
const { Error } = primordials;
64

75
const BaseObject = require('internal/relational_require_cache/base_object');

src/node.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,13 @@ InitializationResult InitializeOncePerProcess(
10621062
return result;
10631063
}
10641064

1065+
if (per_process::cli_options->print_anode_version) {
1066+
printf("%s\n", ANODE_VERSION);
1067+
result.exit_code = 0;
1068+
result.early_return = true;
1069+
return result;
1070+
}
1071+
10651072
if (per_process::cli_options->print_bash_completion) {
10661073
std::string completion = options_parser::GetBashCompletion();
10671074
printf("%s\n", completion.c_str());

src/node_metadata.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void Metadata::Versions::InitializeIntlVersions() {
6666

6767
Metadata::Versions::Versions() {
6868
node = NODE_VERSION_STRING;
69+
anode = ANODE_VERSION_STRING;
6970
v8 = v8::V8::GetVersion();
7071
uv = uv_version_string();
7172
zlib = ZLIB_VERSION;

src/node_metadata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace node {
3535
V(nghttp2) \
3636
V(napi) \
3737
V(llhttp) \
38+
V(anode) \
3839

3940
#if HAVE_OPENSSL
4041
#define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl)

src/node_options.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ PerProcessOptionsParser::PerProcessOptionsParser(
801801
AddOption(
802802
"--version", "print Node.js version", &PerProcessOptions::print_version);
803803
AddAlias("-v", "--version");
804+
AddOption(
805+
"--anode-version", "print Anode version",
806+
&PerProcessOptions::print_anode_version);
804807
AddOption("--v8-options",
805808
"print V8 command line options",
806809
&PerProcessOptions::print_v8_help);

src/node_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class PerProcessOptions : public Options {
243243
bool print_help = false;
244244
bool print_v8_help = false;
245245
bool print_version = false;
246+
bool print_anode_version = false;
246247

247248
#ifdef NODE_HAVE_I18N_SUPPORT
248249
std::string icu_data_dir;

src/node_version.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define NODE_MINOR_VERSION 19
2727
#define NODE_PATCH_VERSION 0
2828

29+
#define ANODE_REVISE 1
30+
2931
#define NODE_VERSION_IS_LTS 1
3032
#define NODE_VERSION_LTS_CODENAME "Gallium"
3133

@@ -58,11 +60,16 @@
5860
NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
5961
NODE_STRINGIFY(NODE_PATCH_VERSION) \
6062
NODE_TAG
63+
64+
# define ANODE_VERSION_STRING NODE_VERSION_STRING "-anode." \
65+
NODE_STRINGIFY(ANODE_REVISE)
66+
6167
#ifndef NODE_EXE_VERSION
6268
# define NODE_EXE_VERSION NODE_VERSION_STRING
6369
#endif
6470

6571
#define NODE_VERSION "v" NODE_VERSION_STRING
72+
#define ANODE_VERSION "v" ANODE_VERSION_STRING
6673

6774

6875
#define NODE_VERSION_AT_LEAST(major, minor, patch) \

test/parallel/test-process-versions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const expected_keys = [
1313
'nghttp2',
1414
'napi',
1515
'llhttp',
16+
'anode',
1617
];
1718

1819
if (common.hasCrypto) {

0 commit comments

Comments
 (0)