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

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

Issue 1665833002: [interpreter] Switch context during stack unwinding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1107
1108 1108
1109 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { 1109 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
1110 TryCatchBuilder try_control_builder(builder()); 1110 TryCatchBuilder try_control_builder(builder());
1111 Register no_reg; 1111 Register no_reg;
1112 1112
1113 // Preserve the context in a dedicated register, so that it can be restored 1113 // Preserve the context in a dedicated register, so that it can be restored
1114 // when the handler is entered by the stack-unwinding machinery. 1114 // when the handler is entered by the stack-unwinding machinery.
1115 // TODO(mstarzinger): Be smarter about register allocation. 1115 // TODO(mstarzinger): Be smarter about register allocation.
1116 Register context = register_allocator()->NewRegister(); 1116 Register context = register_allocator()->NewRegister();
1117 builder()->MoveRegister(Register::current_context(), context);
1117 1118
1118 // Evaluate the try-block inside a control scope. This simulates a handler 1119 // Evaluate the try-block inside a control scope. This simulates a handler
1119 // that is intercepting 'throw' control commands. 1120 // that is intercepting 'throw' control commands.
1120 try_control_builder.BeginTry(context); 1121 try_control_builder.BeginTry(context);
1121 { 1122 {
1122 ControlScopeForTryCatch scope(this, &try_control_builder); 1123 ControlScopeForTryCatch scope(this, &try_control_builder);
1123 Visit(stmt->try_block()); 1124 Visit(stmt->try_block());
1124 } 1125 }
1125 try_control_builder.EndTry(); 1126 try_control_builder.EndTry();
1126 1127
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 // - BreakStatement/ContinueStatement: Undefined and not used. 1161 // - BreakStatement/ContinueStatement: Undefined and not used.
1161 // - Falling through into finally-block: Undefined and not used. 1162 // - Falling through into finally-block: Undefined and not used.
1162 Register token = register_allocator()->NewRegister(); 1163 Register token = register_allocator()->NewRegister();
1163 Register result = register_allocator()->NewRegister(); 1164 Register result = register_allocator()->NewRegister();
1164 ControlScope::DeferredCommands commands(this, token, result); 1165 ControlScope::DeferredCommands commands(this, token, result);
1165 1166
1166 // Preserve the context in a dedicated register, so that it can be restored 1167 // Preserve the context in a dedicated register, so that it can be restored
1167 // when the handler is entered by the stack-unwinding machinery. 1168 // when the handler is entered by the stack-unwinding machinery.
1168 // TODO(mstarzinger): Be smarter about register allocation. 1169 // TODO(mstarzinger): Be smarter about register allocation.
1169 Register context = register_allocator()->NewRegister(); 1170 Register context = register_allocator()->NewRegister();
1171 builder()->MoveRegister(Register::current_context(), context);
1170 1172
1171 // Evaluate the try-block inside a control scope. This simulates a handler 1173 // Evaluate the try-block inside a control scope. This simulates a handler
1172 // that is intercepting all control commands. 1174 // that is intercepting all control commands.
1173 try_control_builder.BeginTry(context); 1175 try_control_builder.BeginTry(context);
1174 { 1176 {
1175 ControlScopeForTryFinally scope(this, &try_control_builder, &commands); 1177 ControlScopeForTryFinally scope(this, &try_control_builder, &commands);
1176 Visit(stmt->try_block()); 1178 Visit(stmt->try_block());
1177 } 1179 }
1178 try_control_builder.EndTry(); 1180 try_control_builder.EndTry();
1179 1181
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 } 2522 }
2521 2523
2522 2524
2523 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 2525 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
2524 return info()->feedback_vector()->GetIndex(slot); 2526 return info()->feedback_vector()->GetIndex(slot);
2525 } 2527 }
2526 2528
2527 } // namespace interpreter 2529 } // namespace interpreter
2528 } // namespace internal 2530 } // namespace internal
2529 } // namespace v8 2531 } // namespace v8
OLDNEW
« src/compiler/bytecode-graph-builder.cc ('K') | « src/frames.cc ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698