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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 1308693014: [Interpreter] Ensure that implicit return undefined is generated. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
+ builder_.LoadUndefined();
+ builder_.Return();
+ }
+
set_scope(nullptr);
set_info(nullptr);
return builder_.ToBytecodeArray();
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698