OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 return NoChange(); | 1842 return NoChange(); |
1843 } | 1843 } |
1844 | 1844 |
1845 | 1845 |
1846 Reduction JSTypedLowering::Reduce(Node* node) { | 1846 Reduction JSTypedLowering::Reduce(Node* node) { |
1847 // Check if the output type is a singleton. In that case we already know the | 1847 // Check if the output type is a singleton. In that case we already know the |
1848 // result value and can simply replace the node if it's eliminable. | 1848 // result value and can simply replace the node if it's eliminable. |
1849 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && | 1849 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && |
1850 node->op()->HasProperty(Operator::kEliminatable)) { | 1850 node->op()->HasProperty(Operator::kEliminatable)) { |
1851 Type* upper = NodeProperties::GetType(node); | 1851 Type* upper = NodeProperties::GetType(node); |
1852 if (upper->IsConstant()) { | 1852 if (upper->IsInhabited()) { |
1853 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); | 1853 if (upper->IsConstant()) { |
1854 ReplaceWithValue(node, replacement); | 1854 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); |
1855 return Changed(replacement); | 1855 ReplaceWithValue(node, replacement); |
1856 } else if (upper->Is(Type::MinusZero())) { | 1856 return Changed(replacement); |
1857 Node* replacement = jsgraph()->Constant(factory()->minus_zero_value()); | 1857 } else if (upper->Is(Type::MinusZero())) { |
1858 ReplaceWithValue(node, replacement); | 1858 Node* replacement = jsgraph()->Constant(factory()->minus_zero_value()); |
1859 return Changed(replacement); | 1859 ReplaceWithValue(node, replacement); |
1860 } else if (upper->Is(Type::NaN())) { | 1860 return Changed(replacement); |
1861 Node* replacement = jsgraph()->NaNConstant(); | 1861 } else if (upper->Is(Type::NaN())) { |
1862 ReplaceWithValue(node, replacement); | 1862 Node* replacement = jsgraph()->NaNConstant(); |
1863 return Changed(replacement); | 1863 ReplaceWithValue(node, replacement); |
1864 } else if (upper->Is(Type::Null())) { | 1864 return Changed(replacement); |
1865 Node* replacement = jsgraph()->NullConstant(); | 1865 } else if (upper->Is(Type::Null())) { |
1866 ReplaceWithValue(node, replacement); | 1866 Node* replacement = jsgraph()->NullConstant(); |
1867 return Changed(replacement); | 1867 ReplaceWithValue(node, replacement); |
1868 } else if (upper->Is(Type::PlainNumber()) && upper->Min() == upper->Max()) { | 1868 return Changed(replacement); |
1869 Node* replacement = jsgraph()->Constant(upper->Min()); | 1869 } else if (upper->Is(Type::PlainNumber()) && |
1870 ReplaceWithValue(node, replacement); | 1870 upper->Min() == upper->Max()) { |
1871 return Changed(replacement); | 1871 Node* replacement = jsgraph()->Constant(upper->Min()); |
1872 } else if (upper->Is(Type::Undefined())) { | 1872 ReplaceWithValue(node, replacement); |
1873 Node* replacement = jsgraph()->UndefinedConstant(); | 1873 return Changed(replacement); |
1874 ReplaceWithValue(node, replacement); | 1874 } else if (upper->Is(Type::Undefined())) { |
1875 return Changed(replacement); | 1875 Node* replacement = jsgraph()->UndefinedConstant(); |
| 1876 ReplaceWithValue(node, replacement); |
| 1877 return Changed(replacement); |
| 1878 } |
1876 } | 1879 } |
1877 } | 1880 } |
1878 switch (node->opcode()) { | 1881 switch (node->opcode()) { |
1879 case IrOpcode::kJSEqual: | 1882 case IrOpcode::kJSEqual: |
1880 return ReduceJSEqual(node, false); | 1883 return ReduceJSEqual(node, false); |
1881 case IrOpcode::kJSNotEqual: | 1884 case IrOpcode::kJSNotEqual: |
1882 return ReduceJSEqual(node, true); | 1885 return ReduceJSEqual(node, true); |
1883 case IrOpcode::kJSStrictEqual: | 1886 case IrOpcode::kJSStrictEqual: |
1884 return ReduceJSStrictEqual(node, false); | 1887 return ReduceJSStrictEqual(node, false); |
1885 case IrOpcode::kJSStrictNotEqual: | 1888 case IrOpcode::kJSStrictNotEqual: |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 } | 2010 } |
2008 | 2011 |
2009 | 2012 |
2010 CompilationDependencies* JSTypedLowering::dependencies() const { | 2013 CompilationDependencies* JSTypedLowering::dependencies() const { |
2011 return dependencies_; | 2014 return dependencies_; |
2012 } | 2015 } |
2013 | 2016 |
2014 } // namespace compiler | 2017 } // namespace compiler |
2015 } // namespace internal | 2018 } // namespace internal |
2016 } // namespace v8 | 2019 } // namespace v8 |
OLD | NEW |