@@ -41,10 +41,10 @@ void PerformanceEntry::New(const FunctionCallbackInfo<Value>& args) {
4141
4242void PerformanceEntry::NotifyObservers (Environment* env,
4343 PerformanceEntry* entry) {
44- uint32_t * observers = env->performance_state ()->observers ;
44+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
45+ env->performance_state ()->observers ;
4546 PerformanceEntryType type = ToPerformanceEntryTypeEnum (entry->type ().c_str ());
46- if (observers == nullptr ||
47- type == NODE_PERFORMANCE_ENTRY_TYPE_INVALID ||
47+ if (type == NODE_PERFORMANCE_ENTRY_TYPE_INVALID ||
4848 !observers[type]) {
4949 return ;
5050 }
@@ -88,7 +88,8 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
8888 Utf8Value startMark (isolate, args[1 ]);
8989 Utf8Value endMark (isolate, args[2 ]);
9090
91- double * milestones = env->performance_state ()->milestones ;
91+ AliasedBuffer<double , v8::Float64Array>& milestones =
92+ env->performance_state ()->milestones ;
9293
9394 uint64_t startTimestamp = timeOrigin;
9495 uint64_t start = GetPerformanceMark (env, *startMark);
@@ -155,7 +156,8 @@ void GetPerformanceEntryDuration(const Local<String> prop,
155156void MarkMilestone (const FunctionCallbackInfo<Value>& args) {
156157 Environment* env = Environment::GetCurrent (args);
157158 Local<Context> context = env->context ();
158- double * milestones = env->performance_state ()->milestones ;
159+ AliasedBuffer<double , v8::Float64Array>& milestones =
160+ env->performance_state ()->milestones ;
159161 PerformanceMilestone milestone =
160162 static_cast <PerformanceMilestone>(
161163 args[0 ]->Int32Value (context).ToChecked ());
@@ -182,7 +184,8 @@ void PerformanceGCCallback(uv_async_t* handle) {
182184 Local<Object> obj;
183185 PerformanceGCKind kind = static_cast <PerformanceGCKind>(data->data ());
184186
185- uint32_t * observers = env->performance_state ()->observers ;
187+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
188+ env->performance_state ()->observers ;
186189 if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) {
187190 goto cleanup;
188191 }
@@ -285,8 +288,8 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
285288 args.GetReturnValue ().Set (ret.ToLocalChecked ());
286289 }
287290
288-
289- uint32_t * observers = env->performance_state ()->observers ;
291+ AliasedBuffer< uint32_t , v8::Uint32Array>& observers =
292+ env->performance_state ()->observers ;
290293 if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])
291294 return ;
292295
@@ -319,16 +322,12 @@ void Init(Local<Object> target,
319322 performance_state* state = env->performance_state ();
320323 auto state_ab = ArrayBuffer::New (isolate, state, sizeof (*state));
321324
322- #define SET_STATE_TYPEDARRAY (name, type, field ) \
323- target->Set (context, \
324- FIXED_ONE_BYTE_STRING (isolate, (name)), \
325- type::New (state_ab, \
326- offsetof (performance_state, field), \
327- arraysize (state->field ))) \
328- .FromJust ()
329- SET_STATE_TYPEDARRAY (" observerCounts" , v8::Uint32Array, observers);
330- SET_STATE_TYPEDARRAY (" milestones" , v8::Float64Array, milestones);
331- #undef SET_STATE_TYPEDARRAY
325+ target->Set (context,
326+ FIXED_ONE_BYTE_STRING (isolate, " observerCounts" ),
327+ state->observers .GetJSArray ()).FromJust ();
328+ target->Set (context,
329+ FIXED_ONE_BYTE_STRING (isolate, " milestones" ),
330+ state->milestones .GetJSArray ()).FromJust ();
332331
333332 Local<String> performanceEntryString =
334333 FIXED_ONE_BYTE_STRING (isolate, " PerformanceEntry" );
0 commit comments