GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_types.cc Lines: 45 45 100.0 %
Date: 2021-06-05 04:12:00 Branches: 16 18 88.9 %

Line Branch Exec Source
1
#include "env-inl.h"
2
#include "node.h"
3
#include "node_external_reference.h"
4
5
using v8::Context;
6
using v8::FunctionCallbackInfo;
7
using v8::Local;
8
using v8::Object;
9
using v8::Value;
10
11
namespace node {
12
namespace {
13
14
#define VALUE_METHOD_MAP(V)                                                   \
15
  V(External)                                                                 \
16
  V(Date)                                                                     \
17
  V(ArgumentsObject)                                                          \
18
  V(BigIntObject)                                                             \
19
  V(BooleanObject)                                                            \
20
  V(NumberObject)                                                             \
21
  V(StringObject)                                                             \
22
  V(SymbolObject)                                                             \
23
  V(NativeError)                                                              \
24
  V(RegExp)                                                                   \
25
  V(AsyncFunction)                                                            \
26
  V(GeneratorFunction)                                                        \
27
  V(GeneratorObject)                                                          \
28
  V(Promise)                                                                  \
29
  V(Map)                                                                      \
30
  V(Set)                                                                      \
31
  V(MapIterator)                                                              \
32
  V(SetIterator)                                                              \
33
  V(WeakMap)                                                                  \
34
  V(WeakSet)                                                                  \
35
  V(ArrayBuffer)                                                              \
36
  V(DataView)                                                                 \
37
  V(SharedArrayBuffer)                                                        \
38
  V(Proxy)                                                                    \
39
  V(ModuleNamespaceObject)                                                    \
40
41
42
#define V(type) \
43
  static void Is##type(const FunctionCallbackInfo<Value>& args) {             \
44
    args.GetReturnValue().Set(args[0]->Is##type());                           \
45
  }
46
47
2125
  VALUE_METHOD_MAP(V)
48
515221
#undef V
49
232512
50
160280
static void IsAnyArrayBuffer(const FunctionCallbackInfo<Value>& args) {
51
479001
  args.GetReturnValue().Set(
52

788384
    args[0]->IsArrayBuffer() || args[0]->IsSharedArrayBuffer());
53
161056
}
54
87630
55
502222
static void IsBoxedPrimitive(const FunctionCallbackInfo<Value>& args) {
56
591318
  args.GetReturnValue().Set(
57
138354
    args[0]->IsNumberObject() ||
58
132350
    args[0]->IsStringObject() ||
59
139882
    args[0]->IsBooleanObject() ||
60

263473
    args[0]->IsBigIntObject() ||
61
105703
    args[0]->IsSymbolObject());
62
51237
}
63
21631
64
119315
void InitializeTypes(Local<Object> target,
65
219655
                     Local<Value> unused,
66
56153
                     Local<Context> context,
67
138149
                     void* priv) {
68
679
  Environment* env = Environment::GetCurrent(context);
69
210458
70
109620
#define V(type) env->SetMethodNoSideEffect(target,     \
71
27405
                                           "is" #type, \
72
                                           Is##type);
73
464
  VALUE_METHOD_MAP(V)
74
464
#undef V
75
464
76
928
  env->SetMethodNoSideEffect(target, "isAnyArrayBuffer", IsAnyArrayBuffer);
77
928
  env->SetMethodNoSideEffect(target, "isBoxedPrimitive", IsBoxedPrimitive);
78
928
}
79
464
80
464
}  // anonymous namespace
81
464
82
5242
void RegisterTypesExternalReferences(ExternalReferenceRegistry* registry) {
83
464
#define V(type) registry->Register(Is##type);
84
5242
  VALUE_METHOD_MAP(V)
85
5242
#undef V
86
5242
87
9556
  registry->Register(IsAnyArrayBuffer);
88
9556
  registry->Register(IsBoxedPrimitive);
89
9556
}
90
4778
}  // namespace node
91
92
4836
NODE_MODULE_CONTEXT_AWARE_INTERNAL(types, node::InitializeTypes)
93

19310
NODE_MODULE_EXTERNAL_REFERENCE(types, node::RegisterTypesExternalReferences)