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

Unified Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10431006: First step toward an optimizing compiler: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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_x64.cc
===================================================================
--- runtime/vm/flow_graph_compiler_x64.cc (revision 7907)
+++ runtime/vm/flow_graph_compiler_x64.cc (working copy)
@@ -32,7 +32,52 @@
DECLARE_FLAG(bool, report_usage_count);
DECLARE_FLAG(bool, code_comments);
+class DeoptimizationStub : public ZoneAllocated {
+ public:
+ DeoptimizationStub(intptr_t deopt_id,
+ intptr_t deopt_token_index,
+ intptr_t try_index,
+ DeoptReasonId reason)
+ : deopt_id_(deopt_id),
+ deopt_token_index_(deopt_token_index),
+ try_index_(try_index),
+ reason_(reason),
+ registers_(2),
+ entry_label_() {}
+ void Push(Register reg) { registers_.Add(reg); }
+ Label* entry_label() { return &entry_label_; }
+
+ void GenerateCode(FlowGraphCompiler* compiler);
+
+ private:
+ const intptr_t deopt_id_;
+ const intptr_t deopt_token_index_;
+ const intptr_t try_index_;
+ const DeoptReasonId reason_;
+ GrowableArray<Register> registers_;
+ Label entry_label_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeoptimizationStub);
+};
+
+
+void DeoptimizationStub::GenerateCode(FlowGraphCompiler* compiler) {
+ Assembler* assem = compiler->assembler();
+ assem->Comment("Deopt stub for id %d", deopt_id_);
+ assem->Bind(entry_label());
Florian Schneider 2012/05/24 00:20:39 Maybe make a temporary definition of the __ macro
srdjan 2012/05/24 01:36:26 Done
+ for (intptr_t i = 0; i < registers_.length(); i++) {
+ assem->pushq(registers_[i]);
+ }
+ assem->movq(RAX, Immediate(Smi::RawValue(reason_)));
+ assem->call(&StubCode::DeoptimizeLabel());
+ compiler->AddCurrentDescriptor(PcDescriptors::kOther,
+ deopt_id_,
+ deopt_token_index_,
+ try_index_);
+}
+
+
FlowGraphCompiler::FlowGraphCompiler(
Assembler* assembler,
const ParsedFunction& parsed_function,
@@ -45,6 +90,7 @@
current_block_(NULL),
pc_descriptors_list_(NULL),
exception_handlers_list_(NULL),
+ deopt_stubs_(),
is_optimizing_(is_optimizing) {
}
@@ -1317,6 +1363,11 @@
}
+void FlowGraphCompiler::VisitBinaryOp(BinaryOpComp* comp) {
+ UNIMPLEMENTED();
+}
+
+
void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) {
LocationSummary* locs = instr->locs();
ASSERT(locs != NULL);
@@ -1857,6 +1908,7 @@
VisitBlocks();
__ int3();
+ GenerateDeferredCode();
// Emit function patching code. This will be swapped with the first 13 bytes
// at entry point.
pc_descriptors_list_->AddDescriptor(PcDescriptors::kPatchCode,
@@ -1868,6 +1920,13 @@
}
+void FlowGraphCompiler::GenerateDeferredCode() {
+ for (intptr_t i = 0; i < deopt_stubs_.length(); i++) {
+ deopt_stubs_[i]->GenerateCode(this);
+ }
+}
+
+
// Infrastructure copied from class CodeGenerator.
void FlowGraphCompiler::GenerateCall(intptr_t token_index,
intptr_t try_index,
@@ -1900,6 +1959,21 @@
}
+Label* FlowGraphCompiler::AddDeoptStub(intptr_t deopt_id,
+ intptr_t deopt_token_index,
+ intptr_t try_index,
+ DeoptReasonId reason,
+ Register reg1,
+ Register reg2) {
+ DeoptimizationStub* stub =
+ new DeoptimizationStub(deopt_id, deopt_token_index, try_index, reason);
+ stub->Push(reg1);
+ stub->Push(reg2);
+ deopt_stubs_.Add(stub);
+ return stub->entry_label();
+}
+
+
void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) {
ASSERT(pc_descriptors_list_ != NULL);
const PcDescriptors& descriptors = PcDescriptors::Handle(

Powered by Google App Engine
This is Rietveld 408576698