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

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 23589008: Clean up handling of guarded fields in the flow graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/code_descriptors.h" 10 #include "vm/code_descriptors.h"
(...skipping 27 matching lines...) Expand all
38 static const String& PrivateCoreLibName(const String& str) { 38 static const String& PrivateCoreLibName(const String& str) {
39 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 39 const Library& core_lib = Library::Handle(Library::CoreLibrary());
40 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str)); 40 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str));
41 return private_name; 41 return private_name;
42 } 42 }
43 43
44 44
45 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function, 45 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function,
46 const Array& ic_data_array, 46 const Array& ic_data_array,
47 InlineExitCollector* exit_collector, 47 InlineExitCollector* exit_collector,
48 GrowableArray<const Field*>* guarded_fields,
49 intptr_t osr_id) 48 intptr_t osr_id)
50 : parsed_function_(parsed_function), 49 : parsed_function_(parsed_function),
51 ic_data_array_(ic_data_array), 50 ic_data_array_(ic_data_array),
52 num_copied_params_(parsed_function->num_copied_params()), 51 num_copied_params_(parsed_function->num_copied_params()),
53 // All parameters are copied if any parameter is. 52 // All parameters are copied if any parameter is.
54 num_non_copied_params_((num_copied_params_ == 0) 53 num_non_copied_params_((num_copied_params_ == 0)
55 ? parsed_function->function().num_fixed_parameters() 54 ? parsed_function->function().num_fixed_parameters()
56 : 0), 55 : 0),
57 num_stack_locals_(parsed_function->num_stack_locals()), 56 num_stack_locals_(parsed_function->num_stack_locals()),
58 exit_collector_(exit_collector), 57 exit_collector_(exit_collector),
59 guarded_fields_(guarded_fields), 58 guarded_fields_(new ZoneGrowableArray<const Field*>()),
60 last_used_block_id_(0), // 0 is used for the graph entry. 59 last_used_block_id_(0), // 0 is used for the graph entry.
61 context_level_(0), 60 context_level_(0),
62 try_index_(CatchClauseNode::kInvalidTryIndex), 61 try_index_(CatchClauseNode::kInvalidTryIndex),
63 catch_try_index_(CatchClauseNode::kInvalidTryIndex), 62 catch_try_index_(CatchClauseNode::kInvalidTryIndex),
64 loop_depth_(0), 63 loop_depth_(0),
65 graph_entry_(NULL), 64 graph_entry_(NULL),
66 args_pushed_(0), 65 args_pushed_(0),
67 osr_id_(osr_id) { } 66 osr_id_(osr_id) { }
68 67
69 68
70 void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) { 69 void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) {
71 graph_entry_->AddCatchEntry(entry); 70 graph_entry_->AddCatchEntry(entry);
72 } 71 }
73 72
74 73
75 void FlowGraphBuilder::AddToGuardedFields(const Field& field) const {
76 if ((field.guarded_cid() == kDynamicCid) ||
77 (field.guarded_cid() == kIllegalCid)) {
78 return;
79 }
80 for (intptr_t j = 0; j < guarded_fields_->length(); j++) {
81 if ((*guarded_fields_)[j]->raw() == field.raw()) {
82 return;
83 }
84 }
85 guarded_fields_->Add(&field);
86 }
87
88
89 void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) { 74 void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) {
90 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1); 75 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1);
91 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id()); 76 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id());
92 ASSERT(callee_graph->max_virtual_register_number() > 77 ASSERT(callee_graph->max_virtual_register_number() >
93 caller_graph_->max_virtual_register_number()); 78 caller_graph_->max_virtual_register_number());
94 79
95 // Adjust the caller's maximum block id and current SSA temp index. 80 // Adjust the caller's maximum block id and current SSA temp index.
96 caller_graph_->set_max_block_id(callee_graph->max_block_id()); 81 caller_graph_->set_max_block_id(callee_graph->max_block_id());
97 caller_graph_->set_current_ssa_temp_index( 82 caller_graph_->set_current_ssa_temp_index(
98 callee_graph->max_virtual_register_number()); 83 callee_graph->max_virtual_register_number());
(...skipping 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 AbstractType::ZoneHandle(node->field().type())); 3041 AbstractType::ZoneHandle(node->field().type()));
3057 load->set_field(&node->field()); 3042 load->set_field(&node->field());
3058 if (owner()->exit_collector() != NULL) { 3043 if (owner()->exit_collector() != NULL) {
3059 // While inlining into an optimized function, the field has 3044 // While inlining into an optimized function, the field has
3060 // to be added to the list of guarded fields of the caller. 3045 // to be added to the list of guarded fields of the caller.
3061 if (node->field().guarded_cid() != kIllegalCid) { 3046 if (node->field().guarded_cid() != kIllegalCid) {
3062 if (!node->field().is_nullable() || 3047 if (!node->field().is_nullable() ||
3063 (node->field().guarded_cid() == kNullCid)) { 3048 (node->field().guarded_cid() == kNullCid)) {
3064 load->set_result_cid(node->field().guarded_cid()); 3049 load->set_result_cid(node->field().guarded_cid());
3065 } 3050 }
3066 owner()->AddToGuardedFields(node->field()); 3051 FlowGraph::AddToGuardedFields(owner()->guarded_fields(), &node->field());
3067 } 3052 }
3068 } 3053 }
3069 ReturnDefinition(load); 3054 ReturnDefinition(load);
3070 } 3055 }
3071 3056
3072 3057
3073 void EffectGraphVisitor::VisitStoreInstanceFieldNode( 3058 void EffectGraphVisitor::VisitStoreInstanceFieldNode(
3074 StoreInstanceFieldNode* node) { 3059 StoreInstanceFieldNode* node) {
3075 ValueGraphVisitor for_instance(owner(), temp_index()); 3060 ValueGraphVisitor for_instance(owner(), temp_index());
3076 node->instance()->Visit(&for_instance); 3061 node->instance()->Visit(&for_instance);
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3826 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3842 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3827 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3843 OS::SNPrint(chars, len, kFormat, function_name, reason); 3828 OS::SNPrint(chars, len, kFormat, function_name, reason);
3844 const Error& error = Error::Handle( 3829 const Error& error = Error::Handle(
3845 LanguageError::New(String::Handle(String::New(chars)))); 3830 LanguageError::New(String::Handle(String::New(chars))));
3846 Isolate::Current()->long_jump_base()->Jump(1, error); 3831 Isolate::Current()->long_jump_base()->Jump(1, error);
3847 } 3832 }
3848 3833
3849 3834
3850 } // namespace dart 3835 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698