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

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
Merge 099e621 as of 2018-03-09
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Jack Horton <jahorto@microsoft.com>
  • Loading branch information
chakrabot committed Mar 9, 2018
2 parents ff3d26b + 099e621 commit 8fcb1b4
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 45 deletions.
3 changes: 2 additions & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ platforms in production.

| System | Support type | Version | Architectures | Notes |
|--------------|--------------|----------------------------------|----------------------|------------------|
| GNU/Linux | Tier 1 | kernel >= 2.6.32, glibc >= 2.12 | x64, arm, arm64 | |
| GNU/Linux | Tier 1 | kernel >= 2.6.32, glibc >= 2.12 | x64, arm | |
| GNU/Linux | Tier 1 | kernel >= 3.10, glibc >= 2.17 | arm64 | |
| macOS | Tier 1 | >= 10.10 | x64 | |
| Windows | Tier 1 | >= Windows 7/2008 R2 | x86, x64 | vs2017 |
| SmartOS | Tier 2 | >= 15 < 16.4 | x86, x64 | see note1 |
Expand Down
5 changes: 2 additions & 3 deletions doc/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
* American English spelling is preferred. "Capitalize" vs. "Capitalise",
"color" vs. "colour", etc.
* Use [serial commas][].
* Generally avoid personal pronouns in reference documentation ("I", "you",
"we").
* Avoid personal pronouns in reference documentation ("I", "you", "we").
* Pronouns are acceptable in more colloquial documentation, like guides.
* Use gender-neutral pronouns and mass nouns. Non-comprehensive
examples:
* OK: "they", "their", "them", "folks", "people", "developers", "cats"
* OK: "they", "their", "them", "folks", "people", "developers"
* NOT OK: "his", "hers", "him", "her", "guys", "dudes"
* When combining wrapping elements (parentheses and quotes), terminal
punctuation should be placed:
Expand Down
3 changes: 0 additions & 3 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,6 @@ readable.on('readable', () => {
});
```

Avoid the use of the `'readable'` event and the `readable.read()` method in
favor of using either `readable.pipe()` or the `'data'` event.

A Readable stream in object mode will always return a single item from
a call to [`readable.read(size)`][stream-read], regardless of the value of the
`size` argument.
Expand Down
12 changes: 7 additions & 5 deletions lib/internal/trace_events_async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const END_EVENT = 'e'.charCodeAt(0);
// non-init events, use a map to manually map the asyncId to the type name.
const typeMemory = new Map();

const trace_event_category = 'node,node.async_hooks';

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

typeMemory.set(asyncId, type);
trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
trace_events.emit(BEFORE_EVENT, trace_event_category,
type, asyncId,
'triggerAsyncId', triggerAsyncId,
'executionAsyncId', async_hooks.executionAsyncId());
Expand All @@ -37,23 +39,23 @@ const hook = async_hooks.createHook({
const type = typeMemory.get(asyncId);
if (type === undefined) return;

trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
trace_events.emit(BEFORE_EVENT, trace_event_category,
type + '_CALLBACK', asyncId);
},

after(asyncId) {
const type = typeMemory.get(asyncId);
if (type === undefined) return;

trace_events.emit(END_EVENT, 'node.async_hooks',
trace_events.emit(END_EVENT, trace_event_category,
type + '_CALLBACK', asyncId);
},

destroy(asyncId) {
const type = typeMemory.get(asyncId);
if (type === undefined) return;

trace_events.emit(END_EVENT, 'node.async_hooks',
trace_events.emit(END_EVENT, trace_event_category,
type, asyncId);

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


exports.setup = function() {
if (trace_events.categoryGroupEnabled('node.async_hooks')) {
if (trace_events.categoryGroupEnabled(trace_event_category)) {
hook.enable();
}
};
16 changes: 16 additions & 0 deletions src/aliased_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ class AliasedBuffer {
return aliased_buffer_->GetValue(index_);
}

template <typename T>
inline Reference& operator+=(const T& val) {
const T current = aliased_buffer_->GetValue(index_);
aliased_buffer_->SetValue(index_, current + val);
return *this;
}

inline Reference& operator+=(const Reference& val) {
return this->operator+=(static_cast<NativeT>(val));
}

template <typename T>
inline Reference& operator-=(const T& val) {
return this->operator+=(-val);
}

private:
AliasedBuffer<NativeT, V8T>* aliased_buffer_;
size_t index_;
Expand Down
12 changes: 8 additions & 4 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ void AsyncWrap::EmitTraceEventBefore() {
switch (provider_type()) {
#define V(PROVIDER) \
case PROVIDER_ ## PROVIDER: \
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("node.async_hooks", \
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( \
TRACING_CATEGORY_NODE1(async_hooks), \
#PROVIDER "_CALLBACK", static_cast<int64_t>(get_async_id())); \
break;
NODE_ASYNC_PROVIDER_TYPES(V)
Expand Down Expand Up @@ -207,7 +208,8 @@ void AsyncWrap::EmitTraceEventAfter() {
switch (provider_type()) {
#define V(PROVIDER) \
case PROVIDER_ ## PROVIDER: \
TRACE_EVENT_NESTABLE_ASYNC_END0("node.async_hooks", \
TRACE_EVENT_NESTABLE_ASYNC_END0( \
TRACING_CATEGORY_NODE1(async_hooks), \
#PROVIDER "_CALLBACK", static_cast<int64_t>(get_async_id())); \
break;
NODE_ASYNC_PROVIDER_TYPES(V)
Expand Down Expand Up @@ -631,7 +633,8 @@ void AsyncWrap::EmitTraceEventDestroy() {
switch (provider_type()) {
#define V(PROVIDER) \
case PROVIDER_ ## PROVIDER: \
TRACE_EVENT_NESTABLE_ASYNC_END0("node.async_hooks", \
TRACE_EVENT_NESTABLE_ASYNC_END0( \
TRACING_CATEGORY_NODE1(async_hooks), \
#PROVIDER, static_cast<int64_t>(get_async_id())); \
break;
NODE_ASYNC_PROVIDER_TYPES(V)
Expand Down Expand Up @@ -664,7 +667,8 @@ void AsyncWrap::AsyncReset(double execution_async_id, bool silent) {
switch (provider_type()) {
#define V(PROVIDER) \
case PROVIDER_ ## PROVIDER: \
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2("node.async_hooks", \
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( \
TRACING_CATEGORY_NODE1(async_hooks), \
#PROVIDER, static_cast<int64_t>(get_async_id()), \
"executionAsyncId", \
static_cast<int64_t>(env()->execution_async_id()), \
Expand Down
16 changes: 7 additions & 9 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ inline v8::Local<v8::String> Environment::AsyncHooks::provider_string(int idx) {
}

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

inline Environment* Environment::AsyncHooks::env() {
Expand All @@ -135,7 +134,7 @@ inline void Environment::AsyncHooks::push_async_ids(double async_id,
grow_async_ids_stack();
async_ids_stack_[2 * offset] = async_id_fields_[kExecutionAsyncId];
async_ids_stack_[2 * offset + 1] = async_id_fields_[kTriggerAsyncId];
fields_[kStackLength] = fields_[kStackLength] + 1;
fields_[kStackLength] += 1;
async_id_fields_[kExecutionAsyncId] = async_id;
async_id_fields_[kTriggerAsyncId] = trigger_async_id;
}
Expand Down Expand Up @@ -240,19 +239,19 @@ inline bool Environment::ImmediateInfo::has_outstanding() const {
}

inline void Environment::ImmediateInfo::count_inc(uint32_t increment) {
fields_[kCount] = fields_[kCount] + increment;
fields_[kCount] += increment;
}

inline void Environment::ImmediateInfo::count_dec(uint32_t decrement) {
fields_[kCount] = fields_[kCount] - decrement;
fields_[kCount] -= decrement;
}

inline void Environment::ImmediateInfo::ref_count_inc(uint32_t increment) {
fields_[kRefCount] = fields_[kRefCount] + increment;
fields_[kRefCount] += increment;
}

inline void Environment::ImmediateInfo::ref_count_dec(uint32_t decrement) {
fields_[kRefCount] = fields_[kRefCount] - decrement;
fields_[kRefCount] -= decrement;
}

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

inline double Environment::new_async_id() {
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] =
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] + 1;
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] += 1;
return async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter];
}

Expand Down
2 changes: 1 addition & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3281,7 +3281,7 @@ bool CipherBase::Update(const char* data,
unsigned char** out,
int* out_len) {
if (ctx_ == nullptr)
return 0;
return false;

// on first update:
if (kind_ == kDecipher && IsAuthenticatedMode() && auth_tag_len_ > 0) {
Expand Down
9 changes: 9 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,15 @@ static inline const char *errno_string(int errorno) {
#define NODE_MODULE_CONTEXT_AWARE_INTERNAL(modname, regfunc) \
NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_INTERNAL)

#define TRACING_CATEGORY_NODE "node"
#define TRACING_CATEGORY_NODE1(one) \
TRACING_CATEGORY_NODE "," \
TRACING_CATEGORY_NODE "." #one
#define TRACING_CATEGORY_NODE2(one, two) \
TRACING_CATEGORY_NODE "," \
TRACING_CATEGORY_NODE "." #one "," \
TRACING_CATEGORY_NODE "." #one "." #two

} // namespace node


Expand Down
21 changes: 14 additions & 7 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ void Mark(const FunctionCallbackInfo<Value>& args) {
(*marks)[*name] = now;

TRACE_EVENT_COPY_MARK_WITH_TIMESTAMP(
"node.perf,node.perf.usertiming", *name, now / 1000);
TRACING_CATEGORY_NODE2(perf, usertiming),
*name, now / 1000);

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

TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
"node.perf,node.perf.usertiming", *name, *name, startTimestamp / 1000);
TRACING_CATEGORY_NODE2(perf, usertiming),
*name, *name, startTimestamp / 1000);
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
"node.perf,node.perf.usertiming", *name, *name, endTimestamp / 1000);
TRACING_CATEGORY_NODE2(perf, usertiming),
*name, *name, endTimestamp / 1000);

PerformanceEntry entry(env, *name, "measure", startTimestamp, endTimestamp);
Local<Object> obj = entry.ToObject();
Expand Down Expand Up @@ -301,13 +304,15 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
if (args.IsConstructCall()) {
start = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
"node.perf,node.perf.timerify", *name, *name, start / 1000);
TRACING_CATEGORY_NODE2(perf, timerify),
*name, *name, start / 1000);
v8::MaybeLocal<Object> ret = fn->NewInstance(context,
call_args.size(),
call_args.data());
end = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
"node.perf,node.perf.timerify", *name, *name, end / 1000);
TRACING_CATEGORY_NODE2(perf, timerify),
*name, *name, end / 1000);

if (ret.IsEmpty()) {
try_catch.ReThrow();
Expand All @@ -317,14 +322,16 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
} else {
start = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
"node.perf,node.perf.timerify", *name, *name, start / 1000);
TRACING_CATEGORY_NODE2(perf, timerify),
*name, *name, start / 1000);
v8::MaybeLocal<Value> ret = fn->Call(context,
args.This(),
call_args.size(),
call_args.data());
end = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
"node.perf,node.perf.timerify", *name, *name, end / 1000);
TRACING_CATEGORY_NODE2(perf, timerify),
*name, *name, end / 1000);

if (ret.IsEmpty()) {
try_catch.ReThrow();
Expand Down
30 changes: 30 additions & 0 deletions test/cctest/test_aliased_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,33 @@ TEST_F(AliasBufferTest, SharedArrayBuffer4) {
int8_t, v8::Int8Array,
int32_t, v8::Int32Array>(isolate_, 1, 3, 1);
}

TEST_F(AliasBufferTest, OperatorOverloads) {
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context = v8::Context::New(isolate_);
v8::Context::Scope context_scope(context);
const size_t size = 10;
AliasedBuffer<uint32_t, v8::Uint32Array> ab{isolate_, size};

EXPECT_EQ(static_cast<uint32_t>(1), ab[0] = 1);
EXPECT_EQ(static_cast<uint32_t>(4), ab[0] += 3);
EXPECT_EQ(static_cast<uint32_t>(2), ab[0] -= 2);
EXPECT_EQ(static_cast<uint32_t>(-2), -ab[0]);
}

TEST_F(AliasBufferTest, OperatorOverloadsRefs) {
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context = v8::Context::New(isolate_);
v8::Context::Scope context_scope(context);
AliasedBuffer<uint32_t, v8::Uint32Array> ab{isolate_, 2};
using Reference = AliasedBuffer<uint32_t, v8::Uint32Array>::Reference;
Reference ref = ab[0];
Reference ref_value = ab[1] = 2;

EXPECT_EQ(static_cast<uint32_t>(2), ref = ref_value);
EXPECT_EQ(static_cast<uint32_t>(4), ref += ref_value);
EXPECT_EQ(static_cast<uint32_t>(2), ref -= ref_value);
EXPECT_EQ(static_cast<uint32_t>(-2), -ref);
}
4 changes: 2 additions & 2 deletions test/internet/test-http-https-default-ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const https = require('https');

const http = require('http');

https.get(`https://${addresses.INET_HOST}/`, common.mustCall(function(res) {
https.get(`https://${addresses.INET_HOST}/`, common.mustCall((res) => {
res.resume();
}));

