• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_TOOLS_DEBUG_HELPER_HEAP_CONSTANTS_H_
6 #define V8_TOOLS_DEBUG_HELPER_HEAP_CONSTANTS_H_
7 
8 #include <cstdint>
9 #include <string>
10 #include <vector>
11 
12 #include "debug-helper.h"
13 #include "src/objects/instance-type.h"
14 
15 namespace d = v8::debug_helper;
16 
17 namespace v8 {
18 namespace internal {
19 namespace debug_helper_internal {
20 
21 // ===== Functions generated by gen-heap-constants.py: =========================
22 
23 // Returns the name of a known object, given its offset within the first page of
24 // the space, or empty string on failure.
25 std::string FindKnownObjectInOldSpace(uintptr_t offset);
26 std::string FindKnownObjectInReadOnlySpace(uintptr_t offset);
27 std::string FindKnownObjectInMapSpace(uintptr_t offset);
28 
29 // In builds with pointer compression enabled, sets the *_first_page members in
30 // the HeapAddresses object. In other builds, does nothing.
31 void FillInUnknownHeapAddresses(d::HeapAddresses* heap_addresses,
32                                 uintptr_t any_uncompressed_ptr);
33 
34 // Returns the instance type for the known Map, given its offset within the
35 // first page of the space, or empty string on failure.
36 int FindKnownMapInstanceTypeInMapSpace(uintptr_t offset);
37 int FindKnownMapInstanceTypeInOldSpace(uintptr_t offset);
38 int FindKnownMapInstanceTypeInReadOnlySpace(uintptr_t offset);
39 
40 // ===== End of generated functions. ===========================================
41 
42 // Returns a descriptive string if the given address matches a known object, or
43 // an empty string otherwise.
44 std::string FindKnownObject(uintptr_t address,
45                             const d::HeapAddresses& heap_addresses);
46 
47 struct KnownInstanceType {
48   enum class Confidence {
49     kLow,
50     kHigh,
51   };
KnownInstanceTypeKnownInstanceType52   KnownInstanceType() : confidence(Confidence::kLow) {}
KnownInstanceTypeKnownInstanceType53   KnownInstanceType(int type) : KnownInstanceType() {
54     if (type >= 0) {
55       confidence = Confidence::kHigh;
56       types.push_back(static_cast<v8::internal::InstanceType>(type));
57     }
58   }
59   Confidence confidence;
60   std::vector<v8::internal::InstanceType> types;
61 };
62 
63 // Returns information about the instance type of the Map at the given address,
64 // based on the list of known Maps.
65 KnownInstanceType FindKnownMapInstanceTypes(
66     uintptr_t address, const d::HeapAddresses& heap_addresses);
67 
68 }  // namespace debug_helper_internal
69 }  // namespace internal
70 }  // namespace v8
71 
72 #endif
73