| 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 void FlowGraphOptimizer::ReplaceWithMathCFunction( | 1715 void FlowGraphOptimizer::ReplaceWithMathCFunction( |
| 1716 InstanceCallInstr* call, | 1716 InstanceCallInstr* call, |
| 1717 MethodRecognizer::Kind recognized_kind) { | 1717 MethodRecognizer::Kind recognized_kind) { |
| 1718 AddReceiverCheck(call); | 1718 AddReceiverCheck(call); |
| 1719 ZoneGrowableArray<Value*>* args = | 1719 ZoneGrowableArray<Value*>* args = |
| 1720 new ZoneGrowableArray<Value*>(call->ArgumentCount()); | 1720 new ZoneGrowableArray<Value*>(call->ArgumentCount()); |
| 1721 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { | 1721 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { |
| 1722 args->Add(new Value(call->ArgumentAt(i))); | 1722 args->Add(new Value(call->ArgumentAt(i))); |
| 1723 } | 1723 } |
| 1724 InvokeMathCFunctionInstr* invoke = | 1724 InvokeMathCFunctionInstr* invoke = |
| 1725 new InvokeMathCFunctionInstr(args, call, recognized_kind); | 1725 new InvokeMathCFunctionInstr(args, call->deopt_id(), recognized_kind); |
| 1726 ReplaceCall(call, invoke); | 1726 ReplaceCall(call, invoke); |
| 1727 } | 1727 } |
| 1728 | 1728 |
| 1729 | 1729 |
| 1730 static bool IsSupportedByteArrayViewCid(intptr_t cid) { | 1730 static bool IsSupportedByteArrayViewCid(intptr_t cid) { |
| 1731 switch (cid) { | 1731 switch (cid) { |
| 1732 case kTypedDataInt8ArrayCid: | 1732 case kTypedDataInt8ArrayCid: |
| 1733 case kTypedDataUint8ArrayCid: | 1733 case kTypedDataUint8ArrayCid: |
| 1734 case kExternalTypedDataUint8ArrayCid: | 1734 case kExternalTypedDataUint8ArrayCid: |
| 1735 case kTypedDataUint8ClampedArrayCid: | 1735 case kTypedDataUint8ClampedArrayCid: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 // Do not repeatedly deoptimize because result didn't fit into Smi. | 1854 // Do not repeatedly deoptimize because result didn't fit into Smi. |
| 1855 d2i_instr = new DoubleToIntegerInstr(new Value(input), call); | 1855 d2i_instr = new DoubleToIntegerInstr(new Value(input), call); |
| 1856 } else { | 1856 } else { |
| 1857 // Optimistically assume result fits into Smi. | 1857 // Optimistically assume result fits into Smi. |
| 1858 d2i_instr = new DoubleToSmiInstr(new Value(input), call->deopt_id()); | 1858 d2i_instr = new DoubleToSmiInstr(new Value(input), call->deopt_id()); |
| 1859 } | 1859 } |
| 1860 ReplaceCall(call, d2i_instr); | 1860 ReplaceCall(call, d2i_instr); |
| 1861 return true; | 1861 return true; |
| 1862 } | 1862 } |
| 1863 case MethodRecognizer::kDoubleMod: | 1863 case MethodRecognizer::kDoubleMod: |
| 1864 case MethodRecognizer::kDoublePow: | |
| 1865 case MethodRecognizer::kDoubleRound: | 1864 case MethodRecognizer::kDoubleRound: |
| 1866 ReplaceWithMathCFunction(call, recognized_kind); | 1865 ReplaceWithMathCFunction(call, recognized_kind); |
| 1867 return true; | 1866 return true; |
| 1868 case MethodRecognizer::kDoubleTruncate: | 1867 case MethodRecognizer::kDoubleTruncate: |
| 1869 case MethodRecognizer::kDoubleFloor: | 1868 case MethodRecognizer::kDoubleFloor: |
| 1870 case MethodRecognizer::kDoubleCeil: | 1869 case MethodRecognizer::kDoubleCeil: |
| 1871 if (!CPUFeatures::double_truncate_round_supported()) { | 1870 if (!CPUFeatures::double_truncate_round_supported()) { |
| 1872 ReplaceWithMathCFunction(call, recognized_kind); | 1871 ReplaceWithMathCFunction(call, recognized_kind); |
| 1873 } else { | 1872 } else { |
| 1874 AddReceiverCheck(call); | 1873 AddReceiverCheck(call); |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2762 call->env(), | 2761 call->env(), |
| 2763 call); | 2762 call); |
| 2764 AddCheckClass(min_max->right()->definition(), | 2763 AddCheckClass(min_max->right()->definition(), |
| 2765 unary_checks, | 2764 unary_checks, |
| 2766 call->deopt_id(), | 2765 call->deopt_id(), |
| 2767 call->env(), | 2766 call->env(), |
| 2768 call); | 2767 call); |
| 2769 ReplaceCall(call, min_max); | 2768 ReplaceCall(call, min_max); |
| 2770 } | 2769 } |
| 2771 } | 2770 } |
| 2771 } else if (recognized_kind == MethodRecognizer::kMathDoublePow) { |
| 2772 // We know that first argument is double, the second is num. |
| 2773 // InvokeMathCFunctionInstr requires unboxed doubles. UnboxDouble |
| 2774 // instructions contain type checks and conversions to double. |
| 2775 ZoneGrowableArray<Value*>* args = |
| 2776 new ZoneGrowableArray<Value*>(call->ArgumentCount()); |
| 2777 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { |
| 2778 args->Add(new Value(call->ArgumentAt(i))); |
| 2779 } |
| 2780 InvokeMathCFunctionInstr* invoke = |
| 2781 new InvokeMathCFunctionInstr(args, call->deopt_id(), recognized_kind); |
| 2782 ReplaceCall(call, invoke); |
| 2772 } | 2783 } |
| 2773 } | 2784 } |
| 2774 | 2785 |
| 2775 | 2786 |
| 2776 bool FlowGraphOptimizer::TryInlineInstanceSetter(InstanceCallInstr* instr, | 2787 bool FlowGraphOptimizer::TryInlineInstanceSetter(InstanceCallInstr* instr, |
| 2777 const ICData& unary_ic_data) { | 2788 const ICData& unary_ic_data) { |
| 2778 ASSERT((unary_ic_data.NumberOfChecks() > 0) && | 2789 ASSERT((unary_ic_data.NumberOfChecks() > 0) && |
| 2779 (unary_ic_data.num_args_tested() == 1)); | 2790 (unary_ic_data.num_args_tested() == 1)); |
| 2780 if (FLAG_enable_type_checks) { | 2791 if (FLAG_enable_type_checks) { |
| 2781 // TODO(srdjan): Add assignable check node if --enable_type_checks. | 2792 // TODO(srdjan): Add assignable check node if --enable_type_checks. |
| (...skipping 4722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7504 } | 7515 } |
| 7505 | 7516 |
| 7506 // Insert materializations at environment uses. | 7517 // Insert materializations at environment uses. |
| 7507 for (intptr_t i = 0; i < exits.length(); i++) { | 7518 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7508 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7519 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7509 } | 7520 } |
| 7510 } | 7521 } |
| 7511 | 7522 |
| 7512 | 7523 |
| 7513 } // namespace dart | 7524 } // namespace dart |
| OLD | NEW |