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

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

Issue 1607433005: [interpreter] Implement exception handler table building. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added moar tests. 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
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/control-flow-builders.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 builder()->Bind(&subject_undefined_label); 892 builder()->Bind(&subject_undefined_label);
893 } 893 }
894 894
895 895
896 void BytecodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { 896 void BytecodeGenerator::VisitForOfStatement(ForOfStatement* stmt) {
897 UNIMPLEMENTED(); 897 UNIMPLEMENTED();
898 } 898 }
899 899
900 900
901 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { 901 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
902 if (FLAG_ignition_fake_try_catch) { 902 TryCatchBuilder try_control_builder(builder());
903 Visit(stmt->try_block()); 903 if (!FLAG_ignition_fake_try_catch) UNIMPLEMENTED();
904 return; 904
905 } 905 // Preserve the context in a dedicated register, so that it can be restored
906 UNIMPLEMENTED(); 906 // when the handler is entered by the stack-unwinding machinery.
907 // TODO(mstarzinger): Be smarter about register allocation.
908 Register context = register_allocator()->NewRegister();
909
910 // Evaluate the try-block inside a control scope. This simulates a handler
911 // that is intercepting 'throw' control commands.
912 try_control_builder.BeginTry(context);
913 // TODO(mstarzinger): Control scope is missing!
914 Visit(stmt->try_block());
915 try_control_builder.EndTry();
916
917 // Clear message object as we enter the catch block.
918 // TODO(mstarzinger): Implement this!
919
920 // Create a catch scope that binds the exception.
921 register_allocator()->PrepareForConsecutiveAllocations(3);
922 Register name = register_allocator()->NextConsecutiveRegister();
923 Register exception = register_allocator()->NextConsecutiveRegister();
924 Register closure = register_allocator()->NextConsecutiveRegister();
925 builder()
926 ->StoreAccumulatorInRegister(exception)
927 .LoadLiteral(stmt->variable()->name())
928 .StoreAccumulatorInRegister(name);
929 VisitFunctionClosureForContext();
930 builder()->StoreAccumulatorInRegister(closure).CallRuntime(
931 Runtime::kPushCatchContext, name, 3);
932
933 // Evaluate the catch-block.
934 Visit(stmt->catch_block());
935 try_control_builder.EndCatch();
907 } 936 }
908 937
909 938
910 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 939 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
911 if (FLAG_ignition_fake_try_catch) { 940 TryFinallyBuilder try_control_builder(builder());
912 Visit(stmt->try_block()); 941 if (!FLAG_ignition_fake_try_catch) UNIMPLEMENTED();
913 Visit(stmt->finally_block()); 942
914 return; 943 // Preserve the context in a dedicated register, so that it can be restored
915 } 944 // when the handler is entered by the stack-unwinding machinery.
916 UNIMPLEMENTED(); 945 // TODO(mstarzinger): Be smarter about register allocation.
946 Register context = register_allocator()->NewRegister();
947
948 // Evaluate the try-block inside a control scope. This simulates a handler
949 // that is intercepting all control commands.
950 try_control_builder.BeginTry(context);
951 // TODO(mstarzinger): Control scope is missing!
952 Visit(stmt->try_block());
953 try_control_builder.EndTry();
954
955 // Clear message object as we enter the finally block.
956 // TODO(mstarzinger): Implement this!
957
958 // Evaluate the finally-block.
959 Visit(stmt->finally_block());
960 try_control_builder.EndFinally();
917 } 961 }
918 962
919 963
920 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { 964 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) {
921 UNIMPLEMENTED(); 965 UNIMPLEMENTED();
922 } 966 }
923 967
924 968
925 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { 969 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
926 // Find or build a shared function info. 970 // Find or build a shared function info.
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 } 2257 }
2214 2258
2215 2259
2216 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 2260 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
2217 return info()->feedback_vector()->GetIndex(slot); 2261 return info()->feedback_vector()->GetIndex(slot);
2218 } 2262 }
2219 2263
2220 } // namespace interpreter 2264 } // namespace interpreter
2221 } // namespace internal 2265 } // namespace internal
2222 } // namespace v8 2266 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/control-flow-builders.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698