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 22 matching lines...) Expand all Loading... |
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 #if defined(__arm__) | 39 #if defined(__arm__) |
40 | 40 |
41 // When running without a simulator we call the entry directly. | 41 // When running without a simulator we call the entry directly. |
42 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 42 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ |
43 reinterpret_cast<Object*>(entry(p0, p1, p2, p3, p4)) | 43 (entry(p0, p1, p2, p3, p4)) |
44 | 44 |
45 // Calculated the stack limit beyond which we will throw stack overflow errors. | 45 // Calculated the stack limit beyond which we will throw stack overflow errors. |
46 // This macro must be called from a C++ method. It relies on being able to take | 46 // This macro must be called from a C++ method. It relies on being able to take |
47 // the address of "this" to get a value on the current execution stack and then | 47 // the address of "this" to get a value on the current execution stack and then |
48 // calculates the stack limit based on that value. | 48 // calculates the stack limit based on that value. |
49 #define GENERATED_CODE_STACK_LIMIT(limit) \ | 49 #define GENERATED_CODE_STACK_LIMIT(limit) \ |
50 (reinterpret_cast<uintptr_t>(this) - limit) | 50 (reinterpret_cast<uintptr_t>(this) - limit) |
51 | 51 |
| 52 |
| 53 // Call the generated regexp code directly. The entry function pointer should |
| 54 // expect seven int/pointer sized arguments and return an int. |
| 55 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ |
| 56 entry(p0, p1, p2, p3, p4, p5, p6) |
| 57 |
52 #else // defined(__arm__) | 58 #else // defined(__arm__) |
53 | 59 |
54 // When running with the simulator transition into simulated execution at this | 60 // When running with the simulator transition into simulated execution at this |
55 // point. | 61 // point. |
56 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 62 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ |
57 assembler::arm::Simulator::current()->Call((int32_t)entry, (int32_t)p0, \ | 63 reinterpret_cast<Object*>( \ |
58 (int32_t)p1, (int32_t)p2, (int32_t)p3, (int32_t)p4) | 64 assembler::arm::Simulator::current()->Call(FUNCTION_ADDR(entry), 5, \ |
| 65 p0, p1, p2, p3, p4)) |
59 | 66 |
60 // The simulator has its own stack. Thus it has a different stack limit from | 67 // The simulator has its own stack. Thus it has a different stack limit from |
61 // the C-based native code. | 68 // the C-based native code. |
62 #define GENERATED_CODE_STACK_LIMIT(limit) \ | 69 #define GENERATED_CODE_STACK_LIMIT(limit) \ |
63 (assembler::arm::Simulator::current()->StackLimit()) | 70 (assembler::arm::Simulator::current()->StackLimit()) |
64 | 71 |
65 | 72 |
| 73 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ |
| 74 assembler::arm::Simulator::current()->Call( \ |
| 75 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6) |
| 76 |
66 #include "constants-arm.h" | 77 #include "constants-arm.h" |
67 | 78 |
68 | 79 |
69 namespace assembler { | 80 namespace assembler { |
70 namespace arm { | 81 namespace arm { |
71 | 82 |
72 class Simulator { | 83 class Simulator { |
73 public: | 84 public: |
74 friend class Debugger; | 85 friend class Debugger; |
75 | 86 |
(...skipping 26 matching lines...) Expand all Loading... |
102 | 113 |
103 // Accessor to the internal simulator stack area. | 114 // Accessor to the internal simulator stack area. |
104 uintptr_t StackLimit() const; | 115 uintptr_t StackLimit() const; |
105 | 116 |
106 // Executes ARM instructions until the PC reaches end_sim_pc. | 117 // Executes ARM instructions until the PC reaches end_sim_pc. |
107 void Execute(); | 118 void Execute(); |
108 | 119 |
109 // Call on program start. | 120 // Call on program start. |
110 static void Initialize(); | 121 static void Initialize(); |
111 | 122 |
112 // V8 generally calls into generated code with 5 parameters. This is a | 123 // V8 generally calls into generated JS code with 5 parameters and into |
113 // convenience function, which sets up the simulator state and grabs the | 124 // generated RegExp code with 7 parameters. This is a convenience function, |
114 // result on return. | 125 // which sets up the simulator state and grabs the result on return. |
115 v8::internal::Object* Call(int32_t entry, int32_t p0, int32_t p1, | 126 int32_t Call(byte* entry, int argument_count, ...); |
116 int32_t p2, int32_t p3, int32_t p4); | |
117 | 127 |
118 private: | 128 private: |
119 enum special_values { | 129 enum special_values { |
120 // Known bad pc value to ensure that the simulator does not execute | 130 // Known bad pc value to ensure that the simulator does not execute |
121 // without being properly setup. | 131 // without being properly setup. |
122 bad_lr = -1, | 132 bad_lr = -1, |
123 // A pc value used to signal the simulator to stop execution. Generally | 133 // A pc value used to signal the simulator to stop execution. Generally |
124 // the lr is set to this value on transition from native C code to | 134 // the lr is set to this value on transition from native C code to |
125 // simulated execution, so that the simulator can "return" to the native | 135 // simulated execution, so that the simulator can "return" to the native |
126 // C code. | 136 // C code. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 inline void WriteW(int32_t addr, int value, Instr* instr); | 177 inline void WriteW(int32_t addr, int value, Instr* instr); |
168 | 178 |
169 // Executing is handled based on the instruction type. | 179 // Executing is handled based on the instruction type. |
170 void DecodeType01(Instr* instr); // both type 0 and type 1 rolled into one | 180 void DecodeType01(Instr* instr); // both type 0 and type 1 rolled into one |
171 void DecodeType2(Instr* instr); | 181 void DecodeType2(Instr* instr); |
172 void DecodeType3(Instr* instr); | 182 void DecodeType3(Instr* instr); |
173 void DecodeType4(Instr* instr); | 183 void DecodeType4(Instr* instr); |
174 void DecodeType5(Instr* instr); | 184 void DecodeType5(Instr* instr); |
175 void DecodeType6(Instr* instr); | 185 void DecodeType6(Instr* instr); |
176 void DecodeType7(Instr* instr); | 186 void DecodeType7(Instr* instr); |
| 187 void DecodeUnconditional(Instr* instr); |
177 | 188 |
178 // Executes one instruction. | 189 // Executes one instruction. |
179 void InstructionDecode(Instr* instr); | 190 void InstructionDecode(Instr* instr); |
180 | 191 |
181 // Runtime call support. | 192 // Runtime call support. |
182 static void* RedirectExternalReference(void* external_function, | 193 static void* RedirectExternalReference(void* external_function, |
183 bool fp_return); | 194 bool fp_return); |
184 | 195 |
185 // For use in calls that take two double values, constructed from r0, r1, r2 | 196 // For use in calls that take two double values, constructed from r0, r1, r2 |
186 // and r3. | 197 // and r3. |
(...skipping 17 matching lines...) Expand all Loading... |
204 // registered breakpoints | 215 // registered breakpoints |
205 Instr* break_pc_; | 216 Instr* break_pc_; |
206 instr_t break_instr_; | 217 instr_t break_instr_; |
207 }; | 218 }; |
208 | 219 |
209 } } // namespace assembler::arm | 220 } } // namespace assembler::arm |
210 | 221 |
211 #endif // defined(__arm__) | 222 #endif // defined(__arm__) |
212 | 223 |
213 #endif // V8_ARM_SIMULATOR_ARM_H_ | 224 #endif // V8_ARM_SIMULATOR_ARM_H_ |
OLD | NEW |