GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/aliased_struct-inl.h Lines: 11 11 100.0 %
Date: 2020-09-06 22:14:11 Branches: 1 2 50.0 %

Line Branch Exec Source
1
#ifndef SRC_ALIASED_STRUCT_INL_H_
2
#define SRC_ALIASED_STRUCT_INL_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "aliased_struct.h"
7
#include "v8.h"
8
#include <memory>
9
10
namespace node {
11
12
template <typename T>
13
template <typename... Args>
14
630
AliasedStruct<T>::AliasedStruct(v8::Isolate* isolate, Args&&... args)
15
630
    : isolate_(isolate) {
16
1260
  const v8::HandleScope handle_scope(isolate);
17
18
630
  store_ = v8::ArrayBuffer::NewBackingStore(isolate, sizeof(T));
19
630
  ptr_ = new (store_->Data()) T(std::forward<Args>(args)...);
20
  DCHECK_NOT_NULL(ptr_);
21
22
630
  v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(isolate, store_);
23
1260
  buffer_ = v8::Global<v8::ArrayBuffer>(isolate, buffer);
24
630
}
25
26
template <typename T>
27
AliasedStruct<T>::AliasedStruct(const AliasedStruct& that)
28
    : AliasedStruct(that.isolate_, *that) {}
29
30
template <typename T>
31
AliasedStruct<T>& AliasedStruct<T>::operator=(
32
    AliasedStruct<T>&& that) noexcept {
33
  this->~AliasedStruct();
34
  isolate_ = that.isolate_;
35
  store_ = that.store_;
36
  ptr_ = that.ptr_;
37
38
  buffer_ = std::move(that.buffer_);
39
40
  that.ptr_ = nullptr;
41
  that.store_.reset();
42
  return *this;
43
}
44
45
template <typename T>
46
630
AliasedStruct<T>::~AliasedStruct() {
47
630
  if (ptr_ != nullptr) ptr_->~T();
48
1260
}
49
50
}  // namespace node
51
52
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
53
54
#endif  // SRC_ALIASED_STRUCT_INL_H_