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

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

Issue 17421003: Store arguments descriptor in ICData. Remove loading of arguments descriptor at unoptimized call si… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « runtime/vm/flow_graph_inliner.cc ('k') | runtime/vm/instructions_arm.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (function.IsNull()) { 113 if (function.IsNull()) {
114 return false; 114 return false;
115 } 115 }
116 // Create new ICData, do not modify the one attached to the instruction 116 // Create new ICData, do not modify the one attached to the instruction
117 // since it is attached to the assembly instruction itself. 117 // since it is attached to the assembly instruction itself.
118 // TODO(srdjan): Prevent modification of ICData object that is 118 // TODO(srdjan): Prevent modification of ICData object that is
119 // referenced in assembly code. 119 // referenced in assembly code.
120 ICData& ic_data = ICData::ZoneHandle(ICData::New( 120 ICData& ic_data = ICData::ZoneHandle(ICData::New(
121 flow_graph_->parsed_function().function(), 121 flow_graph_->parsed_function().function(),
122 call->function_name(), 122 call->function_name(),
123 Object::null_array(), // Dummy argument descriptor.
123 call->deopt_id(), 124 call->deopt_id(),
124 class_ids.length())); 125 class_ids.length()));
125 ic_data.AddReceiverCheck(class_ids[0], function); 126 ic_data.AddReceiverCheck(class_ids[0], function);
126 call->set_ic_data(&ic_data); 127 call->set_ic_data(&ic_data);
127 return true; 128 return true;
128 } 129 }
129 return false; 130 return false;
130 } 131 }
131 132
132 133
133 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) { 134 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) {
134 ASSERT(ic_data.num_args_tested() == 1); 135 ASSERT(ic_data.num_args_tested() == 1);
135 136
136 if ((ic_data.NumberOfChecks() == 1) && 137 if ((ic_data.NumberOfChecks() == 1) &&
137 (ic_data.GetReceiverClassIdAt(0) == cid)) { 138 (ic_data.GetReceiverClassIdAt(0) == cid)) {
138 return ic_data; // Nothing to do 139 return ic_data; // Nothing to do
139 } 140 }
140 141
141 const ICData& new_ic_data = ICData::ZoneHandle(ICData::New( 142 const ICData& new_ic_data = ICData::ZoneHandle(ICData::New(
142 Function::Handle(ic_data.function()), 143 Function::Handle(ic_data.function()),
143 String::Handle(ic_data.target_name()), 144 String::Handle(ic_data.target_name()),
145 Object::null_array(), // Dummy argument descriptor.
144 ic_data.deopt_id(), 146 ic_data.deopt_id(),
145 ic_data.num_args_tested())); 147 ic_data.num_args_tested()));
146 148
147 const Function& function = 149 const Function& function =
148 Function::Handle(ic_data.GetTargetForReceiverClassId(cid)); 150 Function::Handle(ic_data.GetTargetForReceiverClassId(cid));
149 if (!function.IsNull()) { 151 if (!function.IsNull()) {
150 new_ic_data.AddReceiverCheck(cid, function); 152 new_ic_data.AddReceiverCheck(cid, function);
151 } 153 }
152 154
153 return new_ic_data; 155 return new_ic_data;
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 case kTypedDataInt8ArrayCid: 2105 case kTypedDataInt8ArrayCid:
2104 case kTypedDataUint8ArrayCid: 2106 case kTypedDataUint8ArrayCid:
2105 case kTypedDataUint8ClampedArrayCid: 2107 case kTypedDataUint8ClampedArrayCid:
2106 case kExternalTypedDataUint8ArrayCid: 2108 case kExternalTypedDataUint8ArrayCid:
2107 case kExternalTypedDataUint8ClampedArrayCid: 2109 case kExternalTypedDataUint8ClampedArrayCid:
2108 case kTypedDataInt16ArrayCid: 2110 case kTypedDataInt16ArrayCid:
2109 case kTypedDataUint16ArrayCid: { 2111 case kTypedDataUint16ArrayCid: {
2110 // Check that value is always smi. 2112 // Check that value is always smi.
2111 value_check = ICData::New(Function::Handle(), 2113 value_check = ICData::New(Function::Handle(),
2112 String::Handle(), 2114 String::Handle(),
2115 Object::null_array(),
2113 Isolate::kNoDeoptId, 2116 Isolate::kNoDeoptId,
2114 1); 2117 1);
2115 value_check.AddReceiverCheck(kSmiCid, Function::Handle()); 2118 value_check.AddReceiverCheck(kSmiCid, Function::Handle());
2116 break; 2119 break;
2117 } 2120 }
2118 case kTypedDataInt32ArrayCid: 2121 case kTypedDataInt32ArrayCid:
2119 case kTypedDataUint32ArrayCid: 2122 case kTypedDataUint32ArrayCid:
2120 // We don't have ICData for the value stored, so we optimistically assume 2123 // We don't have ICData for the value stored, so we optimistically assume
2121 // smis first. If we ever deoptimized here, we require to unbox the value 2124 // smis first. If we ever deoptimized here, we require to unbox the value
2122 // before storing to handle the mint case, too. 2125 // before storing to handle the mint case, too.
2123 if (call->ic_data()->deopt_reason() == kDeoptUnknown) { 2126 if (call->ic_data()->deopt_reason() == kDeoptUnknown) {
2124 value_check = ICData::New(Function::Handle(), 2127 value_check = ICData::New(Function::Handle(),
2125 String::Handle(), 2128 String::Handle(),
2129 Object::null_array(), // Dummy args. descr.
2126 Isolate::kNoDeoptId, 2130 Isolate::kNoDeoptId,
2127 1); 2131 1);
2128 value_check.AddReceiverCheck(kSmiCid, Function::Handle()); 2132 value_check.AddReceiverCheck(kSmiCid, Function::Handle());
2129 } 2133 }
2130 break; 2134 break;
2131 case kTypedDataFloat32ArrayCid: 2135 case kTypedDataFloat32ArrayCid:
2132 case kTypedDataFloat64ArrayCid: { 2136 case kTypedDataFloat64ArrayCid: {
2133 // Check that value is always double. 2137 // Check that value is always double.
2134 value_check = ICData::New(Function::Handle(), 2138 value_check = ICData::New(Function::Handle(),
2135 String::Handle(), 2139 String::Handle(),
2140 Object::null_array(), // Dummy args. descr.
2136 Isolate::kNoDeoptId, 2141 Isolate::kNoDeoptId,
2137 1); 2142 1);
2138 value_check.AddReceiverCheck(kDoubleCid, Function::Handle()); 2143 value_check.AddReceiverCheck(kDoubleCid, Function::Handle());
2139 break; 2144 break;
2140 } 2145 }
2141 case kTypedDataFloat32x4ArrayCid: { 2146 case kTypedDataFloat32x4ArrayCid: {
2142 // Check that value is always Float32x4. 2147 // Check that value is always Float32x4.
2143 value_check = ICData::New(Function::Handle(), 2148 value_check = ICData::New(Function::Handle(),
2144 String::Handle(), 2149 String::Handle(),
2150 Object::null_array(), // Dummy args. descr.
2145 Isolate::kNoDeoptId, 2151 Isolate::kNoDeoptId,
2146 1); 2152 1);
2147 value_check.AddReceiverCheck(kFloat32x4Cid, Function::Handle()); 2153 value_check.AddReceiverCheck(kFloat32x4Cid, Function::Handle());
2148 break; 2154 break;
2149 } 2155 }
2150 default: 2156 default:
2151 // Array cids are already checked in the caller. 2157 // Array cids are already checked in the caller.
2152 UNREACHABLE(); 2158 UNREACHABLE();
2153 } 2159 }
2154 2160
(...skipping 3897 matching lines...) Expand 10 before | Expand all | Expand 10 after
6052 comparison->kind(), 6058 comparison->kind(),
6053 left, 6059 left,
6054 right); 6060 right);
6055 } else if (comparison->IsEqualityCompare()) { 6061 } else if (comparison->IsEqualityCompare()) {
6056 EqualityCompareInstr* equality_compare = comparison->AsEqualityCompare(); 6062 EqualityCompareInstr* equality_compare = comparison->AsEqualityCompare();
6057 EqualityCompareInstr* new_equality_compare = 6063 EqualityCompareInstr* new_equality_compare =
6058 new EqualityCompareInstr(equality_compare->token_pos(), 6064 new EqualityCompareInstr(equality_compare->token_pos(),
6059 comparison->kind(), 6065 comparison->kind(),
6060 left, 6066 left,
6061 right, 6067 right,
6062 Array::Handle()); 6068 Object::null_array());
6063 new_equality_compare->set_ic_data(equality_compare->ic_data()); 6069 new_equality_compare->set_ic_data(equality_compare->ic_data());
6064 new_comparison = new_equality_compare; 6070 new_comparison = new_equality_compare;
6065 } else { 6071 } else {
6066 ASSERT(comparison->IsRelationalOp()); 6072 ASSERT(comparison->IsRelationalOp());
6067 RelationalOpInstr* relational_op = comparison->AsRelationalOp(); 6073 RelationalOpInstr* relational_op = comparison->AsRelationalOp();
6068 RelationalOpInstr* new_relational_op = 6074 RelationalOpInstr* new_relational_op =
6069 new RelationalOpInstr(relational_op->token_pos(), 6075 new RelationalOpInstr(relational_op->token_pos(),
6070 comparison->kind(), 6076 comparison->kind(),
6071 left, 6077 left,
6072 right, 6078 right,
6073 Array::Handle()); 6079 Object::null_array());
6074 new_relational_op->set_ic_data(relational_op->ic_data()); 6080 new_relational_op->set_ic_data(relational_op->ic_data());
6075 new_comparison = new_relational_op; 6081 new_comparison = new_relational_op;
6076 } 6082 }
6077 return new BranchInstr(new_comparison, branch->is_checked()); 6083 return new BranchInstr(new_comparison, branch->is_checked());
6078 } 6084 }
6079 6085
6080 6086
6081 void BranchSimplifier::Simplify(FlowGraph* flow_graph) { 6087 void BranchSimplifier::Simplify(FlowGraph* flow_graph) {
6082 // Optimize some branches that test the value of a phi. When it is safe 6088 // Optimize some branches that test the value of a phi. When it is safe
6083 // to do so, push the branch to each of the predecessor blocks. This is 6089 // to do so, push the branch to each of the predecessor blocks. This is
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
6571 6577
6572 // Insert materializations at environment uses. 6578 // Insert materializations at environment uses.
6573 const Class& cls = Class::Handle(alloc->constructor().Owner()); 6579 const Class& cls = Class::Handle(alloc->constructor().Owner());
6574 for (intptr_t i = 0; i < exits.length(); i++) { 6580 for (intptr_t i = 0; i < exits.length(); i++) {
6575 CreateMaterializationAt(exits[i], alloc, cls, *fields); 6581 CreateMaterializationAt(exits[i], alloc, cls, *fields);
6576 } 6582 }
6577 } 6583 }
6578 6584
6579 6585
6580 } // namespace dart 6586 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_inliner.cc ('k') | runtime/vm/instructions_arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698