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