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

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

Issue 1605633003: [interpreter] First implementation of stack unwinding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_int-5
Patch Set: Created 4 years, 11 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 // that is intercepting 'throw' control commands. 910 // that is intercepting 'throw' control commands.
911 try_control_builder.BeginTry(context); 911 try_control_builder.BeginTry(context);
912 // TODO(mstarzinger): Control scope is missing! 912 // TODO(mstarzinger): Control scope is missing!
913 Visit(stmt->try_block()); 913 Visit(stmt->try_block());
914 try_control_builder.EndTry(); 914 try_control_builder.EndTry();
915 915
916 // Clear message object as we enter the catch block. 916 // Clear message object as we enter the catch block.
917 // TODO(mstarzinger): Implement this! 917 // TODO(mstarzinger): Implement this!
918 918
919 // Create a catch scope that binds the exception. 919 // Create a catch scope that binds the exception.
920 register_allocator()->PrepareForConsecutiveAllocations(3); 920 VisitNewLocalCatchContext(stmt->variable());
921 Register name = register_allocator()->NextConsecutiveRegister(); 921 ContextScope scope(this, stmt->scope());
922 Register exception = register_allocator()->NextConsecutiveRegister();
923 Register closure = register_allocator()->NextConsecutiveRegister();
924 builder()
925 ->StoreAccumulatorInRegister(exception)
926 .LoadLiteral(stmt->variable()->name())
927 .StoreAccumulatorInRegister(name);
928 VisitFunctionClosureForContext();
929 builder()->StoreAccumulatorInRegister(closure).CallRuntime(
930 Runtime::kPushCatchContext, name, 3);
931 922
932 // Evaluate the catch-block. 923 // Evaluate the catch-block.
933 Visit(stmt->catch_block()); 924 Visit(stmt->catch_block());
934 try_control_builder.EndCatch(); 925 try_control_builder.EndCatch();
935 } 926 }
936 927
937 928
938 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 929 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
939 TryFinallyBuilder try_control_builder(builder()); 930 TryFinallyBuilder try_control_builder(builder());
940 931
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 ->LoadLiteral(scope->GetScopeInfo(isolate())) 2107 ->LoadLiteral(scope->GetScopeInfo(isolate()))
2117 .StoreAccumulatorInRegister(scope_info); 2108 .StoreAccumulatorInRegister(scope_info);
2118 VisitFunctionClosureForContext(); 2109 VisitFunctionClosureForContext();
2119 builder() 2110 builder()
2120 ->StoreAccumulatorInRegister(closure) 2111 ->StoreAccumulatorInRegister(closure)
2121 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2); 2112 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2);
2122 execution_result()->SetResultInAccumulator(); 2113 execution_result()->SetResultInAccumulator();
2123 } 2114 }
2124 2115
2125 2116
2117 void BytecodeGenerator::VisitNewLocalCatchContext(Variable* variable) {
2118 AccumulatorResultScope accumulator_execution_result(this);
2119 DCHECK(variable->IsContextSlot());
2120
2121 // Allocate a new local block context.
2122 register_allocator()->PrepareForConsecutiveAllocations(3);
2123 Register name = register_allocator()->NextConsecutiveRegister();
2124 Register exception = register_allocator()->NextConsecutiveRegister();
2125 Register closure = register_allocator()->NextConsecutiveRegister();
2126
2127 builder()
2128 ->StoreAccumulatorInRegister(exception)
2129 .LoadLiteral(variable->name())
2130 .StoreAccumulatorInRegister(name);
2131 VisitFunctionClosureForContext();
2132 builder()->StoreAccumulatorInRegister(closure).CallRuntime(
2133 Runtime::kPushCatchContext, name, 3);
2134 execution_result()->SetResultInAccumulator();
2135 }
2136
2137
2126 void BytecodeGenerator::VisitObjectLiteralAccessor( 2138 void BytecodeGenerator::VisitObjectLiteralAccessor(
2127 Register home_object, ObjectLiteralProperty* property, Register value_out) { 2139 Register home_object, ObjectLiteralProperty* property, Register value_out) {
2128 // TODO(rmcilroy): Replace value_out with VisitForRegister(); 2140 // TODO(rmcilroy): Replace value_out with VisitForRegister();
2129 if (property == nullptr) { 2141 if (property == nullptr) {
2130 builder()->LoadNull().StoreAccumulatorInRegister(value_out); 2142 builder()->LoadNull().StoreAccumulatorInRegister(value_out);
2131 } else { 2143 } else {
2132 VisitForAccumulatorValue(property->value()); 2144 VisitForAccumulatorValue(property->value());
2133 builder()->StoreAccumulatorInRegister(value_out); 2145 builder()->StoreAccumulatorInRegister(value_out);
2134 VisitSetHomeObject(value_out, home_object, property); 2146 VisitSetHomeObject(value_out, home_object, property);
2135 } 2147 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 } 2267 }
2256 2268
2257 2269
2258 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 2270 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
2259 return info()->feedback_vector()->GetIndex(slot); 2271 return info()->feedback_vector()->GetIndex(slot);
2260 } 2272 }
2261 2273
2262 } // namespace interpreter 2274 } // namespace interpreter
2263 } // namespace internal 2275 } // namespace internal
2264 } // namespace v8 2276 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698