| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 PPC instructions if we are not generating a native | 6 // Declares a Simulator for PPC instructions if we are not generating a native |
| 7 // PPC binary. This Simulator allows us to run and debug PPC code generation on | 7 // PPC binary. This Simulator allows us to run and debug PPC code generation on |
| 8 // regular desktop machines. | 8 // 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 // Accessor to the internal simulator stack area. | 211 // Accessor to the internal simulator stack area. |
| 212 uintptr_t StackLimit(uintptr_t c_limit) const; | 212 uintptr_t StackLimit(uintptr_t c_limit) const; |
| 213 | 213 |
| 214 // Executes PPC instructions until the PC reaches end_sim_pc. | 214 // Executes PPC instructions until the PC reaches end_sim_pc. |
| 215 void Execute(); | 215 void Execute(); |
| 216 | 216 |
| 217 // Call on program start. | 217 // Call on program start. |
| 218 static void Initialize(Isolate* isolate); | 218 static void Initialize(Isolate* isolate); |
| 219 | 219 |
| 220 static void TearDown(base::HashMap* i_cache, Redirection* first); | 220 static void TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first); |
| 221 | 221 |
| 222 // V8 generally calls into generated JS code with 5 parameters and into | 222 // V8 generally calls into generated JS code with 5 parameters and into |
| 223 // generated RegExp code with 7 parameters. This is a convenience function, | 223 // generated RegExp code with 7 parameters. This is a convenience function, |
| 224 // which sets up the simulator state and grabs the result on return. | 224 // which sets up the simulator state and grabs the result on return. |
| 225 intptr_t Call(byte* entry, int argument_count, ...); | 225 intptr_t Call(byte* entry, int argument_count, ...); |
| 226 // Alternative: call a 2-argument double function. | 226 // Alternative: call a 2-argument double function. |
| 227 void CallFP(byte* entry, double d0, double d1); | 227 void CallFP(byte* entry, double d0, double d1); |
| 228 int32_t CallFPReturnsInt(byte* entry, double d0, double d1); | 228 int32_t CallFPReturnsInt(byte* entry, double d0, double d1); |
| 229 double CallFPReturnsDouble(byte* entry, double d0, double d1); | 229 double CallFPReturnsDouble(byte* entry, double d0, double d1); |
| 230 | 230 |
| 231 // Push an address onto the JS stack. | 231 // Push an address onto the JS stack. |
| 232 uintptr_t PushAddress(uintptr_t address); | 232 uintptr_t PushAddress(uintptr_t address); |
| 233 | 233 |
| 234 // Pop an address from the JS stack. | 234 // Pop an address from the JS stack. |
| 235 uintptr_t PopAddress(); | 235 uintptr_t PopAddress(); |
| 236 | 236 |
| 237 // Debugger input. | 237 // Debugger input. |
| 238 void set_last_debugger_input(char* input); | 238 void set_last_debugger_input(char* input); |
| 239 char* last_debugger_input() { return last_debugger_input_; } | 239 char* last_debugger_input() { return last_debugger_input_; } |
| 240 | 240 |
| 241 // ICache checking. | 241 // ICache checking. |
| 242 static void FlushICache(base::HashMap* i_cache, void* start, size_t size); | 242 static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, |
| 243 size_t size); |
| 243 | 244 |
| 244 // Returns true if pc register contains one of the 'special_values' defined | 245 // Returns true if pc register contains one of the 'special_values' defined |
| 245 // below (bad_lr, end_sim_pc). | 246 // below (bad_lr, end_sim_pc). |
| 246 bool has_bad_pc() const; | 247 bool has_bad_pc() const; |
| 247 | 248 |
| 248 private: | 249 private: |
| 249 enum special_values { | 250 enum special_values { |
| 250 // Known bad pc value to ensure that the simulator does not execute | 251 // Known bad pc value to ensure that the simulator does not execute |
| 251 // without being properly setup. | 252 // without being properly setup. |
| 252 bad_lr = -1, | 253 bad_lr = -1, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 #endif | 323 #endif |
| 323 void ExecuteGeneric(Instruction* instr); | 324 void ExecuteGeneric(Instruction* instr); |
| 324 | 325 |
| 325 void SetFPSCR(int bit) { fp_condition_reg_ |= (1 << (31 - bit)); } | 326 void SetFPSCR(int bit) { fp_condition_reg_ |= (1 << (31 - bit)); } |
| 326 void ClearFPSCR(int bit) { fp_condition_reg_ &= ~(1 << (31 - bit)); } | 327 void ClearFPSCR(int bit) { fp_condition_reg_ &= ~(1 << (31 - bit)); } |
| 327 | 328 |
| 328 // Executes one instruction. | 329 // Executes one instruction. |
| 329 void ExecuteInstruction(Instruction* instr); | 330 void ExecuteInstruction(Instruction* instr); |
| 330 | 331 |
| 331 // ICache. | 332 // ICache. |
| 332 static void CheckICache(base::HashMap* i_cache, Instruction* instr); | 333 static void CheckICache(base::CustomMatcherHashMap* i_cache, |
| 333 static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size); | 334 Instruction* instr); |
| 334 static CachePage* GetCachePage(base::HashMap* i_cache, void* page); | 335 static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, |
| 336 int size); |
| 337 static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache, |
| 338 void* page); |
| 335 | 339 |
| 336 // Runtime call support. | 340 // Runtime call support. |
| 337 static void* RedirectExternalReference( | 341 static void* RedirectExternalReference( |
| 338 Isolate* isolate, void* external_function, | 342 Isolate* isolate, void* external_function, |
| 339 v8::internal::ExternalReference::Type type); | 343 v8::internal::ExternalReference::Type type); |
| 340 | 344 |
| 341 // Handle arguments and return value for runtime FP functions. | 345 // Handle arguments and return value for runtime FP functions. |
| 342 void GetFpArgs(double* x, double* y, intptr_t* z); | 346 void GetFpArgs(double* x, double* y, intptr_t* z); |
| 343 void SetFpResult(const double& result); | 347 void SetFpResult(const double& result); |
| 344 void TrashCallerSaveRegisters(); | 348 void TrashCallerSaveRegisters(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 362 // Simulator support. | 366 // Simulator support. |
| 363 char* stack_; | 367 char* stack_; |
| 364 static const size_t stack_protection_size_ = 256 * kPointerSize; | 368 static const size_t stack_protection_size_ = 256 * kPointerSize; |
| 365 bool pc_modified_; | 369 bool pc_modified_; |
| 366 int icount_; | 370 int icount_; |
| 367 | 371 |
| 368 // Debugger input. | 372 // Debugger input. |
| 369 char* last_debugger_input_; | 373 char* last_debugger_input_; |
| 370 | 374 |
| 371 // Icache simulation | 375 // Icache simulation |
| 372 base::HashMap* i_cache_; | 376 base::CustomMatcherHashMap* i_cache_; |
| 373 | 377 |
| 374 // Registered breakpoints. | 378 // Registered breakpoints. |
| 375 Instruction* break_pc_; | 379 Instruction* break_pc_; |
| 376 Instr break_instr_; | 380 Instr break_instr_; |
| 377 | 381 |
| 378 v8::internal::Isolate* isolate_; | 382 v8::internal::Isolate* isolate_; |
| 379 | 383 |
| 380 // A stop is watched if its code is less than kNumOfWatchedStops. | 384 // A stop is watched if its code is less than kNumOfWatchedStops. |
| 381 // Only watched stops support enabling/disabling and the counter feature. | 385 // Only watched stops support enabling/disabling and the counter feature. |
| 382 static const uint32_t kNumOfWatchedStops = 256; | 386 static const uint32_t kNumOfWatchedStops = 256; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 434 |
| 431 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 435 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
| 432 Simulator::current(isolate)->PopAddress(); | 436 Simulator::current(isolate)->PopAddress(); |
| 433 } | 437 } |
| 434 }; | 438 }; |
| 435 } // namespace internal | 439 } // namespace internal |
| 436 } // namespace v8 | 440 } // namespace v8 |
| 437 | 441 |
| 438 #endif // !defined(USE_SIMULATOR) | 442 #endif // !defined(USE_SIMULATOR) |
| 439 #endif // V8_PPC_SIMULATOR_PPC_H_ | 443 #endif // V8_PPC_SIMULATOR_PPC_H_ |
| OLD | NEW |