summaryrefslogtreecommitdiff
path: root/deps/v8/src/debug/debug-type-profile.h
blob: 16f739e4536d3f4e5b089e2575acb65034c976d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_DEBUG_DEBUG_TYPE_PROFILE_H_
#define V8_DEBUG_DEBUG_TYPE_PROFILE_H_

#include <vector>

#include "src/debug/debug-interface.h"
#include "src/handles/handles.h"
#include "src/objects/objects.h"

namespace v8 {
namespace internal {

// Forward declaration.
class Isolate;

struct TypeProfileEntry {
  explicit TypeProfileEntry(
      int pos, std::vector<v8::internal::Handle<internal::String>> t)
      : position(pos), types(std::move(t)) {}
  int position;
  std::vector<v8::internal::Handle<internal::String>> types;
};

struct TypeProfileScript {
  explicit TypeProfileScript(Handle<Script> s) : script(s) {}
  Handle<Script> script;
  std::vector<TypeProfileEntry> entries;
};

class TypeProfile : public std::vector<TypeProfileScript> {
 public:
  static std::unique_ptr<TypeProfile> Collect(Isolate* isolate);
  static void SelectMode(Isolate* isolate, debug::TypeProfileMode mode);

 private:
  TypeProfile() = default;
};

}  // namespace internal
}  // namespace v8

#endif  // V8_DEBUG_DEBUG_TYPE_PROFILE_H_