GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/timers.cc Lines: 32 32 100.0 %
Date: 2020-05-27 22:15:15 Branches: 2 4 50.0 %

Line Branch Exec Source
1
#include "env-inl.h"
2
#include "util-inl.h"
3
#include "v8.h"
4
5
#include <cstdint>
6
7
namespace node {
8
namespace {
9
10
using v8::Context;
11
using v8::Function;
12
using v8::FunctionCallbackInfo;
13
using v8::Local;
14
using v8::Object;
15
using v8::Value;
16
17
4594
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
18
9188
  CHECK(args[0]->IsFunction());
19
9188
  CHECK(args[1]->IsFunction());
20
4594
  auto env = Environment::GetCurrent(args);
21
22
9188
  env->set_immediate_callback_function(args[0].As<Function>());
23
9188
  env->set_timers_callback_function(args[1].As<Function>());
24
4594
}
25
26
14134
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
27
14134
  Environment* env = Environment::GetCurrent(args);
28
42408
  args.GetReturnValue().Set(env->GetNow());
29
14136
}
30
31
1399
void ScheduleTimer(const FunctionCallbackInfo<Value>& args) {
32
1399
  auto env = Environment::GetCurrent(args);
33
5596
  env->ScheduleTimer(args[0]->IntegerValue(env->context()).FromJust());
34
1399
}
35
36
1092
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
37
2184
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
38
1092
}
39
40
27847
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
41
55694
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
42
27847
}
43
44
4594
void Initialize(Local<Object> target,
45
                       Local<Value> unused,
46
                       Local<Context> context,
47
                       void* priv) {
48
4594
  Environment* env = Environment::GetCurrent(context);
49
50
4594
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
51
4594
  env->SetMethod(target, "setupTimers", SetupTimers);
52
4594
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
53
4594
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
54
4594
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
55
56
9188
  target->Set(env->context(),
57
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
58
22970
              env->immediate_info()->fields().GetJSArray()).Check();
59
4594
}
60
61
62
}  // anonymous namespace
63
}  // namespace node
64
65
4325
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)