@@ -41,10 +41,10 @@ void PerformanceEntry::New(const FunctionCallbackInfo<Value>& args) {
41
41
42
42
void PerformanceEntry::NotifyObservers (Environment* env,
43
43
PerformanceEntry* entry) {
44
- uint32_t * observers = env->performance_state ()->observers ;
44
+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
45
+ env->performance_state ()->observers ;
45
46
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 ||
48
48
!observers[type]) {
49
49
return ;
50
50
}
@@ -88,7 +88,8 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
88
88
Utf8Value startMark (isolate, args[1 ]);
89
89
Utf8Value endMark (isolate, args[2 ]);
90
90
91
- double * milestones = env->performance_state ()->milestones ;
91
+ AliasedBuffer<double , v8::Float64Array>& milestones =
92
+ env->performance_state ()->milestones ;
92
93
93
94
uint64_t startTimestamp = timeOrigin;
94
95
uint64_t start = GetPerformanceMark (env, *startMark);
@@ -155,7 +156,8 @@ void GetPerformanceEntryDuration(const Local<String> prop,
155
156
void MarkMilestone (const FunctionCallbackInfo<Value>& args) {
156
157
Environment* env = Environment::GetCurrent (args);
157
158
Local<Context> context = env->context ();
158
- double * milestones = env->performance_state ()->milestones ;
159
+ AliasedBuffer<double , v8::Float64Array>& milestones =
160
+ env->performance_state ()->milestones ;
159
161
PerformanceMilestone milestone =
160
162
static_cast <PerformanceMilestone>(
161
163
args[0 ]->Int32Value (context).ToChecked ());
@@ -182,7 +184,8 @@ void PerformanceGCCallback(uv_async_t* handle) {
182
184
Local<Object> obj;
183
185
PerformanceGCKind kind = static_cast <PerformanceGCKind>(data->data ());
184
186
185
- uint32_t * observers = env->performance_state ()->observers ;
187
+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
188
+ env->performance_state ()->observers ;
186
189
if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) {
187
190
goto cleanup;
188
191
}
@@ -285,8 +288,8 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
285
288
args.GetReturnValue ().Set (ret.ToLocalChecked ());
286
289
}
287
290
288
-
289
- uint32_t * observers = env->performance_state ()->observers ;
291
+ AliasedBuffer< uint32_t , v8::Uint32Array>& observers =
292
+ env->performance_state ()->observers ;
290
293
if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])
291
294
return ;
292
295
@@ -319,16 +322,12 @@ void Init(Local<Object> target,
319
322
performance_state* state = env->performance_state ();
320
323
auto state_ab = ArrayBuffer::New (isolate, state, sizeof (*state));
321
324
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 ();
332
331
333
332
Local<String> performanceEntryString =
334
333
FIXED_ONE_BYTE_STRING (isolate, " PerformanceEntry" );
0 commit comments