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-06-24 22:13: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::Context;
11
using v8::Function;
12
using v8::FunctionCallbackInfo;
13
using v8::Local;
14
using v8::Object;
15
using v8::Value;
16
17
4703
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
18
9406
  CHECK(args[0]->IsFunction());
19
9406
  CHECK(args[1]->IsFunction());
20
4703
  auto env = Environment::GetCurrent(args);
21
22
9406
  env->set_immediate_callback_function(args[0].As<Function>());
23
9406
  env->set_timers_callback_function(args[1].As<Function>());
24
4703
}
25
26
14111
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
27
14111
  Environment* env = Environment::GetCurrent(args);
28
42333
  args.GetReturnValue().Set(env->GetNow());
29
14111
}
30
31
1418
void ScheduleTimer(const FunctionCallbackInfo<Value>& args) {
32
1418
  auto env = Environment::GetCurrent(args);
33
5672
  env->ScheduleTimer(args[0]->IntegerValue(env->context()).FromJust());
34
1418
}
35
36
1110
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
37
2220
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
38
1110
}
39
40
27442
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
41
54884
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
42
27442
}
43
44
4703
void Initialize(Local<Object> target,
45
                       Local<Value> unused,
46
                       Local<Context> context,
47
                       void* priv) {
48
4703
  Environment* env = Environment::GetCurrent(context);
49
50
4703
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
51
4703
  env->SetMethod(target, "setupTimers", SetupTimers);
52
4703
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
53
4703
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
54
4703
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
55
56
9406
  target->Set(env->context(),
57
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
58
23515
              env->immediate_info()->fields().GetJSArray()).Check();
59
4703
}
60
61
62
}  // anonymous namespace
63
}  // namespace node
64
65
4398
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)