| OLD | NEW | 
|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 | 5 | 
| 6 // Declares a Simulator for MIPS instructions if we are not generating a native | 6 // Declares a Simulator for MIPS instructions if we are not generating a native | 
| 7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation | 7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation | 
| 8 // on regular desktop machines. | 8 // on regular desktop machines. | 
| 9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, | 9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, | 
| 10 // which will start execution in the Simulator or forwards to the real entry | 10 // which will start execution in the Simulator or forwards to the real entry | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 177   // Coprocessor registers. | 177   // Coprocessor registers. | 
| 178   // Generated code will always use doubles. So we will only use even registers. | 178   // Generated code will always use doubles. So we will only use even registers. | 
| 179   enum FPURegister { | 179   enum FPURegister { | 
| 180     f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, | 180     f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, | 
| 181     f12, f13, f14, f15,   // f12 and f14 are arguments FPURegisters. | 181     f12, f13, f14, f15,   // f12 and f14 are arguments FPURegisters. | 
| 182     f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, | 182     f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, | 
| 183     f26, f27, f28, f29, f30, f31, | 183     f26, f27, f28, f29, f30, f31, | 
| 184     kNumFPURegisters | 184     kNumFPURegisters | 
| 185   }; | 185   }; | 
| 186 | 186 | 
|  | 187   // MSA registers | 
|  | 188   enum MSARegister { | 
|  | 189     w0, | 
|  | 190     w1, | 
|  | 191     w2, | 
|  | 192     w3, | 
|  | 193     w4, | 
|  | 194     w5, | 
|  | 195     w6, | 
|  | 196     w7, | 
|  | 197     w8, | 
|  | 198     w9, | 
|  | 199     w10, | 
|  | 200     w11, | 
|  | 201     w12, | 
|  | 202     w13, | 
|  | 203     w14, | 
|  | 204     w15, | 
|  | 205     w16, | 
|  | 206     w17, | 
|  | 207     w18, | 
|  | 208     w19, | 
|  | 209     w20, | 
|  | 210     w21, | 
|  | 211     w22, | 
|  | 212     w23, | 
|  | 213     w24, | 
|  | 214     w25, | 
|  | 215     w26, | 
|  | 216     w27, | 
|  | 217     w28, | 
|  | 218     w29, | 
|  | 219     w30, | 
|  | 220     w31, | 
|  | 221     kNumMSARegisters | 
|  | 222   }; | 
|  | 223 | 
| 187   explicit Simulator(Isolate* isolate); | 224   explicit Simulator(Isolate* isolate); | 
| 188   ~Simulator(); | 225   ~Simulator(); | 
| 189 | 226 | 
| 190   // The currently executing Simulator instance. Potentially there can be one | 227   // The currently executing Simulator instance. Potentially there can be one | 
| 191   // for each native thread. | 228   // for each native thread. | 
| 192   static Simulator* current(v8::internal::Isolate* isolate); | 229   static Simulator* current(v8::internal::Isolate* isolate); | 
| 193 | 230 | 
| 194   // Accessors for register state. Reading the pc value adheres to the MIPS | 231   // Accessors for register state. Reading the pc value adheres to the MIPS | 
| 195   // architecture specification and is off by a 8 from the currently executing | 232   // architecture specification and is off by a 8 from the currently executing | 
| 196   // instruction. | 233   // instruction. | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 209   void set_fpu_register_word_invalid_result(float original, float rounded); | 246   void set_fpu_register_word_invalid_result(float original, float rounded); | 
| 210   void set_fpu_register_invalid_result64(double original, double rounded); | 247   void set_fpu_register_invalid_result64(double original, double rounded); | 
| 211   void set_fpu_register_invalid_result(double original, double rounded); | 248   void set_fpu_register_invalid_result(double original, double rounded); | 
| 212   void set_fpu_register_word_invalid_result(double original, double rounded); | 249   void set_fpu_register_word_invalid_result(double original, double rounded); | 
| 213   int64_t get_fpu_register(int fpureg) const; | 250   int64_t get_fpu_register(int fpureg) const; | 
| 214   int32_t get_fpu_register_word(int fpureg) const; | 251   int32_t get_fpu_register_word(int fpureg) const; | 
| 215   int32_t get_fpu_register_signed_word(int fpureg) const; | 252   int32_t get_fpu_register_signed_word(int fpureg) const; | 
| 216   int32_t get_fpu_register_hi_word(int fpureg) const; | 253   int32_t get_fpu_register_hi_word(int fpureg) const; | 
| 217   float get_fpu_register_float(int fpureg) const; | 254   float get_fpu_register_float(int fpureg) const; | 
| 218   double get_fpu_register_double(int fpureg) const; | 255   double get_fpu_register_double(int fpureg) const; | 
|  | 256   template <typename T> | 
|  | 257   void get_msa_register(int wreg, T* value); | 
|  | 258   template <typename T> | 
|  | 259   void set_msa_register(int wreg, const T* value); | 
| 219   void set_fcsr_bit(uint32_t cc, bool value); | 260   void set_fcsr_bit(uint32_t cc, bool value); | 
| 220   bool test_fcsr_bit(uint32_t cc); | 261   bool test_fcsr_bit(uint32_t cc); | 
| 221   void set_fcsr_rounding_mode(FPURoundingMode mode); | 262   void set_fcsr_rounding_mode(FPURoundingMode mode); | 
| 222   unsigned int get_fcsr_rounding_mode(); | 263   unsigned int get_fcsr_rounding_mode(); | 
| 223   bool set_fcsr_round_error(double original, double rounded); | 264   bool set_fcsr_round_error(double original, double rounded); | 
| 224   bool set_fcsr_round_error(float original, float rounded); | 265   bool set_fcsr_round_error(float original, float rounded); | 
| 225   bool set_fcsr_round64_error(double original, double rounded); | 266   bool set_fcsr_round64_error(double original, double rounded); | 
| 226   bool set_fcsr_round64_error(float original, float rounded); | 267   bool set_fcsr_round64_error(float original, float rounded); | 
| 227   void round_according_to_fcsr(double toRound, double& rounded, | 268   void round_according_to_fcsr(double toRound, double& rounded, | 
| 228                                int32_t& rounded_int, double fs); | 269                                int32_t& rounded_int, double fs); | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 289     // Unpredictable value. | 330     // Unpredictable value. | 
| 290     Unpredictable = 0xbadbeaf | 331     Unpredictable = 0xbadbeaf | 
| 291   }; | 332   }; | 
| 292 | 333 | 
| 293   // Unsupported instructions use Format to print an error and stop execution. | 334   // Unsupported instructions use Format to print an error and stop execution. | 
| 294   void Format(Instruction* instr, const char* format); | 335   void Format(Instruction* instr, const char* format); | 
| 295 | 336 | 
| 296   // Helpers for data value tracing. | 337   // Helpers for data value tracing. | 
| 297   enum TraceType { BYTE, HALF, WORD, DWORD, FLOAT, DOUBLE, FLOAT_DOUBLE }; | 338   enum TraceType { BYTE, HALF, WORD, DWORD, FLOAT, DOUBLE, FLOAT_DOUBLE }; | 
| 298 | 339 | 
|  | 340   // MSA Data Format | 
|  | 341   enum MSADataFormat { MSA_VECT = 0, MSA_BYTE, MSA_HALF, MSA_WORD, MSA_DWORD }; | 
|  | 342 | 
| 299   // Read and write memory. | 343   // Read and write memory. | 
| 300   inline uint32_t ReadBU(int32_t addr); | 344   inline uint32_t ReadBU(int32_t addr); | 
| 301   inline int32_t ReadB(int32_t addr); | 345   inline int32_t ReadB(int32_t addr); | 
| 302   inline void WriteB(int32_t addr, uint8_t value); | 346   inline void WriteB(int32_t addr, uint8_t value); | 
| 303   inline void WriteB(int32_t addr, int8_t value); | 347   inline void WriteB(int32_t addr, int8_t value); | 
| 304 | 348 | 
| 305   inline uint16_t ReadHU(int32_t addr, Instruction* instr); | 349   inline uint16_t ReadHU(int32_t addr, Instruction* instr); | 
| 306   inline int16_t ReadH(int32_t addr, Instruction* instr); | 350   inline int16_t ReadH(int32_t addr, Instruction* instr); | 
| 307   // Note: Overloaded on the sign of the value. | 351   // Note: Overloaded on the sign of the value. | 
| 308   inline void WriteH(int32_t addr, uint16_t value, Instruction* instr); | 352   inline void WriteH(int32_t addr, uint16_t value, Instruction* instr); | 
| 309   inline void WriteH(int32_t addr, int16_t value, Instruction* instr); | 353   inline void WriteH(int32_t addr, int16_t value, Instruction* instr); | 
| 310 | 354 | 
| 311   inline int ReadW(int32_t addr, Instruction* instr, TraceType t = WORD); | 355   inline int ReadW(int32_t addr, Instruction* instr, TraceType t = WORD); | 
| 312   inline void WriteW(int32_t addr, int value, Instruction* instr); | 356   inline void WriteW(int32_t addr, int value, Instruction* instr); | 
| 313 | 357 | 
| 314   inline double ReadD(int32_t addr, Instruction* instr); | 358   inline double ReadD(int32_t addr, Instruction* instr); | 
| 315   inline void WriteD(int32_t addr, double value, Instruction* instr); | 359   inline void WriteD(int32_t addr, double value, Instruction* instr); | 
| 316 | 360 | 
| 317   void TraceRegWr(int32_t value, TraceType t = WORD); | 361   void TraceRegWr(int32_t value, TraceType t = WORD); | 
| 318   void TraceRegWr(int64_t value, TraceType t = DWORD); | 362   void TraceRegWr(int64_t value, TraceType t = DWORD); | 
|  | 363   template <typename T> | 
|  | 364   void TraceMSARegWr(T* value, TraceType t); | 
| 319   void TraceMemWr(int32_t addr, int32_t value, TraceType t = WORD); | 365   void TraceMemWr(int32_t addr, int32_t value, TraceType t = WORD); | 
| 320   void TraceMemRd(int32_t addr, int32_t value, TraceType t = WORD); | 366   void TraceMemRd(int32_t addr, int32_t value, TraceType t = WORD); | 
| 321   void TraceMemWr(int32_t addr, int64_t value, TraceType t = DWORD); | 367   void TraceMemWr(int32_t addr, int64_t value, TraceType t = DWORD); | 
| 322   void TraceMemRd(int32_t addr, int64_t value, TraceType t = DWORD); | 368   void TraceMemRd(int32_t addr, int64_t value, TraceType t = DWORD); | 
| 323   EmbeddedVector<char, 128> trace_buf_; | 369   EmbeddedVector<char, 128> trace_buf_; | 
| 324 | 370 | 
| 325   // Operations depending on endianness. | 371   // Operations depending on endianness. | 
| 326   // Get Double Higher / Lower word. | 372   // Get Double Higher / Lower word. | 
| 327   inline int32_t GetDoubleHIW(double* addr); | 373   inline int32_t GetDoubleHIW(double* addr); | 
| 328   inline int32_t GetDoubleLOW(double* addr); | 374   inline int32_t GetDoubleLOW(double* addr); | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 348 | 394 | 
| 349   // Called from DecodeTypeRegisterCOP1. | 395   // Called from DecodeTypeRegisterCOP1. | 
| 350   void DecodeTypeRegisterSRsType(); | 396   void DecodeTypeRegisterSRsType(); | 
| 351 | 397 | 
| 352   void DecodeTypeRegisterDRsType(); | 398   void DecodeTypeRegisterDRsType(); | 
| 353 | 399 | 
| 354   void DecodeTypeRegisterWRsType(); | 400   void DecodeTypeRegisterWRsType(); | 
| 355 | 401 | 
| 356   void DecodeTypeRegisterLRsType(); | 402   void DecodeTypeRegisterLRsType(); | 
| 357 | 403 | 
|  | 404   int DecodeMsaDataFormat(); | 
|  | 405   void DecodeTypeMsaI8(); | 
|  | 406   void DecodeTypeMsaI5(); | 
|  | 407   void DecodeTypeMsaI10(); | 
|  | 408   void DecodeTypeMsaELM(); | 
|  | 409   void DecodeTypeMsaBIT(); | 
|  | 410   void DecodeTypeMsaMI10(); | 
|  | 411   void DecodeTypeMsa3R(); | 
|  | 412   void DecodeTypeMsa3RF(); | 
|  | 413   void DecodeTypeMsaVec(); | 
|  | 414   void DecodeTypeMsa2R(); | 
|  | 415   void DecodeTypeMsa2RF(); | 
|  | 416 | 
| 358   inline int32_t rs_reg() const { return instr_.RsValue(); } | 417   inline int32_t rs_reg() const { return instr_.RsValue(); } | 
| 359   inline int32_t rs() const { return get_register(rs_reg()); } | 418   inline int32_t rs() const { return get_register(rs_reg()); } | 
| 360   inline uint32_t rs_u() const { | 419   inline uint32_t rs_u() const { | 
| 361     return static_cast<uint32_t>(get_register(rs_reg())); | 420     return static_cast<uint32_t>(get_register(rs_reg())); | 
| 362   } | 421   } | 
| 363   inline int32_t rt_reg() const { return instr_.RtValue(); } | 422   inline int32_t rt_reg() const { return instr_.RtValue(); } | 
| 364   inline int32_t rt() const { return get_register(rt_reg()); } | 423   inline int32_t rt() const { return get_register(rt_reg()); } | 
| 365   inline uint32_t rt_u() const { | 424   inline uint32_t rt_u() const { | 
| 366     return static_cast<uint32_t>(get_register(rt_reg())); | 425     return static_cast<uint32_t>(get_register(rt_reg())); | 
| 367   } | 426   } | 
| 368   inline int32_t rd_reg() const { return instr_.RdValue(); } | 427   inline int32_t rd_reg() const { return instr_.RdValue(); } | 
| 369   inline int32_t fr_reg() const { return instr_.FrValue(); } | 428   inline int32_t fr_reg() const { return instr_.FrValue(); } | 
| 370   inline int32_t fs_reg() const { return instr_.FsValue(); } | 429   inline int32_t fs_reg() const { return instr_.FsValue(); } | 
| 371   inline int32_t ft_reg() const { return instr_.FtValue(); } | 430   inline int32_t ft_reg() const { return instr_.FtValue(); } | 
| 372   inline int32_t fd_reg() const { return instr_.FdValue(); } | 431   inline int32_t fd_reg() const { return instr_.FdValue(); } | 
| 373   inline int32_t sa() const { return instr_.SaValue(); } | 432   inline int32_t sa() const { return instr_.SaValue(); } | 
| 374   inline int32_t lsa_sa() const { return instr_.LsaSaValue(); } | 433   inline int32_t lsa_sa() const { return instr_.LsaSaValue(); } | 
|  | 434   inline int32_t ws_reg() const { return instr_.WsValue(); } | 
|  | 435   inline int32_t wt_reg() const { return instr_.WtValue(); } | 
|  | 436   inline int32_t wd_reg() const { return instr_.WdValue(); } | 
| 375 | 437 | 
| 376   inline void SetResult(int32_t rd_reg, int32_t alu_out) { | 438   inline void SetResult(int32_t rd_reg, int32_t alu_out) { | 
| 377     set_register(rd_reg, alu_out); | 439     set_register(rd_reg, alu_out); | 
| 378     TraceRegWr(alu_out); | 440     TraceRegWr(alu_out); | 
| 379   } | 441   } | 
| 380 | 442 | 
| 381   inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { | 443   inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { | 
| 382     set_fpu_register_word(fd_reg, alu_out); | 444     set_fpu_register_word(fd_reg, alu_out); | 
| 383     TraceRegWr(get_fpu_register_word(fd_reg)); | 445     TraceRegWr(get_fpu_register_word(fd_reg)); | 
| 384   } | 446   } | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 476   void SetFpResult(const double& result); | 538   void SetFpResult(const double& result); | 
| 477 | 539 | 
| 478   void CallInternal(byte* entry); | 540   void CallInternal(byte* entry); | 
| 479 | 541 | 
| 480   // Architecture state. | 542   // Architecture state. | 
| 481   // Registers. | 543   // Registers. | 
| 482   int32_t registers_[kNumSimuRegisters]; | 544   int32_t registers_[kNumSimuRegisters]; | 
| 483   // Coprocessor Registers. | 545   // Coprocessor Registers. | 
| 484   // Note: FP32 mode uses only the lower 32-bit part of each element, | 546   // Note: FP32 mode uses only the lower 32-bit part of each element, | 
| 485   // the upper 32-bit is unpredictable. | 547   // the upper 32-bit is unpredictable. | 
| 486   int64_t FPUregisters_[kNumFPURegisters]; | 548   // Note: FPUregisters_[] array is increased to 64 * 8B = 32 * 16B in | 
|  | 549   // order to support MSA registers | 
|  | 550   int64_t FPUregisters_[kNumFPURegisters * 2]; | 
| 487   // FPU control register. | 551   // FPU control register. | 
| 488   uint32_t FCSR_; | 552   uint32_t FCSR_; | 
| 489 | 553 | 
| 490   // Simulator support. | 554   // Simulator support. | 
| 491   // Allocate 1MB for stack. | 555   // Allocate 1MB for stack. | 
| 492   static const size_t stack_size_ = 1 * 1024*1024; | 556   static const size_t stack_size_ = 1 * 1024*1024; | 
| 493   char* stack_; | 557   char* stack_; | 
| 494   bool pc_modified_; | 558   bool pc_modified_; | 
| 495   uint64_t icount_; | 559   uint64_t icount_; | 
| 496   int break_count_; | 560   int break_count_; | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 554   static inline void UnregisterCTryCatch(Isolate* isolate) { | 618   static inline void UnregisterCTryCatch(Isolate* isolate) { | 
| 555     Simulator::current(isolate)->PopAddress(); | 619     Simulator::current(isolate)->PopAddress(); | 
| 556   } | 620   } | 
| 557 }; | 621 }; | 
| 558 | 622 | 
| 559 }  // namespace internal | 623 }  // namespace internal | 
| 560 }  // namespace v8 | 624 }  // namespace v8 | 
| 561 | 625 | 
| 562 #endif  // !defined(USE_SIMULATOR) | 626 #endif  // !defined(USE_SIMULATOR) | 
| 563 #endif  // V8_MIPS_SIMULATOR_MIPS_H_ | 627 #endif  // V8_MIPS_SIMULATOR_MIPS_H_ | 
| OLD | NEW | 
|---|