v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
tagged-impl.cc
Go to the documentation of this file.
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
6
7#include <sstream>
8
10#include "src/objects/objects.h"
11#include "src/objects/smi.h"
14#include "src/utils/ostreams.h"
15
16#ifdef V8_EXTERNAL_CODE_SPACE
17// For IsCodeSpaceObject().
19#endif
20
21namespace v8 {
22namespace internal {
23
24#if defined(V8_EXTERNAL_CODE_SPACE) || defined(V8_ENABLE_SANDBOX)
25bool CheckObjectComparisonAllowed(Address a, Address b) {
27 return true;
28 }
31 // This check might fail when we try to compare objects in different pointer
32 // compression cages (e.g. the one used by code space or trusted space) with
33 // each other. The main legitimate case when such "mixed" comparison could
34 // happen is comparing two AbstractCode objects. If that's the case one must
35 // use AbstractCode's == operator instead of Object's one or SafeEquals().
37#ifdef V8_ENABLE_SANDBOX
40#endif
41 return true;
42}
43#endif // defined(V8_EXTERNAL_CODE_SPACE) || defined(V8_ENABLE_SANDBOX)
44
45template <HeapObjectReferenceType kRefType, typename StorageType>
47 OFStream os(out);
48 os << Brief(ptr);
49}
51 TaggedImpl<HeapObjectReferenceType::STRONG, Address> ptr, FILE* out);
53 TaggedImpl<HeapObjectReferenceType::WEAK, Address> ptr, FILE* out);
54
55template <HeapObjectReferenceType kRefType, typename StorageType>
57 StringStream* accumulator) {
58 std::ostringstream os;
59 os << Brief(ptr);
60 accumulator->Add(os.str().c_str());
61}
63 TaggedImpl<HeapObjectReferenceType::STRONG, Address> ptr,
64 StringStream* accumulator);
66 TaggedImpl<HeapObjectReferenceType::WEAK, Address> ptr,
67 StringStream* accumulator);
68
69template <HeapObjectReferenceType kRefType, typename StorageType>
70void ShortPrint(TaggedImpl<kRefType, StorageType> ptr, std::ostream& os) {
71 os << Brief(ptr);
72}
74 TaggedImpl<HeapObjectReferenceType::STRONG, Address> ptr, std::ostream& os);
76 TaggedImpl<HeapObjectReferenceType::WEAK, Address> ptr, std::ostream& os);
77
78#ifdef OBJECT_PRINT
79template <HeapObjectReferenceType kRefType, typename StorageType>
80void Print(TaggedImpl<kRefType, StorageType> ptr) {
81 StdoutStream os;
82 Print(ptr, os);
83 os << std::flush;
84}
86 TaggedImpl<HeapObjectReferenceType::STRONG, Address> ptr);
88 TaggedImpl<HeapObjectReferenceType::WEAK, Address> ptr);
89
90template <HeapObjectReferenceType kRefType, typename StorageType>
91void Print(TaggedImpl<kRefType, StorageType> ptr, std::ostream& os) {
92 Tagged<Smi> smi;
93 Tagged<HeapObject> heap_object;
94 if (ptr.ToSmi(&smi)) {
95 os << "Smi: " << std::hex << "0x" << smi.value();
96 os << std::dec << " (" << smi.value() << ")\n";
97 } else if (ptr.IsCleared()) {
98 os << "[cleared]";
99 } else if (ptr.GetHeapObjectIfWeak(&heap_object)) {
100 os << "[weak] ";
101 heap_object->HeapObjectPrint(os);
102 } else if (ptr.GetHeapObjectIfStrong(&heap_object)) {
103 heap_object->HeapObjectPrint(os);
104 } else {
105 UNREACHABLE();
106 }
107}
109 TaggedImpl<HeapObjectReferenceType::STRONG, Address> ptr, std::ostream& os);
111 TaggedImpl<HeapObjectReferenceType::WEAK, Address> ptr, std::ostream& os);
112#endif // OBJECT_PRINT
113
114// Explicit instantiation declarations.
115template class TaggedImpl<HeapObjectReferenceType::STRONG, Address>;
116template class TaggedImpl<HeapObjectReferenceType::WEAK, Address>;
117
118} // namespace internal
119} // namespace v8
static V8_INLINE bool InTrustedSpace(Tagged< HeapObject > object)
static V8_INLINE bool InCodeSpace(Tagged< HeapObject > object)
void Add(const char *format)
#define HAS_STRONG_HEAP_OBJECT_TAG(value)
Definition globals.h:1774
#define EXPORT_TEMPLATE_DEFINE(export)
kInterpreterTrampolineOffset Tagged< HeapObject >
void Print(Tagged< Object > obj)
Definition objects.h:774
Handle< To > UncheckedCast(Handle< From > value)
Definition handles-inl.h:55
void ShortPrint(Tagged< Object > obj, FILE *out)
Definition objects.cc:1865
#define CHECK_EQ(lhs, rhs)
#define V8_EXPORT_PRIVATE
Definition macros.h:460