GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../tools/code_cache/mkcodecache.cc Lines: 26 30 86.7 %
Date: 2021-02-19 04:08:54 Branches: 4 8 50.0 %

Line Branch Exec Source
1
#include <cstdio>
2
#include <fstream>
3
#include <iostream>
4
#include <sstream>
5
#include <string>
6
7
#include "cache_builder.h"
8
#include "debug_utils-inl.h"
9
#include "libplatform/libplatform.h"
10
#include "v8.h"
11
12
using node::native_module::CodeCacheBuilder;
13
using v8::ArrayBuffer;
14
using v8::Context;
15
using v8::HandleScope;
16
using v8::Isolate;
17
using v8::Local;
18
19
#ifdef _WIN32
20
#include <VersionHelpers.h>
21
#include <WinError.h>
22
#include <windows.h>
23
24
int wmain(int argc, wchar_t* argv[]) {
25
#else   // UNIX
26
7
int main(int argc, char* argv[]) {
27
7
  argv = uv_setup_args(argc, argv);
28
#endif  // _WIN32
29
30
7
  v8::V8::SetFlagsFromString("--random_seed=42");
31
7
  v8::V8::SetFlagsFromString("--harmony-top-level-await");
32
33
7
  if (argc < 2) {
34
    std::cerr << "Usage: " << argv[0] << " <path/to/output.cc>\n";
35
    return 1;
36
  }
37
38
14
  std::ofstream out;
39
7
  out.open(argv[1], std::ios::out | std::ios::binary);
40
7
  if (!out.is_open()) {
41
    std::cerr << "Cannot open " << argv[1] << "\n";
42
    return 1;
43
  }
44
45
7
  node::per_process::enabled_debug_list.Parse(nullptr);
46
47
14
  std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
48
7
  v8::V8::InitializePlatform(platform.get());
49
  v8::V8::Initialize();
50
51
  // Create a new Isolate and make it the current one.
52
14
  Isolate::CreateParams create_params;
53
7
  create_params.array_buffer_allocator_shared.reset(
54
7
      ArrayBuffer::Allocator::NewDefaultAllocator());
55
7
  Isolate* isolate = Isolate::New(create_params);
56
  {
57
14
    Isolate::Scope isolate_scope(isolate);
58
14
    v8::HandleScope handle_scope(isolate);
59
14
    v8::Local<v8::Context> context = v8::Context::New(isolate);
60
    v8::Context::Scope context_scope(context);
61
62
    // The command line flags are part of the code cache's checksum so reset
63
    // --random_seed= to its default value before creating the code cache.
64
7
    v8::V8::SetFlagsFromString("--random_seed=0");
65
14
    std::string cache = CodeCacheBuilder::Generate(context);
66
7
    out << cache;
67
7
    out.close();
68
  }
69
7
  isolate->Dispose();
70
71
7
  v8::V8::ShutdownPlatform();
72
7
  return 0;
73

21
}