| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // Choose the correct frame state and frame state info depending on | 346 // Choose the correct frame state and frame state info depending on |
| 347 // whether there conceptually is an arguments adaptor frame in the call | 347 // whether there conceptually is an arguments adaptor frame in the call |
| 348 // chain. | 348 // chain. |
| 349 Node* const args_state = GetArgumentsFrameState(frame_state); | 349 Node* const args_state = GetArgumentsFrameState(frame_state); |
| 350 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 350 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
| 351 // Prepare element backing store to be used by arguments object. | 351 // Prepare element backing store to be used by arguments object. |
| 352 bool has_aliased_arguments = false; | 352 bool has_aliased_arguments = false; |
| 353 Node* const elements = AllocateAliasedArguments( | 353 Node* const elements = AllocateAliasedArguments( |
| 354 effect, control, args_state, context, shared, &has_aliased_arguments); | 354 effect, control, args_state, context, shared, &has_aliased_arguments); |
| 355 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; | 355 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; |
| 356 // Load the arguments object map from the current native context. | 356 // Load the arguments object map. |
| 357 Node* const load_native_context = effect = graph()->NewNode( | 357 Node* const arguments_map = jsgraph()->HeapConstant(handle( |
| 358 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 358 has_aliased_arguments ? native_context()->fast_aliased_arguments_map() |
| 359 context, context, effect); | 359 : native_context()->sloppy_arguments_map(), |
| 360 Node* const load_arguments_map = effect = graph()->NewNode( | 360 isolate())); |
| 361 simplified()->LoadField(AccessBuilder::ForContextSlot( | |
| 362 has_aliased_arguments ? Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX | |
| 363 : Context::SLOPPY_ARGUMENTS_MAP_INDEX)), | |
| 364 load_native_context, effect, control); | |
| 365 // Actually allocate and initialize the arguments object. | 361 // Actually allocate and initialize the arguments object. |
| 366 AllocationBuilder a(jsgraph(), effect, control); | 362 AllocationBuilder a(jsgraph(), effect, control); |
| 367 Node* properties = jsgraph()->EmptyFixedArrayConstant(); | 363 Node* properties = jsgraph()->EmptyFixedArrayConstant(); |
| 368 int length = args_state_info.parameter_count() - 1; // Minus receiver. | 364 int length = args_state_info.parameter_count() - 1; // Minus receiver. |
| 369 STATIC_ASSERT(JSSloppyArgumentsObject::kSize == 5 * kPointerSize); | 365 STATIC_ASSERT(JSSloppyArgumentsObject::kSize == 5 * kPointerSize); |
| 370 a.Allocate(JSSloppyArgumentsObject::kSize); | 366 a.Allocate(JSSloppyArgumentsObject::kSize); |
| 371 a.Store(AccessBuilder::ForMap(), load_arguments_map); | 367 a.Store(AccessBuilder::ForMap(), arguments_map); |
| 372 a.Store(AccessBuilder::ForJSObjectProperties(), properties); | 368 a.Store(AccessBuilder::ForJSObjectProperties(), properties); |
| 373 a.Store(AccessBuilder::ForJSObjectElements(), elements); | 369 a.Store(AccessBuilder::ForJSObjectElements(), elements); |
| 374 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); | 370 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); |
| 375 a.Store(AccessBuilder::ForArgumentsCallee(), callee); | 371 a.Store(AccessBuilder::ForArgumentsCallee(), callee); |
| 376 RelaxControls(node); | 372 RelaxControls(node); |
| 377 a.FinishAndChange(node); | 373 a.FinishAndChange(node); |
| 378 return Changed(node); | 374 return Changed(node); |
| 379 } else if (type == CreateArgumentsType::kUnmappedArguments) { | 375 } else if (type == CreateArgumentsType::kUnmappedArguments) { |
| 380 // Use inline allocation for all unmapped arguments objects within inlined | 376 // Use inline allocation for all unmapped arguments objects within inlined |
| 381 // (i.e. non-outermost) frames, independent of the object size. | 377 // (i.e. non-outermost) frames, independent of the object size. |
| 382 Node* const context = NodeProperties::GetContextInput(node); | |
| 383 Node* effect = NodeProperties::GetEffectInput(node); | 378 Node* effect = NodeProperties::GetEffectInput(node); |
| 384 // Choose the correct frame state and frame state info depending on | 379 // Choose the correct frame state and frame state info depending on |
| 385 // whether there conceptually is an arguments adaptor frame in the call | 380 // whether there conceptually is an arguments adaptor frame in the call |
| 386 // chain. | 381 // chain. |
| 387 Node* const args_state = GetArgumentsFrameState(frame_state); | 382 Node* const args_state = GetArgumentsFrameState(frame_state); |
| 388 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 383 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
| 389 // Prepare element backing store to be used by arguments object. | 384 // Prepare element backing store to be used by arguments object. |
| 390 Node* const elements = AllocateArguments(effect, control, args_state); | 385 Node* const elements = AllocateArguments(effect, control, args_state); |
| 391 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; | 386 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; |
| 392 // Load the arguments object map from the current native context. | 387 // Load the arguments object map. |
| 393 Node* const load_native_context = effect = graph()->NewNode( | 388 Node* const arguments_map = jsgraph()->HeapConstant( |
| 394 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 389 handle(native_context()->strict_arguments_map(), isolate())); |
| 395 context, context, effect); | |
| 396 Node* const load_arguments_map = effect = graph()->NewNode( | |
| 397 simplified()->LoadField(AccessBuilder::ForContextSlot( | |
| 398 Context::STRICT_ARGUMENTS_MAP_INDEX)), | |
| 399 load_native_context, effect, control); | |
| 400 // Actually allocate and initialize the arguments object. | 390 // Actually allocate and initialize the arguments object. |
| 401 AllocationBuilder a(jsgraph(), effect, control); | 391 AllocationBuilder a(jsgraph(), effect, control); |
| 402 Node* properties = jsgraph()->EmptyFixedArrayConstant(); | 392 Node* properties = jsgraph()->EmptyFixedArrayConstant(); |
| 403 int length = args_state_info.parameter_count() - 1; // Minus receiver. | 393 int length = args_state_info.parameter_count() - 1; // Minus receiver. |
| 404 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); | 394 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); |
| 405 a.Allocate(JSStrictArgumentsObject::kSize); | 395 a.Allocate(JSStrictArgumentsObject::kSize); |
| 406 a.Store(AccessBuilder::ForMap(), load_arguments_map); | 396 a.Store(AccessBuilder::ForMap(), arguments_map); |
| 407 a.Store(AccessBuilder::ForJSObjectProperties(), properties); | 397 a.Store(AccessBuilder::ForJSObjectProperties(), properties); |
| 408 a.Store(AccessBuilder::ForJSObjectElements(), elements); | 398 a.Store(AccessBuilder::ForJSObjectElements(), elements); |
| 409 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); | 399 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); |
| 410 RelaxControls(node); | 400 RelaxControls(node); |
| 411 a.FinishAndChange(node); | 401 a.FinishAndChange(node); |
| 412 return Changed(node); | 402 return Changed(node); |
| 413 } else if (type == CreateArgumentsType::kRestParameter) { | 403 } else if (type == CreateArgumentsType::kRestParameter) { |
| 414 Handle<SharedFunctionInfo> shared; | 404 Handle<SharedFunctionInfo> shared; |
| 415 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); | 405 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); |
| 416 int start_index = shared->internal_formal_parameter_count(); | 406 int start_index = shared->internal_formal_parameter_count(); |
| 417 // Use inline allocation for all unmapped arguments objects within inlined | 407 // Use inline allocation for all unmapped arguments objects within inlined |
| 418 // (i.e. non-outermost) frames, independent of the object size. | 408 // (i.e. non-outermost) frames, independent of the object size. |
| 419 Node* const context = NodeProperties::GetContextInput(node); | |
| 420 Node* effect = NodeProperties::GetEffectInput(node); | 409 Node* effect = NodeProperties::GetEffectInput(node); |
| 421 // Choose the correct frame state and frame state info depending on | 410 // Choose the correct frame state and frame state info depending on |
| 422 // whether there conceptually is an arguments adaptor frame in the call | 411 // whether there conceptually is an arguments adaptor frame in the call |
| 423 // chain. | 412 // chain. |
| 424 Node* const args_state = GetArgumentsFrameState(frame_state); | 413 Node* const args_state = GetArgumentsFrameState(frame_state); |
| 425 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 414 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
| 426 // Prepare element backing store to be used by the rest array. | 415 // Prepare element backing store to be used by the rest array. |
| 427 Node* const elements = | 416 Node* const elements = |
| 428 AllocateRestArguments(effect, control, args_state, start_index); | 417 AllocateRestArguments(effect, control, args_state, start_index); |
| 429 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; | 418 effect = elements->op()->EffectOutputCount() > 0 ? elements : effect; |
| 430 // Load the JSArray object map from the current native context. | 419 // Load the JSArray object map. |
| 431 Node* const load_native_context = effect = graph()->NewNode( | 420 Node* const jsarray_map = jsgraph()->HeapConstant(handle( |
| 432 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 421 native_context()->js_array_fast_elements_map_index(), isolate())); |
| 433 context, context, effect); | |
| 434 Node* const load_jsarray_map = effect = graph()->NewNode( | |
| 435 simplified()->LoadField(AccessBuilder::ForContextSlot( | |
| 436 Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX)), | |
| 437 load_native_context, effect, control); | |
| 438 // Actually allocate and initialize the jsarray. | 422 // Actually allocate and initialize the jsarray. |
| 439 AllocationBuilder a(jsgraph(), effect, control); | 423 AllocationBuilder a(jsgraph(), effect, control); |
| 440 Node* properties = jsgraph()->EmptyFixedArrayConstant(); | 424 Node* properties = jsgraph()->EmptyFixedArrayConstant(); |
| 441 | 425 |
| 442 // -1 to minus receiver | 426 // -1 to minus receiver |
| 443 int argument_count = args_state_info.parameter_count() - 1; | 427 int argument_count = args_state_info.parameter_count() - 1; |
| 444 int length = std::max(0, argument_count - start_index); | 428 int length = std::max(0, argument_count - start_index); |
| 445 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); | 429 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
| 446 a.Allocate(JSArray::kSize); | 430 a.Allocate(JSArray::kSize); |
| 447 a.Store(AccessBuilder::ForMap(), load_jsarray_map); | 431 a.Store(AccessBuilder::ForMap(), jsarray_map); |
| 448 a.Store(AccessBuilder::ForJSObjectProperties(), properties); | 432 a.Store(AccessBuilder::ForJSObjectProperties(), properties); |
| 449 a.Store(AccessBuilder::ForJSObjectElements(), elements); | 433 a.Store(AccessBuilder::ForJSObjectElements(), elements); |
| 450 a.Store(AccessBuilder::ForJSArrayLength(FAST_ELEMENTS), | 434 a.Store(AccessBuilder::ForJSArrayLength(FAST_ELEMENTS), |
| 451 jsgraph()->Constant(length)); | 435 jsgraph()->Constant(length)); |
| 452 RelaxControls(node); | 436 RelaxControls(node); |
| 453 a.FinishAndChange(node); | 437 a.FinishAndChange(node); |
| 454 return Changed(node); | 438 return Changed(node); |
| 455 } | 439 } |
| 456 } | 440 } |
| 457 | 441 |
| 458 return NoChange(); | 442 return NoChange(); |
| 459 } | 443 } |
| 460 | 444 |
| 461 Reduction JSCreateLowering::ReduceNewArray(Node* node, Node* length, | 445 Reduction JSCreateLowering::ReduceNewArray(Node* node, Node* length, |
| 462 int capacity, | 446 int capacity, |
| 463 Handle<AllocationSite> site) { | 447 Handle<AllocationSite> site) { |
| 464 DCHECK_EQ(IrOpcode::kJSCreateArray, node->opcode()); | 448 DCHECK_EQ(IrOpcode::kJSCreateArray, node->opcode()); |
| 465 Node* context = NodeProperties::GetContextInput(node); | |
| 466 Node* effect = NodeProperties::GetEffectInput(node); | 449 Node* effect = NodeProperties::GetEffectInput(node); |
| 467 Node* control = NodeProperties::GetControlInput(node); | 450 Node* control = NodeProperties::GetControlInput(node); |
| 468 | 451 |
| 469 // Extract transition and tenuring feedback from the {site} and add | 452 // Extract transition and tenuring feedback from the {site} and add |
| 470 // appropriate code dependencies on the {site} if deoptimization is | 453 // appropriate code dependencies on the {site} if deoptimization is |
| 471 // enabled. | 454 // enabled. |
| 472 PretenureFlag pretenure = site->GetPretenureMode(); | 455 PretenureFlag pretenure = site->GetPretenureMode(); |
| 473 ElementsKind elements_kind = site->GetElementsKind(); | 456 ElementsKind elements_kind = site->GetElementsKind(); |
| 474 DCHECK(IsFastElementsKind(elements_kind)); | 457 DCHECK(IsFastElementsKind(elements_kind)); |
| 475 if (NodeProperties::GetType(length)->Max() > 0) { | 458 if (NodeProperties::GetType(length)->Max() > 0) { |
| 476 elements_kind = GetHoleyElementsKind(elements_kind); | 459 elements_kind = GetHoleyElementsKind(elements_kind); |
| 477 } | 460 } |
| 478 dependencies()->AssumeTenuringDecision(site); | 461 dependencies()->AssumeTenuringDecision(site); |
| 479 dependencies()->AssumeTransitionStable(site); | 462 dependencies()->AssumeTransitionStable(site); |
| 480 | 463 |
| 481 // Retrieve the initial map for the array from the appropriate native context. | 464 // Retrieve the initial map for the array. |
| 482 Node* native_context = effect = graph()->NewNode( | 465 int const array_map_index = Context::ArrayMapIndex(elements_kind); |
| 483 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 466 Node* js_array_map = jsgraph()->HeapConstant( |
| 484 context, context, effect); | 467 handle(Map::cast(native_context()->get(array_map_index)), isolate())); |
| 485 Node* js_array_map = effect = graph()->NewNode( | |
| 486 javascript()->LoadContext(0, Context::ArrayMapIndex(elements_kind), true), | |
| 487 native_context, native_context, effect); | |
| 488 | 468 |
| 489 // Setup elements and properties. | 469 // Setup elements and properties. |
| 490 Node* elements; | 470 Node* elements; |
| 491 if (capacity == 0) { | 471 if (capacity == 0) { |
| 492 elements = jsgraph()->EmptyFixedArrayConstant(); | 472 elements = jsgraph()->EmptyFixedArrayConstant(); |
| 493 } else { | 473 } else { |
| 494 elements = effect = | 474 elements = effect = |
| 495 AllocateElements(effect, control, elements_kind, capacity, pretenure); | 475 AllocateElements(effect, control, elements_kind, capacity, pretenure); |
| 496 } | 476 } |
| 497 Node* properties = jsgraph()->EmptyFixedArrayConstant(); | 477 Node* properties = jsgraph()->EmptyFixedArrayConstant(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 } | 657 } |
| 678 | 658 |
| 679 Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { | 659 Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { |
| 680 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); | 660 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); |
| 681 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); | 661 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); |
| 682 Handle<SharedFunctionInfo> shared = p.shared_info(); | 662 Handle<SharedFunctionInfo> shared = p.shared_info(); |
| 683 | 663 |
| 684 Node* effect = NodeProperties::GetEffectInput(node); | 664 Node* effect = NodeProperties::GetEffectInput(node); |
| 685 Node* control = NodeProperties::GetControlInput(node); | 665 Node* control = NodeProperties::GetControlInput(node); |
| 686 Node* context = NodeProperties::GetContextInput(node); | 666 Node* context = NodeProperties::GetContextInput(node); |
| 687 Node* native_context = effect = graph()->NewNode( | 667 int const function_map_index = |
| 688 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | |
| 689 context, context, effect); | |
| 690 int function_map_index = | |
| 691 Context::FunctionMapIndex(shared->language_mode(), shared->kind()); | 668 Context::FunctionMapIndex(shared->language_mode(), shared->kind()); |
| 692 Node* function_map = effect = | 669 Node* function_map = jsgraph()->HeapConstant( |
| 693 graph()->NewNode(javascript()->LoadContext(0, function_map_index, true), | 670 handle(Map::cast(native_context()->get(function_map_index)), isolate())); |
| 694 native_context, native_context, effect); | |
| 695 // Note that it is only safe to embed the raw entry point of the compile | 671 // Note that it is only safe to embed the raw entry point of the compile |
| 696 // lazy stub into the code, because that stub is immortal and immovable. | 672 // lazy stub into the code, because that stub is immortal and immovable. |
| 697 Node* compile_entry = jsgraph()->IntPtrConstant(reinterpret_cast<intptr_t>( | 673 Node* compile_entry = jsgraph()->IntPtrConstant(reinterpret_cast<intptr_t>( |
| 698 jsgraph()->isolate()->builtins()->CompileLazy()->entry())); | 674 jsgraph()->isolate()->builtins()->CompileLazy()->entry())); |
| 699 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant(); | 675 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant(); |
| 700 Node* empty_literals_array = jsgraph()->EmptyLiteralsArrayConstant(); | 676 Node* empty_literals_array = jsgraph()->EmptyLiteralsArrayConstant(); |
| 701 Node* the_hole = jsgraph()->TheHoleConstant(); | 677 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 702 Node* undefined = jsgraph()->UndefinedConstant(); | 678 Node* undefined = jsgraph()->UndefinedConstant(); |
| 703 AllocationBuilder a(jsgraph(), effect, control); | 679 AllocationBuilder a(jsgraph(), effect, control); |
| 704 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize); | 680 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 716 a.FinishAndChange(node); | 692 a.FinishAndChange(node); |
| 717 return Changed(node); | 693 return Changed(node); |
| 718 } | 694 } |
| 719 | 695 |
| 720 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) { | 696 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) { |
| 721 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode()); | 697 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode()); |
| 722 Node* value = NodeProperties::GetValueInput(node, 0); | 698 Node* value = NodeProperties::GetValueInput(node, 0); |
| 723 Node* done = NodeProperties::GetValueInput(node, 1); | 699 Node* done = NodeProperties::GetValueInput(node, 1); |
| 724 Node* effect = NodeProperties::GetEffectInput(node); | 700 Node* effect = NodeProperties::GetEffectInput(node); |
| 725 | 701 |
| 726 Node* iterator_result_map; | 702 Node* iterator_result_map = jsgraph()->HeapConstant( |
| 727 Handle<Context> native_context; | 703 handle(native_context()->iterator_result_map(), isolate())); |
| 728 if (GetSpecializationNativeContext(node).ToHandle(&native_context)) { | |
| 729 // Specialize to the constant JSIteratorResult map to enable map check | |
| 730 // elimination to eliminate subsequent checks in case of inlining. | |
| 731 iterator_result_map = jsgraph()->HeapConstant( | |
| 732 handle(native_context->iterator_result_map(), isolate())); | |
| 733 } else { | |
| 734 // Load the JSIteratorResult map for the {context}. | |
| 735 Node* context = NodeProperties::GetContextInput(node); | |
| 736 Node* native_context = effect = graph()->NewNode( | |
| 737 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | |
| 738 context, context, effect); | |
| 739 iterator_result_map = effect = graph()->NewNode( | |
| 740 javascript()->LoadContext(0, Context::ITERATOR_RESULT_MAP_INDEX, true), | |
| 741 native_context, native_context, effect); | |
| 742 } | |
| 743 | 704 |
| 744 // Emit code to allocate the JSIteratorResult instance. | 705 // Emit code to allocate the JSIteratorResult instance. |
| 745 AllocationBuilder a(jsgraph(), effect, graph()->start()); | 706 AllocationBuilder a(jsgraph(), effect, graph()->start()); |
| 746 a.Allocate(JSIteratorResult::kSize); | 707 a.Allocate(JSIteratorResult::kSize); |
| 747 a.Store(AccessBuilder::ForMap(), iterator_result_map); | 708 a.Store(AccessBuilder::ForMap(), iterator_result_map); |
| 748 a.Store(AccessBuilder::ForJSObjectProperties(), | 709 a.Store(AccessBuilder::ForJSObjectProperties(), |
| 749 jsgraph()->EmptyFixedArrayConstant()); | 710 jsgraph()->EmptyFixedArrayConstant()); |
| 750 a.Store(AccessBuilder::ForJSObjectElements(), | 711 a.Store(AccessBuilder::ForJSObjectElements(), |
| 751 jsgraph()->EmptyFixedArrayConstant()); | 712 jsgraph()->EmptyFixedArrayConstant()); |
| 752 a.Store(AccessBuilder::ForJSIteratorResultValue(), value); | 713 a.Store(AccessBuilder::ForJSIteratorResultValue(), value); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 int slot_count = OpParameter<int>(node->op()); | 752 int slot_count = OpParameter<int>(node->op()); |
| 792 Node* const closure = NodeProperties::GetValueInput(node, 0); | 753 Node* const closure = NodeProperties::GetValueInput(node, 0); |
| 793 | 754 |
| 794 // Use inline allocation for function contexts up to a size limit. | 755 // Use inline allocation for function contexts up to a size limit. |
| 795 if (slot_count < kFunctionContextAllocationLimit) { | 756 if (slot_count < kFunctionContextAllocationLimit) { |
| 796 // JSCreateFunctionContext[slot_count < limit]](fun) | 757 // JSCreateFunctionContext[slot_count < limit]](fun) |
| 797 Node* effect = NodeProperties::GetEffectInput(node); | 758 Node* effect = NodeProperties::GetEffectInput(node); |
| 798 Node* control = NodeProperties::GetControlInput(node); | 759 Node* control = NodeProperties::GetControlInput(node); |
| 799 Node* context = NodeProperties::GetContextInput(node); | 760 Node* context = NodeProperties::GetContextInput(node); |
| 800 Node* extension = jsgraph()->TheHoleConstant(); | 761 Node* extension = jsgraph()->TheHoleConstant(); |
| 801 Node* native_context = effect = graph()->NewNode( | |
| 802 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | |
| 803 context, context, effect); | |
| 804 AllocationBuilder a(jsgraph(), effect, control); | 762 AllocationBuilder a(jsgraph(), effect, control); |
| 805 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 763 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 806 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; | 764 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; |
| 807 a.AllocateArray(context_length, factory()->function_context_map()); | 765 a.AllocateArray(context_length, factory()->function_context_map()); |
| 808 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 766 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 809 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 767 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| 810 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); | 768 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
| 811 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 769 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), |
| 812 native_context); | 770 jsgraph()->HeapConstant(native_context())); |
| 813 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { | 771 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
| 814 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); | 772 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); |
| 815 } | 773 } |
| 816 RelaxControls(node); | 774 RelaxControls(node); |
| 817 a.FinishAndChange(node); | 775 a.FinishAndChange(node); |
| 818 return Changed(node); | 776 return Changed(node); |
| 819 } | 777 } |
| 820 | 778 |
| 821 return NoChange(); | 779 return NoChange(); |
| 822 } | 780 } |
| 823 | 781 |
| 824 Reduction JSCreateLowering::ReduceJSCreateWithContext(Node* node) { | 782 Reduction JSCreateLowering::ReduceJSCreateWithContext(Node* node) { |
| 825 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); | 783 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); |
| 826 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 784 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
| 827 Node* object = NodeProperties::GetValueInput(node, 0); | 785 Node* object = NodeProperties::GetValueInput(node, 0); |
| 828 Node* closure = NodeProperties::GetValueInput(node, 1); | 786 Node* closure = NodeProperties::GetValueInput(node, 1); |
| 829 Node* effect = NodeProperties::GetEffectInput(node); | 787 Node* effect = NodeProperties::GetEffectInput(node); |
| 830 Node* control = NodeProperties::GetControlInput(node); | 788 Node* control = NodeProperties::GetControlInput(node); |
| 831 Node* context = NodeProperties::GetContextInput(node); | 789 Node* context = NodeProperties::GetContextInput(node); |
| 832 Node* native_context = effect = graph()->NewNode( | |
| 833 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | |
| 834 context, context, effect); | |
| 835 | 790 |
| 836 AllocationBuilder aa(jsgraph(), effect, control); | 791 AllocationBuilder aa(jsgraph(), effect, control); |
| 837 aa.Allocate(ContextExtension::kSize); | 792 aa.Allocate(ContextExtension::kSize); |
| 838 aa.Store(AccessBuilder::ForMap(), factory()->context_extension_map()); | 793 aa.Store(AccessBuilder::ForMap(), factory()->context_extension_map()); |
| 839 aa.Store(AccessBuilder::ForContextExtensionScopeInfo(), scope_info); | 794 aa.Store(AccessBuilder::ForContextExtensionScopeInfo(), scope_info); |
| 840 aa.Store(AccessBuilder::ForContextExtensionExtension(), object); | 795 aa.Store(AccessBuilder::ForContextExtensionExtension(), object); |
| 841 Node* extension = aa.Finish(); | 796 Node* extension = aa.Finish(); |
| 842 | 797 |
| 843 AllocationBuilder a(jsgraph(), extension, control); | 798 AllocationBuilder a(jsgraph(), extension, control); |
| 844 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 799 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 845 a.AllocateArray(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map()); | 800 a.AllocateArray(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map()); |
| 846 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 801 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 847 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 802 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| 848 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); | 803 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
| 849 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 804 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), |
| 850 native_context); | 805 jsgraph()->HeapConstant(native_context())); |
| 851 RelaxControls(node); | 806 RelaxControls(node); |
| 852 a.FinishAndChange(node); | 807 a.FinishAndChange(node); |
| 853 return Changed(node); | 808 return Changed(node); |
| 854 } | 809 } |
| 855 | 810 |
| 856 Reduction JSCreateLowering::ReduceJSCreateCatchContext(Node* node) { | 811 Reduction JSCreateLowering::ReduceJSCreateCatchContext(Node* node) { |
| 857 DCHECK_EQ(IrOpcode::kJSCreateCatchContext, node->opcode()); | 812 DCHECK_EQ(IrOpcode::kJSCreateCatchContext, node->opcode()); |
| 858 const CreateCatchContextParameters& parameters = | 813 const CreateCatchContextParameters& parameters = |
| 859 CreateCatchContextParametersOf(node->op()); | 814 CreateCatchContextParametersOf(node->op()); |
| 860 Node* exception = NodeProperties::GetValueInput(node, 0); | 815 Node* exception = NodeProperties::GetValueInput(node, 0); |
| 861 Node* closure = NodeProperties::GetValueInput(node, 1); | 816 Node* closure = NodeProperties::GetValueInput(node, 1); |
| 862 Node* effect = NodeProperties::GetEffectInput(node); | 817 Node* effect = NodeProperties::GetEffectInput(node); |
| 863 Node* control = NodeProperties::GetControlInput(node); | 818 Node* control = NodeProperties::GetControlInput(node); |
| 864 Node* context = NodeProperties::GetContextInput(node); | 819 Node* context = NodeProperties::GetContextInput(node); |
| 865 Node* native_context = effect = graph()->NewNode( | |
| 866 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | |
| 867 context, context, effect); | |
| 868 | 820 |
| 869 AllocationBuilder aa(jsgraph(), effect, control); | 821 AllocationBuilder aa(jsgraph(), effect, control); |
| 870 aa.Allocate(ContextExtension::kSize); | 822 aa.Allocate(ContextExtension::kSize); |
| 871 aa.Store(AccessBuilder::ForMap(), factory()->context_extension_map()); | 823 aa.Store(AccessBuilder::ForMap(), factory()->context_extension_map()); |
| 872 aa.Store(AccessBuilder::ForContextExtensionScopeInfo(), | 824 aa.Store(AccessBuilder::ForContextExtensionScopeInfo(), |
| 873 parameters.scope_info()); | 825 parameters.scope_info()); |
| 874 aa.Store(AccessBuilder::ForContextExtensionExtension(), | 826 aa.Store(AccessBuilder::ForContextExtensionExtension(), |
| 875 parameters.catch_name()); | 827 parameters.catch_name()); |
| 876 Node* extension = aa.Finish(); | 828 Node* extension = aa.Finish(); |
| 877 | 829 |
| 878 AllocationBuilder a(jsgraph(), extension, control); | 830 AllocationBuilder a(jsgraph(), extension, control); |
| 879 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 831 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 880 a.AllocateArray(Context::MIN_CONTEXT_SLOTS + 1, | 832 a.AllocateArray(Context::MIN_CONTEXT_SLOTS + 1, |
| 881 factory()->catch_context_map()); | 833 factory()->catch_context_map()); |
| 882 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 834 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 883 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 835 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| 884 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); | 836 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
| 885 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 837 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), |
| 886 native_context); | 838 jsgraph()->HeapConstant(native_context())); |
| 887 a.Store(AccessBuilder::ForContextSlot(Context::THROWN_OBJECT_INDEX), | 839 a.Store(AccessBuilder::ForContextSlot(Context::THROWN_OBJECT_INDEX), |
| 888 exception); | 840 exception); |
| 889 RelaxControls(node); | 841 RelaxControls(node); |
| 890 a.FinishAndChange(node); | 842 a.FinishAndChange(node); |
| 891 return Changed(node); | 843 return Changed(node); |
| 892 } | 844 } |
| 893 | 845 |
| 894 Reduction JSCreateLowering::ReduceJSCreateBlockContext(Node* node) { | 846 Reduction JSCreateLowering::ReduceJSCreateBlockContext(Node* node) { |
| 895 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); | 847 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); |
| 896 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 848 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
| 897 int const context_length = scope_info->ContextLength(); | 849 int const context_length = scope_info->ContextLength(); |
| 898 Node* const closure = NodeProperties::GetValueInput(node, 0); | 850 Node* const closure = NodeProperties::GetValueInput(node, 0); |
| 899 | 851 |
| 900 // Use inline allocation for block contexts up to a size limit. | 852 // Use inline allocation for block contexts up to a size limit. |
| 901 if (context_length < kBlockContextAllocationLimit) { | 853 if (context_length < kBlockContextAllocationLimit) { |
| 902 // JSCreateBlockContext[scope[length < limit]](fun) | 854 // JSCreateBlockContext[scope[length < limit]](fun) |
| 903 Node* effect = NodeProperties::GetEffectInput(node); | 855 Node* effect = NodeProperties::GetEffectInput(node); |
| 904 Node* control = NodeProperties::GetControlInput(node); | 856 Node* control = NodeProperties::GetControlInput(node); |
| 905 Node* context = NodeProperties::GetContextInput(node); | 857 Node* context = NodeProperties::GetContextInput(node); |
| 906 Node* extension = jsgraph()->Constant(scope_info); | 858 Node* extension = jsgraph()->Constant(scope_info); |
| 907 Node* native_context = effect = graph()->NewNode( | 859 |
| 908 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | |
| 909 context, context, effect); | |
| 910 AllocationBuilder a(jsgraph(), effect, control); | 860 AllocationBuilder a(jsgraph(), effect, control); |
| 911 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 861 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 912 a.AllocateArray(context_length, factory()->block_context_map()); | 862 a.AllocateArray(context_length, factory()->block_context_map()); |
| 913 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 863 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 914 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 864 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| 915 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); | 865 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
| 916 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 866 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), |
| 917 native_context); | 867 jsgraph()->HeapConstant(native_context())); |
| 918 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { | 868 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
| 919 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); | 869 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); |
| 920 } | 870 } |
| 921 RelaxControls(node); | 871 RelaxControls(node); |
| 922 a.FinishAndChange(node); | 872 a.FinishAndChange(node); |
| 923 return Changed(node); | 873 return Changed(node); |
| 924 } | 874 } |
| 925 | 875 |
| 926 return NoChange(); | 876 return NoChange(); |
| 927 } | 877 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 return literals_array_; | 1222 return literals_array_; |
| 1273 } | 1223 } |
| 1274 break; | 1224 break; |
| 1275 } | 1225 } |
| 1276 default: | 1226 default: |
| 1277 break; | 1227 break; |
| 1278 } | 1228 } |
| 1279 return MaybeHandle<LiteralsArray>(); | 1229 return MaybeHandle<LiteralsArray>(); |
| 1280 } | 1230 } |
| 1281 | 1231 |
| 1282 MaybeHandle<Context> JSCreateLowering::GetSpecializationNativeContext( | |
| 1283 Node* node) { | |
| 1284 Node* const context = NodeProperties::GetContextInput(node); | |
| 1285 return NodeProperties::GetSpecializationNativeContext(context, | |
| 1286 native_context_); | |
| 1287 } | |
| 1288 | |
| 1289 Factory* JSCreateLowering::factory() const { return isolate()->factory(); } | 1232 Factory* JSCreateLowering::factory() const { return isolate()->factory(); } |
| 1290 | 1233 |
| 1291 Graph* JSCreateLowering::graph() const { return jsgraph()->graph(); } | 1234 Graph* JSCreateLowering::graph() const { return jsgraph()->graph(); } |
| 1292 | 1235 |
| 1293 Isolate* JSCreateLowering::isolate() const { return jsgraph()->isolate(); } | 1236 Isolate* JSCreateLowering::isolate() const { return jsgraph()->isolate(); } |
| 1294 | 1237 |
| 1295 JSOperatorBuilder* JSCreateLowering::javascript() const { | 1238 JSOperatorBuilder* JSCreateLowering::javascript() const { |
| 1296 return jsgraph()->javascript(); | 1239 return jsgraph()->javascript(); |
| 1297 } | 1240 } |
| 1298 | 1241 |
| 1299 CommonOperatorBuilder* JSCreateLowering::common() const { | 1242 CommonOperatorBuilder* JSCreateLowering::common() const { |
| 1300 return jsgraph()->common(); | 1243 return jsgraph()->common(); |
| 1301 } | 1244 } |
| 1302 | 1245 |
| 1303 SimplifiedOperatorBuilder* JSCreateLowering::simplified() const { | 1246 SimplifiedOperatorBuilder* JSCreateLowering::simplified() const { |
| 1304 return jsgraph()->simplified(); | 1247 return jsgraph()->simplified(); |
| 1305 } | 1248 } |
| 1306 | 1249 |
| 1307 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1250 MachineOperatorBuilder* JSCreateLowering::machine() const { |
| 1308 return jsgraph()->machine(); | 1251 return jsgraph()->machine(); |
| 1309 } | 1252 } |
| 1310 | 1253 |
| 1311 } // namespace compiler | 1254 } // namespace compiler |
| 1312 } // namespace internal | 1255 } // namespace internal |
| 1313 } // namespace v8 | 1256 } // namespace v8 |
| OLD | NEW |