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

Side by Side Diff: src/mips64/simulator-mips64.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, 3 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 void round_according_to_fcsr(float toRound, float& rounded, 216 void round_according_to_fcsr(float toRound, float& rounded,
217 int32_t& rounded_int, float fs); 217 int32_t& rounded_int, float fs);
218 void round64_according_to_fcsr(float toRound, float& rounded, 218 void round64_according_to_fcsr(float toRound, float& rounded,
219 int64_t& rounded_int, float fs); 219 int64_t& rounded_int, float fs);
220 void set_fcsr_rounding_mode(FPURoundingMode mode); 220 void set_fcsr_rounding_mode(FPURoundingMode mode);
221 unsigned int get_fcsr_rounding_mode(); 221 unsigned int get_fcsr_rounding_mode();
222 // Special case of set_register and get_register to access the raw PC value. 222 // Special case of set_register and get_register to access the raw PC value.
223 void set_pc(int64_t value); 223 void set_pc(int64_t value);
224 int64_t get_pc() const; 224 int64_t get_pc() const;
225 225
226 Address get_sp() { 226 Address get_sp() const {
227 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp))); 227 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp)));
228 } 228 }
229 229
230 // Accessor to the internal simulator stack area. 230 // Accessor to the internal simulator stack area.
231 uintptr_t StackLimit() const; 231 uintptr_t StackLimit(uintptr_t c_limit) const;
232 232
233 // Executes MIPS instructions until the PC reaches end_sim_pc. 233 // Executes MIPS instructions until the PC reaches end_sim_pc.
234 void Execute(); 234 void Execute();
235 235
236 // Call on program start. 236 // Call on program start.
237 static void Initialize(Isolate* isolate); 237 static void Initialize(Isolate* isolate);
238 238
239 static void TearDown(HashMap* i_cache, Redirection* first); 239 static void TearDown(HashMap* i_cache, Redirection* first);
240 240
241 // V8 generally calls into generated JS code with 5 parameters and into 241 // V8 generally calls into generated JS code with 5 parameters and into
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 ->Call(entry, 10, p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8)) 502 ->Call(entry, 10, p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8))
503 #else // Must be O32 Abi. 503 #else // Must be O32 Abi.
504 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ 504 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
505 static_cast<int>( \ 505 static_cast<int>( \
506 Simulator::current(Isolate::Current()) \ 506 Simulator::current(Isolate::Current()) \
507 ->Call(entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)) 507 ->Call(entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
508 #endif // MIPS_ABI_N64 508 #endif // MIPS_ABI_N64
509 509
510 510
511 // The simulator has its own stack. Thus it has a different stack limit from 511 // The simulator has its own stack. Thus it has a different stack limit from
512 // the C-based native code. Setting the c_limit to indicate a very small 512 // the C-based native code. The JS-based limit normally points near the end of
513 // stack cause stack overflow errors, since the simulator ignores the input. 513 // the simulator stack. When the C-based limit is exhausted we reflect that by
514 // This is unlikely to be an issue in practice, though it might cause testing 514 // lowering the JS-based limit as well, to make stack checks trigger.
515 // trouble down the line.
516 class SimulatorStack : public v8::internal::AllStatic { 515 class SimulatorStack : public v8::internal::AllStatic {
517 public: 516 public:
518 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, 517 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate,
519 uintptr_t c_limit) { 518 uintptr_t c_limit) {
520 return Simulator::current(isolate)->StackLimit(); 519 return Simulator::current(isolate)->StackLimit(c_limit);
521 } 520 }
522 521
523 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { 522 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) {
524 Simulator* sim = Simulator::current(Isolate::Current()); 523 Simulator* sim = Simulator::current(Isolate::Current());
525 return sim->PushAddress(try_catch_address); 524 return sim->PushAddress(try_catch_address);
526 } 525 }
527 526
528 static inline void UnregisterCTryCatch() { 527 static inline void UnregisterCTryCatch() {
529 Simulator::current(Isolate::Current())->PopAddress(); 528 Simulator::current(Isolate::Current())->PopAddress();
530 } 529 }
531 }; 530 };
532 531
533 } } // namespace v8::internal 532 } } // namespace v8::internal
534 533
535 #endif // !defined(USE_SIMULATOR) 534 #endif // !defined(USE_SIMULATOR)
536 #endif // V8_MIPS_SIMULATOR_MIPS_H_ 535 #endif // V8_MIPS_SIMULATOR_MIPS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698