13 #ifndef V8_ARM_SIMULATOR_ARM_H_
14 #define V8_ARM_SIMULATOR_ARM_H_
18 #if !defined(USE_SIMULATOR)
25 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
26 (entry(p0, p1, p2, p3, p4))
36 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
37 (FUNCTION_CAST<arm_regexp_matcher>(entry)( \
38 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
52 return try_catch_address;
72 static const int LINE_VALID = 0;
73 static const int LINE_INVALID = 1;
75 static const int kPageShift = 12;
76 static const int kPageSize = 1 << kPageShift;
77 static const int kPageMask = kPageSize - 1;
78 static const int kLineShift = 2;
79 static const int kLineLength = 1 << kLineShift;
80 static const int kLineMask = kLineLength - 1;
83 memset(&validity_map_, LINE_INVALID,
sizeof(validity_map_));
86 char* ValidityByte(
int offset) {
87 return &validity_map_[offset >> kLineShift];
90 char* CachedData(
int offset) {
91 return &data_[offset];
95 char data_[kPageSize];
96 static const int kValidityMapSize = kPageSize >> kLineShift;
97 char validity_map_[kValidityMapSize];
103 friend class ArmDebugger;
116 num_s_registers = 32,
121 num_d_registers = 32,
127 explicit Simulator(Isolate* isolate);
137 void set_register(
int reg,
int32_t value);
138 int32_t get_register(
int reg)
const;
139 double get_double_from_register_pair(
int reg);
140 void set_register_pair_from_double(
int reg,
double* value);
141 void set_dw_register(
int dreg,
const int* dbl);
144 void get_d_register(
int dreg, uint64_t* value);
145 void set_d_register(
int dreg,
const uint64_t* value);
146 void get_d_register(
int dreg,
uint32_t* value);
147 void set_d_register(
int dreg,
const uint32_t* value);
148 void get_q_register(
int qreg, uint64_t* value);
149 void set_q_register(
int qreg,
const uint64_t* value);
150 void get_q_register(
int qreg,
uint32_t* value);
151 void set_q_register(
int qreg,
const uint32_t* value);
153 void set_s_register(
int reg,
unsigned int value);
154 unsigned int get_s_register(
int reg)
const;
156 void set_d_register_from_double(
int dreg,
const double& dbl) {
157 SetVFPRegister<double, 2>(dreg, dbl);
160 double get_double_from_d_register(
int dreg) {
161 return GetFromVFPRegister<double, 2>(dreg);
164 void set_s_register_from_float(
int sreg,
const float flt) {
165 SetVFPRegister<float, 1>(sreg, flt);
168 float get_float_from_s_register(
int sreg) {
169 return GetFromVFPRegister<float, 1>(sreg);
172 void set_s_register_from_sinteger(
int sreg,
const int sint) {
173 SetVFPRegister<int, 1>(sreg, sint);
176 int get_sinteger_from_s_register(
int sreg) {
177 return GetFromVFPRegister<int, 1>(sreg);
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 void CallFP(
byte* entry,
double d0,
double d1);
203 int32_t CallFPReturnsInt(
byte* entry,
double d0,
double d1);
204 double CallFPReturnsDouble(
byte* entry,
double d0,
double d1);
213 void set_last_debugger_input(
char* input);
214 char* last_debugger_input() {
return last_debugger_input_; }
222 bool has_bad_pc()
const;
225 bool use_eabi_hardfloat() {
226 #if USE_EABI_HARDFLOAT
234 enum special_values {
246 void Format(Instruction* instr,
const char* format);
250 inline bool ConditionallyExecute(Instruction* instr);
254 void SetCFlag(
bool val);
255 void SetVFlag(
bool val);
258 bool OverflowFrom(
int32_t alu_out,
263 inline int GetCarry() {
264 return c_flag_ ? 1 : 0;
268 void Compute_FPSCR_Flags(
double val1,
double val2);
269 void Copy_FPSCR_to_APSR();
270 inline double canonicalizeNaN(
double value);
273 int32_t GetShiftRm(Instruction* instr,
bool* carry_out);
274 int32_t GetImm(Instruction* instr,
bool* carry_out);
275 int32_t ProcessPU(Instruction* instr,
278 intptr_t* start_address,
279 intptr_t* end_address);
280 void HandleRList(Instruction* instr,
bool load);
281 void HandleVList(Instruction* inst);
282 void SoftwareInterrupt(Instruction* instr);
285 inline bool isStopInstruction(Instruction* instr);
286 inline bool isWatchedStop(
uint32_t bkpt_code);
287 inline bool isEnabledStop(
uint32_t bkpt_code);
288 inline void EnableStop(
uint32_t bkpt_code);
289 inline void DisableStop(
uint32_t bkpt_code);
290 inline void IncreaseStopCounter(
uint32_t bkpt_code);
294 inline uint8_t ReadBU(
int32_t addr);
295 inline int8_t ReadB(
int32_t addr);
296 inline void WriteB(
int32_t addr, uint8_t value);
297 inline void WriteB(
int32_t addr, int8_t value);
303 inline void WriteH(
int32_t addr,
int16_t value, Instruction* instr);
305 inline int ReadW(
int32_t addr, Instruction* instr);
306 inline void WriteW(
int32_t addr,
int value, Instruction* instr);
313 void DecodeType01(Instruction* instr);
314 void DecodeType2(Instruction* instr);
315 void DecodeType3(Instruction* instr);
316 void DecodeType4(Instruction* instr);
317 void DecodeType5(Instruction* instr);
318 void DecodeType6(Instruction* instr);
319 void DecodeType7(Instruction* instr);
322 void DecodeTypeVFP(Instruction* instr);
323 void DecodeType6CoprocessorIns(Instruction* instr);
324 void DecodeSpecialCondition(Instruction* instr);
326 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instruction* instr);
327 void DecodeVCMP(Instruction* instr);
328 void DecodeVCVTBetweenDoubleAndSingle(Instruction* instr);
329 void DecodeVCVTBetweenFloatingPointAndInteger(Instruction* instr);
332 void InstructionDecode(Instruction* instr);
341 static void* RedirectExternalReference(
342 void* external_function,
346 void GetFpArgs(
double* x,
double*
y,
int32_t* z);
347 void SetFpResult(
const double& result);
348 void TrashCallerSaveRegisters();
350 template<
class ReturnType,
int register_size>
351 ReturnType GetFromVFPRegister(
int reg_index);
353 template<
class InputType,
int register_size>
354 void SetVFPRegister(
int reg_index,
const InputType& value);
356 void CallInternal(
byte* entry);
369 unsigned int vfp_registers_[num_d_registers * 2];
377 bool FPSCR_default_NaN_mode_;
380 bool inv_op_vfp_flag_;
381 bool div_zero_vfp_flag_;
382 bool overflow_vfp_flag_;
383 bool underflow_vfp_flag_;
384 bool inexact_vfp_flag_;
392 char* last_debugger_input_;
398 Instruction* break_pc_;
405 static const uint32_t kNumOfWatchedStops = 256;
408 static const uint32_t kStopDisabledBit = 1 << 31;
414 struct StopCountAndDesc {
418 StopCountAndDesc watched_stops_[kNumOfWatchedStops];
424 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
425 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \
426 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
428 #define CALL_GENERATED_FP_INT(entry, p0, p1) \
429 Simulator::current(Isolate::Current())->CallFPReturnsInt( \
430 FUNCTION_ADDR(entry), p0, p1)
432 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
433 Simulator::current(Isolate::Current())->Call( \
434 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)
446 return Simulator::current(isolate)->StackLimit();
450 Simulator* sim = Simulator::current(Isolate::Current());
451 return sim->PushAddress(try_catch_address);
455 Simulator::current(Isolate::Current())->PopAddress();
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
const LowDwVfpRegister d2
const LowDwVfpRegister d7
const LowDwVfpRegister d6
TypeImpl< ZoneTypeConfig > Type
const LowDwVfpRegister d9
const LowDwVfpRegister d1
const LowDwVfpRegister d5
const LowDwVfpRegister d0
const LowDwVfpRegister d8
const LowDwVfpRegister d12
const LowDwVfpRegister d11
const LowDwVfpRegister d13
const LowDwVfpRegister d3
int(* arm_regexp_matcher)(String *, int, const byte *, const byte *, void *, int *, int, Address, int, Isolate *)
const LowDwVfpRegister d10
const LowDwVfpRegister d15
const LowDwVfpRegister d14
const LowDwVfpRegister d4
Debugger support for the V8 JavaScript engine.