| 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 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 return TypedData::length_offset(); | 1386 return TypedData::length_offset(); |
| 1387 case MethodRecognizer::kGrowableArrayLength: | 1387 case MethodRecognizer::kGrowableArrayLength: |
| 1388 return GrowableObjectArray::length_offset(); | 1388 return GrowableObjectArray::length_offset(); |
| 1389 default: | 1389 default: |
| 1390 UNREACHABLE(); | 1390 UNREACHABLE(); |
| 1391 return 0; | 1391 return 0; |
| 1392 } | 1392 } |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 | 1395 |
| 1396 bool FlowGraphOptimizer::InlineFloat32x4Getter(InstanceCallInstr* call, |
| 1397 MethodRecognizer::Kind getter) { |
| 1398 AddCheckClass(call->ArgumentAt(0), |
| 1399 ICData::ZoneHandle( |
| 1400 call->ic_data()->AsUnaryClassChecksForArgNr(0)), |
| 1401 call->deopt_id(), |
| 1402 call->env(), |
| 1403 call); |
| 1404 Float32x4ShuffleInstr* instr = new Float32x4ShuffleInstr( |
| 1405 getter, |
| 1406 new Value(call->ArgumentAt(0)), |
| 1407 call); |
| 1408 ReplaceCall(call, instr); |
| 1409 return true; |
| 1410 } |
| 1411 |
| 1412 |
| 1396 // Only unique implicit instance getters can be currently handled. | 1413 // Only unique implicit instance getters can be currently handled. |
| 1397 bool FlowGraphOptimizer::TryInlineInstanceGetter(InstanceCallInstr* call) { | 1414 bool FlowGraphOptimizer::TryInlineInstanceGetter(InstanceCallInstr* call) { |
| 1398 ASSERT(call->HasICData()); | 1415 ASSERT(call->HasICData()); |
| 1399 const ICData& ic_data = *call->ic_data(); | 1416 const ICData& ic_data = *call->ic_data(); |
| 1400 if (ic_data.NumberOfChecks() == 0) { | 1417 if (ic_data.NumberOfChecks() == 0) { |
| 1401 // No type feedback collected. | 1418 // No type feedback collected. |
| 1402 return false; | 1419 return false; |
| 1403 } | 1420 } |
| 1404 Function& target = Function::Handle(ic_data.GetTargetAt(0)); | 1421 Function& target = Function::Handle(ic_data.GetTargetAt(0)); |
| 1405 if (target.kind() == RawFunction::kImplicitGetter) { | 1422 if (target.kind() == RawFunction::kImplicitGetter) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 } | 1464 } |
| 1448 InlineStringLengthGetter(call); | 1465 InlineStringLengthGetter(call); |
| 1449 return true; | 1466 return true; |
| 1450 case MethodRecognizer::kStringBaseIsEmpty: | 1467 case MethodRecognizer::kStringBaseIsEmpty: |
| 1451 if (!ic_data.HasOneTarget()) { | 1468 if (!ic_data.HasOneTarget()) { |
| 1452 // Target is not only StringBase_get_isEmpty. | 1469 // Target is not only StringBase_get_isEmpty. |
| 1453 return false; | 1470 return false; |
| 1454 } | 1471 } |
| 1455 InlineStringIsEmptyGetter(call); | 1472 InlineStringIsEmptyGetter(call); |
| 1456 return true; | 1473 return true; |
| 1474 case MethodRecognizer::kFloat32x4ShuffleXXXX: |
| 1475 case MethodRecognizer::kFloat32x4ShuffleYYYY: |
| 1476 case MethodRecognizer::kFloat32x4ShuffleZZZZ: |
| 1477 case MethodRecognizer::kFloat32x4ShuffleWWWW: |
| 1478 case MethodRecognizer::kFloat32x4ShuffleX: |
| 1479 case MethodRecognizer::kFloat32x4ShuffleY: |
| 1480 case MethodRecognizer::kFloat32x4ShuffleZ: |
| 1481 case MethodRecognizer::kFloat32x4ShuffleW: |
| 1482 if (!ic_data.HasReceiverClassId(kFloat32x4Cid) || |
| 1483 !ic_data.HasOneTarget()) { |
| 1484 return false; |
| 1485 } |
| 1486 return InlineFloat32x4Getter(call, recognized_kind); |
| 1457 default: | 1487 default: |
| 1458 ASSERT(recognized_kind == MethodRecognizer::kUnknown); | 1488 ASSERT(recognized_kind == MethodRecognizer::kUnknown); |
| 1459 } | 1489 } |
| 1460 return false; | 1490 return false; |
| 1461 } | 1491 } |
| 1462 | 1492 |
| 1463 | 1493 |
| 1464 LoadIndexedInstr* FlowGraphOptimizer::BuildStringCodeUnitAt( | 1494 LoadIndexedInstr* FlowGraphOptimizer::BuildStringCodeUnitAt( |
| 1465 InstanceCallInstr* call, | 1495 InstanceCallInstr* call, |
| 1466 intptr_t cid) { | 1496 intptr_t cid) { |
| (...skipping 3225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4692 const Object& right = instr->right()->definition()->constant_value(); | 4722 const Object& right = instr->right()->definition()->constant_value(); |
| 4693 if (IsNonConstant(left) || IsNonConstant(right)) { | 4723 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 4694 SetValue(instr, non_constant_); | 4724 SetValue(instr, non_constant_); |
| 4695 } else if (IsConstant(left) && IsConstant(right)) { | 4725 } else if (IsConstant(left) && IsConstant(right)) { |
| 4696 // TODO(kmillikin): Handle binary operation. | 4726 // TODO(kmillikin): Handle binary operation. |
| 4697 SetValue(instr, non_constant_); | 4727 SetValue(instr, non_constant_); |
| 4698 } | 4728 } |
| 4699 } | 4729 } |
| 4700 | 4730 |
| 4701 | 4731 |
| 4732 void ConstantPropagator::VisitFloat32x4Shuffle(Float32x4ShuffleInstr* instr) { |
| 4733 SetValue(instr, non_constant_); |
| 4734 } |
| 4735 |
| 4736 |
| 4702 void ConstantPropagator::VisitMathSqrt(MathSqrtInstr* instr) { | 4737 void ConstantPropagator::VisitMathSqrt(MathSqrtInstr* instr) { |
| 4703 const Object& value = instr->value()->definition()->constant_value(); | 4738 const Object& value = instr->value()->definition()->constant_value(); |
| 4704 if (IsNonConstant(value)) { | 4739 if (IsNonConstant(value)) { |
| 4705 SetValue(instr, non_constant_); | 4740 SetValue(instr, non_constant_); |
| 4706 } else if (IsConstant(value)) { | 4741 } else if (IsConstant(value)) { |
| 4707 // TODO(kmillikin): Handle sqrt. | 4742 // TODO(kmillikin): Handle sqrt. |
| 4708 SetValue(instr, non_constant_); | 4743 SetValue(instr, non_constant_); |
| 4709 } | 4744 } |
| 4710 } | 4745 } |
| 4711 | 4746 |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5316 if (changed) { | 5351 if (changed) { |
| 5317 // We may have changed the block order and the dominator tree. | 5352 // We may have changed the block order and the dominator tree. |
| 5318 flow_graph->DiscoverBlocks(); | 5353 flow_graph->DiscoverBlocks(); |
| 5319 GrowableArray<BitVector*> dominance_frontier; | 5354 GrowableArray<BitVector*> dominance_frontier; |
| 5320 flow_graph->ComputeDominators(&dominance_frontier); | 5355 flow_graph->ComputeDominators(&dominance_frontier); |
| 5321 } | 5356 } |
| 5322 } | 5357 } |
| 5323 | 5358 |
| 5324 | 5359 |
| 5325 } // namespace dart | 5360 } // namespace dart |
| OLD | NEW |