http.get(`http://${addresses.INET_HOST}/`, common.mustCall(function(res) {
http.get(`http://${addresses.INET_HOST}/`, common.mustCall((res) => {
res.resume();
}));
4 changes: 2 additions & 2 deletions test/parallel/test-trace-events-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ proc.once('exit', common.mustCall(() => {
assert(traces.some((trace) => {
if (trace.pid !== proc.pid)
return false;
if (trace.cat !== 'node.async_hooks')
if (trace.cat !== 'node,node.async_hooks')
return false;
if (trace.name !== 'TIMERWRAP')
return false;
Expand All @@ -47,7 +47,7 @@ proc.once('exit', common.mustCall(() => {
assert(traces.some((trace) => {
if (trace.pid !== proc.pid)
return false;
if (trace.cat !== 'node.async_hooks')
if (trace.cat !== 'node,node.async_hooks')
return false;
if (trace.name !== 'Timeout')
return false;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-trace-events-async-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ proc.once('exit', common.mustCall(() => {
assert(traces.some((trace) => {
if (trace.pid !== proc.pid)
return false;
if (trace.cat !== 'node.async_hooks')
if (trace.cat !== 'node,node.async_hooks')
return false;
if (trace.name !== 'TIMERWRAP')
return false;
Expand All @@ -48,7 +48,7 @@ proc.once('exit', common.mustCall(() => {
assert(traces.some((trace) => {
if (trace.pid !== proc.pid)
return false;
if (trace.cat !== 'node.async_hooks')
if (trace.cat !== 'node,node.async_hooks')
return false;
if (trace.name !== 'Timeout')
return false;
Expand Down
Loading

0 comments on commit 8fcb1b4

Please sign in to comment.