@@ -85,9 +85,9 @@ void PerformanceEntry::Notify(Environment* env,
8585 PerformanceEntryType type,
8686 Local<Value> object) {
8787 Context::Scope scope (env->context ());
88- uint32_t * observers = env-> performance_state ()-> observers ;
89- if (observers != nullptr &&
90- type != NODE_PERFORMANCE_ENTRY_TYPE_INVALID &&
88+ AliasedBuffer< uint32_t , v8::Uint32Array>& observers =
89+ env-> performance_state ()-> observers ;
90+ if ( type != NODE_PERFORMANCE_ENTRY_TYPE_INVALID &&
9191 observers[type]) {
9292 node::MakeCallback (env->isolate (),
9393 env->process_object (),
@@ -130,7 +130,8 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
130130 Utf8Value startMark (env->isolate (), args[1 ]);
131131 Utf8Value endMark (env->isolate (), args[2 ]);
132132
133- double * milestones = env->performance_state ()->milestones ;
133+ AliasedBuffer<double , v8::Float64Array>& milestones =
134+ env->performance_state ()->milestones ;
134135
135136 uint64_t startTimestamp = timeOrigin;
136137 uint64_t start = GetPerformanceMark (env, *startMark);
@@ -165,7 +166,8 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
165166void MarkMilestone (const FunctionCallbackInfo<Value>& args) {
166167 Environment* env = Environment::GetCurrent (args);
167168 Local<Context> context = env->context ();
168- double * milestones = env->performance_state ()->milestones ;
169+ AliasedBuffer<double , v8::Float64Array>& milestones =
170+ env->performance_state ()->milestones ;
169171 PerformanceMilestone milestone =
170172 static_cast <PerformanceMilestone>(
171173 args[0 ]->Int32Value (context).ToChecked ());
@@ -188,7 +190,8 @@ void PerformanceGCCallback(uv_async_t* handle) {
188190 HandleScope scope (env->isolate ());
189191 Local<Context> context = env->context ();
190192
191- uint32_t * observers = env->performance_state ()->observers ;
193+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
194+ env->performance_state ()->observers ;
192195 if (observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) {
193196 Local<Object> obj = entry->ToObject ();
194197 v8::PropertyAttribute attr =
@@ -297,8 +300,8 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
297300 args.GetReturnValue ().Set (ret.ToLocalChecked ());
298301 }
299302
300-
301- uint32_t * observers = env->performance_state ()->observers ;
303+ AliasedBuffer< uint32_t , v8::Uint32Array>& observers =
304+ env->performance_state ()->observers ;
302305 if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])
303306 return ;
304307
@@ -331,16 +334,12 @@ void Init(Local<Object> target,
331334 performance_state* state = env->performance_state ();
332335 auto state_ab = ArrayBuffer::New (isolate, state, sizeof (*state));
333336
334- #define SET_STATE_TYPEDARRAY (name, type, field ) \
335- target->Set (context, \
336- FIXED_ONE_BYTE_STRING (isolate, (name)), \
337- type::New (state_ab, \
338- offsetof (performance_state, field), \
339- arraysize (state->field ))) \
340- .FromJust ()
341- SET_STATE_TYPEDARRAY (" observerCounts" , v8::Uint32Array, observers);
342- SET_STATE_TYPEDARRAY (" milestones" , v8::Float64Array, milestones);
343- #undef SET_STATE_TYPEDARRAY
337+ target->Set (context,
338+ FIXED_ONE_BYTE_STRING (isolate, " observerCounts" ),
339+ state->observers .GetJSArray ()).FromJust ();
340+ target->Set (context,
341+ FIXED_ONE_BYTE_STRING (isolate, " milestones" ),
342+ state->milestones .GetJSArray ()).FromJust ();
344343
345344 Local<String> performanceEntryString =
346345 FIXED_ONE_BYTE_STRING (isolate, " PerformanceEntry" );
0 commit comments