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

Side by Side Diff: src/interpreter/mkpeephole.cc

Issue 2793923002: [Interpreter] Optimize code of the form 'if (x === undefined)'. (Closed)
Patch Set: Rebase Created 3 years, 8 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 <array> 5 #include <array>
6 #include <fstream> 6 #include <fstream>
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 Bytecode::kShiftLeftSmi}; 185 Bytecode::kShiftLeftSmi};
186 case Bytecode::kShiftRight: 186 case Bytecode::kShiftRight:
187 return { 187 return {
188 PeepholeAction::kTransformLdaZeroBinaryOpToBinaryOpWithZeroAction, 188 PeepholeAction::kTransformLdaZeroBinaryOpToBinaryOpWithZeroAction,
189 Bytecode::kShiftRightSmi}; 189 Bytecode::kShiftRightSmi};
190 default: 190 default:
191 break; 191 break;
192 } 192 }
193 } 193 }
194 194
195 // Fuse LdaNull/LdaUndefined followed by a equality comparison with test
196 // undetectable. Testing undetectable is a simple check on the map which is
197 // more efficient than the full comparison operation.
198 if (last == Bytecode::kLdaNull || last == Bytecode::kLdaUndefined) {
199 if (current == Bytecode::kTestEqual) {
200 return {PeepholeAction::kTransformEqualityWithNullOrUndefinedAction,
201 Bytecode::kTestUndetectable};
202 }
203 }
204
205 // Fuse LdaNull/LdaUndefined followed by a strict equals with
206 // TestNull/TestUndefined.
207 if (current == Bytecode::kTestEqualStrict) {
208 if (last == Bytecode::kLdaNull) {
209 return {PeepholeAction::kTransformEqualityWithNullOrUndefinedAction,
210 Bytecode::kTestNull};
211 } else if (last == Bytecode::kLdaUndefined) {
212 return {PeepholeAction::kTransformEqualityWithNullOrUndefinedAction,
213 Bytecode::kTestUndefined};
214 }
215 }
216
217 // If there is no last bytecode to optimize against, store the incoming 195 // If there is no last bytecode to optimize against, store the incoming
218 // bytecode or for jumps emit incoming bytecode immediately. 196 // bytecode or for jumps emit incoming bytecode immediately.
219 if (last == Bytecode::kIllegal) { 197 if (last == Bytecode::kIllegal) {
220 if (Bytecodes::IsJump(current)) { 198 if (Bytecodes::IsJump(current)) {
221 return {PeepholeAction::kUpdateLastJumpAction, Bytecode::kIllegal}; 199 return {PeepholeAction::kUpdateLastJumpAction, Bytecode::kIllegal};
222 } else if (current == Bytecode::kNop) { 200 } else if (current == Bytecode::kNop) {
223 return {PeepholeAction::kUpdateLastIfSourceInfoPresentAction, 201 return {PeepholeAction::kUpdateLastIfSourceInfoPresentAction,
224 Bytecode::kIllegal}; 202 Bytecode::kIllegal};
225 } else { 203 } else {
226 return {PeepholeAction::kUpdateLastAction, Bytecode::kIllegal}; 204 return {PeepholeAction::kUpdateLastAction, Bytecode::kIllegal};
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 350
373 std::ofstream ofs(argv[1], std::ofstream::trunc); 351 std::ofstream ofs(argv[1], std::ofstream::trunc);
374 v8::internal::interpreter::PeepholeActionTableWriter writer; 352 v8::internal::interpreter::PeepholeActionTableWriter writer;
375 writer.BuildTable(); 353 writer.BuildTable();
376 writer.Write(ofs); 354 writer.Write(ofs);
377 ofs.flush(); 355 ofs.flush();
378 ofs.close(); 356 ofs.close();
379 357
380 return 0; 358 return 0;
381 } 359 }
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-generator.cc ('k') | test/cctest/interpreter/bytecode_expectations/CompareNil.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698