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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 JSOperatorBuilder* javascript() { return &javascript_; } | 64 JSOperatorBuilder* javascript() { return &javascript_; } |
65 | 65 |
66 private: | 66 private: |
67 JSOperatorBuilder javascript_; | 67 JSOperatorBuilder javascript_; |
68 }; | 68 }; |
69 | 69 |
70 | 70 |
71 // ----------------------------------------------------------------------------- | 71 // ----------------------------------------------------------------------------- |
| 72 // JSToBoolean |
| 73 |
| 74 |
| 75 TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { |
| 76 Node* input = Parameter(Type::String()); |
| 77 Node* context = UndefinedConstant(); |
| 78 Node* effect = graph()->start(); |
| 79 Node* control = graph()->start(); |
| 80 |
| 81 Reduction r = Reduce(graph()->NewNode(javascript()->ToBoolean(), input, |
| 82 context, effect, control)); |
| 83 ASSERT_TRUE(r.Changed()); |
| 84 EXPECT_THAT(r.replacement(), |
| 85 IsBooleanNot(IsNumberEqual( |
| 86 IsLoadField(AccessBuilder::ForStringLength(), input, |
| 87 graph()->start(), graph()->start()), |
| 88 IsNumberConstant(0)))); |
| 89 } |
| 90 |
| 91 |
| 92 TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumberAndBoolean) { |
| 93 Node* p0 = Parameter(Type::OrderedNumber(), 0); |
| 94 Node* p1 = Parameter(Type::Boolean(), 1); |
| 95 Node* context = UndefinedConstant(); |
| 96 Node* effect = graph()->start(); |
| 97 Node* control = graph()->start(); |
| 98 |
| 99 Reduction r = Reduce(graph()->NewNode( |
| 100 javascript()->ToBoolean(), |
| 101 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p1, control), |
| 102 context, effect, control)); |
| 103 ASSERT_TRUE(r.Changed()); |
| 104 EXPECT_THAT( |
| 105 r.replacement(), |
| 106 IsPhi(kMachAnyTagged, |
| 107 IsBooleanNot(IsNumberEqual(p0, IsNumberConstant(0))), p1, control)); |
| 108 } |
| 109 |
| 110 |
| 111 // ----------------------------------------------------------------------------- |
72 // JSLoadProperty | 112 // JSLoadProperty |
73 | 113 |
74 | 114 |
75 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) { | 115 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) { |
76 const size_t kLength = 17; | 116 const size_t kLength = 17; |
77 uint8_t backing_store[kLength * 8]; | 117 uint8_t backing_store[kLength * 8]; |
78 Handle<JSArrayBuffer> buffer = | 118 Handle<JSArrayBuffer> buffer = |
79 NewArrayBuffer(backing_store, arraysize(backing_store)); | 119 NewArrayBuffer(backing_store, arraysize(backing_store)); |
80 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), | 120 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), |
81 FeedbackVectorICSlot::Invalid()); | 121 FeedbackVectorICSlot::Invalid()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), | 184 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), |
145 key, IsInt32Constant(static_cast<int>(kLength)), value, | 185 key, IsInt32Constant(static_cast<int>(kLength)), value, |
146 effect, control)); | 186 effect, control)); |
147 } | 187 } |
148 } | 188 } |
149 } | 189 } |
150 | 190 |
151 } // namespace compiler | 191 } // namespace compiler |
152 } // namespace internal | 192 } // namespace internal |
153 } // namespace v8 | 193 } // namespace v8 |
OLD | NEW |