summaryrefslogtreecommitdiff
path: root/deps/v8/src/snapshot/builtin-serializer-allocator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/snapshot/builtin-serializer-allocator.cc')
-rw-r--r--deps/v8/src/snapshot/builtin-serializer-allocator.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/deps/v8/src/snapshot/builtin-serializer-allocator.cc b/deps/v8/src/snapshot/builtin-serializer-allocator.cc
new file mode 100644
index 0000000000..dbb5789721
--- /dev/null
+++ b/deps/v8/src/snapshot/builtin-serializer-allocator.cc
@@ -0,0 +1,67 @@
+// Copyright 2017 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.
+
+#include "src/snapshot/builtin-serializer-allocator.h"
+
+#include "src/heap/heap-inl.h"
+
+namespace v8 {
+namespace internal {
+
+SerializerReference BuiltinSerializerAllocator::Allocate(AllocationSpace space,
+ uint32_t size) {
+ DCHECK_EQ(space, CODE_SPACE);
+ DCHECK_GT(size, 0);
+
+ // Builtin serialization & deserialization does not use the reservation
+ // system. Instead of worrying about chunk indices and offsets, we simply
+ // need to generate unique offsets here.
+
+ const uint32_t virtual_chunk_index = 0;
+ const auto ref = SerializerReference::BackReference(
+ CODE_SPACE, virtual_chunk_index, virtual_chunk_offset_);
+
+ virtual_chunk_size_ += size;
+ virtual_chunk_offset_ += kObjectAlignment; // Needs to be aligned.
+
+ return ref;
+}
+
+#ifdef DEBUG
+bool BuiltinSerializerAllocator::BackReferenceIsAlreadyAllocated(
+ SerializerReference reference) const {
+ DCHECK(reference.is_back_reference());
+ AllocationSpace space = reference.space();
+ DCHECK_EQ(space, CODE_SPACE);
+ DCHECK_EQ(reference.chunk_index(), 0);
+ return reference.chunk_offset() < virtual_chunk_offset_;
+}
+#endif // DEBUG
+
+std::vector<SerializedData::Reservation>
+BuiltinSerializerAllocator::EncodeReservations() const {
+ return std::vector<SerializedData::Reservation>();
+}
+
+void BuiltinSerializerAllocator::OutputStatistics() {
+ DCHECK(FLAG_serialization_statistics);
+
+ PrintF(" Spaces (bytes):\n");
+
+ STATIC_ASSERT(NEW_SPACE == 0);
+ for (int space = 0; space < kNumberOfSpaces; space++) {
+ PrintF("%16s", AllocationSpaceName(static_cast<AllocationSpace>(space)));
+ }
+ PrintF("\n");
+
+ STATIC_ASSERT(NEW_SPACE == 0);
+ for (int space = 0; space < kNumberOfSpaces; space++) {
+ uint32_t space_size = (space == CODE_SPACE) ? virtual_chunk_size_ : 0;
+ PrintF("%16d", space_size);
+ }
+ PrintF("\n");
+}
+
+} // namespace internal
+} // namespace v8