V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
allocation-builder-inl.h
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 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  Allocate(size, NOT_TENURED, Type::OtherInternal());
24  Store(AccessBuilder::ForMap(), map);
25  STATIC_ASSERT(static_cast<int>(Context::kLengthOffset) ==
26  static_cast<int>(FixedArray::kLengthOffset));
27  Store(AccessBuilder::ForFixedArrayLength(),
28  jsgraph()->Constant(variadic_part_length));
29 }
30 
31 // Compound allocation of a FixedArray.
32 void AllocationBuilder::AllocateArray(int length, Handle<Map> map,
33  PretenureFlag pretenure) {
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  : FixedDoubleArray::SizeFor(length);
39  Allocate(size, pretenure, Type::OtherInternal());
40  Store(AccessBuilder::ForMap(), map);
41  Store(AccessBuilder::ForFixedArrayLength(), jsgraph()->Constant(length));
42 }
43 
44 } // namespace compiler
45 } // namespace internal
46 } // namespace v8
47 
48 #endif // V8_COMPILER_ALLOCATION_BUILDER_INL_H_
Definition: libplatform.h:13