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

Unified Diff: runtime/vm/kernel_to_il.cc

Issue 2776373002: Initial steps into streaming the kernel flowgraph (Closed)
Patch Set: Rebase + fix lint error Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_to_il.cc
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index b64ca2809b8411be4f61711f823fbf9364ea8f2b..c9428e606e42da1538ceafcbde45cdc2ce809191 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -11,6 +11,7 @@
#include "vm/compiler.h"
#include "vm/intermediate_language.h"
#include "vm/kernel_reader.h"
+#include "vm/kernel_binary_flowgraph.h"
#include "vm/longjump.h"
#include "vm/method_recognizer.h"
#include "vm/object_store.h"
@@ -962,34 +963,6 @@ class TryCatchBlock {
};
-class CatchBlock {
- public:
- CatchBlock(FlowGraphBuilder* builder,
- LocalVariable* exception_var,
- LocalVariable* stack_trace_var,
- intptr_t catch_try_index)
- : builder_(builder),
- outer_(builder->catch_block_),
- exception_var_(exception_var),
- stack_trace_var_(stack_trace_var),
- catch_try_index_(catch_try_index) {
- builder_->catch_block_ = this;
- }
- ~CatchBlock() { builder_->catch_block_ = outer_; }
-
- LocalVariable* exception_var() { return exception_var_; }
- LocalVariable* stack_trace_var() { return stack_trace_var_; }
- intptr_t catch_try_index() { return catch_try_index_; }
-
- private:
- FlowGraphBuilder* builder_;
- CatchBlock* outer_;
- LocalVariable* exception_var_;
- LocalVariable* stack_trace_var_;
- intptr_t catch_try_index_;
-};
-
-
Fragment& Fragment::operator+=(const Fragment& other) {
if (entry == NULL) {
entry = other.entry;
@@ -1978,13 +1951,15 @@ FlowGraphBuilder::FlowGraphBuilder(
type_translator_(&translation_helper_,
&active_class_,
/* finalize= */ true),
- constant_evaluator_(this,
- zone_,
- &translation_helper_,
- &type_translator_) {}
+ constant_evaluator_(this, zone_, &translation_helper_, &type_translator_),
+ streaming_flow_graph_builder_(NULL) {}
-FlowGraphBuilder::~FlowGraphBuilder() {}
+FlowGraphBuilder::~FlowGraphBuilder() {
+ if (streaming_flow_graph_builder_ != NULL) {
+ delete streaming_flow_graph_builder_;
+ }
+}
Fragment FlowGraphBuilder::TranslateFinallyFinalizers(
@@ -3033,6 +3008,36 @@ FlowGraph* FlowGraphBuilder::BuildGraph() {
if (function.IsConstructorClosureFunction()) return NULL;
+ TreeNode* library_node = node_;
+ if (node_ != NULL) {
+ const dart::Function* parent = &function;
+ while (true) {
+ library_node = static_cast<kernel::TreeNode*>(parent->kernel_function());
+ while (library_node != NULL && !library_node->IsLibrary()) {
+ if (library_node->IsMember()) {
+ library_node = Member::Cast(library_node)->parent();
+ } else if (library_node->IsClass()) {
+ library_node = Class::Cast(library_node)->parent();
+ break;
+ } else {
+ library_node = NULL;
+ break;
+ }
+ }
+ if (library_node != NULL) break;
+ parent = &dart::Function::Handle(parent->parent_function());
+ }
+ }
+ if (streaming_flow_graph_builder_ != NULL) {
+ delete streaming_flow_graph_builder_;
+ streaming_flow_graph_builder_ = NULL;
+ }
+ if (library_node != NULL && library_node->IsLibrary()) {
+ Library* library = Library::Cast(library_node);
+ streaming_flow_graph_builder_ = new StreamingFlowGraphBuilder(
+ this, library->kernel_data(), library->kernel_data_size());
+ }
+
dart::Class& klass =
dart::Class::Handle(zone_, parsed_function_->function().Owner());
@@ -5354,17 +5359,7 @@ void FlowGraphBuilder::VisitThrow(Throw* node) {
void FlowGraphBuilder::VisitRethrow(Rethrow* node) {
- Fragment instructions;
-
- instructions = DebugStepCheck(node->position()) + instructions;
- instructions += LoadLocal(catch_block_->exception_var());
- instructions += PushArgument();
- instructions += LoadLocal(catch_block_->stack_trace_var());
- instructions += PushArgument();
- instructions +=
- RethrowException(node->position(), catch_block_->catch_try_index());
-
- fragment_ = instructions;
+ fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset());
}
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698