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 18 matching lines...) Expand all Loading... |
29 // Declares a Simulator for ARM instructions if we are not generating a native | 29 // Declares a Simulator for ARM instructions if we are not generating a native |
30 // ARM binary. This Simulator allows us to run and debug ARM code generation on | 30 // ARM binary. This Simulator allows us to run and debug ARM code generation on |
31 // regular desktop machines. | 31 // regular desktop machines. |
32 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, | 32 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, |
33 // which will start execution in the Simulator or forwards to the real entry | 33 // which will start execution in the Simulator or forwards to the real entry |
34 // on a ARM HW platform. | 34 // on a ARM HW platform. |
35 | 35 |
36 #ifndef V8_ARM_SIMULATOR_ARM_H_ | 36 #ifndef V8_ARM_SIMULATOR_ARM_H_ |
37 #define V8_ARM_SIMULATOR_ARM_H_ | 37 #define V8_ARM_SIMULATOR_ARM_H_ |
38 | 38 |
| 39 #include "allocation.h" |
| 40 |
39 #if defined(__arm__) | 41 #if defined(__arm__) |
40 | 42 |
41 // When running without a simulator we call the entry directly. | 43 // When running without a simulator we call the entry directly. |
42 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 44 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ |
43 (entry(p0, p1, p2, p3, p4)) | 45 (entry(p0, p1, p2, p3, p4)) |
44 | 46 |
45 // Calculated the stack limit beyond which we will throw stack overflow errors. | 47 // The stack limit beyond which we will throw stack overflow errors in |
46 // This macro must be called from a C++ method. It relies on being able to take | 48 // generated code. Because generated code on arm uses the C stack, we |
47 // the address of "this" to get a value on the current execution stack and then | 49 // just use the C stack limit. |
48 // calculates the stack limit based on that value. | 50 class SimulatorStack : public v8::internal::AllStatic { |
49 #define GENERATED_CODE_STACK_LIMIT(limit) \ | 51 public: |
50 (reinterpret_cast<uintptr_t>(this) - limit) | 52 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { |
| 53 return c_limit; |
| 54 } |
| 55 }; |
51 | 56 |
52 | 57 |
53 // Call the generated regexp code directly. The entry function pointer should | 58 // Call the generated regexp code directly. The entry function pointer should |
54 // expect seven int/pointer sized arguments and return an int. | 59 // expect seven int/pointer sized arguments and return an int. |
55 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ | 60 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ |
56 entry(p0, p1, p2, p3, p4, p5, p6) | 61 entry(p0, p1, p2, p3, p4, p5, p6) |
57 | 62 |
58 #else // defined(__arm__) | 63 #else // defined(__arm__) |
59 | 64 |
60 // When running with the simulator transition into simulated execution at this | 65 // When running with the simulator transition into simulated execution at this |
61 // point. | 66 // point. |
62 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 67 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ |
63 reinterpret_cast<Object*>( \ | 68 reinterpret_cast<Object*>( \ |
64 assembler::arm::Simulator::current()->Call(FUNCTION_ADDR(entry), 5, \ | 69 assembler::arm::Simulator::current()->Call(FUNCTION_ADDR(entry), 5, \ |
65 p0, p1, p2, p3, p4)) | 70 p0, p1, p2, p3, p4)) |
66 | 71 |
67 // The simulator has its own stack. Thus it has a different stack limit from | |
68 // the C-based native code. | |
69 #define GENERATED_CODE_STACK_LIMIT(limit) \ | |
70 (assembler::arm::Simulator::current()->StackLimit()) | |
71 | |
72 | |
73 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ | 72 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ |
74 assembler::arm::Simulator::current()->Call( \ | 73 assembler::arm::Simulator::current()->Call( \ |
75 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6) | 74 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6) |
76 | 75 |
77 #include "constants-arm.h" | 76 #include "constants-arm.h" |
78 | 77 |
79 | 78 |
80 namespace assembler { | 79 namespace assembler { |
81 namespace arm { | 80 namespace arm { |
82 | 81 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 int icount_; | 211 int icount_; |
213 static bool initialized_; | 212 static bool initialized_; |
214 | 213 |
215 // registered breakpoints | 214 // registered breakpoints |
216 Instr* break_pc_; | 215 Instr* break_pc_; |
217 instr_t break_instr_; | 216 instr_t break_instr_; |
218 }; | 217 }; |
219 | 218 |
220 } } // namespace assembler::arm | 219 } } // namespace assembler::arm |
221 | 220 |
| 221 |
| 222 // The simulator has its own stack. Thus it has a different stack limit from |
| 223 // the C-based native code. Setting the c_limit to indicate a very small |
| 224 // stack cause stack overflow errors, since the simulator ignores the input. |
| 225 // This is unlikely to be an issue in practice, though it might cause testing |
| 226 // trouble down the line. |
| 227 class SimulatorStack : public v8::internal::AllStatic { |
| 228 public: |
| 229 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { |
| 230 return assembler::arm::Simulator::current()->StackLimit(); |
| 231 } |
| 232 }; |
| 233 |
| 234 |
222 #endif // defined(__arm__) | 235 #endif // defined(__arm__) |
223 | 236 |
224 #endif // V8_ARM_SIMULATOR_ARM_H_ | 237 #endif // V8_ARM_SIMULATOR_ARM_H_ |
OLD | NEW |