Skip to content

Commit f1488bb

Browse files
trevnorrisevanlucas
authored andcommitted
src,http_parser: remove KickNextTick call
Now that HTTPParser uses MakeCallback it is unnecessary to manually process the nextTickQueue. The KickNextTick function is now no longer needed so code has moved back to node::MakeCallback to simplify implementation. Include minor cleanup moving Environment::tick_info() call below the early return to save an operation. PR-URL: #5756 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
1 parent 8fa0b5c commit f1488bb

File tree

5 files changed

+21
-33
lines changed

5 files changed

+21
-33
lines changed

src/async-wrap.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
181181
Local<Function> post_fn = env()->async_hooks_post_function();
182182
Local<Value> uid = Integer::New(env()->isolate(), get_uid());
183183
Local<Object> context = object();
184-
Local<Object> process = env()->process_object();
185184
Local<Object> domain;
186185
bool has_domain = false;
187186

@@ -233,16 +232,18 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
233232
}
234233
}
235234

236-
Environment::TickInfo* tick_info = env()->tick_info();
237-
238235
if (callback_scope.in_makecallback()) {
239236
return ret;
240237
}
241238

239+
Environment::TickInfo* tick_info = env()->tick_info();
240+
242241
if (tick_info->length() == 0) {
243242
env()->isolate()->RunMicrotasks();
244243
}
245244

245+
Local<Object> process = env()->process_object();
246+
246247
if (tick_info->length() == 0) {
247248
tick_info->set_index(0);
248249
return ret;

src/env.cc

-23
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,4 @@ void Environment::PrintSyncTrace() const {
6464
fflush(stderr);
6565
}
6666

67-
68-
bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) {
69-
TickInfo* info = tick_info();
70-
71-
if (scope->in_makecallback()) {
72-
return true;
73-
}
74-
75-
if (info->length() == 0) {
76-
isolate()->RunMicrotasks();
77-
}
78-
79-
if (info->length() == 0) {
80-
info->set_index(0);
81-
return true;
82-
}
83-
84-
Local<Value> ret =
85-
tick_callback_function()->Call(process_object(), 0, nullptr);
86-
87-
return !ret.IsEmpty();
88-
}
89-
9067
} // namespace node

src/env.h

-2
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,6 @@ class Environment {
467467

468468
inline int64_t get_async_wrap_uid();
469469

470-
bool KickNextTick(AsyncCallbackScope* scope);
471-
472470
inline uint32_t* heap_statistics_buffer() const;
473471
inline void set_heap_statistics_buffer(uint32_t* pointer);
474472

src/node.cc

+17-1
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,23 @@ Local<Value> MakeCallback(Environment* env,
12041204
}
12051205
}
12061206

1207-
if (!env->KickNextTick(&callback_scope)) {
1207+
if (callback_scope.in_makecallback()) {
1208+
return ret;
1209+
}
1210+
1211+
Environment::TickInfo* tick_info = env->tick_info();
1212+
1213+
if (tick_info->length() == 0) {
1214+
env->isolate()->RunMicrotasks();
1215+
}
1216+
1217+
Local<Object> process = env->process_object();
1218+
1219+
if (tick_info->length() == 0) {
1220+
tick_info->set_index(0);
1221+
}
1222+
1223+
if (env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) {
12081224
return Undefined(env->isolate());
12091225
}
12101226

src/node_http_parser.cc

-4
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,6 @@ class Parser : public AsyncWrap {
587587
if (!cb->IsFunction())
588588
return;
589589

590-
Environment::AsyncCallbackScope callback_scope(parser->env());
591-
592590
// Hooks for GetCurrentBuffer
593591
parser->current_buffer_len_ = nread;
594592
parser->current_buffer_data_ = buf->base;
@@ -597,8 +595,6 @@ class Parser : public AsyncWrap {
597595

598596
parser->current_buffer_len_ = 0;
599597
parser->current_buffer_data_ = nullptr;
600-
601-
parser->env()->KickNextTick(&callback_scope);
602598
}
603599

604600

0 commit comments

Comments
 (0)