Chromium Code Reviews| 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/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
| 8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
| 10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 } | 725 } |
| 726 | 726 |
| 727 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { | 727 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { |
| 728 BuildStaLookupSlot(LanguageMode::SLOPPY); | 728 BuildStaLookupSlot(LanguageMode::SLOPPY); |
| 729 } | 729 } |
| 730 | 730 |
| 731 void BytecodeGraphBuilder::VisitStaLookupSlotStrict() { | 731 void BytecodeGraphBuilder::VisitStaLookupSlotStrict() { |
| 732 BuildStaLookupSlot(LanguageMode::STRICT); | 732 BuildStaLookupSlot(LanguageMode::STRICT); |
| 733 } | 733 } |
| 734 | 734 |
| 735 void BytecodeGraphBuilder::BuildNamedLoad() { | 735 void BytecodeGraphBuilder::VisitLdaNamedProperty() { |
| 736 FrameStateBeforeAndAfter states(this); | 736 FrameStateBeforeAndAfter states(this); |
| 737 Node* object = | 737 Node* object = |
| 738 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 738 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 739 Handle<Name> name = | 739 Handle<Name> name = |
| 740 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | 740 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
| 741 VectorSlotPair feedback = | 741 VectorSlotPair feedback = |
| 742 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 742 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
| 743 | 743 |
| 744 const Operator* op = javascript()->LoadNamed(name, feedback); | 744 const Operator* op = javascript()->LoadNamed(name, feedback); |
| 745 Node* node = NewNode(op, object, GetFunctionClosure()); | 745 Node* node = NewNode(op, object, GetFunctionClosure()); |
| 746 environment()->BindAccumulator(node, &states); | 746 environment()->BindAccumulator(node, &states); |
| 747 } | 747 } |
| 748 | 748 |
| 749 void BytecodeGraphBuilder::VisitLoadIC() { BuildNamedLoad(); } | 749 void BytecodeGraphBuilder::VisitLdaKeyedProperty() { |
| 750 | |
| 751 void BytecodeGraphBuilder::BuildKeyedLoad() { | |
| 752 FrameStateBeforeAndAfter states(this); | 750 FrameStateBeforeAndAfter states(this); |
| 753 Node* key = environment()->LookupAccumulator(); | 751 Node* key = environment()->LookupAccumulator(); |
| 754 Node* object = | 752 Node* object = |
| 755 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 753 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 756 VectorSlotPair feedback = | 754 VectorSlotPair feedback = |
| 757 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 755 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
| 758 | 756 |
| 759 const Operator* op = javascript()->LoadProperty(feedback); | 757 const Operator* op = javascript()->LoadProperty(feedback); |
| 760 Node* node = NewNode(op, object, key, GetFunctionClosure()); | 758 Node* node = NewNode(op, object, key, GetFunctionClosure()); |
| 761 environment()->BindAccumulator(node, &states); | 759 environment()->BindAccumulator(node, &states); |
| 762 } | 760 } |
| 763 | 761 |
| 764 void BytecodeGraphBuilder::VisitKeyedLoadIC() { BuildKeyedLoad(); } | |
| 765 | |
| 766 void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) { | 762 void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) { |
| 767 FrameStateBeforeAndAfter states(this); | 763 FrameStateBeforeAndAfter states(this); |
| 768 Node* value = environment()->LookupAccumulator(); | 764 Node* value = environment()->LookupAccumulator(); |
| 769 Node* object = | 765 Node* object = |
| 770 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 766 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 771 Handle<Name> name = | 767 Handle<Name> name = |
| 772 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | 768 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
| 773 VectorSlotPair feedback = | 769 VectorSlotPair feedback = |
| 774 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 770 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
| 775 | 771 |
| 776 const Operator* op = javascript()->StoreNamed(language_mode, name, feedback); | 772 const Operator* op = javascript()->StoreNamed(language_mode, name, feedback); |
| 777 Node* node = NewNode(op, object, value, GetFunctionClosure()); | 773 Node* node = NewNode(op, object, value, GetFunctionClosure()); |
| 778 environment()->RecordAfterState(node, &states); | 774 environment()->RecordAfterState(node, &states); |
| 779 } | 775 } |
| 780 | 776 |
| 781 void BytecodeGraphBuilder::VisitStoreICSloppy() { | 777 void BytecodeGraphBuilder::VisitStaNamedPropertySloppy() { |
| 782 BuildNamedStore(LanguageMode::SLOPPY); | 778 BuildNamedStore(LanguageMode::SLOPPY); |
| 783 } | 779 } |
| 784 | 780 |
| 785 void BytecodeGraphBuilder::VisitStoreICStrict() { | 781 void BytecodeGraphBuilder::VisitStaNamedPropertyStrict() { |
| 786 BuildNamedStore(LanguageMode::STRICT); | 782 BuildNamedStore(LanguageMode::STRICT); |
| 787 } | 783 } |
| 788 | 784 |
| 789 void BytecodeGraphBuilder::BuildKeyedStore(LanguageMode language_mode) { | 785 void BytecodeGraphBuilder::BuildKeyedStore(LanguageMode language_mode) { |
| 790 FrameStateBeforeAndAfter states(this); | 786 FrameStateBeforeAndAfter states(this); |
| 791 Node* value = environment()->LookupAccumulator(); | 787 Node* value = environment()->LookupAccumulator(); |
| 792 Node* object = | 788 Node* object = |
| 793 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 789 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 794 Node* key = | 790 Node* key = |
| 795 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); | 791 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
| 796 VectorSlotPair feedback = | 792 VectorSlotPair feedback = |
| 797 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | 793 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
| 798 | 794 |
| 799 const Operator* op = javascript()->StoreProperty(language_mode, feedback); | 795 const Operator* op = javascript()->StoreProperty(language_mode, feedback); |
| 800 Node* node = NewNode(op, object, key, value, GetFunctionClosure()); | 796 Node* node = NewNode(op, object, key, value, GetFunctionClosure()); |
| 801 environment()->RecordAfterState(node, &states); | 797 environment()->RecordAfterState(node, &states); |
| 802 } | 798 } |
| 803 | 799 |
| 804 void BytecodeGraphBuilder::VisitKeyedStoreICSloppy() { | 800 void BytecodeGraphBuilder::VisitStaKeyedPropertySloppy() { |
| 805 BuildKeyedStore(LanguageMode::SLOPPY); | 801 BuildKeyedStore(LanguageMode::SLOPPY); |
| 806 } | 802 } |
| 807 | 803 |
| 808 void BytecodeGraphBuilder::VisitKeyedStoreICStrict() { | 804 void BytecodeGraphBuilder::VisitStaKeyedPropertyStrict() { |
| 809 BuildKeyedStore(LanguageMode::STRICT); | 805 BuildKeyedStore(LanguageMode::STRICT); |
| 810 } | 806 } |
| 811 | 807 |
| 812 void BytecodeGraphBuilder::VisitPushContext() { | 808 void BytecodeGraphBuilder::VisitPushContext() { |
| 813 Node* new_context = environment()->LookupAccumulator(); | 809 Node* new_context = environment()->LookupAccumulator(); |
| 814 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), | 810 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), |
| 815 environment()->Context()); | 811 environment()->Context()); |
| 816 environment()->SetContext(new_context); | 812 environment()->SetContext(new_context); |
| 817 } | 813 } |
| 818 | 814 |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1418 UNREACHABLE(); | 1414 UNREACHABLE(); |
| 1419 } | 1415 } |
| 1420 | 1416 |
| 1421 void BytecodeGraphBuilder::VisitIllegal() { | 1417 void BytecodeGraphBuilder::VisitIllegal() { |
| 1422 // Not emitted in valid bytecode. | 1418 // Not emitted in valid bytecode. |
| 1423 UNREACHABLE(); | 1419 UNREACHABLE(); |
| 1424 } | 1420 } |
| 1425 | 1421 |
| 1426 void BytecodeGraphBuilder::VisitNop() {} | 1422 void BytecodeGraphBuilder::VisitNop() {} |
| 1427 | 1423 |
| 1424 void BytecodeGraphBuilder::VisitLdrUndefined() { | |
| 1425 Node* node = jsgraph()->UndefinedConstant(); | |
| 1426 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), node); | |
| 1427 } | |
| 1428 | |
| 1429 void BytecodeGraphBuilder::VisitLdrContextSlot() { | |
| 1430 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | |
| 1431 // generating bytecode. Hence the value of depth is always 0. Update this | |
| 1432 // code, when the implementation changes. | |
| 1433 // TODO(mythria): immutable flag is also set to false. This information is not | |
| 1434 // available in bytecode array. update this code when the implementation | |
| 1435 // changes. | |
| 1436 const Operator* op = javascript()->LoadContext( | |
| 1437 0, bytecode_iterator().GetIndexOperand(1), false); | |
| 1438 Node* context = | |
| 1439 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | |
| 1440 Node* node = NewNode(op, context); | |
|
rmcilroy
2016/05/17 15:49:33
Could we factor out the common code to a BuildXXX(
oth
2016/05/18 20:22:24
Done.
| |
| 1441 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(2), node); | |
| 1442 } | |
| 1443 | |
| 1444 void BytecodeGraphBuilder::VisitLdrGlobal() { | |
| 1445 FrameStateBeforeAndAfter states(this); | |
| 1446 Handle<Name> name = | |
| 1447 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | |
| 1448 VectorSlotPair feedback = | |
| 1449 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | |
| 1450 | |
| 1451 const Operator* op = | |
| 1452 javascript()->LoadGlobal(name, feedback, TypeofMode::NOT_INSIDE_TYPEOF); | |
| 1453 Node* node = NewNode(op, GetFunctionClosure()); | |
| 1454 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(2), node, | |
| 1455 &states); | |
| 1456 } | |
| 1457 | |
| 1458 void BytecodeGraphBuilder::VisitLdrNamedProperty() { | |
| 1459 FrameStateBeforeAndAfter states(this); | |
| 1460 Node* object = | |
| 1461 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | |
| 1462 Handle<Name> name = | |
| 1463 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); | |
| 1464 VectorSlotPair feedback = | |
| 1465 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); | |
| 1466 | |
| 1467 const Operator* op = javascript()->LoadNamed(name, feedback); | |
| 1468 Node* node = NewNode(op, object, GetFunctionClosure()); | |
| 1469 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(3), node, | |
| 1470 &states); | |
| 1471 } | |
| 1472 | |
| 1473 void BytecodeGraphBuilder::VisitLdrKeyedProperty() { | |
| 1474 FrameStateBeforeAndAfter states(this); | |
| 1475 Node* key = environment()->LookupAccumulator(); | |
| 1476 Node* object = | |
| 1477 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | |
| 1478 VectorSlotPair feedback = | |
| 1479 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | |
| 1480 | |
| 1481 const Operator* op = javascript()->LoadProperty(feedback); | |
| 1482 Node* node = NewNode(op, object, key, GetFunctionClosure()); | |
| 1483 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(2), node, | |
| 1484 &states); | |
| 1485 } | |
| 1486 | |
| 1428 void BytecodeGraphBuilder::SwitchToMergeEnvironment(int current_offset) { | 1487 void BytecodeGraphBuilder::SwitchToMergeEnvironment(int current_offset) { |
| 1429 if (merge_environments_[current_offset] != nullptr) { | 1488 if (merge_environments_[current_offset] != nullptr) { |
| 1430 if (environment() != nullptr) { | 1489 if (environment() != nullptr) { |
| 1431 merge_environments_[current_offset]->Merge(environment()); | 1490 merge_environments_[current_offset]->Merge(environment()); |
| 1432 } | 1491 } |
| 1433 set_environment(merge_environments_[current_offset]); | 1492 set_environment(merge_environments_[current_offset]); |
| 1434 } | 1493 } |
| 1435 } | 1494 } |
| 1436 | 1495 |
| 1437 void BytecodeGraphBuilder::BuildLoopHeaderEnvironment(int current_offset) { | 1496 void BytecodeGraphBuilder::BuildLoopHeaderEnvironment(int current_offset) { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1690 // Phi does not exist yet, introduce one. | 1749 // Phi does not exist yet, introduce one. |
| 1691 value = NewPhi(inputs, value, control); | 1750 value = NewPhi(inputs, value, control); |
| 1692 value->ReplaceInput(inputs - 1, other); | 1751 value->ReplaceInput(inputs - 1, other); |
| 1693 } | 1752 } |
| 1694 return value; | 1753 return value; |
| 1695 } | 1754 } |
| 1696 | 1755 |
| 1697 } // namespace compiler | 1756 } // namespace compiler |
| 1698 } // namespace internal | 1757 } // namespace internal |
| 1699 } // namespace v8 | 1758 } // namespace v8 |
| OLD | NEW |