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_H_ 6 #define V8_OBJECTS_FREE_SPACE_H_ 7 8 #include "src/objects/heap-object.h" 9 10 // Has to be the last include (doesn't have include guards): 11 #include "src/objects/object-macros.h" 12 13 namespace v8 { 14 namespace internal { 15 16 #include "torque-generated/src/objects/free-space-tq.inc" 17 18 // FreeSpace are fixed-size free memory blocks used by the heap and GC. 19 // They look like heap objects (are heap object tagged and have a map) so that 20 // the heap remains iterable. They have a size and a next pointer. 21 // The next pointer is the raw address of the next FreeSpace object (or NULL) 22 // in the free list. 23 class FreeSpace : public TorqueGeneratedFreeSpace<FreeSpace, HeapObject> { 24 public: 25 // [size]: size of the free space including the header. 26 inline int relaxed_read_size() const; 27 inline void relaxed_write_size(int value); 28 29 inline int Size(); 30 31 // Accessors for the next field. 32 inline FreeSpace next(); 33 inline void set_next(FreeSpace next); 34 35 inline static FreeSpace cast(HeapObject obj); 36 inline static FreeSpace unchecked_cast(const Object obj); 37 38 // Dispatched behavior. 39 DECL_PRINTER(FreeSpace) 40 41 private: 42 inline bool IsValid(); 43 44 TQ_OBJECT_CONSTRUCTORS(FreeSpace) 45 }; 46 47 } // namespace internal 48 } // namespace v8 49 50 #include "src/objects/object-macros-undef.h" 51 52 #endif // V8_OBJECTS_FREE_SPACE_H_ 53