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

Unified Diff: runtime/vm/flow_graph_compiler.cc

Issue 10823131: Add deopt info to code object and print it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
Index: runtime/vm/flow_graph_compiler.cc
===================================================================
--- runtime/vm/flow_graph_compiler.cc (revision 10252)
+++ runtime/vm/flow_graph_compiler.cc (working copy)
@@ -8,6 +8,7 @@
#include "vm/dart_entry.h"
#include "vm/debugger.h"
+#include "vm/deopt_instructions.h"
#include "vm/il_printer.h"
#include "vm/intrinsifier.h"
#include "vm/locations.h"
@@ -28,7 +29,37 @@
DECLARE_FLAG(bool, trace_functions);
DECLARE_FLAG(int, optimization_counter_threshold);
+RawDeoptInfo* DeoptimizationStub::CreateDeoptInfo(FlowGraphCompiler* compiler) {
+ if (deoptimization_env_ == NULL) return DeoptInfo::null();
+ // We do not support copied parameters yet.
+ ASSERT(compiler->parsed_function().function().num_optional_parameters() == 0);
+ const intptr_t fixed_parameter_count =
+ deoptimization_env_->fixed_parameter_count();
+ DeoptInfoBuilder builder(compiler->object_table(), fixed_parameter_count);
+ builder.AddReturnAddress(compiler->parsed_function().function(), deopt_id_);
+
+ // All locals between TOS and PC-marker.
+ const GrowableArray<Value*>& values = deoptimization_env_->values();
+ // const intptr_t local_slot_count = values.length() - fixed_parameter_count;
+ for (intptr_t i = values.length() - 1; i >= fixed_parameter_count; i--) {
+ builder.AddCopy(deoptimization_env_->LocationAt(i), *values[i]);
+ }
+
+ // PC marker, caller-fp, caller-pc.
+ builder.AddPcMarker(compiler->parsed_function().function());
+ builder.AddCallerFp();
+ builder.AddCallerPc();
+ // Incoming arguments.
+ for (intptr_t i = fixed_parameter_count - 1; i >= 0; i--) {
+ builder.AddCopy(deoptimization_env_->LocationAt(i), *values[i]);
+ }
+
+ const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo());
+ return deopt_info.raw();
+}
+
+
FlowGraphCompiler::FlowGraphCompiler(
Assembler* assembler,
const ParsedFunction& parsed_function,
@@ -45,6 +76,7 @@
stackmap_table_builder_(NULL),
block_info_(block_order.length()),
deopt_stubs_(),
+ object_table_(),
is_optimizing_(is_optimizing),
is_ssa_(is_ssa),
is_dart_leaf_(is_leaf),
@@ -166,7 +198,7 @@
void FlowGraphCompiler::GenerateDeferredCode() {
for (intptr_t i = 0; i < deopt_stubs_.length(); i++) {
- deopt_stubs_[i]->GenerateCode(this);
+ deopt_stubs_[i]->GenerateCode(this, i);
}
}
@@ -233,6 +265,24 @@
}
+void FlowGraphCompiler::FinalizeDeoptInfo(const Code& code) {
+ const Array& array =
+ Array::Handle(Array::New(deopt_stubs_.length(), Heap::kOld));
+ for (intptr_t i = 0; i < deopt_stubs_.length(); i++) {
+ const DeoptInfo& info =
+ DeoptInfo::Handle(deopt_stubs_[i]->CreateDeoptInfo(this));
+ array.SetAt(i, info);
+ }
+ code.set_deopt_info_array(array);
+ intptr_t len = object_table_.length();
+ const Array& object_array = Array::Handle(Array::New(len));
+ for (intptr_t i = 0; i < len; i++) {
+ object_array.SetAt(i, *object_table_[i]);
+ }
siva 2012/08/04 01:21:50 If you had been carrying the object_table_ as a gr
srdjan 2012/08/06 20:09:05 Done.
+ code.set_object_table(object_array);
+}
+
+
void FlowGraphCompiler::FinalizeStackmaps(const Code& code) {
if (stackmap_table_builder_ == NULL) {
// The unoptimizing compiler has no stack maps.

Powered by Google App Engine
This is Rietveld 408576698