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

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

Issue 14246039: Implements features to run "Hello, world!" on simulated MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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_MIPS) 10 #if defined(TARGET_ARCH_MIPS)
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 SimulatorDebugger dbg(this); 744 SimulatorDebugger dbg(this);
745 dbg.Stop(instr, buffer); 745 dbg.Stop(instr, buffer);
746 // The debugger will return control in non-interactive mode. 746 // The debugger will return control in non-interactive mode.
747 FATAL("Cannot continue execution after illegal memory access."); 747 FATAL("Cannot continue execution after illegal memory access.");
748 } 748 }
749 749
750 750
751 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) { 751 void Simulator::UnalignedAccess(const char* msg, uword addr, Instr* instr) {
752 // The debugger will not be able to single step past this instruction, but 752 // The debugger will not be able to single step past this instruction, but
753 // it will be possible to disassemble the code and inspect registers. 753 // it will be possible to disassemble the code and inspect registers.
754 char buffer[64]; 754 char buffer[128];
755 snprintf(buffer, sizeof(buffer), 755 snprintf(buffer, sizeof(buffer),
756 "unaligned %s at 0x%"Px", pc=%p\n", msg, addr, instr); 756 "pc=%p, unaligned %s at 0x%"Px"\n", instr, msg, addr);
757 SimulatorDebugger dbg(this); 757 SimulatorDebugger dbg(this);
758 dbg.Stop(instr, buffer); 758 dbg.Stop(instr, buffer);
759 // The debugger will return control in non-interactive mode. 759 // The debugger will return control in non-interactive mode.
760 FATAL("Cannot continue execution after unaligned access."); 760 FATAL("Cannot continue execution after unaligned access.");
761 } 761 }
762 762
763 763
764 // Returns the top of the stack area to enable checking for stack pointer 764 // Returns the top of the stack area to enable checking for stack pointer
765 // validity. 765 // validity.
766 uword Simulator::StackTop() const { 766 uword Simulator::StackTop() const {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 ASSERT(instr->OpcodeField() == SPECIAL); 898 ASSERT(instr->OpcodeField() == SPECIAL);
899 ASSERT(instr->FunctionField() == BREAK); 899 ASSERT(instr->FunctionField() == BREAK);
900 if (instr->BreakCodeField() == Instr::kStopMessageCode) { 900 if (instr->BreakCodeField() == Instr::kStopMessageCode) {
901 SimulatorDebugger dbg(this); 901 SimulatorDebugger dbg(this);
902 const char* message = *reinterpret_cast<const char**>( 902 const char* message = *reinterpret_cast<const char**>(
903 reinterpret_cast<intptr_t>(instr) - Instr::kInstrSize); 903 reinterpret_cast<intptr_t>(instr) - Instr::kInstrSize);
904 set_pc(get_pc() + Instr::kInstrSize); 904 set_pc(get_pc() + Instr::kInstrSize);
905 dbg.Stop(instr, message); 905 dbg.Stop(instr, message);
906 // Adjust for extra pc increment. 906 // Adjust for extra pc increment.
907 set_pc(get_pc() - Instr::kInstrSize); 907 set_pc(get_pc() - Instr::kInstrSize);
908 } else if (instr->BreakCodeField() == Instr::kMsgMessageCode) {
909 const char* message = *reinterpret_cast<const char**>(
910 reinterpret_cast<intptr_t>(instr) - Instr::kInstrSize);
911 if (FLAG_trace_sim) {
912 OS::Print("Message: %s\n", message);
913 } else {
914 OS::PrintErr("Bad break code: 0x%x\n", instr->InstructionBits());
915 UnimplementedInstruction(instr);
916 }
908 } else if (instr->BreakCodeField() == Instr::kRedirectCode) { 917 } else if (instr->BreakCodeField() == Instr::kRedirectCode) {
909 SimulatorSetjmpBuffer buffer(this); 918 SimulatorSetjmpBuffer buffer(this);
910 919
911 if (!setjmp(buffer.buffer_)) { 920 if (!setjmp(buffer.buffer_)) {
912 int32_t saved_ra = get_register(RA); 921 int32_t saved_ra = get_register(RA);
913 Redirection* redirection = Redirection::FromBreakInstruction(instr); 922 Redirection* redirection = Redirection::FromBreakInstruction(instr);
914 uword external = redirection->external_function(); 923 uword external = redirection->external_function();
915 if (FLAG_trace_sim) { 924 if (FLAG_trace_sim) {
916 OS::Print("Call to host function at 0x%"Pd"\n", external); 925 OS::Print("Call to host function at 0x%"Pd"\n", external);
917 } 926 }
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); 1878 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace));
1870 } 1879 }
1871 buf->Longjmp(); 1880 buf->Longjmp();
1872 } 1881 }
1873 1882
1874 } // namespace dart 1883 } // namespace dart
1875 1884
1876 #endif // !defined(HOST_ARCH_MIPS) 1885 #endif // !defined(HOST_ARCH_MIPS)
1877 1886
1878 #endif // defined TARGET_ARCH_MIPS 1887 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698