debug-helper-internal.cc 1.91 KB
Newer Older
1 2 3 4 5 6
// Copyright 2019 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.

#include "debug-helper-internal.h"
#include "src/common/ptr-compr-inl.h"
7
#include "torque-generated/class-debug-readers-tq.h"
8 9 10

namespace i = v8::internal;

11 12 13
namespace v8 {
namespace internal {
namespace debug_helper_internal {
14 15 16

bool IsPointerCompressed(uintptr_t address) {
#if COMPRESS_POINTERS_BOOL
17
  return address < i::kPtrComprHeapReservationSize;
18 19 20 21 22
#else
  return false;
#endif
}

23 24
uintptr_t EnsureDecompressed(uintptr_t address,
                             uintptr_t any_uncompressed_ptr) {
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  if (!COMPRESS_POINTERS_BOOL || !IsPointerCompressed(address)) return address;
  return i::DecompressTaggedAny(any_uncompressed_ptr,
                                static_cast<i::Tagged_t>(address));
}

d::PropertyKind GetArrayKind(d::MemoryAccessResult mem_result) {
  d::PropertyKind indexed_field_kind{};
  switch (mem_result) {
    case d::MemoryAccessResult::kOk:
      indexed_field_kind = d::PropertyKind::kArrayOfKnownSize;
      break;
    case d::MemoryAccessResult::kAddressNotValid:
      indexed_field_kind =
          d::PropertyKind::kArrayOfUnknownSizeDueToInvalidMemory;
      break;
    default:
      indexed_field_kind =
          d::PropertyKind::kArrayOfUnknownSizeDueToValidButInaccessibleMemory;
      break;
  }
  return indexed_field_kind;
}

std::vector<std::unique_ptr<ObjectProperty>> TqObject::GetProperties(
49
    d::MemoryAccessor accessor) const {
50 51 52
  return std::vector<std::unique_ptr<ObjectProperty>>();
}

53 54 55 56 57 58
const char* TqObject::GetName() const { return "v8::internal::Object"; }

void TqObject::Visit(TqObjectVisitor* visitor) const {
  visitor->VisitObject(this);
}

59 60 61 62
bool TqObject::IsSuperclassOf(const TqObject* other) const {
  return GetName() != other->GetName();
}

63 64 65
}  // namespace debug_helper_internal
}  // namespace internal
}  // namespace v8