13 #ifndef V8_MIPS_SIMULATOR_MIPS_H_
14 #define V8_MIPS_SIMULATOR_MIPS_H_
19 #if !defined(USE_SIMULATOR)
26 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
27 entry(p0, p1, p2, p3, p4)
37 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
38 (FUNCTION_CAST<mips_regexp_matcher>(entry)( \
39 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
52 return try_catch_address;
66 #define GENERATED_CODE_STACK_LIMIT(limit) \
67 (reinterpret_cast<uintptr_t>(this) >= limit ? \
68 reinterpret_cast<uintptr_t>(this) - limit : 0)
84 static const int LINE_VALID = 0;
85 static const int LINE_INVALID = 1;
87 static const int kPageShift = 12;
88 static const int kPageSize = 1 << kPageShift;
89 static const int kPageMask = kPageSize - 1;
90 static const int kLineShift = 2;
91 static const int kLineLength = 1 << kLineShift;
92 static const int kLineMask = kLineLength - 1;
95 memset(&validity_map_, LINE_INVALID,
sizeof(validity_map_));
98 char* ValidityByte(
int offset) {
99 return &validity_map_[offset >> kLineShift];
102 char* CachedData(
int offset) {
103 return &data_[offset];
107 char data_[kPageSize];
108 static const int kValidityMapSize = kPageSize >> kLineShift;
109 char validity_map_[kValidityMapSize];
114 friend class MipsDebugger;
123 t0, t1, t2, t3, t4, t5, t6, t7,
143 f0,
f1,
f2,
f3,
f4,
f5,
f6,
f7,
f8,
f9,
f10,
f11,
145 f16,
f17,
f18,
f19,
f20,
f21,
f22,
f23,
f24,
f25,
150 explicit Simulator(Isolate* isolate);
160 void set_register(
int reg,
int32_t value);
161 void set_dw_register(
int dreg,
const int* dbl);
162 int32_t get_register(
int reg)
const;
163 double get_double_from_register_pair(
int reg);
165 void set_fpu_register(
int fpureg, int64_t value);
166 void set_fpu_register_word(
int fpureg,
int32_t value);
167 void set_fpu_register_hi_word(
int fpureg,
int32_t value);
168 void set_fpu_register_float(
int fpureg,
float value);
169 void set_fpu_register_double(
int fpureg,
double value);
170 int64_t get_fpu_register(
int fpureg)
const;
171 int32_t get_fpu_register_word(
int fpureg)
const;
172 int32_t get_fpu_register_signed_word(
int fpureg)
const;
173 int32_t get_fpu_register_hi_word(
int fpureg)
const;
174 float get_fpu_register_float(
int fpureg)
const;
175 double get_fpu_register_double(
int fpureg)
const;
178 bool set_fcsr_round_error(
double original,
double rounded);
185 return reinterpret_cast<Address>(
static_cast<intptr_t
>(get_register(
sp)));
195 static void Initialize(Isolate* isolate);
200 int32_t Call(
byte* entry,
int argument_count, ...);
202 double CallFP(
byte* entry,
double d0,
double d1);
211 void set_last_debugger_input(
char* input);
212 char* last_debugger_input() {
return last_debugger_input_; }
220 bool has_bad_pc()
const;
223 enum special_values {
233 Unpredictable = 0xbadbeaf
237 void Format(Instruction* instr,
const char* format);
242 inline void WriteB(
int32_t addr, uint8_t value);
243 inline void WriteB(
int32_t addr, int8_t value);
249 inline void WriteH(
int32_t addr,
int16_t value, Instruction* instr);
251 inline int ReadW(
int32_t addr, Instruction* instr);
252 inline void WriteW(
int32_t addr,
int value, Instruction* instr);
254 inline double ReadD(
int32_t addr, Instruction* instr);
255 inline void WriteD(
int32_t addr,
double value, Instruction* instr);
259 inline int32_t GetDoubleHIW(
double* addr);
260 inline int32_t GetDoubleLOW(
double* addr);
262 inline int32_t SetDoubleHIW(
double* addr);
263 inline int32_t SetDoubleLOW(
double* addr);
266 void DecodeTypeRegister(Instruction* instr);
269 void ConfigureTypeRegister(Instruction* instr,
277 void DecodeTypeImmediate(Instruction* instr);
278 void DecodeTypeJump(Instruction* instr);
281 void SoftwareInterrupt(Instruction* instr);
285 void PrintWatchpoint(
uint32_t code);
286 void HandleStop(
uint32_t code, Instruction* instr);
287 bool IsStopInstruction(Instruction* instr);
291 void IncreaseStopCounter(
uint32_t code);
296 void InstructionDecode(Instruction* instr);
298 void BranchDelayInstructionDecode(Instruction* instr) {
299 if (instr->InstructionBits() ==
nopInstr) {
305 if (instr->IsForbiddenInBranchDelay()) {
307 "Eror:Unexpected %i opcode in a branch delay slot.",
308 instr->OpcodeValue());
310 InstructionDecode(instr);
326 int16_t exceptions[kNumExceptions];
329 void SignalExceptions();
332 static void* RedirectExternalReference(
void* external_function,
336 void GetFpArgs(
double* x,
double*
y,
int32_t* z);
337 void SetFpResult(
const double& result);
339 void CallInternal(
byte* entry);
353 static const size_t stack_size_ = 1 * 1024*1024;
360 char* last_debugger_input_;
368 Instruction* break_pc_;
372 static const uint32_t kStopDisabledBit = 1 << 31;
378 struct StopCountAndDesc {
388 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
389 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \
390 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
392 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
393 Simulator::current(Isolate::Current())->Call( \
394 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)
406 return Simulator::current(isolate)->StackLimit();
410 Simulator* sim = Simulator::current(Isolate::Current());
411 return sim->PushAddress(try_catch_address);
415 Simulator::current(Isolate::Current())->PopAddress();
static uintptr_t JsLimitFromCLimit(Isolate *isolate, uintptr_t c_limit)
static void UnregisterCTryCatch()
static uintptr_t RegisterCTryCatch(uintptr_t try_catch_address)
static uintptr_t JsLimitFromCLimit(v8::internal::Isolate *isolate, uintptr_t c_limit)
enable harmony numeric enable harmony object literal extensions Optimize object size
void V8_Fatal(const char *file, int line, const char *format,...)
TypeImpl< ZoneTypeConfig > Type
const LowDwVfpRegister d1
const uint32_t kMaxStopCode
const LowDwVfpRegister d0
const int kNumFPURegisters
const int kNumSimuRegisters
int(* mips_regexp_matcher)(String *, int, const byte *, const byte *, void *, int *, int, Address, int, Isolate *)
Debugger support for the V8 JavaScript engine.