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

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

Issue 2302013002: Store the scope info in catch contexts (Closed)
Patch Set: Created 4 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 "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 // Evaluate the try-block inside a control scope. This simulates a handler 1381 // Evaluate the try-block inside a control scope. This simulates a handler
1382 // that is intercepting 'throw' control commands. 1382 // that is intercepting 'throw' control commands.
1383 try_control_builder.BeginTry(context); 1383 try_control_builder.BeginTry(context);
1384 { 1384 {
1385 ControlScopeForTryCatch scope(this, &try_control_builder); 1385 ControlScopeForTryCatch scope(this, &try_control_builder);
1386 Visit(stmt->try_block()); 1386 Visit(stmt->try_block());
1387 } 1387 }
1388 try_control_builder.EndTry(); 1388 try_control_builder.EndTry();
1389 1389
1390 // Create a catch scope that binds the exception. 1390 // Create a catch scope that binds the exception.
1391 VisitNewLocalCatchContext(stmt->variable()); 1391 VisitNewLocalCatchContext(stmt->variable(), stmt->scope());
1392 builder()->StoreAccumulatorInRegister(context); 1392 builder()->StoreAccumulatorInRegister(context);
1393 1393
1394 // If requested, clear message object as we enter the catch block. 1394 // If requested, clear message object as we enter the catch block.
1395 if (stmt->clear_pending_message()) { 1395 if (stmt->clear_pending_message()) {
1396 builder()->CallRuntime(Runtime::kInterpreterClearPendingMessage, no_reg, 0); 1396 builder()->CallRuntime(Runtime::kInterpreterClearPendingMessage, no_reg, 0);
1397 } 1397 }
1398 1398
1399 // Load the catch context into the accumulator. 1399 // Load the catch context into the accumulator.
1400 builder()->LoadAccumulatorWithRegister(context); 1400 builder()->LoadAccumulatorWithRegister(context);
1401 1401
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
3201 AccumulatorResultScope accumulator_execution_result(this); 3201 AccumulatorResultScope accumulator_execution_result(this);
3202 3202
3203 Register extension_object = register_allocator()->NewRegister(); 3203 Register extension_object = register_allocator()->NewRegister();
3204 3204
3205 builder()->CastAccumulatorToJSObject(extension_object); 3205 builder()->CastAccumulatorToJSObject(extension_object);
3206 VisitFunctionClosureForContext(); 3206 VisitFunctionClosureForContext();
3207 builder()->CreateWithContext(extension_object); 3207 builder()->CreateWithContext(extension_object);
3208 execution_result()->SetResultInAccumulator(); 3208 execution_result()->SetResultInAccumulator();
3209 } 3209 }
3210 3210
3211 void BytecodeGenerator::VisitNewLocalCatchContext(Variable* variable) { 3211 void BytecodeGenerator::VisitNewLocalCatchContext(Variable* variable,
3212 Scope* scope) {
3212 AccumulatorResultScope accumulator_execution_result(this); 3213 AccumulatorResultScope accumulator_execution_result(this);
3213 DCHECK(variable->IsContextSlot()); 3214 DCHECK(variable->IsContextSlot());
3214 3215
3215 Register exception = register_allocator()->NewRegister(); 3216 Register exception = register_allocator()->NewRegister();
3216 builder()->StoreAccumulatorInRegister(exception); 3217 builder()->StoreAccumulatorInRegister(exception);
3217 VisitFunctionClosureForContext(); 3218 VisitFunctionClosureForContext();
3218 builder()->CreateCatchContext(exception, variable->name()); 3219 builder()->CreateCatchContext(exception, variable->name(),
3220 scope->scope_info());
3219 execution_result()->SetResultInAccumulator(); 3221 execution_result()->SetResultInAccumulator();
3220 } 3222 }
3221 3223
3222 void BytecodeGenerator::VisitObjectLiteralAccessor( 3224 void BytecodeGenerator::VisitObjectLiteralAccessor(
3223 Register home_object, ObjectLiteralProperty* property, Register value_out) { 3225 Register home_object, ObjectLiteralProperty* property, Register value_out) {
3224 // TODO(rmcilroy): Replace value_out with VisitForRegister(); 3226 // TODO(rmcilroy): Replace value_out with VisitForRegister();
3225 if (property == nullptr) { 3227 if (property == nullptr) {
3226 builder()->LoadNull().StoreAccumulatorInRegister(value_out); 3228 builder()->LoadNull().StoreAccumulatorInRegister(value_out);
3227 } else { 3229 } else {
3228 VisitForAccumulatorValue(property->value()); 3230 VisitForAccumulatorValue(property->value());
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 return execution_context()->scope()->language_mode(); 3392 return execution_context()->scope()->language_mode();
3391 } 3393 }
3392 3394
3393 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3395 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3394 return TypeFeedbackVector::GetIndex(slot); 3396 return TypeFeedbackVector::GetIndex(slot);
3395 } 3397 }
3396 3398
3397 } // namespace interpreter 3399 } // namespace interpreter
3398 } // namespace internal 3400 } // namespace internal
3399 } // namespace v8 3401 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698