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/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 right = temp; | 1840 right = temp; |
1841 } | 1841 } |
1842 if (IsLengthOneString(left)) { | 1842 if (IsLengthOneString(left)) { |
1843 // Optimize if left is a string with length one (either constant or | 1843 // Optimize if left is a string with length one (either constant or |
1844 // result of string-from-char-code. | 1844 // result of string-from-char-code. |
1845 if (left->IsConstant()) { | 1845 if (left->IsConstant()) { |
1846 ConstantInstr* left_const = left->AsConstant(); | 1846 ConstantInstr* left_const = left->AsConstant(); |
1847 const String& str = String::Cast(left_const->value()); | 1847 const String& str = String::Cast(left_const->value()); |
1848 ASSERT(str.Length() == 1); | 1848 ASSERT(str.Length() == 1); |
1849 ConstantInstr* char_code_left = flow_graph()->GetConstant( | 1849 ConstantInstr* char_code_left = flow_graph()->GetConstant( |
1850 Smi::ZoneHandle(I, Smi::New(str.CharAt(0)))); | 1850 Smi::ZoneHandle(I, Smi::New(static_cast<intptr_t>(str.CharAt(0))))); |
1851 left_val = new(I) Value(char_code_left); | 1851 left_val = new(I) Value(char_code_left); |
1852 } else if (left->IsStringFromCharCode()) { | 1852 } else if (left->IsStringFromCharCode()) { |
1853 // Use input of string-from-charcode as left value. | 1853 // Use input of string-from-charcode as left value. |
1854 StringFromCharCodeInstr* instr = left->AsStringFromCharCode(); | 1854 StringFromCharCodeInstr* instr = left->AsStringFromCharCode(); |
1855 left_val = new(I) Value(instr->char_code()->definition()); | 1855 left_val = new(I) Value(instr->char_code()->definition()); |
1856 to_remove_left = instr; | 1856 to_remove_left = instr; |
1857 } else { | 1857 } else { |
1858 // IsLengthOneString(left) should have been false. | 1858 // IsLengthOneString(left) should have been false. |
1859 UNREACHABLE(); | 1859 UNREACHABLE(); |
1860 } | 1860 } |
(...skipping 6145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8006 } | 8006 } |
8007 } | 8007 } |
8008 | 8008 |
8009 | 8009 |
8010 void ConstantPropagator::VisitStringToCharCode(StringToCharCodeInstr* instr) { | 8010 void ConstantPropagator::VisitStringToCharCode(StringToCharCodeInstr* instr) { |
8011 const Object& o = instr->str()->definition()->constant_value(); | 8011 const Object& o = instr->str()->definition()->constant_value(); |
8012 if (o.IsNull() || IsNonConstant(o)) { | 8012 if (o.IsNull() || IsNonConstant(o)) { |
8013 SetValue(instr, non_constant_); | 8013 SetValue(instr, non_constant_); |
8014 } else if (IsConstant(o)) { | 8014 } else if (IsConstant(o)) { |
8015 const String& str = String::Cast(o); | 8015 const String& str = String::Cast(o); |
8016 const intptr_t result = (str.Length() == 1) ? str.CharAt(0) : -1; | 8016 const intptr_t result = |
| 8017 (str.Length() == 1) ? static_cast<intptr_t>(str.CharAt(0)) : -1; |
8017 SetValue(instr, Smi::ZoneHandle(I, Smi::New(result))); | 8018 SetValue(instr, Smi::ZoneHandle(I, Smi::New(result))); |
8018 } | 8019 } |
8019 } | 8020 } |
8020 | 8021 |
8021 | 8022 |
8022 | 8023 |
8023 | 8024 |
8024 void ConstantPropagator::VisitStringInterpolate(StringInterpolateInstr* instr) { | 8025 void ConstantPropagator::VisitStringInterpolate(StringInterpolateInstr* instr) { |
8025 SetValue(instr, non_constant_); | 8026 SetValue(instr, non_constant_); |
8026 return; | 8027 return; |
(...skipping 10 matching lines...) Expand all Loading... |
8037 if (!index_obj.IsSmi()) { | 8038 if (!index_obj.IsSmi()) { |
8038 // Should not occur. | 8039 // Should not occur. |
8039 SetValue(instr, non_constant_); | 8040 SetValue(instr, non_constant_); |
8040 return; | 8041 return; |
8041 } | 8042 } |
8042 const intptr_t index = Smi::Cast(index_obj).Value(); | 8043 const intptr_t index = Smi::Cast(index_obj).Value(); |
8043 if (index >= 0) { | 8044 if (index >= 0) { |
8044 if (array_obj.IsString()) { | 8045 if (array_obj.IsString()) { |
8045 const String& str = String::Cast(array_obj); | 8046 const String& str = String::Cast(array_obj); |
8046 if (str.Length() > index) { | 8047 if (str.Length() > index) { |
8047 SetValue(instr, Smi::Handle(I, Smi::New(str.CharAt(index)))); | 8048 SetValue(instr, Smi::Handle(I, |
| 8049 Smi::New(static_cast<intptr_t>(str.CharAt(index))))); |
8048 return; | 8050 return; |
8049 } | 8051 } |
8050 } else if (array_obj.IsArray()) { | 8052 } else if (array_obj.IsArray()) { |
8051 const Array& a = Array::Cast(array_obj); | 8053 const Array& a = Array::Cast(array_obj); |
8052 if ((a.Length() > index) && a.IsImmutable()) { | 8054 if ((a.Length() > index) && a.IsImmutable()) { |
8053 Instance& result = Instance::Handle(I); | 8055 Instance& result = Instance::Handle(I); |
8054 result ^= a.At(index); | 8056 result ^= a.At(index); |
8055 SetValue(instr, result); | 8057 SetValue(instr, result); |
8056 return; | 8058 return; |
8057 } | 8059 } |
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10093 | 10095 |
10094 // Insert materializations at environment uses. | 10096 // Insert materializations at environment uses. |
10095 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 10097 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
10096 CreateMaterializationAt( | 10098 CreateMaterializationAt( |
10097 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 10099 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
10098 } | 10100 } |
10099 } | 10101 } |
10100 | 10102 |
10101 | 10103 |
10102 } // namespace dart | 10104 } // namespace dart |
OLD | NEW |