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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 ASSERT_TRUE(r.Changed()); | 1080 ASSERT_TRUE(r.Changed()); |
1081 EXPECT_THAT( | 1081 EXPECT_THAT( |
1082 r.replacement(), | 1082 r.replacement(), |
1083 IsCall(_, IsHeapConstant( | 1083 IsCall(_, IsHeapConstant( |
1084 CodeFactory::FastCloneShallowObject(isolate(), 6).code()), | 1084 CodeFactory::FastCloneShallowObject(isolate(), 6).code()), |
1085 input0, input1, input2, _, context, frame_state, effect, control)); | 1085 input0, input1, input2, _, context, frame_state, effect, control)); |
1086 } | 1086 } |
1087 | 1087 |
1088 | 1088 |
1089 // ----------------------------------------------------------------------------- | 1089 // ----------------------------------------------------------------------------- |
| 1090 // JSCreateFunctionContext |
| 1091 |
| 1092 |
| 1093 TEST_F(JSTypedLoweringTest, JSCreateFunctionContextViaInlinedAllocation) { |
| 1094 if (!FLAG_turbo_allocate) return; |
| 1095 Node* const closure = Parameter(Type::Any()); |
| 1096 Node* const context = Parameter(Type::Any()); |
| 1097 Node* const effect = graph()->start(); |
| 1098 Node* const control = graph()->start(); |
| 1099 Reduction const r = |
| 1100 Reduce(graph()->NewNode(javascript()->CreateFunctionContext(8), closure, |
| 1101 context, effect, control)); |
| 1102 ASSERT_TRUE(r.Changed()); |
| 1103 EXPECT_THAT(r.replacement(), |
| 1104 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( |
| 1105 8 + Context::MIN_CONTEXT_SLOTS)), |
| 1106 effect, control), |
| 1107 _)); |
| 1108 } |
| 1109 |
| 1110 |
| 1111 TEST_F(JSTypedLoweringTest, JSCreateFunctionContextViaStub) { |
| 1112 Node* const closure = Parameter(Type::Any()); |
| 1113 Node* const context = Parameter(Type::Any()); |
| 1114 Node* const effect = graph()->start(); |
| 1115 Node* const control = graph()->start(); |
| 1116 Reduction const r = |
| 1117 Reduce(graph()->NewNode(javascript()->CreateFunctionContext(32), closure, |
| 1118 context, effect, control)); |
| 1119 ASSERT_TRUE(r.Changed()); |
| 1120 EXPECT_THAT(r.replacement(), |
| 1121 IsCall(_, IsHeapConstant( |
| 1122 CodeFactory::FastNewContext(isolate(), 32).code()), |
| 1123 closure, context, effect, control)); |
| 1124 } |
| 1125 |
| 1126 |
| 1127 // ----------------------------------------------------------------------------- |
1090 // JSCreateWithContext | 1128 // JSCreateWithContext |
1091 | 1129 |
1092 | 1130 |
1093 TEST_F(JSTypedLoweringTest, JSCreateWithContext) { | 1131 TEST_F(JSTypedLoweringTest, JSCreateWithContext) { |
1094 FLAG_turbo_allocate = true; | 1132 if (!FLAG_turbo_allocate) return; |
1095 Node* const object = Parameter(Type::Receiver()); | 1133 Node* const object = Parameter(Type::Receiver()); |
1096 Node* const closure = Parameter(Type::Any()); | 1134 Node* const closure = Parameter(Type::Any()); |
1097 Node* const context = Parameter(Type::Any()); | 1135 Node* const context = Parameter(Type::Any()); |
1098 Node* const frame_state = EmptyFrameState(); | 1136 Node* const frame_state = EmptyFrameState(); |
1099 Node* const effect = graph()->start(); | 1137 Node* const effect = graph()->start(); |
1100 Node* const control = graph()->start(); | 1138 Node* const control = graph()->start(); |
1101 Reduction r = | 1139 Reduction r = |
1102 Reduce(graph()->NewNode(javascript()->CreateWithContext(), object, | 1140 Reduce(graph()->NewNode(javascript()->CreateWithContext(), object, |
1103 closure, context, frame_state, effect, control)); | 1141 closure, context, frame_state, effect, control)); |
1104 ASSERT_TRUE(r.Changed()); | 1142 ASSERT_TRUE(r.Changed()); |
1105 EXPECT_THAT(r.replacement(), | 1143 EXPECT_THAT(r.replacement(), |
1106 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( | 1144 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( |
1107 Context::MIN_CONTEXT_SLOTS)), | 1145 Context::MIN_CONTEXT_SLOTS)), |
1108 effect, control), | 1146 effect, control), |
1109 _)); | 1147 _)); |
1110 } | 1148 } |
1111 | 1149 |
1112 } // namespace compiler | 1150 } // namespace compiler |
1113 } // namespace internal | 1151 } // namespace internal |
1114 } // namespace v8 | 1152 } // namespace v8 |
OLD | NEW |