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

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

Issue 1399773002: [Interpreter] Adds logical and, logical or and comma operators to interpreter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added a new bytecode to jump by casting the value to boolean. This reduces code size for logical op… Created 5 years, 2 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 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 "test/unittests/test-utils.h" 9 #include "test/unittests/test-utils.h"
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 .CompareOperation(Token::Value::IN, reg, Strength::WEAK); 99 .CompareOperation(Token::Value::IN, reg, Strength::WEAK);
100 100
101 // Emit cast operator invocations. 101 // Emit cast operator invocations.
102 builder.LoadNull().CastAccumulatorToBoolean(); 102 builder.LoadNull().CastAccumulatorToBoolean();
103 103
104 // Emit control flow. Return must be the last instruction. 104 // Emit control flow. Return must be the last instruction.
105 BytecodeLabel start; 105 BytecodeLabel start;
106 builder.Bind(&start); 106 builder.Bind(&start);
107 // Short jumps with Imm8 operands 107 // Short jumps with Imm8 operands
108 builder.Jump(&start).JumpIfTrue(&start).JumpIfFalse(&start); 108 builder.Jump(&start).JumpIfTrue(&start).JumpIfFalse(&start);
109 builder.JumpIfToBooleanTrue(&start).JumpIfToBooleanFalse(&start);
rmcilroy 2015/10/13 15:43:24 nit - you can avoid the builder. and just make thi
mythria 2015/10/14 13:33:42 Done.
109 // Insert dummy ops to force longer jumps 110 // Insert dummy ops to force longer jumps
110 for (int i = 0; i < 128; i++) { 111 for (int i = 0; i < 128; i++) {
111 builder.LoadTrue(); 112 builder.LoadTrue();
112 } 113 }
113 // Longer jumps requiring Constant operand 114 // Longer jumps requiring Constant operand
114 builder.Jump(&start).JumpIfTrue(&start).JumpIfFalse(&start); 115 builder.Jump(&start).JumpIfTrue(&start).JumpIfFalse(&start);
116 builder.JumpIfToBooleanTrue(&start).JumpIfToBooleanFalse(&start);
115 builder.Return(); 117 builder.Return();
116 118
117 // Generate BytecodeArray. 119 // Generate BytecodeArray.
118 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); 120 Handle<BytecodeArray> the_array = builder.ToBytecodeArray();
119 CHECK_EQ(the_array->frame_size(), builder.locals_count() * kPointerSize); 121 CHECK_EQ(the_array->frame_size(), builder.locals_count() * kPointerSize);
120 122
121 // Build scorecard of bytecodes encountered in the BytecodeArray. 123 // Build scorecard of bytecodes encountered in the BytecodeArray.
122 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); 124 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1);
123 Bytecode final_bytecode = Bytecode::kLdaZero; 125 Bytecode final_bytecode = Bytecode::kLdaZero;
124 int i = 0; 126 int i = 0;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 463
462 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 464 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
463 iterator.Advance(); 465 iterator.Advance();
464 CHECK(iterator.done()); 466 CHECK(iterator.done());
465 } 467 }
466 468
467 469
468 } // namespace interpreter 470 } // namespace interpreter
469 } // namespace internal 471 } // namespace internal
470 } // namespace v8 472 } // namespace v8
OLDNEW
« test/cctest/interpreter/test-interpreter.cc ('K') | « test/cctest/interpreter/test-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698