Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
afa5499
src: introduce custom smart pointers for `BaseObject`s
addaleax Sep 28, 2019
e1b1267
http2: use custom BaseObject smart pointers
addaleax Sep 28, 2019
95bf451
src: use BaseObjectPtr for keeping channel alive in dns bindings
addaleax Nov 12, 2019
cb196ce
src: remove keep alive option from SetImmediate()
addaleax Nov 12, 2019
92cb961
src: remove HandleWrap instances from list once closed
addaleax Oct 11, 2019
b18531d
src: keep object alive in stream_pipe code
addaleax Nov 26, 2019
ece9faf
src: add more `can_call_into_js()` guards
addaleax Nov 26, 2019
c3fff25
src: no SetImmediate from destructor in stream_pipe code
addaleax Nov 26, 2019
2470035
src: run native immediates during Environment cleanup
addaleax Nov 26, 2019
973f8ef
src: better encapsulate native immediate list
addaleax Dec 16, 2019
5e1bcae
src: exclude C++ SetImmediate() from count
addaleax Jan 15, 2020
f1aeed5
src: add a threadsafe variant of SetImmediate()
addaleax Jan 15, 2020
3f9d1dd
src: remove AsyncRequest
addaleax Jan 15, 2020
b0ce668
src: add interrupts to Environments/Workers
addaleax Jan 16, 2020
4e1a192
src: move MemoryInfo() for worker code to .cc files
addaleax Jan 16, 2020
a9c4fe5
report: add support for Workers
addaleax Jan 16, 2020
9c43d0e
src: simplify native immediate queue running
addaleax Jan 25, 2020
1915b5b
worker: move JoinThread() back into exit callback
addaleax Jan 22, 2020
4d3275b
src: harden running native `SetImmediate()`s slightly
addaleax Jan 22, 2020
d85cb07
src: delete BaseObjectWeakPtr data when pointee is gone
addaleax Mar 20, 2020
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
Prev Previous commit
Next Next commit
src: exclude C++ SetImmediate() from count
There is no real reason to manage a count manually, given that
checking whether there are C++ callbacks is a single pointer
comparison.

This makes it easier to add other kinds of native C++ callbacks
that are managed in a similar way.

PR-URL: #31386
Refs: openjs-foundation/summit#240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed Apr 1, 2020
commit 5e1bcaee6f5a2fd75c7ac4380fe29d00d02b208a
9 changes: 0 additions & 9 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,6 @@ inline bool ImmediateInfo::has_outstanding() const {
return fields_[kHasOutstanding] == 1;
}

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

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

inline void ImmediateInfo::ref_count_inc(uint32_t increment) {
fields_[kRefCount] += increment;
}
Expand Down Expand Up @@ -771,7 +763,6 @@ void Environment::CreateImmediate(Fn&& cb, bool ref) {
auto callback = std::make_unique<NativeImmediateCallbackImpl<Fn>>(
std::move(cb), ref);
native_immediates_.Push(std::move(callback));
immediate_info()->count_inc(1);
}

template <typename Fn>
Expand Down
12 changes: 4 additions & 8 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
"RunAndClearNativeImmediates", this);
size_t ref_count = 0;
size_t count = 0;

NativeImmediateQueue queue;
queue.ConcatMove(std::move(native_immediates_));
Expand All @@ -673,7 +672,6 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
TryCatchScope try_catch(this);
DebugSealHandleScope seal_handle_scope(isolate());
while (std::unique_ptr<NativeImmediateCallback> head = queue.Shift()) {
count++;
if (head->is_refed())
ref_count++;

Expand All @@ -691,9 +689,10 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
};
while (queue.size() > 0 && drain_list()) {}

DCHECK_GE(immediate_info()->count(), count);
immediate_info()->count_dec(count);
immediate_info()->ref_count_dec(ref_count);

if (immediate_info()->ref_count() == 0)
ToggleImmediateRef(false);
}


Expand Down Expand Up @@ -779,15 +778,12 @@ void Environment::CheckImmediate(uv_check_t* handle) {
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
"CheckImmediate", env);

if (env->immediate_info()->count() == 0)
return;

HandleScope scope(env->isolate());
Context::Scope context_scope(env->context());

env->RunAndClearNativeImmediates();

if (!env->can_call_into_js())
if (env->immediate_info()->count() == 0 || !env->can_call_into_js())
return;

do {
Expand Down
2 changes: 0 additions & 2 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,6 @@ class ImmediateInfo : public MemoryRetainer {
inline uint32_t count() const;
inline uint32_t ref_count() const;
inline bool has_outstanding() const;
inline void count_inc(uint32_t increment);
inline void count_dec(uint32_t decrement);
inline void ref_count_inc(uint32_t increment);
inline void ref_count_dec(uint32_t decrement);

Expand Down