diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-03-11 12:55:59 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-03-28 11:30:55 -0600 |
commit | 41f333e67949dec26cad3cb8c0bcea686164819b (patch) | |
tree | cfed30a17af3c40eb2e19afe309c69a898c2b697 /src | |
parent | 4bc1cccb228fdfd1a527de0ee1d9cedc6dac87e2 (diff) | |
download | android-node-v8-41f333e67949dec26cad3cb8c0bcea686164819b.tar.gz android-node-v8-41f333e67949dec26cad3cb8c0bcea686164819b.tar.bz2 android-node-v8-41f333e67949dec26cad3cb8c0bcea686164819b.zip |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/async-wrap.cc | 7 | ||||
-rw-r--r-- | src/env.cc | 23 | ||||
-rw-r--r-- | src/env.h | 2 | ||||
-rw-r--r-- | src/node.cc | 18 | ||||
-rw-r--r-- | src/node_http_parser.cc | 4 |
5 files changed, 21 insertions, 33 deletions
diff --git a/src/async-wrap.cc b/src/async-wrap.cc index e205403101..dde07aa075 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -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; diff --git a/src/env.cc b/src/env.cc index 75a628face..ea0ab51cfe 100644 --- a/src/env.cc +++ b/src/env.cc @@ -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 @@ -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); diff --git a/src/node.cc b/src/node.cc index 0d059cc43f..ca923585e0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -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()); } diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 0b363ca6c3..12ae9e1443 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -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); } |