Skip to content

Commit 6084a7c

Browse files
trevnorrisMyles Borins
authored and
Myles Borins
committed
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. Ref: #7048 PR-URL: #5756 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
1 parent 534e199 commit 6084a7c

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
@@ -57,27 +57,4 @@ void Environment::PrintSyncTrace() const {
5757
fflush(stderr);
5858
}
5959

60-
61-
bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) {
62-
TickInfo* info = tick_info();
63-
64-
if (scope->in_makecallback()) {
65-
return true;
66-
}
67-
68-
if (info->length() == 0) {
69-
isolate()->RunMicrotasks();
70-
}
71-
72-
if (info->length() == 0) {
73-
info->set_index(0);
74-
return true;
75-
}
76-
77-
Local<Value> ret =
78-
tick_callback_function()->Call(process_object(), 0, nullptr);
79-
80-
return !ret.IsEmpty();
81-
}
82-
8360
} // namespace node

src/env.h

-2
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,6 @@ class Environment {
453453

454454
inline int64_t get_async_wrap_uid();
455455

456-
bool KickNextTick(AsyncCallbackScope* scope);
457-
458456
inline uint32_t* heap_statistics_buffer() const;
459457
inline void set_heap_statistics_buffer(uint32_t* pointer);
460458

src/node.cc

+17-1
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,23 @@ Local<Value> MakeCallback(Environment* env,
11941194
}
11951195
}
11961196

1197-
if (!env->KickNextTick(&callback_scope)) {
1197+
if (callback_scope.in_makecallback()) {
1198+
return ret;
1199+
}
1200+
1201+
Environment::TickInfo* tick_info = env->tick_info();
1202+
1203+
if (tick_info->length() == 0) {
1204+
env->isolate()->RunMicrotasks();
1205+
}
1206+
1207+
Local<Object> process = env->process_object();
1208+
1209+
if (tick_info->length() == 0) {
1210+
tick_info->set_index(0);
1211+
}
1212+
1213+
if (env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) {
11981214
return Undefined(env->isolate());
11991215
}
12001216

src/node_http_parser.cc

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

591-
Environment::AsyncCallbackScope callback_scope(parser->env());
592-
593591
// Hooks for GetCurrentBuffer
594592
parser->current_buffer_len_ = nread;
595593
parser->current_buffer_data_ = buf->base;
@@ -598,8 +596,6 @@ class Parser : public AsyncWrap {
598596

599597
parser->current_buffer_len_ = 0;
600598
parser->current_buffer_data_ = nullptr;
601-
602-
parser->env()->KickNextTick(&callback_scope);
603599
}
604600

605601

0 commit comments

Comments
 (0)