OLD | NEW |
---|---|
(Empty) | |
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 | |
marja
2016/09/19 08:05:11
You need include guards here too
heimbuef
2016/09/19 10:47:52
Done.
| |
5 #include "src/v8.h" | |
6 | |
7 // Segments represent chunks of memory: They have starting address | |
8 // (encoded in the this pointer) and a size in bytes. Segments are | |
9 // chained together forming a LIFO structure with the newest segment | |
10 // available as segment_head_. Segments are allocated using malloc() | |
11 // and de-allocated using free(). | |
12 namespace v8 { | |
13 namespace internal { | |
14 | |
15 // Forward declaration | |
16 class Zone; | |
17 | |
18 class Segment { | |
19 public: | |
20 void Initialize(Segment* next, size_t size, Zone* zone) { | |
21 next_ = next; | |
22 size_ = size; | |
23 zone_ = zone; | |
24 } | |
25 | |
26 Zone* zone() const { return zone_; } | |
27 void set_zone(Zone* const zone) { zone_ = zone; } | |
28 | |
29 Segment* next() const { return next_; } | |
30 void set_next(Segment* const next) { next_ = next; } | |
31 | |
32 size_t size() const { return size_; } | |
33 size_t capacity() const { return size_ - sizeof(Segment); } | |
34 | |
35 Address start() const { return address(sizeof(Segment)); } | |
36 Address end() const { return address(size_); } | |
37 | |
38 private: | |
39 // Computes the address of the nth byte in this segment. | |
40 Address address(size_t n) const { return Address(this) + n; } | |
41 | |
42 Zone* zone_; | |
43 Segment* next_; | |
44 size_t size_; | |
45 }; | |
46 } // namespace internal | |
47 } // namespace v8 | |
OLD | NEW |