OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 builder()->SetExpressionAsStatementPosition(stmt->subject()); | 1195 builder()->SetExpressionAsStatementPosition(stmt->subject()); |
1196 VisitForAccumulatorValue(stmt->subject()); | 1196 VisitForAccumulatorValue(stmt->subject()); |
1197 builder()->JumpIfUndefined(&subject_undefined_label); | 1197 builder()->JumpIfUndefined(&subject_undefined_label); |
1198 builder()->JumpIfNull(&subject_null_label); | 1198 builder()->JumpIfNull(&subject_null_label); |
1199 Register receiver = register_allocator()->NewRegister(); | 1199 Register receiver = register_allocator()->NewRegister(); |
1200 builder()->ConvertAccumulatorToObject(receiver); | 1200 builder()->ConvertAccumulatorToObject(receiver); |
1201 | 1201 |
1202 // Used as kRegTriple and kRegPair in ForInPrepare and ForInNext. | 1202 // Used as kRegTriple and kRegPair in ForInPrepare and ForInNext. |
1203 RegisterList triple = register_allocator()->NewRegisterList(3); | 1203 RegisterList triple = register_allocator()->NewRegisterList(3); |
1204 Register cache_length = triple[2]; | 1204 Register cache_length = triple[2]; |
1205 builder()->ForInPrepare(receiver, triple.first_register()); | 1205 builder()->ForInPrepare(receiver, triple); |
1206 | 1206 |
1207 // Set up loop counter | 1207 // Set up loop counter |
1208 Register index = register_allocator()->NewRegister(); | 1208 Register index = register_allocator()->NewRegister(); |
1209 builder()->LoadLiteral(Smi::FromInt(0)); | 1209 builder()->LoadLiteral(Smi::FromInt(0)); |
1210 builder()->StoreAccumulatorInRegister(index); | 1210 builder()->StoreAccumulatorInRegister(index); |
1211 | 1211 |
1212 // The loop | 1212 // The loop |
1213 VisitIterationHeader(stmt, &loop_builder); | 1213 VisitIterationHeader(stmt, &loop_builder); |
1214 builder()->SetExpressionAsStatementPosition(stmt->each()); | 1214 builder()->SetExpressionAsStatementPosition(stmt->each()); |
1215 builder()->ForInContinue(index, cache_length); | 1215 builder()->ForInContinue(index, cache_length); |
1216 loop_builder.BreakIfFalse(); | 1216 loop_builder.BreakIfFalse(); |
1217 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 1217 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
1218 builder()->ForInNext(receiver, index, triple.first_register(), | 1218 builder()->ForInNext(receiver, index, triple.Truncate(2), |
1219 feedback_index(slot)); | 1219 feedback_index(slot)); |
1220 loop_builder.ContinueIfUndefined(); | 1220 loop_builder.ContinueIfUndefined(); |
1221 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1221 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
1222 VisitIterationBody(stmt, &loop_builder); | 1222 VisitIterationBody(stmt, &loop_builder); |
1223 builder()->ForInStep(index); | 1223 builder()->ForInStep(index); |
1224 builder()->StoreAccumulatorInRegister(index); | 1224 builder()->StoreAccumulatorInRegister(index); |
1225 loop_builder.JumpToHeader(loop_depth_); | 1225 loop_builder.JumpToHeader(loop_depth_); |
1226 loop_builder.EndLoop(); | 1226 loop_builder.EndLoop(); |
1227 builder()->Bind(&subject_null_label); | 1227 builder()->Bind(&subject_null_label); |
1228 builder()->Bind(&subject_undefined_label); | 1228 builder()->Bind(&subject_undefined_label); |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 break; | 2371 break; |
2372 } | 2372 } |
2373 case Call::LOOKUP_SLOT_CALL: | 2373 case Call::LOOKUP_SLOT_CALL: |
2374 case Call::POSSIBLY_EVAL_CALL: { | 2374 case Call::POSSIBLY_EVAL_CALL: { |
2375 if (callee_expr->AsVariableProxy()->var()->IsLookupSlot()) { | 2375 if (callee_expr->AsVariableProxy()->var()->IsLookupSlot()) { |
2376 RegisterAllocationScope inner_register_scope(this); | 2376 RegisterAllocationScope inner_register_scope(this); |
2377 Register name = register_allocator()->NewRegister(); | 2377 Register name = register_allocator()->NewRegister(); |
2378 | 2378 |
2379 // Call %LoadLookupSlotForCall to get the callee and receiver. | 2379 // Call %LoadLookupSlotForCall to get the callee and receiver. |
2380 DCHECK(Register::AreContiguous(callee, receiver)); | 2380 DCHECK(Register::AreContiguous(callee, receiver)); |
| 2381 RegisterList result_pair(callee.index(), 2); |
2381 Variable* variable = callee_expr->AsVariableProxy()->var(); | 2382 Variable* variable = callee_expr->AsVariableProxy()->var(); |
2382 builder() | 2383 builder() |
2383 ->LoadLiteral(variable->name()) | 2384 ->LoadLiteral(variable->name()) |
2384 .StoreAccumulatorInRegister(name) | 2385 .StoreAccumulatorInRegister(name) |
2385 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name, callee); | 2386 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name, |
| 2387 result_pair); |
2386 break; | 2388 break; |
2387 } | 2389 } |
2388 // Fall through. | 2390 // Fall through. |
2389 DCHECK_EQ(call_type, Call::POSSIBLY_EVAL_CALL); | 2391 DCHECK_EQ(call_type, Call::POSSIBLY_EVAL_CALL); |
2390 } | 2392 } |
2391 case Call::OTHER_CALL: { | 2393 case Call::OTHER_CALL: { |
2392 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); | 2394 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
2393 VisitForRegisterValue(callee_expr, callee); | 2395 VisitForRegisterValue(callee_expr, callee); |
2394 break; | 2396 break; |
2395 } | 2397 } |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3163 } | 3165 } |
3164 | 3166 |
3165 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3167 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3166 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3168 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3167 : Runtime::kStoreKeyedToSuper_Sloppy; | 3169 : Runtime::kStoreKeyedToSuper_Sloppy; |
3168 } | 3170 } |
3169 | 3171 |
3170 } // namespace interpreter | 3172 } // namespace interpreter |
3171 } // namespace internal | 3173 } // namespace internal |
3172 } // namespace v8 | 3174 } // namespace v8 |
OLD | NEW |