Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 8fcb1b4

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge 099e621 as of 2018-03-09 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Jack Horton <[email protected]>
2 parents ff3d26b + 099e621 commit 8fcb1b4

16 files changed

+110
-45
lines changed

Diff for: BUILDING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ platforms in production.
3939

4040
| System | Support type | Version | Architectures | Notes |
4141
|--------------|--------------|----------------------------------|----------------------|------------------|
42-
| GNU/Linux | Tier 1 | kernel >= 2.6.32, glibc >= 2.12 | x64, arm, arm64 | |
42+
| GNU/Linux | Tier 1 | kernel >= 2.6.32, glibc >= 2.12 | x64, arm | |
43+
| GNU/Linux | Tier 1 | kernel >= 3.10, glibc >= 2.17 | arm64 | |
4344
| macOS | Tier 1 | >= 10.10 | x64 | |
4445
| Windows | Tier 1 | >= Windows 7/2008 R2 | x86, x64 | vs2017 |
4546
| SmartOS | Tier 2 | >= 15 < 16.4 | x86, x64 | see note1 |

Diff for: doc/STYLE_GUIDE.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
* American English spelling is preferred. "Capitalize" vs. "Capitalise",
1414
"color" vs. "colour", etc.
1515
* Use [serial commas][].
16-
* Generally avoid personal pronouns in reference documentation ("I", "you",
17-
"we").
16+
* Avoid personal pronouns in reference documentation ("I", "you", "we").
1817
* Pronouns are acceptable in more colloquial documentation, like guides.
1918
* Use gender-neutral pronouns and mass nouns. Non-comprehensive
2019
examples:
21-
* OK: "they", "their", "them", "folks", "people", "developers", "cats"
20+
* OK: "they", "their", "them", "folks", "people", "developers"
2221
* NOT OK: "his", "hers", "him", "her", "guys", "dudes"
2322
* When combining wrapping elements (parentheses and quotes), terminal
2423
punctuation should be placed:

Diff for: doc/api/stream.md

