| 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 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 | 1383 |
| 1384 | 1384 |
| 1385 // Inline only simple, frequently called core library methods. | 1385 // Inline only simple, frequently called core library methods. |
| 1386 bool FlowGraphOptimizer::TryInlineInstanceMethod(InstanceCallInstr* call) { | 1386 bool FlowGraphOptimizer::TryInlineInstanceMethod(InstanceCallInstr* call) { |
| 1387 ASSERT(call->HasICData()); | 1387 ASSERT(call->HasICData()); |
| 1388 const ICData& ic_data = *call->ic_data(); | 1388 const ICData& ic_data = *call->ic_data(); |
| 1389 if ((ic_data.NumberOfChecks() == 0) || !ic_data.HasOneTarget()) { | 1389 if ((ic_data.NumberOfChecks() == 0) || !ic_data.HasOneTarget()) { |
| 1390 // No type feedback collected or multiple targets found. | 1390 // No type feedback collected or multiple targets found. |
| 1391 return false; | 1391 return false; |
| 1392 } | 1392 } |
| 1393 |
| 1393 Function& target = Function::Handle(); | 1394 Function& target = Function::Handle(); |
| 1394 GrowableArray<intptr_t> class_ids; | 1395 GrowableArray<intptr_t> class_ids; |
| 1395 ic_data.GetCheckAt(0, &class_ids, &target); | 1396 ic_data.GetCheckAt(0, &class_ids, &target); |
| 1396 MethodRecognizer::Kind recognized_kind = | 1397 MethodRecognizer::Kind recognized_kind = |
| 1397 MethodRecognizer::RecognizeKind(target); | 1398 MethodRecognizer::RecognizeKind(target); |
| 1399 |
| 1400 // Byte array access. |
| 1401 switch (recognized_kind) { |
| 1402 case MethodRecognizer::kFloat32ArrayGetIndexed: |
| 1403 case MethodRecognizer::kFloat64ArrayGetIndexed: |
| 1404 case MethodRecognizer::kInt8ArrayGetIndexed: |
| 1405 case MethodRecognizer::kUint8ArrayGetIndexed: |
| 1406 case MethodRecognizer::kUint8ClampedArrayGetIndexed: |
| 1407 case MethodRecognizer::kExternalUint8ArrayGetIndexed: |
| 1408 case MethodRecognizer::kExternalUint8ClampedArrayGetIndexed: |
| 1409 case MethodRecognizer::kInt16ArrayGetIndexed: |
| 1410 case MethodRecognizer::kUint16ArrayGetIndexed: |
| 1411 case MethodRecognizer::kInt32ArrayGetIndexed: |
| 1412 case MethodRecognizer::kUint32ArrayGetIndexed: |
| 1413 return TryReplaceWithLoadIndexed(call); |
| 1414 default: |
| 1415 break; |
| 1416 } |
| 1417 |
| 1398 if ((recognized_kind == MethodRecognizer::kStringBaseCharCodeAt) && | 1418 if ((recognized_kind == MethodRecognizer::kStringBaseCharCodeAt) && |
| 1399 (ic_data.NumberOfChecks() == 1) && | 1419 (ic_data.NumberOfChecks() == 1) && |
| 1400 ((class_ids[0] == kOneByteStringCid) || | 1420 ((class_ids[0] == kOneByteStringCid) || |
| 1401 (class_ids[0] == kTwoByteStringCid))) { | 1421 (class_ids[0] == kTwoByteStringCid))) { |
| 1402 LoadIndexedInstr* instr = BuildStringCharCodeAt(call, class_ids[0]); | 1422 LoadIndexedInstr* instr = BuildStringCharCodeAt(call, class_ids[0]); |
| 1403 call->ReplaceWith(instr, current_iterator()); | 1423 call->ReplaceWith(instr, current_iterator()); |
| 1404 RemovePushArguments(call); | 1424 RemovePushArguments(call); |
| 1405 return true; | 1425 return true; |
| 1406 } | 1426 } |
| 1407 if ((recognized_kind == MethodRecognizer::kStringBaseCharAt) && | 1427 if ((recognized_kind == MethodRecognizer::kStringBaseCharAt) && |
| (...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4255 | 4275 |
| 4256 if (FLAG_trace_constant_propagation) { | 4276 if (FLAG_trace_constant_propagation) { |
| 4257 OS::Print("\n==== After constant propagation ====\n"); | 4277 OS::Print("\n==== After constant propagation ====\n"); |
| 4258 FlowGraphPrinter printer(*graph_); | 4278 FlowGraphPrinter printer(*graph_); |
| 4259 printer.PrintBlocks(); | 4279 printer.PrintBlocks(); |
| 4260 } | 4280 } |
| 4261 } | 4281 } |
| 4262 | 4282 |
| 4263 | 4283 |
| 4264 } // namespace dart | 4284 } // namespace dart |
| OLD | NEW |