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: 22 26 84.6 %
Date: 2019-09-25 22:36:03 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
#include <vector>
7
8
#include "cache_builder.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
1
int main(int argc, char* argv[]) {
27
#endif  // _WIN32
28
29
1
  v8::V8::SetFlagsFromString("--random_seed=42");
30
31
1
  if (argc < 2) {
32
    std::cerr << "Usage: " << argv[0] << " <path/to/output.cc>\n";
33
    return 1;
34
  }
35
36
1
  std::ofstream out;
37
1
  out.open(argv[1], std::ios::out | std::ios::binary);
38
1
  if (!out.is_open()) {
39
    std::cerr << "Cannot open " << argv[1] << "\n";
40
    return 1;
41
  }
42
43
2
  std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
44
1
  v8::V8::InitializePlatform(platform.get());
45
1
  v8::V8::Initialize();
46
47
  // Create a new Isolate and make it the current one.
48
1
  Isolate::CreateParams create_params;
49
  create_params.array_buffer_allocator =
50
1
      ArrayBuffer::Allocator::NewDefaultAllocator();
51
1
  Isolate* isolate = Isolate::New(create_params);
52
  {
53
1
    Isolate::Scope isolate_scope(isolate);
54
2
    v8::HandleScope handle_scope(isolate);
55
2
    v8::Local<v8::Context> context = v8::Context::New(isolate);
56
    v8::Context::Scope context_scope(context);
57
58
    // The command line flags are part of the code cache's checksum so reset
59
    // --random_seed= to its default value before creating the code cache.
60
1
    v8::V8::SetFlagsFromString("--random_seed=0");
61
2
    std::string cache = CodeCacheBuilder::Generate(context);
62
1
    out << cache;
63
2
    out.close();
64
  }
65
66
1
  v8::V8::ShutdownPlatform();
67
2
  return 0;
68

3
}