| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "frames-inl.h" | 30 #include "frames-inl.h" |
| 31 #include "mark-compact.h" | 31 #include "mark-compact.h" |
| 32 #include "scopeinfo.h" | 32 #include "scopeinfo.h" |
| 33 #include "string-stream.h" | 33 #include "string-stream.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 PcToCodeCache::PcToCodeCacheEntry | |
| 39 PcToCodeCache::cache_[PcToCodeCache::kPcToCodeCacheSize]; | |
| 40 | 38 |
| 41 int SafeStackFrameIterator::active_count_ = 0; | 39 int SafeStackFrameIterator::active_count_ = 0; |
| 42 | 40 |
| 43 // Iterator that supports traversing the stack handlers of a | 41 // Iterator that supports traversing the stack handlers of a |
| 44 // particular frame. Needs to know the top of the handler chain. | 42 // particular frame. Needs to know the top of the handler chain. |
| 45 class StackHandlerIterator BASE_EMBEDDED { | 43 class StackHandlerIterator BASE_EMBEDDED { |
| 46 public: | 44 public: |
| 47 StackHandlerIterator(const StackFrame* frame, StackHandler* handler) | 45 StackHandlerIterator(const StackFrame* frame, StackHandler* handler) |
| 48 : limit_(frame->fp()), handler_(handler) { | 46 : limit_(frame->fp()), handler_(handler) { |
| 49 // Make sure the handler has already been unwound to this frame. | 47 // Make sure the handler has already been unwound to this frame. |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 417 |
| 420 | 418 |
| 421 void ExitFrame::SetCallerFp(Address caller_fp) { | 419 void ExitFrame::SetCallerFp(Address caller_fp) { |
| 422 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp; | 420 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp; |
| 423 } | 421 } |
| 424 | 422 |
| 425 | 423 |
| 426 void ExitFrame::Iterate(ObjectVisitor* v) const { | 424 void ExitFrame::Iterate(ObjectVisitor* v) const { |
| 427 // The arguments are traversed as part of the expression stack of | 425 // The arguments are traversed as part of the expression stack of |
| 428 // the calling frame. | 426 // the calling frame. |
| 429 IteratePc(v, pc_address(), code()); | 427 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); |
| 430 v->VisitPointer(&code_slot()); | 428 v->VisitPointer(&code_slot()); |
| 431 } | 429 } |
| 432 | 430 |
| 433 | 431 |
| 434 Address ExitFrame::GetCallerStackPointer() const { | 432 Address ExitFrame::GetCallerStackPointer() const { |
| 435 return fp() + ExitFrameConstants::kCallerSPDisplacement; | 433 return fp() + ExitFrameConstants::kCallerSPDisplacement; |
| 436 } | 434 } |
| 437 | 435 |
| 438 | 436 |
| 439 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { | 437 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 | 751 |
| 754 accumulator->Add("}\n\n"); | 752 accumulator->Add("}\n\n"); |
| 755 } | 753 } |
| 756 | 754 |
| 757 | 755 |
| 758 void EntryFrame::Iterate(ObjectVisitor* v) const { | 756 void EntryFrame::Iterate(ObjectVisitor* v) const { |
| 759 StackHandlerIterator it(this, top_handler()); | 757 StackHandlerIterator it(this, top_handler()); |
| 760 ASSERT(!it.done()); | 758 ASSERT(!it.done()); |
| 761 StackHandler* handler = it.handler(); | 759 StackHandler* handler = it.handler(); |
| 762 ASSERT(handler->is_entry()); | 760 ASSERT(handler->is_entry()); |
| 763 handler->Iterate(v, code()); | 761 handler->Iterate(v, LookupCode(Isolate::Current())); |
| 764 #ifdef DEBUG | 762 #ifdef DEBUG |
| 765 // Make sure that the entry frame does not contain more than one | 763 // Make sure that the entry frame does not contain more than one |
| 766 // stack handler. | 764 // stack handler. |
| 767 it.Advance(); | 765 it.Advance(); |
| 768 ASSERT(it.done()); | 766 ASSERT(it.done()); |
| 769 #endif | 767 #endif |
| 770 IteratePc(v, pc_address(), code()); | 768 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); |
| 771 } | 769 } |
| 772 | 770 |
| 773 | 771 |
| 774 void StandardFrame::IterateExpressions(ObjectVisitor* v) const { | 772 void StandardFrame::IterateExpressions(ObjectVisitor* v) const { |
| 775 const int offset = StandardFrameConstants::kContextOffset; | 773 const int offset = StandardFrameConstants::kContextOffset; |
| 776 Object** base = &Memory::Object_at(sp()); | 774 Object** base = &Memory::Object_at(sp()); |
| 777 Object** limit = &Memory::Object_at(fp() + offset) + 1; | 775 Object** limit = &Memory::Object_at(fp() + offset) + 1; |
| 778 for (StackHandlerIterator it(this, top_handler()); !it.done(); it.Advance()) { | 776 for (StackHandlerIterator it(this, top_handler()); !it.done(); it.Advance()) { |
| 779 StackHandler* handler = it.handler(); | 777 StackHandler* handler = it.handler(); |
| 780 // Traverse pointers down to - but not including - the next | 778 // Traverse pointers down to - but not including - the next |
| 781 // handler in the handler chain. Update the base to skip the | 779 // handler in the handler chain. Update the base to skip the |
| 782 // handler and allow the handler to traverse its own pointers. | 780 // handler and allow the handler to traverse its own pointers. |
| 783 const Address address = handler->address(); | 781 const Address address = handler->address(); |
| 784 v->VisitPointers(base, reinterpret_cast<Object**>(address)); | 782 v->VisitPointers(base, reinterpret_cast<Object**>(address)); |
| 785 base = reinterpret_cast<Object**>(address + StackHandlerConstants::kSize); | 783 base = reinterpret_cast<Object**>(address + StackHandlerConstants::kSize); |
| 786 // Traverse the pointers in the handler itself. | 784 // Traverse the pointers in the handler itself. |
| 787 handler->Iterate(v, code()); | 785 handler->Iterate(v, LookupCode(Isolate::Current())); |
| 788 } | 786 } |
| 789 v->VisitPointers(base, limit); | 787 v->VisitPointers(base, limit); |
| 790 } | 788 } |
| 791 | 789 |
| 792 | 790 |
| 793 void JavaScriptFrame::Iterate(ObjectVisitor* v) const { | 791 void JavaScriptFrame::Iterate(ObjectVisitor* v) const { |
| 794 IterateExpressions(v); | 792 IterateExpressions(v); |
| 795 IteratePc(v, pc_address(), code()); | 793 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); |
| 796 | 794 |
| 797 // Traverse callee-saved registers, receiver, and parameters. | 795 // Traverse callee-saved registers, receiver, and parameters. |
| 798 const int kBaseOffset = JavaScriptFrameConstants::kSavedRegistersOffset; | 796 const int kBaseOffset = JavaScriptFrameConstants::kSavedRegistersOffset; |
| 799 const int kLimitOffset = JavaScriptFrameConstants::kReceiverOffset; | 797 const int kLimitOffset = JavaScriptFrameConstants::kReceiverOffset; |
| 800 Object** base = &Memory::Object_at(fp() + kBaseOffset); | 798 Object** base = &Memory::Object_at(fp() + kBaseOffset); |
| 801 Object** limit = &Memory::Object_at(caller_sp() + kLimitOffset) + 1; | 799 Object** limit = &Memory::Object_at(caller_sp() + kLimitOffset) + 1; |
| 802 v->VisitPointers(base, limit); | 800 v->VisitPointers(base, limit); |
| 803 } | 801 } |
| 804 | 802 |
| 805 | 803 |
| 806 void InternalFrame::Iterate(ObjectVisitor* v) const { | 804 void InternalFrame::Iterate(ObjectVisitor* v) const { |
| 807 // Internal frames only have object pointers on the expression stack | 805 // Internal frames only have object pointers on the expression stack |
| 808 // as they never have any arguments. | 806 // as they never have any arguments. |
| 809 IterateExpressions(v); | 807 IterateExpressions(v); |
| 810 IteratePc(v, pc_address(), code()); | 808 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); |
| 811 } | 809 } |
| 812 | 810 |
| 813 | 811 |
| 814 // ------------------------------------------------------------------------- | 812 // ------------------------------------------------------------------------- |
| 815 | 813 |
| 816 | 814 |
| 817 JavaScriptFrame* StackFrameLocator::FindJavaScriptFrame(int n) { | 815 JavaScriptFrame* StackFrameLocator::FindJavaScriptFrame(int n) { |
| 818 ASSERT(n >= 0); | 816 ASSERT(n >= 0); |
| 819 for (int i = 0; i <= n; i++) { | 817 for (int i = 0; i <= n; i++) { |
| 820 while (!iterator_.frame()->is_java_script()) iterator_.Advance(); | 818 while (!iterator_.frame()->is_java_script()) iterator_.Advance(); |
| 821 if (i == n) return JavaScriptFrame::cast(iterator_.frame()); | 819 if (i == n) return JavaScriptFrame::cast(iterator_.frame()); |
| 822 iterator_.Advance(); | 820 iterator_.Advance(); |
| 823 } | 821 } |
| 824 UNREACHABLE(); | 822 UNREACHABLE(); |
| 825 return NULL; | 823 return NULL; |
| 826 } | 824 } |
| 827 | 825 |
| 828 | 826 |
| 829 // ------------------------------------------------------------------------- | 827 // ------------------------------------------------------------------------- |
| 830 | 828 |
| 831 | 829 |
| 832 Code* PcToCodeCache::GcSafeCastToCode(HeapObject* object, Address pc) { | 830 Code* PcToCodeCache::GcSafeCastToCode(HeapObject* object, Address pc) { |
| 833 Code* code = reinterpret_cast<Code*>(object); | 831 Code* code = reinterpret_cast<Code*>(object); |
| 834 ASSERT(code != NULL && code->contains(pc)); | 832 ASSERT(code != NULL && code->contains(pc)); |
| 835 return code; | 833 return code; |
| 836 } | 834 } |
| 837 | 835 |
| 838 | 836 |
| 839 Code* PcToCodeCache::GcSafeFindCodeForPc(Address pc) { | 837 Code* PcToCodeCache::GcSafeFindCodeForPc(Address pc) { |
| 840 Heap* heap = HEAP; | 838 Heap* heap = isolate_->heap(); |
| 841 // Check if the pc points into a large object chunk. | 839 // Check if the pc points into a large object chunk. |
| 842 LargeObjectChunk* chunk = heap->lo_space()->FindChunkContainingPc(pc); | 840 LargeObjectChunk* chunk = heap->lo_space()->FindChunkContainingPc(pc); |
| 843 if (chunk != NULL) return GcSafeCastToCode(chunk->GetObject(), pc); | 841 if (chunk != NULL) return GcSafeCastToCode(chunk->GetObject(), pc); |
| 844 | 842 |
| 845 // Iterate through the 8K page until we reach the end or find an | 843 // Iterate through the 8K page until we reach the end or find an |
| 846 // object starting after the pc. | 844 // object starting after the pc. |
| 847 Page* page = Page::FromAddress(pc); | 845 Page* page = Page::FromAddress(pc); |
| 848 HeapObjectIterator iterator(page, heap->GcSafeSizeOfOldObjectFunction()); | 846 HeapObjectIterator iterator(page, heap->GcSafeSizeOfOldObjectFunction()); |
| 849 HeapObject* previous = NULL; | 847 HeapObject* previous = NULL; |
| 850 while (true) { | 848 while (true) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 ZoneList<StackFrame*> list(10); | 940 ZoneList<StackFrame*> list(10); |
| 943 for (StackFrameIterator it; !it.done(); it.Advance()) { | 941 for (StackFrameIterator it; !it.done(); it.Advance()) { |
| 944 StackFrame* frame = AllocateFrameCopy(it.frame()); | 942 StackFrame* frame = AllocateFrameCopy(it.frame()); |
| 945 list.Add(frame); | 943 list.Add(frame); |
| 946 } | 944 } |
| 947 return list.ToVector(); | 945 return list.ToVector(); |
| 948 } | 946 } |
| 949 | 947 |
| 950 | 948 |
| 951 } } // namespace v8::internal | 949 } } // namespace v8::internal |
| OLD | NEW |