OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
11 | 11 |
12 #if V8_TARGET_ARCH_MIPS | 12 #if V8_TARGET_ARCH_MIPS |
13 | 13 |
14 #include "src/assembler.h" | 14 #include "src/assembler.h" |
15 #include "src/cpu.h" | |
16 #include "src/disasm.h" | 15 #include "src/disasm.h" |
17 #include "src/globals.h" // Need the BitCast. | 16 #include "src/globals.h" // Need the BitCast. |
18 #include "src/mips/constants-mips.h" | 17 #include "src/mips/constants-mips.h" |
19 #include "src/mips/simulator-mips.h" | 18 #include "src/mips/simulator-mips.h" |
20 | 19 |
21 | 20 |
22 // Only build the simulator if not compiling for real MIPS hardware. | 21 // Only build the simulator if not compiling for real MIPS hardware. |
23 #if defined(USE_SIMULATOR) | 22 #if defined(USE_SIMULATOR) |
24 | 23 |
25 namespace v8 { | 24 namespace v8 { |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 559 } |
561 | 560 |
562 while (cur < end) { | 561 while (cur < end) { |
563 dasm.InstructionDecode(buffer, cur); | 562 dasm.InstructionDecode(buffer, cur); |
564 PrintF(" 0x%08x %s\n", | 563 PrintF(" 0x%08x %s\n", |
565 reinterpret_cast<intptr_t>(cur), buffer.start()); | 564 reinterpret_cast<intptr_t>(cur), buffer.start()); |
566 cur += Instruction::kInstrSize; | 565 cur += Instruction::kInstrSize; |
567 } | 566 } |
568 } else if (strcmp(cmd, "gdb") == 0) { | 567 } else if (strcmp(cmd, "gdb") == 0) { |
569 PrintF("relinquishing control to gdb\n"); | 568 PrintF("relinquishing control to gdb\n"); |
570 v8::internal::OS::DebugBreak(); | 569 v8::base::OS::DebugBreak(); |
571 PrintF("regaining control from gdb\n"); | 570 PrintF("regaining control from gdb\n"); |
572 } else if (strcmp(cmd, "break") == 0) { | 571 } else if (strcmp(cmd, "break") == 0) { |
573 if (argc == 2) { | 572 if (argc == 2) { |
574 int32_t value; | 573 int32_t value; |
575 if (GetValue(arg1, &value)) { | 574 if (GetValue(arg1, &value)) { |
576 if (!SetBreakpoint(reinterpret_cast<Instruction*>(value))) { | 575 if (!SetBreakpoint(reinterpret_cast<Instruction*>(value))) { |
577 PrintF("setting breakpoint failed\n"); | 576 PrintF("setting breakpoint failed\n"); |
578 } | 577 } |
579 } else { | 578 } else { |
580 PrintF("%s unrecognized\n", arg1); | 579 PrintF("%s unrecognized\n", arg1); |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 | 1236 |
1238 | 1237 |
1239 double Simulator::ReadD(int32_t addr, Instruction* instr) { | 1238 double Simulator::ReadD(int32_t addr, Instruction* instr) { |
1240 if ((addr & kDoubleAlignmentMask) == 0) { | 1239 if ((addr & kDoubleAlignmentMask) == 0) { |
1241 double* ptr = reinterpret_cast<double*>(addr); | 1240 double* ptr = reinterpret_cast<double*>(addr); |
1242 return *ptr; | 1241 return *ptr; |
1243 } | 1242 } |
1244 PrintF("Unaligned (double) read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1243 PrintF("Unaligned (double) read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1245 addr, | 1244 addr, |
1246 reinterpret_cast<intptr_t>(instr)); | 1245 reinterpret_cast<intptr_t>(instr)); |
1247 OS::Abort(); | 1246 base::OS::Abort(); |
1248 return 0; | 1247 return 0; |
1249 } | 1248 } |
1250 | 1249 |
1251 | 1250 |
1252 void Simulator::WriteD(int32_t addr, double value, Instruction* instr) { | 1251 void Simulator::WriteD(int32_t addr, double value, Instruction* instr) { |
1253 if ((addr & kDoubleAlignmentMask) == 0) { | 1252 if ((addr & kDoubleAlignmentMask) == 0) { |
1254 double* ptr = reinterpret_cast<double*>(addr); | 1253 double* ptr = reinterpret_cast<double*>(addr); |
1255 *ptr = value; | 1254 *ptr = value; |
1256 return; | 1255 return; |
1257 } | 1256 } |
1258 PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1257 PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1259 addr, | 1258 addr, |
1260 reinterpret_cast<intptr_t>(instr)); | 1259 reinterpret_cast<intptr_t>(instr)); |
1261 OS::Abort(); | 1260 base::OS::Abort(); |
1262 } | 1261 } |
1263 | 1262 |
1264 | 1263 |
1265 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { | 1264 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { |
1266 if ((addr & 1) == 0) { | 1265 if ((addr & 1) == 0) { |
1267 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1266 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
1268 return *ptr; | 1267 return *ptr; |
1269 } | 1268 } |
1270 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1269 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1271 addr, | 1270 addr, |
1272 reinterpret_cast<intptr_t>(instr)); | 1271 reinterpret_cast<intptr_t>(instr)); |
1273 OS::Abort(); | 1272 base::OS::Abort(); |
1274 return 0; | 1273 return 0; |
1275 } | 1274 } |
1276 | 1275 |
1277 | 1276 |
1278 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { | 1277 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { |
1279 if ((addr & 1) == 0) { | 1278 if ((addr & 1) == 0) { |
1280 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1279 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
1281 return *ptr; | 1280 return *ptr; |
1282 } | 1281 } |
1283 PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1282 PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1284 addr, | 1283 addr, |
1285 reinterpret_cast<intptr_t>(instr)); | 1284 reinterpret_cast<intptr_t>(instr)); |
1286 OS::Abort(); | 1285 base::OS::Abort(); |
1287 return 0; | 1286 return 0; |
1288 } | 1287 } |
1289 | 1288 |
1290 | 1289 |
1291 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { | 1290 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { |
1292 if ((addr & 1) == 0) { | 1291 if ((addr & 1) == 0) { |
1293 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1292 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
1294 *ptr = value; | 1293 *ptr = value; |
1295 return; | 1294 return; |
1296 } | 1295 } |
1297 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1296 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1298 addr, | 1297 addr, |
1299 reinterpret_cast<intptr_t>(instr)); | 1298 reinterpret_cast<intptr_t>(instr)); |
1300 OS::Abort(); | 1299 base::OS::Abort(); |
1301 } | 1300 } |
1302 | 1301 |
1303 | 1302 |
1304 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { | 1303 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { |
1305 if ((addr & 1) == 0) { | 1304 if ((addr & 1) == 0) { |
1306 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1305 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
1307 *ptr = value; | 1306 *ptr = value; |
1308 return; | 1307 return; |
1309 } | 1308 } |
1310 PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1309 PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1311 addr, | 1310 addr, |
1312 reinterpret_cast<intptr_t>(instr)); | 1311 reinterpret_cast<intptr_t>(instr)); |
1313 OS::Abort(); | 1312 base::OS::Abort(); |
1314 } | 1313 } |
1315 | 1314 |
1316 | 1315 |
1317 uint32_t Simulator::ReadBU(int32_t addr) { | 1316 uint32_t Simulator::ReadBU(int32_t addr) { |
1318 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); | 1317 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); |
1319 return *ptr & 0xff; | 1318 return *ptr & 0xff; |
1320 } | 1319 } |
1321 | 1320 |
1322 | 1321 |
1323 int32_t Simulator::ReadB(int32_t addr) { | 1322 int32_t Simulator::ReadB(int32_t addr) { |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2850 set_register(a0, va_arg(parameters, int32_t)); | 2849 set_register(a0, va_arg(parameters, int32_t)); |
2851 set_register(a1, va_arg(parameters, int32_t)); | 2850 set_register(a1, va_arg(parameters, int32_t)); |
2852 set_register(a2, va_arg(parameters, int32_t)); | 2851 set_register(a2, va_arg(parameters, int32_t)); |
2853 set_register(a3, va_arg(parameters, int32_t)); | 2852 set_register(a3, va_arg(parameters, int32_t)); |
2854 | 2853 |
2855 // Remaining arguments passed on stack. | 2854 // Remaining arguments passed on stack. |
2856 int original_stack = get_register(sp); | 2855 int original_stack = get_register(sp); |
2857 // Compute position of stack on entry to generated code. | 2856 // Compute position of stack on entry to generated code. |
2858 int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t) | 2857 int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t) |
2859 - kCArgsSlotsSize); | 2858 - kCArgsSlotsSize); |
2860 if (OS::ActivationFrameAlignment() != 0) { | 2859 if (base::OS::ActivationFrameAlignment() != 0) { |
2861 entry_stack &= -OS::ActivationFrameAlignment(); | 2860 entry_stack &= -base::OS::ActivationFrameAlignment(); |
2862 } | 2861 } |
2863 // Store remaining arguments on stack, from low to high memory. | 2862 // Store remaining arguments on stack, from low to high memory. |
2864 intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack); | 2863 intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack); |
2865 for (int i = 4; i < argument_count; i++) { | 2864 for (int i = 4; i < argument_count; i++) { |
2866 stack_argument[i - 4 + kCArgSlotCount] = va_arg(parameters, int32_t); | 2865 stack_argument[i - 4 + kCArgSlotCount] = va_arg(parameters, int32_t); |
2867 } | 2866 } |
2868 va_end(parameters); | 2867 va_end(parameters); |
2869 set_register(sp, entry_stack); | 2868 set_register(sp, entry_stack); |
2870 | 2869 |
2871 CallInternal(entry); | 2870 CallInternal(entry); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2918 } | 2917 } |
2919 | 2918 |
2920 | 2919 |
2921 #undef UNSUPPORTED | 2920 #undef UNSUPPORTED |
2922 | 2921 |
2923 } } // namespace v8::internal | 2922 } } // namespace v8::internal |
2924 | 2923 |
2925 #endif // USE_SIMULATOR | 2924 #endif // USE_SIMULATOR |
2926 | 2925 |
2927 #endif // V8_TARGET_ARCH_MIPS | 2926 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |