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

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

Issue 2554723004: [Interpreter] Transform StrictEquality with null/undefined to special bytecodes. (Closed)
Patch Set: "Fixed a DCHECK" 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 198 // Emit peephole optimizations of equality with Null or Undefined.
199 builder.LoadUndefined() 199 builder.LoadUndefined()
200 .CompareOperation(Token::Value::EQ, reg, 1) 200 .CompareOperation(Token::Value::EQ, reg, 1)
201 .LoadNull() 201 .LoadNull()
202 .CompareOperation(Token::Value::EQ, reg, 1); 202 .CompareOperation(Token::Value::EQ, reg, 1)
203 .LoadUndefined()
204 .CompareOperation(Token::Value::EQ_STRICT, reg, 1)
205 .LoadNull()
206 .CompareOperation(Token::Value::EQ_STRICT, reg, 1);
203 207
204 // Emit conversion operator invocations. 208 // Emit conversion operator invocations.
205 builder.ConvertAccumulatorToNumber(reg) 209 builder.ConvertAccumulatorToNumber(reg)
206 .ConvertAccumulatorToObject(reg) 210 .ConvertAccumulatorToObject(reg)
207 .ConvertAccumulatorToName(reg); 211 .ConvertAccumulatorToName(reg);
208 212
209 // Short jumps with Imm8 operands 213 // Short jumps with Imm8 operands
210 { 214 {
211 BytecodeLabel start, after_jump1, after_jump2, after_jump3, after_jump4; 215 BytecodeLabel start, after_jump1, after_jump2, after_jump3, after_jump4;
212 builder.Bind(&start) 216 builder.Bind(&start)
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalse)] = 1; 402 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalse)] = 1;
399 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrueConstant)] = 1; 403 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrueConstant)] = 1;
400 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalseConstant)] = 1; 404 scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalseConstant)] = 1;
401 scorecard[Bytecodes::ToByte(Bytecode::kAddSmi)] = 1; 405 scorecard[Bytecodes::ToByte(Bytecode::kAddSmi)] = 1;
402 scorecard[Bytecodes::ToByte(Bytecode::kSubSmi)] = 1; 406 scorecard[Bytecodes::ToByte(Bytecode::kSubSmi)] = 1;
403 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseAndSmi)] = 1; 407 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseAndSmi)] = 1;
404 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseOrSmi)] = 1; 408 scorecard[Bytecodes::ToByte(Bytecode::kBitwiseOrSmi)] = 1;
405 scorecard[Bytecodes::ToByte(Bytecode::kShiftLeftSmi)] = 1; 409 scorecard[Bytecodes::ToByte(Bytecode::kShiftLeftSmi)] = 1;
406 scorecard[Bytecodes::ToByte(Bytecode::kShiftRightSmi)] = 1; 410 scorecard[Bytecodes::ToByte(Bytecode::kShiftRightSmi)] = 1;
407 scorecard[Bytecodes::ToByte(Bytecode::kTestUndetectable)] = 1; 411 scorecard[Bytecodes::ToByte(Bytecode::kTestUndetectable)] = 1;
412 scorecard[Bytecodes::ToByte(Bytecode::kTestUndefined)] = 1;
413 scorecard[Bytecodes::ToByte(Bytecode::kTestNull)] = 1;
408 } 414 }
409 415
410 // Check return occurs at the end and only once in the BytecodeArray. 416 // Check return occurs at the end and only once in the BytecodeArray.
411 CHECK_EQ(final_bytecode, Bytecode::kReturn); 417 CHECK_EQ(final_bytecode, Bytecode::kReturn);
412 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1); 418 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1);
413 419
414 #define CHECK_BYTECODE_PRESENT(Name, ...) \ 420 #define CHECK_BYTECODE_PRESENT(Name, ...) \
415 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \ 421 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \
416 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \ 422 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \
417 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \ 423 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 iterator.Advance(); 743 iterator.Advance();
738 } 744 }
739 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 745 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
740 iterator.Advance(); 746 iterator.Advance();
741 CHECK(iterator.done()); 747 CHECK(iterator.done());
742 } 748 }
743 749
744 } // namespace interpreter 750 } // namespace interpreter
745 } // namespace internal 751 } // namespace internal
746 } // namespace v8 752 } // namespace v8
OLDNEW
« src/interpreter/interpreter.cc ('K') | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698