Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 487b86543794b9effc862db130ea37a2e0e36ca7..0f24995c92a9b150b38f002a73ea5d70ff61a360 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -45,6 +45,13 @@ Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { |
| // Visit statements in the function body. |
| VisitStatements(info->literal()->body()); |
| + // If the last bytecode wasn't a return, then return 'undefined' to avoid |
| + // falling off the end. |
| + if (!builder_.HasExplicitReturn()) { |
|
Michael Starzinger
2015/09/08 08:25:10
This looks dangerous. Depending on how control flo
rmcilroy
2015/09/08 09:41:59
Good point, we need to take this into account, but
|
| + builder_.LoadUndefined(); |
| + builder_.Return(); |
| + } |
| + |
| set_scope(nullptr); |
| set_info(nullptr); |
| return builder_.ToBytecodeArray(); |