v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
field-type.cc
Go to the documentation of this file.
1// Copyright 2016 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
8#include "src/objects/map.h"
10#include "src/objects/smi.h"
11#include "src/utils/ostreams.h"
12
13namespace v8 {
14namespace internal {
15
16// static
20
21// static
25
26// static
28 return direct_handle(None(), isolate);
29}
30
31// static
33 return direct_handle(Any(), isolate);
34}
35
36// static
40
41// static
43 Isolate* isolate) {
44 return direct_handle(Class(*map), isolate);
45}
46
47// static
48bool IsClass(Tagged<FieldType> obj) { return IsMap(obj); }
49
50// static
55
56// static
61
62// static
64 return !IsClass(type) || AsClass(type)->is_stable();
65}
66
67// static
69 if (IsAny(other)) return true;
70 if (IsNone(type)) return true;
71 if (IsNone(other)) return false;
72 if (IsAny(type)) return false;
73 DCHECK(IsClass(type));
74 DCHECK(IsClass(other));
75 return type == other;
76}
77
78// static
80 if (IsAny(type) && IsAny(other)) return true;
81 if (IsNone(type) && IsNone(other)) return true;
82 if (IsClass(type) && IsClass(other)) {
83 return type == other;
84 }
85 return false;
86}
87
88// static
90 return NowIs(type, *other);
91}
92
93// static
94void FieldType::PrintTo(Tagged<FieldType> type, std::ostream& os) {
95 if (IsAny(type)) {
96 os << "Any";
97 } else if (IsNone(type)) {
98 os << "None";
99 } else {
100 DCHECK(IsClass(type));
101 os << "Class(" << reinterpret_cast<void*>(AsClass(type).ptr()) << ")";
102 }
103}
104
105// static
107 if (type == Any()) return true;
108 if (type == None()) return false;
109 if (!IsHeapObject(value)) return false;
110 return Cast<HeapObject>(value)->map() == Cast<Map>(type);
111}
112
113} // namespace internal
114} // namespace v8
static V8_EXPORT_PRIVATE void PrintTo(Tagged< FieldType > type, std::ostream &os)
Definition field-type.cc:94
static bool NowStable(Tagged< FieldType > type)
Definition field-type.cc:63
static V8_EXPORT_PRIVATE bool Equals(Tagged< FieldType > type, Tagged< FieldType > other)
Definition field-type.cc:79
static V8_EXPORT_PRIVATE Tagged< FieldType > Class(Tagged< Map > map)
Definition field-type.cc:37
static Tagged< Map > AsClass(Tagged< FieldType > type)
Definition field-type.cc:51
static V8_EXPORT_PRIVATE Tagged< FieldType > Any()
Definition field-type.cc:22
static V8_EXPORT_PRIVATE Tagged< FieldType > None()
Definition field-type.cc:17
static bool NowContains(Tagged< FieldType > type, Tagged< Object > value)
static bool NowIs(Tagged< FieldType > type, Tagged< FieldType > other)
Definition field-type.cc:68
static constexpr Tagged< Smi > FromInt(int value)
Definition smi.h:38
V8_INLINE constexpr StorageType ptr() const
bool IsNone(Tagged< FieldType > obj)
Definition field-type.h:50
Tagged(T object) -> Tagged< T >
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
bool IsClass(Tagged< FieldType > obj)
Definition field-type.cc:48
V8_INLINE constexpr bool IsHeapObject(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:669
bool IsAny(Tagged< FieldType > obj)
Definition field-type.h:51
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK(condition)
Definition logging.h:482