OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-native-context-specialization.h" | 5 #include "src/compiler/js-native-context-specialization.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 296 } |
297 effect = graph()->NewNode( | 297 effect = graph()->NewNode( |
298 simplified()->StoreField(AccessBuilder::ForPropertyCellValue()), | 298 simplified()->StoreField(AccessBuilder::ForPropertyCellValue()), |
299 jsgraph()->Constant(property_cell), value, effect, control); | 299 jsgraph()->Constant(property_cell), value, effect, control); |
300 return Replace(node, value, effect, control); | 300 return Replace(node, value, effect, control); |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 Reduction JSNativeContextSpecialization::ReduceNamedAccess( | 304 Reduction JSNativeContextSpecialization::ReduceNamedAccess( |
305 Node* node, Node* value, MapHandleList const& receiver_maps, | 305 Node* node, Node* value, MapHandleList const& receiver_maps, |
306 Handle<Name> name, PropertyAccessMode access_mode) { | 306 Handle<Name> name, PropertyAccessMode access_mode, |
| 307 LanguageMode language_mode) { |
307 DCHECK(node->opcode() == IrOpcode::kJSLoadNamed || | 308 DCHECK(node->opcode() == IrOpcode::kJSLoadNamed || |
308 node->opcode() == IrOpcode::kJSStoreNamed); | 309 node->opcode() == IrOpcode::kJSStoreNamed); |
309 Node* receiver = NodeProperties::GetValueInput(node, 0); | 310 Node* receiver = NodeProperties::GetValueInput(node, 0); |
310 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); | 311 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); |
311 Node* effect = NodeProperties::GetEffectInput(node); | 312 Node* effect = NodeProperties::GetEffectInput(node); |
312 Node* control = NodeProperties::GetControlInput(node); | 313 Node* control = NodeProperties::GetControlInput(node); |
313 | 314 |
314 // Not much we can do if deoptimization support is disabled. | 315 // Not much we can do if deoptimization support is disabled. |
315 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); | 316 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); |
316 | 317 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 this_control_count, &this_controls.front()); | 393 this_control_count, &this_controls.front()); |
393 } | 394 } |
394 | 395 |
395 // Determine actual holder and perform prototype chain checks. | 396 // Determine actual holder and perform prototype chain checks. |
396 Handle<JSObject> holder; | 397 Handle<JSObject> holder; |
397 if (access_info.holder().ToHandle(&holder)) { | 398 if (access_info.holder().ToHandle(&holder)) { |
398 AssumePrototypesStable(receiver_type, holder); | 399 AssumePrototypesStable(receiver_type, holder); |
399 } | 400 } |
400 | 401 |
401 // Generate the actual property access. | 402 // Generate the actual property access. |
402 if (access_info.IsDataConstant()) { | 403 if (access_info.IsNotFound()) { |
| 404 DCHECK_EQ(PropertyAccessMode::kLoad, access_mode); |
| 405 if (is_strong(language_mode)) { |
| 406 // TODO(bmeurer/mstarzinger): Add support for lowering inside try |
| 407 // blocks rewiring the IfException edge to a runtime call/throw. |
| 408 exit_controls.push_back(this_control); |
| 409 continue; |
| 410 } else { |
| 411 this_value = jsgraph()->UndefinedConstant(); |
| 412 } |
| 413 } else if (access_info.IsDataConstant()) { |
403 this_value = jsgraph()->Constant(access_info.constant()); | 414 this_value = jsgraph()->Constant(access_info.constant()); |
404 if (access_mode == PropertyAccessMode::kStore) { | 415 if (access_mode == PropertyAccessMode::kStore) { |
405 Node* check = graph()->NewNode( | 416 Node* check = graph()->NewNode( |
406 simplified()->ReferenceEqual(Type::Tagged()), value, this_value); | 417 simplified()->ReferenceEqual(Type::Tagged()), value, this_value); |
407 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue), | 418 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue), |
408 check, this_control); | 419 check, this_control); |
409 exit_controls.push_back(graph()->NewNode(common()->IfFalse(), branch)); | 420 exit_controls.push_back(graph()->NewNode(common()->IfFalse(), branch)); |
410 this_control = graph()->NewNode(common()->IfTrue(), branch); | 421 this_control = graph()->NewNode(common()->IfTrue(), branch); |
411 } | 422 } |
412 } else { | 423 } else { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 ? exit_controls.front() | 590 ? exit_controls.front() |
580 : graph()->NewNode(common()->Merge(exit_control_count), | 591 : graph()->NewNode(common()->Merge(exit_control_count), |
581 exit_control_count, &exit_controls.front()); | 592 exit_control_count, &exit_controls.front()); |
582 Node* deoptimize = graph()->NewNode(common()->Deoptimize(), frame_state, | 593 Node* deoptimize = graph()->NewNode(common()->Deoptimize(), frame_state, |
583 exit_effect, exit_control); | 594 exit_effect, exit_control); |
584 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 595 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
585 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 596 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
586 | 597 |
587 // Generate the final merge point for all (polymorphic) branches. | 598 // Generate the final merge point for all (polymorphic) branches. |
588 int const control_count = static_cast<int>(controls.size()); | 599 int const control_count = static_cast<int>(controls.size()); |
589 if (control_count == 1) { | 600 if (control_count == 0) { |
| 601 value = effect = control = jsgraph()->Dead(); |
| 602 } else if (control_count == 1) { |
590 value = values.front(); | 603 value = values.front(); |
591 effect = effects.front(); | 604 effect = effects.front(); |
592 control = controls.front(); | 605 control = controls.front(); |
593 } else { | 606 } else { |
594 control = graph()->NewNode(common()->Merge(control_count), control_count, | 607 control = graph()->NewNode(common()->Merge(control_count), control_count, |
595 &controls.front()); | 608 &controls.front()); |
596 values.push_back(control); | 609 values.push_back(control); |
597 value = graph()->NewNode(common()->Phi(kMachAnyTagged, control_count), | 610 value = graph()->NewNode(common()->Phi(kMachAnyTagged, control_count), |
598 control_count + 1, &values.front()); | 611 control_count + 1, &values.front()); |
599 effects.push_back(control); | 612 effects.push_back(control); |
(...skipping 11 matching lines...) Expand all Loading... |
611 | 624 |
612 // Extract receiver maps from the LOAD_IC using the LoadICNexus. | 625 // Extract receiver maps from the LOAD_IC using the LoadICNexus. |
613 MapHandleList receiver_maps; | 626 MapHandleList receiver_maps; |
614 if (!p.feedback().IsValid()) return NoChange(); | 627 if (!p.feedback().IsValid()) return NoChange(); |
615 LoadICNexus nexus(p.feedback().vector(), p.feedback().slot()); | 628 LoadICNexus nexus(p.feedback().vector(), p.feedback().slot()); |
616 if (nexus.ExtractMaps(&receiver_maps) == 0) return NoChange(); | 629 if (nexus.ExtractMaps(&receiver_maps) == 0) return NoChange(); |
617 DCHECK_LT(0, receiver_maps.length()); | 630 DCHECK_LT(0, receiver_maps.length()); |
618 | 631 |
619 // Try to lower the named access based on the {receiver_maps}. | 632 // Try to lower the named access based on the {receiver_maps}. |
620 return ReduceNamedAccess(node, value, receiver_maps, p.name(), | 633 return ReduceNamedAccess(node, value, receiver_maps, p.name(), |
621 PropertyAccessMode::kLoad); | 634 PropertyAccessMode::kLoad, p.language_mode()); |
622 } | 635 } |
623 | 636 |
624 | 637 |
625 Reduction JSNativeContextSpecialization::ReduceJSStoreNamed(Node* node) { | 638 Reduction JSNativeContextSpecialization::ReduceJSStoreNamed(Node* node) { |
626 DCHECK_EQ(IrOpcode::kJSStoreNamed, node->opcode()); | 639 DCHECK_EQ(IrOpcode::kJSStoreNamed, node->opcode()); |
627 NamedAccess const& p = NamedAccessOf(node->op()); | 640 NamedAccess const& p = NamedAccessOf(node->op()); |
628 Node* const value = NodeProperties::GetValueInput(node, 1); | 641 Node* const value = NodeProperties::GetValueInput(node, 1); |
629 | 642 |
630 // Extract receiver maps from the STORE_IC using the StoreICNexus. | 643 // Extract receiver maps from the STORE_IC using the StoreICNexus. |
631 MapHandleList receiver_maps; | 644 MapHandleList receiver_maps; |
632 if (!p.feedback().IsValid()) return NoChange(); | 645 if (!p.feedback().IsValid()) return NoChange(); |
633 StoreICNexus nexus(p.feedback().vector(), p.feedback().slot()); | 646 StoreICNexus nexus(p.feedback().vector(), p.feedback().slot()); |
634 if (nexus.ExtractMaps(&receiver_maps) == 0) return NoChange(); | 647 if (nexus.ExtractMaps(&receiver_maps) == 0) return NoChange(); |
635 DCHECK_LT(0, receiver_maps.length()); | 648 DCHECK_LT(0, receiver_maps.length()); |
636 | 649 |
637 // Try to lower the named access based on the {receiver_maps}. | 650 // Try to lower the named access based on the {receiver_maps}. |
638 return ReduceNamedAccess(node, value, receiver_maps, p.name(), | 651 return ReduceNamedAccess(node, value, receiver_maps, p.name(), |
639 PropertyAccessMode::kStore); | 652 PropertyAccessMode::kStore, p.language_mode()); |
640 } | 653 } |
641 | 654 |
642 | 655 |
643 Reduction JSNativeContextSpecialization::Replace(Node* node, | 656 Reduction JSNativeContextSpecialization::Replace(Node* node, |
644 Handle<Object> value) { | 657 Handle<Object> value) { |
645 return Replace(node, jsgraph()->Constant(value)); | 658 return Replace(node, jsgraph()->Constant(value)); |
646 } | 659 } |
647 | 660 |
648 | 661 |
649 bool JSNativeContextSpecialization::LookupInScriptContextTable( | 662 bool JSNativeContextSpecialization::LookupInScriptContextTable( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 } | 734 } |
722 | 735 |
723 | 736 |
724 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 737 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
725 return jsgraph()->simplified(); | 738 return jsgraph()->simplified(); |
726 } | 739 } |
727 | 740 |
728 } // namespace compiler | 741 } // namespace compiler |
729 } // namespace internal | 742 } // namespace internal |
730 } // namespace v8 | 743 } // namespace v8 |
OLD | NEW |