| 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 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 } | 1935 } |
| 1936 } | 1936 } |
| 1937 | 1937 |
| 1938 if ((class_ids[0] == kFloat32x4Cid) && (ic_data.NumberOfChecks() == 1)) { | 1938 if ((class_ids[0] == kFloat32x4Cid) && (ic_data.NumberOfChecks() == 1)) { |
| 1939 return TryInlineFloat32x4Method(call, recognized_kind); | 1939 return TryInlineFloat32x4Method(call, recognized_kind); |
| 1940 } | 1940 } |
| 1941 | 1941 |
| 1942 if ((class_ids[0] == kUint32x4Cid) && (ic_data.NumberOfChecks() == 1)) { | 1942 if ((class_ids[0] == kUint32x4Cid) && (ic_data.NumberOfChecks() == 1)) { |
| 1943 return TryInlineUint32x4Method(call, recognized_kind); | 1943 return TryInlineUint32x4Method(call, recognized_kind); |
| 1944 } | 1944 } |
| 1945 |
| 1946 if (recognized_kind == MethodRecognizer::kIntegerLeftShiftWithMask32) { |
| 1947 ASSERT(call->ArgumentCount() == 3); |
| 1948 ASSERT(ic_data.num_args_tested() == 2); |
| 1949 Definition* value = call->ArgumentAt(0); |
| 1950 Definition* count = call->ArgumentAt(1); |
| 1951 Definition* int32_mask = call->ArgumentAt(2); |
| 1952 if (HasOnlyTwoOf(ic_data, kSmiCid)) { |
| 1953 if (ic_data.deopt_reason() == kDeoptShiftMintOp) { |
| 1954 return false; |
| 1955 } |
| 1956 // We cannot overflow. The input value must be a Smi |
| 1957 AddCheckSmi(value, call->deopt_id(), call->env(), call); |
| 1958 AddCheckSmi(count, call->deopt_id(), call->env(), call); |
| 1959 ASSERT(int32_mask->IsConstant()); |
| 1960 const Integer& mask_literal = Integer::Cast( |
| 1961 int32_mask->AsConstant()->value()); |
| 1962 const int64_t mask_value = mask_literal.AsInt64Value(); |
| 1963 ASSERT(mask_value >= 0); |
| 1964 if (mask_value > Smi::kMaxValue) { |
| 1965 // The result will not be Smi. |
| 1966 return false; |
| 1967 } |
| 1968 BinarySmiOpInstr* left_shift = |
| 1969 new BinarySmiOpInstr(Token::kSHL, |
| 1970 new Value(value), new Value(count), |
| 1971 call->deopt_id()); |
| 1972 left_shift->set_is_truncating(true); |
| 1973 if (mask_value == 0xffffffffLL) { |
| 1974 // No BIT_AND operation needed. |
| 1975 ReplaceCall(call, left_shift); |
| 1976 } else { |
| 1977 InsertBefore(call, left_shift, call->env(), Definition::kValue); |
| 1978 BinarySmiOpInstr* bit_and = |
| 1979 new BinarySmiOpInstr(Token::kBIT_AND, |
| 1980 new Value(left_shift), new Value(int32_mask), |
| 1981 call->deopt_id()); |
| 1982 ReplaceCall(call, bit_and); |
| 1983 } |
| 1984 return true; |
| 1985 } |
| 1986 |
| 1987 if (HasTwoMintOrSmi(ic_data) && |
| 1988 HasOnlyOneSmi(ICData::Handle(ic_data.AsUnaryClassChecksForArgNr(1)))) { |
| 1989 if (!FlowGraphCompiler::SupportsUnboxedMints() || |
| 1990 (ic_data.deopt_reason() == kDeoptShiftMintOp)) { |
| 1991 return false; |
| 1992 } |
| 1993 ShiftMintOpInstr* left_shift = |
| 1994 new ShiftMintOpInstr(Token::kSHL, |
| 1995 new Value(value), new Value(count), |
| 1996 call->deopt_id()); |
| 1997 InsertBefore(call, left_shift, call->env(), Definition::kValue); |
| 1998 BinaryMintOpInstr* bit_and = |
| 1999 new BinaryMintOpInstr(Token::kBIT_AND, |
| 2000 new Value(left_shift), new Value(int32_mask), |
| 2001 call->deopt_id()); |
| 2002 ReplaceCall(call, bit_and); |
| 2003 return true; |
| 2004 } |
| 2005 } |
| 1945 return false; | 2006 return false; |
| 1946 } | 2007 } |
| 1947 | 2008 |
| 1948 | 2009 |
| 1949 bool FlowGraphOptimizer::TryInlineFloat32x4Constructor( | 2010 bool FlowGraphOptimizer::TryInlineFloat32x4Constructor( |
| 1950 StaticCallInstr* call, | 2011 StaticCallInstr* call, |
| 1951 MethodRecognizer::Kind recognized_kind) { | 2012 MethodRecognizer::Kind recognized_kind) { |
| 1952 if (!ShouldInlineSimd()) { | 2013 if (!ShouldInlineSimd()) { |
| 1953 return false; | 2014 return false; |
| 1954 } | 2015 } |
| (...skipping 5454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7409 } | 7470 } |
| 7410 | 7471 |
| 7411 // Insert materializations at environment uses. | 7472 // Insert materializations at environment uses. |
| 7412 for (intptr_t i = 0; i < exits.length(); i++) { | 7473 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7413 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7474 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7414 } | 7475 } |
| 7415 } | 7476 } |
| 7416 | 7477 |
| 7417 | 7478 |
| 7418 } // namespace dart | 7479 } // namespace dart |
| OLD | NEW |