OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/js-create-lowering.h" | 5 #include "src/compiler/js-create-lowering.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 273 } |
274 } | 274 } |
275 return NoChange(); | 275 return NoChange(); |
276 } | 276 } |
277 | 277 |
278 Reduction JSCreateLowering::ReduceJSCreateArguments(Node* node) { | 278 Reduction JSCreateLowering::ReduceJSCreateArguments(Node* node) { |
279 DCHECK_EQ(IrOpcode::kJSCreateArguments, node->opcode()); | 279 DCHECK_EQ(IrOpcode::kJSCreateArguments, node->opcode()); |
280 CreateArgumentsType type = CreateArgumentsTypeOf(node->op()); | 280 CreateArgumentsType type = CreateArgumentsTypeOf(node->op()); |
281 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 281 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
282 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); | 282 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); |
| 283 Node* const control = graph()->start(); |
283 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); | 284 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); |
284 | 285 |
285 // Use the ArgumentsAccessStub for materializing both mapped and unmapped | 286 // Use the ArgumentsAccessStub for materializing both mapped and unmapped |
286 // arguments object, but only for non-inlined (i.e. outermost) frames. | 287 // arguments object, but only for non-inlined (i.e. outermost) frames. |
287 if (outer_state->opcode() != IrOpcode::kFrameState) { | 288 if (outer_state->opcode() != IrOpcode::kFrameState) { |
288 switch (type) { | 289 switch (type) { |
289 case CreateArgumentsType::kMappedArguments: { | 290 case CreateArgumentsType::kMappedArguments: { |
290 // TODO(mstarzinger): Duplicate parameters are not handled yet. | 291 // TODO(mstarzinger): Duplicate parameters are not handled yet. |
291 Handle<SharedFunctionInfo> shared_info; | 292 Handle<SharedFunctionInfo> shared_info; |
292 if (!state_info.shared_info().ToHandle(&shared_info) || | 293 if (!state_info.shared_info().ToHandle(&shared_info) || |
293 shared_info->has_duplicate_parameters()) { | 294 shared_info->has_duplicate_parameters()) { |
294 return NoChange(); | 295 return NoChange(); |
295 } | 296 } |
296 // TODO(bmeurer): Actually we don't need a frame state here. | |
297 Callable callable = CodeFactory::FastNewSloppyArguments(isolate()); | 297 Callable callable = CodeFactory::FastNewSloppyArguments(isolate()); |
| 298 Operator::Properties properties = node->op()->properties(); |
298 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 299 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
299 isolate(), graph()->zone(), callable.descriptor(), 0, | 300 isolate(), graph()->zone(), callable.descriptor(), 0, |
300 CallDescriptor::kNeedsFrameState); | 301 CallDescriptor::kNoFlags, properties); |
301 const Operator* new_op = common()->Call(desc); | 302 const Operator* new_op = common()->Call(desc); |
302 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 303 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
303 node->InsertInput(graph()->zone(), 0, stub_code); | 304 node->InsertInput(graph()->zone(), 0, stub_code); |
| 305 node->RemoveInput(3); // Remove the frame state. |
304 NodeProperties::ChangeOp(node, new_op); | 306 NodeProperties::ChangeOp(node, new_op); |
305 return Changed(node); | 307 return Changed(node); |
306 } | 308 } |
307 case CreateArgumentsType::kUnmappedArguments: { | 309 case CreateArgumentsType::kUnmappedArguments: { |
308 // TODO(bmeurer): Actually we don't need a frame state here. | |
309 Callable callable = CodeFactory::FastNewStrictArguments(isolate()); | 310 Callable callable = CodeFactory::FastNewStrictArguments(isolate()); |
| 311 Operator::Properties properties = node->op()->properties(); |
310 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 312 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
311 isolate(), graph()->zone(), callable.descriptor(), 0, | 313 isolate(), graph()->zone(), callable.descriptor(), 0, |
312 CallDescriptor::kNeedsFrameState); | 314 CallDescriptor::kNoFlags, properties); |
313 const Operator* new_op = common()->Call(desc); | 315 const Operator* new_op = common()->Call(desc); |
314 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 316 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
315 node->InsertInput(graph()->zone(), 0, stub_code); | 317 node->InsertInput(graph()->zone(), 0, stub_code); |
| 318 node->RemoveInput(3); // Remove the frame state. |
316 NodeProperties::ChangeOp(node, new_op); | 319 NodeProperties::ChangeOp(node, new_op); |
317 return Changed(node); | 320 return Changed(node); |
318 } | 321 } |
319 case CreateArgumentsType::kRestParameter: { | 322 case CreateArgumentsType::kRestParameter: { |
320 // TODO(bmeurer): Actually we don't need a frame state here. | |
321 Callable callable = CodeFactory::FastNewRestParameter(isolate()); | 323 Callable callable = CodeFactory::FastNewRestParameter(isolate()); |
| 324 Operator::Properties properties = node->op()->properties(); |
322 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 325 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
323 isolate(), graph()->zone(), callable.descriptor(), 0, | 326 isolate(), graph()->zone(), callable.descriptor(), 0, |
324 CallDescriptor::kNeedsFrameState); | 327 CallDescriptor::kNoFlags, properties); |
325 const Operator* new_op = common()->Call(desc); | 328 const Operator* new_op = common()->Call(desc); |
326 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 329 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
327 node->InsertInput(graph()->zone(), 0, stub_code); | 330 node->InsertInput(graph()->zone(), 0, stub_code); |
| 331 node->RemoveInput(3); // Remove the frame state. |
328 NodeProperties::ChangeOp(node, new_op); | 332 NodeProperties::ChangeOp(node, new_op); |
329 return Changed(node); | 333 return Changed(node); |
330 } | 334 } |
331 } | 335 } |
332 UNREACHABLE(); | 336 UNREACHABLE(); |
333 } else if (outer_state->opcode() == IrOpcode::kFrameState) { | 337 } else if (outer_state->opcode() == IrOpcode::kFrameState) { |
334 // Use inline allocation for all mapped arguments objects within inlined | 338 // Use inline allocation for all mapped arguments objects within inlined |
335 // (i.e. non-outermost) frames, independent of the object size. | 339 // (i.e. non-outermost) frames, independent of the object size. |
336 if (type == CreateArgumentsType::kMappedArguments) { | 340 if (type == CreateArgumentsType::kMappedArguments) { |
337 Handle<SharedFunctionInfo> shared; | 341 Handle<SharedFunctionInfo> shared; |
338 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); | 342 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); |
339 Node* const callee = NodeProperties::GetValueInput(node, 0); | 343 Node* const callee = NodeProperties::GetValueInput(node, 0); |
340 Node* const control = NodeProperties::GetControlInput(node); | |
341 Node* const context = NodeProperties::GetContextInput(node); | 344 Node* const context = NodeProperties::GetContextInput(node); |
342 Node* effect = NodeProperties::GetEffectInput(node); | 345 Node* effect = NodeProperties::GetEffectInput(node); |
343 // TODO(mstarzinger): Duplicate parameters are not handled yet. | 346 // TODO(mstarzinger): Duplicate parameters are not handled yet. |
344 if (shared->has_duplicate_parameters()) return NoChange(); | 347 if (shared->has_duplicate_parameters()) return NoChange(); |
345 // Choose the correct frame state and frame state info depending on | 348 // Choose the correct frame state and frame state info depending on |
346 // whether there conceptually is an arguments adaptor frame in the call | 349 // whether there conceptually is an arguments adaptor frame in the call |
347 // chain. | 350 // chain. |
348 Node* const args_state = GetArgumentsFrameState(frame_state); | 351 Node* const args_state = GetArgumentsFrameState(frame_state); |
349 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 352 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
350 // Prepare element backing store to be used by arguments object. | 353 // Prepare element backing store to be used by arguments object. |
(...skipping 20 matching lines...) Expand all Loading... |
371 a.Store(AccessBuilder::ForJSObjectProperties(), properties); | 374 a.Store(AccessBuilder::ForJSObjectProperties(), properties); |
372 a.Store(AccessBuilder::ForJSObjectElements(), elements); | 375 a.Store(AccessBuilder::ForJSObjectElements(), elements); |
373 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); | 376 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); |
374 a.Store(AccessBuilder::ForArgumentsCallee(), callee); | 377 a.Store(AccessBuilder::ForArgumentsCallee(), callee); |
375 RelaxControls(node); | 378 RelaxControls(node); |
376 a.FinishAndChange(node); | 379 a.FinishAndChange(node); |
377 return Changed(node); | 380 return Changed(node); |
378 } else if (type == CreateArgumentsType::kUnmappedArguments) { | 381 } else if (type == CreateArgumentsType::kUnmappedArguments) { |
379 // Use inline allocation for all unmapped arguments objects within inlined | 382 // Use inline allocation for all unmapped arguments objects within inlined |
380 // (i.e. non-outermost) frames, independent of the object size. | 383 // (i.e. non-outermost) frames, independent of the object size. |
381 Node* const control = NodeProperties::GetControlInput(node); | |
382 Node* const context = NodeProperties::GetContextInput(node); | 384 Node* const context = NodeProperties::GetContextInput(node); |
383 Node* effect = NodeProperties::GetEffectInput(node); | 385 Node* effect = NodeProperties::GetEffectInput(node); |
384 // Choose the correct frame state and frame state info depending on | 386 // Choose the correct frame state and frame state info depending on |
385 // whether there conceptually is an arguments adaptor frame in the call | 387 // whether there conceptually is an arguments adaptor frame in the call |
386 // chain. | 388 // chain. |
387 Node* const args_state = GetArgumentsFrameState(frame_state); | 389 Node* const args_state = GetArgumentsFrameState(frame_state); |
388 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 390 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
389 // Prepare element backing store to be used by arguments object. | 391 // Prepare element backing store to be used by arguments object. |
390 Node* const elements = AllocateArguments(effect, control, args_state); | 392 Node* const elements = AllocateArguments(effect, control, args_state); |
391 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; | 393 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; |
(...skipping 17 matching lines...) Expand all Loading... |
409 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); | 411 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); |
410 RelaxControls(node); | 412 RelaxControls(node); |
411 a.FinishAndChange(node); | 413 a.FinishAndChange(node); |
412 return Changed(node); | 414 return Changed(node); |
413 } else if (type == CreateArgumentsType::kRestParameter) { | 415 } else if (type == CreateArgumentsType::kRestParameter) { |
414 Handle<SharedFunctionInfo> shared; | 416 Handle<SharedFunctionInfo> shared; |
415 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); | 417 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); |
416 int start_index = shared->internal_formal_parameter_count(); | 418 int start_index = shared->internal_formal_parameter_count(); |
417 // Use inline allocation for all unmapped arguments objects within inlined | 419 // Use inline allocation for all unmapped arguments objects within inlined |
418 // (i.e. non-outermost) frames, independent of the object size. | 420 // (i.e. non-outermost) frames, independent of the object size. |
419 Node* const control = NodeProperties::GetControlInput(node); | |
420 Node* const context = NodeProperties::GetContextInput(node); | 421 Node* const context = NodeProperties::GetContextInput(node); |
421 Node* effect = NodeProperties::GetEffectInput(node); | 422 Node* effect = NodeProperties::GetEffectInput(node); |
422 // Choose the correct frame state and frame state info depending on | 423 // Choose the correct frame state and frame state info depending on |
423 // whether there conceptually is an arguments adaptor frame in the call | 424 // whether there conceptually is an arguments adaptor frame in the call |
424 // chain. | 425 // chain. |
425 Node* const args_state = GetArgumentsFrameState(frame_state); | 426 Node* const args_state = GetArgumentsFrameState(frame_state); |
426 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 427 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
427 // Prepare element backing store to be used by the rest array. | 428 // Prepare element backing store to be used by the rest array. |
428 Node* const elements = | 429 Node* const elements = |
429 AllocateRestArguments(effect, control, args_state, start_index); | 430 AllocateRestArguments(effect, control, args_state, start_index); |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 return jsgraph()->simplified(); | 1131 return jsgraph()->simplified(); |
1131 } | 1132 } |
1132 | 1133 |
1133 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1134 MachineOperatorBuilder* JSCreateLowering::machine() const { |
1134 return jsgraph()->machine(); | 1135 return jsgraph()->machine(); |
1135 } | 1136 } |
1136 | 1137 |
1137 } // namespace compiler | 1138 } // namespace compiler |
1138 } // namespace internal | 1139 } // namespace internal |
1139 } // namespace v8 | 1140 } // namespace v8 |
OLD | NEW |