| 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/compiler/js-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
| 6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
| 7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
| 8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 TEST_F(JSTypedLoweringTest, JSToBooleanWithReceiverOrNullOrUndefined) { | 124 TEST_F(JSTypedLoweringTest, JSToBooleanWithReceiverOrNullOrUndefined) { |
| 125 Node* input = Parameter(Type::ReceiverOrNullOrUndefined(), 0); | 125 Node* input = Parameter(Type::ReceiverOrNullOrUndefined(), 0); |
| 126 Node* context = Parameter(Type::Any(), 1); | 126 Node* context = Parameter(Type::Any(), 1); |
| 127 Reduction r = Reduce(graph()->NewNode( | 127 Reduction r = Reduce(graph()->NewNode( |
| 128 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); | 128 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); |
| 129 ASSERT_TRUE(r.Changed()); | 129 ASSERT_TRUE(r.Changed()); |
| 130 EXPECT_THAT(r.replacement(), IsBooleanNot(IsObjectIsUndetectable(input))); | 130 EXPECT_THAT(r.replacement(), IsBooleanNot(IsObjectIsUndetectable(input))); |
| 131 } | 131 } |
| 132 | 132 |
| 133 TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { |
| 134 Node* input = Parameter(Type::String(), 0); |
| 135 Node* context = Parameter(Type::Any(), 1); |
| 136 Reduction r = Reduce(graph()->NewNode( |
| 137 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); |
| 138 ASSERT_TRUE(r.Changed()); |
| 139 EXPECT_THAT(r.replacement(), |
| 140 IsBooleanNot(IsReferenceEqual( |
| 141 input, IsHeapConstant(factory()->empty_string())))); |
| 142 } |
| 143 |
| 133 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { | 144 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { |
| 134 Node* input = Parameter(Type::Any(), 0); | 145 Node* input = Parameter(Type::Any(), 0); |
| 135 Node* context = Parameter(Type::Any(), 1); | 146 Node* context = Parameter(Type::Any(), 1); |
| 136 Reduction r = Reduce(graph()->NewNode( | 147 Reduction r = Reduce(graph()->NewNode( |
| 137 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); | 148 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); |
| 138 ASSERT_FALSE(r.Changed()); | 149 ASSERT_FALSE(r.Changed()); |
| 139 } | 150 } |
| 140 | 151 |
| 141 | 152 |
| 142 // ----------------------------------------------------------------------------- | 153 // ----------------------------------------------------------------------------- |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 EmptyFrameState(), effect, control)); | 1018 EmptyFrameState(), effect, control)); |
| 1008 ASSERT_TRUE(r.Changed()); | 1019 ASSERT_TRUE(r.Changed()); |
| 1009 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( | 1020 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( |
| 1010 NumberOperationHint::kNumberOrOddball, lhs, | 1021 NumberOperationHint::kNumberOrOddball, lhs, |
| 1011 rhs, effect, control)); | 1022 rhs, effect, control)); |
| 1012 } | 1023 } |
| 1013 | 1024 |
| 1014 } // namespace compiler | 1025 } // namespace compiler |
| 1015 } // namespace internal | 1026 } // namespace internal |
| 1016 } // namespace v8 | 1027 } // namespace v8 |
| OLD | NEW |