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: 258 277 93.1 %
Date: 2021-01-16 04:10:54 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.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
4665
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
432
static void Chdir(const FunctionCallbackInfo<Value>& args) {
83
432
  Environment* env = Environment::GetCurrent(args);
84
432
  CHECK(env->owns_process_state());
85
86
432
  CHECK_EQ(args.Length(), 1);
87
1296
  CHECK(args[0]->IsString());
88
863
  Utf8Value path(env->isolate(), args[0]);
89
432
  int err = uv_chdir(*path);
90
432
  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
558
inline Local<ArrayBuffer> get_fields_array_buffer(
101
    const FunctionCallbackInfo<Value>& args,
102
    size_t index,
103
    size_t array_length) {
104
1674
  CHECK(args[index]->IsFloat64Array());
105
1674
  Local<Float64Array> arr = args[index].As<Float64Array>();
106
558
  CHECK_EQ(arr->Length(), array_length);
107
558
  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
5521
static void Cwd(const FunctionCallbackInfo<Value>& args) {
134
5521
  Environment* env = Environment::GetCurrent(args);
135
5521
  CHECK(env->has_run_bootstrapping_code());
136
  char buf[PATH_MAX_BYTES];
137
5521
  size_t cwd_len = sizeof(buf);
138
5521
  int err = uv_cwd(buf, &cwd_len);
139
5521
  if (err)
140
13
    return env->ThrowUVException(err, "uv_cwd");
141
142
11016
  Local<String> cwd = String::NewFromUtf8(env->isolate(),
143
                                          buf,
144
                                          NewStringType::kNormal,
145
11016
                                          cwd_len).ToLocalChecked();
146
11016
  args.GetReturnValue().Set(cwd);
147
}
148
149
63
static void Kill(const FunctionCallbackInfo<Value>& args) {
150
63
  Environment* env = Environment::GetCurrent(args);
151
63
  Local<Context> context = env->context();
152
153
63
  if (args.Length() < 2) {
154
    THROW_ERR_MISSING_ARGS(env, "Bad argument.");
155
  }
156
157
  int pid;
158
189
  if (!args[0]->Int32Value(context).To(&pid)) return;
159
  int sig;
160
189
  if (!args[1]->Int32Value(context).To(&sig)) return;
161
162
63
  uv_pid_t own_pid = uv_os_getpid();
163

187
  if (sig > 0 &&
164


151
      (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
63
  int err = uv_kill(pid, sig);
172
126
  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
524
static void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
187
524
  Environment* env = Environment::GetCurrent(args);
188
189
524
  Isolate* isolate = env->isolate();
190
  // V8 memory usage
191
524
  HeapStatistics v8_heap_stats;
192
524
  isolate->GetHeapStatistics(&v8_heap_stats);
193
194
  NodeArrayBufferAllocator* array_buffer_allocator =
195
524
      env->isolate_data()->node_allocator();
196
197
  // Get the double array pointer from the Float64Array argument.
198
524
  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 5);
199
524
  double* fields = static_cast<double*>(ab->GetBackingStore()->Data());
200
201
  size_t rss;
202
524
  int err = uv_resident_set_memory(&rss);
203
524
  if (err)
204
    return env->ThrowUVException(err, "uv_resident_set_memory");
205
206
524
  fields[0] = rss;
207
524
  fields[1] = v8_heap_stats.total_heap_size();
208
524
  fields[2] = v8_heap_stats.used_heap_size();
209
524
  fields[3] = v8_heap_stats.external_memory();
210
1048
  fields[4] = array_buffer_allocator == nullptr ?
211
524
      0 : array_buffer_allocator->total_mem_usage();
212
}
213
214
12
void RawDebug(const FunctionCallbackInfo<Value>& args) {
215


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

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

18586
NODE_MODULE_EXTERNAL_REFERENCE(process_methods,
604
                               node::RegisterProcessMethodsExternalReferences)