Chromium Code Reviews| Index: runtime/vm/flow_graph_compiler_shared.cc |
| =================================================================== |
| --- runtime/vm/flow_graph_compiler_shared.cc (revision 0) |
| +++ runtime/vm/flow_graph_compiler_shared.cc (revision 0) |
| @@ -0,0 +1,91 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#include "vm/flow_graph_compiler_shared.h" |
| + |
| +#include "vm/intermediate_language.h" |
| +#include "vm/parser.h" |
| + |
| +namespace dart { |
| + |
| +FlowGraphCompilerShared::FlowGraphCompilerShared( |
| + const ParsedFunction& parsed_function, intptr_t num_blocks) |
| + : parsed_function_(parsed_function), |
| + exception_handlers_list_(NULL), |
| + pc_descriptors_list_(NULL), |
| + stackmap_builder_(NULL), |
| + num_blocks_(num_blocks), |
| + block_info_(num_blocks) {} |
| + |
| + |
| +FlowGraphCompilerShared::~FlowGraphCompilerShared() { |
| + // 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 FlowGraphCompilerShared::InitCompiler() { |
| + pc_descriptors_list_ = new DescriptorList(); |
| + exception_handlers_list_ = new ExceptionHandlerList(); |
| + block_info_.Clear(); |
| + for (int i = 0; i < num_blocks_; ++i) { |
| + block_info_.Add(new BlockInfo()); |
| + } |
| +} |
| + |
| + |
| +Label* |
| +FlowGraphCompilerShared::GetBlockLabel(BlockEntryInstr* block_entry) const { |
|
Vyacheslav Egorov (Google)
2012/06/01 10:55:24
this is a very strange formatting.
srdjan
2012/06/01 17:44:47
Done.
|
| + intptr_t block_index = block_entry->postorder_number(); |
| + return &block_info_[block_index]->label; |
| +} |
| + |
| + |
| +void FlowGraphCompilerShared::AddExceptionHandler(intptr_t try_index, |
| + intptr_t pc_offset) { |
| + exception_handlers_list_->AddHandler(try_index, pc_offset); |
| +} |
| + |
| + |
| +void FlowGraphCompilerShared::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 FlowGraphCompilerShared::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 FlowGraphCompilerShared::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 FlowGraphCompilerShared::FinalizeVarDescriptors(const Code& code) { |
| + const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( |
| + parsed_function_.node_sequence()->scope()->GetVarDescriptors()); |
| + code.set_var_descriptors(var_descs); |
| +} |
| + |
| +} // namespace dart |
| + |
| + |