1 // Copyright 2020 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_HEAP_CONCURRENT_ALLOCATOR_INL_H_
6 #define V8_HEAP_CONCURRENT_ALLOCATOR_INL_H_
7
8 #include "include/v8-internal.h"
9 #include "src/common/globals.h"
10 #include "src/heap/concurrent-allocator.h"
11 #include "src/heap/heap.h"
12 #include "src/heap/incremental-marking.h"
13 #include "src/heap/local-heap.h"
14 #include "src/heap/spaces-inl.h"
15 #include "src/heap/spaces.h"
16 #include "src/objects/heap-object.h"
17
18 namespace v8 {
19 namespace internal {
20
AllocateRaw(int object_size, AllocationAlignment alignment, AllocationOrigin origin)21 AllocationResult ConcurrentAllocator::AllocateRaw(int object_size,
22 AllocationAlignment alignment,
23 AllocationOrigin origin) {
24 DCHECK(!FLAG_enable_third_party_heap);
25 // TODO(dinfuehr): Add support for allocation observers
26 #ifdef DEBUG
27 if (local_heap_) local_heap_->VerifyCurrent();
28 #endif
29
30 if (object_size > kMaxLabObjectSize) {
31 return AllocateOutsideLab(object_size, alignment, origin);
32 }
33
34 return AllocateInLab(object_size, alignment, origin);
35 }
36
AllocateInLab( int object_size, AllocationAlignment alignment, AllocationOrigin origin)37 AllocationResult ConcurrentAllocator::AllocateInLab(
38 int object_size, AllocationAlignment alignment, AllocationOrigin origin) {
39 AllocationResult allocation = lab_.AllocateRawAligned(object_size, alignment);
40 return allocation.IsFailure()
41 ? AllocateInLabSlow(object_size, alignment, origin)
42 : allocation;
43 }
44
45 } // namespace internal
46 } // namespace v8
47
48 #endif // V8_HEAP_CONCURRENT_ALLOCATOR_INL_H_
49