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

Side by Side Diff: test/unittests/interpreter/bytecode-array-builder-unittest.cc

Issue 2547043002: [Interpreter] Optimize equality check with null/undefined with a check on the map. (Closed)
Patch Set: Address comments from Ross. Created 4 years 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 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/bytecode-array-builder.h" 7 #include "src/interpreter/bytecode-array-builder.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-label.h" 9 #include "src/interpreter/bytecode-label.h"
10 #include "src/interpreter/bytecode-register-allocator.h" 10 #include "src/interpreter/bytecode-register-allocator.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 builder.CompareOperation(Token::Value::EQ, reg, 1) 188 builder.CompareOperation(Token::Value::EQ, reg, 1)
189 .CompareOperation(Token::Value::NE, reg, 2) 189 .CompareOperation(Token::Value::NE, reg, 2)
190 .CompareOperation(Token::Value::EQ_STRICT, reg, 3) 190 .CompareOperation(Token::Value::EQ_STRICT, reg, 3)
191 .CompareOperation(Token::Value::LT, reg, 4) 191 .CompareOperation(Token::Value::LT, reg, 4)
192 .CompareOperation(Token::Value::GT, reg, 5) 192 .CompareOperation(Token::Value::GT, reg, 5)
193 .CompareOperation(Token::Value::LTE, reg, 6) 193 .CompareOperation(Token::Value::LTE, reg, 6)
194 .CompareOperation(Token::Value::GTE, reg, 7) 194 .CompareOperation(Token::Value::GTE, reg, 7)
195 .CompareOperation(Token::Value::INSTANCEOF, reg, 8) 195 .CompareOperation(Token::Value::INSTANCEOF, reg, 8)
196 .CompareOperation(Token::Value::IN, reg, 9); 196 .CompareOperation(Token::Value::IN, reg, 9);
197 197
198 // Emit peephole optimizations of equality with Null or Undefined.
199 builder.LoadUndefined()
200 .CompareOperation(Token::Value::EQ, reg, 1)
201 .LoadNull()
202 .CompareOperation(Token::Value::EQ, reg, 1);
203
198 // Emit conversion operator invocations. 204 // Emit conversion operator invocations.
199 builder.ConvertAccumulatorToNumber(reg) 205 builder.ConvertAccumulatorToNumber(reg)
200 .ConvertAccumulatorToObject(reg) 206 .ConvertAccumulatorToObject(reg)
201 .ConvertAccumulatorToName(reg); 207 .ConvertAccumulatorToName(reg);
202 208
203 // Short jumps with Imm8 operands 209 // Short jumps with Imm8 operands
204 { 210 {
205 BytecodeLabel start, after_jump1, after_jump2, after_jump3, after_jump4; 211 BytecodeLabel start, after_jump1, after_jump2, after_jump3, after_jump4;
206 builder.Bind(&start) 212 builder.Bind(&start)
207 .Jump(&after_jump1) 213 .Jump(&after_jump1)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrue)] = 1; 397 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrue)] = 1;
392 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalse)] = 1; 398 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalse)] = 1;
393 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrueConstant)] = 1; 399 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrueConstant)] = 1;
394 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalseConstant)] = 1; 400 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalseConstant)] = 1;
395 scorecard[Bytecodes::ToByte(Bytecode::kAddSmi)] = 1; 401 scorecard[Bytecodes::ToByte(Bytecode::kAddSmi)] = 1;
396 scorecard[Bytecodes::ToByte(Bytecode::kSubSmi)] = 1; 402 scorecard[Bytecodes::ToByte(Bytecode::kSubSmi)] = 1;
397 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseAndSmi)] = 1; 403 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseAndSmi)] = 1;
398 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseOrSmi)] = 1; 404 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseOrSmi)] = 1;
399 scorecard[Bytecodes::ToByte(Bytecode::kShiftLeftSmi)] = 1; 405 scorecard[Bytecodes::ToByte(Bytecode::kShiftLeftSmi)] = 1;
400 scorecard[Bytecodes::ToByte(Bytecode::kShiftRightSmi)] = 1; 406 scorecard[Bytecodes::ToByte(Bytecode::kShiftRightSmi)] = 1;
407 scorecard[Bytecodes::ToByte(Bytecode::kTestUndetectable)] = 1;
401 } 408 }
402 409
403 // Check return occurs at the end and only once in the BytecodeArray. 410 // Check return occurs at the end and only once in the BytecodeArray.
404 CHECK_EQ(final_bytecode, Bytecode::kReturn); 411 CHECK_EQ(final_bytecode, Bytecode::kReturn);
405 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1); 412 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1);
406 413
407 #define CHECK_BYTECODE_PRESENT(Name, ...) \ 414 #define CHECK_BYTECODE_PRESENT(Name, ...) \
408 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \ 415 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \
409 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \ 416 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \
410 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \ 417 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 iterator.Advance(); 737 iterator.Advance();
731 } 738 }
732 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 739 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
733 iterator.Advance(); 740 iterator.Advance();
734 CHECK(iterator.done()); 741 CHECK(iterator.done());
735 } 742 }
736 743
737 } // namespace interpreter 744 } // namespace interpreter
738 } // namespace internal 745 } // namespace internal
739 } // namespace v8 746 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698