| 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/compiler/js-graph.h" | 5 #include "src/compiler/js-graph.h" |
| 6 #include "src/compiler/linkage.h" | 6 #include "src/compiler/linkage.h" |
| 7 #include "src/compiler/liveness-analyzer.h" | 7 #include "src/compiler/liveness-analyzer.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/state-values-utils.h" | 9 #include "src/compiler/state-values-utils.h" |
| 10 #include "test/unittests/compiler/graph-unittest.h" | 10 #include "test/unittests/compiler/graph-unittest.h" |
| 11 #include "test/unittests/compiler/node-test-utils.h" | 11 #include "test/unittests/compiler/node-test-utils.h" |
| 12 | 12 |
| 13 using testing::MakeMatcher; | 13 using testing::MakeMatcher; |
| 14 using testing::MatcherInterface; | 14 using testing::MatcherInterface; |
| 15 using testing::MatchResultListener; | 15 using testing::MatchResultListener; |
| 16 using testing::StringMatchResultListener; | 16 using testing::StringMatchResultListener; |
| 17 | 17 |
| 18 namespace v8 { | 18 namespace v8 { |
| 19 namespace internal { | 19 namespace internal { |
| 20 namespace compiler { | 20 namespace compiler { |
| 21 | 21 |
| 22 class LivenessAnalysisTest : public GraphTest { | 22 class LivenessAnalysisTest : public GraphTest { |
| 23 public: | 23 public: |
| 24 explicit LivenessAnalysisTest(int locals_count = 4) | 24 explicit LivenessAnalysisTest(int locals_count = 4) |
| 25 : locals_count_(locals_count), | 25 : locals_count_(locals_count), |
| 26 machine_(zone(), MachineRepresentation::kWord32), | 26 machine_(zone(), MachineRepresentation::kWord32), |
| 27 javascript_(zone()), | 27 javascript_(zone()), |
| 28 jsgraph_(isolate(), graph(), common(), &javascript_, nullptr, | 28 jsgraph_(isolate(), graph(), common(), &javascript_, nullptr, |
| 29 &machine_), | 29 &machine_), |
| 30 analyzer_(locals_count, zone()), | 30 analyzer_(locals_count, false, zone()), |
| 31 empty_values_(graph()->NewNode(common()->StateValues(0), 0, nullptr)), | 31 empty_values_(graph()->NewNode(common()->StateValues(0), 0, nullptr)), |
| 32 next_checkpoint_id_(0), | 32 next_checkpoint_id_(0), |
| 33 current_block_(nullptr) {} | 33 current_block_(nullptr) {} |
| 34 | 34 |
| 35 | |
| 36 protected: | 35 protected: |
| 37 JSGraph* jsgraph() { return &jsgraph_; } | 36 JSGraph* jsgraph() { return &jsgraph_; } |
| 38 | 37 |
| 39 LivenessAnalyzer* analyzer() { return &analyzer_; } | 38 LivenessAnalyzer* analyzer() { return &analyzer_; } |
| 40 void Run() { | 39 void Run() { |
| 41 StateValuesCache cache(jsgraph()); | 40 StateValuesCache cache(jsgraph()); |
| 42 NonLiveFrameStateSlotReplacer replacer(&cache, | 41 NonLiveFrameStateSlotReplacer replacer( |
| 43 jsgraph()->UndefinedConstant(), | 42 &cache, jsgraph()->UndefinedConstant(), analyzer()->local_count(), |
| 44 analyzer()->local_count(), zone()); | 43 false, zone()); |
| 45 analyzer()->Run(&replacer); | 44 analyzer()->Run(&replacer); |
| 46 } | 45 } |
| 47 | 46 |
| 48 Node* Checkpoint() { | 47 Node* Checkpoint() { |
| 49 int ast_num = next_checkpoint_id_++; | 48 int ast_num = next_checkpoint_id_++; |
| 50 int first_const = intconst_from_bailout_id(ast_num, locals_count_); | 49 int first_const = intconst_from_bailout_id(ast_num, locals_count_); |
| 51 | 50 |
| 52 const Operator* locals_op = common()->StateValues(locals_count_); | 51 const Operator* locals_op = common()->StateValues(locals_count_); |
| 53 | 52 |
| 54 ZoneVector<Node*> local_inputs(locals_count_, nullptr, zone()); | 53 ZoneVector<Node*> local_inputs(locals_count_, nullptr, zone()); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 EXPECT_THAT(c1_in_loop, IsCheckpointModuloLiveness(".L.L")); | 369 EXPECT_THAT(c1_in_loop, IsCheckpointModuloLiveness(".L.L")); |
| 371 EXPECT_THAT(c2_in_loop, IsCheckpointModuloLiveness("LL.L")); | 370 EXPECT_THAT(c2_in_loop, IsCheckpointModuloLiveness("LL.L")); |
| 372 | 371 |
| 373 EXPECT_THAT(c1_end, IsCheckpointModuloLiveness(".LL.")); | 372 EXPECT_THAT(c1_end, IsCheckpointModuloLiveness(".LL.")); |
| 374 EXPECT_THAT(c2_end, IsCheckpointModuloLiveness("....")); | 373 EXPECT_THAT(c2_end, IsCheckpointModuloLiveness("....")); |
| 375 } | 374 } |
| 376 | 375 |
| 377 } // namespace compiler | 376 } // namespace compiler |
| 378 } // namespace internal | 377 } // namespace internal |
| 379 } // namespace v8 | 378 } // namespace v8 |
| OLD | NEW |