From be2cbccf003d110cad00317090072788021efa56 Mon Sep 17 00:00:00 2001 From: Kyle Farnung Date: Mon, 22 Jan 2018 11:43:35 -0800 Subject: http2,perf_hooks: perf state using AliasedBuffer Update performance_state to use AliasedBuffer and update usage sites. PR-URL: https://github.com/nodejs/node/pull/18300 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- src/node_perf_common.h | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/node_perf_common.h') diff --git a/src/node_perf_common.h b/src/node_perf_common.h index 713f126d7f7..435a4cffe5a 100644 --- a/src/node_perf_common.h +++ b/src/node_perf_common.h @@ -61,10 +61,33 @@ enum PerformanceEntryType { node::performance::NODE_PERFORMANCE_MILESTONE_##n); \ } while (0); -struct performance_state { - // doubles first so that they are always sizeof(double)-aligned - double milestones[NODE_PERFORMANCE_MILESTONE_INVALID]; - uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID]; +class performance_state { + public: + explicit performance_state(v8::Isolate* isolate) : + root( + isolate, + sizeof(performance_state_internal)), + milestones( + isolate, + offsetof(performance_state_internal, milestones), + NODE_PERFORMANCE_MILESTONE_INVALID, + root), + observers( + isolate, + offsetof(performance_state_internal, observers), + NODE_PERFORMANCE_ENTRY_TYPE_INVALID, + root) {} + + AliasedBuffer root; + AliasedBuffer milestones; + AliasedBuffer observers; + + private: + struct performance_state_internal { + // doubles first so that they are always sizeof(double)-aligned + double milestones[NODE_PERFORMANCE_MILESTONE_INVALID]; + uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID]; + }; }; } // namespace performance -- cgit v1.2.3