Skip to content

Commit

Permalink
src,http_parser: remove KickNextTick call
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
trevnorris authored and Myles Borins committed Jun 24, 2016
1 parent 76cea4f commit 057ab03
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 33 deletions.
7 changes: 4 additions & 3 deletions src/async-wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
23 changes: 0 additions & 23 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,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
2 changes: 0 additions & 2 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,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);

Expand Down
18 changes: 17 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,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());
}

Expand Down
4 changes: 0 additions & 4 deletions src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,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;
Expand All @@ -598,8 +596,6 @@ class Parser : public AsyncWrap {

parser->current_buffer_len_ = 0;
parser->current_buffer_data_ = nullptr;

parser->env()->KickNextTick(&callback_scope);
}


Expand Down

0 comments on commit 057ab03

Please sign in to comment.