36 #ifndef V8_ARM_SIMULATOR_ARM_H_
37 #define V8_ARM_SIMULATOR_ARM_H_
41 #if !defined(USE_SIMULATOR)
48 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
49 (entry(p0, p1, p2, p3, p4))
59 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
60 (FUNCTION_CAST<arm_regexp_matcher>(entry)( \
61 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
63 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
64 reinterpret_cast<TryCatch*>(try_catch_address)
78 return try_catch_address;
86 #else // !defined(USE_SIMULATOR)
98 static const int LINE_VALID = 0;
99 static const int LINE_INVALID = 1;
101 static const int kPageShift = 12;
102 static const int kPageSize = 1 << kPageShift;
103 static const int kPageMask = kPageSize - 1;
104 static const int kLineShift = 2;
105 static const int kLineLength = 1 << kLineShift;
106 static const int kLineMask = kLineLength - 1;
109 memset(&validity_map_, LINE_INVALID,
sizeof(validity_map_));
112 char* ValidityByte(
int offset) {
113 return &validity_map_[offset >> kLineShift];
116 char* CachedData(
int offset) {
117 return &data_[offset];
121 char data_[kPageSize];
122 static const int kValidityMapSize = kPageSize >> kLineShift;
123 char validity_map_[kValidityMapSize];
129 friend class ArmDebugger;
142 num_s_registers = 32,
148 explicit Simulator(Isolate* isolate);
158 void set_register(
int reg,
int32_t value);
159 int32_t get_register(
int reg)
const;
160 double get_double_from_register_pair(
int reg);
161 void set_dw_register(
int dreg,
const int* dbl);
164 void set_s_register(
int reg,
unsigned int value);
165 unsigned int get_s_register(
int reg)
const;
166 void set_d_register_from_double(
int dreg,
const double& dbl);
167 double get_double_from_d_register(
int dreg);
168 void set_s_register_from_float(
int sreg,
const float dbl);
169 float get_float_from_s_register(
int sreg);
170 void set_s_register_from_sinteger(
int reg,
const int value);
171 int get_sinteger_from_s_register(
int reg);
178 uintptr_t StackLimit()
const;
184 static void Initialize(Isolate* isolate);
189 int32_t Call(
byte* entry,
int argument_count, ...);
192 uintptr_t PushAddress(uintptr_t address);
195 uintptr_t PopAddress();
198 void set_last_debugger_input(
char* input);
199 char* last_debugger_input() {
return last_debugger_input_; }
207 bool has_bad_pc()
const;
210 bool use_eabi_hardfloat() {
211 #if USE_EABI_HARDFLOAT
219 enum special_values {
231 void Format(Instruction* instr,
const char* format);
235 bool ConditionallyExecute(Instruction* instr);
239 void SetCFlag(
bool val);
240 void SetVFlag(
bool val);
243 bool OverflowFrom(
int32_t alu_out,
248 inline int GetCarry() {
249 return c_flag_ ? 1 : 0;
253 void Compute_FPSCR_Flags(
double val1,
double val2);
254 void Copy_FPSCR_to_APSR();
257 int32_t GetShiftRm(Instruction* instr,
bool* carry_out);
258 int32_t GetImm(Instruction* instr,
bool* carry_out);
259 void ProcessPUW(Instruction* instr,
262 intptr_t* start_address,
263 intptr_t* end_address);
264 void HandleRList(Instruction* instr,
bool load);
265 void HandleVList(Instruction* inst);
266 void SoftwareInterrupt(Instruction* instr);
269 inline bool isStopInstruction(Instruction* instr);
270 inline bool isWatchedStop(uint32_t bkpt_code);
271 inline bool isEnabledStop(uint32_t bkpt_code);
272 inline void EnableStop(uint32_t bkpt_code);
273 inline void DisableStop(uint32_t bkpt_code);
274 inline void IncreaseStopCounter(uint32_t bkpt_code);
275 void PrintStopInfo(uint32_t code);
278 inline uint8_t ReadBU(
int32_t addr);
279 inline int8_t ReadB(
int32_t addr);
280 inline void WriteB(
int32_t addr, uint8_t value);
281 inline void WriteB(
int32_t addr, int8_t value);
287 inline void WriteH(
int32_t addr,
int16_t value, Instruction* instr);
289 inline int ReadW(
int32_t addr, Instruction* instr);
290 inline void WriteW(
int32_t addr,
int value, Instruction* instr);
297 void DecodeType01(Instruction* instr);
298 void DecodeType2(Instruction* instr);
299 void DecodeType3(Instruction* instr);
300 void DecodeType4(Instruction* instr);
301 void DecodeType5(Instruction* instr);
302 void DecodeType6(Instruction* instr);
303 void DecodeType7(Instruction* instr);
306 void DecodeTypeVFP(Instruction* instr);
307 void DecodeType6CoprocessorIns(Instruction* instr);
309 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instruction* instr);
310 void DecodeVCMP(Instruction* instr);
311 void DecodeVCVTBetweenDoubleAndSingle(Instruction* instr);
312 void DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr);
315 void InstructionDecode(Instruction* instr);
324 static void* RedirectExternalReference(
325 void* external_function,
326 v8::internal::ExternalReference::Type
type);
329 void GetFpArgs(
double* x,
double* y);
330 void GetFpArgs(
double* x);
331 void GetFpArgs(
double* x,
int32_t* y);
332 void SetFpResult(
const double& result);
333 void TrashCallerSaveRegisters();
346 unsigned int vfp_register[num_s_registers];
356 bool inv_op_vfp_flag_;
357 bool div_zero_vfp_flag_;
358 bool overflow_vfp_flag_;
359 bool underflow_vfp_flag_;
360 bool inexact_vfp_flag_;
368 char* last_debugger_input_;
374 Instruction* break_pc_;
381 static const uint32_t kNumOfWatchedStops = 256;
384 static const uint32_t kStopDisabledBit = 1 << 31;
390 struct StopCountAndDesc {
394 StopCountAndDesc watched_stops[kNumOfWatchedStops];
400 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
401 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \
402 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
404 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
405 Simulator::current(Isolate::Current())->Call( \
406 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)
408 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
409 try_catch_address == NULL ? \
410 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address))
422 return Simulator::current(isolate)->StackLimit();
426 Simulator* sim = Simulator::current(Isolate::Current());
427 return sim->PushAddress(try_catch_address);
431 Simulator::current(Isolate::Current())->PopAddress();
437 #endif // !defined(USE_SIMULATOR)
438 #endif // V8_ARM_SIMULATOR_ARM_H_
static void UnregisterCTryCatch()
static uintptr_t JsLimitFromCLimit(v8::internal::Isolate *isolate, uintptr_t c_limit)
static uintptr_t RegisterCTryCatch(uintptr_t try_catch_address)
int(* arm_regexp_matcher)(String *, int, const byte *, const byte *, void *, int *, int, Address, int, Isolate *)