v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
loop-unrolling.h
Go to the documentation of this file.
1
// Copyright 2021 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_LOOP_UNROLLING_H_
6
#define V8_COMPILER_LOOP_UNROLLING_H_
7
8
// Loop unrolling is an optimization that copies the body of a loop and creates
9
// a fresh loop, whose iteration corresponds to 2 or more iterations of the
10
// initial loop. For a high-level description of the algorithm see
11
// https://bit.ly/3G0VdWW.
12
13
#include "
src/compiler/common-operator.h
"
14
#include "
src/compiler/loop-analysis.h
"
15
16
namespace
v8
{
17
namespace
internal
{
18
namespace
compiler {
19
20
static
constexpr
uint32_t
kMaximumUnnestedSize
= 50;
21
static
constexpr
uint32_t
kMaximumUnrollingCount
= 5;
22
23
// A simple heuristic to decide how many times to unroll a loop. Favors small
24
// and deeply nested loops.
25
// TODO(manoskouk): Investigate how this can be improved.
26
V8_INLINE
uint32_t
unrolling_count_heuristic
(uint32_t size, uint32_t depth) {
27
return
std::min((depth + 1) *
kMaximumUnnestedSize
/ size,
28
kMaximumUnrollingCount
);
29
}
30
31
V8_INLINE
uint32_t
maximum_unrollable_size
(uint32_t depth) {
32
return
(depth + 1) *
kMaximumUnnestedSize
;
33
}
34
35
void
UnrollLoop
(Node* loop_node,
ZoneUnorderedSet<Node*>
* loop, uint32_t depth,
36
TFGraph* graph, CommonOperatorBuilder* common,
Zone
* tmp_zone,
37
SourcePositionTable
*
source_positions
,
38
NodeOriginTable* node_origins);
39
40
}
// namespace compiler
41
}
// namespace internal
42
}
// namespace v8
43
44
#endif
// V8_COMPILER_LOOP_UNROLLING_H_
v8::internal::SourcePositionTable
Definition
profile-generator.h:33
v8::internal::ZoneUnorderedSet
Definition
zone-containers.h:727
v8::internal::Zone
Definition
zone.h:43
common-operator.h
source_positions
SourcePositionTable * source_positions
Definition
graph-builder.cc:72
loop-analysis.h
v8::internal::compiler::kMaximumUnnestedSize
static constexpr uint32_t kMaximumUnnestedSize
Definition
loop-unrolling.h:20
v8::internal::compiler::kMaximumUnrollingCount
static constexpr uint32_t kMaximumUnrollingCount
Definition
loop-unrolling.h:21
v8::internal::compiler::unrolling_count_heuristic
V8_INLINE uint32_t unrolling_count_heuristic(uint32_t size, uint32_t depth)
Definition
loop-unrolling.h:26
v8::internal::compiler::maximum_unrollable_size
V8_INLINE uint32_t maximum_unrollable_size(uint32_t depth)
Definition
loop-unrolling.h:31
v8::internal::compiler::UnrollLoop
void UnrollLoop(Node *loop_node, ZoneUnorderedSet< Node * > *loop, uint32_t depth, TFGraph *graph, CommonOperatorBuilder *common, Zone *tmp_zone, SourcePositionTable *source_positions, NodeOriginTable *node_origins)
Definition
loop-unrolling.cc:17
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
V8_INLINE
#define V8_INLINE
Definition
v8config.h:500
src
compiler
loop-unrolling.h
Generated on Sun Apr 6 2025 21:08:52 for v8 by
1.12.0