| 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 return dregisters_[reg]; | 783 return dregisters_[reg]; |
| 784 } | 784 } |
| 785 | 785 |
| 786 | 786 |
| 787 void Simulator::HandleIllegalAccess(uword addr, Instr* instr) { | 787 void Simulator::HandleIllegalAccess(uword addr, Instr* instr) { |
| 788 uword fault_pc = get_pc(); | 788 uword fault_pc = get_pc(); |
| 789 // The debugger will not be able to single step past this instruction, but | 789 // The debugger will not be able to single step past this instruction, but |
| 790 // it will be possible to disassemble the code and inspect registers. | 790 // it will be possible to disassemble the code and inspect registers. |
| 791 char buffer[128]; | 791 char buffer[128]; |
| 792 snprintf(buffer, sizeof(buffer), | 792 snprintf(buffer, sizeof(buffer), |
| 793 "illegal memory access at 0x%x, pc=0x%x\n", | 793 "illegal memory access at 0x%"Px", pc=0x%"Px"\n", |
| 794 addr, fault_pc); | 794 addr, fault_pc); |
| 795 SimulatorDebugger dbg(this); | 795 SimulatorDebugger dbg(this); |
| 796 dbg.Stop(instr, buffer); | 796 dbg.Stop(instr, buffer); |
| 797 // The debugger will return control in non-interactive mode. | 797 // The debugger will return control in non-interactive mode. |
| 798 FATAL("Cannot continue execution after illegal memory access."); | 798 FATAL("Cannot continue execution after illegal memory access."); |
| 799 } | 799 } |
| 800 | 800 |
| 801 | 801 |
| 802 // Processor versions prior to ARMv7 could not do unaligned reads and writes. | 802 // Processor versions prior to ARMv7 could not do unaligned reads and writes. |
| 803 // On some ARM platforms an interrupt is caused. On others it does a funky | 803 // On some ARM platforms an interrupt is caused. On others it does a funky |
| 804 // rotation thing. However, from version v7, unaligned access is supported. | 804 // rotation thing. However, from version v7, unaligned access is supported. |
| 805 // Note that simulator runs have the runtime system running directly on the host | 805 // Note that simulator runs have the runtime system running directly on the host |
| 806 // system and only generated code is executed in the simulator. Since the host | 806 // system and only generated code is executed in the simulator. Since the host |
| 807 // is typically IA32 we will get the correct ARMv7-like behaviour on unaligned | 807 // is typically IA32 we will get the correct ARMv7-like behaviour on unaligned |
| 808 // accesses, but we should actually not generate code accessing unaligned data, | 808 // accesses, but we should actually not generate code accessing unaligned data, |
| 809 // so we still want to know and abort if we encounter such code. | 809 // so we still want to know and abort if we encounter such code. |
| 810 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) { | 810 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) { |
| 811 // The debugger will not be able to single step past this instruction, but | 811 // The debugger will not be able to single step past this instruction, but |
| 812 // it will be possible to disassemble the code and inspect registers. | 812 // it will be possible to disassemble the code and inspect registers. |
| 813 char buffer[64]; | 813 char buffer[64]; |
| 814 snprintf(buffer, sizeof(buffer), | 814 snprintf(buffer, sizeof(buffer), |
| 815 "unaligned %s at 0x%x, pc=%p\n", msg, addr, instr); | 815 "unaligned %s at 0x%"Px", pc=%p\n", msg, addr, instr); |
| 816 SimulatorDebugger dbg(this); | 816 SimulatorDebugger dbg(this); |
| 817 dbg.Stop(instr, buffer); | 817 dbg.Stop(instr, buffer); |
| 818 // The debugger will return control in non-interactive mode. | 818 // The debugger will return control in non-interactive mode. |
| 819 FATAL("Cannot continue execution after unaligned access."); | 819 FATAL("Cannot continue execution after unaligned access."); |
| 820 } | 820 } |
| 821 | 821 |
| 822 | 822 |
| 823 int Simulator::ReadW(uword addr, Instr* instr) { | 823 int Simulator::ReadW(uword addr, Instr* instr) { |
| 824 static StatsCounter counter_read_w("Simulated word reads"); | 824 static StatsCounter counter_read_w("Simulated word reads"); |
| 825 counter_read_w.Increment(); | 825 counter_read_w.Increment(); |
| (...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2730 // isolate->ChangeStateToGeneratedCode(); | 2730 // isolate->ChangeStateToGeneratedCode(); |
| 2731 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); | 2731 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); |
| 2732 buf->Longjmp(); | 2732 buf->Longjmp(); |
| 2733 } | 2733 } |
| 2734 | 2734 |
| 2735 } // namespace dart | 2735 } // namespace dart |
| 2736 | 2736 |
| 2737 #endif // !defined(HOST_ARCH_ARM) | 2737 #endif // !defined(HOST_ARCH_ARM) |
| 2738 | 2738 |
| 2739 #endif // defined TARGET_ARCH_ARM | 2739 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |