Chromium Code Reviews| 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)), | |
|
srdjan
2013/04/22 22:28:18
indent of 4 chars
Cutch
2013/04/22 23:05:41
Done.
| |
| 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 3028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4495 const Object& right = instr->right()->definition()->constant_value(); | 4525 const Object& right = instr->right()->definition()->constant_value(); |
| 4496 if (IsNonConstant(left) || IsNonConstant(right)) { | 4526 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 4497 SetValue(instr, non_constant_); | 4527 SetValue(instr, non_constant_); |
| 4498 } else if (IsConstant(left) && IsConstant(right)) { | 4528 } else if (IsConstant(left) && IsConstant(right)) { |
| 4499 // TODO(kmillikin): Handle binary operation. | 4529 // TODO(kmillikin): Handle binary operation. |
| 4500 SetValue(instr, non_constant_); | 4530 SetValue(instr, non_constant_); |
| 4501 } | 4531 } |
| 4502 } | 4532 } |
| 4503 | 4533 |
| 4504 | 4534 |
| 4535 void ConstantPropagator::VisitFloat32x4Shuffle(Float32x4ShuffleInstr* instr) { | |
| 4536 SetValue(instr, non_constant_); | |
| 4537 } | |
| 4538 | |
| 4539 | |
| 4505 void ConstantPropagator::VisitMathSqrt(MathSqrtInstr* instr) { | 4540 void ConstantPropagator::VisitMathSqrt(MathSqrtInstr* instr) { |
| 4506 const Object& value = instr->value()->definition()->constant_value(); | 4541 const Object& value = instr->value()->definition()->constant_value(); |
| 4507 if (IsNonConstant(value)) { | 4542 if (IsNonConstant(value)) { |
| 4508 SetValue(instr, non_constant_); | 4543 SetValue(instr, non_constant_); |
| 4509 } else if (IsConstant(value)) { | 4544 } else if (IsConstant(value)) { |
| 4510 // TODO(kmillikin): Handle sqrt. | 4545 // TODO(kmillikin): Handle sqrt. |
| 4511 SetValue(instr, non_constant_); | 4546 SetValue(instr, non_constant_); |
| 4512 } | 4547 } |
| 4513 } | 4548 } |
| 4514 | 4549 |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5119 if (changed) { | 5154 if (changed) { |
| 5120 // We may have changed the block order and the dominator tree. | 5155 // We may have changed the block order and the dominator tree. |
| 5121 flow_graph->DiscoverBlocks(); | 5156 flow_graph->DiscoverBlocks(); |
| 5122 GrowableArray<BitVector*> dominance_frontier; | 5157 GrowableArray<BitVector*> dominance_frontier; |
| 5123 flow_graph->ComputeDominators(&dominance_frontier); | 5158 flow_graph->ComputeDominators(&dominance_frontier); |
| 5124 } | 5159 } |
| 5125 } | 5160 } |
| 5126 | 5161 |
| 5127 | 5162 |
| 5128 } // namespace dart | 5163 } // namespace dart |
| OLD | NEW |