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

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

Issue 12529008: Collect type feedback for fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 7 years, 9 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
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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 63
64 bool Value::Equals(Value* other) const { 64 bool Value::Equals(Value* other) const {
65 return definition() == other->definition(); 65 return definition() == other->definition();
66 } 66 }
67 67
68 68
69 CheckClassInstr::CheckClassInstr(Value* value, 69 CheckClassInstr::CheckClassInstr(Value* value,
70 intptr_t deopt_id, 70 intptr_t deopt_id,
71 const ICData& unary_checks) 71 const ICData& unary_checks)
72 : unary_checks_(unary_checks) { 72 : unary_checks_(unary_checks),
73 null_check_(false) {
73 ASSERT(unary_checks.IsZoneHandle()); 74 ASSERT(unary_checks.IsZoneHandle());
74 // Expected useful check data. 75 // Expected useful check data.
75 ASSERT(!unary_checks_.IsNull()); 76 ASSERT(!unary_checks_.IsNull());
76 ASSERT(unary_checks_.NumberOfChecks() > 0); 77 ASSERT(unary_checks_.NumberOfChecks() > 0);
77 ASSERT(unary_checks_.num_args_tested() == 1); 78 ASSERT(unary_checks_.num_args_tested() == 1);
78 SetInputAt(0, value); 79 SetInputAt(0, value);
79 deopt_id_ = deopt_id; 80 deopt_id_ = deopt_id;
80 // Otherwise use CheckSmiInstr. 81 // Otherwise use CheckSmiInstr.
81 ASSERT((unary_checks_.NumberOfChecks() != 1) || 82 ASSERT((unary_checks_.NumberOfChecks() != 1) ||
82 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid)); 83 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid));
(...skipping 19 matching lines...) Expand all
102 103
103 104
104 bool CheckClassInstr::AffectedBySideEffect() const { 105 bool CheckClassInstr::AffectedBySideEffect() const {
105 // The class-id of string objects is not invariant: Externalization of strings 106 // The class-id of string objects is not invariant: Externalization of strings
106 // via the API can change the class-id. 107 // via the API can change the class-id.
107 return unary_checks().HasReceiverClassId(kOneByteStringCid) 108 return unary_checks().HasReceiverClassId(kOneByteStringCid)
108 || unary_checks().HasReceiverClassId(kTwoByteStringCid); 109 || unary_checks().HasReceiverClassId(kTwoByteStringCid);
109 } 110 }
110 111
111 112
113 bool GuardFieldInstr::AttributesEqual(Instruction* other) const {
114 return field().raw() == other->AsGuardField()->field().raw();
115 }
116
117
118 bool GuardFieldInstr::AffectedBySideEffect() const {
119 return false;
120 }
121
122
112 bool CheckArrayBoundInstr::AttributesEqual(Instruction* other) const { 123 bool CheckArrayBoundInstr::AttributesEqual(Instruction* other) const {
113 CheckArrayBoundInstr* other_check = other->AsCheckArrayBound(); 124 CheckArrayBoundInstr* other_check = other->AsCheckArrayBound();
114 ASSERT(other_check != NULL); 125 ASSERT(other_check != NULL);
115 return array_type() == other_check->array_type(); 126 return array_type() == other_check->array_type();
116 } 127 }
117 128
118 129
119 bool AssertAssignableInstr::AttributesEqual(Instruction* other) const { 130 bool AssertAssignableInstr::AttributesEqual(Instruction* other) const {
120 AssertAssignableInstr* other_assert = other->AsAssertAssignable(); 131 AssertAssignableInstr* other_assert = other->AsAssertAssignable();
121 ASSERT(other_assert != NULL); 132 ASSERT(other_assert != NULL);
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 if (value_cid == unary_checks().GetReceiverClassIdAt(i)) { 1312 if (value_cid == unary_checks().GetReceiverClassIdAt(i)) {
1302 // No checks needed. 1313 // No checks needed.
1303 return NULL; 1314 return NULL;
1304 } 1315 }
1305 } 1316 }
1306 1317
1307 return this; 1318 return this;
1308 } 1319 }
1309 1320
1310 1321
1322 Instruction* GuardFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
1323 if (field().guarded_cid() == kDynamicCid) {
1324 return NULL; // Nothing to guard.
1325 }
1326
1327 if (field().is_nullable() && value()->Type()->IsNull()) {
1328 return NULL;
1329 }
1330
1331 const intptr_t cid = field().is_nullable() ? value()->Type()->ToNullableCid()
1332 : value()->Type()->ToCid();
1333 if (field().guarded_cid() == cid) {
1334 return NULL; // Value is guaranteed to have this cid.
1335 }
1336
1337
Kevin Millikin (Google) 2013/03/13 16:03:36 There is an extra blank line.
1338 return this;
1339 }
1340
1341
1311 Instruction* CheckSmiInstr::Canonicalize(FlowGraphOptimizer* optimizer) { 1342 Instruction* CheckSmiInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
1312 return (value()->Type()->ToCid() == kSmiCid) ? NULL : this; 1343 return (value()->Type()->ToCid() == kSmiCid) ? NULL : this;
1313 } 1344 }
1314 1345
1315 1346
1316 Instruction* CheckEitherNonSmiInstr::Canonicalize( 1347 Instruction* CheckEitherNonSmiInstr::Canonicalize(
1317 FlowGraphOptimizer* optimizer) { 1348 FlowGraphOptimizer* optimizer) {
1318 if ((left()->Type()->ToCid() == kDoubleCid) || 1349 if ((left()->Type()->ToCid() == kDoubleCid) ||
1319 (right()->Type()->ToCid() == kDoubleCid)) { 1350 (right()->Type()->ToCid() == kDoubleCid)) {
1320 return NULL; // Remove from the graph. 1351 return NULL; // Remove from the graph.
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 default: 2317 default:
2287 UNREACHABLE(); 2318 UNREACHABLE();
2288 } 2319 }
2289 return kPowRuntimeEntry; 2320 return kPowRuntimeEntry;
2290 } 2321 }
2291 2322
2292 2323
2293 #undef __ 2324 #undef __
2294 2325
2295 } // namespace dart 2326 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698