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-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 graph()->NewNode(common()->Merge(2), check_true, check_false); | 1142 graph()->NewNode(common()->Merge(2), check_true, check_false); |
1143 Node* new_effect = | 1143 Node* new_effect = |
1144 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control); | 1144 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control); |
1145 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast, | 1145 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast, |
1146 slow, new_control); | 1146 slow, new_control); |
1147 ReplaceWithValue(node, new_value, new_effect, new_control); | 1147 ReplaceWithValue(node, new_value, new_effect, new_control); |
1148 return Changed(new_value); | 1148 return Changed(new_value); |
1149 } | 1149 } |
1150 | 1150 |
1151 | 1151 |
| 1152 Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) { |
| 1153 DCHECK_EQ(IrOpcode::kJSConvertReceiver, node->opcode()); |
| 1154 ConvertReceiverMode mode = ConvertReceiverModeOf(node->op()); |
| 1155 Node* receiver = NodeProperties::GetValueInput(node, 0); |
| 1156 Type* receiver_type = NodeProperties::GetType(receiver); |
| 1157 Node* context = NodeProperties::GetContextInput(node); |
| 1158 Type* context_type = NodeProperties::GetType(context); |
| 1159 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 1160 Node* effect = NodeProperties::GetEffectInput(node); |
| 1161 Node* control = NodeProperties::GetControlInput(node); |
| 1162 if (!receiver_type->Is(Type::Receiver())) { |
| 1163 if (receiver_type->Is(Type::NullOrUndefined()) || |
| 1164 mode == ConvertReceiverMode::kNullOrUndefined) { |
| 1165 if (context_type->IsConstant()) { |
| 1166 Handle<JSObject> global_proxy( |
| 1167 Handle<Context>::cast(context_type->AsConstant()->Value()) |
| 1168 ->global_proxy(), |
| 1169 isolate()); |
| 1170 receiver = jsgraph()->Constant(global_proxy); |
| 1171 } else { |
| 1172 Node* global_object = effect = graph()->NewNode( |
| 1173 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), |
| 1174 context, context, effect); |
| 1175 receiver = effect = |
| 1176 graph()->NewNode(simplified()->LoadField( |
| 1177 AccessBuilder::ForGlobalObjectGlobalProxy()), |
| 1178 global_object, effect, control); |
| 1179 } |
| 1180 } else if (!receiver_type->Maybe(Type::NullOrUndefined()) || |
| 1181 mode == ConvertReceiverMode::kNotNullOrUndefined) { |
| 1182 receiver = effect = |
| 1183 graph()->NewNode(javascript()->ToObject(), receiver, context, |
| 1184 frame_state, effect, control); |
| 1185 } else { |
| 1186 return NoChange(); |
| 1187 } |
| 1188 } |
| 1189 ReplaceWithValue(node, receiver, effect, control); |
| 1190 return Changed(receiver); |
| 1191 } |
| 1192 |
| 1193 |
1152 Reduction JSTypedLowering::ReduceJSCreateArguments(Node* node) { | 1194 Reduction JSTypedLowering::ReduceJSCreateArguments(Node* node) { |
1153 DCHECK_EQ(IrOpcode::kJSCreateArguments, node->opcode()); | 1195 DCHECK_EQ(IrOpcode::kJSCreateArguments, node->opcode()); |
1154 CreateArgumentsParameters const& p = CreateArgumentsParametersOf(node->op()); | 1196 CreateArgumentsParameters const& p = CreateArgumentsParametersOf(node->op()); |
1155 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 1197 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
1156 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); | 1198 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); |
1157 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); | 1199 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); |
1158 | 1200 |
1159 // Use the ArgumentsAccessStub for materializing both mapped and unmapped | 1201 // Use the ArgumentsAccessStub for materializing both mapped and unmapped |
1160 // arguments object, but only for non-inlined (i.e. outermost) frames. | 1202 // arguments object, but only for non-inlined (i.e. outermost) frames. |
1161 if (p.type() != CreateArgumentsParameters::kRestArray && | 1203 if (p.type() != CreateArgumentsParameters::kRestArray && |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 case IrOpcode::kJSStoreProperty: | 1894 case IrOpcode::kJSStoreProperty: |
1853 return ReduceJSStoreProperty(node); | 1895 return ReduceJSStoreProperty(node); |
1854 case IrOpcode::kJSLoadContext: | 1896 case IrOpcode::kJSLoadContext: |
1855 return ReduceJSLoadContext(node); | 1897 return ReduceJSLoadContext(node); |
1856 case IrOpcode::kJSStoreContext: | 1898 case IrOpcode::kJSStoreContext: |
1857 return ReduceJSStoreContext(node); | 1899 return ReduceJSStoreContext(node); |
1858 case IrOpcode::kJSLoadDynamicGlobal: | 1900 case IrOpcode::kJSLoadDynamicGlobal: |
1859 return ReduceJSLoadDynamicGlobal(node); | 1901 return ReduceJSLoadDynamicGlobal(node); |
1860 case IrOpcode::kJSLoadDynamicContext: | 1902 case IrOpcode::kJSLoadDynamicContext: |
1861 return ReduceJSLoadDynamicContext(node); | 1903 return ReduceJSLoadDynamicContext(node); |
| 1904 case IrOpcode::kJSConvertReceiver: |
| 1905 return ReduceJSConvertReceiver(node); |
1862 case IrOpcode::kJSCreateArguments: | 1906 case IrOpcode::kJSCreateArguments: |
1863 return ReduceJSCreateArguments(node); | 1907 return ReduceJSCreateArguments(node); |
1864 case IrOpcode::kJSCreateClosure: | 1908 case IrOpcode::kJSCreateClosure: |
1865 return ReduceJSCreateClosure(node); | 1909 return ReduceJSCreateClosure(node); |
1866 case IrOpcode::kJSCreateLiteralArray: | 1910 case IrOpcode::kJSCreateLiteralArray: |
1867 return ReduceJSCreateLiteralArray(node); | 1911 return ReduceJSCreateLiteralArray(node); |
1868 case IrOpcode::kJSCreateLiteralObject: | 1912 case IrOpcode::kJSCreateLiteralObject: |
1869 return ReduceJSCreateLiteralObject(node); | 1913 return ReduceJSCreateLiteralObject(node); |
1870 case IrOpcode::kJSCreateFunctionContext: | 1914 case IrOpcode::kJSCreateFunctionContext: |
1871 return ReduceJSCreateFunctionContext(node); | 1915 return ReduceJSCreateFunctionContext(node); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 } | 1984 } |
1941 | 1985 |
1942 | 1986 |
1943 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1987 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1944 return jsgraph()->machine(); | 1988 return jsgraph()->machine(); |
1945 } | 1989 } |
1946 | 1990 |
1947 } // namespace compiler | 1991 } // namespace compiler |
1948 } // namespace internal | 1992 } // namespace internal |
1949 } // namespace v8 | 1993 } // namespace v8 |
OLD | NEW |