Skip to content

Commit

Permalink
cli: add version for anode and fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
guangwong authored and oraluben committed Aug 16, 2023
1 parent b6904fe commit a31a123
Show file tree
Hide file tree
Showing 26 changed files with 75 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ permissions:

jobs:
build-tarball:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ permissions:

jobs:
build-windows:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ permissions:

jobs:
coverage-linux:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ permissions:

jobs:
coverage-windows:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions:

jobs:
build-docs:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ permissions:

jobs:
test-asan:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: ubuntu-20.04
env:
CC: clang
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ permissions:

jobs:
test-linux:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ permissions:

jobs:
test-macOS:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && false
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,17 +800,16 @@ external libraries that are available under a variety of licenses. See
[LICENSE](https://github.com/nodejs/node/blob/HEAD/LICENSE) for the full
license text.

## Noslate-Anode

Noslate-Anode is developed by Alibaba and based on the Node.js project.
All changes licensed under the MIT License.
See the NOTICE file for more information.

[Code of Conduct]: https://github.com/nodejs/admin/blob/HEAD/CODE_OF_CONDUCT.md
[Contributing to the project]: CONTRIBUTING.md
[Node.js website]: https://nodejs.org/
[OpenJS Foundation]: https://openjsf.org/
[Strategic initiatives]: doc/contributing/strategic-initiatives.md
[Technical values and prioritization]: doc/contributing/technical-values.md
[Working Groups]: https://github.com/nodejs/TSC/blob/HEAD/WORKING_GROUPS.md


## Noslate-Node

Noslate-Node is developed by Alibaba and based on the Node.js project.
All changes licensed under the MIT License.
See the NOTICE file for more information.
12 changes: 6 additions & 6 deletions deps/metacache/city.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ static uint32 UNALIGNED_LOAD32(const char *p) {

#endif // __BIG_ENDIAN__

#if !defined(LIKELY)
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define LIKELY(x) (__builtin_expect(!!(x), 1))
#define MY_LIKELY(x) (__builtin_expect(!!(x), 1))
#else
#define LIKELY(x) (x)
#endif
#define MY_LIKELY(x) (x)
#endif

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

void CityHashCrc256(const char *s, size_t len, uint64 *result) {
if (LIKELY(len >= 240)) {
if (MY_LIKELY(len >= 240)) {
CityHashCrc256Long(s, len, 0, result);
} else {
CityHashCrc256Short(s, len, result);
Expand Down Expand Up @@ -463,3 +461,5 @@ uint128 CityHashCrc128(const char *s, size_t len) {
}

#endif

undef MY_LIKELY
2 changes: 1 addition & 1 deletion deps/metacache/metacache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int metacache::savefile(const char *file)
std::ofstream f(file, std::ios::binary);
void *ptr = vmem_cur;
size_t size = (uint64_t)ptr - MC_VMEM;
f.write((char *)MC_VMEM, ALIGN_PAGE(size));
f.write((char *)MC_VMEM, MC_ALIGN_PAGE(size));
f.close();
printf("%s(%s) = %lu\n", __func__, file, size);
return 0;
Expand Down
24 changes: 14 additions & 10 deletions deps/metacache/metacache.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <inttypes.h>

#include <new>
#include <string>
Expand Down Expand Up @@ -38,8 +39,8 @@ namespace strontium {
namespace metacache {

// likely and unlikey
#define LIKELY(x) (__builtin_expect(!!(x), 1))
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
#define MY_LIKELY(x) (__builtin_expect(!!(x), 1))
#define MY_UNLIKELY(x) (__builtin_expect(!!(x), 0))

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

// page aligned
// const int kPageSize = sysconf(_SC_PAGE_SIZE);
#define PAGE_SIZE (4096)
#define MC_PAGE_SIZE (4096)
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
//#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
#define ALIGN(x,a) __ALIGN_MASK(x,((a)-1))
#define ALIGN_PAGE(x) ALIGN(x,PAGE_SIZE)
//#define MC_ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
#define MC_ALIGN(x,a) __ALIGN_MASK(x,((a)-1))
#define MC_ALIGN_PAGE(x) MC_ALIGN(x,MC_PAGE_SIZE)

// metacache uses offset for memory saving.
// the whole metacache using 32b pointer in 64b platform.
Expand Down Expand Up @@ -415,7 +416,7 @@ class city {
std::swap(z, x);
s += 64;
len -= 128;
} while (LIKELY(len >= 128));
} while (MY_LIKELY(len >= 128));
x += Rotate(v.first + z, 49) * k0;
z += Rotate(w.first, 37) * k0;
// If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
Expand Down Expand Up @@ -595,7 +596,7 @@ struct cm {
std::ofstream f(file, std::ios::binary);
void *ptr = _vmcur;
size_t size = (uint64_t)ptr - MC_DEF_VMADDR;
f.write((char *)MC_DEF_VMADDR, ALIGN_PAGE(size));
f.write((char *)MC_DEF_VMADDR, MC_ALIGN_PAGE(size));
f.close();
printf("%s(%s) = %lu\n", __func__, file, size);
return 0;
Expand Down Expand Up @@ -2482,7 +2483,7 @@ struct fs_w : _wT {
void debug_print()
{
// show records table
printf("Records table: %u\n", _records.size());
printf("Records table: %lu\n", _records.size());
printf("%4s %4s %s\n", "STAT", "OPEN", "FILE_PATH");
auto it = _records.begin();
for (; it != _records.end(); it++) {
Expand Down Expand Up @@ -2547,7 +2548,7 @@ struct metacache_w : _wT {
{
str_w w(s);
auto it = _set_str.insert(w);
printf(" wc::str('%s'), hash(%lx), cmptr(%p)\n", w._sz.c_str(), w._hash, w._cm_ptr);
printf(" wc::str('%s'), hash(%" PRIx64 "), cmptr(%p)\n", w._sz.c_str(), w._hash, w._cm_ptr);
return *it.first;
}

Expand Down Expand Up @@ -2577,3 +2578,6 @@ struct metacache_w : _wT {
}; // namespace strontium

#endif // _STRONTIUM_METACACHE_H_

#undef MY_LIKELY
#undef MY_UNLIKELY
12 changes: 6 additions & 6 deletions deps/strontium/src/pgo/require-cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ RequireCacheWrap::RequireCacheWrap(Environment* env,
mc_(metacache::load(cache_filename)),
error_info_(""),
cache_filename_(cache_filename),
type_(READER),
// type_(READER),
contents_(),
relationship_(),
internal_meta_kv_() {
Expand Down Expand Up @@ -125,8 +125,8 @@ RequireCacheWrap::RequireCacheWrap(Environment* env,
Local<Array> entries)
: BaseObject(env, obj),
mc_(metacache::create(METACACHE_MAX_SIZE)),
cache_filename_(""),
type_(WRITER) {
// type_(WRITER),
cache_filename_("") {
MakeWeak();

if (mc_ == nullptr) {
Expand Down Expand Up @@ -317,12 +317,12 @@ string RequireCacheWrap::TransformFilenameBack(const char* filename,
return *ret;
}

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

if (index < 0 || index >= entries_count_) {
if (index < 0 || index >= (ssize_t) entries_count_) {
env->ThrowError("Broken entry index.");
return "";
}
Expand Down
5 changes: 3 additions & 2 deletions deps/strontium/src/pgo/require-cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class MetaCacheTypeUnion {
~MetaCacheTypeUnion() {
if (body_.ptr != nullptr) {
// TODO(zl131478): 需要完整的析构
delete body_.ptr;
// TODO(guangwong): 不知道该转成哪个类型来析构,先转个基础类型逃避下检查
delete (int*) body_.ptr;
body_.ptr = nullptr;
}
}
Expand Down Expand Up @@ -147,7 +148,7 @@ class RequireCacheWrap : public BaseObject {
string error_info_;
string cache_filename_;

WrapType type_;
// WrapType type_;
MetaCacheTypeUnion<MetaCacheFileBufferR, MetaCacheFileBufferW> contents_;
MetaCacheTypeUnion<MetaCacheRelationR, MetaCacheRelationW> relationship_;
MetaCacheTypeUnion<MetaCacheMetaKVR, MetaCacheMetaKVW> internal_meta_kv_;
Expand Down
3 changes: 0 additions & 3 deletions lib/alinode/relational_require_cache.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict';

/* eslint-disable max-len */


const { ArrayIsArray } = primordials;
const assert = require('assert');

Expand Down
2 changes: 0 additions & 2 deletions lib/internal/relational_require_cache/loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

/* eslint-disable max-len */

const { Symbol } = primordials;
const { Error } = primordials;
const { JSONParse } = primordials;
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/relational_require_cache/recorder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

/* eslint-disable max-len */

const { Symbol } = primordials;
const { Error } = primordials;

Expand Down
2 changes: 0 additions & 2 deletions lib/internal/relational_require_cache/require_cache.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

/* eslint-disable max-len */

const { Error } = primordials;

const BaseObject = require('internal/relational_require_cache/base_object');
Expand Down
7 changes: 7 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,13 @@ InitializationResult InitializeOncePerProcess(
return result;
}

if (per_process::cli_options->print_anode_version) {
printf("%s\n", ANODE_VERSION);
result.exit_code = 0;
result.early_return = true;
return result;
}

if (per_process::cli_options->print_bash_completion) {
std::string completion = options_parser::GetBashCompletion();
printf("%s\n", completion.c_str());
Expand Down
1 change: 1 addition & 0 deletions src/node_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void Metadata::Versions::InitializeIntlVersions() {

Metadata::Versions::Versions() {
node = NODE_VERSION_STRING;
anode = ANODE_VERSION_STRING;
v8 = v8::V8::GetVersion();
uv = uv_version_string();
zlib = ZLIB_VERSION;
Expand Down
1 change: 1 addition & 0 deletions src/node_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace node {
V(nghttp2) \
V(napi) \
V(llhttp) \
V(anode) \

#if HAVE_OPENSSL
#define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl)
Expand Down
3 changes: 3 additions & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ PerProcessOptionsParser::PerProcessOptionsParser(
AddOption(
"--version", "print Node.js version", &PerProcessOptions::print_version);
AddAlias("-v", "--version");
AddOption(
"--anode-version", "print Anode version",
&PerProcessOptions::print_anode_version);
AddOption("--v8-options",
"print V8 command line options",
&PerProcessOptions::print_v8_help);
Expand Down
1 change: 1 addition & 0 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class PerProcessOptions : public Options {
bool print_help = false;
bool print_v8_help = false;
bool print_version = false;
bool print_anode_version = false;

#ifdef NODE_HAVE_I18N_SUPPORT
std::string icu_data_dir;
Expand Down
7 changes: 7 additions & 0 deletions src/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#define NODE_MINOR_VERSION 19
#define NODE_PATCH_VERSION 0

#define ANODE_REVISE 1

#define NODE_VERSION_IS_LTS 1
#define NODE_VERSION_LTS_CODENAME "Gallium"

Expand Down Expand Up @@ -58,11 +60,16 @@
NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
NODE_STRINGIFY(NODE_PATCH_VERSION) \
NODE_TAG

# define ANODE_VERSION_STRING NODE_VERSION_STRING "-anode." \
NODE_STRINGIFY(ANODE_REVISE)

#ifndef NODE_EXE_VERSION
# define NODE_EXE_VERSION NODE_VERSION_STRING
#endif

#define NODE_VERSION "v" NODE_VERSION_STRING
#define ANODE_VERSION "v" ANODE_VERSION_STRING


#define NODE_VERSION_AT_LEAST(major, minor, patch) \
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const expected_keys = [
'nghttp2',
'napi',
'llhttp',
'anode',
];

if (common.hasCrypto) {
Expand Down
Loading

0 comments on commit a31a123

Please sign in to comment.