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

Side by Side Diff: runtime/vm/flow_graph_compiler_shared.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, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "vm/flow_graph_compiler_shared.h"
6
7 #include "vm/intermediate_language.h"
8 #include "vm/parser.h"
9
10 namespace dart {
11
12 FlowGraphCompilerShared::FlowGraphCompilerShared(
13 const ParsedFunction& parsed_function, intptr_t num_blocks)
14 : parsed_function_(parsed_function),
15 exception_handlers_list_(NULL),
16 pc_descriptors_list_(NULL),
17 stackmap_builder_(NULL),
18 num_blocks_(num_blocks),
19 block_info_(num_blocks) {}
20
21
22 FlowGraphCompilerShared::~FlowGraphCompilerShared() {
23 // BlockInfos are zone-allocated, so their destructors are not called.
24 // Verify the labels explicitly here.
25 for (int i = 0; i < block_info_.length(); ++i) {
26 ASSERT(!block_info_[i]->label.IsLinked());
27 ASSERT(!block_info_[i]->label.HasNear());
28 }
29 }
30
31 void FlowGraphCompilerShared::InitCompiler() {
32 pc_descriptors_list_ = new DescriptorList();
33 exception_handlers_list_ = new ExceptionHandlerList();
34 block_info_.Clear();
35 for (int i = 0; i < num_blocks_; ++i) {
36 block_info_.Add(new BlockInfo());
37 }
38 }
39
40
41 Label*
42 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.
43 intptr_t block_index = block_entry->postorder_number();
44 return &block_info_[block_index]->label;
45 }
46
47
48 void FlowGraphCompilerShared::AddExceptionHandler(intptr_t try_index,
49 intptr_t pc_offset) {
50 exception_handlers_list_->AddHandler(try_index, pc_offset);
51 }
52
53
54 void FlowGraphCompilerShared::FinalizeExceptionHandlers(const Code& code) {
55 ASSERT(exception_handlers_list_ != NULL);
56 const ExceptionHandlers& handlers = ExceptionHandlers::Handle(
57 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint()));
58 code.set_exception_handlers(handlers);
59 }
60
61
62 void FlowGraphCompilerShared::FinalizePcDescriptors(const Code& code) {
63 ASSERT(pc_descriptors_list_ != NULL);
64 const PcDescriptors& descriptors = PcDescriptors::Handle(
65 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint()));
66 descriptors.Verify(parsed_function_.function().is_optimizable());
67 code.set_pc_descriptors(descriptors);
68 }
69
70
71 void FlowGraphCompilerShared::FinalizeStackmaps(const Code& code) {
72 if (stackmap_builder_ == NULL) {
73 // The unoptimizing compiler has no stack maps.
74 code.set_stackmaps(Array::Handle());
75 } else {
76 // Finalize the stack map array and add it to the code object.
77 code.set_stackmaps(
78 Array::Handle(stackmap_builder_->FinalizeStackmaps(code)));
79 }
80 }
81
82
83 void FlowGraphCompilerShared::FinalizeVarDescriptors(const Code& code) {
84 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(
85 parsed_function_.node_sequence()->scope()->GetVarDescriptors());
86 code.set_var_descriptors(var_descs);
87 }
88
89 } // namespace dart
90
91
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698