| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 entry(p0, p1, p2, p3, p4, p5, p6) | 67 entry(p0, p1, p2, p3, p4, p5, p6) |
| 68 | 68 |
| 69 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ | 69 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ |
| 70 reinterpret_cast<TryCatch*>(try_catch_address) | 70 reinterpret_cast<TryCatch*>(try_catch_address) |
| 71 | 71 |
| 72 | 72 |
| 73 #else // defined(__arm__) | 73 #else // defined(__arm__) |
| 74 | 74 |
| 75 // When running with the simulator transition into simulated execution at this | 75 // When running with the simulator transition into simulated execution at this |
| 76 // point. | 76 // point. |
| 77 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 77 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ |
| 78 reinterpret_cast<Object*>( \ | 78 reinterpret_cast<Object*>( \ |
| 79 assembler::arm::Simulator::current()->Call(FUNCTION_ADDR(entry), 5, \ | 79 assembler::arm::Simulator::current(Isolate::Current())-> \ |
| 80 p0, p1, p2, p3, p4)) | 80 Call(FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) |
| 81 | 81 |
| 82 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ | 82 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ |
| 83 assembler::arm::Simulator::current()->Call( \ | 83 assembler::arm::Simulator::current(Isolate::Current())->Call( \ |
| 84 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6) | 84 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6) |
| 85 | 85 |
| 86 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ | 86 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ |
| 87 try_catch_address == NULL ? \ | 87 try_catch_address == NULL ? \ |
| 88 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) | 88 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) |
| 89 | 89 |
| 90 | 90 |
| 91 #include "constants-arm.h" | 91 #include "constants-arm.h" |
| 92 #include "hashmap.h" | 92 #include "hashmap.h" |
| 93 | 93 |
| 94 | 94 |
| 95 namespace assembler { | 95 namespace assembler { |
| 96 namespace arm { | 96 namespace arm { |
| 97 | 97 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 d0 = 0, d1, d2, d3, d4, d5, d6, d7, | 145 d0 = 0, d1, d2, d3, d4, d5, d6, d7, |
| 146 d8, d9, d10, d11, d12, d13, d14, d15, | 146 d8, d9, d10, d11, d12, d13, d14, d15, |
| 147 num_d_registers = 16 | 147 num_d_registers = 16 |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 Simulator(); | 150 Simulator(); |
| 151 ~Simulator(); | 151 ~Simulator(); |
| 152 | 152 |
| 153 // The currently executing Simulator instance. Potentially there can be one | 153 // The currently executing Simulator instance. Potentially there can be one |
| 154 // for each native thread. | 154 // for each native thread. |
| 155 static Simulator* current(); | 155 static Simulator* current(v8::internal::Isolate* isolate); |
| 156 | 156 |
| 157 // Accessors for register state. Reading the pc value adheres to the ARM | 157 // Accessors for register state. Reading the pc value adheres to the ARM |
| 158 // architecture specification and is off by a 8 from the currently executing | 158 // architecture specification and is off by a 8 from the currently executing |
| 159 // instruction. | 159 // instruction. |
| 160 void set_register(int reg, int32_t value); | 160 void set_register(int reg, int32_t value); |
| 161 int32_t get_register(int reg) const; | 161 int32_t get_register(int reg) const; |
| 162 void set_dw_register(int dreg, const int* dbl); | 162 void set_dw_register(int dreg, const int* dbl); |
| 163 | 163 |
| 164 // Support for VFP. | 164 // Support for VFP. |
| 165 void set_s_register(int reg, unsigned int value); | 165 void set_s_register(int reg, unsigned int value); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 189 // which sets up the simulator state and grabs the result on return. | 189 // which sets up the simulator state and grabs the result on return. |
| 190 int32_t Call(byte* entry, int argument_count, ...); | 190 int32_t Call(byte* entry, int argument_count, ...); |
| 191 | 191 |
| 192 // Push an address onto the JS stack. | 192 // Push an address onto the JS stack. |
| 193 uintptr_t PushAddress(uintptr_t address); | 193 uintptr_t PushAddress(uintptr_t address); |
| 194 | 194 |
| 195 // Pop an address from the JS stack. | 195 // Pop an address from the JS stack. |
| 196 uintptr_t PopAddress(); | 196 uintptr_t PopAddress(); |
| 197 | 197 |
| 198 // ICache checking. | 198 // ICache checking. |
| 199 static void FlushICache(void* start, size_t size); | 199 static void FlushICache(v8::internal::HashMap* i_cache, void* start, |
| 200 size_t size); |
| 200 | 201 |
| 201 private: | 202 private: |
| 202 enum special_values { | 203 enum special_values { |
| 203 // Known bad pc value to ensure that the simulator does not execute | 204 // Known bad pc value to ensure that the simulator does not execute |
| 204 // without being properly setup. | 205 // without being properly setup. |
| 205 bad_lr = -1, | 206 bad_lr = -1, |
| 206 // A pc value used to signal the simulator to stop execution. Generally | 207 // A pc value used to signal the simulator to stop execution. Generally |
| 207 // the lr is set to this value on transition from native C code to | 208 // the lr is set to this value on transition from native C code to |
| 208 // simulated execution, so that the simulator can "return" to the native | 209 // simulated execution, so that the simulator can "return" to the native |
| 209 // C code. | 210 // C code. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 273 |
| 273 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instr* instr); | 274 void DecodeVMOVBetweenCoreAndSinglePrecisionRegisters(Instr* instr); |
| 274 void DecodeVCMP(Instr* instr); | 275 void DecodeVCMP(Instr* instr); |
| 275 void DecodeVCVTBetweenDoubleAndSingle(Instr* instr); | 276 void DecodeVCVTBetweenDoubleAndSingle(Instr* instr); |
| 276 void DecodeVCVTBetweenFloatingPointAndInteger(Instr* instr); | 277 void DecodeVCVTBetweenFloatingPointAndInteger(Instr* instr); |
| 277 | 278 |
| 278 // Executes one instruction. | 279 // Executes one instruction. |
| 279 void InstructionDecode(Instr* instr); | 280 void InstructionDecode(Instr* instr); |
| 280 | 281 |
| 281 // ICache. | 282 // ICache. |
| 282 static void CheckICache(Instr* instr); | 283 static void CheckICache(v8::internal::HashMap* i_cache, Instr* instr); |
| 283 static void FlushOnePage(intptr_t start, int size); | 284 static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, |
| 284 static CachePage* GetCachePage(void* page); | 285 int size); |
| 286 static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page); |
| 285 | 287 |
| 286 // Runtime call support. | 288 // Runtime call support. |
| 287 static void* RedirectExternalReference(void* external_function, | 289 static void* RedirectExternalReference(void* external_function, |
| 288 bool fp_return); | 290 bool fp_return); |
| 289 | 291 |
| 290 // For use in calls that take two double values, constructed from r0, r1, r2 | 292 // For use in calls that take two double values, constructed from r0, r1, r2 |
| 291 // and r3. | 293 // and r3. |
| 292 void GetFpArgs(double* x, double* y); | 294 void GetFpArgs(double* x, double* y); |
| 293 void SetFpResult(const double& result); | 295 void SetFpResult(const double& result); |
| 294 void TrashCallerSaveRegisters(); | 296 void TrashCallerSaveRegisters(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 311 bool inv_op_vfp_flag_; | 313 bool inv_op_vfp_flag_; |
| 312 bool div_zero_vfp_flag_; | 314 bool div_zero_vfp_flag_; |
| 313 bool overflow_vfp_flag_; | 315 bool overflow_vfp_flag_; |
| 314 bool underflow_vfp_flag_; | 316 bool underflow_vfp_flag_; |
| 315 bool inexact_vfp_flag_; | 317 bool inexact_vfp_flag_; |
| 316 | 318 |
| 317 // Simulator support. | 319 // Simulator support. |
| 318 char* stack_; | 320 char* stack_; |
| 319 bool pc_modified_; | 321 bool pc_modified_; |
| 320 int icount_; | 322 int icount_; |
| 321 static bool initialized_; | |
| 322 | 323 |
| 323 // Icache simulation | 324 // Icache simulation |
| 324 static v8::internal::HashMap* i_cache_; | 325 v8::internal::HashMap* i_cache_; |
| 325 | 326 |
| 326 // Registered breakpoints. | 327 // Registered breakpoints. |
| 327 Instr* break_pc_; | 328 Instr* break_pc_; |
| 328 instr_t break_instr_; | 329 instr_t break_instr_; |
| 330 |
| 331 v8::internal::Isolate* isolate_; |
| 329 }; | 332 }; |
| 330 | 333 |
| 331 } } // namespace assembler::arm | 334 } } // namespace assembler::arm |
| 332 | 335 |
| 333 | 336 |
| 334 // The simulator has its own stack. Thus it has a different stack limit from | 337 // The simulator has its own stack. Thus it has a different stack limit from |
| 335 // the C-based native code. Setting the c_limit to indicate a very small | 338 // the C-based native code. Setting the c_limit to indicate a very small |
| 336 // stack cause stack overflow errors, since the simulator ignores the input. | 339 // stack cause stack overflow errors, since the simulator ignores the input. |
| 337 // This is unlikely to be an issue in practice, though it might cause testing | 340 // This is unlikely to be an issue in practice, though it might cause testing |
| 338 // trouble down the line. | 341 // trouble down the line. |
| 339 class SimulatorStack : public v8::internal::AllStatic { | 342 class SimulatorStack : public v8::internal::AllStatic { |
| 340 public: | 343 public: |
| 341 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { | 344 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { |
| 342 return assembler::arm::Simulator::current()->StackLimit(); | 345 return assembler::arm::Simulator::current( |
| 346 v8::internal::Isolate::Current())->StackLimit(); |
| 343 } | 347 } |
| 344 | 348 |
| 345 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 349 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
| 346 assembler::arm::Simulator* sim = assembler::arm::Simulator::current(); | 350 assembler::arm::Simulator* sim = |
| 351 assembler::arm::Simulator::current(v8::internal::Isolate::Current()); |
| 347 return sim->PushAddress(try_catch_address); | 352 return sim->PushAddress(try_catch_address); |
| 348 } | 353 } |
| 349 | 354 |
| 350 static inline void UnregisterCTryCatch() { | 355 static inline void UnregisterCTryCatch() { |
| 351 assembler::arm::Simulator::current()->PopAddress(); | 356 assembler::arm::Simulator::current(v8::internal::Isolate::Current())-> |
| 357 PopAddress(); |
| 352 } | 358 } |
| 353 }; | 359 }; |
| 354 | 360 |
| 355 | 361 |
| 356 #endif // defined(__arm__) | 362 #endif // defined(__arm__) |
| 357 | 363 |
| 358 #endif // V8_ARM_SIMULATOR_ARM_H_ | 364 #endif // V8_ARM_SIMULATOR_ARM_H_ |
| OLD | NEW |