| 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/builtins/builtins-constructor.h" | 9 #include "src/builtins/builtins-constructor.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { | 1087 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { |
| 1088 builder()->SetStatementPosition(stmt); | 1088 builder()->SetStatementPosition(stmt); |
| 1089 execution_control()->Break(stmt->target()); | 1089 execution_control()->Break(stmt->target()); |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 1092 void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { |
| 1093 builder()->SetStatementPosition(stmt); | 1093 builder()->SetStatementPosition(stmt); |
| 1094 VisitForAccumulatorValue(stmt->expression()); | 1094 VisitForAccumulatorValue(stmt->expression()); |
| 1095 | |
| 1096 if (stmt->HasTypeProfileSlot()) { | |
| 1097 FeedbackSlot collect_type_feedback_slot = stmt->TypeProfileSlot(); | |
| 1098 builder()->CollectTypeProfile(stmt->position(), | |
| 1099 feedback_index(collect_type_feedback_slot)); | |
| 1100 } | |
| 1101 | |
| 1102 if (stmt->is_async_return()) { | 1095 if (stmt->is_async_return()) { |
| 1103 execution_control()->AsyncReturnAccumulator(); | 1096 execution_control()->AsyncReturnAccumulator(); |
| 1104 } else { | 1097 } else { |
| 1105 execution_control()->ReturnAccumulator(); | 1098 execution_control()->ReturnAccumulator(); |
| 1106 } | 1099 } |
| 1107 } | 1100 } |
| 1108 | 1101 |
| 1109 void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) { | 1102 void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) { |
| 1110 builder()->SetStatementPosition(stmt); | 1103 builder()->SetStatementPosition(stmt); |
| 1111 VisitForAccumulatorValue(stmt->expression()); | 1104 VisitForAccumulatorValue(stmt->expression()); |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 } | 2016 } |
| 2024 | 2017 |
| 2025 void BytecodeGenerator::BuildReturn() { | 2018 void BytecodeGenerator::BuildReturn() { |
| 2026 if (FLAG_trace) { | 2019 if (FLAG_trace) { |
| 2027 RegisterAllocationScope register_scope(this); | 2020 RegisterAllocationScope register_scope(this); |
| 2028 Register result = register_allocator()->NewRegister(); | 2021 Register result = register_allocator()->NewRegister(); |
| 2029 // Runtime returns {result} value, preserving accumulator. | 2022 // Runtime returns {result} value, preserving accumulator. |
| 2030 builder()->StoreAccumulatorInRegister(result).CallRuntime( | 2023 builder()->StoreAccumulatorInRegister(result).CallRuntime( |
| 2031 Runtime::kTraceExit, result); | 2024 Runtime::kTraceExit, result); |
| 2032 } | 2025 } |
| 2026 if (!info()->literal()->TypeProfileSlot().IsInvalid()) { |
| 2027 builder()->CollectTypeProfile( |
| 2028 info()->literal()->position(), |
| 2029 feedback_index(info()->literal()->TypeProfileSlot())); |
| 2030 } |
| 2033 builder()->Return(); | 2031 builder()->Return(); |
| 2034 } | 2032 } |
| 2035 | 2033 |
| 2036 void BytecodeGenerator::BuildAsyncReturn() { | 2034 void BytecodeGenerator::BuildAsyncReturn() { |
| 2037 DCHECK(IsAsyncFunction(info()->literal()->kind())); | 2035 DCHECK(IsAsyncFunction(info()->literal()->kind())); |
| 2038 RegisterAllocationScope register_scope(this); | 2036 RegisterAllocationScope register_scope(this); |
| 2039 RegisterList args = register_allocator()->NewRegisterList(3); | 2037 RegisterList args = register_allocator()->NewRegisterList(3); |
| 2040 Register receiver = args[0]; | 2038 Register receiver = args[0]; |
| 2041 Register promise = args[1]; | 2039 Register promise = args[1]; |
| 2042 Register return_value = args[2]; | 2040 Register return_value = args[2]; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); | 2330 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); |
| 2333 break; | 2331 break; |
| 2334 } | 2332 } |
| 2335 case KEYED_SUPER_PROPERTY: { | 2333 case KEYED_SUPER_PROPERTY: { |
| 2336 builder() | 2334 builder() |
| 2337 ->StoreAccumulatorInRegister(super_property_args[3]) | 2335 ->StoreAccumulatorInRegister(super_property_args[3]) |
| 2338 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); | 2336 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); |
| 2339 break; | 2337 break; |
| 2340 } | 2338 } |
| 2341 } | 2339 } |
| 2342 | |
| 2343 // Value is in accumulator. | |
| 2344 // TODO(franzih): Collect type profile once we can handle more than just | |
| 2345 // return statements. | |
| 2346 if (false && expr->HasTypeProfileSlot()) { | |
| 2347 FeedbackSlot collect_type_feedback_slot = expr->TypeProfileSlot(); | |
| 2348 | |
| 2349 builder()->CollectTypeProfile(expr->position(), | |
| 2350 feedback_index(collect_type_feedback_slot)); | |
| 2351 } | |
| 2352 } | 2340 } |
| 2353 | 2341 |
| 2354 void BytecodeGenerator::VisitYield(Yield* expr) { | 2342 void BytecodeGenerator::VisitYield(Yield* expr) { |
| 2355 builder()->SetExpressionPosition(expr); | 2343 builder()->SetExpressionPosition(expr); |
| 2356 Register value = VisitForRegisterValue(expr->expression()); | 2344 Register value = VisitForRegisterValue(expr->expression()); |
| 2357 | 2345 |
| 2358 Register generator = VisitForRegisterValue(expr->generator_object()); | 2346 Register generator = VisitForRegisterValue(expr->generator_object()); |
| 2359 | 2347 |
| 2360 // Save context, registers, and state. Then return. | 2348 // Save context, registers, and state. Then return. |
| 2361 builder() | 2349 builder() |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3504 } | 3492 } |
| 3505 | 3493 |
| 3506 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3494 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
| 3507 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3495 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
| 3508 : Runtime::kStoreKeyedToSuper_Sloppy; | 3496 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 3509 } | 3497 } |
| 3510 | 3498 |
| 3511 } // namespace interpreter | 3499 } // namespace interpreter |
| 3512 } // namespace internal | 3500 } // namespace internal |
| 3513 } // namespace v8 | 3501 } // namespace v8 |
| OLD | NEW |