| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 namespace internal { | 31 namespace internal { |
| 32 | 32 |
| 33 static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) { | 33 static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) { |
| 34 HValue* index = array_operation->GetKey()->ActualValue(); | 34 HValue* index = array_operation->GetKey()->ActualValue(); |
| 35 if (!index->representation().IsSmiOrInteger32()) return; | 35 if (!index->representation().IsSmiOrInteger32()) return; |
| 36 if (!index->IsAdd() && !index->IsSub()) return; | 36 if (!index->IsAdd() && !index->IsSub()) return; |
| 37 | 37 |
| 38 HConstant* constant; | 38 HConstant* constant; |
| 39 HValue* subexpression; | 39 HValue* subexpression; |
| 40 HBinaryOperation* binary_operation = HBinaryOperation::cast(index); | 40 HBinaryOperation* binary_operation = HBinaryOperation::cast(index); |
| 41 if (binary_operation->left()->IsConstant()) { | 41 if (binary_operation->left()->IsConstant() && index->IsAdd()) { |
| 42 subexpression = binary_operation->right(); | 42 subexpression = binary_operation->right(); |
| 43 constant = HConstant::cast(binary_operation->left()); | 43 constant = HConstant::cast(binary_operation->left()); |
| 44 } else if (binary_operation->right()->IsConstant()) { | 44 } else if (binary_operation->right()->IsConstant()) { |
| 45 subexpression = binary_operation->left(); | 45 subexpression = binary_operation->left(); |
| 46 constant = HConstant::cast(binary_operation->right()); | 46 constant = HConstant::cast(binary_operation->right()); |
| 47 } else { | 47 } else { |
| 48 return; | 48 return; |
| 49 } | 49 } |
| 50 | 50 |
| 51 if (!constant->HasInteger32Value()) return; | 51 if (!constant->HasInteger32Value()) return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 71 if (instr->IsLoadKeyed()) { | 71 if (instr->IsLoadKeyed()) { |
| 72 DehoistArrayIndex(HLoadKeyed::cast(instr)); | 72 DehoistArrayIndex(HLoadKeyed::cast(instr)); |
| 73 } else if (instr->IsStoreKeyed()) { | 73 } else if (instr->IsStoreKeyed()) { |
| 74 DehoistArrayIndex(HStoreKeyed::cast(instr)); | 74 DehoistArrayIndex(HStoreKeyed::cast(instr)); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 } } // namespace v8::internal | 80 } } // namespace v8::internal |
| OLD | NEW |