Commit 2b4eb88c authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Cache conversions inserted during typed lowering.

This greatly reduces the number of nodes in the graph (by more than 20x in
some extreme cases) for the Emscripten python interpreter main function.

BUG=v8:3763
LOG=y
TEST=cctest,mjsunit,unittests
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/802353003

Cr-Commit-Position: refs/heads/master@{#25840}
parent d287f225
This diff is collapsed.
......@@ -22,7 +22,7 @@ class MachineOperatorBuilder;
// Lowers JS-level operators to simplified operators based on types.
class JSTypedLowering FINAL : public Reducer {
public:
explicit JSTypedLowering(JSGraph* jsgraph);
JSTypedLowering(JSGraph* jsgraph, Zone* zone);
~JSTypedLowering() FINAL {}
Reduction Reduce(Node* node) FINAL;
......@@ -52,6 +52,12 @@ class JSTypedLowering FINAL : public Reducer {
Reduction ReduceUI32Shift(Node* node, Signedness left_signedness,
const Operator* shift_op);
Node* ConvertToBoolean(Node* input);
Node* ConvertToNumber(Node* input);
template <IrOpcode::Value>
Node* FindConversion(Node* input);
void InsertConversion(Node* conversion);
Node* Word32Shl(Node* const lhs, int32_t const rhs);
Factory* factory() const;
......@@ -64,6 +70,7 @@ class JSTypedLowering FINAL : public Reducer {
JSGraph* jsgraph_;
SimplifiedOperatorBuilder simplified_;
ZoneVector<Node*> conversions_; // Cache inserted JSToXXX() conversions.
Type* zero_range_;
Type* one_range_;
Type* zero_thirtyone_range_;
......
......@@ -419,7 +419,7 @@ struct TypedLoweringPhase {
ValueNumberingReducer vn_reducer(temp_zone);
LoadElimination load_elimination;
JSBuiltinReducer builtin_reducer(data->jsgraph());
JSTypedLowering typed_lowering(data->jsgraph());
JSTypedLowering typed_lowering(data->jsgraph(), temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
graph_reducer.AddReducer(&vn_reducer);
......
......@@ -76,7 +76,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
Node* reduce(Node* node) {
JSGraph jsgraph(&graph, &common, &javascript, &machine);
JSTypedLowering reducer(&jsgraph);
JSTypedLowering reducer(&jsgraph, main_zone());
Reduction reduction = reducer.Reduce(node);
if (reduction.Changed()) return reduction.replacement();
return node;
......@@ -990,7 +990,7 @@ TEST(OrderNumberBinopEffects1) {
};
for (size_t j = 0; j < arraysize(ops); j += 2) {
BinopEffectsTester B(ops[j], Type::String(), Type::String());
BinopEffectsTester B(ops[j], Type::Symbol(), Type::Symbol());
CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true);
......@@ -1063,8 +1063,8 @@ TEST(OrderCompareEffects) {
CHECK_EQ(B.p1, i0->InputAt(0));
CHECK_EQ(B.p0, i1->InputAt(0));
// But effects should be ordered start -> i1 -> i0 -> effect_use
B.CheckEffectOrdering(i1, i0);
// But effects should be ordered start -> i1 -> effect_use
B.CheckEffectOrdering(i1);
}
for (size_t j = 0; j < arraysize(ops); j += 2) {
......
......@@ -46,7 +46,7 @@ class JSTypedLoweringTest : public TypedGraphTest {
Reduction Reduce(Node* node) {
MachineOperatorBuilder machine(zone());
JSGraph jsgraph(graph(), common(), javascript(), &machine);
JSTypedLowering reducer(&jsgraph);
JSTypedLowering reducer(&jsgraph, zone());
return reducer.Reduce(node);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment