• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FREE_SPACE_INL_H_
6 #define V8_OBJECTS_FREE_SPACE_INL_H_
7 
8 #include "src/execution/isolate.h"
9 #include "src/heap/heap-write-barrier-inl.h"
10 #include "src/heap/heap.h"
11 #include "src/objects/free-space.h"
12 #include "src/objects/objects-inl.h"
13 
14 // Has to be the last include (doesn't have include guards):
15 #include "src/objects/object-macros.h"
16 
17 namespace v8 {
18 namespace internal {
19 
20 #include "torque-generated/src/objects/free-space-tq-inl.inc"
21 
22 TQ_OBJECT_CONSTRUCTORS_IMPL(FreeSpace)
23 
RELAXED_SMI_ACCESSORS(FreeSpace,size,kSizeOffset)24 RELAXED_SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
25 
26 int FreeSpace::Size() { return size(); }
27 
next()28 FreeSpace FreeSpace::next() {
29   DCHECK(IsValid());
30   return FreeSpace::unchecked_cast(
31       TaggedField<Object, kNextOffset>::load(*this));
32 }
33 
set_next(FreeSpace next)34 void FreeSpace::set_next(FreeSpace next) {
35   DCHECK(IsValid());
36   RELAXED_WRITE_FIELD(*this, kNextOffset, next);
37 }
38 
cast(HeapObject o)39 FreeSpace FreeSpace::cast(HeapObject o) {
40   SLOW_DCHECK((!GetHeapFromWritableObject(o)->deserialization_complete()) ||
41               o.IsFreeSpace());
42   return bit_cast<FreeSpace>(o);
43 }
44 
unchecked_cast(const Object o)45 FreeSpace FreeSpace::unchecked_cast(const Object o) {
46   return bit_cast<FreeSpace>(o);
47 }
48 
IsValid()49 bool FreeSpace::IsValid() {
50   Heap* heap = GetHeapFromWritableObject(*this);
51   Object free_space_map =
52       Isolate::FromHeap(heap)->root(RootIndex::kFreeSpaceMap);
53   CHECK_IMPLIES(!map_slot().contains_value(free_space_map.ptr()),
54                 !heap->deserialization_complete() &&
55                     map_slot().contains_value(kNullAddress));
56   CHECK_LE(kNextOffset + kTaggedSize, relaxed_read_size());
57   return true;
58 }
59 
60 }  // namespace internal
61 }  // namespace v8
62 
63 #include "src/objects/object-macros-undef.h"
64 
65 #endif  // V8_OBJECTS_FREE_SPACE_INL_H_
66