OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 3776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3787 } | 3787 } |
3788 break; | 3788 break; |
3789 case DMULTU: | 3789 case DMULTU: |
3790 UNIMPLEMENTED_MIPS(); | 3790 UNIMPLEMENTED_MIPS(); |
3791 break; | 3791 break; |
3792 case DSLL: | 3792 case DSLL: |
3793 set_register(rd_reg, alu_out); | 3793 set_register(rd_reg, alu_out); |
3794 TraceRegWr(alu_out); | 3794 TraceRegWr(alu_out); |
3795 break; | 3795 break; |
3796 case DIV: | 3796 case DIV: |
3797 case DDIV: | 3797 case DDIV: { |
| 3798 const int64_t int_min_value = |
| 3799 instr->FunctionFieldRaw() == DIV ? INT_MIN : LONG_MIN; |
3798 switch (kArchVariant) { | 3800 switch (kArchVariant) { |
3799 case kMips64r2: | 3801 case kMips64r2: |
3800 // Divide by zero and overflow was not checked in the | 3802 // Divide by zero and overflow was not checked in the |
3801 // configuration step - div and divu do not raise exceptions. On | 3803 // configuration step - div and divu do not raise exceptions. On |
3802 // division by 0 the result will be UNPREDICTABLE. On overflow | 3804 // division by 0 the result will be UNPREDICTABLE. On overflow |
3803 // (INT_MIN/-1), return INT_MIN which is what the hardware does. | 3805 // (INT_MIN/-1), return INT_MIN which is what the hardware does. |
3804 if (rs == INT_MIN && rt == -1) { | 3806 if (rs == int_min_value && rt == -1) { |
3805 set_register(LO, INT_MIN); | 3807 set_register(LO, int_min_value); |
3806 set_register(HI, 0); | 3808 set_register(HI, 0); |
3807 } else if (rt != 0) { | 3809 } else if (rt != 0) { |
3808 set_register(LO, rs / rt); | 3810 set_register(LO, rs / rt); |
3809 set_register(HI, rs % rt); | 3811 set_register(HI, rs % rt); |
3810 } | 3812 } |
3811 break; | 3813 break; |
3812 case kMips64r6: | 3814 case kMips64r6: |
3813 switch (instr->SaValue()) { | 3815 switch (instr->SaValue()) { |
3814 case DIV_OP: | 3816 case DIV_OP: |
3815 if (rs == INT_MIN && rt == -1) { | 3817 if (rs == int_min_value && rt == -1) { |
3816 set_register(rd_reg, INT_MIN); | 3818 set_register(rd_reg, int_min_value); |
3817 } else if (rt != 0) { | 3819 } else if (rt != 0) { |
3818 set_register(rd_reg, rs / rt); | 3820 set_register(rd_reg, rs / rt); |
3819 } | 3821 } |
3820 break; | 3822 break; |
3821 case MOD_OP: | 3823 case MOD_OP: |
3822 if (rs == INT_MIN && rt == -1) { | 3824 if (rs == int_min_value && rt == -1) { |
3823 set_register(rd_reg, 0); | 3825 set_register(rd_reg, 0); |
3824 } else if (rt != 0) { | 3826 } else if (rt != 0) { |
3825 set_register(rd_reg, rs % rt); | 3827 set_register(rd_reg, rs % rt); |
3826 } | 3828 } |
3827 break; | 3829 break; |
3828 default: | 3830 default: |
3829 UNIMPLEMENTED_MIPS(); | 3831 UNIMPLEMENTED_MIPS(); |
3830 break; | 3832 break; |
3831 } | 3833 } |
3832 break; | 3834 break; |
3833 default: | 3835 default: |
3834 break; | 3836 break; |
3835 } | 3837 } |
3836 break; | 3838 break; |
| 3839 } |
3837 case DIVU: | 3840 case DIVU: |
3838 if (rt_u != 0) { | 3841 if (rt_u != 0) { |
3839 set_register(LO, rs_u / rt_u); | 3842 set_register(LO, rs_u / rt_u); |
3840 set_register(HI, rs_u % rt_u); | 3843 set_register(HI, rs_u % rt_u); |
3841 } | 3844 } |
3842 break; | 3845 break; |
3843 // Break and trap instructions. | 3846 // Break and trap instructions. |
3844 case BREAK: | 3847 case BREAK: |
3845 case TGE: | 3848 case TGE: |
3846 case TGEU: | 3849 case TGEU: |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4778 } | 4781 } |
4779 | 4782 |
4780 | 4783 |
4781 #undef UNSUPPORTED | 4784 #undef UNSUPPORTED |
4782 } // namespace internal | 4785 } // namespace internal |
4783 } // namespace v8 | 4786 } // namespace v8 |
4784 | 4787 |
4785 #endif // USE_SIMULATOR | 4788 #endif // USE_SIMULATOR |
4786 | 4789 |
4787 #endif // V8_TARGET_ARCH_MIPS64 | 4790 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |