| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 2618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 __ sllv(result, left, TMP); | 2629 __ sllv(result, left, TMP); |
| 2630 } | 2630 } |
| 2631 return; | 2631 return; |
| 2632 } | 2632 } |
| 2633 | 2633 |
| 2634 const bool right_needs_check = | 2634 const bool right_needs_check = |
| 2635 (right_range == NULL) || !right_range->IsWithin(0, (Smi::kBits - 1)); | 2635 (right_range == NULL) || !right_range->IsWithin(0, (Smi::kBits - 1)); |
| 2636 if (is_truncating) { | 2636 if (is_truncating) { |
| 2637 if (right_needs_check) { | 2637 if (right_needs_check) { |
| 2638 const bool right_may_be_negative = | 2638 const bool right_may_be_negative = |
| 2639 (right_range == NULL) || | 2639 (right_range == NULL) || right_range->IsNegative(); |
| 2640 !right_range->IsWithin(0, RangeBoundary::kPlusInfinity); | |
| 2641 if (right_may_be_negative) { | 2640 if (right_may_be_negative) { |
| 2642 ASSERT(shift_left->CanDeoptimize()); | 2641 ASSERT(shift_left->CanDeoptimize()); |
| 2643 __ bltz(right, deopt); | 2642 __ bltz(right, deopt); |
| 2644 } | 2643 } |
| 2645 Label done, is_not_zero; | 2644 Label done, is_not_zero; |
| 2646 | 2645 |
| 2647 __ sltiu(CMPRES1, | 2646 __ sltiu(CMPRES1, |
| 2648 right, Immediate(reinterpret_cast<int32_t>(Smi::New(Smi::kBits)))); | 2647 right, Immediate(reinterpret_cast<int32_t>(Smi::New(Smi::kBits)))); |
| 2649 __ movz(result, ZR, CMPRES1); // result = right >= kBits ? 0 : result. | 2648 __ movz(result, ZR, CMPRES1); // result = right >= kBits ? 0 : result. |
| 2650 __ sra(TMP, right, kSmiTagSize); | 2649 __ sra(TMP, right, kSmiTagSize); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 // } | 2969 // } |
| 2971 Label done; | 2970 Label done; |
| 2972 __ bgez(result, &done); | 2971 __ bgez(result, &done); |
| 2973 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) { | 2972 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) { |
| 2974 Label subtract; | 2973 Label subtract; |
| 2975 __ bltz(right, &subtract); | 2974 __ bltz(right, &subtract); |
| 2976 __ addu(result, result, TMP); | 2975 __ addu(result, result, TMP); |
| 2977 __ b(&done); | 2976 __ b(&done); |
| 2978 __ Bind(&subtract); | 2977 __ Bind(&subtract); |
| 2979 __ subu(result, result, TMP); | 2978 __ subu(result, result, TMP); |
| 2980 } else if (right_range->IsWithin(0, RangeBoundary::kPlusInfinity)) { | 2979 } else if (right_range->IsPositive()) { |
| 2981 // Right is positive. | 2980 // Right is positive. |
| 2982 __ addu(result, result, TMP); | 2981 __ addu(result, result, TMP); |
| 2983 } else { | 2982 } else { |
| 2984 // Right is negative. | 2983 // Right is negative. |
| 2985 __ subu(result, result, TMP); | 2984 __ subu(result, result, TMP); |
| 2986 } | 2985 } |
| 2987 __ Bind(&done); | 2986 __ Bind(&done); |
| 2988 __ SmiTag(result); | 2987 __ SmiTag(result); |
| 2989 break; | 2988 break; |
| 2990 } | 2989 } |
| 2991 case Token::kSHR: { | 2990 case Token::kSHR: { |
| 2992 Register temp = locs()->temp(0).reg(); | 2991 Register temp = locs()->temp(0).reg(); |
| 2993 if (CanDeoptimize()) { | 2992 if (CanDeoptimize()) { |
| 2994 __ bltz(right, deopt); | 2993 __ bltz(right, deopt); |
| 2995 } | 2994 } |
| 2996 __ SmiUntag(temp, right); | 2995 __ SmiUntag(temp, right); |
| 2997 // sra operation masks the count to 5 bits. | 2996 // sra operation masks the count to 5 bits. |
| 2998 const intptr_t kCountLimit = 0x1F; | 2997 const intptr_t kCountLimit = 0x1F; |
| 2999 if ((right_range == NULL) || | 2998 if ((right_range == NULL) || |
| 3000 !right_range->IsWithin(RangeBoundary::kMinusInfinity, kCountLimit)) { | 2999 !right_range->OnlyLessThanOrEqualTo(kCountLimit)) { |
| 3001 Label ok; | 3000 Label ok; |
| 3002 __ BranchSignedLessEqual(temp, kCountLimit, &ok); | 3001 __ BranchSignedLessEqual(temp, kCountLimit, &ok); |
| 3003 __ LoadImmediate(temp, kCountLimit); | 3002 __ LoadImmediate(temp, kCountLimit); |
| 3004 __ Bind(&ok); | 3003 __ Bind(&ok); |
| 3005 } | 3004 } |
| 3006 | 3005 |
| 3007 __ SmiUntag(CMPRES1, left); | 3006 __ SmiUntag(CMPRES1, left); |
| 3008 __ srav(result, CMPRES1, temp); | 3007 __ srav(result, CMPRES1, temp); |
| 3009 __ SmiTag(result); | 3008 __ SmiTag(result); |
| 3010 break; | 3009 break; |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4189 // } | 4188 // } |
| 4190 Label done; | 4189 Label done; |
| 4191 __ bgez(result_mod, &done); | 4190 __ bgez(result_mod, &done); |
| 4192 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) { | 4191 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) { |
| 4193 Label subtract; | 4192 Label subtract; |
| 4194 __ bltz(right, &subtract); | 4193 __ bltz(right, &subtract); |
| 4195 __ addu(result_mod, result_mod, TMP); | 4194 __ addu(result_mod, result_mod, TMP); |
| 4196 __ b(&done); | 4195 __ b(&done); |
| 4197 __ Bind(&subtract); | 4196 __ Bind(&subtract); |
| 4198 __ subu(result_mod, result_mod, TMP); | 4197 __ subu(result_mod, result_mod, TMP); |
| 4199 } else if (right_range->IsWithin(0, RangeBoundary::kPlusInfinity)) { | 4198 } else if (right_range->IsPositive()) { |
| 4200 // Right is positive. | 4199 // Right is positive. |
| 4201 __ addu(result_mod, result_mod, TMP); | 4200 __ addu(result_mod, result_mod, TMP); |
| 4202 } else { | 4201 } else { |
| 4203 // Right is negative. | 4202 // Right is negative. |
| 4204 __ subu(result_mod, result_mod, TMP); | 4203 __ subu(result_mod, result_mod, TMP); |
| 4205 } | 4204 } |
| 4206 __ Bind(&done); | 4205 __ Bind(&done); |
| 4207 | 4206 |
| 4208 __ SmiTag(result_div); | 4207 __ SmiTag(result_div); |
| 4209 __ SmiTag(result_mod); | 4208 __ SmiTag(result_mod); |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4678 compiler->GenerateCall(token_pos(), | 4677 compiler->GenerateCall(token_pos(), |
| 4679 &label, | 4678 &label, |
| 4680 PcDescriptors::kOther, | 4679 PcDescriptors::kOther, |
| 4681 locs()); | 4680 locs()); |
| 4682 __ Drop(ArgumentCount()); // Discard arguments. | 4681 __ Drop(ArgumentCount()); // Discard arguments. |
| 4683 } | 4682 } |
| 4684 | 4683 |
| 4685 } // namespace dart | 4684 } // namespace dart |
| 4686 | 4685 |
| 4687 #endif // defined TARGET_ARCH_MIPS | 4686 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |