GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_process_methods.cc Lines: 259 278 93.2 %
Date: 2021-05-28 04:11:57 Branches: 61 90 67.8 %

Line Branch Exec Source
1
#include "base_object-inl.h"
2
#include "debug_utils-inl.h"
3
#include "env-inl.h"
4
#include "memory_tracker-inl.h"
5
#include "node.h"
6
#include "node_errors.h"
7
#include "node_external_reference.h"
8
#include "node_internals.h"
9
#include "node_process-inl.h"
10
#include "util-inl.h"
11
#include "uv.h"
12
#include "v8-fast-api-calls.h"
13
#include "v8.h"
14
15
#include <vector>
16
17
#if HAVE_INSPECTOR
18
#include "inspector_io.h"
19
#endif
20
21
#include <climits>  // PATH_MAX
22
#include <cstdio>
23
24
#if defined(_MSC_VER)
25
#include <direct.h>
26
#include <io.h>
27
#define umask _umask
28
typedef int mode_t;
29
#else
30
#include <pthread.h>
31
#include <sys/resource.h>  // getrlimit, setrlimit
32
#include <termios.h>  // tcgetattr, tcsetattr
33
#endif
34
35
namespace node {
36
37
using v8::ApiObject;
38
using v8::Array;
39
using v8::ArrayBuffer;
40
using v8::BackingStore;
41
using v8::CFunction;
42
using v8::ConstructorBehavior;
43
using v8::Context;
44
using v8::Float64Array;
45
using v8::FunctionCallbackInfo;
46
using v8::FunctionTemplate;
47
using v8::Global;
48
using v8::HeapStatistics;
49
using v8::Integer;
50
using v8::Isolate;
51
using v8::Local;
52
using v8::NewStringType;
53
using v8::Number;
54
using v8::Object;
55
using v8::ObjectTemplate;
56
using v8::SideEffectType;
57
using v8::Signature;
58
using v8::String;
59
using v8::Uint32;
60
using v8::Value;
61
62
namespace per_process {
63
4840
Mutex umask_mutex;
64
}   // namespace per_process
65
66
// Microseconds in a second, as a float, used in CPUUsage() below
67
#define MICROS_PER_SEC 1e6
68
// used in Hrtime() and Uptime() below
69
#define NANOS_PER_SEC 1000000000
70
71
static void Abort(const FunctionCallbackInfo<Value>& args) {
72
  Abort();
73
}
74
75
// For internal testing only, not exposed to userland.
76
static void CauseSegfault(const FunctionCallbackInfo<Value>& args) {
77
  // This should crash hard all platforms.
78
  volatile void** d = static_cast<volatile void**>(nullptr);
79
  *d = nullptr;
80
}
81
82
451
static void Chdir(const FunctionCallbackInfo<Value>& args) {
83
451
  Environment* env = Environment::GetCurrent(args);
84
451
  CHECK(env->owns_process_state());
85
86
451
  CHECK_EQ(args.Length(), 1);
87
1353
  CHECK(args[0]->IsString());
88
901
  Utf8Value path(env->isolate(), args[0]);
89
451
  int err = uv_chdir(*path);
90
451
  if (err) {
91
    // Also include the original working directory, since that will usually
92
    // be helpful information when debugging a `chdir()` failure.
93
    char buf[PATH_MAX_BYTES];
94
1
    size_t cwd_len = sizeof(buf);
95
1
    uv_cwd(buf, &cwd_len);
96
1
    return env->ThrowUVException(err, "chdir", nullptr, buf, *path);
97
  }
98
}
99
100
556
inline Local<ArrayBuffer> get_fields_array_buffer(
101
    const FunctionCallbackInfo<Value>& args,
102
    size_t index,
103
    size_t array_length) {
104
1668
  CHECK(args[index]->IsFloat64Array());
105
1668
  Local<Float64Array> arr = args[index].As<Float64Array>();
106
556
  CHECK_EQ(arr->Length(), array_length);
107
556
  return arr->Buffer();
108
}
109
110
// CPUUsage use libuv's uv_getrusage() this-process resource usage accessor,
111
// to access ru_utime (user CPU time used) and ru_stime (system CPU time used),
112
// which are uv_timeval_t structs (long tv_sec, long tv_usec).
113
// Returns those values as Float64 microseconds in the elements of the array
114
// passed to the function.
115
33
static void CPUUsage(const FunctionCallbackInfo<Value>& args) {
116
33
  Environment* env = Environment::GetCurrent(args);
117
  uv_rusage_t rusage;
118
119
  // Call libuv to get the values we'll return.
120
33
  int err = uv_getrusage(&rusage);
121
33
  if (err)
122
    return env->ThrowUVException(err, "uv_getrusage");
123
124
  // Get the double array pointer from the Float64Array argument.
125
33
  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 2);
126
33
  double* fields = static_cast<double*>(ab->GetBackingStore()->Data());
127
128
  // Set the Float64Array elements to be user / system values in microseconds.
129
33
  fields[0] = MICROS_PER_SEC * rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec;
130
33
  fields[1] = MICROS_PER_SEC * rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec;
131
}
132
133
5740
static void Cwd(const FunctionCallbackInfo<Value>& args) {
134
5740
  Environment* env = Environment::GetCurrent(args);
135
5740
  CHECK(env->has_run_bootstrapping_code());
136
  char buf[PATH_MAX_BYTES];
137
5740
  size_t cwd_len = sizeof(buf);
138
5740
  int err = uv_cwd(buf, &cwd_len);
139
5740
  if (err)
140
13
    return env->ThrowUVException(err, "uv_cwd");
141
142
11454
  Local<String> cwd = String::NewFromUtf8(env->isolate(),
143
                                          buf,
144
                                          NewStringType::kNormal,
145
11454
                                          cwd_len).ToLocalChecked();
146
11454
  args.GetReturnValue().Set(cwd);
147
}
148
149
61
static void Kill(const FunctionCallbackInfo<Value>& args) {
150
61
  Environment* env = Environment::GetCurrent(args);
151
61
  Local<Context> context = env->context();
152
153
61
  if (args.Length() < 2) {
154
    THROW_ERR_MISSING_ARGS(env, "Bad argument.");
155
  }
156
157
  int pid;
158
183
  if (!args[0]->Int32Value(context).To(&pid)) return;
159
  int sig;
160
183
  if (!args[1]->Int32Value(context).To(&sig)) return;
161
162
61
  uv_pid_t own_pid = uv_os_getpid();
163

181
  if (sig > 0 &&
164


147
      (pid == 0 || pid == -1 || pid == own_pid || pid == -own_pid) &&
165
28
      !HasSignalJSHandler(sig)) {
166
    // This is most likely going to terminate this process.
167
    // It's not an exact method but it might be close enough.
168
19
    RunAtExit(env);
169
  }
170
171
61
  int err = uv_kill(pid, sig);
172
122
  args.GetReturnValue().Set(err);
173
}
174
175
4
static void Rss(const FunctionCallbackInfo<Value>& args) {
176
4
  Environment* env = Environment::GetCurrent(args);
177
178
  size_t rss;
179
4
  int err = uv_resident_set_memory(&rss);
180
4
  if (err)
181
    return env->ThrowUVException(err, "uv_resident_set_memory");
182
183
12
  args.GetReturnValue().Set(static_cast<double>(rss));
184
}
185
186
522
static void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
187
522
  Environment* env = Environment::GetCurrent(args);
188
189
522
  Isolate* isolate = env->isolate();
190
  // V8 memory usage
191
522
  HeapStatistics v8_heap_stats;
192
522
  isolate->GetHeapStatistics(&v8_heap_stats);
193
194
  NodeArrayBufferAllocator* array_buffer_allocator =
195
522
      env->isolate_data()->node_allocator();
196
197
  // Get the double array pointer from the Float64Array argument.
198
522
  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 5);
199
522
  double* fields = static_cast<double*>(ab->GetBackingStore()->Data());
200
201
  size_t rss;
202
522
  int err = uv_resident_set_memory(&rss);
203
522
  if (err)
204
    return env->ThrowUVException(err, "uv_resident_set_memory");
205
206
522
  fields[0] = static_cast<double>(rss);
207
522
  fields[1] = static_cast<double>(v8_heap_stats.total_heap_size());
208
522
  fields[2] = static_cast<double>(v8_heap_stats.used_heap_size());
209
522
  fields[3] = static_cast<double>(v8_heap_stats.external_memory());
210
1044
  fields[4] =
211
      array_buffer_allocator == nullptr
212
1044
          ? 0
213
522
          : static_cast<double>(array_buffer_allocator->total_mem_usage());
214
}
215
216
22
void RawDebug(const FunctionCallbackInfo<Value>& args) {
217


88
  CHECK(args.Length() == 1 && args[0]->IsString() &&
218
        "must be called with a single string");
219
44
  Utf8Value message(args.GetIsolate(), args[0]);
220
22
  FPrintF(stderr, "%s\n", message);
221
22
  fflush(stderr);
222
22
}
223
224
4013
static void Umask(const FunctionCallbackInfo<Value>& args) {
225
4013
  Environment* env = Environment::GetCurrent(args);
226
4013
  CHECK(env->has_run_bootstrapping_code());
227
4013
  CHECK_EQ(args.Length(), 1);
228

20049
  CHECK(args[0]->IsUndefined() || args[0]->IsUint32());
229
8026
  Mutex::ScopedLock scoped_lock(per_process::umask_mutex);
230
231
  uint32_t old;
232
12039
  if (args[0]->IsUndefined()) {
233
8
    old = umask(0);
234
8
    umask(static_cast<mode_t>(old));
235
  } else {
236
12015
    int oct = args[0].As<Uint32>()->Value();
237
4005
    old = umask(static_cast<mode_t>(oct));
238
  }
239
240
8026
  args.GetReturnValue().Set(old);
241
4013
}
242
243
4
static void Uptime(const FunctionCallbackInfo<Value>& args) {
244
4
  Environment* env = Environment::GetCurrent(args);
245
246
4
  uv_update_time(env->event_loop());
247
  double uptime =
248
4
      static_cast<double>(uv_hrtime() - per_process::node_start_time);
249
4
  Local<Number> result = Number::New(env->isolate(), uptime / NANOS_PER_SEC);
250
8
  args.GetReturnValue().Set(result);
251
4
}
252
253
2
static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
254
2
  Environment* env = Environment::GetCurrent(args);
255
256
4
  std::vector<Local<Value>> request_v;
257
14
  for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
258
12
    AsyncWrap* w = req_wrap->GetAsyncWrap();
259
24
    if (w->persistent().IsEmpty())
260
      continue;
261
12
    request_v.emplace_back(w->GetOwner());
262
  }
263
264
6
  args.GetReturnValue().Set(
265
      Array::New(env->isolate(), request_v.data(), request_v.size()));
266
2
}
267
268
// Non-static, friend of HandleWrap. Could have been a HandleWrap method but
269
// implemented here for consistency with GetActiveRequests().
270
5
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
271
5
  Environment* env = Environment::GetCurrent(args);
272
273
10
  std::vector<Local<Value>> handle_v;
274
25
  for (auto w : *env->handle_wrap_queue()) {
275
20
    if (!HandleWrap::HasRef(w))
276
1
      continue;
277
19
    handle_v.emplace_back(w->GetOwner());
278
  }
279
15
  args.GetReturnValue().Set(
280
      Array::New(env->isolate(), handle_v.data(), handle_v.size()));
281
5
}
282
283
1
static void ResourceUsage(const FunctionCallbackInfo<Value>& args) {
284
1
  Environment* env = Environment::GetCurrent(args);
285
286
  uv_rusage_t rusage;
287
1
  int err = uv_getrusage(&rusage);
288
1
  if (err)
289
    return env->ThrowUVException(err, "uv_getrusage");
290
291
1
  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 16);
292
1
  double* fields = static_cast<double*>(ab->GetBackingStore()->Data());
293
294
1
  fields[0] = MICROS_PER_SEC * rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec;
295
1
  fields[1] = MICROS_PER_SEC * rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec;
296
1
  fields[2] = static_cast<double>(rusage.ru_maxrss);
297
1
  fields[3] = static_cast<double>(rusage.ru_ixrss);
298
1
  fields[4] = static_cast<double>(rusage.ru_idrss);
299
1
  fields[5] = static_cast<double>(rusage.ru_isrss);
300
1
  fields[6] = static_cast<double>(rusage.ru_minflt);
301
1
  fields[7] = static_cast<double>(rusage.ru_majflt);
302
1
  fields[8] = static_cast<double>(rusage.ru_nswap);
303
1
  fields[9] = static_cast<double>(rusage.ru_inblock);
304
1
  fields[10] = static_cast<double>(rusage.ru_oublock);
305
1
  fields[11] = static_cast<double>(rusage.ru_msgsnd);
306
1
  fields[12] = static_cast<double>(rusage.ru_msgrcv);
307
1
  fields[13] = static_cast<double>(rusage.ru_nsignals);
308
1
  fields[14] = static_cast<double>(rusage.ru_nvcsw);
309
1
  fields[15] = static_cast<double>(rusage.ru_nivcsw);
