Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v10.x] src: more automatic memory management in node_crypto.cc #20609

Closed
wants to merge 81 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
763627a
doc: add more missing backticks
vsemozhetbyt Apr 29, 2018
f6c6950
doc: remove squash guideline from onboarding doc
Trott Apr 30, 2018
ca7e3e4
doc: add squash guideline to pull-requests doc
Trott Apr 30, 2018
8fbd0d3
benchmark: fix next-tick-depth
apapirovski May 2, 2018
a8fc842
doc: add http.ClientRequest maxHeadersCount
darai0512 Apr 23, 2018
f6d37f2
tools: fix TypeError from `test.py --time`
richardlau Apr 27, 2018
bd8e626
doc: update writing-and-running-benchmarks.md
xsbchen Apr 28, 2018
a8ffbbe
timers: named anonymous functions
js-kyle Apr 29, 2018
147ced4
child_process: name anonymous functions
SerayaEryn Apr 29, 2018
3d2a7fe
test: remove unnecessary strictEqual() argument from remoteClose()
dayloryanes Apr 26, 2018
f438438
test: use fs.copyFileSync()
richardlau Apr 26, 2018
1de252a
doc: add missing periods in documentation.md
vsemozhetbyt May 2, 2018
52e6ef0
events: optimize condition for optimal scenario
apapirovski May 1, 2018
dbf3089
util: improve spliceOne perf
apapirovski May 1, 2018
2d26f55
doc: update cli flag in crypto.md
shobhitchittora Apr 29, 2018
b15c793
doc: synchronize argument names for appendFile()
Trott May 3, 2018
43ba7a6
util: named anonymous functions
ccoxwell Apr 29, 2018
81584d1
lib: named anonymous functions
ccoxwell Apr 30, 2018
7e87142
doc: update Collaborator Guide reference
Trott May 2, 2018
36d93da
doc: cleanup n-api.md doc
mhdawson Apr 30, 2018
a5467bf
src: remove `kFlagNoShutdown` flag
addaleax Apr 28, 2018
fd67e9e
src: access `ContextifyContext*` more directly in property cbs
addaleax May 1, 2018
98a39e3
src: refactor `BaseObject` internal field management
addaleax May 1, 2018
18bb358
doc: update examples for fs.access()
BeniCheni May 1, 2018
d329778
n-api: make test_error functions static
Apr 27, 2018
c66ba19
crypto: allocate more memory for cipher.update()
yhwang Apr 26, 2018
ff148b9
deps: patch V8 to 6.6.346.27
MylesBorins May 2, 2018
8c0cf1e
doc: fix mkdtemp() documentation
Trott May 4, 2018
0254698
doc: document using `domain` in REPL
AyushG3112 Apr 28, 2018
d7dcc0a
test: add fs/promises filehandle stat test
May 3, 2018
064b061
repl: add spaces to load/save messages
cjihrig May 5, 2018
5248cd7
test: rename misnamed test
Trott May 5, 2018
6966c04
test: fix up N-API error test
May 3, 2018
ae33fa3
src: fix inconsistency in extern declaration
hashseed Apr 30, 2018
3da63ff
build: check for different deprecation signatures
BridgeAR Apr 28, 2018
34f73ec
doc: fix manpage warning
kapouer Apr 28, 2018
b9dfaac
https: defines maxHeadersCount in the constructor
darai0512 Apr 22, 2018
1e2ce1d
src: removed unnecessary prototypes from Environment::SetProtoMethod
brandontruggles Apr 26, 2018
0642b6f
test: fix common.canCreateSymLink() on non-Windows
May 4, 2018
f508574
lib: expose FixedQueue internally and fix nextTick bug
apapirovski May 2, 2018
fc311f2
tls: cleanup onhandshakestart callback
apapirovski May 2, 2018
d0d0547
benchmark: track exec time in next-tick-exec
apapirovski May 2, 2018
0f75c08
doc: fix N-API property descriptor documentation
Apr 30, 2018
31dfb0a
doc: updates crypto doc with openssl list -cipher-algorithms
shobhitchittora May 3, 2018
d866984
tls: remove sharedCreds in Server constructor
danbev May 3, 2018
6e2a22f
errors: remove dead code
BridgeAR May 2, 2018
755e88f
http2: rename http2_state class to Http2State
danbev Apr 30, 2018
59ed6c0
doc: add snake_case section for C-like structs
danbev May 2, 2018
ea6af3b
src: add public API to expose the main V8 Platform
helloshuangzi May 1, 2018
aef4f80
doc: update one more command in crypto.md
shobhitchittora May 3, 2018
c06821a
Revert "stream: prevent 'end' to be emitted after 'error'"
mscdex May 1, 2018
b06d90d
url: fix WHATWG host formatting error
peakji May 3, 2018
a068808
tools: remove redundant code in doc/html.js
vsemozhetbyt May 4, 2018
883d03b
doc: clearer doc-only deprecations
BridgeAR Apr 28, 2018
702ba74
test: fix buffer writes on mips
BridgeAR Apr 27, 2018
849d10d
test: fix test-cli-node-options.js on mips
BridgeAR Apr 28, 2018
f8ddf7b
doc: add parameters for Http2Session:stream event
ryzokuken May 5, 2018
2bddd24
doc: edit text for DEP0104
Trott May 4, 2018
b7e8249
doc: edit text for DEP0101
Trott May 4, 2018
6011c21
doc: edit text for DEP0012
Trott May 4, 2018
6a18a42
doc: edit text for DEP0094
Trott May 4, 2018
7d9234b
doc: fix text for DEP0085
Trott May 4, 2018
bc8d08d
doc: edit text for DEP0082
Trott May 4, 2018
f59619a
doc: fix minor typographical error in DEP0079 text
Trott May 4, 2018
17f9da5
doc: minor edit to DEP0065
Trott May 4, 2018
4ce7026
doc: edit text for DEP0013
Trott May 4, 2018
b0d6edc
doc: edit text about revoking deprecations
Trott May 4, 2018
dc8c8ef
doc: excise "periodically" before "emit events"
jeswcollins May 7, 2018
9ba8ab0
doc: update "Who to cc..." in COLLABORATOR_GUIDE
vsemozhetbyt May 6, 2018
8ed803d
fs: move fs/promises to fs.promises
cjihrig May 3, 2018
381fccd
doc: add trace category for fs sync methods
chinhuang007 May 4, 2018
fa0565e
console: make console.table() use colored inspect
makenowjust May 4, 2018
e2fb920
doc: move tunniclm to Emeritus
Trott May 5, 2018
acf3019
fs: remove broken code in promises/write
ChALkeR Apr 29, 2018
88f9c38
fs: fchmod->fchown in promises/lchown
ChALkeR Apr 29, 2018
69a8a65
doc: clarify `this` in event listeners
dagolinuxoid May 5, 2018
7b4e815
tools: add v10 to alternative version docs menu
vsemozhetbyt May 7, 2018
85babad
test: use common.canCreateSymLink() consistently
cjihrig May 5, 2018
aad2c23
tools: add eslint check for skipIfEslintMissing
richardlau Apr 27, 2018
7bf23cf
doc: match console.count()/countReset() signatures
Lambdac0re May 8, 2018
c7514a5
src: more automatic memory management in node_crypto.cc
addaleax Apr 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions COLLABORATOR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,15 @@ longer be used.

