v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
allocation-builder-inl.h
Go to the documentation of this file.
1// Copyright 2018 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_COMPILER_ALLOCATION_BUILDER_INL_H_
6#define V8_COMPILER_ALLOCATION_BUILDER_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
12#include "src/heap/heap-inl.h"
14
15namespace v8 {
16namespace internal {
17namespace compiler {
18
20 Type type) {
21 CHECK_GT(size, 0);
22 DCHECK_LE(size, isolate()->heap()->MaxRegularHeapObjectSize(allocation));
26 graph()->NewNode(simplified()->Allocate(type, allocation),
27 jsgraph()->ConstantNoHole(size), effect_, control_);
29}
30
31void AllocationBuilder::AllocateContext(int variadic_part_length, MapRef map) {
32 DCHECK(base::IsInRange(map.instance_type(), FIRST_CONTEXT_TYPE,
33 LAST_CONTEXT_TYPE));
34 DCHECK_NE(NATIVE_CONTEXT_TYPE, map.instance_type());
35 int size = Context::SizeFor(variadic_part_length);
36 Allocate(size, AllocationType::kYoung, Type::OtherInternal());
38 static_assert(static_cast<int>(Context::kLengthOffset) ==
39 static_cast<int>(offsetof(FixedArray, length_)));
41 jsgraph()->ConstantNoHole(variadic_part_length));
42}
43
45 AllocationType allocation) {
46 DCHECK(map.instance_type() == FIXED_ARRAY_TYPE ||
47 map.instance_type() == FIXED_DOUBLE_ARRAY_TYPE);
48 int const size = (map.instance_type() == FIXED_ARRAY_TYPE)
49 ? FixedArray::SizeFor(length)
51 return size <= isolate()->heap()->MaxRegularHeapObjectSize(allocation);
52}
53
54// Compound allocation of a FixedArray.
56 AllocationType allocation) {
57 DCHECK(CanAllocateArray(length, map, allocation));
58 int size = (map.instance_type() == FIXED_ARRAY_TYPE)
59 ? FixedArray::SizeFor(length)
61 Allocate(size, allocation, Type::OtherInternal());
64 jsgraph()->ConstantNoHole(length));
65}
66
68 int length, MapRef map, AllocationType allocation) {
69 int const size = SloppyArgumentsElements::SizeFor(length);
70 return size <= isolate()->heap()->MaxRegularHeapObjectSize(allocation);
71}
72
74 int length, MapRef map, AllocationType allocation) {
75 DCHECK(CanAllocateSloppyArgumentElements(length, map, allocation));
76 int size = SloppyArgumentsElements::SizeFor(length);
77 Allocate(size, allocation, Type::OtherInternal());
80 jsgraph()->ConstantNoHole(length));
81}
82
83} // namespace compiler
84} // namespace internal
85} // namespace v8
86
87#endif // V8_COMPILER_ALLOCATION_BUILDER_INL_H_
static V8_INLINE constexpr int SizeFor(int length)
Definition contexts.h:503
V8_EXPORT_PRIVATE int MaxRegularHeapObjectSize(AllocationType allocation)
Definition heap-inl.h:185
static FieldAccess ForMap(WriteBarrierKind write_barrier=kMapWriteBarrier)
void AllocateSloppyArgumentElements(int length, MapRef map, AllocationType allocation=AllocationType::kYoung)
void AllocateArray(int length, MapRef map, AllocationType allocation=AllocationType::kYoung)
void Allocate(int size, AllocationType allocation=AllocationType::kYoung, Type type=Type::Any())
void AllocateContext(int variadic_part_length, MapRef map)
bool CanAllocateArray(int length, MapRef map, AllocationType allocation=AllocationType::kYoung)
bool CanAllocateSloppyArgumentElements(int length, MapRef map, AllocationType allocation=AllocationType::kYoung)
void Store(const FieldAccess &access, Node *value)
SimplifiedOperatorBuilder * simplified()
Node * NewNode(const Operator *op, int input_count, Node *const *inputs, bool incomplete=false)
const int length_
Definition mul-fft.cc:473
constexpr bool IsInRange(T value, U lower_limit, U higher_limit)
Definition bounds.h:20
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define CHECK_GT(lhs, rhs)
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK(condition)
Definition logging.h:482