| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
| 6 #include "src/codegen.h" | 6 #include "src/codegen.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/machine-operator-reducer.h" | 8 #include "src/compiler/machine-operator-reducer.h" |
| 9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
| 10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 | 50 |
| 51 class ReducerTester : public HandleAndZoneScope { | 51 class ReducerTester : public HandleAndZoneScope { |
| 52 public: | 52 public: |
| 53 explicit ReducerTester( | 53 explicit ReducerTester( |
| 54 int num_parameters = 0, | 54 int num_parameters = 0, |
| 55 MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) | 55 MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) |
| 56 : isolate(main_isolate()), | 56 : isolate(main_isolate()), |
| 57 binop(NULL), | 57 binop(NULL), |
| 58 unop(NULL), | 58 unop(NULL), |
| 59 machine(main_zone(), kMachPtr, flags), | 59 machine(main_zone(), MachineType::PointerRepresentation(), flags), |
| 60 common(main_zone()), | 60 common(main_zone()), |
| 61 graph(main_zone()), | 61 graph(main_zone()), |
| 62 javascript(main_zone()), | 62 javascript(main_zone()), |
| 63 typer(isolate, &graph), | 63 typer(isolate, &graph), |
| 64 jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine), | 64 jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine), |
| 65 maxuint32(Constant<int32_t>(kMaxUInt32)) { | 65 maxuint32(Constant<int32_t>(kMaxUInt32)) { |
| 66 Node* s = graph.NewNode(common.Start(num_parameters)); | 66 Node* s = graph.NewNode(common.Start(num_parameters)); |
| 67 graph.SetStart(s); | 67 graph.SetStart(s); |
| 68 } | 68 } |
| 69 | 69 |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 R.CheckFoldBinop<int32_t>(1, zero, x); // 0 <= x => 1 | 696 R.CheckFoldBinop<int32_t>(1, zero, x); // 0 <= x => 1 |
| 697 R.CheckFoldBinop<int32_t>(1, x, x); // x <= x => 1 | 697 R.CheckFoldBinop<int32_t>(1, x, x); // x <= x => 1 |
| 698 } | 698 } |
| 699 | 699 |
| 700 | 700 |
| 701 TEST(ReduceLoadStore) { | 701 TEST(ReduceLoadStore) { |
| 702 ReducerTester R; | 702 ReducerTester R; |
| 703 | 703 |
| 704 Node* base = R.Constant<int32_t>(11); | 704 Node* base = R.Constant<int32_t>(11); |
| 705 Node* index = R.Constant<int32_t>(4); | 705 Node* index = R.Constant<int32_t>(4); |
| 706 Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index, | 706 Node* load = R.graph.NewNode(R.machine.Load(MachineType::Int32()), base, |
| 707 R.graph.start(), R.graph.start()); | 707 index, R.graph.start(), R.graph.start()); |
| 708 | 708 |
| 709 { | 709 { |
| 710 MachineOperatorReducer reducer(&R.jsgraph); | 710 MachineOperatorReducer reducer(&R.jsgraph); |
| 711 Reduction reduction = reducer.Reduce(load); | 711 Reduction reduction = reducer.Reduce(load); |
| 712 CHECK(!reduction.Changed()); // loads should not be reduced. | 712 CHECK(!reduction.Changed()); // loads should not be reduced. |
| 713 } | 713 } |
| 714 | 714 |
| 715 { | 715 { |
| 716 Node* store = R.graph.NewNode( | 716 Node* store = R.graph.NewNode(R.machine.Store(StoreRepresentation( |
| 717 R.machine.Store(StoreRepresentation(kMachInt32, kNoWriteBarrier)), base, | 717 MachineType::Int32(), kNoWriteBarrier)), |
| 718 index, load, load, R.graph.start()); | 718 base, index, load, load, R.graph.start()); |
| 719 MachineOperatorReducer reducer(&R.jsgraph); | 719 MachineOperatorReducer reducer(&R.jsgraph); |
| 720 Reduction reduction = reducer.Reduce(store); | 720 Reduction reduction = reducer.Reduce(store); |
| 721 CHECK(!reduction.Changed()); // stores should not be reduced. | 721 CHECK(!reduction.Changed()); // stores should not be reduced. |
| 722 } | 722 } |
| 723 } | 723 } |
| 724 | 724 |
| 725 | 725 |
| 726 // TODO(titzer): test MachineOperatorReducer for Word64And | 726 // TODO(titzer): test MachineOperatorReducer for Word64And |
| 727 // TODO(titzer): test MachineOperatorReducer for Word64Or | 727 // TODO(titzer): test MachineOperatorReducer for Word64Or |
| 728 // TODO(titzer): test MachineOperatorReducer for Word64Xor | 728 // TODO(titzer): test MachineOperatorReducer for Word64Xor |
| (...skipping 16 matching lines...) Expand all Loading... |
| 745 // TODO(titzer): test MachineOperatorReducer for Float64Compare | 745 // TODO(titzer): test MachineOperatorReducer for Float64Compare |
| 746 // TODO(titzer): test MachineOperatorReducer for Float64Add | 746 // TODO(titzer): test MachineOperatorReducer for Float64Add |
| 747 // TODO(titzer): test MachineOperatorReducer for Float64Sub | 747 // TODO(titzer): test MachineOperatorReducer for Float64Sub |
| 748 // TODO(titzer): test MachineOperatorReducer for Float64Mul | 748 // TODO(titzer): test MachineOperatorReducer for Float64Mul |
| 749 // TODO(titzer): test MachineOperatorReducer for Float64Div | 749 // TODO(titzer): test MachineOperatorReducer for Float64Div |
| 750 // TODO(titzer): test MachineOperatorReducer for Float64Mod | 750 // TODO(titzer): test MachineOperatorReducer for Float64Mod |
| 751 | 751 |
| 752 } // namespace compiler | 752 } // namespace compiler |
| 753 } // namespace internal | 753 } // namespace internal |
| 754 } // namespace v8 | 754 } // namespace v8 |
| OLD | NEW |