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

Unified Diff: runtime/vm/flow_graph_compiler_ia32.cc

Issue 10447133: FlowGraphCompiler is not a visitor any longer. Start consolidating shared code between the x64 and … (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_ia32.cc
===================================================================
--- runtime/vm/flow_graph_compiler_ia32.cc (revision 8180)
+++ runtime/vm/flow_graph_compiler_ia32.cc (working copy)
@@ -82,39 +82,20 @@
const ParsedFunction& parsed_function,
const GrowableArray<BlockEntryInstr*>& block_order,
bool is_optimizing)
- : FlowGraphVisitor(block_order),
+ : FlowGraphCompilerShared(parsed_function, block_order.length()),
assembler_(assembler),
- parsed_function_(parsed_function),
- block_info_(block_order.length()),
+ block_order_(block_order),
current_block_(NULL),
- pc_descriptors_list_(NULL),
- stackmap_builder_(NULL),
- exception_handlers_list_(NULL),
deopt_stubs_(),
is_optimizing_(is_optimizing) {
}
-FlowGraphCompiler::~FlowGraphCompiler() {
- // BlockInfos are zone-allocated, so their destructors are not called.
- // Verify the labels explicitly here.
- for (int i = 0; i < block_info_.length(); ++i) {
- ASSERT(!block_info_[i]->label.IsLinked());
- ASSERT(!block_info_[i]->label.HasNear());
- }
+void FlowGraphCompiler::FinalizeComments(const Code& code) {
+ code.set_comments(assembler_->GetCodeComments());
}
-void FlowGraphCompiler::InitCompiler() {
- pc_descriptors_list_ = new DescriptorList();
- exception_handlers_list_ = new ExceptionHandlerList();
- block_info_.Clear();
- for (int i = 0; i < block_order_.length(); ++i) {
- block_info_.Add(new BlockInfo());
- }
-}
-
-
void FlowGraphCompiler::Bailout(const char* reason) {
const char* kFormat = "FlowGraphCompiler Bailout: %s.";
intptr_t len = OS::SNPrint(NULL, 0, kFormat, reason) + 1;
@@ -132,7 +113,7 @@
intptr_t cid,
intptr_t token_index,
intptr_t try_index) {
- pc_descriptors_list_->AddDescriptor(kind,
+ pc_descriptors_list()->AddDescriptor(kind,
assembler_->CodeSize(),
cid,
token_index,
@@ -145,7 +126,7 @@
// TOS: return address.
// +1 : receiver.
// Sequence node has one return node, its input is load field node.
- const SequenceNode& sequence_node = *parsed_function_.node_sequence();
+ const SequenceNode& sequence_node = *parsed_function().node_sequence();
ASSERT(sequence_node.length() == 1);
ASSERT(sequence_node.NodeAt(0)->IsReturnNode());
const ReturnNode& return_node = *sequence_node.NodeAt(0)->AsReturnNode();
@@ -163,7 +144,7 @@
// +1 : value
// +2 : receiver.
// Sequence node has one store node and one return NULL node.
- const SequenceNode& sequence_node = *parsed_function_.node_sequence();
+ const SequenceNode& sequence_node = *parsed_function().node_sequence();
ASSERT(sequence_node.length() == 2);
ASSERT(sequence_node.NodeAt(0)->IsStoreInstanceFieldNode());
ASSERT(sequence_node.NodeAt(1)->IsReturnNode());
@@ -180,8 +161,8 @@
intptr_t FlowGraphCompiler::StackSize() const {
- return parsed_function_.stack_local_count() +
- parsed_function_.copied_parameter_count();
+ return parsed_function().stack_local_count() +
+ parsed_function().copied_parameter_count();
}
@@ -200,11 +181,11 @@
// Intrinsification skips arguments checks, therefore disable if in checked
// mode.
if (FLAG_intrinsify && !FLAG_trace_functions && !FLAG_enable_type_checks) {
- if ((parsed_function_.function().kind() == RawFunction::kImplicitGetter)) {
+ if ((parsed_function().function().kind() == RawFunction::kImplicitGetter)) {
IntrinsifyGetter();
return true;
}
- if ((parsed_function_.function().kind() == RawFunction::kImplicitSetter)) {
+ if ((parsed_function().function().kind() == RawFunction::kImplicitSetter)) {
IntrinsifySetter();
return true;
}
@@ -212,7 +193,7 @@
// Even if an intrinsified version of the function was successfully
// generated, it may fall through to the non-intrinsified method body.
if (!FLAG_trace_functions) {
- return Intrinsifier::Intrinsify(parsed_function_.function(), assembler_);
+ return Intrinsifier::Intrinsify(parsed_function().function(), assembler_);
}
return false;
}
@@ -240,11 +221,11 @@
return;
}
// Specialized version of entry code from CodeGenerator::GenerateEntryCode.
- const Function& function = parsed_function_.function();
+ const Function& function = parsed_function().function();
const int parameter_count = function.num_fixed_parameters();
- const int num_copied_params = parsed_function_.copied_parameter_count();
- const int local_count = parsed_function_.stack_local_count();
+ const int num_copied_params = parsed_function().copied_parameter_count();
+ const int local_count = parsed_function().stack_local_count();
AssemblerMacros::EnterDartFrame(assembler_, (StackSize() * kWordSize));
// We check the number of passed arguments when we have to copy them due to
// the presence of optional named parameters.
@@ -281,7 +262,7 @@
const Immediate raw_null =
Immediate(reinterpret_cast<intptr_t>(Object::null()));
__ movl(EAX, raw_null);
- const int base = parsed_function_.first_stack_local_index();
+ const int base = parsed_function().first_stack_local_index();
for (int i = 0; i < local_count; ++i) {
// Subtract index i (locals lie at lower addresses than EBP).
__ movl(Address(EBP, (base - i) * kWordSize), EAX);
@@ -306,7 +287,7 @@
// Second printing.
OS::Print("Annotated ");
}
- AstPrinter::PrintFunctionScope(parsed_function_);
+ AstPrinter::PrintFunctionScope(parsed_function());
}
VisitBlocks();
@@ -315,7 +296,7 @@
GenerateDeferredCode();
// Emit function patching code. This will be swapped with the first 5 bytes
// at entry point.
- pc_descriptors_list_->AddDescriptor(PcDescriptors::kPatchCode,
+ pc_descriptors_list()->AddDescriptor(PcDescriptors::kPatchCode,
assembler_->CodeSize(),
AstNode::kNoId,
0,
@@ -331,7 +312,7 @@
intptr_t argument_count,
const Array& argument_names,
intptr_t checked_argument_count) {
- ICData& ic_data = ICData::ZoneHandle(ICData::New(parsed_function_.function(),
+ ICData& ic_data = ICData::ZoneHandle(ICData::New(parsed_function().function(),
function_name,
cid,
checked_argument_count));
@@ -428,7 +409,8 @@
__ Comment("B%d", i);
// Compile the block entry.
current_block_ = block_order_[i];
- Instruction* instr = current_block()->Accept(this);
+ current_block_->EmitNativeCode(this);
+ Instruction* instr = current_block_->StraightLineSuccessor();
// Compile all successors until an exit, branch, or a block entry.
while ((instr != NULL) && !instr->IsBlockEntry()) {
if (FLAG_code_comments) EmitComment(instr);
@@ -447,53 +429,12 @@
// next block in the list. Otherwise, we need a jump.
if ((i == block_order_.length() - 1) ||
(block_order_[i + 1] != successor)) {
- __ jmp(&block_info_[successor->postorder_number()]->label);
+ __ jmp(&block_info()[successor->postorder_number()]->label);
}
}
}
}
-
-void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) {
- ASSERT(pc_descriptors_list_ != NULL);
- const PcDescriptors& descriptors = PcDescriptors::Handle(
- pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint()));
- descriptors.Verify(parsed_function_.function().is_optimizable());
- code.set_pc_descriptors(descriptors);
-}
-
-
-void FlowGraphCompiler::FinalizeStackmaps(const Code& code) {
- if (stackmap_builder_ == NULL) {
- // The unoptimizing compiler has no stack maps.
- code.set_stackmaps(Array::Handle());
- } else {
- // Finalize the stack map array and add it to the code object.
- code.set_stackmaps(
- Array::Handle(stackmap_builder_->FinalizeStackmaps(code)));
- }
-}
-
-
-void FlowGraphCompiler::FinalizeVarDescriptors(const Code& code) {
- const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(
- parsed_function_.node_sequence()->scope()->GetVarDescriptors());
- code.set_var_descriptors(var_descs);
-}
-
-
-void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) {
- ASSERT(exception_handlers_list_ != NULL);
- const ExceptionHandlers& handlers = ExceptionHandlers::Handle(
- exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint()));
- code.set_exception_handlers(handlers);
-}
-
-
-void FlowGraphCompiler::FinalizeComments(const Code& code) {
- code.set_comments(assembler_->GetCodeComments());
-}
-
#undef __
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698