310
}
311
312
#ifdef __POSIX__
313
4
static void DebugProcess(const FunctionCallbackInfo<Value>& args) {
314
4
  Environment* env = Environment::GetCurrent(args);
315
316
4
  if (args.Length() < 1) {
317
    return THROW_ERR_MISSING_ARGS(env, "Invalid number of arguments.");
318
  }
319
320
8
  CHECK(args[0]->IsNumber());
321
12
  pid_t pid = args[0].As<Integer>()->Value();
322
4
  int r = kill(pid, SIGUSR1);
323
324
4
  if (r != 0) {
325
1
    return env->ThrowErrnoException(errno, "kill");
326
  }
327
}
328
#endif  // __POSIX__
329
330
#ifdef _WIN32
331
static int GetDebugSignalHandlerMappingName(DWORD pid,
332
                                            wchar_t* buf,
333
                                            size_t buf_len) {
334
  return _snwprintf(buf, buf_len, L"node-debug-handler-%u", pid);
335
}
336
337
static void DebugProcess(const FunctionCallbackInfo<Value>& args) {
338
  Environment* env = Environment::GetCurrent(args);
339
  Isolate* isolate = args.GetIsolate();
340
341
  if (args.Length() < 1) {
342
    return THROW_ERR_MISSING_ARGS(env, "Invalid number of arguments.");
343
  }
344
345
  HANDLE process = nullptr;
346
  HANDLE thread = nullptr;
347
  HANDLE mapping = nullptr;
348
  wchar_t mapping_name[32];
349
  LPTHREAD_START_ROUTINE* handler = nullptr;
350
  DWORD pid = 0;
351
352
  auto cleanup = OnScopeLeave([&]() {
353
    if (process != nullptr) CloseHandle(process);
354
    if (thread != nullptr) CloseHandle(thread);
355
    if (handler != nullptr) UnmapViewOfFile(handler);
356
    if (mapping != nullptr) CloseHandle(mapping);
357
  });
358
359
  CHECK(args[0]->IsNumber());
360
  pid = static_cast<DWORD>(args[0].As<Integer>()->Value());
361
362
  process =
363
      OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION |
364
                      PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
365
                  FALSE,
366
                  pid);
367
  if (process == nullptr) {
368
    isolate->ThrowException(
369
        WinapiErrnoException(isolate, GetLastError(), "OpenProcess"));
370
    return;
371
  }
372
373
  if (GetDebugSignalHandlerMappingName(
374
          pid, mapping_name, arraysize(mapping_name)) < 0) {
375
    env->ThrowErrnoException(errno, "sprintf");
376
    return;
377
  }
378
379
  mapping = OpenFileMappingW(FILE_MAP_READ, FALSE, mapping_name);
380
  if (mapping == nullptr) {
381
    isolate->ThrowException(
382
        WinapiErrnoException(isolate, GetLastError(), "OpenFileMappingW"));
383
    return;
384
  }
385
386
  handler = reinterpret_cast<LPTHREAD_START_ROUTINE*>(
387
      MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, sizeof *handler));
388
  if (handler == nullptr || *handler == nullptr) {
389
    isolate->ThrowException(
390
        WinapiErrnoException(isolate, GetLastError(), "MapViewOfFile"));
391
    return;
392
  }
393
394
  thread =
395
      CreateRemoteThread(process, nullptr, 0, *handler, nullptr, 0, nullptr);
396
  if (thread == nullptr) {
397
    isolate->ThrowException(
398
        WinapiErrnoException(isolate, GetLastError(), "CreateRemoteThread"));
399
    return;
400
  }
401
402
  // Wait for the thread to terminate
403
  if (WaitForSingleObject(thread, INFINITE) != WAIT_OBJECT_0) {
404
    isolate->ThrowException(
405
        WinapiErrnoException(isolate, GetLastError(), "WaitForSingleObject"));
406
    return;
407
  }
408
}
409
#endif  // _WIN32
410
411
5
static void DebugEnd(const FunctionCallbackInfo<Value>& args) {
412
#if HAVE_INSPECTOR
413
5
  Environment* env = Environment::GetCurrent(args);
414
5
  if (env->inspector_agent()->IsListening()) {
415
4
    env->inspector_agent()->Stop();
416
  }
417
#endif
418
5
}
419
420
399
static void ReallyExit(const FunctionCallbackInfo<Value>& args) {
421
399
  Environment* env = Environment::GetCurrent(args);
422
399
  RunAtExit(env);
423
1596
  int code = args[0]->Int32Value(env->context()).FromMaybe(0);
424
399
  env->Exit(code);
425
56
}
426
427
13886
class FastHrtime : public BaseObject {
428
 public:
429
5201
  static Local<Object> New(Environment* env) {
430
5201
    Local<FunctionTemplate> ctor = FunctionTemplate::New(env->isolate());
431
10402
    ctor->Inherit(BaseObject::GetConstructorTemplate(env));
432
5201
    Local<ObjectTemplate> otmpl = ctor->InstanceTemplate();
433
5201
    otmpl->SetInternalFieldCount(FastHrtime::kInternalFieldCount);
434
435
20804
    auto create_func = [env](auto fast_func, auto slow_func) {
436
10402
      auto cfunc = CFunction::Make(fast_func);
437
20804
      return FunctionTemplate::New(env->isolate(),
438
                                   slow_func,
439
                                   Local<Value>(),
440
                                   Local<Signature>(),
441
                                   0,
442
                                   ConstructorBehavior::kThrow,
443
                                   SideEffectType::kHasNoSideEffect,
444
20804
                                   &cfunc);
445
5201
    };
446
447
20804
    otmpl->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "hrtime"),
448
5201
               create_func(FastNumber, SlowNumber));
449
20804
    otmpl->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "hrtimeBigInt"),
450
5201
               create_func(FastBigInt, SlowBigInt));
451
452
15603
    Local<Object> obj = otmpl->NewInstance(env->context()).ToLocalChecked();
453
454
    Local<ArrayBuffer> ab =
455
        ArrayBuffer::New(env->isolate(),
456
5201
            std::max(sizeof(uint64_t), sizeof(uint32_t) * 3));
457
5201
    new FastHrtime(env, obj, ab);
458
10402
    obj->Set(
459
20804
           env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "buffer"), ab)
460
        .ToChecked();
461
462
5201
    return obj;
463
  }
464
465
 private:
466
5201
  FastHrtime(Environment* env,
467
             Local<Object> object,
468
             Local<ArrayBuffer> ab)
469
5201
      : BaseObject(env, object),
470
        array_buffer_(env->isolate(), ab),
471
10402
        backing_store_(ab->GetBackingStore()) {
472
5201
    MakeWeak();
473
5201
  }
474
475
22
  void MemoryInfo(MemoryTracker* tracker) const override {
476
22
    tracker->TrackField("array_buffer", array_buffer_);
477
22
  }
478
22
  SET_MEMORY_INFO_NAME(FastHrtime)
479
22
  SET_SELF_SIZE(FastHrtime)
480
481
  static FastHrtime* FromV8ApiObject(ApiObject api_object) {
482
    Object* v8_object = reinterpret_cast<Object*>(&api_object);
483
    return static_cast<FastHrtime*>(
484
        v8_object->GetAlignedPointerFromInternalField(BaseObject::kSlot));
485
  }
486
487
  // This is the legacy version of hrtime before BigInt was introduced in
488
  // JavaScript.
489
  // The value returned by uv_hrtime() is a 64-bit int representing nanoseconds,
490
  // so this function instead fills in an Uint32Array with 3 entries,
491
  // to avoid any integer overflow possibility.
492
  // The first two entries contain the second part of the value
493
  // broken into the upper/lower 32 bits to be converted back in JS,
494
  // because there is no Uint64Array in JS.
495
  // The third entry contains the remaining nanosecond part of the value.
496
256787
  static void NumberImpl(FastHrtime* receiver) {
497
256787
    uint64_t t = uv_hrtime();
498
256787
    uint32_t* fields = static_cast<uint32_t*>(receiver->backing_store_->Data());
499
256787
    fields[0] = (t / NANOS_PER_SEC) >> 32;
500
256787
    fields[1] = (t / NANOS_PER_SEC) & 0xffffffff;
501
256787
    fields[2] = t % NANOS_PER_SEC;
502
256787
  }
503
504
  static void FastNumber(ApiObject receiver) {
505
    NumberImpl(FromV8ApiObject(receiver));
506
  }
507
508
256787
  static void SlowNumber(const FunctionCallbackInfo<Value>& args) {
509
256787
    NumberImpl(FromJSObject<FastHrtime>(args.Holder()));
510
256787
  }
511
512
356245
  static void BigIntImpl(FastHrtime* receiver) {
513
356245
    uint64_t t = uv_hrtime();
514
356245
    uint64_t* fields = static_cast<uint64_t*>(receiver->backing_store_->Data());
515
356245
    fields[0] = t;
516
356245
  }
