| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
| 6 #include <setjmp.h> | 6 #include <setjmp.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #if defined(TARGET_ARCH_MIPS) | 10 #if defined(TARGET_ARCH_MIPS) |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 // the size specified by the user and the buffer space needed for | 529 // the size specified by the user and the buffer space needed for |
| 530 // handling stack overflow exceptions. To be safe in potential | 530 // handling stack overflow exceptions. To be safe in potential |
| 531 // stack underflows we also add some underflow buffer space. | 531 // stack underflows we also add some underflow buffer space. |
| 532 stack_ = new char[(Isolate::GetSpecifiedStackSize() + | 532 stack_ = new char[(Isolate::GetSpecifiedStackSize() + |
| 533 Isolate::kStackSizeBuffer + | 533 Isolate::kStackSizeBuffer + |
| 534 kSimulatorStackUnderflowSize)]; | 534 kSimulatorStackUnderflowSize)]; |
| 535 icount_ = 0; | 535 icount_ = 0; |
| 536 delay_slot_ = false; | 536 delay_slot_ = false; |
| 537 break_pc_ = NULL; | 537 break_pc_ = NULL; |
| 538 break_instr_ = 0; | 538 break_instr_ = 0; |
| 539 last_setjmp_buffer_ = NULL; |
| 539 | 540 |
| 540 // Setup architecture state. | 541 // Setup architecture state. |
| 541 // All registers are initialized to zero to start with. | 542 // All registers are initialized to zero to start with. |
| 542 for (int i = 0; i < kNumberOfCpuRegisters; i++) { | 543 for (int i = 0; i < kNumberOfCpuRegisters; i++) { |
| 543 registers_[i] = 0; | 544 registers_[i] = 0; |
| 544 } | 545 } |
| 545 pc_ = 0; | 546 pc_ = 0; |
| 546 // The sp is initialized to point to the bottom (high address) of the | 547 // The sp is initialized to point to the bottom (high address) of the |
| 547 // allocated stack area. | 548 // allocated stack area. |
| 548 registers_[SP] = StackTop(); | 549 registers_[SP] = StackTop(); |
| 550 |
| 551 // All double-precision registers are initialized to zero. |
| 552 for (int i = 0; i < kNumberOfFRegisters; i++) { |
| 553 fregisters_[i] = 0.0; |
| 554 } |
| 549 } | 555 } |
| 550 | 556 |
| 551 | 557 |
| 552 Simulator::~Simulator() { | 558 Simulator::~Simulator() { |
| 559 delete[] stack_; |
| 553 Isolate* isolate = Isolate::Current(); | 560 Isolate* isolate = Isolate::Current(); |
| 554 if (isolate != NULL) { | 561 if (isolate != NULL) { |
| 555 isolate->set_simulator(NULL); | 562 isolate->set_simulator(NULL); |
| 556 } | 563 } |
| 557 } | 564 } |
| 558 | 565 |
| 559 | 566 |
| 560 // When the generated code calls an external reference we need to catch that in | 567 // When the generated code calls an external reference we need to catch that in |
| 561 // the simulator. The external reference will be a function compiled for the | 568 // the simulator. The external reference will be a function compiled for the |
| 562 // host architecture. We need to call that function instead of trying to | 569 // host architecture. We need to call that function instead of trying to |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 default: { | 1261 default: { |
| 1255 OS::PrintErr("DecodeRegImm: 0x%x\n", instr->InstructionBits()); | 1262 OS::PrintErr("DecodeRegImm: 0x%x\n", instr->InstructionBits()); |
| 1256 UnimplementedInstruction(instr); | 1263 UnimplementedInstruction(instr); |
| 1257 break; | 1264 break; |
| 1258 } | 1265 } |
| 1259 } | 1266 } |
| 1260 } | 1267 } |
| 1261 | 1268 |
| 1262 | 1269 |
| 1263 void Simulator::InstructionDecode(Instr* instr) { | 1270 void Simulator::InstructionDecode(Instr* instr) { |
| 1271 if (FLAG_trace_sim) { |
| 1272 const uword start = reinterpret_cast<uword>(instr); |
| 1273 const uword end = start + Instr::kInstrSize; |
| 1274 Disassembler::Disassemble(start, end); |
| 1275 } |
| 1276 |
| 1264 switch (instr->OpcodeField()) { | 1277 switch (instr->OpcodeField()) { |
| 1265 case SPECIAL: { | 1278 case SPECIAL: { |
| 1266 DecodeSpecial(instr); | 1279 DecodeSpecial(instr); |
| 1267 break; | 1280 break; |
| 1268 } | 1281 } |
| 1269 case SPECIAL2: { | 1282 case SPECIAL2: { |
| 1270 DecodeSpecial2(instr); | 1283 DecodeSpecial2(instr); |
| 1271 break; | 1284 break; |
| 1272 } | 1285 } |
| 1273 case REGIMM: { | 1286 case REGIMM: { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 // Restore the SP register and return R1:R0. | 1611 // Restore the SP register and return R1:R0. |
| 1599 set_register(SP, sp_before_call); | 1612 set_register(SP, sp_before_call); |
| 1600 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); | 1613 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); |
| 1601 } | 1614 } |
| 1602 | 1615 |
| 1603 } // namespace dart | 1616 } // namespace dart |
| 1604 | 1617 |
| 1605 #endif // !defined(HOST_ARCH_MIPS) | 1618 #endif // !defined(HOST_ARCH_MIPS) |
| 1606 | 1619 |
| 1607 #endif // defined TARGET_ARCH_MIPS | 1620 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |