Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: src/zone/zone-segment.h

Issue 2344143003: Moved zones and zone related stuff in its own directory. (Closed)
Patch Set: Merge branch 'master' into zonefolder Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/zone/zone-containers.h ('k') | test/cctest/cctest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
5 #ifndef V8_ZONE_ZONE_SEGMENT_H_
6 #define V8_ZONE_ZONE_SEGMENT_H_
7
8 #include "src/v8.h"
9
10 // Segments represent chunks of memory: They have starting address
11 // (encoded in the this pointer) and a size in bytes. Segments are
12 // chained together forming a LIFO structure with the newest segment
13 // available as segment_head_. Segments are allocated using malloc()
14 // and de-allocated using free().
15 namespace v8 {
16 namespace internal {
17
18 // Forward declaration
19 class Zone;
20
21 class Segment {
22 public:
23 void Initialize(Segment* next, size_t size, Zone* zone) {
24 next_ = next;
25 size_ = size;
26 zone_ = zone;
27 }
28
29 Zone* zone() const { return zone_; }
30 void set_zone(Zone* const zone) { zone_ = zone; }
31
32 Segment* next() const { return next_; }
33 void set_next(Segment* const next) { next_ = next; }
34
35 size_t size() const { return size_; }
36 size_t capacity() const { return size_ - sizeof(Segment); }
37
38 Address start() const { return address(sizeof(Segment)); }
39 Address end() const { return address(size_); }
40
41 private:
42 // Computes the address of the nth byte in this segment.
43 Address address(size_t n) const { return Address(this) + n; }
44
45 Zone* zone_;
46 Segment* next_;
47 size_t size_;
48 };
49 } // namespace internal
50 } // namespace v8
51
52 #endif // V8_ZONE_ZONE_SEGMENT_H_
OLDNEW
« no previous file with comments | « src/zone/zone-containers.h ('k') | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698