2015-01-20 09:45:02 +00:00
|
|
|
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef V8_COMPILER_LOOP_PEELING_H_
|
|
|
|
#define V8_COMPILER_LOOP_PEELING_H_
|
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
#include "src/base/compiler-specific.h"
|
2019-05-24 13:51:59 +00:00
|
|
|
#include "src/common/globals.h"
|
2015-01-20 09:45:02 +00:00
|
|
|
#include "src/compiler/loop-analysis.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
|
|
|
|
2018-05-18 14:04:36 +00:00
|
|
|
class NodeOriginTable;
|
2017-12-13 08:48:00 +00:00
|
|
|
class SourcePositionTable;
|
|
|
|
|
2015-01-20 09:45:02 +00:00
|
|
|
// Represents the output of peeling a loop, which is basically the mapping
|
|
|
|
// from the body of the loop to the corresponding nodes in the peeled
|
|
|
|
// iteration.
|
2016-10-17 10:01:42 +00:00
|
|
|
class V8_EXPORT_PRIVATE PeeledIteration : public NON_EXPORTED_BASE(ZoneObject) {
|
2015-01-20 09:45:02 +00:00
|
|
|
public:
|
|
|
|
// Maps {node} to its corresponding copy in the peeled iteration, if
|
|
|
|
// the node was part of the body of the loop. Returns {node} otherwise.
|
|
|
|
Node* map(Node* node);
|
|
|
|
|
|
|
|
protected:
|
2018-09-17 11:30:48 +00:00
|
|
|
PeeledIteration() = default;
|
2015-01-20 09:45:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CommonOperatorBuilder;
|
|
|
|
|
|
|
|
// Implements loop peeling.
|
2016-10-17 10:01:42 +00:00
|
|
|
class V8_EXPORT_PRIVATE LoopPeeler {
|
2015-01-20 09:45:02 +00:00
|
|
|
public:
|
2017-12-13 08:48:00 +00:00
|
|
|
LoopPeeler(Graph* graph, CommonOperatorBuilder* common, LoopTree* loop_tree,
|
2018-05-18 14:04:36 +00:00
|
|
|
Zone* tmp_zone, SourcePositionTable* source_positions,
|
|
|
|
NodeOriginTable* node_origins)
|
2017-12-13 08:48:00 +00:00
|
|
|
: graph_(graph),
|
|
|
|
common_(common),
|
|
|
|
loop_tree_(loop_tree),
|
|
|
|
tmp_zone_(tmp_zone),
|
2018-05-18 14:04:36 +00:00
|
|
|
source_positions_(source_positions),
|
|
|
|
node_origins_(node_origins) {}
|
2017-12-13 08:48:00 +00:00
|
|
|
bool CanPeel(LoopTree::Loop* loop);
|
|
|
|
PeeledIteration* Peel(LoopTree::Loop* loop);
|
|
|
|
void PeelInnerLoopsOfTree();
|
|
|
|
|
|
|
|
static void EliminateLoopExits(Graph* graph, Zone* tmp_zone);
|
2016-07-15 10:23:29 +00:00
|
|
|
static const size_t kMaxPeeledNodes = 1000;
|
2017-12-13 08:48:00 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Graph* const graph_;
|
|
|
|
CommonOperatorBuilder* const common_;
|
|
|
|
LoopTree* const loop_tree_;
|
|
|
|
Zone* const tmp_zone_;
|
|
|
|
SourcePositionTable* const source_positions_;
|
2018-05-18 14:04:36 +00:00
|
|
|
NodeOriginTable* const node_origins_;
|
2017-12-13 08:48:00 +00:00
|
|
|
|
|
|
|
void PeelInnerLoops(LoopTree::Loop* loop);
|
2015-01-20 09:45:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif // V8_COMPILER_LOOP_PEELING_H_
|