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: https://github.com/nodejs/node/pull/5756
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
This commit is contained in:
Trevor Norris 2016-03-11 12:55:59 -07:00
parent 4bc1cccb22
commit 41f333e679
5 changed files with 21 additions and 33 deletions

View File

@ -181,7 +181,6 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
Local<Function> post_fn = env()->async_hooks_post_function();
Local<Value> uid = Integer::New(env()->isolate(), get_uid());
Local<Object> context = object();
Local<Object> process = env()->process_object();
Local<Object> domain;
bool has_domain = false;
@ -233,16 +232,18 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
}
}
Environment::TickInfo* tick_info = env()->tick_info();
if (callback_scope.in_makecallback()) {
return ret;
}
Environment::TickInfo* tick_info = env()->tick_info();
if (tick_info->length() == 0) {
env()->isolate()->RunMicrotasks();
}
Local<Object> process = env()->process_object();
if (tick_info->length() == 0) {
tick_info->set_index(0);
return ret;

View File

@ -64,27 +64,4 @@ void Environment::PrintSyncTrace() const {
fflush(stderr);
}
bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) {
TickInfo* info = tick_info();
if (scope->in_makecallback()) {
return true;
}
if (info->length() == 0) {
isolate()->RunMicrotasks();
}
if (info->length() == 0) {
info->set_index(0);
return true;
}
Local<Value> ret =
tick_callback_function()->Call(process_object(), 0, nullptr);
return !ret.IsEmpty();
}
} // namespace node

View File

@ -475,8 +475,6 @@ class Environment {
inline int64_t get_async_wrap_uid();
bool KickNextTick(AsyncCallbackScope* scope);
inline uint32_t* heap_statistics_buffer() const;
inline void set_heap_statistics_buffer(uint32_t* pointer);

View File

@ -1222,7 +1222,23 @@ Local<Value> MakeCallback(Environment* env,
}
}
if (!env->KickNextTick(&callback_scope)) {
if (callback_scope.in_makecallback()) {
return ret;
}
Environment::TickInfo* tick_info = env->tick_info();
if (tick_info->length() == 0) {
env->isolate()->RunMicrotasks();
}
Local<Object> process = env->process_object();
if (tick_info->length() == 0) {
tick_info->set_index(0);
}
if (env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) {
return Undefined(env->isolate());
}

View File

@ -587,8 +587,6 @@ class Parser : public AsyncWrap {
if (!cb->IsFunction())
return;
Environment::AsyncCallbackScope callback_scope(parser->env());
// Hooks for GetCurrentBuffer
parser->current_buffer_len_ = nread;
parser->current_buffer_data_ = buf->base;
@ -597,8 +595,6 @@ class Parser : public AsyncWrap {
parser->current_buffer_len_ = 0;
parser->current_buffer_data_ = nullptr;
parser->env()->KickNextTick(&callback_scope);
}