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

Side by Side Diff: src/serialize.cc

Issue 8380035: Get the speed back in new context creation after it was tanked (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 752
753 753
754 static const int kUnknownOffsetFromStart = -1; 754 static const int kUnknownOffsetFromStart = -1;
755 755
756 756
757 void Deserializer::ReadChunk(Object** current, 757 void Deserializer::ReadChunk(Object** current,
758 Object** limit, 758 Object** limit,
759 int source_space, 759 int source_space,
760 Address current_object_address) { 760 Address current_object_address) {
761 Isolate* const isolate = isolate_; 761 Isolate* const isolate = isolate_;
762 bool write_barrier_needed = (current_object_address != NULL &&
763 source_space != NEW_SPACE &&
764 source_space != CELL_SPACE &&
765 source_space == OLD_DATA_SPACE);
762 while (current < limit) { 766 while (current < limit) {
763 int data = source_->Get(); 767 int data = source_->Get();
764 switch (data) { 768 switch (data) {
765 #define CASE_STATEMENT(where, how, within, space_number) \ 769 #define CASE_STATEMENT(where, how, within, space_number) \
766 case where + how + within + space_number: \ 770 case where + how + within + space_number: \
767 ASSERT((where & ~kPointedToMask) == 0); \ 771 ASSERT((where & ~kPointedToMask) == 0); \
768 ASSERT((how & ~kHowToCodeMask) == 0); \ 772 ASSERT((how & ~kHowToCodeMask) == 0); \
769 ASSERT((within & ~kWhereToPointMask) == 0); \ 773 ASSERT((within & ~kWhereToPointMask) == 0); \
770 ASSERT((space_number & ~kSpaceMask) == 0); 774 ASSERT((space_number & ~kSpaceMask) == 0);
771 775
772 #define CASE_BODY(where, how, within, space_number_if_any, offset_from_start) \ 776 #define CASE_BODY(where, how, within, space_number_if_any, offset_from_start) \
773 { \ 777 { \
774 bool emit_write_barrier = false; \ 778 bool emit_write_barrier = false; \
775 bool current_was_incremented = false; \ 779 bool current_was_incremented = false; \
776 int space_number = space_number_if_any == kAnyOldSpace ? \ 780 int space_number = space_number_if_any == kAnyOldSpace ? \
777 (data & kSpaceMask) : space_number_if_any; \ 781 (data & kSpaceMask) : space_number_if_any; \
778 if (where == kNewObject && how == kPlain && within == kStartOfObject) {\ 782 if (where == kNewObject && how == kPlain && within == kStartOfObject) {\
779 ASSIGN_DEST_SPACE(space_number) \ 783 ASSIGN_DEST_SPACE(space_number) \
780 ReadObject(space_number, dest_space, current); \ 784 ReadObject(space_number, dest_space, current); \
781 emit_write_barrier = (space_number == NEW_SPACE && \ 785 emit_write_barrier = (space_number == NEW_SPACE); \
782 source_space != NEW_SPACE && \
783 source_space != CELL_SPACE); \
784 } else { \ 786 } else { \
785 Object* new_object = NULL; /* May not be a real Object pointer. */ \ 787 Object* new_object = NULL; /* May not be a real Object pointer. */ \
786 if (where == kNewObject) { \ 788 if (where == kNewObject) { \
787 ASSIGN_DEST_SPACE(space_number) \ 789 ASSIGN_DEST_SPACE(space_number) \
788 ReadObject(space_number, dest_space, &new_object); \ 790 ReadObject(space_number, dest_space, &new_object); \
789 } else if (where == kRootArray) { \ 791 } else if (where == kRootArray) { \
790 if (source_space != CELL_SPACE && \ 792 emit_write_barrier = true; \
791 source_space != CODE_SPACE && \
792 source_space != OLD_DATA_SPACE) { \
793 emit_write_barrier = true; \
794 } \
795 int root_id = source_->GetInt(); \ 793 int root_id = source_->GetInt(); \
796 new_object = isolate->heap()->roots_array_start()[root_id]; \ 794 new_object = isolate->heap()->roots_array_start()[root_id]; \
797 } else if (where == kPartialSnapshotCache) { \ 795 } else if (where == kPartialSnapshotCache) { \
798 if (source_space != CELL_SPACE && \ 796 emit_write_barrier = true; \
799 source_space != CODE_SPACE && \
800 source_space != OLD_DATA_SPACE) { \
801 emit_write_barrier = true; \
802 } \
803 int cache_index = source_->GetInt(); \ 797 int cache_index = source_->GetInt(); \
804 new_object = isolate->serialize_partial_snapshot_cache() \ 798 new_object = isolate->serialize_partial_snapshot_cache() \
805 [cache_index]; \ 799 [cache_index]; \
806 } else if (where == kExternalReference) { \ 800 } else if (where == kExternalReference) { \
807 int reference_id = source_->GetInt(); \ 801 int reference_id = source_->GetInt(); \
808 Address address = external_reference_decoder_-> \ 802 Address address = external_reference_decoder_-> \
809 Decode(reference_id); \ 803 Decode(reference_id); \
810 new_object = reinterpret_cast<Object*>(address); \ 804 new_object = reinterpret_cast<Object*>(address); \
811 } else if (where == kBackref) { \ 805 } else if (where == kBackref) { \
812 emit_write_barrier = (space_number == NEW_SPACE && \ 806 emit_write_barrier = (space_number == NEW_SPACE); \
813 source_space != NEW_SPACE && \
814 source_space != CELL_SPACE); \
815 new_object = GetAddressFromEnd(data & kSpaceMask); \ 807 new_object = GetAddressFromEnd(data & kSpaceMask); \
816 } else { \ 808 } else { \
817 ASSERT(where == kFromStart); \ 809 ASSERT(where == kFromStart); \
818 if (offset_from_start == kUnknownOffsetFromStart) { \ 810 if (offset_from_start == kUnknownOffsetFromStart) { \
819 emit_write_barrier = (space_number == NEW_SPACE && \ 811 emit_write_barrier = (space_number == NEW_SPACE); \
820 source_space != NEW_SPACE && \
821 source_space != CELL_SPACE); \
822 new_object = GetAddressFromStart(data & kSpaceMask); \ 812 new_object = GetAddressFromStart(data & kSpaceMask); \
823 } else { \ 813 } else { \
824 Address object_address = pages_[space_number][0] + \ 814 Address object_address = pages_[space_number][0] + \
825 (offset_from_start << kObjectAlignmentBits); \ 815 (offset_from_start << kObjectAlignmentBits); \
826 new_object = HeapObject::FromAddress(object_address); \ 816 new_object = HeapObject::FromAddress(object_address); \
827 } \ 817 } \
828 } \ 818 } \
829 if (within == kFirstInstruction) { \ 819 if (within == kFirstInstruction) { \
830 Code* new_code_object = reinterpret_cast<Code*>(new_object); \ 820 Code* new_code_object = reinterpret_cast<Code*>(new_object); \
831 new_object = reinterpret_cast<Object*>( \ 821 new_object = reinterpret_cast<Object*>( \
832 new_code_object->instruction_start()); \ 822 new_code_object->instruction_start()); \
833 } \ 823 } \
834 if (how == kFromCode) { \ 824 if (how == kFromCode) { \
835 Address location_of_branch_data = \ 825 Address location_of_branch_data = \
836 reinterpret_cast<Address>(current); \ 826 reinterpret_cast<Address>(current); \
837 Assembler::set_target_at(location_of_branch_data, \ 827 Assembler::set_target_at(location_of_branch_data, \
838 reinterpret_cast<Address>(new_object)); \ 828 reinterpret_cast<Address>(new_object)); \
839 if (within == kFirstInstruction) { \ 829 if (within == kFirstInstruction) { \
840 location_of_branch_data += Assembler::kCallTargetSize; \ 830 location_of_branch_data += Assembler::kCallTargetSize; \
841 current = reinterpret_cast<Object**>(location_of_branch_data); \ 831 current = reinterpret_cast<Object**>(location_of_branch_data); \
842 current_was_incremented = true; \ 832 current_was_incremented = true; \
843 } \ 833 } \
844 } else { \ 834 } else { \
845 *current = new_object; \ 835 *current = new_object; \
846 } \ 836 } \
847 } \ 837 } \
848 if (emit_write_barrier && current_object_address != NULL) { \ 838 if (emit_write_barrier && write_barrier_needed) { \
849 Address current_address = reinterpret_cast<Address>(current); \ 839 Address current_address = reinterpret_cast<Address>(current); \
850 isolate->heap()->RecordWrite( \ 840 isolate->heap()->RecordWrite( \
851 current_object_address, \ 841 current_object_address, \
852 static_cast<int>(current_address - current_object_address)); \ 842 static_cast<int>(current_address - current_object_address)); \
853 } \ 843 } \
854 if (!current_was_incremented) { \ 844 if (!current_was_incremented) { \
855 current++; /* Increment current if it wasn't done above. */ \ 845 current++; \
856 } \ 846 } \
857 break; \ 847 break; \
858 } \ 848 } \
859 849
860 // This generates a case and a body for each space. The large object spaces are 850 // This generates a case and a body for each space. The large object spaces are
861 // very rare in snapshots so they are grouped in one body. 851 // very rare in snapshots so they are grouped in one body.
862 #define ONE_PER_SPACE(where, how, within) \ 852 #define ONE_PER_SPACE(where, how, within) \
863 CASE_STATEMENT(where, how, within, NEW_SPACE) \ 853 CASE_STATEMENT(where, how, within, NEW_SPACE) \
864 CASE_BODY(where, how, within, NEW_SPACE, kUnknownOffsetFromStart) \ 854 CASE_BODY(where, how, within, NEW_SPACE, kUnknownOffsetFromStart) \
865 CASE_STATEMENT(where, how, within, OLD_DATA_SPACE) \ 855 CASE_STATEMENT(where, how, within, OLD_DATA_SPACE) \
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 1641 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
1652 } 1642 }
1653 } 1643 }
1654 int allocation_address = fullness_[space]; 1644 int allocation_address = fullness_[space];
1655 fullness_[space] = allocation_address + size; 1645 fullness_[space] = allocation_address + size;
1656 return allocation_address; 1646 return allocation_address;
1657 } 1647 }
1658 1648
1659 1649
1660 } } // namespace v8::internal 1650 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698