Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: runtime/vm/simulator_arm.cc

Issue 14784011: Fixes for integer division on ARM hardware so that assembler tests pass. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 ASSERT(instr->Bits(21, 2) == 0x1); 1475 ASSERT(instr->Bits(21, 2) == 0x1);
1476 // Format(instr, "blx'cond 'rm"); 1476 // Format(instr, "blx'cond 'rm");
1477 Register rm = instr->RmField(); 1477 Register rm = instr->RmField();
1478 int32_t rm_val = get_register(rm); 1478 int32_t rm_val = get_register(rm);
1479 intptr_t pc = get_pc(); 1479 intptr_t pc = get_pc();
1480 set_register(LR, pc + Instr::kInstrSize); 1480 set_register(LR, pc + Instr::kInstrSize);
1481 set_pc(rm_val); 1481 set_pc(rm_val);
1482 break; 1482 break;
1483 } 1483 }
1484 case 7: { 1484 case 7: {
1485 if (instr->Bits(21, 2) == 0x1) { 1485 if ((instr->Bits(21, 2) == 0x1) && (instr->ConditionField() == AL)) {
1486 // Format(instr, "bkpt'cond #'imm12_4"); 1486 // Format(instr, "bkpt'cond #'imm12_4");
regis 2013/05/07 17:14:35 Remove 'cond.
zra 2013/05/07 17:50:18 Done.
1487 SimulatorDebugger dbg(this); 1487 SimulatorDebugger dbg(this);
1488 set_pc(get_pc() + Instr::kInstrSize); 1488 set_pc(get_pc() + Instr::kInstrSize);
1489 char buffer[32]; 1489 char buffer[32];
1490 snprintf(buffer, sizeof(buffer), "bkpt #0x%x", instr->BkptField()); 1490 snprintf(buffer, sizeof(buffer), "bkpt #0x%x", instr->BkptField());
1491 dbg.Stop(instr, buffer); 1491 dbg.Stop(instr, buffer);
1492 } else { 1492 } else {
1493 // Format(instr, "smc'cond"); 1493 // Format(instr, "smc'cond");
1494 UnimplementedInstruction(instr); 1494 UnimplementedInstruction(instr);
1495 } 1495 }
1496 break; 1496 break;
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 } else { 2060 } else {
2061 WriteW(addr, get_register(rd), instr); 2061 WriteW(addr, get_register(rd), instr);
2062 } 2062 }
2063 } 2063 }
2064 } 2064 }
2065 } 2065 }
2066 2066
2067 2067
2068 void Simulator::DoDivision(Instr* instr) { 2068 void Simulator::DoDivision(Instr* instr) {
2069 ASSERT(CPUFeatures::integer_division_supported()); 2069 ASSERT(CPUFeatures::integer_division_supported());
2070 Register rd = instr->RdField(); 2070 Register rd = instr->DivRdField();
2071 Register rn = instr->RnField(); 2071 Register rn = instr->DivRnField();
2072 Register rm = instr->RmField(); 2072 Register rm = instr->DivRmField();
2073 2073
2074 // TODO(zra): Does the hardware trap on divide-by-zero? 2074 // ARMv7-a does not trap on divide-by-zero. The destination register is just
2075 // Revisit when we test on ARM hardware. 2075 // set to 0.
2076 if (get_register(rm) == 0) { 2076 if (get_register(rm) == 0) {
2077 set_register(rd, 0); 2077 set_register(rd, 0);
2078 return; 2078 return;
2079 } 2079 }
2080 2080
2081 if (instr->Bit(21) == 1) { 2081 if (instr->Bit(21) == 1) {
2082 // unsigned division. 2082 // unsigned division.
2083 uint32_t rn_val = static_cast<uint32_t>(get_register(rn)); 2083 uint32_t rn_val = static_cast<uint32_t>(get_register(rn));
2084 uint32_t rm_val = static_cast<uint32_t>(get_register(rm)); 2084 uint32_t rm_val = static_cast<uint32_t>(get_register(rm));
2085 uint32_t result = rn_val / rm_val; 2085 uint32_t result = rn_val / rm_val;
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); 2922 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace));
2923 } 2923 }
2924 buf->Longjmp(); 2924 buf->Longjmp();
2925 } 2925 }
2926 2926
2927 } // namespace dart 2927 } // namespace dart
2928 2928
2929 #endif // !defined(HOST_ARCH_ARM) 2929 #endif // !defined(HOST_ARCH_ARM)
2930 2930
2931 #endif // defined TARGET_ARCH_ARM 2931 #endif // defined TARGET_ARCH_ARM
OLDNEW
« runtime/vm/disassembler_arm.cc ('K') | « runtime/vm/disassembler_arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698