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

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

Issue 24096018: Fix bug in field type tracking and polymorphic inlining. (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.h » ('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,
48 intptr_t osr_id) 49 intptr_t osr_id)
49 : parsed_function_(parsed_function), 50 : parsed_function_(parsed_function),
50 ic_data_array_(ic_data_array), 51 ic_data_array_(ic_data_array),
51 num_copied_params_(parsed_function->num_copied_params()), 52 num_copied_params_(parsed_function->num_copied_params()),
52 // All parameters are copied if any parameter is. 53 // All parameters are copied if any parameter is.
53 num_non_copied_params_((num_copied_params_ == 0) 54 num_non_copied_params_((num_copied_params_ == 0)
54 ? parsed_function->function().num_fixed_parameters() 55 ? parsed_function->function().num_fixed_parameters()
55 : 0), 56 : 0),
56 num_stack_locals_(parsed_function->num_stack_locals()), 57 num_stack_locals_(parsed_function->num_stack_locals()),
57 exit_collector_(exit_collector), 58 exit_collector_(exit_collector),
59 guarded_fields_(guarded_fields),
58 last_used_block_id_(0), // 0 is used for the graph entry. 60 last_used_block_id_(0), // 0 is used for the graph entry.
59 context_level_(0), 61 context_level_(0),
60 try_index_(CatchClauseNode::kInvalidTryIndex), 62 try_index_(CatchClauseNode::kInvalidTryIndex),
61 catch_try_index_(CatchClauseNode::kInvalidTryIndex), 63 catch_try_index_(CatchClauseNode::kInvalidTryIndex),
62 loop_depth_(0), 64 loop_depth_(0),
63 graph_entry_(NULL), 65 graph_entry_(NULL),
64 args_pushed_(0), 66 args_pushed_(0),
65 osr_id_(osr_id) { } 67 osr_id_(osr_id) { }
66 68
67 69
68 void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) { 70 void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) {
69 graph_entry_->AddCatchEntry(entry); 71 graph_entry_->AddCatchEntry(entry);
70 } 72 }
71 73
72 74
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
73 void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) { 89 void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) {
74 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1); 90 ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1);
75 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id()); 91 ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id());
76 ASSERT(callee_graph->max_virtual_register_number() > 92 ASSERT(callee_graph->max_virtual_register_number() >
77 caller_graph_->max_virtual_register_number()); 93 caller_graph_->max_virtual_register_number());
78 94
79 // Adjust the caller's maximum block id and current SSA temp index. 95 // Adjust the caller's maximum block id and current SSA temp index.
80 caller_graph_->set_max_block_id(callee_graph->max_block_id()); 96 caller_graph_->set_max_block_id(callee_graph->max_block_id());
81 caller_graph_->set_current_ssa_temp_index( 97 caller_graph_->set_current_ssa_temp_index(
82 callee_graph->max_virtual_register_number()); 98 callee_graph->max_virtual_register_number());
(...skipping 2949 matching lines...) Expand 10 before | Expand all | Expand 10 after
3032 void EffectGraphVisitor::VisitLoadInstanceFieldNode( 3048 void EffectGraphVisitor::VisitLoadInstanceFieldNode(
3033 LoadInstanceFieldNode* node) { 3049 LoadInstanceFieldNode* node) {
3034 ValueGraphVisitor for_instance(owner(), temp_index()); 3050 ValueGraphVisitor for_instance(owner(), temp_index());
3035 node->instance()->Visit(&for_instance); 3051 node->instance()->Visit(&for_instance);
3036 Append(for_instance); 3052 Append(for_instance);
3037 LoadFieldInstr* load = new LoadFieldInstr( 3053 LoadFieldInstr* load = new LoadFieldInstr(
3038 for_instance.value(), 3054 for_instance.value(),
3039 node->field().Offset(), 3055 node->field().Offset(),
3040 AbstractType::ZoneHandle(node->field().type())); 3056 AbstractType::ZoneHandle(node->field().type()));
3041 load->set_field(&node->field()); 3057 load->set_field(&node->field());
3058 if (owner()->exit_collector() != NULL) {
3059 // While inlining into an optimized function, the field has
3060 // to be added to the list of guarded fields of the caller.
3061 if (node->field().guarded_cid() != kIllegalCid) {
3062 if (!node->field().is_nullable() ||
3063 (node->field().guarded_cid() == kNullCid)) {
3064 load->set_result_cid(node->field().guarded_cid());
3065 }
3066 owner()->AddToGuardedFields(node->field());
3067 }
3068 }
3042 ReturnDefinition(load); 3069 ReturnDefinition(load);
3043 } 3070 }
3044 3071
3045 3072
3046 void EffectGraphVisitor::VisitStoreInstanceFieldNode( 3073 void EffectGraphVisitor::VisitStoreInstanceFieldNode(
3047 StoreInstanceFieldNode* node) { 3074 StoreInstanceFieldNode* node) {
3048 ValueGraphVisitor for_instance(owner(), temp_index()); 3075 ValueGraphVisitor for_instance(owner(), temp_index());
3049 node->instance()->Visit(&for_instance); 3076 node->instance()->Visit(&for_instance);
3050 Append(for_instance); 3077 Append(for_instance);
3051 ValueGraphVisitor for_value(owner(), for_instance.temp_index()); 3078 ValueGraphVisitor for_value(owner(), for_instance.temp_index());
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
3814 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3841 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3815 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3842 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3816 OS::SNPrint(chars, len, kFormat, function_name, reason); 3843 OS::SNPrint(chars, len, kFormat, function_name, reason);
3817 const Error& error = Error::Handle( 3844 const Error& error = Error::Handle(
3818 LanguageError::New(String::Handle(String::New(chars)))); 3845 LanguageError::New(String::Handle(String::New(chars))));
3819 Isolate::Current()->long_jump_base()->Jump(1, error); 3846 Isolate::Current()->long_jump_base()->Jump(1, error);
3820 } 3847 }
3821 3848
3822 3849
3823 } // namespace dart 3850 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_inliner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698