11cb0ef41Sopenharmony_ci// Copyright 2019 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "debug-helper-internal.h"
61cb0ef41Sopenharmony_ci#include "src/common/ptr-compr-inl.h"
71cb0ef41Sopenharmony_ci#include "torque-generated/class-debug-readers.h"
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cinamespace i = v8::internal;
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cinamespace v8 {
121cb0ef41Sopenharmony_cinamespace internal {
131cb0ef41Sopenharmony_cinamespace debug_helper_internal {
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_cibool IsPointerCompressed(uintptr_t address) {
161cb0ef41Sopenharmony_ci#if COMPRESS_POINTERS_BOOL
171cb0ef41Sopenharmony_ci  return address < i::kPtrComprCageReservationSize;
181cb0ef41Sopenharmony_ci#else
191cb0ef41Sopenharmony_ci  return false;
201cb0ef41Sopenharmony_ci#endif
211cb0ef41Sopenharmony_ci}
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciuintptr_t EnsureDecompressed(uintptr_t address,
241cb0ef41Sopenharmony_ci                             uintptr_t any_uncompressed_ptr) {
251cb0ef41Sopenharmony_ci  if (!COMPRESS_POINTERS_BOOL || !IsPointerCompressed(address)) return address;
261cb0ef41Sopenharmony_ci  return i::DecompressTaggedAny(any_uncompressed_ptr,
271cb0ef41Sopenharmony_ci                                static_cast<i::Tagged_t>(address));
281cb0ef41Sopenharmony_ci}
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_cid::PropertyKind GetArrayKind(d::MemoryAccessResult mem_result) {
311cb0ef41Sopenharmony_ci  d::PropertyKind indexed_field_kind{};
321cb0ef41Sopenharmony_ci  switch (mem_result) {
331cb0ef41Sopenharmony_ci    case d::MemoryAccessResult::kOk:
341cb0ef41Sopenharmony_ci      indexed_field_kind = d::PropertyKind::kArrayOfKnownSize;
351cb0ef41Sopenharmony_ci      break;
361cb0ef41Sopenharmony_ci    case d::MemoryAccessResult::kAddressNotValid:
371cb0ef41Sopenharmony_ci      indexed_field_kind =
381cb0ef41Sopenharmony_ci          d::PropertyKind::kArrayOfUnknownSizeDueToInvalidMemory;
391cb0ef41Sopenharmony_ci      break;
401cb0ef41Sopenharmony_ci    default:
411cb0ef41Sopenharmony_ci      indexed_field_kind =
421cb0ef41Sopenharmony_ci          d::PropertyKind::kArrayOfUnknownSizeDueToValidButInaccessibleMemory;
431cb0ef41Sopenharmony_ci      break;
441cb0ef41Sopenharmony_ci  }
451cb0ef41Sopenharmony_ci  return indexed_field_kind;
461cb0ef41Sopenharmony_ci}
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_cistd::vector<std::unique_ptr<ObjectProperty>> TqObject::GetProperties(
491cb0ef41Sopenharmony_ci    d::MemoryAccessor accessor) const {
501cb0ef41Sopenharmony_ci  return std::vector<std::unique_ptr<ObjectProperty>>();
511cb0ef41Sopenharmony_ci}
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ciconst char* TqObject::GetName() const { return "v8::internal::Object"; }
541cb0ef41Sopenharmony_ci
551cb0ef41Sopenharmony_civoid TqObject::Visit(TqObjectVisitor* visitor) const {
561cb0ef41Sopenharmony_ci  visitor->VisitObject(this);
571cb0ef41Sopenharmony_ci}
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_cibool TqObject::IsSuperclassOf(const TqObject* other) const {
601cb0ef41Sopenharmony_ci  return GetName() != other->GetName();
611cb0ef41Sopenharmony_ci}
621cb0ef41Sopenharmony_ci
631cb0ef41Sopenharmony_ci}  // namespace debug_helper_internal
641cb0ef41Sopenharmony_ci}  // namespace internal
651cb0ef41Sopenharmony_ci}  // namespace v8
66