summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2019-01-18 15:31:46 +0100
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-02-11 08:50:07 +0100
commit9af04ad684a666888f76024876d7b74eee60d2f7 (patch)
tree90ce38c03c30b1331070c01c97599a14f7f303bd /src
parentfcaeb1f1221c7c4296d44136b2f81d8f6e0db92d (diff)
downloadandroid-node-v8-9af04ad684a666888f76024876d7b74eee60d2f7.tar.gz
android-node-v8-9af04ad684a666888f76024876d7b74eee60d2f7.tar.bz2
android-node-v8-9af04ad684a666888f76024876d7b74eee60d2f7.zip
http2: improve compat performance
This bunch of commits help me improve the performance of a http2 server by 8-10%. The benchmarks reports several 1-2% improvements in various areas. PR-URL: https://github.com/nodejs/node/pull/25567 Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/stream_wrap.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc
index e957cb1725..d126f90eef 100644
--- a/src/stream_wrap.cc
+++ b/src/stream_wrap.cc
@@ -64,11 +64,29 @@ void LibuvStreamWrap::Initialize(Local<Object> target,
};
Local<FunctionTemplate> sw =
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
- sw->InstanceTemplate()->SetInternalFieldCount(StreamReq::kStreamReqField + 1);
+ sw->InstanceTemplate()->SetInternalFieldCount(
+ StreamReq::kStreamReqField + 1 + 3);
Local<String> wrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap");
sw->SetClassName(wrapString);
+
+ // we need to set handle and callback to null,
+ // so that those fields are created and functions
+ // do not become megamorphic
+ // Fields:
+ // - oncomplete
+ // - callback
+ // - handle
+ sw->InstanceTemplate()->Set(
+ FIXED_ONE_BYTE_STRING(env->isolate(), "oncomplete"),
+ v8::Null(env->isolate()));
+ sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "callback"),
+ v8::Null(env->isolate()));
+ sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "handle"),
+ v8::Null(env->isolate()));
+
sw->Inherit(AsyncWrap::GetConstructorTemplate(env));
+
target->Set(env->context(),
wrapString,
sw->GetFunction(env->context()).ToLocalChecked()).FromJust();