OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 .CompareOperation(Token::Value::LT, reg, Strength::WEAK) | 119 .CompareOperation(Token::Value::LT, reg, Strength::WEAK) |
120 .CompareOperation(Token::Value::GT, reg, Strength::WEAK) | 120 .CompareOperation(Token::Value::GT, reg, Strength::WEAK) |
121 .CompareOperation(Token::Value::LTE, reg, Strength::WEAK) | 121 .CompareOperation(Token::Value::LTE, reg, Strength::WEAK) |
122 .CompareOperation(Token::Value::GTE, reg, Strength::WEAK) | 122 .CompareOperation(Token::Value::GTE, reg, Strength::WEAK) |
123 .CompareOperation(Token::Value::INSTANCEOF, reg, Strength::WEAK) | 123 .CompareOperation(Token::Value::INSTANCEOF, reg, Strength::WEAK) |
124 .CompareOperation(Token::Value::IN, reg, Strength::WEAK); | 124 .CompareOperation(Token::Value::IN, reg, Strength::WEAK); |
125 | 125 |
126 // Emit cast operator invocations. | 126 // Emit cast operator invocations. |
127 builder.CastAccumulatorToNumber() | 127 builder.CastAccumulatorToNumber() |
128 .CastAccumulatorToBoolean() | 128 .CastAccumulatorToBoolean() |
| 129 .CastAccumulatorToJSObject() |
129 .CastAccumulatorToName(); | 130 .CastAccumulatorToName(); |
130 | 131 |
131 // Emit control flow. Return must be the last instruction. | 132 // Emit control flow. Return must be the last instruction. |
132 BytecodeLabel start; | 133 BytecodeLabel start; |
133 builder.Bind(&start); | 134 builder.Bind(&start); |
134 // Short jumps with Imm8 operands | 135 // Short jumps with Imm8 operands |
135 builder.Jump(&start) | 136 builder.Jump(&start) |
136 .JumpIfTrue(&start) | 137 .JumpIfTrue(&start) |
137 .JumpIfFalse(&start) | 138 .JumpIfFalse(&start) |
138 .JumpIfToBooleanTrue(&start) | 139 .JumpIfToBooleanTrue(&start) |
139 .JumpIfToBooleanFalse(&start); | 140 .JumpIfToBooleanFalse(&start) |
| 141 .JumpIfNull(&start) |
| 142 .JumpIfUndefined(&start); |
| 143 |
140 // Insert dummy ops to force longer jumps | 144 // Insert dummy ops to force longer jumps |
141 for (int i = 0; i < 128; i++) { | 145 for (int i = 0; i < 128; i++) { |
142 builder.LoadTrue(); | 146 builder.LoadTrue(); |
143 } | 147 } |
144 // Longer jumps requiring Constant operand | 148 // Longer jumps requiring Constant operand |
145 builder.Jump(&start) | 149 builder.Jump(&start) |
146 .JumpIfTrue(&start) | 150 .JumpIfTrue(&start) |
147 .JumpIfFalse(&start) | 151 .JumpIfFalse(&start) |
148 .JumpIfToBooleanTrue(&start) | 152 .JumpIfToBooleanTrue(&start) |
149 .JumpIfToBooleanFalse(&start); | 153 .JumpIfToBooleanFalse(&start) |
| 154 .JumpIfNull(&start) |
| 155 .JumpIfUndefined(&start); |
150 | 156 |
151 builder.EnterBlock() | 157 builder.EnterBlock() |
152 .Throw() | 158 .Throw() |
153 .LeaveBlock(); | 159 .LeaveBlock(); |
154 | 160 |
| 161 builder.ForInPrepare(reg).ForInDone(reg).ForInNext(reg, reg); |
| 162 |
155 builder.Return(); | 163 builder.Return(); |
156 | 164 |
157 // Generate BytecodeArray. | 165 // Generate BytecodeArray. |
158 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); | 166 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); |
159 CHECK_EQ(the_array->frame_size(), | 167 CHECK_EQ(the_array->frame_size(), |
160 builder.fixed_register_count() * kPointerSize); | 168 builder.fixed_register_count() * kPointerSize); |
161 | 169 |
162 // Build scorecard of bytecodes encountered in the BytecodeArray. | 170 // Build scorecard of bytecodes encountered in the BytecodeArray. |
163 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); | 171 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); |
164 Bytecode final_bytecode = Bytecode::kLdaZero; | 172 Bytecode final_bytecode = Bytecode::kLdaZero; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 547 |
540 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 548 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
541 iterator.Advance(); | 549 iterator.Advance(); |
542 CHECK(iterator.done()); | 550 CHECK(iterator.done()); |
543 } | 551 } |
544 | 552 |
545 | 553 |
546 } // namespace interpreter | 554 } // namespace interpreter |
547 } // namespace internal | 555 } // namespace internal |
548 } // namespace v8 | 556 } // namespace v8 |
OLD | NEW |