Node.js uses three Deprecation levels:

* *Documentation-Only Deprecation* refers to elements of the Public API that are
being staged for deprecation in a future Node.js major release. An explicit
notice indicating the deprecated status is added to the API documentation
but no functional changes are implemented in the code. There will be no
runtime deprecation warnings emitted for such deprecations by default.
Documentation-only deprecations may trigger a runtime warning when Node.js
is started with the [`--pending-deprecation`][] flag or the
`NODE_PENDING_DEPRECATION=1` environment variable is set.
* *Documentation-Only Deprecation* refers to elements of the Public API that
should be avoided by developers and that might be staged for a runtime
deprecation in a future Node.js major release. An explicit notice indicating
the deprecation status is added to the API documentation but no functional
changes are implemented in the code. By default there will be no deprecation
warnings emitted for such deprecations at runtime. Documentation-only
deprecations may trigger a runtime warning when Node.js is started with the
[`--pending-deprecation`][] flag or the `NODE_PENDING_DEPRECATION=1`
environment variable is set.

* *Runtime Deprecation* refers to the use of process warnings emitted at
runtime the first time that a deprecated API is used. A command-line
Expand Down Expand Up @@ -831,7 +832,6 @@ LTS working group and the Release team.
| Subsystem | Maintainers |
| --- | --- |
| `benchmark/*` | @nodejs/benchmarking, @mscdex |
| `bootstrap_node.js` | @nodejs/process |
| `doc/*`, `*.md` | @nodejs/documentation |
| `lib/assert` | @nodejs/testing |
| `lib/async_hooks` | @nodejs/async\_hooks for bugs/reviews (+ @nodejs/diagnostics for API) |
Expand All @@ -844,20 +844,21 @@ LTS working group and the Release team.
| `lib/fs`, `src/{fs,file}` | @nodejs/fs |
| `lib/{_}http{*}` | @nodejs/http |
| `lib/inspector.js`, `src/inspector_*` | @nodejs/V8-inspector |
| `lib/internal/bootstrap/*` | @nodejs/process |
| `lib/internal/url`, `src/node_url` | @nodejs/url |
| `lib/net` | @bnoordhuis, @indutny, @nodejs/streams |
| `lib/repl` | @nodejs/repl |
| `lib/{_}stream{*}` | @nodejs/streams |
| `lib/timers` | @nodejs/timers |
| `lib/util` | @nodejs/util |
| `lib/zlib` | @nodejs/zlib |
| `src/async-wrap.*` | @nodejs/async\_hooks |
| `src/async_wrap.*` | @nodejs/async\_hooks |
| `src/node_api.*` | @nodejs/n-api |
| `src/node_crypto.*` | @nodejs/crypto |
| `test/*` | @nodejs/testing |
| `tools/node_modules/eslint`, `.eslintrc` | @nodejs/linting |
| build | @nodejs/build |
| `src/module_wrap.*`, `lib/internal/loader/*`, `lib/internal/vm/Module.js` | @nodejs/modules |
| `src/module_wrap.*`, `lib/internal/modules/*`, `lib/internal/vm/module.js` | @nodejs/modules |
| GYP | @nodejs/gyp |
| performance | @nodejs/performance |
| platform specific | @nodejs/platform-{aix,arm,freebsd,macos,ppc,smartos,s390,windows} |
Expand Down
10 changes: 10 additions & 0 deletions CPP_STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [CamelCase for methods, functions, and classes](#camelcase-for-methods-functions-and-classes)
* [snake\_case for local variables and parameters](#snake_case-for-local-variables-and-parameters)
* [snake\_case\_ for private class fields](#snake_case_-for-private-class-fields)
* [snake\_case\_ for C-like structs](#snake_case_-for-c-like-structs)
* [Space after `template`](#space-after-template)
* [Memory Management](#memory-management)
* [Memory allocation](#memory-allocation)
Expand Down Expand Up @@ -147,6 +148,15 @@ class Foo {
};
```

## snake\_case\_ for C-like structs
For plain C-like structs snake_case can be used.

```c++
struct foo_bar {
int name;
}
```

## Space after `template`

```c++
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@ release-only:
exit 1 ; \
fi
@if [ "$(DISTTYPE)" != "nightly" ] && [ "$(DISTTYPE)" != "next-nightly" ] && \
`grep -q DEP00XX doc/api/deprecations.md`; then \
echo 'Please update DEP00XX in doc/api/deprecations.md (See doc/releases.md)' ; \
`grep -q DEP...X doc/api/deprecations.md`; then \
echo 'Please update DEP...X in doc/api/deprecations.md (See doc/releases.md)' ; \
exit 1 ; \
fi
@if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,6 @@ For more information about the governance of the Node.js project, see
**Trivikram Kamat** <trivikr.dev@gmail.com>
* [Trott](https://github.com/Trott) -
**Rich Trott** <rtrott@gmail.com> (he/him)
* [tunniclm](https://github.com/tunniclm) -
**Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com>
* [vdeturckheim](https://github.com/vdeturckheim) -
**Vladimir de Turckheim** <vlad2t@hotmail.com> (he/him)
* [vkurchatkin](https://github.com/vkurchatkin) -
Expand Down Expand Up @@ -559,6 +557,8 @@ For more information about the governance of the Node.js project, see
**Alex Kocharin** <alex@kocharin.ru>
* [tellnes](https://github.com/tellnes) -
**Christian Tellnes** <christian@tellnes.no>
* [tunniclm](https://github.com/tunniclm) -
**Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com>

Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
maintaining the Node.js project.
Expand Down
2 changes: 1 addition & 1 deletion benchmark/events/ee-add-remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const common = require('../common.js');
const events = require('events');

const bench = common.createBenchmark(main, { n: [25e4] });
const bench = common.createBenchmark(main, { n: [1e6] });

function main({ n }) {
const ee = new events.EventEmitter();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/bench-stat-promise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const common = require('../common');
const fsPromises = require('fs/promises');
const fsPromises = require('fs').promises;

const bench = common.createBenchmark(main, {
n: [20e4],
Expand Down
33 changes: 17 additions & 16 deletions benchmark/process/next-tick-depth-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,53 @@ const bench = common.createBenchmark(main, {
process.maxTickDepth = Infinity;

function main({ n }) {
let counter = n;
function cb4(arg1, arg2, arg3, arg4) {
if (--n) {
if (n % 4 === 0)
if (--counter) {
if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
else if (n % 3 === 0)
else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
else if (n % 2 === 0)
else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
} else
bench.end(n);
}
function cb3(arg1, arg2, arg3) {
if (--n) {
if (n % 4 === 0)
if (--counter) {
if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
else if (n % 3 === 0)
else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
else if (n % 2 === 0)
else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
} else
bench.end(n);
}
function cb2(arg1, arg2) {
if (--n) {
if (n % 4 === 0)
if (--counter) {
if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
else if (n % 3 === 0)
else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
else if (n % 2 === 0)
else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
} else
bench.end(n);
}
function cb1(arg1) {
if (--n) {
if (n % 4 === 0)
if (--counter) {
if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
else if (n % 3 === 0)
else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
else if (n % 2 === 0)
else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
Expand Down
4 changes: 2 additions & 2 deletions benchmark/process/next-tick-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const bench = common.createBenchmark(main, {
process.maxTickDepth = Infinity;

function main({ n }) {

let counter = n;
bench.start();
process.nextTick(onNextTick);
function onNextTick() {
if (--n)
if (--counter)
process.nextTick(onNextTick);
else
bench.end(n);
Expand Down
11 changes: 6 additions & 5 deletions benchmark/process/next-tick-exec-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}

bench.start();
for (var i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(onNextTick, i, true, 10, 'test');
Expand All @@ -17,8 +20,6 @@ function main({ n }) {
else
process.nextTick(onNextTick, i);
}
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}

bench.start();
}
11 changes: 6 additions & 5 deletions benchmark/process/next-tick-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {

bench.start();
for (var i = 0; i < n; i++) {
process.nextTick(onNextTick, i);
}
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}

for (var i = 0; i < n; i++) {
process.nextTick(onNextTick, i);
}

bench.start();
}
33 changes: 33 additions & 0 deletions benchmark/util/splice-one.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

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

const bench = common.createBenchmark(main, {
n: [1e7],
pos: ['start', 'middle', 'end'],
size: [10, 100, 500],
}, { flags: ['--expose-internals'] });

function main({ n, pos, size }) {
const { spliceOne } = require('internal/util');
const arr = new Array(size);
arr.fill('');
let index;
switch (pos) {
case 'end':
index = size - 1;
break;
case 'middle':
index = Math.floor(size / 2);
break;
default: // start
index = 0;
}

bench.start();
for (var i = 0; i < n; i++) {
spliceOne(arr, index);
arr.push('');
}
bench.end(n);
}
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 6
#define V8_BUILD_NUMBER 346
#define V8_PATCH_LEVEL 24
#define V8_PATCH_LEVEL 27

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
9 changes: 8 additions & 1 deletion deps/v8/src/keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ void KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) {
Handle<String>::cast(key)->AsArrayIndex(&index)) {
key = isolate_->factory()->NewNumberFromUint(index);
}
keys_ = OrderedHashSet::Add(keys(), key);
Handle<OrderedHashSet> new_set = OrderedHashSet::Add(keys(), key);
if (*new_set != *keys_) {
// The keys_ Set is converted directly to a FixedArray in GetKeys which can
// be left-trimmer. Hence the previous Set should not keep a pointer to the
// new one.
keys_->set(OrderedHashTableBase::kNextTableIndex, Smi::kZero);
keys_ = new_set;
}
}

void KeyAccumulator::AddKeys(Handle<FixedArray> array,
Expand Down
Loading