diff --git a/src/api/environment.cc b/src/api/environment.cc index 5dfac00647eddd..e5d06f27d13110 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -1,4 +1,4 @@ -#include "env.h" +#include "env-inl.h" #include "node.h" #include "node_context_data.h" #include "node_errors.h" diff --git a/src/api/utils.cc b/src/api/utils.cc index da7281a68f3bb1..3e59932f2f8b73 100644 --- a/src/api/utils.cc +++ b/src/api/utils.cc @@ -1,3 +1,4 @@ +#include "env-inl.h" #include "node.h" #include "node_internals.h" #include "util-inl.h" diff --git a/src/base_object.h b/src/base_object.h index cb83462ff51e54..f616108a1d9486 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -24,7 +24,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "memory_tracker-inl.h" +#include "memory_tracker.h" #include "v8.h" #include // std::remove_reference diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 07882a4212c6b2..0be02596f96945 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -23,6 +23,7 @@ #include "ares.h" #include "async_wrap-inl.h" #include "env-inl.h" +#include "memory_tracker-inl.h" #include "node.h" #include "req_wrap-inl.h" #include "util-inl.h" diff --git a/src/debug_utils.cc b/src/debug_utils.cc index b86710fba6e85b..a9bfa86b6d2aea 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -1,4 +1,5 @@ #include "debug_utils.h" +#include "env-inl.h" #include "util-inl.h" #ifdef __POSIX__ diff --git a/src/debug_utils.h b/src/debug_utils.h index ef5a4c0c47590c..db01cacba6a1b6 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -4,7 +4,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "async_wrap.h" -#include "env-inl.h" +#include "env.h" #include #include diff --git a/src/env.cc b/src/env.cc index 5f408f18f146a4..bc43fac963bbc3 100644 --- a/src/env.cc +++ b/src/env.cc @@ -1,6 +1,7 @@ #include "env.h" #include "async_wrap.h" +#include "memory_tracker-inl.h" #include "node_buffer.h" #include "node_context_data.h" #include "node_errors.h" diff --git a/src/heap_utils.cc b/src/heap_utils.cc index ee0665cfe279d8..acc63fd1d9a14c 100644 --- a/src/heap_utils.cc +++ b/src/heap_utils.cc @@ -1,4 +1,5 @@ #include "env-inl.h" +#include "memory_tracker-inl.h" #include "stream_base-inl.h" #include "util-inl.h" diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index d551c3a7d7324c..83f7140e93d7e7 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -1,5 +1,6 @@ #include "inspector_agent.h" +#include "env-inl.h" #include "inspector/main_thread_interface.h" #include "inspector/node_string.h" #include "inspector/runtime_agent.h" diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 5caf3fa09a4d10..9d649385706131 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -1,6 +1,7 @@ #include "base_object-inl.h" #include "inspector_agent.h" #include "inspector_io.h" +#include "memory_tracker-inl.h" #include "util-inl.h" #include "v8.h" #include "v8-inspector.h" diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc index 4604e0a5b441e1..7e76ad778a0f4a 100644 --- a/src/inspector_profiler.cc +++ b/src/inspector_profiler.cc @@ -2,6 +2,7 @@ #include #include "base_object-inl.h" #include "debug_utils.h" +#include "memory_tracker-inl.h" #include "node_file.h" #include "node_internals.h" #include "v8-inspector.h" diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index 286086ab6af46d..da460e6b52b489 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -2,6 +2,7 @@ #include #include #define NAPI_EXPERIMENTAL +#include "env-inl.h" #include "js_native_api_v8.h" #include "js_native_api.h" #include "util-inl.h" diff --git a/src/module_wrap.cc b/src/module_wrap.cc index a4e81dcc29474b..e104afb736c28d 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -1,6 +1,7 @@ #include "module_wrap.h" #include "env.h" +#include "memory_tracker-inl.h" #include "node_errors.h" #include "node_url.h" #include "util-inl.h" diff --git a/src/node.cc b/src/node.cc index 7dccd7ce576828..e5e9a23730f0b6 100644 --- a/src/node.cc +++ b/src/node.cc @@ -25,6 +25,7 @@ #include "debug_utils.h" #include "env-inl.h" +#include "memory_tracker-inl.h" #include "node_binding.h" #include "node_internals.h" #include "node_main_instance.h" diff --git a/src/node_api.cc b/src/node_api.cc index f8b0d8b550391f..32393883d7c601 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -1,11 +1,12 @@ #include -#include "env.h" +#include "env-inl.h" #define NAPI_EXPERIMENTAL #include "js_native_api_v8.h" #include "node_api.h" #include "node_binding.h" #include "node_errors.h" #include "node_internals.h" +#include "threadpoolwork-inl.h" #include "util-inl.h" #include diff --git a/src/node_config.cc b/src/node_config.cc index 335ebedc583bdc..92985dff2f8b0c 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -1,4 +1,5 @@ #include "env-inl.h" +#include "memory_tracker.h" #include "node.h" #include "node_i18n.h" #include "node_native_module_env.h" diff --git a/src/node_constants.cc b/src/node_constants.cc index aa2afc59d95e64..7c9e4ce276112b 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -19,6 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +#include "env-inl.h" #include "node_constants.h" #include "node_internals.h" #include "util-inl.h" diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 77622f8cbd6d2b..ee5a9db574f0f9 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -21,6 +21,7 @@ #include "node_contextify.h" +#include "memory_tracker-inl.h" #include "node_internals.h" #include "node_watchdog.h" #include "base_object-inl.h" diff --git a/src/node_credentials.cc b/src/node_credentials.cc index d384504f2ac906..6f99cf6641eec3 100644 --- a/src/node_credentials.cc +++ b/src/node_credentials.cc @@ -1,3 +1,4 @@ +#include "env-inl.h" #include "node_internals.h" #include "util-inl.h" diff --git a/src/node_crypto.cc b/src/node_crypto.cc index bbb07e5b48b4a2..76a8cc8a193f1e 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -32,7 +32,9 @@ #include "async_wrap-inl.h" #include "base_object-inl.h" #include "env-inl.h" +#include "memory_tracker-inl.h" #include "string_bytes.h" +#include "threadpoolwork-inl.h" #include "util-inl.h" #include "v8.h" diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc index fcbe30ca9c07c0..9f06801c3ae20c 100644 --- a/src/node_crypto_bio.cc +++ b/src/node_crypto_bio.cc @@ -20,6 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. #include "base_object-inl.h" +#include "memory_tracker-inl.h" #include "node_crypto_bio.h" #include "openssl/bio.h" #include "util-inl.h" diff --git a/src/node_file.cc b/src/node_file.cc index 4da2a4f53cb581..8f82d639d6d0a3 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -21,6 +21,7 @@ #include "node_file.h" #include "aliased_buffer.h" +#include "memory_tracker-inl.h" #include "node_buffer.h" #include "node_process.h" #include "node_stat_watcher.h" diff --git a/src/node_http2.cc b/src/node_http2.cc index 0c650290c2b7f2..d9b886284ddd2b 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1,5 +1,6 @@ #include "aliased_buffer.h" #include "debug_utils.h" +#include "memory_tracker-inl.h" #include "node.h" #include "node_buffer.h" #include "node_http2.h" diff --git a/src/node_http_parser_llhttp.cc b/src/node_http_parser_llhttp.cc index d2063873f17efd..6e1d18d3af94ff 100644 --- a/src/node_http_parser_llhttp.cc +++ b/src/node_http_parser_llhttp.cc @@ -1,6 +1,7 @@ #define NODE_EXPERIMENTAL_HTTP 1 #include "node_http_parser_impl.h" +#include "memory_tracker-inl.h" #include "node_metadata.h" #include "util-inl.h" diff --git a/src/node_http_parser_traditional.cc b/src/node_http_parser_traditional.cc index 7b413af8b6ce0c..11aa387f109828 100644 --- a/src/node_http_parser_traditional.cc +++ b/src/node_http_parser_traditional.cc @@ -2,6 +2,7 @@ #undef NODE_EXPERIMENTAL_HTTP #endif +#include "memory_tracker-inl.h" #include "node_http_parser_impl.h" #include "node_metadata.h" #include "util-inl.h" diff --git a/src/node_internals.h b/src/node_internals.h index cb039f297b190b..f74e67ce6f077b 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -24,7 +24,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "env-inl.h" +#include "env.h" #include "node.h" #include "node_binding.h" #include "node_mutex.h" @@ -252,27 +252,6 @@ class ThreadPoolWork { uv_work_t work_req_; }; -void ThreadPoolWork::ScheduleWork() { - env_->IncreaseWaitingRequestCounter(); - int status = uv_queue_work( - env_->event_loop(), - &work_req_, - [](uv_work_t* req) { - ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req); - self->DoThreadPoolWork(); - }, - [](uv_work_t* req, int status) { - ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req); - self->env_->DecreaseWaitingRequestCounter(); - self->AfterThreadPoolWork(status); - }); - CHECK_EQ(status, 0); -} - -int ThreadPoolWork::CancelWork() { - return uv_cancel(reinterpret_cast(&work_req_)); -} - #define TRACING_CATEGORY_NODE "node" #define TRACING_CATEGORY_NODE1(one) \ TRACING_CATEGORY_NODE "," \ diff --git a/src/node_messaging.cc b/src/node_messaging.cc index ea7b48779ca188..fa583a2570315b 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -2,6 +2,7 @@ #include "async_wrap-inl.h" #include "debug_utils.h" +#include "memory_tracker-inl.h" #include "node_contextify.h" #include "node_buffer.h" #include "node_errors.h" diff --git a/src/node_perf.cc b/src/node_perf.cc index 08632020300038..f43c10213624bb 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -1,4 +1,5 @@ #include "aliased_buffer.h" +#include "memory_tracker-inl.h" #include "node_internals.h" #include "node_perf.h" #include "node_buffer.h" diff --git a/src/node_report.cc b/src/node_report.cc index 578da4376e07da..2f668b54630761 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -1,3 +1,4 @@ +#include "env-inl.h" #include "node_report.h" #include "debug_utils.h" #include "node_internals.h" diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index 33d7c52b34f78e..2581af06fac62d 100644 --- a/src/node_report_utils.cc +++ b/src/node_report_utils.cc @@ -1,3 +1,4 @@ +#include "env-inl.h" #include "node_internals.h" #include "node_report.h" #include "util-inl.h" diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index b7fb45900f9bb8..ae30825cbbdbd2 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -19,6 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +#include "memory_tracker-inl.h" #include "node_stat_watcher.h" #include "async_wrap-inl.h" #include "env.h" diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index 13072a3340ced9..24e1d66fb7e7f4 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -1,5 +1,6 @@ #include "base_object-inl.h" #include "env.h" +#include "memory_tracker-inl.h" #include "node.h" #include "node_internals.h" #include "node_v8_platform-inl.h" diff --git a/src/node_url.h b/src/node_url.h index e85b14e2bdf35c..e85ca6e7129f6a 100644 --- a/src/node_url.h +++ b/src/node_url.h @@ -4,7 +4,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "node.h" -#include "env-inl.h" +#include "env.h" #include diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc index 28df2fb44983e1..63fa8870249976 100644 --- a/src/node_watchdog.cc +++ b/src/node_watchdog.cc @@ -19,11 +19,13 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -#include "node_watchdog.h" #include + #include "debug_utils.h" +#include "env-inl.h" #include "node_errors.h" #include "node_internals.h" +#include "node_watchdog.h" #include "util-inl.h" namespace node { diff --git a/src/node_worker.cc b/src/node_worker.cc index 20b883664da207..e84b36f132ae3b 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -1,5 +1,6 @@ #include "node_worker.h" #include "debug_utils.h" +#include "memory_tracker-inl.h" #include "node_errors.h" #include "node_buffer.h" #include "node_options-inl.h" diff --git a/src/node_zlib.cc b/src/node_zlib.cc index f389257882215e..30fef0ff1d4d57 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -19,11 +19,13 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +#include "memory_tracker-inl.h" #include "node.h" #include "node_buffer.h" #include "async_wrap-inl.h" #include "env-inl.h" +#include "threadpoolwork-inl.h" #include "util-inl.h" #include "v8.h" diff --git a/src/threadpoolwork-inl.h b/src/threadpoolwork-inl.h new file mode 100644 index 00000000000000..8bba988b18db0f --- /dev/null +++ b/src/threadpoolwork-inl.h @@ -0,0 +1,57 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef SRC_THREADPOOLWORK_INL_H_ +#define SRC_THREADPOOLWORK_INL_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "util-inl.h" +#include "node_internals.h" + +namespace node { + +void ThreadPoolWork::ScheduleWork() { + env_->IncreaseWaitingRequestCounter(); + int status = uv_queue_work( + env_->event_loop(), + &work_req_, + [](uv_work_t* req) { + ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req); + self->DoThreadPoolWork(); + }, + [](uv_work_t* req, int status) { + ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req); + self->env_->DecreaseWaitingRequestCounter(); + self->AfterThreadPoolWork(status); + }); + CHECK_EQ(status, 0); +} + +int ThreadPoolWork::CancelWork() { + return uv_cancel(reinterpret_cast(&work_req_)); +} + +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_THREADPOOLWORK_INL_H_ diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index cd6321b9693c3b..22996f9bcffa08 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -22,6 +22,7 @@ #include "tls_wrap.h" #include "async_wrap-inl.h" #include "debug_utils.h" +#include "memory_tracker-inl.h" #include "node_buffer.h" // Buffer #include "node_crypto.h" // SecureContext #include "node_crypto_bio.h" // NodeBIO diff --git a/src/util.cc b/src/util.cc index 51f11b45396fa3..26dbfe844995eb 100644 --- a/src/util.cc +++ b/src/util.cc @@ -22,6 +22,7 @@ #include "util.h" // NOLINT(build/include_inline) #include "util-inl.h" +#include "env-inl.h" #include "node_buffer.h" #include "node_errors.h" #include "node_internals.h" diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index f5740e5ce9278a..a396f14d18c6e4 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -7,7 +7,7 @@ #include "node.h" #include "node_platform.h" #include "node_internals.h" -#include "env.h" +#include "env-inl.h" #include "util-inl.h" #include "v8.h" #include "libplatform/libplatform.h" diff --git a/test/cctest/test_aliased_buffer.cc b/test/cctest/test_aliased_buffer.cc index 5421dd6d14582e..ba947700c1bf27 100644 --- a/test/cctest/test_aliased_buffer.cc +++ b/test/cctest/test_aliased_buffer.cc @@ -1,4 +1,3 @@ - #include "v8.h" #include "aliased_buffer.h" #include "node_test_fixture.h" diff --git a/test/cctest/test_url.cc b/test/cctest/test_url.cc index ddef534b57485f..96f9741386360f 100644 --- a/test/cctest/test_url.cc +++ b/test/cctest/test_url.cc @@ -1,5 +1,6 @@ #include "node_url.h" #include "node_i18n.h" +#include "util-inl.h" #include "gtest/gtest.h" diff --git a/tools/js2c.py b/tools/js2c.py index 9c5130a91630c3..413158765551d3 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -177,6 +177,7 @@ def ReadMacros(macro_files): TEMPLATE = """ +#include "env-inl.h" #include "node_native_module.h" #include "node_internals.h" diff --git a/tools/snapshot/node_mksnapshot.cc b/tools/snapshot/node_mksnapshot.cc index c273ba20b610e1..5cf24f32b49e01 100644 --- a/tools/snapshot/node_mksnapshot.cc +++ b/tools/snapshot/node_mksnapshot.cc @@ -5,9 +5,11 @@ #include #include +#include "env-inl.h" #include "libplatform/libplatform.h" #include "node_internals.h" #include "snapshot_builder.h" +#include "util-inl.h" #include "v8.h" #ifdef _WIN32