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

Side by Side Diff: runtime/vm/kernel_to_il.cc

Issue 2776373002: Initial steps into streaming the kernel flowgraph (Closed)
Patch Set: Changed type Created 3 years, 8 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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "vm/kernel_to_il.h" 9 #include "vm/kernel_to_il.h"
10 10
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/intermediate_language.h" 12 #include "vm/intermediate_language.h"
13 #include "vm/kernel_reader.h" 13 #include "vm/kernel_reader.h"
14 #include "vm/kernel_binary_flowgraph.h"
14 #include "vm/longjump.h" 15 #include "vm/longjump.h"
15 #include "vm/method_recognizer.h" 16 #include "vm/method_recognizer.h"
16 #include "vm/object_store.h" 17 #include "vm/object_store.h"
17 #include "vm/report.h" 18 #include "vm/report.h"
18 #include "vm/resolver.h" 19 #include "vm/resolver.h"
19 #include "vm/stack_frame.h" 20 #include "vm/stack_frame.h"
20 21
21 #if !defined(DART_PRECOMPILED_RUNTIME) 22 #if !defined(DART_PRECOMPILED_RUNTIME)
22 namespace dart { 23 namespace dart {
23 24
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 intptr_t try_index() { return try_index_; } 956 intptr_t try_index() { return try_index_; }
956 TryCatchBlock* outer() const { return outer_; } 957 TryCatchBlock* outer() const { return outer_; }
957 958
958 private: 959 private:
959 FlowGraphBuilder* builder_; 960 FlowGraphBuilder* builder_;
960 TryCatchBlock* outer_; 961 TryCatchBlock* outer_;
961 intptr_t try_index_; 962 intptr_t try_index_;
962 }; 963 };
963 964
964 965
965 class CatchBlock {
966 public:
967 CatchBlock(FlowGraphBuilder* builder,
968 LocalVariable* exception_var,
969 LocalVariable* stack_trace_var,
970 intptr_t catch_try_index)
971 : builder_(builder),
972 outer_(builder->catch_block_),
973 exception_var_(exception_var),
974 stack_trace_var_(stack_trace_var),
975 catch_try_index_(catch_try_index) {
976 builder_->catch_block_ = this;
977 }
978 ~CatchBlock() { builder_->catch_block_ = outer_; }
979
980 LocalVariable* exception_var() { return exception_var_; }
981 LocalVariable* stack_trace_var() { return stack_trace_var_; }
982 intptr_t catch_try_index() { return catch_try_index_; }
983
984 private:
985 FlowGraphBuilder* builder_;
986 CatchBlock* outer_;
987 LocalVariable* exception_var_;
988 LocalVariable* stack_trace_var_;
989 intptr_t catch_try_index_;
990 };
991
992
993 Fragment& Fragment::operator+=(const Fragment& other) { 966 Fragment& Fragment::operator+=(const Fragment& other) {
994 if (entry == NULL) { 967 if (entry == NULL) {
995 entry = other.entry; 968 entry = other.entry;
996 current = other.current; 969 current = other.current;
997 } else if (current != NULL && other.entry != NULL) { 970 } else if (current != NULL && other.entry != NULL) {
998 current->LinkTo(other.entry); 971 current->LinkTo(other.entry);
999 current = other.current; 972 current = other.current;
1000 } 973 }
1001 return *this; 974 return *this;
1002 } 975 }
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 scopes_(NULL), 1907 scopes_(NULL),
1935 breakable_block_(NULL), 1908 breakable_block_(NULL),
1936 switch_block_(NULL), 1909 switch_block_(NULL),
1937 try_finally_block_(NULL), 1910 try_finally_block_(NULL),
1938 try_catch_block_(NULL), 1911 try_catch_block_(NULL),
1939 next_used_try_index_(0), 1912 next_used_try_index_(0),
1940 catch_block_(NULL), 1913 catch_block_(NULL),
1941 type_translator_(&translation_helper_, 1914 type_translator_(&translation_helper_,
1942 &active_class_, 1915 &active_class_,
1943 /* finalize= */ true), 1916 /* finalize= */ true),
1944 constant_evaluator_(this, 1917 constant_evaluator_(this, zone_, &translation_helper_, &type_translator_),
1945 zone_, 1918 library_(NULL) {}
1946 &translation_helper_,
1947 &type_translator_) {}
1948 1919
1949 1920
1950 FlowGraphBuilder::~FlowGraphBuilder() {} 1921 FlowGraphBuilder::~FlowGraphBuilder() {}
1951 1922
1952 1923
1953 Fragment FlowGraphBuilder::TranslateFinallyFinalizers( 1924 Fragment FlowGraphBuilder::TranslateFinallyFinalizers(
1954 TryFinallyBlock* outer_finally, 1925 TryFinallyBlock* outer_finally,
1955 intptr_t target_context_depth) { 1926 intptr_t target_context_depth) {
1956 TryFinallyBlock* const saved_block = try_finally_block_; 1927 TryFinallyBlock* const saved_block = try_finally_block_;
1957 TryCatchBlock* const saved_try_catch_block = try_catch_block_; 1928 TryCatchBlock* const saved_try_catch_block = try_catch_block_;
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2989 parsed_function_->Bailout("kernel::FlowGraphBuilder", reason); 2960 parsed_function_->Bailout("kernel::FlowGraphBuilder", reason);
2990 } 2961 }
2991 } 2962 }
2992 2963
2993 2964
2994 FlowGraph* FlowGraphBuilder::BuildGraph() { 2965 FlowGraph* FlowGraphBuilder::BuildGraph() {
2995 const dart::Function& function = parsed_function_->function(); 2966 const dart::Function& function = parsed_function_->function();
2996 2967
2997 if (function.IsConstructorClosureFunction()) return NULL; 2968 if (function.IsConstructorClosureFunction()) return NULL;
2998 2969
2970 TreeNode* library_node = node_;
2971 if (node_ != NULL) {
2972 const dart::Function* parent = &function;
2973 while (true) {
2974 library_node = static_cast<kernel::TreeNode*>(parent->kernel_function());
2975 while (library_node != NULL && !library_node->IsLibrary()) {
2976 if (library_node->IsMember()) {
2977 library_node = Member::Cast(library_node)->parent();
2978 } else if (library_node->IsClass()) {
2979 library_node = Class::Cast(library_node)->parent();
2980 break;
2981 } else {
2982 library_node = NULL;
2983 break;
2984 }
2985 }
2986 if (library_node != NULL) break;
2987 parent = &dart::Function::Handle(parent->parent_function());
2988 }
2989 }
2990 if (library_node != NULL && library_node->IsLibrary()) {
2991 library_ = Library::Cast(library_node);
2992 } else {
2993 library_ = NULL;
2994 }
2995
2999 dart::Class& klass = 2996 dart::Class& klass =
3000 dart::Class::Handle(zone_, parsed_function_->function().Owner()); 2997 dart::Class::Handle(zone_, parsed_function_->function().Owner());
3001 2998
3002 Function& outermost_function = Function::Handle(Z); 2999 Function& outermost_function = Function::Handle(Z);
3003 TreeNode* outermost_node = NULL; 3000 TreeNode* outermost_node = NULL;
3004 Class* kernel_klass = NULL; 3001 Class* kernel_klass = NULL;
3005 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node, 3002 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node,
3006 &kernel_klass); 3003 &kernel_klass);
3007 3004
3008 // Mark that we are using [klass]/[kernell_klass] as active class. Resolving 3005 // Mark that we are using [klass]/[kernell_klass] as active class. Resolving
(...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 } 5317 }
5321 instructions += PushArgument(); 5318 instructions += PushArgument();
5322 instructions += ThrowException(node->position()); 5319 instructions += ThrowException(node->position());
5323 ASSERT(instructions.is_closed()); 5320 ASSERT(instructions.is_closed());
5324 5321
5325 fragment_ = instructions; 5322 fragment_ = instructions;
5326 } 5323 }
5327 5324
5328 5325
5329 void FlowGraphBuilder::VisitRethrow(Rethrow* node) { 5326 void FlowGraphBuilder::VisitRethrow(Rethrow* node) {
5330 Fragment instructions; 5327 KernelFlowgraphBuilder builder(this, library_->kernel_data(),
5331 5328 library_->kernel_data_size());
5332 instructions = DebugStepCheck(node->position()) + instructions; 5329 fragment_ = builder.BuildAt(node->kernel_offset());
Kevin Millikin (Google) 2017/03/28 12:50:00 This is pretty weird.
jensj 2017/03/29 09:30:42 Yeah, sorry about that :x
5333 instructions += LoadLocal(catch_block_->exception_var());
5334 instructions += PushArgument();
5335 instructions += LoadLocal(catch_block_->stack_trace_var());
5336 instructions += PushArgument();
5337 instructions +=
5338 RethrowException(node->position(), catch_block_->catch_try_index());
5339
5340 fragment_ = instructions;
5341 } 5330 }
5342 5331
5343 5332
5344 Fragment FlowGraphBuilder::TranslateArguments(Arguments* node, 5333 Fragment FlowGraphBuilder::TranslateArguments(Arguments* node,
5345 Array* argument_names) { 5334 Array* argument_names) {
5346 Fragment instructions; 5335 Fragment instructions;
5347 5336
5348 List<Expression>& positional = node->positional(); 5337 List<Expression>& positional = node->positional();
5349 for (intptr_t i = 0; i < positional.length(); ++i) { 5338 for (intptr_t i = 0; i < positional.length(); ++i) {
5350 instructions += TranslateExpression(positional[i]); 5339 instructions += TranslateExpression(positional[i]);
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
6462 thread->clear_sticky_error(); 6451 thread->clear_sticky_error();
6463 return error.raw(); 6452 return error.raw();
6464 } 6453 }
6465 } 6454 }
6466 6455
6467 6456
6468 } // namespace kernel 6457 } // namespace kernel
6469 } // namespace dart 6458 } // namespace dart
6470 6459
6471 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6460 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698