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

Side by Side 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 unified diff | Download patch
OLDNEW
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 <stack> 7 #include <stack>
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 27 matching lines...) Expand all
38 if (scope()->is_function_scope() && scope()->function() != NULL) { 38 if (scope()->is_function_scope() && scope()->function() != NULL) {
39 VisitVariableDeclaration(scope()->function()); 39 VisitVariableDeclaration(scope()->function());
40 } 40 }
41 41
42 // Visit declarations within the function scope. 42 // Visit declarations within the function scope.
43 VisitDeclarations(scope()->declarations()); 43 VisitDeclarations(scope()->declarations());
44 44
45 // Visit statements in the function body. 45 // Visit statements in the function body.
46 VisitStatements(info->literal()->body()); 46 VisitStatements(info->literal()->body());
47 47
48 // If the last bytecode wasn't a return, then return 'undefined' to avoid
49 // falling off the end.
50 if (!builder_.HasExplicitReturn()) {
51 builder_.LoadUndefined();
52 builder_.Return();
53 }
54
48 set_scope(nullptr); 55 set_scope(nullptr);
49 set_info(nullptr); 56 set_info(nullptr);
50 return builder_.ToBytecodeArray(); 57 return builder_.ToBytecodeArray();
51 } 58 }
52 59
53 60
54 void BytecodeGenerator::VisitBlock(Block* node) { 61 void BytecodeGenerator::VisitBlock(Block* node) {
55 if (node->scope() == NULL) { 62 if (node->scope() == NULL) {
56 // Visit statements in the same scope, no declarations. 63 // Visit statements in the same scope, no declarations.
57 VisitStatements(node->statements()); 64 VisitStatements(node->statements());
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 415 }
409 416
410 417
411 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { 418 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const {
412 return info()->feedback_vector()->GetIndex(slot); 419 return info()->feedback_vector()->GetIndex(slot);
413 } 420 }
414 421
415 } // namespace interpreter 422 } // namespace interpreter
416 } // namespace internal 423 } // namespace internal
417 } // namespace v8 424 } // namespace v8
OLDNEW
« 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