OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 case MULT: | 2267 case MULT: |
2268 set_register(LO, static_cast<int32_t>(i64hilo & 0xffffffff)); | 2268 set_register(LO, static_cast<int32_t>(i64hilo & 0xffffffff)); |
2269 set_register(HI, static_cast<int32_t>(i64hilo >> 32)); | 2269 set_register(HI, static_cast<int32_t>(i64hilo >> 32)); |
2270 break; | 2270 break; |
2271 case MULTU: | 2271 case MULTU: |
2272 set_register(LO, static_cast<int32_t>(u64hilo & 0xffffffff)); | 2272 set_register(LO, static_cast<int32_t>(u64hilo & 0xffffffff)); |
2273 set_register(HI, static_cast<int32_t>(u64hilo >> 32)); | 2273 set_register(HI, static_cast<int32_t>(u64hilo >> 32)); |
2274 break; | 2274 break; |
2275 case DIV: | 2275 case DIV: |
2276 // Divide by zero and overflow was not checked in the configuration | 2276 // Divide by zero and overflow was not checked in the configuration |
2277 // step - div and divu do not raise exceptions. On division by 0 and | 2277 // step - div and divu do not raise exceptions. On division by 0 |
2278 // on overflow (INT_MIN/-1), the result will be UNPREDICTABLE. | 2278 // the result will be UNPREDICTABLE. On overflow (INT_MIN/-1), |
2279 if (rt != 0 && !(rs == INT_MIN && rt == -1)) { | 2279 // return INT_MIN which is what the hardware does. |
| 2280 if (rs == INT_MIN && rt == -1) { |
| 2281 set_register(LO, INT_MIN); |
| 2282 set_register(HI, 0); |
| 2283 } else if (rt != 0) { |
2280 set_register(LO, rs / rt); | 2284 set_register(LO, rs / rt); |
2281 set_register(HI, rs % rt); | 2285 set_register(HI, rs % rt); |
2282 } | 2286 } |
2283 break; | 2287 break; |
2284 case DIVU: | 2288 case DIVU: |
2285 if (rt_u != 0) { | 2289 if (rt_u != 0) { |
2286 set_register(LO, rs_u / rt_u); | 2290 set_register(LO, rs_u / rt_u); |
2287 set_register(HI, rs_u % rt_u); | 2291 set_register(HI, rs_u % rt_u); |
2288 } | 2292 } |
2289 break; | 2293 break; |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2917 } | 2921 } |
2918 | 2922 |
2919 | 2923 |
2920 #undef UNSUPPORTED | 2924 #undef UNSUPPORTED |
2921 | 2925 |
2922 } } // namespace v8::internal | 2926 } } // namespace v8::internal |
2923 | 2927 |
2924 #endif // USE_SIMULATOR | 2928 #endif // USE_SIMULATOR |
2925 | 2929 |
2926 #endif // V8_TARGET_ARCH_MIPS | 2930 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |