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: 31 31 100.0 %
Date: 2019-10-07 22:40:39 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::Array;
11
using v8::Context;
12
using v8::Function;
13
using v8::FunctionCallbackInfo;
14
using v8::Integer;
15
using v8::Local;
16
using v8::Object;
17
using v8::Value;
18
19
5094
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
20
10188
  CHECK(args[0]->IsFunction());
21
10188
  CHECK(args[1]->IsFunction());
22
5094
  auto env = Environment::GetCurrent(args);
23
24
10188
  env->set_immediate_callback_function(args[0].As<Function>());
25
10188
  env->set_timers_callback_function(args[1].As<Function>());
26
5094
}
27
28
244006
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
29
244006
  Environment* env = Environment::GetCurrent(args);
30
732018
  args.GetReturnValue().Set(env->GetNow());
31
244006
}
32
33
1697
void ScheduleTimer(const FunctionCallbackInfo<Value>& args) {
34
1697
  auto env = Environment::GetCurrent(args);
35
6788
  env->ScheduleTimer(args[0]->IntegerValue(env->context()).FromJust());
36
1697
}
37
38
1281
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
39
2562
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
40
1281
}
41
42
34253
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
43
68506
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
44
34253
}
45
46
5094
void Initialize(Local<Object> target,
47
                       Local<Value> unused,
48
                       Local<Context> context,
49
                       void* priv) {
50
5094
  Environment* env = Environment::GetCurrent(context);
51
52
5094
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
53
5094
  env->SetMethod(target, "setupTimers", SetupTimers);
54
5094
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
55
5094
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
56
5094
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
57
58
  target->Set(env->context(),
59
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
60
25470
              env->immediate_info()->fields().GetJSArray()).Check();
61
5094
}
62
63
64
}  // anonymous namespace
65
}  // namespace node
66
67
4948
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)