| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 8446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8457 HInstruction* checked_index = | 8457 HInstruction* checked_index = |
| 8458 AddInstruction(new(zone()) HBoundsCheck(index, length)); | 8458 AddInstruction(new(zone()) HBoundsCheck(index, length)); |
| 8459 return new(zone()) HStringCharCodeAt(context, string, checked_index); | 8459 return new(zone()) HStringCharCodeAt(context, string, checked_index); |
| 8460 } | 8460 } |
| 8461 | 8461 |
| 8462 // Checks if the given shift amounts have form: (sa) and (32 - sa). | 8462 // Checks if the given shift amounts have form: (sa) and (32 - sa). |
| 8463 static bool ShiftAmountsAllowReplaceByRotate(HValue* sa, | 8463 static bool ShiftAmountsAllowReplaceByRotate(HValue* sa, |
| 8464 HValue* const32_minus_sa) { | 8464 HValue* const32_minus_sa) { |
| 8465 if (!const32_minus_sa->IsSub()) return false; | 8465 if (!const32_minus_sa->IsSub()) return false; |
| 8466 HSub* sub = HSub::cast(const32_minus_sa); | 8466 HSub* sub = HSub::cast(const32_minus_sa); |
| 8467 if (sa != sub->right()) return false; |
| 8467 HValue* const32 = sub->left(); | 8468 HValue* const32 = sub->left(); |
| 8468 if (!const32->IsConstant() || | 8469 if (!const32->IsConstant() || |
| 8469 HConstant::cast(const32)->Integer32Value() != 32) { | 8470 HConstant::cast(const32)->Integer32Value() != 32) { |
| 8470 return false; | 8471 return false; |
| 8471 } | 8472 } |
| 8472 return (sub->right() == sa); | 8473 return (sub->right() == sa); |
| 8473 } | 8474 } |
| 8474 | 8475 |
| 8475 | 8476 |
| 8476 // Checks if the left and the right are shift instructions with the oposite | 8477 // Checks if the left and the right are shift instructions with the oposite |
| 8477 // directions that can be replaced by one rotate right instruction or not. | 8478 // directions that can be replaced by one rotate right instruction or not. |
| 8478 // Returns the operand and the shift amount for the rotate instruction in the | 8479 // Returns the operand and the shift amount for the rotate instruction in the |
| 8479 // former case. | 8480 // former case. |
| 8480 bool HOptimizedGraphBuilder::MatchRotateRight(HValue* left, | 8481 bool HOptimizedGraphBuilder::MatchRotateRight(HValue* left, |
| 8481 HValue* right, | 8482 HValue* right, |
| 8482 HValue** operand, | 8483 HValue** operand, |
| 8483 HValue** shift_amount) { | 8484 HValue** shift_amount) { |
| 8484 HShl* shl; | 8485 HShl* shl; |
| 8485 HShr* shr; | 8486 HShr* shr; |
| 8486 if (left->IsShl() && right->IsShr()) { | 8487 if (left->IsShl() && right->IsShr()) { |
| 8487 shl = HShl::cast(left); | 8488 shl = HShl::cast(left); |
| 8488 shr = HShr::cast(right); | 8489 shr = HShr::cast(right); |
| 8489 } else if (left->IsShr() && right->IsShl()) { | 8490 } else if (left->IsShr() && right->IsShl()) { |
| 8490 shl = HShl::cast(right); | 8491 shl = HShl::cast(right); |
| 8491 shr = HShr::cast(left); | 8492 shr = HShr::cast(left); |
| 8492 } else { | 8493 } else { |
| 8493 return false; | 8494 return false; |
| 8494 } | 8495 } |
| 8496 if (shl->left() != shr->left()) return false; |
| 8495 | 8497 |
| 8496 if (!ShiftAmountsAllowReplaceByRotate(shl->right(), shr->right()) && | 8498 if (!ShiftAmountsAllowReplaceByRotate(shl->right(), shr->right()) && |
| 8497 !ShiftAmountsAllowReplaceByRotate(shr->right(), shl->right())) { | 8499 !ShiftAmountsAllowReplaceByRotate(shr->right(), shl->right())) { |
| 8498 return false; | 8500 return false; |
| 8499 } | 8501 } |
| 8500 *operand= shr->left(); | 8502 *operand= shr->left(); |
| 8501 *shift_amount = shr->right(); | 8503 *shift_amount = shr->right(); |
| 8502 return true; | 8504 return true; |
| 8503 } | 8505 } |
| 8504 | 8506 |
| (...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10301 } | 10303 } |
| 10302 } | 10304 } |
| 10303 | 10305 |
| 10304 #ifdef DEBUG | 10306 #ifdef DEBUG |
| 10305 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10307 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 10306 if (allocator_ != NULL) allocator_->Verify(); | 10308 if (allocator_ != NULL) allocator_->Verify(); |
| 10307 #endif | 10309 #endif |
| 10308 } | 10310 } |
| 10309 | 10311 |
| 10310 } } // namespace v8::internal | 10312 } } // namespace v8::internal |
| OLD | NEW |