From bc69a8127686c58e01631952e3158f507dd3231c Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 20 Mar 2019 19:42:02 +0800 Subject: [PATCH] src: move TickInfo out of Environment PR-URL: https://github.com/nodejs/node/pull/26824 Refs: https://github.com/nodejs/node/issues/26776 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- src/api/callback.cc | 2 +- src/env-inl.h | 10 +++++----- src/env.h | 40 ++++++++++++++++++---------------------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/api/callback.cc b/src/api/callback.cc index 4083ae84879059..52a8da35b671d1 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -96,7 +96,7 @@ void InternalCallbackScope::Close() { return; } - Environment::TickInfo* tick_info = env_->tick_info(); + TickInfo* tick_info = env_->tick_info(); if (!env_->can_call_into_js()) return; if (!tick_info->has_tick_scheduled()) { diff --git a/src/env-inl.h b/src/env-inl.h index 5f60c25d0518b7..938317fa2f8d93 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -268,18 +268,18 @@ inline void ImmediateInfo::ref_count_dec(uint32_t decrement) { fields_[kRefCount] -= decrement; } -inline Environment::TickInfo::TickInfo(v8::Isolate* isolate) +inline TickInfo::TickInfo(v8::Isolate* isolate) : fields_(isolate, kFieldsCount) {} -inline AliasedBuffer& Environment::TickInfo::fields() { +inline AliasedBuffer& TickInfo::fields() { return fields_; } -inline bool Environment::TickInfo::has_tick_scheduled() const { +inline bool TickInfo::has_tick_scheduled() const { return fields_[kHasTickScheduled] == 1; } -inline bool Environment::TickInfo::has_rejection_to_warn() const { +inline bool TickInfo::has_rejection_to_warn() const { return fields_[kHasRejectionToWarn] == 1; } @@ -439,7 +439,7 @@ inline ImmediateInfo* Environment::immediate_info() { return &immediate_info_; } -inline Environment::TickInfo* Environment::tick_info() { +inline TickInfo* Environment::tick_info() { return &tick_info_; } diff --git a/src/env.h b/src/env.h index ed95c748ae7bd9..7ac325abbc77cc 100644 --- a/src/env.h +++ b/src/env.h @@ -642,6 +642,24 @@ class ImmediateInfo { AliasedBuffer fields_; }; +class TickInfo { + public: + inline AliasedBuffer& fields(); + inline bool has_tick_scheduled() const; + inline bool has_rejection_to_warn() const; + + TickInfo(const TickInfo&) = delete; + TickInfo& operator=(const TickInfo&) = delete; + + private: + friend class Environment; // So we can call the constructor. + inline explicit TickInfo(v8::Isolate* isolate); + + enum Fields { kHasTickScheduled = 0, kHasRejectionToWarn, kFieldsCount }; + + AliasedBuffer fields_; +}; + class Environment { public: Environment(const Environment&) = delete; @@ -651,28 +669,6 @@ class Environment { inline void PushAsyncCallbackScope(); inline void PopAsyncCallbackScope(); - class TickInfo { - public: - inline AliasedBuffer& fields(); - inline bool has_tick_scheduled() const; - inline bool has_rejection_to_warn() const; - - TickInfo(const TickInfo&) = delete; - TickInfo& operator=(const TickInfo&) = delete; - - private: - friend class Environment; // So we can call the constructor. - inline explicit TickInfo(v8::Isolate* isolate); - - enum Fields { - kHasTickScheduled = 0, - kHasRejectionToWarn, - kFieldsCount - }; - - AliasedBuffer fields_; - }; - enum Flags { kNoFlags = 0, kIsMainThread = 1 << 0,