Line data Source code
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 :
8 : #include "src/compiler/allocation-builder.h"
9 :
10 : #include "src/compiler/access-builder.h"
11 : #include "src/objects/map-inl.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 : namespace compiler {
16 :
17 49799 : void AllocationBuilder::AllocateContext(int variadic_part_length,
18 : Handle<Map> map) {
19 : DCHECK(
20 : IsInRange(map->instance_type(), FIRST_CONTEXT_TYPE, LAST_CONTEXT_TYPE));
21 : DCHECK_NE(NATIVE_CONTEXT_TYPE, map->instance_type());
22 : int size = Context::SizeFor(variadic_part_length);
23 49799 : Allocate(size, AllocationType::kYoung, Type::OtherInternal());
24 49799 : Store(AccessBuilder::ForMap(), map);
25 : STATIC_ASSERT(static_cast<int>(Context::kLengthOffset) ==
26 : static_cast<int>(FixedArray::kLengthOffset));
27 99598 : Store(AccessBuilder::ForFixedArrayLength(),
28 49799 : jsgraph()->Constant(variadic_part_length));
29 49799 : }
30 :
31 : // Compound allocation of a FixedArray.
32 9146 : void AllocationBuilder::AllocateArray(int length, Handle<Map> map,
33 : AllocationType allocation) {
34 : DCHECK(map->instance_type() == FIXED_ARRAY_TYPE ||
35 : map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE);
36 : int size = (map->instance_type() == FIXED_ARRAY_TYPE)
37 : ? FixedArray::SizeFor(length)
38 9146 : : FixedDoubleArray::SizeFor(length);
39 9146 : Allocate(size, allocation, Type::OtherInternal());
40 9146 : Store(AccessBuilder::ForMap(), map);
41 9146 : Store(AccessBuilder::ForFixedArrayLength(), jsgraph()->Constant(length));
42 9146 : }
43 :
44 : } // namespace compiler
45 : } // namespace internal
46 : } // namespace v8
47 :
48 : #endif // V8_COMPILER_ALLOCATION_BUILDER_INL_H_
|