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/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 shared->kind()).code()), | 1084 shared->kind()).code()), |
1085 IsHeapConstant(shared), effect, control)); | 1085 IsHeapConstant(shared), effect, control)); |
1086 } | 1086 } |
1087 | 1087 |
1088 | 1088 |
1089 // ----------------------------------------------------------------------------- | 1089 // ----------------------------------------------------------------------------- |
1090 // JSCreateLiteralArray | 1090 // JSCreateLiteralArray |
1091 | 1091 |
1092 | 1092 |
1093 TEST_F(JSTypedLoweringTest, JSCreateLiteralArray) { | 1093 TEST_F(JSTypedLoweringTest, JSCreateLiteralArray) { |
1094 Node* const input0 = Parameter(0); | 1094 Handle<FixedArray> const constant_elements = factory()->NewFixedArray(12); |
1095 Node* const input1 = Parameter(1); | 1095 int const literal_flags = ArrayLiteral::kShallowElements; |
1096 Node* const input2 = HeapConstant(factory()->NewFixedArray(12)); | 1096 int const literal_index = 1; |
1097 Node* const context = UndefinedConstant(); | 1097 Node* const input = Parameter(0); |
| 1098 Node* const context = Parameter(1); |
1098 Node* const frame_state = EmptyFrameState(); | 1099 Node* const frame_state = EmptyFrameState(); |
1099 Node* const effect = graph()->start(); | 1100 Node* const effect = graph()->start(); |
1100 Node* const control = graph()->start(); | 1101 Node* const control = graph()->start(); |
1101 Reduction const r = Reduce(graph()->NewNode( | 1102 Reduction const r = Reduce( |
1102 javascript()->CreateLiteralArray(ArrayLiteral::kShallowElements), input0, | 1103 graph()->NewNode(javascript()->CreateLiteralArray( |
1103 input1, input2, context, frame_state, effect, control)); | 1104 constant_elements, literal_flags, literal_index), |
| 1105 input, context, frame_state, effect, control)); |
1104 ASSERT_TRUE(r.Changed()); | 1106 ASSERT_TRUE(r.Changed()); |
1105 EXPECT_THAT( | 1107 EXPECT_THAT( |
1106 r.replacement(), | 1108 r.replacement(), |
1107 IsCall(_, IsHeapConstant( | 1109 IsCall(_, IsHeapConstant( |
1108 CodeFactory::FastCloneShallowArray(isolate()).code()), | 1110 CodeFactory::FastCloneShallowArray(isolate()).code()), |
1109 input0, input1, input2, context, frame_state, effect, control)); | 1111 input, IsNumberConstant(literal_index), |
| 1112 IsHeapConstant(constant_elements), context, frame_state, effect, |
| 1113 control)); |
1110 } | 1114 } |
1111 | 1115 |
1112 | 1116 |
1113 // ----------------------------------------------------------------------------- | 1117 // ----------------------------------------------------------------------------- |
1114 // JSCreateLiteralObject | 1118 // JSCreateLiteralObject |
1115 | 1119 |
1116 | 1120 |
1117 TEST_F(JSTypedLoweringTest, JSCreateLiteralObject) { | 1121 TEST_F(JSTypedLoweringTest, JSCreateLiteralObject) { |
1118 Node* const input0 = Parameter(0); | 1122 Handle<FixedArray> const constant_properties = |
1119 Node* const input1 = Parameter(1); | 1123 factory()->NewFixedArray(6 * 2); |
1120 Node* const input2 = HeapConstant(factory()->NewFixedArray(2 * 6)); | 1124 int const literal_flags = ObjectLiteral::kShallowProperties; |
1121 Node* const context = UndefinedConstant(); | 1125 int const literal_index = 1; |
| 1126 Node* const input = Parameter(0); |
| 1127 Node* const context = Parameter(1); |
1122 Node* const frame_state = EmptyFrameState(); | 1128 Node* const frame_state = EmptyFrameState(); |
1123 Node* const effect = graph()->start(); | 1129 Node* const effect = graph()->start(); |
1124 Node* const control = graph()->start(); | 1130 Node* const control = graph()->start(); |
1125 Reduction const r = Reduce(graph()->NewNode( | 1131 Reduction const r = Reduce( |
1126 javascript()->CreateLiteralObject(ObjectLiteral::kShallowProperties), | 1132 graph()->NewNode(javascript()->CreateLiteralObject( |
1127 input0, input1, input2, context, frame_state, effect, control)); | 1133 constant_properties, literal_flags, literal_index), |
| 1134 input, context, frame_state, effect, control)); |
1128 ASSERT_TRUE(r.Changed()); | 1135 ASSERT_TRUE(r.Changed()); |
1129 EXPECT_THAT( | 1136 EXPECT_THAT( |
1130 r.replacement(), | 1137 r.replacement(), |
1131 IsCall(_, IsHeapConstant( | 1138 IsCall(_, IsHeapConstant( |
1132 CodeFactory::FastCloneShallowObject(isolate(), 6).code()), | 1139 CodeFactory::FastCloneShallowObject(isolate(), 6).code()), |
1133 input0, input1, input2, _, context, frame_state, effect, control)); | 1140 input, IsNumberConstant(literal_index), |
| 1141 IsHeapConstant(constant_properties), _, context, frame_state, |
| 1142 effect, control)); |
1134 } | 1143 } |
1135 | 1144 |
1136 | 1145 |
1137 // ----------------------------------------------------------------------------- | 1146 // ----------------------------------------------------------------------------- |
1138 // JSCreateFunctionContext | 1147 // JSCreateFunctionContext |
1139 | 1148 |
1140 | 1149 |
1141 TEST_F(JSTypedLoweringTest, JSCreateFunctionContextViaInlinedAllocation) { | 1150 TEST_F(JSTypedLoweringTest, JSCreateFunctionContextViaInlinedAllocation) { |
1142 Node* const closure = Parameter(Type::Any()); | 1151 Node* const closure = Parameter(Type::Any()); |
1143 Node* const context = Parameter(Type::Any()); | 1152 Node* const context = Parameter(Type::Any()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, | 1262 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, |
1254 frame_state, effect, control); | 1263 frame_state, effect, control); |
1255 Reduction r = Reduce(instanceOf); | 1264 Reduction r = Reduce(instanceOf); |
1256 ASSERT_FALSE(r.Changed()); | 1265 ASSERT_FALSE(r.Changed()); |
1257 ASSERT_EQ(instanceOf, dummy->InputAt(0)); | 1266 ASSERT_EQ(instanceOf, dummy->InputAt(0)); |
1258 } | 1267 } |
1259 | 1268 |
1260 } // namespace compiler | 1269 } // namespace compiler |
1261 } // namespace internal | 1270 } // namespace internal |
1262 } // namespace v8 | 1271 } // namespace v8 |
OLD | NEW |