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 // Declares a Simulator for S390 instructions if we are not generating a native | 5 // Declares a Simulator for S390 instructions if we are not generating a native |
6 // S390 binary. This Simulator allows us to run and debug S390 code generation | 6 // S390 binary. This Simulator allows us to run and debug S390 code generation |
7 // on regular desktop machines. | 7 // on regular desktop machines. |
8 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, | 8 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, |
9 // which will start execution in the Simulator or forwards to the real entry | 9 // which will start execution in the Simulator or forwards to the real entry |
10 // on a S390 hardware platform. | 10 // on a S390 hardware platform. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 USE(isolate); | 57 USE(isolate); |
58 } | 58 } |
59 }; | 59 }; |
60 } // namespace internal | 60 } // namespace internal |
61 } // namespace v8 | 61 } // namespace v8 |
62 | 62 |
63 #else // !defined(USE_SIMULATOR) | 63 #else // !defined(USE_SIMULATOR) |
64 // Running with a simulator. | 64 // Running with a simulator. |
65 | 65 |
66 #include "src/assembler.h" | 66 #include "src/assembler.h" |
67 #include "src/hashmap.h" | 67 #include "src/base/hashmap.h" |
68 #include "src/s390/constants-s390.h" | 68 #include "src/s390/constants-s390.h" |
69 | 69 |
70 namespace v8 { | 70 namespace v8 { |
71 namespace internal { | 71 namespace internal { |
72 | 72 |
73 class CachePage { | 73 class CachePage { |
74 public: | 74 public: |
75 static const int LINE_VALID = 0; | 75 static const int LINE_VALID = 0; |
76 static const int LINE_INVALID = 1; | 76 static const int LINE_INVALID = 1; |
77 | 77 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 // Accessor to the internal simulator stack area. | 205 // Accessor to the internal simulator stack area. |
206 uintptr_t StackLimit(uintptr_t c_limit) const; | 206 uintptr_t StackLimit(uintptr_t c_limit) const; |
207 | 207 |
208 // Executes S390 instructions until the PC reaches end_sim_pc. | 208 // Executes S390 instructions until the PC reaches end_sim_pc. |
209 void Execute(); | 209 void Execute(); |
210 | 210 |
211 // Call on program start. | 211 // Call on program start. |
212 static void Initialize(Isolate* isolate); | 212 static void Initialize(Isolate* isolate); |
213 | 213 |
214 static void TearDown(HashMap* i_cache, Redirection* first); | 214 static void TearDown(base::HashMap* i_cache, Redirection* first); |
215 | 215 |
216 // V8 generally calls into generated JS code with 5 parameters and into | 216 // V8 generally calls into generated JS code with 5 parameters and into |
217 // generated RegExp code with 7 parameters. This is a convenience function, | 217 // generated RegExp code with 7 parameters. This is a convenience function, |
218 // which sets up the simulator state and grabs the result on return. | 218 // which sets up the simulator state and grabs the result on return. |
219 intptr_t Call(byte* entry, int argument_count, ...); | 219 intptr_t Call(byte* entry, int argument_count, ...); |
220 // Alternative: call a 2-argument double function. | 220 // Alternative: call a 2-argument double function. |
221 void CallFP(byte* entry, double d0, double d1); | 221 void CallFP(byte* entry, double d0, double d1); |
222 int32_t CallFPReturnsInt(byte* entry, double d0, double d1); | 222 int32_t CallFPReturnsInt(byte* entry, double d0, double d1); |
223 double CallFPReturnsDouble(byte* entry, double d0, double d1); | 223 double CallFPReturnsDouble(byte* entry, double d0, double d1); |
224 | 224 |
225 // Push an address onto the JS stack. | 225 // Push an address onto the JS stack. |
226 uintptr_t PushAddress(uintptr_t address); | 226 uintptr_t PushAddress(uintptr_t address); |
227 | 227 |
228 // Pop an address from the JS stack. | 228 // Pop an address from the JS stack. |
229 uintptr_t PopAddress(); | 229 uintptr_t PopAddress(); |
230 | 230 |
231 // Debugger input. | 231 // Debugger input. |
232 void set_last_debugger_input(char* input); | 232 void set_last_debugger_input(char* input); |
233 char* last_debugger_input() { return last_debugger_input_; } | 233 char* last_debugger_input() { return last_debugger_input_; } |
234 | 234 |
235 // ICache checking. | 235 // ICache checking. |
236 static void FlushICache(v8::internal::HashMap* i_cache, void* start, | 236 static void FlushICache(base::HashMap* i_cache, void* start, size_t size); |
237 size_t size); | |
238 | 237 |
239 // Returns true if pc register contains one of the 'special_values' defined | 238 // Returns true if pc register contains one of the 'special_values' defined |
240 // below (bad_lr, end_sim_pc). | 239 // below (bad_lr, end_sim_pc). |
241 bool has_bad_pc() const; | 240 bool has_bad_pc() const; |
242 | 241 |
243 private: | 242 private: |
244 enum special_values { | 243 enum special_values { |
245 // Known bad pc value to ensure that the simulator does not execute | 244 // Known bad pc value to ensure that the simulator does not execute |
246 // without being properly setup. | 245 // without being properly setup. |
247 bad_lr = -1, | 246 bad_lr = -1, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 // Check for unconditional branch | 436 // Check for unconditional branch |
438 if (mask == 0xf) return true; | 437 if (mask == 0xf) return true; |
439 | 438 |
440 return (condition_reg_ & mask) != 0; | 439 return (condition_reg_ & mask) != 0; |
441 } | 440 } |
442 | 441 |
443 // Executes one instruction. | 442 // Executes one instruction. |
444 void ExecuteInstruction(Instruction* instr, bool auto_incr_pc = true); | 443 void ExecuteInstruction(Instruction* instr, bool auto_incr_pc = true); |
445 | 444 |
446 // ICache. | 445 // ICache. |
447 static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr); | 446 static void CheckICache(base::HashMap* i_cache, Instruction* instr); |
448 static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, | 447 static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size); |
449 int size); | 448 static CachePage* GetCachePage(base::HashMap* i_cache, void* page); |
450 static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page); | |
451 | 449 |
452 // Runtime call support. | 450 // Runtime call support. |
453 static void* RedirectExternalReference( | 451 static void* RedirectExternalReference( |
454 Isolate* isolate, void* external_function, | 452 Isolate* isolate, void* external_function, |
455 v8::internal::ExternalReference::Type type); | 453 v8::internal::ExternalReference::Type type); |
456 | 454 |
457 // Handle arguments and return value for runtime FP functions. | 455 // Handle arguments and return value for runtime FP functions. |
458 void GetFpArgs(double* x, double* y, intptr_t* z); | 456 void GetFpArgs(double* x, double* y, intptr_t* z); |
459 void SetFpResult(const double& result); | 457 void SetFpResult(const double& result); |
460 void TrashCallerSaveRegisters(); | 458 void TrashCallerSaveRegisters(); |
(...skipping 14 matching lines...) Expand all Loading... |
475 // Simulator support. | 473 // Simulator support. |
476 char* stack_; | 474 char* stack_; |
477 static const size_t stack_protection_size_ = 256 * kPointerSize; | 475 static const size_t stack_protection_size_ = 256 * kPointerSize; |
478 bool pc_modified_; | 476 bool pc_modified_; |
479 int64_t icount_; | 477 int64_t icount_; |
480 | 478 |
481 // Debugger input. | 479 // Debugger input. |
482 char* last_debugger_input_; | 480 char* last_debugger_input_; |
483 | 481 |
484 // Icache simulation | 482 // Icache simulation |
485 v8::internal::HashMap* i_cache_; | 483 base::HashMap* i_cache_; |
486 | 484 |
487 // Registered breakpoints. | 485 // Registered breakpoints. |
488 Instruction* break_pc_; | 486 Instruction* break_pc_; |
489 Instr break_instr_; | 487 Instr break_instr_; |
490 | 488 |
491 v8::internal::Isolate* isolate_; | 489 v8::internal::Isolate* isolate_; |
492 | 490 |
493 // A stop is watched if its code is less than kNumOfWatchedStops. | 491 // A stop is watched if its code is less than kNumOfWatchedStops. |
494 // Only watched stops support enabling/disabling and the counter feature. | 492 // Only watched stops support enabling/disabling and the counter feature. |
495 static const uint32_t kNumOfWatchedStops = 256; | 493 static const uint32_t kNumOfWatchedStops = 256; |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 1277 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
1280 Simulator::current(isolate)->PopAddress(); | 1278 Simulator::current(isolate)->PopAddress(); |
1281 } | 1279 } |
1282 }; | 1280 }; |
1283 | 1281 |
1284 } // namespace internal | 1282 } // namespace internal |
1285 } // namespace v8 | 1283 } // namespace v8 |
1286 | 1284 |
1287 #endif // !defined(USE_SIMULATOR) | 1285 #endif // !defined(USE_SIMULATOR) |
1288 #endif // V8_S390_SIMULATOR_S390_H_ | 1286 #endif // V8_S390_SIMULATOR_S390_H_ |
OLD | NEW |