517
518
  static void FastBigInt(ApiObject receiver) {
519
    BigIntImpl(FromV8ApiObject(receiver));
520
  }
521
522
356245
  static void SlowBigInt(const FunctionCallbackInfo<Value>& args) {
523
356245
    BigIntImpl(FromJSObject<FastHrtime>(args.Holder()));
524
356245
  }
525
526
  Global<ArrayBuffer> array_buffer_;
527
  std::shared_ptr<BackingStore> backing_store_;
528
};
529
530
5201
static void GetFastAPIs(const FunctionCallbackInfo<Value>& args) {
531
5201
  Environment* env = Environment::GetCurrent(args);
532
5201
  Local<Object> ret = Object::New(env->isolate());
533
10402
  ret->Set(env->context(),
534
           FIXED_ONE_BYTE_STRING(env->isolate(), "hrtime"),
535
26005
           FastHrtime::New(env))
536
      .ToChecked();
537
10402
  args.GetReturnValue().Set(ret);
538
5201
}
539
540
468
static void InitializeProcessMethods(Local<Object> target,
541
                                     Local<Value> unused,
542
                                     Local<Context> context,
543
                                     void* priv) {
544
468
  Environment* env = Environment::GetCurrent(context);
545
546
  // define various internal methods
547
468
  if (env->owns_process_state()) {
548
51
    env->SetMethod(target, "_debugProcess", DebugProcess);
549
51
    env->SetMethod(target, "_debugEnd", DebugEnd);
550
51
    env->SetMethod(target, "abort", Abort);
551
51
    env->SetMethod(target, "causeSegfault", CauseSegfault);
552
51
    env->SetMethod(target, "chdir", Chdir);
553
  }
554
555
468
  env->SetMethod(target, "umask", Umask);
556
468
  env->SetMethod(target, "_rawDebug", RawDebug);
557
468
  env->SetMethod(target, "memoryUsage", MemoryUsage);
558
468
  env->SetMethod(target, "rss", Rss);
559
468
  env->SetMethod(target, "cpuUsage", CPUUsage);
560
468
  env->SetMethod(target, "resourceUsage", ResourceUsage);
561
562
468
  env->SetMethod(target, "_getActiveRequests", GetActiveRequests);
563
468
  env->SetMethod(target, "_getActiveHandles", GetActiveHandles);
564
468
  env->SetMethod(target, "_kill", Kill);
565
566
468
  env->SetMethodNoSideEffect(target, "cwd", Cwd);
567
468
  env->SetMethod(target, "dlopen", binding::DLOpen);
568
468
  env->SetMethod(target, "reallyExit", ReallyExit);
569
468
  env->SetMethodNoSideEffect(target, "uptime", Uptime);
570
468
  env->SetMethod(target, "patchProcessObject", PatchProcessObject);
571
468
  env->SetMethod(target, "getFastAPIs", GetFastAPIs);
572
468
}
573
574
4774
void RegisterProcessMethodsExternalReferences(
575
    ExternalReferenceRegistry* registry) {
576
4774
  registry->Register(DebugProcess);
577
4774
  registry->Register(DebugEnd);
578
4774
  registry->Register(Abort);
579
4774
  registry->Register(CauseSegfault);
580
4774
  registry->Register(Chdir);
581
582
4774
  registry->Register(Umask);
583
4774
  registry->Register(RawDebug);
584
4774
  registry->Register(MemoryUsage);
585
4774
  registry->Register(Rss);
586
4774
  registry->Register(CPUUsage);
587
4774
  registry->Register(ResourceUsage);
588
589
4774
  registry->Register(GetActiveRequests);
590
4774
  registry->Register(GetActiveHandles);
591
4774
  registry->Register(Kill);
592
593
4774
  registry->Register(Cwd);
594
4774
  registry->Register(binding::DLOpen);
595
4774
  registry->Register(ReallyExit);
596
4774
  registry->Register(Uptime);
597
4774
  registry->Register(PatchProcessObject);
598
4774
  registry->Register(GetFastAPIs);
599
4774
}
600
601
}  // namespace node
602
603
4832
NODE_MODULE_CONTEXT_AWARE_INTERNAL(process_methods,
604
                                   node::InitializeProcessMethods)
605

19294
NODE_MODULE_EXTERNAL_REFERENCE(process_methods,
606
                               node::RegisterProcessMethodsExternalReferences)