| 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/aot_optimizer.h" | 5 #include "vm/aot_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 if ((class_ids[0] == kInt32x4Cid) && (ic_data.NumberOfChecks() == 1)) { | 1899 if ((class_ids[0] == kInt32x4Cid) && (ic_data.NumberOfChecks() == 1)) { |
| 1900 return TryInlineInt32x4Method(call, recognized_kind); | 1900 return TryInlineInt32x4Method(call, recognized_kind); |
| 1901 } | 1901 } |
| 1902 | 1902 |
| 1903 if ((class_ids[0] == kFloat64x2Cid) && (ic_data.NumberOfChecks() == 1)) { | 1903 if ((class_ids[0] == kFloat64x2Cid) && (ic_data.NumberOfChecks() == 1)) { |
| 1904 return TryInlineFloat64x2Method(call, recognized_kind); | 1904 return TryInlineFloat64x2Method(call, recognized_kind); |
| 1905 } | 1905 } |
| 1906 | 1906 |
| 1907 if (recognized_kind == MethodRecognizer::kIntegerLeftShiftWithMask32) { | |
| 1908 ASSERT(call->ArgumentCount() == 3); | |
| 1909 ASSERT(ic_data.NumArgsTested() == 2); | |
| 1910 Definition* value = call->ArgumentAt(0); | |
| 1911 Definition* count = call->ArgumentAt(1); | |
| 1912 Definition* int32_mask = call->ArgumentAt(2); | |
| 1913 if (HasOnlyTwoOf(ic_data, kSmiCid)) { | |
| 1914 if (ic_data.HasDeoptReason(ICData::kDeoptBinaryMintOp)) { | |
| 1915 return false; | |
| 1916 } | |
| 1917 // We cannot overflow. The input value must be a Smi | |
| 1918 AddCheckSmi(value, call->deopt_id(), call->env(), call); | |
| 1919 AddCheckSmi(count, call->deopt_id(), call->env(), call); | |
| 1920 ASSERT(int32_mask->IsConstant()); | |
| 1921 const Integer& mask_literal = Integer::Cast( | |
| 1922 int32_mask->AsConstant()->value()); | |
| 1923 const int64_t mask_value = mask_literal.AsInt64Value(); | |
| 1924 ASSERT(mask_value >= 0); | |
| 1925 if (mask_value > Smi::kMaxValue) { | |
| 1926 // The result will not be Smi. | |
| 1927 return false; | |
| 1928 } | |
| 1929 BinarySmiOpInstr* left_shift = | |
| 1930 new(Z) BinarySmiOpInstr(Token::kSHL, | |
| 1931 new(Z) Value(value), | |
| 1932 new(Z) Value(count), | |
| 1933 call->deopt_id()); | |
| 1934 left_shift->mark_truncating(); | |
| 1935 if ((kBitsPerWord == 32) && (mask_value == 0xffffffffLL)) { | |
| 1936 // No BIT_AND operation needed. | |
| 1937 ReplaceCall(call, left_shift); | |
| 1938 } else { | |
| 1939 InsertBefore(call, left_shift, call->env(), FlowGraph::kValue); | |
| 1940 BinarySmiOpInstr* bit_and = | |
| 1941 new(Z) BinarySmiOpInstr(Token::kBIT_AND, | |
| 1942 new(Z) Value(left_shift), | |
| 1943 new(Z) Value(int32_mask), | |
| 1944 call->deopt_id()); | |
| 1945 ReplaceCall(call, bit_and); | |
| 1946 } | |
| 1947 return true; | |
| 1948 } | |
| 1949 | |
| 1950 if (HasTwoMintOrSmi(ic_data) && | |
| 1951 HasOnlyOneSmi(ICData::Handle(Z, | |
| 1952 ic_data.AsUnaryClassChecksForArgNr(1)))) { | |
| 1953 if (!FlowGraphCompiler::SupportsUnboxedMints() || | |
| 1954 ic_data.HasDeoptReason(ICData::kDeoptBinaryMintOp)) { | |
| 1955 return false; | |
| 1956 } | |
| 1957 ShiftMintOpInstr* left_shift = | |
| 1958 new(Z) ShiftMintOpInstr(Token::kSHL, | |
| 1959 new(Z) Value(value), | |
| 1960 new(Z) Value(count), | |
| 1961 call->deopt_id()); | |
| 1962 InsertBefore(call, left_shift, call->env(), FlowGraph::kValue); | |
| 1963 BinaryMintOpInstr* bit_and = | |
| 1964 new(Z) BinaryMintOpInstr(Token::kBIT_AND, | |
| 1965 new(Z) Value(left_shift), | |
| 1966 new(Z) Value(int32_mask), | |
| 1967 call->deopt_id()); | |
| 1968 ReplaceCall(call, bit_and); | |
| 1969 return true; | |
| 1970 } | |
| 1971 } | |
| 1972 return false; | 1907 return false; |
| 1973 } | 1908 } |
| 1974 | 1909 |
| 1975 | 1910 |
| 1976 bool AotOptimizer::TryInlineFloat32x4Constructor( | 1911 bool AotOptimizer::TryInlineFloat32x4Constructor( |
| 1977 StaticCallInstr* call, | 1912 StaticCallInstr* call, |
| 1978 MethodRecognizer::Kind recognized_kind) { | 1913 MethodRecognizer::Kind recognized_kind) { |
| 1979 // Cannot handle unboxed instructions. | 1914 // Cannot handle unboxed instructions. |
| 1980 ASSERT(FLAG_precompiled_mode); | 1915 ASSERT(FLAG_precompiled_mode); |
| 1981 return false; | 1916 return false; |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2821 | 2756 |
| 2822 // Discard the environment from the original instruction because the store | 2757 // Discard the environment from the original instruction because the store |
| 2823 // can't deoptimize. | 2758 // can't deoptimize. |
| 2824 instr->RemoveEnvironment(); | 2759 instr->RemoveEnvironment(); |
| 2825 ReplaceCall(instr, store); | 2760 ReplaceCall(instr, store); |
| 2826 return true; | 2761 return true; |
| 2827 } | 2762 } |
| 2828 | 2763 |
| 2829 | 2764 |
| 2830 } // namespace dart | 2765 } // namespace dart |
| OLD | NEW |