Chromium Code Reviews| 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 <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
| 6 #include <setjmp.h> | 6 #include <setjmp.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #if defined(TARGET_ARCH_ARM) | 10 #if defined(TARGET_ARCH_ARM) |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1989 if (instr->HasL()) { | 1989 if (instr->HasL()) { |
| 1990 set_register(rd, ReadW(addr, instr)); | 1990 set_register(rd, ReadW(addr, instr)); |
| 1991 } else { | 1991 } else { |
| 1992 WriteW(addr, get_register(rd), instr); | 1992 WriteW(addr, get_register(rd), instr); |
| 1993 } | 1993 } |
| 1994 } | 1994 } |
| 1995 } | 1995 } |
| 1996 } | 1996 } |
| 1997 | 1997 |
| 1998 | 1998 |
| 1999 void Simulator::DoDivision(Instr* instr) { | |
| 2000 ASSERT(CPUFeatures::integer_division_supported()); | |
| 2001 Register rd = instr->RdField(); | |
| 2002 Register rn = instr->RnField(); | |
| 2003 Register rm = instr->RmField(); | |
|
regis
2013/03/05 19:11:34
You need to test if rm is zero. In that case, the
| |
| 2004 if (instr->Bit(21) == 1) { | |
| 2005 // unsigned division. | |
| 2006 uint32_t rn_val = static_cast<uint32_t>(get_register(rn)); | |
| 2007 uint32_t rm_val = static_cast<uint32_t>(get_register(rm)); | |
| 2008 uint32_t result = rn_val / rm_val; | |
| 2009 set_register(rd, static_cast<int32_t>(result)); | |
| 2010 } else { | |
| 2011 // signed division. | |
| 2012 int32_t rn_val = get_register(rn); | |
| 2013 int32_t rm_val = get_register(rm); | |
| 2014 int32_t result = rn_val / rm_val; | |
| 2015 set_register(rd, result); | |
| 2016 } | |
| 2017 } | |
| 2018 | |
| 2019 | |
| 1999 void Simulator::DecodeType3(Instr* instr) { | 2020 void Simulator::DecodeType3(Instr* instr) { |
| 2021 if (instr->IsDivision()) { | |
| 2022 DoDivision(instr); | |
| 2023 return; | |
| 2024 } | |
| 2000 Register rd = instr->RdField(); | 2025 Register rd = instr->RdField(); |
| 2001 Register rn = instr->RnField(); | 2026 Register rn = instr->RnField(); |
| 2002 int32_t rn_val = get_register(rn); | 2027 int32_t rn_val = get_register(rn); |
| 2003 bool shifter_carry_out = 0; | 2028 bool shifter_carry_out = 0; |
| 2004 int32_t shifter_operand = GetShiftRm(instr, &shifter_carry_out); | 2029 int32_t shifter_operand = GetShiftRm(instr, &shifter_carry_out); |
| 2005 uword addr = 0; | 2030 uword addr = 0; |
| 2006 bool write_back = false; | 2031 bool write_back = false; |
| 2007 switch (instr->PUField()) { | 2032 switch (instr->PUField()) { |
| 2008 case 0: { | 2033 case 0: { |
| 2009 // Format(instr, "'memop'cond'b 'rd, ['rn], -'shift_rm"); | 2034 // Format(instr, "'memop'cond'b 'rd, ['rn], -'shift_rm"); |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2807 // isolate->ChangeStateToGeneratedCode(); | 2832 // isolate->ChangeStateToGeneratedCode(); |
| 2808 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); | 2833 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); |
| 2809 buf->Longjmp(); | 2834 buf->Longjmp(); |
| 2810 } | 2835 } |
| 2811 | 2836 |
| 2812 } // namespace dart | 2837 } // namespace dart |
| 2813 | 2838 |
| 2814 #endif // !defined(HOST_ARCH_ARM) | 2839 #endif // !defined(HOST_ARCH_ARM) |
| 2815 | 2840 |
| 2816 #endif // defined TARGET_ARCH_ARM | 2841 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |