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

Side by Side Diff: src/frames.h

Issue 39009: Dump more stack frames to perf log when executing a C++ function. (Closed)
Patch Set: Changes according to Soren's comments Created 11 years, 9 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 | « no previous file | src/frames.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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 502
503 503
504 class StackFrameIterator BASE_EMBEDDED { 504 class StackFrameIterator BASE_EMBEDDED {
505 public: 505 public:
506 // An iterator that iterates over the current thread's stack. 506 // An iterator that iterates over the current thread's stack.
507 StackFrameIterator(); 507 StackFrameIterator();
508 508
509 // An iterator that iterates over a given thread's stack. 509 // An iterator that iterates over a given thread's stack.
510 explicit StackFrameIterator(ThreadLocalTop* thread); 510 explicit StackFrameIterator(ThreadLocalTop* thread);
511 511
512 // An iterator that conditionally resets itself on init.
513 explicit StackFrameIterator(bool reset);
514
512 StackFrame* frame() const { 515 StackFrame* frame() const {
513 ASSERT(!done()); 516 ASSERT(!done());
514 return frame_; 517 return frame_;
515 } 518 }
516 519
517 bool done() const { return frame_ == NULL; } 520 bool done() const { return frame_ == NULL; }
518 void Advance(); 521 void Advance();
519 522
520 // Go back to the first frame. 523 // Go back to the first frame.
521 void Reset(); 524 void Reset();
(...skipping 13 matching lines...) Expand all
535 538
536 // Get the type-specific frame singleton in a given state. 539 // Get the type-specific frame singleton in a given state.
537 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); 540 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state);
538 541
539 friend class StackFrame; 542 friend class StackFrame;
540 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator); 543 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
541 }; 544 };
542 545
543 546
544 // Iterator that supports iterating through all JavaScript frames. 547 // Iterator that supports iterating through all JavaScript frames.
545 class JavaScriptFrameIterator BASE_EMBEDDED { 548 template<typename Iterator>
549 class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
546 public: 550 public:
547 JavaScriptFrameIterator() { if (!done()) Advance(); } 551 JavaScriptFrameIteratorTemp() { if (!done()) Advance(); }
548 552
549 explicit JavaScriptFrameIterator(ThreadLocalTop* thread) : iterator_(thread) { 553 explicit JavaScriptFrameIteratorTemp(ThreadLocalTop* thread) :
554 iterator_(thread) {
550 if (!done()) Advance(); 555 if (!done()) Advance();
551 } 556 }
552 557
553 // Skip frames until the frame with the given id is reached. 558 // Skip frames until the frame with the given id is reached.
554 explicit JavaScriptFrameIterator(StackFrame::Id id); 559 explicit JavaScriptFrameIteratorTemp(StackFrame::Id id);
560
561 explicit JavaScriptFrameIteratorTemp(Address low_bound, Address high_bound) :
562 iterator_(low_bound, high_bound) { if (!done()) Advance(); }
555 563
556 inline JavaScriptFrame* frame() const; 564 inline JavaScriptFrame* frame() const;
557 565
558 bool done() const { return iterator_.done(); } 566 bool done() const { return iterator_.done(); }
559 void Advance(); 567 void Advance();
560 568
561 // Advance to the frame holding the arguments for the current 569 // Advance to the frame holding the arguments for the current
562 // frame. This only affects the current frame if it has adapted 570 // frame. This only affects the current frame if it has adapted
563 // arguments. 571 // arguments.
564 void AdvanceToArgumentsFrame(); 572 void AdvanceToArgumentsFrame();
565 573
566 // Go back to the first frame. 574 // Go back to the first frame.
567 void Reset(); 575 void Reset();
568 576
569 private: 577 private:
578 Iterator iterator_;
579 };
580
581
582 typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator;
583
584
585 // NOTE: The stack trace frame iterator is an iterator that only
586 // traverse proper JavaScript frames; that is JavaScript frames that
587 // have proper JavaScript functions. This excludes the problematic
588 // functions in runtime.js.
589 class StackTraceFrameIterator: public JavaScriptFrameIterator {
590 public:
591 StackTraceFrameIterator();
592 void Advance();
593 };
594
595
596 class SafeStackFrameIterator BASE_EMBEDDED {
597 public:
598 explicit SafeStackFrameIterator(Address low_bound, Address high_bound);
599
600 StackFrame* frame() const {
601 ASSERT(is_working_iterator_);
602 return iterator_.frame();
603 }
604
605 bool done() const { return iteration_done_ ? true : iterator_.done(); }
606
607 void Advance();
608 void Reset();
609
610 private:
611 static bool IsInBounds(
612 Address low_bound, Address high_bound, Address addr) {
613 return low_bound <= addr && addr <= high_bound;
614 }
615 bool IsGoodStackAddress(Address addr) const {
616 return IsInBounds(low_bound_, high_bound_, addr);
617 }
618
619 Address low_bound_;
620 Address high_bound_;
621 const bool is_working_iterator_;
622 bool iteration_done_;
570 StackFrameIterator iterator_; 623 StackFrameIterator iterator_;
571 }; 624 };
572 625
573 626
627 #ifdef ENABLE_LOGGING_AND_PROFILING
628 typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator>
629 SafeJavaScriptFrameIterator;
630
631
632 class SafeStackTraceFrameIterator: public SafeJavaScriptFrameIterator {
633 public:
634 explicit SafeStackTraceFrameIterator(Address low_bound, Address high_bound);
635 void Advance();
636 };
637 #endif
638
639
574 class StackFrameLocator BASE_EMBEDDED { 640 class StackFrameLocator BASE_EMBEDDED {
575 public: 641 public:
576 // Find the nth JavaScript frame on the stack. The caller must 642 // Find the nth JavaScript frame on the stack. The caller must
577 // guarantee that such a frame exists. 643 // guarantee that such a frame exists.
578 JavaScriptFrame* FindJavaScriptFrame(int n); 644 JavaScriptFrame* FindJavaScriptFrame(int n);
579 645
580 private: 646 private:
581 StackFrameIterator iterator_; 647 StackFrameIterator iterator_;
582 }; 648 };
583 649
584 650
585 } } // namespace v8::internal 651 } } // namespace v8::internal
586 652
587 #endif // V8_FRAMES_H_ 653 #endif // V8_FRAMES_H_
OLDNEW
« no previous file with comments | « no previous file | src/frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698