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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/zone/zone-containers.h ('k') | test/cctest/cctest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone/zone-segment.h
diff --git a/src/zone/zone-segment.h b/src/zone/zone-segment.h
new file mode 100644
index 0000000000000000000000000000000000000000..140112c102bd85864c5683c0053d880a5f03562c
--- /dev/null
+++ b/src/zone/zone-segment.h
@@ -0,0 +1,52 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_ZONE_ZONE_SEGMENT_H_
+#define V8_ZONE_ZONE_SEGMENT_H_
+
+#include "src/v8.h"
+
+// Segments represent chunks of memory: They have starting address
+// (encoded in the this pointer) and a size in bytes. Segments are
+// chained together forming a LIFO structure with the newest segment
+// available as segment_head_. Segments are allocated using malloc()
+// and de-allocated using free().
+namespace v8 {
+namespace internal {
+
+// Forward declaration
+class Zone;
+
+class Segment {
+ public:
+ void Initialize(Segment* next, size_t size, Zone* zone) {
+ next_ = next;
+ size_ = size;
+ zone_ = zone;
+ }
+
+ Zone* zone() const { return zone_; }
+ void set_zone(Zone* const zone) { zone_ = zone; }
+
+ Segment* next() const { return next_; }
+ void set_next(Segment* const next) { next_ = next; }
+
+ size_t size() const { return size_; }
+ size_t capacity() const { return size_ - sizeof(Segment); }
+
+ Address start() const { return address(sizeof(Segment)); }
+ Address end() const { return address(size_); }
+
+ private:
+ // Computes the address of the nth byte in this segment.
+ Address address(size_t n) const { return Address(this) + n; }
+
+ Zone* zone_;
+ Segment* next_;
+ size_t size_;
+};
+} // namespace internal
+} // namespace v8
+
+#endif // V8_ZONE_ZONE_SEGMENT_H_
« 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