summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/cppgc/heap-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/cppgc/heap-inl.h')
-rw-r--r--deps/v8/src/heap/cppgc/heap-inl.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/deps/v8/src/heap/cppgc/heap-inl.h b/deps/v8/src/heap/cppgc/heap-inl.h
new file mode 100644
index 0000000000..28a4a14139
--- /dev/null
+++ b/deps/v8/src/heap/cppgc/heap-inl.h
@@ -0,0 +1,36 @@
+// Copyright 2020 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/heap/cppgc/heap.h"
+
+#include "src/heap/cppgc/globals.h"
+#include "src/heap/cppgc/heap-object-header-inl.h"
+
+#ifndef V8_HEAP_CPPGC_HEAP_INL_H_
+#define V8_HEAP_CPPGC_HEAP_INL_H_
+
+namespace cppgc {
+namespace internal {
+
+void* Heap::Allocate(size_t size, GCInfoIndex index) {
+ // TODO(chromium:1056170): This is merely a dummy implementation and will be
+ // replaced with proper allocation code throughout the migration.
+ size_t allocation_size = size + sizeof(HeapObjectHeader);
+ // The allocation size calculation can overflow for large sizes.
+ CHECK_GT(allocation_size, size);
+ // calloc() provides stricter alignment guarantees than the GC. Allocate
+ // a multiple of kAllocationGranularity to follow restrictions of
+ // HeapObjectHeader.
+ allocation_size = (allocation_size + kAllocationMask) & ~kAllocationMask;
+ void* memory = calloc(1, allocation_size);
+ HeapObjectHeader* header =
+ new (memory) HeapObjectHeader(allocation_size, index);
+ objects_.push_back(header);
+ return header->Payload();
+}
+
+} // namespace internal
+} // namespace cppgc
+
+#endif // V8_HEAP_CPPGC_HEAP_INL_H_