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 const byte* input_start,
38 const byte* input_end,
46 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
47 (FUNCTION_CAST<mips_regexp_matcher>(entry)( \
48 p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8))
54 const byte* input_start,
55 const byte* input_end,
63 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
64 (FUNCTION_CAST<mips_regexp_matcher>(entry)( \
65 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
81 return try_catch_address;
95 #define GENERATED_CODE_STACK_LIMIT(limit) \
96 (reinterpret_cast<uintptr_t>(this) >= limit ? \
97 reinterpret_cast<uintptr_t>(this) - limit : 0)
113 static const int LINE_VALID = 0;
114 static const int LINE_INVALID = 1;
116 static const int kPageShift = 12;
117 static const int kPageSize = 1 << kPageShift;
118 static const int kPageMask = kPageSize - 1;
119 static const int kLineShift = 2;
120 static const int kLineLength = 1 << kLineShift;
121 static const int kLineMask = kLineLength - 1;
124 memset(&validity_map_, LINE_INVALID,
sizeof(validity_map_));
127 char* ValidityByte(
int offset) {
128 return &validity_map_[offset >> kLineShift];
131 char* CachedData(
int offset) {
132 return &data_[offset];
136 char data_[kPageSize];
137 static const int kValidityMapSize = kPageSize >> kLineShift;
138 char validity_map_[kValidityMapSize];
143 friend class MipsDebugger;
151 a0, a1, a2, a3, a4, a5, a6, a7,
172 f0,
f1,
f2,
f3,
f4,
f5,
f6,
f7,
f8,
f9,
f10,
f11,
174 f16,
f17,
f18,
f19,
f20,
f21,
f22,
f23,
f24,
f25,
179 explicit Simulator(Isolate* isolate);
189 void set_register(
int reg, int64_t value);
190 void set_register_word(
int reg,
int32_t value);
191 void set_dw_register(
int dreg,
const int* dbl);
192 int64_t get_register(
int reg)
const;
193 double get_double_from_register_pair(
int reg);
195 void set_fpu_register(
int fpureg, int64_t value);
196 void set_fpu_register_word(
int fpureg,
int32_t value);
197 void set_fpu_register_hi_word(
int fpureg,
int32_t value);
198 void set_fpu_register_float(
int fpureg,
float value);
199 void set_fpu_register_double(
int fpureg,
double value);
200 int64_t get_fpu_register(
int fpureg)
const;
201 int32_t get_fpu_register_word(
int fpureg)
const;
202 int32_t get_fpu_register_signed_word(
int fpureg)
const;
203 int32_t get_fpu_register_hi_word(
int fpureg)
const;
204 float get_fpu_register_float(
int fpureg)
const;
205 double get_fpu_register_double(
int fpureg)
const;
208 bool set_fcsr_round_error(
double original,
double rounded);
209 bool set_fcsr_round64_error(
double original,
double rounded);
212 void set_pc(int64_t value);
213 int64_t get_pc()
const;
216 return reinterpret_cast<Address>(
static_cast<intptr_t
>(get_register(
sp)));
226 static void Initialize(Isolate* isolate);
231 int64_t Call(
byte* entry,
int argument_count, ...);
233 double CallFP(
byte* entry,
double d0,
double d1);
242 void set_last_debugger_input(
char* input);
243 char* last_debugger_input() {
return last_debugger_input_; }
251 bool has_bad_pc()
const;
254 enum special_values {
264 Unpredictable = 0xbadbeaf
268 void Format(Instruction* instr,
const char* format);
271 inline uint32_t ReadBU(int64_t addr);
272 inline int32_t ReadB(int64_t addr);
273 inline void WriteB(int64_t addr, uint8_t value);
274 inline void WriteB(int64_t addr, int8_t value);
276 inline uint16_t ReadHU(int64_t addr, Instruction* instr);
277 inline int16_t ReadH(int64_t addr, Instruction* instr);
279 inline void WriteH(int64_t addr,
uint16_t value, Instruction* instr);
280 inline void WriteH(int64_t addr,
int16_t value, Instruction* instr);
282 inline uint32_t ReadWU(int64_t addr, Instruction* instr);
283 inline int32_t ReadW(int64_t addr, Instruction* instr);
284 inline void WriteW(int64_t addr,
int32_t value, Instruction* instr);
285 inline int64_t Read2W(int64_t addr, Instruction* instr);
286 inline void Write2W(int64_t addr, int64_t value, Instruction* instr);
288 inline double ReadD(int64_t addr, Instruction* instr);
289 inline void WriteD(int64_t addr,
double value, Instruction* instr);
292 inline void DieOrDebug();
303 void TraceRegWr(int64_t value);
304 void TraceMemWr(int64_t addr, int64_t value, TraceType t);
305 void TraceMemRd(int64_t addr, int64_t value);
309 inline int32_t GetDoubleHIW(
double* addr);
310 inline int32_t GetDoubleLOW(
double* addr);
312 inline int32_t SetDoubleHIW(
double* addr);
313 inline int32_t SetDoubleLOW(
double* addr);
316 void DecodeTypeRegister(Instruction* instr);
319 void ConfigureTypeRegister(Instruction* instr,
324 int64_t* return_addr_reg,
327 int64_t* result128L);
329 void DecodeTypeImmediate(Instruction* instr);
330 void DecodeTypeJump(Instruction* instr);
333 void SoftwareInterrupt(Instruction* instr);
336 bool IsWatchpoint(uint64_t code);
337 void PrintWatchpoint(uint64_t code);
338 void HandleStop(uint64_t code, Instruction* instr);
339 bool IsStopInstruction(Instruction* instr);
340 bool IsEnabledStop(uint64_t code);
341 void EnableStop(uint64_t code);
342 void DisableStop(uint64_t code);
343 void IncreaseStopCounter(uint64_t code);
344 void PrintStopInfo(uint64_t code);
348 void InstructionDecode(Instruction* instr);
350 void BranchDelayInstructionDecode(Instruction* instr) {
351 if (instr->InstructionBits() ==
nopInstr) {
357 if (instr->IsForbiddenInBranchDelay()) {
359 "Eror:Unexpected %i opcode in a branch delay slot.",
360 instr->OpcodeValue());
362 InstructionDecode(instr);
378 int16_t exceptions[kNumExceptions];
381 void SignalExceptions();
384 static void* RedirectExternalReference(
void* external_function,
388 void GetFpArgs(
double* x,
double*
y,
int32_t* z);
389 void SetFpResult(
const double& result);
391 void CallInternal(
byte* entry);
408 EmbeddedVector<char, 128> trace_buf_;
411 char* last_debugger_input_;
419 Instruction* break_pc_;
423 static const uint32_t kStopDisabledBit = 1 << 31;
429 struct StopCountAndDesc {
439 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
440 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \
441 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
444 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
445 Simulator::current(Isolate::Current())->Call( \
446 entry, 10, p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8)
448 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
449 Simulator::current(Isolate::Current())->Call( \
450 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)
463 return Simulator::current(isolate)->StackLimit();
467 Simulator* sim = Simulator::current(Isolate::Current());
468 return sim->PushAddress(try_catch_address);
472 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,...)
typedef DWORD(__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID)
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.