| OLD | NEW |
| 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 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 | 1370 |
| 1371 ConstantInstr* zero = flow_graph()->GetConstant(Smi::Handle(Smi::New(0))); | 1371 ConstantInstr* zero = flow_graph()->GetConstant(Smi::Handle(Smi::New(0))); |
| 1372 StrictCompareInstr* compare = | 1372 StrictCompareInstr* compare = |
| 1373 new StrictCompareInstr(Token::kEQ_STRICT, | 1373 new StrictCompareInstr(Token::kEQ_STRICT, |
| 1374 new Value(load), | 1374 new Value(load), |
| 1375 new Value(zero)); | 1375 new Value(zero)); |
| 1376 ReplaceCall(call, compare); | 1376 ReplaceCall(call, compare); |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 | 1379 |
| 1380 void FlowGraphOptimizer::InlineObjectCid(InstanceCallInstr* call) { |
| 1381 LoadClassIdInstr* load = new LoadClassIdInstr(new Value(call->ArgumentAt(0))); |
| 1382 ReplaceCall(call, load); |
| 1383 } |
| 1384 |
| 1385 |
| 1380 static intptr_t OffsetForLengthGetter(MethodRecognizer::Kind kind) { | 1386 static intptr_t OffsetForLengthGetter(MethodRecognizer::Kind kind) { |
| 1381 switch (kind) { | 1387 switch (kind) { |
| 1382 case MethodRecognizer::kObjectArrayLength: | 1388 case MethodRecognizer::kObjectArrayLength: |
| 1383 case MethodRecognizer::kImmutableArrayLength: | 1389 case MethodRecognizer::kImmutableArrayLength: |
| 1384 return Array::length_offset(); | 1390 return Array::length_offset(); |
| 1385 case MethodRecognizer::kTypedDataLength: | 1391 case MethodRecognizer::kTypedDataLength: |
| 1386 // .length is defined in _TypedList which is the base class for internal | 1392 // .length is defined in _TypedList which is the base class for internal |
| 1387 // and external typed data. | 1393 // and external typed data. |
| 1388 ASSERT(TypedData::length_offset() == ExternalTypedData::length_offset()); | 1394 ASSERT(TypedData::length_offset() == ExternalTypedData::length_offset()); |
| 1389 return TypedData::length_offset(); | 1395 return TypedData::length_offset(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 } else if (target.kind() == RawFunction::kMethodExtractor) { | 1438 } else if (target.kind() == RawFunction::kMethodExtractor) { |
| 1433 return false; | 1439 return false; |
| 1434 } | 1440 } |
| 1435 | 1441 |
| 1436 // Not an implicit getter. | 1442 // Not an implicit getter. |
| 1437 MethodRecognizer::Kind recognized_kind = | 1443 MethodRecognizer::Kind recognized_kind = |
| 1438 MethodRecognizer::RecognizeKind(target); | 1444 MethodRecognizer::RecognizeKind(target); |
| 1439 | 1445 |
| 1440 // VM objects length getter. | 1446 // VM objects length getter. |
| 1441 switch (recognized_kind) { | 1447 switch (recognized_kind) { |
| 1448 case MethodRecognizer::kObjectCid: { |
| 1449 InlineObjectCid(call); |
| 1450 return true; |
| 1451 } |
| 1442 case MethodRecognizer::kObjectArrayLength: | 1452 case MethodRecognizer::kObjectArrayLength: |
| 1443 case MethodRecognizer::kImmutableArrayLength: | 1453 case MethodRecognizer::kImmutableArrayLength: |
| 1444 case MethodRecognizer::kTypedDataLength: | 1454 case MethodRecognizer::kTypedDataLength: |
| 1445 case MethodRecognizer::kGrowableArrayLength: { | 1455 case MethodRecognizer::kGrowableArrayLength: { |
| 1446 if (!ic_data.HasOneTarget()) { | 1456 if (!ic_data.HasOneTarget()) { |
| 1447 // TODO(srdjan): Implement for mutiple targets. | 1457 // TODO(srdjan): Implement for mutiple targets. |
| 1448 return false; | 1458 return false; |
| 1449 } | 1459 } |
| 1450 const bool is_immutable = | 1460 const bool is_immutable = |
| 1451 (recognized_kind == MethodRecognizer::kObjectArrayLength) || | 1461 (recognized_kind == MethodRecognizer::kObjectArrayLength) || |
| (...skipping 4702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6154 | 6164 |
| 6155 // Insert materializations at environment uses. | 6165 // Insert materializations at environment uses. |
| 6156 const Class& cls = Class::Handle(alloc->constructor().Owner()); | 6166 const Class& cls = Class::Handle(alloc->constructor().Owner()); |
| 6157 for (intptr_t i = 0; i < exits.length(); i++) { | 6167 for (intptr_t i = 0; i < exits.length(); i++) { |
| 6158 CreateMaterializationAt(exits[i], alloc, cls, *fields); | 6168 CreateMaterializationAt(exits[i], alloc, cls, *fields); |
| 6159 } | 6169 } |
| 6160 } | 6170 } |
| 6161 | 6171 |
| 6162 | 6172 |
| 6163 } // namespace dart | 6173 } // namespace dart |
| OLD | NEW |