@@ -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 ());
@@ -187,7 +189,8 @@ void PerformanceGCCallback(Environment* env, void* ptr) {
187189 HandleScope scope (env->isolate ());
188190 Local<Context> context = env->context ();
189191
190- uint32_t * observers = env->performance_state ()->observers ;
192+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
193+ env->performance_state ()->observers ;
191194 if (observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) {
192195 Local<Object> obj = entry->ToObject ();
193196 v8::PropertyAttribute attr =
@@ -289,8 +292,8 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
289292 args.GetReturnValue ().Set (ret.ToLocalChecked ());
290293 }
291294
292-
293- uint32_t * observers = env->performance_state ()->observers ;
295+ AliasedBuffer< uint32_t , v8::Uint32Array>& observers =
296+ env->performance_state ()->observers ;
294297 if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])
295298 return ;
296299
@@ -323,16 +326,12 @@ void Init(Local<Object> target,
323326 performance_state* state = env->performance_state ();
324327 auto state_ab = ArrayBuffer::New (isolate, state, sizeof (*state));
325328
326- #define SET_STATE_TYPEDARRAY (name, type, field ) \
327- target->Set (context, \
328- FIXED_ONE_BYTE_STRING (isolate, (name)), \
329- type::New (state_ab, \
330- offsetof (performance_state, field), \
331- arraysize (state->field ))) \
332- .FromJust ()
333- SET_STATE_TYPEDARRAY (" observerCounts" , v8::Uint32Array, observers);
334- SET_STATE_TYPEDARRAY (" milestones" , v8::Float64Array, milestones);
335- #undef SET_STATE_TYPEDARRAY
329+ target->Set (context,
330+ FIXED_ONE_BYTE_STRING (isolate, " observerCounts" ),
331+ state->observers .GetJSArray ()).FromJust ();
332+ target->Set (context,
333+ FIXED_ONE_BYTE_STRING (isolate, " milestones" ),
334+ state->milestones .GetJSArray ()).FromJust ();
336335
337336 Local<String> performanceEntryString =
338337 FIXED_ONE_BYTE_STRING (isolate, " PerformanceEntry" );
0 commit comments