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-02-13 22:28:58 Branches: 2 4 50.0 %

Line Branch Exec Source
1
#include "env-inl.h"
2
#include "util.h"
3
#include "v8.h"
4
5
#include <stdint.h>
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
4408
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
20
8816
  CHECK(args[0]->IsFunction());
21
8816
  CHECK(args[1]->IsFunction());
22
4408
  auto env = Environment::GetCurrent(args);
23
24
8816
  env->set_immediate_callback_function(args[0].As<Function>());
25
8816
  env->set_timers_callback_function(args[1].As<Function>());
26
4408
}
27
28
335592
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
29
335592
  Environment* env = Environment::GetCurrent(args);
30
1006776
  args.GetReturnValue().Set(env->GetNow());
31
335592
}
32
33
2025
void ScheduleTimer(const FunctionCallbackInfo<Value>& args) {
34
2025
  auto env = Environment::GetCurrent(args);
35
8100
  env->ScheduleTimer(args[0]->IntegerValue(env->context()).FromJust());
36
2025
}
37
38
1257
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
39
2514
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
40
1257
}
41
42
25227
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
43
50454
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
44
25227
}
45
46
4409
void Initialize(Local<Object> target,
47
                       Local<Value> unused,
48
                       Local<Context> context,
49
                       void* priv) {
50
4409
  Environment* env = Environment::GetCurrent(context);
51
52
4409
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
53
4409
  env->SetMethod(target, "setupTimers", SetupTimers);
54
4409
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
55
4409
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
56
4409
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
57
58
  target->Set(env->context(),
59
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
60
22045
              env->immediate_info()->fields().GetJSArray()).FromJust();
61
4409
}
62
63
64
}  // anonymous namespace
65
}  // namespace node
66
67
4314
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)