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

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

Issue 1314623002: Make Simulator respect C stack limits as well. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Architecture ports.wq Created 5 years, 4 months 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 5
6 // Declares a Simulator for MIPS instructions if we are not generating a native 6 // Declares a Simulator for MIPS instructions if we are not generating a native
7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation 7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation
8 // on regular desktop machines. 8 // on regular desktop machines.
9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, 9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro,
10 // which will start execution in the Simulator or forwards to the real entry 10 // which will start execution in the Simulator or forwards to the real entry
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 void round_according_to_fcsr(float toRound, float& rounded, 186 void round_according_to_fcsr(float toRound, float& rounded,
187 int32_t& rounded_int, float fs); 187 int32_t& rounded_int, float fs);
188 void round64_according_to_fcsr(double toRound, double& rounded, 188 void round64_according_to_fcsr(double toRound, double& rounded,
189 int64_t& rounded_int, double fs); 189 int64_t& rounded_int, double fs);
190 void round64_according_to_fcsr(float toRound, float& rounded, 190 void round64_according_to_fcsr(float toRound, float& rounded,
191 int64_t& rounded_int, float fs); 191 int64_t& rounded_int, float fs);
192 // Special case of set_register and get_register to access the raw PC value. 192 // Special case of set_register and get_register to access the raw PC value.
193 void set_pc(int32_t value); 193 void set_pc(int32_t value);
194 int32_t get_pc() const; 194 int32_t get_pc() const;
195 195
196 Address get_sp() { 196 Address get_sp() const {
197 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp))); 197 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp)));
198 } 198 }
199 199
200 // Accessor to the internal simulator stack area. 200 // Accessor to the internal simulator stack area.
201 uintptr_t StackLimit() const; 201 uintptr_t StackLimit(uintptr_t c_limit) const;
202 202
203 // Executes MIPS instructions until the PC reaches end_sim_pc. 203 // Executes MIPS instructions until the PC reaches end_sim_pc.
204 void Execute(); 204 void Execute();
205 205
206 // Call on program start. 206 // Call on program start.
207 static void Initialize(Isolate* isolate); 207 static void Initialize(Isolate* isolate);
208 208
209 static void TearDown(HashMap* i_cache, Redirection* first); 209 static void TearDown(HashMap* i_cache, Redirection* first);
210 210
211 // V8 generally calls into generated JS code with 5 parameters and into 211 // V8 generally calls into generated JS code with 5 parameters and into
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ 459 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
460 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \ 460 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->Call( \
461 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) 461 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
462 462
463 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ 463 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
464 Simulator::current(Isolate::Current())->Call( \ 464 Simulator::current(Isolate::Current())->Call( \
465 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) 465 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)
466 466
467 467
468 // The simulator has its own stack. Thus it has a different stack limit from 468 // The simulator has its own stack. Thus it has a different stack limit from
469 // the C-based native code. Setting the c_limit to indicate a very small 469 // the C-based native code. The JS-based limit normally points near the end of
470 // stack cause stack overflow errors, since the simulator ignores the input. 470 // the simulator stack. When the C-based limit is exhausted we reflect that by
471 // This is unlikely to be an issue in practice, though it might cause testing 471 // lowering the JS-based limit as well, to make stack checks trigger.
472 // trouble down the line.
473 class SimulatorStack : public v8::internal::AllStatic { 472 class SimulatorStack : public v8::internal::AllStatic {
474 public: 473 public:
475 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, 474 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate,
476 uintptr_t c_limit) { 475 uintptr_t c_limit) {
477 return Simulator::current(isolate)->StackLimit(); 476 return Simulator::current(isolate)->StackLimit(c_limit);
478 } 477 }
479 478
480 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { 479 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) {
481 Simulator* sim = Simulator::current(Isolate::Current()); 480 Simulator* sim = Simulator::current(Isolate::Current());
482 return sim->PushAddress(try_catch_address); 481 return sim->PushAddress(try_catch_address);
483 } 482 }
484 483
485 static inline void UnregisterCTryCatch() { 484 static inline void UnregisterCTryCatch() {
486 Simulator::current(Isolate::Current())->PopAddress(); 485 Simulator::current(Isolate::Current())->PopAddress();
487 } 486 }
488 }; 487 };
489 488
490 } } // namespace v8::internal 489 } } // namespace v8::internal
491 490
492 #endif // !defined(USE_SIMULATOR) 491 #endif // !defined(USE_SIMULATOR)
493 #endif // V8_MIPS_SIMULATOR_MIPS_H_ 492 #endif // V8_MIPS_SIMULATOR_MIPS_H_
OLDNEW
« src/arm/simulator-arm.h ('K') | « src/execution.cc ('k') | src/mips/simulator-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698