Skip to content

Commit

Permalink
src: move TickInfo out of Environment
Browse files Browse the repository at this point in the history
PR-URL: #26824
Refs: #26776
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and targos committed Mar 27, 2019
1 parent 495e5e9 commit bc69a81
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/api/callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
10 changes: 5 additions & 5 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t, v8::Uint8Array>& Environment::TickInfo::fields() {
inline AliasedBuffer<uint8_t, v8::Uint8Array>& 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;
}

Expand Down Expand Up @@ -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_;
}

Expand Down
40 changes: 18 additions & 22 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,24 @@ class ImmediateInfo {
AliasedBuffer<uint32_t, v8::Uint32Array> fields_;
};

class TickInfo {
public:
inline AliasedBuffer<uint8_t, v8::Uint8Array>& 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<uint8_t, v8::Uint8Array> fields_;
};

class Environment {
public:
Environment(const Environment&) = delete;
Expand All @@ -651,28 +669,6 @@ class Environment {
inline void PushAsyncCallbackScope();
inline void PopAsyncCallbackScope();

class TickInfo {
public:
inline AliasedBuffer<uint8_t, v8::Uint8Array>& 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<uint8_t, v8::Uint8Array> fields_;
};

enum Flags {
kNoFlags = 0,
kIsMainThread = 1 << 0,
Expand Down

0 comments on commit bc69a81

Please sign in to comment.