Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/env.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2021-01-28 17:00:03 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2021-02-05 15:10:29 +0300
commit9aeb83643486328cbdffb55a23efe953f6ee54e0 (patch)
treee5f192f2ba3d20065b2cf01b2b344ef4b37e5c7f /src/env.h
parent664cce92ec09363d5a37c9f2a360ee0810fe30e3 (diff)
src: refactor bookkeeping of bootstrap status
This patch 1. Refactors the bootstrap routine of the main instance so that when --no-node-snapshot is used, Environment::InitializeMainContext() will only be called once (previously it would be called twice, which was harmless for now but not ideal). 2. Mark the number of BaseObjects in RunBootstrapping() when creating the Environment from scratch and in InitializeMainContext() when the Environment is deserialized. Previously the marking was done in the Environment constructor and InitializeMainContext() respectively for the cctest which was incorrect because the cctest never uses an Environment that's not bootstrapped. Also renames the mark to base_object_created_after_bootstrap to reflect what it's intended for. PR-URL: https://github.com/nodejs/node/pull/37113 Refs: https://github.com/nodejs/node/pull/36943 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env.h')
-rw-r--r--src/env.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/env.h b/src/env.h
index 829e2f9fb07..ce0bcbfd25f 100644
--- a/src/env.h
+++ b/src/env.h
@@ -1129,7 +1129,7 @@ class Environment : public MemoryRetainer {
inline void add_refs(int64_t diff);
inline bool has_run_bootstrapping_code() const;
- inline void set_has_run_bootstrapping_code(bool has_run_bootstrapping_code);
+ inline void DoneBootstrapping();
inline bool has_serialized_options() const;
inline void set_has_serialized_options(bool has_serialized_options);
@@ -1315,6 +1315,7 @@ class Environment : public MemoryRetainer {
// no memory leaks caused by BaseObjects staying alive longer than expected
// (in particular, no circular BaseObjectPtr references).
inline void modify_base_object_count(int64_t delta);
+ inline int64_t base_object_created_after_bootstrap() const;
inline int64_t base_object_count() const;
inline int32_t stack_trace_limit() const { return 10; }
@@ -1508,7 +1509,7 @@ class Environment : public MemoryRetainer {
bool started_cleanup_ = false;
int64_t base_object_count_ = 0;
- int64_t initial_base_object_count_ = 0;
+ int64_t base_object_created_by_bootstrap_ = 0;
std::atomic_bool is_stopping_ { false };
std::unordered_set<int> unmanaged_fds_;