• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 #ifndef V8_HEAP_REMEMBERED_SET_INL_H_
6 #define V8_HEAP_REMEMBERED_SET_INL_H_
7 
8 #include "src/common/ptr-compr-inl.h"
9 #include "src/heap/remembered-set.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 template <typename Callback>
UpdateTypedSlot(Heap * heap,SlotType slot_type,Address addr,Callback callback)15 SlotCallbackResult UpdateTypedSlotHelper::UpdateTypedSlot(Heap* heap,
16                                                           SlotType slot_type,
17                                                           Address addr,
18                                                           Callback callback) {
19   switch (slot_type) {
20     case SlotType::kCodeEntry: {
21       RelocInfo rinfo(addr, RelocInfo::CODE_TARGET, 0, Code());
22       return UpdateCodeTarget(&rinfo, callback);
23     }
24     case SlotType::kConstPoolCodeEntry: {
25       return UpdateCodeEntry(addr, callback);
26     }
27     case SlotType::kEmbeddedObjectCompressed: {
28       RelocInfo rinfo(addr, RelocInfo::COMPRESSED_EMBEDDED_OBJECT, 0, Code());
29       return UpdateEmbeddedPointer(heap, &rinfo, callback);
30     }
31     case SlotType::kEmbeddedObjectFull: {
32       RelocInfo rinfo(addr, RelocInfo::FULL_EMBEDDED_OBJECT, 0, Code());
33       return UpdateEmbeddedPointer(heap, &rinfo, callback);
34     }
35     case SlotType::kEmbeddedObjectData: {
36       RelocInfo rinfo(addr, RelocInfo::DATA_EMBEDDED_OBJECT, 0, Code());
37       return UpdateEmbeddedPointer(heap, &rinfo, callback);
38     }
39     case SlotType::kConstPoolEmbeddedObjectCompressed: {
40       HeapObject old_target = HeapObject::cast(Object(
41           DecompressTaggedAny(heap->isolate(), base::Memory<Tagged_t>(addr))));
42       HeapObject new_target = old_target;
43       SlotCallbackResult result = callback(FullMaybeObjectSlot(&new_target));
44       DCHECK(!HasWeakHeapObjectTag(new_target));
45       if (new_target != old_target) {
46         base::Memory<Tagged_t>(addr) = CompressTagged(new_target.ptr());
47       }
48       return result;
49     }
50     case SlotType::kConstPoolEmbeddedObjectFull: {
51       return callback(FullMaybeObjectSlot(addr));
52     }
53     case SlotType::kCleared:
54       break;
55   }
56   UNREACHABLE();
57 }
58 
59 }  // namespace internal
60 }  // namespace v8
61 #endif  // V8_HEAP_REMEMBERED_SET_INL_H_
62