Changeset 164417 in webkit for trunk/Source/JavaScriptCore/dfg/DFGNode.h
- Timestamp:
- Feb 20, 2014, 12:00:28 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGNode.h
r164207 r164417 79 79 }; 80 80 81 struct BranchTarget { 82 BranchTarget() 83 : block(0) 84 , count(QNaN) 85 { 86 } 87 88 explicit BranchTarget(BasicBlock* block) 89 : block(block) 90 , count(QNaN) 91 { 92 } 93 94 void setBytecodeIndex(unsigned bytecodeIndex) 95 { 96 block = bitwise_cast<BasicBlock*>(static_cast<uintptr_t>(bytecodeIndex)); 97 } 98 unsigned bytecodeIndex() const { return bitwise_cast<uintptr_t>(block); } 99 100 void dump(PrintStream&) const; 101 102 BasicBlock* block; 103 float count; 104 }; 105 106 struct BranchData { 107 static BranchData withBytecodeIndices( 108 unsigned takenBytecodeIndex, unsigned notTakenBytecodeIndex) 109 { 110 BranchData result; 111 result.taken.block = bitwise_cast<BasicBlock*>(static_cast<uintptr_t>(takenBytecodeIndex)); 112 result.notTaken.block = bitwise_cast<BasicBlock*>(static_cast<uintptr_t>(notTakenBytecodeIndex)); 113 return result; 114 } 115 116 unsigned takenBytecodeIndex() const { return taken.bytecodeIndex(); } 117 unsigned notTakenBytecodeIndex() const { return notTaken.bytecodeIndex(); } 118 119 BasicBlock*& forCondition(bool condition) 120 { 121 if (condition) 122 return taken.block; 123 return notTaken.block; 124 } 125 126 BranchTarget taken; 127 BranchTarget notTaken; 128 }; 129 81 130 // The SwitchData and associated data structures duplicate the information in 82 131 // JumpTable. The DFG may ultimately end up using the JumpTable, though it may … … 92 141 struct SwitchCase { 93 142 SwitchCase() 94 : target(0)95 143 { 96 144 } … … 106 154 SwitchCase result; 107 155 result.value = value; 108 result.target = bitwise_cast<BasicBlock*>(static_cast<uintptr_t>(bytecodeIndex));156 result.target.setBytecodeIndex(bytecodeIndex); 109 157 return result; 110 158 } 111 159 112 unsigned targetBytecodeIndex() const { return bitwise_cast<uintptr_t>(target); }113 114 160 LazyJSValue value; 115 B asicBlock*target;161 BranchTarget target; 116 162 }; 117 163 … … 127 173 // care about manually. 128 174 SwitchData() 129 : fallThrough(0) 130 , kind(static_cast<SwitchKind>(-1)) 175 : kind(static_cast<SwitchKind>(-1)) 131 176 , switchTableIndex(UINT_MAX) 132 177 , didUseJumpTable(false) … … 134 179 } 135 180 136 void setFallThroughBytecodeIndex(unsigned bytecodeIndex)137 {138 fallThrough = bitwise_cast<BasicBlock*>(static_cast<uintptr_t>(bytecodeIndex));139 }140 unsigned fallThroughBytecodeIndex() const { return bitwise_cast<uintptr_t>(fallThrough); }141 142 181 Vector<SwitchCase> cases; 143 B asicBlock*fallThrough;182 BranchTarget fallThrough; 144 183 SwitchKind kind; 145 184 unsigned switchTableIndex; … … 820 859 } 821 860 822 unsigned ta kenBytecodeOffsetDuringParsing()823 { 824 ASSERT(is Branch() || isJump());861 unsigned targetBytecodeOffsetDuringParsing() 862 { 863 ASSERT(isJump()); 825 864 return m_opInfo; 826 865 } 827 866 828 unsigned notTakenBytecodeOffsetDuringParsing() 867 BasicBlock*& targetBlock() 868 { 869 ASSERT(isJump()); 870 return *bitwise_cast<BasicBlock**>(&m_opInfo); 871 } 872 873 BranchData* branchData() 829 874 { 830 875 ASSERT(isBranch()); 831 return m_opInfo2; 832 } 833 834 void setTakenBlock(BasicBlock* block) 835 { 836 ASSERT(isBranch() || isJump()); 837 m_opInfo = bitwise_cast<uintptr_t>(block); 838 } 839 840 void setNotTakenBlock(BasicBlock* block) 841 { 842 ASSERT(isBranch()); 843 m_opInfo2 = bitwise_cast<uintptr_t>(block); 844 } 845 846 BasicBlock*& takenBlock() 847 { 848 ASSERT(isBranch() || isJump()); 849 return *bitwise_cast<BasicBlock**>(&m_opInfo); 850 } 851 852 BasicBlock*& notTakenBlock() 853 { 854 ASSERT(isBranch()); 855 return *bitwise_cast<BasicBlock**>(&m_opInfo2); 876 return bitwise_cast<BranchData*>(m_opInfo); 856 877 } 857 878 … … 880 901 if (isSwitch()) { 881 902 if (index < switchData()->cases.size()) 882 return switchData()->cases[index].target ;903 return switchData()->cases[index].target.block; 883 904 RELEASE_ASSERT(index == switchData()->cases.size()); 884 return switchData()->fallThrough ;905 return switchData()->fallThrough.block; 885 906 } 886 907 switch (index) { 887 908 case 0: 888 return takenBlock(); 909 if (isJump()) 910 return targetBlock(); 911 return branchData()->taken.block; 889 912 case 1: 890 return notTakenBlock();913 return branchData()->notTaken.block; 891 914 default: 892 915 RELEASE_ASSERT_NOT_REACHED(); 893 return ta kenBlock();916 return targetBlock(); 894 917 } 895 918 } … … 897 920 BasicBlock*& successorForCondition(bool condition) 898 921 { 899 ASSERT(isBranch()); 900 return condition ? takenBlock() : notTakenBlock(); 922 return branchData()->forCondition(condition); 901 923 } 902 924
Note:
See TracChangeset
for help on using the changeset viewer.