| 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 "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 // Only build the simulator if not compiling for real MIPS hardware. | 8 // Only build the simulator if not compiling for real MIPS hardware. |
| 9 #if !defined(HOST_ARCH_MIPS) | 9 #if !defined(HOST_ARCH_MIPS) |
| 10 | 10 |
| 11 #include "vm/simulator.h" | 11 #include "vm/simulator.h" |
| 12 | 12 |
| 13 #include "vm/assembler.h" | 13 #include "vm/assembler.h" |
| 14 #include "vm/constants_mips.h" | 14 #include "vm/constants_mips.h" |
| 15 #include "vm/disassembler.h" | 15 #include "vm/disassembler.h" |
| 16 | 16 |
| 17 namespace dart { | 17 namespace dart { |
| 18 | 18 |
| 19 Simulator::Simulator() { | 19 Simulator::Simulator() { |
| 20 UNIMPLEMENTED(); | 20 // Setup simulator support first. Some of this information is needed to |
| 21 // setup the architecture state. |
| 22 // We allocate the stack here, the size is computed as the sum of |
| 23 // the size specified by the user and the buffer space needed for |
| 24 // handling stack overflow exceptions. To be safe in potential |
| 25 // stack underflows we also add some underflow buffer space. |
| 26 stack_ = new char[(Isolate::GetSpecifiedStackSize() + |
| 27 Isolate::kStackSizeBuffer + |
| 28 kSimulatorStackUnderflowSize)]; |
| 21 } | 29 } |
| 22 | 30 |
| 23 | 31 |
| 24 Simulator::~Simulator() { | 32 Simulator::~Simulator() { |
| 25 Isolate* isolate = Isolate::Current(); | 33 Isolate* isolate = Isolate::Current(); |
| 26 if (isolate != NULL) { | 34 if (isolate != NULL) { |
| 27 isolate->set_simulator(NULL); | 35 isolate->set_simulator(NULL); |
| 28 } | 36 } |
| 29 } | 37 } |
| 30 | 38 |
| 31 | 39 |
| 32 // Get the active Simulator for the current isolate. | 40 // Get the active Simulator for the current isolate. |
| 33 Simulator* Simulator::Current() { | 41 Simulator* Simulator::Current() { |
| 34 Simulator* simulator = Isolate::Current()->simulator(); | 42 Simulator* simulator = Isolate::Current()->simulator(); |
| 35 if (simulator == NULL) { | 43 if (simulator == NULL) { |
| 36 simulator = new Simulator(); | 44 simulator = new Simulator(); |
| 37 Isolate::Current()->set_simulator(simulator); | 45 Isolate::Current()->set_simulator(simulator); |
| 38 } | 46 } |
| 39 return simulator; | 47 return simulator; |
| 40 } | 48 } |
| 41 | 49 |
| 42 | 50 |
| 51 // Returns the top of the stack area to enable checking for stack pointer |
| 52 // validity. |
| 53 uword Simulator::StackTop() const { |
| 54 // To be safe in potential stack underflows we leave some buffer above and |
| 55 // set the stack top. |
| 56 return reinterpret_cast<uword>(stack_) + |
| 57 (Isolate::GetSpecifiedStackSize() + Isolate::kStackSizeBuffer); |
| 58 } |
| 59 |
| 60 |
| 43 void Simulator::InitOnce() { | 61 void Simulator::InitOnce() { |
| 44 } | 62 } |
| 45 | 63 |
| 46 | 64 |
| 47 int64_t Simulator::Call(int32_t entry, | 65 int64_t Simulator::Call(int32_t entry, |
| 48 int32_t parameter0, | 66 int32_t parameter0, |
| 49 int32_t parameter1, | 67 int32_t parameter1, |
| 50 int32_t parameter2, | 68 int32_t parameter2, |
| 51 int32_t parameter3, | 69 int32_t parameter3, |
| 52 int32_t parameter4) { | 70 int32_t parameter4) { |
| 53 UNIMPLEMENTED(); | 71 UNIMPLEMENTED(); |
| 54 return 0LL; | 72 return 0LL; |
| 55 } | 73 } |
| 56 | 74 |
| 57 } // namespace dart | 75 } // namespace dart |
| 58 | 76 |
| 59 #endif // !defined(HOST_ARCH_MIPS) | 77 #endif // !defined(HOST_ARCH_MIPS) |
| 60 | 78 |
| 61 #endif // defined TARGET_ARCH_MIPS | 79 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |