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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1651993002: [interpreter] Clear pending message object on handler entry. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Enable test. Created 4 years, 10 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 "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/interpreter/bytecode-register-allocator.h" 9 #include "src/interpreter/bytecode-register-allocator.h"
10 #include "src/interpreter/control-flow-builders.h" 10 #include "src/interpreter/control-flow-builders.h"
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1100
1101 VisitForEffect(stmt->assign_each()); 1101 VisitForEffect(stmt->assign_each());
1102 Visit(stmt->body()); 1102 Visit(stmt->body());
1103 loop_builder.JumpToHeader(); 1103 loop_builder.JumpToHeader();
1104 loop_builder.EndLoop(); 1104 loop_builder.EndLoop();
1105 } 1105 }
1106 1106
1107 1107
1108 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { 1108 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
1109 TryCatchBuilder try_control_builder(builder()); 1109 TryCatchBuilder try_control_builder(builder());
1110 Register no_reg;
1110 1111
1111 // Preserve the context in a dedicated register, so that it can be restored 1112 // Preserve the context in a dedicated register, so that it can be restored
1112 // when the handler is entered by the stack-unwinding machinery. 1113 // when the handler is entered by the stack-unwinding machinery.
1113 // TODO(mstarzinger): Be smarter about register allocation. 1114 // TODO(mstarzinger): Be smarter about register allocation.
1114 Register context = register_allocator()->NewRegister(); 1115 Register context = register_allocator()->NewRegister();
1115 1116
1116 // Evaluate the try-block inside a control scope. This simulates a handler 1117 // Evaluate the try-block inside a control scope. This simulates a handler
1117 // that is intercepting 'throw' control commands. 1118 // that is intercepting 'throw' control commands.
1118 try_control_builder.BeginTry(context); 1119 try_control_builder.BeginTry(context);
1119 { 1120 {
1120 ControlScopeForTryCatch scope(this, &try_control_builder); 1121 ControlScopeForTryCatch scope(this, &try_control_builder);
1121 Visit(stmt->try_block()); 1122 Visit(stmt->try_block());
1122 } 1123 }
1123 try_control_builder.EndTry(); 1124 try_control_builder.EndTry();
1124 1125
1125 // Clear message object as we enter the catch block.
1126 // TODO(mstarzinger): Implement this!
1127
1128 // Create a catch scope that binds the exception. 1126 // Create a catch scope that binds the exception.
1129 VisitNewLocalCatchContext(stmt->variable()); 1127 VisitNewLocalCatchContext(stmt->variable());
1128 builder()->StoreAccumulatorInRegister(context);
1129
1130 // Clear message object as we enter the catch block.
1131 builder()->CallRuntime(Runtime::kInterpreterClearPendingMessage, no_reg, 0);
1132
1133 // Load the catch context into the accumulator.
1134 builder()->LoadAccumulatorWithRegister(context);
1130 1135
1131 // Evaluate the catch-block. 1136 // Evaluate the catch-block.
1132 VisitInScope(stmt->catch_block(), stmt->scope()); 1137 VisitInScope(stmt->catch_block(), stmt->scope());
1133 try_control_builder.EndCatch(); 1138 try_control_builder.EndCatch();
1134 } 1139 }
1135 1140
1136 1141
1137 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 1142 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
1138 TryFinallyBuilder try_control_builder(builder()); 1143 TryFinallyBuilder try_control_builder(builder());
1144 Register no_reg;
1139 1145
1140 // We keep a record of all paths that enter the finally-block to be able to 1146 // We keep a record of all paths that enter the finally-block to be able to
1141 // dispatch to the correct continuation point after the statements in the 1147 // dispatch to the correct continuation point after the statements in the
1142 // finally-block have been evaluated. 1148 // finally-block have been evaluated.
1143 // 1149 //
1144 // The try-finally construct can enter the finally-block in three ways: 1150 // The try-finally construct can enter the finally-block in three ways:
1145 // 1. By exiting the try-block normally, falling through at the end. 1151 // 1. By exiting the try-block normally, falling through at the end.
1146 // 2. By exiting the try-block with a function-local control flow transfer 1152 // 2. By exiting the try-block with a function-local control flow transfer
1147 // (i.e. through break/continue/return statements). 1153 // (i.e. through break/continue/return statements).
1148 // 3. By exiting the try-block with a thrown exception. 1154 // 3. By exiting the try-block with a thrown exception.
(...skipping 23 matching lines...) Expand all
1172 1178
1173 // Record fall-through and exception cases. 1179 // Record fall-through and exception cases.
1174 commands.RecordFallThroughPath(); 1180 commands.RecordFallThroughPath();
1175 try_control_builder.LeaveTry(); 1181 try_control_builder.LeaveTry();
1176 try_control_builder.BeginHandler(); 1182 try_control_builder.BeginHandler();
1177 commands.RecordHandlerReThrowPath(); 1183 commands.RecordHandlerReThrowPath();
1178 1184
1179 try_control_builder.BeginFinally(); 1185 try_control_builder.BeginFinally();
1180 1186
1181 // Clear message object as we enter the finally block. 1187 // Clear message object as we enter the finally block.
1182 // TODO(mstarzinger): Implement this! 1188 builder()->CallRuntime(Runtime::kInterpreterClearPendingMessage, no_reg, 0);
1183 1189
1184 // Evaluate the finally-block. 1190 // Evaluate the finally-block.
1185 Visit(stmt->finally_block()); 1191 Visit(stmt->finally_block());
1186 try_control_builder.EndFinally(); 1192 try_control_builder.EndFinally();
1187 1193
1188 // Dynamic dispatch after the finally-block. 1194 // Dynamic dispatch after the finally-block.
1189 commands.ApplyDeferredCommands(); 1195 commands.ApplyDeferredCommands();
1190 } 1196 }
1191 1197
1192 1198
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2506 } 2512 }
2507 2513
2508 2514
2509 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 2515 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
2510 return info()->feedback_vector()->GetIndex(slot); 2516 return info()->feedback_vector()->GetIndex(slot);
2511 } 2517 }
2512 2518
2513 } // namespace interpreter 2519 } // namespace interpreter
2514 } // namespace internal 2520 } // namespace internal
2515 } // namespace v8 2521 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | test/cctest/interpreter/test-bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698