Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: src/arm/simulator-arm.h

Issue 360004: Rework the way we handle the fact that the ARM simulator uses a... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/arm/simulator-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 (entry(p0, p1, p2, p3, p4)) 45 (entry(p0, p1, p2, p3, p4))
46 46
47 // The stack limit beyond which we will throw stack overflow errors in 47 // The stack limit beyond which we will throw stack overflow errors in
48 // generated code. Because generated code on arm uses the C stack, we 48 // generated code. Because generated code on arm uses the C stack, we
49 // just use the C stack limit. 49 // just use the C stack limit.
50 class SimulatorStack : public v8::internal::AllStatic { 50 class SimulatorStack : public v8::internal::AllStatic {
51 public: 51 public:
52 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { 52 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) {
53 return c_limit; 53 return c_limit;
54 } 54 }
55
56 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) {
57 return try_catch_address;
58 }
59
60 static inline void UnregisterCTryCatch() { }
55 }; 61 };
56 62
57 63
58 // Call the generated regexp code directly. The entry function pointer should 64 // Call the generated regexp code directly. The entry function pointer should
59 // expect seven int/pointer sized arguments and return an int. 65 // expect seven int/pointer sized arguments and return an int.
60 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \ 66 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
61 entry(p0, p1, p2, p3, p4, p5, p6) 67 entry(p0, p1, p2, p3, p4, p5, p6)
62 68
69 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
70 reinterpret_cast<TryCatch*>(try_catch_address)
71
72
63 #else // defined(__arm__) 73 #else // defined(__arm__)
64 74
65 // When running with the simulator transition into simulated execution at this 75 // When running with the simulator transition into simulated execution at this
66 // point. 76 // point.
67 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ 77 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
68 reinterpret_cast<Object*>( \ 78 reinterpret_cast<Object*>( \
69 assembler::arm::Simulator::current()->Call(FUNCTION_ADDR(entry), 5, \ 79 assembler::arm::Simulator::current()->Call(FUNCTION_ADDR(entry), 5, \
70 p0, p1, p2, p3, p4)) 80 p0, p1, p2, p3, p4))
71 81
72 #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) \
73 assembler::arm::Simulator::current()->Call( \ 83 assembler::arm::Simulator::current()->Call( \
74 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6) 84 FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6)
75 85
86 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
87 try_catch_address == NULL ? \
88 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address))
89
90
76 #include "constants-arm.h" 91 #include "constants-arm.h"
77 92
78 93
79 namespace assembler { 94 namespace assembler {
80 namespace arm { 95 namespace arm {
81 96
82 class Simulator { 97 class Simulator {
83 public: 98 public:
84 friend class Debugger; 99 friend class Debugger;
85 100
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 void Execute(); 132 void Execute();
118 133
119 // Call on program start. 134 // Call on program start.
120 static void Initialize(); 135 static void Initialize();
121 136
122 // V8 generally calls into generated JS code with 5 parameters and into 137 // V8 generally calls into generated JS code with 5 parameters and into
123 // generated RegExp code with 7 parameters. This is a convenience function, 138 // generated RegExp code with 7 parameters. This is a convenience function,
124 // which sets up the simulator state and grabs the result on return. 139 // which sets up the simulator state and grabs the result on return.
125 int32_t Call(byte* entry, int argument_count, ...); 140 int32_t Call(byte* entry, int argument_count, ...);
126 141
142 // Push an address onto the JS stack.
143 uintptr_t PushAddress(uintptr_t address);
144
145 // Pop an address from the JS stack.
146 uintptr_t PopAddress();
147
127 private: 148 private:
128 enum special_values { 149 enum special_values {
129 // Known bad pc value to ensure that the simulator does not execute 150 // Known bad pc value to ensure that the simulator does not execute
130 // without being properly setup. 151 // without being properly setup.
131 bad_lr = -1, 152 bad_lr = -1,
132 // A pc value used to signal the simulator to stop execution. Generally 153 // A pc value used to signal the simulator to stop execution. Generally
133 // the lr is set to this value on transition from native C code to 154 // the lr is set to this value on transition from native C code to
134 // simulated execution, so that the simulator can "return" to the native 155 // simulated execution, so that the simulator can "return" to the native
135 // C code. 156 // C code.
136 end_sim_pc = -2 157 end_sim_pc = -2
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Runtime call support. 212 // Runtime call support.
192 static void* RedirectExternalReference(void* external_function, 213 static void* RedirectExternalReference(void* external_function,
193 bool fp_return); 214 bool fp_return);
194 215
195 // For use in calls that take two double values, constructed from r0, r1, r2 216 // For use in calls that take two double values, constructed from r0, r1, r2
196 // and r3. 217 // and r3.
197 void GetFpArgs(double* x, double* y); 218 void GetFpArgs(double* x, double* y);
198 void SetFpResult(const double& result); 219 void SetFpResult(const double& result);
199 void TrashCallerSaveRegisters(); 220 void TrashCallerSaveRegisters();
200 221
201 // architecture state 222 // Architecture state.
202 int32_t registers_[16]; 223 int32_t registers_[16];
203 bool n_flag_; 224 bool n_flag_;
204 bool z_flag_; 225 bool z_flag_;
205 bool c_flag_; 226 bool c_flag_;
206 bool v_flag_; 227 bool v_flag_;
207 228
208 // simulator support 229 // Simulator support.
209 char* stack_; 230 char* stack_;
210 bool pc_modified_; 231 bool pc_modified_;
211 int icount_; 232 int icount_;
212 static bool initialized_; 233 static bool initialized_;
213 234
214 // registered breakpoints 235 // Registered breakpoints.
215 Instr* break_pc_; 236 Instr* break_pc_;
216 instr_t break_instr_; 237 instr_t break_instr_;
217 }; 238 };
218 239
219 } } // namespace assembler::arm 240 } } // namespace assembler::arm
220 241
221 242
222 // The simulator has its own stack. Thus it has a different stack limit from 243 // 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 244 // 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. 245 // 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 246 // This is unlikely to be an issue in practice, though it might cause testing
226 // trouble down the line. 247 // trouble down the line.
227 class SimulatorStack : public v8::internal::AllStatic { 248 class SimulatorStack : public v8::internal::AllStatic {
228 public: 249 public:
229 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { 250 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) {
230 return assembler::arm::Simulator::current()->StackLimit(); 251 return assembler::arm::Simulator::current()->StackLimit();
231 } 252 }
253
254 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) {
255 assembler::arm::Simulator* sim = assembler::arm::Simulator::current();
256 return sim->PushAddress(try_catch_address);
257 }
258
259 static inline void UnregisterCTryCatch() {
260 assembler::arm::Simulator::current()->PopAddress();
261 }
232 }; 262 };
233 263
234 264
235 #endif // defined(__arm__) 265 #endif // defined(__arm__)
236 266
237 #endif // V8_ARM_SIMULATOR_ARM_H_ 267 #endif // V8_ARM_SIMULATOR_ARM_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/arm/simulator-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698