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

Side by Side Diff: src/debug.h

Issue 2943002: Reimplement stack manipulations for LiveEdit (Closed)
Patch Set: follow codereview Created 10 years, 5 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
« no previous file with comments | « src/builtins.cc ('k') | src/debug.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 323 }
324 324
325 // Getters for the current exception break state. 325 // Getters for the current exception break state.
326 static bool break_on_exception() { return break_on_exception_; } 326 static bool break_on_exception() { return break_on_exception_; }
327 static bool break_on_uncaught_exception() { 327 static bool break_on_uncaught_exception() {
328 return break_on_uncaught_exception_; 328 return break_on_uncaught_exception_;
329 } 329 }
330 330
331 enum AddressId { 331 enum AddressId {
332 k_after_break_target_address, 332 k_after_break_target_address,
333 k_restarted_frame_fp_address,
333 k_debug_break_return_address, 334 k_debug_break_return_address,
334 k_debug_break_slot_address, 335 k_debug_break_slot_address,
335 k_register_address 336 k_register_address
336 }; 337 };
337 338
338 // Support for setting the address to jump to when returning from break point. 339 // Support for setting the address to jump to when returning from break point.
339 static Address* after_break_target_address() { 340 static Address* after_break_target_address() {
340 return reinterpret_cast<Address*>(&thread_local_.after_break_target_); 341 return reinterpret_cast<Address*>(&thread_local_.after_break_target_);
341 } 342 }
342 343
344 static Address* restarted_frame_fp_address() {
345 return reinterpret_cast<Address*>(&thread_local_.restarted_frame_fp_);
346 }
347
348
349
343 // Support for saving/restoring registers when handling debug break calls. 350 // Support for saving/restoring registers when handling debug break calls.
344 static Object** register_address(int r) { 351 static Object** register_address(int r) {
345 return &registers_[r]; 352 return &registers_[r];
346 } 353 }
347 354
348 // Access to the debug break on return code. 355 // Access to the debug break on return code.
349 static Code* debug_break_return() { return debug_break_return_; } 356 static Code* debug_break_return() { return debug_break_return_; }
350 static Code** debug_break_return_address() { 357 static Code** debug_break_return_address() {
351 return &debug_break_return_; 358 return &debug_break_return_;
352 } 359 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 static void GenerateSlot(MacroAssembler* masm); 395 static void GenerateSlot(MacroAssembler* masm);
389 static void GenerateLoadICDebugBreak(MacroAssembler* masm); 396 static void GenerateLoadICDebugBreak(MacroAssembler* masm);
390 static void GenerateStoreICDebugBreak(MacroAssembler* masm); 397 static void GenerateStoreICDebugBreak(MacroAssembler* masm);
391 static void GenerateKeyedLoadICDebugBreak(MacroAssembler* masm); 398 static void GenerateKeyedLoadICDebugBreak(MacroAssembler* masm);
392 static void GenerateKeyedStoreICDebugBreak(MacroAssembler* masm); 399 static void GenerateKeyedStoreICDebugBreak(MacroAssembler* masm);
393 static void GenerateConstructCallDebugBreak(MacroAssembler* masm); 400 static void GenerateConstructCallDebugBreak(MacroAssembler* masm);
394 static void GenerateReturnDebugBreak(MacroAssembler* masm); 401 static void GenerateReturnDebugBreak(MacroAssembler* masm);
395 static void GenerateStubNoRegistersDebugBreak(MacroAssembler* masm); 402 static void GenerateStubNoRegistersDebugBreak(MacroAssembler* masm);
396 static void GenerateSlotDebugBreak(MacroAssembler* masm); 403 static void GenerateSlotDebugBreak(MacroAssembler* masm);
397 static void GeneratePlainReturnLiveEdit(MacroAssembler* masm); 404 static void GeneratePlainReturnLiveEdit(MacroAssembler* masm);
398 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); 405
406 // LiveEdit restarter patch. For javascript stack frames that has to be
407 // restarted. First it is appended at the end of a regular code of javascript
408 // function. Frame PC should be set to the entry point
409 // of the patch. When control finally returns to the frame, restarter resets
410 // registers and jumps to the function entry. Stack analizer sees
411 // the frame as if paused at the very beginning of the function (from source
412 // point of view). Local scope is not available in this state and shouldn't be
413 // accessed.
414 // The patch code starts with NOP instruction. The next byte is a patch
415 // starting point (its offset is typically 1 and is defined
416 // in Debug::kFrameDropperEntryOffset. The NOP instruction is for being
417 // annotated with position-bearing rinfo (in the actual function), because
418 // source position resolver expects position-bearing rinfo exactly before
419 // pc pointer (see Code::SourcePosition).
420 // It also resets the global variable restarter_frame_fp.
421 //
422 static void GenerateRestarterPatchLiveEdit(MacroAssembler* masm);
423
399 424
400 // Called from stub-cache.cc. 425 // Called from stub-cache.cc.
401 static void GenerateCallICDebugBreak(MacroAssembler* masm); 426 static void GenerateCallICDebugBreak(MacroAssembler* masm);
402 427
403 // Describes how exactly a frame has been dropped from stack. 428 // Describes how exactly a frame has been dropped from stack.
404 enum FrameDropMode { 429 enum FrameDropMode {
405 // No frame has been dropped. 430 // No frame has been dropped.
406 FRAMES_UNTOUCHED, 431 FRAMES_UNTOUCHED,
407 // The top JS frame had been calling IC stub. IC stub mustn't be called now. 432 // The top JS frame had been calling IC stub. IC stub mustn't be called now.
408 FRAME_DROPPED_IN_IC_CALL, 433 FRAME_DROPPED_IN_IC_CALL,
409 // The top JS frame had been calling debug break slot stub. Patch the 434 // The top JS frame had been calling debug break slot stub. Patch the
410 // address this stub jumps to in the end. 435 // address this stub jumps to in the end.
411 FRAME_DROPPED_IN_DEBUG_SLOT_CALL, 436 FRAME_DROPPED_IN_DEBUG_SLOT_CALL,
412 // The top JS frame had been calling some C++ function. The return address 437 // The top JS frame had been calling some C++ function. The return address
413 // gets patched automatically. 438 // gets patched automatically.
414 FRAME_DROPPED_IN_DIRECT_CALL 439 FRAME_DROPPED_IN_DIRECT_CALL
415 }; 440 };
416 441
417 static void FramesHaveBeenDropped(StackFrame::Id new_break_frame_id, 442 static void FramesHaveBeenDropped(JavaScriptFrame* new_top_js_frame,
418 FrameDropMode mode); 443 FrameDropMode mode);
419 444
420 static void SetUpFrameDropperFrame(StackFrame* bottom_js_frame, 445 // Returns fp of the restarted frame that is currently on the active stack
421 Handle<Code> code); 446 // or NULL.
422 static const int kFrameDropperFrameSize; 447 static Address GetRestartedFrameFp();
448
449 // The actual entry point offset in the frame restarter patch.
450 static const int kFrameRestarterEntryOffset;
451
452 // The height (in words) of the restarted JavaScript frame.
453 // A negative value indicates that stack manipulation is not supported.
454 static const int kRestartedFrameHeight;
423 455
424 private: 456 private:
425 static bool CompileDebuggerScript(int index); 457 static bool CompileDebuggerScript(int index);
426 static void ClearOneShot(); 458 static void ClearOneShot();
427 static void ActivateStepIn(StackFrame* frame); 459 static void ActivateStepIn(StackFrame* frame);
428 static void ClearStepIn(); 460 static void ClearStepIn();
429 static void ActivateStepOut(StackFrame* frame); 461 static void ActivateStepOut(StackFrame* frame);
430 static void ClearStepOut(); 462 static void ClearStepOut();
431 static void ClearStepNext(); 463 static void ClearStepNext();
432 // Returns whether the compile succeeded. 464 // Returns whether the compile succeeded.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // Frame pointer for frame from which step in was performed. 511 // Frame pointer for frame from which step in was performed.
480 Address step_into_fp_; 512 Address step_into_fp_;
481 513
482 // Frame pointer for the frame where debugger should be called when current 514 // Frame pointer for the frame where debugger should be called when current
483 // step out action is completed. 515 // step out action is completed.
484 Address step_out_fp_; 516 Address step_out_fp_;
485 517
486 // Storage location for jump when exiting debug break calls. 518 // Storage location for jump when exiting debug break calls.
487 Address after_break_target_; 519 Address after_break_target_;
488 520
521 // Stores fp of the restarted frame that is currently on the active stack
522 // or NULL. This variable is reset when that frame gets running.
523 Address restarted_frame_fp_;
524
489 // Stores the way how LiveEdit has patched the stack. It is used when 525 // Stores the way how LiveEdit has patched the stack. It is used when
490 // debugger returns control back to user script. 526 // debugger returns control back to user script.
491 FrameDropMode frame_drop_mode_; 527 FrameDropMode frame_drop_mode_;
492 528
493 // Top debugger entry. 529 // Top debugger entry.
494 EnterDebugger* debugger_entry_; 530 EnterDebugger* debugger_entry_;
495 531
496 // Pending interrupts scheduled while debugging. 532 // Pending interrupts scheduled while debugging.
497 int pending_interrupts_; 533 int pending_interrupts_;
498 }; 534 };
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 public: 946 public:
911 Debug_Address(Debug::AddressId id, int reg = 0) 947 Debug_Address(Debug::AddressId id, int reg = 0)
912 : id_(id), reg_(reg) { 948 : id_(id), reg_(reg) {
913 ASSERT(reg == 0 || id == Debug::k_register_address); 949 ASSERT(reg == 0 || id == Debug::k_register_address);
914 } 950 }
915 951
916 static Debug_Address AfterBreakTarget() { 952 static Debug_Address AfterBreakTarget() {
917 return Debug_Address(Debug::k_after_break_target_address); 953 return Debug_Address(Debug::k_after_break_target_address);
918 } 954 }
919 955
956 static Debug_Address RestartedFrameFp() {
957 return Debug_Address(Debug::k_restarted_frame_fp_address);
958 }
959
920 static Debug_Address DebugBreakReturn() { 960 static Debug_Address DebugBreakReturn() {
921 return Debug_Address(Debug::k_debug_break_return_address); 961 return Debug_Address(Debug::k_debug_break_return_address);
922 } 962 }
923 963
924 static Debug_Address Register(int reg) { 964 static Debug_Address Register(int reg) {
925 return Debug_Address(Debug::k_register_address, reg); 965 return Debug_Address(Debug::k_register_address, reg);
926 } 966 }
927 967
928 Address address() const { 968 Address address() const {
929 switch (id_) { 969 switch (id_) {
930 case Debug::k_after_break_target_address: 970 case Debug::k_after_break_target_address:
931 return reinterpret_cast<Address>(Debug::after_break_target_address()); 971 return reinterpret_cast<Address>(Debug::after_break_target_address());
972 case Debug::k_restarted_frame_fp_address:
973 return reinterpret_cast<Address>(Debug::restarted_frame_fp_address());
932 case Debug::k_debug_break_return_address: 974 case Debug::k_debug_break_return_address:
933 return reinterpret_cast<Address>(Debug::debug_break_return_address()); 975 return reinterpret_cast<Address>(Debug::debug_break_return_address());
934 case Debug::k_debug_break_slot_address: 976 case Debug::k_debug_break_slot_address:
935 return reinterpret_cast<Address>(Debug::debug_break_slot_address()); 977 return reinterpret_cast<Address>(Debug::debug_break_slot_address());
936 case Debug::k_register_address: 978 case Debug::k_register_address:
937 return reinterpret_cast<Address>(Debug::register_address(reg_)); 979 return reinterpret_cast<Address>(Debug::register_address(reg_));
938 default: 980 default:
939 UNREACHABLE(); 981 UNREACHABLE();
940 return NULL; 982 return NULL;
941 } 983 }
(...skipping 23 matching lines...) Expand all
965 1007
966 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); 1008 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread);
967 }; 1009 };
968 1010
969 1011
970 } } // namespace v8::internal 1012 } } // namespace v8::internal
971 1013
972 #endif // ENABLE_DEBUGGER_SUPPORT 1014 #endif // ENABLE_DEBUGGER_SUPPORT
973 1015
974 #endif // V8_DEBUG_H_ 1016 #endif // V8_DEBUG_H_
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698