Skip to content

Commit

Permalink
fixup! pacify linter
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jul 9, 2022
1 parent e9d6d72 commit df89e4b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
1 change: 0 additions & 1 deletion src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ T* BaseObject::FromJSObject(v8::Local<v8::Value> object) {
return static_cast<T*>(FromJSObject(object));
}


void BaseObject::OnGCCollect() {
delete this;
}
Expand Down
111 changes: 55 additions & 56 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ void AsyncHooks::push_async_context(double async_id,
}

uint32_t offset = fields_[kStackLength];
if (offset * 2 >= async_ids_stack_.Length())
grow_async_ids_stack();
if (offset * 2 >= async_ids_stack_.Length()) grow_async_ids_stack();
async_ids_stack_[2 * offset] = async_id_fields_[kExecutionAsyncId];
async_ids_stack_[2 * offset + 1] = async_id_fields_[kTriggerAsyncId];
fields_[kStackLength] += 1;
Expand Down Expand Up @@ -138,8 +137,7 @@ bool AsyncHooks::pop_async_context(double async_id) {
if (LIKELY(offset < native_execution_async_resources_.size() &&
!native_execution_async_resources_[offset].IsEmpty())) {
#ifdef DEBUG
for (uint32_t i = offset + 1;
i < native_execution_async_resources_.size();
for (uint32_t i = offset + 1; i < native_execution_async_resources_.size();
i++) {
CHECK(native_execution_async_resources_[i].IsEmpty());
}
Expand Down Expand Up @@ -167,10 +165,10 @@ void AsyncHooks::clear_async_id_stack() {
Isolate* isolate = env()->isolate();
HandleScope handle_scope(isolate);
if (!js_execution_async_resources_.IsEmpty()) {
USE(PersistentToLocal::Strong(js_execution_async_resources_)->Set(
env()->context(),
env()->length_string(),
Integer::NewFromUnsigned(isolate, 0)));
USE(PersistentToLocal::Strong(js_execution_async_resources_)
->Set(env()->context(),
env()->length_string(),
Integer::NewFromUnsigned(isolate, 0)));
}
native_execution_async_resources_.clear();
native_execution_async_resources_.shrink_to_fit();
Expand All @@ -181,19 +179,18 @@ void AsyncHooks::clear_async_id_stack() {
}

void AsyncHooks::AddContext(Local<Context> ctx) {
ctx->SetPromiseHooks(
js_promise_hooks_[0].IsEmpty() ?
Local<Function>() :
PersistentToLocal::Strong(js_promise_hooks_[0]),
js_promise_hooks_[1].IsEmpty() ?
Local<Function>() :
PersistentToLocal::Strong(js_promise_hooks_[1]),
js_promise_hooks_[2].IsEmpty() ?
Local<Function>() :
PersistentToLocal::Strong(js_promise_hooks_[2]),
js_promise_hooks_[3].IsEmpty() ?
Local<Function>() :
PersistentToLocal::Strong(js_promise_hooks_[3]));
ctx->SetPromiseHooks(js_promise_hooks_[0].IsEmpty()
? Local<Function>()
: PersistentToLocal::Strong(js_promise_hooks_[0]),
js_promise_hooks_[1].IsEmpty()
? Local<Function>()
: PersistentToLocal::Strong(js_promise_hooks_[1]),
js_promise_hooks_[2].IsEmpty()
? Local<Function>()
: PersistentToLocal::Strong(js_promise_hooks_[2]),
js_promise_hooks_[3].IsEmpty()
? Local<Function>()
: PersistentToLocal::Strong(js_promise_hooks_[3]));

size_t id = contexts_.size();
contexts_.resize(id + 1);
Expand All @@ -209,8 +206,7 @@ void AsyncHooks::RemoveContext(Local<Context> ctx) {
[&](auto&& el) { return el.IsEmpty(); }),
contexts_.end());
for (auto it = contexts_.begin(); it != contexts_.end(); it++) {
Local<Context> saved_context =
PersistentToLocal::Weak(isolate, *it);
Local<Context> saved_context = PersistentToLocal::Weak(isolate, *it);
if (saved_context == ctx) {
it->Reset();
contexts_.erase(it);
Expand All @@ -227,14 +223,14 @@ AsyncHooks::DefaultTriggerAsyncIdScope::DefaultTriggerAsyncIdScope(
}

old_default_trigger_async_id_ =
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId];
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId];
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
default_trigger_async_id;
default_trigger_async_id;
}

AsyncHooks::DefaultTriggerAsyncIdScope::~DefaultTriggerAsyncIdScope() {
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
old_default_trigger_async_id_;
old_default_trigger_async_id_;
}

AsyncHooks::DefaultTriggerAsyncIdScope::DefaultTriggerAsyncIdScope(
Expand Down Expand Up @@ -435,11 +431,11 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() {

void Environment::AssignToContext(Local<v8::Context> context,
const ContextInfo& info) {
context->SetAlignedPointerInEmbedderData(
ContextEmbedderIndex::kEnvironment, this);
context->SetAlignedPointerInEmbedderData(ContextEmbedderIndex::kEnvironment,
this);
// Used by Environment::GetCurrent to know that we are on a node context.
context->SetAlignedPointerInEmbedderData(
ContextEmbedderIndex::kContextTag, Environment::kNodeContextTagPtr);
context->SetAlignedPointerInEmbedderData(ContextEmbedderIndex::kContextTag,
Environment::kNodeContextTagPtr);
// Used to retrieve bindings
context->SetAlignedPointerInEmbedderData(
ContextEmbedderIndex::kBindingListIndex, &(this->bindings_));
Expand All @@ -452,7 +448,8 @@ void Environment::AssignToContext(Local<v8::Context> context,
}

void Environment::TryLoadAddon(
const char* filename, int flags,
const char* filename,
int flags,
const std::function<bool(binding::DLib*)>& was_loaded) {
loaded_addons_.emplace_back(filename, flags);
if (!was_loaded(&loaded_addons_.back())) {
Expand Down Expand Up @@ -485,8 +482,7 @@ void Environment::add_refs(int64_t diff) {
uv_ref(reinterpret_cast<uv_handle_t*>(&task_queues_async_));
}

uv_buf_t Environment::allocate_managed_buffer(
const size_t suggested_size) {
uv_buf_t Environment::allocate_managed_buffer(const size_t suggested_size) {
NoArrayBufferZeroFillScope no_zero_fill_scope(isolate_data());
std::unique_ptr<v8::BackingStore> bs =
v8::ArrayBuffer::NewBackingStore(isolate(), suggested_size);
Expand Down Expand Up @@ -528,7 +524,8 @@ void Environment::SetMethod(Local<v8::Object> that,
v8::FunctionCallback callback) {
Local<v8::Context> context = isolate()->GetCurrentContext();
Local<v8::Function> function =
NewFunctionTemplate(callback, Local<v8::Signature>(),
NewFunctionTemplate(callback,
Local<v8::Signature>(),
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasSideEffect)
->GetFunction(context)
Expand Down Expand Up @@ -565,7 +562,8 @@ void Environment::SetMethodNoSideEffect(Local<v8::Object> that,
v8::FunctionCallback callback) {
Local<v8::Context> context = isolate()->GetCurrentContext();
Local<v8::Function> function =
NewFunctionTemplate(callback, Local<v8::Signature>(),
NewFunctionTemplate(callback,
Local<v8::Signature>(),
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasNoSideEffect)
->GetFunction(context)
Expand All @@ -583,7 +581,9 @@ void Environment::SetProtoMethod(Local<v8::FunctionTemplate> that,
v8::FunctionCallback callback) {
Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
Local<v8::FunctionTemplate> t =
NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow,
NewFunctionTemplate(callback,
signature,
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasSideEffect);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
Expand All @@ -593,13 +593,14 @@ void Environment::SetProtoMethod(Local<v8::FunctionTemplate> that,
t->SetClassName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
}

void Environment::SetProtoMethodNoSideEffect(
Local<v8::FunctionTemplate> that,
const char* name,
v8::FunctionCallback callback) {
void Environment::SetProtoMethodNoSideEffect(Local<v8::FunctionTemplate> that,
const char* name,
v8::FunctionCallback callback) {
Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
Local<v8::FunctionTemplate> t =
NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow,
NewFunctionTemplate(callback,
signature,
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasNoSideEffect);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
Expand All @@ -614,7 +615,9 @@ void Environment::SetInstanceMethod(Local<v8::FunctionTemplate> that,
v8::FunctionCallback callback) {
Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
Local<v8::FunctionTemplate> t =
NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow,
NewFunctionTemplate(callback,
signature,
v8::ConstructorBehavior::kThrow,
v8::SideEffectType::kHasSideEffect);
// kInternalized strings are created in the old space.
const v8::NewStringType type = v8::NewStringType::kInternalized;
Expand All @@ -637,10 +640,8 @@ void Environment::SetConstructorFunction(Local<v8::Object> that,
SetConstructorFunctionFlag flag) {
if (LIKELY(flag == SetConstructorFunctionFlag::SET_CLASS_NAME))
tmpl->SetClassName(name);
that->Set(
context(),
name,
tmpl->GetFunction(context()).ToLocalChecked()).Check();
that->Set(context(), name, tmpl->GetFunction(context()).ToLocalChecked())
.Check();
}

void Environment::CreateProperties() {
Expand Down Expand Up @@ -2126,9 +2127,8 @@ BaseObject::BaseObject(Environment* env, Local<Object> object)
: persistent_handle_(env->isolate(), object), env_(env) {
CHECK_EQ(false, object.IsEmpty());
CHECK_GT(object->InternalFieldCount(), 0);
object->SetAlignedPointerInInternalField(
BaseObject::kSlot,
static_cast<void*>(this));
object->SetAlignedPointerInInternalField(BaseObject::kSlot,
static_cast<void*>(this));
env->AddCleanupHook(DeleteMe, static_cast<void*>(this));
env->modify_base_object_count(1);
}
Expand All @@ -2141,8 +2141,7 @@ BaseObject::~BaseObject() {
PointerData* metadata = pointer_data();
CHECK_EQ(metadata->strong_ptr_count, 0);
metadata->self = nullptr;
if (metadata->weak_ptr_count == 0)
delete metadata;
if (metadata->weak_ptr_count == 0) delete metadata;
}

if (persistent_handle_.IsEmpty()) {
Expand Down Expand Up @@ -2174,7 +2173,8 @@ void BaseObject::MakeWeak() {
CHECK_IMPLIES(obj->has_pointer_data(),
obj->pointer_data()->strong_ptr_count == 0);
obj->OnGCCollect();
}, WeakCallbackType::kParameter);
},
WeakCallbackType::kParameter);
}

void BaseObject::LazilyInitializedJSTemplateConstructor(
Expand All @@ -2184,13 +2184,12 @@ void BaseObject::LazilyInitializedJSTemplateConstructor(
args.This()->SetAlignedPointerInInternalField(BaseObject::kSlot, nullptr);
}

Local<FunctionTemplate>
BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
Local<FunctionTemplate> BaseObject::MakeLazilyInitializedJSTemplate(
Environment* env) {
Local<FunctionTemplate> t =
env->NewFunctionTemplate(LazilyInitializedJSTemplateConstructor);
t->Inherit(BaseObject::GetConstructorTemplate(env));
t->InstanceTemplate()->SetInternalFieldCount(
BaseObject::kInternalFieldCount);
t->InstanceTemplate()->SetInternalFieldCount(BaseObject::kInternalFieldCount);
return t;
}

Expand Down
6 changes: 4 additions & 2 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,8 @@ class AsyncHooks : public MemoryRetainer {
// NB: This call does not take (co-)ownership of `execution_async_resource`.
// The lifetime of the `v8::Local<>` pointee must last until
// `pop_async_context()` or `clear_async_id_stack()` are called.
void push_async_context(double async_id, double trigger_async_id,
void push_async_context(double async_id,
double trigger_async_id,
v8::Local<v8::Object> execution_async_resource);
bool pop_async_context(double async_id);
void clear_async_id_stack(); // Used in fatal exceptions.
Expand Down Expand Up @@ -1134,7 +1135,8 @@ class Environment : public MemoryRetainer {

inline v8::Isolate* isolate() const;
inline uv_loop_t* event_loop() const;
void TryLoadAddon(const char* filename, int flags,
void TryLoadAddon(const char* filename,
int flags,
const std::function<bool(binding::DLib*)>& was_loaded);

static inline Environment* from_timer_handle(uv_timer_t* handle);
Expand Down

0 comments on commit df89e4b

Please sign in to comment.