| 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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| 11 #include "src/compiler/typer.h" | 11 #include "src/compiler/typer.h" |
| 12 #include "test/unittests/compiler/compiler-test-utils.h" | 12 #include "test/unittests/compiler/compiler-test-utils.h" |
| 13 #include "test/unittests/compiler/graph-unittest.h" | 13 #include "test/unittests/compiler/graph-unittest.h" |
| 14 #include "test/unittests/compiler/node-test-utils.h" | 14 #include "test/unittests/compiler/node-test-utils.h" |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const ExternalArrayType kExternalArrayTypes[] = { | 22 const ExternalArrayType kExternalArrayTypes[] = { |
| 23 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) kExternal##Type##Array, | 23 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) kExternal##Type##Array, |
| 24 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 24 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 25 #undef TYPED_ARRAY_CASE | 25 #undef TYPED_ARRAY_CASE |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 | 28 |
| 29 Type* const kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(), |
| 30 Type::Number(), Type::String(), Type::Object()}; |
| 31 |
| 32 |
| 29 const StrictMode kStrictModes[] = {SLOPPY, STRICT}; | 33 const StrictMode kStrictModes[] = {SLOPPY, STRICT}; |
| 30 | 34 |
| 31 } // namespace | 35 } // namespace |
| 32 | 36 |
| 33 | 37 |
| 34 class JSTypedLoweringTest : public TypedGraphTest { | 38 class JSTypedLoweringTest : public TypedGraphTest { |
| 35 public: | 39 public: |
| 36 JSTypedLoweringTest() : TypedGraphTest(3), javascript_(zone()) {} | 40 JSTypedLoweringTest() : TypedGraphTest(3), javascript_(zone()) {} |
| 37 virtual ~JSTypedLoweringTest() {} | 41 virtual ~JSTypedLoweringTest() {} |
| 38 | 42 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 context, effect, control)); | 106 context, effect, control)); |
| 103 ASSERT_TRUE(r.Changed()); | 107 ASSERT_TRUE(r.Changed()); |
| 104 EXPECT_THAT( | 108 EXPECT_THAT( |
| 105 r.replacement(), | 109 r.replacement(), |
| 106 IsPhi(kMachAnyTagged, | 110 IsPhi(kMachAnyTagged, |
| 107 IsBooleanNot(IsNumberEqual(p0, IsNumberConstant(0))), p1, control)); | 111 IsBooleanNot(IsNumberEqual(p0, IsNumberConstant(0))), p1, control)); |
| 108 } | 112 } |
| 109 | 113 |
| 110 | 114 |
| 111 // ----------------------------------------------------------------------------- | 115 // ----------------------------------------------------------------------------- |
| 116 // JSStrictEqual |
| 117 |
| 118 |
| 119 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) { |
| 120 Node* const the_hole = HeapConstant(factory()->the_hole_value()); |
| 121 Node* const context = UndefinedConstant(); |
| 122 Node* const effect = graph()->start(); |
| 123 Node* const control = graph()->start(); |
| 124 TRACED_FOREACH(Type*, type, kJSTypes) { |
| 125 Node* const lhs = Parameter(type); |
| 126 Reduction r = Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, |
| 127 the_hole, context, effect, control)); |
| 128 ASSERT_TRUE(r.Changed()); |
| 129 EXPECT_THAT(r.replacement(), IsFalseConstant()); |
| 130 } |
| 131 } |
| 132 |
| 133 |
| 134 // ----------------------------------------------------------------------------- |
| 112 // JSShiftLeft | 135 // JSShiftLeft |
| 113 | 136 |
| 114 | 137 |
| 115 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { | 138 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { |
| 116 Node* const lhs = Parameter(Type::Signed32()); | 139 Node* const lhs = Parameter(Type::Signed32()); |
| 117 Node* const context = UndefinedConstant(); | 140 Node* const context = UndefinedConstant(); |
| 118 Node* const effect = graph()->start(); | 141 Node* const effect = graph()->start(); |
| 119 Node* const control = graph()->start(); | 142 Node* const control = graph()->start(); |
| 120 TRACED_FORRANGE(int32_t, rhs, 0, 31) { | 143 TRACED_FORRANGE(int32_t, rhs, 0, 31) { |
| 121 Reduction r = | 144 Reduction r = |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), | 305 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), |
| 283 key, IsNumberConstant(array->length()->Number()), value, | 306 key, IsNumberConstant(array->length()->Number()), value, |
| 284 effect, control)); | 307 effect, control)); |
| 285 } | 308 } |
| 286 } | 309 } |
| 287 } | 310 } |
| 288 | 311 |
| 289 } // namespace compiler | 312 } // namespace compiler |
| 290 } // namespace internal | 313 } // namespace internal |
| 291 } // namespace v8 | 314 } // namespace v8 |
| OLD | NEW |