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-09-16 22:31:04 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
5099
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
20
10198
  CHECK(args[0]->IsFunction());
21
10198
  CHECK(args[1]->IsFunction());
22
5099
  auto env = Environment::GetCurrent(args);
23
24
10198
  env->set_immediate_callback_function(args[0].As<Function>());
25
10198
  env->set_timers_callback_function(args[1].As<Function>());
26
5099
}
27
28
250208
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
29
250208
  Environment* env = Environment::GetCurrent(args);
30
750624
  args.GetReturnValue().Set(env->GetNow());
31
250208
}
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
1300
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
39
2600
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
40
1300
}
41
42
27465
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
43
54930
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
44
27465
}
45
46
5099
void Initialize(Local<Object> target,
47
                       Local<Value> unused,
48
                       Local<Context> context,
49
                       void* priv) {
50
5099
  Environment* env = Environment::GetCurrent(context);
51
52
5099
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
53
5099
  env->SetMethod(target, "setupTimers", SetupTimers);
54
5099
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
55
5099
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
56
5099
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
57
58
  target->Set(env->context(),
59
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
60
25495
              env->immediate_info()->fields().GetJSArray()).Check();
61
5099
}
62
63
64
}  // anonymous namespace
65
}  // namespace node
66
67
4952
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)