Line data Source code
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 : // FreeSpace are fixed-size free memory blocks used by the heap and GC.
17 : // They look like heap objects (are heap object tagged and have a map) so that
18 : // the heap remains iterable. They have a size and a next pointer.
19 : // The next pointer is the raw address of the next FreeSpace object (or NULL)
20 : // in the free list.
21 : class FreeSpace : public HeapObject {
22 : public:
23 : // [size]: size of the free space including the header.
24 : inline int size() const;
25 : inline void set_size(int value);
26 :
27 : inline int relaxed_read_size() const;
28 : inline void relaxed_write_size(int value);
29 :
30 : inline int Size();
31 :
32 : // Accessors for the next field.
33 : inline FreeSpace next();
34 : inline void set_next(FreeSpace next);
35 :
36 : inline static FreeSpace cast(HeapObject obj);
37 : inline static FreeSpace unchecked_cast(const Object obj);
38 :
39 : // Dispatched behavior.
40 : DECL_PRINTER(FreeSpace)
41 : DECL_VERIFIER(FreeSpace)
42 :
43 : // Layout description.
44 : #define FREE_SPACE_FIELDS(V) \
45 : V(kSizeOffset, kTaggedSize) \
46 : V(kNextOffset, kTaggedSize) \
47 : /* Header size. */ \
48 : V(kSize, 0)
49 :
50 : DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, FREE_SPACE_FIELDS)
51 : #undef FREE_SPACE_FIELDS
52 :
53 2 : OBJECT_CONSTRUCTORS(FreeSpace, HeapObject);
54 : };
55 :
56 : } // namespace internal
57 : } // namespace v8
58 :
59 : #include "src/objects/object-macros-undef.h"
60 :
61 : #endif // V8_OBJECTS_FREE_SPACE_H_
|