Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: test/unittests/interpreter/bytecode-dead-code-optimizer-unittest.cc

Issue 2209633002: [Interpreter] Assign feedback slots for binary operations and use them in ignition. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased the patch. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 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 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/bytecode-dead-code-optimizer.h" 7 #include "src/interpreter/bytecode-dead-code-optimizer.h"
8 #include "src/interpreter/bytecode-label.h" 8 #include "src/interpreter/bytecode-label.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const BytecodeNode& last_written() const { return last_written_; } 43 const BytecodeNode& last_written() const { return last_written_; }
44 44
45 private: 45 private:
46 BytecodeDeadCodeOptimizer dead_code_optimizer_; 46 BytecodeDeadCodeOptimizer dead_code_optimizer_;
47 47
48 int write_count_ = 0; 48 int write_count_ = 0;
49 BytecodeNode last_written_; 49 BytecodeNode last_written_;
50 }; 50 };
51 51
52 TEST_F(BytecodeDeadCodeOptimizerTest, LiveCodeKept) { 52 TEST_F(BytecodeDeadCodeOptimizerTest, LiveCodeKept) {
53 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand()); 53 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
54 optimizer()->Write(&add); 54 optimizer()->Write(&add);
55 CHECK_EQ(write_count(), 1); 55 CHECK_EQ(write_count(), 1);
56 CHECK_EQ(add, last_written()); 56 CHECK_EQ(add, last_written());
57 57
58 BytecodeLabel target; 58 BytecodeLabel target;
59 BytecodeNode jump(Bytecode::kJump, 0); 59 BytecodeNode jump(Bytecode::kJump, 0);
60 optimizer()->WriteJump(&jump, &target); 60 optimizer()->WriteJump(&jump, &target);
61 CHECK_EQ(write_count(), 2); 61 CHECK_EQ(write_count(), 2);
62 CHECK_EQ(jump, last_written()); 62 CHECK_EQ(jump, last_written());
63 } 63 }
64 64
65 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterReturnEliminated) { 65 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterReturnEliminated) {
66 BytecodeNode ret(Bytecode::kReturn); 66 BytecodeNode ret(Bytecode::kReturn);
67 optimizer()->Write(&ret); 67 optimizer()->Write(&ret);
68 CHECK_EQ(write_count(), 1); 68 CHECK_EQ(write_count(), 1);
69 CHECK_EQ(ret, last_written()); 69 CHECK_EQ(ret, last_written());
70 70
71 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand()); 71 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
72 optimizer()->Write(&add); 72 optimizer()->Write(&add);
73 CHECK_EQ(write_count(), 1); 73 CHECK_EQ(write_count(), 1);
74 CHECK_EQ(ret, last_written()); 74 CHECK_EQ(ret, last_written());
75 } 75 }
76 76
77 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterThrowEliminated) { 77 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterThrowEliminated) {
78 BytecodeNode thrw(Bytecode::kThrow); 78 BytecodeNode thrw(Bytecode::kThrow);
79 optimizer()->Write(&thrw); 79 optimizer()->Write(&thrw);
80 CHECK_EQ(write_count(), 1); 80 CHECK_EQ(write_count(), 1);
81 CHECK_EQ(thrw, last_written()); 81 CHECK_EQ(thrw, last_written());
82 82
83 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand()); 83 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
84 optimizer()->Write(&add); 84 optimizer()->Write(&add);
85 CHECK_EQ(write_count(), 1); 85 CHECK_EQ(write_count(), 1);
86 CHECK_EQ(thrw, last_written()); 86 CHECK_EQ(thrw, last_written());
87 } 87 }
88 88
89 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterReThrowEliminated) { 89 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterReThrowEliminated) {
90 BytecodeNode rethrow(Bytecode::kReThrow); 90 BytecodeNode rethrow(Bytecode::kReThrow);
91 optimizer()->Write(&rethrow); 91 optimizer()->Write(&rethrow);
92 CHECK_EQ(write_count(), 1); 92 CHECK_EQ(write_count(), 1);
93 CHECK_EQ(rethrow, last_written()); 93 CHECK_EQ(rethrow, last_written());
94 94
95 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand()); 95 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
96 optimizer()->Write(&add); 96 optimizer()->Write(&add);
97 CHECK_EQ(write_count(), 1); 97 CHECK_EQ(write_count(), 1);
98 CHECK_EQ(rethrow, last_written()); 98 CHECK_EQ(rethrow, last_written());
99 } 99 }
100 100
101 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterJumpEliminated) { 101 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeAfterJumpEliminated) {
102 BytecodeLabel target; 102 BytecodeLabel target;
103 BytecodeNode jump(Bytecode::kJump, 0); 103 BytecodeNode jump(Bytecode::kJump, 0);
104 optimizer()->WriteJump(&jump, &target); 104 optimizer()->WriteJump(&jump, &target);
105 CHECK_EQ(write_count(), 1); 105 CHECK_EQ(write_count(), 1);
106 CHECK_EQ(jump, last_written()); 106 CHECK_EQ(jump, last_written());
107 107
108 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand()); 108 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
109 optimizer()->Write(&add); 109 optimizer()->Write(&add);
110 CHECK_EQ(write_count(), 1); 110 CHECK_EQ(write_count(), 1);
111 CHECK_EQ(jump, last_written()); 111 CHECK_EQ(jump, last_written());
112 } 112 }
113 113
114 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeStillDeadAfterConditinalJump) { 114 TEST_F(BytecodeDeadCodeOptimizerTest, DeadCodeStillDeadAfterConditinalJump) {
115 BytecodeNode ret(Bytecode::kReturn); 115 BytecodeNode ret(Bytecode::kReturn);
116 optimizer()->Write(&ret); 116 optimizer()->Write(&ret);
117 CHECK_EQ(write_count(), 1); 117 CHECK_EQ(write_count(), 1);
118 CHECK_EQ(ret, last_written()); 118 CHECK_EQ(ret, last_written());
119 119
120 BytecodeLabel target; 120 BytecodeLabel target;
121 BytecodeNode jump(Bytecode::kJumpIfTrue, 0); 121 BytecodeNode jump(Bytecode::kJumpIfTrue, 0);
122 optimizer()->WriteJump(&jump, &target); 122 optimizer()->WriteJump(&jump, &target);
123 CHECK_EQ(write_count(), 1); 123 CHECK_EQ(write_count(), 1);
124 CHECK_EQ(ret, last_written()); 124 CHECK_EQ(ret, last_written());
125 125
126 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand()); 126 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
127 optimizer()->Write(&add); 127 optimizer()->Write(&add);
128 CHECK_EQ(write_count(), 1); 128 CHECK_EQ(write_count(), 1);
129 CHECK_EQ(ret, last_written()); 129 CHECK_EQ(ret, last_written());
130 } 130 }
131 131
132 TEST_F(BytecodeDeadCodeOptimizerTest, CodeLiveAfterLabelBind) { 132 TEST_F(BytecodeDeadCodeOptimizerTest, CodeLiveAfterLabelBind) {
133 BytecodeNode ret(Bytecode::kReturn); 133 BytecodeNode ret(Bytecode::kReturn);
134 optimizer()->Write(&ret); 134 optimizer()->Write(&ret);
135 CHECK_EQ(write_count(), 1); 135 CHECK_EQ(write_count(), 1);
136 CHECK_EQ(ret, last_written()); 136 CHECK_EQ(ret, last_written());
137 137
138 BytecodeLabel target; 138 BytecodeLabel target;
139 optimizer()->BindLabel(&target); 139 optimizer()->BindLabel(&target);
140 140
141 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand()); 141 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
142 optimizer()->Write(&add); 142 optimizer()->Write(&add);
143 CHECK_EQ(write_count(), 2); 143 CHECK_EQ(write_count(), 2);
144 CHECK_EQ(add, last_written()); 144 CHECK_EQ(add, last_written());
145 } 145 }
146 146
147 } // namespace interpreter 147 } // namespace interpreter
148 } // namespace internal 148 } // namespace internal
149 } // namespace v8 149 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698