v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
maybe-object-inl.h
Go to the documentation of this file.
1// Copyright 2018 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_OBJECTS_MAYBE_OBJECT_INL_H_
6#define V8_OBJECTS_MAYBE_OBJECT_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
12#include "src/objects/casting.h"
13#include "src/objects/smi-inl.h"
15#include "src/objects/tagged.h"
16
17namespace v8 {
18namespace internal {
19
21 // Construct cleared weak ref value.
23#ifdef V8_COMPRESS_POINTERS
24 // This is necessary to make pointer decompression computation also
25 // suitable for cleared weak references.
28#else
30#endif
31 // The rest of the code will check only the lower 32-bits.
32 DCHECK_EQ(kClearedWeakHeapObjectLower32, static_cast<uint32_t>(value));
33 return Tagged<ClearedWeakValue>(value);
34}
35
46
47template <typename THeapObjectSlot>
48void UpdateHeapObjectReferenceSlot(THeapObjectSlot slot,
49 Tagged<HeapObject> value) {
50 static_assert(std::is_same<THeapObjectSlot, FullHeapObjectSlot>::value ||
51 std::is_same<THeapObjectSlot, HeapObjectSlot>::value,
52 "Only FullHeapObjectSlot and HeapObjectSlot are expected here");
53 Address old_value = (*slot).ptr();
54 DCHECK(!HAS_SMI_TAG(old_value));
55 Address new_value = value.ptr();
57
58#ifdef DEBUG
59 bool weak_before = HAS_WEAK_HEAP_OBJECT_TAG(old_value);
60#endif
61
63 Tagged<MaybeObject>(new_value | (old_value & kWeakHeapObjectMask))));
64
65#ifdef DEBUG
66 bool weak_after = HAS_WEAK_HEAP_OBJECT_TAG((*slot).ptr());
67 DCHECK_EQ(weak_before, weak_after);
68#endif
69}
70
71} // namespace internal
72} // namespace v8
73
74#endif // V8_OBJECTS_MAYBE_OBJECT_INL_H_
static V8_INLINE constexpr bool HasHeapObjectTag(Address value)
static V8_INLINE Address DecompressTagged(TOnHeapAddress on_heap_addr, Tagged_t raw_value)
V8_CONST static V8_INLINE Address base()
#define HAS_SMI_TAG(value)
Definition globals.h:1771
#define HAS_WEAK_HEAP_OBJECT_TAG(value)
Definition globals.h:1778
const Address kWeakHeapObjectMask
Definition globals.h:967
Tagged< ClearedWeakValue > ClearedValue(PtrComprCageBase cage_base)
Tagged< ClearedWeakValue > ClearedTrustedValue()
void UpdateHeapObjectReferenceSlot(THeapObjectSlot slot, Tagged< HeapObject > value)
return value
Definition map-inl.h:893
const uint32_t kClearedWeakHeapObjectLower32
Definition globals.h:981
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
#define DCHECK_EQ(v1, v2)
Definition logging.h:485