-3
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,6 @@ readable.on('readable', () => {
955955
});
956956
```
957957

958-
Avoid the use of the `'readable'` event and the `readable.read()` method in
959-
favor of using either `readable.pipe()` or the `'data'` event.
960-
961958
A Readable stream in object mode will always return a single item from
962959
a call to [`readable.read(size)`][stream-read], regardless of the value of the
963960
`size` argument.

Diff for: lib/internal/trace_events_async_hooks.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const END_EVENT = 'e'.charCodeAt(0);
1515
// non-init events, use a map to manually map the asyncId to the type name.
1616
const typeMemory = new Map();
1717

18+
const trace_event_category = 'node,node.async_hooks';
19+
1820
// It is faster to emit trace_events directly from C++. Thus, this happens in
1921
// async_wrap.cc. However, events emitted from the JavaScript API or the
2022
// Embedder C++ API can't be emitted from async_wrap.cc. Thus they are
@@ -27,7 +29,7 @@ const hook = async_hooks.createHook({
2729
if (nativeProviders.has(type)) return;
2830

2931
typeMemory.set(asyncId, type);
30-
trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
32+
trace_events.emit(BEFORE_EVENT, trace_event_category,
3133
type, asyncId,
3234
'triggerAsyncId', triggerAsyncId,
3335
'executionAsyncId', async_hooks.executionAsyncId());
@@ -37,23 +39,23 @@ const hook = async_hooks.createHook({
3739
const type = typeMemory.get(asyncId);
3840
if (type === undefined) return;
3941

40-
trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
42+
trace_events.emit(BEFORE_EVENT, trace_event_category,
4143
type + '_CALLBACK', asyncId);
4244
},
4345

4446
after(asyncId) {
4547
const type = typeMemory.get(asyncId);
4648
if (type === undefined) return;
4749

48-
trace_events.emit(END_EVENT, 'node.async_hooks',
50+
trace_events.emit(END_EVENT, trace_event_category,
4951
type + '_CALLBACK', asyncId);
5052
},
5153

5254
destroy(asyncId) {
5355
const type = typeMemory.get(asyncId);
5456
if (type === undefined) return;
5557

56-
trace_events.emit(END_EVENT, 'node.async_hooks',
58+
trace_events.emit(END_EVENT, trace_event_category,
5759
type, asyncId);
5860

5961
// cleanup asyncId to type map
@@ -63,7 +65,7 @@ const hook = async_hooks.createHook({
6365

6466

6567
exports.setup = function() {
66-
if (trace_events.categoryGroupEnabled('node.async_hooks')) {
68+
if (trace_events.categoryGroupEnabled(trace_event_category)) {
6769
hook.enable();
6870
}
6971
};

Diff for: src/aliased_buffer.h

+16
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ class AliasedBuffer {
142142
return aliased_buffer_->GetValue(index_);
143143
}
144144

145+
template <typename T>
146+
inline Reference& operator+=(const T& val) {
147+
const T current = aliased_buffer_->GetValue(index_);
148+
aliased_buffer_->SetValue(index_, current + val);
149+
return *this;
150+
}
151+
152+
inline Reference& operator+=(const Reference& val) {
153+
return this->operator+=(static_cast<NativeT>(val));
154+
}
155+
156+
template <typename T>
157+
inline Reference& operator-=(const T& val) {
158+
return this->operator+=(-val);
159+
}
160+
145161
private:
146162
AliasedBuffer<NativeT, V8T>* aliased_buffer_;
147163
size_t index_;

Diff for: src/async_wrap.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ void AsyncWrap::EmitTraceEventBefore() {
179179
switch (provider_type()) {
180180
#define V(PROVIDER) \
181181
case PROVIDER_ ## PROVIDER: \
182-
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("node.async_hooks", \
182+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( \
183+
TRACING_CATEGORY_NODE1(async_hooks), \
183184
#PROVIDER "_CALLBACK", static_cast<int64_t>(get_async_id())); \
184185
break;
185186
NODE_ASYNC_PROVIDER_TYPES(V)
@@ -207,7 +208,8 @@ void AsyncWrap::EmitTraceEventAfter() {
207208
switch (provider_type()) {
208209
#define V(PROVIDER) \
209210
case PROVIDER_ ## PROVIDER: \
210-
TRACE_EVENT_NESTABLE_ASYNC_END0("node.async_hooks", \
211+
TRACE_EVENT_NESTABLE_ASYNC_END0( \
212+
TRACING_CATEGORY_NODE1(async_hooks), \
211213
#PROVIDER "_CALLBACK", static_cast<int64_t>(get_async_id())); \
212214
break;
213215
NODE_ASYNC_PROVIDER_TYPES(V)
@@ -631,7 +633,8 @@ void AsyncWrap::EmitTraceEventDestroy() {
631633
switch (provider_type()) {
632634
#define V(PROVIDER) \
633635
case PROVIDER_ ## PROVIDER: \
634-
TRACE_EVENT_NESTABLE_ASYNC_END0("node.async_hooks", \
636+
TRACE_EVENT_NESTABLE_ASYNC_END0( \
637+
TRACING_CATEGORY_NODE1(async_hooks), \
635638
#PROVIDER, static_cast<int64_t>(get_async_id())); \
636639
break;
637640
NODE_ASYNC_PROVIDER_TYPES(V)
@@ -664,7 +667,8 @@ void AsyncWrap::AsyncReset(double execution_async_id, bool silent) {
664667
switch (provider_type()) {
665668
#define V(PROVIDER) \
666669
case PROVIDER_ ## PROVIDER: \
667-
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2("node.async_hooks", \
670+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( \
671+
TRACING_CATEGORY_NODE1(async_hooks), \
668672
#PROVIDER, static_cast<int64_t>(get_async_id()), \
669673
"executionAsyncId", \
670674
static_cast<int64_t>(env()->execution_async_id()), \

Diff for: src/env-inl.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ inline v8::Local<v8::String> Environment::AsyncHooks::provider_string(int idx) {
112112
}
113113

114114
inline void Environment::AsyncHooks::no_force_checks() {
115-
// fields_ does not have the -= operator defined
116-
fields_[kCheck] = fields_[kCheck] - 1;
115+
fields_[kCheck] -= 1;
117116
}
118117

119118
inline Environment* Environment::AsyncHooks::env() {
@@ -135,7 +134,7 @@ inline void Environment::AsyncHooks::push_async_ids(double async_id,
135134
grow_async_ids_stack();
136135
async_ids_stack_[2 * offset] = async_id_fields_[kExecutionAsyncId];
137136
async_ids_stack_[2 * offset + 1] = async_id_fields_[kTriggerAsyncId];
138-
fields_[kStackLength] = fields_[kStackLength] + 1;
137+
fields_[kStackLength] += 1;
139138
async_id_fields_[kExecutionAsyncId] = async_id;
140139
async_id_fields_[kTriggerAsyncId] = trigger_async_id;
141140
}
@@ -240,19 +239,19 @@ inline bool Environment::ImmediateInfo::has_outstanding() const {
240239
}
241240

242241
inline void Environment::ImmediateInfo::count_inc(uint32_t increment) {
243-
fields_[kCount] = fields_[kCount] + increment;
242+
fields_[kCount] += increment;
244243
}
245244

246245
inline void Environment::ImmediateInfo::count_dec(uint32_t decrement) {
247-
fields_[kCount] = fields_[kCount] - decrement;
246+
fields_[kCount] -= decrement;
248247
}
249248

250249
inline void Environment::ImmediateInfo::ref_count_inc(uint32_t increment) {
251-
fields_[kRefCount] = fields_[kRefCount] + increment;
250+
fields_[kRefCount] += increment;
252251
}
253252

254253
inline void Environment::ImmediateInfo::ref_count_dec(uint32_t decrement) {
255-
fields_[kRefCount] = fields_[kRefCount] - decrement;
254+
fields_[kRefCount] -= decrement;
256255
}
257256

258257
inline Environment::TickInfo::TickInfo(v8::Isolate* isolate)
@@ -478,8 +477,7 @@ inline std::vector<double>* Environment::destroy_async_id_list() {
478477
}
479478

480479
inline double Environment::new_async_id() {
481-
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] =
482-
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] + 1;
480+
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] += 1;
483481
return async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter];
484482
}
485483

Diff for: src/node_crypto.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3281,7 +3281,7 @@ bool CipherBase::Update(const char* data,
32813281
unsigned char** out,
32823282
int* out_len) {
32833283
if (ctx_ == nullptr)
3284-
return 0;
3284+
return false;
32853285

32863286
// on first update:
32873287
if (kind_ == kDecipher && IsAuthenticatedMode() && auth_tag_len_ > 0) {

Diff for: src/node_internals.h

+9
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,15 @@ static inline const char *errno_string(int errorno) {
779779
#define NODE_MODULE_CONTEXT_AWARE_INTERNAL(modname, regfunc) \
780780
NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_INTERNAL)
781781

782+
#define TRACING_CATEGORY_NODE "node"
783+
#define TRACING_CATEGORY_NODE1(one) \
784+
TRACING_CATEGORY_NODE "," \
785+
TRACING_CATEGORY_NODE "." #one
786+
#define TRACING_CATEGORY_NODE2(one, two) \
787+
TRACING_CATEGORY_NODE "," \
788+
TRACING_CATEGORY_NODE "." #one "," \
789+
TRACING_CATEGORY_NODE "." #one "." #two
790+
782791
} // namespace node
783792

784793

Diff for: src/node_perf.cc

+14-7
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ void Mark(const FunctionCallbackInfo<Value>& args) {
135135
(*marks)[*name] = now;
136136

137137
TRACE_EVENT_COPY_MARK_WITH_TIMESTAMP(
138-
"node.perf,node.perf.usertiming", *name, now / 1000);
138+
TRACING_CATEGORY_NODE2(perf, usertiming),
139+
*name, now / 1000);
139140

140141
PerformanceEntry entry(env, *name, "mark", now, now);
141142
Local<Object> obj = entry.ToObject();
@@ -183,9 +184,11 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
183184
endTimestamp = startTimestamp;
184185

185186
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
186-
"node.perf,node.perf.usertiming", *name, *name, startTimestamp / 1000);
187+
TRACING_CATEGORY_NODE2(perf, usertiming),
188+
*name, *name, startTimestamp / 1000);
187189
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
188-
"node.perf,node.perf.usertiming", *name, *name, endTimestamp / 1000);
190+
TRACING_CATEGORY_NODE2(perf, usertiming),
191+
*name, *name, endTimestamp / 1000);
189192

190193
PerformanceEntry entry(env, *name, "measure", startTimestamp, endTimestamp);
191194
Local<Object> obj = entry.ToObject();
@@ -301,13 +304,15 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
301304
if (args.IsConstructCall()) {
302305
start = PERFORMANCE_NOW();
303306
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
304-
"node.perf,node.perf.timerify", *name, *name, start / 1000);
307+
TRACING_CATEGORY_NODE2(perf, timerify),
308+
*name, *name, start / 1000);
305309
v8::MaybeLocal<Object> ret = fn->NewInstance(context,
306310
call_args.size(),
307311
call_args.data());
308312
end = PERFORMANCE_NOW();
309313
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
310-
"node.perf,node.perf.timerify", *name, *name, end / 1000);
314+
TRACING_CATEGORY_NODE2(perf, timerify),
315+
*name, *name, end / 1000);
311316

312317
if (ret.IsEmpty()) {
313318
try_catch.ReThrow();
@@ -317,14 +322,16 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
317322
} else {
318323
start = PERFORMANCE_NOW();
319324
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
320-
"node.perf,node.perf.timerify", *name, *name, start / 1000);
325+
TRACING_CATEGORY_NODE2(perf, timerify),
326+
*name, *name, start / 1000);
321327
v8::MaybeLocal<Value> ret = fn->Call(context,
322328
args.This(),
323329
call_args.size(),
324330
call_args.data());
325331
end = PERFORMANCE_NOW();
326332
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
327-
"node.perf,node.perf.timerify", *name, *name, end / 1000);
333+
TRACING_CATEGORY_NODE2(perf, timerify),
334+
*name, *name, end / 1000);
328335

329336
if (ret.IsEmpty()) {
330337
try_catch.ReThrow();

Diff for: test/cctest/test_aliased_buffer.cc

+30
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,33 @@ TEST_F(AliasBufferTest, SharedArrayBuffer4) {
207207
int8_t, v8::Int8Array,
208208
int32_t, v8::Int32Array>(isolate_, 1, 3, 1);
209209
}
210+
211+
TEST_F(AliasBufferTest, OperatorOverloads) {
212+
v8::Isolate::Scope isolate_scope(isolate_);
213+
v8::HandleScope handle_scope(isolate_);
214+
v8::Local<v8::Context> context = v8::Context::New(isolate_);
215+
v8::Context::Scope context_scope(context);
216+
const size_t size = 10;
217+
AliasedBuffer<uint32_t, v8::Uint32Array> ab{isolate_, size};
218+
219+
EXPECT_EQ(static_cast<uint32_t>(1), ab[0] = 1);
220+
EXPECT_EQ(static_cast<uint32_t>(4), ab[0] += 3);
221+
EXPECT_EQ(static_cast<uint32_t>(2), ab[0] -= 2);
222+
EXPECT_EQ(static_cast<uint32_t>(-2), -ab[0]);
223+
}
224+
225+
TEST_F(AliasBufferTest, OperatorOverloadsRefs) {
226+
v8::Isolate::Scope isolate_scope(isolate_);
227+
v8::HandleScope handle_scope(isolate_);
228+
v8::Local<v8::Context> context = v8::Context::New(isolate_);
229+
v8::Context::Scope context_scope(context);
230+
AliasedBuffer<uint32_t, v8::Uint32Array> ab{isolate_, 2};
231+
using Reference = AliasedBuffer<uint32_t, v8::Uint32Array>::Reference;
232+
Reference ref = ab[0];
233+
Reference ref_value = ab[1] = 2;
234+
235+
EXPECT_EQ(static_cast<uint32_t>(2), ref = ref_value);
236+
EXPECT_EQ(static_cast<uint32_t>(4), ref += ref_value);
237+
EXPECT_EQ(static_cast<uint32_t>(2), ref -= ref_value);
238+
EXPECT_EQ(static_cast<uint32_t>(-2), -ref);
239+
}

Diff for: test/internet/test-http-https-default-ports.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const https = require('https');
3030

3131
const http = require('http');
3232

33-
https.get(`https://${addresses.INET_HOST}/`, common.mustCall(function(res) {
33+
https.get(`https://${addresses.INET_HOST}/`, common.mustCall((res) => {
3434
res.resume();
3535
}));
3636

