| OLD | NEW | 
|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> | 
| 6 | 6 | 
| 7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" | 
| 8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" | 
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" | 
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" | 
| (...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2064                 cont->OverwriteAndNegateIfEqual(kOverflow); | 2064                 cont->OverwriteAndNegateIfEqual(kOverflow); | 
| 2065                 return VisitBinop(selector, node, kX64Sub, cont); | 2065                 return VisitBinop(selector, node, kX64Sub, cont); | 
| 2066               default: | 2066               default: | 
| 2067                 break; | 2067                 break; | 
| 2068             } | 2068             } | 
| 2069           } | 2069           } | 
| 2070         } | 2070         } | 
| 2071         break; | 2071         break; | 
| 2072       case IrOpcode::kInt32Sub: | 2072       case IrOpcode::kInt32Sub: | 
| 2073         return VisitWordCompare(selector, value, kX64Cmp32, cont); | 2073         return VisitWordCompare(selector, value, kX64Cmp32, cont); | 
| 2074       case IrOpcode::kInt64Sub: |  | 
| 2075         return VisitWord64Compare(selector, value, cont); |  | 
| 2076       case IrOpcode::kWord32And: | 2074       case IrOpcode::kWord32And: | 
| 2077         return VisitWordCompare(selector, value, kX64Test32, cont); | 2075         return VisitWordCompare(selector, value, kX64Test32, cont); | 
| 2078       case IrOpcode::kWord64And: |  | 
| 2079         return VisitWordCompare(selector, value, kX64Test, cont); |  | 
| 2080       default: | 2076       default: | 
| 2081         break; | 2077         break; | 
| 2082     } | 2078     } | 
| 2083   } | 2079   } | 
| 2084 | 2080 | 
| 2085   // Branch could not be combined with a compare, emit compare against 0. | 2081   // Branch could not be combined with a compare, emit compare against 0. | 
| 2086   VisitCompareZero(selector, value, kX64Cmp32, cont); | 2082   VisitCompareZero(selector, value, kX64Cmp32, cont); | 
| 2087 } | 2083 } | 
| 2088 | 2084 | 
| 2089 }  // namespace | 2085 }  // namespace | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2148   // Generate a sequence of conditional jumps. | 2144   // Generate a sequence of conditional jumps. | 
| 2149   return EmitLookupSwitch(sw, value_operand); | 2145   return EmitLookupSwitch(sw, value_operand); | 
| 2150 } | 2146 } | 
| 2151 | 2147 | 
| 2152 | 2148 | 
| 2153 void InstructionSelector::VisitWord32Equal(Node* const node) { | 2149 void InstructionSelector::VisitWord32Equal(Node* const node) { | 
| 2154   Node* user = node; | 2150   Node* user = node; | 
| 2155   FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); | 2151   FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); | 
| 2156   Int32BinopMatcher m(user); | 2152   Int32BinopMatcher m(user); | 
| 2157   if (m.right().Is(0)) { | 2153   if (m.right().Is(0)) { | 
| 2158     Node* value = m.left().node(); | 2154     return VisitWordCompareZero(this, m.node(), m.left().node(), &cont); | 
| 2159 |  | 
| 2160     // Try to combine with comparisons against 0 by simply inverting the branch. |  | 
| 2161     while (CanCover(user, value) && value->opcode() == IrOpcode::kWord32Equal) { |  | 
| 2162       Int32BinopMatcher m(value); |  | 
| 2163       if (m.right().Is(0)) { |  | 
| 2164         user = value; |  | 
| 2165         value = m.left().node(); |  | 
| 2166         cont.Negate(); |  | 
| 2167       } else { |  | 
| 2168         break; |  | 
| 2169       } |  | 
| 2170     } |  | 
| 2171 |  | 
| 2172     // Try to combine the branch with a comparison. |  | 
| 2173     if (CanCover(user, value)) { |  | 
| 2174       switch (value->opcode()) { |  | 
| 2175         case IrOpcode::kInt32Sub: |  | 
| 2176           return VisitWordCompare(this, value, kX64Cmp32, &cont); |  | 
| 2177         case IrOpcode::kWord32And: |  | 
| 2178           return VisitWordCompare(this, value, kX64Test32, &cont); |  | 
| 2179         default: |  | 
| 2180           break; |  | 
| 2181       } |  | 
| 2182     } |  | 
| 2183     return VisitCompareZero(this, value, kX64Cmp32, &cont); |  | 
| 2184   } | 2155   } | 
| 2185   VisitWordCompare(this, node, kX64Cmp32, &cont); | 2156   VisitWordCompare(this, node, kX64Cmp32, &cont); | 
| 2186 } | 2157 } | 
| 2187 | 2158 | 
| 2188 | 2159 | 
| 2189 void InstructionSelector::VisitInt32LessThan(Node* node) { | 2160 void InstructionSelector::VisitInt32LessThan(Node* node) { | 
| 2190   FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); | 2161   FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); | 
| 2191   VisitWordCompare(this, node, kX64Cmp32, &cont); | 2162   VisitWordCompare(this, node, kX64Cmp32, &cont); | 
| 2192 } | 2163 } | 
| 2193 | 2164 | 
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2481 // static | 2452 // static | 
| 2482 MachineOperatorBuilder::AlignmentRequirements | 2453 MachineOperatorBuilder::AlignmentRequirements | 
| 2483 InstructionSelector::AlignmentRequirements() { | 2454 InstructionSelector::AlignmentRequirements() { | 
| 2484   return MachineOperatorBuilder::AlignmentRequirements:: | 2455   return MachineOperatorBuilder::AlignmentRequirements:: | 
| 2485       FullUnalignedAccessSupport(); | 2456       FullUnalignedAccessSupport(); | 
| 2486 } | 2457 } | 
| 2487 | 2458 | 
| 2488 }  // namespace compiler | 2459 }  // namespace compiler | 
| 2489 }  // namespace internal | 2460 }  // namespace internal | 
| 2490 }  // namespace v8 | 2461 }  // namespace v8 | 
| OLD | NEW | 
|---|