@@ -85,9 +85,9 @@ void PerformanceEntry::Notify(Environment* env,
85
85
PerformanceEntryType type,
86
86
Local<Value> object) {
87
87
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 &&
91
91
observers[type]) {
92
92
node::MakeCallback (env->isolate (),
93
93
env->process_object (),
@@ -130,7 +130,8 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
130
130
Utf8Value startMark (env->isolate (), args[1 ]);
131
131
Utf8Value endMark (env->isolate (), args[2 ]);
132
132
133
- double * milestones = env->performance_state ()->milestones ;
133
+ AliasedBuffer<double , v8::Float64Array>& milestones =
134
+ env->performance_state ()->milestones ;
134
135
135
136
uint64_t startTimestamp = timeOrigin;
136
137
uint64_t start = GetPerformanceMark (env, *startMark);
@@ -165,7 +166,8 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
165
166
void MarkMilestone (const FunctionCallbackInfo<Value>& args) {
166
167
Environment* env = Environment::GetCurrent (args);
167
168
Local<Context> context = env->context ();
168
- double * milestones = env->performance_state ()->milestones ;
169
+ AliasedBuffer<double , v8::Float64Array>& milestones =
170
+ env->performance_state ()->milestones ;
169
171
PerformanceMilestone milestone =
170
172
static_cast <PerformanceMilestone>(
171
173
args[0 ]->Int32Value (context).ToChecked ());
@@ -188,7 +190,8 @@ void PerformanceGCCallback(uv_async_t* handle) {
188
190
HandleScope scope (env->isolate ());
189
191
Local<Context> context = env->context ();
190
192
191
- uint32_t * observers = env->performance_state ()->observers ;
193
+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
194
+ env->performance_state ()->observers ;
192
195
if (observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) {
193
196
Local<Object> obj = entry->ToObject ();
194
197
v8::PropertyAttribute attr =
@@ -297,8 +300,8 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
297
300
args.GetReturnValue ().Set (ret.ToLocalChecked ());
298
301
}
299
302
300
-
301
- uint32_t * observers = env->performance_state ()->observers ;
303
+ AliasedBuffer< uint32_t , v8::Uint32Array>& observers =
304
+ env->performance_state ()->observers ;
302
305
if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])
303
306
return ;
304
307
@@ -331,16 +334,12 @@ void Init(Local<Object> target,
331
334
performance_state* state = env->performance_state ();
332
335
auto state_ab = ArrayBuffer::New (isolate, state, sizeof (*state));
333
336
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 ();
344
343
345
344
Local<String> performanceEntryString =
346
345
FIXED_ONE_BYTE_STRING (isolate, " PerformanceEntry" );
0 commit comments