37-
http.get(`http://${addresses.INET_HOST}/`, common.mustCall(function(res) {
37+
http.get(`http://${addresses.INET_HOST}/`, common.mustCall((res) => {
3838
res.resume();
3939
}));

Diff for: test/parallel/test-trace-events-all.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ proc.once('exit', common.mustCall(() => {
3535
assert(traces.some((trace) => {
3636
if (trace.pid !== proc.pid)
3737
return false;
38-
if (trace.cat !== 'node.async_hooks')
38+
if (trace.cat !== 'node,node.async_hooks')
3939
return false;
4040
if (trace.name !== 'TIMERWRAP')
4141
return false;
@@ -47,7 +47,7 @@ proc.once('exit', common.mustCall(() => {
4747
assert(traces.some((trace) => {
4848
if (trace.pid !== proc.pid)
4949
return false;
50-
if (trace.cat !== 'node.async_hooks')
50+
if (trace.cat !== 'node,node.async_hooks')
5151
return false;
5252
if (trace.name !== 'Timeout')
5353
return false;

Diff for: test/parallel/test-trace-events-async-hooks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ proc.once('exit', common.mustCall(() => {
3737
assert(traces.some((trace) => {
3838
if (trace.pid !== proc.pid)
3939
return false;
40-
if (trace.cat !== 'node.async_hooks')
40+
if (trace.cat !== 'node,node.async_hooks')
4141
return false;
4242
if (trace.name !== 'TIMERWRAP')
4343
return false;
@@ -48,7 +48,7 @@ proc.once('exit', common.mustCall(() => {
4848
assert(traces.some((trace) => {
4949
if (trace.pid !== proc.pid)
5050
return false;
51-
if (trace.cat !== 'node.async_hooks')
51+
if (trace.cat !== 'node,node.async_hooks')
5252
return false;
5353
if (trace.name !== 'Timeout')
5454
return false;

0 commit comments

Comments
 (0)