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-07-27 22:37:30 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
4965
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
20
9930
  CHECK(args[0]->IsFunction());
21
9930
  CHECK(args[1]->IsFunction());
22
4965
  auto env = Environment::GetCurrent(args);
23
24
9930
  env->set_immediate_callback_function(args[0].As<Function>());
25
9930
  env->set_timers_callback_function(args[1].As<Function>());
26
4965
}
27
28
147628
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
29
147628
  Environment* env = Environment::GetCurrent(args);
30
442884
  args.GetReturnValue().Set(env->GetNow());
31
147628
}
32
33
1695
void ScheduleTimer(const FunctionCallbackInfo<Value>& args) {
34
1695
  auto env = Environment::GetCurrent(args);
35
6780
  env->ScheduleTimer(args[0]->IntegerValue(env->context()).FromJust());
36
1695
}
37
38
1310
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
39
2620
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
40
1310
}
41
42
27786
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
43
55572
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
44
27786
}
45
46
4965
void Initialize(Local<Object> target,
47
                       Local<Value> unused,
48
                       Local<Context> context,
49
                       void* priv) {
50
4965
  Environment* env = Environment::GetCurrent(context);
51
52
4965
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
53
4965
  env->SetMethod(target, "setupTimers", SetupTimers);
54
4965
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
55
4965
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
56
4965
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
57
58
  target->Set(env->context(),
59
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
60
24825
              env->immediate_info()->fields().GetJSArray()).Check();
61
4965
}
62
63
64
}  // anonymous namespace
65
}  // namespace node
66
67
4831
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)