36 #ifndef V8_MIPS_SIMULATOR_MIPS_H_
37 #define V8_MIPS_SIMULATOR_MIPS_H_
42 #if !defined(USE_SIMULATOR)
49 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
50 entry(p0, p1, p2, p3, p4)
60 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
61 (FUNCTION_CAST<mips_regexp_matcher>(entry)( \
62 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
64 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
65 reinterpret_cast<TryCatch*>(try_catch_address)
78 return try_catch_address;
92 #define GENERATED_CODE_STACK_LIMIT(limit) \
93 (reinterpret_cast<uintptr_t>(this) >= limit ? \
94 reinterpret_cast<uintptr_t>(this) - limit : 0)
96 #else // !defined(USE_SIMULATOR)
110 static const int LINE_VALID = 0;
111 static const int LINE_INVALID = 1;
113 static const int kPageShift = 12;
114 static const int kPageSize = 1 << kPageShift;
115 static const int kPageMask = kPageSize - 1;
116 static const int kLineShift = 2;
117 static const int kLineLength = 1 << kLineShift;
118 static const int kLineMask = kLineLength - 1;
121 memset(&validity_map_, LINE_INVALID,
sizeof(validity_map_));
124 char* ValidityByte(
int offset) {
125 return &validity_map_[offset >> kLineShift];
128 char* CachedData(
int offset) {
129 return &data_[offset];
133 char data_[kPageSize];
134 static const int kValidityMapSize = kPageSize >> kLineShift;
135 char validity_map_[kValidityMapSize];
140 friend class MipsDebugger;
149 t0, t1, t2, t3, t4, t5, t6, t7,
169 f0,
f1,
f2,
f3,
f4,
f5,
f6,
f7,
f8,
f9,
f10,
f11,
171 f16,
f17,
f18,
f19,
f20,
f21,
f22,
f23,
f24,
f25,
176 explicit Simulator(Isolate* isolate);
186 void set_register(
int reg,
int32_t value);
187 int32_t get_register(
int reg)
const;
189 void set_fpu_register(
int fpureg,
int32_t value);
190 void set_fpu_register_float(
int fpureg,
float value);
191 void set_fpu_register_double(
int fpureg,
double value);
192 int32_t get_fpu_register(
int fpureg)
const;
193 int64_t get_fpu_register_long(
int fpureg)
const;
194 float get_fpu_register_float(
int fpureg)
const;
195 double get_fpu_register_double(
int fpureg)
const;
196 void set_fcsr_bit(uint32_t
cc,
bool value);
197 bool test_fcsr_bit(uint32_t cc);
198 bool set_fcsr_round_error(
double original,
double rounded);
205 uintptr_t StackLimit()
const;
211 static void Initialize(Isolate* isolate);
216 int32_t Call(
byte* entry,
int argument_count, ...);
219 uintptr_t PushAddress(uintptr_t address);
222 uintptr_t PopAddress();
225 void set_last_debugger_input(
char* input);
226 char* last_debugger_input() {
return last_debugger_input_; }
234 bool has_bad_pc()
const;
237 enum special_values {
247 Unpredictable = 0xbadbeaf
251 void Format(Instruction* instr,
const char* format);
254 inline uint32_t ReadBU(
int32_t addr);
256 inline void WriteB(
int32_t addr, uint8_t value);
257 inline void WriteB(
int32_t addr, int8_t value);
263 inline void WriteH(
int32_t addr,
int16_t value, Instruction* instr);
265 inline int ReadW(
int32_t addr, Instruction* instr);
266 inline void WriteW(
int32_t addr,
int value, Instruction* instr);
268 inline double ReadD(
int32_t addr, Instruction* instr);
269 inline void WriteD(
int32_t addr,
double value, Instruction* instr);
273 inline int32_t GetDoubleHIW(
double* addr);
274 inline int32_t GetDoubleLOW(
double* addr);
276 inline int32_t SetDoubleHIW(
double* addr);
277 inline int32_t SetDoubleLOW(
double* addr);
280 void DecodeTypeRegister(Instruction* instr);
283 void ConfigureTypeRegister(Instruction* instr,
290 void DecodeTypeImmediate(Instruction* instr);
291 void DecodeTypeJump(Instruction* instr);
294 void SoftwareInterrupt(Instruction* instr);
297 bool IsWatchpoint(uint32_t
code);
298 void PrintWatchpoint(uint32_t code);
299 void HandleStop(uint32_t code, Instruction* instr);
300 bool IsStopInstruction(Instruction* instr);
301 bool IsEnabledStop(uint32_t code);
302 void EnableStop(uint32_t code);
303 void DisableStop(uint32_t code);
304 void IncreaseStopCounter(uint32_t code);
305 void PrintStopInfo(uint32_t code);
309 void InstructionDecode(Instruction* instr);
311 void BranchDelayInstructionDecode(Instruction* instr) {
312 if (instr->InstructionBits() ==
nopInstr) {
315 set_register(
pc, reinterpret_cast<int32_t>(instr) +
320 if (instr->IsForbiddenInBranchDelay()) {
322 "Eror:Unexpected %i opcode in a branch delay slot.",
323 instr->OpcodeValue());
325 InstructionDecode(instr);
341 int16_t exceptions[kNumExceptions];
344 void SignalExceptions();
347 static void* RedirectExternalReference(
void* external_function,
348 ExternalReference::Type type);
351 void GetFpArgs(
double* x,
double* y);
352 void GetFpArgs(
double* x);
353 void GetFpArgs(
double* x,
int32_t* y);
354 void SetFpResult(
const double& result);
367 static const size_t stack_size_ = 1 * 1024*1024;
374 char* last_debugger_input_;
382 Instruction* break_pc_;
386 static const uint32_t kStopDisabledBit = 1 << 31;
392 struct StopCountAndDesc {
402 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
403 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \
404 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
406 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
407 Simulator::current(Isolate::Current())->Call( \
408 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)
410 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
411 try_catch_address == NULL ? \
412 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address))
424 return Simulator::current(isolate)->StackLimit();
428 Simulator* sim = Simulator::current(Isolate::Current());
429 return sim->PushAddress(try_catch_address);
433 Simulator::current(Isolate::Current())->PopAddress();
439 #endif // !defined(USE_SIMULATOR)
440 #endif // V8_MIPS_SIMULATOR_MIPS_H_
static uintptr_t JsLimitFromCLimit(Isolate *isolate, uintptr_t c_limit)
const int kNumSimuRegisters
int(* mips_regexp_matcher)(String *, int, const byte *, const byte *, void *, int *, int, Address, int, Isolate *)
const uint32_t kMaxStopCode
static void UnregisterCTryCatch()
const int kNumFPURegisters
void V8_Fatal(const char *file, int line, const char *format,...)
static uintptr_t JsLimitFromCLimit(v8::internal::Isolate *isolate, uintptr_t c_limit)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
static uintptr_t RegisterCTryCatch(uintptr_t try_catch_address)