@@ -95,8 +95,7 @@ void AsyncHooks::push_async_context(double async_id,
95
95
}
96
96
97
97
uint32_t offset = fields_[kStackLength ];
98
- if (offset * 2 >= async_ids_stack_.Length ())
99
- grow_async_ids_stack ();
98
+ if (offset * 2 >= async_ids_stack_.Length ()) grow_async_ids_stack ();
100
99
async_ids_stack_[2 * offset] = async_id_fields_[kExecutionAsyncId ];
101
100
async_ids_stack_[2 * offset + 1 ] = async_id_fields_[kTriggerAsyncId ];
102
101
fields_[kStackLength ] += 1 ;
@@ -138,8 +137,7 @@ bool AsyncHooks::pop_async_context(double async_id) {
138
137
if (LIKELY (offset < native_execution_async_resources_.size () &&
139
138
!native_execution_async_resources_[offset].IsEmpty ())) {
140
139
#ifdef DEBUG
141
- for (uint32_t i = offset + 1 ;
142
- i < native_execution_async_resources_.size ();
140
+ for (uint32_t i = offset + 1 ; i < native_execution_async_resources_.size ();
143
141
i++) {
144
142
CHECK (native_execution_async_resources_[i].IsEmpty ());
145
143
}
@@ -167,10 +165,10 @@ void AsyncHooks::clear_async_id_stack() {
167
165
Isolate* isolate = env ()->isolate ();
168
166
HandleScope handle_scope (isolate);
169
167
if (!js_execution_async_resources_.IsEmpty ()) {
170
- USE (PersistentToLocal::Strong (js_execution_async_resources_)-> Set (
171
- env ()->context (),
172
- env ()->length_string (),
173
- Integer::NewFromUnsigned (isolate, 0 )));
168
+ USE (PersistentToLocal::Strong (js_execution_async_resources_)
169
+ -> Set ( env ()->context (),
170
+ env ()->length_string (),
171
+ Integer::NewFromUnsigned (isolate, 0 )));
174
172
}
175
173
native_execution_async_resources_.clear ();
176
174
native_execution_async_resources_.shrink_to_fit ();
@@ -181,19 +179,18 @@ void AsyncHooks::clear_async_id_stack() {
181
179
}
182
180
183
181
void AsyncHooks::AddContext (Local<Context> ctx) {
184
- ctx->SetPromiseHooks (
185
- js_promise_hooks_[0 ].IsEmpty () ?
186
- Local<Function>() :
187
- PersistentToLocal::Strong (js_promise_hooks_[0 ]),
188
- js_promise_hooks_[1 ].IsEmpty () ?
189
- Local<Function>() :
190
- PersistentToLocal::Strong (js_promise_hooks_[1 ]),
191
- js_promise_hooks_[2 ].IsEmpty () ?
192
- Local<Function>() :
193
- PersistentToLocal::Strong (js_promise_hooks_[2 ]),
194
- js_promise_hooks_[3 ].IsEmpty () ?
195
- Local<Function>() :
196
- PersistentToLocal::Strong (js_promise_hooks_[3 ]));
182
+ ctx->SetPromiseHooks (js_promise_hooks_[0 ].IsEmpty ()
183
+ ? Local<Function>()
184
+ : PersistentToLocal::Strong (js_promise_hooks_[0 ]),
185
+ js_promise_hooks_[1 ].IsEmpty ()
186
+ ? Local<Function>()
187
+ : PersistentToLocal::Strong (js_promise_hooks_[1 ]),
188
+ js_promise_hooks_[2 ].IsEmpty ()
189
+ ? Local<Function>()
190
+ : PersistentToLocal::Strong (js_promise_hooks_[2 ]),
191
+ js_promise_hooks_[3 ].IsEmpty ()
192
+ ? Local<Function>()
193
+ : PersistentToLocal::Strong (js_promise_hooks_[3 ]));
197
194
198
195
size_t id = contexts_.size ();
199
196
contexts_.resize (id + 1 );
@@ -209,8 +206,7 @@ void AsyncHooks::RemoveContext(Local<Context> ctx) {
209
206
[&](auto && el) { return el.IsEmpty (); }),
210
207
contexts_.end ());
211
208
for (auto it = contexts_.begin (); it != contexts_.end (); it++) {
212
- Local<Context> saved_context =
213
- PersistentToLocal::Weak (isolate, *it);
209
+ Local<Context> saved_context = PersistentToLocal::Weak (isolate, *it);
214
210
if (saved_context == ctx) {
215
211
it->Reset ();
216
212
contexts_.erase (it);
@@ -227,14 +223,14 @@ AsyncHooks::DefaultTriggerAsyncIdScope::DefaultTriggerAsyncIdScope(
227
223
}
228
224
229
225
old_default_trigger_async_id_ =
230
- async_hooks_->async_id_fields ()[AsyncHooks::kDefaultTriggerAsyncId ];
226
+ async_hooks_->async_id_fields ()[AsyncHooks::kDefaultTriggerAsyncId ];
231
227
async_hooks_->async_id_fields ()[AsyncHooks::kDefaultTriggerAsyncId ] =
232
- default_trigger_async_id;
228
+ default_trigger_async_id;
233
229
}
234
230
235
231
AsyncHooks::DefaultTriggerAsyncIdScope::~DefaultTriggerAsyncIdScope () {
236
232
async_hooks_->async_id_fields ()[AsyncHooks::kDefaultTriggerAsyncId ] =
237
- old_default_trigger_async_id_;
233
+ old_default_trigger_async_id_;
238
234
}
239
235
240
236
AsyncHooks::DefaultTriggerAsyncIdScope::DefaultTriggerAsyncIdScope (
@@ -435,11 +431,11 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() {
435
431
436
432
void Environment::AssignToContext (Local<v8::Context> context,
437
433
const ContextInfo& info) {
438
- context->SetAlignedPointerInEmbedderData (
439
- ContextEmbedderIndex:: kEnvironment , this );
434
+ context->SetAlignedPointerInEmbedderData (ContextEmbedderIndex:: kEnvironment ,
435
+ this );
440
436
// Used by Environment::GetCurrent to know that we are on a node context.
441
- context->SetAlignedPointerInEmbedderData (
442
- ContextEmbedderIndex:: kContextTag , Environment::kNodeContextTagPtr );
437
+ context->SetAlignedPointerInEmbedderData (ContextEmbedderIndex:: kContextTag ,
438
+ Environment::kNodeContextTagPtr );
443
439
// Used to retrieve bindings
444
440
context->SetAlignedPointerInEmbedderData (
445
441
ContextEmbedderIndex::kBindingListIndex , &(this ->bindings_ ));
@@ -452,7 +448,8 @@ void Environment::AssignToContext(Local<v8::Context> context,
452
448
}
453
449
454
450
void Environment::TryLoadAddon (
455
- const char * filename, int flags,
451
+ const char * filename,
452
+ int flags,
456
453
const std::function<bool (binding::DLib*)>& was_loaded) {
457
454
loaded_addons_.emplace_back (filename, flags);
458
455
if (!was_loaded (&loaded_addons_.back ())) {
@@ -485,8 +482,7 @@ void Environment::add_refs(int64_t diff) {
485
482
uv_ref (reinterpret_cast <uv_handle_t *>(&task_queues_async_));
486
483
}
487
484
488
- uv_buf_t Environment::allocate_managed_buffer (
489
- const size_t suggested_size) {
485
+ uv_buf_t Environment::allocate_managed_buffer (const size_t suggested_size) {
490
486
NoArrayBufferZeroFillScope no_zero_fill_scope (isolate_data ());
491
487
std::unique_ptr<v8::BackingStore> bs =
492
488
v8::ArrayBuffer::NewBackingStore (isolate (), suggested_size);
@@ -528,7 +524,8 @@ void Environment::SetMethod(Local<v8::Object> that,
528
524
v8::FunctionCallback callback) {
529
525
Local<v8::Context> context = isolate ()->GetCurrentContext ();
530
526
Local<v8::Function> function =
531
- NewFunctionTemplate (callback, Local<v8::Signature>(),
527
+ NewFunctionTemplate (callback,
528
+ Local<v8::Signature>(),
532
529
v8::ConstructorBehavior::kThrow ,
533
530
v8::SideEffectType::kHasSideEffect )
534
531
->GetFunction (context)
@@ -565,7 +562,8 @@ void Environment::SetMethodNoSideEffect(Local<v8::Object> that,
565
562
v8::FunctionCallback callback) {
566
563
Local<v8::Context> context = isolate ()->GetCurrentContext ();
567
564
Local<v8::Function> function =
568
- NewFunctionTemplate (callback, Local<v8::Signature>(),
565
+ NewFunctionTemplate (callback,
566
+ Local<v8::Signature>(),
569
567
v8::ConstructorBehavior::kThrow ,
570
568
v8::SideEffectType::kHasNoSideEffect )
571
569
->GetFunction (context)
@@ -583,7 +581,9 @@ void Environment::SetProtoMethod(Local<v8::FunctionTemplate> that,
583
581
v8::FunctionCallback callback) {
584
582
Local<v8::Signature> signature = v8::Signature::New (isolate (), that);
585
583
Local<v8::FunctionTemplate> t =
586
- NewFunctionTemplate (callback, signature, v8::ConstructorBehavior::kThrow ,
584
+ NewFunctionTemplate (callback,
585
+ signature,
586
+ v8::ConstructorBehavior::kThrow ,
587
587
v8::SideEffectType::kHasSideEffect );
588
588
// kInternalized strings are created in the old space.
589
589
const v8::NewStringType type = v8::NewStringType::kInternalized ;
@@ -593,13 +593,14 @@ void Environment::SetProtoMethod(Local<v8::FunctionTemplate> that,
593
593
t->SetClassName (name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
594
594
}
595
595
596
- void Environment::SetProtoMethodNoSideEffect (
597
- Local<v8::FunctionTemplate> that,
598
- const char * name,
599
- v8::FunctionCallback callback) {
596
+ void Environment::SetProtoMethodNoSideEffect (Local<v8::FunctionTemplate> that,
597
+ const char * name,
598
+ v8::FunctionCallback callback) {
600
599
Local<v8::Signature> signature = v8::Signature::New (isolate (), that);
601
600
Local<v8::FunctionTemplate> t =
602
- NewFunctionTemplate (callback, signature, v8::ConstructorBehavior::kThrow ,
601
+ NewFunctionTemplate (callback,
602
+ signature,
603
+ v8::ConstructorBehavior::kThrow ,
603
604
v8::SideEffectType::kHasNoSideEffect );
604
605
// kInternalized strings are created in the old space.
605
606
const v8::NewStringType type = v8::NewStringType::kInternalized ;
@@ -614,7 +615,9 @@ void Environment::SetInstanceMethod(Local<v8::FunctionTemplate> that,
614
615
v8::FunctionCallback callback) {
615
616
Local<v8::Signature> signature = v8::Signature::New (isolate (), that);
616
617
Local<v8::FunctionTemplate> t =
617
- NewFunctionTemplate (callback, signature, v8::ConstructorBehavior::kThrow ,
618
+ NewFunctionTemplate (callback,
619
+ signature,
620
+ v8::ConstructorBehavior::kThrow ,
618
621
v8::SideEffectType::kHasSideEffect );
619
622
// kInternalized strings are created in the old space.
620
623
const v8::NewStringType type = v8::NewStringType::kInternalized ;
@@ -637,10 +640,8 @@ void Environment::SetConstructorFunction(Local<v8::Object> that,
637
640
SetConstructorFunctionFlag flag) {
638
641
if (LIKELY (flag == SetConstructorFunctionFlag::SET_CLASS_NAME))
639
642
tmpl->SetClassName (name);
640
- that->Set (
641
- context (),
642
- name,
643
- tmpl->GetFunction (context ()).ToLocalChecked ()).Check ();
643
+ that->Set (context (), name, tmpl->GetFunction (context ()).ToLocalChecked ())
644
+ .Check ();
644
645
}
645
646
646
647
void Environment::CreateProperties () {
@@ -2126,9 +2127,8 @@ BaseObject::BaseObject(Environment* env, Local<Object> object)
2126
2127
: persistent_handle_(env->isolate (), object), env_(env) {
2127
2128
CHECK_EQ (false , object.IsEmpty ());
2128
2129
CHECK_GT (object->InternalFieldCount (), 0 );
2129
- object->SetAlignedPointerInInternalField (
2130
- BaseObject::kSlot ,
2131
- static_cast <void *>(this ));
2130
+ object->SetAlignedPointerInInternalField (BaseObject::kSlot ,
2131
+ static_cast <void *>(this ));
2132
2132
env->AddCleanupHook (DeleteMe, static_cast <void *>(this ));
2133
2133
env->modify_base_object_count (1 );
2134
2134
}
@@ -2141,8 +2141,7 @@ BaseObject::~BaseObject() {
2141
2141
PointerData* metadata = pointer_data ();
2142
2142
CHECK_EQ (metadata->strong_ptr_count , 0 );
2143
2143
metadata->self = nullptr ;
2144
- if (metadata->weak_ptr_count == 0 )
2145
- delete metadata;
2144
+ if (metadata->weak_ptr_count == 0 ) delete metadata;
2146
2145
}
2147
2146
2148
2147
if (persistent_handle_.IsEmpty ()) {
@@ -2174,7 +2173,8 @@ void BaseObject::MakeWeak() {
2174
2173
CHECK_IMPLIES (obj->has_pointer_data (),
2175
2174
obj->pointer_data ()->strong_ptr_count == 0 );
2176
2175
obj->OnGCCollect ();
2177
- }, WeakCallbackType::kParameter );
2176
+ },
2177
+ WeakCallbackType::kParameter );
2178
2178
}
2179
2179
2180
2180
void BaseObject::LazilyInitializedJSTemplateConstructor (
@@ -2184,13 +2184,12 @@ void BaseObject::LazilyInitializedJSTemplateConstructor(
2184
2184
args.This ()->SetAlignedPointerInInternalField (BaseObject::kSlot , nullptr );
2185
2185
}
2186
2186
2187
- Local<FunctionTemplate>
2188
- BaseObject::MakeLazilyInitializedJSTemplate ( Environment* env) {
2187
+ Local<FunctionTemplate> BaseObject::MakeLazilyInitializedJSTemplate (
2188
+ Environment* env) {
2189
2189
Local<FunctionTemplate> t =
2190
2190
env->NewFunctionTemplate (LazilyInitializedJSTemplateConstructor);
2191
2191
t->Inherit (BaseObject::GetConstructorTemplate (env));
2192
- t->InstanceTemplate ()->SetInternalFieldCount (
2193
- BaseObject::kInternalFieldCount );
2192
+ t->InstanceTemplate ()->SetInternalFieldCount (BaseObject::kInternalFieldCount );
2194
2193
return t;
2195
2194
}
2196
2195
0 commit comments