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

Side by Side Diff: src/mips/simulator-mips.cc

Issue 6965006: Update mips infrastructure files. (Closed) Base URL: http://github.com/v8/v8.git@bleeding_edge
Patch Set: Fix additional style issues. Created 9 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
(...skipping 16 matching lines...) Expand all
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <math.h> 29 #include <math.h>
30 #include <limits.h> 30 #include <limits.h>
31 #include <cstdarg> 31 #include <cstdarg>
32 #include "v8.h" 32 #include "v8.h"
33 33
34 #if defined(V8_TARGET_ARCH_MIPS) 34 #if defined(V8_TARGET_ARCH_MIPS)
35 35
36 #include "disasm.h" 36 #include "disasm.h"
37 #include "assembler.h" 37 #include "assembler.h"
38 #include "globals.h" // Need the BitCast 38 #include "globals.h" // Need the BitCast.
39 #include "mips/constants-mips.h" 39 #include "mips/constants-mips.h"
40 #include "mips/simulator-mips.h" 40 #include "mips/simulator-mips.h"
41 41
42 42
43 // Only build the simulator if not compiling for real MIPS hardware. 43 // Only build the simulator if not compiling for real MIPS hardware.
44 #if defined(USE_SIMULATOR) 44 #if defined(USE_SIMULATOR)
45 45
46 namespace v8 { 46 namespace v8 {
47 namespace internal { 47 namespace internal {
48 48
49 // Utils functions 49 // Utils functions.
50 bool HaveSameSign(int32_t a, int32_t b) { 50 bool HaveSameSign(int32_t a, int32_t b) {
51 return ((a ^ b) >= 0); 51 return ((a ^ b) >= 0);
52 } 52 }
53 53
54 54
55 uint32_t get_fcsr_condition_bit(uint32_t cc) { 55 uint32_t get_fcsr_condition_bit(uint32_t cc) {
56 if (cc == 0) { 56 if (cc == 0) {
57 return 23; 57 return 23;
58 } else { 58 } else {
59 return 24 + cc; 59 return 24 + cc;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (coverage_log != NULL) { 132 if (coverage_log != NULL) {
133 fprintf(coverage_log, "%s\n", str); 133 fprintf(coverage_log, "%s\n", str);
134 fflush(coverage_log); 134 fflush(coverage_log);
135 } 135 }
136 instr->SetInstructionBits(0x0); // Overwrite with nop. 136 instr->SetInstructionBits(0x0); // Overwrite with nop.
137 } 137 }
138 sim_->set_pc(sim_->get_pc() + Instruction::kInstrSize); 138 sim_->set_pc(sim_->get_pc() + Instruction::kInstrSize);
139 } 139 }
140 140
141 141
142 #else // ndef GENERATED_CODE_COVERAGE 142 #else // GENERATED_CODE_COVERAGE
143 143
144 #define UNSUPPORTED() printf("Unsupported instruction.\n"); 144 #define UNSUPPORTED() printf("Unsupported instruction.\n");
145 145
146 static void InitializeCoverage() {} 146 static void InitializeCoverage() {}
147 147
148 148
149 void MipsDebugger::Stop(Instruction* instr) { 149 void MipsDebugger::Stop(Instruction* instr) {
150 const char* str = reinterpret_cast<char*>(instr->InstructionBits()); 150 const char* str = reinterpret_cast<char*>(instr->InstructionBits());
151 PrintF("Simulator hit %s\n", str); 151 PrintF("Simulator hit %s\n", str);
152 sim_->set_pc(sim_->get_pc() + Instruction::kInstrSize); 152 sim_->set_pc(sim_->get_pc() + Instruction::kInstrSize);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (sim_->break_pc_ != NULL) { 256 if (sim_->break_pc_ != NULL) {
257 sim_->break_pc_->SetInstructionBits(kBreakpointInstr); 257 sim_->break_pc_->SetInstructionBits(kBreakpointInstr);
258 } 258 }
259 } 259 }
260 260
261 261
262 void MipsDebugger::PrintAllRegs() { 262 void MipsDebugger::PrintAllRegs() {
263 #define REG_INFO(n) Registers::Name(n), GetRegisterValue(n), GetRegisterValue(n) 263 #define REG_INFO(n) Registers::Name(n), GetRegisterValue(n), GetRegisterValue(n)
264 264
265 PrintF("\n"); 265 PrintF("\n");
266 // at, v0, a0 266 // at, v0, a0.
267 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n", 267 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
268 REG_INFO(1), REG_INFO(2), REG_INFO(4)); 268 REG_INFO(1), REG_INFO(2), REG_INFO(4));
269 // v1, a1 269 // v1, a1.
270 PrintF("%26s\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n", 270 PrintF("%26s\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
271 "", REG_INFO(3), REG_INFO(5)); 271 "", REG_INFO(3), REG_INFO(5));
272 // a2 272 // a2.
273 PrintF("%26s\t%26s\t%3s: 0x%08x %10d\n", "", "", REG_INFO(6)); 273 PrintF("%26s\t%26s\t%3s: 0x%08x %10d\n", "", "", REG_INFO(6));
274 // a3 274 // a3.
275 PrintF("%26s\t%26s\t%3s: 0x%08x %10d\n", "", "", REG_INFO(7)); 275 PrintF("%26s\t%26s\t%3s: 0x%08x %10d\n", "", "", REG_INFO(7));
276 PrintF("\n"); 276 PrintF("\n");
277 // t0-t7, s0-s7 277 // t0-t7, s0-s7
278 for (int i = 0; i < 8; i++) { 278 for (int i = 0; i < 8; i++) {
279 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n", 279 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
280 REG_INFO(8+i), REG_INFO(16+i)); 280 REG_INFO(8+i), REG_INFO(16+i));
281 } 281 }
282 PrintF("\n"); 282 PrintF("\n");
283 // t8, k0, LO 283 // t8, k0, LO.
284 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n", 284 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
285 REG_INFO(24), REG_INFO(26), REG_INFO(32)); 285 REG_INFO(24), REG_INFO(26), REG_INFO(32));
286 // t9, k1, HI 286 // t9, k1, HI.
287 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n", 287 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
288 REG_INFO(25), REG_INFO(27), REG_INFO(33)); 288 REG_INFO(25), REG_INFO(27), REG_INFO(33));
289 // sp, fp, gp 289 // sp, fp, gp.
290 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n", 290 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
291 REG_INFO(29), REG_INFO(30), REG_INFO(28)); 291 REG_INFO(29), REG_INFO(30), REG_INFO(28));
292 // pc 292 // pc.
293 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n", 293 PrintF("%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n",
294 REG_INFO(31), REG_INFO(34)); 294 REG_INFO(31), REG_INFO(34));
295 295
296 #undef REG_INFO 296 #undef REG_INFO
297 #undef FPU_REG_INFO 297 #undef FPU_REG_INFO
298 } 298 }
299 299
300 300
301 void MipsDebugger::PrintAllRegsIncludingFPU() { 301 void MipsDebugger::PrintAllRegsIncludingFPU() {
302 #define FPU_REG_INFO(n) FPURegisters::Name(n), FPURegisters::Name(n+1), \ 302 #define FPU_REG_INFO(n) FPURegisters::Name(n), FPURegisters::Name(n+1), \
303 GetFPURegisterValueInt(n+1), \ 303 GetFPURegisterValueInt(n+1), \
304 GetFPURegisterValueInt(n), \ 304 GetFPURegisterValueInt(n), \
305 GetFPURegisterValueDouble(n) 305 GetFPURegisterValueDouble(n)
306 306
307 PrintAllRegs(); 307 PrintAllRegs();
308 308
309 PrintF("\n\n"); 309 PrintF("\n\n");
310 // f0, f1, f2, ... f31 310 // f0, f1, f2, ... f31.
311 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(0) ); 311 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(0) );
312 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(2) ); 312 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(2) );
313 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(4) ); 313 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(4) );
314 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(6) ); 314 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(6) );
315 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(8) ); 315 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(8) );
316 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(10)); 316 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(10));
317 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(12)); 317 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(12));
318 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(14)); 318 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(14));
319 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(16)); 319 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(16));
320 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(18)); 320 PrintF("%3s,%3s: 0x%08x%08x %16.4e\n", FPU_REG_INFO(18));
(...skipping 17 matching lines...) Expand all
338 #define ARG_SIZE 255 338 #define ARG_SIZE 255
339 339
340 #define STR(a) #a 340 #define STR(a) #a
341 #define XSTR(a) STR(a) 341 #define XSTR(a) STR(a)
342 342
343 char cmd[COMMAND_SIZE + 1]; 343 char cmd[COMMAND_SIZE + 1];
344 char arg1[ARG_SIZE + 1]; 344 char arg1[ARG_SIZE + 1];
345 char arg2[ARG_SIZE + 1]; 345 char arg2[ARG_SIZE + 1];
346 char* argv[3] = { cmd, arg1, arg2 }; 346 char* argv[3] = { cmd, arg1, arg2 };
347 347
348 // make sure to have a proper terminating character if reaching the limit 348 // Make sure to have a proper terminating character if reaching the limit.
349 cmd[COMMAND_SIZE] = 0; 349 cmd[COMMAND_SIZE] = 0;
350 arg1[ARG_SIZE] = 0; 350 arg1[ARG_SIZE] = 0;
351 arg2[ARG_SIZE] = 0; 351 arg2[ARG_SIZE] = 0;
352 352
353 // Undo all set breakpoints while running in the debugger shell. This will 353 // Undo all set breakpoints while running in the debugger shell. This will
354 // make them invisible to all commands. 354 // make them invisible to all commands.
355 UndoBreakpoints(); 355 UndoBreakpoints();
356 356
357 while (!done && (sim_->get_pc() != Simulator::end_sim_pc)) { 357 while (!done && (sim_->get_pc() != Simulator::end_sim_pc)) {
358 if (last_pc != sim_->get_pc()) { 358 if (last_pc != sim_->get_pc()) {
359 disasm::NameConverter converter; 359 disasm::NameConverter converter;
360 disasm::Disassembler dasm(converter); 360 disasm::Disassembler dasm(converter);
361 // use a reasonably large buffer 361 // Use a reasonably large buffer.
362 v8::internal::EmbeddedVector<char, 256> buffer; 362 v8::internal::EmbeddedVector<char, 256> buffer;
363 dasm.InstructionDecode(buffer, 363 dasm.InstructionDecode(buffer,
364 reinterpret_cast<byte_*>(sim_->get_pc())); 364 reinterpret_cast<byte*>(sim_->get_pc()));
365 PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start()); 365 PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start());
366 last_pc = sim_->get_pc(); 366 last_pc = sim_->get_pc();
367 } 367 }
368 char* line = ReadLine("sim> "); 368 char* line = ReadLine("sim> ");
369 if (line == NULL) { 369 if (line == NULL) {
370 break; 370 break;
371 } else { 371 } else {
372 // Use sscanf to parse the individual parts of the command line. At the 372 // Use sscanf to parse the individual parts of the command line. At the
373 // moment no command expects more than two parameters. 373 // moment no command expects more than two parameters.
374 int argc = SScanF(line, 374 int argc = SScanF(line,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } else { 468 } else {
469 PrintF("printobject <value>\n"); 469 PrintF("printobject <value>\n");
470 } 470 }
471 } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) { 471 } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
472 int32_t* cur = NULL; 472 int32_t* cur = NULL;
473 int32_t* end = NULL; 473 int32_t* end = NULL;
474 int next_arg = 1; 474 int next_arg = 1;
475 475
476 if (strcmp(cmd, "stack") == 0) { 476 if (strcmp(cmd, "stack") == 0) {
477 cur = reinterpret_cast<int32_t*>(sim_->get_register(Simulator::sp)); 477 cur = reinterpret_cast<int32_t*>(sim_->get_register(Simulator::sp));
478 } else { // "mem" 478 } else { // Command "mem".
479 int32_t value; 479 int32_t value;
480 if (!GetValue(arg1, &value)) { 480 if (!GetValue(arg1, &value)) {
481 PrintF("%s unrecognized\n", arg1); 481 PrintF("%s unrecognized\n", arg1);
482 continue; 482 continue;
483 } 483 }
484 cur = reinterpret_cast<int32_t*>(value); 484 cur = reinterpret_cast<int32_t*>(value);
485 next_arg++; 485 next_arg++;
486 } 486 }
487 487
488 int32_t words; 488 int32_t words;
489 if (argc == next_arg) { 489 if (argc == next_arg) {
490 words = 10; 490 words = 10;
491 } else if (argc == next_arg + 1) { 491 } else if (argc == next_arg + 1) {
492 if (!GetValue(argv[next_arg], &words)) { 492 if (!GetValue(argv[next_arg], &words)) {
493 words = 10; 493 words = 10;
494 } 494 }
495 } 495 }
496 end = cur + words; 496 end = cur + words;
497 497
498 while (cur < end) { 498 while (cur < end) {
499 PrintF(" 0x%08x: 0x%08x %10d\n", 499 PrintF(" 0x%08x: 0x%08x %10d\n",
500 reinterpret_cast<intptr_t>(cur), *cur, *cur); 500 reinterpret_cast<intptr_t>(cur), *cur, *cur);
501 cur++; 501 cur++;
502 } 502 }
503 503
504 } else if ((strcmp(cmd, "disasm") == 0) || (strcmp(cmd, "dpc") == 0)) { 504 } else if ((strcmp(cmd, "disasm") == 0) || (strcmp(cmd, "dpc") == 0)) {
505 disasm::NameConverter converter; 505 disasm::NameConverter converter;
506 disasm::Disassembler dasm(converter); 506 disasm::Disassembler dasm(converter);
507 // use a reasonably large buffer 507 // Use a reasonably large buffer.
508 v8::internal::EmbeddedVector<char, 256> buffer; 508 v8::internal::EmbeddedVector<char, 256> buffer;
509 509
510 byte_* cur = NULL; 510 byte* cur = NULL;
511 byte_* end = NULL; 511 byte* end = NULL;
512 512
513 if (argc == 1) { 513 if (argc == 1) {
514 cur = reinterpret_cast<byte_*>(sim_->get_pc()); 514 cur = reinterpret_cast<byte*>(sim_->get_pc());
515 end = cur + (10 * Instruction::kInstrSize); 515 end = cur + (10 * Instruction::kInstrSize);
516 } else if (argc == 2) { 516 } else if (argc == 2) {
517 int32_t value; 517 int32_t value;
518 if (GetValue(arg1, &value)) { 518 if (GetValue(arg1, &value)) {
519 cur = reinterpret_cast<byte_*>(value); 519 cur = reinterpret_cast<byte*>(value);
520 // no length parameter passed, assume 10 instructions 520 // No length parameter passed, assume 10 instructions.
521 end = cur + (10 * Instruction::kInstrSize); 521 end = cur + (10 * Instruction::kInstrSize);
522 } 522 }
523 } else { 523 } else {
524 int32_t value1; 524 int32_t value1;
525 int32_t value2; 525 int32_t value2;
526 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { 526 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) {
527 cur = reinterpret_cast<byte_*>(value1); 527 cur = reinterpret_cast<byte*>(value1);
528 end = cur + (value2 * Instruction::kInstrSize); 528 end = cur + (value2 * Instruction::kInstrSize);
529 } 529 }
530 } 530 }
531 531
532 while (cur < end) { 532 while (cur < end) {
533 dasm.InstructionDecode(buffer, cur); 533 dasm.InstructionDecode(buffer, cur);
534 PrintF(" 0x%08x %s\n", 534 PrintF(" 0x%08x %s\n",
535 reinterpret_cast<intptr_t>(cur), buffer.start()); 535 reinterpret_cast<intptr_t>(cur), buffer.start());
536 cur += Instruction::kInstrSize; 536 cur += Instruction::kInstrSize;
537 } 537 }
(...skipping 16 matching lines...) Expand all
554 } 554 }
555 } else if (strcmp(cmd, "del") == 0) { 555 } else if (strcmp(cmd, "del") == 0) {
556 if (!DeleteBreakpoint(NULL)) { 556 if (!DeleteBreakpoint(NULL)) {
557 PrintF("deleting breakpoint failed\n"); 557 PrintF("deleting breakpoint failed\n");
558 } 558 }
559 } else if (strcmp(cmd, "flags") == 0) { 559 } else if (strcmp(cmd, "flags") == 0) {
560 PrintF("No flags on MIPS !\n"); 560 PrintF("No flags on MIPS !\n");
561 } else if (strcmp(cmd, "unstop") == 0) { 561 } else if (strcmp(cmd, "unstop") == 0) {
562 PrintF("Unstop command not implemented on MIPS."); 562 PrintF("Unstop command not implemented on MIPS.");
563 } else if ((strcmp(cmd, "stat") == 0) || (strcmp(cmd, "st") == 0)) { 563 } else if ((strcmp(cmd, "stat") == 0) || (strcmp(cmd, "st") == 0)) {
564 // Print registers and disassemble 564 // Print registers and disassemble.
565 PrintAllRegs(); 565 PrintAllRegs();
566 PrintF("\n"); 566 PrintF("\n");
567 567
568 disasm::NameConverter converter; 568 disasm::NameConverter converter;
569 disasm::Disassembler dasm(converter); 569 disasm::Disassembler dasm(converter);
570 // use a reasonably large buffer 570 // Use a reasonably large buffer.
571 v8::internal::EmbeddedVector<char, 256> buffer; 571 v8::internal::EmbeddedVector<char, 256> buffer;
572 572
573 byte_* cur = NULL; 573 byte* cur = NULL;
574 byte_* end = NULL; 574 byte* end = NULL;
575 575
576 if (argc == 1) { 576 if (argc == 1) {
577 cur = reinterpret_cast<byte_*>(sim_->get_pc()); 577 cur = reinterpret_cast<byte*>(sim_->get_pc());
578 end = cur + (10 * Instruction::kInstrSize); 578 end = cur + (10 * Instruction::kInstrSize);
579 } else if (argc == 2) { 579 } else if (argc == 2) {
580 int32_t value; 580 int32_t value;
581 if (GetValue(arg1, &value)) { 581 if (GetValue(arg1, &value)) {
582 cur = reinterpret_cast<byte_*>(value); 582 cur = reinterpret_cast<byte*>(value);
583 // no length parameter passed, assume 10 instructions 583 // no length parameter passed, assume 10 instructions
584 end = cur + (10 * Instruction::kInstrSize); 584 end = cur + (10 * Instruction::kInstrSize);
585 } 585 }
586 } else { 586 } else {
587 int32_t value1; 587 int32_t value1;
588 int32_t value2; 588 int32_t value2;
589 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { 589 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) {
590 cur = reinterpret_cast<byte_*>(value1); 590 cur = reinterpret_cast<byte*>(value1);
591 end = cur + (value2 * Instruction::kInstrSize); 591 end = cur + (value2 * Instruction::kInstrSize);
592 } 592 }
593 } 593 }
594 594
595 while (cur < end) { 595 while (cur < end) {
596 dasm.InstructionDecode(buffer, cur); 596 dasm.InstructionDecode(buffer, cur);
597 PrintF(" 0x%08x %s\n", 597 PrintF(" 0x%08x %s\n",
598 reinterpret_cast<intptr_t>(cur), buffer.start()); 598 reinterpret_cast<intptr_t>(cur), buffer.start());
599 cur += Instruction::kInstrSize; 599 cur += Instruction::kInstrSize;
600 } 600 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 offset = 0; 682 offset = 0;
683 } 683 }
684 if (size != 0) { 684 if (size != 0) {
685 FlushOnePage(i_cache, start, size); 685 FlushOnePage(i_cache, start, size);
686 } 686 }
687 } 687 }
688 688
689 689
690 CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) { 690 CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
691 v8::internal::HashMap::Entry* entry = i_cache->Lookup(page, 691 v8::internal::HashMap::Entry* entry = i_cache->Lookup(page,
692 ICacheHash(page), 692 ICacheHash(page),
693 true); 693 true);
694 if (entry->value == NULL) { 694 if (entry->value == NULL) {
695 CachePage* new_page = new CachePage(); 695 CachePage* new_page = new CachePage();
696 entry->value = new_page; 696 entry->value = new_page;
697 } 697 }
698 return reinterpret_cast<CachePage*>(entry->value); 698 return reinterpret_cast<CachePage*>(entry->value);
699 } 699 }
700 700
701 701
702 // Flush from start up to and not including start + size. 702 // Flush from start up to and not including start + size.
703 void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, 703 void Simulator::FlushOnePage(v8::internal::HashMap* i_cache,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 748
749 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { 749 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
750 i_cache_ = isolate_->simulator_i_cache(); 750 i_cache_ = isolate_->simulator_i_cache();
751 if (i_cache_ == NULL) { 751 if (i_cache_ == NULL) {
752 i_cache_ = new v8::internal::HashMap(&ICacheMatch); 752 i_cache_ = new v8::internal::HashMap(&ICacheMatch);
753 isolate_->set_simulator_i_cache(i_cache_); 753 isolate_->set_simulator_i_cache(i_cache_);
754 } 754 }
755 Initialize(isolate); 755 Initialize(isolate);
756 // Setup simulator support first. Some of this information is needed to 756 // Setup simulator support first. Some of this information is needed to
757 // setup the architecture state. 757 // setup the architecture state.
758 stack_size_ = 1 * 1024*1024; // allocate 1MB for stack
759 stack_ = reinterpret_cast<char*>(malloc(stack_size_)); 758 stack_ = reinterpret_cast<char*>(malloc(stack_size_));
760 pc_modified_ = false; 759 pc_modified_ = false;
761 icount_ = 0; 760 icount_ = 0;
762 break_count_ = 0; 761 break_count_ = 0;
763 break_pc_ = NULL; 762 break_pc_ = NULL;
764 break_instr_ = 0; 763 break_instr_ = 0;
765 764
766 // Setup architecture state. 765 // Setup architecture state.
767 // All registers are initialized to zero to start with. 766 // All registers are initialized to zero to start with.
768 for (int i = 0; i < kNumSimuRegisters; i++) { 767 for (int i = 0; i < kNumSimuRegisters; i++) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 867
869 868
870 // Sets the register in the architecture state. It will also deal with updating 869 // Sets the register in the architecture state. It will also deal with updating
871 // Simulator internal state for special registers such as PC. 870 // Simulator internal state for special registers such as PC.
872 void Simulator::set_register(int reg, int32_t value) { 871 void Simulator::set_register(int reg, int32_t value) {
873 ASSERT((reg >= 0) && (reg < kNumSimuRegisters)); 872 ASSERT((reg >= 0) && (reg < kNumSimuRegisters));
874 if (reg == pc) { 873 if (reg == pc) {
875 pc_modified_ = true; 874 pc_modified_ = true;
876 } 875 }
877 876
878 // zero register always hold 0. 877 // Zero register always holds 0.
879 registers_[reg] = (reg == 0) ? 0 : value; 878 registers_[reg] = (reg == 0) ? 0 : value;
880 } 879 }
881 880
882 881
883 void Simulator::set_fpu_register(int fpureg, int32_t value) { 882 void Simulator::set_fpu_register(int fpureg, int32_t value) {
884 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters)); 883 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters));
885 FPUregisters_[fpureg] = value; 884 FPUregisters_[fpureg] = value;
886 } 885 }
887 886
888 887
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 // The MIPS cannot do unaligned reads and writes. On some MIPS platforms an 985 // The MIPS cannot do unaligned reads and writes. On some MIPS platforms an
987 // interrupt is caused. On others it does a funky rotation thing. For now we 986 // interrupt is caused. On others it does a funky rotation thing. For now we
988 // simply disallow unaligned reads, but at some point we may want to move to 987 // simply disallow unaligned reads, but at some point we may want to move to
989 // emulating the rotate behaviour. Note that simulator runs have the runtime 988 // emulating the rotate behaviour. Note that simulator runs have the runtime
990 // system running directly on the host system and only generated code is 989 // system running directly on the host system and only generated code is
991 // executed in the simulator. Since the host is typically IA32 we will not 990 // executed in the simulator. Since the host is typically IA32 we will not
992 // get the correct MIPS-like behaviour on unaligned accesses. 991 // get the correct MIPS-like behaviour on unaligned accesses.
993 992
994 int Simulator::ReadW(int32_t addr, Instruction* instr) { 993 int Simulator::ReadW(int32_t addr, Instruction* instr) {
995 if (addr >=0 && addr < 0x400) { 994 if (addr >=0 && addr < 0x400) {
996 // this has to be a NULL-dereference 995 // This has to be a NULL-dereference, drop into debugger.
997 MipsDebugger dbg(this); 996 MipsDebugger dbg(this);
998 dbg.Debug(); 997 dbg.Debug();
999 } 998 }
1000 if ((addr & kPointerAlignmentMask) == 0) { 999 if ((addr & kPointerAlignmentMask) == 0) {
1001 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); 1000 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1002 return *ptr; 1001 return *ptr;
1003 } 1002 }
1004 PrintF("Unaligned read at 0x%08x, pc=%p\n", addr, 1003 PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1005 reinterpret_cast<void*>(instr)); 1004 addr,
1005 reinterpret_cast<intptr_t>(instr));
1006 MipsDebugger dbg(this); 1006 MipsDebugger dbg(this);
1007 dbg.Debug(); 1007 dbg.Debug();
1008 return 0; 1008 return 0;
1009 } 1009 }
1010 1010
1011 1011
1012 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { 1012 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) {
1013 if (addr >= 0 && addr < 0x400) { 1013 if (addr >= 0 && addr < 0x400) {
1014 // this has to be a NULL-dereference 1014 // This has to be a NULL-dereference, drop into debugger.
1015 MipsDebugger dbg(this); 1015 MipsDebugger dbg(this);
1016 dbg.Debug(); 1016 dbg.Debug();
1017 } 1017 }
1018 if ((addr & kPointerAlignmentMask) == 0) { 1018 if ((addr & kPointerAlignmentMask) == 0) {
1019 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); 1019 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
1020 *ptr = value; 1020 *ptr = value;
1021 return; 1021 return;
1022 } 1022 }
1023 PrintF("Unaligned write at 0x%08x, pc=%p\n", addr, 1023 PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1024 reinterpret_cast<void*>(instr)); 1024 addr,
1025 reinterpret_cast<intptr_t>(instr));
1025 MipsDebugger dbg(this); 1026 MipsDebugger dbg(this);
1026 dbg.Debug(); 1027 dbg.Debug();
1027 } 1028 }
1028 1029
1029 1030
1030 double Simulator::ReadD(int32_t addr, Instruction* instr) { 1031 double Simulator::ReadD(int32_t addr, Instruction* instr) {
1031 if ((addr & kDoubleAlignmentMask) == 0) { 1032 if ((addr & kDoubleAlignmentMask) == 0) {
1032 double* ptr = reinterpret_cast<double*>(addr); 1033 double* ptr = reinterpret_cast<double*>(addr);
1033 return *ptr; 1034 return *ptr;
1034 } 1035 }
1035 PrintF("Unaligned (double) read at 0x%08x, pc=%p\n", addr, 1036 PrintF("Unaligned (double) read at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1036 reinterpret_cast<void*>(instr)); 1037 addr,
1038 reinterpret_cast<intptr_t>(instr));
1037 OS::Abort(); 1039 OS::Abort();
1038 return 0; 1040 return 0;
1039 } 1041 }
1040 1042
1041 1043
1042 void Simulator::WriteD(int32_t addr, double value, Instruction* instr) { 1044 void Simulator::WriteD(int32_t addr, double value, Instruction* instr) {
1043 if ((addr & kDoubleAlignmentMask) == 0) { 1045 if ((addr & kDoubleAlignmentMask) == 0) {
1044 double* ptr = reinterpret_cast<double*>(addr); 1046 double* ptr = reinterpret_cast<double*>(addr);
1045 *ptr = value; 1047 *ptr = value;
1046 return; 1048 return;
1047 } 1049 }
1048 PrintF("Unaligned (double) write at 0x%08x, pc=%p\n", addr, 1050 PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1049 reinterpret_cast<void*>(instr)); 1051 addr,
1052 reinterpret_cast<intptr_t>(instr));
1050 OS::Abort(); 1053 OS::Abort();
1051 } 1054 }
1052 1055
1053 1056
1054 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { 1057 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) {
1055 if ((addr & 1) == 0) { 1058 if ((addr & 1) == 0) {
1056 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); 1059 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1057 return *ptr; 1060 return *ptr;
1058 } 1061 }
1059 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=%p\n", addr, 1062 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1060 reinterpret_cast<void*>(instr)); 1063 addr,
1064 reinterpret_cast<intptr_t>(instr));
1061 OS::Abort(); 1065 OS::Abort();
1062 return 0; 1066 return 0;
1063 } 1067 }
1064 1068
1065 1069
1066 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { 1070 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) {
1067 if ((addr & 1) == 0) { 1071 if ((addr & 1) == 0) {
1068 int16_t* ptr = reinterpret_cast<int16_t*>(addr); 1072 int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1069 return *ptr; 1073 return *ptr;
1070 } 1074 }
1071 PrintF("Unaligned signed halfword read at 0x%08x, pc=%p\n", addr, 1075 PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1072 reinterpret_cast<void*>(instr)); 1076 addr,
1077 reinterpret_cast<intptr_t>(instr));
1073 OS::Abort(); 1078 OS::Abort();
1074 return 0; 1079 return 0;
1075 } 1080 }
1076 1081
1077 1082
1078 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { 1083 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) {
1079 if ((addr & 1) == 0) { 1084 if ((addr & 1) == 0) {
1080 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); 1085 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
1081 *ptr = value; 1086 *ptr = value;
1082 return; 1087 return;
1083 } 1088 }
1084 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=%p\n", addr, 1089 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1085 reinterpret_cast<void*>(instr)); 1090 addr,
1091 reinterpret_cast<intptr_t>(instr));
1086 OS::Abort(); 1092 OS::Abort();
1087 } 1093 }
1088 1094
1089 1095
1090 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { 1096 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) {
1091 if ((addr & 1) == 0) { 1097 if ((addr & 1) == 0) {
1092 int16_t* ptr = reinterpret_cast<int16_t*>(addr); 1098 int16_t* ptr = reinterpret_cast<int16_t*>(addr);
1093 *ptr = value; 1099 *ptr = value;
1094 return; 1100 return;
1095 } 1101 }
1096 PrintF("Unaligned halfword write at 0x%08x, pc=%p\n", addr, 1102 PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n",
1097 reinterpret_cast<void*>(instr)); 1103 addr,
1104 reinterpret_cast<intptr_t>(instr));
1098 OS::Abort(); 1105 OS::Abort();
1099 } 1106 }
1100 1107
1101 1108
1102 uint32_t Simulator::ReadBU(int32_t addr) { 1109 uint32_t Simulator::ReadBU(int32_t addr) {
1103 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); 1110 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
1104 return *ptr & 0xff; 1111 return *ptr & 0xff;
1105 } 1112 }
1106 1113
1107 1114
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 int32_t arg1, 1156 int32_t arg1,
1150 int32_t arg2, 1157 int32_t arg2,
1151 int32_t arg3, 1158 int32_t arg3,
1152 int32_t arg4, 1159 int32_t arg4,
1153 int32_t arg5); 1160 int32_t arg5);
1154 typedef double (*SimulatorRuntimeFPCall)(int32_t arg0, 1161 typedef double (*SimulatorRuntimeFPCall)(int32_t arg0,
1155 int32_t arg1, 1162 int32_t arg1,
1156 int32_t arg2, 1163 int32_t arg2,
1157 int32_t arg3); 1164 int32_t arg3);
1158 1165
1166 // This signature supports direct call in to API function native callback
1167 // (refer to InvocationCallback in v8.h).
1168 typedef v8::Handle<v8::Value> (*SimulatorRuntimeApiCall)(int32_t arg0);
1169
1159 // Software interrupt instructions are used by the simulator to call into the 1170 // Software interrupt instructions are used by the simulator to call into the
1160 // C-based V8 runtime. They are also used for debugging with simulator. 1171 // C-based V8 runtime. They are also used for debugging with simulator.
1161 void Simulator::SoftwareInterrupt(Instruction* instr) { 1172 void Simulator::SoftwareInterrupt(Instruction* instr) {
1162 // There are several instructions that could get us here, 1173 // There are several instructions that could get us here,
1163 // the break_ instruction, or several variants of traps. All 1174 // the break_ instruction, or several variants of traps. All
1164 // Are "SPECIAL" class opcode, and are distinuished by function. 1175 // Are "SPECIAL" class opcode, and are distinuished by function.
1165 int32_t func = instr->FunctionFieldRaw(); 1176 int32_t func = instr->FunctionFieldRaw();
1166 int32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1; 1177 int32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1;
1167 1178
1168 // We first check if we met a call_rt_redirected. 1179 // We first check if we met a call_rt_redirected.
1169 if (instr->InstructionBits() == rtCallRedirInstr) { 1180 if (instr->InstructionBits() == rtCallRedirInstr) {
1170 // Check if stack is aligned. Error if not aligned is reported below to
1171 // include information on the function called.
1172 bool stack_aligned =
1173 (get_register(sp)
1174 & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0;
1175 Redirection* redirection = Redirection::FromSwiInstruction(instr); 1181 Redirection* redirection = Redirection::FromSwiInstruction(instr);
1176 int32_t arg0 = get_register(a0); 1182 int32_t arg0 = get_register(a0);
1177 int32_t arg1 = get_register(a1); 1183 int32_t arg1 = get_register(a1);
1178 int32_t arg2 = get_register(a2); 1184 int32_t arg2 = get_register(a2);
1179 int32_t arg3 = get_register(a3); 1185 int32_t arg3 = get_register(a3);
1180 int32_t arg4 = 0; 1186 int32_t arg4 = 0;
1181 int32_t arg5 = 0; 1187 int32_t arg5 = 0;
1182 1188
1183 // Need to check if sp is valid before assigning arg4, arg5. 1189 // Need to check if sp is valid before assigning arg4, arg5.
1184 // This is a fix for cctest test-api/CatchStackOverflow which causes 1190 // This is a fix for cctest test-api/CatchStackOverflow which causes
1185 // the stack to overflow. For some reason arm doesn't need this 1191 // the stack to overflow. For some reason arm doesn't need this
1186 // stack check here. 1192 // stack check here.
1187 int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp)); 1193 int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp));
1188 int32_t* stack = reinterpret_cast<int32_t*>(stack_); 1194 int32_t* stack = reinterpret_cast<int32_t*>(stack_);
1189 if (stack_pointer >= stack && stack_pointer < stack + stack_size_) { 1195 if (stack_pointer >= stack && stack_pointer < stack + stack_size_ - 5) {
1190 arg4 = stack_pointer[0]; 1196 // Args 4 and 5 are on the stack after the reserved space for args 0..3.
1191 arg5 = stack_pointer[1]; 1197 arg4 = stack_pointer[4];
1198 arg5 = stack_pointer[5];
1192 } 1199 }
1200
1201 bool fp_call =
1202 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) ||
1203 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) ||
1204 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) ||
1205 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL);
1206
1193 // This is dodgy but it works because the C entry stubs are never moved. 1207 // This is dodgy but it works because the C entry stubs are never moved.
1194 // See comment in codegen-arm.cc and bug 1242173. 1208 // See comment in codegen-arm.cc and bug 1242173.
1195 int32_t saved_ra = get_register(ra); 1209 int32_t saved_ra = get_register(ra);
1196 1210
1197 intptr_t external = 1211 intptr_t external =
1198 reinterpret_cast<int32_t>(redirection->external_function()); 1212 reinterpret_cast<intptr_t>(redirection->external_function());
1199 1213
1200 // Based on CpuFeatures::IsSupported(FPU), Mips will use either hardware 1214 // Based on CpuFeatures::IsSupported(FPU), Mips will use either hardware
1201 // FPU, or gcc soft-float routines. Hardware FPU is simulated in this 1215 // FPU, or gcc soft-float routines. Hardware FPU is simulated in this
1202 // simulator. Soft-float has additional abstraction of ExternalReference, 1216 // simulator. Soft-float has additional abstraction of ExternalReference,
1203 // to support serialization. Finally, when simulated on x86 host, the 1217 // to support serialization. Finally, when simulated on x86 host, the
1204 // x86 softfloat routines are used, and this Redirection infrastructure 1218 // x86 softfloat routines are used, and this Redirection infrastructure
1205 // lets simulated-mips make calls into x86 C code. 1219 // lets simulated-mips make calls into x86 C code.
1206 // When doing that, the 'double' return type must be handled differently 1220 // When doing that, the 'double' return type must be handled differently
1207 // than the usual int64_t return. The data is returned in different 1221 // than the usual int64_t return. The data is returned in different
1208 // registers and cannot be cast from one type to the other. However, the 1222 // registers and cannot be cast from one type to the other. However, the
1209 // calling arguments are passed the same way in both cases. 1223 // calling arguments are passed the same way in both cases.
1210 if (redirection->type() == ExternalReference::FP_RETURN_CALL) { 1224 if (fp_call) {
1211 SimulatorRuntimeFPCall target = 1225 SimulatorRuntimeFPCall target =
1212 reinterpret_cast<SimulatorRuntimeFPCall>(external); 1226 reinterpret_cast<SimulatorRuntimeFPCall>(external);
1213 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { 1227 if (::v8::internal::FLAG_trace_sim) {
1214 PrintF("Call to host function at %p with args %08x:%08x %08x:%08x", 1228 PrintF(
1215 FUNCTION_ADDR(target), arg0, arg1, arg2, arg3); 1229 "Call to host function at %p args %08x, %08x, %08x, %08x\n",
1216 if (!stack_aligned) { 1230 FUNCTION_ADDR(target),
1217 PrintF(" with unaligned stack %08x\n", get_register(sp)); 1231 arg0,
1218 } 1232 arg1,
1219 PrintF("\n"); 1233 arg2,
1220 } 1234 arg3);
1235 }
1221 double result = target(arg0, arg1, arg2, arg3); 1236 double result = target(arg0, arg1, arg2, arg3);
1222 // fp result -> registers v0 and v1. 1237 // fp result -> registers v0 and v1.
1223 int32_t gpreg_pair[2]; 1238 int32_t gpreg_pair[2];
1224 memcpy(&gpreg_pair[0], &result, 2 * sizeof(int32_t)); 1239 memcpy(&gpreg_pair[0], &result, 2 * sizeof(int32_t));
1225 set_register(v0, gpreg_pair[0]); 1240 set_register(v0, gpreg_pair[0]);
1226 set_register(v1, gpreg_pair[1]); 1241 set_register(v1, gpreg_pair[1]);
1227 } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { 1242 } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) {
1228 PrintF("Mips does not yet support ExternalReference::DIRECT_API_CALL\n"); 1243 SimulatorRuntimeApiCall target =
1229 ASSERT(redirection->type() != ExternalReference::DIRECT_API_CALL); 1244 reinterpret_cast<SimulatorRuntimeApiCall>(external);
1230 } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { 1245 if (::v8::internal::FLAG_trace_sim) {
1231 PrintF("Mips does not support ExternalReference::DIRECT_GETTER_CALL\n"); 1246 PrintF("Call to host function at %p args %08x\n",
1232 ASSERT(redirection->type() != ExternalReference::DIRECT_GETTER_CALL); 1247 FUNCTION_ADDR(target),
1248 arg0);
1249 }
1250 v8::Handle<v8::Value> result = target(arg0);
1251 set_register(v0, (int32_t) *result);
1233 } else { 1252 } else {
1234 // Builtin call.
1235 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL);
1236 SimulatorRuntimeCall target = 1253 SimulatorRuntimeCall target =
1237 reinterpret_cast<SimulatorRuntimeCall>(external); 1254 reinterpret_cast<SimulatorRuntimeCall>(external);
1238 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { 1255 if (::v8::internal::FLAG_trace_sim) {
1239 PrintF( 1256 PrintF(
1240 "Call to host function at %p: %08x, %08x, %08x, %08x, %08x, %08x", 1257 "Call to host function at %p "
1258 "args %08x, %08x, %08x, %08x, %08x, %08x\n",
1241 FUNCTION_ADDR(target), 1259 FUNCTION_ADDR(target),
1242 arg0, 1260 arg0,
1243 arg1, 1261 arg1,
1244 arg2, 1262 arg2,
1245 arg3, 1263 arg3,
1246 arg4, 1264 arg4,
1247 arg5); 1265 arg5);
1248 if (!stack_aligned) {
1249 PrintF(" with unaligned stack %08x\n", get_register(sp));
1250 }
1251 PrintF("\n");
1252 } 1266 }
1253
1254 int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5); 1267 int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5);
1255 set_register(v0, static_cast<int32_t>(result)); 1268 set_register(v0, static_cast<int32_t>(result));
1256 set_register(v1, static_cast<int32_t>(result >> 32)); 1269 set_register(v1, static_cast<int32_t>(result >> 32));
1257 } 1270 }
1258 if (::v8::internal::FLAG_trace_sim) { 1271 if (::v8::internal::FLAG_trace_sim) {
1259 PrintF("Returned %08x : %08x\n", get_register(v1), get_register(v0)); 1272 PrintF("Returned %08x : %08x\n", get_register(v1), get_register(v0));
1260 } 1273 }
1261 set_register(ra, saved_ra); 1274 set_register(ra, saved_ra);
1262 set_pc(get_register(ra)); 1275 set_pc(get_register(ra));
1263 1276
1264 } else if (func == BREAK && code >= 0 && code < 16) { 1277 } else if (func == BREAK && code >= 0 && code < 32) {
1265 // First 16 break_ codes interpreted as debug markers. 1278 // First 32 break_ codes interpreted as debug-markers/watchpoints.
1266 MipsDebugger dbg(this); 1279 MipsDebugger dbg(this);
1267 ++break_count_; 1280 ++break_count_;
1268 PrintF("\n---- break %d marker: %3d (instr count: %8d) ----------" 1281 PrintF("\n---- break %d marker: %3d (instr count: %8d) ----------"
1269 "----------------------------------", 1282 "----------------------------------",
1270 code, break_count_, icount_); 1283 code, break_count_, icount_);
1271 dbg.PrintAllRegs(); // Print registers and continue running. 1284 dbg.PrintAllRegs(); // Print registers and continue running.
1272 } else { 1285 } else {
1273 // All remaining break_ codes, and all traps are handled here. 1286 // All remaining break_ codes, and all traps are handled here.
1274 MipsDebugger dbg(this); 1287 MipsDebugger dbg(this);
1275 dbg.Debug(); 1288 dbg.Debug();
(...skipping 29 matching lines...) Expand all
1305 const uint32_t rs_u = static_cast<uint32_t>(rs); 1318 const uint32_t rs_u = static_cast<uint32_t>(rs);
1306 const int32_t rt_reg = instr->RtValue(); 1319 const int32_t rt_reg = instr->RtValue();
1307 const int32_t rt = get_register(rt_reg); 1320 const int32_t rt = get_register(rt_reg);
1308 const uint32_t rt_u = static_cast<uint32_t>(rt); 1321 const uint32_t rt_u = static_cast<uint32_t>(rt);
1309 const int32_t rd_reg = instr->RdValue(); 1322 const int32_t rd_reg = instr->RdValue();
1310 const uint32_t sa = instr->SaValue(); 1323 const uint32_t sa = instr->SaValue();
1311 1324
1312 const int32_t fs_reg = instr->FsValue(); 1325 const int32_t fs_reg = instr->FsValue();
1313 1326
1314 1327
1315 // ---------- Configuration 1328 // ---------- Configuration.
1316 switch (op) { 1329 switch (op) {
1317 case COP1: // Coprocessor instructions 1330 case COP1: // Coprocessor instructions.
1318 switch (instr->RsFieldRaw()) { 1331 switch (instr->RsFieldRaw()) {
1319 case BC1: // Handled in DecodeTypeImmed, should never come here. 1332 case BC1: // Handled in DecodeTypeImmed, should never come here.
1320 UNREACHABLE(); 1333 UNREACHABLE();
1321 break; 1334 break;
1322 case CFC1: 1335 case CFC1:
1323 // At the moment only FCSR is supported. 1336 // At the moment only FCSR is supported.
1324 ASSERT(fs_reg == kFCSRRegister); 1337 ASSERT(fs_reg == kFCSRRegister);
1325 alu_out = FCSR_; 1338 alu_out = FCSR_;
1326 break; 1339 break;
1327 case MFC1: 1340 case MFC1:
(...skipping 28 matching lines...) Expand all
1356 alu_out = rt << sa; 1369 alu_out = rt << sa;
1357 break; 1370 break;
1358 case SRL: 1371 case SRL:
1359 if (rs_reg == 0) { 1372 if (rs_reg == 0) {
1360 // Regular logical right shift of a word by a fixed number of 1373 // Regular logical right shift of a word by a fixed number of
1361 // bits instruction. RS field is always equal to 0. 1374 // bits instruction. RS field is always equal to 0.
1362 alu_out = rt_u >> sa; 1375 alu_out = rt_u >> sa;
1363 } else { 1376 } else {
1364 // Logical right-rotate of a word by a fixed number of bits. This 1377 // Logical right-rotate of a word by a fixed number of bits. This
1365 // is special case of SRL instruction, added in MIPS32 Release 2. 1378 // is special case of SRL instruction, added in MIPS32 Release 2.
1366 // RS field is equal to 00001 1379 // RS field is equal to 00001.
1367 alu_out = (rt_u >> sa) | (rt_u << (32 - sa)); 1380 alu_out = (rt_u >> sa) | (rt_u << (32 - sa));
1368 } 1381 }
1369 break; 1382 break;
1370 case SRA: 1383 case SRA:
1371 alu_out = rt >> sa; 1384 alu_out = rt >> sa;
1372 break; 1385 break;
1373 case SLLV: 1386 case SLLV:
1374 alu_out = rt << rs; 1387 alu_out = rt << rs;
1375 break; 1388 break;
1376 case SRLV: 1389 case SRLV:
1377 if (sa == 0) { 1390 if (sa == 0) {
1378 // Regular logical right-shift of a word by a variable number of 1391 // Regular logical right-shift of a word by a variable number of
1379 // bits instruction. SA field is always equal to 0. 1392 // bits instruction. SA field is always equal to 0.
1380 alu_out = rt_u >> rs; 1393 alu_out = rt_u >> rs;
1381 } else { 1394 } else {
1382 // Logical right-rotate of a word by a variable number of bits. 1395 // Logical right-rotate of a word by a variable number of bits.
1383 // This is special case od SRLV instruction, added in MIPS32 1396 // This is special case od SRLV instruction, added in MIPS32
1384 // Release 2. SA field is equal to 00001 1397 // Release 2. SA field is equal to 00001.
1385 alu_out = (rt_u >> rs_u) | (rt_u << (32 - rs_u)); 1398 alu_out = (rt_u >> rs_u) | (rt_u << (32 - rs_u));
1386 } 1399 }
1387 break; 1400 break;
1388 case SRAV: 1401 case SRAV:
1389 alu_out = rt >> rs; 1402 alu_out = rt >> rs;
1390 break; 1403 break;
1391 case MFHI: 1404 case MFHI:
1392 alu_out = get_register(HI); 1405 alu_out = get_register(HI);
1393 break; 1406 break;
1394 case MFLO: 1407 case MFLO:
1395 alu_out = get_register(LO); 1408 alu_out = get_register(LO);
1396 break; 1409 break;
1397 case MULT: 1410 case MULT:
1398 i64hilo = static_cast<int64_t>(rs) * static_cast<int64_t>(rt); 1411 i64hilo = static_cast<int64_t>(rs) * static_cast<int64_t>(rt);
1399 break; 1412 break;
1400 case MULTU: 1413 case MULTU:
1401 u64hilo = static_cast<uint64_t>(rs_u) * static_cast<uint64_t>(rt_u); 1414 u64hilo = static_cast<uint64_t>(rs_u) * static_cast<uint64_t>(rt_u);
1402 break; 1415 break;
1403 case DIV:
1404 case DIVU:
1405 exceptions[kDivideByZero] = rt == 0;
1406 break;
1407 case ADD: 1416 case ADD:
1408 if (HaveSameSign(rs, rt)) { 1417 if (HaveSameSign(rs, rt)) {
1409 if (rs > 0) { 1418 if (rs > 0) {
1410 exceptions[kIntegerOverflow] = rs > (Registers::kMaxValue - rt); 1419 exceptions[kIntegerOverflow] = rs > (Registers::kMaxValue - rt);
1411 } else if (rs < 0) { 1420 } else if (rs < 0) {
1412 exceptions[kIntegerUnderflow] = rs < (Registers::kMinValue - rt); 1421 exceptions[kIntegerUnderflow] = rs < (Registers::kMinValue - rt);
1413 } 1422 }
1414 } 1423 }
1415 alu_out = rs + rt; 1424 alu_out = rs + rt;
1416 break; 1425 break;
(...skipping 24 matching lines...) Expand all
1441 break; 1450 break;
1442 case NOR: 1451 case NOR:
1443 alu_out = ~(rs | rt); 1452 alu_out = ~(rs | rt);
1444 break; 1453 break;
1445 case SLT: 1454 case SLT:
1446 alu_out = rs < rt ? 1 : 0; 1455 alu_out = rs < rt ? 1 : 0;
1447 break; 1456 break;
1448 case SLTU: 1457 case SLTU:
1449 alu_out = rs_u < rt_u ? 1 : 0; 1458 alu_out = rs_u < rt_u ? 1 : 0;
1450 break; 1459 break;
1451 // Break and trap instructions 1460 // Break and trap instructions.
1452 case BREAK: 1461 case BREAK:
1453 1462
1454 do_interrupt = true; 1463 do_interrupt = true;
1455 break; 1464 break;
1456 case TGE: 1465 case TGE:
1457 do_interrupt = rs >= rt; 1466 do_interrupt = rs >= rt;
1458 break; 1467 break;
1459 case TGEU: 1468 case TGEU:
1460 do_interrupt = rs_u >= rt_u; 1469 do_interrupt = rs_u >= rt_u;
1461 break; 1470 break;
1462 case TLT: 1471 case TLT:
1463 do_interrupt = rs < rt; 1472 do_interrupt = rs < rt;
1464 break; 1473 break;
1465 case TLTU: 1474 case TLTU:
1466 do_interrupt = rs_u < rt_u; 1475 do_interrupt = rs_u < rt_u;
1467 break; 1476 break;
1468 case TEQ: 1477 case TEQ:
1469 do_interrupt = rs == rt; 1478 do_interrupt = rs == rt;
1470 break; 1479 break;
1471 case TNE: 1480 case TNE:
1472 do_interrupt = rs != rt; 1481 do_interrupt = rs != rt;
1473 break; 1482 break;
1474 case MOVN: 1483 case MOVN:
1475 case MOVZ: 1484 case MOVZ:
1476 case MOVCI: 1485 case MOVCI:
1477 // No action taken on decode. 1486 // No action taken on decode.
1478 break; 1487 break;
1488 case DIV:
1489 case DIVU:
1490 // div and divu never raise exceptions.
1491 break;
1479 default: 1492 default:
1480 UNREACHABLE(); 1493 UNREACHABLE();
1481 }; 1494 };
1482 break; 1495 break;
1483 case SPECIAL2: 1496 case SPECIAL2:
1484 switch (instr->FunctionFieldRaw()) { 1497 switch (instr->FunctionFieldRaw()) {
1485 case MUL: 1498 case MUL:
1486 alu_out = rs_u * rt_u; // Only the lower 32 bits are kept. 1499 alu_out = rs_u * rt_u; // Only the lower 32 bits are kept.
1487 break; 1500 break;
1488 case CLZ: 1501 case CLZ:
1489 alu_out = __builtin_clz(rs_u); 1502 alu_out = __builtin_clz(rs_u);
1490 break; 1503 break;
1491 default: 1504 default:
1492 UNREACHABLE(); 1505 UNREACHABLE();
1493 }; 1506 };
1494 break; 1507 break;
1495 case SPECIAL3: 1508 case SPECIAL3:
1496 switch (instr->FunctionFieldRaw()) { 1509 switch (instr->FunctionFieldRaw()) {
1497 case INS: { // Mips32r2 instruction. 1510 case INS: { // Mips32r2 instruction.
1498 // Interpret Rd field as 5-bit msb of insert. 1511 // Interpret rd field as 5-bit msb of insert.
1499 uint16_t msb = rd_reg; 1512 uint16_t msb = rd_reg;
1500 // Interpret sa field as 5-bit lsb of insert. 1513 // Interpret sa field as 5-bit lsb of insert.
1501 uint16_t lsb = sa; 1514 uint16_t lsb = sa;
1502 uint16_t size = msb - lsb + 1; 1515 uint16_t size = msb - lsb + 1;
1503 uint32_t mask = (1 << size) - 1; 1516 uint32_t mask = (1 << size) - 1;
1504 alu_out = (rt_u & ~(mask << lsb)) | ((rs_u & mask) << lsb); 1517 alu_out = (rt_u & ~(mask << lsb)) | ((rs_u & mask) << lsb);
1505 break; 1518 break;
1506 } 1519 }
1507 case EXT: { // Mips32r2 instruction. 1520 case EXT: { // Mips32r2 instruction.
1508 // Interpret Rd field as 5-bit msb of extract. 1521 // Interpret rd field as 5-bit msb of extract.
1509 uint16_t msb = rd_reg; 1522 uint16_t msb = rd_reg;
1510 // Interpret sa field as 5-bit lsb of extract. 1523 // Interpret sa field as 5-bit lsb of extract.
1511 uint16_t lsb = sa; 1524 uint16_t lsb = sa;
1512 uint16_t size = msb + 1; 1525 uint16_t size = msb + 1;
1513 uint32_t mask = (1 << size) - 1; 1526 uint32_t mask = (1 << size) - 1;
1514 alu_out = (rs_u & (mask << lsb)) >> lsb; 1527 alu_out = (rs_u & (mask << lsb)) >> lsb;
1515 break; 1528 break;
1516 } 1529 }
1517 default: 1530 default:
1518 UNREACHABLE(); 1531 UNREACHABLE();
(...skipping 15 matching lines...) Expand all
1534 const int32_t rt = get_register(rt_reg); 1547 const int32_t rt = get_register(rt_reg);
1535 const uint32_t rt_u = static_cast<uint32_t>(rt); 1548 const uint32_t rt_u = static_cast<uint32_t>(rt);
1536 const int32_t rd_reg = instr->RdValue(); 1549 const int32_t rd_reg = instr->RdValue();
1537 1550
1538 const int32_t fs_reg = instr->FsValue(); 1551 const int32_t fs_reg = instr->FsValue();
1539 const int32_t ft_reg = instr->FtValue(); 1552 const int32_t ft_reg = instr->FtValue();
1540 const int32_t fd_reg = instr->FdValue(); 1553 const int32_t fd_reg = instr->FdValue();
1541 int64_t i64hilo = 0; 1554 int64_t i64hilo = 0;
1542 uint64_t u64hilo = 0; 1555 uint64_t u64hilo = 0;
1543 1556
1544 // ALU output 1557 // ALU output.
1545 // It should not be used as is. Instructions using it should always 1558 // It should not be used as is. Instructions using it should always
1546 // initialize it first. 1559 // initialize it first.
1547 int32_t alu_out = 0x12345678; 1560 int32_t alu_out = 0x12345678;
1548 1561
1549 // For break and trap instructions. 1562 // For break and trap instructions.
1550 bool do_interrupt = false; 1563 bool do_interrupt = false;
1551 1564
1552 // For jr and jalr 1565 // For jr and jalr.
1553 // Get current pc. 1566 // Get current pc.
1554 int32_t current_pc = get_pc(); 1567 int32_t current_pc = get_pc();
1555 // Next pc 1568 // Next pc
1556 int32_t next_pc = 0; 1569 int32_t next_pc = 0;
1557 1570
1558 // Setup the variables if needed before executing the instruction. 1571 // Setup the variables if needed before executing the instruction.
1559 ConfigureTypeRegister(instr, 1572 ConfigureTypeRegister(instr,
1560 alu_out, 1573 alu_out,
1561 i64hilo, 1574 i64hilo,
1562 u64hilo, 1575 u64hilo,
1563 next_pc, 1576 next_pc,
1564 do_interrupt); 1577 do_interrupt);
1565 1578
1566 // ---------- Raise exceptions triggered. 1579 // ---------- Raise exceptions triggered.
1567 SignalExceptions(); 1580 SignalExceptions();
1568 1581
1569 // ---------- Execution 1582 // ---------- Execution.
1570 switch (op) { 1583 switch (op) {
1571 case COP1: 1584 case COP1:
1572 switch (instr->RsFieldRaw()) { 1585 switch (instr->RsFieldRaw()) {
1573 case BC1: // branch on coprocessor condition 1586 case BC1: // Branch on coprocessor condition.
1574 UNREACHABLE(); 1587 UNREACHABLE();
1575 break; 1588 break;
1576 case CFC1: 1589 case CFC1:
1577 set_register(rt_reg, alu_out); 1590 set_register(rt_reg, alu_out);
1578 case MFC1: 1591 case MFC1:
1579 set_register(rt_reg, alu_out); 1592 set_register(rt_reg, alu_out);
1580 break; 1593 break;
1581 case MFHC1: 1594 case MFHC1:
1582 UNIMPLEMENTED_MIPS(); 1595 UNIMPLEMENTED_MIPS();
1583 break; 1596 break;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 current_pc+Instruction::kInstrSize); 1806 current_pc+Instruction::kInstrSize);
1794 BranchDelayInstructionDecode(branch_delay_instr); 1807 BranchDelayInstructionDecode(branch_delay_instr);
1795 set_pc(next_pc); 1808 set_pc(next_pc);
1796 pc_modified_ = true; 1809 pc_modified_ = true;
1797 break; 1810 break;
1798 } 1811 }
1799 case JALR: { 1812 case JALR: {
1800 Instruction* branch_delay_instr = reinterpret_cast<Instruction*>( 1813 Instruction* branch_delay_instr = reinterpret_cast<Instruction*>(
1801 current_pc+Instruction::kInstrSize); 1814 current_pc+Instruction::kInstrSize);
1802 BranchDelayInstructionDecode(branch_delay_instr); 1815 BranchDelayInstructionDecode(branch_delay_instr);
1803 set_register(31, current_pc + 2* Instruction::kInstrSize); 1816 set_register(31, current_pc + 2 * Instruction::kInstrSize);
1804 set_pc(next_pc); 1817 set_pc(next_pc);
1805 pc_modified_ = true; 1818 pc_modified_ = true;
1806 break; 1819 break;
1807 } 1820 }
1808 // Instructions using HI and LO registers. 1821 // Instructions using HI and LO registers.
1809 case MULT: 1822 case MULT:
1810 set_register(LO, static_cast<int32_t>(i64hilo & 0xffffffff)); 1823 set_register(LO, static_cast<int32_t>(i64hilo & 0xffffffff));
1811 set_register(HI, static_cast<int32_t>(i64hilo >> 32)); 1824 set_register(HI, static_cast<int32_t>(i64hilo >> 32));
1812 break; 1825 break;
1813 case MULTU: 1826 case MULTU:
1814 set_register(LO, static_cast<int32_t>(u64hilo & 0xffffffff)); 1827 set_register(LO, static_cast<int32_t>(u64hilo & 0xffffffff));
1815 set_register(HI, static_cast<int32_t>(u64hilo >> 32)); 1828 set_register(HI, static_cast<int32_t>(u64hilo >> 32));
1816 break; 1829 break;
1817 case DIV: 1830 case DIV:
1818 // Divide by zero was checked in the configuration step. 1831 // Divide by zero was not checked in the configuration step - div and
1819 set_register(LO, rs / rt); 1832 // divu do not raise exceptions. On division by 0, the result will
1820 set_register(HI, rs % rt); 1833 // be UNPREDICTABLE.
1834 if (rt != 0) {
1835 set_register(LO, rs / rt);
1836 set_register(HI, rs % rt);
1837 }
1821 break; 1838 break;
1822 case DIVU: 1839 case DIVU:
1823 set_register(LO, rs_u / rt_u); 1840 if (rt_u != 0) {
1824 set_register(HI, rs_u % rt_u); 1841 set_register(LO, rs_u / rt_u);
1842 set_register(HI, rs_u % rt_u);
1843 }
1825 break; 1844 break;
1826 // Break and trap instructions. 1845 // Break and trap instructions.
1827 case BREAK: 1846 case BREAK:
1828 case TGE: 1847 case TGE:
1829 case TGEU: 1848 case TGEU:
1830 case TLT: 1849 case TLT:
1831 case TLTU: 1850 case TLTU:
1832 case TEQ: 1851 case TEQ:
1833 case TNE: 1852 case TNE:
1834 if (do_interrupt) { 1853 if (do_interrupt) {
1835 SoftwareInterrupt(instr); 1854 SoftwareInterrupt(instr);
1836 } 1855 }
1837 break; 1856 break;
1838 // Conditional moves. 1857 // Conditional moves.
1839 case MOVN: 1858 case MOVN:
1840 if (rt) set_register(rd_reg, rs); 1859 if (rt) set_register(rd_reg, rs);
1841 break; 1860 break;
1842 case MOVCI: { 1861 case MOVCI: {
1843 uint32_t cc = instr->FCccValue(); 1862 uint32_t cc = instr->FBccValue();
1844 uint32_t fcsr_cc = get_fcsr_condition_bit(cc); 1863 uint32_t fcsr_cc = get_fcsr_condition_bit(cc);
1845 if (instr->Bit(16)) { // Read Tf bit 1864 if (instr->Bit(16)) { // Read Tf bit.
1846 if (test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs); 1865 if (test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs);
1847 } else { 1866 } else {
1848 if (!test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs); 1867 if (!test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs);
1849 } 1868 }
1850 break; 1869 break;
1851 } 1870 }
1852 case MOVZ: 1871 case MOVZ:
1853 if (!rt) set_register(rd_reg, rs); 1872 if (!rt) set_register(rd_reg, rs);
1854 break; 1873 break;
1855 default: // For other special opcodes we do the default operation. 1874 default: // For other special opcodes we do the default operation.
(...skipping 28 matching lines...) Expand all
1884 break; 1903 break;
1885 // Unimplemented opcodes raised an error in the configuration step before, 1904 // Unimplemented opcodes raised an error in the configuration step before,
1886 // so we can use the default here to set the destination register in common 1905 // so we can use the default here to set the destination register in common
1887 // cases. 1906 // cases.
1888 default: 1907 default:
1889 set_register(rd_reg, alu_out); 1908 set_register(rd_reg, alu_out);
1890 }; 1909 };
1891 } 1910 }
1892 1911
1893 1912
1894 // Type 2: instructions using a 16 bytes immediate. (eg: addi, beq) 1913 // Type 2: instructions using a 16 bytes immediate. (eg: addi, beq).
1895 void Simulator::DecodeTypeImmediate(Instruction* instr) { 1914 void Simulator::DecodeTypeImmediate(Instruction* instr) {
1896 // Instruction fields. 1915 // Instruction fields.
1897 Opcode op = instr->OpcodeFieldRaw(); 1916 Opcode op = instr->OpcodeFieldRaw();
1898 int32_t rs = get_register(instr->RsValue()); 1917 int32_t rs = get_register(instr->RsValue());
1899 uint32_t rs_u = static_cast<uint32_t>(rs); 1918 uint32_t rs_u = static_cast<uint32_t>(rs);
1900 int32_t rt_reg = instr->RtValue(); // destination register 1919 int32_t rt_reg = instr->RtValue(); // Destination register.
1901 int32_t rt = get_register(rt_reg); 1920 int32_t rt = get_register(rt_reg);
1902 int16_t imm16 = instr->Imm16Value(); 1921 int16_t imm16 = instr->Imm16Value();
1903 1922
1904 int32_t ft_reg = instr->FtValue(); // destination register 1923 int32_t ft_reg = instr->FtValue(); // Destination register.
1905 1924
1906 // Zero extended immediate. 1925 // Zero extended immediate.
1907 uint32_t oe_imm16 = 0xffff & imm16; 1926 uint32_t oe_imm16 = 0xffff & imm16;
1908 // Sign extended immediate. 1927 // Sign extended immediate.
1909 int32_t se_imm16 = imm16; 1928 int32_t se_imm16 = imm16;
1910 1929
1911 // Get current pc. 1930 // Get current pc.
1912 int32_t current_pc = get_pc(); 1931 int32_t current_pc = get_pc();
1913 // Next pc. 1932 // Next pc.
1914 int32_t next_pc = bad_ra; 1933 int32_t next_pc = bad_ra;
1915 1934
1916 // Used for conditional branch instructions. 1935 // Used for conditional branch instructions.
1917 bool do_branch = false; 1936 bool do_branch = false;
1918 bool execute_branch_delay_instruction = false; 1937 bool execute_branch_delay_instruction = false;
1919 1938
1920 // Used for arithmetic instructions. 1939 // Used for arithmetic instructions.
1921 int32_t alu_out = 0; 1940 int32_t alu_out = 0;
1922 // Floating point. 1941 // Floating point.
1923 double fp_out = 0.0; 1942 double fp_out = 0.0;
1924 uint32_t cc, cc_value, fcsr_cc; 1943 uint32_t cc, cc_value, fcsr_cc;
1925 1944
1926 // Used for memory instructions. 1945 // Used for memory instructions.
1927 int32_t addr = 0x0; 1946 int32_t addr = 0x0;
1928 // Value to be written in memory 1947 // Value to be written in memory.
1929 uint32_t mem_value = 0x0; 1948 uint32_t mem_value = 0x0;
1930 1949
1931 // ---------- Configuration (and execution for REGIMM) 1950 // ---------- Configuration (and execution for REGIMM).
1932 switch (op) { 1951 switch (op) {
1933 // ------------- COP1. Coprocessor instructions. 1952 // ------------- COP1. Coprocessor instructions.
1934 case COP1: 1953 case COP1:
1935 switch (instr->RsFieldRaw()) { 1954 switch (instr->RsFieldRaw()) {
1936 case BC1: // Branch on coprocessor condition. 1955 case BC1: // Branch on coprocessor condition.
1937 cc = instr->FBccValue(); 1956 cc = instr->FBccValue();
1938 fcsr_cc = get_fcsr_condition_bit(cc); 1957 fcsr_cc = get_fcsr_condition_bit(cc);
1939 cc_value = test_fcsr_bit(fcsr_cc); 1958 cc_value = test_fcsr_bit(fcsr_cc);
1940 do_branch = (instr->FBtrueValue()) ? cc_value : !cc_value; 1959 do_branch = (instr->FBtrueValue()) ? cc_value : !cc_value;
1941 execute_branch_delay_instruction = true; 1960 execute_branch_delay_instruction = true;
1942 // Set next_pc 1961 // Set next_pc.
1943 if (do_branch) { 1962 if (do_branch) {
1944 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize; 1963 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize;
1945 } else { 1964 } else {
1946 next_pc = current_pc + kBranchReturnOffset; 1965 next_pc = current_pc + kBranchReturnOffset;
1947 } 1966 }
1948 break; 1967 break;
1949 default: 1968 default:
1950 UNREACHABLE(); 1969 UNREACHABLE();
1951 }; 1970 };
1952 break; 1971 break;
1953 // ------------- REGIMM class 1972 // ------------- REGIMM class.
1954 case REGIMM: 1973 case REGIMM:
1955 switch (instr->RtFieldRaw()) { 1974 switch (instr->RtFieldRaw()) {
1956 case BLTZ: 1975 case BLTZ:
1957 do_branch = (rs < 0); 1976 do_branch = (rs < 0);
1958 break; 1977 break;
1959 case BLTZAL: 1978 case BLTZAL:
1960 do_branch = rs < 0; 1979 do_branch = rs < 0;
1961 break; 1980 break;
1962 case BGEZ: 1981 case BGEZ:
1963 do_branch = rs >= 0; 1982 do_branch = rs >= 0;
1964 break; 1983 break;
1965 case BGEZAL: 1984 case BGEZAL:
1966 do_branch = rs >= 0; 1985 do_branch = rs >= 0;
1967 break; 1986 break;
1968 default: 1987 default:
1969 UNREACHABLE(); 1988 UNREACHABLE();
1970 }; 1989 };
1971 switch (instr->RtFieldRaw()) { 1990 switch (instr->RtFieldRaw()) {
1972 case BLTZ: 1991 case BLTZ:
1973 case BLTZAL: 1992 case BLTZAL:
1974 case BGEZ: 1993 case BGEZ:
1975 case BGEZAL: 1994 case BGEZAL:
1976 // Branch instructions common part. 1995 // Branch instructions common part.
1977 execute_branch_delay_instruction = true; 1996 execute_branch_delay_instruction = true;
1978 // Set next_pc 1997 // Set next_pc.
1979 if (do_branch) { 1998 if (do_branch) {
1980 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize; 1999 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize;
1981 if (instr->IsLinkingInstruction()) { 2000 if (instr->IsLinkingInstruction()) {
1982 set_register(31, current_pc + kBranchReturnOffset); 2001 set_register(31, current_pc + kBranchReturnOffset);
1983 } 2002 }
1984 } else { 2003 } else {
1985 next_pc = current_pc + kBranchReturnOffset; 2004 next_pc = current_pc + kBranchReturnOffset;
1986 } 2005 }
1987 default: 2006 default:
1988 break; 2007 break;
1989 }; 2008 };
1990 break; // case REGIMM 2009 break; // case REGIMM.
1991 // ------------- Branch instructions 2010 // ------------- Branch instructions.
1992 // When comparing to zero, the encoding of rt field is always 0, so we don't 2011 // When comparing to zero, the encoding of rt field is always 0, so we don't
1993 // need to replace rt with zero. 2012 // need to replace rt with zero.
1994 case BEQ: 2013 case BEQ:
1995 do_branch = (rs == rt); 2014 do_branch = (rs == rt);
1996 break; 2015 break;
1997 case BNE: 2016 case BNE:
1998 do_branch = rs != rt; 2017 do_branch = rs != rt;
1999 break; 2018 break;
2000 case BLEZ: 2019 case BLEZ:
2001 do_branch = rs <= 0; 2020 do_branch = rs <= 0;
2002 break; 2021 break;
2003 case BGTZ: 2022 case BGTZ:
2004 do_branch = rs > 0; 2023 do_branch = rs > 0;
2005 break; 2024 break;
2006 // ------------- Arithmetic instructions 2025 // ------------- Arithmetic instructions.
2007 case ADDI: 2026 case ADDI:
2008 if (HaveSameSign(rs, se_imm16)) { 2027 if (HaveSameSign(rs, se_imm16)) {
2009 if (rs > 0) { 2028 if (rs > 0) {
2010 exceptions[kIntegerOverflow] = rs > (Registers::kMaxValue - se_imm16); 2029 exceptions[kIntegerOverflow] = rs > (Registers::kMaxValue - se_imm16);
2011 } else if (rs < 0) { 2030 } else if (rs < 0) {
2012 exceptions[kIntegerUnderflow] = 2031 exceptions[kIntegerUnderflow] =
2013 rs < (Registers::kMinValue - se_imm16); 2032 rs < (Registers::kMinValue - se_imm16);
2014 } 2033 }
2015 } 2034 }
2016 alu_out = rs + se_imm16; 2035 alu_out = rs + se_imm16;
(...skipping 12 matching lines...) Expand all
2029 break; 2048 break;
2030 case ORI: 2049 case ORI:
2031 alu_out = rs | oe_imm16; 2050 alu_out = rs | oe_imm16;
2032 break; 2051 break;
2033 case XORI: 2052 case XORI:
2034 alu_out = rs ^ oe_imm16; 2053 alu_out = rs ^ oe_imm16;
2035 break; 2054 break;
2036 case LUI: 2055 case LUI:
2037 alu_out = (oe_imm16 << 16); 2056 alu_out = (oe_imm16 << 16);
2038 break; 2057 break;
2039 // ------------- Memory instructions 2058 // ------------- Memory instructions.
2040 case LB: 2059 case LB:
2041 addr = rs + se_imm16; 2060 addr = rs + se_imm16;
2042 alu_out = ReadB(addr); 2061 alu_out = ReadB(addr);
2043 break; 2062 break;
2044 case LH: 2063 case LH:
2045 addr = rs + se_imm16; 2064 addr = rs + se_imm16;
2046 alu_out = ReadH(addr, instr); 2065 alu_out = ReadH(addr, instr);
2047 break; 2066 break;
2048 case LWL: { 2067 case LWL: {
2049 // al_offset is an offset of the effective address within an aligned word 2068 // al_offset is offset of the effective address within an aligned word.
2050 uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask; 2069 uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask;
2051 uint8_t byte_shift = kPointerAlignmentMask - al_offset; 2070 uint8_t byte_shift = kPointerAlignmentMask - al_offset;
2052 uint32_t mask = (1 << byte_shift * 8) - 1; 2071 uint32_t mask = (1 << byte_shift * 8) - 1;
2053 addr = rs + se_imm16 - al_offset; 2072 addr = rs + se_imm16 - al_offset;
2054 alu_out = ReadW(addr, instr); 2073 alu_out = ReadW(addr, instr);
2055 alu_out <<= byte_shift * 8; 2074 alu_out <<= byte_shift * 8;
2056 alu_out |= rt & mask; 2075 alu_out |= rt & mask;
2057 break; 2076 break;
2058 } 2077 }
2059 case LW: 2078 case LW:
2060 addr = rs + se_imm16; 2079 addr = rs + se_imm16;
2061 alu_out = ReadW(addr, instr); 2080 alu_out = ReadW(addr, instr);
2062 break; 2081 break;
2063 case LBU: 2082 case LBU:
2064 addr = rs + se_imm16; 2083 addr = rs + se_imm16;
2065 alu_out = ReadBU(addr); 2084 alu_out = ReadBU(addr);
2066 break; 2085 break;
2067 case LHU: 2086 case LHU:
2068 addr = rs + se_imm16; 2087 addr = rs + se_imm16;
2069 alu_out = ReadHU(addr, instr); 2088 alu_out = ReadHU(addr, instr);
2070 break; 2089 break;
2071 case LWR: { 2090 case LWR: {
2072 // al_offset is an offset of the effective address within an aligned word 2091 // al_offset is offset of the effective address within an aligned word.
2073 uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask; 2092 uint8_t al_offset = (rs + se_imm16) & kPointerAlignmentMask;
2074 uint8_t byte_shift = kPointerAlignmentMask - al_offset; 2093 uint8_t byte_shift = kPointerAlignmentMask - al_offset;
2075 uint32_t mask = al_offset ? (~0 << (byte_shift + 1) * 8) : 0; 2094 uint32_t mask = al_offset ? (~0 << (byte_shift + 1) * 8) : 0;
2076 addr = rs + se_imm16 - al_offset; 2095 addr = rs + se_imm16 - al_offset;
2077 alu_out = ReadW(addr, instr); 2096 alu_out = ReadW(addr, instr);
2078 alu_out = static_cast<uint32_t> (alu_out) >> al_offset * 8; 2097 alu_out = static_cast<uint32_t> (alu_out) >> al_offset * 8;
2079 alu_out |= rt & mask; 2098 alu_out |= rt & mask;
2080 break; 2099 break;
2081 } 2100 }
2082 case SB: 2101 case SB:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 case SDC1: 2136 case SDC1:
2118 addr = rs + se_imm16; 2137 addr = rs + se_imm16;
2119 break; 2138 break;
2120 default: 2139 default:
2121 UNREACHABLE(); 2140 UNREACHABLE();
2122 }; 2141 };
2123 2142
2124 // ---------- Raise exceptions triggered. 2143 // ---------- Raise exceptions triggered.
2125 SignalExceptions(); 2144 SignalExceptions();
2126 2145
2127 // ---------- Execution 2146 // ---------- Execution.
2128 switch (op) { 2147 switch (op) {
2129 // ------------- Branch instructions 2148 // ------------- Branch instructions.
2130 case BEQ: 2149 case BEQ:
2131 case BNE: 2150 case BNE:
2132 case BLEZ: 2151 case BLEZ:
2133 case BGTZ: 2152 case BGTZ:
2134 // Branch instructions common part. 2153 // Branch instructions common part.
2135 execute_branch_delay_instruction = true; 2154 execute_branch_delay_instruction = true;
2136 // Set next_pc 2155 // Set next_pc.
2137 if (do_branch) { 2156 if (do_branch) {
2138 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize; 2157 next_pc = current_pc + (imm16 << 2) + Instruction::kInstrSize;
2139 if (instr->IsLinkingInstruction()) { 2158 if (instr->IsLinkingInstruction()) {
2140 set_register(31, current_pc + 2* Instruction::kInstrSize); 2159 set_register(31, current_pc + 2* Instruction::kInstrSize);
2141 } 2160 }
2142 } else { 2161 } else {
2143 next_pc = current_pc + 2 * Instruction::kInstrSize; 2162 next_pc = current_pc + 2 * Instruction::kInstrSize;
2144 } 2163 }
2145 break; 2164 break;
2146 // ------------- Arithmetic instructions 2165 // ------------- Arithmetic instructions.
2147 case ADDI: 2166 case ADDI:
2148 case ADDIU: 2167 case ADDIU:
2149 case SLTI: 2168 case SLTI:
2150 case SLTIU: 2169 case SLTIU:
2151 case ANDI: 2170 case ANDI:
2152 case ORI: 2171 case ORI:
2153 case XORI: 2172 case XORI:
2154 case LUI: 2173 case LUI:
2155 set_register(rt_reg, alu_out); 2174 set_register(rt_reg, alu_out);
2156 break; 2175 break;
2157 // ------------- Memory instructions 2176 // ------------- Memory instructions.
2158 case LB: 2177 case LB:
2159 case LH: 2178 case LH:
2160 case LWL: 2179 case LWL:
2161 case LW: 2180 case LW:
2162 case LBU: 2181 case LBU:
2163 case LHU: 2182 case LHU:
2164 case LWR: 2183 case LWR:
2165 set_register(rt_reg, alu_out); 2184 set_register(rt_reg, alu_out);
2166 break; 2185 break;
2167 case SB: 2186 case SB:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 BranchDelayInstructionDecode(branch_delay_instr); 2226 BranchDelayInstructionDecode(branch_delay_instr);
2208 } 2227 }
2209 2228
2210 // If needed update pc after the branch delay execution. 2229 // If needed update pc after the branch delay execution.
2211 if (next_pc != bad_ra) { 2230 if (next_pc != bad_ra) {
2212 set_pc(next_pc); 2231 set_pc(next_pc);
2213 } 2232 }
2214 } 2233 }
2215 2234
2216 2235
2217 // Type 3: instructions using a 26 bytes immediate. (eg: j, jal) 2236 // Type 3: instructions using a 26 bytes immediate. (eg: j, jal).
2218 void Simulator::DecodeTypeJump(Instruction* instr) { 2237 void Simulator::DecodeTypeJump(Instruction* instr) {
2219 // Get current pc. 2238 // Get current pc.
2220 int32_t current_pc = get_pc(); 2239 int32_t current_pc = get_pc();
2221 // Get unchanged bits of pc. 2240 // Get unchanged bits of pc.
2222 int32_t pc_high_bits = current_pc & 0xf0000000; 2241 int32_t pc_high_bits = current_pc & 0xf0000000;
2223 // Next pc 2242 // Next pc.
2224 int32_t next_pc = pc_high_bits | (instr->Imm26Value() << 2); 2243 int32_t next_pc = pc_high_bits | (instr->Imm26Value() << 2);
2225 2244
2226 // Execute branch delay slot 2245 // Execute branch delay slot.
2227 // We don't check for end_sim_pc. First it should not be met as the current pc 2246 // We don't check for end_sim_pc. First it should not be met as the current pc
2228 // is valid. Secondly a jump should always execute its branch delay slot. 2247 // is valid. Secondly a jump should always execute its branch delay slot.
2229 Instruction* branch_delay_instr = 2248 Instruction* branch_delay_instr =
2230 reinterpret_cast<Instruction*>(current_pc+Instruction::kInstrSize); 2249 reinterpret_cast<Instruction*>(current_pc + Instruction::kInstrSize);
2231 BranchDelayInstructionDecode(branch_delay_instr); 2250 BranchDelayInstructionDecode(branch_delay_instr);
2232 2251
2233 // Update pc and ra if necessary. 2252 // Update pc and ra if necessary.
2234 // Do this after the branch delay execution. 2253 // Do this after the branch delay execution.
2235 if (instr->IsLinkingInstruction()) { 2254 if (instr->IsLinkingInstruction()) {
2236 set_register(31, current_pc + 2* Instruction::kInstrSize); 2255 set_register(31, current_pc + 2 * Instruction::kInstrSize);
2237 } 2256 }
2238 set_pc(next_pc); 2257 set_pc(next_pc);
2239 pc_modified_ = true; 2258 pc_modified_ = true;
2240 } 2259 }
2241 2260
2242 2261
2243 // Executes the current instruction. 2262 // Executes the current instruction.
2244 void Simulator::InstructionDecode(Instruction* instr) { 2263 void Simulator::InstructionDecode(Instruction* instr) {
2245 if (v8::internal::FLAG_check_icache) { 2264 if (v8::internal::FLAG_check_icache) {
2246 CheckICache(isolate_->simulator_i_cache(), instr); 2265 CheckICache(isolate_->simulator_i_cache(), instr);
2247 } 2266 }
2248 pc_modified_ = false; 2267 pc_modified_ = false;
2249 if (::v8::internal::FLAG_trace_sim) { 2268 if (::v8::internal::FLAG_trace_sim) {
2250 disasm::NameConverter converter; 2269 disasm::NameConverter converter;
2251 disasm::Disassembler dasm(converter); 2270 disasm::Disassembler dasm(converter);
2252 // use a reasonably large buffer 2271 // Use a reasonably large buffer.
2253 v8::internal::EmbeddedVector<char, 256> buffer; 2272 v8::internal::EmbeddedVector<char, 256> buffer;
2254 dasm.InstructionDecode(buffer, reinterpret_cast<byte_*>(instr)); 2273 dasm.InstructionDecode(buffer, reinterpret_cast<byte*>(instr));
2255 PrintF(" 0x%08x %s\n", reinterpret_cast<intptr_t>(instr), 2274 PrintF(" 0x%08x %s\n", reinterpret_cast<intptr_t>(instr),
2256 buffer.start()); 2275 buffer.start());
2257 } 2276 }
2258 2277
2259 switch (instr->InstructionType()) { 2278 switch (instr->InstructionType()) {
2260 case Instruction::kRegisterType: 2279 case Instruction::kRegisterType:
2261 DecodeTypeRegister(instr); 2280 DecodeTypeRegister(instr);
2262 break; 2281 break;
2263 case Instruction::kImmediateType: 2282 case Instruction::kImmediateType:
2264 DecodeTypeImmediate(instr); 2283 DecodeTypeImmediate(instr);
2265 break; 2284 break;
2266 case Instruction::kJumpType: 2285 case Instruction::kJumpType:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 dbg.Debug(); 2320 dbg.Debug();
2302 } else { 2321 } else {
2303 InstructionDecode(instr); 2322 InstructionDecode(instr);
2304 } 2323 }
2305 program_counter = get_pc(); 2324 program_counter = get_pc();
2306 } 2325 }
2307 } 2326 }
2308 } 2327 }
2309 2328
2310 2329
2311 int32_t Simulator::Call(byte_* entry, int argument_count, ...) { 2330 int32_t Simulator::Call(byte* entry, int argument_count, ...) {
2312 va_list parameters; 2331 va_list parameters;
2313 va_start(parameters, argument_count); 2332 va_start(parameters, argument_count);
2314 // Setup arguments 2333 // Setup arguments.
2315 2334
2316 // First four arguments passed in registers. 2335 // First four arguments passed in registers.
2317 ASSERT(argument_count >= 4); 2336 ASSERT(argument_count >= 4);
2318 set_register(a0, va_arg(parameters, int32_t)); 2337 set_register(a0, va_arg(parameters, int32_t));
2319 set_register(a1, va_arg(parameters, int32_t)); 2338 set_register(a1, va_arg(parameters, int32_t));
2320 set_register(a2, va_arg(parameters, int32_t)); 2339 set_register(a2, va_arg(parameters, int32_t));
2321 set_register(a3, va_arg(parameters, int32_t)); 2340 set_register(a3, va_arg(parameters, int32_t));
2322 2341
2323 // Remaining arguments passed on stack. 2342 // Remaining arguments passed on stack.
2324 int original_stack = get_register(sp); 2343 int original_stack = get_register(sp);
2325 // Compute position of stack on entry to generated code. 2344 // Compute position of stack on entry to generated code.
2326 int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t) 2345 int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t)
2327 - kCArgsSlotsSize); 2346 - kCArgsSlotsSize);
2328 if (OS::ActivationFrameAlignment() != 0) { 2347 if (OS::ActivationFrameAlignment() != 0) {
2329 entry_stack &= -OS::ActivationFrameAlignment(); 2348 entry_stack &= -OS::ActivationFrameAlignment();
2330 } 2349 }
2331 // Store remaining arguments on stack, from low to high memory. 2350 // Store remaining arguments on stack, from low to high memory.
2332 intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack); 2351 intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack);
2333 for (int i = 4; i < argument_count; i++) { 2352 for (int i = 4; i < argument_count; i++) {
2334 stack_argument[i - 4 + kArgsSlotsNum] = va_arg(parameters, int32_t); 2353 stack_argument[i - 4 + kArgsSlotsNum] = va_arg(parameters, int32_t);
2335 } 2354 }
2336 va_end(parameters); 2355 va_end(parameters);
2337 set_register(sp, entry_stack); 2356 set_register(sp, entry_stack);
2338 2357
2339 // Prepare to execute the code at entry 2358 // Prepare to execute the code at entry.
2340 set_register(pc, reinterpret_cast<int32_t>(entry)); 2359 set_register(pc, reinterpret_cast<int32_t>(entry));
2341 // Put down marker for end of simulation. The simulator will stop simulation 2360 // Put down marker for end of simulation. The simulator will stop simulation
2342 // when the PC reaches this value. By saving the "end simulation" value into 2361 // when the PC reaches this value. By saving the "end simulation" value into
2343 // the LR the simulation stops when returning to this call point. 2362 // the LR the simulation stops when returning to this call point.
2344 set_register(ra, end_sim_pc); 2363 set_register(ra, end_sim_pc);
2345 2364
2346 // Remember the values of callee-saved registers. 2365 // Remember the values of callee-saved registers.
2347 // The code below assumes that r9 is not used as sb (static base) in 2366 // The code below assumes that r9 is not used as sb (static base) in
2348 // simulator code and therefore is regarded as a callee-saved register. 2367 // simulator code and therefore is regarded as a callee-saved register.
2349 int32_t s0_val = get_register(s0); 2368 int32_t s0_val = get_register(s0);
(...skipping 15 matching lines...) Expand all
2365 set_register(s1, callee_saved_value); 2384 set_register(s1, callee_saved_value);
2366 set_register(s2, callee_saved_value); 2385 set_register(s2, callee_saved_value);
2367 set_register(s3, callee_saved_value); 2386 set_register(s3, callee_saved_value);
2368 set_register(s4, callee_saved_value); 2387 set_register(s4, callee_saved_value);
2369 set_register(s5, callee_saved_value); 2388 set_register(s5, callee_saved_value);
2370 set_register(s6, callee_saved_value); 2389 set_register(s6, callee_saved_value);
2371 set_register(s7, callee_saved_value); 2390 set_register(s7, callee_saved_value);
2372 set_register(gp, callee_saved_value); 2391 set_register(gp, callee_saved_value);
2373 set_register(fp, callee_saved_value); 2392 set_register(fp, callee_saved_value);
2374 2393
2375 // Start the simulation 2394 // Start the simulation.
2376 Execute(); 2395 Execute();
2377 2396
2378 // Check that the callee-saved registers have been preserved. 2397 // Check that the callee-saved registers have been preserved.
2379 CHECK_EQ(callee_saved_value, get_register(s0)); 2398 CHECK_EQ(callee_saved_value, get_register(s0));
2380 CHECK_EQ(callee_saved_value, get_register(s1)); 2399 CHECK_EQ(callee_saved_value, get_register(s1));
2381 CHECK_EQ(callee_saved_value, get_register(s2)); 2400 CHECK_EQ(callee_saved_value, get_register(s2));
2382 CHECK_EQ(callee_saved_value, get_register(s3)); 2401 CHECK_EQ(callee_saved_value, get_register(s3));
2383 CHECK_EQ(callee_saved_value, get_register(s4)); 2402 CHECK_EQ(callee_saved_value, get_register(s4));
2384 CHECK_EQ(callee_saved_value, get_register(s5)); 2403 CHECK_EQ(callee_saved_value, get_register(s5));
2385 CHECK_EQ(callee_saved_value, get_register(s6)); 2404 CHECK_EQ(callee_saved_value, get_register(s6));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 } 2446 }
2428 2447
2429 2448
2430 #undef UNSUPPORTED 2449 #undef UNSUPPORTED
2431 2450
2432 } } // namespace v8::internal 2451 } } // namespace v8::internal
2433 2452
2434 #endif // USE_SIMULATOR 2453 #endif // USE_SIMULATOR
2435 2454
2436 #endif // V8_TARGET_ARCH_MIPS 2455 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698