@@ -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 ());
@@ -187,7 +189,8 @@ void PerformanceGCCallback(Environment* env, void* ptr) {
187
189
HandleScope scope (env->isolate ());
188
190
Local<Context> context = env->context ();
189
191
190
- uint32_t * observers = env->performance_state ()->observers ;
192
+ AliasedBuffer<uint32_t , v8::Uint32Array>& observers =
193
+ env->performance_state ()->observers ;
191
194
if (observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) {
192
195
Local<Object> obj = entry->ToObject ();
193
196
v8::PropertyAttribute attr =
@@ -289,8 +292,8 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
289
292
args.GetReturnValue ().Set (ret.ToLocalChecked ());
290
293
}
291
294
292
-
293
- uint32_t * observers = env->performance_state ()->observers ;
295
+ AliasedBuffer< uint32_t , v8::Uint32Array>& observers =
296
+ env->performance_state ()->observers ;
294
297
if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])
295
298
return ;
296
299
@@ -323,16 +326,12 @@ void Init(Local<Object> target,
323
326
performance_state* state = env->performance_state ();
324
327
auto state_ab = ArrayBuffer::New (isolate, state, sizeof (*state));
325
328
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 ();
336
335
337
336
Local<String> performanceEntryString =
338
337
FIXED_ONE_BYTE_STRING (isolate, " PerformanceEntry" );
0 commit comments