Skip to content
This repository was archived by the owner on Feb 11, 2020. It is now read-only.

Commit 03975be

Browse files
jaro-sevcikCommit bot
authored andcommitted
[turbofan] Remove some clever-but-wrong bits from select lowering.
BUG=chromium:600593 LOG=n [email protected] Review URL: https://codereview.chromium.org/1870763003 Cr-Commit-Position: refs/heads/master@{#35347}
1 parent d721121 commit 03975be

File tree

5 files changed

+25
-133
lines changed

5 files changed

+25
-133
lines changed

src/compiler/select-lowering.cc

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ namespace internal {
1515
namespace compiler {
1616

1717
SelectLowering::SelectLowering(Graph* graph, CommonOperatorBuilder* common)
18-
: common_(common),
19-
graph_(graph),
20-
merges_(Merges::key_compare(), Merges::allocator_type(graph->zone())) {}
21-
18+
: common_(common), graph_(graph) {}
2219

2320
SelectLowering::~SelectLowering() {}
2421

@@ -30,58 +27,16 @@ Reduction SelectLowering::Reduce(Node* node) {
3027
Node* cond = node->InputAt(0);
3128
Node* vthen = node->InputAt(1);
3229
Node* velse = node->InputAt(2);
33-
Node* merge = nullptr;
34-
35-
// Check if we already have a diamond for this condition.
36-
auto range = merges_.equal_range(cond);
37-
for (auto i = range.first;; ++i) {
38-
if (i == range.second) {
39-
// Create a new diamond for this condition and remember its merge node.
40-
Diamond d(graph(), common(), cond, p.hint());
41-
merges_.insert(std::make_pair(cond, d.merge));
42-
merge = d.merge;
43-
break;
44-
}
45-
46-
// If the diamond is reachable from the Select, merging them would result in
47-
// an unschedulable graph, so we cannot reuse the diamond in that case.
48-
merge = i->second;
49-
if (!ReachableFrom(merge, node)) {
50-
break;
51-
}
52-
}
5330

54-
// Create a Phi hanging off the previously determined merge.
31+
// Create a diamond and a phi.
32+
Diamond d(graph(), common(), cond, p.hint());
5533
node->ReplaceInput(0, vthen);
5634
node->ReplaceInput(1, velse);
57-
node->ReplaceInput(2, merge);
35+
node->ReplaceInput(2, d.merge);
5836
NodeProperties::ChangeOp(node, common()->Phi(p.representation(), 2));
5937
return Changed(node);
6038
}
6139

62-
63-
bool SelectLowering::ReachableFrom(Node* const sink, Node* const source) {
64-
// TODO(turbofan): This is probably horribly expensive, and it should be moved
65-
// into node.h or somewhere else?!
66-
Zone zone(graph()->zone()->allocator());
67-
std::queue<Node*, NodeDeque> queue((NodeDeque(&zone)));
68-
BoolVector visited(graph()->NodeCount(), false, &zone);
69-
queue.push(source);
70-
visited[source->id()] = true;
71-
while (!queue.empty()) {
72-
Node* current = queue.front();
73-
if (current == sink) return true;
74-
queue.pop();
75-
for (auto input : current->inputs()) {
76-
if (!visited[input->id()]) {
77-
queue.push(input);
78-
visited[input->id()] = true;
79-
}
80-
}
81-
}
82-
return false;
83-
}
84-
8540
} // namespace compiler
8641
} // namespace internal
8742
} // namespace v8

src/compiler/select-lowering.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
#ifndef V8_COMPILER_SELECT_LOWERING_H_
66
#define V8_COMPILER_SELECT_LOWERING_H_
77

8-
#include <map>
9-
108
#include "src/compiler/graph-reducer.h"
11-
#include "src/zone-allocator.h"
129

1310
namespace v8 {
1411
namespace internal {
@@ -28,17 +25,11 @@ class SelectLowering final : public Reducer {
2825
Reduction Reduce(Node* node) override;
2926

3027
private:
31-
typedef std::multimap<Node*, Node*, std::less<Node*>,
32-
zone_allocator<std::pair<Node* const, Node*>>> Merges;
33-
34-
bool ReachableFrom(Node* const sink, Node* const source);
35-
3628
CommonOperatorBuilder* common() const { return common_; }
3729
Graph* graph() const { return graph_; }
3830

3931
CommonOperatorBuilder* common_;
4032
Graph* graph_;
41-
Merges merges_;
4233
};
4334

4435
} // namespace compiler
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2016 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+
// Flags: --allow-natives-syntax
6+
7+
"use strict"
8+
9+
function f(c) {
10+
if (c) { throw new Error(); }
11+
throw new Error();
12+
};
13+
14+
function Error() {
15+
return arguments.length;
16+
}
17+
18+
assertThrows(function() { f(true); });
19+
assertThrows(function() { f(false); });
20+
%OptimizeFunctionOnNextCall(f);
21+
assertThrows(function() { f(true); });

test/unittests/compiler/select-lowering-unittest.cc

Lines changed: 0 additions & 74 deletions
This file was deleted.

test/unittests/unittests.gyp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
'compiler/opcodes-unittest.cc',
8484
'compiler/register-allocator-unittest.cc',
8585
'compiler/schedule-unittest.cc',
86-
'compiler/select-lowering-unittest.cc',
8786
'compiler/scheduler-unittest.cc',
8887
'compiler/scheduler-rpo-unittest.cc',
8988
'compiler/simplified-operator-reducer-unittest.cc',

0 commit comments

Comments
 (0)